diff options
author | Eric Koegel <eric.koegel@gmail.com> | 2015-07-24 19:47:29 +0300 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-08-04 14:41:33 +0200 |
commit | d40d1ba931afc1c23d9828814eb1c743442ef1ae (patch) | |
tree | 2338dfda07b6afb12c31fcf0f15bba1f703bcd42 | |
parent | a983552308c5b6728e74bb006f7a45012d632752 (diff) | |
download | NetworkManager-d40d1ba931afc1c23d9828814eb1c743442ef1ae.tar.gz |
sleep-monitor: add support for ConsoleKit2 inhibit
ConsoleKit2 has added the same suspend/resume DBUS API that Systemd
uses. This patch adds the code to use ConsoleKit2's inhibit API.
http://consolekit2.github.io/ConsoleKit2/#Manager.Inhibit
https://bugzilla.gnome.org/show_bug.cgi?id=752836
-rw-r--r-- | configure.ac | 18 | ||||
-rw-r--r-- | src/Makefile.am | 8 | ||||
-rw-r--r-- | src/nm-sleep-monitor-systemd.c | 15 |
3 files changed, 33 insertions, 8 deletions
diff --git a/configure.ac b/configure.ac index a97c3da55a..d317381aa3 100644 --- a/configure.ac +++ b/configure.ac @@ -452,7 +452,7 @@ if test "$use_consolekit" = "yes"; then fi session_tracking="$(printf '%s' "${session_tracking}" | sed 's/^, //')" -AC_ARG_WITH(suspend-resume, AS_HELP_STRING([--with-suspend-resume=upower|systemd], [Build NetworkManager with specific suspend/resume support])) +AC_ARG_WITH(suspend-resume, AS_HELP_STRING([--with-suspend-resume=upower|systemd|consolekit], [Build NetworkManager with specific suspend/resume support])) if test "z$with_suspend_resume" = "z"; then PKG_CHECK_EXISTS([libsystemd >= 209], [have_systemd_inhibit=yes], [PKG_CHECK_EXISTS([libsystemd-login >= 183], [have_systemd_inhibit=yes], [have_systemd_inhibit=no])]) @@ -460,8 +460,13 @@ if test "z$with_suspend_resume" = "z"; then # Use systemd if it's new enough with_suspend_resume="systemd" else - # Fall back to upower - with_suspend_resume="upower" + if test "$use_consolekit" = "yes"; then + # Use consolekit suspend if session tracking is consolekit + with_suspend_resume="consolekit" + else + # Fall back to upower + with_suspend_resume="upower" + fi fi fi @@ -470,13 +475,18 @@ case $with_suspend_resume in systemd) PKG_CHECK_MODULES(SYSTEMD_INHIBIT, [libsystemd >= 209],, [PKG_CHECK_MODULES(SYSTEMD_INHIBIT, [libsystemd-login >= 183])]) + AC_DEFINE([SUSPEND_RESUME_SYSTEMD], 1, [Define to 1 to use systemd suspend api]) ;; + consolekit) + AC_DEFINE([SUSPEND_RESUME_CONSOLEKIT], 1, [Define to 1 to use ConsoleKit2 suspend api]) + ;; *) - AC_MSG_ERROR(--with-suspend-resume must be one of [upower, systemd]) + AC_MSG_ERROR(--with-suspend-resume must be one of [upower, systemd, consolekit]) ;; esac AM_CONDITIONAL(SUSPEND_RESUME_UPOWER, test "x$with_suspend_resume" = "xupower") AM_CONDITIONAL(SUSPEND_RESUME_SYSTEMD, test "x$with_suspend_resume" = "xsystemd") +AM_CONDITIONAL(SUSPEND_RESUME_CONSOLEKIT, test "x$with_suspend_resume" = "xconsolekit") # SELinux support AC_ARG_WITH(selinux, AS_HELP_STRING([--with-selinux=yes|no|auto], [Build with SELinux (default: auto)]),,[with_selinux=auto]) diff --git a/src/Makefile.am b/src/Makefile.am index a5d7973a77..c869949aba 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -358,11 +358,11 @@ nm_sources = \ NetworkManagerUtils.h -if SUSPEND_RESUME_SYSTEMD -nm_sources += nm-sleep-monitor-systemd.c -else -# UPower suspend/resume used whenever systemd is not enabled +if SUSPEND_RESUME_UPOWER nm_sources += nm-sleep-monitor-upower.c +else +# systemd/consolekit suspend/resume used whenever upower is not enabled +nm_sources += nm-sleep-monitor-systemd.c endif if WITH_WEXT diff --git a/src/nm-sleep-monitor-systemd.c b/src/nm-sleep-monitor-systemd.c index 175c0c1233..30be9c6c6a 100644 --- a/src/nm-sleep-monitor-systemd.c +++ b/src/nm-sleep-monitor-systemd.c @@ -36,6 +36,10 @@ #define SD_PATH "/org/freedesktop/login1" #define SD_INTERFACE "org.freedesktop.login1.Manager" +#define CK_NAME "org.freedesktop.ConsoleKit" +#define CK_PATH "/org/freedesktop/ConsoleKit/Manager" +#define CK_INTERFACE "org.freedesktop.ConsoleKit.Manager" + struct _NMSleepMonitor { GObject parent_instance; @@ -190,6 +194,7 @@ static void nm_sleep_monitor_init (NMSleepMonitor *self) { self->inhibit_fd = -1; +#ifdef SUSPEND_RESUME_SYSTEMD g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START | G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, @@ -197,6 +202,16 @@ nm_sleep_monitor_init (NMSleepMonitor *self) SD_NAME, SD_PATH, SD_INTERFACE, NULL, (GAsyncReadyCallback) on_proxy_acquired, self); +#endif /* SUSPEND_RESUME_SYSTEMD */ +#ifdef SUSPEND_RESUME_CONSOLEKIT + g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START | + G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, + NULL, + CK_NAME, CK_PATH, CK_INTERFACE, + NULL, + (GAsyncReadyCallback) on_proxy_acquired, self); +#endif /* SUSPEND_RESUME_CONSOLEKIT */ } static void |