From 053e02b45fae9d04d068a4b1a62ba5ed40a229c7 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Fri, 7 Nov 2014 16:40:14 +0100 Subject: [PATCH] Notifications: make "enable on startup" work. Fixes #9425. --- src/preferences/notifications/GeneralView.cpp | 50 ------------------- .../notification/NotificationWindow.cpp | 7 +++ 2 files changed, 7 insertions(+), 50 deletions(-) diff --git a/src/preferences/notifications/GeneralView.cpp b/src/preferences/notifications/GeneralView.cpp index d570afc10c..50ca791858 100644 --- a/src/preferences/notifications/GeneralView.cpp +++ b/src/preferences/notifications/GeneralView.cpp @@ -207,56 +207,6 @@ GeneralView::Save(BMessage& settings) int32 timeout = atol(fTimeout->Text()); settings.AddInt32(kTimeoutName, timeout); - // Find server path - entry_ref ref; - if (!_CanFindServer(&ref)) { - BAlert* alert = new BAlert("", - B_TRANSLATE("The notifications server cannot be found.\n" - "A possible cause is an installation not done correctly"), - B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); - (void)alert->Go(); - return B_ERROR; - } - - // UserBootscript command - BPath serverPath(&ref); - - // Start server at boot time - BPath path; - status_t ret = find_directory(B_USER_SETTINGS_DIRECTORY, &path, true); - if (ret != B_OK) { - BAlert* alert = new BAlert("", - B_TRANSLATE("Can't save preferences, you probably don't have " - "write access to the settings directory."), B_TRANSLATE("OK"), - NULL, NULL, - B_WIDTH_AS_USUAL, B_STOP_ALERT); - alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); - (void)alert->Go(); - return ret; - } - - path.Append("boot/launch"); - BDirectory directory(path.Path()); - BEntry entry(&directory, serverPath.Leaf()); - - // Remove symbolic link - entry.Remove(); - - if (autoStart) { - // Put a symlink into ~/config/boot/launch - if ((ret = directory.CreateSymLink(serverPath.Leaf(), - serverPath.Path(), NULL) != B_OK)) { - BAlert* alert = new BAlert("", - B_TRANSLATE("Can't enable notifications at startup time, " - "you probably don't have write permission to the boot settings" - " directory."), B_TRANSLATE("OK"), NULL, NULL, - B_WIDTH_AS_USUAL, B_STOP_ALERT); - alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); - (void)alert->Go(); - return ret; - } - } - return B_OK; } diff --git a/src/servers/notification/NotificationWindow.cpp b/src/servers/notification/NotificationWindow.cpp index 6a37db25b1..07fea0a235 100644 --- a/src/servers/notification/NotificationWindow.cpp +++ b/src/servers/notification/NotificationWindow.cpp @@ -457,6 +457,13 @@ NotificationWindow::_LoadAppFilters(BMessage& settings) void NotificationWindow::_LoadGeneralSettings(BMessage& settings) { + bool shouldRun; + if (settings.FindBool(kAutoStartName, &shouldRun) == B_OK) { + if (shouldRun == false) { + // We should not start. Quit the app! + be_app_messenger.SendMessage(B_QUIT_REQUESTED); + } + } if (settings.FindInt32(kTimeoutName, &fTimeout) != B_OK) fTimeout = kDefaultTimeout;