summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-08-04 14:36:34 +0200
committerThomas Haller <thaller@redhat.com>2015-08-04 14:45:42 +0200
commit7ab40385061f46bc9f83d3ff922af28e88d74e9d (patch)
tree5b3ce75487564b2c7b102eda8f1df50327cf9b7f
parent3b29a4e0dab5dc6f86a2c8d5f05c2db483a958d7 (diff)
downloadNetworkManager-th/ConsoleKit2-inhibit-bgo752836.tar.gz
fixup! sleep-monitor: add support for ConsoleKit2 inhibitth/ConsoleKit2-inhibit-bgo752836
-rw-r--r--src/nm-sleep-monitor-systemd.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/nm-sleep-monitor-systemd.c b/src/nm-sleep-monitor-systemd.c
index 2d97ce931a..6c24ecfbeb 100644
--- a/src/nm-sleep-monitor-systemd.c
+++ b/src/nm-sleep-monitor-systemd.c
@@ -32,14 +32,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
-#define CK_NAME "org.freedesktop.ConsoleKit"
-#define CK_PATH "/org/freedesktop/ConsoleKit/Manager"
-#define CK_INTERFACE "org.freedesktop.ConsoleKit.Manager"
+#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;
@@ -194,24 +207,13 @@ 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,
- NULL,
- 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,
+ SUSPEND_DBUS_NAME, SUSPEND_DBUS_PATH, SUSPEND_DBUS_INTERFACE,
NULL,
(GAsyncReadyCallback) on_proxy_acquired, self);
-#endif /* SUSPEND_RESUME_CONSOLEKIT */
}
static void