From b8b3819fadc3fb733717cfcbc3883460208d1248 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Sat, 25 Aug 2012 08:54:16 +0200 Subject: [PATCH] Bug 783765 - Use libnotify as a dynamic library. r=glandium --- config/system-headers | 1 - configure.in | 42 +-------------- js/src/config/system-headers | 1 - toolkit/system/gnome/Makefile.in | 17 +++---- toolkit/system/gnome/nsAlertsIconListener.cpp | 51 ++++++++++++++----- toolkit/system/gnome/nsAlertsIconListener.h | 27 +++++++++- toolkit/system/gnome/nsGnomeModule.cpp | 8 --- 7 files changed, 71 insertions(+), 76 deletions(-) diff --git a/config/system-headers b/config/system-headers index 55fa60c83e1b..f4917c72e046 100644 --- a/config/system-headers +++ b/config/system-headers @@ -404,7 +404,6 @@ libgnomevfs/gnome-vfs-mime-utils.h libgnomevfs/gnome-vfs-ops.h libgnomevfs/gnome-vfs-standard-callbacks.h lib$routines.h -libnotify/notify.h limits limits.h link.h diff --git a/configure.in b/configure.in index 4f86389c9f54..5bc7ad7514a1 100644 --- a/configure.in +++ b/configure.in @@ -74,7 +74,6 @@ GIO_VERSION=2.18 STARTUP_NOTIFICATION_VERSION=0.8 DBUS_VERSION=0.60 SQLITE_VERSION=3.7.13 -LIBNOTIFY_VERSION=0.4 MSMANIFEST_TOOL= @@ -4929,51 +4928,12 @@ AC_SUBST(MOZ_LIBPROXY_CFLAGS) AC_SUBST(MOZ_LIBPROXY_LIBS) dnl ======================================================== -dnl = libnotify support +dnl = GNOME component (mozgnome) dnl ======================================================== 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 - if test "$MOZ_ENABLE_GTK2" - then - if test "$MOZ_ENABLE_LIBNOTIFY" - then - PKG_CHECK_MODULES(MOZ_LIBNOTIFY, libnotify >= $LIBNOTIFY_VERSION) - fi - fi -fi -AC_SUBST(MOZ_ENABLE_LIBNOTIFY) -AC_SUBST(MOZ_LIBNOTIFY_CFLAGS) -AC_SUBST(MOZ_LIBNOTIFY_LIBS) - -dnl ======================================================== -dnl = GNOME component (mozgnome) -dnl ======================================================== - -# The GNOME component is built if one of -# gnome-vfs, gio, gconf or libnotify is available. -if test "$MOZ_ENABLE_GCONF" -o \ - "$MOZ_ENABLE_GNOMEVFS" -o \ - "$MOZ_ENABLE_GIO" -o \ - "$MOZ_ENABLE_LIBNOTIFY"; then MOZ_ENABLE_GNOME_COMPONENT=1 -else - MOZ_ENABLE_GNOME_COMPONENT= fi AC_SUBST(MOZ_ENABLE_GNOME_COMPONENT) diff --git a/js/src/config/system-headers b/js/src/config/system-headers index 55fa60c83e1b..f4917c72e046 100644 --- a/js/src/config/system-headers +++ b/js/src/config/system-headers @@ -404,7 +404,6 @@ libgnomevfs/gnome-vfs-mime-utils.h libgnomevfs/gnome-vfs-ops.h libgnomevfs/gnome-vfs-standard-callbacks.h lib$routines.h -libnotify/notify.h limits limits.h link.h diff --git a/toolkit/system/gnome/Makefile.in b/toolkit/system/gnome/Makefile.in index cd2712c22caa..4b96165e3fbc 100644 --- a/toolkit/system/gnome/Makefile.in +++ b/toolkit/system/gnome/Makefile.in @@ -15,8 +15,12 @@ FORCE_SHARED_LIB = 1 IS_COMPONENT = 1 -CPPSRCS = nsGnomeModule.cpp - +CPPSRCS = \ + nsGnomeModule.cpp \ + nsAlertsService.cpp \ + nsAlertsIconListener.cpp \ + $(NULL) + ifdef MOZ_ENABLE_GCONF CPPSRCS += \ nsGConfService.cpp \ @@ -36,13 +40,6 @@ CPPSRCS += \ $(NULL) endif -ifdef MOZ_ENABLE_LIBNOTIFY -CPPSRCS += \ - nsAlertsService.cpp \ - nsAlertsIconListener.cpp \ - $(NULL) -endif - EXTRA_DSO_LDOPTS += \ $(XPCOM_GLUE_LDOPTS) \ $(XPCOM_FROZEN_LDOPTS) \ @@ -50,7 +47,6 @@ EXTRA_DSO_LDOPTS += \ $(MOZ_GCONF_LIBS) \ $(MOZ_GNOMEVFS_LIBS) \ $(GLIB_LIBS) \ - $(MOZ_LIBNOTIFY_LIBS) \ $(MOZ_GIO_LIBS) \ $(NULL) @@ -63,6 +59,5 @@ CXXFLAGS += \ $(MOZ_GNOMEVFS_CFLAGS) \ $(MOZ_GIO_CFLAGS) \ $(GLIB_CFLAGS) \ - $(MOZ_LIBNOTIFY_CFLAGS) \ $(MOZ_GTK2_CFLAGS) \ $(NULL) diff --git a/toolkit/system/gnome/nsAlertsIconListener.cpp b/toolkit/system/gnome/nsAlertsIconListener.cpp index c6c39aa2fe64..bfc43d17aaa6 100644 --- a/toolkit/system/gnome/nsAlertsIconListener.cpp +++ b/toolkit/system/gnome/nsAlertsIconListener.cpp @@ -13,16 +13,22 @@ #include "nsIObserverService.h" #include "nsCRT.h" +#include #include -// Compatibility macro for CancelAndForgetObserver(NS_BINDING_ABORTED); + // Don't dlclose libnotify as it uses atexit(). } NS_IMETHODIMP @@ -185,14 +214,7 @@ nsAlertsIconListener::OnStopFrame(imgIRequest* aRequest, nsresult nsAlertsIconListener::ShowAlert(GdkPixbuf* aPixbuf) { - mNotification = notify_notification_new(mAlertTitle.get(), - mAlertText.get(), - NULL -// >=libnotify-0.7.0 has no support for attaching to widgets -#if !NOTIFY_CHECK_VERSION(0,7,0) - , NULL -#endif - ); + mNotification = notify_notification_new(mAlertTitle.get(), mAlertText.get(), NULL, NULL); if (!mNotification) return NS_ERROR_OUT_OF_MEMORY; @@ -284,6 +306,9 @@ nsAlertsIconListener::InitAlertAsync(const nsAString & aImageUrl, const nsAString & aAlertCookie, nsIObserver * aAlertListener) { + if (!libNotifyHandle) + return NS_ERROR_FAILURE; + if (!notify_is_initted()) { // Give the name of this application to libnotify nsCOMPtr bundleService = diff --git a/toolkit/system/gnome/nsAlertsIconListener.h b/toolkit/system/gnome/nsAlertsIconListener.h index bdb76160724a..8f0b9443e947 100644 --- a/toolkit/system/gnome/nsAlertsIconListener.h +++ b/toolkit/system/gnome/nsAlertsIconListener.h @@ -13,10 +13,11 @@ #include "nsWeakReference.h" #include -#include class imgIRequest; +struct NotifyNotification; + class nsAlertsIconListener : public imgIDecoderObserver, public nsIObserver, public nsSupportsWeakReference @@ -41,6 +42,21 @@ public: void SendClosed(); protected: + /** + * The only difference between libnotify.so.4 and libnotify.so.1 for these symbols + * is that notify_notification_new takes three arguments in libnotify.so.4 and + * four in libnotify.so.1. + * Passing the fourth argument as NULL is binary compatible. + */ + typedef void (*NotifyActionCallback)(NotifyNotification*, char*, gpointer); + typedef bool (*notify_is_initted_t)(void); + typedef bool (*notify_init_t)(const char*); + typedef GList* (*notify_get_server_caps_t)(void); + typedef NotifyNotification* (*notify_notification_new_t)(const char*, const char*, const char*, const char*); + typedef bool (*notify_notification_show_t)(void*, char*); + typedef void (*notify_notification_set_icon_from_pixbuf_t)(void*, GdkPixbuf*); + typedef void (*notify_notification_add_action_t)(void*, const char*, const char*, NotifyActionCallback, gpointer, GFreeFunc); + nsCOMPtr mIconRequest; nsCString mAlertTitle; nsCString mAlertText; @@ -51,6 +67,15 @@ protected: bool mLoadedFrame; bool mAlertHasAction; + static void* libNotifyHandle; + static bool libNotifyNotAvail; + static notify_is_initted_t notify_is_initted; + static notify_init_t notify_init; + static notify_get_server_caps_t notify_get_server_caps; + static notify_notification_new_t notify_notification_new; + static notify_notification_show_t notify_notification_show; + static notify_notification_set_icon_from_pixbuf_t notify_notification_set_icon_from_pixbuf; + static notify_notification_add_action_t notify_notification_add_action; NotifyNotification* mNotification; gulong mClosureHandler; diff --git a/toolkit/system/gnome/nsGnomeModule.cpp b/toolkit/system/gnome/nsGnomeModule.cpp index f3159d436b35..9e7d7c146cf7 100644 --- a/toolkit/system/gnome/nsGnomeModule.cpp +++ b/toolkit/system/gnome/nsGnomeModule.cpp @@ -22,10 +22,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGnomeVFSService, Init) NS_GENERIC_FACTORY_CONSTRUCTOR(nsGIOService) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGSettingsService, Init) #endif -#ifdef MOZ_ENABLE_LIBNOTIFY #include "nsAlertsService.h" NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAlertsService, Init) -#endif #ifdef MOZ_ENABLE_GCONF NS_DEFINE_NAMED_CID(NS_GCONFSERVICE_CID); @@ -37,9 +35,7 @@ NS_DEFINE_NAMED_CID(NS_GNOMEVFSSERVICE_CID); NS_DEFINE_NAMED_CID(NS_GIOSERVICE_CID); NS_DEFINE_NAMED_CID(NS_GSETTINGSSERVICE_CID); #endif -#ifdef MOZ_ENABLE_LIBNOTIFY NS_DEFINE_NAMED_CID(NS_SYSTEMALERTSSERVICE_CID); -#endif static const mozilla::Module::CIDEntry kGnomeCIDs[] = { @@ -53,9 +49,7 @@ static const mozilla::Module::CIDEntry kGnomeCIDs[] = { { &kNS_GIOSERVICE_CID, false, NULL, nsGIOServiceConstructor }, { &kNS_GSETTINGSSERVICE_CID, false, NULL, nsGSettingsServiceConstructor }, #endif -#ifdef MOZ_ENABLE_LIBNOTIFY { &kNS_SYSTEMALERTSSERVICE_CID, false, NULL, nsAlertsServiceConstructor }, -#endif { NULL } }; @@ -70,9 +64,7 @@ static const mozilla::Module::ContractIDEntry kGnomeContracts[] = { { NS_GIOSERVICE_CONTRACTID, &kNS_GIOSERVICE_CID }, { NS_GSETTINGSSERVICE_CONTRACTID, &kNS_GSETTINGSSERVICE_CID }, #endif -#ifdef MOZ_ENABLE_LIBNOTIFY { NS_SYSTEMALERTSERVICE_CONTRACTID, &kNS_SYSTEMALERTSSERVICE_CID }, -#endif { NULL } };