From 85e637f69c37e3bf1d13e3f1697add3df2eb5637 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Tue, 23 Jan 2018 12:39:09 +1300 Subject: Fix incorrect use of ConsoleKit CanSuspend/Hibernate API --- liblightdm-gobject/power.c | 16 ++++++++++++---- tests/src/test-runner.c | 8 ++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/liblightdm-gobject/power.c b/liblightdm-gobject/power.c index b81165de..0c07726e 100644 --- a/liblightdm-gobject/power.c +++ b/liblightdm-gobject/power.c @@ -130,9 +130,13 @@ lightdm_get_can_suspend (void) } if (!r) { + const gchar *result; r = ck_call_function ("CanSuspend", NULL, NULL); - if (r && g_variant_is_of_type (r, G_VARIANT_TYPE ("(b)"))) - g_variant_get (r, "(b)", &can_suspend); + if (r && g_variant_is_of_type (r, G_VARIANT_TYPE ("(s)"))) + { + g_variant_get (r, "(&s)", &result); + can_suspend = g_strcmp0 (result, "yes") == 0; + } } if (!r) { @@ -208,9 +212,13 @@ lightdm_get_can_hibernate (void) } if (!r) { + const gchar *result; r = ck_call_function ("CanHibernate", NULL, NULL); - if (r && g_variant_is_of_type (r, G_VARIANT_TYPE ("(b)"))) - g_variant_get (r, "(b)", &can_hibernate); + if (r && g_variant_is_of_type (r, G_VARIANT_TYPE ("(s)"))) + { + g_variant_get (r, "(&s)", &result); + can_hibernate = g_strcmp0 (result, "yes") == 0; + } } if (!r) { diff --git a/tests/src/test-runner.c b/tests/src/test-runner.c index 503b04a7..19bf32c4 100644 --- a/tests/src/test-runner.c +++ b/tests/src/test-runner.c @@ -1241,12 +1241,12 @@ handle_ck_call (GDBusConnection *connection, else if (strcmp (method_name, "CanSuspend") == 0) { check_status ("CONSOLE-KIT CAN-SUSPEND"); - g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", TRUE)); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", "yes")); } else if (strcmp (method_name, "CanHibernate") == 0) { check_status ("CONSOLE-KIT CAN-HIBERNATE"); - g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", TRUE)); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", "yes")); } else if (strcmp (method_name, "CloseSession") == 0) g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", TRUE)); @@ -1358,10 +1358,10 @@ ck_name_acquired_cb (GDBusConnection *connection, " " " " " " - " " + " " " " " " - " " + " " " " " " " " -- cgit v1.2.1