Notifications: make "enable on startup" work.

Fixes #9425.
This commit is contained in:
Adrien Destugues
2014-11-07 16:40:14 +01:00
parent c6e1228c8e
commit 053e02b45f
2 changed files with 7 additions and 50 deletions
@@ -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;
}
@@ -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;