diff options
author | Stefano Karapetsas <[email protected]> | 2013-11-07 19:38:44 +0100 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2013-11-07 19:38:44 +0100 |
commit | c38e25ccb5f77ae4bfca9a43e54b4554220bdba9 (patch) | |
tree | 3917c71710a202026cef5ac72237f0680401becf /mate-session/gsm-manager.c | |
parent | c17333cbd562c8021ad152b6a41d7eaa46617719 (diff) | |
download | mate-session-manager-c38e25ccb5f77ae4bfca9a43e54b4554220bdba9.tar.bz2 mate-session-manager-c38e25ccb5f77ae4bfca9a43e54b4554220bdba9.tar.xz |
Make upower optional
This commit is just an improved version of the pull request by Wolfgang Ulbrich
at https://github.com/mate-desktop/mate-session-manager/pull/38
making it working with both upower and systemd, and improving configure part
Diffstat (limited to 'mate-session/gsm-manager.c')
-rw-r--r-- | mate-session/gsm-manager.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/mate-session/gsm-manager.c b/mate-session/gsm-manager.c index cbe680b..eda565b 100644 --- a/mate-session/gsm-manager.c +++ b/mate-session/gsm-manager.c @@ -38,7 +38,9 @@ #include <dbus/dbus-glib.h> #include <dbus/dbus-glib-lowlevel.h> +#ifdef HAVE_UPOWER #include <upower.h> +#endif #include <gtk/gtk.h> /* for logout dialog */ #include <gio/gio.h> /* for gsettings */ @@ -144,9 +146,10 @@ struct GsmManagerPrivate DBusGProxy *bus_proxy; DBusGConnection *connection; - +#ifdef HAVE_UPOWER /* Interface with other parts of the system */ UpClient *up_client; +#endif }; enum { @@ -1142,10 +1145,11 @@ manager_perhaps_lock (GsmManager *manager) static void manager_attempt_hibernate (GsmManager *manager) { +#ifdef HAVE_UPOWER gboolean can_hibernate; GError *error; gboolean ret; - +#endif #ifdef HAVE_SYSTEMD if (LOGIND_RUNNING()) { @@ -1158,8 +1162,11 @@ manager_attempt_hibernate (GsmManager *manager) gsm_systemd_attempt_hibernate (systemd); } +#endif +#if defined(HAVE_SYSTEMD) && defined(HAVE_UPOWER) else { #endif +#ifdef HAVE_UPOWER can_hibernate = up_client_get_can_hibernate (manager->priv->up_client); if (can_hibernate) { @@ -1174,7 +1181,8 @@ manager_attempt_hibernate (GsmManager *manager) g_error_free (error); } } -#ifdef HAVE_SYSTEMD +#endif +#if defined(HAVE_SYSTEMD) && defined(HAVE_UPOWER) } #endif } @@ -1182,10 +1190,11 @@ manager_attempt_hibernate (GsmManager *manager) static void manager_attempt_suspend (GsmManager *manager) { +#ifdef HAVE_UPOWER gboolean can_suspend; GError *error; gboolean ret; - +#endif #ifdef HAVE_SYSTEMD if (LOGIND_RUNNING()) { @@ -1198,8 +1207,11 @@ manager_attempt_suspend (GsmManager *manager) gsm_systemd_attempt_suspend (systemd); } +#endif +#if defined(HAVE_SYSTEMD) && defined(HAVE_UPOWER) else { #endif +#ifdef HAVE_UPOWER can_suspend = up_client_get_can_suspend (manager->priv->up_client); if (can_suspend) { @@ -1214,7 +1226,8 @@ manager_attempt_suspend (GsmManager *manager) g_error_free (error); } } -#ifdef HAVE_SYSTEMD +#endif +#if defined(HAVE_SYSTEMD) && defined(HAVE_UPOWER) } #endif } @@ -2387,12 +2400,12 @@ gsm_manager_dispose (GObject *object) g_object_unref (manager->priv->settings_screensaver); manager->priv->settings_screensaver = NULL; } - +#ifdef HAVE_UPOWER if (manager->priv->up_client != NULL) { g_object_unref (manager->priv->up_client); manager->priv->up_client = NULL; } - +#endif G_OBJECT_CLASS (gsm_manager_parent_class)->dispose (object); } @@ -2599,9 +2612,9 @@ gsm_manager_init (GsmManager *manager) "status-changed", G_CALLBACK (on_presence_status_changed), manager); - +#ifdef HAVE_UPOWER manager->priv->up_client = up_client_new (); - +#endif g_signal_connect (manager->priv->settings_session, "changed", G_CALLBACK (on_gsettings_key_changed), @@ -3270,12 +3283,12 @@ gsm_manager_can_shutdown (GsmManager *manager, #endif gboolean can_suspend; gboolean can_hibernate; - +#ifdef HAVE_UPOWER g_object_get (manager->priv->up_client, "can-suspend", &can_suspend, "can-hibernate", &can_hibernate, NULL); - +#endif g_debug ("GsmManager: CanShutdown called"); g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE); |