diff --git a/src/servers/notification/AppGroupView.cpp b/src/servers/notification/AppGroupView.cpp index 38fec70..b01e1af 100644 --- a/src/servers/notification/AppGroupView.cpp +++ b/src/servers/notification/AppGroupView.cpp @@ -13,6 +13,7 @@ #include +#include #include #include #include @@ -172,7 +173,8 @@ void AppGroupView::MessageReceived(BMessage* msg) { switch (msg->what) { - case kRemoveView: + case kViewClosed: + case kTimeoutExpired: { NotificationView* view = NULL; if (msg->FindPointer("view", (void**)&view) != B_OK) @@ -184,7 +186,9 @@ AppGroupView::MessageReceived(BMessage* msg) fInfo.erase(vIt); view->RemoveSelf(); - delete view; + + if (msg->what != kTimeoutExpired) + delete view; fParent->PostMessage(msg); @@ -195,6 +199,12 @@ AppGroupView::MessageReceived(BMessage* msg) fParent->PostMessage(&removeSelfMessage); } + // Send message to add view to notification center + if (msg->what == kTimeoutExpired) { + msg->what = kAddView; + be_app->PostMessage(msg); + } + break; } default: diff --git a/src/servers/notification/NotificationServer.cpp b/src/servers/notification/NotificationServer.cpp index 27cf979..3ba3684 100644 --- a/src/servers/notification/NotificationServer.cpp +++ b/src/servers/notification/NotificationServer.cpp @@ -43,6 +43,7 @@ void NotificationServer::ReadyToRun() { fWindow = new NotificationWindow(); + fCenter = new NotificationWindow(); } @@ -68,6 +69,13 @@ NotificationServer::MessageReceived(BMessage* message) BMessenger(fWindow).SendMessage(message); break; } + + case kAddView: + { + BMessenger(fCenter).SendMessage(message); + break; + } + default: BApplication::MessageReceived(message); } diff --git a/src/servers/notification/NotificationServer.h b/src/servers/notification/NotificationServer.h index 50122f5..d488aca 100644 --- a/src/servers/notification/NotificationServer.h +++ b/src/servers/notification/NotificationServer.h @@ -27,6 +27,7 @@ public: private: NotificationWindow* fWindow; + NotificationWindow* fCenter; }; diff --git a/src/servers/notification/NotificationView.cpp b/src/servers/notification/NotificationView.cpp index 2856b42..59986ff 100644 --- a/src/servers/notification/NotificationView.cpp +++ b/src/servers/notification/NotificationView.cpp @@ -61,6 +61,7 @@ NotificationView::NotificationView(NotificationWindow* win, fParent(win), fNotification(notification), fTimeout(timeout), + fTimeoutEnabled(true), fRunner(NULL), fBitmap(NULL), fCloseClicked(false) @@ -123,10 +124,12 @@ NotificationView::AttachedToWindow() { SetText(); - BMessage msg(kRemoveView); - msg.AddPointer("view", this); + if (fTimeoutEnabled) { + BMessage msg(kTimeoutExpired); + msg.AddPointer("view", this); - fRunner = new BMessageRunner(BMessenger(Parent()), &msg, fTimeout, 1); + fRunner = new BMessageRunner(BMessenger(Parent()), &msg, fTimeout, 1); + } } @@ -396,7 +399,7 @@ NotificationView::MouseDown(BPoint point) } // Remove the info view after a click - BMessage remove_msg(kRemoveView); + BMessage remove_msg(kViewClosed); remove_msg.AddPointer("view", this); BMessenger msgr(Parent()); @@ -548,6 +551,13 @@ NotificationView::SetText(float newMaxWidth) } +void +NotificationView::EnableTimeout(bool enabled) +{ + fTimeoutEnabled = enabled; +} + + const char* NotificationView::MessageID() const { @@ -555,6 +565,13 @@ NotificationView::MessageID() const } +const char* +NotificationView::Group() const +{ + return fNotification->Group(); +} + + void NotificationView::_CalculateSize() { diff --git a/src/servers/notification/NotificationView.h b/src/servers/notification/NotificationView.h index da851cd..a323d4e 100644 --- a/src/servers/notification/NotificationView.h +++ b/src/servers/notification/NotificationView.h @@ -20,7 +20,9 @@ class BNotification; class NotificationWindow; -const uint32 kRemoveView = 'ReVi'; +const uint32 kViewClosed = 'ReVi'; +const uint32 kTimeoutExpired = 'TiEx'; +const uint32 kAddView = 'AdVi'; class NotificationView : public BView { @@ -47,8 +49,10 @@ public: virtual status_t GetSupportedSuites(BMessage* msg); void SetText(float newMaxWidth = -1); + void EnableTimeout(bool enabled = true); const char* MessageID() const; + const char* Group() const; private: void _CalculateSize(); @@ -65,6 +69,7 @@ private: NotificationWindow* fParent; BNotification* fNotification; bigtime_t fTimeout; + bool fTimeoutEnabled; BMessageRunner* fRunner; diff --git a/src/servers/notification/NotificationWindow.cpp b/src/servers/notification/NotificationWindow.cpp index 7a9d9aa..c5727cf 100644 --- a/src/servers/notification/NotificationWindow.cpp +++ b/src/servers/notification/NotificationWindow.cpp @@ -214,7 +214,48 @@ NotificationWindow::MessageReceived(BMessage* message) message->SendReply(&reply); break; } - case kRemoveView: + case kAddView: + { + NotificationView* view = NULL; + if (message->FindPointer("view", (void**)&view) != B_OK) + return; + + // TODO can we assume it has already gone through filtering? +/* bool allow = false; + appfilter_t::iterator it = fAppFilters.find(info.signature); + + if (it == fAppFilters.end()) { + AppUsage* appUsage = new AppUsage(notification->Group(), + true); + + appUsage->Allowed(notification->Title(), + notification->Type()); + fAppFilters[info.signature] = appUsage; + allow = true; + } else { + allow = it->second->Allowed(notification->Title(), + notification->Type()); + } + + if (allow) {*/ + BString groupName(view->Group()); + appview_t::iterator aIt = fAppViews.find(groupName); + AppGroupView* group = NULL; + if (aIt == fAppViews.end()) { + group = new AppGroupView(this, + groupName == "" ? NULL : groupName.String()); + fAppViews[groupName] = group; + GetLayout()->AddView(group); + } else + group = aIt->second; + + view->EnableTimeout(false); + group->AddInfo(view); + + _ShowHide(); + } + case kViewClosed: + case kTimeoutExpired: { NotificationView* view = NULL; if (message->FindPointer("view", (void**)&view) != B_OK) @@ -224,6 +265,7 @@ NotificationWindow::MessageReceived(BMessage* message) if (it != fViews.end()) fViews.erase(it); + break; } case kRemoveGroupView: