summaryrefslogtreecommitdiff
path: root/src/gpm-control.c
diff options
context:
space:
mode:
authorinfirit <[email protected]>2016-04-17 19:23:33 +0200
committermonsta <[email protected]>2017-03-07 22:17:52 +0300
commita4d30e30fdf9ae097ced2e92c9a5130126ff9b94 (patch)
treecb90eecd76a3e80f9dfc0092bc4f2644c78c0e07 /src/gpm-control.c
parenta11f72eee66b3dc244313a5cd0fc20fd7a1530ad (diff)
downloadmate-power-manager-a4d30e30fdf9ae097ced2e92c9a5130126ff9b94.tar.bz2
mate-power-manager-a4d30e30fdf9ae097ced2e92c9a5130126ff9b94.tar.xz
Replace deprecated UPower functions with ConsoleKit2 equivalents
This requires ConsoleKit2 0.9.2. + some corrections for issues mentioned at https://github.com/mate-desktop/mate-power-manager/pull/209
Diffstat (limited to 'src/gpm-control.c')
-rw-r--r--src/gpm-control.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/gpm-control.c b/src/gpm-control.c
index d9adb56..84a1171 100644
--- a/src/gpm-control.c
+++ b/src/gpm-control.c
@@ -36,9 +36,8 @@
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
+#include <gio/gio.h>
#include <glib/gi18n.h>
-#define UPOWER_ENABLE_DEPRECATED
-#include <libupower-glib/upower.h>
#ifdef WITH_KEYRING
#include <gnome-keyring.h>
@@ -57,7 +56,6 @@
struct GpmControlPrivate
{
GSettings *settings;
- UpClient *client;
};
enum {
@@ -210,6 +208,7 @@ gpm_control_suspend (GpmControl *control, GError **error)
gboolean ret = FALSE;
gboolean do_lock;
gboolean nm_sleep;
+ EggConsoleKit *console;
GpmScreensaver *screensaver;
guint32 throttle_cookie = 0;
#ifdef WITH_KEYRING
@@ -224,9 +223,10 @@ gpm_control_suspend (GpmControl *control, GError **error)
screensaver = gpm_screensaver_new ();
if (!LOGIND_RUNNING()) {
- g_object_get (control->priv->client,
- "can-suspend", &allowed,
- NULL);
+ console = egg_console_kit_new ();
+ egg_console_kit_can_suspend (console, &allowed, NULL);
+ g_object_unref (console);
+
if (!allowed) {
egg_debug ("cannot suspend as not allowed from policy");
g_set_error_literal (error, GPM_CONTROL_ERROR, GPM_CONTROL_ERROR_GENERAL, "Cannot suspend");
@@ -292,11 +292,12 @@ gpm_control_suspend (GpmControl *control, GError **error)
}
g_object_unref(proxy);
}
-#if !UP_CHECK_VERSION(0, 99, 0)
else {
- ret = up_client_suspend_sync (control->priv->client, NULL, error);
+ console = egg_console_kit_new ();
+ ret = egg_console_kit_suspend (console, error);
+ g_object_unref (console);
}
-#endif
+
egg_debug ("emitting resume");
g_signal_emit (control, signals [RESUME], 0, GPM_CONTROL_ACTION_SUSPEND);
@@ -325,6 +326,7 @@ gpm_control_hibernate (GpmControl *control, GError **error)
gboolean ret = FALSE;
gboolean do_lock;
gboolean nm_sleep;
+ EggConsoleKit *console;
GpmScreensaver *screensaver;
guint32 throttle_cookie = 0;
#ifdef WITH_KEYRING
@@ -339,9 +341,10 @@ gpm_control_hibernate (GpmControl *control, GError **error)
screensaver = gpm_screensaver_new ();
if (!LOGIND_RUNNING()) {
- g_object_get (control->priv->client,
- "can-hibernate", &allowed,
- NULL);
+ console = egg_console_kit_new ();
+ egg_console_kit_can_hibernate (console, &allowed, NULL);
+ g_object_unref (console);
+
if (!allowed) {
egg_debug ("cannot hibernate as not allowed from policy");
g_set_error_literal (error, GPM_CONTROL_ERROR, GPM_CONTROL_ERROR_GENERAL, "Cannot hibernate");
@@ -406,11 +409,12 @@ gpm_control_hibernate (GpmControl *control, GError **error)
ret = TRUE;
}
}
-#if !UP_CHECK_VERSION(0, 99, 0)
else {
- ret = up_client_hibernate_sync (control->priv->client, NULL, error);
+ console = egg_console_kit_new ();
+ ret = egg_console_kit_hibernate (console, error);
+ g_object_unref (console);
}
-#endif
+
egg_debug ("emitting resume");
g_signal_emit (control, signals [RESUME], 0, GPM_CONTROL_ACTION_HIBERNATE);
@@ -442,7 +446,6 @@ gpm_control_finalize (GObject *object)
control = GPM_CONTROL (object);
g_object_unref (control->priv->settings);
- g_object_unref (control->priv->client);
g_return_if_fail (control->priv != NULL);
G_OBJECT_CLASS (gpm_control_parent_class)->finalize (object);
@@ -488,7 +491,6 @@ gpm_control_init (GpmControl *control)
{
control->priv = GPM_CONTROL_GET_PRIVATE (control);
- control->priv->client = up_client_new ();
control->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA);
}