aboutsummaryrefslogtreecommitdiff
path: root/src/gtk-dialog
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-07-23 15:56:04 -0500
committerTed Gould <ted@canonical.com>2009-07-23 15:56:04 -0500
commit04c5db216a561b9232df1e7626a852ff8df9cbf1 (patch)
treeb256ece41367ed68bf5bed88ed8b9b1d91432d10 /src/gtk-dialog
parent624c4acbd0c256f5cf8e7067e8dab935bf6c2b5f (diff)
downloadayatana-indicator-session-04c5db216a561b9232df1e7626a852ff8df9cbf1.tar.gz
ayatana-indicator-session-04c5db216a561b9232df1e7626a852ff8df9cbf1.tar.bz2
ayatana-indicator-session-04c5db216a561b9232df1e7626a852ff8df9cbf1.zip
Adding in the action code from our previous patches to FUSA
Diffstat (limited to 'src/gtk-dialog')
-rw-r--r--src/gtk-dialog/gtk-logout-helper.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/gtk-dialog/gtk-logout-helper.c b/src/gtk-dialog/gtk-logout-helper.c
index c7f67a5..75ab63f 100644
--- a/src/gtk-dialog/gtk-logout-helper.c
+++ b/src/gtk-dialog/gtk-logout-helper.c
@@ -1,9 +1,66 @@
#include <glib.h>
#include <gtk/gtk.h>
+#include <dbus/dbus-glib.h>
#include "logout-dialog.h"
#include "ck-pk-helper.h"
+static void
+session_action (LogoutDialogAction action)
+{
+ DBusGConnection * sbus;
+ DBusGProxy * sm_proxy;
+ GError * error = NULL;
+ gboolean res = FALSE;
+
+ sbus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
+ if (sbus == NULL) {
+ g_warning("Unable to get DBus session bus.");
+ return;
+ }
+ sm_proxy = dbus_g_proxy_new_for_name_owner (sbus,
+ "org.gnome.SessionManager",
+ "/org/gnome/SessionManager",
+ "org.gnome.SessionManager",
+ &error);
+ if (sm_proxy == NULL) {
+ g_warning("Unable to get DBus proxy to SessionManager interface: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ g_clear_error (&error);
+
+ if (action == LOGOUT_DIALOG_LOGOUT) {
+ res = dbus_g_proxy_call_with_timeout (sm_proxy, "Logout", INT_MAX, &error,
+ G_TYPE_UINT, 1, G_TYPE_INVALID, G_TYPE_INVALID);
+ } else if (action == LOGOUT_DIALOG_SHUTDOWN) {
+ res = dbus_g_proxy_call_with_timeout (sm_proxy, "RequestShutdown", INT_MAX, &error,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+ } else if (action == LOGOUT_DIALOG_RESTART) {
+ res = dbus_g_proxy_call_with_timeout (sm_proxy, "RequestReboot", INT_MAX, &error,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+ } else {
+ g_warning ("Unknown session action");
+ }
+
+ if (!res) {
+ if (error != NULL) {
+ g_warning ("SessionManager action failed: %s", error->message);
+ } else {
+ g_warning ("SessionManager action failed: unknown error");
+ }
+ }
+
+ g_object_unref(sm_proxy);
+
+ if (error != NULL) {
+ g_error_free(error);
+ }
+
+ return;
+}
+
static LogoutDialogAction type = LOGOUT_DIALOG_LOGOUT;
static gboolean
@@ -71,5 +128,7 @@ main (int argc, char * argv[])
}
}
+ session_action(type);
+
return 0;
}