Mageia Bugzilla – Attachment 3273 Details for
Bug 7995
Port lightdm to use systemd(-logind) instead of consolekit
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
Replacement for Fedora patch
mageia-lightdm-1.4.0-systemd_login1_power.patch (text/plain), 3.76 KB, created by
Derek Jennings
on 2012-12-21 14:15:25 CET
(
hide
)
Description:
Replacement for Fedora patch
Filename:
MIME Type:
Creator:
Derek Jennings
Created:
2012-12-21 14:15:25 CET
Size:
3.76 KB
patch
obsolete
>--- lightdm-1.4.0/liblightdm-gobject/power.c 2011-12-09 01:51:23.000000000 +0000 >+++ lightdm-1.4.0/liblightdm-gobject/power.c 2012-12-21 12:58:54.741950000 +0000 >@@ -18,6 +18,7 @@ > > static GDBusProxy *upower_proxy = NULL; > static GDBusProxy *ck_proxy = NULL; >+static GDBusProxy *login1_proxy = NULL; > > static gboolean > upower_call_function (const gchar *function, gboolean default_result, GError **error) >@@ -148,6 +149,55 @@ > return function_result; > } > >+static gboolean >+login1_call_function (const gchar *function, GVariant *parameters, gboolean default_result, GError **error) >+{ >+ GVariant *result; >+ gboolean function_result = FALSE; >+ const gchar *true_result = "yes"; >+ gchar *str_result; >+ >+ if (!login1_proxy) >+ { >+ login1_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, >+ G_DBUS_PROXY_FLAGS_NONE, >+ NULL, >+ "org.freedesktop.login1", >+ "/org/freedesktop/login1", >+ "org.freedesktop.login1.Manager", >+ NULL, >+ error); >+ if (!login1_proxy) >+ return FALSE; >+ } >+ >+ result = g_dbus_proxy_call_sync (login1_proxy, >+ function, >+ parameters, >+ G_DBUS_CALL_FLAGS_NONE, >+ -1, >+ NULL, >+ error); >+ >+ if (!result) >+ return default_result; >+ >+ /** >+ * CanReboot, CanPowerOff returns a string "yes", "no", or "challenge", not a boolean as ConsoleKit >+ **/ >+ if (g_variant_is_of_type (result, G_VARIANT_TYPE ("(s)"))) { >+ g_variant_get (result, "(s)", &str_result); >+ if(g_strcmp0(str_result,true_result) == 0) { >+ function_result = TRUE; >+ } >+ else { >+ function_result = default_result; >+ } >+ } >+ g_variant_unref (result); >+ return function_result; >+} >+ > /** > * lightdm_get_can_restart: > * >@@ -158,7 +208,11 @@ > gboolean > lightdm_get_can_restart (void) > { >- return ck_call_function ("CanRestart", FALSE, NULL); >+ gboolean function_result = FALSE; >+ function_result = login1_call_function ("CanReboot", NULL, FALSE, NULL); >+ if (!function_result) >+ function_result = ck_call_function ("CanRestart", FALSE, NULL); >+ return function_result; > } > > /** >@@ -172,7 +226,11 @@ > gboolean > lightdm_restart (GError **error) > { >- return ck_call_function ("Restart", TRUE, error); >+ gboolean function_result = FALSE; >+ function_result = login1_call_function ("Reboot", g_variant_new("(b)",0), TRUE, error); >+ if (!function_result) >+ function_result = ck_call_function ("Restart", TRUE, error); >+ return function_result; > } > > /** >@@ -185,7 +243,11 @@ > gboolean > lightdm_get_can_shutdown (void) > { >- return ck_call_function ("CanStop", FALSE, NULL); >+ gboolean function_result = FALSE; >+ function_result = login1_call_function ("CanPowerOff", NULL, FALSE, NULL); >+ if (!function_result) >+ function_result = ck_call_function ("CanStop", FALSE, NULL); >+ return function_result; > } > > /** >@@ -199,5 +261,9 @@ > gboolean > lightdm_shutdown (GError **error) > { >- return ck_call_function ("Stop", TRUE, error); >+ gboolean function_result = FALSE; >+ function_result = login1_call_function ("PowerOff", g_variant_new("(b)",0), TRUE, error); >+ if (!function_result) >+ function_result = ck_call_function ("Stop", TRUE, error); >+ return function_result; > }
--- lightdm-1.4.0/liblightdm-gobject/power.c 2011-12-09 01:51:23.000000000 +0000 +++ lightdm-1.4.0/liblightdm-gobject/power.c 2012-12-21 12:58:54.741950000 +0000 @@ -18,6 +18,7 @@ static GDBusProxy *upower_proxy = NULL; static GDBusProxy *ck_proxy = NULL; +static GDBusProxy *login1_proxy = NULL; static gboolean upower_call_function (const gchar *function, gboolean default_result, GError **error) @@ -148,6 +149,55 @@ return function_result; } +static gboolean +login1_call_function (const gchar *function, GVariant *parameters, gboolean default_result, GError **error) +{ + GVariant *result; + gboolean function_result = FALSE; + const gchar *true_result = "yes"; + gchar *str_result; + + if (!login1_proxy) + { + login1_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + "org.freedesktop.login1", + "/org/freedesktop/login1", + "org.freedesktop.login1.Manager", + NULL, + error); + if (!login1_proxy) + return FALSE; + } + + result = g_dbus_proxy_call_sync (login1_proxy, + function, + parameters, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + error); + + if (!result) + return default_result; + + /** + * CanReboot, CanPowerOff returns a string "yes", "no", or "challenge", not a boolean as ConsoleKit + **/ + if (g_variant_is_of_type (result, G_VARIANT_TYPE ("(s)"))) { + g_variant_get (result, "(s)", &str_result); + if(g_strcmp0(str_result,true_result) == 0) { + function_result = TRUE; + } + else { + function_result = default_result; + } + } + g_variant_unref (result); + return function_result; +} + /** * lightdm_get_can_restart: * @@ -158,7 +208,11 @@ gboolean lightdm_get_can_restart (void) { - return ck_call_function ("CanRestart", FALSE, NULL); + gboolean function_result = FALSE; + function_result = login1_call_function ("CanReboot", NULL, FALSE, NULL); + if (!function_result) + function_result = ck_call_function ("CanRestart", FALSE, NULL); + return function_result; } /** @@ -172,7 +226,11 @@ gboolean lightdm_restart (GError **error) { - return ck_call_function ("Restart", TRUE, error); + gboolean function_result = FALSE; + function_result = login1_call_function ("Reboot", g_variant_new("(b)",0), TRUE, error); + if (!function_result) + function_result = ck_call_function ("Restart", TRUE, error); + return function_result; } /** @@ -185,7 +243,11 @@ gboolean lightdm_get_can_shutdown (void) { - return ck_call_function ("CanStop", FALSE, NULL); + gboolean function_result = FALSE; + function_result = login1_call_function ("CanPowerOff", NULL, FALSE, NULL); + if (!function_result) + function_result = ck_call_function ("CanStop", FALSE, NULL); + return function_result; } /** @@ -199,5 +261,9 @@ gboolean lightdm_shutdown (GError **error) { - return ck_call_function ("Stop", TRUE, error); + gboolean function_result = FALSE; + function_result = login1_call_function ("PowerOff", g_variant_new("(b)",0), TRUE, error); + if (!function_result) + function_result = ck_call_function ("Stop", TRUE, error); + return function_result; }
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 7995
:
3270
|
3272
| 3273