mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-14 20:18:39 +00:00
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 [thaller@redhat.com: modified original patch] https://bugzilla.gnome.org/show_bug.cgi?id=752836
This commit is contained in:
parent
558117222f
commit
0db81e1014
26
configure.ac
26
configure.ac
|
@ -452,31 +452,41 @@ 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])])
|
||||
if test "z${have_systemd_inhibit}" = "zyes"; then
|
||||
# Use systemd if it's new enough
|
||||
with_suspend_resume="systemd"
|
||||
# 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
|
||||
|
||||
case $with_suspend_resume in
|
||||
upower) ;;
|
||||
systemd)
|
||||
PKG_CHECK_MODULES(SYSTEMD_INHIBIT, [libsystemd >= 209],,
|
||||
[PKG_CHECK_MODULES(SYSTEMD_INHIBIT, [libsystemd-login >= 183])])
|
||||
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])
|
||||
|
|
|
@ -361,11 +361,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
|
||||
|
|
|
@ -30,10 +30,27 @@
|
|||
|
||||
#include "nm-sleep-monitor.h"
|
||||
|
||||
#define SD_NAME "org.freedesktop.login1"
|
||||
#define SD_PATH "/org/freedesktop/login1"
|
||||
#define SD_INTERFACE "org.freedesktop.login1.Manager"
|
||||
#if defined (SUSPEND_RESUME_SYSTEMD) == defined (SUSPEND_RESUME_CONSOLEKIT)
|
||||
#error either define SUSPEND_RESUME_SYSTEMD or SUSPEND_RESUME_CONSOLEKIT
|
||||
#endif
|
||||
|
||||
#ifdef SUSPEND_RESUME_SYSTEMD
|
||||
|
||||
#define SUSPEND_DBUS_NAME "org.freedesktop.login1"
|
||||
#define SUSPEND_DBUS_PATH "/org/freedesktop/login1"
|
||||
#define SUSPEND_DBUS_INTERFACE "org.freedesktop.login1.Manager"
|
||||
|
||||
#else
|
||||
|
||||
/* ConsoleKit2 has added the same suspend/resume DBUS API that Systemd
|
||||
* uses. http://consolekit2.github.io/ConsoleKit2/#Manager.Inhibit
|
||||
*/
|
||||
|
||||
#define SUSPEND_DBUS_NAME "org.freedesktop.ConsoleKit"
|
||||
#define SUSPEND_DBUS_PATH "/org/freedesktop/ConsoleKit/Manager"
|
||||
#define SUSPEND_DBUS_INTERFACE "org.freedesktop.ConsoleKit.Manager"
|
||||
|
||||
#endif
|
||||
|
||||
struct _NMSleepMonitor {
|
||||
GObject parent_instance;
|
||||
|
@ -192,7 +209,7 @@ nm_sleep_monitor_init (NMSleepMonitor *self)
|
|||
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START |
|
||||
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
|
||||
NULL,
|
||||
SD_NAME, SD_PATH, SD_INTERFACE,
|
||||
SUSPEND_DBUS_NAME, SUSPEND_DBUS_PATH, SUSPEND_DBUS_INTERFACE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback) on_proxy_acquired, self);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue