Merge lp:~ted/indicator-session/no-gs-fallback into lp:indicator-session/0.1

Proposed by Ted Gould
Status: Merged
Merged at revision: not available
Proposed branch: lp:~ted/indicator-session/no-gs-fallback
Merge into: lp:indicator-session/0.1
Diff against target: 56 lines (+40/-0)
1 file modified
src/gtk-dialog/gtk-logout-helper.c (+40/-0)
To merge this branch: bzr merge lp:~ted/indicator-session/no-gs-fallback
Reviewer Review Type Date Requested Status
Indicator Applet Developers Pending
Review via email: mp+20091@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

This code makes it so that if we can't get a proxy to the gnome-session,
we can still bring the machine down. This is also for cases where
people have chosen not to use gnome-session.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/gtk-dialog/gtk-logout-helper.c'
2--- src/gtk-dialog/gtk-logout-helper.c 2009-09-24 17:24:09 +0000
3+++ src/gtk-dialog/gtk-logout-helper.c 2010-02-24 22:50:27 +0000
4@@ -30,6 +30,44 @@
5 #include "gconf-helper.h"
6
7 static void
8+consolekit_fallback (LogoutDialogAction action)
9+{
10+ DBusGConnection * sbus = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
11+ g_return_if_fail(sbus != NULL); /* worst case */
12+ DBusGProxy * proxy = dbus_g_proxy_new_for_name(sbus, "org.freedesktop.ConsoleKit",
13+ "/org/freedesktop/ConsoleKit/Manager",
14+ "org.freedesktop.ConsoleKit.Manager");
15+
16+ if (proxy == NULL) {
17+ g_warning("Unable to get consolekit proxy");
18+ return;
19+ }
20+
21+ switch (action) {
22+ case LOGOUT_DIALOG_LOGOUT:
23+ g_warning("Unable to fallback to ConsoleKit for logout as it's a session issue. We need some sort of session handler.");
24+ break;
25+ case LOGOUT_DIALOG_SHUTDOWN:
26+ dbus_g_proxy_call_no_reply(proxy,
27+ "Stop",
28+ G_TYPE_INVALID);
29+ break;
30+ case LOGOUT_DIALOG_RESTART:
31+ dbus_g_proxy_call_no_reply(proxy,
32+ "Restart",
33+ G_TYPE_INVALID);
34+ break;
35+ default:
36+ g_warning("Unknown action");
37+ break;
38+ }
39+
40+ g_object_unref(proxy);
41+
42+ return;
43+}
44+
45+static void
46 session_action (LogoutDialogAction action)
47 {
48 DBusGConnection * sbus;
49@@ -50,6 +88,8 @@
50 if (sm_proxy == NULL) {
51 g_warning("Unable to get DBus proxy to SessionManager interface: %s", error->message);
52 g_error_free(error);
53+
54+ consolekit_fallback(action);
55 return;
56 }
57

Subscribers

People subscribed via source and target branches