1 # HG changeset patch |
|
2 # User Wolfgang Rosenauer <wr@rosenauer.org> |
|
3 # Parent c684863b1eb3bcae92ef24bc2ac511985b1ad7e4 |
|
4 Bug 737646 - no biff notification if notification-daemon not running |
|
5 |
|
6 diff --git a/toolkit/system/gnome/nsAlertsIconListener.cpp b/toolkit/system/gnome/nsAlertsIconListener.cpp |
|
7 --- a/toolkit/system/gnome/nsAlertsIconListener.cpp |
|
8 +++ b/toolkit/system/gnome/nsAlertsIconListener.cpp |
|
9 @@ -47,16 +47,17 @@ |
|
10 #include <gdk/gdk.h> |
|
11 |
|
12 // Compatibility macro for <libnotify-0.7 |
|
13 #ifndef NOTIFY_CHECK_VERSION |
|
14 #define NOTIFY_CHECK_VERSION(x,y,z) 0 |
|
15 #endif |
|
16 |
|
17 static bool gHasActions = false; |
|
18 +static bool gHasCaps = false; |
|
19 |
|
20 static void notify_action_cb(NotifyNotification *notification, |
|
21 gchar *action, gpointer user_data) |
|
22 { |
|
23 nsAlertsIconListener* alert = static_cast<nsAlertsIconListener*> (user_data); |
|
24 alert->SendCallback(); |
|
25 } |
|
26 |
|
27 @@ -338,27 +339,34 @@ nsAlertsIconListener::InitAlertAsync(con |
|
28 appShortName.AssignLiteral("Mozilla"); |
|
29 } |
|
30 |
|
31 if (!notify_init(appShortName.get())) |
|
32 return NS_ERROR_FAILURE; |
|
33 |
|
34 GList *server_caps = notify_get_server_caps(); |
|
35 if (server_caps) { |
|
36 + gHasCaps = true; |
|
37 for (GList* cap = server_caps; cap != NULL; cap = cap->next) { |
|
38 if (!strcmp((char*) cap->data, "actions")) { |
|
39 gHasActions = true; |
|
40 break; |
|
41 } |
|
42 } |
|
43 g_list_foreach(server_caps, (GFunc)g_free, NULL); |
|
44 g_list_free(server_caps); |
|
45 } |
|
46 } |
|
47 |
|
48 + if (!gHasCaps) { |
|
49 + // if notify_get_server_caps() failed above we need to assume |
|
50 + // there is no notification-server to display anything |
|
51 + return NS_ERROR_FAILURE; |
|
52 + } |
|
53 + |
|
54 if (!gHasActions && aAlertTextClickable) |
|
55 return NS_ERROR_FAILURE; // No good, fallback to XUL |
|
56 |
|
57 nsCOMPtr<nsIObserverService> obsServ = |
|
58 do_GetService("@mozilla.org/observer-service;1"); |
|
59 if (obsServ) |
|
60 obsServ->AddObserver(this, "quit-application", true); |
|
61 |
|