Merge lp:~ted/indicator-session/no-ck-errors-for-you into lp:indicator-session/0.1

Proposed by Ted Gould
Status: Merged
Merged at revision: not available
Proposed branch: lp:~ted/indicator-session/no-ck-errors-for-you
Merge into: lp:indicator-session/0.1
Diff against target: 425 lines (+364/-8)
4 files modified
.bzrignore (+1/-0)
src/Makefile.am (+8/-0)
src/consolekit-manager.xml (+353/-0)
src/users-service-dbus.c (+2/-8)
To merge this branch: bzr merge lp:~ted/indicator-session/no-ck-errors-for-you
Reviewer Review Type Date Requested Status
David Barth Approve
Review via email: mp+20419@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

Switching the get sessions function to using the dbus-glib generated
interface to get rid of an error. I still can't tell what's really
changed, but this is a better way to do it anyway.

Revision history for this message
David Barth (dbarth) wrote :

Still it feels strange that the xml service definition file is not an external -dev dependency. Ie you have to maintain it in sync with upstream. Is there a way around that? Or then couldn't you trim down the file to just declare the GetSessionsForUnixUser you're only using for now?

review: Needs Information
Revision history for this message
Ted Gould (ted) wrote :

On Tue, 2010-03-02 at 20:23 +0000, David Barth wrote:
> Still it feels strange that the xml service definition file is not
> an external -dev dependency. Ie you have to maintain it in sync with
> upstream. Is there a way around that? Or then couldn't you trim down
> the file to just declare the GetSessionsForUnixUser you're only using
> for now?

I discussed that with upstream with regards to GPM and they weren't too
interested in doing it. KDE does, but GNOME has continually avoided it.
I think if we're going to do that, we need to do it distro wide.

The reason I kept the whole file was just so it's a direct copy from the
ConsoleKit source tree. I think that's better than having a manual step
of editing.

Revision history for this message
David Barth (dbarth) wrote :

Ok, no time to make that kind of distro change, so that solution makes sense.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2009-10-08 14:45:29 +0000
3+++ .bzrignore 2010-03-02 03:40:29 +0000
4@@ -54,3 +54,4 @@
5 indicator-session-[0-9].[0-9].tar.gz
6 indicator-session-[0-9].[0-9].[0-9].tar.gz.asc
7 indicator-session-[0-9].[0-9].tar.gz.asc
8+src/consolekit-manager-client.h
9
10=== modified file 'src/Makefile.am'
11--- src/Makefile.am 2010-02-11 19:26:17 +0000
12+++ src/Makefile.am 2010-03-02 03:40:29 +0000
13@@ -17,6 +17,12 @@
14 libsession_la_LIBADD = $(APPLET_LIBS)
15 libsession_la_LDFLAGS = -module -avoid-version
16
17+consolekit-manager-client.h: $(srcdir)/consolekit-manager.xml
18+ dbus-binding-tool \
19+ --prefix=_consolekit_manager_client \
20+ --mode=glib-client \
21+ --output=consolekit-manager-client.h \
22+ $(srcdir)/consolekit-manager.xml
23
24 users-service-client.h: $(srcdir)/users-service.xml
25 dbus-binding-tool \
26@@ -56,11 +62,13 @@
27 ###############
28
29 BUILT_SOURCES = \
30+ consolekit-manager-client.h \
31 users-service-client.h \
32 users-service-marshal.h \
33 users-service-marshal.c
34
35 EXTRA_DIST = \
36+ consolekit-manager.xml \
37 users-service.xml \
38 users-service.list
39
40
41=== added file 'src/consolekit-manager.xml'
42--- src/consolekit-manager.xml 1970-01-01 00:00:00 +0000
43+++ src/consolekit-manager.xml 2010-03-02 03:40:29 +0000
44@@ -0,0 +1,353 @@
45+<?xml version="1.0" encoding="UTF-8"?>
46+<node name="/org/freedesktop/ConsoleKit/Manager"
47+ xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"
48+>
49+
50+ <interface name="org.freedesktop.ConsoleKit.Manager">
51+ <method name="Restart">
52+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
53+ <doc:doc>
54+ <doc:description>
55+ <doc:para>This method initiates a request to restart (ie. reboot) the computer system.</doc:para>
56+ </doc:description>
57+ </doc:doc>
58+ </method>
59+
60+ <method name="CanRestart">
61+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
62+ <arg name="can_restart" type="b" direction="out"/>
63+ </method>
64+
65+ <method name="Stop">
66+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
67+ <doc:doc>
68+ <doc:description>
69+ <doc:para>This method initiates a request to stop (ie. shutdown) the computer system.</doc:para>
70+ </doc:description>
71+ </doc:doc>
72+ </method>
73+
74+ <method name="CanStop">
75+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
76+ <arg name="can_stop" type="b" direction="out"/>
77+ </method>
78+
79+ <method name="OpenSession">
80+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
81+ <arg name="cookie" direction="out" type="s">
82+ <doc:doc>
83+ <doc:summary>The secret cookie that is used to identify the new session</doc:summary>
84+ </doc:doc>
85+ </arg>
86+ <doc:doc>
87+ <doc:description>
88+ <doc:para>This method requests that a new <doc:ref type="interface" to="Session">Session</doc:ref>
89+ be created for the calling process. The properties of this new Session are set automatically
90+ from information collected about the calling process.
91+ </doc:para>
92+ <doc:para>This new session exists until the calling process disconnects from the system bus or
93+ calls <doc:ref type="method" to="Manager.CloseSession">CloseSession()</doc:ref>.
94+ </doc:para>
95+ <doc:para>It is the responsibility of the calling process to set the environment variable
96+ XDG_SESSION_COOKIE to the value of the returned cookie. This cookie should only
97+ be made available to child processes of the caller so that they may be identified
98+ as members of this session.
99+ </doc:para>
100+ <doc:para>See this simple example:
101+ <doc:example language="c" title="simple example"><doc:code>
102+ DBusError error;
103+ DBusMessage *message;
104+ DBusMessage *reply;
105+
106+ message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit",
107+ "/org/freedesktop/ConsoleKit/Manager",
108+ "org.freedesktop.ConsoleKit.Manager",
109+ "OpenSession");
110+ if (message == NULL) {
111+ goto out;
112+ }
113+
114+ dbus_error_init (&amp;error);
115+ reply = dbus_connection_send_with_reply_and_block (connector->connection,
116+ message,
117+ -1,
118+ &amp;error);
119+ if (reply == NULL) {
120+ goto out;
121+ }
122+
123+ dbus_error_init (&amp;error);
124+ if (! dbus_message_get_args (reply,
125+ &amp;error,
126+ DBUS_TYPE_STRING, &amp;cookie,
127+ DBUS_TYPE_INVALID)) {
128+ goto out;
129+ }
130+
131+ </doc:code></doc:example></doc:para>
132+ </doc:description>
133+ <doc:seealso><doc:ref type="method" to="Manager.OpenSessionWithParameters">OpenSessionWithParameters()</doc:ref></doc:seealso>
134+ </doc:doc>
135+ </method>
136+ <method name="OpenSessionWithParameters">
137+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
138+ <arg name="parameters" direction="in" type="a(sv)">
139+ <doc:doc>
140+ <doc:summary>An array of sets of property names and values</doc:summary>
141+ </doc:doc>
142+ </arg>
143+ <arg name="cookie" direction="out" type="s">
144+ <doc:doc>
145+ <doc:summary>The secret cookie that is used to identify the new session</doc:summary>
146+ </doc:doc>
147+ </arg>
148+ <doc:doc>
149+ <doc:description>
150+ <doc:para>This method requests that a new <doc:ref type="interface" to="Session">Session</doc:ref>
151+ be created for the calling process. The properties of this new Session are from the
152+ parameters provided.
153+ </doc:para>
154+ <doc:para>This new session exists until the calling process disconnects from the system bus or
155+ calls <doc:ref type="method" to="Manager.CloseSession">CloseSession()</doc:ref>.
156+ </doc:para>
157+ <doc:para>It is the responsibility of the calling process to set the environment variable
158+ XDG_SESSION_COOKIE to the value of the returned cookie. This cookie should only
159+ be made available to child processes of the caller so that they may be identified
160+ as members of this session.
161+ </doc:para>
162+ <doc:para>See the <doc:ref type="interface" to="Session">Session</doc:ref> properties for a list of valid parameters.</doc:para>
163+ </doc:description>
164+ <doc:seealso><doc:ref type="interface" to="Session">org.freedesktop.ConsoleKit.Session</doc:ref></doc:seealso>
165+ <doc:permission>This method is restricted to privileged users by D-Bus policy.</doc:permission>
166+ </doc:doc>
167+ </method>
168+ <method name="CloseSession">
169+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
170+ <arg name="cookie" direction="in" type="s">
171+ <doc:doc>
172+ <doc:summary>The secret cookie that is used to identify the session</doc:summary>
173+ </doc:doc>
174+ </arg>
175+ <arg name="result" direction="out" type="b">
176+ <doc:doc>
177+ <doc:summary>Whether the session was successfully closed</doc:summary>
178+ </doc:doc>
179+ </arg>
180+ <doc:doc>
181+ <doc:description>
182+ <doc:para>This method is used to close the session identified by the supplied cookie.
183+ </doc:para>
184+ <doc:para>The session can only be closed by the same process that opened the session.
185+ </doc:para>
186+ </doc:description>
187+ </doc:doc>
188+ </method>
189+
190+ <method name="GetSeats">
191+ <arg name="seats" direction="out" type="ao">
192+ <doc:doc>
193+ <doc:summary>an array of Seat IDs</doc:summary>
194+ </doc:doc>
195+ </arg>
196+ <doc:doc>
197+ <doc:description>
198+ <doc:para>This gets a list of all the <doc:ref type="interface" to="Seat">Seats</doc:ref>
199+ that are currently present on the system.</doc:para>
200+ <doc:para>Each Seat ID is an D-Bus object path for the object that implements the
201+ <doc:ref type="interface" to="Seat">Seat</doc:ref> interface.</doc:para>
202+ </doc:description>
203+ <doc:seealso><doc:ref type="interface" to="Seat">org.freedesktop.ConsoleKit.Seat</doc:ref></doc:seealso>
204+ </doc:doc>
205+ </method>
206+
207+ <method name="GetSessions">
208+ <arg name="sessions" direction="out" type="ao">
209+ <doc:doc>
210+ <doc:summary>an array of Session IDs</doc:summary>
211+ </doc:doc>
212+ </arg>
213+ <doc:doc>
214+ <doc:description>
215+ <doc:para>This gets a list of all the <doc:ref type="interface" to="Session">Sessions</doc:ref>
216+ that are currently present on the system.</doc:para>
217+ <doc:para>Each Session ID is an D-Bus object path for the object that implements the
218+ <doc:ref type="interface" to="Session">Session</doc:ref> interface.</doc:para>
219+ </doc:description>
220+ <doc:seealso><doc:ref type="interface" to="Session">org.freedesktop.ConsoleKit.Session</doc:ref></doc:seealso>
221+ </doc:doc>
222+ </method>
223+
224+ <method name="GetSessionForCookie">
225+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
226+ <arg name="cookie" direction="in" type="s">
227+ <doc:doc>
228+ <doc:summary>The secret cookie that is used to identify the session</doc:summary>
229+ </doc:doc>
230+ </arg>
231+ <arg name="ssid" direction="out" type="o">
232+ <doc:doc>
233+ <doc:summary>The object identifier for the current session</doc:summary>
234+ </doc:doc>
235+ </arg>
236+ <doc:doc>
237+ <doc:description>
238+ <doc:para>Returns the session ID that is associated with the specified cookie.
239+ </doc:para>
240+ </doc:description>
241+ </doc:doc>
242+ </method>
243+ <method name="GetSessionForUnixProcess">
244+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
245+ <arg name="pid" direction="in" type="u">
246+ <doc:doc>
247+ <doc:summary>The POSIX process ID</doc:summary>
248+ </doc:doc>
249+ </arg>
250+ <arg name="ssid" direction="out" type="o">
251+ <doc:doc>
252+ <doc:summary>The object identifier for the current session</doc:summary>
253+ </doc:doc>
254+ </arg>
255+ <doc:doc>
256+ <doc:description>
257+ <doc:para>Attempts to determine the session ID for the specified
258+ POSIX process ID (pid).
259+ </doc:para>
260+ </doc:description>
261+ </doc:doc>
262+ </method>
263+ <method name="GetCurrentSession">
264+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
265+ <arg name="ssid" direction="out" type="o">
266+ <doc:doc>
267+ <doc:summary>The object identifier for the current session</doc:summary>
268+ </doc:doc>
269+ </arg>
270+ <doc:doc>
271+ <doc:description>
272+ <doc:para>Attempts to determine the session ID that the caller belongs to.
273+ </doc:para>
274+ <doc:para>See this example of using dbus-send:
275+ <doc:example language="shell" title="shell example"><doc:code>
276+ dbus-send --system --dest=org.freedesktop.ConsoleKit \
277+ --type=method_call --print-reply --reply-timeout=2000 \
278+ /org/freedesktop/ConsoleKit/Manager \
279+ org.freedesktop.ConsoleKit.Manager.GetCurrentSession
280+ </doc:code></doc:example></doc:para>
281+ </doc:description>
282+ </doc:doc>
283+ </method>
284+ <method name="GetSessionsForUnixUser">
285+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
286+ <arg name="uid" direction="in" type="u">
287+ <doc:doc>
288+ <doc:summary>POSIX User identification</doc:summary>
289+ </doc:doc>
290+ </arg>
291+ <arg name="sessions" direction="out" type="ao">
292+ <doc:doc>
293+ <doc:summary>an array of Session IDs</doc:summary>
294+ </doc:doc>
295+ </arg>
296+ <doc:doc>
297+ <doc:description>
298+ <doc:para>This gets a list of all the <doc:ref type="interface" to="Session">Sessions</doc:ref>
299+ that are currently open for the specified user.</doc:para>
300+ <doc:para>Each Session ID is an D-Bus object path for the object that implements the
301+ <doc:ref type="interface" to="Session">Session</doc:ref> interface.</doc:para>
302+ </doc:description>
303+ </doc:doc>
304+ </method>
305+ <method name="GetSessionsForUser">
306+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
307+ <arg name="uid" direction="in" type="u">
308+ <doc:doc>
309+ <doc:summary>User identification</doc:summary>
310+ </doc:doc>
311+ </arg>
312+ <arg name="sessions" direction="out" type="ao">
313+ <doc:doc>
314+ <doc:summary>an array of Session IDs</doc:summary>
315+ </doc:doc>
316+ </arg>
317+ <doc:doc>
318+ <doc:description>
319+ <doc:para>This gets a list of all the <doc:ref type="interface" to="Session">Sessions</doc:ref>
320+ that are currently open for the specified user.</doc:para>
321+ <doc:para>Each Session ID is an D-Bus object path for the object that implements the
322+ <doc:ref type="interface" to="Session">Session</doc:ref> interface.</doc:para>
323+ </doc:description>
324+ <doc:deprecated version="0.1.3" instead="GetSessionsForUnixUser"/>
325+ </doc:doc>
326+ </method>
327+
328+ <method name="GetSystemIdleHint">
329+ <arg name="idle_hint" type="b" direction="out">
330+ <doc:doc>
331+ <doc:summary>The value of the system-idle-hint</doc:summary>
332+ </doc:doc>
333+ </arg>
334+ <doc:doc>
335+ <doc:description>
336+ <doc:para>Returns TRUE if the <doc:ref type="property" to="Session:idle-hint">idle-hint</doc:ref>
337+ property of every open session is TRUE or if there are no open sessions.
338+ </doc:para>
339+ </doc:description>
340+ </doc:doc>
341+ </method>
342+ <method name="GetSystemIdleSinceHint">
343+ <arg name="iso8601_datetime" type="s" direction="out">
344+ <doc:doc>
345+ <doc:summary>An ISO 8601 format date-type string</doc:summary>
346+ </doc:doc>
347+ </arg>
348+ <doc:doc>
349+ <doc:description>
350+ <doc:para>Returns an ISO 8601 date-time string that corresponds to
351+ the time of the last change of the system-idle-hint.
352+ </doc:para>
353+ </doc:description>
354+ </doc:doc>
355+ </method>
356+
357+ <signal name="SeatAdded">
358+ <arg name="sid" type="o">
359+ <doc:doc>
360+ <doc:summary>The Seat ID for the added seat</doc:summary>
361+ </doc:doc>
362+ </arg>
363+ <doc:doc>
364+ <doc:description>
365+ <doc:para>Emitted when a Seat has been added to the system.
366+ </doc:para>
367+ </doc:description>
368+ </doc:doc>
369+ </signal>
370+ <signal name="SeatRemoved">
371+ <arg name="sid" type="o">
372+ <doc:doc>
373+ <doc:summary>The Seat ID for the removed seat</doc:summary>
374+ </doc:doc>
375+ </arg>
376+ <doc:doc>
377+ <doc:description>
378+ <doc:para>Emitted when a Seat has been removed from the system.
379+ </doc:para>
380+ </doc:description>
381+ </doc:doc>
382+ </signal>
383+ <signal name="SystemIdleHintChanged">
384+ <arg name="hint" type="b">
385+ <doc:doc>
386+ <doc:summary>The value of the system-idle-hint</doc:summary>
387+ </doc:doc>
388+ </arg>
389+ <doc:doc>
390+ <doc:description>
391+ <doc:para>Emitted when the value of the system-idle-hint has changed.
392+ </doc:para>
393+ </doc:description>
394+ </doc:doc>
395+ </signal>
396+ </interface>
397+</node>
398
399=== modified file 'src/users-service-dbus.c'
400--- src/users-service-dbus.c 2010-02-19 12:28:45 +0000
401+++ src/users-service-dbus.c 2010-03-02 03:40:29 +0000
402@@ -34,6 +34,7 @@
403 #include "users-service-dbus.h"
404 #include "users-service-client.h"
405 #include "users-service-marshal.h"
406+#include "consolekit-manager-client.h"
407
408 static void users_service_dbus_class_init (UsersServiceDbusClass *klass);
409 static void users_service_dbus_init (UsersServiceDbus *self);
410@@ -509,14 +510,7 @@
411 int i;
412
413 error = NULL;
414- if (!dbus_g_proxy_call (priv->ck_proxy,
415- "GetSessionsForUnixUser",
416- &error,
417- G_TYPE_UINT, user->uid,
418- G_TYPE_INVALID,
419- dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
420- &sessions,
421- G_TYPE_INVALID))
422+ if (!org_freedesktop_ConsoleKit_Manager_get_sessions_for_unix_user(priv->ck_proxy, user->uid, &sessions, &error))
423 {
424 g_debug ("Failed to call GetSessionsForUnixUser: %s", error->message);
425 g_error_free (error);

Subscribers

People subscribed via source and target branches