diff options
author | Edward Sheldrake <ejsheldrake@gmail.com> | 2012-04-25 09:29:46 +0100 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2012-04-30 15:38:31 -0400 |
commit | 67d91afb77a162961c1dd86634a6ebe0136ac7a2 (patch) | |
tree | c53affee0bb8eeb44513a983e38962dc727fda41 | |
parent | 06db2b1bcfa75cbb0cd58368e1ac0f1dcd0d7d52 (diff) | |
download | gdm-67d91afb77a162961c1dd86634a6ebe0136ac7a2.tar.gz |
greeter: use org.freedesktop.login1 to shutdown
To make the restart and shutdown menu items in the fallback greeter
function without ConsoleKit, try the org.freedesktop.login1.Manager dbus
interface first. If that interface is not present, fallback to ConsoleKit.
Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=674741
-rw-r--r-- | gui/simple-greeter/gdm-greeter-panel.c | 91 |
1 files changed, 67 insertions, 24 deletions
diff --git a/gui/simple-greeter/gdm-greeter-panel.c b/gui/simple-greeter/gdm-greeter-panel.c index 552e6fa9..ba6f8102 100644 --- a/gui/simple-greeter/gdm-greeter-panel.c +++ b/gui/simple-greeter/gdm-greeter-panel.c @@ -56,6 +56,10 @@ #define CK_MANAGER_PATH "/org/freedesktop/ConsoleKit/Manager" #define CK_MANAGER_INTERFACE "org.freedesktop.ConsoleKit.Manager" +#define LOGIN1_NAME "org.freedesktop.login1" +#define LOGIN1_PATH "/org/freedesktop/login1" +#define LOGIN1_INTERFACE "org.freedesktop.login1.Manager" + #define GPM_DBUS_NAME "org.gnome.SettingsDaemon" #define GPM_DBUS_PATH "/org/gnome/SettingsDaemon/Power" #define GPM_DBUS_INTERFACE "org.gnome.SettingsDaemon.Power" @@ -630,18 +634,38 @@ try_system_stop (DBusGConnection *connection, g_debug ("GdmGreeterPanel: trying to stop system"); - proxy = dbus_g_proxy_new_for_name (connection, - CK_NAME, - CK_MANAGER_PATH, - CK_MANAGER_INTERFACE); - res = dbus_g_proxy_call_with_timeout (proxy, - "Stop", - INT_MAX, - error, - /* parameters: */ - G_TYPE_INVALID, - /* return values: */ - G_TYPE_INVALID); + /* try systemd first */ + proxy = dbus_g_proxy_new_for_name_owner (connection, + LOGIN1_NAME, + LOGIN1_PATH, + LOGIN1_INTERFACE, + error); + if (proxy) { + res = dbus_g_proxy_call_with_timeout (proxy, + "PowerOff", + INT_MAX, + error, + /* parameters: */ + G_TYPE_BOOLEAN, + TRUE, + G_TYPE_INVALID, + /* return values: */ + G_TYPE_INVALID); + } else { + proxy = dbus_g_proxy_new_for_name (connection, + CK_NAME, + CK_MANAGER_PATH, + CK_MANAGER_INTERFACE); + res = dbus_g_proxy_call_with_timeout (proxy, + "Stop", + INT_MAX, + error, + /* parameters: */ + G_TYPE_INVALID, + /* return values: */ + G_TYPE_INVALID); + } + return res; } @@ -654,18 +678,37 @@ try_system_restart (DBusGConnection *connection, g_debug ("GdmGreeterPanel: trying to restart system"); - proxy = dbus_g_proxy_new_for_name (connection, - CK_NAME, - CK_MANAGER_PATH, - CK_MANAGER_INTERFACE); - res = dbus_g_proxy_call_with_timeout (proxy, - "Restart", - INT_MAX, - error, - /* parameters: */ - G_TYPE_INVALID, - /* return values: */ - G_TYPE_INVALID); + /* try systemd first */ + proxy = dbus_g_proxy_new_for_name_owner (connection, + LOGIN1_NAME, + LOGIN1_PATH, + LOGIN1_INTERFACE, + error); + if (proxy) { + res = dbus_g_proxy_call_with_timeout (proxy, + "Reboot", + INT_MAX, + error, + /* parameters: */ + G_TYPE_BOOLEAN, + TRUE, + G_TYPE_INVALID, + /* return values: */ + G_TYPE_INVALID); + } else { + proxy = dbus_g_proxy_new_for_name (connection, + CK_NAME, + CK_MANAGER_PATH, + CK_MANAGER_INTERFACE); + res = dbus_g_proxy_call_with_timeout (proxy, + "Restart", + INT_MAX, + error, + /* parameters: */ + G_TYPE_INVALID, + /* return values: */ + G_TYPE_INVALID); + } return res; } |