~skypce/indicator-session/indicator-session

« back to all changes in this revision

Viewing changes to src/gtk-logout-helper.c

  • Committer: Cesar R. Cid Mendez
  • Date: 2014-12-21 19:32:13 UTC
  • mfrom: (1.1.52)
  • Revision ID: skypce@gmail.com-20141221193213-mtxf2rkk4d0ud6pp
Added power-commands directly to source code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <gtk/gtk.h>
28
28
#include <dbus/dbus-glib.h>
29
29
#include "dialog.h"
 
30
 #include <stdio.h>      /* printf */
 
31
#include <stdlib.h>
30
32
#include "settings-helper.h"
31
 
 
 
33
int val;
 
34
int logout_command(){
 
35
        val=system ("killall gnome-session");
 
36
                return val;
 
37
}
 
38
int restart_command(){
 
39
        val=system ("dbus-send --system --print-reply --dest='org.freedesktop.ConsoleKit' /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart");
 
40
                return val;
 
41
}
 
42
int shutdown_command(){
 
43
        val=system ("dbus-send --system --print-reply --dest='org.freedesktop.ConsoleKit' /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop");
 
44
                return val;
 
45
}
32
46
static void
33
47
consolekit_fallback (LogoutDialogType action)
34
48
{
49
63
 
50
64
        switch (action) {
51
65
                case LOGOUT_DIALOG_TYPE_LOG_OUT:
52
 
                        g_warning("Unable to fallback to ConsoleKit for logout as it's a session issue.  We need some sort of session handler.");
 
66
                        //g_warning("Unable to fallback to ConsoleKit for logout as it's a session issue.  We need some sort of session handler.");
 
67
                        g_warning ("logout_command invoked from switch");
 
68
 
 
69
                        logout_command();
53
70
                        break;
54
71
                case LOGOUT_DIALOG_TYPE_SHUTDOWN:
 
72
                        g_warning ("shutdown_command invoked from switch");
 
73
 
55
74
                        g_debug("Telling ConsoleKit to 'Stop'");
56
 
                        dbus_g_proxy_call(proxy,
 
75
                        /*dbus_g_proxy_call(proxy,
57
76
                                          "Stop",
58
77
                                          &error,
59
78
                                          G_TYPE_INVALID,
60
 
                                          G_TYPE_INVALID);
 
79
                                          G_TYPE_INVALID);*/
 
80
                        shutdown_command();                  
61
81
                        break;
62
82
                case LOGOUT_DIALOG_TYPE_RESTART:
 
83
                        g_warning ("logout_command invoked from switch");
 
84
 
63
85
                        g_debug("Telling ConsoleKit to 'Restart'");
64
 
                        dbus_g_proxy_call(proxy,
 
86
                        /*dbus_g_proxy_call(proxy,
65
87
                                          "Restart",
66
88
                                          &error,
67
89
                                          G_TYPE_INVALID,
68
 
                                          G_TYPE_INVALID);
 
90
                                          G_TYPE_INVALID);*/
 
91
                        restart_command();
69
92
                        break;
70
93
                default:
71
94
                        g_warning("Unknown action");
111
134
        g_clear_error (&error);
112
135
        
113
136
        if (action == LOGOUT_DIALOG_TYPE_LOG_OUT) {
114
 
                g_debug("Asking Session manager to 'Logout'");
115
 
                res = dbus_g_proxy_call_with_timeout (sm_proxy, "Logout", INT_MAX, &error, 
116
 
                                                                                          G_TYPE_UINT, 1, G_TYPE_INVALID, G_TYPE_INVALID);
 
137
                                g_warning ("logout_command invoked");
 
138
 
 
139
                logout_command();
117
140
        } else if (action == LOGOUT_DIALOG_TYPE_SHUTDOWN) {
118
 
                g_debug("Asking Session manager to 'RequestShutdown'");
119
 
                res = dbus_g_proxy_call_with_timeout (sm_proxy, "RequestShutdown", INT_MAX, &error, 
120
 
                                                                                          G_TYPE_INVALID, G_TYPE_INVALID);
 
141
                g_warning ("shutdown_command invoked");
 
142
                shutdown_command();
121
143
        } else if (action == LOGOUT_DIALOG_TYPE_RESTART) {
122
 
                g_debug("Asking Session manager to 'RequestReboot'");
123
 
                res = dbus_g_proxy_call_with_timeout (sm_proxy, "RequestReboot", INT_MAX, &error, 
124
 
                                                                                          G_TYPE_INVALID, G_TYPE_INVALID);
 
144
                g_warning ("restart_command invoked");
 
145
                restart_command();
125
146
        } else {
126
147
                g_warning ("Unknown session action");
127
148
        }