From 352ad899ab041bce07f56a3bc4af0469844b4105 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Thu, 4 Jul 2013 23:39:48 +0200 Subject: drop --with-systemdinhibit and move logind detection to runtime There is no need to bind the user to either systemd-logind or upower at build time. People can switch between init systems or run logind without systemd. --- src/gpm-manager.c | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) (limited to 'src/gpm-manager.c') diff --git a/src/gpm-manager.c b/src/gpm-manager.c index 9b697b5..c99bd09 100644 --- a/src/gpm-manager.c +++ b/src/gpm-manager.c @@ -33,9 +33,6 @@ #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ -#ifdef WITH_SYSTEMD_INHIBIT -#include -#endif /* WITH_SYSTEMD_INHIBIT */ #include #include @@ -103,10 +100,8 @@ struct GpmManagerPrivate NotifyNotification *notification_warning_low; NotifyNotification *notification_discharging; NotifyNotification *notification_fully_charged; -#ifdef WITH_SYSTEMD_INHIBIT gint32 systemd_inhibit; GDBusProxy *systemd_inhibit_proxy; -#endif }; typedef enum { @@ -1847,9 +1842,8 @@ gpm_manager_control_resume_cb (GpmControl *control, GpmControlAction action, Gpm g_timeout_add_seconds (1, gpm_manager_reset_just_resumed_cb, manager); } -#ifdef WITH_SYSTEMD_INHIBIT /** - * gpm_main_system_inhibit: + * gpm_main_systemd_inhibit: * * Return a fd to the to the inhibitor, that we can close on exit. * @@ -1917,7 +1911,6 @@ gpm_manager_systemd_inhibit (GDBusProxy *proxy) { egg_debug ("Inhibiting systemd sleep - success"); return r; } -#endif /** * gpm_manager_init: @@ -1929,20 +1922,17 @@ gpm_manager_init (GpmManager *manager) gboolean check_type_cpu; gint timeout; DBusGConnection *connection; - GDBusConnection *g_connection; + GDBusConnection *g_connection; GError *error = NULL; manager->priv = GPM_MANAGER_GET_PRIVATE (manager); connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - g_connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); - -#ifdef WITH_SYSTEMD_INHIBIT - /* We want to inhibit the systemd suspend options, and take care of them ourselves */ - if (sd_booted() > 0) { - manager->priv->systemd_inhibit = gpm_manager_systemd_inhibit (manager->priv->systemd_inhibit_proxy); - } + g_connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); -#endif + /* We want to inhibit the systemd suspend options, and take care of them ourselves */ + if (LOGIND_RUNNING()) { + manager->priv->systemd_inhibit = gpm_manager_systemd_inhibit (manager->priv->systemd_inhibit_proxy); + } /* init to unthrottled */ manager->priv->screensaver_ac_throttle_id = 0; @@ -2101,16 +2091,15 @@ gpm_manager_finalize (GObject *object) g_object_unref (manager->priv->client); g_object_unref (manager->priv->status_icon); -#ifdef WITH_SYSTEMD_INHIBIT - /* Let systemd take over again ... */ - if (manager->priv->systemd_inhibit > 0) { - close(manager->priv->systemd_inhibit); - } - if (manager->priv->systemd_inhibit_proxy != NULL) { - g_object_unref (manager->priv->systemd_inhibit_proxy); - } - //g_object_unref (manager->priv->systemd_inhibit); -#endif + if (LOGIND_RUNNING()) { + /* Let systemd take over again ... */ + if (manager->priv->systemd_inhibit > 0) { + close(manager->priv->systemd_inhibit); + } + if (manager->priv->systemd_inhibit_proxy != NULL) { + g_object_unref (manager->priv->systemd_inhibit_proxy); + } + } G_OBJECT_CLASS (gpm_manager_parent_class)->finalize (object); } -- cgit v1.2.1