mozilla-libnotify.patch
changeset 417 62102cc5132a
parent 414 88a71e903038
equal deleted inserted replaced
416:72a48d628998 417:62102cc5132a
     1 # HG changeset patch
     1 # HG changeset patch
     2 # User Wolfgang Rosenauer <wr@rosenauer.org>
     2 # User Wolfgang Rosenauer <wr@rosenauer.org>
     3 # Parent 629ea8797e7393eb6e9add489db2c5636516b305
     3 # Parent c684863b1eb3bcae92ef24bc2ac511985b1ad7e4
     4 Bug 737646 - no biff notification if notification-daemon not running
     4 Bug 737646 - no biff notification if notification-daemon not running
     5 
     5 
     6 diff --git a/toolkit/system/gnome/nsAlertsIconListener.cpp b/toolkit/system/gnome/nsAlertsIconListener.cpp
     6 diff --git a/toolkit/system/gnome/nsAlertsIconListener.cpp b/toolkit/system/gnome/nsAlertsIconListener.cpp
     7 --- a/toolkit/system/gnome/nsAlertsIconListener.cpp
     7 --- a/toolkit/system/gnome/nsAlertsIconListener.cpp
     8 +++ b/toolkit/system/gnome/nsAlertsIconListener.cpp
     8 +++ b/toolkit/system/gnome/nsAlertsIconListener.cpp
     9 @@ -346,16 +346,21 @@ nsAlertsIconListener::InitAlertAsync(con
     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;
    10        for (GList* cap = server_caps; cap != NULL; cap = cap->next) {
    37        for (GList* cap = server_caps; cap != NULL; cap = cap->next) {
    11          if (!strcmp((char*) cap->data, "actions")) {
    38          if (!strcmp((char*) cap->data, "actions")) {
    12            gHasActions = true;
    39            gHasActions = true;
    13            break;
    40            break;
    14          }
    41          }
    15        }
    42        }
    16        g_list_foreach(server_caps, (GFunc)g_free, NULL);
    43        g_list_foreach(server_caps, (GFunc)g_free, NULL);
    17        g_list_free(server_caps);
    44        g_list_free(server_caps);
    18 +    } else {
       
    19 +      // notify_get_server_caps() is expected to return something
       
    20 +      // otherwise we need to assume there is no notification-server
       
    21 +      // to display anything
       
    22 +      return NS_ERROR_FAILURE;
       
    23      }
    45      }
    24    }
    46    }
    25  
    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 +
    26    if (!gHasActions && aAlertTextClickable)
    54    if (!gHasActions && aAlertTextClickable)
    27      return NS_ERROR_FAILURE; // No good, fallback to XUL
    55      return NS_ERROR_FAILURE; // No good, fallback to XUL
    28  
    56  
    29    nsCOMPtr<nsIObserverService> obsServ =
    57    nsCOMPtr<nsIObserverService> obsServ =
    30        do_GetService("@mozilla.org/observer-service;1");
    58        do_GetService("@mozilla.org/observer-service;1");
       
    59    if (obsServ)
       
    60      obsServ->AddObserver(this, "quit-application", true);
       
    61