Style fixes.

This commit is contained in:
Adrien Destugues 2014-03-06 08:57:12 +01:00
parent 54e1893c41
commit 0009559ca3

View File

@ -62,7 +62,8 @@ GeneralView::GeneralView(SettingsHost* host)
B_TRANSLATE("seconds of inactivity")); B_TRANSLATE("seconds of inactivity"));
// Default position // Default position
// TODO: Here will come a screen representation with the four corners clickable // TODO: Here will come a screen representation with the four corners
// clickable
// Load settings // Load settings
Load(); Load();
@ -105,67 +106,69 @@ void
GeneralView::MessageReceived(BMessage* msg) GeneralView::MessageReceived(BMessage* msg)
{ {
switch (msg->what) { switch (msg->what) {
case kToggleNotifications: { case kToggleNotifications:
entry_ref ref; {
entry_ref ref;
// Check if server is available // Check if server is available
if (!_CanFindServer(&ref)) { if (!_CanFindServer(&ref)) {
BAlert* alert = new BAlert(B_TRANSLATE("Notifications"), BAlert* alert = new BAlert(B_TRANSLATE("Notifications"),
B_TRANSLATE("The notifications server cannot be" B_TRANSLATE("The notifications server cannot be"
" found, this means your InfoPopper installation was" " found, this means your InfoPopper installation was"
" not successfully completed."), B_TRANSLATE("OK"), " not successfully completed."), B_TRANSLATE("OK"),
NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
(void)alert->Go();
return;
}
if (fNotificationBox->Value() == B_CONTROL_OFF) {
// Server team
team_id team = be_roster->TeamFor(kNotificationServerSignature);
// Establish a connection to infopopper_server
status_t ret = B_ERROR;
BMessenger messenger(kNotificationServerSignature, team, &ret);
if (ret != B_OK) {
BAlert* alert = new BAlert(B_TRANSLATE(
"Notifications"), B_TRANSLATE("Notifications "
"cannot be stopped, because the server can't be"
" reached."), B_TRANSLATE("OK"), NULL, NULL,
B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
(void)alert->Go(); (void)alert->Go();
return; return;
} }
if (fNotificationBox->Value() == B_CONTROL_OFF) { // Send quit message
// Server team if (messenger.SendMessage(B_QUIT_REQUESTED) != B_OK) {
team_id team = be_roster->TeamFor(kNotificationServerSignature); BAlert* alert = new BAlert(B_TRANSLATE(
"Notifications"), B_TRANSLATE("Cannot disable"
// Establish a connection to infopopper_server " notifications because the server can't be "
status_t ret = B_ERROR; "reached."), B_TRANSLATE("OK"),
BMessenger messenger(kNotificationServerSignature, team, &ret); NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
if (ret != B_OK) { alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
BAlert* alert = new BAlert(B_TRANSLATE( (void)alert->Go();
"Notifications"), B_TRANSLATE("Notifications " return;
"cannot be stopped, because the server can't be"
" reached."), B_TRANSLATE("OK"), NULL, NULL,
B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
(void)alert->Go();
return;
}
// Send quit message
if (messenger.SendMessage(new BMessage(B_QUIT_REQUESTED)) != B_OK) {
BAlert* alert = new BAlert(B_TRANSLATE(
"Notifications"), B_TRANSLATE("Cannot disable"
" notifications because the server can't be "
"reached."), B_TRANSLATE("OK"),
NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
(void)alert->Go();
return;
}
} else if(!_IsServerRunning()){
// Start server
status_t err = be_roster->Launch(kNotificationServerSignature);
if (err != B_OK) {
BAlert* alert = new BAlert(B_TRANSLATE(
"Notifications"), B_TRANSLATE("Cannot enable"
" notifications because the server cannot be "
"found.\nThis means your InfoPopper installation"
" was not successfully completed."),
B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL,
B_STOP_ALERT);
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
(void)alert->Go();
return;
}
} }
} break; } else if (!_IsServerRunning()) {
// Start server
status_t err = be_roster->Launch(kNotificationServerSignature);
if (err != B_OK) {
BAlert* alert = new BAlert(B_TRANSLATE(
"Notifications"), B_TRANSLATE("Cannot enable"
" notifications because the server cannot be "
"found.\nThis means your InfoPopper installation"
" was not successfully completed."),
B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL,
B_STOP_ALERT);
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
(void)alert->Go();
return;
}
}
break;
}
case kSettingChanged: case kSettingChanged:
SettingsPane::MessageReceived(msg); SettingsPane::MessageReceived(msg);
break; break;