Author: pulkomandy Date: 2011-11-02 15:57:43 +0100 (Wed, 02 Nov 2011) New Revision: 43114 Changeset: https://dev.haiku-os.org/changeset/43114 Removed: haiku/trunk/src/servers/notification/BorderView.cpp haiku/trunk/src/servers/notification/BorderView.h Modified: haiku/trunk/headers/os/app/Notification.h haiku/trunk/headers/os/app/Roster.h haiku/trunk/headers/os/mail/MailSettings.h haiku/trunk/src/bin/notify.cpp haiku/trunk/src/kits/notification/AppUsage.cpp haiku/trunk/src/kits/notification/Notifications.cpp haiku/trunk/src/servers/mail/MailDaemon.cpp haiku/trunk/src/servers/mail/Notifier.cpp haiku/trunk/src/servers/notification/AppGroupView.cpp haiku/trunk/src/servers/notification/AppGroupView.h haiku/trunk/src/servers/notification/Jamfile haiku/trunk/src/servers/notification/NotificationServer.cpp haiku/trunk/src/servers/notification/NotificationServer.h haiku/trunk/src/servers/notification/NotificationView.cpp haiku/trunk/src/servers/notification/NotificationView.h haiku/trunk/src/servers/notification/NotificationWindow.cpp haiku/trunk/src/servers/notification/NotificationWindow.h Log: Merge patch by plfiorini : Some changes to the API for notifications. * Don't go through be_roster to send a notification, but use Notification->Send() instead. * Rename App to Group to make the purpose clearer And some changes to the notification code itself: * Use the Notification class as the way to convey informations about a notification. Allows easier extension of this class * Code cleanup * Use of the layout kit for the notify window Unfortunately, the latter part clashes quite a bit with the changes I already did to the notification window, so it's now quite broken. Working on that next, but I wanted to separate that work from the patch ... Modified: haiku/trunk/headers/os/app/Notification.h =================================================================== --- haiku/trunk/headers/os/app/Notification.h 2011-11-02 14:51:15 UTC (rev 43113) +++ haiku/trunk/headers/os/app/Notification.h 2011-11-02 14:57:43 UTC (rev 43114) @@ -6,6 +6,7 @@ #define _NOTIFICATION_H +#include <Archivable.h> #include <Entry.h> #include <List.h> #include <String.h> @@ -22,15 +23,21 @@ class BBitmap; -class BNotification { +class BNotification : public BArchivable { public: BNotification(notification_type type); - ~BNotification(); + BNotification(BMessage* archive); + virtual ~BNotification(); + status_t InitCheck() const; + + static BArchivable* Instantiate(BMessage* archive); + virtual status_t Archive(BMessage* archive, bool deep = true) const; + notification_type Type() const; - const char* Application() const; - void SetApplication(const BString& app); + const char* Group() const; + void SetGroup(const BString& group); const char* Title() const; void SetTitle(const BString& title); @@ -61,9 +68,13 @@ const BBitmap* Icon() const; status_t SetIcon(const BBitmap* icon); + status_t Send(bigtime_t timeout = -1); + private: + status_t fInitStatus; + notification_type fType; - BString fAppName; + BString fGroup; BString fTitle; BString fContent; BString fID; Modified: haiku/trunk/headers/os/app/Roster.h =================================================================== --- haiku/trunk/headers/os/app/Roster.h 2011-11-02 14:51:15 UTC (rev 43113) +++ haiku/trunk/headers/os/app/Roster.h 2011-11-02 14:57:43 UTC (rev 43114) @@ -13,7 +13,6 @@ class BFile; class BMimeType; class BNodeInfo; -class BNotification; struct app_info { @@ -117,10 +116,6 @@ void AddToRecentFolders(const entry_ref *folder, const char *appSig = 0) const; - // notifications - status_t Notify(const BNotification& notification, - bigtime_t timeout = -1) const; - // private/reserved stuff starts here class Private; Modified: haiku/trunk/headers/os/mail/MailSettings.h =================================================================== --- haiku/trunk/headers/os/mail/MailSettings.h 2011-11-02 14:51:15 UTC (rev 43113) +++ haiku/trunk/headers/os/mail/MailSettings.h 2011-11-02 14:57:43 UTC (rev 43114) @@ -28,15 +28,6 @@ } b_mail_status_window_option; -typedef enum { - B_MAIL_STATUS_LOOK_TITLED = 0, - B_MAIL_STATUS_LOOK_NORMAL_BORDER = 1, - B_MAIL_STATUS_LOOK_FLOATING = 2, - B_MAIL_STATUS_LOOK_THIN_BORDER = 3, - B_MAIL_STATUS_LOOK_NO_BORDER = 4 -} b_mail_status_window_look; - - class BMailSettings { public: BMailSettings(); Modified: haiku/trunk/src/bin/notify.cpp =================================================================== --- haiku/trunk/src/bin/notify.cpp 2011-11-02 14:51:15 UTC (rev 43113) +++ haiku/trunk/src/bin/notify.cpp 2011-11-02 14:57:43 UTC (rev 43114) @@ -10,7 +10,6 @@ #include <stdio.h> #include <stdlib.h> -#include <string.h> #include <Application.h> #include <Bitmap.h> @@ -19,7 +18,6 @@ #include <Mime.h> #include <Notification.h> #include <Path.h> -#include <Roster.h> #include <TranslationUtils.h> const char* kSignature = "application/x-vnd.Haiku-notify"; @@ -52,15 +50,15 @@ private: bool fHasGoodArguments; notification_type fType; - char* fAppName; - char* fTitle; - char* fMsgId; + BString fGroup; + BString fTitle; + BString fMsgId; float fProgress; bigtime_t fTimeout; - char* fIconFile; + BString fIconFile; entry_ref fFileRef; - char* fMessage; - char* fApp; + BString fContent; + BString fOnClickApp; bool fHasFile; entry_ref fFile; BList* fRefs; @@ -76,14 +74,8 @@ BApplication(kSignature), fHasGoodArguments(false), fType(B_INFORMATION_NOTIFICATION), - fAppName(NULL), - fTitle(NULL), - fMsgId(NULL), fProgress(0.0f), - fTimeout(0), - fIconFile(NULL), - fMessage(NULL), - fApp(NULL), + fTimeout(-1), fHasFile(false) { fRefs = new BList(); @@ -93,19 +85,12 @@ NotifyApp::~NotifyApp() { - free(fAppName); - free(fTitle); - free(fMsgId); - free(fIconFile); - free(fMessage); - free(fApp); - for (int32 i = 0; void* item = fRefs->ItemAt(i); i++) delete (BEntry*)item; delete fRefs; for (int32 i = 0; void* item = fArgv->ItemAt(i); i++) - free(item); + delete (BString*)item; delete fArgv; } @@ -134,25 +119,25 @@ if (strncmp(kTypeNames[i], argument, strlen(argument)) == 0) fType = (notification_type)i; } - } else if (strcmp(option, "app") == 0) - fAppName = strdup(argument); + } else if (strcmp(option, "group") == 0) + fGroup = argument; else if (strcmp(option, "title") == 0) - fTitle = strdup(argument); + fTitle = argument; else if (strcmp(option, "messageID") == 0) - fMsgId = strdup(argument); + fMsgId = argument; else if (strcmp(option, "progress") == 0) fProgress = atof(argument); else if (strcmp(option, "timeout") == 0) fTimeout = atol(argument) * 1000000; else if (strcmp(option, "icon") == 0) { - fIconFile = strdup(argument); + fIconFile = argument; - if (get_ref_for_path(fIconFile, &fFileRef) < B_OK) { + if (get_ref_for_path(fIconFile.String(), &fFileRef) < B_OK) { fprintf(stderr, "Bad icon path!\n\n"); return; } } else if (strcmp(option, "onClickApp") == 0) - fApp = strdup(argument); + fOnClickApp = argument; else if (strcmp(option, "onClickFile") == 0) { if (get_ref_for_path(argument, &fFile) != B_OK) { fprintf(stderr, "Bad path for --onClickFile!\n\n"); @@ -170,7 +155,7 @@ fRefs->AddItem(new BEntry(&ref)); } else if (strcmp(option, "onClickArgv") == 0) - fArgv->AddItem(strdup(argument)); + fArgv->AddItem(new BString(argument)); else { // Unrecognized option fprintf(stderr, "Unrecognized option --%s\n\n", option); @@ -188,17 +173,7 @@ } } - // Check for missing arguments - if (fAppName == NULL) { - fprintf(stderr, "Missing --app argument!\n\n"); - return; - } - if (fTitle == NULL) { - fprintf(stderr, "Missing --title argument!\n\n"); - return; - } - - fMessage = strdup(argv[index]); + fContent = argv[index]; fHasGoodArguments = true; } @@ -208,13 +183,13 @@ fprintf(stderr, "Usage: notify [OPTION]... [MESSAGE]\n" "Send notifications to notification_server.\n" " --type <type>\tNotification type,\n" - " \t <type>: "); + " \t <type> - \"information\" is assumed by default: "); for (int32 i = 0; kTypeNames[i]; i++) fprintf(stderr, kTypeNames[i + 1] ? "%s|" : "%s\n", kTypeNames[i]); fprintf(stderr, - " --app <app name>\tApplication name\n" + " --group <group>\tGroup\n" " --title <title>\tMessage title\n" " --messageID <msg id>\tMessage ID\n" " --progress <float>\tProgress, value between 0.0 and 1.0 - if type is set to progress\n" @@ -256,17 +231,20 @@ { if (HasGoodArguments()) { BNotification notification(fType); - notification.SetApplication(fAppName); - notification.SetTitle(fTitle); - notification.SetContent(fMessage); + if (fGroup != "") + notification.SetGroup(fGroup); + if (fTitle != "") + notification.SetTitle(fTitle); + if (fContent != "") + notification.SetContent(fContent); - if (fMsgId != NULL) + if (fMsgId != "") notification.SetMessageID(fMsgId); if (fType == B_PROGRESS_NOTIFICATION) notification.SetProgress(fProgress); - if (fIconFile != NULL) { + if (fIconFile != "") { BBitmap* bitmap = _GetBitmap(&fFileRef); if (bitmap) { notification.SetIcon(bitmap); @@ -274,8 +252,8 @@ } } - if (fApp != NULL) - notification.SetOnClickApp(fApp); + if (fOnClickApp != "") + notification.SetOnClickApp(fOnClickApp); if (fHasFile) notification.SetOnClickFile(&fFile); @@ -289,11 +267,11 @@ } for (int32 i = 0; void* item = fArgv->ItemAt(i); i++) { - const char* arg = (const char*)item; - notification.AddOnClickArg(arg); + BString* arg = (BString*)item; + notification.AddOnClickArg(arg->String()); } - status_t ret = be_roster->Notify(notification, fTimeout); + status_t ret = notification.Send(fTimeout); if (ret != B_OK) { fprintf(stderr, "Failed to deliver notification: %s\n", strerror(ret)); Modified: haiku/trunk/src/kits/notification/AppUsage.cpp =================================================================== --- haiku/trunk/src/kits/notification/AppUsage.cpp 2011-11-02 14:51:15 UTC (rev 43113) +++ haiku/trunk/src/kits/notification/AppUsage.cpp 2011-11-02 14:57:43 UTC (rev 43114) @@ -27,9 +27,8 @@ } -AppUsage::AppUsage(entry_ref ref, const char* name, bool allow) +AppUsage::AppUsage(const char* name, bool allow) : - fRef(ref), fName(name), fAllow(allow) { @@ -38,7 +37,7 @@ AppUsage::~AppUsage() { - notify_t::iterator nIt; + notification_t::iterator nIt; for (nIt = fNotifications.begin(); nIt != fNotifications.end(); nIt++) delete nIt->second; } @@ -55,13 +54,12 @@ AppUsage::Flatten(void* buffer, ssize_t numBytes) const { BMessage msg; - msg.AddString("app_name", fName); - msg.AddRef("app_ref", &fRef); - msg.AddBool("app_allow", fAllow); + msg.AddString("signature", fName); + msg.AddBool("allow", fAllow); - notify_t::const_iterator nIt; + notification_t::const_iterator nIt; for (nIt = fNotifications.begin(); nIt != fNotifications.end(); nIt++) - msg.AddFlat("notify", nIt->second); + msg.AddFlat("notification", nIt->second); if (numBytes < msg.FlattenedSize()) return B_ERROR; @@ -74,13 +72,12 @@ AppUsage::FlattenedSize() const { BMessage msg; - msg.AddString("app_name", fName); - msg.AddRef("app_ref", &fRef); - msg.AddBool("app_allow", fAllow); + msg.AddString("signature", fName); + msg.AddBool("allow", fAllow); - notify_t::const_iterator nIt; + notification_t::const_iterator nIt; for (nIt = fNotifications.begin(); nIt != fNotifications.end(); nIt++) - msg.AddFlat("notify", nIt->second); + msg.AddFlat("notification", nIt->second); return msg.FlattenedSize(); } @@ -113,21 +110,20 @@ status = msg.Unflatten((const char*)buffer); if (status == B_OK) { - msg.FindString("app_name", &fName); - msg.FindRef("app_ref", &fRef); - msg.FindBool("app_allow", &fAllow); + msg.FindString("signature", &fName); + msg.FindBool("allow", &fAllow); type_code type; int32 count = 0; - status = msg.GetInfo("notify", &type, &count); + status = msg.GetInfo("notification", &type, &count); if (status != B_OK) return status; for (int32 i = 0; i < count; i++) { - NotificationReceived *notify = new NotificationReceived(); - msg.FindFlat("notify", i, notify); - fNotifications[notify->Title()] = notify; + NotificationReceived *notification = new NotificationReceived(); + msg.FindFlat("notification", i, notification); + fNotifications[notification->Title()] = notification; } status = B_OK; @@ -137,13 +133,6 @@ } -entry_ref -AppUsage::Ref() -{ - return fRef; -} - - const char* AppUsage::Name() { @@ -157,7 +146,7 @@ bool allowed = fAllow; if (allowed) { - notify_t::iterator nIt = fNotifications.find(title); + notification_t::iterator nIt = fNotifications.find(title); if (nIt == fNotifications.end()) { allowed = true; fNotifications[title] = new NotificationReceived(title, type); @@ -182,7 +171,7 @@ NotificationReceived* AppUsage::NotificationAt(int32 index) { - notify_t::iterator nIt = fNotifications.begin(); + notification_t::iterator nIt = fNotifications.begin(); for (int32 i = 0; i < index; i++) nIt++; Modified: haiku/trunk/src/kits/notification/Notifications.cpp =================================================================== --- haiku/trunk/src/kits/notification/Notifications.cpp 2011-11-02 14:51:15 UTC (rev 43113) +++ haiku/trunk/src/kits/notification/Notifications.cpp 2011-11-02 14:57:43 UTC (rev 43114) @@ -20,5 +20,3 @@ // Display settings const char* kWidthName = "width"; const char* kIconSizeName = "icon size"; -const char* kLayoutName = "layout"; - Modified: haiku/trunk/src/servers/mail/MailDaemon.cpp =================================================================== --- haiku/trunk/src/servers/mail/MailDaemon.cpp 2011-11-02 14:51:15 UTC (rev 43113) +++ haiku/trunk/src/servers/mail/MailDaemon.cpp 2011-11-02 14:57:43 UTC (rev 43114) @@ -191,7 +191,7 @@ fCentralBeep = false; fNotification = new BNotification(B_INFORMATION_NOTIFICATION); - fNotification->SetApplication(B_TRANSLATE("Mail status")); + fNotification->SetGroup(B_TRANSLATE("Mail status")); fNotification->SetTitle(string); fNotification->SetMessageID("daemon_status"); @@ -390,7 +390,7 @@ fNotification->SetTitle(string.String()); if (fNotifyMode != B_MAIL_SHOW_STATUS_WINDOW_NEVER) - be_roster->Notify(*fNotification); + fNotification->Send(); break; } Modified: haiku/trunk/src/servers/mail/Notifier.cpp =================================================================== --- haiku/trunk/src/servers/mail/Notifier.cpp 2011-11-02 14:51:15 UTC (rev 43113) +++ haiku/trunk/src/servers/mail/Notifier.cpp 2011-11-02 14:57:43 UTC (rev 43114) @@ -42,7 +42,7 @@ // Two windows for each acocunt : one for sending and the other for // receiving mails fNotification.SetMessageID(identifier); - fNotification.SetApplication(B_TRANSLATE("Mail Status")); + fNotification.SetGroup(B_TRANSLATE("Mail Status")); fNotification.SetTitle(desc); app_info info; @@ -127,7 +127,7 @@ if ((!fIsInbound && fShowMode | B_MAIL_SHOW_STATUS_WINDOW_WHEN_SENDING) || (fIsInbound && fShowMode | B_MAIL_SHOW_STATUS_WINDOW_WHEN_ACTIVE)) - be_roster->Notify(fNotification, timeout); + fNotification.Send(timeout); } @@ -137,5 +137,5 @@ fNotification.SetProgress(0); if (message != NULL) fNotification.SetTitle(message); - be_roster->Notify(fNotification, 0); + fNotification.Send(0); } Modified: haiku/trunk/src/servers/notification/AppGroupView.cpp =================================================================== --- haiku/trunk/src/servers/notification/AppGroupView.cpp 2011-11-02 14:51:15 UTC (rev 43113) +++ haiku/trunk/src/servers/notification/AppGroupView.cpp 2011-11-02 14:57:43 UTC (rev 43114) @@ -13,6 +13,9 @@ #include <algorithm> +#include <GroupLayout.h> +#include <GroupView.h> + #include "AppGroupView.h" #include "NotificationWindow.h" @@ -21,13 +24,16 @@ AppGroupView::AppGroupView(NotificationWindow* win, const char* label) : - BView(BRect(0, 0, win->ViewWidth(), 1), label, B_FOLLOW_LEFT_RIGHT, - B_WILL_DRAW|B_FULL_UPDATE_ON_RESIZE|B_FRAME_EVENTS), + BBox(B_FANCY_BORDER, (fView = new BGroupView(B_VERTICAL, 10))), fLabel(label), fParent(win), fCollapsed(false) { - Show(); + // If no group was specified we don't have any border or label + if (label == NULL) + SetBorder(B_NO_BORDER); + else + SetLabel(label); } @@ -36,6 +42,7 @@ } +/* void AppGroupView::AttachedToWindow() { @@ -43,8 +50,9 @@ SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetHighColor(ui_color(B_PANEL_TEXT_COLOR)); } +*/ - +/* void AppGroupView::Draw(BRect updateRect) { @@ -120,8 +128,8 @@ Sync(); } +*/ - void AppGroupView::MouseDown(BPoint point) { @@ -131,7 +139,7 @@ int32 children = fInfo.size(); for (int32 i = 0; i < children; i++) { - fInfo[i]->RemoveSelf(); + fView->GetLayout()->RemoveView(fInfo[i]); delete fInfo[i]; } fInfo.clear(); @@ -143,42 +151,12 @@ } if (changed) { - ResizeViews(); - Invalidate(); + _ResizeViews(); } } void -AppGroupView::GetPreferredSize(float* width, float* height) -{ - font_height fh; - be_bold_font->GetHeight(&fh); - - float h = fh.ascent + fh.leading + fh.leading; - h += kEdgePadding * 2; // Padding between top and bottom of label - - if (!fCollapsed) { - int32 children = fInfo.size(); - - for (int32 i = 0; i < children; i++) { - float childHeight = 0; - float childWidth = 0; - - fInfo[i]->GetPreferredSize(&childWidth, &childHeight); - - h += childHeight; - } - } - - h += kEdgePadding; - - *width = fParent->ViewWidth(); - *height = h; -} - - -void AppGroupView::MessageReceived(BMessage* msg) { switch (msg->what) { @@ -192,16 +170,14 @@ if (vIt != fInfo.end()) { fInfo.erase(vIt); - view->RemoveSelf(); + fView->GetLayout()->RemoveView(view); delete view; } - ResizeViews(); - Invalidate(); + if (Window() != NULL) + Window()->PostMessage(msg); - // When all the views are destroy, save app filters - if (fInfo.size() == 0) - dynamic_cast<NotificationWindow*>(Window())->SaveAppFilters(); + _ResizeViews(); break; } default: @@ -214,13 +190,14 @@ AppGroupView::AddInfo(NotificationView* view) { BString id = view->MessageID(); + bool found = false; + if (id.Length() > 0) { int32 children = fInfo.size(); - bool found = false; for (int32 i = 0; i < children; i++) { - if (fInfo[i]->HasMessageID(id.String())) { - fInfo[i]->RemoveSelf(); + if (id == fInfo[i]->MessageID()) { + fView->GetLayout()->RemoveView(fInfo[i]); delete fInfo[i]; fInfo[i] = view; @@ -229,28 +206,23 @@ break; } } + } - if (!found) - fInfo.push_back(view); - } else + if (!found) fInfo.push_back(view); + fView->GetLayout()->AddView(view); - if (fParent->IsHidden()) - fParent->Show(); if (IsHidden()) Show(); if (view->IsHidden()) view->Show(); - AddChild(view); - - ResizeViews(); - Invalidate(); + _ResizeViews(); } void -AppGroupView::ResizeViews() +AppGroupView::_ResizeViews() { font_height fh; be_bold_font->GetHeight(&fh); @@ -268,22 +240,14 @@ offset += fInfo[i]->Bounds().Height(); if (fInfo[i]->IsHidden()) fInfo[i]->Show(); - fInfo[i]->SetPosition(false, false); - }; + } } else { for (int32 i = 0; i < children; i++) if (!fInfo[i]->IsHidden()) fInfo[i]->Hide(); } - if (children == 1) - fInfo[0]->SetPosition(true, true); - else if (children > 1) { - fInfo[0]->SetPosition(true, false); - fInfo[children - 1]->SetPosition(false, true); - } - - ResizeTo(fParent->ViewWidth(), offset); + ResizeTo(fParent->Width(), offset); float labelOffset = fh.ascent + fh.leading; BRect borderRect = Bounds().InsetByCopy(kEdgePadding, kEdgePadding); @@ -299,8 +263,6 @@ fCloseRect.top += kEdgePadding * 1.5; fCloseRect.left = fCloseRect.right - kCloseSize; fCloseRect.bottom = fCloseRect.top + kCloseSize; - - fParent->ResizeAll(); } Modified: haiku/trunk/src/servers/notification/AppGroupView.h =================================================================== --- haiku/trunk/src/servers/notification/AppGroupView.h 2011-11-02 14:51:15 UTC (rev 43113) +++ haiku/trunk/src/servers/notification/AppGroupView.h 2011-11-02 14:57:43 UTC (rev 43114) @@ -1,50 +1,47 @@ /* - * Copyright 2005-2008, Mikael Eiman. - * Copyright 2005-2008, Michael Davidson. + * Copyright 2010, Haiku, Inc. All Rights Reserved. + * Copyright 2008-2009, Pier Luigi Fiorini. All Rights Reserved. + * Copyright 2004-2008, Michael Davidson. All Rights Reserved. + * Copyright 2004-2007, Mikael Eiman. All Rights Reserved. * Distributed under the terms of the MIT License. - * - * Authors: - * Mikael Eiman <mikael@xxxxxxxx> - * Michael Davidson <slaad@xxxxxxxxxxx> */ +#ifndef _APP_GROUP_VIEW_H +#define _APP_GROUP_VIEW_H -#ifndef APPGROUPVIEW_H -#define APPGROUPVIEW_H - #include <vector> +#include <Box.h> #include <String.h> -#include <View.h> +class BGroupView; + class NotificationWindow; class NotificationView; -typedef std::vector<NotificationView *> infoview_t; +typedef std::vector<NotificationView*> infoview_t; -class AppGroupView : public BView { - public: - AppGroupView(NotificationWindow *win, const char *label); - ~AppGroupView(void); - - // Hooks - void AttachedToWindow(void); - void Draw(BRect bounds); - void MouseDown(BPoint point); - void GetPreferredSize(float *width, float *height); - void MessageReceived(BMessage *msg); - - // Public - void AddInfo(NotificationView *view); - void ResizeViews(void); - bool HasChildren(void); - - private: - BString fLabel; - NotificationWindow *fParent; - infoview_t fInfo; - bool fCollapsed; - BRect fCloseRect; - BRect fCollapseRect; +class AppGroupView : public BBox { +public: + AppGroupView(NotificationWindow* win, const char* label); + ~AppGroupView(); + + virtual void MouseDown(BPoint point); + virtual void MessageReceived(BMessage* msg); + + bool HasChildren(); + + void AddInfo(NotificationView* view); + +private: + void _ResizeViews(); + + BString fLabel; + NotificationWindow* fParent; + BGroupView* fView; + infoview_t fInfo; + bool fCollapsed; + BRect fCloseRect; + BRect fCollapseRect; }; -#endif +#endif // _APP_GROUP_VIEW_H Modified: haiku/trunk/src/servers/notification/Jamfile =================================================================== --- haiku/trunk/src/servers/notification/Jamfile 2011-11-02 14:51:15 UTC (rev 43113) +++ haiku/trunk/src/servers/notification/Jamfile 2011-11-02 14:57:43 UTC (rev 43114) @@ -4,11 +4,10 @@ Server notification_server : AppGroupView.cpp - BorderView.cpp NotificationServer.cpp NotificationView.cpp NotificationWindow.cpp - : be $(TARGET_LIBSTDC++) libicon.a libnotification.a $(HAIKU_LOCALE_LIBS) + : be translation $(TARGET_LIBSTDC++) libnotification.a $(HAIKU_LOCALE_LIBS) : notification_server.rdef ; @@ -20,5 +19,4 @@ NotificationWindow.cpp ; -Depends notification_server : libicon.a ; Depends notification_server : libnotification.a ; Modified: haiku/trunk/src/servers/notification/NotificationServer.cpp =================================================================== --- haiku/trunk/src/servers/notification/NotificationServer.cpp 2011-11-02 14:51:15 UTC (rev 43113) +++ haiku/trunk/src/servers/notification/NotificationServer.cpp 2011-11-02 14:57:43 UTC (rev 43114) @@ -24,7 +24,6 @@ NotificationServer::NotificationServer() : BApplication(kNotificationServerSignature) { - fWindow = new NotificationWindow(); } @@ -34,6 +33,13 @@ void +NotificationServer::ReadyToRun() +{ + fWindow = new NotificationWindow(); +} + + +void NotificationServer::MessageReceived(BMessage* message) { switch (message->what) { @@ -61,17 +67,6 @@ } -bool -NotificationServer::QuitRequested() -{ - if (fWindow && fWindow->Lock()) { - fWindow->Quit(); - fWindow = NULL; - } - return true; -} - - status_t NotificationServer::GetSupportedSuites(BMessage* msg) { @@ -110,8 +105,8 @@ add_system_beep_event(kSoundNames[i++], 0); // Start! - NotificationServer* server = new NotificationServer(); - server->Run(); + NotificationServer server; + server.Run(); return 0; } Modified: haiku/trunk/src/servers/notification/NotificationServer.h =================================================================== --- haiku/trunk/src/servers/notification/NotificationServer.h 2011-11-02 14:51:15 UTC (rev 43113) +++ haiku/trunk/src/servers/notification/NotificationServer.h 2011-11-02 14:57:43 UTC (rev 43114) @@ -14,8 +14,8 @@ NotificationServer(); virtual ~NotificationServer(); + virtual void ReadyToRun(); virtual void MessageReceived(BMessage* message); - virtual bool QuitRequested(); virtual status_t GetSupportedSuites(BMessage* msg); virtual BHandler* ResolveSpecifier(BMessage* msg, int32 index, BMessage* spec, Modified: haiku/trunk/src/servers/notification/NotificationView.cpp =================================================================== --- haiku/trunk/src/servers/notification/NotificationView.cpp 2011-11-02 14:51:15 UTC (rev 43113) +++ haiku/trunk/src/servers/notification/NotificationView.cpp 2011-11-02 14:57:43 UTC (rev 43114) @@ -13,28 +13,16 @@ * Adrien Destugues <pulkomandy@xxxxxxxxxxxxxxxxx> */ -#include <stdlib.h> - #include <ControlLook.h> -#include <Font.h> -#include <IconUtils.h> +#include <LayoutUtils.h> #include <Messenger.h> -#include <Picture.h> -#include <PropertyInfo.h> -#include <Region.h> -#include <Resources.h> +#include <Path.h> #include <Roster.h> #include <StatusBar.h> -#include <StringView.h> -#include <TranslationUtils.h> #include "NotificationView.h" #include "NotificationWindow.h" -const char* kSmallIconAttribute = "BEOS:M:STD_ICON"; -const char* kLargeIconAttribute = "BEOS:L:STD_ICON"; -const char* kIconAttribute = "BEOS:ICON"; - static const int kIconStripeWidth = 32; property_info message_prop_list[] = { @@ -55,46 +43,25 @@ NotificationView::NotificationView(NotificationWindow* win, - notification_type type, const char* app, const char* title, const char* text, - BMessage* details) + BNotification* notification, bigtime_t timeout) : - BView(BRect(0, 0, win->ViewWidth(), 1), "NotificationView", - B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE + BView("NotificationView", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS), fParent(win), - fType(type), + fNotification(notification), + fTimeout(timeout), fRunner(NULL), - fProgress(0.0f), - fMessageID(""), - fDetails(details), - fBitmap(NULL), - fIsFirst(false), - fIsLast(false) + fBitmap(NULL) { - BMessage iconMsg; - if (fDetails->FindMessage("icon", &iconMsg) == B_OK) - fBitmap = new BBitmap(&iconMsg); + if (fNotification->Icon() != NULL) + fBitmap = new BBitmap(fNotification->Icon()); - if (!fBitmap) - _LoadIcon(); + if (fTimeout <= 0) + fTimeout = fParent->Timeout() * 1000000; - const char* messageID = NULL; - if (fDetails->FindString("messageID", &messageID) == B_OK) - fMessageID = messageID; + SetText(); - if (fDetails->FindFloat("progress", &fProgress) != B_OK) - fProgress = 0.0f; - - // Progress is between 0 and 1 - if (fProgress < 0.0f) - fProgress = 0.0f; - if (fProgress > 1.0f) - fProgress = 1.0f; - - SetText(app, title, text); - ResizeToPreferred(); - - switch (type) { + switch (fNotification->Type()) { case B_IMPORTANT_NOTIFICATION: SetViewColor(255, 255, 255); SetLowColor(255, 255, 255); @@ -110,18 +77,18 @@ BStatusBar* progress = new BStatusBar(frame, "progress"); progress->SetBarHeight(12.0f); progress->SetMaxValue(1.0f); - progress->Update(fProgress); + progress->Update(fNotification->Progress()); [... truncated: 970 lines follow ...]