- fix BeOS build (it's getting nasty)
- add a media node count data source. Yes I do have work to do instead :P git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25022 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
43eda1cd8f
commit
dc1ffc79ef
@ -10,7 +10,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __HAIKU__
|
||||
#include <AbstractLayoutItem.h>
|
||||
#endif
|
||||
#include <Application.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Dragger.h>
|
||||
@ -30,6 +32,7 @@ struct data_item {
|
||||
int64 value;
|
||||
};
|
||||
|
||||
#ifdef __HAIKU__
|
||||
class ActivityView::HistoryLayoutItem : public BAbstractLayoutItem {
|
||||
public:
|
||||
HistoryLayoutItem(ActivityView* parent);
|
||||
@ -70,6 +73,7 @@ private:
|
||||
ActivityView* fParent;
|
||||
BRect fFrame;
|
||||
};
|
||||
#endif
|
||||
|
||||
const bigtime_t kInitialRefreshInterval = 500000LL;
|
||||
|
||||
@ -166,6 +170,7 @@ DataHistory::SetRefreshInterval(bigtime_t interval)
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
#ifdef __HAIKU__
|
||||
ActivityView::HistoryLayoutItem::HistoryLayoutItem(ActivityView* parent)
|
||||
:
|
||||
fParent(parent),
|
||||
@ -299,6 +304,7 @@ ActivityView::LegendLayoutItem::BaseAlignment()
|
||||
{
|
||||
return BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
@ -357,8 +363,10 @@ ActivityView::_Init(const BMessage* settings)
|
||||
{
|
||||
fBackgroundColor = (rgb_color){255, 255, 240};
|
||||
fOffscreen = NULL;
|
||||
#ifdef __HAIKU__
|
||||
fHistoryLayoutItem = NULL;
|
||||
fLegendLayoutItem = NULL;
|
||||
#endif
|
||||
SetViewColor(B_TRANSPARENT_COLOR);
|
||||
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
@ -438,6 +446,7 @@ ActivityView::SaveState(BMessage& state) const
|
||||
}
|
||||
|
||||
|
||||
#ifdef __HAIKU__
|
||||
BLayoutItem*
|
||||
ActivityView::CreateHistoryLayoutItem()
|
||||
{
|
||||
@ -456,7 +465,7 @@ ActivityView::CreateLegendLayoutItem()
|
||||
|
||||
return fLegendLayoutItem;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
DataSource*
|
||||
ActivityView::FindDataSource(const DataSource* search)
|
||||
@ -518,7 +527,9 @@ ActivityView::AddDataSource(const DataSource* source)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __HAIKU__
|
||||
InvalidateLayout();
|
||||
#endif
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@ -547,7 +558,9 @@ ActivityView::RemoveDataSource(const DataSource* remove)
|
||||
removed = true;
|
||||
}
|
||||
|
||||
#ifdef __HAIKU__
|
||||
InvalidateLayout();
|
||||
#endif
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@ -645,6 +658,8 @@ ActivityView::MouseDown(BPoint where)
|
||||
menu->SetFont(be_plain_font);
|
||||
|
||||
BMenu* additionalMenu = new BMenu("Additional Items");
|
||||
additionalMenu->SetFont(be_plain_font);
|
||||
|
||||
SystemInfo info;
|
||||
BMenuItem* item;
|
||||
|
||||
@ -673,6 +688,7 @@ ActivityView::MouseDown(BPoint where)
|
||||
new BMessage(kMsgToggleLegend)));
|
||||
|
||||
menu->SetTargetForItems(this);
|
||||
additionalMenu->SetTargetForItems(this);
|
||||
|
||||
ConvertToScreen(&where);
|
||||
menu->Go(where, true, false, true);
|
||||
@ -755,11 +771,18 @@ ActivityView::MessageReceived(BMessage* message)
|
||||
void
|
||||
ActivityView::_UpdateFrame()
|
||||
{
|
||||
#ifdef __HAIKU__
|
||||
if (fLegendLayoutItem == NULL || fHistoryLayoutItem == NULL)
|
||||
return;
|
||||
|
||||
BRect historyFrame = fHistoryLayoutItem->Frame();
|
||||
BRect legendFrame = fLegendLayoutItem->Frame();
|
||||
#else
|
||||
BRect historyFrame = Bounds();
|
||||
BRect legendFrame = Bounds();
|
||||
historyFrame.bottom -= 2 * Bounds().Height() / 3;
|
||||
legendFrame.top += Bounds().Height() / 3;
|
||||
#endif
|
||||
MoveTo(historyFrame.left, historyFrame.top);
|
||||
ResizeTo(legendFrame.left + legendFrame.Width() - historyFrame.left,
|
||||
legendFrame.top + legendFrame.Height() - historyFrame.top);
|
||||
@ -797,9 +820,11 @@ BRect
|
||||
ActivityView::_LegendFrame() const
|
||||
{
|
||||
float height;
|
||||
#ifdef __HAIKU__
|
||||
if (fLegendLayoutItem != NULL)
|
||||
height = fLegendLayoutItem->Frame().Height();
|
||||
else
|
||||
#endif
|
||||
height = _LegendHeight();
|
||||
|
||||
BRect frame = Bounds();
|
||||
|
@ -56,8 +56,10 @@ public:
|
||||
|
||||
status_t SaveState(BMessage& state) const;
|
||||
|
||||
#ifdef __HAIKU__
|
||||
BLayoutItem* CreateHistoryLayoutItem();
|
||||
BLayoutItem* CreateLegendLayoutItem();
|
||||
#endif
|
||||
|
||||
DataSource* FindDataSource(const DataSource* source);
|
||||
status_t AddDataSource(const DataSource* source);
|
||||
@ -102,8 +104,10 @@ private:
|
||||
|
||||
rgb_color fBackgroundColor;
|
||||
BBitmap* fOffscreen;
|
||||
#ifdef __HAIKU__
|
||||
BLayoutItem* fHistoryLayoutItem;
|
||||
BLayoutItem* fLegendLayoutItem;
|
||||
#endif
|
||||
BObjectList<DataSource> fSources;
|
||||
BObjectList<DataHistory> fValues;
|
||||
BMessageRunner* fRunner;
|
||||
|
@ -28,7 +28,8 @@ const DataSource* kSources[] = {
|
||||
new NetworkUsageDataSource(true),
|
||||
new NetworkUsageDataSource(false),
|
||||
new ClipboardSizeDataSource(false),
|
||||
new ClipboardSizeDataSource(true)
|
||||
new ClipboardSizeDataSource(true),
|
||||
new MediaNodesDataSource()
|
||||
};
|
||||
const size_t kSourcesCount = sizeof(kSources) / sizeof(kSources[0]);
|
||||
|
||||
@ -990,3 +991,50 @@ ClipboardSizeDataSource::AdaptiveScale() const
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
MediaNodesDataSource::MediaNodesDataSource()
|
||||
{
|
||||
SystemInfo info;
|
||||
|
||||
fMinimum = 0;
|
||||
fMaximum = INT32_MAX;
|
||||
|
||||
fColor = (rgb_color){255, 150, 225};
|
||||
}
|
||||
|
||||
|
||||
MediaNodesDataSource::~MediaNodesDataSource()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DataSource*
|
||||
MediaNodesDataSource::Copy() const
|
||||
{
|
||||
return new MediaNodesDataSource(*this);
|
||||
}
|
||||
|
||||
|
||||
int64
|
||||
MediaNodesDataSource::NextValue(SystemInfo& info)
|
||||
{
|
||||
return info.MediaNodes();
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
MediaNodesDataSource::Label() const
|
||||
{
|
||||
return "Media Nodes";
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
MediaNodesDataSource::AdaptiveScale() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -253,4 +253,17 @@ private:
|
||||
bool fText;
|
||||
};
|
||||
|
||||
|
||||
class MediaNodesDataSource : public DataSource {
|
||||
public:
|
||||
MediaNodesDataSource();
|
||||
virtual ~MediaNodesDataSource();
|
||||
|
||||
virtual DataSource* Copy() const;
|
||||
|
||||
virtual int64 NextValue(SystemInfo& info);
|
||||
virtual const char* Label() const;
|
||||
virtual bool AdaptiveScale() const;
|
||||
};
|
||||
|
||||
#endif // DATA_SOURCE_H
|
||||
|
@ -13,6 +13,6 @@ Application ActivityMonitor :
|
||||
SystemInfo.cpp
|
||||
SystemInfoHandler.cpp
|
||||
|
||||
: be tracker $(TARGET_LIBSTDC++) $(TARGET_NETWORK_LIBS)
|
||||
: be tracker media $(TARGET_LIBSTDC++) $(TARGET_NETWORK_LIBS)
|
||||
: ActivityMonitor.rdef
|
||||
;
|
||||
|
@ -21,7 +21,10 @@ SystemInfo::SystemInfo(SystemInfoHandler* handler)
|
||||
fRetrievedNetwork(false),
|
||||
fRunningApps(0),
|
||||
fClipboardSize(0),
|
||||
fClipboardTextSize(0)
|
||||
fClipboardTextSize(0),
|
||||
fMediaNodes(0),
|
||||
fMediaConnections(0),
|
||||
fMediaBuffers(0)
|
||||
{
|
||||
get_system_info(&fSystemInfo);
|
||||
|
||||
@ -29,6 +32,9 @@ SystemInfo::SystemInfo(SystemInfoHandler* handler)
|
||||
fRunningApps = handler->RunningApps();
|
||||
fClipboardSize = handler->ClipboardSize();
|
||||
fClipboardTextSize = handler->ClipboardTextSize();
|
||||
fMediaNodes = handler->MediaNodes();
|
||||
fMediaConnections = handler->MediaConnections();
|
||||
fMediaBuffers = handler->MediaBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,3 +231,24 @@ SystemInfo::ClipboardTextSize() const
|
||||
}
|
||||
|
||||
|
||||
uint32
|
||||
SystemInfo::MediaNodes() const
|
||||
{
|
||||
return fMediaNodes;
|
||||
}
|
||||
|
||||
|
||||
uint32
|
||||
SystemInfo::MediaConnections() const
|
||||
{
|
||||
return fMediaConnections;
|
||||
}
|
||||
|
||||
|
||||
uint32
|
||||
SystemInfo::MediaBuffers() const
|
||||
{
|
||||
return fMediaBuffers;
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,6 +45,10 @@ public:
|
||||
uint32 ClipboardSize() const;
|
||||
uint32 ClipboardTextSize() const;
|
||||
|
||||
uint32 MediaNodes() const;
|
||||
uint32 MediaConnections() const; // UNIMPLEMENTED
|
||||
uint32 MediaBuffers() const; // UNIMPLEMENTED
|
||||
|
||||
private:
|
||||
void _RetrieveNetwork();
|
||||
|
||||
@ -56,6 +60,9 @@ private:
|
||||
uint32 fRunningApps;
|
||||
uint32 fClipboardSize;
|
||||
uint32 fClipboardTextSize;
|
||||
uint32 fMediaNodes;
|
||||
uint32 fMediaConnections;
|
||||
uint32 fMediaBuffers;
|
||||
};
|
||||
|
||||
#endif // SYSTEM_INFO_H
|
||||
|
@ -12,7 +12,9 @@
|
||||
|
||||
#include <Clipboard.h>
|
||||
#include <Handler.h>
|
||||
#include <Input.h>
|
||||
#include <List.h>
|
||||
#include <MediaRoster.h>
|
||||
#include <Messenger.h>
|
||||
#include <Roster.h>
|
||||
|
||||
@ -20,6 +22,12 @@
|
||||
SystemInfoHandler::SystemInfoHandler()
|
||||
: BHandler("SystemInfoHandler")
|
||||
{
|
||||
fRunningApps = 0;
|
||||
fClipboardSize = 0;
|
||||
fClipboardTextSize = 0;
|
||||
fMediaNodes = 0;
|
||||
fMediaConnections = 0;
|
||||
fMediaBuffers = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -40,9 +48,13 @@ SystemInfoHandler::Archive(BMessage* data, bool deep) const
|
||||
void
|
||||
SystemInfoHandler::StartWatching()
|
||||
{
|
||||
status_t status;
|
||||
fRunningApps = 0;
|
||||
fClipboardSize = 0;
|
||||
fClipboardTextSize = 0;
|
||||
fMediaNodes = 0;
|
||||
fMediaConnections = 0;
|
||||
fMediaBuffers = 0;
|
||||
|
||||
// running applications count
|
||||
BList teamList;
|
||||
@ -59,16 +71,50 @@ SystemInfoHandler::StartWatching()
|
||||
be_clipboard->StartWatching(BMessenger(this));
|
||||
_UpdateClipboardData();
|
||||
}
|
||||
|
||||
if (BMediaRoster::Roster(&status) && (status >= B_OK)) {
|
||||
BMediaRoster::Roster()->StartWatching(BMessenger(this), B_MEDIA_NODE_CREATED);
|
||||
BMediaRoster::Roster()->StartWatching(BMessenger(this), B_MEDIA_NODE_DELETED);
|
||||
BMediaRoster::Roster()->StartWatching(BMessenger(this), B_MEDIA_CONNECTION_MADE);
|
||||
BMediaRoster::Roster()->StartWatching(BMessenger(this), B_MEDIA_CONNECTION_BROKEN);
|
||||
BMediaRoster::Roster()->StartWatching(BMessenger(this), B_MEDIA_BUFFER_CREATED);
|
||||
BMediaRoster::Roster()->StartWatching(BMessenger(this), B_MEDIA_BUFFER_DELETED);
|
||||
// XXX: this won't survive a media_server restart...
|
||||
|
||||
live_node_info nodeInfo; // I just need one
|
||||
int32 nodeCount = 1;
|
||||
if (BMediaRoster::Roster()->GetLiveNodes(&nodeInfo, &nodeCount)) {
|
||||
if (nodeCount > 0)
|
||||
fMediaNodes = (uint32)nodeCount;
|
||||
// TODO: retry with an array, and use GetNodeInput/Output
|
||||
// to find initial connection count
|
||||
}
|
||||
// TODO: get initial buffer count
|
||||
|
||||
}
|
||||
|
||||
// doesn't work on R5
|
||||
watch_input_devices(BMessenger(this), true);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SystemInfoHandler::StopWatching()
|
||||
{
|
||||
if (be_roster)
|
||||
be_roster->StopWatching(BMessenger(this));
|
||||
status_t status;
|
||||
watch_input_devices(BMessenger(this), false);
|
||||
if (BMediaRoster::Roster(&status) && (status >= B_OK)) {
|
||||
BMediaRoster::Roster()->StopWatching(BMessenger(this), B_MEDIA_NODE_CREATED);
|
||||
BMediaRoster::Roster()->StopWatching(BMessenger(this), B_MEDIA_NODE_DELETED);
|
||||
BMediaRoster::Roster()->StopWatching(BMessenger(this), B_MEDIA_CONNECTION_MADE);
|
||||
BMediaRoster::Roster()->StopWatching(BMessenger(this), B_MEDIA_CONNECTION_BROKEN);
|
||||
BMediaRoster::Roster()->StopWatching(BMessenger(this), B_MEDIA_BUFFER_CREATED);
|
||||
BMediaRoster::Roster()->StopWatching(BMessenger(this), B_MEDIA_BUFFER_DELETED);
|
||||
}
|
||||
if (be_clipboard)
|
||||
be_clipboard->StopWatching(BMessenger(this));
|
||||
if (be_roster)
|
||||
be_roster->StopWatching(BMessenger(this));
|
||||
}
|
||||
|
||||
|
||||
@ -87,7 +133,26 @@ SystemInfoHandler::MessageReceived(BMessage* message)
|
||||
case B_CLIPBOARD_CHANGED:
|
||||
_UpdateClipboardData();
|
||||
break;
|
||||
case B_MEDIA_NODE_CREATED:
|
||||
fMediaNodes++;
|
||||
break;
|
||||
case B_MEDIA_NODE_DELETED:
|
||||
fMediaNodes--;
|
||||
break;
|
||||
case B_MEDIA_CONNECTION_MADE:
|
||||
fMediaConnections++;
|
||||
break;
|
||||
case B_MEDIA_CONNECTION_BROKEN:
|
||||
fMediaConnections--;
|
||||
break;
|
||||
case B_MEDIA_BUFFER_CREATED:
|
||||
fMediaBuffers++;
|
||||
break;
|
||||
case B_MEDIA_BUFFER_DELETED:
|
||||
fMediaBuffers--;
|
||||
break;
|
||||
default:
|
||||
message->PrintToStream();
|
||||
BHandler::MessageReceived(message);
|
||||
}
|
||||
}
|
||||
@ -114,6 +179,27 @@ SystemInfoHandler::ClipboardTextSize() const
|
||||
}
|
||||
|
||||
|
||||
uint32
|
||||
SystemInfoHandler::MediaNodes() const
|
||||
{
|
||||
return fMediaNodes;
|
||||
}
|
||||
|
||||
|
||||
uint32
|
||||
SystemInfoHandler::MediaConnections() const
|
||||
{
|
||||
return fMediaConnections;
|
||||
}
|
||||
|
||||
|
||||
uint32
|
||||
SystemInfoHandler::MediaBuffers() const
|
||||
{
|
||||
return fMediaBuffers;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SystemInfoHandler::_UpdateClipboardData()
|
||||
{
|
||||
|
@ -24,6 +24,9 @@ public:
|
||||
uint32 RunningApps() const;
|
||||
uint32 ClipboardSize() const;
|
||||
uint32 ClipboardTextSize() const;
|
||||
uint32 MediaNodes() const;
|
||||
uint32 MediaConnections() const;
|
||||
uint32 MediaBuffers() const;
|
||||
|
||||
private:
|
||||
void _UpdateClipboardData();
|
||||
@ -31,6 +34,9 @@ private:
|
||||
uint32 fRunningApps;
|
||||
uint32 fClipboardSize;
|
||||
uint32 fClipboardTextSize;
|
||||
uint32 fMediaNodes;
|
||||
uint32 fMediaConnections;
|
||||
uint32 fMediaBuffers;
|
||||
};
|
||||
|
||||
#endif // SYSTEM_INFO_HANDLER_H
|
||||
|
Loading…
Reference in New Issue
Block a user