diff options
author | Nick Schermer <nick@xfce.org> | 2012-04-13 19:19:14 +0200 |
---|---|---|
committer | Nick Schermer <nick@xfce.org> | 2012-04-13 19:19:45 +0200 |
commit | 5992ea6bbfd19ec44df276e704b403320cfe6779 (patch) | |
tree | 1eae2c9361e0a901a895a1ba71f510aedae9b82a /xfce4-session-logout | |
parent | ae4cdddc8a0165cfed353c76ef042ca2b0b9ffb3 (diff) | |
download | xfce4-session-5992ea6bbfd19ec44df276e704b403320cfe6779.tar.gz |
Fallback to old method for shutdown (bug #8630).
Diffstat (limited to 'xfce4-session-logout')
-rw-r--r-- | xfce4-session-logout/main.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/xfce4-session-logout/main.c b/xfce4-session-logout/main.c index 1bc73cd2..5af54c6f 100644 --- a/xfce4-session-logout/main.c +++ b/xfce4-session-logout/main.c @@ -51,6 +51,16 @@ gboolean opt_hibernate = FALSE; gboolean allow_save = FALSE; gboolean opt_version = FALSE; +enum +{ + XFSM_SHUTDOWN_ASK = 0, + XFSM_SHUTDOWN_LOGOUT, + XFSM_SHUTDOWN_HALT, + XFSM_SHUTDOWN_REBOOT, + XFSM_SHUTDOWN_SUSPEND, + XFSM_SHUTDOWN_HIBERNATE +}; + static GOptionEntry option_entries[] = { { "logout", 'l', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &opt_logout, @@ -112,6 +122,7 @@ main (int argc, char **argv) gboolean have_display; gboolean show_dialog; gboolean result = FALSE; + guint shutdown_type; xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); @@ -178,6 +189,32 @@ main (int argc, char **argv) } } + /* fallback for the old 4.8 API dbus, so users can logout if + * they upgraded their system, see bug #8630 */ + if (!result && g_error_matches (err, DBUS_GERROR, DBUS_GERROR_UNKNOWN_METHOD)) + { + g_clear_error (&err); + + if (opt_logout) + shutdown_type = XFSM_SHUTDOWN_LOGOUT; + else if (opt_halt) + shutdown_type = XFSM_SHUTDOWN_HALT; + else if (opt_reboot) + shutdown_type = XFSM_SHUTDOWN_REBOOT; + else if (opt_suspend) + shutdown_type = XFSM_SHUTDOWN_SUSPEND; + else if (opt_hibernate) + shutdown_type = XFSM_SHUTDOWN_HIBERNATE; + else + shutdown_type = XFSM_SHUTDOWN_ASK; + + result = dbus_g_proxy_call (proxy, "Shutdown", &err, + G_TYPE_UINT, shutdown_type, + G_TYPE_BOOLEAN, allow_save, + G_TYPE_INVALID, G_TYPE_INVALID); + } + + if (proxy != NULL) g_object_unref (proxy); |