Backed out changeset 99cdecb3734f
authorDão Gottwald <dao@mozilla.com>
Mon, 04 May 2009 10:23:25 +0200
changeset 27967 af694bc8771e687231cd2f26834a92dfa4b802cc
parent 27966 99cdecb3734f171f0480c6fa4b0f5cf20f6f5260
child 27968 c2ba27e9e639eeeae9b54bf5a436e78777ee906e
push id6811
push userdgottwald@mozilla.com
push dateMon, 04 May 2009 08:23:54 +0000
treeherdermozilla-central@af694bc8771e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.2a1pre
backs out99cdecb3734f171f0480c6fa4b0f5cf20f6f5260
Backed out changeset 99cdecb3734f
configure.in
toolkit/components/alerts/Makefile.in
toolkit/components/alerts/src/nsAlertsService.cpp
toolkit/components/alerts/test/Makefile.in
toolkit/components/alerts/test/test_alerts.html
toolkit/system/gnome/Makefile.in
toolkit/system/gnome/nsAlertsIconListener.cpp
toolkit/system/gnome/nsAlertsIconListener.h
toolkit/system/gnome/nsAlertsService.cpp
--- a/configure.in
+++ b/configure.in
@@ -5277,25 +5277,23 @@ fi
 AC_SUBST(MOZ_ENABLE_DBUS)
 AC_SUBST(MOZ_DBUS_GLIB_CFLAGS)
 AC_SUBST(MOZ_DBUS_GLIB_LIBS)
 
 dnl ========================================================
 dnl = libnotify support
 dnl ========================================================
 
+MOZ_ARG_ENABLE_BOOL(libnotify,
+[  --enable-libnotify       Enable libnotify support ],
+    MOZ_ENABLE_LIBNOTIFY=1,
+    MOZ_ENABLE_LIBNOTIFY=)
+
 if test "$MOZ_ENABLE_GTK2"
 then
-    MOZ_ENABLE_LIBNOTIFY=1
-
-    MOZ_ARG_DISABLE_BOOL(libnotify,
-    [  --disable-libnotify       Disable libnotify support ],
-    MOZ_ENABLE_LIBNOTIFY=,
-    MOZ_ENABLE_LIBNOTIFY=1)
-
     if test "$MOZ_ENABLE_LIBNOTIFY"
     then
         AC_DEFINE(MOZ_ENABLE_LIBNOTIFY)
     fi
 fi
 
 if test -z "$SKIP_LIBRARY_CHECKS"
 then
--- a/toolkit/components/alerts/Makefile.in
+++ b/toolkit/components/alerts/Makefile.in
@@ -52,14 +52,10 @@ endif
 ifneq (,$(filter cocoa, $(MOZ_WIDGET_TOOLKIT)))
 # src/mac/growl needs to be first for linking to work!
 DIRS += \
   src/mac/growl \
   src/mac \
   $(NULL)
 endif
 
-ifdef ENABLE_TESTS
-DIRS  += test
-endif
-
 include $(topsrcdir)/config/rules.mk
 
--- a/toolkit/components/alerts/src/nsAlertsService.cpp
+++ b/toolkit/components/alerts/src/nsAlertsService.cpp
@@ -71,26 +71,23 @@ nsAlertsService::~nsAlertsService()
 NS_IMETHODIMP nsAlertsService::ShowAlertNotification(const nsAString & aImageUrl, const nsAString & aAlertTitle, 
                                                      const nsAString & aAlertText, PRBool aAlertTextClickable,
                                                      const nsAString & aAlertCookie,
                                                      nsIObserver * aAlertListener,
                                                      const nsAString & aAlertName)
 {
   // Check if there is an optional service that handles system-level notifications
   nsCOMPtr<nsIAlertsService> sysAlerts(do_GetService(NS_SYSTEMALERTSERVICE_CONTRACTID));
-  nsresult rv;
-  if (sysAlerts) {
-    rv = sysAlerts->ShowAlertNotification(aImageUrl, aAlertTitle, aAlertText, aAlertTextClickable,
-                                          aAlertCookie, aAlertListener, aAlertName);
-    if (NS_SUCCEEDED(rv))
-      return rv;
-  }
+  if (sysAlerts)
+    return sysAlerts->ShowAlertNotification(aImageUrl, aAlertTitle, aAlertText, aAlertTextClickable,
+                                            aAlertCookie, aAlertListener, aAlertName);
 
   nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
   nsCOMPtr<nsIDOMWindow> newWindow;
+  nsresult rv;
 
   nsCOMPtr<nsISupportsArray> argsArray;
   rv = NS_NewISupportsArray(getter_AddRefs(argsArray));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // create scriptable versions of our strings that we can store in our nsISupportsArray....
   nsCOMPtr<nsISupportsString> scriptableImageUrl (do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
   NS_ENSURE_TRUE(scriptableImageUrl, NS_ERROR_FAILURE);
deleted file mode 100644
--- a/toolkit/components/alerts/test/Makefile.in
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Mozilla Corporation.
-# Portions created by the Initial Developer are Copyright (C) 2009
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-DEPTH   = ../../../..
-topsrcdir = @top_srcdir@
-srcdir    = @srcdir@
-VPATH   = @srcdir@
-relativesrcdir  = toolkit/components/alerts/test
-
-include $(DEPTH)/config/autoconf.mk
-
-# Mochitest tests
-MOCHI_TESTS = \
-		test_alerts.html \
-		$(NULL)
-
-
-include $(topsrcdir)/config/rules.mk
-
-libs:: $(MOCHI_TESTS)
-	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
deleted file mode 100644
--- a/toolkit/components/alerts/test/test_alerts.html
+++ /dev/null
@@ -1,48 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for Alerts Service</title>
-  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<p id="display"></p>
-
-Alerts service mochitest<br/>
-
-Did an alert appear anywhere?<br/>
-If so, the test will finish once the alert disappears. If not, the test will time out.<br/>
-
-<pre id="test">
-<script class="testbody" type="text/javascript">
-netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
-var observer = {
-  observe: function (aSubject, aTopic, aData) {
-    if (aTopic != "alertclickcallback") // Did someone click the alert while running mochitests?...
-      is(aTopic, "alertfinished", "Checking the topic for a finished notification");
-
-    is(aData, "foobarcookie", "Checking whether the alert cookie was passed correctly");
-    SimpleTest.finish();
-  }
-};
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-try {
-  var notifier = Cc["@mozilla.org/alerts-service;1"].
-                 getService(Ci.nsIAlertsService);
-  notifier.showAlertNotification(null, "Notification test", "Surprise! I'm here to test notifications!",
-                                 false, "foobarcookie", observer);
-
-  SimpleTest.waitForExplicitFinish();
-} catch (ex) {
-  // Alerts service doesn't exist
-}
-
-</script>
-</pre>
-</body>
-</html>
-
--- a/toolkit/system/gnome/Makefile.in
+++ b/toolkit/system/gnome/Makefile.in
@@ -51,18 +51,16 @@ REQUIRES = \
 	xpcom \
 	string \
 	necko \
 	alerts \
 	gfx \
 	imglib2 \
 	intl \
 	widget \
-	thebes \
-	cairo \
 	$(NULL)
 
 CPPSRCS = \
 	nsGConfService.cpp \
 	nsGnomeVFSService.cpp \
 	nsGnomeModule.cpp \
 	$(NULL)
 
--- a/toolkit/system/gnome/nsAlertsIconListener.cpp
+++ b/toolkit/system/gnome/nsAlertsIconListener.cpp
@@ -41,36 +41,16 @@
 #include "gfxIImageFrame.h"
 #include "nsIImage.h"
 #include "nsNetUtil.h"
 #include "nsIImageToPixbuf.h"
 #include "nsIStringBundle.h"
 
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <libnotify/notify.h>
-#include <gdk/gdk.h>
-
-static PRBool gHasActions = PR_FALSE;
-
-static void notify_action_cb(NotifyNotification *notification,
-                             gchar *action, gpointer user_data)
-{
-  nsAlertsIconListener* alert = static_cast<nsAlertsIconListener*> (user_data);
-  alert->SendCallback();
-}
-
-static void notify_closed_cb(NotifyNotification *notification,
-                             gpointer user_data)
-{
-  g_object_unref(notification);
-
-  nsAlertsIconListener* alert = static_cast<nsAlertsIconListener*> (user_data);
-  alert->SendClosed();
-  NS_RELEASE(alert);
-}
 
 NS_IMPL_ISUPPORTS2(nsAlertsIconListener, imgIContainerObserver, imgIDecoderObserver)
 
 nsAlertsIconListener::nsAlertsIconListener()
 : mLoadedFrame(PR_FALSE)
 {
   MOZ_COUNT_CTOR(nsAlertsIconListener);
 }
@@ -208,27 +188,19 @@ nsAlertsIconListener::ShowAlert(GdkPixbu
                                                        mAlertText.get(),
                                                        NULL, NULL);
   if (!notify)
     return NS_ERROR_OUT_OF_MEMORY;
 
   if (aPixbuf)
     notify_notification_set_icon_from_pixbuf(notify, aPixbuf);
 
-  NS_ADDREF(this);
-  if (mAlertHasAction) {
-    // What we put as the label doesn't matter here, if the action
-    // string is "default" then that makes the entire bubble clickable
-    // rather than creating a button.
-    notify_notification_add_action(notify, "default", "Activate",
-                                   notify_action_cb, this, NULL);
-  }
-
-  g_signal_connect(notify, "closed", G_CALLBACK(notify_closed_cb), this);
+  notify_notification_set_timeout(notify, NOTIFY_EXPIRES_DEFAULT);
   gboolean result = notify_notification_show(notify, NULL);
+  g_object_unref(notify);
 
   return result ? NS_OK : NS_ERROR_FAILURE;
 }
 
 nsresult
 nsAlertsIconListener::StartRequest(const nsAString & aImageUrl)
 {
   if (mIconRequest) {
@@ -246,35 +218,20 @@ nsAlertsIconListener::StartRequest(const
   if (!il)
     return ShowAlert(NULL);
 
   return il->LoadImage(imageUri, nsnull, nsnull, nsnull, this,
                        nsnull, nsIRequest::LOAD_NORMAL, nsnull, nsnull,
                        getter_AddRefs(mIconRequest));
 }
 
-void
-nsAlertsIconListener::SendCallback()
-{
-  mAlertListener->Observe(NULL, "alertclickcallback", mAlertCookie.get());
-}
-
-void
-nsAlertsIconListener::SendClosed()
-{
-  mAlertListener->Observe(NULL, "alertfinished", mAlertCookie.get());
-}
-
 nsresult
 nsAlertsIconListener::InitAlertAsync(const nsAString & aImageUrl,
                                      const nsAString & aAlertTitle, 
-                                     const nsAString & aAlertText,
-                                     PRBool aAlertTextClickable,
-                                     const nsAString & aAlertCookie,
-                                     nsIObserver * aAlertListener)
+                                     const nsAString & aAlertText)
 {
   if (!notify_is_initted()) {
     // Give the name of this application to libnotify
     nsCOMPtr<nsIStringBundleService> bundleService = 
       do_GetService(NS_STRINGBUNDLE_CONTRACTID);
 
     nsCAutoString appShortName;
     if (bundleService) {
@@ -292,35 +249,15 @@ nsAlertsIconListener::InitAlertAsync(con
         appShortName.AssignLiteral("Mozilla");
       }
     } else {
       appShortName.AssignLiteral("Mozilla");
     }
 
     if (!notify_init(appShortName.get()))
       return NS_ERROR_FAILURE;
-
-    GList *server_caps = notify_get_server_caps();
-    if (server_caps) {
-      for (GList* cap = server_caps; cap != NULL; cap = cap->next) {
-        if (!strcmp((char*) cap->data, "actions")) {
-          gHasActions = PR_TRUE;
-          break;
-        }
-      }
-      g_list_foreach(server_caps, (GFunc)g_free, NULL);
-      g_list_free(server_caps);
-    }
   }
 
-  if (!gHasActions && aAlertTextClickable)
-    return NS_ERROR_FAILURE; // No good, fallback to XUL
-
   mAlertTitle = NS_ConvertUTF16toUTF8(aAlertTitle);
   mAlertText = NS_ConvertUTF16toUTF8(aAlertText);
 
-  mAlertHasAction = aAlertTextClickable;
-
-  mAlertListener = aAlertListener;
-  mAlertCookie = aAlertCookie;
-
   return StartRequest(aImageUrl);
 }
--- a/toolkit/system/gnome/nsAlertsIconListener.h
+++ b/toolkit/system/gnome/nsAlertsIconListener.h
@@ -36,17 +36,16 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsAlertsIconListener_h__
 #define nsAlertsIconListener_h__
 
 #include "nsCOMPtr.h"
 #include "imgIDecoderObserver.h"
 #include "nsStringAPI.h"
-#include "nsIObserver.h"
 
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
 class imgIRequest;
 
 class nsAlertsIconListener : public imgIDecoderObserver
 {
 public:
@@ -54,32 +53,22 @@ public:
   NS_DECL_IMGICONTAINEROBSERVER
   NS_DECL_IMGIDECODEROBSERVER
 
   nsAlertsIconListener();
   virtual ~nsAlertsIconListener();
 
   nsresult InitAlertAsync(const nsAString & aImageUrl,
                           const nsAString & aAlertTitle, 
-                          const nsAString & aAlertText,
-                          PRBool aAlertTextClickable,
-                          const nsAString & aAlertCookie,
-                          nsIObserver * aAlertListener);
-
-  void SendCallback();
-  void SendClosed();
+                          const nsAString & aAlertText);
 
 protected:
   nsCOMPtr<imgIRequest> mIconRequest;
   nsCString mAlertTitle;
   nsCString mAlertText;
 
-  nsCOMPtr<nsIObserver> mAlertListener;
-  nsString mAlertCookie;
-
   PRPackedBool mLoadedFrame;
-  PRPackedBool mAlertHasAction;
 
   nsresult StartRequest(const nsAString & aImageUrl);
   nsresult ShowAlert(GdkPixbuf* aPixbuf);
 };
 
 #endif
--- a/toolkit/system/gnome/nsAlertsService.cpp
+++ b/toolkit/system/gnome/nsAlertsService.cpp
@@ -63,11 +63,10 @@ NS_IMETHODIMP nsAlertsService::ShowAlert
                                                      const nsAString & aAlertCookie,
                                                      nsIObserver * aAlertListener,
                                                      const nsAString & aAlertName)
 {
   nsCOMPtr<nsAlertsIconListener> alertListener = new nsAlertsIconListener();
   if (!alertListener)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  return alertListener->InitAlertAsync(aImageUrl, aAlertTitle, aAlertText, aAlertTextClickable,
-                                       aAlertCookie, aAlertListener);
+  return alertListener->InitAlertAsync(aImageUrl, aAlertTitle, aAlertText);
 }