Merge lp:~laney/indicator-session/logind-port into lp:indicator-session/13.10

Proposed by Iain Lane
Status: Merged
Approved by: Mathieu Trudel-Lapierre
Approved revision: 393
Merged at revision: 388
Proposed branch: lp:~laney/indicator-session/logind-port
Merge into: lp:indicator-session/13.10
Diff against target: 2813 lines (+657/-1650)
14 files modified
src/Makefile.am (+39/-53)
src/dialog.c (+17/-17)
src/gtk-logout-helper.c (+14/-16)
src/org.freedesktop.ConsoleKit.Manager.xml (+0/-353)
src/org.freedesktop.ConsoleKit.Seat.xml (+0/-164)
src/org.freedesktop.ConsoleKit.Session.xml (+0/-435)
src/org.freedesktop.login1.Manager.xml (+199/-0)
src/org.freedesktop.login1.Seat.xml (+21/-0)
src/org.freedesktop.login1.Session.xml (+49/-0)
src/org.freedesktop.login1.User.xml (+56/-0)
src/session-menu-mgr.c (+58/-100)
src/upower.xml (+0/-309)
src/users-service-dbus.c (+202/-200)
src/users-service-dbus.h (+2/-3)
To merge this branch: bzr merge lp:~laney/indicator-session/logind-port
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+160096@code.launchpad.net

Commit message

Stop using ConsoleKit and UPower for session tracking and shutdown/reboot/suspend/hibernate; migrate to logind.

Description of the change

Stop using ConsoleKit and UPower; migrate to logind.

I don't know the proper way to get the .xml files for input to gdbus-codegen so I generated these with gdbus introspect --xml. Hope that's OK, otherwise I'm happy to fix it if someone can tell me what the proper way is. :-)

Style error spotting appreciated. After a while you stop being able to notice such things.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Should get rid of that comment too:

1845 /* maybe the seat doesn't support activation */

The rest looks fine to me.

review: Approve
394. By Iain Lane

Remove stray comment

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2012-10-03 19:35:57 +0000
+++ src/Makefile.am 2013-04-22 12:49:38 +0000
@@ -43,34 +43,34 @@
43 --generate-c-code dbus-display-manager \43 --generate-c-code dbus-display-manager \
44 $^44 $^
4545
46dbus_consolekit_manager_sources = \46dbus_login1_manager_sources = \
47 dbus-consolekit-manager.c \47 dbus-login1-manager.c \
48 dbus-consolekit-manager.h48 dbus-login1-manager.h
4949
50$(dbus_consolekit_manager_sources): org.freedesktop.ConsoleKit.Manager.xml50$(dbus_login1_manager_sources): org.freedesktop.login1.Manager.xml
51 $(AM_V_GEN) gdbus-codegen \51 $(AM_V_GEN) gdbus-codegen \
52 --interface-prefix org.freedesktop \52 --interface-prefix org.freedesktop \
53 --generate-c-code dbus-consolekit-manager \53 --generate-c-code dbus-login1-manager \
54 $^54 $^
5555
56dbus_consolekit_seat_sources = \56dbus_login1_session_sources = \
57 dbus-consolekit-seat.c \57 dbus-login1-session.c \
58 dbus-consolekit-seat.h58 dbus-login1-session.h
5959
60$(dbus_consolekit_seat_sources): org.freedesktop.ConsoleKit.Seat.xml60$(dbus_login1_session_sources): org.freedesktop.login1.Session.xml
61 $(AM_V_GEN) gdbus-codegen \61 $(AM_V_GEN) gdbus-codegen \
62 --interface-prefix org.freedesktop \62 --interface-prefix org.freedesktop \
63 --generate-c-code dbus-consolekit-seat \63 --generate-c-code dbus-login1-session \
64 $^64 $^
6565
66dbus_consolekit_session_sources = \66dbus_login1_user_sources = \
67 dbus-consolekit-session.c \67 dbus-login1-user.c \
68 dbus-consolekit-session.h68 dbus-login1-user.h
6969
70$(dbus_consolekit_session_sources): org.freedesktop.ConsoleKit.Session.xml70$(dbus_login1_user_sources): org.freedesktop.login1.User.xml
71 $(AM_V_GEN) gdbus-codegen \71 $(AM_V_GEN) gdbus-codegen \
72 --interface-prefix org.freedesktop \72 --interface-prefix org.freedesktop \
73 --generate-c-code dbus-consolekit-session \73 --generate-c-code dbus-login1-user \
74 $^74 $^
7575
76dbus_accounts_sources = \76dbus_accounts_sources = \
@@ -92,17 +92,6 @@
92 --interface-prefix org.freedesktop \92 --interface-prefix org.freedesktop \
93 --generate-c-code dbus-user \93 --generate-c-code dbus-user \
94 $^94 $^
95
96dbus_upower_sources = \
97 dbus-upower.c \
98 dbus-upower.h
99
100$(dbus_upower_sources): upower.xml
101 $(AM_V_GEN) gdbus-codegen \
102 --interface-prefix org.freedesktop \
103 --generate-c-code dbus-upower \
104 --c-namespace DBus \
105 $^
10695
107gen-%.xml.c: %.xml96gen-%.xml.c: %.xml
108 @echo "Building $@ from $<"97 @echo "Building $@ from $<"
@@ -120,11 +109,10 @@
120109
121indicator_session_service_SOURCES = \110indicator_session_service_SOURCES = \
122 $(dbus_accounts_sources) \111 $(dbus_accounts_sources) \
123 $(dbus_consolekit_manager_sources) \112 $(dbus_login1_manager_sources) \
124 $(dbus_consolekit_seat_sources) \113 $(dbus_login1_user_sources) \
125 $(dbus_consolekit_session_sources) \114 $(dbus_login1_session_sources) \
126 $(dbus_display_manager_sources) \115 $(dbus_display_manager_sources) \
127 $(dbus_upower_sources) \
128 $(dbus_user_sources) \116 $(dbus_user_sources) \
129 session-service.c \117 session-service.c \
130 session-dbus.c \118 session-dbus.c \
@@ -156,7 +144,7 @@
156144
157if BUILD_GTKLOGOUTHELPER145if BUILD_GTKLOGOUTHELPER
158gtk_logout_helper_SOURCES = \146gtk_logout_helper_SOURCES = \
159 $(dbus_consolekit_manager_sources) \147 $(dbus_login1_manager_sources) \
160 gtk-logout-helper.c \148 gtk-logout-helper.c \
161 dialog.c \149 dialog.c \
162 dialog.h150 dialog.h
@@ -185,11 +173,10 @@
185173
186BUILT_SOURCES = \174BUILT_SOURCES = \
187 $(dbus_accounts_sources) \175 $(dbus_accounts_sources) \
188 $(dbus_consolekit_manager_sources) \176 $(dbus_login1_manager_sources) \
189 $(dbus_consolekit_seat_sources) \177 $(dbus_login1_user_sources) \
190 $(dbus_consolekit_session_sources) \178 $(dbus_login1_session_sources) \
191 $(dbus_display_manager_sources) \179 $(dbus_display_manager_sources) \
192 $(dbus_upower_sources) \
193 $(dbus_user_sources) \180 $(dbus_user_sources) \
194 gen-session-dbus.xml.c \181 gen-session-dbus.xml.c \
195 gen-session-dbus.xml.h182 gen-session-dbus.xml.h
@@ -198,10 +185,9 @@
198 display-manager.xml \185 display-manager.xml \
199 org.freedesktop.Accounts.User.xml \186 org.freedesktop.Accounts.User.xml \
200 org.freedesktop.Accounts.xml \187 org.freedesktop.Accounts.xml \
201 org.freedesktop.ConsoleKit.Manager.xml \188 org.freedesktop.login1.Manager.xml \
202 org.freedesktop.ConsoleKit.Seat.xml \189 org.freedesktop.login1.Session.xml \
203 org.freedesktop.ConsoleKit.Session.xml \190 org.freedesktop.login1.User.xml \
204 session-dbus.xml \191 session-dbus.xml
205 upower.xml
206192
207CLEANFILES += $(BUILT_SOURCES)193CLEANFILES += $(BUILT_SOURCES)
208194
=== modified file 'src/dialog.c'
--- src/dialog.c 2012-10-03 19:35:57 +0000
+++ src/dialog.c 2013-04-22 12:49:38 +0000
@@ -26,7 +26,7 @@
2626
27#include <glib/gi18n.h>27#include <glib/gi18n.h>
2828
29#include "dbus-consolekit-manager.h"29#include "dbus-login1-manager.h"
30#include "dialog.h"30#include "dialog.h"
3131
32/* Strings */32/* Strings */
@@ -133,35 +133,35 @@
133 return g_file_test("/var/run/reboot-required", G_FILE_TEST_EXISTS);133 return g_file_test("/var/run/reboot-required", G_FILE_TEST_EXISTS);
134}134}
135135
136/* Checks with console kit to see if we can do what we want */136/* Checks with logind to see if we can do what we want */
137static gboolean137static gboolean
138ck_check_allowed (LogoutDialogType type)138logind_check_allowed (LogoutDialogType type)
139{139{
140 gboolean allowed = TRUE;140 gchar * allowed = NULL;
141141
142 ConsoleKitManager * ck_proxy = console_kit_manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,142 Login1Manager * manager_proxy = login1_manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
143 G_DBUS_PROXY_FLAGS_NONE,143 G_DBUS_PROXY_FLAGS_NONE,
144 "org.freedesktop.ConsoleKit",144 "org.freedesktop.login1",
145 "/org/freedesktop/ConsoleKit/Manager",145 "/org/freedesktop/login1",
146 NULL,146 NULL,
147 NULL);147 NULL);
148 if (ck_proxy != NULL)148 if (manager_proxy != NULL)
149 {149 {
150 switch (type) {150 switch (type) {
151 case LOGOUT_DIALOG_TYPE_RESTART:151 case LOGOUT_DIALOG_TYPE_RESTART:
152 console_kit_manager_call_can_restart_sync (ck_proxy, &allowed, NULL, NULL);152 login1_manager_call_can_reboot_sync (manager_proxy, &allowed, NULL, NULL);
153 break;153 break;
154 case LOGOUT_DIALOG_TYPE_SHUTDOWN:154 case LOGOUT_DIALOG_TYPE_SHUTDOWN:
155 console_kit_manager_call_can_stop_sync (ck_proxy, &allowed, NULL, NULL);155 login1_manager_call_can_power_off_sync (manager_proxy, &allowed, NULL, NULL);
156 break;156 break;
157 default:157 default:
158 break;158 break;
159 }159 }
160160
161 g_object_unref(ck_proxy);161 g_object_unref(manager_proxy);
162 }162 }
163163
164 return allowed;164 return g_strcmp0 (allowed, "yes") == 0;
165}165}
166166
167LogoutDialog *167LogoutDialog *
@@ -188,9 +188,9 @@
188188
189 gboolean allowed = FALSE;189 gboolean allowed = FALSE;
190 if (type == LOGOUT_DIALOG_TYPE_LOG_OUT) {190 if (type == LOGOUT_DIALOG_TYPE_LOG_OUT) {
191 allowed = ck_check_allowed(LOGOUT_DIALOG_TYPE_RESTART);191 allowed = logind_check_allowed(LOGOUT_DIALOG_TYPE_RESTART);
192 } else {192 } else {
193 allowed = ck_check_allowed(type);193 allowed = logind_check_allowed(type);
194 }194 }
195195
196 gboolean restart_required = FALSE;196 gboolean restart_required = FALSE;
197197
=== modified file 'src/gtk-logout-helper.c'
--- src/gtk-logout-helper.c 2012-11-29 22:09:57 +0000
+++ src/gtk-logout-helper.c 2013-04-22 12:49:38 +0000
@@ -31,7 +31,7 @@
31#include "shared-names.h"31#include "shared-names.h"
3232
33static GVariant *33static GVariant *
34call_console_kit (const gchar *method, GVariant *parameters, GError **error)34call_logind (const gchar *method, GVariant *parameters, GError **error)
35{35{
36 GDBusConnection * bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, error);36 GDBusConnection * bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, error);
37 if (!bus)37 if (!bus)
@@ -41,9 +41,9 @@
41 }41 }
4242
43 GVariant *result = g_dbus_connection_call_sync(bus,43 GVariant *result = g_dbus_connection_call_sync(bus,
44 "org.freedesktop.ConsoleKit",44 "org.freedesktop.login1",
45 "/org/freedesktop/ConsoleKit/Manager",45 "/org/freedesktop/login1",
46 "org.freedesktop.ConsoleKit.Manager",46 "org.freedesktop.login1.Manager",
47 method,47 method,
48 parameters,48 parameters,
49 NULL,49 NULL,
@@ -57,24 +57,24 @@
57}57}
5858
59static void59static void
60consolekit_fallback (LogoutDialogType action)60logind_fallback (LogoutDialogType action)
61{61{
62 GError * error = NULL;62 GError * error = NULL;
63 GVariant *result = NULL;63 GVariant *result = NULL;
6464
65 g_debug("Falling back to using ConsoleKit for action");65 g_debug("Falling back to using logind for action");
6666
67 switch (action) {67 switch (action) {
68 case LOGOUT_DIALOG_TYPE_LOG_OUT:68 case LOGOUT_DIALOG_TYPE_LOG_OUT:
69 g_warning("Unable to fallback to ConsoleKit for logout as it's a session issue. We need some sort of session handler.");69 g_warning("Unable to fallback to logind for logout as it's a session issue. We need some sort of session handler.");
70 break;70 break;
71 case LOGOUT_DIALOG_TYPE_SHUTDOWN:71 case LOGOUT_DIALOG_TYPE_SHUTDOWN:
72 g_debug("Telling ConsoleKit to 'Stop'");72 g_debug("Telling logind to 'PowerOff'");
73 result = call_console_kit ("Stop", g_variant_new ("()"), &error);73 result = call_logind ("PowerOff", g_variant_new ("(b)", FALSE), &error);
74 break;74 break;
75 case LOGOUT_DIALOG_TYPE_RESTART:75 case LOGOUT_DIALOG_TYPE_RESTART:
76 g_debug("Telling ConsoleKit to 'Restart'");76 g_debug("Telling logind to 'Reboot'");
77 result = call_console_kit ("Restart", g_variant_new ("()"), &error);77 result = call_logind ("Reboot", g_variant_new ("(b)", FALSE), &error);
78 break;78 break;
79 default:79 default:
80 g_warning("Unknown action");80 g_warning("Unknown action");
@@ -83,12 +83,10 @@
8383
84 if (!result) {84 if (!result) {
85 if (error != NULL) {85 if (error != NULL) {
86 g_warning ("ConsoleKit action failed: %s", error->message);86 g_warning ("logind action failed: %s", error->message);
87 } else {87 } else {
88 g_warning ("ConsoleKit action failed: unknown error");88 g_warning ("logind action failed: unknown error");
89 }89 }
90
91 consolekit_fallback(action);
92 }90 }
93 else91 else
94 g_variant_unref (result);92 g_variant_unref (result);
@@ -149,7 +147,7 @@
149 g_warning ("SessionManager action failed: unknown error");147 g_warning ("SessionManager action failed: unknown error");
150 }148 }
151149
152 consolekit_fallback(action);150 logind_fallback(action);
153 }151 }
154 else152 else
155 g_variant_unref (result);153 g_variant_unref (result);
156154
=== removed file 'src/org.freedesktop.ConsoleKit.Manager.xml'
--- src/org.freedesktop.ConsoleKit.Manager.xml 2011-08-17 20:53:51 +0000
+++ src/org.freedesktop.ConsoleKit.Manager.xml 1970-01-01 00:00:00 +0000
@@ -1,353 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<node name="/org/freedesktop/ConsoleKit/Manager"
3 xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"
4>
5
6 <interface name="org.freedesktop.ConsoleKit.Manager">
7 <method name="Restart">
8 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
9 <doc:doc>
10 <doc:description>
11 <doc:para>This method initiates a request to restart (ie. reboot) the computer system.</doc:para>
12 </doc:description>
13 </doc:doc>
14 </method>
15
16 <method name="CanRestart">
17 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
18 <arg name="can_restart" type="b" direction="out"/>
19 </method>
20
21 <method name="Stop">
22 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
23 <doc:doc>
24 <doc:description>
25 <doc:para>This method initiates a request to stop (ie. shutdown) the computer system.</doc:para>
26 </doc:description>
27 </doc:doc>
28 </method>
29
30 <method name="CanStop">
31 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
32 <arg name="can_stop" type="b" direction="out"/>
33 </method>
34
35 <method name="OpenSession">
36 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
37 <arg name="cookie" direction="out" type="s">
38 <doc:doc>
39 <doc:summary>The secret cookie that is used to identify the new session</doc:summary>
40 </doc:doc>
41 </arg>
42 <doc:doc>
43 <doc:description>
44 <doc:para>This method requests that a new <doc:ref type="interface" to="Session">Session</doc:ref>
45 be created for the calling process. The properties of this new Session are set automatically
46 from information collected about the calling process.
47 </doc:para>
48 <doc:para>This new session exists until the calling process disconnects from the system bus or
49 calls <doc:ref type="method" to="Manager.CloseSession">CloseSession()</doc:ref>.
50 </doc:para>
51 <doc:para>It is the responsibility of the calling process to set the environment variable
52 XDG_SESSION_COOKIE to the value of the returned cookie. This cookie should only
53 be made available to child processes of the caller so that they may be identified
54 as members of this session.
55 </doc:para>
56 <doc:para>See this simple example:
57 <doc:example language="c" title="simple example"><doc:code>
58 DBusError error;
59 DBusMessage *message;
60 DBusMessage *reply;
61
62 message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit",
63 "/org/freedesktop/ConsoleKit/Manager",
64 "org.freedesktop.ConsoleKit.Manager",
65 "OpenSession");
66 if (message == NULL) {
67 goto out;
68 }
69
70 dbus_error_init (&amp;error);
71 reply = dbus_connection_send_with_reply_and_block (connector->connection,
72 message,
73 -1,
74 &amp;error);
75 if (reply == NULL) {
76 goto out;
77 }
78
79 dbus_error_init (&amp;error);
80 if (! dbus_message_get_args (reply,
81 &amp;error,
82 DBUS_TYPE_STRING, &amp;cookie,
83 DBUS_TYPE_INVALID)) {
84 goto out;
85 }
86
87 </doc:code></doc:example></doc:para>
88 </doc:description>
89 <doc:seealso><doc:ref type="method" to="Manager.OpenSessionWithParameters">OpenSessionWithParameters()</doc:ref></doc:seealso>
90 </doc:doc>
91 </method>
92 <method name="OpenSessionWithParameters">
93 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
94 <arg name="parameters" direction="in" type="a(sv)">
95 <doc:doc>
96 <doc:summary>An array of sets of property names and values</doc:summary>
97 </doc:doc>
98 </arg>
99 <arg name="cookie" direction="out" type="s">
100 <doc:doc>
101 <doc:summary>The secret cookie that is used to identify the new session</doc:summary>
102 </doc:doc>
103 </arg>
104 <doc:doc>
105 <doc:description>
106 <doc:para>This method requests that a new <doc:ref type="interface" to="Session">Session</doc:ref>
107 be created for the calling process. The properties of this new Session are from the
108 parameters provided.
109 </doc:para>
110 <doc:para>This new session exists until the calling process disconnects from the system bus or
111 calls <doc:ref type="method" to="Manager.CloseSession">CloseSession()</doc:ref>.
112 </doc:para>
113 <doc:para>It is the responsibility of the calling process to set the environment variable
114 XDG_SESSION_COOKIE to the value of the returned cookie. This cookie should only
115 be made available to child processes of the caller so that they may be identified
116 as members of this session.
117 </doc:para>
118 <doc:para>See the <doc:ref type="interface" to="Session">Session</doc:ref> properties for a list of valid parameters.</doc:para>
119 </doc:description>
120 <doc:seealso><doc:ref type="interface" to="Session">org.freedesktop.ConsoleKit.Session</doc:ref></doc:seealso>
121 <doc:permission>This method is restricted to privileged users by D-Bus policy.</doc:permission>
122 </doc:doc>
123 </method>
124 <method name="CloseSession">
125 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
126 <arg name="cookie" direction="in" type="s">
127 <doc:doc>
128 <doc:summary>The secret cookie that is used to identify the session</doc:summary>
129 </doc:doc>
130 </arg>
131 <arg name="result" direction="out" type="b">
132 <doc:doc>
133 <doc:summary>Whether the session was successfully closed</doc:summary>
134 </doc:doc>
135 </arg>
136 <doc:doc>
137 <doc:description>
138 <doc:para>This method is used to close the session identified by the supplied cookie.
139 </doc:para>
140 <doc:para>The session can only be closed by the same process that opened the session.
141 </doc:para>
142 </doc:description>
143 </doc:doc>
144 </method>
145
146 <method name="GetSeats">
147 <arg name="seats" direction="out" type="ao">
148 <doc:doc>
149 <doc:summary>an array of Seat IDs</doc:summary>
150 </doc:doc>
151 </arg>
152 <doc:doc>
153 <doc:description>
154 <doc:para>This gets a list of all the <doc:ref type="interface" to="Seat">Seats</doc:ref>
155 that are currently present on the system.</doc:para>
156 <doc:para>Each Seat ID is an D-Bus object path for the object that implements the
157 <doc:ref type="interface" to="Seat">Seat</doc:ref> interface.</doc:para>
158 </doc:description>
159 <doc:seealso><doc:ref type="interface" to="Seat">org.freedesktop.ConsoleKit.Seat</doc:ref></doc:seealso>
160 </doc:doc>
161 </method>
162
163 <method name="GetSessions">
164 <arg name="sessions" direction="out" type="ao">
165 <doc:doc>
166 <doc:summary>an array of Session IDs</doc:summary>
167 </doc:doc>
168 </arg>
169 <doc:doc>
170 <doc:description>
171 <doc:para>This gets a list of all the <doc:ref type="interface" to="Session">Sessions</doc:ref>
172 that are currently present on the system.</doc:para>
173 <doc:para>Each Session ID is an D-Bus object path for the object that implements the
174 <doc:ref type="interface" to="Session">Session</doc:ref> interface.</doc:para>
175 </doc:description>
176 <doc:seealso><doc:ref type="interface" to="Session">org.freedesktop.ConsoleKit.Session</doc:ref></doc:seealso>
177 </doc:doc>
178 </method>
179
180 <method name="GetSessionForCookie">
181 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
182 <arg name="cookie" direction="in" type="s">
183 <doc:doc>
184 <doc:summary>The secret cookie that is used to identify the session</doc:summary>
185 </doc:doc>
186 </arg>
187 <arg name="ssid" direction="out" type="o">
188 <doc:doc>
189 <doc:summary>The object identifier for the current session</doc:summary>
190 </doc:doc>
191 </arg>
192 <doc:doc>
193 <doc:description>
194 <doc:para>Returns the session ID that is associated with the specified cookie.
195 </doc:para>
196 </doc:description>
197 </doc:doc>
198 </method>
199 <method name="GetSessionForUnixProcess">
200 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
201 <arg name="pid" direction="in" type="u">
202 <doc:doc>
203 <doc:summary>The POSIX process ID</doc:summary>
204 </doc:doc>
205 </arg>
206 <arg name="ssid" direction="out" type="o">
207 <doc:doc>
208 <doc:summary>The object identifier for the current session</doc:summary>
209 </doc:doc>
210 </arg>
211 <doc:doc>
212 <doc:description>
213 <doc:para>Attempts to determine the session ID for the specified
214 POSIX process ID (pid).
215 </doc:para>
216 </doc:description>
217 </doc:doc>
218 </method>
219 <method name="GetCurrentSession">
220 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
221 <arg name="ssid" direction="out" type="o">
222 <doc:doc>
223 <doc:summary>The object identifier for the current session</doc:summary>
224 </doc:doc>
225 </arg>
226 <doc:doc>
227 <doc:description>
228 <doc:para>Attempts to determine the session ID that the caller belongs to.
229 </doc:para>
230 <doc:para>See this example of using dbus-send:
231 <doc:example language="shell" title="shell example"><doc:code>
232 dbus-send --system --dest=org.freedesktop.ConsoleKit \
233 --type=method_call --print-reply --reply-timeout=2000 \
234 /org/freedesktop/ConsoleKit/Manager \
235 org.freedesktop.ConsoleKit.Manager.GetCurrentSession
236 </doc:code></doc:example></doc:para>
237 </doc:description>
238 </doc:doc>
239 </method>
240 <method name="GetSessionsForUnixUser">
241 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
242 <arg name="uid" direction="in" type="u">
243 <doc:doc>
244 <doc:summary>POSIX User identification</doc:summary>
245 </doc:doc>
246 </arg>
247 <arg name="sessions" direction="out" type="ao">
248 <doc:doc>
249 <doc:summary>an array of Session IDs</doc:summary>
250 </doc:doc>
251 </arg>
252 <doc:doc>
253 <doc:description>
254 <doc:para>This gets a list of all the <doc:ref type="interface" to="Session">Sessions</doc:ref>
255 that are currently open for the specified user.</doc:para>
256 <doc:para>Each Session ID is an D-Bus object path for the object that implements the
257 <doc:ref type="interface" to="Session">Session</doc:ref> interface.</doc:para>
258 </doc:description>
259 </doc:doc>
260 </method>
261 <method name="GetSessionsForUser">
262 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
263 <arg name="uid" direction="in" type="u">
264 <doc:doc>
265 <doc:summary>User identification</doc:summary>
266 </doc:doc>
267 </arg>
268 <arg name="sessions" direction="out" type="ao">
269 <doc:doc>
270 <doc:summary>an array of Session IDs</doc:summary>
271 </doc:doc>
272 </arg>
273 <doc:doc>
274 <doc:description>
275 <doc:para>This gets a list of all the <doc:ref type="interface" to="Session">Sessions</doc:ref>
276 that are currently open for the specified user.</doc:para>
277 <doc:para>Each Session ID is an D-Bus object path for the object that implements the
278 <doc:ref type="interface" to="Session">Session</doc:ref> interface.</doc:para>
279 </doc:description>
280 <doc:deprecated version="0.1.3" instead="GetSessionsForUnixUser"/>
281 </doc:doc>
282 </method>
283
284 <method name="GetSystemIdleHint">
285 <arg name="idle_hint" type="b" direction="out">
286 <doc:doc>
287 <doc:summary>The value of the system-idle-hint</doc:summary>
288 </doc:doc>
289 </arg>
290 <doc:doc>
291 <doc:description>
292 <doc:para>Returns TRUE if the <doc:ref type="property" to="Session:idle-hint">idle-hint</doc:ref>
293 property of every open session is TRUE or if there are no open sessions.
294 </doc:para>
295 </doc:description>
296 </doc:doc>
297 </method>
298 <method name="GetSystemIdleSinceHint">
299 <arg name="iso8601_datetime" type="s" direction="out">
300 <doc:doc>
301 <doc:summary>An ISO 8601 format date-type string</doc:summary>
302 </doc:doc>
303 </arg>
304 <doc:doc>
305 <doc:description>
306 <doc:para>Returns an ISO 8601 date-time string that corresponds to
307 the time of the last change of the system-idle-hint.
308 </doc:para>
309 </doc:description>
310 </doc:doc>
311 </method>
312
313 <signal name="SeatAdded">
314 <arg name="sid" type="o">
315 <doc:doc>
316 <doc:summary>The Seat ID for the added seat</doc:summary>
317 </doc:doc>
318 </arg>
319 <doc:doc>
320 <doc:description>
321 <doc:para>Emitted when a Seat has been added to the system.
322 </doc:para>
323 </doc:description>
324 </doc:doc>
325 </signal>
326 <signal name="SeatRemoved">
327 <arg name="sid" type="o">
328 <doc:doc>
329 <doc:summary>The Seat ID for the removed seat</doc:summary>
330 </doc:doc>
331 </arg>
332 <doc:doc>
333 <doc:description>
334 <doc:para>Emitted when a Seat has been removed from the system.
335 </doc:para>
336 </doc:description>
337 </doc:doc>
338 </signal>
339 <signal name="SystemIdleHintChanged">
340 <arg name="hint" type="b">
341 <doc:doc>
342 <doc:summary>The value of the system-idle-hint</doc:summary>
343 </doc:doc>
344 </arg>
345 <doc:doc>
346 <doc:description>
347 <doc:para>Emitted when the value of the system-idle-hint has changed.
348 </doc:para>
349 </doc:description>
350 </doc:doc>
351 </signal>
352 </interface>
353</node>
3540
=== removed file 'src/org.freedesktop.ConsoleKit.Seat.xml'
--- src/org.freedesktop.ConsoleKit.Seat.xml 2012-06-12 05:39:31 +0000
+++ src/org.freedesktop.ConsoleKit.Seat.xml 1970-01-01 00:00:00 +0000
@@ -1,164 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<node xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
3
4 <interface name="org.freedesktop.ConsoleKit.Seat">
5 <doc:doc>
6 <doc:description>
7 <doc:para>A seat is a collection of sessions and a set of hardware (usually at
8least a keyboard and mouse). Only one session may be active on a
9seat at a time.</doc:para>
10 </doc:description>
11 </doc:doc>
12
13 <method name="GetId">
14 <arg name="sid" direction="out" type="o">
15 <doc:doc>
16 <doc:summary>Seat ID</doc:summary>
17 </doc:doc>
18 </arg>
19 <doc:doc>
20 <doc:description>
21 <doc:para>Returns the ID for Seat.</doc:para>
22 </doc:description>
23 </doc:doc>
24 </method>
25
26 <method name="GetSessions">
27 <arg name="sessions" direction="out" type="ao">
28 <doc:doc>
29 <doc:summary>an array of Session IDs</doc:summary>
30 </doc:doc>
31 </arg>
32 <doc:doc>
33 <doc:description>
34 <doc:para>This gets a list of all the <doc:ref type="interface" to="Session">Sessions</doc:ref>
35 that are currently attached to this seat.</doc:para>
36 <doc:para>Each Session ID is an D-Bus object path for the object that implements the
37 <doc:ref type="interface" to="Session">Session</doc:ref> interface.</doc:para>
38 </doc:description>
39 </doc:doc>
40 </method>
41
42 <method name="GetDevices">
43 <arg name="devices" direction="out" type="a(ss)">
44 <doc:doc>
45 <doc:summary>an array of devices</doc:summary>
46 </doc:doc>
47 </arg>
48 <doc:doc>
49 <doc:description>
50 <doc:para>This gets a list of all the devices
51 that are currently associated with this seat.</doc:para>
52 <doc:para>Each device is an D-Bus structure that represents
53 the device type and the device id.
54 </doc:para>
55 </doc:description>
56 </doc:doc>
57 </method>
58
59 <method name="GetActiveSession">
60 <arg name="ssid" direction="out" type="o">
61 <doc:doc>
62 <doc:summary>Session ID</doc:summary>
63 </doc:doc>
64 </arg>
65 <doc:doc>
66 <doc:description>
67 <doc:para>Gets the Session ID that is currently active on this Seat.</doc:para>
68 <doc:para>Returns NULL if there is no active session.</doc:para>
69 </doc:description>
70 </doc:doc>
71 </method>
72
73 <method name="CanActivateSessions">
74 <arg name="can_activate" direction="out" type="b">
75 <doc:doc>
76 <doc:summary>TRUE if seat supports session activation</doc:summary>
77 </doc:doc>
78 </arg>
79 <doc:doc>
80 <doc:description><doc:para>Used to determine whether the seat supports session activation.</doc:para>
81 </doc:description>
82 </doc:doc>
83 </method>
84
85 <method name="ActivateSession">
86 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
87 <arg name="ssid" direction="in" type="o">
88 <doc:doc>
89 <doc:summary>Session ID</doc:summary>
90 </doc:doc>
91 </arg>
92 <doc:doc>
93 <doc:description>
94 <doc:para>Attempt to activate the specified session. In most
95 cases, if successful, this will cause the session to
96 become visible and take control of the hardware that is
97 associated with this seat.</doc:para>
98 </doc:description>
99 <doc:seealso><doc:ref type="method" to="Session.Activate">Activate()</doc:ref></doc:seealso>
100 </doc:doc>
101 </method>
102
103 <signal name="ActiveSessionChanged">
104 <arg name="ssid" type="s">
105 <doc:doc>
106 <doc:summary>Session ID</doc:summary>
107 </doc:doc>
108 </arg>
109 <doc:doc>
110 <doc:description>
111 <doc:para>Emitted when the active session has changed.</doc:para>
112 </doc:description>
113 </doc:doc>
114 </signal>
115 <signal name="SessionAdded">
116 <arg name="ssid" type="o">
117 <doc:doc>
118 <doc:summary>Session ID</doc:summary>
119 </doc:doc>
120 </arg>
121 <doc:doc>
122 <doc:description>
123 <doc:para>Emitted when a session has been added to the seat.</doc:para>
124 </doc:description>
125 </doc:doc>
126 </signal>
127 <signal name="SessionRemoved">
128 <arg name="ssid" type="o">
129 <doc:doc>
130 <doc:summary>Session ID</doc:summary>
131 </doc:doc>
132 </arg>
133 <doc:doc>
134 <doc:description>
135 <doc:para>Emitted when a session has been removed from the seat.</doc:para>
136 </doc:description>
137 </doc:doc>
138 </signal>
139 <signal name="DeviceAdded">
140 <arg name="device" type="(ss)">
141 <doc:doc>
142 <doc:summary>Device structure</doc:summary>
143 </doc:doc>
144 </arg>
145 <doc:doc>
146 <doc:description>
147 <doc:para>Emitted when a device has been associated with the seat.</doc:para>
148 </doc:description>
149 </doc:doc>
150 </signal>
151 <signal name="DeviceRemoved">
152 <arg name="device" type="(ss)">
153 <doc:doc>
154 <doc:summary>Device structure</doc:summary>
155 </doc:doc>
156 </arg>
157 <doc:doc>
158 <doc:description>
159 <doc:para>Emitted when a device has been dissociated from the seat.</doc:para>
160 </doc:description>
161 </doc:doc>
162 </signal>
163 </interface>
164</node>
1650
=== removed file 'src/org.freedesktop.ConsoleKit.Session.xml'
--- src/org.freedesktop.ConsoleKit.Session.xml 2011-08-17 20:53:51 +0000
+++ src/org.freedesktop.ConsoleKit.Session.xml 1970-01-01 00:00:00 +0000
@@ -1,435 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<node xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
3
4 <interface name="org.freedesktop.ConsoleKit.Session">
5 <doc:doc>
6 <doc:description>
7 <doc:para>Session objects represent and store information
8 related to a user session.
9 </doc:para>
10 <doc:para>The properties associated with the Session
11 specifically refer to the properties of the "session leader".
12 </doc:para>
13 </doc:description>
14 </doc:doc>
15 <method name="GetId">
16 <arg name="ssid" direction="out" type="o">
17 <doc:doc>
18 <doc:summary>Session ID</doc:summary>
19 </doc:doc>
20 </arg>
21 <doc:doc>
22 <doc:description><doc:para>Returns the ID for Session.</doc:para>
23 </doc:description>
24 </doc:doc>
25 </method>
26 <method name="GetSeatId">
27 <arg name="sid" direction="out" type="o">
28 <doc:doc>
29 <doc:summary>Seat ID</doc:summary>
30 </doc:doc>
31 </arg>
32 <doc:doc>
33 <doc:description><doc:para>Returns the ID for the Seat the Session is
34 attached to.</doc:para>
35 </doc:description>
36 <doc:seealso><doc:ref type="interface" to="Seat">org.freedesktop.ConsoleKit.Seat</doc:ref></doc:seealso>
37 </doc:doc>
38 </method>
39 <method name="GetSessionType">
40 <arg name="type" direction="out" type="s">
41 <doc:doc>
42 <doc:summary>Session type</doc:summary>
43 </doc:doc>
44 </arg>
45 <doc:doc>
46 <doc:description>
47 <doc:para>Returns the type of the session.</doc:para>
48 <doc:para>Warning: we haven't yet defined the allowed values for this property.
49 It is probably best to avoid this until we do.
50 </doc:para>
51 </doc:description>
52 <doc:seealso><doc:ref type="property" to="Session:session-type">session-type</doc:ref></doc:seealso>
53 </doc:doc>
54 </method>
55 <method name="GetUser">
56 <arg name="uid" direction="out" type="u">
57 <doc:doc>
58 <doc:summary>User ID</doc:summary>
59 </doc:doc>
60 </arg>
61 <doc:doc>
62 <doc:description><doc:para>Returns the user that the session belongs to.</doc:para>
63 </doc:description>
64 <doc:deprecated version="0.1.3" instead="GetUnixUser"/>
65 <doc:seealso><doc:ref type="property" to="Session:user">user</doc:ref></doc:seealso>
66 </doc:doc>
67 </method>
68 <method name="GetUnixUser">
69 <arg name="uid" direction="out" type="u">
70 <doc:doc>
71 <doc:summary>POSIX User ID</doc:summary>
72 </doc:doc>
73 </arg>
74 <doc:doc>
75 <doc:description><doc:para>Returns the POSIX user ID that the session belongs to.</doc:para>
76 </doc:description>
77 <doc:seealso><doc:ref type="property" to="Session:unix-user">unix-user</doc:ref></doc:seealso>
78 </doc:doc>
79 </method>
80 <method name="GetX11Display">
81 <arg name="display" direction="out" type="s">
82 <doc:doc>
83 <doc:summary>The value of the X11 display</doc:summary>
84 </doc:doc>
85 </arg>
86 <doc:doc>
87 <doc:description><doc:para>Returns the value of the X11 DISPLAY for this session
88 if one is present.</doc:para>
89 </doc:description>
90 <doc:seealso><doc:ref type="property" to="Session:x11-display">x11-display</doc:ref></doc:seealso>
91 </doc:doc>
92 </method>
93 <method name="GetX11DisplayDevice">
94 <arg name="x11_display_device" direction="out" type="s">
95 <doc:doc>
96 <doc:summary>The value of the X11 display device</doc:summary>
97 </doc:doc>
98 </arg>
99 <doc:doc>
100 <doc:description><doc:para>Returns the value of the display device (aka TTY) that the
101 X11 display for the session is connected to. If there is no x11-display set then this value
102 is undefined.</doc:para>
103 </doc:description>
104 <doc:seealso><doc:ref type="property" to="Session:x11-display-device">x11-display-device</doc:ref></doc:seealso>
105 </doc:doc>
106 </method>
107 <method name="GetDisplayDevice">
108 <arg name="display_device" direction="out" type="s">
109 <doc:doc>
110 <doc:summary>The value of the display device</doc:summary>
111 </doc:doc>
112 </arg>
113 <doc:doc>
114 <doc:description><doc:para>Returns the value of the display device (aka TTY) that the
115 session is connected to.</doc:para>
116 </doc:description>
117 <doc:seealso><doc:ref type="property" to="Session:display-device">display-device</doc:ref></doc:seealso>
118 </doc:doc>
119 </method>
120 <method name="GetRemoteHostName">
121 <arg name="remote_host_name" direction="out" type="s">
122 <doc:doc>
123 <doc:summary>The remote host name</doc:summary>
124 </doc:doc>
125 </arg>
126 <doc:doc>
127 <doc:description><doc:para>Returns the value of the remote host name for the session.
128 </doc:para>
129 </doc:description>
130 <doc:seealso><doc:ref type="property" to="Session:remote-host-name">remote-host-name</doc:ref></doc:seealso>
131 </doc:doc>
132 </method>
133 <method name="GetLoginSessionId">
134 <arg name="login_session_id" direction="out" type="s">
135 <doc:doc>
136 <doc:summary>The value of the native system login session ID</doc:summary>
137 </doc:doc>
138 </arg>
139 <doc:doc>
140 <doc:description><doc:para>Returns the value of the login session ID that the
141 underlying system uses to enforce session boundaries. If there is no login session ID
142 set then this value is an empty string.</doc:para>
143 </doc:description>
144 </doc:doc>
145 </method>
146 <method name="IsActive">
147 <arg name="active" direction="out" type="b">
148 <doc:doc>
149 <doc:summary>TRUE if the session is active, otherwise FALSE</doc:summary>
150 </doc:doc>
151 </arg>
152 <doc:doc>
153 <doc:description><doc:para>Returns whether the session is active on the Seat that
154 it is attached to.</doc:para>
155 <doc:para>If the session is not attached to a seat this value is undefined.
156 </doc:para>
157 </doc:description>
158 <doc:seealso><doc:ref type="property" to="Session:active">active</doc:ref></doc:seealso>
159 </doc:doc>
160 </method>
161 <method name="IsLocal">
162 <arg name="local" direction="out" type="b">
163 <doc:doc>
164 <doc:summary>TRUE if the session is local, otherwise FALSE</doc:summary>
165 </doc:doc>
166 </arg>
167 <doc:doc>
168 <doc:description><doc:para>Returns whether the session is local</doc:para>
169 <doc:para>FIXME: we need to come up with a concrete definition for this value.
170 It was originally used as a way to identify XDMCP sessions that originate
171 from a remote system.
172 </doc:para>
173 </doc:description>
174 <doc:seealso><doc:ref type="property" to="Session:is-local">is-local</doc:ref></doc:seealso>
175 </doc:doc>
176 </method>
177 <method name="GetCreationTime">
178 <arg name="iso8601_datetime" type="s" direction="out">
179 <doc:doc>
180 <doc:summary>An ISO 8601 format date-type string</doc:summary>
181 </doc:doc>
182 </arg>
183 <doc:doc>
184 <doc:description>
185 <doc:para>Returns an ISO 8601 date-time string that corresponds to
186 the time that the session was opened.
187 </doc:para>
188 </doc:description>
189 </doc:doc>
190 </method>
191
192 <method name="Activate">
193 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
194 <doc:doc>
195 <doc:description>
196 <doc:para>Attempt to activate the this session. In most
197 cases, if successful, this will cause the session to
198 become visible and become active on the seat that it
199 is attached to.</doc:para>
200 </doc:description>
201 <doc:seealso><doc:ref type="method" to="Seat.ActivateSession">Seat.ActivateSession()</doc:ref></doc:seealso>
202 </doc:doc>
203 </method>
204 <method name="Lock">
205 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
206 <doc:doc>
207 <doc:description>
208 <doc:para>This will cause a <doc:ref type="signal" to="Session::Lock">Lock</doc:ref>
209 signal to be emitted for this session.
210 </doc:para>
211 </doc:description>
212 <doc:permission>This method is restricted to privileged users by D-Bus policy.</doc:permission>
213 <doc:seealso><doc:ref type="signal" to="Session::Lock">Lock signal</doc:ref></doc:seealso>
214 </doc:doc>
215 </method>
216 <method name="Unlock">
217 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
218 <doc:doc>
219 <doc:description>
220 <doc:para>This will cause an <doc:ref type="signal" to="Session::Unlock">Unlock</doc:ref>
221 signal to be emitted for this session.
222 </doc:para>
223 <doc:para>This can be used by login managers to unlock a session before it is
224 re-activated during fast-user-switching.
225 </doc:para>
226 </doc:description>
227 <doc:permission>This method is restricted to privileged users by D-Bus policy.</doc:permission>
228 <doc:seealso><doc:ref type="signal" to="Session::Unlock">Unlock signal</doc:ref></doc:seealso>
229 </doc:doc>
230 </method>
231
232 <method name="GetIdleHint">
233 <arg name="idle_hint" type="b" direction="out">
234 <doc:doc>
235 <doc:summary>The value of the idle-hint</doc:summary>
236 </doc:doc>
237 </arg>
238 <doc:doc>
239 <doc:description>
240 <doc:para>Gets the value of the <doc:ref type="property" to="Session:idle-hint">idle-hint</doc:ref>
241 property.
242 </doc:para>
243 </doc:description>
244 <doc:seealso><doc:ref type="property" to="Session:idle-hint">idle-hint</doc:ref></doc:seealso>
245 </doc:doc>
246 </method>
247 <method name="GetIdleSinceHint">
248 <arg name="iso8601_datetime" type="s" direction="out">
249 <doc:doc>
250 <doc:summary>An ISO 8601 format date-type string</doc:summary>
251 </doc:doc>
252 </arg>
253 <doc:doc>
254 <doc:description>
255 <doc:para>Returns an ISO 8601 date-time string that corresponds to
256 the time of the last change of the idle-hint.
257 </doc:para>
258 </doc:description>
259 </doc:doc>
260 </method>
261 <method name="SetIdleHint">
262 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
263 <arg name="idle_hint" type="b" direction="in">
264 <doc:doc>
265 <doc:summary>boolean value to set the idle-hint to</doc:summary>
266 </doc:doc>
267 </arg>
268 <doc:doc>
269 <doc:description>
270 <doc:para>This may be used by the session to indicate that
271 it is idle.
272 </doc:para>
273 <doc:para>Use of this method is restricted to the user
274 that owns the session.</doc:para>
275 </doc:description>
276 </doc:doc>
277 </method>
278
279 <signal name="ActiveChanged">
280 <arg name="is_active" type="b">
281 <doc:doc>
282 <doc:summary>TRUE if the session is active, otherwise FALSE</doc:summary>
283 </doc:doc>
284 </arg>
285 <doc:doc>
286 <doc:description>
287 <doc:para>Emitted when the active property has changed.</doc:para>
288 </doc:description>
289 </doc:doc>
290 </signal>
291 <signal name="IdleHintChanged">
292 <arg name="hint" type="b">
293 <doc:doc>
294 <doc:summary>the new value of idle-hint</doc:summary>
295 </doc:doc>
296 </arg>
297 <doc:doc>
298 <doc:description>
299 <doc:para>Emitted when the idle-hint property has changed.</doc:para>
300 </doc:description>
301 </doc:doc>
302 </signal>
303 <signal name="Lock">
304 <doc:doc>
305 <doc:description>
306 <doc:para>Emitted in response to a call to the <doc:ref type="method" to="Session.Lock">Lock()</doc:ref> method.</doc:para>
307 <doc:para>It is intended that the screensaver for the session should lock the screen in response to this signal.</doc:para>
308 </doc:description>
309 </doc:doc>
310 </signal>
311 <signal name="Unlock">
312 <doc:doc>
313 <doc:description>
314 <doc:para>Emitted in response to a call to the <doc:ref type="method" to="Session.Unlock">Unlock()</doc:ref> method.</doc:para>
315 <doc:para>It is intended that the screensaver for the session should unlock the screen in response to this signal.</doc:para>
316 </doc:description>
317 </doc:doc>
318 </signal>
319
320 <property name="unix-user" type="u" access="readwrite">
321 <doc:doc>
322 <doc:description>
323 <doc:para>The user assigned to the session.</doc:para>
324 </doc:description>
325 </doc:doc>
326 </property>
327 <property name="user" type="u" access="readwrite">
328 <doc:doc>
329 <doc:description>
330 <doc:para>The user assigned to the session.</doc:para>
331 </doc:description>
332 <doc:deprecated version="0.1.3" instead="unix-user"/>
333 </doc:doc>
334 </property>
335 <property name="session-type" type="s" access="readwrite">
336 <doc:doc>
337 <doc:description>
338 <doc:para>The type of the session.</doc:para>
339 <doc:para>Warning: we haven't yet defined the allowed values for this property.
340 It is probably best to avoid this until we do.
341 </doc:para>
342 </doc:description>
343 </doc:doc>
344 </property>
345 <property name="remote-host-name" type="s" access="readwrite">
346 <doc:doc>
347 <doc:description>
348 <doc:para>The remote host name for the session.
349 </doc:para>
350 <doc:para>This will be set in situations where the session is
351 opened and controlled from a remote system.
352 </doc:para>
353 <doc:para>For example, this value will be set when the
354 session is created from an SSH or XDMCP connection.
355 </doc:para>
356 </doc:description>
357 </doc:doc>
358 </property>
359 <property name="display-device" type="s" access="readwrite">
360 <doc:doc>
361 <doc:description>
362 <doc:para>The display device (aka TTY) that the
363 session is connected to.
364 </doc:para>
365 </doc:description>
366 </doc:doc>
367 </property>
368 <property name="x11-display" type="s" access="readwrite">
369 <doc:doc>
370 <doc:description>
371 <doc:para>Value of the X11 DISPLAY for this session
372 if one is present.
373 </doc:para>
374 </doc:description>
375 </doc:doc>
376 </property>
377 <property name="x11-display-device" type="s" access="readwrite">
378 <doc:doc>
379 <doc:description>
380 <doc:para>
381 The display device (aka TTY) that the X11 display for the
382 session is connected to. If there is no x11-display set then
383 this value is undefined.
384 </doc:para>
385 </doc:description>
386 </doc:doc>
387 </property>
388 <property name="active" type="b" access="readwrite">
389 <doc:doc>
390 <doc:description>
391 <doc:para>
392 Whether the session is active on the Seat that
393 it is attached to.</doc:para>
394 <doc:para>If the session is not attached to a seat this value is undefined.
395 </doc:para>
396 </doc:description>
397 </doc:doc>
398 </property>
399 <property name="is-local" type="b" access="readwrite">
400 <doc:doc>
401 <doc:description>
402 <doc:para>
403 Whether the session is local</doc:para>
404 <doc:para>FIXME: we need to come up with a concrete definition for this value.
405 It was originally used as a way to identify XDMCP sessions that originate
406 from a remote system.
407 </doc:para>
408 </doc:description>
409 </doc:doc>
410 </property>
411 <property name="idle-hint" type="b" access="readwrite">
412 <doc:doc>
413 <doc:description>
414 <doc:para>
415 This is a hint used to indicate that the session may be idle.
416 </doc:para>
417 <doc:para>
418 For sessions with a <doc:ref type="property" to="Session:x11-display">x11-display</doc:ref> set (ie. graphical
419 sessions), it is up to each session to delegate the
420 responsibility for updating this value. Typically, the
421 screensaver will set this.
422 </doc:para>
423 <doc:para>However, for non-graphical sessions with a <doc:ref type="property" to="Session:display-device">display-device</doc:ref> set
424 the Session object itself will periodically update this value based
425 on the activity detected on the display-device itself.
426 </doc:para>
427 <doc:para>
428 This should not be considered authoritative.
429 </doc:para>
430 </doc:description>
431 </doc:doc>
432 </property>
433
434 </interface>
435</node>
4360
=== added file 'src/org.freedesktop.login1.Manager.xml'
--- src/org.freedesktop.login1.Manager.xml 1970-01-01 00:00:00 +0000
+++ src/org.freedesktop.login1.Manager.xml 2013-04-22 12:49:38 +0000
@@ -0,0 +1,199 @@
1<?xml version="1.0"?>
2<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
3<node>
4 <interface name="org.freedesktop.login1.Manager">
5 <method name="GetSession">
6 <arg name="id" type="s" direction="in"/>
7 <arg name="session" type="o" direction="out"/>
8 </method>
9 <method name="GetSessionByPID">
10 <arg name="pid" type="u" direction="in"/>
11 <arg name="session" type="o" direction="out"/>
12 </method>
13 <method name="GetUser">
14 <arg name="uid" type="u" direction="in"/>
15 <arg name="user" type="o" direction="out"/>
16 </method>
17 <method name="GetSeat">
18 <arg name="id" type="s" direction="in"/>
19 <arg name="seat" type="o" direction="out"/>
20 </method>
21 <method name="ListSessions">
22 <arg name="sessions" type="a(susso)" direction="out"/>
23 <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="SessionObjectList"/>
24 </method>
25 <method name="ListUsers">
26 <arg name="users" type="a(uso)" direction="out"/>
27 <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="UintStringPathList"/>
28 </method>
29 <method name="ListSeats">
30 <arg name="seats" type="a(so)" direction="out"/>
31 <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="StringPathList"/>
32 </method>
33 <method name="CreateSession">
34 <arg name="uid" type="u" direction="in"/>
35 <arg name="leader" type="u" direction="in"/>
36 <arg name="sevice" type="s" direction="in"/>
37 <arg name="type" type="s" direction="in"/>
38 <arg name="klass" type="s" direction="in"/>
39 <arg name="seat" type="s" direction="in"/>
40 <arg name="vtnr" type="u" direction="in"/>
41 <arg name="tty" type="s" direction="in"/>
42 <arg name="display" type="s" direction="in"/>
43 <arg name="remote" type="b" direction="in"/>
44 <arg name="remote_user" type="s" direction="in"/>
45 <arg name="remote_host" type="s" direction="in"/>
46 <arg name="controllers" type="as" direction="in"/>
47 <arg name="reset_controllers" type="as" direction="in"/>
48 <arg name="kill_processes" type="b" direction="in"/>
49 <arg name="id" type="s" direction="out"/>
50 <arg name="path" type="o" direction="out"/>
51 <arg name="runtime_path" type="o" direction="out"/>
52 <arg name="fd" type="h" direction="out"/>
53 <arg name="seat" type="s" direction="out"/>
54 <arg name="vtnr" type="u" direction="out"/>
55 <arg name="existing" type="b" direction="out"/>
56 </method>
57 <method name="ReleaseSession">
58 <arg name="id" type="s" direction="in"/>
59 </method>
60 <method name="ActivateSession">
61 <arg name="id" type="s" direction="in"/>
62 </method>
63 <method name="ActivateSessionOnSeat">
64 <arg name="id" type="s" direction="in"/>
65 <arg name="seat" type="s" direction="in"/>
66 </method>
67 <method name="LockSession">
68 <arg name="id" type="s" direction="in"/>
69 </method>
70 <method name="UnlockSession">
71 <arg name="id" type="s" direction="in"/>
72 </method>
73 <method name="LockSessions"/>
74 <method name="KillSession">
75 <arg name="id" type="s" direction="in"/>
76 <arg name="who" type="s" direction="in"/>
77 <arg name="signal" type="s" direction="in"/>
78 </method>
79 <method name="KillUser">
80 <arg name="uid" type="u" direction="in"/>
81 <arg name="signal" type="s" direction="in"/>
82 </method>
83 <method name="TerminateSession">
84 <arg name="id" type="s" direction="in"/>
85 </method>
86 <method name="TerminateUser">
87 <arg name="uid" type="u" direction="in"/>
88 </method>
89 <method name="TerminateSeat">
90 <arg name="id" type="s" direction="in"/>
91 </method>
92 <method name="SetUserLinger">
93 <arg name="uid" type="u" direction="in"/>
94 <arg name="b" type="b" direction="in"/>
95 <arg name="interactive" type="b" direction="in"/>
96 </method>
97 <method name="AttachDevice">
98 <arg name="seat" type="s" direction="in"/>
99 <arg name="sysfs" type="s" direction="in"/>
100 <arg name="interactive" type="b" direction="in"/>
101 </method>
102 <method name="FlushDevices">
103 <arg name="interactive" type="b" direction="in"/>
104 </method>
105 <method name="PowerOff">
106 <arg name="interactive" type="b" direction="in"/>
107 </method>
108 <method name="Reboot">
109 <arg name="interactive" type="b" direction="in"/>
110 </method>
111 <method name="Suspend">
112 <arg name="interactive" type="b" direction="in"/>
113 </method>
114 <method name="Hibernate">
115 <arg name="interactive" type="b" direction="in"/>
116 </method>
117 <method name="HybridSleep">
118 <arg name="interactive" type="b" direction="in"/>
119 </method>
120 <method name="CanPowerOff">
121 <arg name="result" type="s" direction="out"/>
122 </method>
123 <method name="CanReboot">
124 <arg name="result" type="s" direction="out"/>
125 </method>
126 <method name="CanSuspend">
127 <arg name="result" type="s" direction="out"/>
128 </method>
129 <method name="CanHibernate">
130 <arg name="result" type="s" direction="out"/>
131 </method>
132 <method name="CanHybridSleep">
133 <arg name="result" type="s" direction="out"/>
134 </method>
135 <method name="Inhibit">
136 <arg name="what" type="s" direction="in"/>
137 <arg name="who" type="s" direction="in"/>
138 <arg name="why" type="s" direction="in"/>
139 <arg name="mode" type="s" direction="in"/>
140 <arg name="fd" type="h" direction="out"/>
141 </method>
142 <method name="ListInhibitors">
143 <arg name="inhibitors" type="a(ssssuu)" direction="out"/>
144 <!-- TODO: Create an appropriate type -->
145 <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantList"/>
146 </method>
147 <signal name="SessionNew">
148 <arg name="id" type="s"/>
149 <arg name="path" type="o"/>
150 </signal>
151 <signal name="SessionRemoved">
152 <arg name="id" type="s"/>
153 <arg name="path" type="o"/>
154 </signal>
155 <signal name="UserNew">
156 <arg name="uid" type="u"/>
157 <arg name="path" type="o"/>
158 </signal>
159 <signal name="UserRemoved">
160 <arg name="uid" type="u"/>
161 <arg name="path" type="o"/>
162 </signal>
163 <signal name="SeatNew">
164 <arg name="id" type="s"/>
165 <arg name="path" type="o"/>
166 </signal>
167 <signal name="SeatRemoved">
168 <arg name="id" type="s"/>
169 <arg name="path" type="o"/>
170 </signal>
171 <signal name="PrepareForShutdown">
172 <arg name="active" type="b"/>
173 </signal>
174 <signal name="PrepareForSleep">
175 <arg name="active" type="b"/>
176 </signal>
177 <property name="ControlGroupHierarchy" type="s" access="read"/>
178 <property name="Controllers" type="as" access="read"/>
179 <property name="ResetControllers" type="as" access="read"/>
180 <property name="NAutoVTs" type="u" access="read"/>
181 <property name="KillOnlyUsers" type="as" access="read"/>
182 <property name="KillExcludeUsers" type="as" access="read"/>
183 <property name="KillUserProcesses" type="b" access="read"/>
184 <property name="IdleHint" type="b" access="read"/>
185 <property name="IdleSinceHint" type="t" access="read"/>
186 <property name="IdleSinceHintMonotonic" type="t" access="read"/>
187 <property name="BlockInhibited" type="s" access="read"/>
188 <property name="DelayInhibited" type="s" access="read"/>
189 <property name="InhibitDelayMaxUSec" type="t" access="read"/>
190 <property name="HandlePowerKey" type="s" access="read"/>
191 <property name="HandleSuspendKey" type="s" access="read"/>
192 <property name="HandleHibernateKey" type="s" access="read"/>
193 <property name="HandleLidSwitch" type="s" access="read"/>
194 <property name="IdleAction" type="s" access="read"/>
195 <property name="IdleActionUSec" type="t" access="read"/>
196 <property name="PreparingForShutdown" type="b" access="read"/>
197 <property name="PreparingForSleep" type="b" access="read"/>
198 </interface>
199</node>
0200
=== added file 'src/org.freedesktop.login1.Seat.xml'
--- src/org.freedesktop.login1.Seat.xml 1970-01-01 00:00:00 +0000
+++ src/org.freedesktop.login1.Seat.xml 2013-04-22 12:49:38 +0000
@@ -0,0 +1,21 @@
1<?xml version="1.0"?>
2<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
3<node>
4 <interface name="org.freedesktop.login1.Seat">
5 <method name="Terminate"/>
6 <method name="ActivateSession">
7 <arg name="id" type="s"/>
8 </method>
9 <property name="Id" type="s" access="read"/>
10 <property name="ActiveSession" type="so" access="read"/>
11 <property name="CanMultiSession" type="b" access="read"/>
12 <property name="CanTTY" type="b" access="read"/>
13 <property name="CanGraphical" type="b" access="read"/>
14 <property name="Sessions" type="a(so)" access="read">
15 <annotation name="org.qtproject.QtDBus.QtTypeName" value="StringPathList"/>
16 </property>
17 <property name="IdleHint" type="b" access="read"/>
18 <property name="IdleSinceHint" type="t" access="read"/>
19 <property name="IdleSinceHintMonotonic" type="t" access="read"/>
20 </interface>
21</node>
022
=== added file 'src/org.freedesktop.login1.Session.xml'
--- src/org.freedesktop.login1.Session.xml 1970-01-01 00:00:00 +0000
+++ src/org.freedesktop.login1.Session.xml 2013-04-22 12:49:38 +0000
@@ -0,0 +1,49 @@
1<?xml version="1.0"?>
2<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
3<node>
4 <interface name="org.freedesktop.login1.Session">
5 <method name="Terminate"/>
6 <method name="Activate"/>
7 <method name="Lock"/>
8 <method name="Unlock"/>
9 <method name="SetIdleHint">
10 <arg name="b" direction="in" type="b"/>
11 </method>
12 <method name="Kill">
13 <arg name="who" direction="in" type="s"/>
14 <arg name="signal" direction="in" type="s"/>
15 </method>
16 <signal name="Lock"/>
17 <signal name="Unlock"/>
18 <property name="Id" type="s" access="read"/>
19 <property name="User" type="(uo)" access="read">
20 <annotation name="org.qtproject.QtDBus.QtTypeName" value="UintPath"/>
21 </property>
22 <property name="Name" type="s" access="read"/>
23 <property name="Timestamp" type="t" access="read"/>
24 <property name="TimestampMonotonic" type="t" access="read"/>
25 <property name="DefaultControlGroup" type="s" access="read"/>
26 <property name="VTNr" type="u" access="read"/>
27 <property name="Seat" type="(so)" access="read">
28 <annotation name="org.qtproject.QtDBus.QtTypeName" value="StringPath"/>
29 </property>
30 <property name="TTY" type="s" access="read"/>
31 <property name="Display" type="s" access="read"/>
32 <property name="Remote" type="b" access="read"/>
33 <property name="RemoteHost" type="s" access="read"/>
34 <property name="RemoteUser" type="s" access="read"/>
35 <property name="Service" type="s" access="read"/>
36 <property name="Leader" type="u" access="read"/>
37 <property name="Audit" type="u" access="read"/>
38 <property name="Type" type="s" access="read"/>
39 <property name="Class" type="s" access="read"/>
40 <property name="Active" type="b" access="read"/>
41 <property name="State" type="s" access="read"/>
42 <property name="Controllers" type="as" access="read"/>
43 <property name="ResetControllers" type="as" access="read"/>
44 <property name="KillProcesses" type="b" access="read"/>
45 <property name="IdleHint" type="b" access="read"/>
46 <property name="IdleSinceHint" type="t" access="read"/>
47 <property name="IdleSinceHintMonotonic" type="t" access="read"/>
48 </interface>
49</node>
050
=== added file 'src/org.freedesktop.login1.User.xml'
--- src/org.freedesktop.login1.User.xml 1970-01-01 00:00:00 +0000
+++ src/org.freedesktop.login1.User.xml 2013-04-22 12:49:38 +0000
@@ -0,0 +1,56 @@
1<?xml version="1.0"?>
2<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
3<node>
4 <interface name="org.freedesktop.login1.User">
5 <method name="Terminate"/>
6 <method name="Kill">
7 <arg name="signal" direction="in" type="s"/>
8 </method>
9 <property name="UID" type="u" access="read"/>
10 <property name="GID" type="u" access="read"/>
11 <property name="Name" type="s" access="read"/>
12 <property name="Timestamp" type="t" access="read"/>
13 <property name="TimestampMonotonic" type="t" access="read"/>
14 <property name="RuntimePath" type="s" access="read"/>
15 <property name="DefaultControlGroup" type="s" access="read"/>
16 <property name="Service" type="s" access="read"/>
17 <property name="Display" type="(so)" access="read"/>
18 <property name="State" type="s" access="read"/>
19 <property name="Sessions" type="a(so)" access="read"/>
20 <property name="IdleHint" type="b" access="read"/>
21 <property name="IdleSinceHint" type="t" access="read"/>
22 <property name="IdleSinceHintMonotonic" type="t" access="read"/>
23 </interface>
24 <interface name="org.freedesktop.DBus.Properties">
25 <method name="Get">
26 <arg name="interface" direction="in" type="s"/>
27 <arg name="property" direction="in" type="s"/>
28 <arg name="value" direction="out" type="v"/>
29 </method>
30 <method name="GetAll">
31 <arg name="interface" direction="in" type="s"/>
32 <arg name="properties" direction="out" type="a{sv}"/>
33 </method>
34 <method name="Set">
35 <arg name="interface" direction="in" type="s"/>
36 <arg name="property" direction="in" type="s"/>
37 <arg name="value" direction="in" type="v"/>
38 </method>
39 <signal name="PropertiesChanged">
40 <arg type="s" name="interface"/>
41 <arg type="a{sv}" name="changed_properties"/>
42 <arg type="as" name="invalidated_properties"/>
43 </signal>
44 </interface>
45<interface name="org.freedesktop.DBus.Peer">
46 <method name="Ping"/>
47 <method name="GetMachineId">
48 <arg type="s" name="machine_uuid" direction="out"/>
49 </method>
50</interface>
51 <interface name="org.freedesktop.DBus.Introspectable">
52 <method name="Introspect">
53 <arg name="data" type="s" direction="out"/>
54 </method>
55 </interface>
56</node>
057
=== modified file 'src/session-menu-mgr.c'
--- src/session-menu-mgr.c 2013-03-06 15:29:26 +0000
+++ src/session-menu-mgr.c 2013-04-22 12:49:38 +0000
@@ -29,7 +29,7 @@
29#include <libdbusmenu-glib/client.h>29#include <libdbusmenu-glib/client.h>
30#include <libdbusmenu-gtk/menuitem.h>30#include <libdbusmenu-gtk/menuitem.h>
3131
32#include "dbus-upower.h"32#include "dbus-login1-manager.h"
33#include "session-menu-mgr.h"33#include "session-menu-mgr.h"
34#include "shared-names.h"34#include "shared-names.h"
35#include "users-service-dbus.h"35#include "users-service-dbus.h"
@@ -37,8 +37,8 @@
3737
38#define DEBUG_SHOW_ALL FALSE38#define DEBUG_SHOW_ALL FALSE
3939
40#define UPOWER_ADDRESS "org.freedesktop.UPower"40#define LOGIN1_MANAGER_ADDRESS "org.freedesktop.login1"
41#define UPOWER_PATH "/org/freedesktop/UPower"41#define LOGIN1_MANAGER_PATH "/org/freedesktop/login1"
4242
43#define CMD_HELP "yelp"43#define CMD_HELP "yelp"
44#define CMD_INFO "gnome-control-center info"44#define CMD_INFO "gnome-control-center info"
@@ -77,7 +77,7 @@
77 * This is a pretty straightforward class: it creates the menumodel77 * This is a pretty straightforward class: it creates the menumodel
78 * and listens for events that can affect the model's properties.78 * and listens for events that can affect the model's properties.
79 *79 *
80 * Simple event sources, such as GSettings and a UPower DBus proxy,80 * Simple event sources, such as GSettings and a logind DBus proxy,
81 * are handled here. More involved event sources are delegated to the81 * are handled here. More involved event sources are delegated to the
82 * UsersServiceDBus facade class.82 * UsersServiceDBus facade class.
83 */83 */
@@ -104,18 +104,16 @@
104 GSettings * indicator_settings;104 GSettings * indicator_settings;
105 GSettings * keybinding_settings;105 GSettings * keybinding_settings;
106106
107 /* cached settings taken from the upower proxy */107 /* cached settings taken from the logind proxy */
108 gboolean can_hibernate;108 gboolean can_hibernate;
109 gboolean can_suspend;109 gboolean can_suspend;
110 gboolean allow_hibernate;
111 gboolean allow_suspend;
112110
113 gboolean shell_mode;111 gboolean shell_mode;
114 gboolean greeter_mode;112 gboolean greeter_mode;
115113
116 guint shell_name_watcher;114 guint shell_name_watcher;
117 GCancellable * cancellable;115 GCancellable * cancellable;
118 DBusUPower * upower_proxy;116 Login1Manager * login1_manager_proxy;
119 SessionDbus * session_dbus;117 SessionDbus * session_dbus;
120 UsersServiceDbus * users_dbus_facade;118 UsersServiceDbus * users_dbus_facade;
121 OnlineAccountsMgr * online_accounts_mgr;119 OnlineAccountsMgr * online_accounts_mgr;
@@ -123,7 +121,7 @@
123121
124static SwitcherMode get_switcher_mode (SessionMenuMgr *);122static SwitcherMode get_switcher_mode (SessionMenuMgr *);
125123
126static void init_upower_proxy (SessionMenuMgr *);124static void init_login1_proxy (SessionMenuMgr *);
127static void init_shell_watcher (SessionMenuMgr *);125static void init_shell_watcher (SessionMenuMgr *);
128126
129static void update_screensaver_shortcut (SessionMenuMgr *);127static void update_screensaver_shortcut (SessionMenuMgr *);
@@ -203,7 +201,7 @@
203 g_signal_connect (mgr->users_dbus_facade, "guest-logged-in-changed",201 g_signal_connect (mgr->users_dbus_facade, "guest-logged-in-changed",
204 G_CALLBACK(on_guest_logged_in_changed), mgr);202 G_CALLBACK(on_guest_logged_in_changed), mgr);
205203
206 init_upower_proxy (mgr);204 init_login1_proxy (mgr);
207 init_shell_watcher (mgr);205 init_shell_watcher (mgr);
208206
209 /* Online accounts menu item */207 /* Online accounts menu item */
@@ -224,7 +222,7 @@
224 g_clear_object (&mgr->indicator_settings);222 g_clear_object (&mgr->indicator_settings);
225 g_clear_object (&mgr->lockdown_settings);223 g_clear_object (&mgr->lockdown_settings);
226 g_clear_object (&mgr->keybinding_settings);224 g_clear_object (&mgr->keybinding_settings);
227 g_clear_object (&mgr->upower_proxy);225 g_clear_object (&mgr->login1_manager_proxy);
228 g_clear_object (&mgr->users_dbus_facade);226 g_clear_object (&mgr->users_dbus_facade);
229 g_clear_object (&mgr->top_mi);227 g_clear_object (&mgr->top_mi);
230 g_clear_object (&mgr->session_dbus);228 g_clear_object (&mgr->session_dbus);
@@ -248,97 +246,67 @@
248 object_class->dispose = session_menu_mgr_dispose;246 object_class->dispose = session_menu_mgr_dispose;
249}247}
250248
251/***249static gboolean
252**** UPower Proxy:250can_perform_operation (gchar * permission)
253****
254**** 1. While bootstrapping, we invoke the AllowSuspend and AllowHibernate
255**** methods to find out whether or not those features are allowed.
256**** 2. While bootstrapping, we get the CanSuspend and CanHibernate properties
257**** and also listen for property changes.
258**** 3. These four values are used to set suspend and hibernate's visibility.
259****
260***/
261
262static void
263on_upower_properties_changed (SessionMenuMgr * mgr)
264{251{
265 gboolean need_refresh = FALSE;252 return g_strcmp0 ("yes", permission) == 0;
266
267 if (mgr->upower_proxy != NULL)
268 {
269 gboolean b;
270
271 /* suspend */
272 b = dbus_upower_get_can_suspend (mgr->upower_proxy);
273 if (mgr->can_suspend != b)
274 {
275 mgr->can_suspend = b;
276 need_refresh = TRUE;
277 }
278
279 /* hibernate */
280 b = dbus_upower_get_can_hibernate (mgr->upower_proxy);
281 if (mgr->can_hibernate != b)
282 {
283 mgr->can_hibernate = b;
284 need_refresh = TRUE;
285 }
286 }
287
288 if (need_refresh)
289 {
290 update_session_menuitems (mgr);
291 }
292}253}
293254
294static void255static void
295init_upower_proxy (SessionMenuMgr * mgr)256init_login1_proxy (SessionMenuMgr * mgr)
296{257{
297 /* default values */258 /* default values */
298 mgr->can_suspend = TRUE;259 mgr->can_suspend = TRUE;
299 mgr->can_hibernate = TRUE;260 mgr->can_hibernate = TRUE;
300 mgr->allow_suspend = TRUE;261
301 mgr->allow_hibernate = TRUE;262 gchar * can_suspend;
263 gchar * can_hibernate;
302264
303 mgr->cancellable = g_cancellable_new ();265 mgr->cancellable = g_cancellable_new ();
304266
305 GError * error = NULL;267 GError * error = NULL;
306 mgr->upower_proxy = dbus_upower_proxy_new_for_bus_sync (268 mgr->login1_manager_proxy = login1_manager_proxy_new_for_bus_sync (
307 G_BUS_TYPE_SYSTEM,269 G_BUS_TYPE_SYSTEM,
308 G_DBUS_PROXY_FLAGS_NONE,270 G_DBUS_PROXY_FLAGS_NONE,
309 UPOWER_ADDRESS,271 LOGIN1_MANAGER_ADDRESS,
310 UPOWER_PATH,272 LOGIN1_MANAGER_PATH,
311 NULL,273 NULL,
312 &error);274 &error);
313 if (error != NULL)275 if (error != NULL)
314 {276 {
315 g_warning ("Error creating upower proxy: %s", error->message);277 g_warning ("Error creating logind proxy: %s", error->message);
316 g_clear_error (&error);278 g_clear_error (&error);
317 }279 }
318 else280 else
319 {281 {
320 dbus_upower_call_suspend_allowed_sync (mgr->upower_proxy,282 login1_manager_call_can_suspend_sync (mgr->login1_manager_proxy,
321 &mgr->allow_suspend,283 &can_suspend,
322 NULL,284 NULL,
323 &error);285 &error);
324 if (error != NULL)286 if (error != NULL)
325 {287 {
326 g_warning ("%s: %s", G_STRFUNC, error->message);288 g_warning ("%s: %s", G_STRFUNC, error->message);
327 g_clear_error (&error);289 g_clear_error (&error);
328 }290 }
329291 else
330 dbus_upower_call_hibernate_allowed_sync (mgr->upower_proxy,292 {
331 &mgr->allow_hibernate,293 mgr->can_suspend = can_perform_operation (can_suspend);
332 NULL,294 }
333 &error);295
334 if (error != NULL)296 login1_manager_call_can_hibernate_sync (mgr->login1_manager_proxy,
335 {297 &can_hibernate,
336 g_warning ("%s: %s", G_STRFUNC, error->message);298 NULL,
337 g_clear_error (&error);299 &error);
338 }300 if (error != NULL)
339301 {
340 g_signal_connect_swapped (mgr->upower_proxy, "changed",302 g_warning ("%s: %s", G_STRFUNC, error->message);
341 G_CALLBACK(on_upower_properties_changed), mgr);303 g_clear_error (&error);
304 }
305 else
306 {
307 mgr->can_hibernate = can_perform_operation (can_hibernate);
308 }
309
342 }310 }
343}311}
344312
@@ -505,13 +473,9 @@
505 && !g_settings_get_boolean (s, "suppress-logout-menuitem");473 && !g_settings_get_boolean (s, "suppress-logout-menuitem");
506 mi_set_visible (mgr->logout_mi, v);474 mi_set_visible (mgr->logout_mi, v);
507475
508 v = mgr->can_suspend476 mi_set_visible (mgr->suspend_mi, mgr->can_suspend);
509 && mgr->allow_suspend;
510 mi_set_visible (mgr->suspend_mi, v);
511477
512 v = mgr->can_hibernate478 mi_set_visible (mgr->hibernate_mi, mgr->can_hibernate);
513 && mgr->allow_hibernate;
514 mi_set_visible (mgr->hibernate_mi, v);
515479
516 v = (!mgr->shell_mode || g_settings_get_boolean (s, "suppress-logout-restart-shutdown"))480 v = (!mgr->shell_mode || g_settings_get_boolean (s, "suppress-logout-restart-shutdown"))
517 && (HAVE_RESTART_CMD || mgr->shell_mode)481 && (HAVE_RESTART_CMD || mgr->shell_mode)
@@ -878,10 +842,6 @@
878 }842 }
879843
880 /* maybe the seat doesn't support activation */844 /* maybe the seat doesn't support activation */
881 if (!users_service_dbus_can_activate_session (mgr->users_dbus_facade))
882 {
883 return FALSE;
884 }
885845
886 return TRUE;846 return TRUE;
887}847}
@@ -1147,9 +1107,10 @@
1147{1107{
1148 GError * error = NULL;1108 GError * error = NULL;
11491109
1150 dbus_upower_call_suspend_sync (mgr->upower_proxy,1110 login1_manager_call_suspend_sync (mgr->login1_manager_proxy,
1151 mgr->cancellable,1111 TRUE,
1152 &error);1112 mgr->cancellable,
1113 &error);
11531114
1154 if (error != NULL)1115 if (error != NULL)
1155 {1116 {
@@ -1163,9 +1124,10 @@
1163{1124{
1164 GError * error = NULL;1125 GError * error = NULL;
11651126
1166 dbus_upower_call_hibernate_sync (mgr->upower_proxy,1127 login1_manager_call_hibernate_sync (mgr->login1_manager_proxy,
1167 mgr->cancellable,1128 TRUE,
1168 &error);1129 mgr->cancellable,
1130 &error);
11691131
1170 if (error != NULL)1132 if (error != NULL)
1171 {1133 {
@@ -1350,10 +1312,6 @@
1350 update_user_menuitems (mgr);1312 update_user_menuitems (mgr);
1351 build_session_menuitems (mgr);1313 build_session_menuitems (mgr);
13521314
1353 /* After we have the session menu items built we can look to
1354 align them with UPower */
1355 on_upower_properties_changed (mgr);
1356
1357 return mgr;1315 return mgr;
1358}1316}
13591317
13601318
=== removed file 'src/upower.xml'
--- src/upower.xml 2012-06-12 05:39:31 +0000
+++ src/upower.xml 1970-01-01 00:00:00 +0000
@@ -1,309 +0,0 @@
1<!DOCTYPE node PUBLIC
2"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
3"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
4<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
5
6 <interface name="org.freedesktop.UPower">
7 <doc:doc>
8 <doc:description>
9 <doc:para>
10 The DeviceKit-power service is available via the system message
11 bus. To access the service, use
12 the <doc:tt>org.freedesktop.UPower</doc:tt> interface on
13 the <doc:tt>/org/freedesktop/UPower</doc:tt> object on
14 the D-Bus system bus service with the well-known
15 name <doc:tt>org.freedesktop.UPower</doc:tt>.
16 </doc:para>
17 <doc:para>
18 <doc:example language="shell" title="simple example">
19 <doc:code>
20$ dbus-send --print-reply \
21 --system \
22 --dest=org.freedesktop.UPower \
23 /org/freedesktop/UPower \
24 org.freedesktop.UPower.EnumerateDevices
25
26method return sender=:1.386 -> dest=:1.451 reply_serial=2
27 array [
28 object path "/org/freedesktop/UPower/devices/line_power_AC"
29 object path "/org/freedesktop/UPower/devices/battery_BAT0"
30 ]
31 </doc:code>
32 </doc:example>
33 </doc:para>
34 </doc:description>
35 </doc:doc>
36
37 <!-- ************************************************************ -->
38
39 <method name="EnumerateDevices">
40 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
41 <arg name="devices" direction="out" type="ao">
42 <doc:doc><doc:summary>An array of object paths for devices.</doc:summary></doc:doc>
43 </arg>
44
45 <doc:doc>
46 <doc:description>
47 <doc:para>
48 Enumerate all power objects on the system.
49 </doc:para>
50 </doc:description>
51 </doc:doc>
52 </method>
53
54 <!-- ************************************************************ -->
55
56 <signal name="DeviceAdded">
57 <arg name="device" type="o">
58 <doc:doc><doc:summary>Object path of device that was added.</doc:summary></doc:doc>
59 </arg>
60
61 <doc:doc>
62 <doc:description>
63 <doc:para>
64 Emitted when a device is added.
65 </doc:para>
66 </doc:description>
67 </doc:doc>
68 </signal>
69
70 <!-- ************************************************************ -->
71
72 <signal name="DeviceRemoved">
73 <arg name="device" type="o">
74 <doc:doc><doc:summary>Object path of device that was removed.</doc:summary></doc:doc>
75 </arg>
76
77 <doc:doc>
78 <doc:description>
79 <doc:para>
80 Emitted when a device is removed.
81 </doc:para>
82 </doc:description>
83 </doc:doc>
84 </signal>
85
86 <!-- ************************************************************ -->
87
88 <signal name="DeviceChanged">
89 <arg name="device" type="s">
90 <doc:doc><doc:summary>Object path of device that was changed.</doc:summary></doc:doc>
91 </arg>
92
93 <doc:doc>
94 <doc:description>
95 <doc:para>
96 Emitted when a device changed.
97 </doc:para>
98 </doc:description>
99 </doc:doc>
100 </signal>
101
102 <!-- ************************************************************ -->
103
104 <signal name="Changed">
105 <doc:doc>
106 <doc:description>
107 <doc:para>
108 Emitted when one or more properties on the object changes.
109 </doc:para>
110 </doc:description>
111 </doc:doc>
112 </signal>
113
114 <!-- ************************************************************ -->
115
116 <signal name="Sleeping">
117 <doc:doc>
118 <doc:description>
119 <doc:para>
120 This signal is sent when the session is about to be suspended or
121 hibernated.
122 Session and system programs have one second to do anything required
123 before the sleep action is taken (such as sending out Avahi or
124 Jabber messages).
125 </doc:para>
126 </doc:description>
127 </doc:doc>
128 </signal>
129
130 <!-- ************************************************************ -->
131
132 <signal name="Resuming">
133 <doc:doc>
134 <doc:description>
135 <doc:para>
136 This signal is sent when the session has just returned from
137 Suspend() or Hibernate().
138 Session and system programs can then do anything required (such as
139 sending out Avahi or Jabber messages).
140 </doc:para>
141 </doc:description>
142 </doc:doc>
143 </signal>
144
145 <!-- ************************************************************ -->
146
147 <method name="AboutToSleep">
148 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
149 <doc:doc>
150 <doc:description>
151 <doc:para>
152 This method tells UPower that the Suspend() or Hibernate() method
153 is about to be called.
154 This allows UPower to emit the Suspending signal whilst
155 session activities are happening that have to be done before the
156 suspend process is started.
157 </doc:para>
158 <doc:para>
159 This method would typically be called by the session power
160 management daemon, before it locks the screen and waits for the
161 screen to fade to black.
162 The session power management component would then call Suspend() or
163 Hibernate() when these syncronous tasks have completed.
164 </doc:para>
165 <doc:para>
166 If this method is not called than nothing bad will happen and
167 Suspend() or Hibernate() will block for the required second.
168 </doc:para>
169 </doc:description>
170 </doc:doc>
171 </method>
172
173 <!-- ************************************************************ -->
174
175 <method name="Suspend">
176 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
177 <doc:doc>
178 <doc:description>
179 <doc:para>
180 Suspends the computer into a low power state.
181 System state is not preserved if the power is lost.
182 </doc:para>
183 <doc:para>
184 If AboutToRequestSleep() has not been called then UPower will send
185 the Sleeping() signal and block for one second.
186 </doc:para>
187 <doc:para>
188 If AboutToRequestSleep() has been called less than one second
189 before this method is called then UPower will block for the
190 remaining time to complete one second of delay.
191 </doc:para>
192 </doc:description>
193 </doc:doc>
194 </method>
195
196 <!-- ************************************************************ -->
197
198 <method name="SuspendAllowed">
199 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
200 <arg name="allowed" direction="out" type="b">
201 <doc:doc><doc:summary>TRUE if allowed, otherwise FALSE</doc:summary></doc:doc>
202 </arg>
203 <doc:doc>
204 <doc:description>
205 <doc:para>
206 Check if the caller has (or can get) the PolicyKit privilege to call
207 <doc:ref type="method" to="Power.Suspend">Suspend</doc:ref>.
208 </doc:para>
209 </doc:description>
210 </doc:doc>
211 </method>
212
213 <!-- ************************************************************ -->
214
215 <method name="Hibernate">
216 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
217 <doc:doc>
218 <doc:description>
219 <doc:para>
220 Hibernates the computer into a low power state.
221 System state is preserved if the power is lost.
222 </doc:para>
223 <doc:para>
224 If AboutToRequestSleep() has not been called then UPower will send
225 the Sleeping() signal and block for one second.
226 </doc:para>
227 <doc:para>
228 If AboutToRequestSleep() has been called less than one second
229 before this method is called then UPower will block for the
230 remaining time to complete one second of delay.
231 </doc:para>
232 </doc:description>
233 </doc:doc>
234 </method>
235
236 <!-- ************************************************************ -->
237
238 <method name="HibernateAllowed">
239 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
240 <arg name="allowed" direction="out" type="b">
241 <doc:doc><doc:summary>TRUE if allowed, otherwise FALSE</doc:summary></doc:doc>
242 </arg>
243 <doc:doc>
244 <doc:description>
245 <doc:para>
246 Check if the caller has (or can get) the PolicyKit privilege to call
247 <doc:ref type="method" to="Power.Hibernate">Hibernate</doc:ref>.
248 </doc:para>
249 </doc:description>
250 </doc:doc>
251 </method>
252
253 <!-- ************************************************************ -->
254
255 <property name="DaemonVersion" type="s" access="read">
256 <doc:doc><doc:description><doc:para>
257 Version of the running daemon, e.g. <doc:tt>002</doc:tt>.
258 </doc:para></doc:description></doc:doc>
259 </property>
260
261 <property name="CanSuspend" type="b" access="read">
262 <doc:doc><doc:description><doc:para>
263 Whether the system is able to suspend.
264 </doc:para></doc:description></doc:doc>
265 </property>
266
267 <property name="CanHibernate" type="b" access="read">
268 <doc:doc><doc:description><doc:para>
269 Whether the system is able to hibernate.
270 </doc:para></doc:description></doc:doc>
271 </property>
272
273 <property name="OnBattery" type="b" access="read">
274 <doc:doc><doc:description><doc:para>
275 Indicates whether the system is running on battery power.
276 This property is provided for convenience.
277 </doc:para></doc:description></doc:doc>
278 </property>
279
280 <property name="OnLowBattery" type="b" access="read">
281 <doc:doc><doc:description><doc:para>
282 Indicates whether the system is running on battery power and if the battery is critically low.
283 This property is provided for convenience.
284 </doc:para></doc:description></doc:doc>
285 </property>
286
287 <property name="LidIsClosed" type="b" access="read">
288 <doc:doc>
289 <doc:description>
290 <doc:para>
291 Indicates if the laptop lid is closed where the display cannot be seen.
292 </doc:para>
293 </doc:description>
294 </doc:doc>
295 </property>
296
297 <property name="LidIsPresent" type="b" access="read">
298 <doc:doc>
299 <doc:description>
300 <doc:para>
301 If the system has a lid device.
302 </doc:para>
303 </doc:description>
304 </doc:doc>
305 </property>
306
307 </interface>
308
309</node>
3100
=== modified file 'src/users-service-dbus.c'
--- src/users-service-dbus.c 2012-11-12 23:30:15 +0000
+++ src/users-service-dbus.c 2013-04-22 12:49:38 +0000
@@ -30,16 +30,15 @@
30#include <pwd.h> /* getpwuid() */30#include <pwd.h> /* getpwuid() */
3131
32#include "dbus-accounts.h"32#include "dbus-accounts.h"
33#include "dbus-consolekit-manager.h"33#include "dbus-login1-manager.h"
34#include "dbus-consolekit-seat.h"34#include "dbus-login1-session.h"
35#include "dbus-consolekit-session.h"35#include "dbus-login1-user.h"
36#include "dbus-display-manager.h"36#include "dbus-display-manager.h"
37#include "dbus-user.h"37#include "dbus-user.h"
38#include "shared-names.h"38#include "shared-names.h"
39#include "users-service-dbus.h"39#include "users-service-dbus.h"
4040
41#define CK_ADDR "org.freedesktop.ConsoleKit"41#define LOGIND_ADDR "org.freedesktop.login1"
42#define CK_SESSION_IFACE "org.freedesktop.ConsoleKit.Session"
4342
44/**43/**
45***44***
@@ -57,17 +56,19 @@
57 const gchar * user_object_path,56 const gchar * user_object_path,
58 UsersServiceDbus * service);57 UsersServiceDbus * service);
5958
60static void on_session_added (ConsoleKitSeat * seat,59static void on_session_added (Login1Manager * proxy,
61 const gchar * ssid,60 const gchar * ssid,
62 UsersServiceDbus * service);61 const gchar * path,
6362 UsersServiceDbus * service);
64static void on_session_removed (ConsoleKitSeat * seat,63
65 const gchar * ssid,64static void on_session_removed (Login1Manager * proxy,
66 UsersServiceDbus * service);65 const gchar * ssid,
6766 const gchar * path,
68static void on_session_list (ConsoleKitSeat * seat,67 UsersServiceDbus * service);
69 GAsyncResult * result,68
70 UsersServiceDbus * service);69static void on_session_list (Login1Manager * proxy,
70 GAsyncResult * result,
71 UsersServiceDbus * service);
7172
72/***73/***
73**** Priv Struct74**** Priv Struct
@@ -85,8 +86,7 @@
85 GHashTable * users;86 GHashTable * users;
8687
87 GCancellable * cancellable;88 GCancellable * cancellable;
88 ConsoleKitSeat * seat_proxy;89 Login1Manager * manager_proxy;
89 ConsoleKitManager * ck_manager_proxy;
90 Accounts * accounts_proxy;90 Accounts * accounts_proxy;
91};91};
9292
@@ -112,8 +112,7 @@
112 UsersServiceDbusPrivate * priv = USERS_SERVICE_DBUS(object)->priv;112 UsersServiceDbusPrivate * priv = USERS_SERVICE_DBUS(object)->priv;
113113
114 g_clear_object (&priv->accounts_proxy);114 g_clear_object (&priv->accounts_proxy);
115 g_clear_object (&priv->seat_proxy);115 g_clear_object (&priv->manager_proxy);
116 g_clear_object (&priv->ck_manager_proxy);
117116
118 if (priv->cancellable != NULL)117 if (priv->cancellable != NULL)
119 {118 {
@@ -211,14 +210,14 @@
211 g_object_unref);210 g_object_unref);
212211
213 /**212 /**
214 *** create the consolekit manager proxy...213 *** create the logind manager proxy...
215 **/214 **/
216215
217 p->ck_manager_proxy = console_kit_manager_proxy_new_for_bus_sync (216 p->manager_proxy = login1_manager_proxy_new_for_bus_sync (
218 G_BUS_TYPE_SYSTEM,217 G_BUS_TYPE_SYSTEM,
219 G_DBUS_PROXY_FLAGS_NONE,218 G_DBUS_PROXY_FLAGS_NONE,
220 "org.freedesktop.ConsoleKit",219 "org.freedesktop.login1",
221 "/org/freedesktop/ConsoleKit/Manager",220 "/org/freedesktop/login1",
222 NULL,221 NULL,
223 &error);222 &error);
224 if (error != NULL)223 if (error != NULL)
@@ -229,36 +228,13 @@
229228
230 p->seat = get_seat (self);229 p->seat = get_seat (self);
231230
232 /**231 g_signal_connect (p->manager_proxy, "session-new",
233 *** create the consolekit seat proxy...232 G_CALLBACK (on_session_added), self);
234 **/233 g_signal_connect (p->manager_proxy, "session-removed",
235234 G_CALLBACK (on_session_removed), self);
236 if (p->seat != NULL)235
237 {236 login1_manager_call_list_sessions (p->manager_proxy, p->cancellable,
238 ConsoleKitSeat * proxy = console_kit_seat_proxy_new_for_bus_sync (237 (GAsyncReadyCallback) on_session_list, self);
239 G_BUS_TYPE_SYSTEM,
240 G_DBUS_PROXY_FLAGS_NONE,
241 "org.freedesktop.ConsoleKit",
242 p->seat,
243 NULL,
244 &error);
245
246 if (error != NULL)
247 {
248 g_warning ("Failed to connect to the ConsoleKit seat: %s", error->message);
249 g_clear_error (&error);
250 }
251 else
252 {
253 g_signal_connect (proxy, "session-added",
254 G_CALLBACK (on_session_added), self);
255 g_signal_connect (proxy, "session-removed",
256 G_CALLBACK (on_session_removed), self);
257 console_kit_seat_call_get_sessions (proxy, p->cancellable,
258 (GAsyncReadyCallback)on_session_list, self);
259 p->seat_proxy = proxy;
260 }
261 }
262238
263 /**239 /**
264 *** create the accounts manager proxy...240 *** create the accounts manager proxy...
@@ -311,75 +287,129 @@
311****287****
312***/288***/
313289
314static ConsoleKitSession*290static Login1User*
315create_consolekit_session_proxy (const char * ssid)291create_login1_user_proxy (const char * path)
316{292{
317 GError * error = NULL;293
318294 GError * error = NULL;
319 ConsoleKitSession * p = console_kit_session_proxy_new_for_bus_sync (295
320 G_BUS_TYPE_SYSTEM,296 Login1User * p = login1_user_proxy_new_for_bus_sync (
321 G_DBUS_PROXY_FLAGS_NONE,297 G_BUS_TYPE_SYSTEM,
322 CK_ADDR,298 G_DBUS_PROXY_FLAGS_NONE,
323 ssid,299 LOGIND_ADDR,
324 NULL,300 path,
325 &error);301 NULL,
326 if (error != NULL)302 &error);
327 {303 if (error != NULL)
328 g_warning ("%s: %s", G_STRLOC, error->message);304 {
329 g_error_free (error);305 g_warning ("%s: %s", G_STRLOC, error->message);
330 }306 g_error_free (error);
331307 }
332 return p;308
333}309 return p;
310}
311
312static Login1User *
313create_login1_user_proxy_from_uid (UsersServiceDbus * self,
314 guint64 uid)
315{
316 Login1Manager * manager = self->priv->manager_proxy;
317 Login1User * user_proxy = NULL;
318 gchar * user_object_path = NULL;
319 GError * error = NULL;
320
321 login1_manager_call_get_user_sync (manager, uid, &user_object_path, NULL,
322 &error);
323
324 if (error != NULL)
325 {
326 g_warning ("%s: %s", G_STRLOC, error->message);
327 g_error_free (error);
328 }
329
330 if (user_object_path != NULL)
331 user_proxy = create_login1_user_proxy (user_object_path);
332
333 return user_proxy;
334
335}
336
337static Login1Session *
338create_login1_session_proxy (const char * path)
339{
340 GError * error = NULL;
341
342 Login1Session * p = login1_session_proxy_new_for_bus_sync (
343 G_BUS_TYPE_SYSTEM,
344 G_DBUS_PROXY_FLAGS_NONE,
345 LOGIND_ADDR,
346 path,
347 NULL,
348 &error);
349 if (error != NULL)
350 {
351 g_warning ("%s: %s", G_STRLOC, error->message);
352 g_error_free (error);
353 }
354
355 return p;
356}
357
334358
335static gchar *359static gchar *
336get_seat_from_session_proxy (ConsoleKitSession * session_proxy)360get_seat_from_session_proxy (Login1Session * session_proxy)
337{361{
338 gchar * seat = NULL;362 gchar * seat;
363 GVariant * seatobj = login1_session_get_seat (session_proxy);
339364
340 GError * error = NULL;365 g_variant_get (seatobj, "(so)", &seat, NULL);
341 console_kit_session_call_get_seat_id_sync (session_proxy,
342 &seat,
343 NULL,
344 &error);
345 if (error != NULL)
346 {
347 g_debug ("%s: %s", G_STRLOC, error->message);
348 g_error_free (error);
349 }
350366
351 return seat;367 return seat;
352}368}
353369
370static const gchar *
371get_display_from_session_proxy (Login1Session * session_proxy)
372{
373 const gchar * display;
374 display = login1_session_get_display (session_proxy);
375 return display;
376}
377
354static gchar *378static gchar *
355get_seat (UsersServiceDbus *service)379get_seat (UsersServiceDbus *service)
356{380{
357 gchar * seat = NULL;381 gchar * seat = NULL;
358 gchar * ssid = NULL;382 gchar * path = NULL;
359 GError * error = NULL;383 GError * error = NULL;
360 UsersServiceDbusPrivate * priv = service->priv;384 UsersServiceDbusPrivate * priv = service->priv;
361385 Login1Session * session_proxy = NULL;
362 console_kit_manager_call_get_current_session_sync (priv->ck_manager_proxy,386 pid_t pid = getpid();
363 &ssid,387
364 NULL,388 login1_manager_call_get_session_by_pid_sync (priv->manager_proxy,
365 &error);389 pid,
390 &path,
391 NULL,
392 &error);
393
366394
367 if (error != NULL)395 if (error != NULL)
368 {396 {
369 g_debug ("%s: %s", G_STRLOC, error->message);397 g_debug ("%s: %s", G_STRLOC, error->message);
370 g_error_free (error);398 g_error_free (error);
399 goto out;
371 }400 }
372 else401
402 session_proxy = create_login1_session_proxy (path);
403
404 if (!session_proxy)
373 {405 {
374 ConsoleKitSession * session = create_consolekit_session_proxy (ssid);406 g_debug ("%s: Could't get session proxy object", G_STRLOC);
375
376 if (session != NULL)
377 {
378 seat = get_seat_from_session_proxy (session);
379 g_object_unref (session);
380 }
381 }407 }
382408
409 seat = get_seat_from_session_proxy (session_proxy);
410
411out:
412 g_object_unref (session_proxy);
383 return seat;413 return seat;
384}414}
385415
@@ -434,9 +464,10 @@
434static void464static void
435add_user_session (UsersServiceDbus * service,465add_user_session (UsersServiceDbus * service,
436 AccountsUser * user,466 AccountsUser * user,
437 const gchar * ssid)467 const gchar * ssid,
468 const gchar * path)
438{469{
439 ConsoleKitSession * session_proxy = create_consolekit_session_proxy (ssid);470 Login1Session * session_proxy = create_login1_session_proxy (path);
440 if (session_proxy != NULL)471 if (session_proxy != NULL)
441 {472 {
442 UsersServiceDbusPrivate * priv = service->priv;473 UsersServiceDbusPrivate * priv = service->priv;
@@ -446,12 +477,8 @@
446 if (seat && priv->seat && !g_strcmp0 (seat, priv->seat))477 if (seat && priv->seat && !g_strcmp0 (seat, priv->seat))
447 {478 {
448 /* does this session have a display? */479 /* does this session have a display? */
449 gchar * display = NULL;480 const gchar * display = get_display_from_session_proxy (session_proxy);
450 console_kit_session_call_get_x11_display_sync (session_proxy,481 const gboolean has_display = g_strcmp0 ("", display) != 0;
451 &display,
452 NULL, NULL);
453 const gboolean has_display = display && *display;
454 g_free (display);
455482
456 if (has_display)483 if (has_display)
457 {484 {
@@ -480,33 +507,30 @@
480 const char * username = accounts_user_get_user_name (user);507 const char * username = accounts_user_get_user_name (user);
481 g_debug ("%s adding %s (%i)", G_STRLOC, username, (int)uid);508 g_debug ("%s adding %s (%i)", G_STRLOC, username, (int)uid);
482509
483 GError * error = NULL;510 GVariant * sessions = NULL;
484 gchar ** sessions = NULL;511
485 console_kit_manager_call_get_sessions_for_unix_user_sync (512 Login1User * user_proxy = create_login1_user_proxy_from_uid (self, uid);
486 self->priv->ck_manager_proxy,513
487 uid,514 if (user_proxy != NULL)
488 &sessions,
489 NULL,
490 &error);
491
492 if (error != NULL)
493 {515 {
494 g_debug ("%s: %s", G_STRLOC, error->message);516 sessions = login1_user_get_sessions (user_proxy);
495 g_error_free (error);
496 }517 }
497 else if (sessions != NULL)518
519 if (sessions != NULL)
498 {520 {
499 int i;521 GVariantIter iter;
522 g_variant_iter_init (&iter, sessions);
523 gchar * id;
524 gchar * object_path;
500525
501 for (i=0; sessions[i]; i++)526 while (g_variant_iter_loop (&iter, "(so)", &id, &object_path))
502 {527 {
503 const char * const ssid = sessions[i];528 g_debug ("%s adding %s's session %s", G_STRLOC, username, id);
504 g_debug ("%s adding %s's session %s", G_STRLOC, username, ssid);529 add_user_session (self, user, id, object_path);
505 add_user_session (self, user, ssid);
506 }530 }
531 }
507532
508 g_strfreev (sessions);533 g_object_unref (user_proxy);
509 }
510}534}
511535
512/* returns true if this property is one we use */536/* returns true if this property is one we use */
@@ -723,9 +747,10 @@
723***/747***/
724748
725static void749static void
726on_session_removed (ConsoleKitSeat * seat_proxy,750on_session_removed (Login1Manager * proxy,
727 const gchar * ssid,751 const gchar * ssid,
728 UsersServiceDbus * service)752 const gchar * path,
753 UsersServiceDbus * service)
729{754{
730 g_return_if_fail (IS_USERS_SERVICE_DBUS (service));755 g_return_if_fail (IS_USERS_SERVICE_DBUS (service));
731756
@@ -757,42 +782,25 @@
757}782}
758783
759static gchar*784static gchar*
760get_unix_username_from_ssid (UsersServiceDbus * self,785get_unix_username_from_path (UsersServiceDbus * self,
761 const gchar * ssid)786 const gchar * path)
762{787{
763 gchar * username = NULL;
764788
765 ConsoleKitSession * session_proxy = create_consolekit_session_proxy (ssid);789 Login1Session * session_proxy = create_login1_session_proxy (path);
766 if (session_proxy != NULL)790 if (session_proxy != NULL)
767 {791 {
768 guint uid = 0;792 gchar * username = g_strdup (login1_session_get_name (session_proxy));
769 GError * error = NULL;793
770 console_kit_session_call_get_unix_user_sync (session_proxy,794 g_debug ("%s Getting username for %s: %s", G_STRLOC, path, username);
771 &uid,
772 NULL, &error);
773 if (error != NULL)
774 {
775 g_warning ("%s: %s", G_STRLOC, error->message);
776 g_clear_error (&error);
777 }
778 else
779 {
780 errno = 0;
781 const struct passwd * pwent = getpwuid (uid);
782 if (pwent == NULL)
783 {
784 g_warning ("Failed to lookup user id %d: %s", (int)uid, g_strerror(errno));
785 }
786 else
787 {
788 username = g_strdup (pwent->pw_name);
789 }
790 }
791795
792 g_object_unref (session_proxy);796 g_object_unref (session_proxy);
797
798 return username;
799 }
800 else
801 {
802 return NULL;
793 }803 }
794
795 return username;
796}804}
797805
798static gboolean806static gboolean
@@ -810,13 +818,14 @@
810/* If the new session belongs to 'guest', update our guest_ssid.818/* If the new session belongs to 'guest', update our guest_ssid.
811 Otherwise, call add_user_session() to update our session tables */819 Otherwise, call add_user_session() to update our session tables */
812static void820static void
813on_session_added (ConsoleKitSeat * seat_proxy G_GNUC_UNUSED,821on_session_added (Login1Manager * proxy G_GNUC_UNUSED,
814 const gchar * ssid,822 const gchar * ssid,
815 UsersServiceDbus * service)823 const gchar * path,
824 UsersServiceDbus * service)
816{825{
817 g_return_if_fail (IS_USERS_SERVICE_DBUS(service));826 g_return_if_fail (IS_USERS_SERVICE_DBUS(service));
818827
819 gchar * username = get_unix_username_from_ssid (service, ssid);828 gchar * username = get_unix_username_from_path (service, path);
820 g_debug ("%s %s() username %s has new session %s", G_STRLOC, G_STRFUNC, username, ssid);829 g_debug ("%s %s() username %s has new session %s", G_STRLOC, G_STRFUNC, username, ssid);
821830
822 if (is_guest_username (username))831 if (is_guest_username (username))
@@ -834,45 +843,59 @@
834843
835 if (user != NULL)844 if (user != NULL)
836 {845 {
837 add_user_session (service, user, ssid);846 add_user_session (service, user, ssid, path);
838 emit_user_login_changed (service, user);847 emit_user_login_changed (service, user);
839 }848 }
840 }849 }
841850
842 g_free (username);
843}851}
844852
845/* Receives a list of sessions and calls on_session_added() for each of them */853/* Receives a list of sessions and calls on_session_added() for each of them */
846static void854static void
847on_session_list (ConsoleKitSeat * seat_proxy,855on_session_list (Login1Manager * proxy,
848 GAsyncResult * result,856 GAsyncResult * result,
849 UsersServiceDbus * self)857 UsersServiceDbus * self)
850{858{
851 GError * error = NULL;859 GError * error = NULL;
852 gchar ** sessions = NULL;860 GVariant * sessions;
853 g_debug ("%s bootstrapping the session list", G_STRLOC);861 g_debug ("%s bootstrapping the session list", G_STRLOC);
854862
855 console_kit_seat_call_get_sessions_finish (seat_proxy,863 login1_manager_call_list_sessions_finish (proxy,
856 &sessions,864 &sessions,
857 result,865 result,
858 &error);866 &error);
859867
860 if (error != NULL)868 if (error != NULL)
861 {869 {
862 g_debug ("%s: %s", G_STRLOC, error->message);870 g_debug ("%s: %s", G_STRLOC, error->message);
863 g_error_free (error);871 g_error_free (error);
864 }872 }
865 else if (sessions != NULL)873 else
866 {874 {
867 int i;875 GVariantIter * iter;
868876 gchar * seat;
869 for (i=0; sessions[i]; i++)877 gchar * path;
878
879 g_variant_get (sessions, "a(susso)", &iter);
880
881 while (g_variant_iter_loop (iter,
882 "(susso)",
883 NULL,
884 NULL,
885 NULL,
886 &seat,
887 &path))
870 {888 {
871 g_debug ("%s adding initial session '%s'", G_STRLOC, sessions[i]);889 if (g_strcmp0 (seat, self->priv->seat) == 0)
872 on_session_added (seat_proxy, sessions[i], self);890 {
891 g_debug ("%s adding initial session '%s'", G_STRLOC, path);
892 on_session_added (proxy, seat, path, self);
893 }
873 }894 }
874895
875 g_strfreev (sessions);896 g_variant_iter_free (iter);
897 g_variant_unref (sessions);
898
876 }899 }
877900
878 g_debug ("%s done bootstrapping the session list", G_STRLOC);901 g_debug ("%s done bootstrapping the session list", G_STRLOC);
@@ -1005,27 +1028,6 @@
1005}1028}
10061029
1007gboolean1030gboolean
1008users_service_dbus_can_activate_session (UsersServiceDbus * self)
1009{
1010 gboolean can_activate = FALSE;
1011
1012 g_return_val_if_fail (IS_USERS_SERVICE_DBUS(self), can_activate);
1013
1014 GError * error = NULL;
1015 console_kit_seat_call_can_activate_sessions_sync (self->priv->seat_proxy,
1016 &can_activate,
1017 NULL,
1018 &error);
1019 if (error != NULL)
1020 {
1021 g_warning ("%s: %s", G_STRLOC, error->message);
1022 g_error_free (error);
1023 }
1024
1025 return can_activate;
1026}
1027
1028gboolean
1029users_service_dbus_is_guest_logged_in (UsersServiceDbus * self)1031users_service_dbus_is_guest_logged_in (UsersServiceDbus * self)
1030{1032{
1031 g_return_val_if_fail (IS_USERS_SERVICE_DBUS(self), FALSE);1033 g_return_val_if_fail (IS_USERS_SERVICE_DBUS(self), FALSE);
10321034
=== modified file 'src/users-service-dbus.h'
--- src/users-service-dbus.h 2012-06-13 19:41:31 +0000
+++ src/users-service-dbus.h 2013-04-22 12:49:38 +0000
@@ -52,8 +52,8 @@
52 * 2. Track which users currently have X sessions.52 * 2. Track which users currently have X sessions.
53 * This is used for the menuitems' USER_ITEM_PROP_LOGGED_IN property.53 * This is used for the menuitems' USER_ITEM_PROP_LOGGED_IN property.
54 *54 *
55 * We initially build this list by calling org.freedesktop.ConsoleKit.Seat's55 * We initially build this list by calling org.freedesktop.login1's
56 * GetDevices method. We also monitor the seat for SessionAdded and56 * ListSessions method. We also monitor the seat for SessionNew and
57 * SessionRemoved and update the list accordingly.57 * SessionRemoved and update the list accordingly.
58 *58 *
59 * 3. Provide an API for user switching and guest sessions.59 * 3. Provide an API for user switching and guest sessions.
@@ -87,7 +87,6 @@
8787
88void users_service_dbus_show_greeter (UsersServiceDbus * self);88void users_service_dbus_show_greeter (UsersServiceDbus * self);
89gboolean users_service_dbus_guest_session_enabled (UsersServiceDbus * self);89gboolean users_service_dbus_guest_session_enabled (UsersServiceDbus * self);
90gboolean users_service_dbus_can_activate_session (UsersServiceDbus * self);
91void users_service_dbus_activate_guest_session (UsersServiceDbus * self);90void users_service_dbus_activate_guest_session (UsersServiceDbus * self);
92void users_service_dbus_activate_user_session (UsersServiceDbus * self,91void users_service_dbus_activate_user_session (UsersServiceDbus * self,
93 AccountsUser * user);92 AccountsUser * user);

Subscribers

People subscribed via source and target branches