* Amazing: François writes almost style compliant code! :-)
* Minor cleanup - I haven't written SystemInfoHandler, François did. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25017 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -354,7 +354,8 @@ void
|
||||
ActivityView::AttachedToWindow()
|
||||
{
|
||||
Looper()->AddHandler(fSystemInfoHandler);
|
||||
fSystemInfoHandler->StartWatchingStuff();
|
||||
fSystemInfoHandler->StartWatching();
|
||||
|
||||
BMessage refresh(kMsgRefresh);
|
||||
fRunner = new BMessageRunner(this, &refresh, fRefreshInterval);
|
||||
|
||||
@@ -365,8 +366,9 @@ ActivityView::AttachedToWindow()
|
||||
void
|
||||
ActivityView::DetachedFromWindow()
|
||||
{
|
||||
fSystemInfoHandler->StopWatchingStuff();
|
||||
fSystemInfoHandler->StopWatching();
|
||||
Looper()->RemoveHandler(fSystemInfoHandler);
|
||||
|
||||
delete fRunner;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
#include <net/if.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
SystemInfo::SystemInfo(SystemInfoHandler* handler)
|
||||
@@ -25,7 +25,7 @@ SystemInfo::SystemInfo(SystemInfoHandler *handler)
|
||||
{
|
||||
get_system_info(&fSystemInfo);
|
||||
|
||||
if (handler) {
|
||||
if (handler != NULL) {
|
||||
fRunningApps = handler->RunningApps();
|
||||
fClipboardSize = handler->ClipboardSize();
|
||||
fClipboardTextSize = handler->ClipboardTextSize();
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
/*
|
||||
* Copyright 2008, Axel Dörfler, [email protected]. All rights reserved.
|
||||
* Copyright 2008, François Revol, [email protected]. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "SystemInfoHandler.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <Clipboard.h>
|
||||
#include <Handler.h>
|
||||
#include <List.h>
|
||||
#include <Messenger.h>
|
||||
#include <Roster.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
SystemInfoHandler::SystemInfoHandler()
|
||||
@@ -37,7 +38,7 @@ SystemInfoHandler::Archive(BMessage *data, bool deep) const
|
||||
|
||||
|
||||
void
|
||||
SystemInfoHandler::StartWatchingStuff()
|
||||
SystemInfoHandler::StartWatching()
|
||||
{
|
||||
fRunningApps = 0;
|
||||
fClipboardSize = 0;
|
||||
@@ -62,7 +63,7 @@ SystemInfoHandler::StartWatchingStuff()
|
||||
|
||||
|
||||
void
|
||||
SystemInfoHandler::StopWatchingStuff()
|
||||
SystemInfoHandler::StopWatching()
|
||||
{
|
||||
if (be_roster)
|
||||
be_roster->StopWatching(BMessenger(this));
|
||||
@@ -77,11 +78,11 @@ SystemInfoHandler::MessageReceived(BMessage *message)
|
||||
switch (message->what) {
|
||||
case B_SOME_APP_LAUNCHED:
|
||||
fRunningApps++;
|
||||
// XXX: maybe resync periodically in case we miss one
|
||||
// TODO: maybe resync periodically in case we miss one
|
||||
break;
|
||||
case B_SOME_APP_QUIT:
|
||||
fRunningApps--;
|
||||
// XXX: maybe resync periodically in case we miss one
|
||||
// TODO: maybe resync periodically in case we miss one
|
||||
break;
|
||||
case B_CLIPBOARD_CHANGED:
|
||||
_UpdateClipboardData();
|
||||
@@ -118,18 +119,21 @@ SystemInfoHandler::_UpdateClipboardData()
|
||||
{
|
||||
fClipboardSize = 0;
|
||||
fClipboardTextSize = 0;
|
||||
if (be_clipboard && be_clipboard->Lock()) {
|
||||
|
||||
if (be_clipboard == NULL || !be_clipboard->Lock())
|
||||
return;
|
||||
|
||||
BMessage* data = be_clipboard->Data();
|
||||
if (data) {
|
||||
ssize_t size = data->FlattenedSize();
|
||||
fClipboardSize = size < 0 ? 0 : (uint32)size;
|
||||
|
||||
const void* text;
|
||||
ssize_t textSize;
|
||||
fClipboardSize = (size < 0) ? 0 : (uint32)size;
|
||||
if (data->FindData("text/plain", B_MIME_TYPE, &text, &textSize)
|
||||
>= B_OK)
|
||||
if (data->FindData("text/plain", B_MIME_TYPE, &text, &textSize) >= B_OK)
|
||||
fClipboardTextSize = textSize;
|
||||
}
|
||||
|
||||
be_clipboard->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +1,23 @@
|
||||
/*
|
||||
* Copyright 2008, Axel Dörfler, [email protected]. All rights reserved.
|
||||
* Copyright 2008, François Revol, [email protected]. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef SYSTEM_INFO_HANDLER_H
|
||||
#define SYSTEM_INFO_HANDLER_H
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
#include <Handler.h>
|
||||
|
||||
|
||||
class SystemInfoHandler : public BHandler {
|
||||
public:
|
||||
SystemInfoHandler();
|
||||
//SystemInfoHandler(BMessage *data);
|
||||
virtual ~SystemInfoHandler();
|
||||
|
||||
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
||||
|
||||
void StartWatchingStuff();
|
||||
void StopWatchingStuff();
|
||||
void StartWatching();
|
||||
void StopWatching();
|
||||
|
||||
void MessageReceived(BMessage* message);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user