diff options
author | root <root@rshg054.dnsready.net> | 2012-10-15 00:36:27 -0700 |
---|---|---|
committer | root <root@rshg054.dnsready.net> | 2012-10-15 00:36:27 -0700 |
commit | e9dd04abd0ede1143ea4af10059e37c2f599e1fd (patch) | |
tree | 349cdcd294bfe80d37acf0f2c9a189c7d3bc6386 /gnome-unstable/networkmanager | |
parent | 4eb56e1b3a80c84f2dddf2692310369dc9cbd31a (diff) |
Mon Oct 15 00:36:26 PDT 2012
Diffstat (limited to 'gnome-unstable/networkmanager')
-rw-r--r-- | gnome-unstable/networkmanager/PKGBUILD | 6 | ||||
-rw-r--r-- | gnome-unstable/networkmanager/systemd-sleep.patch | 589 |
2 files changed, 287 insertions, 308 deletions
diff --git a/gnome-unstable/networkmanager/PKGBUILD b/gnome-unstable/networkmanager/PKGBUILD index debe2701f..552d189d6 100644 --- a/gnome-unstable/networkmanager/PKGBUILD +++ b/gnome-unstable/networkmanager/PKGBUILD @@ -1,4 +1,4 @@ -# $Id: PKGBUILD 168649 2012-10-13 19:17:30Z heftig $ +# $Id: PKGBUILD 168706 2012-10-14 16:54:10Z heftig $ # Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com> # Maintainer: Jan de Groot <jgc@archlinxu.org> # Contributor: Wael Nasreddine <gandalf@siemens-mobiles.org> @@ -9,7 +9,7 @@ pkgname=networkmanager _pkgname=NetworkManager pkgver=0.9.6.0 -pkgrel=4 +pkgrel=5 pkgdesc="Network Management daemon" arch=('i686' 'x86_64') license=('GPL') @@ -35,7 +35,7 @@ sha256sums=('3982b623b7b199ac99e2ddd0840fe7d088245a49e3f680237e8baebf0cf86d07' '65124505048cc8396daf0242c9f5d532fa669b4bbca305998c248ab2329490cb' 'e23b651a90ef62d515921953b4c6779538d35a737fb74c266b7fce94d62fdb06' 'a1c65a09e5e8ecb1004ab7922517aa7fbc9700dc61e3b2fd348d3d7c23808ce6' - '8fe72946aa3b01d2205f3910bf07a3669c6c0218fb8d2bad45b6a27b48e3e496') + '24c181ab69e769e703e45f64a552add5df5de22fbcd8899d588add053674420a') build() { cd $_pkgname-$pkgver diff --git a/gnome-unstable/networkmanager/systemd-sleep.patch b/gnome-unstable/networkmanager/systemd-sleep.patch index 2240594b2..3470d4654 100644 --- a/gnome-unstable/networkmanager/systemd-sleep.patch +++ b/gnome-unstable/networkmanager/systemd-sleep.patch @@ -1,35 +1,94 @@ -From 64fd8eea7706038e5d38c8463a1c765ed9331db2 Mon Sep 17 00:00:00 2001 +From b444d31cba5b8ac0c9771cc5a246dfd3af9dfd00 Mon Sep 17 00:00:00 2001 From: Matthias Clasen <mclasen@redhat.com> Date: Tue, 9 Oct 2012 00:36:35 -0400 -Subject: [PATCH 1/2] core: factor out the upower suspend/resume code (bgo +Subject: [PATCH] core: factor out the upower suspend/resume code (bgo #677694) Factor the code that listens for upower sleeping and resuming signals out into a class code NMSleepMonitor. + +core: add a systemd suspend/resume monitor (bgo #677694) + +This implementation uses a delay inhibitor to get systemd to +emit PrepareForSleep, and then emits ::Sleeping and ::Resuming +when receiving the before/after PrepareForSleep emissions. + +core: DBusGConnections are not GObjects + +Introduced in 64fd8eea7706038e5d38c8463a1c765ed9331db2. + +core: fix suspend/resume signal names which the manager listens for + +Introduced in 64fd8eea7706038e5d38c8463a1c765ed9331db2; but honestly +I also thought GObject lower-cased signal names since it munges them +for - and _ too. Apparently not. --- - src/Makefile.am | 2 + - src/nm-manager.c | 40 +++++-------- - src/nm-sleep-monitor.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++ - src/nm-sleep-monitor.h | 46 +++++++++++++++ - 4 files changed, 214 insertions(+), 26 deletions(-) - create mode 100644 src/nm-sleep-monitor.c + configure.ac | 2 +- + src/Makefile.am | 9 +- + src/nm-manager.c | 40 +++----- + src/nm-sleep-monitor-systemd.c | 217 +++++++++++++++++++++++++++++++++++++++++ + src/nm-sleep-monitor-upower.c | 151 ++++++++++++++++++++++++++++ + src/nm-sleep-monitor.h | 46 +++++++++ + 6 files changed, 437 insertions(+), 28 deletions(-) + create mode 100644 src/nm-sleep-monitor-systemd.c + create mode 100644 src/nm-sleep-monitor-upower.c create mode 100644 src/nm-sleep-monitor.h +diff --git a/configure.ac b/configure.ac +index e76e193..9152c23 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -327,7 +327,7 @@ PKG_CHECK_MODULES(GUDEV, gudev-1.0 >= 147) + AC_SUBST(GUDEV_CFLAGS) + AC_SUBST(GUDEV_LIBS) + +-PKG_CHECK_MODULES(GIO, gio-2.0) ++PKG_CHECK_MODULES(GIO, gio-unix-2.0) + AC_SUBST(GIO_CFLAGS) + AC_SUBST(GIO_LIBS) + diff --git a/src/Makefile.am b/src/Makefile.am -index b155209..9484a1f 100644 +index b155209..ba7d2d6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am -@@ -191,6 +191,8 @@ NetworkManager_SOURCES = \ +@@ -191,6 +191,7 @@ NetworkManager_SOURCES = \ nm-session-monitor.h \ nm-session-utils.c \ nm-session-utils.h \ + nm-sleep-monitor.h \ -+ nm-sleep-monitor.c \ nm-connection-provider.h \ nm-connection-provider.c \ nm-dispatcher.c \ +@@ -201,13 +202,18 @@ NetworkManager_SOURCES += nm-connectivity.c nm-connectivity.h + endif + + if SESSION_TRACKING_SYSTEMD +-NetworkManager_SOURCES += nm-session-monitor-systemd.c ++NetworkManager_SOURCES += \ ++ nm-session-monitor-systemd.c \ ++ nm-sleep-monitor-systemd.c + else + if SESSION_TRACKING_CK + NetworkManager_SOURCES += nm-session-monitor-ck.c + else + NetworkManager_SOURCES += nm-session-monitor-null.c + endif ++ ++# UPower suspend/resume used whenever systemd is not enabled ++NetworkManager_SOURCES += nm-sleep-monitor-upower.c + endif + + nm-access-point-glue.h: $(top_srcdir)/introspection/nm-access-point.xml +@@ -283,6 +289,7 @@ BUILT_SOURCES = \ + NetworkManager_CPPFLAGS = \ + $(DBUS_CFLAGS) \ + $(GLIB_CFLAGS) \ ++ $(GIO_CFLAGS) \ + $(GUDEV_CFLAGS) \ + $(LIBNL_CFLAGS) \ + $(GMODULE_CFLAGS) \ diff --git a/src/nm-manager.c b/src/nm-manager.c -index 618c4ed..8adb409 100644 +index 618c4ed..c8ce115 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -69,6 +69,7 @@ @@ -113,298 +172,13 @@ index 618c4ed..8adb409 100644 - nm_log_warn (LOGD_SUSPEND, "could not initialize UPower D-Bus proxy"); + /* sleep/wake handling */ + priv->sleep_monitor = nm_sleep_monitor_get (); -+ g_signal_connect (priv->sleep_monitor, "Sleeping", -+ G_CALLBACK (sleeping_cb), manager); -+ g_signal_connect (priv->sleep_monitor, "Resuming", -+ G_CALLBACK (resuming_cb), manager); ++ g_signal_connect (priv->sleep_monitor, "sleeping", ++ G_CALLBACK (sleeping_cb), manager); ++ g_signal_connect (priv->sleep_monitor, "resuming", ++ G_CALLBACK (resuming_cb), manager); /* Listen for authorization changes */ nm_auth_changed_func_register (authority_changed_cb, manager); -diff --git a/src/nm-sleep-monitor.c b/src/nm-sleep-monitor.c -new file mode 100644 -index 0000000..488200e ---- /dev/null -+++ b/src/nm-sleep-monitor.c -@@ -0,0 +1,152 @@ -+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -+/* This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -+ * -+ * (C) Copyright 2012 Red Hat, Inc. -+ * Author: Matthias Clasen <mclasen@redhat.com> -+ */ -+ -+#include "config.h" -+#include <errno.h> -+#include <string.h> -+#include <sys/stat.h> -+#include <dbus/dbus-glib-lowlevel.h> -+#include <dbus/dbus-glib.h> -+#include <gio/gio.h> -+#include "nm-logging.h" -+#include "nm-dbus-manager.h" -+ -+#include "nm-sleep-monitor.h" -+ -+#define UPOWER_DBUS_SERVICE "org.freedesktop.UPower" -+ -+struct _NMSleepMonitor { -+ GObject parent_instance; -+ -+ DBusGProxy *upower_proxy; -+}; -+ -+struct _NMSleepMonitorClass { -+ GObjectClass parent_class; -+ -+ void (*sleeping) (NMSleepMonitor *monitor); -+ void (*resuming) (NMSleepMonitor *monitor); -+}; -+ -+ -+enum { -+ SLEEPING, -+ RESUMING, -+ LAST_SIGNAL, -+}; -+static guint signals[LAST_SIGNAL] = {0}; -+ -+G_DEFINE_TYPE (NMSleepMonitor, nm_sleep_monitor, G_TYPE_OBJECT); -+ -+/********************************************************************/ -+ -+static void -+upower_sleeping_cb (DBusGProxy *proxy, gpointer user_data) -+{ -+ nm_log_dbg (LOGD_SUSPEND, "Received UPower sleeping signal"); -+ g_signal_emit (user_data, signals[SLEEPING], 0); -+} -+ -+static void -+upower_resuming_cb (DBusGProxy *proxy, gpointer user_data) -+{ -+ nm_log_dbg (LOGD_SUSPEND, "Received UPower resuming signal"); -+ g_signal_emit (user_data, signals[RESUMING], 0); -+} -+ -+static void -+nm_sleep_monitor_init (NMSleepMonitor *self) -+{ -+ NMDBusManager *dbus_mgr; -+ DBusGConnection *bus; -+ -+ dbus_mgr = nm_dbus_manager_get (); -+ bus = nm_dbus_manager_get_connection (dbus_mgr); -+ self->upower_proxy = dbus_g_proxy_new_for_name (bus, -+ UPOWER_DBUS_SERVICE, -+ "/org/freedesktop/UPower", -+ "org.freedesktop.UPower"); -+ if (self->upower_proxy) { -+ dbus_g_proxy_add_signal (self->upower_proxy, "Sleeping", G_TYPE_INVALID); -+ dbus_g_proxy_connect_signal (self->upower_proxy, "Sleeping", -+ G_CALLBACK (upower_sleeping_cb), -+ self, NULL); -+ -+ dbus_g_proxy_add_signal (self->upower_proxy, "Resuming", G_TYPE_INVALID); -+ dbus_g_proxy_connect_signal (self->upower_proxy, "Resuming", -+ G_CALLBACK (upower_resuming_cb), -+ self, NULL); -+ } else -+ nm_log_warn (LOGD_SUSPEND, "could not initialize UPower D-Bus proxy"); -+ g_object_unref (bus); -+ g_object_unref (dbus_mgr); -+} -+ -+static void -+finalize (GObject *object) -+{ -+ NMSleepMonitor *self = NM_SLEEP_MONITOR (object); -+ -+ if (self->upower_proxy) -+ g_object_unref (self->upower_proxy); -+ -+ if (G_OBJECT_CLASS (nm_sleep_monitor_parent_class)->finalize != NULL) -+ G_OBJECT_CLASS (nm_sleep_monitor_parent_class)->finalize (object); -+} -+ -+static void -+nm_sleep_monitor_class_init (NMSleepMonitorClass *klass) -+{ -+ GObjectClass *gobject_class; -+ -+ gobject_class = G_OBJECT_CLASS (klass); -+ -+ gobject_class->finalize = finalize; -+ -+ signals[SLEEPING] = g_signal_new (NM_SLEEP_MONITOR_SLEEPING, -+ NM_TYPE_SLEEP_MONITOR, -+ G_SIGNAL_RUN_LAST, -+ G_STRUCT_OFFSET (NMSleepMonitorClass, sleeping), -+ NULL, /* accumulator */ -+ NULL, /* accumulator data */ -+ g_cclosure_marshal_VOID__VOID, -+ G_TYPE_NONE, 0); -+ signals[RESUMING] = g_signal_new (NM_SLEEP_MONITOR_RESUMING, -+ NM_TYPE_SLEEP_MONITOR, -+ G_SIGNAL_RUN_LAST, -+ G_STRUCT_OFFSET (NMSleepMonitorClass, resuming), -+ NULL, /* accumulator */ -+ NULL, /* accumulator data */ -+ g_cclosure_marshal_VOID__VOID, -+ G_TYPE_NONE, 0); -+} -+ -+NMSleepMonitor * -+nm_sleep_monitor_get (void) -+{ -+ static NMSleepMonitor *singleton = NULL; -+ -+ if (singleton) -+ return g_object_ref (singleton); -+ -+ singleton = NM_SLEEP_MONITOR (g_object_new (NM_TYPE_SLEEP_MONITOR, NULL)); -+ return singleton; -+} -+ -+/* ---------------------------------------------------------------------------------------------------- */ -diff --git a/src/nm-sleep-monitor.h b/src/nm-sleep-monitor.h -new file mode 100644 -index 0000000..173e6a1 ---- /dev/null -+++ b/src/nm-sleep-monitor.h -@@ -0,0 +1,46 @@ -+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -+/* This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -+ * -+ * (C) Copyright 2012 Red Hat, Inc. -+ * Author: Matthias Clasen <mclasen@redhat.com> -+ */ -+ -+#ifndef NM_SLEEP_MONITOR_H -+#define NM_SLEEP_MONITOR_H -+ -+#include <glib-object.h> -+ -+G_BEGIN_DECLS -+ -+#define NM_TYPE_SLEEP_MONITOR (nm_sleep_monitor_get_type ()) -+#define NM_SLEEP_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NM_TYPE_SLEEP_MONITOR, NMSleepMonitor)) -+#define NM_SLEEP_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), NM_TYPE_SLEEP_MONITOR, NMSleepMonitorClass)) -+#define NM_SLEEP_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NM_TYPE_SLEEP_MONITOR, NMSleepMonitorClass)) -+#define NM_IS_SLEEP_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NM_TYPE_SLEEP_MONITOR)) -+#define NM_IS_SLEEP_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NM_TYPE_SLEEP_MONITOR)) -+ -+#define NM_SLEEP_MONITOR_SLEEPING "sleeping" -+#define NM_SLEEP_MONITOR_RESUMING "resuming" -+ -+typedef struct _NMSleepMonitor NMSleepMonitor; -+typedef struct _NMSleepMonitorClass NMSleepMonitorClass; -+ -+GType nm_sleep_monitor_get_type (void) G_GNUC_CONST; -+NMSleepMonitor *nm_sleep_monitor_get (void); -+ -+G_END_DECLS -+ -+#endif /* NM_SLEEP_MONITOR_H */ -+ --- -1.7.12.2 - - - -From ea0c3a3e0fcbe400a704692d3b436d4733d348a1 Mon Sep 17 00:00:00 2001 -From: Matthias Clasen <mclasen@redhat.com> -Date: Tue, 9 Oct 2012 00:39:03 -0400 -Subject: [PATCH 2/2] core: add a systemd suspend/resume monitor (bgo #677694) - -This implementation uses a delay inhibitor to get systemd to -emit PrepareForSleep, and then emits ::Sleeping and ::Resuming -when receiving the before/after PrepareForSleep emissions. ---- - configure.ac | 2 +- - src/Makefile.am | 9 +- - src/nm-sleep-monitor-systemd.c | 217 +++++++++++++++++++++ - ...m-sleep-monitor.c => nm-sleep-monitor-upower.c} | 0 - 4 files changed, 225 insertions(+), 3 deletions(-) - create mode 100644 src/nm-sleep-monitor-systemd.c - rename src/{nm-sleep-monitor.c => nm-sleep-monitor-upower.c} (100%) - -diff --git a/configure.ac b/configure.ac -index e76e193..9152c23 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -327,7 +327,7 @@ PKG_CHECK_MODULES(GUDEV, gudev-1.0 >= 147) - AC_SUBST(GUDEV_CFLAGS) - AC_SUBST(GUDEV_LIBS) - --PKG_CHECK_MODULES(GIO, gio-2.0) -+PKG_CHECK_MODULES(GIO, gio-unix-2.0) - AC_SUBST(GIO_CFLAGS) - AC_SUBST(GIO_LIBS) - -diff --git a/src/Makefile.am b/src/Makefile.am -index 9484a1f..ba7d2d6 100644 ---- a/src/Makefile.am -+++ b/src/Makefile.am -@@ -192,7 +192,6 @@ NetworkManager_SOURCES = \ - nm-session-utils.c \ - nm-session-utils.h \ - nm-sleep-monitor.h \ -- nm-sleep-monitor.c \ - nm-connection-provider.h \ - nm-connection-provider.c \ - nm-dispatcher.c \ -@@ -203,13 +202,18 @@ NetworkManager_SOURCES += nm-connectivity.c nm-connectivity.h - endif - - if SESSION_TRACKING_SYSTEMD --NetworkManager_SOURCES += nm-session-monitor-systemd.c -+NetworkManager_SOURCES += \ -+ nm-session-monitor-systemd.c \ -+ nm-sleep-monitor-systemd.c - else - if SESSION_TRACKING_CK - NetworkManager_SOURCES += nm-session-monitor-ck.c - else - NetworkManager_SOURCES += nm-session-monitor-null.c - endif -+ -+# UPower suspend/resume used whenever systemd is not enabled -+NetworkManager_SOURCES += nm-sleep-monitor-upower.c - endif - - nm-access-point-glue.h: $(top_srcdir)/introspection/nm-access-point.xml -@@ -285,6 +289,7 @@ BUILT_SOURCES = \ - NetworkManager_CPPFLAGS = \ - $(DBUS_CFLAGS) \ - $(GLIB_CFLAGS) \ -+ $(GIO_CFLAGS) \ - $(GUDEV_CFLAGS) \ - $(LIBNL_CFLAGS) \ - $(GMODULE_CFLAGS) \ diff --git a/src/nm-sleep-monitor-systemd.c b/src/nm-sleep-monitor-systemd.c new file mode 100644 index 0000000..70adc89 @@ -628,10 +402,215 @@ index 0000000..70adc89 +} + +/* ---------------------------------------------------------------------------------------------------- */ -diff --git a/src/nm-sleep-monitor.c b/src/nm-sleep-monitor-upower.c -similarity index 100% -rename from src/nm-sleep-monitor.c -rename to src/nm-sleep-monitor-upower.c +diff --git a/src/nm-sleep-monitor-upower.c b/src/nm-sleep-monitor-upower.c +new file mode 100644 +index 0000000..3c93f66 +--- /dev/null ++++ b/src/nm-sleep-monitor-upower.c +@@ -0,0 +1,151 @@ ++/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ ++/* This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * (C) Copyright 2012 Red Hat, Inc. ++ * Author: Matthias Clasen <mclasen@redhat.com> ++ */ ++ ++#include "config.h" ++#include <errno.h> ++#include <string.h> ++#include <sys/stat.h> ++#include <dbus/dbus-glib-lowlevel.h> ++#include <dbus/dbus-glib.h> ++#include <gio/gio.h> ++#include "nm-logging.h" ++#include "nm-dbus-manager.h" ++ ++#include "nm-sleep-monitor.h" ++ ++#define UPOWER_DBUS_SERVICE "org.freedesktop.UPower" ++ ++struct _NMSleepMonitor { ++ GObject parent_instance; ++ ++ DBusGProxy *upower_proxy; ++}; ++ ++struct _NMSleepMonitorClass { ++ GObjectClass parent_class; ++ ++ void (*sleeping) (NMSleepMonitor *monitor); ++ void (*resuming) (NMSleepMonitor *monitor); ++}; ++ ++ ++enum { ++ SLEEPING, ++ RESUMING, ++ LAST_SIGNAL, ++}; ++static guint signals[LAST_SIGNAL] = {0}; ++ ++G_DEFINE_TYPE (NMSleepMonitor, nm_sleep_monitor, G_TYPE_OBJECT); ++ ++/********************************************************************/ ++ ++static void ++upower_sleeping_cb (DBusGProxy *proxy, gpointer user_data) ++{ ++ nm_log_dbg (LOGD_SUSPEND, "Received UPower sleeping signal"); ++ g_signal_emit (user_data, signals[SLEEPING], 0); ++} ++ ++static void ++upower_resuming_cb (DBusGProxy *proxy, gpointer user_data) ++{ ++ nm_log_dbg (LOGD_SUSPEND, "Received UPower resuming signal"); ++ g_signal_emit (user_data, signals[RESUMING], 0); ++} ++ ++static void ++nm_sleep_monitor_init (NMSleepMonitor *self) ++{ ++ NMDBusManager *dbus_mgr; ++ DBusGConnection *bus; ++ ++ dbus_mgr = nm_dbus_manager_get (); ++ bus = nm_dbus_manager_get_connection (dbus_mgr); ++ self->upower_proxy = dbus_g_proxy_new_for_name (bus, ++ UPOWER_DBUS_SERVICE, ++ "/org/freedesktop/UPower", ++ "org.freedesktop.UPower"); ++ if (self->upower_proxy) { ++ dbus_g_proxy_add_signal (self->upower_proxy, "Sleeping", G_TYPE_INVALID); ++ dbus_g_proxy_connect_signal (self->upower_proxy, "Sleeping", ++ G_CALLBACK (upower_sleeping_cb), ++ self, NULL); ++ ++ dbus_g_proxy_add_signal (self->upower_proxy, "Resuming", G_TYPE_INVALID); ++ dbus_g_proxy_connect_signal (self->upower_proxy, "Resuming", ++ G_CALLBACK (upower_resuming_cb), ++ self, NULL); ++ } else ++ nm_log_warn (LOGD_SUSPEND, "could not initialize UPower D-Bus proxy"); ++ g_object_unref (dbus_mgr); ++} ++ ++static void ++finalize (GObject *object) ++{ ++ NMSleepMonitor *self = NM_SLEEP_MONITOR (object); ++ ++ if (self->upower_proxy) ++ g_object_unref (self->upower_proxy); ++ ++ if (G_OBJECT_CLASS (nm_sleep_monitor_parent_class)->finalize != NULL) ++ G_OBJECT_CLASS (nm_sleep_monitor_parent_class)->finalize (object); ++} ++ ++static void ++nm_sleep_monitor_class_init (NMSleepMonitorClass *klass) ++{ ++ GObjectClass *gobject_class; ++ ++ gobject_class = G_OBJECT_CLASS (klass); ++ ++ gobject_class->finalize = finalize; ++ ++ signals[SLEEPING] = g_signal_new (NM_SLEEP_MONITOR_SLEEPING, ++ NM_TYPE_SLEEP_MONITOR, ++ G_SIGNAL_RUN_LAST, ++ G_STRUCT_OFFSET (NMSleepMonitorClass, sleeping), ++ NULL, /* accumulator */ ++ NULL, /* accumulator data */ ++ g_cclosure_marshal_VOID__VOID, ++ G_TYPE_NONE, 0); ++ signals[RESUMING] = g_signal_new (NM_SLEEP_MONITOR_RESUMING, ++ NM_TYPE_SLEEP_MONITOR, ++ G_SIGNAL_RUN_LAST, ++ G_STRUCT_OFFSET (NMSleepMonitorClass, resuming), ++ NULL, /* accumulator */ ++ NULL, /* accumulator data */ ++ g_cclosure_marshal_VOID__VOID, ++ G_TYPE_NONE, 0); ++} ++ ++NMSleepMonitor * ++nm_sleep_monitor_get (void) ++{ ++ static NMSleepMonitor *singleton = NULL; ++ ++ if (singleton) ++ return g_object_ref (singleton); ++ ++ singleton = NM_SLEEP_MONITOR (g_object_new (NM_TYPE_SLEEP_MONITOR, NULL)); ++ return singleton; ++} ++ ++/* ---------------------------------------------------------------------------------------------------- */ +diff --git a/src/nm-sleep-monitor.h b/src/nm-sleep-monitor.h +new file mode 100644 +index 0000000..173e6a1 +--- /dev/null ++++ b/src/nm-sleep-monitor.h +@@ -0,0 +1,46 @@ ++/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ ++/* This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * (C) Copyright 2012 Red Hat, Inc. ++ * Author: Matthias Clasen <mclasen@redhat.com> ++ */ ++ ++#ifndef NM_SLEEP_MONITOR_H ++#define NM_SLEEP_MONITOR_H ++ ++#include <glib-object.h> ++ ++G_BEGIN_DECLS ++ ++#define NM_TYPE_SLEEP_MONITOR (nm_sleep_monitor_get_type ()) ++#define NM_SLEEP_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NM_TYPE_SLEEP_MONITOR, NMSleepMonitor)) ++#define NM_SLEEP_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), NM_TYPE_SLEEP_MONITOR, NMSleepMonitorClass)) ++#define NM_SLEEP_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NM_TYPE_SLEEP_MONITOR, NMSleepMonitorClass)) ++#define NM_IS_SLEEP_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NM_TYPE_SLEEP_MONITOR)) ++#define NM_IS_SLEEP_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NM_TYPE_SLEEP_MONITOR)) ++ ++#define NM_SLEEP_MONITOR_SLEEPING "sleeping" ++#define NM_SLEEP_MONITOR_RESUMING "resuming" ++ ++typedef struct _NMSleepMonitor NMSleepMonitor; ++typedef struct _NMSleepMonitorClass NMSleepMonitorClass; ++ ++GType nm_sleep_monitor_get_type (void) G_GNUC_CONST; ++NMSleepMonitor *nm_sleep_monitor_get (void); ++ ++G_END_DECLS ++ ++#endif /* NM_SLEEP_MONITOR_H */ ++ -- 1.7.12.2 |