diff --git a/src/apps/activitymonitor/ActivityView.cpp b/src/apps/activitymonitor/ActivityView.cpp index fc24069f5e..e8e9d97764 100644 --- a/src/apps/activitymonitor/ActivityView.cpp +++ b/src/apps/activitymonitor/ActivityView.cpp @@ -10,7 +10,9 @@ #include #include +#ifdef __HAIKU__ #include +#endif #include #include #include @@ -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(); diff --git a/src/apps/activitymonitor/ActivityView.h b/src/apps/activitymonitor/ActivityView.h index 7f5b060199..f41c529552 100644 --- a/src/apps/activitymonitor/ActivityView.h +++ b/src/apps/activitymonitor/ActivityView.h @@ -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 fSources; BObjectList fValues; BMessageRunner* fRunner; diff --git a/src/apps/activitymonitor/DataSource.cpp b/src/apps/activitymonitor/DataSource.cpp index e5963fd1d3..f693747be4 100644 --- a/src/apps/activitymonitor/DataSource.cpp +++ b/src/apps/activitymonitor/DataSource.cpp @@ -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; +} + + diff --git a/src/apps/activitymonitor/DataSource.h b/src/apps/activitymonitor/DataSource.h index f0229b47f8..39e4435d66 100644 --- a/src/apps/activitymonitor/DataSource.h +++ b/src/apps/activitymonitor/DataSource.h @@ -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 diff --git a/src/apps/activitymonitor/Jamfile b/src/apps/activitymonitor/Jamfile index 03162b83bf..46dc8a56a4 100644 --- a/src/apps/activitymonitor/Jamfile +++ b/src/apps/activitymonitor/Jamfile @@ -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 ; diff --git a/src/apps/activitymonitor/SystemInfo.cpp b/src/apps/activitymonitor/SystemInfo.cpp index f84b238476..84a7b272bc 100644 --- a/src/apps/activitymonitor/SystemInfo.cpp +++ b/src/apps/activitymonitor/SystemInfo.cpp @@ -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; +} + + diff --git a/src/apps/activitymonitor/SystemInfo.h b/src/apps/activitymonitor/SystemInfo.h index 8a8fe9392b..4ff4b7cb5d 100644 --- a/src/apps/activitymonitor/SystemInfo.h +++ b/src/apps/activitymonitor/SystemInfo.h @@ -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 diff --git a/src/apps/activitymonitor/SystemInfoHandler.cpp b/src/apps/activitymonitor/SystemInfoHandler.cpp index 8ef5d294f0..83e37d223c 100644 --- a/src/apps/activitymonitor/SystemInfoHandler.cpp +++ b/src/apps/activitymonitor/SystemInfoHandler.cpp @@ -12,7 +12,9 @@ #include #include +#include #include +#include #include #include @@ -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() { diff --git a/src/apps/activitymonitor/SystemInfoHandler.h b/src/apps/activitymonitor/SystemInfoHandler.h index bd7512b32a..8759919cae 100644 --- a/src/apps/activitymonitor/SystemInfoHandler.h +++ b/src/apps/activitymonitor/SystemInfoHandler.h @@ -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