mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 783765 - Use libnotify as a dynamic library. r=glandium
This commit is contained in:
parent
39238f1ffb
commit
b8b3819fad
@ -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
|
||||
|
42
configure.in
42
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)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -13,16 +13,22 @@
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
// Compatibility macro for <libnotify-0.7
|
||||
#ifndef NOTIFY_CHECK_VERSION
|
||||
#define NOTIFY_CHECK_VERSION(x,y,z) 0
|
||||
#endif
|
||||
|
||||
static bool gHasActions = false;
|
||||
static bool gHasCaps = false;
|
||||
|
||||
void* nsAlertsIconListener::libNotifyHandle = nullptr;
|
||||
bool nsAlertsIconListener::libNotifyNotAvail = false;
|
||||
nsAlertsIconListener::notify_is_initted_t nsAlertsIconListener::notify_is_initted = nullptr;
|
||||
nsAlertsIconListener::notify_init_t nsAlertsIconListener::notify_init = nullptr;
|
||||
nsAlertsIconListener::notify_get_server_caps_t nsAlertsIconListener::notify_get_server_caps = nullptr;
|
||||
nsAlertsIconListener::notify_notification_new_t nsAlertsIconListener::notify_notification_new = nullptr;
|
||||
nsAlertsIconListener::notify_notification_show_t nsAlertsIconListener::notify_notification_show = nullptr;
|
||||
nsAlertsIconListener::notify_notification_set_icon_from_pixbuf_t nsAlertsIconListener::notify_notification_set_icon_from_pixbuf = nullptr;
|
||||
nsAlertsIconListener::notify_notification_add_action_t nsAlertsIconListener::notify_notification_add_action = nullptr;
|
||||
|
||||
static void notify_action_cb(NotifyNotification *notification,
|
||||
gchar *action, gpointer user_data)
|
||||
{
|
||||
@ -52,12 +58,35 @@ nsAlertsIconListener::nsAlertsIconListener()
|
||||
: mLoadedFrame(false),
|
||||
mNotification(NULL)
|
||||
{
|
||||
if (!libNotifyHandle && !libNotifyNotAvail) {
|
||||
libNotifyHandle = dlopen("libnotify.so.4", RTLD_LAZY);
|
||||
if (!libNotifyHandle) {
|
||||
libNotifyHandle = dlopen("libnotify.so.1", RTLD_LAZY);
|
||||
if (!libNotifyHandle) {
|
||||
libNotifyNotAvail = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
notify_is_initted = (notify_is_initted_t)dlsym(libNotifyHandle, "notify_is_initted");
|
||||
notify_init = (notify_init_t)dlsym(libNotifyHandle, "notify_init");
|
||||
notify_get_server_caps = (notify_get_server_caps_t)dlsym(libNotifyHandle, "notify_get_server_caps");
|
||||
notify_notification_new = (notify_notification_new_t)dlsym(libNotifyHandle, "notify_notification_new");
|
||||
notify_notification_show = (notify_notification_show_t)dlsym(libNotifyHandle, "notify_notification_show");
|
||||
notify_notification_set_icon_from_pixbuf = (notify_notification_set_icon_from_pixbuf_t)dlsym(libNotifyHandle, "notify_notification_set_icon_from_pixbuf");
|
||||
notify_notification_add_action = (notify_notification_add_action_t)dlsym(libNotifyHandle, "notify_notification_add_action");
|
||||
if (!notify_is_initted || !notify_init || !notify_get_server_caps || !notify_notification_new || !notify_notification_show || !notify_notification_set_icon_from_pixbuf || !notify_notification_add_action) {
|
||||
dlclose(libNotifyHandle);
|
||||
libNotifyHandle = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsAlertsIconListener::~nsAlertsIconListener()
|
||||
{
|
||||
if (mIconRequest)
|
||||
mIconRequest->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<nsIStringBundleService> bundleService =
|
||||
|
@ -13,10 +13,11 @@
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <libnotify/notify.h>
|
||||
|
||||
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<imgIRequest> 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;
|
||||
|
||||
|
@ -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 }
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user