author | yippi |
Thu, 28 Jul 2011 03:50:58 +0000 | |
branch | gnome-2-30 |
changeset 22037 | 6bbc65b301fa |
parent 21940 | 435c776c0f32 |
child 22042 | d88ef0594f24 |
permissions | -rw-r--r-- |
16129 | 1 |
diff --git a/configure.ac b/configure.ac |
16844 | 2 |
index 117d788..2ff6020 100644 |
16129 | 3 |
--- a/configure.ac |
4 |
+++ b/configure.ac |
|
5 |
@@ -203,6 +203,18 @@ AM_CONDITIONAL(CK_COMPILE_SOLARIS, test x$CK_BACKEND = xsolaris, [Compiling for |
|
6 |
AC_SUBST(CK_BACKEND) |
|
7 |
||
8 |
dnl --------------------------------------------------------------------------- |
|
9 |
+dnl Check for X11 DIR |
|
10 |
+dnl --------------------------------------------------------------------------- |
|
11 |
+ |
|
12 |
+X11_DIR=`$PKG_CONFIG --variable=bindir xorg-server 2>/dev/null` |
|
13 |
+if test "x$X11_DIR" = x; then |
|
14 |
+ AC_PATH_PROGS([XSERVER], [Xorg X],,[$PATH:/usr/X11/bin:/usr/bin]) |
|
15 |
+ test "x$XSERVER" != x && X11_DIR=`dirname "$XSERVER"` |
|
16 |
+fi |
|
17 |
+test "x$X11_DIR" = x && X11_DIR=$bindir |
|
18 |
+AC_SUBST([X11_DIR]) |
|
19 |
+ |
|
20 |
+dnl --------------------------------------------------------------------------- |
|
21 |
dnl Check for PAM |
|
22 |
dnl --------------------------------------------------------------------------- |
|
23 |
||
16647 | 24 |
@@ -303,6 +315,14 @@ if test "x$enable_inotify" = "xyes" ; then |
25 |
fi |
|
26 |
||
27 |
dnl --------------------------------------------------------------------------- |
|
28 |
+dnl check for strverscmp |
|
29 |
+dnl --------------------------------------------------------------------------- |
|
30 |
+have_strverscmp=no |
|
31 |
+AC_CHECK_FUNCS(strverscmp, [have_strverscmp=yes], []) |
|
32 |
+ |
|
33 |
+AM_CONDITIONAL(USE_SELF_STRVERSCMP, test "x$have_strverscmp" = "xno", [Define if we do not have strverscmp]) |
|
34 |
+ |
|
35 |
+dnl --------------------------------------------------------------------------- |
|
36 |
dnl check for RBAC |
|
37 |
dnl --------------------------------------------------------------------------- |
|
38 |
||
39 |
@@ -401,6 +421,8 @@ tools/linux/Makefile |
|
16129 | 40 |
tools/freebsd/Makefile |
41 |
tools/solaris/Makefile |
|
42 |
data/Makefile |
|
43 |
+data/displays.d/Makefile |
|
16232 | 44 |
+data/sessions.d/Makefile |
16129 | 45 |
doc/Makefile |
46 |
doc/dbus/ConsoleKit.xml |
|
47 |
doc/dbus/Makefile |
|
48 |
diff --git a/data/00-primary.seat b/data/00-primary.seat |
|
16647 | 49 |
index 6e61db4..0632382 100644 |
16129 | 50 |
--- a/data/00-primary.seat |
51 |
+++ b/data/00-primary.seat |
|
16647 | 52 |
@@ -1,5 +1,26 @@ |
16129 | 53 |
[Seat Entry] |
54 |
Version=1.0 |
|
55 |
Name=Primary seat |
|
16647 | 56 |
+# Specified Seat ID, if this value is NULL, ConsoleKit will decide one. |
57 |
+# The ID only contain the ASICC characters "[A-Z][a-z][0-9]_" |
|
58 |
+ID=StaticSeat1 |
|
16129 | 59 |
+Description=start one static local display at :0 |
60 |
+ |
|
61 |
+# Indicate whether to create this seat or not. If it is set true, then CK will |
|
62 |
+# not create this seat. Default value is false. |
|
63 |
Hidden=false |
|
64 |
-Devices= |
|
65 |
\ No newline at end of file |
|
66 |
+ |
|
67 |
+# Indicate input/output devices including keyboard-pointer-video |
|
68 |
+# card-monitor-sound-usb devices, |
|
69 |
+# This key will not implemented now, it might need be divided into |
|
70 |
+# several keys in the future: |
|
71 |
+# Pointer= |
|
72 |
+# Monitor= |
|
73 |
+# VideoCard= |
|
74 |
+# Monitor= |
|
75 |
+# UsbHub= |
|
76 |
+Devices= |
|
77 |
+ |
|
16232 | 78 |
+# List of sessions to start on the seat, separated by ';' |
79 |
+# Each session is defined in sessions.d/ |
|
80 |
+Sessions=Local; |
|
16129 | 81 |
diff --git a/data/ConsoleKit.conf b/data/ConsoleKit.conf |
16475 | 82 |
index 948f95f..8cf490a 100644 |
16129 | 83 |
--- a/data/ConsoleKit.conf |
84 |
+++ b/data/ConsoleKit.conf |
|
16232 | 85 |
@@ -44,6 +44,9 @@ |
86 |
send_member="CloseSession"/> |
|
87 |
<allow send_destination="org.freedesktop.ConsoleKit" |
|
88 |
send_interface="org.freedesktop.ConsoleKit.Manager" |
|
89 |
+ send_member="GetUnmanagedSeats"/> |
|
90 |
+ <allow send_destination="org.freedesktop.ConsoleKit" |
|
91 |
+ send_interface="org.freedesktop.ConsoleKit.Manager" |
|
92 |
send_member="GetSeats"/> |
|
93 |
<allow send_destination="org.freedesktop.ConsoleKit" |
|
94 |
send_interface="org.freedesktop.ConsoleKit.Manager" |
|
95 |
@@ -69,6 +72,18 @@ |
|
96 |
<allow send_destination="org.freedesktop.ConsoleKit" |
|
97 |
send_interface="org.freedesktop.ConsoleKit.Manager" |
|
98 |
send_member="GetSystemIdleSinceHint"/> |
|
99 |
+ <allow send_destination="org.freedesktop.ConsoleKit" |
|
100 |
+ send_interface="org.freedesktop.ConsoleKit.Manager" |
|
101 |
+ send_member="AddSeat"/> |
|
102 |
+ <allow send_destination="org.freedesktop.ConsoleKit" |
|
103 |
+ send_interface="org.freedesktop.ConsoleKit.Manager" |
|
104 |
+ send_member="RemoveSeat"/> |
|
105 |
+ <allow send_destination="org.freedesktop.ConsoleKit" |
|
106 |
+ send_interface="org.freedesktop.ConsoleKit.Manager" |
|
107 |
+ send_member="AddSession"/> |
|
108 |
+ <allow send_destination="org.freedesktop.ConsoleKit" |
|
109 |
+ send_interface="org.freedesktop.ConsoleKit.Manager" |
|
110 |
+ send_member="RemoveSession"/> |
|
111 |
||
112 |
<allow send_destination="org.freedesktop.ConsoleKit" |
|
113 |
send_interface="org.freedesktop.ConsoleKit.Seat" |
|
114 |
@@ -88,6 +103,9 @@ |
|
115 |
<allow send_destination="org.freedesktop.ConsoleKit" |
|
116 |
send_interface="org.freedesktop.ConsoleKit.Seat" |
|
117 |
send_member="ActivateSession"/> |
|
118 |
+ <allow send_destination="org.freedesktop.ConsoleKit" |
|
119 |
+ send_interface="org.freedesktop.ConsoleKit.Seat" |
|
120 |
+ send_member="ManageSeat"/> |
|
121 |
||
122 |
<allow send_destination="org.freedesktop.ConsoleKit" |
|
123 |
send_interface="org.freedesktop.ConsoleKit.Session" |
|
124 |
@@ -103,6 +121,9 @@ |
|
125 |
send_member="GetSessionType"/> |
|
126 |
<allow send_destination="org.freedesktop.ConsoleKit" |
|
127 |
send_interface="org.freedesktop.ConsoleKit.Session" |
|
128 |
+ send_member="GetDisplayType"/> |
|
129 |
+ <allow send_destination="org.freedesktop.ConsoleKit" |
|
130 |
+ send_interface="org.freedesktop.ConsoleKit.Session" |
|
131 |
send_member="GetUser"/> |
|
132 |
<allow send_destination="org.freedesktop.ConsoleKit" |
|
133 |
send_interface="org.freedesktop.ConsoleKit.Session" |
|
134 |
@@ -127,6 +148,12 @@ |
|
16129 | 135 |
send_member="IsLocal"/> |
136 |
<allow send_destination="org.freedesktop.ConsoleKit" |
|
137 |
send_interface="org.freedesktop.ConsoleKit.Session" |
|
138 |
+ send_member="IsDynamic"/> |
|
139 |
+ <allow send_destination="org.freedesktop.ConsoleKit" |
|
140 |
+ send_interface="org.freedesktop.ConsoleKit.Session" |
|
16232 | 141 |
+ send_member="IsOpen"/> |
142 |
+ <allow send_destination="org.freedesktop.ConsoleKit" |
|
143 |
+ send_interface="org.freedesktop.ConsoleKit.Session" |
|
16129 | 144 |
send_member="GetCreationTime"/> |
145 |
<allow send_destination="org.freedesktop.ConsoleKit" |
|
146 |
send_interface="org.freedesktop.ConsoleKit.Session" |
|
16475 | 147 |
@@ -136,12 +163,11 @@ |
148 |
send_member="GetIdleHint"/> |
|
149 |
<allow send_destination="org.freedesktop.ConsoleKit" |
|
150 |
send_interface="org.freedesktop.ConsoleKit.Session" |
|
151 |
- send_member="SetIdleHint"/> |
|
152 |
- <allow send_destination="org.freedesktop.ConsoleKit" |
|
153 |
- send_interface="org.freedesktop.ConsoleKit.Session" |
|
154 |
send_member="GetIdleSinceHint"/> |
|
155 |
<allow send_interface="org.freedesktop.ConsoleKit.Session" |
|
156 |
send_member="SetIdleHint"/> |
|
157 |
+ <allow send_interface="org.freedesktop.ConsoleKit.Session" |
|
158 |
+ send_member="SetRemoveOnClose"/> |
|
159 |
</policy> |
|
160 |
||
161 |
</busconfig> |
|
16129 | 162 |
diff --git a/data/Makefile.am b/data/Makefile.am |
16232 | 163 |
index 041b431..2054e96 100644 |
16129 | 164 |
--- a/data/Makefile.am |
165 |
+++ b/data/Makefile.am |
|
16232 | 166 |
@@ -1,5 +1,10 @@ |
16129 | 167 |
NULL = |
168 |
||
169 |
+SUBDIRS = \ |
|
170 |
+ displays.d \ |
|
16232 | 171 |
+ sessions.d \ |
16129 | 172 |
+ $(NULL) |
173 |
+ |
|
174 |
dbusconfdir = $(DBUS_SYS_DIR) |
|
175 |
dbusconf_DATA = ConsoleKit.conf |
|
176 |
||
16232 | 177 |
diff --git a/data/displays.d/Headless.display.in b/data/displays.d/Headless.display.in |
16129 | 178 |
new file mode 100644 |
16232 | 179 |
index 0000000..754d2bf |
16129 | 180 |
--- /dev/null |
16232 | 181 |
+++ b/data/displays.d/Headless.display.in |
182 |
@@ -0,0 +1,5 @@ |
|
16129 | 183 |
+[Display] |
16232 | 184 |
+Type=X11 |
185 |
+ |
|
186 |
+[X11] |
|
187 |
+Exec=@X11_DIR@/Xvfb $display -auth $auth |
|
188 |
diff --git a/data/displays.d/Local.display.in b/data/displays.d/Local.display.in |
|
16129 | 189 |
new file mode 100644 |
16232 | 190 |
index 0000000..b845a7b |
16129 | 191 |
--- /dev/null |
16232 | 192 |
+++ b/data/displays.d/Local.display.in |
193 |
@@ -0,0 +1,5 @@ |
|
16129 | 194 |
+[Display] |
16232 | 195 |
+Type=X11 |
196 |
+ |
|
197 |
+[X11] |
|
198 |
+Exec=@X11_DIR@/Xorg $display -br -verbose -auth $auth -nolisten tcp $vt |
|
199 |
diff --git a/data/displays.d/LocalVNC.display.in b/data/displays.d/LocalVNC.display.in |
|
16129 | 200 |
new file mode 100644 |
16232 | 201 |
index 0000000..6ad336b |
16129 | 202 |
--- /dev/null |
16232 | 203 |
+++ b/data/displays.d/LocalVNC.display.in |
204 |
@@ -0,0 +1,5 @@ |
|
16129 | 205 |
+[Display] |
16232 | 206 |
+Type=X11 |
207 |
+ |
|
208 |
+[X11] |
|
209 |
+Exec=@X11_DIR@/Xvnc $display -auth $auth -query localhost |
|
16129 | 210 |
diff --git a/data/displays.d/Makefile.am b/data/displays.d/Makefile.am |
211 |
new file mode 100644 |
|
16232 | 212 |
index 0000000..1fab1d2 |
16129 | 213 |
--- /dev/null |
214 |
+++ b/data/displays.d/Makefile.am |
|
215 |
@@ -0,0 +1,29 @@ |
|
216 |
+NULL = |
|
217 |
+ |
|
218 |
+displaydir = $(sysconfdir)/ConsoleKit/displays.d |
|
219 |
+display_in_files = \ |
|
16232 | 220 |
+ Local.display.in \ |
221 |
+ RemoteMachine.display.in \ |
|
222 |
+ LocalVNC.display.in \ |
|
223 |
+ Headless.display.in |
|
224 |
+ |
|
225 |
+display_DATA = $(display_in_files:.display.in=.display) |
|
226 |
+ |
|
227 |
+Local.display: Local.display.in Makefile |
|
16129 | 228 |
+ sed -e "s|\@X11_DIR\@|$(X11_DIR)|" $< > $@ |
16232 | 229 |
+RemoteMachine.display: RemoteMachine.display.in Makefile |
16129 | 230 |
+ sed -e "s|\@X11_DIR\@|$(X11_DIR)|" $< > $@ |
16232 | 231 |
+LocalVNC.display: LocalVNC.display.in Makefile |
16129 | 232 |
+ sed -e "s|\@X11_DIR\@|$(X11_DIR)|" $< > $@ |
16232 | 233 |
+Headless.display: Headless.display.in Makefile |
16129 | 234 |
+ sed -e "s|\@X11_DIR\@|$(X11_DIR)|" $< > $@ |
235 |
+ |
|
236 |
+EXTRA_DIST = \ |
|
237 |
+ $(display_in_files) \ |
|
238 |
+ $(NULL) |
|
239 |
+ |
|
240 |
+MAINTAINERCLEANFILES = \ |
|
241 |
+ *~ \ |
|
242 |
+ Makefile.in |
|
243 |
+ |
|
244 |
+CLEANFILES = $(display_DATA) |
|
16232 | 245 |
diff --git a/data/displays.d/RemoteMachine.display.in b/data/displays.d/RemoteMachine.display.in |
246 |
new file mode 100644 |
|
247 |
index 0000000..7c69451 |
|
248 |
--- /dev/null |
|
249 |
+++ b/data/displays.d/RemoteMachine.display.in |
|
250 |
@@ -0,0 +1,5 @@ |
|
251 |
+[Display] |
|
252 |
+Type=X11 |
|
253 |
+ |
|
254 |
+[X11] |
|
255 |
+Exec=@X11_DIR@/Xorg $display -br -verbose -auth $auth -indirect $vt |
|
256 |
diff --git a/data/sessions.d/Headless.session b/data/sessions.d/Headless.session |
|
16129 | 257 |
new file mode 100644 |
16232 | 258 |
index 0000000..d376af9 |
259 |
--- /dev/null |
|
260 |
+++ b/data/sessions.d/Headless.session |
|
261 |
@@ -0,0 +1,8 @@ |
|
262 |
+[Session Entry] |
|
263 |
+Name=Headless |
|
264 |
+Type=LoginWindow |
|
265 |
+Description=Login Window running on headless display |
|
266 |
+DisplayTemplate=Headless |
|
267 |
+ |
|
268 |
+[Headless] |
|
269 |
+display=:32 |
|
270 |
diff --git a/data/sessions.d/Local.session b/data/sessions.d/Local.session |
|
271 |
new file mode 100644 |
|
272 |
index 0000000..9d3b975 |
|
273 |
--- /dev/null |
|
274 |
+++ b/data/sessions.d/Local.session |
|
275 |
@@ -0,0 +1,9 @@ |
|
276 |
+[Session Entry] |
|
277 |
+Name=Local |
|
278 |
+Type=LoginWindow |
|
279 |
+Description=Local Login Screen |
|
280 |
+DisplayTemplate=Local |
|
281 |
+ |
|
282 |
+[Local] |
|
283 |
+display=:0 |
|
284 |
+vt=vt1 |
|
285 |
diff --git a/data/sessions.d/LocalVNC.session b/data/sessions.d/LocalVNC.session |
|
286 |
new file mode 100644 |
|
287 |
index 0000000..c05802f |
|
16129 | 288 |
--- /dev/null |
16232 | 289 |
+++ b/data/sessions.d/LocalVNC.session |
290 |
@@ -0,0 +1,8 @@ |
|
291 |
+[Session Entry] |
|
292 |
+Name=LocalVNC |
|
293 |
+Type=LoginWindow |
|
294 |
+Description=Connect to local VNC server running on same machine |
|
295 |
+DisplayTemplate=LocalVNC |
|
296 |
+ |
|
297 |
+[LocalVNC] |
|
298 |
+display=:64 |
|
299 |
diff --git a/data/sessions.d/Makefile.am b/data/sessions.d/Makefile.am |
|
300 |
new file mode 100644 |
|
301 |
index 0000000..f17ffdc |
|
302 |
--- /dev/null |
|
303 |
+++ b/data/sessions.d/Makefile.am |
|
304 |
@@ -0,0 +1,16 @@ |
|
305 |
+NULL = |
|
306 |
+ |
|
307 |
+sessiondir = $(sysconfdir)/ConsoleKit/sessions.d |
|
308 |
+session_DATA = \ |
|
309 |
+ Headless.session \ |
|
310 |
+ Local.session \ |
|
311 |
+ LocalVNC.session \ |
|
312 |
+ Remote.session |
|
313 |
+ |
|
314 |
+EXTRA_DIST = \ |
|
315 |
+ $(session_DATA) \ |
|
316 |
+ $(NULL) |
|
317 |
+ |
|
318 |
+MAINTAINERCLEANFILES = \ |
|
319 |
+ *~ \ |
|
320 |
+ Makefile.in |
|
321 |
diff --git a/data/sessions.d/Remote.session b/data/sessions.d/Remote.session |
|
322 |
new file mode 100644 |
|
323 |
index 0000000..e88f975 |
|
324 |
--- /dev/null |
|
325 |
+++ b/data/sessions.d/Remote.session |
|
326 |
@@ -0,0 +1,9 @@ |
|
327 |
+[Session Entry] |
|
328 |
+Name=Remote Chooser |
|
329 |
+Type=Remote |
|
330 |
+Description=Connect to chooser on nearby remote machine |
|
331 |
+DisplayTemplate=RemoteMachine |
|
332 |
+ |
|
333 |
+[RemoteMachine] |
|
334 |
+display=:96 |
|
335 |
+vt=vt10 |
|
336 |
diff --git a/doc/dbus/ck-terms.xml b/doc/dbus/ck-terms.xml |
|
337 |
index d3d544d..1b43ca6 100644 |
|
338 |
--- a/doc/dbus/ck-terms.xml |
|
339 |
+++ b/doc/dbus/ck-terms.xml |
|
340 |
@@ -64,4 +64,11 @@ True, hardware, multi-seat capabilities will be added in a later release. |
|
341 |
</para> |
|
342 |
</sect1> |
|
343 |
||
344 |
+ <sect1> |
|
345 |
+ <title>Seat manager</title> |
|
346 |
+ <para> |
|
347 |
+The seat manager is the process responsible for starting and stopping sessions on a seat. |
|
348 |
+ </para> |
|
349 |
+ </sect1> |
|
350 |
+ |
|
351 |
</chapter> |
|
16129 | 352 |
diff --git a/libck-connector/ck-connector.c b/libck-connector/ck-connector.c |
16911 | 353 |
index 7f6f87f..87a7d4a 100644 |
16129 | 354 |
--- a/libck-connector/ck-connector.c |
355 |
+++ b/libck-connector/ck-connector.c |
|
16911 | 356 |
@@ -76,8 +76,11 @@ static struct { |
16129 | 357 |
{ "display-device", DBUS_TYPE_STRING }, |
358 |
{ "x11-display-device", DBUS_TYPE_STRING }, |
|
359 |
{ "x11-display", DBUS_TYPE_STRING }, |
|
360 |
+ { "seat-id", DBUS_TYPE_STRING }, |
|
16232 | 361 |
+ { "session", DBUS_TYPE_STRING }, |
16129 | 362 |
{ "remote-host-name", DBUS_TYPE_STRING }, |
363 |
{ "session-type", DBUS_TYPE_STRING }, |
|
16540 | 364 |
+ { "display-type", DBUS_TYPE_STRING }, |
16129 | 365 |
{ "is-local", DBUS_TYPE_BOOLEAN }, |
366 |
{ "unix-user", DBUS_TYPE_INT32 }, |
|
367 |
}; |
|
368 |
diff --git a/src/Makefile.am b/src/Makefile.am |
|
16647 | 369 |
index 6ab05c8..97a59ef 100644 |
16129 | 370 |
--- a/src/Makefile.am |
371 |
+++ b/src/Makefile.am |
|
372 |
@@ -107,6 +107,8 @@ console_kit_daemon_SOURCES = \ |
|
373 |
ck-file-monitor.h \ |
|
374 |
ck-job.h \ |
|
375 |
ck-job.c \ |
|
16232 | 376 |
+ ck-display-template.h \ |
377 |
+ ck-display-template.c \ |
|
16129 | 378 |
ck-seat.h \ |
379 |
ck-seat.c \ |
|
380 |
ck-session-leader.h \ |
|
16647 | 381 |
@@ -122,6 +124,13 @@ console_kit_daemon_SOURCES = \ |
382 |
$(BUILT_SOURCES) \ |
|
383 |
$(NULL) |
|
384 |
||
385 |
+if USE_SELF_STRVERSCMP |
|
386 |
+console_kit_daemon_SOURCES += \ |
|
387 |
+ strverscmp.c \ |
|
388 |
+ strverscmp.h \ |
|
389 |
+ $(NULL) |
|
390 |
+endif |
|
391 |
+ |
|
392 |
if ENABLE_INOTIFY |
|
393 |
FILE_MONITOR_BACKEND = ck-file-monitor-inotify.c |
|
394 |
else |
|
16232 | 395 |
diff --git a/src/ck-display-template.c b/src/ck-display-template.c |
16129 | 396 |
new file mode 100644 |
16232 | 397 |
index 0000000..9206103 |
16129 | 398 |
--- /dev/null |
16232 | 399 |
+++ b/src/ck-display-template.c |
400 |
@@ -0,0 +1,341 @@ |
|
401 |
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- |
|
402 |
+ * |
|
403 |
+ * Authors: [email protected], Ray Strode <[email protected]> |
|
404 |
+ * Copyright (C) 2009 Sun Microsystems, Inc. |
|
405 |
+ * Red Hat, Inc. |
|
406 |
+ * |
|
407 |
+ * This program is free software; you can redistribute it and/or modify |
|
408 |
+ * it under the terms of the GNU General Public License as published by |
|
409 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
410 |
+ * (at your option) any later version. |
|
411 |
+ * |
|
412 |
+ * This program is distributed in the hope that it will be useful, |
|
413 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
414 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
415 |
+ * GNU General Public License for more details. |
|
416 |
+ * |
|
417 |
+ * You should have received a copy of the GNU General Public License |
|
418 |
+ * along with this program; if not, write to the Free Software |
|
419 |
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
420 |
+ * |
|
421 |
+ */ |
|
422 |
+ |
|
423 |
+#include "config.h" |
|
424 |
+ |
|
425 |
+#include <string.h> |
|
426 |
+#include <glib.h> |
|
427 |
+#include <glib-object.h> |
|
428 |
+ |
|
429 |
+#include "ck-display-template.h" |
|
430 |
+ |
|
431 |
+#define CK_DISPLAY_TEMPLATE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CK_TYPE_DISPLAY_TEMPLATE, CkDisplayTemplatePrivate)) |
|
432 |
+ |
|
433 |
+#define CK_DISPLAY_TEMPLATES_DIR SYSCONFDIR "/ConsoleKit/displays.d" |
|
434 |
+ |
|
435 |
+struct CkDisplayTemplatePrivate |
|
436 |
+{ |
|
437 |
+ char *name; |
|
438 |
+ char *type; |
|
439 |
+ GHashTable *parameters; |
|
440 |
+}; |
|
441 |
+ |
|
442 |
+enum { |
|
443 |
+ PROP_0, |
|
444 |
+ PROP_NAME, |
|
445 |
+ PROP_TYPE, |
|
446 |
+ PROP_PARAMETERS, |
|
447 |
+}; |
|
448 |
+ |
|
449 |
+static void ck_display_template_class_init (CkDisplayTemplateClass *klass); |
|
450 |
+static void ck_display_template_init (CkDisplayTemplate *display); |
|
451 |
+static void ck_display_template_finalize (GObject *object); |
|
452 |
+static gboolean ck_display_template_load (CkDisplayTemplate *display); |
|
453 |
+ |
|
454 |
+static GHashTable *ck_display_templates; |
|
455 |
+ |
|
456 |
+G_DEFINE_TYPE (CkDisplayTemplate, ck_display_template, G_TYPE_OBJECT) |
|
457 |
+ |
|
458 |
+static void |
|
459 |
+_ck_display_template_set_name (CkDisplayTemplate *display, |
|
460 |
+ const char *name) |
|
461 |
+{ |
|
462 |
+ g_free (display->priv->name); |
|
463 |
+ display->priv->name = g_strdup (name); |
|
464 |
+} |
|
465 |
+ |
|
466 |
+static void |
|
467 |
+_ck_display_template_set_type_string (CkDisplayTemplate *display, |
|
468 |
+ const char *type) |
|
469 |
+{ |
|
470 |
+ g_free (display->priv->type); |
|
471 |
+ display->priv->type = g_strdup (type); |
|
472 |
+} |
|
473 |
+ |
|
474 |
+static void |
|
475 |
+_ck_display_template_set_parameters (CkDisplayTemplate *display, |
|
476 |
+ GHashTable *parameters) |
|
477 |
+{ |
|
478 |
+ if (display->priv->parameters != NULL) { |
|
479 |
+ g_hash_table_unref (display->priv->parameters); |
|
480 |
+ } |
|
481 |
+ |
|
482 |
+ if (parameters == NULL) { |
|
483 |
+ display->priv->parameters = g_hash_table_new_full (g_str_hash, g_str_equal, |
|
484 |
+ (GDestroyNotify) g_free, |
|
485 |
+ (GDestroyNotify) g_free); |
|
486 |
+ } else { |
|
487 |
+ display->priv->parameters = g_hash_table_ref (parameters); |
|
488 |
+ } |
|
489 |
+} |
|
490 |
+ |
|
491 |
+static void |
|
492 |
+ck_display_template_set_property (GObject *object, |
|
493 |
+ guint prop_id, |
|
494 |
+ const GValue *value, |
|
495 |
+ GParamSpec *pspec) |
|
496 |
+{ |
|
497 |
+ CkDisplayTemplate *self; |
|
498 |
+ |
|
499 |
+ self = CK_DISPLAY_TEMPLATE (object); |
|
500 |
+ |
|
501 |
+ switch (prop_id) { |
|
502 |
+ case PROP_NAME: |
|
503 |
+ _ck_display_template_set_name (self, g_value_get_string (value)); |
|
504 |
+ break; |
|
505 |
+ case PROP_TYPE: |
|
506 |
+ _ck_display_template_set_type_string (self, g_value_get_string (value)); |
|
507 |
+ break; |
|
508 |
+ case PROP_PARAMETERS: |
|
509 |
+ _ck_display_template_set_parameters (self, g_value_get_boxed (value)); |
|
510 |
+ break; |
|
511 |
+ default: |
|
512 |
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
|
513 |
+ break; |
|
514 |
+ } |
|
515 |
+} |
|
516 |
+ |
|
517 |
+static void |
|
518 |
+ck_display_template_get_property (GObject *object, |
|
519 |
+ guint prop_id, |
|
520 |
+ GValue *value, |
|
521 |
+ GParamSpec *pspec) |
|
522 |
+{ |
|
523 |
+ CkDisplayTemplate *self; |
|
524 |
+ |
|
525 |
+ self = CK_DISPLAY_TEMPLATE (object); |
|
526 |
+ |
|
527 |
+ switch (prop_id) { |
|
528 |
+ case PROP_NAME: |
|
529 |
+ g_value_set_string (value, self->priv->name); |
|
530 |
+ break; |
|
531 |
+ case PROP_TYPE: |
|
532 |
+ g_value_set_string (value, self->priv->type); |
|
533 |
+ break; |
|
534 |
+ case PROP_PARAMETERS: |
|
535 |
+ g_value_set_boxed (value, self->priv->parameters); |
|
536 |
+ break; |
|
537 |
+ default: |
|
538 |
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
|
539 |
+ break; |
|
540 |
+ } |
|
541 |
+} |
|
542 |
+ |
|
543 |
+static void |
|
544 |
+ck_display_template_class_init (CkDisplayTemplateClass *klass) |
|
545 |
+{ |
|
546 |
+ GObjectClass *object_class = G_OBJECT_CLASS (klass); |
|
547 |
+ |
|
548 |
+ object_class->get_property = ck_display_template_get_property; |
|
549 |
+ object_class->set_property = ck_display_template_set_property; |
|
550 |
+ object_class->finalize = ck_display_template_finalize; |
|
551 |
+ |
|
552 |
+ g_object_class_install_property (object_class, |
|
553 |
+ PROP_NAME, |
|
554 |
+ g_param_spec_string ("name", |
|
555 |
+ "display type name", |
|
556 |
+ "display type name", |
|
557 |
+ NULL, |
|
558 |
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); |
|
559 |
+ g_object_class_install_property (object_class, |
|
560 |
+ PROP_TYPE, |
|
561 |
+ g_param_spec_string ("type", |
|
562 |
+ "type", |
|
563 |
+ "Type", |
|
564 |
+ NULL, |
|
565 |
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); |
|
566 |
+ g_object_class_install_property (object_class, |
|
567 |
+ PROP_PARAMETERS, |
|
568 |
+ g_param_spec_boxed ("parameters", |
|
569 |
+ "Parameters", |
|
570 |
+ "Parameters", |
|
571 |
+ G_TYPE_HASH_TABLE, |
|
572 |
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); |
|
573 |
+ g_type_class_add_private (klass, sizeof (CkDisplayTemplatePrivate)); |
|
574 |
+} |
|
575 |
+ |
|
576 |
+static void |
|
577 |
+ck_display_template_init (CkDisplayTemplate *display) |
|
578 |
+{ |
|
579 |
+ display->priv = CK_DISPLAY_TEMPLATE_GET_PRIVATE (display); |
|
580 |
+ |
|
581 |
+ display->priv->name = NULL; |
|
582 |
+ display->priv->type = NULL; |
|
583 |
+ display->priv->parameters = g_hash_table_new_full (g_str_hash, g_str_equal, |
|
584 |
+ (GDestroyNotify) g_free, |
|
585 |
+ (GDestroyNotify) g_free); |
|
586 |
+} |
|
587 |
+ |
|
588 |
+static void |
|
589 |
+ck_display_template_finalize (GObject *object) |
|
590 |
+{ |
|
591 |
+ CkDisplayTemplate *display; |
|
592 |
+ |
|
593 |
+ g_return_if_fail (object != NULL); |
|
594 |
+ g_return_if_fail (CK_IS_DISPLAY_TEMPLATE (object)); |
|
595 |
+ |
|
596 |
+ display = CK_DISPLAY_TEMPLATE (object); |
|
597 |
+ |
|
598 |
+ g_return_if_fail (display->priv != NULL); |
|
599 |
+ |
|
600 |
+ g_free (display->priv->name); |
|
601 |
+ g_free (display->priv->type); |
|
602 |
+ g_hash_table_unref (display->priv->parameters); |
|
603 |
+ |
|
604 |
+ G_OBJECT_CLASS (ck_display_template_parent_class)->finalize (object); |
|
605 |
+} |
|
606 |
+ |
|
607 |
+static gboolean |
|
608 |
+ck_display_template_load (CkDisplayTemplate *display) |
|
609 |
+{ |
|
610 |
+ GKeyFile *key_file; |
|
611 |
+ const char *name; |
|
612 |
+ char *group; |
|
613 |
+ char *filename; |
|
614 |
+ gboolean hidden; |
|
615 |
+ char *type; |
|
616 |
+ gboolean res; |
|
617 |
+ GError *error; |
|
618 |
+ char **type_keys; |
|
619 |
+ GHashTable *parameters; |
|
620 |
+ |
|
621 |
+ name = ck_display_template_get_name (display); |
|
622 |
+ |
|
623 |
+ g_return_val_if_fail (name && !g_str_equal (name, ""), FALSE); |
|
624 |
+ |
|
625 |
+ filename = g_strdup_printf ("%s/%s.display", CK_DISPLAY_TEMPLATES_DIR, name); |
|
626 |
+ |
|
627 |
+ key_file = g_key_file_new (); |
|
628 |
+ |
|
629 |
+ error = NULL; |
|
630 |
+ res = g_key_file_load_from_file (key_file, |
|
631 |
+ filename, |
|
632 |
+ G_KEY_FILE_NONE, |
|
633 |
+ &error); |
|
634 |
+ if (! res) { |
|
635 |
+ g_warning ("Unable to load display from file %s: %s", filename, error->message); |
|
636 |
+ g_error_free (error); |
|
637 |
+ return FALSE; |
|
638 |
+ } |
|
639 |
+ g_free (filename); |
|
640 |
+ |
|
641 |
+ group = g_key_file_get_start_group (key_file); |
|
642 |
+ |
|
643 |
+ if (group == NULL || strcmp (group, "Display") != 0) { |
|
644 |
+ g_warning ("Not a display type file: %s", filename); |
|
645 |
+ g_free (group); |
|
646 |
+ g_key_file_free (key_file); |
|
647 |
+ return FALSE; |
|
648 |
+ } |
|
649 |
+ |
|
650 |
+ hidden = g_key_file_get_boolean (key_file, group, "Hidden", NULL); |
|
651 |
+ |
|
652 |
+ type = g_key_file_get_string (key_file, group, "Type", NULL); |
|
653 |
+ |
|
654 |
+ if (type == NULL) { |
|
655 |
+ g_warning ("Unable to read type from display file"); |
|
656 |
+ g_free (group); |
|
657 |
+ g_key_file_free (key_file); |
|
658 |
+ return FALSE; |
|
659 |
+ } |
|
660 |
+ |
|
661 |
+ display->priv->type = type; |
|
662 |
+ |
|
663 |
+ parameters = g_hash_table_new_full (g_str_hash, g_str_equal, |
|
664 |
+ (GDestroyNotify) g_free, |
|
665 |
+ (GDestroyNotify) g_free); |
|
666 |
+ |
|
667 |
+ type_keys = g_key_file_get_keys (key_file, type, NULL, NULL); |
|
668 |
+ |
|
669 |
+ if (type_keys != NULL) { |
|
670 |
+ int i; |
|
671 |
+ for (i = 0; type_keys[i] != NULL; i++) { |
|
672 |
+ char *string; |
|
673 |
+ |
|
674 |
+ string = g_key_file_get_string (key_file, type, type_keys[i], NULL); |
|
675 |
+ g_hash_table_insert (parameters, g_strdup (type_keys[i]), string); |
|
676 |
+ } |
|
677 |
+ g_strfreev (type_keys); |
|
678 |
+ } |
|
679 |
+ |
|
680 |
+ _ck_display_template_set_parameters (display, parameters); |
|
681 |
+ g_hash_table_unref (parameters); |
|
682 |
+ |
|
683 |
+ g_free (group); |
|
684 |
+ g_key_file_free (key_file); |
|
685 |
+ return TRUE; |
|
686 |
+} |
|
687 |
+ |
|
688 |
+CkDisplayTemplate * |
|
689 |
+ck_display_template_get_from_name (const char *name) |
|
690 |
+{ |
|
691 |
+ CkDisplayTemplate *display_template; |
|
692 |
+ |
|
693 |
+ if (ck_display_templates == NULL) { |
|
694 |
+ ck_display_templates = g_hash_table_new_full (g_str_hash, g_str_equal, |
|
695 |
+ (GDestroyNotify) g_free, |
|
696 |
+ (GDestroyNotify) g_object_unref); |
|
697 |
+ } |
|
698 |
+ |
|
699 |
+ display_template = g_hash_table_lookup (ck_display_templates, name); |
|
700 |
+ |
|
701 |
+ if (display_template == NULL) { |
|
702 |
+ GObject *object; |
|
703 |
+ |
|
704 |
+ object = g_object_new (CK_TYPE_DISPLAY_TEMPLATE, |
|
705 |
+ "name", name, |
|
706 |
+ NULL); |
|
707 |
+ |
|
708 |
+ if (!ck_display_template_load (CK_DISPLAY_TEMPLATE (object))) { |
|
709 |
+ g_object_unref (object); |
|
710 |
+ return NULL; |
|
711 |
+ } |
|
712 |
+ |
|
713 |
+ g_hash_table_insert (ck_display_templates, g_strdup (name), object); |
|
714 |
+ display_template = CK_DISPLAY_TEMPLATE (object); |
|
715 |
+ } |
|
716 |
+ |
|
717 |
+ return g_object_ref (display_template); |
|
718 |
+} |
|
719 |
+ |
|
720 |
+G_CONST_RETURN char* |
|
721 |
+ck_display_template_get_name (CkDisplayTemplate *display) |
|
722 |
+{ |
|
723 |
+ g_return_val_if_fail (CK_IS_DISPLAY_TEMPLATE (display), NULL); |
|
724 |
+ |
|
725 |
+ return display->priv->name; |
|
726 |
+} |
|
727 |
+ |
|
728 |
+G_CONST_RETURN char * |
|
729 |
+ck_display_template_get_type_string (CkDisplayTemplate *display) |
|
730 |
+{ |
|
731 |
+ return display->priv->type; |
|
732 |
+} |
|
733 |
+ |
|
734 |
+GHashTable * |
|
735 |
+ck_display_template_get_parameters (CkDisplayTemplate *display) |
|
736 |
+{ |
|
737 |
+ g_return_val_if_fail (CK_IS_DISPLAY_TEMPLATE (display), NULL); |
|
738 |
+ |
|
739 |
+ return g_hash_table_ref (display->priv->parameters); |
|
740 |
+} |
|
741 |
+ |
|
742 |
diff --git a/src/ck-display-template.h b/src/ck-display-template.h |
|
743 |
new file mode 100644 |
|
744 |
index 0000000..fa74e67 |
|
745 |
--- /dev/null |
|
746 |
+++ b/src/ck-display-template.h |
|
747 |
@@ -0,0 +1,57 @@ |
|
16129 | 748 |
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- |
749 |
+ * |
|
750 |
+ * Authors: [email protected] |
|
751 |
+ * Copyright (C) 2009 Sun Microsystems, Inc. |
|
752 |
+ * |
|
753 |
+ * This program is free software; you can redistribute it and/or modify |
|
754 |
+ * it under the terms of the GNU General Public License as published by |
|
755 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
756 |
+ * (at your option) any later version. |
|
757 |
+ * |
|
758 |
+ * This program is distributed in the hope that it will be useful, |
|
759 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
760 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
761 |
+ * GNU General Public License for more details. |
|
762 |
+ * |
|
763 |
+ * You should have received a copy of the GNU General Public License |
|
764 |
+ * along with this program; if not, write to the Free Software |
|
765 |
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
766 |
+ * |
|
767 |
+ */ |
|
768 |
+ |
|
16232 | 769 |
+#ifndef __CK_DISPLAY_TEMPLATE_H |
770 |
+#define __CK_DISPLAY_TEMPLATE_H |
|
16129 | 771 |
+ |
772 |
+#include <glib-object.h> |
|
773 |
+ |
|
774 |
+G_BEGIN_DECLS |
|
775 |
+ |
|
16232 | 776 |
+#define CK_TYPE_DISPLAY_TEMPLATE (ck_display_template_get_type ()) |
777 |
+#define CK_DISPLAY_TEMPLATE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CK_TYPE_DISPLAY_TEMPLATE, CkDisplayTemplate)) |
|
778 |
+#define CK_DISPLAY_TEMPLATE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CK_TYPE_DISPLAY_TEMPLATE, CkDisplayTemplateClass)) |
|
779 |
+#define CK_IS_DISPLAY_TEMPLATE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CK_TYPE_DISPLAY_TEMPLATE)) |
|
780 |
+#define CK_IS_DISPLAY_TEMPLATE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CK_TYPE_DISPLAY_TEMPLATE)) |
|
781 |
+#define CK_DISPLAY_TEMPLATE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CK_TYPE_DISPLAY_TEMPLATE, CkDisplayTemplateClass)) |
|
782 |
+ |
|
783 |
+typedef struct CkDisplayTemplatePrivate CkDisplayTemplatePrivate; |
|
16129 | 784 |
+ |
785 |
+typedef struct |
|
786 |
+{ |
|
787 |
+ GObject parent; |
|
16232 | 788 |
+ CkDisplayTemplatePrivate *priv; |
789 |
+} CkDisplayTemplate; |
|
16129 | 790 |
+ |
791 |
+typedef struct |
|
792 |
+{ |
|
793 |
+ GObjectClass parent_class; |
|
16232 | 794 |
+} CkDisplayTemplateClass; |
795 |
+ |
|
796 |
+GType ck_display_template_get_type (void); |
|
797 |
+CkDisplayTemplate * ck_display_template_get_from_name (const char *name); |
|
798 |
+G_CONST_RETURN char * ck_display_template_get_name (CkDisplayTemplate *display); |
|
799 |
+G_CONST_RETURN char * ck_display_template_get_type_string (CkDisplayTemplate *display); |
|
800 |
+GHashTable * ck_display_template_get_parameters (CkDisplayTemplate *display); |
|
16129 | 801 |
+ |
802 |
+G_END_DECLS |
|
803 |
+ |
|
16232 | 804 |
+#endif /* __CK_DISPLAY_TEMPLATE_H */ |
16129 | 805 |
diff --git a/src/ck-log-event.c b/src/ck-log-event.c |
17862 | 806 |
index 66f439c..d13a0f8 100644 |
16129 | 807 |
--- a/src/ck-log-event.c |
808 |
+++ b/src/ck-log-event.c |
|
16647 | 809 |
@@ -79,6 +79,8 @@ event_seat_session_added_free (CkLogSeatSessionAddedEvent *event) |
16540 | 810 |
event->session_id = NULL; |
811 |
g_free (event->session_type); |
|
812 |
event->session_type = NULL; |
|
813 |
+ g_free (event->display_type); |
|
814 |
+ event->display_type = NULL; |
|
815 |
g_free (event->session_x11_display); |
|
816 |
event->session_x11_display = NULL; |
|
817 |
g_free (event->session_x11_display_device); |
|
16647 | 818 |
@@ -103,6 +105,8 @@ event_seat_session_removed_free (CkLogSeatSessionRemovedEvent *event) |
16540 | 819 |
event->session_id = NULL; |
820 |
g_free (event->session_type); |
|
821 |
event->session_type = NULL; |
|
822 |
+ g_free (event->display_type); |
|
823 |
+ event->display_type = NULL; |
|
824 |
g_free (event->session_x11_display); |
|
825 |
event->session_x11_display = NULL; |
|
826 |
g_free (event->session_x11_display_device); |
|
16911 | 827 |
@@ -213,6 +217,7 @@ event_seat_session_added_copy (CkLogSeatSessionAddedEvent *event, |
16540 | 828 |
event_copy->seat_id = g_strdup (event->seat_id); |
829 |
event_copy->session_id = g_strdup (event->session_id); |
|
830 |
event_copy->session_type = g_strdup (event->session_type); |
|
831 |
+ event_copy->display_type = g_strdup (event->display_type); |
|
832 |
event_copy->session_x11_display = g_strdup (event->session_x11_display); |
|
833 |
event_copy->session_x11_display_device = g_strdup (event->session_x11_display_device); |
|
16129 | 834 |
event_copy->session_display_device = g_strdup (event->session_display_device); |
16911 | 835 |
@@ -232,6 +237,7 @@ event_seat_session_removed_copy (CkLogSeatSessionRemovedEvent *event, |
836 |
event_copy->seat_id = g_strdup (event->seat_id); |
|
837 |
event_copy->session_id = g_strdup (event->session_id); |
|
838 |
event_copy->session_type = g_strdup (event->session_type); |
|
839 |
+ event_copy->display_type = g_strdup (event->display_type); |
|
840 |
event_copy->session_x11_display = g_strdup (event->session_x11_display); |
|
841 |
event_copy->session_x11_display_device = g_strdup (event->session_x11_display_device); |
|
842 |
event_copy->session_display_device = g_strdup (event->session_display_device); |
|
843 |
@@ -415,10 +421,11 @@ add_log_for_seat_session_added (GString *str, |
|
16129 | 844 |
|
845 |
e = (CkLogSeatSessionAddedEvent *)event; |
|
846 |
g_string_append_printf (str, |
|
847 |
- "seat-id='%s' session-id='%s' session-type='%s' session-x11-display='%s' session-x11-display-device='%s' session-display-device='%s' session-remote-host-name='%s' session-is-local=%s session-unix-user=%u session-creation-time='%s'", |
|
16911 | 848 |
+ "seat-id='%s' session-id='%s' session-type='%s' display-type='%s' session-x11-display='%s' session-x11-display-device='%s' session-display-device='%s' session-remote-host-name='%s' session-is-local=%s session-unix-user=%u session-creation-time='%s'", |
16129 | 849 |
e->seat_id ? e->seat_id : "", |
850 |
e->session_id ? e->session_id : "", |
|
851 |
e->session_type ? e->session_type : "", |
|
16540 | 852 |
+ e->display_type ? e->display_type : "", |
853 |
e->session_x11_display ? e->session_x11_display : "", |
|
854 |
e->session_x11_display_device ? e->session_x11_display_device : "", |
|
16129 | 855 |
e->session_display_device ? e->session_display_device : "", |
16911 | 856 |
@@ -436,10 +443,11 @@ add_log_for_seat_session_removed (GString *str, |
857 |
||
858 |
e = (CkLogSeatSessionRemovedEvent *)event; |
|
859 |
g_string_append_printf (str, |
|
860 |
- "seat-id='%s' session-id='%s' session-type='%s' session-x11-display='%s' session-x11-display-device='%s' session-display-device='%s' session-remote-host-name='%s' session-is-local=%s session-unix-user=%u session-creation-time='%s'", |
|
861 |
+ "seat-id='%s' session-id='%s' session-type='%s' display-type='%s' session-x11-display='%s' session-x11-display-device='%s' session-display-device='%s' session-remote-host-name='%s' session-is-local=%s session-unix-user=%u session-creation-time='%s'", |
|
862 |
e->seat_id ? e->seat_id : "", |
|
863 |
e->session_id ? e->session_id : "", |
|
864 |
e->session_type ? e->session_type : "", |
|
865 |
+ e->display_type ? e->display_type : "", |
|
866 |
e->session_x11_display ? e->session_x11_display : "", |
|
867 |
e->session_x11_display_device ? e->session_x11_display_device : "", |
|
868 |
e->session_display_device ? e->session_display_device : "", |
|
17862 | 869 |
@@ -721,7 +729,7 @@ parse_log_for_seat_added (const GString *str, |
870 |
error = NULL; |
|
871 |
re = g_regex_new ("seat-id='(?P<seatid>[a-zA-Z0-9/]+)' seat-kind=(?P<sessionid>[0-9]*)", 0, 0, &error); |
|
872 |
if (re == NULL) { |
|
873 |
- g_warning (error->message); |
|
874 |
+ g_warning ("%s", error->message); |
|
875 |
goto out; |
|
876 |
} |
|
877 |
||
878 |
@@ -781,7 +789,7 @@ parse_log_for_seat_removed (const GString *str, |
|
879 |
error = NULL; |
|
880 |
re = g_regex_new ("seat-id='(?P<seatid>[a-zA-Z0-9/]+)' seat-kind=(?P<sessionid>[0-9]*)", 0, 0, &error); |
|
881 |
if (re == NULL) { |
|
882 |
- g_warning (error->message); |
|
883 |
+ g_warning ("%s", error->message); |
|
884 |
goto out; |
|
885 |
} |
|
886 |
||
887 |
@@ -887,7 +895,7 @@ parse_log_for_system_start (const GString *str, |
|
888 |
error = NULL; |
|
889 |
re = g_regex_new ("(kernel-release='(?P<release>[^']+)')?[ ]?(boot-arguments='(?P<arguments>.*)')?", 0, 0, &error); |
|
890 |
if (re == NULL) { |
|
891 |
- g_warning (error->message); |
|
892 |
+ g_warning ("%s", error->message); |
|
893 |
goto out; |
|
894 |
} |
|
895 |
||
896 |
@@ -939,9 +947,9 @@ parse_log_for_seat_session_added (const GString *str, |
|
897 |
} |
|
898 |
||
899 |
error = NULL; |
|
900 |
- re = g_regex_new ("seat-id='(?P<seatid>[a-zA-Z0-9/]+)' session-id='(?P<sessionid>[a-zA-Z0-9/]+)' session-type='(?P<sessiontype>[a-zA-Z0-9 ]*)' session-x11-display='(?P<sessionx11display>[0-9a-zA-Z.:]*)' session-x11-display-device='(?P<sessionx11displaydevice>[^']*)' session-display-device='(?P<sessiondisplaydevice>[^']*)' session-remote-host-name='(?P<sessionremovehostname>[^']*)' session-is-local=(?P<sessionislocal>[a-zA-Z]*) session-unix-user=(?P<sessionunixuser>[0-9]*) session-creation-time='(?P<sessioncreationtime>[^']*)'", 0, 0, &error); |
|
901 |
+ re = g_regex_new ("seat-id='(?P<seatid>[a-zA-Z0-9/]+)' session-id='(?P<sessionid>[a-zA-Z0-9/]+)' session-type='(?P<sessiontype>[a-zA-Z0-9 ]*)' display-type='(?P<displaytype>[a-zA-Z0-9 ]*)' session-x11-display='(?P<sessionx11display>[0-9a-zA-Z.:]*)' session-x11-display-device='(?P<sessionx11displaydevice>[^']*)' session-display-device='(?P<sessiondisplaydevice>[^']*)' session-remote-host-name='(?P<sessionremovehostname>[^']*)' session-is-local=(?P<sessionislocal>[a-zA-Z]*) session-unix-user=(?P<sessionunixuser>[0-9]*) session-creation-time='(?P<sessioncreationtime>[^']*)'", 0, 0, &error); |
|
902 |
if (re == NULL) { |
|
903 |
- g_warning (error->message); |
|
904 |
+ g_warning ("%s", error->message); |
|
905 |
goto out; |
|
906 |
} |
|
907 |
||
908 |
@@ -957,6 +965,7 @@ parse_log_for_seat_session_added (const GString *str, |
|
909 |
e->seat_id = g_match_info_fetch_named (match_info, "seatid"); |
|
910 |
e->session_id = g_match_info_fetch_named (match_info, "sessionid"); |
|
911 |
e->session_type = g_match_info_fetch_named (match_info, "sessiontype"); |
|
912 |
+ e->display_type = g_match_info_fetch_named (match_info, "displaytype"); |
|
913 |
e->session_x11_display = g_match_info_fetch_named (match_info, "sessionx11display"); |
|
914 |
e->session_x11_display_device = g_match_info_fetch_named (match_info, "sessionx11displaydevice"); |
|
915 |
e->session_display_device = g_match_info_fetch_named (match_info, "sessiondisplaydevice"); |
|
916 |
@@ -1014,9 +1023,9 @@ parse_log_for_seat_session_removed (const GString *str, |
|
917 |
} |
|
918 |
||
919 |
error = NULL; |
|
920 |
- re = g_regex_new ("seat-id='(?P<seatid>[a-zA-Z0-9/]+)' session-id='(?P<sessionid>[a-zA-Z0-9/]+)' session-type='(?P<sessiontype>[a-zA-Z0-9 ]*)' session-x11-display='(?P<sessionx11display>[0-9a-zA-Z.:]*)' session-x11-display-device='(?P<sessionx11displaydevice>[^']*)' session-display-device='(?P<sessiondisplaydevice>[^']*)' session-remote-host-name='(?P<sessionremovehostname>[^']*)' session-is-local=(?P<sessionislocal>[a-zA-Z]*) session-unix-user=(?P<sessionunixuser>[0-9]*) session-creation-time='(?P<sessioncreationtime>[^']*)'", 0, 0, &error); |
|
921 |
+ re = g_regex_new ("seat-id='(?P<seatid>[a-zA-Z0-9/]+)' session-id='(?P<sessionid>[a-zA-Z0-9/]+)' session-type='(?P<sessiontype>[a-zA-Z0-9 ]*)' display-type='(?P<displaytype>[a-zA-Z0-9 ]*)' session-x11-display='(?P<sessionx11display>[0-9a-zA-Z.:]*)' session-x11-display-device='(?P<sessionx11displaydevice>[^']*)' session-display-device='(?P<sessiondisplaydevice>[^']*)' session-remote-host-name='(?P<sessionremovehostname>[^']*)' session-is-local=(?P<sessionislocal>[a-zA-Z]*) session-unix-user=(?P<sessionunixuser>[0-9]*) session-creation-time='(?P<sessioncreationtime>[^']*)'", 0, 0, &error); |
|
922 |
if (re == NULL) { |
|
923 |
- g_warning (error->message); |
|
924 |
+ g_warning ("%s", error->message); |
|
925 |
goto out; |
|
926 |
} |
|
927 |
||
16911 | 928 |
@@ -1032,6 +1041,7 @@ parse_log_for_seat_session_removed (const GString *str, |
16540 | 929 |
e->seat_id = g_match_info_fetch_named (match_info, "seatid"); |
930 |
e->session_id = g_match_info_fetch_named (match_info, "sessionid"); |
|
931 |
e->session_type = g_match_info_fetch_named (match_info, "sessiontype"); |
|
932 |
+ e->display_type = g_match_info_fetch_named (match_info, "displaytype"); |
|
933 |
e->session_x11_display = g_match_info_fetch_named (match_info, "sessionx11display"); |
|
934 |
e->session_x11_display_device = g_match_info_fetch_named (match_info, "sessionx11displaydevice"); |
|
935 |
e->session_display_device = g_match_info_fetch_named (match_info, "sessiondisplaydevice"); |
|
17862 | 936 |
@@ -1090,7 +1100,7 @@ parse_log_for_seat_active_session_changed (const GString *str, |
937 |
error = NULL; |
|
938 |
re = g_regex_new ("seat-id='(?P<seatid>[a-zA-Z0-9/]+)' session-id='(?P<sessionid>[a-zA-Z0-9/]*)'", 0, 0, &error); |
|
939 |
if (re == NULL) { |
|
940 |
- g_warning (error->message); |
|
941 |
+ g_warning ("%s", error->message); |
|
942 |
goto out; |
|
943 |
} |
|
944 |
||
945 |
@@ -1142,7 +1152,7 @@ parse_log_for_seat_device_added (const GString *str, |
|
946 |
error = NULL; |
|
947 |
re = g_regex_new ("seat-id='(?P<seatid>[a-zA-Z0-9/]+)' device-id='(?P<deviceid>[^']+)' device-type='(?P<devicetype>[^']+)'", 0, 0, &error); |
|
948 |
if (re == NULL) { |
|
949 |
- g_warning (error->message); |
|
950 |
+ g_warning ("%s", error->message); |
|
951 |
goto out; |
|
952 |
} |
|
953 |
||
954 |
@@ -1195,7 +1205,7 @@ parse_log_for_seat_device_removed (const GString *str, |
|
955 |
error = NULL; |
|
956 |
re = g_regex_new ("seat-id='(?P<seatid>[a-zA-Z0-9/]+)' device-id='(?P<deviceid>[^']+)' device-type='(?P<devicetype>[^']+)'", 0, 0, &error); |
|
957 |
if (re == NULL) { |
|
958 |
- g_warning (error->message); |
|
959 |
+ g_warning ("%s", error->message); |
|
960 |
goto out; |
|
961 |
} |
|
962 |
||
16129 | 963 |
diff --git a/src/ck-log-event.h b/src/ck-log-event.h |
16647 | 964 |
index 65571f0..2d4ed4e 100644 |
16129 | 965 |
--- a/src/ck-log-event.h |
966 |
+++ b/src/ck-log-event.h |
|
16647 | 967 |
@@ -68,6 +68,7 @@ typedef struct |
16232 | 968 |
{ |
969 |
char *seat_id; |
|
970 |
int seat_kind; |
|
971 |
+ char *seat_type; |
|
972 |
} CkLogSeatAddedEvent; |
|
973 |
||
974 |
typedef struct |
|
16647 | 975 |
@@ -81,11 +82,13 @@ typedef struct |
16540 | 976 |
char *seat_id; |
977 |
char *session_id; |
|
978 |
char *session_type; |
|
979 |
+ char *display_type; |
|
980 |
char *session_x11_display; |
|
981 |
char *session_x11_display_device; |
|
16129 | 982 |
char *session_display_device; |
983 |
char *session_remote_host_name; |
|
984 |
gboolean session_is_local; |
|
985 |
+ gboolean session_is_dynamic; |
|
986 |
guint session_unix_user; |
|
987 |
char *session_creation_time; |
|
988 |
} CkLogSeatSessionAddedEvent; |
|
16647 | 989 |
@@ -95,11 +98,13 @@ typedef struct |
16540 | 990 |
char *seat_id; |
991 |
char *session_id; |
|
992 |
char *session_type; |
|
993 |
+ char *display_type; |
|
994 |
char *session_x11_display; |
|
995 |
char *session_x11_display_device; |
|
16129 | 996 |
char *session_display_device; |
997 |
char *session_remote_host_name; |
|
998 |
gboolean session_is_local; |
|
999 |
+ gboolean session_is_dynamic; |
|
1000 |
guint session_unix_user; |
|
1001 |
char *session_creation_time; |
|
1002 |
} CkLogSeatSessionRemovedEvent; |
|
20076 | 1003 |
--- ConsoleKit-0.4.1/src/ck-manager.c.1 2010-09-06 17:41:32.942210394 +0800 |
1004 |
+++ ConsoleKit-0.4.1/src/ck-manager.c 2010-09-06 17:41:56.671280731 +0800 |
|
16647 | 1005 |
@@ -46,9 +46,14 @@ |
1006 |
#include <secdb.h> |
|
1007 |
#endif |
|
1008 |
||
1009 |
+#ifndef HAVE_STRVERSCMP |
|
1010 |
+#include "strverscmp.h" |
|
1011 |
+#endif |
|
1012 |
+ |
|
16129 | 1013 |
#include "ck-manager.h" |
1014 |
#include "ck-manager-glue.h" |
|
1015 |
#include "ck-seat.h" |
|
16232 | 1016 |
+#include "ck-display-template.h" |
16129 | 1017 |
#include "ck-session-leader.h" |
1018 |
#include "ck-session.h" |
|
1019 |
#include "ck-marshal.h" |
|
16647 | 1020 |
@@ -58,12 +63,19 @@ |
16232 | 1021 |
|
1022 |
#define CK_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CK_TYPE_MANAGER, CkManagerPrivate)) |
|
1023 |
||
1024 |
+#define CK_TYPE_PARAMETER_STRUCT (dbus_g_type_get_struct ("GValueArray", \ |
|
1025 |
+ G_TYPE_STRING, \ |
|
1026 |
+ G_TYPE_VALUE, \ |
|
1027 |
+ G_TYPE_INVALID)) |
|
1028 |
+ |
|
1029 |
#define CK_SEAT_DIR SYSCONFDIR "/ConsoleKit/seats.d" |
|
1030 |
#define LOG_FILE LOCALSTATEDIR "/log/ConsoleKit/history" |
|
1031 |
#define CK_DBUS_PATH "/org/freedesktop/ConsoleKit" |
|
16647 | 1032 |
#define CK_MANAGER_DBUS_PATH CK_DBUS_PATH "/Manager" |
1033 |
#define CK_MANAGER_DBUS_NAME "org.freedesktop.ConsoleKit.Manager" |
|
1034 |
||
1035 |
+#define IS_STR_SET(x) (x != NULL && x[0] != '\0') |
|
1036 |
+ |
|
1037 |
struct CkManagerPrivate |
|
1038 |
{ |
|
1039 |
#ifdef HAVE_POLKIT |
|
21938 | 1040 |
@@ -392,6 +404,7 @@ log_seat_added_event (CkManager *manage |
16232 | 1041 |
GError *error; |
1042 |
char *sid; |
|
1043 |
CkSeatKind seat_kind; |
|
1044 |
+ char *seat_type; |
|
1045 |
||
1046 |
memset (&event, 0, sizeof (CkLogEvent)); |
|
1047 |
||
21938 | 1048 |
@@ -401,9 +414,11 @@ log_seat_added_event (CkManager *manage |
16232 | 1049 |
sid = NULL; |
1050 |
ck_seat_get_id (seat, &sid, NULL); |
|
1051 |
ck_seat_get_kind (seat, &seat_kind, NULL); |
|
1052 |
+ ck_seat_get_type_string (seat, &seat_type, NULL); |
|
1053 |
||
1054 |
event.event.seat_added.seat_id = (char *)get_object_id_basename (sid); |
|
1055 |
event.event.seat_added.seat_kind = (int)seat_kind; |
|
1056 |
+ event.event.seat_added.seat_type = (char *)seat_type; |
|
1057 |
||
1058 |
error = NULL; |
|
1059 |
res = ck_event_logger_queue_event (manager->priv->logger, &event, &error); |
|
21938 | 1060 |
@@ -413,6 +428,7 @@ log_seat_added_event (CkManager *manage |
16232 | 1061 |
} |
1062 |
||
1063 |
g_free (sid); |
|
1064 |
+ g_free (seat_type); |
|
1065 |
} |
|
1066 |
||
1067 |
static void |
|
21938 | 1068 |
@@ -517,6 +533,7 @@ log_seat_session_added_event (CkManager |
16540 | 1069 |
if (session != NULL) { |
1070 |
g_object_get (session, |
|
1071 |
"session-type", &event.event.seat_session_added.session_type, |
|
1072 |
+ "display-type", &event.event.seat_session_added.display_type, |
|
1073 |
"x11-display", &event.event.seat_session_added.session_x11_display, |
|
1074 |
"x11-display-device", &event.event.seat_session_added.session_x11_display_device, |
|
16129 | 1075 |
"display-device", &event.event.seat_session_added.session_display_device, |
21938 | 1076 |
@@ -572,6 +589,7 @@ log_seat_session_removed_event (CkManage |
16540 | 1077 |
if (session != NULL) { |
1078 |
g_object_get (session, |
|
1079 |
"session-type", &event.event.seat_session_removed.session_type, |
|
1080 |
+ "display-type", &event.event.seat_session_removed.display_type, |
|
1081 |
"x11-display", &event.event.seat_session_removed.session_x11_display, |
|
1082 |
"x11-display-device", &event.event.seat_session_removed.session_x11_display_device, |
|
16129 | 1083 |
"display-device", &event.event.seat_session_removed.session_display_device, |
21938 | 1084 |
@@ -845,6 +863,8 @@ ready_cb (PolkitAuthority *authority, |
1085 |
PolkitAuthorizationResult *ret; |
|
1086 |
GError *error; |
|
1087 |
||
1088 |
+ g_debug ("CkManager: Ready."); |
|
1089 |
+ |
|
1090 |
error = NULL; |
|
1091 |
ret = polkit_authority_check_authorization_finish (authority, res, &error); |
|
1092 |
if (error != NULL) { |
|
1093 |
@@ -975,6 +995,7 @@ session_is_real_user (CkSession *session |
|
1094 |
||
1095 |
/* filter out GDM user */ |
|
1096 |
if (username != NULL && strcmp (username, "gdm") == 0) { |
|
1097 |
+ g_debug ("CkManager: Session is not real user"); |
|
1098 |
ret = FALSE; |
|
1099 |
goto out; |
|
1100 |
} |
|
1101 |
@@ -983,6 +1004,7 @@ session_is_real_user (CkSession *session |
|
1102 |
*userp = g_strdup (username); |
|
1103 |
} |
|
1104 |
||
1105 |
+ g_debug ("CkManager: Session is real user"); |
|
1106 |
ret = TRUE; |
|
1107 |
||
1108 |
out: |
|
1109 |
@@ -1230,6 +1252,7 @@ on_seat_active_session_changed_full (CkS |
|
1110 |
{ |
|
1111 |
char *ssid = NULL; |
|
1112 |
||
1113 |
+ g_debug ("CkManager: Active session changed."); |
|
1114 |
if (session != NULL) { |
|
1115 |
ck_session_get_id (session, &ssid, NULL); |
|
1116 |
} |
|
1117 |
@@ -1247,6 +1270,7 @@ on_seat_session_added_full (CkSeat * |
|
1118 |
{ |
|
1119 |
char *ssid = NULL; |
|
1120 |
||
1121 |
+ g_debug ("CkManager: Session added."); |
|
1122 |
ck_session_get_id (session, &ssid, NULL); |
|
1123 |
||
1124 |
ck_manager_dump (manager); |
|
1125 |
@@ -1262,6 +1286,7 @@ on_seat_session_removed_full (CkSeat |
|
1126 |
{ |
|
1127 |
char *ssid = NULL; |
|
1128 |
||
1129 |
+ g_debug ("CkManager: Seat Session removed."); |
|
1130 |
ck_session_get_id (session, &ssid, NULL); |
|
1131 |
||
1132 |
ck_manager_dump (manager); |
|
1133 |
@@ -1275,6 +1300,7 @@ on_seat_device_added (CkSeat *seat, |
|
1134 |
GValueArray *device, |
|
1135 |
CkManager *manager) |
|
1136 |
{ |
|
1137 |
+ g_debug ("CkManager: Seat device added."); |
|
1138 |
ck_manager_dump (manager); |
|
1139 |
log_seat_device_added_event (manager, seat, device); |
|
1140 |
} |
|
1141 |
@@ -1284,6 +1310,7 @@ on_seat_device_removed (CkSeat *sea |
|
1142 |
GValueArray *device, |
|
1143 |
CkManager *manager) |
|
1144 |
{ |
|
1145 |
+ g_debug ("CkManager: Seat device removed."); |
|
1146 |
ck_manager_dump (manager); |
|
1147 |
log_seat_device_removed_event (manager, seat, device); |
|
1148 |
} |
|
1149 |
@@ -1311,15 +1338,23 @@ disconnect_seat_signals (CkManager *mana |
|
16232 | 1150 |
} |
1151 |
||
1152 |
static CkSeat * |
|
1153 |
-add_new_seat (CkManager *manager, |
|
1154 |
- CkSeatKind kind) |
|
16647 | 1155 |
+add_new_seat (CkManager *manager, |
1156 |
+ const char *give_sid, |
|
1157 |
+ CkSeatKind kind, |
|
1158 |
+ const char *type) |
|
16232 | 1159 |
{ |
1160 |
char *sid; |
|
1161 |
CkSeat *seat; |
|
1162 |
||
16647 | 1163 |
- sid = generate_seat_id (manager); |
1164 |
+ if (IS_STR_SET (give_sid)) { |
|
1165 |
+ sid = g_strdup (give_sid); |
|
1166 |
+ } else { |
|
1167 |
+ sid = generate_seat_id (manager); |
|
1168 |
+ } |
|
21938 | 1169 |
+ |
1170 |
+ g_debug ("CkManager: Add new seat '%s'.", sid); |
|
16232 | 1171 |
|
1172 |
- seat = ck_seat_new (sid, kind); |
|
1173 |
+ seat = ck_seat_new (sid, kind, type); |
|
1174 |
||
16647 | 1175 |
/* First we connect our own signals to the seat, followed by |
1176 |
* the D-Bus signal hookup to make sure we can first dump the |
|
21938 | 1177 |
@@ -1344,7 +1379,7 @@ add_new_seat (CkManager *manager, |
16647 | 1178 |
ck_seat_run_programs (seat, NULL, NULL, "seat_added"); |
16232 | 1179 |
|
21939 | 1180 |
g_debug ("Emitting seat-added: %s", sid); |
16232 | 1181 |
- g_signal_emit (manager, signals [SEAT_ADDED], 0, sid); |
1182 |
+ g_signal_emit (manager, signals [SEAT_ADDED], 0, sid, type); |
|
1183 |
||
1184 |
log_seat_added_event (manager, seat); |
|
16647 | 1185 |
|
21938 | 1186 |
@@ -1363,6 +1398,8 @@ remove_seat (CkManager *manager, |
1187 |
sid = NULL; |
|
1188 |
ck_seat_get_id (seat, &sid, NULL); |
|
1189 |
||
1190 |
+ g_debug ("CkManager: Remove seat '%s'", sid); |
|
1191 |
+ |
|
1192 |
/* Need to get the original key/value */ |
|
1193 |
res = g_hash_table_lookup_extended (manager->priv->seats, |
|
1194 |
sid, |
|
1195 |
@@ -1402,64 +1439,22 @@ remove_seat (CkManager *manager, |
|
16647 | 1196 |
g_free (sid); |
1197 |
} |
|
1198 |
||
1199 |
-#define IS_STR_SET(x) (x != NULL && x[0] != '\0') |
|
16232 | 1200 |
- |
16647 | 1201 |
static CkSeat * |
1202 |
find_seat_for_session (CkManager *manager, |
|
16129 | 1203 |
CkSession *session) |
1204 |
{ |
|
1205 |
CkSeat *seat; |
|
1206 |
- gboolean is_static_x11; |
|
1207 |
- gboolean is_static_text; |
|
1208 |
- char *display_device; |
|
1209 |
- char *x11_display_device; |
|
1210 |
- char *x11_display; |
|
1211 |
- char *remote_host_name; |
|
1212 |
- gboolean is_local; |
|
1213 |
- |
|
1214 |
- is_static_text = FALSE; |
|
1215 |
- is_static_x11 = FALSE; |
|
1216 |
- |
|
1217 |
- seat = NULL; |
|
1218 |
- display_device = NULL; |
|
1219 |
- x11_display_device = NULL; |
|
1220 |
- x11_display = NULL; |
|
1221 |
- remote_host_name = NULL; |
|
1222 |
- is_local = FALSE; |
|
1223 |
- |
|
1224 |
- /* FIXME: use matching to group entries? */ |
|
1225 |
- |
|
1226 |
- ck_session_get_display_device (session, &display_device, NULL); |
|
1227 |
- ck_session_get_x11_display_device (session, &x11_display_device, NULL); |
|
1228 |
- ck_session_get_x11_display (session, &x11_display, NULL); |
|
1229 |
- ck_session_get_remote_host_name (session, &remote_host_name, NULL); |
|
1230 |
- ck_session_is_local (session, &is_local, NULL); |
|
1231 |
- |
|
1232 |
- if (IS_STR_SET (x11_display) |
|
1233 |
- && IS_STR_SET (x11_display_device) |
|
1234 |
- && ! IS_STR_SET (remote_host_name) |
|
1235 |
- && is_local == TRUE) { |
|
1236 |
- is_static_x11 = TRUE; |
|
1237 |
- } else if (! IS_STR_SET (x11_display) |
|
1238 |
- && ! IS_STR_SET (x11_display_device) |
|
1239 |
- && IS_STR_SET (display_device) |
|
1240 |
- && ! IS_STR_SET (remote_host_name) |
|
1241 |
- && is_local == TRUE) { |
|
1242 |
- is_static_text = TRUE; |
|
1243 |
- } |
|
1244 |
+ char *sid = NULL; |
|
1245 |
+ |
|
1246 |
+ ck_session_get_seat_id (session, &sid, NULL); |
|
20076 | 1247 |
|
1248 |
- if (is_static_x11 || is_static_text) { |
|
1249 |
- char *sid; |
|
16129 | 1250 |
+ if (! IS_STR_SET (sid)) { |
1251 |
sid = g_strdup_printf ("%s/Seat%u", CK_DBUS_PATH, 1); |
|
1252 |
- seat = g_hash_table_lookup (manager->priv->seats, sid); |
|
1253 |
- g_free (sid); |
|
1254 |
} |
|
1255 |
||
1256 |
- g_free (display_device); |
|
1257 |
- g_free (x11_display_device); |
|
1258 |
- g_free (x11_display); |
|
1259 |
- g_free (remote_host_name); |
|
1260 |
+ seat = g_hash_table_lookup (manager->priv->seats, sid); |
|
1261 |
||
1262 |
+ g_free (sid); |
|
1263 |
return seat; |
|
1264 |
} |
|
1265 |
||
21938 | 1266 |
@@ -1594,36 +1589,52 @@ open_session_for_leader (CkManager |
17862 | 1267 |
CkSession *session; |
1268 |
CkSeat *seat; |
|
1269 |
const char *ssid; |
|
1270 |
+ char *sid; |
|
1271 |
const char *cookie; |
|
1272 |
||
21938 | 1273 |
+ g_debug ("CkManager: Open session for leader."); |
16232 | 1274 |
ssid = ck_session_leader_peek_session_id (leader); |
1275 |
cookie = ck_session_leader_peek_cookie (leader); |
|
1276 |
||
1277 |
- session = ck_session_new_with_parameters (ssid, |
|
1278 |
- cookie, |
|
1279 |
- parameters); |
|
1280 |
+ session = g_hash_table_lookup (manager->priv->sessions, ssid); |
|
1281 |
||
1282 |
if (session == NULL) { |
|
1283 |
- GError *error; |
|
21939 | 1284 |
- g_debug ("Unable to create new session"); |
16232 | 1285 |
- error = g_error_new (CK_MANAGER_ERROR, |
1286 |
- CK_MANAGER_ERROR_GENERAL, |
|
1287 |
- "Unable to create new session"); |
|
1288 |
- dbus_g_method_return_error (context, error); |
|
1289 |
- g_error_free (error); |
|
21938 | 1290 |
+ g_debug ("CkManager: Creating new session."); |
16232 | 1291 |
+ session = ck_session_new_with_parameters (ssid, |
1292 |
+ parameters); |
|
21938 | 1293 |
+ |
16232 | 1294 |
+ if (session == NULL) { |
1295 |
+ GError *error; |
|
21938 | 1296 |
+ g_debug ("CkManager: Unable to create new session"); |
16232 | 1297 |
+ error = g_error_new (CK_MANAGER_ERROR, |
1298 |
+ CK_MANAGER_ERROR_GENERAL, |
|
1299 |
+ "Unable to create new session"); |
|
1300 |
+ dbus_g_method_return_error (context, error); |
|
1301 |
+ g_error_free (error); |
|
21938 | 1302 |
|
1303 |
- return; |
|
16232 | 1304 |
+ return; |
1305 |
+ } |
|
1306 |
+ |
|
1307 |
+ g_hash_table_insert (manager->priv->sessions, |
|
1308 |
+ g_strdup (ssid), |
|
1309 |
+ g_object_ref (session)); |
|
1310 |
+ |
|
1311 |
+ } else { |
|
21938 | 1312 |
+ g_debug ("CkManager: Using found session."); |
16232 | 1313 |
+ ck_session_set_parameters (session, parameters); |
1314 |
} |
|
1315 |
||
1316 |
- g_hash_table_insert (manager->priv->sessions, |
|
1317 |
- g_strdup (ssid), |
|
1318 |
- g_object_ref (session)); |
|
1319 |
+ ck_session_set_cookie (session, cookie, NULL); |
|
1320 |
+ ck_session_set_is_open (session, TRUE, NULL); |
|
1321 |
||
1322 |
/* Add to seat */ |
|
1323 |
seat = find_seat_for_session (manager, session); |
|
1324 |
if (seat == NULL) { |
|
17862 | 1325 |
+ sid = NULL; |
1326 |
+ ck_session_get_seat_id (session, &sid, NULL); |
|
16232 | 1327 |
/* create a new seat */ |
1328 |
- seat = add_new_seat (manager, CK_SEAT_KIND_DYNAMIC); |
|
17862 | 1329 |
+ seat = add_new_seat (manager, sid, CK_SEAT_KIND_DYNAMIC, "Default"); |
1330 |
+ g_free (sid); |
|
16232 | 1331 |
} |
1332 |
||
1333 |
ck_seat_add_session (seat, session, NULL); |
|
21938 | 1334 |
@@ -1683,6 +1694,7 @@ generate_session_for_leader (CkManager |
1335 |
{ |
|
1336 |
gboolean res; |
|
1337 |
||
1338 |
+ g_debug ("CkManager: Generate session for leader."); |
|
1339 |
res = ck_session_leader_collect_parameters (leader, |
|
1340 |
context, |
|
1341 |
(CkSessionLeaderDoneFunc)collect_parameters_cb, |
|
1342 |
@@ -1697,11 +1709,57 @@ generate_session_for_leader (CkManager |
|
16232 | 1343 |
} |
16129 | 1344 |
} |
1345 |
||
16232 | 1346 |
+static char * |
1347 |
+check_parameters_for_ssid (const GPtrArray *parameters) |
|
1348 |
+{ |
|
1349 |
+ int i; |
|
1350 |
+ |
|
1351 |
+ if (parameters == NULL) { |
|
1352 |
+ return NULL; |
|
1353 |
+ } |
|
1354 |
+ |
|
1355 |
+ for (i = 0; i < parameters->len; i++) { |
|
1356 |
+ GValue val_struct = { 0, }; |
|
1357 |
+ char *prop_name; |
|
1358 |
+ gboolean res; |
|
1359 |
+ |
|
1360 |
+ g_value_init (&val_struct, CK_TYPE_PARAMETER_STRUCT); |
|
1361 |
+ g_value_set_static_boxed (&val_struct, g_ptr_array_index (parameters, i)); |
|
1362 |
+ |
|
1363 |
+ res = dbus_g_type_struct_get (&val_struct, |
|
1364 |
+ 0, &prop_name, |
|
1365 |
+ G_MAXUINT); |
|
1366 |
+ if (! res) { |
|
21938 | 1367 |
+ g_debug ("CkManager: Unable to read parameter name"); |
16232 | 1368 |
+ continue; |
1369 |
+ } |
|
1370 |
+ |
|
1371 |
+ if (prop_name != NULL && strcmp (prop_name, "session") == 0) { |
|
1372 |
+ GValue prop_val = { 0, }; |
|
1373 |
+ GValue *session_val; |
|
1374 |
+ |
|
1375 |
+ g_value_init (&prop_val, G_TYPE_VALUE); |
|
1376 |
+ res = dbus_g_type_struct_get_member (&val_struct, 1, &prop_val); |
|
1377 |
+ |
|
1378 |
+ if (! res) { |
|
21938 | 1379 |
+ g_debug ("CkManager: Unable to read parameter value"); |
16232 | 1380 |
+ continue; |
1381 |
+ } |
|
1382 |
+ |
|
1383 |
+ session_val = g_value_get_boxed (&prop_val); |
|
1384 |
+ |
|
1385 |
+ return g_value_dup_string (session_val); |
|
1386 |
+ } |
|
1387 |
+ } |
|
1388 |
+ |
|
1389 |
+ return NULL; |
|
1390 |
+} |
|
1391 |
+ |
|
1392 |
static gboolean |
|
1393 |
-create_session_for_sender (CkManager *manager, |
|
1394 |
- const char *sender, |
|
1395 |
- const GPtrArray *parameters, |
|
1396 |
- DBusGMethodInvocation *context) |
|
1397 |
+open_session_for_sender (CkManager *manager, |
|
1398 |
+ const char *sender, |
|
1399 |
+ const GPtrArray *parameters, |
|
1400 |
+ DBusGMethodInvocation *context) |
|
1401 |
{ |
|
1402 |
pid_t pid; |
|
1403 |
uid_t uid; |
|
21938 | 1404 |
@@ -1709,6 +1767,7 @@ create_session_for_sender (CkManager |
16232 | 1405 |
char *cookie; |
1406 |
char *ssid; |
|
1407 |
CkSessionLeader *leader; |
|
1408 |
+ CkSession *session; |
|
1409 |
||
1410 |
g_debug ("CkManager: create session for sender: %s", sender); |
|
1411 |
||
21938 | 1412 |
@@ -1727,9 +1786,21 @@ create_session_for_sender (CkManager |
16232 | 1413 |
} |
1414 |
||
1415 |
cookie = generate_session_cookie (manager); |
|
1416 |
- ssid = generate_session_id (manager); |
|
1417 |
||
21939 | 1418 |
- g_debug ("Creating new session ssid: %s", ssid); |
16232 | 1419 |
+ ssid = check_parameters_for_ssid (parameters); |
1420 |
+ |
|
16491 | 1421 |
+ if (IS_STR_SET (ssid)) { |
16232 | 1422 |
+ session = g_hash_table_lookup (manager->priv->sessions, ssid); |
1423 |
+ |
|
1424 |
+ /* FIXME: Need to verify that the session belongs to a seat |
|
1425 |
+ * managed by the sender |
|
1426 |
+ */ |
|
21938 | 1427 |
+ g_debug ("CkManager: Managing existing session ssid: %s", ssid); |
16232 | 1428 |
+ } else { |
1429 |
+ ssid = generate_session_id (manager); |
|
1430 |
+ session = NULL; |
|
21938 | 1431 |
+ g_debug ("CkManager: Creating new session ssid: %s", ssid); |
16232 | 1432 |
+ } |
1433 |
||
1434 |
leader = ck_session_leader_new (); |
|
1435 |
ck_session_leader_set_uid (leader, uid); |
|
21938 | 1436 |
@@ -1967,7 +2038,7 @@ ck_manager_open_session (CkManager |
16232 | 1437 |
gboolean ret; |
1438 |
||
1439 |
sender = dbus_g_method_get_sender (context); |
|
1440 |
- ret = create_session_for_sender (manager, sender, NULL, context); |
|
1441 |
+ ret = open_session_for_sender (manager, sender, NULL, context); |
|
1442 |
g_free (sender); |
|
1443 |
||
1444 |
return ret; |
|
21938 | 1445 |
@@ -1982,7 +2053,7 @@ ck_manager_open_session_with_parameters |
16232 | 1446 |
gboolean ret; |
1447 |
||
1448 |
sender = dbus_g_method_get_sender (context); |
|
1449 |
- ret = create_session_for_sender (manager, sender, parameters, context); |
|
1450 |
+ ret = open_session_for_sender (manager, sender, parameters, context); |
|
1451 |
g_free (sender); |
|
1452 |
||
1453 |
return ret; |
|
21938 | 1454 |
@@ -1999,10 +2070,12 @@ remove_session_for_cookie (CkManager *m |
16232 | 1455 |
char *sid; |
1456 |
gboolean res; |
|
1457 |
gboolean ret; |
|
1458 |
+ gboolean should_remove_session; |
|
1459 |
||
1460 |
ret = FALSE; |
|
1461 |
orig_ssid = NULL; |
|
1462 |
orig_session = NULL; |
|
1463 |
+ should_remove_session = FALSE; |
|
1464 |
||
21939 | 1465 |
g_debug ("Removing session for cookie: %s", cookie); |
21938 | 1466 |
|
1467 |
@@ -2029,6 +2102,17 @@ remove_session_for_cookie (CkManager *m |
|
16232 | 1468 |
goto out; |
1469 |
} |
|
1470 |
||
1471 |
+ ck_session_set_is_open (orig_session, FALSE, NULL); |
|
1472 |
+ ck_session_set_cookie (orig_session, NULL, NULL); |
|
1473 |
+ ck_session_set_active (orig_session, FALSE, NULL); |
|
1474 |
+ ck_session_set_unix_user (orig_session, 0, NULL); |
|
1475 |
+ ck_session_set_x11_display (orig_session, NULL, NULL); |
|
1476 |
+ ck_session_set_x11_display_device (orig_session, NULL, NULL); |
|
1477 |
+ ck_session_set_display_device (orig_session, NULL, NULL); |
|
1478 |
+ ck_session_set_login_session_id (orig_session, NULL, NULL); |
|
1479 |
+ ck_session_set_remote_host_name (orig_session, NULL, NULL); |
|
16844 | 1480 |
+ ck_session_set_under_request (orig_session, FALSE, NULL); |
16232 | 1481 |
+ |
1482 |
/* Must keep a reference to the session in the manager until |
|
1483 |
* all events for seats are cleared. So don't remove |
|
1484 |
* or steal the session from the master list until |
|
21938 | 1485 |
@@ -2036,31 +2120,33 @@ remove_session_for_cookie (CkManager *m |
16232 | 1486 |
* for seat removals doesn't work. |
1487 |
*/ |
|
1488 |
||
16844 | 1489 |
- /* remove from seat */ |
1490 |
- sid = NULL; |
|
1491 |
- ck_session_get_seat_id (orig_session, &sid, NULL); |
|
1492 |
- if (sid != NULL) { |
|
1493 |
- CkSeat *seat; |
|
1494 |
- seat = g_hash_table_lookup (manager->priv->seats, sid); |
|
1495 |
- if (seat != NULL) { |
|
1496 |
- CkSeatKind kind; |
|
1497 |
- |
|
1498 |
- ck_seat_remove_session (seat, orig_session, NULL); |
|
1499 |
- |
|
1500 |
- kind = CK_SEAT_KIND_STATIC; |
|
1501 |
- /* if dynamic seat has no sessions then remove it */ |
|
1502 |
- ck_seat_get_kind (seat, &kind, NULL); |
|
1503 |
- if (kind == CK_SEAT_KIND_DYNAMIC) { |
|
1504 |
- remove_seat (manager, seat); |
|
16475 | 1505 |
+ ck_session_get_remove_on_close (orig_session, &should_remove_session, NULL); |
1506 |
+ |
|
16844 | 1507 |
+ if (should_remove_session) { |
1508 |
+ /* remove from seat */ |
|
21938 | 1509 |
+ g_debug ("CkManager: Should remove session"); |
16844 | 1510 |
+ sid = NULL; |
1511 |
+ ck_session_get_seat_id (orig_session, &sid, NULL); |
|
1512 |
+ if (sid != NULL) { |
|
1513 |
+ CkSeat *seat; |
|
1514 |
+ seat = g_hash_table_lookup (manager->priv->seats, sid); |
|
1515 |
+ if (seat != NULL) { |
|
1516 |
+ CkSeatKind kind; |
|
1517 |
+ |
|
1518 |
+ ck_seat_remove_session (seat, orig_session, NULL); |
|
1519 |
+ |
|
1520 |
+ kind = CK_SEAT_KIND_STATIC; |
|
1521 |
+ /* if dynamic seat has no sessions then remove it */ |
|
1522 |
+ ck_seat_get_kind (seat, &kind, NULL); |
|
16232 | 1523 |
} |
1524 |
} |
|
16844 | 1525 |
- } |
1526 |
- g_free (sid); |
|
1527 |
+ g_free (sid); |
|
16232 | 1528 |
|
1529 |
- /* Remove the session from the list but don't call |
|
1530 |
- * unref until we are done with it */ |
|
1531 |
- g_hash_table_steal (manager->priv->sessions, |
|
1532 |
- ck_session_leader_peek_session_id (leader)); |
|
1533 |
+ /* Remove the session from the list but don't call |
|
1534 |
+ * unref until we are done with it */ |
|
1535 |
+ g_hash_table_steal (manager->priv->sessions, |
|
1536 |
+ ck_session_leader_peek_session_id (leader)); |
|
1537 |
+ } |
|
1538 |
||
1539 |
ck_manager_dump (manager); |
|
1540 |
||
21938 | 1541 |
@@ -2068,11 +2154,13 @@ remove_session_for_cookie (CkManager *m |
16232 | 1542 |
|
1543 |
ret = TRUE; |
|
1544 |
out: |
|
1545 |
- if (orig_session != NULL) { |
|
1546 |
- g_object_unref (orig_session); |
|
1547 |
- } |
|
1548 |
- g_free (orig_ssid); |
|
1549 |
+ if (should_remove_session) { |
|
1550 |
+ if (orig_session != NULL) { |
|
1551 |
+ g_object_unref (orig_session); |
|
1552 |
+ } |
|
1553 |
||
1554 |
+ g_free (orig_ssid); |
|
1555 |
+ } |
|
1556 |
return ret; |
|
1557 |
} |
|
1558 |
||
21938 | 1559 |
@@ -2193,6 +2281,7 @@ remove_leader_for_connection (const char |
1560 |
g_assert (leader != NULL); |
|
1561 |
g_assert (data->service_name != NULL); |
|
1562 |
||
1563 |
+ g_debug ("CkManager: Remove leader for connection"); |
|
1564 |
name = ck_session_leader_peek_service_name (leader); |
|
1565 |
if (strcmp (name, data->service_name) == 0) { |
|
1566 |
remove_session_for_cookie (data->manager, cookie, NULL); |
|
1567 |
@@ -2210,6 +2299,8 @@ remove_sessions_for_connection (CkManage |
|
1568 |
guint n_removed; |
|
1569 |
RemoveLeaderData data; |
|
1570 |
||
1571 |
+ g_debug ("CkManager: Remove sessions for connection"); |
|
1572 |
+ |
|
1573 |
data.service_name = service_name; |
|
1574 |
data.manager = manager; |
|
1575 |
||
1576 |
@@ -2245,6 +2336,8 @@ register_manager (CkManager *manager) |
|
1577 |
manager->priv->pol_ctx = polkit_authority_get (); |
|
1578 |
#endif |
|
1579 |
||
1580 |
+ g_debug ("CkManager: Registering manager"); |
|
1581 |
+ |
|
1582 |
error = NULL; |
|
1583 |
manager->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); |
|
1584 |
if (manager->priv->connection == NULL) { |
|
1585 |
@@ -2290,9 +2383,11 @@ ck_manager_class_init (CkManagerClass *k |
|
16232 | 1586 |
G_STRUCT_OFFSET (CkManagerClass, seat_added), |
1587 |
NULL, |
|
1588 |
NULL, |
|
1589 |
- g_cclosure_marshal_VOID__BOXED, |
|
1590 |
+ ck_marshal_VOID__STRING_STRING, |
|
1591 |
G_TYPE_NONE, |
|
1592 |
- 1, DBUS_TYPE_G_OBJECT_PATH); |
|
1593 |
+ 2, |
|
1594 |
+ G_TYPE_STRING, |
|
1595 |
+ G_TYPE_STRING); |
|
1596 |
signals [SEAT_REMOVED] = |
|
1597 |
g_signal_new ("seat-removed", |
|
1598 |
G_TYPE_FROM_CLASS (object_class), |
|
21938 | 1599 |
@@ -2399,6 +2494,43 @@ ck_manager_get_seats (CkManager *manage |
16232 | 1600 |
} |
1601 |
||
1602 |
static void |
|
1603 |
+listify_unmanaged_seat_ids (char *id, |
|
1604 |
+ CkSeat *seat, |
|
1605 |
+ GPtrArray **array) |
|
1606 |
+{ |
|
1607 |
+ if (ck_seat_is_managed (seat)) { |
|
1608 |
+ return; |
|
1609 |
+ } |
|
1610 |
+ |
|
1611 |
+ g_ptr_array_add (*array, g_strdup (id)); |
|
1612 |
+} |
|
1613 |
+ |
|
1614 |
+ |
|
16129 | 1615 |
+/* |
1616 |
+ Example: |
|
1617 |
+ dbus-send --system --dest=org.freedesktop.ConsoleKit \ |
|
1618 |
+ --type=method_call --print-reply --reply-timeout=2000 \ |
|
1619 |
+ /org/freedesktop/ConsoleKit/Manager \ |
|
1620 |
+ org.freedesktop.ConsoleKit.Manager.GetUnmanagedSeats |
|
1621 |
+*/ |
|
1622 |
+gboolean |
|
1623 |
+ck_manager_get_unmanaged_seats (CkManager *manager, |
|
1624 |
+ GPtrArray **seats, |
|
1625 |
+ GError **error) |
|
1626 |
+{ |
|
1627 |
+ g_return_val_if_fail (CK_IS_MANAGER (manager), FALSE); |
|
1628 |
+ |
|
1629 |
+ if (seats == NULL) { |
|
1630 |
+ return FALSE; |
|
1631 |
+ } |
|
1632 |
+ |
|
1633 |
+ *seats = g_ptr_array_new (); |
|
16232 | 1634 |
+ g_hash_table_foreach (manager->priv->seats, (GHFunc)listify_unmanaged_seat_ids, seats); |
16129 | 1635 |
+ |
1636 |
+ return TRUE; |
|
1637 |
+} |
|
1638 |
+ |
|
16232 | 1639 |
+static void |
16129 | 1640 |
listify_session_ids (char *id, |
1641 |
CkSession *session, |
|
16232 | 1642 |
GPtrArray **array) |
21938 | 1643 |
@@ -2423,16 +2555,321 @@ ck_manager_get_sessions (CkManager *man |
17862 | 1644 |
return TRUE; |
1645 |
} |
|
1646 |
||
1647 |
+/* |
|
1648 |
+ Example: |
|
1649 |
+ dbus-send --system --dest=org.freedesktop.ConsoleKit \ |
|
1650 |
+ --type=method_call --print-reply --reply-timeout=2000 \ |
|
1651 |
+ /org/freedesktop/ConsoleKit/Manager \ |
|
1652 |
+ org.freedesktop.ConsoleKit.Manager.AddSeat string:Default |
|
1653 |
+*/ |
|
1654 |
+gboolean |
|
1655 |
+ck_manager_add_seat (CkManager *manager, |
|
1656 |
+ const char *type, |
|
1657 |
+ char **sid, |
|
1658 |
+ GError **error) |
|
1659 |
+{ |
|
1660 |
+ CkSeat *seat; |
|
1661 |
+ |
|
21938 | 1662 |
+ g_debug ("CkManager: Add seat '%s'.", *sid); |
17862 | 1663 |
+ g_return_val_if_fail (CK_IS_MANAGER (manager), FALSE); |
1664 |
+ |
|
1665 |
+ seat = add_new_seat (manager, NULL, CK_SEAT_KIND_DYNAMIC, type); |
|
1666 |
+ |
|
1667 |
+ if (!ck_seat_get_id (seat, sid, error)) { |
|
1668 |
+ return FALSE; |
|
1669 |
+ } |
|
1670 |
+ |
|
1671 |
+ return TRUE; |
|
1672 |
+} |
|
1673 |
+ |
|
1674 |
+/* |
|
1675 |
+ Example: |
|
1676 |
+ dbus-send --system --dest=org.freedesktop.ConsoleKit \ |
|
1677 |
+ --type=method_call --print-reply --reply-timeout=2000 \ |
|
1678 |
+ /org/freedesktop/ConsoleKit/Manager \ |
|
1679 |
+ org.freedesktop.ConsoleKit.Manager.AddSeatById \ |
|
1680 |
+ objpath:/org/freedesktop/ConsoleKit/SeatTest \ |
|
1681 |
+*/ |
|
1682 |
+gboolean |
|
1683 |
+ck_manager_add_seat_by_id (CkManager *manager, |
|
1684 |
+ const char *type, |
|
1685 |
+ const char *sid, |
|
1686 |
+ GError **error) |
|
1687 |
+{ |
|
1688 |
+ CkSeat *seat; |
|
1689 |
+ |
|
1690 |
+ g_return_val_if_fail (CK_IS_MANAGER (manager), FALSE); |
|
1691 |
+ |
|
1692 |
+ seat = add_new_seat (manager, sid, CK_SEAT_KIND_DYNAMIC, type); |
|
1693 |
+ |
|
1694 |
+ return !(seat == NULL); |
|
1695 |
+} |
|
1696 |
+ |
|
1697 |
+/* |
|
1698 |
+ Example: |
|
1699 |
+ dbus-send --system --dest=org.freedesktop.ConsoleKit \ |
|
1700 |
+ --type=method_call --print-reply --reply-timeout=2000 \ |
|
1701 |
+ /org/freedesktop/ConsoleKit/Manager \ |
|
1702 |
+ org.freedesktop.ConsoleKit.Manager.RemoveSeat \ |
|
1703 |
+ obj:/org/freedesktop/ConsoleKit/Seat2 |
|
1704 |
+*/ |
|
1705 |
+gboolean |
|
1706 |
+ck_manager_remove_seat (CkManager *manager, |
|
1707 |
+ const char *sid, |
|
1708 |
+ DBusGMethodInvocation *context) |
|
1709 |
+{ |
|
1710 |
+ CkSeat *seat = NULL; |
|
1711 |
+ CkSeatKind kind; |
|
1712 |
+ |
|
22037 | 1713 |
+ g_debug ("CkManager: Remove seat '%s'.", sid); |
17862 | 1714 |
+ g_return_val_if_fail (CK_IS_MANAGER (manager), FALSE); |
1715 |
+ |
|
1716 |
+ seat = g_hash_table_lookup (manager->priv->seats, sid); |
|
1717 |
+ |
|
1718 |
+ if (seat == NULL) { |
|
1719 |
+ GError *error; |
|
1720 |
+ |
|
1721 |
+ error = g_error_new (CK_SEAT_ERROR, |
|
1722 |
+ CK_SEAT_ERROR_GENERAL, |
|
1723 |
+ _("Seat '%s' doesn't exist"), |
|
1724 |
+ sid); |
|
1725 |
+ |
|
1726 |
+ dbus_g_method_return_error (context, error); |
|
1727 |
+ g_error_free (error); |
|
1728 |
+ |
|
1729 |
+ return FALSE; |
|
1730 |
+ } |
|
1731 |
+ |
|
1732 |
+ ck_seat_get_kind (seat, &kind, NULL); |
|
1733 |
+ |
|
1734 |
+ if (kind == CK_SEAT_KIND_STATIC) { |
|
1735 |
+ GError *error; |
|
1736 |
+ |
|
1737 |
+ error = g_error_new (CK_SEAT_ERROR, |
|
1738 |
+ CK_SEAT_ERROR_GENERAL, |
|
1739 |
+ _("Seat '%s' is static and can't be removed"), |
|
1740 |
+ sid); |
|
1741 |
+ |
|
1742 |
+ dbus_g_method_return_error (context, error); |
|
1743 |
+ g_error_free (error); |
|
1744 |
+ |
|
1745 |
+ return FALSE; |
|
1746 |
+ } |
|
1747 |
+ |
|
1748 |
+ if (ck_seat_is_managed (seat)) { |
|
1749 |
+ ck_seat_request_removal (seat); |
|
1750 |
+ } else { |
|
1751 |
+ remove_seat (manager, seat); |
|
1752 |
+ } |
|
1753 |
+ |
|
1754 |
+ return TRUE; |
|
1755 |
+} |
|
1756 |
+ |
|
1757 |
+/* |
|
1758 |
+ Example: |
|
1759 |
+ dbus-send --system --dest=org.freedesktop.ConsoleKit \ |
|
1760 |
+ --type=method_call --print-reply --reply-timeout=2000 \ |
|
1761 |
+ /org/freedesktop/ConsoleKit/Manager \ |
|
1762 |
+ org.freedesktop.ConsoleKit.Manager.AddSession \ |
|
1763 |
+ objpath:/org/freedesktop/ConsoleKit/Seat2 \ |
|
1764 |
+ string:"LoginWindow" \ |
|
1765 |
+ dict:string:string:"vt","vt9","display",":123" |
|
1766 |
+*/ |
|
1767 |
+gboolean |
|
1768 |
+ck_manager_add_session (CkManager *manager, |
|
1769 |
+ const char *sid, |
|
1770 |
+ const char *type, |
|
1771 |
+ const char *display_type, |
|
1772 |
+ GHashTable *variables, |
|
1773 |
+ DBusGMethodInvocation *context) |
|
1774 |
+{ |
|
1775 |
+ CkSeat *seat; |
|
1776 |
+ CkSession *session; |
|
1777 |
+ char *ssid; |
|
1778 |
+ |
|
21938 | 1779 |
+ g_debug ("CkManager: Add session"); |
17862 | 1780 |
+ seat = g_hash_table_lookup (manager->priv->seats, sid); |
1781 |
+ |
|
1782 |
+ if (seat == NULL) { |
|
1783 |
+ GError *error; |
|
1784 |
+ |
|
1785 |
+ error = g_error_new (CK_SEAT_ERROR, |
|
1786 |
+ CK_SEAT_ERROR_GENERAL, |
|
1787 |
+ _("Seat '%s' doesn't exist"), |
|
1788 |
+ sid); |
|
1789 |
+ |
|
1790 |
+ dbus_g_method_return_error (context, error); |
|
1791 |
+ g_error_free (error); |
|
1792 |
+ |
|
1793 |
+ return FALSE; |
|
1794 |
+ } |
|
1795 |
+ |
|
1796 |
+ ssid = generate_session_id (manager); |
|
1797 |
+ |
|
1798 |
+ session = ck_session_new (ssid, type, display_type, variables); |
|
1799 |
+ |
|
1800 |
+ if (session == NULL) { |
|
1801 |
+ GError *error; |
|
1802 |
+ |
|
1803 |
+ error = g_error_new (CK_SEAT_ERROR, |
|
1804 |
+ CK_SEAT_ERROR_GENERAL, |
|
1805 |
+ _("Session could not be added to seat '%s'"), |
|
1806 |
+ sid); |
|
1807 |
+ |
|
1808 |
+ dbus_g_method_return_error (context, error); |
|
1809 |
+ g_error_free (error); |
|
1810 |
+ |
|
1811 |
+ return FALSE; |
|
1812 |
+ } |
|
1813 |
+ |
|
1814 |
+ ck_session_set_seat_id (session, sid, NULL); |
|
1815 |
+ if (IS_STR_SET (type) && g_str_equal (type, "LoginWindow")) { |
|
1816 |
+ session_set_remove_on_close (session, FALSE, NULL); |
|
1817 |
+ } else { |
|
1818 |
+ session_set_remove_on_close (session, TRUE, NULL); |
|
1819 |
+ } |
|
1820 |
+ |
|
1821 |
+ ck_seat_add_session (seat, session, NULL); |
|
1822 |
+ |
|
1823 |
+ g_hash_table_insert (manager->priv->sessions, |
|
1824 |
+ ssid, |
|
1825 |
+ session); |
|
1826 |
+ |
|
1827 |
+ dbus_g_method_return (context, ssid); |
|
1828 |
+ return TRUE; |
|
1829 |
+} |
|
1830 |
+ |
|
1831 |
+/* |
|
1832 |
+ Example: |
|
1833 |
+ dbus-send --system --dest=org.freedesktop.ConsoleKit \ |
|
1834 |
+ --type=method_call --print-reply --reply-timeout=2000 \ |
|
1835 |
+ /org/freedesktop/ConsoleKit/Manager \ |
|
1836 |
+ org.freedesktop.ConsoleKit.Manager.RemoveSession \ |
|
1837 |
+ objpath:/org/freedesktop/ConsoleKit/Session2 |
|
1838 |
+*/ |
|
1839 |
+gboolean |
|
1840 |
+ck_manager_remove_session (CkManager *manager, |
|
1841 |
+ const char *ssid, |
|
1842 |
+ DBusGMethodInvocation *context) |
|
1843 |
+{ |
|
1844 |
+ CkSession *session; |
|
1845 |
+ CkSeat *seat; |
|
1846 |
+ GError *error; |
|
1847 |
+ char *sid; |
|
1848 |
+ gboolean is_open; |
|
1849 |
+ |
|
21938 | 1850 |
+ g_debug ("CkManager: Remove session."); |
17862 | 1851 |
+ session = g_hash_table_lookup (manager->priv->sessions, ssid); |
1852 |
+ |
|
1853 |
+ if (session == NULL) { |
|
1854 |
+ GError *error; |
|
1855 |
+ |
|
1856 |
+ error = g_error_new (CK_SEAT_ERROR, |
|
1857 |
+ CK_SEAT_ERROR_GENERAL, |
|
1858 |
+ _("Session '%s' doesn't exist"), |
|
1859 |
+ ssid); |
|
1860 |
+ |
|
1861 |
+ dbus_g_method_return_error (context, error); |
|
1862 |
+ g_error_free (error); |
|
1863 |
+ |
|
1864 |
+ return FALSE; |
|
1865 |
+ } |
|
1866 |
+ |
|
1867 |
+ ck_session_get_seat_id (session, &sid, NULL); |
|
1868 |
+ seat = g_hash_table_lookup (manager->priv->seats, sid); |
|
1869 |
+ g_free (sid); |
|
1870 |
+ |
|
1871 |
+ if (seat == NULL) { |
|
1872 |
+ g_warning ("Session '%s' is not associated with a seat", ssid); |
|
1873 |
+ g_hash_table_remove (manager->priv->sessions, ssid); |
|
1874 |
+ return TRUE; |
|
1875 |
+ } |
|
1876 |
+ |
|
1877 |
+ error = NULL; |
|
1878 |
+ |
|
1879 |
+ ck_session_is_open (session, &is_open, NULL); |
|
1880 |
+ session_set_remove_on_close (session, TRUE, NULL); |
|
1881 |
+ |
|
1882 |
+ /* We'll let the seat manager close us when it's ready |
|
1883 |
+ */ |
|
1884 |
+ if (ck_seat_is_managed (seat) && is_open) { |
|
1885 |
+ ck_seat_request_close_session (seat, session, NULL); |
|
1886 |
+ dbus_g_method_return (context); |
|
1887 |
+ |
|
1888 |
+ return TRUE; |
|
1889 |
+ } |
|
1890 |
+ |
|
1891 |
+ if (!ck_seat_remove_session (seat, session, &error)) { |
|
1892 |
+ if (error == NULL) { |
|
1893 |
+ return TRUE; |
|
1894 |
+ } |
|
1895 |
+ |
|
1896 |
+ dbus_g_method_return_error (context, error); |
|
1897 |
+ g_error_free (error); |
|
1898 |
+ return FALSE; |
|
1899 |
+ } |
|
1900 |
+ |
|
1901 |
+ g_hash_table_remove (manager->priv->sessions, ssid); |
|
1902 |
+ dbus_g_method_return (context); |
|
1903 |
+ return TRUE; |
|
1904 |
+} |
|
1905 |
+ |
|
1906 |
+static void |
|
1907 |
+add_sessions_from_seat (CkManager *manager, |
|
1908 |
+ CkSeat *seat) |
|
1909 |
+{ |
|
1910 |
+ GPtrArray *sessions; |
|
1911 |
+ int i; |
|
1912 |
+ |
|
21938 | 1913 |
+ g_debug ("CkManager: Add session from seat."); |
17862 | 1914 |
+ ck_seat_get_sessions (seat, &sessions, NULL); |
1915 |
+ |
|
1916 |
+ for (i = 0; i < sessions->len; i++) { |
|
1917 |
+ char *ssid; |
|
1918 |
+ CkSession *session; |
|
1919 |
+ |
|
1920 |
+ ssid = g_ptr_array_index (sessions, i); |
|
1921 |
+ session = ck_seat_get_session (seat, ssid); |
|
1922 |
+ |
|
1923 |
+ g_hash_table_insert (manager->priv->sessions, |
|
1924 |
+ ssid, |
|
1925 |
+ session); |
|
1926 |
+ } |
|
1927 |
+ |
|
1928 |
+ g_ptr_array_free (sessions, TRUE); |
|
1929 |
+} |
|
1930 |
+ |
|
1931 |
static void |
|
1932 |
add_seat_for_file (CkManager *manager, |
|
1933 |
const char *filename) |
|
1934 |
{ |
|
1935 |
char *sid; |
|
1936 |
+ char *orig_sid; |
|
1937 |
CkSeat *seat; |
|
1938 |
||
21938 | 1939 |
+ g_debug ("CkManager: Add seat for file."); |
17862 | 1940 |
sid = generate_seat_id (manager); |
1941 |
+ orig_sid = g_strdup (sid); |
|
1942 |
+ seat = ck_seat_new_from_file (&sid, filename); |
|
1943 |
||
1944 |
- seat = ck_seat_new_from_file (sid, filename); |
|
1945 |
+ if (seat == NULL) { |
|
1946 |
+ /* returns null if connection to bus fails */ |
|
1947 |
+ g_free (sid); |
|
1948 |
+ g_free (orig_sid); |
|
1949 |
+ manager->priv->seat_serial--; |
|
1950 |
+ return; |
|
1951 |
+ } |
|
1952 |
+ |
|
1953 |
+ if (!g_str_equal (orig_sid, sid)) { |
|
1954 |
+ manager->priv->seat_serial--; |
|
1955 |
+ } |
|
1956 |
+ g_free (orig_sid); |
|
1957 |
+ |
|
1958 |
+ add_sessions_from_seat (manager, seat); |
|
1959 |
+ |
|
1960 |
+ if (seat == NULL) { |
|
1961 |
+ return; |
|
1962 |
+ } |
|
1963 |
||
1964 |
connect_seat_signals (manager, seat); |
|
1965 |
if (!ck_seat_register (seat)) { |
|
21938 | 1966 |
@@ -2451,7 +2888,7 @@ add_seat_for_file (CkManager *manager, |
16647 | 1967 |
ck_seat_run_programs (seat, NULL, NULL, "seat_added"); |
16232 | 1968 |
|
21939 | 1969 |
g_debug ("Emitting seat-added: %s", sid); |
16232 | 1970 |
- g_signal_emit (manager, signals [SEAT_ADDED], 0, sid); |
1971 |
+ g_signal_emit (manager, signals [SEAT_ADDED], 0, sid, "Default"); |
|
1972 |
||
1973 |
log_seat_added_event (manager, seat); |
|
1974 |
} |
|
21938 | 1975 |
@@ -2462,6 +2899,7 @@ load_seats_from_dir (CkManager *manager) |
16232 | 1976 |
GDir *d; |
1977 |
GError *error; |
|
1978 |
const char *file; |
|
1979 |
+ GQueue seat_queue; |
|
1980 |
||
1981 |
error = NULL; |
|
1982 |
d = g_dir_open (CK_SEAT_DIR, |
|
21938 | 1983 |
@@ -2473,15 +2911,26 @@ load_seats_from_dir (CkManager *manager) |
16232 | 1984 |
return FALSE; |
1985 |
} |
|
1986 |
||
1987 |
+ g_queue_init (&seat_queue); |
|
1988 |
while ((file = g_dir_read_name (d)) != NULL) { |
|
1989 |
char *path; |
|
1990 |
path = g_build_filename (CK_SEAT_DIR, file, NULL); |
|
1991 |
+ g_queue_push_tail (&seat_queue, path); |
|
1992 |
+ } |
|
1993 |
+ g_dir_close (d); |
|
1994 |
+ |
|
16647 | 1995 |
+ g_queue_sort (&seat_queue, (GCompareDataFunc) strverscmp, NULL); |
16232 | 1996 |
+ |
1997 |
+ while (!g_queue_is_empty (&seat_queue)) { |
|
1998 |
+ char *path; |
|
1999 |
+ |
|
2000 |
+ path = g_queue_pop_head (&seat_queue); |
|
2001 |
+ |
|
2002 |
add_seat_for_file (manager, path); |
|
2003 |
+ |
|
2004 |
g_free (path); |
|
2005 |
} |
|
2006 |
||
2007 |
- g_dir_close (d); |
|
2008 |
- |
|
2009 |
return TRUE; |
|
2010 |
} |
|
2011 |
||
21938 | 2012 |
@@ -2517,8 +2966,6 @@ ck_manager_init (CkManager *manager) |
16129 | 2013 |
(GDestroyNotify) g_object_unref); |
2014 |
||
2015 |
manager->priv->logger = ck_event_logger_new (LOG_FILE); |
|
2016 |
- |
|
2017 |
- create_seats (manager); |
|
2018 |
} |
|
2019 |
||
2020 |
static void |
|
21938 | 2021 |
@@ -2563,6 +3010,8 @@ ck_manager_new (void) |
16129 | 2022 |
g_object_unref (manager_object); |
2023 |
return NULL; |
|
2024 |
} |
|
2025 |
+ |
|
2026 |
+ create_seats (CK_MANAGER (manager_object)); |
|
2027 |
} |
|
2028 |
||
2029 |
return CK_MANAGER (manager_object); |
|
2030 |
diff --git a/src/ck-manager.h b/src/ck-manager.h |
|
16647 | 2031 |
index 4bd56e8..4304e71 100644 |
16129 | 2032 |
--- a/src/ck-manager.h |
2033 |
+++ b/src/ck-manager.h |
|
16232 | 2034 |
@@ -49,7 +49,8 @@ typedef struct |
2035 |
GObjectClass parent_class; |
|
2036 |
||
2037 |
void (* seat_added) (CkManager *manager, |
|
2038 |
- const char *sid); |
|
2039 |
+ const char *sid, |
|
2040 |
+ const char *type); |
|
2041 |
void (* seat_removed) (CkManager *manager, |
|
2042 |
const char *sid); |
|
2043 |
void (* system_idle_hint_changed) (CkManager *manager, |
|
2044 |
@@ -96,6 +97,9 @@ gboolean ck_manager_get_sessions (CkManager |
|
16129 | 2045 |
gboolean ck_manager_get_seats (CkManager *manager, |
2046 |
GPtrArray **seats, |
|
2047 |
GError **error); |
|
2048 |
+gboolean ck_manager_get_unmanaged_seats (CkManager *manager, |
|
2049 |
+ GPtrArray **seats, |
|
2050 |
+ GError **error); |
|
2051 |
gboolean ck_manager_close_session (CkManager *manager, |
|
2052 |
const char *cookie, |
|
2053 |
DBusGMethodInvocation *context); |
|
16647 | 2054 |
@@ -128,6 +132,28 @@ gboolean ck_manager_open_session_with_parameters (CkManager |
16129 | 2055 |
const GPtrArray *parameters, |
2056 |
DBusGMethodInvocation *context); |
|
2057 |
||
16232 | 2058 |
+gboolean ck_manager_add_seat (CkManager *manager, |
2059 |
+ const char *type, |
|
2060 |
+ char **sid, |
|
2061 |
+ GError **error); |
|
16647 | 2062 |
+gboolean ck_manager_add_seat_by_id (CkManager *manager, |
2063 |
+ const char *type, |
|
2064 |
+ const char *sid, |
|
2065 |
+ GError **error); |
|
16232 | 2066 |
+gboolean ck_manager_remove_seat (CkManager *manager, |
2067 |
+ const char *sid, |
|
16129 | 2068 |
+ DBusGMethodInvocation *context); |
16232 | 2069 |
+ |
2070 |
+gboolean ck_manager_add_session (CkManager *manager, |
|
2071 |
+ const char *sid, |
|
2072 |
+ const char *type, |
|
2073 |
+ const char *display_type, |
|
2074 |
+ GHashTable *parameters, |
|
16129 | 2075 |
+ DBusGMethodInvocation *context); |
16232 | 2076 |
+gboolean ck_manager_remove_session (CkManager *manager, |
2077 |
+ const char *ssid, |
|
2078 |
+ DBusGMethodInvocation *context); |
|
16129 | 2079 |
+ |
2080 |
G_END_DECLS |
|
2081 |
||
2082 |
#endif /* __CK_MANAGER_H */ |
|
2083 |
diff --git a/src/ck-marshal.list b/src/ck-marshal.list |
|
16647 | 2084 |
index 7f60efc..f8029a6 100644 |
16129 | 2085 |
--- a/src/ck-marshal.list |
2086 |
+++ b/src/ck-marshal.list |
|
21493 | 2087 |
@@ -1,3 +1,6 @@ |
16129 | 2088 |
VOID:UINT,STRING |
2089 |
BOOLEAN:POINTER |
|
21493 | 2090 |
VOID:OBJECT,OBJECT |
16232 | 2091 |
+VOID:STRING,STRING |
2092 |
+VOID:STRING,BOOLEAN,STRING,POINTER,STRING,POINTER |
|
21493 | 2093 |
+VOID:STRING,STRING,STRING,POINTER,STRING,POINTER |
16129 | 2094 |
diff --git a/src/ck-seat.c b/src/ck-seat.c |
17996 | 2095 |
index af7db59..dd2a387 100644 |
16129 | 2096 |
--- a/src/ck-seat.c |
2097 |
+++ b/src/ck-seat.c |
|
16232 | 2098 |
@@ -40,21 +40,30 @@ |
16129 | 2099 |
#include "ck-seat-glue.h" |
2100 |
#include "ck-marshal.h" |
|
2101 |
||
16232 | 2102 |
+#include "ck-display-template.h" |
16129 | 2103 |
#include "ck-session.h" |
2104 |
#include "ck-vt-monitor.h" |
|
2105 |
#include "ck-run-programs.h" |
|
16232 | 2106 |
|
2107 |
#define CK_SEAT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CK_TYPE_SEAT, CkSeatPrivate)) |
|
2108 |
||
2109 |
+#define CK_SESSION_DIR SYSCONFDIR "/ConsoleKit/sessions.d" |
|
2110 |
+ |
|
2111 |
#define CK_DBUS_PATH "/org/freedesktop/ConsoleKit" |
|
16129 | 2112 |
#define CK_DBUS_NAME "org.freedesktop.ConsoleKit" |
2113 |
||
2114 |
#define NONULL_STRING(x) ((x) != NULL ? (x) : "") |
|
2115 |
+#define N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0])) |
|
2116 |
+ |
|
2117 |
+#define IS_STR_SET(x) (x != NULL && x[0] != '\0') |
|
2118 |
+ |
|
16232 | 2119 |
+#define CK_DBUS_TYPE_G_STRING_STRING_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING)) |
16129 | 2120 |
|
2121 |
struct CkSeatPrivate |
|
2122 |
{ |
|
2123 |
char *id; |
|
2124 |
CkSeatKind kind; |
|
16232 | 2125 |
+ char *type; |
16129 | 2126 |
GHashTable *sessions; |
2127 |
GPtrArray *devices; |
|
2128 |
||
16232 | 2129 |
@@ -63,6 +72,8 @@ struct CkSeatPrivate |
2130 |
CkVtMonitor *vt_monitor; |
|
2131 |
||
2132 |
DBusGConnection *connection; |
|
2133 |
+ |
|
2134 |
+ DBusGProxy *manager_proxy; |
|
2135 |
}; |
|
2136 |
||
2137 |
enum { |
|
21493 | 2138 |
@@ -74,6 +85,9 @@ enum { |
16647 | 2139 |
SESSION_REMOVED_FULL, |
16129 | 2140 |
DEVICE_ADDED, |
2141 |
DEVICE_REMOVED, |
|
16232 | 2142 |
+ REMOVE_REQUEST, |
21493 | 2143 |
+ OPEN_SESSION_REQUEST, |
2144 |
+ CLOSE_SESSION_REQUEST, |
|
16129 | 2145 |
LAST_SIGNAL |
2146 |
}; |
|
2147 |
||
21493 | 2148 |
@@ -81,6 +95,7 @@ enum { |
16232 | 2149 |
PROP_0, |
2150 |
PROP_ID, |
|
2151 |
PROP_KIND, |
|
2152 |
+ PROP_TYPE |
|
2153 |
}; |
|
2154 |
||
2155 |
static guint signals [LAST_SIGNAL] = { 0, }; |
|
21493 | 2156 |
@@ -287,6 +302,7 @@ ck_seat_activate_session (CkSeat |
16844 | 2157 |
{ |
2158 |
CkSession *session; |
|
2159 |
gboolean ret; |
|
2160 |
+ gboolean is_open; |
|
2161 |
||
2162 |
g_return_val_if_fail (CK_IS_SEAT (seat), FALSE); |
|
2163 |
||
21938 | 2164 |
@@ -298,12 +314,398 @@ ck_seat_activate_session (CkSeat |
16844 | 2165 |
session = g_hash_table_lookup (seat->priv->sessions, ssid); |
2166 |
} |
|
2167 |
||
2168 |
- ret = _seat_activate_session (seat, session, context); |
|
2169 |
+ ck_session_is_open (session, &is_open, NULL); |
|
2170 |
+ if (!is_open) { |
|
2171 |
+ ret = ck_seat_request_open_session (seat, session, NULL); |
|
2172 |
+ dbus_g_method_return (context, NULL); |
|
2173 |
+ } else { |
|
2174 |
+ ret = _seat_activate_session (seat, session, context); |
|
2175 |
+ } |
|
2176 |
||
2177 |
return ret; |
|
16129 | 2178 |
} |
2179 |
||
16232 | 2180 |
static gboolean |
2181 |
+on_substitution_match (const GMatchInfo *match_info, |
|
2182 |
+ GString *result, |
|
2183 |
+ GHashTable *substitution_variables) |
|
16129 | 2184 |
+{ |
16232 | 2185 |
+ char *match; |
21751 | 2186 |
+ char *value = NULL; |
16232 | 2187 |
+ |
2188 |
+ match = g_match_info_fetch (match_info, 1); |
|
2189 |
+ |
|
21751 | 2190 |
+ if (substitution_variables != NULL) |
2191 |
+ value = g_hash_table_lookup (substitution_variables, match); |
|
16232 | 2192 |
+ |
2193 |
+ if (value != NULL) { |
|
2194 |
+ g_string_append (result, value); |
|
2195 |
+ } else { |
|
2196 |
+ char *original_string; |
|
2197 |
+ |
|
2198 |
+ original_string = g_match_info_fetch (match_info, 0); |
|
2199 |
+ g_string_append (result, original_string); |
|
2200 |
+ g_free (original_string); |
|
16129 | 2201 |
+ } |
16232 | 2202 |
+ g_free (match); |
2203 |
+ |
|
2204 |
+ return FALSE; |
|
2205 |
+} |
|
2206 |
+ |
|
2207 |
+static char * |
|
2208 |
+apply_substitutions (const char *value, |
|
2209 |
+ GHashTable *substitution_variables) |
|
2210 |
+{ |
|
2211 |
+ GRegex *expression; |
|
2212 |
+ char *expanded_string; |
|
2213 |
+ |
|
2214 |
+ expression = g_regex_new ("\\$([^[:space:]]+)", 0, 0, NULL); |
|
2215 |
+ expanded_string = g_regex_replace_eval (expression, |
|
2216 |
+ value, |
|
2217 |
+ -1, 0, 0, |
|
2218 |
+ (GRegexEvalCallback) |
|
2219 |
+ on_substitution_match, |
|
2220 |
+ substitution_variables, |
|
2221 |
+ NULL); |
|
2222 |
+ |
|
2223 |
+ if (expanded_string == NULL) { |
|
2224 |
+ expanded_string = g_strdup (value); |
|
2225 |
+ } |
|
2226 |
+ |
|
2227 |
+ return expanded_string; |
|
16129 | 2228 |
+} |
16232 | 2229 |
+ |
2230 |
+static GHashTable * |
|
2231 |
+get_evaluated_parameter_map (GHashTable *parameters, |
|
2232 |
+ GHashTable *substitution_variables) |
|
2233 |
+{ |
|
2234 |
+ GHashTable *evaluated_parameters; |
|
2235 |
+ GHashTableIter iter; |
|
2236 |
+ gpointer key, value; |
|
2237 |
+ |
|
2238 |
+ evaluated_parameters = g_hash_table_new_full (g_str_hash, g_str_equal, |
|
2239 |
+ (GDestroyNotify) g_free, |
|
2240 |
+ (GDestroyNotify) g_free); |
|
2241 |
+ |
|
2242 |
+ g_hash_table_iter_init (&iter, parameters); |
|
2243 |
+ while (g_hash_table_iter_next (&iter, &key, &value)) { |
|
2244 |
+ char *expanded_string; |
|
2245 |
+ |
|
2246 |
+ expanded_string = apply_substitutions ((char *) value, |
|
2247 |
+ substitution_variables); |
|
2248 |
+ |
|
2249 |
+ g_hash_table_insert (evaluated_parameters, |
|
2250 |
+ g_strdup ((char *) key), |
|
2251 |
+ expanded_string); |
|
2252 |
+ } |
|
2253 |
+ |
|
2254 |
+ return evaluated_parameters; |
|
2255 |
+} |
|
16129 | 2256 |
+ |
2257 |
+static void |
|
16232 | 2258 |
+request_session (gpointer key, |
2259 |
+ gpointer value, |
|
16129 | 2260 |
+ gpointer user_data) |
2261 |
+{ |
|
2262 |
+ CkSeat *seat = CK_SEAT (user_data); |
|
16232 | 2263 |
+ CkSession *session = (CkSession *) value; |
2264 |
+ |
|
21938 | 2265 |
+ g_debug ("CkSeat: Request session"); |
16911 | 2266 |
+ ck_session_set_ever_open (session, FALSE, NULL); |
17003 | 2267 |
+ ck_session_set_under_request (session, FALSE, NULL); |
16232 | 2268 |
+ ck_seat_request_open_session (seat, session, NULL); |
2269 |
+} |
|
2270 |
+ |
|
2271 |
+static void |
|
2272 |
+append_hash_table_to_dbus_message_iter (DBusMessageIter *iter, |
|
2273 |
+ GHashTable *hash_table) |
|
2274 |
+{ |
|
2275 |
+ GHashTableIter hash_table_iter; |
|
2276 |
+ gpointer key, value; |
|
2277 |
+ DBusMessageIter array_iter; |
|
2278 |
+ |
|
2279 |
+ dbus_message_iter_open_container (iter, |
|
2280 |
+ DBUS_TYPE_ARRAY, |
|
2281 |
+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING |
|
2282 |
+ DBUS_TYPE_STRING_AS_STRING |
|
2283 |
+ DBUS_TYPE_STRING_AS_STRING |
|
2284 |
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING, |
|
2285 |
+ &array_iter); |
|
2286 |
+ |
|
2287 |
+ |
|
2288 |
+ g_hash_table_iter_init (&hash_table_iter, hash_table); |
|
2289 |
+ while (g_hash_table_iter_next (&hash_table_iter, &key, &value)) { |
|
2290 |
+ DBusMessageIter dict_iter; |
|
2291 |
+ |
|
2292 |
+ dbus_message_iter_open_container (&array_iter, |
|
2293 |
+ DBUS_TYPE_DICT_ENTRY, |
|
2294 |
+ NULL, |
|
2295 |
+ &dict_iter); |
|
2296 |
+ |
|
2297 |
+ dbus_message_iter_append_basic (&dict_iter, DBUS_TYPE_STRING, &key); |
|
2298 |
+ dbus_message_iter_append_basic (&dict_iter, DBUS_TYPE_STRING, &value); |
|
2299 |
+ dbus_message_iter_close_container (&array_iter, &dict_iter); |
|
16129 | 2300 |
+ } |
16232 | 2301 |
+ dbus_message_iter_close_container (iter, &array_iter); |
2302 |
+} |
|
2303 |
+ |
|
2304 |
+static void |
|
2305 |
+emit_session_open_request (CkSeat *seat, |
|
2306 |
+ const char *ssid, |
|
16540 | 2307 |
+ const char *session_type, |
2308 |
+ const char *display_template_name, |
|
16232 | 2309 |
+ GHashTable *display_variables, |
2310 |
+ const char *display_type, |
|
2311 |
+ GHashTable *evaluated_parameters) |
|
2312 |
+{ |
|
2313 |
+ DBusMessage *message; |
|
2314 |
+ DBusConnection *connection; |
|
2315 |
+ DBusMessageIter iter; |
|
2316 |
+ |
|
17338 | 2317 |
+ if (!ck_seat_is_managed (seat)) |
2318 |
+ return; |
|
2319 |
+ |
|
16232 | 2320 |
+ message = dbus_message_new_signal (seat->priv->id, |
2321 |
+ "org.freedesktop.ConsoleKit.Seat", |
|
2322 |
+ "OpenSessionRequest"); |
|
2323 |
+ |
|
2324 |
+ dbus_message_set_destination (message, |
|
2325 |
+ dbus_g_proxy_get_bus_name (seat->priv->manager_proxy)); |
|
2326 |
+ |
|
2327 |
+ dbus_message_iter_init_append (message, &iter); |
|
2328 |
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_OBJECT_PATH, &ssid); |
|
16540 | 2329 |
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session_type); |
2330 |
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_template_name); |
|
16232 | 2331 |
+ append_hash_table_to_dbus_message_iter (&iter, display_variables); |
2332 |
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_type); |
|
2333 |
+ append_hash_table_to_dbus_message_iter (&iter, evaluated_parameters); |
|
2334 |
+ |
|
2335 |
+ connection = dbus_bus_get (DBUS_BUS_SYSTEM, NULL); |
|
2336 |
+ dbus_connection_send (connection, message, NULL); |
|
2337 |
+ dbus_connection_unref (connection); |
|
2338 |
+ dbus_message_unref (message); |
|
16129 | 2339 |
+} |
2340 |
+ |
|
2341 |
+gboolean |
|
16232 | 2342 |
+ck_seat_request_open_session (CkSeat *seat, |
2343 |
+ CkSession *session, |
|
2344 |
+ GError **error) |
|
2345 |
+{ |
|
2346 |
+ char *ssid; |
|
2347 |
+ char *type; |
|
2348 |
+ CkDisplayTemplate *display_template; |
|
2349 |
+ GHashTable *display_variables; |
|
2350 |
+ GHashTable *display_parameters; |
|
2351 |
+ GHashTable *evaluated_parameters; |
|
2352 |
+ gboolean is_open; |
|
16844 | 2353 |
+ gboolean ever_open; |
2354 |
+ gboolean under_request; |
|
16232 | 2355 |
+ |
2356 |
+ ck_session_is_open (session, &is_open, NULL); |
|
2357 |
+ |
|
2358 |
+ if (is_open) { |
|
2359 |
+ return TRUE; |
|
2360 |
+ } |
|
2361 |
+ |
|
16844 | 2362 |
+ ck_session_get_under_request (session, &under_request, NULL); |
2363 |
+ if (under_request) { |
|
2364 |
+ return TRUE; |
|
2365 |
+ } |
|
2366 |
+ |
|
2367 |
+ ck_session_set_under_request (session, TRUE, NULL); |
|
2368 |
+ |
|
2369 |
+ ck_session_get_ever_open (session, &ever_open, NULL); |
|
2370 |
+ |
|
16232 | 2371 |
+ display_template = ck_session_get_display_template (session); |
2372 |
+ |
|
2373 |
+ if (display_template == NULL) { |
|
2374 |
+ return TRUE; |
|
2375 |
+ } |
|
2376 |
+ |
|
2377 |
+ ck_session_get_session_type (session, &type, NULL); |
|
2378 |
+ |
|
2379 |
+ if (type == NULL) { |
|
2380 |
+ g_object_unref (display_template); |
|
2381 |
+ return TRUE; |
|
2382 |
+ } |
|
2383 |
+ |
|
2384 |
+ /* substitute $display $vt etc */ |
|
2385 |
+ display_variables = ck_session_get_display_variables (session); |
|
2386 |
+ display_parameters = ck_display_template_get_parameters (display_template); |
|
2387 |
+ |
|
2388 |
+ if (display_parameters == NULL) { |
|
2389 |
+ g_free (type); |
|
2390 |
+ g_object_unref (display_template); |
|
2391 |
+ g_hash_table_unref (display_variables); |
|
2392 |
+ return TRUE; |
|
2393 |
+ } |
|
2394 |
+ |
|
16844 | 2395 |
+ if (!ever_open) { |
2396 |
+ evaluated_parameters = get_evaluated_parameter_map (display_parameters, display_variables); |
|
2397 |
+ } else { |
|
2398 |
+ evaluated_parameters = get_evaluated_parameter_map (display_parameters, NULL); |
|
2399 |
+ } |
|
2400 |
+ |
|
16232 | 2401 |
+ g_hash_table_unref (display_parameters); |
2402 |
+ |
|
2403 |
+ ck_session_get_id (session, &ssid, NULL); |
|
2404 |
+ |
|
16540 | 2405 |
+ emit_session_open_request (seat, ssid, type, |
2406 |
+ ck_display_template_get_name (display_template), |
|
2407 |
+ display_variables, |
|
16232 | 2408 |
+ ck_display_template_get_type_string (display_template), |
2409 |
+ evaluated_parameters); |
|
2410 |
+ |
|
2411 |
+ g_free (ssid); |
|
2412 |
+ g_free (type); |
|
2413 |
+ g_hash_table_unref (evaluated_parameters); |
|
2414 |
+ g_hash_table_unref (display_variables); |
|
2415 |
+ g_object_unref (display_template); |
|
2416 |
+ |
|
2417 |
+ return TRUE; |
|
2418 |
+} |
|
2419 |
+ |
|
2420 |
+static void |
|
2421 |
+on_seat_manager_disappeared (CkSeat *seat) |
|
16129 | 2422 |
+{ |
21938 | 2423 |
+ g_debug ("CkSeat: Seat Manager Disappeared."); |
2424 |
+ |
|
16232 | 2425 |
+ g_signal_handlers_disconnect_by_func (seat->priv->manager_proxy, |
2426 |
+ G_CALLBACK (on_seat_manager_disappeared), |
|
2427 |
+ seat); |
|
2428 |
+ g_object_unref (seat->priv->manager_proxy); |
|
2429 |
+ seat->priv->manager_proxy = NULL; |
|
2430 |
+ |
|
2431 |
+ /* FIXME: should probably emit a signal so a new display manager |
|
2432 |
+ * knows that the seat is now unmanaged |
|
2433 |
+ * |
|
2434 |
+ * (maybe only if its kind is static?) |
|
2435 |
+ */ |
|
2436 |
+} |
|
2437 |
+ |
|
2438 |
+gboolean |
|
2439 |
+ck_seat_manage (CkSeat *seat, |
|
2440 |
+ DBusGMethodInvocation *context) |
|
2441 |
+{ |
|
2442 |
+ char *sender_name; |
|
2443 |
+ |
|
21938 | 2444 |
+ g_debug ("CkSeat: Seat manage."); |
16232 | 2445 |
+ sender_name = dbus_g_method_get_sender (context); |
2446 |
+ |
|
2447 |
+ if (seat->priv->manager_proxy != NULL) { |
|
2448 |
+ GError *error; |
|
2449 |
+ const char *existing_manager_name; |
|
2450 |
+ |
|
2451 |
+ existing_manager_name = dbus_g_proxy_get_bus_name (seat->priv->manager_proxy); |
|
2452 |
+ |
|
2453 |
+ if (existing_manager_name == NULL) { |
|
2454 |
+ g_warning ("Seat manager lacks bus unique name"); |
|
2455 |
+ existing_manager_name = "<unknown>"; |
|
2456 |
+ } |
|
2457 |
+ |
|
2458 |
+ error = g_error_new (CK_SEAT_ERROR, |
|
2459 |
+ CK_SEAT_ERROR_GENERAL, |
|
2460 |
+ _("Seat already managed (by '%s')"), |
|
2461 |
+ existing_manager_name); |
|
2462 |
+ |
|
2463 |
+ dbus_g_method_return_error (context, error); |
|
2464 |
+ g_error_free (error); |
|
2465 |
+ return FALSE; |
|
2466 |
+ } |
|
2467 |
+ |
|
2468 |
+ /* FIXME: We pass in a bogus object path (the path we use on this side of |
|
2469 |
+ * the pipe) and interface here. |
|
2470 |
+ * |
|
2471 |
+ * We only use the proxy to watch for when the other side disappears, not |
|
2472 |
+ * for communicating with it. All communication is one-way using signals. |
|
2473 |
+ */ |
|
2474 |
+ seat->priv->manager_proxy = dbus_g_proxy_new_for_name (seat->priv->connection, |
|
2475 |
+ |
|
2476 |
+ sender_name, |
|
2477 |
+ seat->priv->id, |
|
2478 |
+ "org.freedesktop.ConsoleKit.SeatManager"); |
|
2479 |
+ g_free (sender_name); |
|
2480 |
+ |
|
2481 |
+ g_signal_connect_swapped (seat->priv->manager_proxy, |
|
2482 |
+ "destroy", |
|
2483 |
+ G_CALLBACK (on_seat_manager_disappeared), |
|
2484 |
+ seat); |
|
2485 |
+ |
|
2486 |
+ g_hash_table_foreach (seat->priv->sessions, request_session, seat); |
|
2487 |
+ |
|
2488 |
+ dbus_g_method_return (context); |
|
16129 | 2489 |
+ return TRUE; |
2490 |
+} |
|
2491 |
+ |
|
2492 |
+gboolean |
|
16232 | 2493 |
+ck_seat_unmanage (CkSeat *seat, |
2494 |
+ DBusGMethodInvocation *context) |
|
2495 |
+{ |
|
2496 |
+ GError *error; |
|
2497 |
+ const char *existing_manager_name; |
|
2498 |
+ char *sender_name; |
|
2499 |
+ |
|
21938 | 2500 |
+ g_debug ("CkSeat: Seat unmanage."); |
16232 | 2501 |
+ if (seat->priv->manager_proxy == NULL) { |
2502 |
+ GError *error; |
|
2503 |
+ |
|
2504 |
+ error = g_error_new (CK_SEAT_ERROR, |
|
2505 |
+ CK_SEAT_ERROR_GENERAL, |
|
2506 |
+ _("Seat not managed")); |
|
2507 |
+ |
|
2508 |
+ dbus_g_method_return_error (context, error); |
|
2509 |
+ g_error_free (error); |
|
2510 |
+ return FALSE; |
|
2511 |
+ } |
|
2512 |
+ |
|
2513 |
+ sender_name = dbus_g_method_get_sender (context); |
|
2514 |
+ existing_manager_name = dbus_g_proxy_get_bus_name (seat->priv->manager_proxy); |
|
2515 |
+ |
|
2516 |
+ if (strcmp (sender_name, existing_manager_name) != 0) { |
|
2517 |
+ |
|
2518 |
+ error = g_error_new (CK_SEAT_ERROR, |
|
2519 |
+ CK_SEAT_ERROR_GENERAL, |
|
2520 |
+ _("Seat managed by '%s' not '%s'"), |
|
2521 |
+ existing_manager_name, |
|
2522 |
+ sender_name); |
|
2523 |
+ |
|
2524 |
+ dbus_g_method_return_error (context, error); |
|
2525 |
+ g_error_free (error); |
|
2526 |
+ |
|
2527 |
+ return FALSE; |
|
2528 |
+ } |
|
2529 |
+ |
|
2530 |
+ on_seat_manager_disappeared (seat); |
|
2531 |
+ |
|
2532 |
+ dbus_g_method_return (context); |
|
2533 |
+ return TRUE; |
|
2534 |
+} |
|
2535 |
+ |
|
2536 |
+void |
|
2537 |
+ck_seat_request_removal (CkSeat *seat) |
|
16129 | 2538 |
+{ |
16232 | 2539 |
+ DBusMessage *message; |
2540 |
+ DBusConnection *connection; |
|
2541 |
+ |
|
2542 |
+ g_return_if_fail (CK_IS_SEAT (seat)); |
|
2543 |
+ g_return_if_fail (ck_seat_is_managed (seat)); |
|
2544 |
+ |
|
21938 | 2545 |
+ g_debug ("CkSeat: Seat request removal."); |
2546 |
+ |
|
16232 | 2547 |
+ message = dbus_message_new_signal (seat->priv->id, |
2548 |
+ "org.freedesktop.ConsoleKit.Seat", |
|
2549 |
+ "RemoveRequest"); |
|
2550 |
+ |
|
2551 |
+ dbus_message_set_destination (message, |
|
2552 |
+ dbus_g_proxy_get_bus_name (seat->priv->manager_proxy)); |
|
2553 |
+ |
|
2554 |
+ connection = dbus_bus_get (DBUS_BUS_SYSTEM, NULL); |
|
2555 |
+ dbus_connection_send (connection, message, NULL); |
|
2556 |
+ dbus_connection_unref (connection); |
|
2557 |
+ dbus_message_unref (message); |
|
2558 |
+} |
|
2559 |
+ |
|
2560 |
+static gboolean |
|
2561 |
match_session_display_device (const char *key, |
|
2562 |
CkSession *session, |
|
2563 |
const char *display_device) |
|
21938 | 2564 |
@@ -314,6 +716,8 @@ match_session_display_device (const char |
2565 |
device = NULL; |
|
2566 |
ret = FALSE; |
|
2567 |
||
2568 |
+ g_debug ("CkSeat: Session display device."); |
|
2569 |
+ |
|
2570 |
if (session == NULL) { |
|
2571 |
goto out; |
|
2572 |
} |
|
2573 |
@@ -486,6 +890,8 @@ change_active_session (CkSeat *seat, |
|
2574 |
char *ssid; |
|
2575 |
CkSession *old_session; |
|
2576 |
||
2577 |
+ g_debug ("CkSeat: Change active session."); |
|
2578 |
+ |
|
2579 |
if (seat->priv->active_session == session) { |
|
2580 |
return; |
|
2581 |
} |
|
2582 |
@@ -515,7 +921,10 @@ change_active_session (CkSeat *seat, |
|
2583 |
* must be sent when the database dump is finished it is |
|
2584 |
* important that the '-full' signalled is emitted first. */ |
|
2585 |
||
2586 |
- g_signal_emit (seat, signals [ACTIVE_SESSION_CHANGED_FULL], 0, old_session, session); |
|
2587 |
+ if (CK_IS_SESSION (old_session)) { |
|
2588 |
+ g_signal_emit (seat, signals [ACTIVE_SESSION_CHANGED_FULL], 0, old_session, session); |
|
2589 |
+ } |
|
2590 |
+ |
|
2591 |
g_signal_emit (seat, signals [ACTIVE_SESSION_CHANGED], 0, ssid); |
|
2592 |
||
2593 |
if (old_session != NULL) { |
|
21940
435c776c0f32
Another minor fix to correct an issue with a new debug statement found in testing.
yippi
parents:
21939
diff
changeset
|
2594 |
@@ -526,18 +935,59 @@ change_active_session (CkSeat *seat, |
16844 | 2595 |
} |
2596 |
||
2597 |
static void |
|
2598 |
+find_possible_session_to_activate (CkSeat *seat) |
|
2599 |
+{ |
|
2600 |
+ GHashTableIter iter; |
|
2601 |
+ gpointer key, value; |
|
2602 |
+ gboolean is_open; |
|
2603 |
+ char *session_type = NULL; |
|
2604 |
+ CkSession *login_session = NULL; |
|
2605 |
+ |
|
21938 | 2606 |
+ g_debug ("CkSeat: Find possible session to activate"); |
16844 | 2607 |
+ g_hash_table_iter_init (&iter, seat->priv->sessions); |
2608 |
+ while (g_hash_table_iter_next (&iter, &key, &value)) { |
|
2609 |
+ |
|
2610 |
+ ck_session_is_open (value, &is_open, NULL); |
|
2611 |
+ |
|
2612 |
+ if (is_open) { |
|
17996 | 2613 |
+ login_session = NULL; |
16844 | 2614 |
+ change_active_session (seat, value); |
2615 |
+ break; |
|
2616 |
+ } |
|
2617 |
+ |
|
2618 |
+ ck_session_get_session_type (value, &session_type, NULL); |
|
2619 |
+ if (IS_STR_SET (session_type) && |
|
2620 |
+ g_str_equal (session_type, "LoginWindow")) { |
|
2621 |
+ login_session = value; |
|
2622 |
+ g_free (session_type); |
|
2623 |
+ } |
|
2624 |
+ } |
|
2625 |
+ |
|
2626 |
+ if (login_session != NULL) { |
|
2627 |
+ ck_session_set_ever_open (login_session, FALSE, NULL); |
|
2628 |
+ ck_seat_request_open_session (seat, login_session, NULL); |
|
2629 |
+ } |
|
2630 |
+ |
|
2631 |
+} |
|
2632 |
+ |
|
2633 |
+static void |
|
2634 |
update_active_vt (CkSeat *seat, |
|
2635 |
guint num) |
|
2636 |
{ |
|
21938 | 2637 |
CkSession *session; |
2638 |
char *device; |
|
2639 |
||
2640 |
device = ck_get_console_device_for_num (num); |
|
2641 |
||
21939 | 2642 |
g_debug ("Active device: %s", device); |
16844 | 2643 |
|
2644 |
session = find_session_for_display_device (seat, device); |
|
2645 |
- change_active_session (seat, session); |
|
2646 |
+ |
|
2647 |
+ if (session == NULL) { |
|
2648 |
+ find_possible_session_to_activate (seat); |
|
2649 |
+ } else { |
|
2650 |
+ change_active_session (seat, session); |
|
2651 |
+ } |
|
2652 |
||
2653 |
g_free (device); |
|
2654 |
} |
|
21938 | 2655 |
@@ -547,12 +998,20 @@ maybe_update_active_session (CkSeat *sea |
17046 | 2656 |
{ |
2657 |
guint num; |
|
2658 |
||
2659 |
- if (seat->priv->kind != CK_SEAT_KIND_STATIC) { |
|
2660 |
- return; |
|
2661 |
- } |
|
21938 | 2662 |
+ g_debug ("CkSeat: Check to see if we should update active session"); |
2663 |
||
17046 | 2664 |
- if (ck_vt_monitor_get_active (seat->priv->vt_monitor, &num, NULL)) { |
2665 |
- update_active_vt (seat, num); |
|
2666 |
+ switch (seat->priv->kind){ |
|
2667 |
+ case CK_SEAT_KIND_STATIC: |
|
2668 |
+ if (ck_vt_monitor_get_active (seat->priv->vt_monitor, |
|
2669 |
+ &num, NULL)) { |
|
2670 |
+ update_active_vt (seat, num); |
|
2671 |
+ } |
|
2672 |
+ break; |
|
2673 |
+ case CK_SEAT_KIND_DYNAMIC: |
|
2674 |
+ find_possible_session_to_activate (seat); |
|
2675 |
+ break; |
|
2676 |
+ default: |
|
2677 |
+ break; |
|
2678 |
} |
|
2679 |
} |
|
2680 |
||
21938 | 2681 |
@@ -561,6 +1020,7 @@ session_activate (CkSession |
2682 |
DBusGMethodInvocation *context, |
|
2683 |
CkSeat *seat) |
|
2684 |
{ |
|
2685 |
+ g_debug ("CkSeat: Session activate."); |
|
2686 |
_seat_activate_session (seat, session, context); |
|
2687 |
||
2688 |
/* always return TRUE to indicate that the signal was handled */ |
|
2689 |
@@ -584,6 +1044,8 @@ ck_seat_remove_session (CkSeat * |
|
2690 |
ssid = NULL; |
|
2691 |
ck_session_get_id (session, &ssid, NULL); |
|
2692 |
||
2693 |
+ g_debug ("CkSeat: Removing session '%s'", ssid); |
|
2694 |
+ |
|
2695 |
/* Need to get the original key/value */ |
|
2696 |
res = g_hash_table_lookup_extended (seat->priv->sessions, |
|
2697 |
ssid, |
|
2698 |
@@ -628,18 +1090,81 @@ ck_seat_remove_session (CkSeat * |
|
16232 | 2699 |
return ret; |
2700 |
} |
|
2701 |
||
2702 |
+static void |
|
2703 |
+emit_session_close_request (CkSeat *seat, |
|
2704 |
+ const char *ssid) |
|
2705 |
+{ |
|
2706 |
+ DBusMessage *message; |
|
2707 |
+ DBusConnection *connection; |
|
2708 |
+ DBusMessageIter iter; |
|
2709 |
+ |
|
21938 | 2710 |
+ g_debug ("CkSeat: Emit Session Close request"); |
2711 |
+ |
|
16232 | 2712 |
+ message = dbus_message_new_signal (seat->priv->id, |
2713 |
+ "org.freedesktop.ConsoleKit.Seat", |
|
2714 |
+ "CloseSessionRequest"); |
|
2715 |
+ |
|
2716 |
+ dbus_message_set_destination (message, |
|
2717 |
+ dbus_g_proxy_get_bus_name (seat->priv->manager_proxy)); |
|
2718 |
+ |
|
2719 |
+ dbus_message_iter_init_append (message, &iter); |
|
2720 |
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_OBJECT_PATH, &ssid); |
|
2721 |
+ |
|
2722 |
+ connection = dbus_bus_get (DBUS_BUS_SYSTEM, NULL); |
|
2723 |
+ dbus_connection_send (connection, message, NULL); |
|
2724 |
+ dbus_connection_unref (connection); |
|
2725 |
+ dbus_message_unref (message); |
|
16129 | 2726 |
+} |
2727 |
+ |
|
2728 |
+gboolean |
|
16232 | 2729 |
+ck_seat_request_close_session (CkSeat *seat, |
2730 |
+ CkSession *session, |
|
2731 |
+ GError **error) |
|
2732 |
+{ |
|
2733 |
+ char *ssid; |
|
2734 |
+ |
|
2735 |
+ g_return_val_if_fail (CK_IS_SEAT (seat), FALSE); |
|
2736 |
+ g_return_val_if_fail (CK_IS_SESSION (session), FALSE); |
|
2737 |
+ g_return_val_if_fail (ck_seat_is_managed (seat), FALSE); |
|
2738 |
+ |
|
21938 | 2739 |
+ g_debug ("CkSeat: Request close session."); |
16232 | 2740 |
+ ck_session_get_id (session, &ssid, NULL); |
2741 |
+ |
|
2742 |
+ emit_session_close_request (seat, ssid); |
|
2743 |
+ |
|
2744 |
+ g_free (ssid); |
|
2745 |
+ |
|
2746 |
+ return FALSE; |
|
2747 |
+} |
|
2748 |
+ |
|
2749 |
gboolean |
|
2750 |
ck_seat_add_session (CkSeat *seat, |
|
2751 |
CkSession *session, |
|
16475 | 2752 |
GError **error) |
2753 |
{ |
|
2754 |
char *ssid; |
|
2755 |
+ GHashTableIter iter; |
|
2756 |
+ gpointer key, value; |
|
2757 |
+ gboolean found; |
|
2758 |
||
2759 |
g_return_val_if_fail (CK_IS_SEAT (seat), FALSE); |
|
2760 |
||
21938 | 2761 |
+ g_debug ("CkSeat: Add session."); |
16475 | 2762 |
ck_session_get_id (session, &ssid, NULL); |
2763 |
||
2764 |
- g_hash_table_insert (seat->priv->sessions, g_strdup (ssid), g_object_ref (session)); |
|
2765 |
+ found = FALSE; |
|
2766 |
+ g_hash_table_iter_init (&iter, seat->priv->sessions); |
|
2767 |
+ while (g_hash_table_iter_next (&iter, &key, &value)) { |
|
2768 |
+ if (g_str_equal ((gchar *)key, ssid)) { |
|
2769 |
+ found = TRUE; |
|
2770 |
+ break; |
|
2771 |
+ } |
|
2772 |
+ } |
|
2773 |
+ |
|
2774 |
+ if (! found) |
|
2775 |
+ g_hash_table_insert (seat->priv->sessions, g_strdup (ssid), g_object_ref (session)); |
|
2776 |
+ else |
|
2777 |
+ g_object_ref (session); |
|
2778 |
||
2779 |
ck_session_set_seat_id (session, seat->priv->id, NULL); |
|
2780 |
||
21938 | 2781 |
@@ -656,6 +1181,10 @@ ck_seat_add_session (CkSeat *sea |
16232 | 2782 |
|
2783 |
maybe_update_active_session (seat); |
|
2784 |
||
2785 |
+ if (ck_seat_is_managed (seat)) { |
|
2786 |
+ ck_seat_request_open_session (seat, session, NULL); |
|
2787 |
+ } |
|
2788 |
+ |
|
2789 |
g_free (ssid); |
|
2790 |
||
2791 |
return TRUE; |
|
21938 | 2792 |
@@ -742,6 +1271,20 @@ ck_seat_get_kind (CkSeat *seat, |
16232 | 2793 |
} |
2794 |
||
2795 |
gboolean |
|
2796 |
+ck_seat_get_type_string (CkSeat *seat, |
|
2797 |
+ char **type, |
|
2798 |
+ GError **error) |
|
16129 | 2799 |
+{ |
2800 |
+ g_return_val_if_fail (CK_IS_SEAT (seat), FALSE); |
|
2801 |
+ |
|
16232 | 2802 |
+ if (type != NULL) { |
2803 |
+ *type = g_strdup (seat->priv->type); |
|
2804 |
+ } |
|
2805 |
+ |
|
2806 |
+ return TRUE; |
|
16129 | 2807 |
+} |
2808 |
+ |
|
16232 | 2809 |
+gboolean |
2810 |
ck_seat_get_id (CkSeat *seat, |
|
2811 |
char **id, |
|
2812 |
GError **error) |
|
21938 | 2813 |
@@ -771,6 +1314,7 @@ ck_seat_register (CkSeat *seat) |
2814 |
GError *error = NULL; |
|
2815 |
||
2816 |
error = NULL; |
|
2817 |
+ g_debug ("CkSeat: Register seat."); |
|
2818 |
seat->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); |
|
2819 |
if (seat->priv->connection == NULL) { |
|
2820 |
if (error != NULL) { |
|
2821 |
@@ -858,6 +1402,14 @@ _ck_seat_set_kind (CkSeat *seat, |
|
16232 | 2822 |
} |
2823 |
||
2824 |
static void |
|
2825 |
+_ck_seat_set_type_string (CkSeat *seat, |
|
2826 |
+ const char *type) |
|
2827 |
+{ |
|
2828 |
+ g_free (seat->priv->type); |
|
2829 |
+ seat->priv->type = g_strdup (type); |
|
2830 |
+} |
|
2831 |
+ |
|
2832 |
+static void |
|
2833 |
ck_seat_set_property (GObject *object, |
|
2834 |
guint prop_id, |
|
2835 |
const GValue *value, |
|
21938 | 2836 |
@@ -874,6 +1426,9 @@ ck_seat_set_property (GObject |
16232 | 2837 |
case PROP_KIND: |
2838 |
_ck_seat_set_kind (self, g_value_get_enum (value)); |
|
2839 |
break; |
|
2840 |
+ case PROP_TYPE: |
|
2841 |
+ _ck_seat_set_type_string (self, g_value_get_string (value)); |
|
2842 |
+ break; |
|
2843 |
default: |
|
2844 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
|
2845 |
break; |
|
21938 | 2846 |
@@ -895,7 +1450,10 @@ ck_seat_get_property (GObject *object |
16129 | 2847 |
g_value_set_string (value, self->priv->id); |
2848 |
break; |
|
2849 |
case PROP_KIND: |
|
2850 |
- g_value_set_string (value, self->priv->id); |
|
2851 |
+ g_value_set_enum (value, self->priv->kind); |
|
16232 | 2852 |
+ break; |
2853 |
+ case PROP_TYPE: |
|
2854 |
+ g_value_set_string (value, self->priv->type); |
|
16129 | 2855 |
break; |
2856 |
default: |
|
2857 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
|
21938 | 2858 |
@@ -1008,6 +1566,43 @@ ck_seat_class_init (CkSeatClass *klass) |
16129 | 2859 |
G_TYPE_NONE, |
2860 |
1, CK_TYPE_DEVICE); |
|
2861 |
||
16232 | 2862 |
+ signals [REMOVE_REQUEST] = g_signal_new ("remove-request", |
2863 |
+ G_TYPE_FROM_CLASS (object_class), |
|
2864 |
+ G_SIGNAL_RUN_LAST, |
|
2865 |
+ G_STRUCT_OFFSET (CkSeatClass, remove_request), |
|
2866 |
+ NULL, |
|
2867 |
+ NULL, |
|
2868 |
+ g_cclosure_marshal_VOID__VOID, |
|
2869 |
+ G_TYPE_NONE, 0); |
|
16129 | 2870 |
+ |
21493 | 2871 |
+ signals [OPEN_SESSION_REQUEST] = g_signal_new ("open-session-request", |
2872 |
+ G_TYPE_FROM_CLASS (object_class), |
|
2873 |
+ G_SIGNAL_RUN_LAST, |
|
2874 |
+ 0, |
|
2875 |
+ NULL, |
|
2876 |
+ NULL, |
|
2877 |
+ ck_marshal_VOID__STRING_STRING_STRING_POINTER_STRING_POINTER, |
|
2878 |
+ G_TYPE_NONE, |
|
2879 |
+ 6, |
|
2880 |
+ DBUS_TYPE_G_OBJECT_PATH, |
|
2881 |
+ G_TYPE_STRING, |
|
2882 |
+ G_TYPE_STRING, |
|
2883 |
+ CK_DBUS_TYPE_G_STRING_STRING_HASHTABLE, |
|
2884 |
+ G_TYPE_STRING, |
|
2885 |
+ CK_DBUS_TYPE_G_STRING_STRING_HASHTABLE, |
|
2886 |
+ G_TYPE_INVALID); |
|
2887 |
+ |
|
2888 |
+ |
|
2889 |
+ signals [CLOSE_SESSION_REQUEST] = g_signal_new ("close-session-request", |
|
2890 |
+ G_TYPE_FROM_CLASS (object_class), |
|
2891 |
+ G_SIGNAL_RUN_LAST, |
|
2892 |
+ 0, |
|
2893 |
+ NULL, |
|
2894 |
+ NULL, |
|
2895 |
+ g_cclosure_marshal_VOID__VOID, |
|
2896 |
+ G_TYPE_NONE, |
|
2897 |
+ 1, DBUS_TYPE_G_OBJECT_PATH); |
|
2898 |
+ |
|
16129 | 2899 |
g_object_class_install_property (object_class, |
2900 |
PROP_ID, |
|
2901 |
g_param_spec_string ("id", |
|
21938 | 2902 |
@@ -1024,6 +1619,13 @@ ck_seat_class_init (CkSeatClass *klass) |
16232 | 2903 |
CK_SEAT_KIND_DYNAMIC, |
2904 |
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); |
|
2905 |
||
2906 |
+ g_object_class_install_property (object_class, |
|
2907 |
+ PROP_TYPE, |
|
2908 |
+ g_param_spec_string ("type", |
|
2909 |
+ "type", |
|
2910 |
+ "type", |
|
2911 |
+ NULL, |
|
2912 |
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); |
|
2913 |
g_type_class_add_private (klass, sizeof (CkSeatPrivate)); |
|
2914 |
||
2915 |
dbus_g_object_type_install_info (CK_TYPE_SEAT, &dbus_glib_ck_seat_object_info); |
|
21938 | 2916 |
@@ -1039,6 +1641,7 @@ ck_seat_init (CkSeat *seat) |
16129 | 2917 |
g_free, |
2918 |
(GDestroyNotify) g_object_unref); |
|
2919 |
seat->priv->devices = g_ptr_array_new (); |
|
16232 | 2920 |
+ seat->priv->manager_proxy = NULL; |
16129 | 2921 |
} |
2922 |
||
2923 |
static void |
|
21938 | 2924 |
@@ -1064,28 +1667,32 @@ ck_seat_finalize (GObject *object) |
16129 | 2925 |
g_ptr_array_free (seat->priv->devices, TRUE); |
2926 |
g_hash_table_destroy (seat->priv->sessions); |
|
2927 |
g_free (seat->priv->id); |
|
16232 | 2928 |
+ g_free (seat->priv->type); |
16129 | 2929 |
|
2930 |
G_OBJECT_CLASS (ck_seat_parent_class)->finalize (object); |
|
2931 |
} |
|
16232 | 2932 |
|
2933 |
CkSeat * |
|
2934 |
ck_seat_new (const char *sid, |
|
2935 |
- CkSeatKind kind) |
|
2936 |
+ CkSeatKind kind, |
|
2937 |
+ const char *type) |
|
2938 |
{ |
|
2939 |
GObject *object; |
|
16647 | 2940 |
|
16232 | 2941 |
object = g_object_new (CK_TYPE_SEAT, |
2942 |
"id", sid, |
|
2943 |
"kind", kind, |
|
2944 |
+ "type", type, |
|
2945 |
NULL); |
|
2946 |
||
16647 | 2947 |
return CK_SEAT (object); |
16232 | 2948 |
} |
2949 |
||
2950 |
CkSeat * |
|
2951 |
-ck_seat_new_with_devices (const char *sid, |
|
2952 |
- CkSeatKind kind, |
|
2953 |
- GPtrArray *devices) |
|
2954 |
+ck_seat_new_with_devices_and_sessions (const char *sid, |
|
2955 |
+ CkSeatKind kind, |
|
2956 |
+ GPtrArray *devices, |
|
2957 |
+ GPtrArray *sessions) |
|
2958 |
{ |
|
2959 |
GObject *object; |
|
16647 | 2960 |
int i; |
21938 | 2961 |
@@ -1100,27 +1707,62 @@ ck_seat_new_with_devices (const char *si |
16647 | 2962 |
ck_seat_add_device (CK_SEAT (object), g_ptr_array_index (devices, i), NULL); |
16232 | 2963 |
} |
2964 |
} |
|
2965 |
+ if (sessions != NULL) { |
|
2966 |
+ for (i = 0; i < sessions->len; i++) { |
|
2967 |
+ ck_seat_add_session (CK_SEAT (object), g_ptr_array_index (sessions, i), NULL); |
|
2968 |
+ } |
|
2969 |
+ } |
|
2970 |
+ |
|
16647 | 2971 |
|
16129 | 2972 |
return CK_SEAT (object); |
2973 |
} |
|
2974 |
||
2975 |
+static char * |
|
16232 | 2976 |
+generate_static_session_id (const char *sid, |
2977 |
+ const char *session_name) |
|
16129 | 2978 |
+{ |
16232 | 2979 |
+ const char *seat_name; |
2980 |
+ char *ssid; |
|
2981 |
+ |
|
2982 |
+ seat_name = strrchr (sid, '/'); |
|
2983 |
+ |
|
2984 |
+ if (seat_name == NULL) { |
|
2985 |
+ g_warning ("Seat id '%s' lacks a /", sid); |
|
2986 |
+ seat_name = sid; |
|
2987 |
+ } else { |
|
2988 |
+ seat_name++; |
|
2989 |
+ } |
|
2990 |
+ |
|
2991 |
+ ssid = g_strdup_printf ("%s/Session%s%s", |
|
2992 |
+ CK_DBUS_PATH, seat_name, |
|
2993 |
+ session_name); |
|
2994 |
+ |
|
2995 |
+ return ssid; |
|
16129 | 2996 |
+} |
2997 |
+ |
|
2998 |
CkSeat * |
|
16647 | 2999 |
-ck_seat_new_from_file (const char *sid, |
3000 |
+ck_seat_new_from_file (char **sid, |
|
16129 | 3001 |
const char *path) |
3002 |
{ |
|
3003 |
- GKeyFile *key_file; |
|
3004 |
- gboolean res; |
|
3005 |
- GError *error; |
|
3006 |
- char *group; |
|
3007 |
- CkSeat *seat; |
|
3008 |
- gboolean hidden; |
|
3009 |
- GPtrArray *devices; |
|
3010 |
- char **device_list; |
|
3011 |
- gsize ndevices; |
|
3012 |
- gsize i; |
|
3013 |
+ GKeyFile *key_file; |
|
3014 |
+ gboolean res; |
|
3015 |
+ GError *error; |
|
3016 |
+ char *group; |
|
3017 |
+ CkSeat *seat; |
|
16647 | 3018 |
+ char *read_sid; |
16129 | 3019 |
+ gboolean hidden; |
16232 | 3020 |
+ GPtrArray *sessions; |
3021 |
+ char **session_list; |
|
3022 |
+ gsize nsessions; |
|
16129 | 3023 |
+ GPtrArray *devices; |
3024 |
+ char **device_list; |
|
3025 |
+ gsize ndevices; |
|
3026 |
+ gsize i; |
|
3027 |
||
16647 | 3028 |
seat = NULL; |
3029 |
||
21938 | 3030 |
+ g_debug ("CkSeat: New seat from file."); |
3031 |
+ |
|
3032 |
key_file = g_key_file_new (); |
|
3033 |
error = NULL; |
|
3034 |
res = g_key_file_load_from_file (key_file, |
|
3035 |
@@ -1145,9 +1787,52 @@ ck_seat_new_from_file (const char *sid, |
|
16647 | 3036 |
goto out; |
16129 | 3037 |
} |
3038 |
||
16647 | 3039 |
+ read_sid = g_key_file_get_string (key_file, group, "ID", NULL); |
3040 |
+ if (IS_STR_SET (read_sid)) { |
|
3041 |
+ g_free (*sid); |
|
3042 |
+ *sid = g_strdup_printf ("%s/%s", CK_DBUS_PATH, read_sid); |
|
3043 |
+ } else { |
|
3044 |
+ g_free (read_sid); |
|
3045 |
+ } |
|
3046 |
+ |
|
16232 | 3047 |
+ session_list = g_key_file_get_string_list (key_file, group, "Sessions", &nsessions, NULL); |
3048 |
+ |
|
3049 |
+ sessions = g_ptr_array_sized_new (nsessions); |
|
3050 |
+ |
|
3051 |
+ for (i = 0; i < nsessions; i++) { |
|
3052 |
+ char *path; |
|
3053 |
+ char *file; |
|
3054 |
+ char *ssid; |
|
3055 |
+ CkSession *session; |
|
3056 |
+ |
|
3057 |
+ file = g_strconcat (session_list[i], ".session", NULL); |
|
3058 |
+ path = g_build_filename (CK_SESSION_DIR, file, NULL); |
|
3059 |
+ g_free (file); |
|
3060 |
+ |
|
3061 |
+ /* FIXME: we should probably use the same naming pool as |
|
3062 |
+ * sessions generated from ck-manager. We mangle the name |
|
3063 |
+ * here so we don't clash with names from ck-manager |
|
3064 |
+ */ |
|
16647 | 3065 |
+ ssid = generate_static_session_id (*sid, session_list[i]); |
16232 | 3066 |
+ |
3067 |
+ session = ck_session_new_from_file (ssid, path); |
|
3068 |
+ |
|
3069 |
+ if (session == NULL) { |
|
3070 |
+ g_warning ("Unable to load session from file %s", path); |
|
3071 |
+ g_free (path); |
|
3072 |
+ continue; |
|
3073 |
+ } |
|
3074 |
+ g_free (path); |
|
16647 | 3075 |
+ ck_session_set_seat_id (session, *sid, NULL); |
16232 | 3076 |
+ |
3077 |
+ g_ptr_array_add (sessions, session); |
|
16129 | 3078 |
+ } |
3079 |
+ |
|
16232 | 3080 |
+ g_strfreev (session_list); |
16129 | 3081 |
+ |
3082 |
device_list = g_key_file_get_string_list (key_file, group, "Devices", &ndevices, NULL); |
|
3083 |
||
21939 | 3084 |
- g_debug ("Creating seat %s with %zd devices", sid, ndevices); |
21938 | 3085 |
+ g_debug ("CkSeat: Creating seat %s with %zd devices", *sid, ndevices); |
21751 | 3086 |
|
3087 |
devices = g_ptr_array_sized_new (ndevices); |
|
3088 |
||
21938 | 3089 |
@@ -1176,11 +1861,12 @@ ck_seat_new_from_file (const char *sid, |
16129 | 3090 |
g_strfreev (split); |
3091 |
} |
|
16647 | 3092 |
g_strfreev (device_list); |
16129 | 3093 |
- g_free (group); |
16647 | 3094 |
|
16232 | 3095 |
- seat = ck_seat_new_with_devices (sid, CK_SEAT_KIND_STATIC, devices); |
16647 | 3096 |
+ seat = ck_seat_new_with_devices_and_sessions (*sid, CK_SEAT_KIND_STATIC, devices, sessions); |
16129 | 3097 |
g_ptr_array_free (devices, TRUE); |
3098 |
||
3099 |
+ g_free (group); |
|
3100 |
+ |
|
16647 | 3101 |
out: |
16129 | 3102 |
|
16647 | 3103 |
g_key_file_free (key_file); |
21938 | 3104 |
@@ -1348,10 +2034,15 @@ ck_seat_dump (CkSeat *seat, |
17046 | 3105 |
|
3106 |
error = NULL; |
|
3107 |
if (! ck_session_get_id (seat->priv->active_session, &session_id, &error)) { |
|
3108 |
- g_warning ("Cannot get session id for active session on seat %s: %s", |
|
3109 |
- seat->priv->id, |
|
3110 |
- error->message); |
|
3111 |
- g_error_free (error); |
|
3112 |
+ if (error) { |
|
3113 |
+ g_warning ("Cannot get session id for active session on seat %s: %s", |
|
3114 |
+ seat->priv->id, |
|
3115 |
+ error->message); |
|
3116 |
+ g_error_free (error); |
|
3117 |
+ } else { |
|
3118 |
+ g_warning ("Cannot get session id for active session on seat %s", |
|
3119 |
+ seat->priv->id); |
|
3120 |
+ } |
|
3121 |
} else { |
|
3122 |
g_key_file_set_string (key_file, |
|
3123 |
group_name, |
|
21938 | 3124 |
@@ -1363,3 +2054,24 @@ ck_seat_dump (CkSeat *seat, |
16647 | 3125 |
|
16232 | 3126 |
g_free (group_name); |
3127 |
} |
|
16647 | 3128 |
+ |
16232 | 3129 |
+gboolean |
3130 |
+ck_seat_is_managed (CkSeat *seat) |
|
3131 |
+{ |
|
3132 |
+ return seat->priv->manager_proxy != NULL; |
|
3133 |
+} |
|
3134 |
+ |
|
3135 |
+CkSession * |
|
3136 |
+ck_seat_get_session (CkSeat *seat, |
|
3137 |
+ const char *ssid) |
|
3138 |
+{ |
|
3139 |
+ CkSession *session; |
|
3140 |
+ |
|
3141 |
+ session = g_hash_table_lookup (seat->priv->sessions, ssid); |
|
3142 |
+ |
|
3143 |
+ if (session == NULL) { |
|
3144 |
+ return NULL; |
|
3145 |
+ } |
|
3146 |
+ |
|
3147 |
+ return g_object_ref (session); |
|
3148 |
+} |
|
16129 | 3149 |
diff --git a/src/ck-seat.h b/src/ck-seat.h |
16647 | 3150 |
index fb9a955..6276021 100644 |
16129 | 3151 |
--- a/src/ck-seat.h |
3152 |
+++ b/src/ck-seat.h |
|
16232 | 3153 |
@@ -47,6 +47,7 @@ typedef struct |
3154 |
{ |
|
3155 |
GObjectClass parent_class; |
|
3156 |
||
3157 |
+ void (* remove_request) (CkSeat *seat); |
|
3158 |
void (* active_session_changed) (CkSeat *seat, |
|
3159 |
const char *ssid); |
|
3160 |
void (* session_added) (CkSeat *seat, |
|
3161 |
@@ -57,6 +58,11 @@ typedef struct |
|
16129 | 3162 |
GValueArray *device); |
3163 |
void (* device_removed) (CkSeat *seat, |
|
3164 |
GValueArray *device); |
|
3165 |
+ void (* session_to_add) (CkSeat *seat, |
|
3166 |
+ gboolean is_dynamic, |
|
3167 |
+ const char *command); |
|
3168 |
+ void (* session_to_remove) (CkSeat *seat, |
|
3169 |
+ int display_number); |
|
3170 |
} CkSeatClass; |
|
3171 |
||
3172 |
typedef enum |
|
16232 | 3173 |
@@ -84,12 +90,14 @@ typedef enum |
3174 |
GQuark ck_seat_error_quark (void); |
|
3175 |
GType ck_seat_get_type (void); |
|
3176 |
CkSeat * ck_seat_new (const char *sid, |
|
3177 |
- CkSeatKind kind); |
|
16647 | 3178 |
-CkSeat * ck_seat_new_from_file (const char *sid, |
3179 |
- const char *path); |
|
3180 |
-CkSeat * ck_seat_new_with_devices (const char *sid, |
|
3181 |
CkSeatKind kind, |
|
3182 |
- GPtrArray *devices); |
|
16232 | 3183 |
+ const char *type); |
16647 | 3184 |
+CkSeat * ck_seat_new_from_file (char **sid, |
3185 |
+ const char *path); |
|
16232 | 3186 |
+CkSeat * ck_seat_new_with_devices_and_sessions (const char *sid, |
3187 |
+ CkSeatKind kind, |
|
3188 |
+ GPtrArray *devices, |
|
3189 |
+ GPtrArray *sessions); |
|
3190 |
||
16647 | 3191 |
gboolean ck_seat_register (CkSeat *seat); |
3192 |
||
3193 |
@@ -104,18 +112,31 @@ void ck_seat_dump (CkSeat *seat, |
|
16232 | 3194 |
gboolean ck_seat_get_kind (CkSeat *seat, |
3195 |
CkSeatKind *kind, |
|
3196 |
GError **error); |
|
3197 |
+gboolean ck_seat_get_type_string (CkSeat *seat, |
|
3198 |
+ char **type, |
|
3199 |
+ GError **error); |
|
3200 |
gboolean ck_seat_add_session (CkSeat *seat, |
|
3201 |
CkSession *session, |
|
3202 |
GError **error); |
|
3203 |
gboolean ck_seat_remove_session (CkSeat *seat, |
|
3204 |
CkSession *session, |
|
3205 |
GError **error); |
|
3206 |
+gboolean ck_seat_request_open_session (CkSeat *seat, |
|
3207 |
+ CkSession *session, |
|
3208 |
+ GError **error); |
|
3209 |
+gboolean ck_seat_request_close_session (CkSeat *seat, |
|
3210 |
+ CkSession *session, |
|
3211 |
+ GError **error); |
|
16647 | 3212 |
gboolean ck_seat_add_device (CkSeat *seat, |
3213 |
GValueArray *device, |
|
16232 | 3214 |
GError **error); |
3215 |
gboolean ck_seat_remove_device (CkSeat *seat, |
|
3216 |
GValueArray *device, |
|
3217 |
GError **error); |
|
3218 |
+gboolean ck_seat_is_managed (CkSeat *seat); |
|
3219 |
+CkSession *ck_seat_get_session (CkSeat *seat, |
|
3220 |
+ const char *ssid); |
|
3221 |
+void ck_seat_request_removal (CkSeat *seat); |
|
3222 |
||
3223 |
/* exported methods */ |
|
3224 |
gboolean ck_seat_get_id (CkSeat *seat, |
|
16647 | 3225 |
@@ -137,6 +158,10 @@ gboolean ck_seat_can_activate_sessions (CkSeat *seat, |
16129 | 3226 |
gboolean ck_seat_activate_session (CkSeat *seat, |
3227 |
const char *ssid, |
|
3228 |
DBusGMethodInvocation *context); |
|
16232 | 3229 |
+gboolean ck_seat_manage (CkSeat *seat, |
16129 | 3230 |
+ DBusGMethodInvocation *context); |
16232 | 3231 |
+gboolean ck_seat_unmanage (CkSeat *seat, |
3232 |
+ DBusGMethodInvocation *context); |
|
16129 | 3233 |
|
3234 |
G_END_DECLS |
|
3235 |
||
16540 | 3236 |
diff --git a/src/ck-session-leader.c b/src/ck-session-leader.c |
16647 | 3237 |
index 3702602..908d2bb 100644 |
16540 | 3238 |
--- a/src/ck-session-leader.c |
3239 |
+++ b/src/ck-session-leader.c |
|
3240 |
@@ -238,6 +238,7 @@ static struct { |
|
3241 |
{ "x11-display", add_param_string }, |
|
3242 |
{ "remote-host-name", add_param_string }, |
|
3243 |
{ "session-type", add_param_string }, |
|
3244 |
+ { "display-type", add_param_string }, |
|
3245 |
{ "is-local", add_param_boolean }, |
|
3246 |
{ "unix-user", add_param_int }, |
|
3247 |
}; |
|
16129 | 3248 |
diff --git a/src/ck-session.c b/src/ck-session.c |
17862 | 3249 |
index d8db9dd..0354dd5 100644 |
16129 | 3250 |
--- a/src/ck-session.c |
3251 |
+++ b/src/ck-session.c |
|
16232 | 3252 |
@@ -41,6 +41,7 @@ |
3253 |
#include "ck-session-glue.h" |
|
3254 |
#include "ck-marshal.h" |
|
3255 |
#include "ck-run-programs.h" |
|
3256 |
+#include "ck-display-template.h" |
|
3257 |
||
3258 |
#define CK_SESSION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CK_TYPE_SESSION, CkSessionPrivate)) |
|
16129 | 3259 |
|
16540 | 3260 |
@@ -58,6 +59,7 @@ struct CkSessionPrivate |
3261 |
char *seat_id; |
|
3262 |
||
3263 |
char *session_type; |
|
3264 |
+ char *display_type; |
|
3265 |
char *login_session_id; |
|
3266 |
char *display_device; |
|
3267 |
char *x11_display_device; |
|
17003 | 3268 |
@@ -65,8 +67,15 @@ struct CkSessionPrivate |
16232 | 3269 |
char *remote_host_name; |
3270 |
guint uid; |
|
3271 |
||
3272 |
+ CkDisplayTemplate *display_template; |
|
3273 |
+ GHashTable *display_variables; |
|
3274 |
+ |
|
16129 | 3275 |
gboolean active; |
3276 |
gboolean is_local; |
|
16232 | 3277 |
+ gboolean is_open; |
16844 | 3278 |
+ gboolean ever_open; |
3279 |
+ gboolean under_request; |
|
17003 | 3280 |
+ GMutex *mutex_under_request; |
16129 | 3281 |
|
3282 |
GTimeVal creation_time; |
|
3283 |
||
17003 | 3284 |
@@ -75,6 +84,8 @@ struct CkSessionPrivate |
16475 | 3285 |
gboolean idle_hint; |
3286 |
GTimeVal idle_since_hint; |
|
3287 |
||
3288 |
+ gboolean remove_on_close; |
|
3289 |
+ |
|
3290 |
DBusGConnection *connection; |
|
3291 |
DBusGProxy *bus_proxy; |
|
3292 |
}; |
|
17003 | 3293 |
@@ -92,17 +103,24 @@ enum { |
16129 | 3294 |
PROP_0, |
3295 |
PROP_ID, |
|
3296 |
PROP_COOKIE, |
|
3297 |
+ PROP_SEAT_ID, |
|
3298 |
PROP_USER, |
|
3299 |
PROP_UNIX_USER, |
|
3300 |
PROP_X11_DISPLAY, |
|
16232 | 3301 |
PROP_X11_DISPLAY_DEVICE, |
3302 |
PROP_DISPLAY_DEVICE, |
|
3303 |
PROP_SESSION_TYPE, |
|
16540 | 3304 |
+ PROP_DISPLAY_TYPE, |
16232 | 3305 |
+ PROP_DISPLAY_TEMPLATE, |
3306 |
+ PROP_DISPLAY_VARIABLES, |
|
16129 | 3307 |
PROP_REMOTE_HOST_NAME, |
3308 |
PROP_LOGIN_SESSION_ID, |
|
3309 |
PROP_IS_LOCAL, |
|
16232 | 3310 |
+ PROP_IS_OPEN, |
16844 | 3311 |
+ PROP_EVER_OPEN, |
16129 | 3312 |
PROP_ACTIVE, |
3313 |
PROP_IDLE_HINT, |
|
16475 | 3314 |
+ PROP_REMOVE_ON_CLOSE, |
16129 | 3315 |
}; |
16475 | 3316 |
|
3317 |
static guint signals [LAST_SIGNAL] = { 0, }; |
|
21938 | 3318 |
@@ -128,7 +146,9 @@ static gboolean |
16232 | 3319 |
register_session (CkSession *session) |
3320 |
{ |
|
3321 |
GError *error = NULL; |
|
3322 |
+ GObject *existing_session; |
|
3323 |
||
21938 | 3324 |
+ g_debug ("CkSession: Register session."); |
16232 | 3325 |
error = NULL; |
3326 |
session->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); |
|
21938 | 3327 |
if (session->priv->connection == NULL) { |
3328 |
@@ -144,6 +164,15 @@ register_session (CkSession *session) |
|
16232 | 3329 |
DBUS_PATH_DBUS, |
3330 |
DBUS_INTERFACE_DBUS); |
|
3331 |
||
3332 |
+ existing_session = dbus_g_connection_lookup_g_object (session->priv->connection, |
|
3333 |
+ session->priv->id); |
|
3334 |
+ |
|
3335 |
+ if (existing_session != NULL) { |
|
3336 |
+ g_warning ("Session '%s' was registered twice!", |
|
3337 |
+ session->priv->id); |
|
3338 |
+ return FALSE; |
|
3339 |
+ } |
|
3340 |
+ |
|
3341 |
dbus_g_connection_register_g_object (session->priv->connection, session->priv->id, G_OBJECT (session)); |
|
3342 |
||
3343 |
return TRUE; |
|
21938 | 3344 |
@@ -302,6 +331,40 @@ ck_session_set_idle_hint (CkSession |
16475 | 3345 |
} |
3346 |
||
3347 |
gboolean |
|
3348 |
+session_set_remove_on_close (CkSession *session, |
|
3349 |
+ gboolean remove_on_close, |
|
3350 |
+ GError **error) |
|
3351 |
+{ |
|
3352 |
+ g_return_val_if_fail (CK_IS_SESSION (session), FALSE); |
|
3353 |
+ |
|
3354 |
+ if (session->priv->remove_on_close != remove_on_close) { |
|
3355 |
+ session->priv->remove_on_close = remove_on_close; |
|
3356 |
+ } |
|
3357 |
+ |
|
21938 | 3358 |
+ if (session->priv->remove_on_close == TRUE) |
3359 |
+ g_debug ("CkSession: Setting remove on close to true."); |
|
3360 |
+ else |
|
3361 |
+ g_debug ("CkSession: Setting remove on close to false."); |
|
3362 |
+ |
|
16475 | 3363 |
+ return TRUE; |
3364 |
+} |
|
3365 |
+ |
|
3366 |
+/* |
|
3367 |
+ Example: |
|
3368 |
+ dbus-send --system --dest=org.freedesktop.ConsoleKit \ |
|
3369 |
+ --type=method_call --print-reply --reply-timeout=2000 \ |
|
3370 |
+ /org/freedesktop/ConsoleKit/Session1 \ |
|
3371 |
+ org.freedesktop.ConsoleKit.Session.SetRemoveOnClose boolean:TRUE |
|
3372 |
+*/ |
|
3373 |
+gboolean |
|
3374 |
+ck_session_set_remove_on_close (CkSession *session, |
|
3375 |
+ gboolean remove_on_close, |
|
3376 |
+ DBusGMethodInvocation *context) |
|
3377 |
+{ |
|
3378 |
+ return session_set_remove_on_close (session, remove_on_close, NULL); |
|
3379 |
+} |
|
3380 |
+ |
|
3381 |
+gboolean |
|
3382 |
ck_session_get_idle_hint (CkSession *session, |
|
3383 |
gboolean *idle_hint, |
|
3384 |
GError **error) |
|
21938 | 3385 |
@@ -367,6 +430,7 @@ ck_session_activate (CkSession |
3386 |
{ |
|
3387 |
gboolean res; |
|
3388 |
||
3389 |
+ g_debug ("CkSession: Session activate."); |
|
3390 |
g_return_val_if_fail (CK_IS_SESSION (session), FALSE); |
|
3391 |
||
3392 |
res = FALSE; |
|
3393 |
@@ -397,6 +461,8 @@ ck_session_set_active (CkSession *s |
|
3394 |
{ |
|
3395 |
g_return_val_if_fail (CK_IS_SESSION (session), FALSE); |
|
3396 |
||
3397 |
+ g_debug ("CkSession: Session set active."); |
|
3398 |
+ |
|
3399 |
if (session->priv->active != active) { |
|
3400 |
session->priv->active = active; |
|
3401 |
g_signal_emit (session, signals [ACTIVE_CHANGED], 0, active); |
|
3402 |
@@ -420,6 +486,68 @@ ck_session_set_is_local (CkSession |
|
16129 | 3403 |
} |
3404 |
||
3405 |
gboolean |
|
16232 | 3406 |
+ck_session_set_is_open (CkSession *session, |
3407 |
+ gboolean is_open, |
|
3408 |
+ GError **error) |
|
3409 |
+{ |
|
3410 |
+ g_return_val_if_fail (CK_IS_SESSION (session), FALSE); |
|
3411 |
+ |
|
3412 |
+ if (session->priv->is_open != is_open) { |
|
3413 |
+ session->priv->is_open = is_open; |
|
16844 | 3414 |
+ session->priv->ever_open = TRUE; |
3415 |
+ } |
|
3416 |
+ |
|
3417 |
+ return TRUE; |
|
3418 |
+} |
|
3419 |
+ |
|
3420 |
+gboolean |
|
3421 |
+ck_session_set_ever_open (CkSession *session, |
|
3422 |
+ gboolean ever_open, |
|
3423 |
+ GError **error) |
|
3424 |
+{ |
|
3425 |
+ g_return_val_if_fail (CK_IS_SESSION (session), FALSE); |
|
3426 |
+ |
|
3427 |
+ if (session->priv->ever_open != ever_open) { |
|
3428 |
+ session->priv->ever_open = ever_open; |
|
3429 |
+ } |
|
3430 |
+ |
|
3431 |
+ return TRUE; |
|
3432 |
+} |
|
3433 |
+ |
|
3434 |
+static gboolean |
|
3435 |
+timeout_for_under_request (gpointer data) |
|
3436 |
+{ |
|
3437 |
+ CkSession *session = CK_SESSION (data); |
|
17003 | 3438 |
+ g_mutex_lock (session->priv->mutex_under_request); |
16844 | 3439 |
+ session->priv->under_request = FALSE; |
17003 | 3440 |
+ g_mutex_unlock (session->priv->mutex_under_request); |
16844 | 3441 |
+ |
21938 | 3442 |
+ g_debug ("CkSession: timeout for under request of session %s", session->priv->id); |
16844 | 3443 |
+ return FALSE; |
3444 |
+} |
|
3445 |
+ |
|
3446 |
+gboolean |
|
3447 |
+ck_session_set_under_request (CkSession *session, |
|
3448 |
+ gboolean under_request, |
|
3449 |
+ GError **error) |
|
3450 |
+{ |
|
3451 |
+ g_return_val_if_fail (CK_IS_SESSION (session), FALSE); |
|
3452 |
+ |
|
17003 | 3453 |
+ g_mutex_lock (session->priv->mutex_under_request); |
16844 | 3454 |
+ if (!under_request) { |
3455 |
+ session->priv->under_request = FALSE; |
|
3456 |
+ } else { |
|
3457 |
+ if (!session->priv->under_request) { |
|
3458 |
+ session->priv->under_request = TRUE; |
|
3459 |
+ g_timeout_add_seconds (1, timeout_for_under_request, session); |
|
3460 |
+ } |
|
16232 | 3461 |
+ } |
17003 | 3462 |
+ g_mutex_unlock (session->priv->mutex_under_request); |
16232 | 3463 |
+ |
3464 |
+ return TRUE; |
|
3465 |
+} |
|
3466 |
+ |
|
3467 |
+gboolean |
|
16129 | 3468 |
ck_session_get_id (CkSession *session, |
3469 |
char **id, |
|
3470 |
GError **error) |
|
21938 | 3471 |
@@ -555,6 +683,20 @@ ck_session_get_creation_time (CkSession |
16475 | 3472 |
} |
3473 |
||
3474 |
gboolean |
|
3475 |
+ck_session_get_remove_on_close (CkSession *session, |
|
3476 |
+ gboolean *remove_on_close, |
|
3477 |
+ GError **error) |
|
3478 |
+{ |
|
3479 |
+ g_return_val_if_fail (CK_IS_SESSION (session), FALSE); |
|
3480 |
+ |
|
3481 |
+ if (remove_on_close != NULL) { |
|
3482 |
+ *remove_on_close = session->priv->remove_on_close; |
|
3483 |
+ } |
|
3484 |
+ |
|
3485 |
+ return TRUE; |
|
3486 |
+} |
|
3487 |
+ |
|
3488 |
+gboolean |
|
3489 |
ck_session_get_session_type (CkSession *session, |
|
3490 |
char **type, |
|
3491 |
GError **error) |
|
21938 | 3492 |
@@ -569,6 +711,20 @@ ck_session_get_session_type (CkSession |
16232 | 3493 |
} |
3494 |
||
3495 |
gboolean |
|
3496 |
+ck_session_get_display_type (CkSession *session, |
|
3497 |
+ char **type, |
|
3498 |
+ GError **error) |
|
3499 |
+{ |
|
3500 |
+ g_return_val_if_fail (CK_IS_SESSION (session), FALSE); |
|
3501 |
+ |
|
3502 |
+ if (type != NULL) { |
|
16540 | 3503 |
+ *type = g_strdup (session->priv->display_type); |
16232 | 3504 |
+ } |
3505 |
+ |
|
3506 |
+ return TRUE; |
|
3507 |
+} |
|
3508 |
+ |
|
3509 |
+gboolean |
|
3510 |
ck_session_is_active (CkSession *session, |
|
3511 |
gboolean *active, |
|
3512 |
GError **error) |
|
21938 | 3513 |
@@ -597,6 +753,50 @@ ck_session_is_local (CkSession *ses |
16129 | 3514 |
} |
3515 |
||
3516 |
gboolean |
|
16232 | 3517 |
+ck_session_is_open (CkSession *session, |
3518 |
+ gboolean *open, |
|
3519 |
+ GError **error) |
|
3520 |
+{ |
|
3521 |
+ g_return_val_if_fail (CK_IS_SESSION (session), FALSE); |
|
3522 |
+ |
|
3523 |
+ if (open != NULL) { |
|
3524 |
+ *open = session->priv->is_open; |
|
3525 |
+ } |
|
3526 |
+ |
|
3527 |
+ return TRUE; |
|
3528 |
+} |
|
3529 |
+ |
|
3530 |
+gboolean |
|
16844 | 3531 |
+ck_session_get_ever_open (CkSession *session, |
3532 |
+ gboolean *open, |
|
3533 |
+ GError **error) |
|
3534 |
+{ |
|
3535 |
+ g_return_val_if_fail (CK_IS_SESSION (session), FALSE); |
|
3536 |
+ |
|
3537 |
+ if (open != NULL) { |
|
3538 |
+ *open = session->priv->ever_open; |
|
3539 |
+ } |
|
3540 |
+ |
|
3541 |
+ return TRUE; |
|
3542 |
+} |
|
3543 |
+ |
|
3544 |
+gboolean |
|
3545 |
+ck_session_get_under_request (CkSession *session, |
|
3546 |
+ gboolean *under_request, |
|
3547 |
+ GError **error) |
|
3548 |
+{ |
|
3549 |
+ g_return_val_if_fail (CK_IS_SESSION (session), FALSE); |
|
3550 |
+ |
|
3551 |
+ if (under_request != NULL) { |
|
17003 | 3552 |
+ g_mutex_lock (session->priv->mutex_under_request); |
16844 | 3553 |
+ *under_request = session->priv->under_request; |
17003 | 3554 |
+ g_mutex_unlock (session->priv->mutex_under_request); |
16844 | 3555 |
+ } |
3556 |
+ |
|
3557 |
+ return TRUE; |
|
3558 |
+} |
|
3559 |
+ |
|
3560 |
+gboolean |
|
16129 | 3561 |
ck_session_set_id (CkSession *session, |
3562 |
const char *id, |
|
3563 |
GError **error) |
|
21938 | 3564 |
@@ -609,6 +809,21 @@ ck_session_set_id (CkSession *sessi |
16232 | 3565 |
return TRUE; |
3566 |
} |
|
3567 |
||
3568 |
+static void |
|
3569 |
+ck_session_set_display_variables (CkSession *session, |
|
3570 |
+ GHashTable *display_variables) |
|
3571 |
+{ |
|
3572 |
+ if (session->priv->display_variables != NULL) { |
|
3573 |
+ g_hash_table_unref (session->priv->display_variables); |
|
3574 |
+ } |
|
3575 |
+ |
|
3576 |
+ if (display_variables != NULL) { |
|
3577 |
+ session->priv->display_variables = g_hash_table_ref (display_variables); |
|
3578 |
+ } else { |
|
3579 |
+ session->priv->display_variables = NULL; |
|
3580 |
+ } |
|
3581 |
+} |
|
3582 |
+ |
|
3583 |
gboolean |
|
3584 |
ck_session_set_cookie (CkSession *session, |
|
3585 |
const char *cookie, |
|
21938 | 3586 |
@@ -725,6 +940,54 @@ ck_session_set_session_type (CkSession |
16232 | 3587 |
return TRUE; |
3588 |
} |
|
3589 |
||
16540 | 3590 |
+gboolean |
3591 |
+ck_session_set_display_type (CkSession *session, |
|
3592 |
+ const char *type, |
|
3593 |
+ GError **error) |
|
3594 |
+{ |
|
3595 |
+ g_return_val_if_fail (CK_IS_SESSION (session), FALSE); |
|
3596 |
+ |
|
3597 |
+ g_free (session->priv->display_type); |
|
3598 |
+ session->priv->display_type = g_strdup (type); |
|
3599 |
+ |
|
3600 |
+ return TRUE; |
|
3601 |
+} |
|
3602 |
+ |
|
16232 | 3603 |
+static gboolean |
3604 |
+ck_session_set_display_template (CkSession *session, |
|
3605 |
+ CkDisplayTemplate *display_template, |
|
3606 |
+ GError **error) |
|
3607 |
+{ |
|
3608 |
+ g_return_val_if_fail (CK_IS_SESSION (session), FALSE); |
|
3609 |
+ |
|
3610 |
+ if (session->priv->display_template != NULL) { |
|
3611 |
+ g_object_unref (session->priv->display_template); |
|
3612 |
+ } |
|
3613 |
+ |
|
3614 |
+ if (display_template != NULL) { |
|
3615 |
+ session->priv->display_template = g_object_ref (display_template); |
|
16540 | 3616 |
+ ck_session_set_display_type (session, ck_display_template_get_name (display_template), error); |
16232 | 3617 |
+ } else { |
3618 |
+ session->priv->display_template = NULL; |
|
3619 |
+ } |
|
3620 |
+ |
|
3621 |
+ return TRUE; |
|
3622 |
+} |
|
3623 |
+ |
|
3624 |
+GHashTable * |
|
3625 |
+ck_session_get_display_variables (CkSession *session) |
|
3626 |
+{ |
|
3627 |
+ return g_hash_table_ref (session->priv->display_variables); |
|
3628 |
+} |
|
3629 |
+ |
|
3630 |
+CkDisplayTemplate * |
|
3631 |
+ck_session_get_display_template (CkSession *session) |
|
3632 |
+{ |
|
3633 |
+ g_return_val_if_fail (CK_IS_SESSION (session), FALSE); |
|
3634 |
+ |
|
3635 |
+ return g_object_ref (session->priv->display_template); |
|
3636 |
+} |
|
3637 |
+ |
|
3638 |
static void |
|
3639 |
ck_session_set_property (GObject *object, |
|
3640 |
guint prop_id, |
|
21938 | 3641 |
@@ -742,15 +1005,33 @@ ck_session_set_property (GObject |
16129 | 3642 |
case PROP_IS_LOCAL: |
3643 |
ck_session_set_is_local (self, g_value_get_boolean (value), NULL); |
|
3644 |
break; |
|
16232 | 3645 |
+ case PROP_IS_OPEN: |
3646 |
+ ck_session_set_is_open (self, g_value_get_boolean (value), NULL); |
|
3647 |
+ break; |
|
16844 | 3648 |
+ case PROP_EVER_OPEN: |
3649 |
+ ck_session_set_ever_open (self, g_value_get_boolean (value), NULL); |
|
3650 |
+ break; |
|
16129 | 3651 |
case PROP_ID: |
3652 |
ck_session_set_id (self, g_value_get_string (value), NULL); |
|
3653 |
break; |
|
3654 |
case PROP_COOKIE: |
|
3655 |
ck_session_set_cookie (self, g_value_get_string (value), NULL); |
|
3656 |
break; |
|
3657 |
+ case PROP_SEAT_ID: |
|
3658 |
+ ck_session_set_seat_id (self, g_value_get_string (value), NULL); |
|
3659 |
+ break; |
|
3660 |
case PROP_SESSION_TYPE: |
|
3661 |
ck_session_set_session_type (self, g_value_get_string (value), NULL); |
|
3662 |
break; |
|
16540 | 3663 |
+ case PROP_DISPLAY_TYPE: |
3664 |
+ ck_session_set_display_type (self, g_value_get_string (value), NULL); |
|
3665 |
+ break; |
|
16232 | 3666 |
+ case PROP_DISPLAY_TEMPLATE: |
3667 |
+ ck_session_set_display_template (self, g_value_get_object (value), NULL); |
|
3668 |
+ break; |
|
3669 |
+ case PROP_DISPLAY_VARIABLES: |
|
3670 |
+ ck_session_set_display_variables (self, g_value_get_boxed (value)); |
|
3671 |
+ break; |
|
3672 |
case PROP_X11_DISPLAY: |
|
3673 |
ck_session_set_x11_display (self, g_value_get_string (value), NULL); |
|
3674 |
break; |
|
21938 | 3675 |
@@ -775,6 +1056,9 @@ ck_session_set_property (GObject |
16475 | 3676 |
case PROP_IDLE_HINT: |
3677 |
session_set_idle_hint_internal (self, g_value_get_boolean (value)); |
|
3678 |
break; |
|
3679 |
+ case PROP_REMOVE_ON_CLOSE: |
|
3680 |
+ session_set_remove_on_close (self, g_value_get_boolean (value), NULL); |
|
3681 |
+ break; |
|
3682 |
default: |
|
3683 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
|
3684 |
break; |
|
21938 | 3685 |
@@ -798,15 +1082,33 @@ ck_session_get_property (GObject *obj |
16129 | 3686 |
case PROP_IS_LOCAL: |
3687 |
g_value_set_boolean (value, self->priv->is_local); |
|
3688 |
break; |
|
16232 | 3689 |
+ case PROP_IS_OPEN: |
3690 |
+ g_value_set_boolean (value, self->priv->is_open); |
|
3691 |
+ break; |
|
16844 | 3692 |
+ case PROP_EVER_OPEN: |
3693 |
+ g_value_set_boolean (value, self->priv->ever_open); |
|
3694 |
+ break; |
|
16129 | 3695 |
case PROP_ID: |
3696 |
g_value_set_string (value, self->priv->id); |
|
3697 |
break; |
|
3698 |
case PROP_COOKIE: |
|
3699 |
g_value_set_string (value, self->priv->cookie); |
|
3700 |
break; |
|
3701 |
+ case PROP_SEAT_ID: |
|
3702 |
+ g_value_set_string (value, self->priv->seat_id); |
|
3703 |
+ break; |
|
3704 |
case PROP_SESSION_TYPE: |
|
3705 |
g_value_set_string (value, self->priv->session_type); |
|
3706 |
break; |
|
16540 | 3707 |
+ case PROP_DISPLAY_TYPE: |
3708 |
+ g_value_set_string (value, self->priv->display_type); |
|
3709 |
+ break; |
|
16232 | 3710 |
+ case PROP_DISPLAY_TEMPLATE: |
3711 |
+ g_value_set_object (value, self->priv->display_template); |
|
3712 |
+ break; |
|
3713 |
+ case PROP_DISPLAY_VARIABLES: |
|
3714 |
+ g_value_set_boxed (value, self->priv->display_variables); |
|
3715 |
+ break; |
|
3716 |
case PROP_X11_DISPLAY: |
|
3717 |
g_value_set_string (value, self->priv->x11_display); |
|
3718 |
break; |
|
21938 | 3719 |
@@ -831,6 +1133,9 @@ ck_session_get_property (GObject *obj |
16475 | 3720 |
case PROP_IDLE_HINT: |
3721 |
g_value_set_boolean (value, self->priv->idle_hint); |
|
3722 |
break; |
|
3723 |
+ case PROP_REMOVE_ON_CLOSE: |
|
3724 |
+ g_value_set_boolean (value, self->priv->remove_on_close); |
|
3725 |
+ break; |
|
3726 |
default: |
|
3727 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
|
3728 |
break; |
|
21938 | 3729 |
@@ -882,6 +1187,8 @@ session_add_activity_watch (CkSession *s |
3730 |
static void |
|
3731 |
session_remove_activity_watch (CkSession *session) |
|
3732 |
{ |
|
3733 |
+ g_debug ("CkSession: Remove activity watch."); |
|
3734 |
+ |
|
3735 |
if (session->priv->idle_monitor == NULL) { |
|
3736 |
return; |
|
3737 |
} |
|
3738 |
@@ -1000,6 +1307,13 @@ ck_session_class_init (CkSessionClass *k |
|
16129 | 3739 |
"cookie", |
3740 |
NULL, |
|
3741 |
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); |
|
3742 |
+ g_object_class_install_property (object_class, |
|
3743 |
+ PROP_SEAT_ID, |
|
3744 |
+ g_param_spec_string ("seat-id", |
|
3745 |
+ "seat id", |
|
3746 |
+ "seat id", |
|
3747 |
+ NULL, |
|
3748 |
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); |
|
3749 |
||
3750 |
g_object_class_install_property (object_class, |
|
3751 |
PROP_SESSION_TYPE, |
|
21938 | 3752 |
@@ -1009,6 +1323,27 @@ ck_session_class_init (CkSessionClass *k |
16232 | 3753 |
NULL, |
3754 |
G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); |
|
3755 |
g_object_class_install_property (object_class, |
|
16540 | 3756 |
+ PROP_DISPLAY_TYPE, |
3757 |
+ g_param_spec_string ("display-type", |
|
3758 |
+ "session-type", |
|
3759 |
+ "session type", |
|
3760 |
+ NULL, |
|
3761 |
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); |
|
3762 |
+ g_object_class_install_property (object_class, |
|
16232 | 3763 |
+ PROP_DISPLAY_TEMPLATE, |
3764 |
+ g_param_spec_object ("display-template", |
|
3765 |
+ "Display Template", |
|
3766 |
+ "The display template", |
|
3767 |
+ CK_TYPE_DISPLAY_TEMPLATE, |
|
3768 |
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); |
|
3769 |
+ g_object_class_install_property (object_class, |
|
3770 |
+ PROP_DISPLAY_VARIABLES, |
|
3771 |
+ g_param_spec_boxed ("display-variables", |
|
3772 |
+ "Display Variables", |
|
3773 |
+ "Display type specific variables", |
|
3774 |
+ G_TYPE_HASH_TABLE, |
|
3775 |
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); |
|
3776 |
+ g_object_class_install_property (object_class, |
|
3777 |
PROP_LOGIN_SESSION_ID, |
|
3778 |
g_param_spec_string ("login-session-id", |
|
3779 |
"login-session-id", |
|
21938 | 3780 |
@@ -1064,12 +1399,19 @@ ck_session_class_init (CkSessionClass *k |
17862 | 3781 |
0, |
3782 |
G_PARAM_READWRITE)); |
|
3783 |
g_object_class_install_property (object_class, |
|
3784 |
- PROP_ACTIVE, |
|
3785 |
+ PROP_IDLE_HINT, |
|
3786 |
g_param_spec_boolean ("idle-hint", |
|
3787 |
NULL, |
|
16475 | 3788 |
NULL, |
3789 |
FALSE, |
|
3790 |
G_PARAM_READWRITE)); |
|
3791 |
+ g_object_class_install_property (object_class, |
|
3792 |
+ PROP_REMOVE_ON_CLOSE, |
|
3793 |
+ g_param_spec_boolean ("remove-on-close", |
|
3794 |
+ NULL, |
|
3795 |
+ NULL, |
|
3796 |
+ FALSE, |
|
3797 |
+ G_PARAM_READWRITE)); |
|
3798 |
||
3799 |
g_type_class_add_private (klass, sizeof (CkSessionPrivate)); |
|
3800 |
||
21938 | 3801 |
@@ -1081,8 +1423,16 @@ ck_session_init (CkSession *session) |
16232 | 3802 |
{ |
3803 |
session->priv = CK_SESSION_GET_PRIVATE (session); |
|
3804 |
||
3805 |
+ session->priv->display_variables = g_hash_table_new_full (g_str_hash, |
|
3806 |
+ g_str_equal, |
|
3807 |
+ (GDestroyNotify) g_free, |
|
3808 |
+ (GDestroyNotify) g_free); |
|
3809 |
+ |
|
3810 |
/* FIXME: should we have a property for this? */ |
|
3811 |
g_get_current_time (&session->priv->creation_time); |
|
17003 | 3812 |
+ |
3813 |
+ if (!session->priv->mutex_under_request) |
|
3814 |
+ session->priv->mutex_under_request = g_mutex_new (); |
|
16232 | 3815 |
} |
17003 | 3816 |
|
3817 |
static void |
|
21938 | 3818 |
@@ -1105,6 +1455,7 @@ ck_session_finalize (GObject *object) |
16540 | 3819 |
g_free (session->priv->cookie); |
3820 |
g_free (session->priv->seat_id); |
|
3821 |
g_free (session->priv->session_type); |
|
3822 |
+ g_free (session->priv->display_type); |
|
3823 |
g_free (session->priv->x11_display); |
|
3824 |
g_free (session->priv->display_device); |
|
3825 |
g_free (session->priv->x11_display_device); |
|
21938 | 3826 |
@@ -1114,16 +1465,138 @@ ck_session_finalize (GObject *object) |
16232 | 3827 |
} |
3828 |
||
3829 |
CkSession * |
|
3830 |
+ck_session_new_from_file (const char *ssid, |
|
3831 |
+ const char *path) |
|
3832 |
+{ |
|
3833 |
+ GKeyFile *key_file; |
|
3834 |
+ gboolean res; |
|
3835 |
+ GError *error; |
|
3836 |
+ char *group; |
|
3837 |
+ char *name; |
|
3838 |
+ gboolean hidden; |
|
3839 |
+ char *type; |
|
3840 |
+ char *display_template_string; |
|
3841 |
+ CkSession *session; |
|
3842 |
+ GHashTable *display_variables; |
|
3843 |
+ char **type_keys; |
|
3844 |
+ |
|
21938 | 3845 |
+ g_debug ("CkSession: New session from file."); |
16232 | 3846 |
+ key_file = g_key_file_new (); |
3847 |
+ error = NULL; |
|
3848 |
+ res = g_key_file_load_from_file (key_file, |
|
3849 |
+ path, |
|
3850 |
+ G_KEY_FILE_NONE, |
|
3851 |
+ &error); |
|
3852 |
+ |
|
3853 |
+ if (! res) { |
|
3854 |
+ g_warning ("Unable to load sessions from file %s: %s", |
|
3855 |
+ path, error->message); |
|
3856 |
+ g_error_free (error); |
|
3857 |
+ return NULL; |
|
3858 |
+ } |
|
3859 |
+ |
|
3860 |
+ group = g_key_file_get_start_group (key_file); |
|
3861 |
+ if (group == NULL || strcmp (group, "Session Entry") != 0) { |
|
3862 |
+ g_warning ("Not a session file: %s", path); |
|
3863 |
+ g_key_file_free (key_file); |
|
3864 |
+ return NULL; |
|
3865 |
+ } |
|
3866 |
+ |
|
3867 |
+ hidden = g_key_file_get_boolean (key_file, group, "Hidden", NULL); |
|
3868 |
+ |
|
3869 |
+ if (hidden) { |
|
21938 | 3870 |
+ g_debug ("CkSession: Session is hidden"); |
16232 | 3871 |
+ g_free (group); |
3872 |
+ g_key_file_free (key_file); |
|
3873 |
+ return NULL; |
|
3874 |
+ } |
|
3875 |
+ |
|
3876 |
+ name = g_key_file_get_string (key_file, group, "Name", NULL); |
|
3877 |
+ |
|
3878 |
+ if (name == NULL) { |
|
3879 |
+ g_warning ("Session file %s doesn't contain a name", path); |
|
3880 |
+ g_free (group); |
|
3881 |
+ g_key_file_free (key_file); |
|
3882 |
+ return NULL; |
|
3883 |
+ } |
|
3884 |
+ |
|
3885 |
+ type = g_key_file_get_string (key_file, group, "Type", NULL); |
|
3886 |
+ |
|
3887 |
+ if (type == NULL) { |
|
3888 |
+ g_warning ("Session file %s doesn't contain a type", path); |
|
3889 |
+ g_free (group); |
|
3890 |
+ g_key_file_free (key_file); |
|
3891 |
+ return NULL; |
|
3892 |
+ } |
|
3893 |
+ |
|
3894 |
+ display_template_string = g_key_file_get_string (key_file, group, "DisplayTemplate", NULL); |
|
3895 |
+ |
|
3896 |
+ if (display_template_string == NULL) { |
|
3897 |
+ g_warning ("Session file %s doesn't contain a display type", path); |
|
3898 |
+ g_free (group); |
|
3899 |
+ g_key_file_free (key_file); |
|
3900 |
+ return NULL; |
|
3901 |
+ } |
|
3902 |
+ |
|
3903 |
+ /* Find a group in the key file named after the display type and stuff |
|
3904 |
+ * all its entries into a hash table for later. |
|
3905 |
+ * |
|
3906 |
+ * Those keys are for things like the display number and the vt to |
|
3907 |
+ * run X with. |
|
3908 |
+ */ |
|
3909 |
+ display_variables = g_hash_table_new_full (g_str_hash, g_str_equal, |
|
3910 |
+ (GDestroyNotify) g_free, |
|
3911 |
+ (GDestroyNotify) g_free); |
|
3912 |
+ type_keys = g_key_file_get_keys (key_file, display_template_string, NULL, NULL); |
|
3913 |
+ |
|
3914 |
+ if (type_keys != NULL) { |
|
3915 |
+ int i; |
|
3916 |
+ for (i = 0; type_keys[i] != NULL; i++) { |
|
3917 |
+ char *string; |
|
3918 |
+ string = g_key_file_get_string (key_file, display_template_string, type_keys[i], NULL); |
|
3919 |
+ |
|
3920 |
+ g_hash_table_insert (display_variables, g_strdup (type_keys[i]), string); |
|
3921 |
+ } |
|
3922 |
+ g_strfreev (type_keys); |
|
3923 |
+ } |
|
3924 |
+ |
|
3925 |
+ session = ck_session_new (ssid, type, display_template_string, display_variables); |
|
3926 |
+ |
|
3927 |
+ g_free (display_template_string); |
|
3928 |
+ g_free (group); |
|
3929 |
+ g_free (type); |
|
3930 |
+ g_hash_table_unref (display_variables); |
|
3931 |
+ |
|
3932 |
+ return session; |
|
3933 |
+} |
|
3934 |
+ |
|
3935 |
+CkSession * |
|
3936 |
ck_session_new (const char *ssid, |
|
3937 |
- const char *cookie) |
|
3938 |
+ const char *type, |
|
3939 |
+ const char *display_template_string, |
|
3940 |
+ GHashTable *display_variables) |
|
3941 |
{ |
|
3942 |
+ CkDisplayTemplate *display_template; |
|
3943 |
GObject *object; |
|
3944 |
gboolean res; |
|
3945 |
||
21938 | 3946 |
+ g_debug ("CkSession: New Session."); |
3947 |
+ |
|
16232 | 3948 |
+ display_template = ck_display_template_get_from_name (display_template_string); |
3949 |
+ |
|
3950 |
+ if (display_template == NULL) { |
|
3951 |
+ g_warning ("Unable to load display type %s", display_template_string); |
|
3952 |
+ return NULL; |
|
3953 |
+ } |
|
3954 |
+ |
|
3955 |
object = g_object_new (CK_TYPE_SESSION, |
|
3956 |
"id", ssid, |
|
3957 |
- "cookie", cookie, |
|
3958 |
+ "session-type", type, |
|
16540 | 3959 |
+ "display-type", display_template_string, |
16232 | 3960 |
+ "display-template", display_template, |
3961 |
+ "display-variables", display_variables, |
|
3962 |
NULL); |
|
3963 |
+ |
|
3964 |
res = register_session (CK_SESSION (object)); |
|
3965 |
if (! res) { |
|
3966 |
g_object_unref (object); |
|
21938 | 3967 |
@@ -1138,9 +1611,80 @@ ck_session_new (const char *ssid, |
16232 | 3968 |
G_TYPE_VALUE, \ |
3969 |
G_TYPE_INVALID)) |
|
3970 |
||
3971 |
+void |
|
3972 |
+ck_session_set_parameters (CkSession *session, |
|
3973 |
+ const GPtrArray *parameters) |
|
3974 |
+{ |
|
3975 |
+ int i; |
|
3976 |
+ GObjectClass *class; |
|
3977 |
+ GType object_type; |
|
3978 |
+ |
|
3979 |
+ object_type = CK_TYPE_SESSION; |
|
3980 |
+ class = g_type_class_ref (object_type); |
|
3981 |
+ for (i = 0; i < parameters->len; i++) { |
|
3982 |
+ gboolean res; |
|
3983 |
+ GValue val_struct = { 0, }; |
|
3984 |
+ GValue value = { 0, }; |
|
3985 |
+ char *prop_name; |
|
3986 |
+ GValue *prop_val; |
|
3987 |
+ GParamSpec *pspec; |
|
3988 |
+ |
|
3989 |
+ g_value_init (&val_struct, CK_TYPE_PARAMETER_STRUCT); |
|
3990 |
+ g_value_set_static_boxed (&val_struct, g_ptr_array_index (parameters, i)); |
|
3991 |
+ |
|
3992 |
+ res = dbus_g_type_struct_get (&val_struct, |
|
3993 |
+ 0, &prop_name, |
|
3994 |
+ 1, &prop_val, |
|
3995 |
+ G_MAXUINT); |
|
3996 |
+ if (! res) { |
|
21938 | 3997 |
+ g_debug ("CkSession: Unable to extract parameter input"); |
16232 | 3998 |
+ goto cont; |
3999 |
+ } |
|
4000 |
+ |
|
4001 |
+ if (prop_name == NULL) { |
|
21938 | 4002 |
+ g_debug ("CkSession: Skipping NULL parameter"); |
16232 | 4003 |
+ goto cont; |
4004 |
+ } |
|
4005 |
+ |
|
4006 |
+ if (strcmp (prop_name, "id") == 0 |
|
4007 |
+ || strcmp (prop_name, "cookie") == 0) { |
|
21938 | 4008 |
+ g_debug ("CkSession: Skipping restricted parameter: %s", prop_name); |
16232 | 4009 |
+ goto cont; |
4010 |
+ } |
|
4011 |
+ |
|
4012 |
+ pspec = g_object_class_find_property (class, prop_name); |
|
4013 |
+ if (! pspec) { |
|
21938 | 4014 |
+ g_debug ("CkSession: Skipping unknown parameter: %s", prop_name); |
16232 | 4015 |
+ goto cont; |
4016 |
+ } |
|
4017 |
+ |
|
4018 |
+ if (!(pspec->flags & G_PARAM_WRITABLE)) { |
|
21938 | 4019 |
+ g_debug ("CkSession: property '%s' is not writable", pspec->name); |
16232 | 4020 |
+ goto cont; |
4021 |
+ } |
|
4022 |
+ |
|
4023 |
+ g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); |
|
4024 |
+ res = g_value_transform (prop_val, &value); |
|
4025 |
+ if (! res) { |
|
21938 | 4026 |
+ g_debug ("CkSession: unable to transform property value for '%s'", pspec->name); |
16232 | 4027 |
+ goto cont; |
4028 |
+ } |
|
4029 |
+ |
|
4030 |
+ g_object_set_property (G_OBJECT (session), prop_name, &value); |
|
4031 |
+ g_value_unset (&value); |
|
4032 |
+ cont: |
|
4033 |
+ g_free (prop_name); |
|
4034 |
+ if (prop_val != NULL) { |
|
4035 |
+ g_value_unset (prop_val); |
|
4036 |
+ g_free (prop_val); |
|
4037 |
+ } |
|
4038 |
+ } |
|
4039 |
+ |
|
4040 |
+ g_type_class_unref (class); |
|
4041 |
+} |
|
4042 |
+ |
|
4043 |
CkSession * |
|
4044 |
ck_session_new_with_parameters (const char *ssid, |
|
4045 |
- const char *cookie, |
|
4046 |
const GPtrArray *parameters) |
|
4047 |
{ |
|
4048 |
GObject *object; |
|
21938 | 4049 |
@@ -1152,6 +1696,8 @@ ck_session_new_with_parameters (const ch |
4050 |
GObjectClass *class; |
|
4051 |
GType object_type; |
|
4052 |
||
4053 |
+ g_debug ("CkSession: New session with parameters"); |
|
4054 |
+ |
|
4055 |
object_type = CK_TYPE_SESSION; |
|
4056 |
class = g_type_class_ref (object_type); |
|
4057 |
||
4058 |
@@ -1169,12 +1715,6 @@ ck_session_new_with_parameters (const ch |
|
16232 | 4059 |
g_value_set_string (¶ms[n_params].value, ssid); |
4060 |
n_params++; |
|
4061 |
||
4062 |
- params[n_params].name = g_strdup ("cookie"); |
|
4063 |
- params[n_params].value.g_type = 0; |
|
4064 |
- g_value_init (¶ms[n_params].value, G_TYPE_STRING); |
|
4065 |
- g_value_set_string (¶ms[n_params].value, cookie); |
|
4066 |
- n_params++; |
|
4067 |
- |
|
4068 |
if (parameters != NULL) { |
|
4069 |
for (i = 0; i < parameters->len; i++) { |
|
4070 |
gboolean res; |
|
21938 | 4071 |
@@ -1259,7 +1799,7 @@ ck_session_run_programs (CkSession *ses |
16540 | 4072 |
const char *action) |
4073 |
{ |
|
4074 |
int n; |
|
4075 |
- char *extra_env[11]; /* be sure to adjust this as needed */ |
|
4076 |
+ char *extra_env[12]; /* be sure to adjust this as needed */ |
|
4077 |
||
4078 |
n = 0; |
|
4079 |
||
21938 | 4080 |
@@ -1267,6 +1807,9 @@ ck_session_run_programs (CkSession *ses |
16540 | 4081 |
if (session->priv->session_type != NULL) { |
4082 |
extra_env[n++] = g_strdup_printf ("CK_SESSION_TYPE=%s", session->priv->session_type); |
|
4083 |
} |
|
4084 |
+ if (session->priv->display_type != NULL) { |
|
16911 | 4085 |
+ extra_env[n++] = g_strdup_printf ("CK_SESSION_DISPLAY_TYPE=%s", session->priv->display_type); |
16540 | 4086 |
+ } |
4087 |
extra_env[n++] = g_strdup_printf ("CK_SESSION_SEAT_ID=%s", session->priv->seat_id); |
|
4088 |
extra_env[n++] = g_strdup_printf ("CK_SESSION_USER_UID=%d", session->priv->uid); |
|
4089 |
if (session->priv->display_device != NULL && strlen (session->priv->display_device) > 0) { |
|
21938 | 4090 |
@@ -1301,6 +1844,10 @@ ck_session_dump (CkSession *session, |
16232 | 4091 |
char *s; |
4092 |
char *group_name; |
|
4093 |
||
4094 |
+ if (!session->priv->is_open) { |
|
4095 |
+ return; |
|
4096 |
+ } |
|
4097 |
+ |
|
4098 |
group_name = g_strdup_printf ("Session %s", session->priv->id); |
|
4099 |
g_key_file_set_integer (key_file, group_name, "uid", session->priv->uid); |
|
4100 |
g_key_file_set_string (key_file, |
|
21938 | 4101 |
@@ -1313,6 +1860,12 @@ ck_session_dump (CkSession *session, |
16911 | 4102 |
"type", |
4103 |
NONULL_STRING (session->priv->session_type)); |
|
4104 |
} |
|
4105 |
+ if (session->priv->display_type != NULL) { |
|
4106 |
+ g_key_file_set_string (key_file, |
|
4107 |
+ group_name, |
|
4108 |
+ "display_type", |
|
4109 |
+ NONULL_STRING (session->priv->display_type)); |
|
4110 |
+ } |
|
4111 |
if (session->priv->login_session_id != NULL && strlen (session->priv->login_session_id) > 0) { |
|
4112 |
g_key_file_set_string (key_file, |
|
4113 |
group_name, |
|
16129 | 4114 |
diff --git a/src/ck-session.h b/src/ck-session.h |
16911 | 4115 |
index b6b565b..a24d0a8 100644 |
16129 | 4116 |
--- a/src/ck-session.h |
4117 |
+++ b/src/ck-session.h |
|
16232 | 4118 |
@@ -25,6 +25,8 @@ |
4119 |
#include <glib-object.h> |
|
4120 |
#include <dbus/dbus-glib.h> |
|
4121 |
||
4122 |
+#include "ck-display-template.h" |
|
4123 |
+ |
|
4124 |
G_BEGIN_DECLS |
|
4125 |
||
4126 |
#define CK_TYPE_SESSION (ck_session_get_type ()) |
|
4127 |
@@ -68,10 +70,15 @@ typedef enum |
|
4128 |
||
4129 |
GQuark ck_session_error_quark (void); |
|
4130 |
GType ck_session_get_type (void); |
|
4131 |
+CkSession * ck_session_new_from_file (const char *ssid, |
|
4132 |
+ const char *path); |
|
4133 |
CkSession * ck_session_new (const char *ssid, |
|
4134 |
- const char *cookie); |
|
4135 |
+ const char *type, |
|
4136 |
+ const char *display_type_string, |
|
4137 |
+ GHashTable *display_variables); |
|
4138 |
CkSession * ck_session_new_with_parameters (const char *ssid, |
|
4139 |
- const char *cookie, |
|
4140 |
+ const GPtrArray *parameters); |
|
4141 |
+void ck_session_set_parameters (CkSession *session, |
|
4142 |
const GPtrArray *parameters); |
|
4143 |
||
4144 |
void ck_session_dump (CkSession *session, |
|
16911 | 4145 |
@@ -86,6 +93,15 @@ gboolean ck_session_set_active (CkSession *se |
16129 | 4146 |
gboolean ck_session_set_is_local (CkSession *session, |
4147 |
gboolean is_local, |
|
4148 |
GError **error); |
|
16232 | 4149 |
+gboolean ck_session_set_is_open (CkSession *session, |
4150 |
+ gboolean is_open, |
|
4151 |
+ GError **error); |
|
16844 | 4152 |
+gboolean ck_session_set_ever_open (CkSession *session, |
4153 |
+ gboolean ever_open, |
|
4154 |
+ GError **error); |
|
4155 |
+gboolean ck_session_set_under_request (CkSession *session, |
|
4156 |
+ gboolean under_request, |
|
4157 |
+ GError **error); |
|
16129 | 4158 |
gboolean ck_session_set_id (CkSession *session, |
4159 |
const char *ssid, |
|
4160 |
GError **error); |
|
16911 | 4161 |
@@ -116,6 +132,11 @@ gboolean ck_session_set_remote_host_name (CkSession *se |
16232 | 4162 |
gboolean ck_session_set_session_type (CkSession *session, |
4163 |
const char *type, |
|
4164 |
GError **error); |
|
16844 | 4165 |
+gboolean ck_session_set_display_type (CkSession *session, |
4166 |
+ const char *type, |
|
4167 |
+ GError **error); |
|
16232 | 4168 |
+GHashTable *ck_session_get_display_variables (CkSession *session); |
4169 |
+CkDisplayTemplate *ck_session_get_display_template (CkSession *session); |
|
4170 |
||
4171 |
/* Exported methods */ |
|
4172 |
||
16911 | 4173 |
@@ -132,6 +153,15 @@ gboolean ck_session_is_active (CkSession *se |
16129 | 4174 |
gboolean ck_session_is_local (CkSession *session, |
4175 |
gboolean *local, |
|
4176 |
GError **error); |
|
16232 | 4177 |
+gboolean ck_session_is_open (CkSession *session, |
4178 |
+ gboolean *open, |
|
4179 |
+ GError **error); |
|
16844 | 4180 |
+gboolean ck_session_get_ever_open (CkSession *session, |
4181 |
+ gboolean *open, |
|
4182 |
+ GError **error); |
|
4183 |
+gboolean ck_session_get_under_request (CkSession *session, |
|
4184 |
+ gboolean *under_request, |
|
4185 |
+ GError **error); |
|
16129 | 4186 |
gboolean ck_session_get_unix_user (CkSession *session, |
4187 |
guint *uid, |
|
4188 |
GError **error); |
|
16911 | 4189 |
@@ -150,12 +180,18 @@ gboolean ck_session_get_login_session_id (CkSession *se |
16232 | 4190 |
gboolean ck_session_get_session_type (CkSession *session, |
4191 |
char **type, |
|
4192 |
GError **error); |
|
4193 |
+gboolean ck_session_get_display_type (CkSession *session, |
|
4194 |
+ char **type, |
|
4195 |
+ GError **error); |
|
4196 |
gboolean ck_session_get_remote_host_name (CkSession *session, |
|
4197 |
char **host_name, |
|
4198 |
GError **error); |
|
16475 | 4199 |
gboolean ck_session_get_creation_time (CkSession *session, |
4200 |
char **iso8601_datetime, |
|
4201 |
GError **error); |
|
4202 |
+gboolean ck_session_get_remove_on_close (CkSession *session, |
|
4203 |
+ gboolean *remove_on_close, |
|
4204 |
+ GError **error); |
|
4205 |
/*deprecated*/ |
|
4206 |
gboolean ck_session_get_user (CkSession *session, |
|
4207 |
guint *uid, |
|
16911 | 4208 |
@@ -171,6 +207,12 @@ gboolean ck_session_get_idle_since_hint (CkSession *se |
16475 | 4209 |
gboolean ck_session_set_idle_hint (CkSession *session, |
4210 |
gboolean idle_hint, |
|
4211 |
DBusGMethodInvocation *context); |
|
4212 |
+gboolean session_set_remove_on_close (CkSession *session, |
|
4213 |
+ gboolean remove_on_close, |
|
4214 |
+ GError **error); |
|
4215 |
+gboolean ck_session_set_remove_on_close (CkSession *session, |
|
4216 |
+ gboolean remove_on_close, |
|
4217 |
+ DBusGMethodInvocation *context); |
|
4218 |
||
4219 |
/* Privileged actions */ |
|
4220 |
gboolean ck_session_activate (CkSession *session, |
|
17862 | 4221 |
diff --git a/src/main.c b/src/main.c |
4222 |
index b8f698f..f685026 100644 |
|
4223 |
--- a/src/main.c |
|
4224 |
+++ b/src/main.c |
|
4225 |
@@ -283,7 +283,7 @@ main (int argc, |
|
4226 |
res = g_option_context_parse (context, &argc, &argv, &error); |
|
4227 |
g_option_context_free (context); |
|
4228 |
if (! res) { |
|
4229 |
- g_warning (error->message); |
|
4230 |
+ g_warning ("%s", error->message); |
|
4231 |
g_error_free (error); |
|
4232 |
goto out; |
|
4233 |
} |
|
16129 | 4234 |
diff --git a/src/org.freedesktop.ConsoleKit.Manager.xml b/src/org.freedesktop.ConsoleKit.Manager.xml |
16647 | 4235 |
index f903b55..34a6d04 100644 |
16129 | 4236 |
--- a/src/org.freedesktop.ConsoleKit.Manager.xml |
4237 |
+++ b/src/org.freedesktop.ConsoleKit.Manager.xml |
|
4238 |
@@ -160,6 +160,23 @@ |
|
4239 |
</doc:doc> |
|
4240 |
</method> |
|
4241 |
||
4242 |
+ <method name="GetUnmanagedSeats"> |
|
4243 |
+ <arg name="seats" direction="out" type="ao"> |
|
4244 |
+ <doc:doc> |
|
4245 |
+ <doc:summary>an array of unmanaged Seat IDs</doc:summary> |
|
4246 |
+ </doc:doc> |
|
4247 |
+ </arg> |
|
4248 |
+ <doc:doc> |
|
4249 |
+ <doc:description> |
|
4250 |
+ <doc:para>This gets a list of the unmanaged <doc:ref type="interface" to="Seat">Seats</doc:ref> |
|
4251 |
+ that are statically configured under /etc/ConsoleKit/seats.d</doc:para> |
|
4252 |
+ <doc:para>Each Seat ID is an D-Bus object path for the object that implements the |
|
4253 |
+ <doc:ref type="interface" to="Seat">Seat</doc:ref> interface.</doc:para> |
|
4254 |
+ </doc:description> |
|
4255 |
+ <doc:seealso><doc:ref type="interface" to="Seat">org.freedesktop.ConsoleKit.Seat</doc:ref></doc:seealso> |
|
4256 |
+ </doc:doc> |
|
4257 |
+ </method> |
|
4258 |
+ |
|
4259 |
<method name="GetSessions"> |
|
4260 |
<arg name="sessions" direction="out" type="ao"> |
|
4261 |
<doc:doc> |
|
16647 | 4262 |
@@ -310,12 +327,115 @@ |
16129 | 4263 |
</doc:doc> |
4264 |
</method> |
|
4265 |
||
16232 | 4266 |
+ <method name="AddSeat"> |
4267 |
+ <arg name="type" type="s" direction="in"> |
|
16129 | 4268 |
+ <doc:doc> |
16232 | 4269 |
+ <doc:summary>The type of seat to add</doc:summary> |
4270 |
+ </doc:doc> |
|
4271 |
+ </arg> |
|
4272 |
+ <arg name="sid" type="o" direction="out"> |
|
4273 |
+ <doc:doc> |
|
4274 |
+ <doc:summary>The Seat ID of the added seat</doc:summary> |
|
16129 | 4275 |
+ </doc:doc> |
4276 |
+ </arg> |
|
16232 | 4277 |
+ <doc:doc> |
4278 |
+ <doc:description> |
|
4279 |
+ <doc:para>This method is to create a new seat |
|
4280 |
+ </doc:para> |
|
4281 |
+ </doc:description> |
|
4282 |
+ </doc:doc> |
|
4283 |
+ </method> |
|
16647 | 4284 |
+ <method name="AddSeatById"> |
4285 |
+ <arg name="type" type="s" direction="in"> |
|
4286 |
+ <doc:doc> |
|
4287 |
+ <doc:summary>The type of seat to add</doc:summary> |
|
4288 |
+ </doc:doc> |
|
4289 |
+ </arg> |
|
4290 |
+ <arg name="sid" type="o" direction="in"> |
|
4291 |
+ <doc:doc> |
|
4292 |
+ <doc:summary>The Seat ID of to be added seat</doc:summary> |
|
4293 |
+ </doc:doc> |
|
4294 |
+ </arg> |
|
4295 |
+ <doc:doc> |
|
4296 |
+ <doc:description> |
|
4297 |
+ <doc:para>This method is to create a new seat by specify given sid |
|
4298 |
+ </doc:para> |
|
4299 |
+ </doc:description> |
|
4300 |
+ </doc:doc> |
|
4301 |
+ </method> |
|
16232 | 4302 |
+ <method name="RemoveSeat"> |
4303 |
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> |
|
4304 |
+ <arg name="sid" type="o" direction="in"> |
|
16129 | 4305 |
+ <doc:doc> |
16232 | 4306 |
+ <doc:summary>The Seat ID of the seat to remove</doc:summary> |
16129 | 4307 |
+ </doc:doc> |
4308 |
+ </arg> |
|
4309 |
+ <doc:doc> |
|
4310 |
+ <doc:description> |
|
16232 | 4311 |
+ <doc:para>This method is to remove a seat |
16129 | 4312 |
+ </doc:para> |
4313 |
+ </doc:description> |
|
4314 |
+ </doc:doc> |
|
4315 |
+ </method> |
|
16232 | 4316 |
+ <method name="AddSession"> |
4317 |
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> |
|
4318 |
+ <arg name="sid" type="o"> |
|
4319 |
+ <doc:doc> |
|
4320 |
+ <doc:summary>The seat to add the session to</doc:summary> |
|
4321 |
+ </doc:doc> |
|
4322 |
+ </arg> |
|
4323 |
+ <arg name="type" type="s"> |
|
16129 | 4324 |
+ <doc:doc> |
16232 | 4325 |
+ <doc:summary>The type of session to run (e.g. "LoginWindow", "Chooser", etc)</doc:summary> |
4326 |
+ </doc:doc> |
|
4327 |
+ </arg> |
|
4328 |
+ <arg name="display_type" type="s"> |
|
4329 |
+ <doc:doc> |
|
4330 |
+ <doc:summary>The name of the display type to use (defined in displays.d)</doc:summary> |
|
4331 |
+ </doc:doc> |
|
4332 |
+ </arg> |
|
4333 |
+ <arg name="variables" type="a{ss}"> |
|
4334 |
+ <doc:doc> |
|
4335 |
+ <doc:summary>Session type specific parameters</doc:summary> |
|
4336 |
+ </doc:doc> |
|
4337 |
+ </arg> |
|
4338 |
+ <arg name="ssid" direction="out" type="o"> |
|
4339 |
+ <doc:doc> |
|
4340 |
+ <doc:summary>Session ID</doc:summary> |
|
16129 | 4341 |
+ </doc:doc> |
4342 |
+ </arg> |
|
4343 |
+ <doc:doc> |
|
4344 |
+ <doc:description> |
|
16232 | 4345 |
+ <doc:para>Request a new session gets added to seat.</doc:para> |
4346 |
+ </doc:description> |
|
4347 |
+ </doc:doc> |
|
4348 |
+ </method> |
|
4349 |
+ <method name="RemoveSession"> |
|
4350 |
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> |
|
4351 |
+ <arg name="ssid" type="o" direction="in"> |
|
4352 |
+ <doc:doc> |
|
4353 |
+ <doc:summary>The session id of the session to remove</doc:summary> |
|
4354 |
+ </doc:doc> |
|
4355 |
+ </arg> |
|
4356 |
+ <doc:doc> |
|
4357 |
+ <doc:description> |
|
4358 |
+ <doc:para>This method is to remove a session from a seat |
|
16129 | 4359 |
+ </doc:para> |
4360 |
+ </doc:description> |
|
4361 |
+ </doc:doc> |
|
4362 |
+ </method> |
|
4363 |
+ |
|
4364 |
<signal name="SeatAdded"> |
|
4365 |
<arg name="sid" type="o"> |
|
4366 |
<doc:doc> |
|
16232 | 4367 |
<doc:summary>The Seat ID for the added seat</doc:summary> |
4368 |
</doc:doc> |
|
4369 |
</arg> |
|
4370 |
+ <arg name="type" type="s"> |
|
4371 |
+ <doc:doc> |
|
4372 |
+ <doc:summary>The type of seat added.</doc:summary> |
|
4373 |
+ </doc:doc> |
|
4374 |
+ </arg> |
|
4375 |
<doc:doc> |
|
4376 |
<doc:description> |
|
4377 |
<doc:para>Emitted when a Seat has been added to the system. |
|
16129 | 4378 |
diff --git a/src/org.freedesktop.ConsoleKit.Seat.xml b/src/org.freedesktop.ConsoleKit.Seat.xml |
16540 | 4379 |
index d95990b..1f6c46f 100644 |
16129 | 4380 |
--- a/src/org.freedesktop.ConsoleKit.Seat.xml |
4381 |
+++ b/src/org.freedesktop.ConsoleKit.Seat.xml |
|
16232 | 4382 |
@@ -100,6 +100,24 @@ seat at a time.</doc:para> |
16129 | 4383 |
</doc:doc> |
4384 |
</method> |
|
4385 |
||
16232 | 4386 |
+ <method name="Manage"> |
4387 |
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> |
|
16129 | 4388 |
+ <doc:doc> |
4389 |
+ <doc:description> |
|
4390 |
+ <doc:para>Attempt to create unmanaged sessions for this seat.</doc:para> |
|
4391 |
+ </doc:description> |
|
4392 |
+ </doc:doc> |
|
4393 |
+ </method> |
|
4394 |
+ |
|
16232 | 4395 |
+ <method name="Unmanage"> |
4396 |
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> |
|
4397 |
+ <doc:doc> |
|
4398 |
+ <doc:description> |
|
4399 |
+ <doc:para>Stop managing seat.</doc:para> |
|
4400 |
+ </doc:description> |
|
4401 |
+ </doc:doc> |
|
4402 |
+ </method> |
|
4403 |
+ |
|
16129 | 4404 |
<signal name="ActiveSessionChanged"> |
4405 |
<arg name="ssid" type="o"> |
|
4406 |
<doc:doc> |
|
16540 | 4407 |
@@ -160,5 +178,61 @@ seat at a time.</doc:para> |
16129 | 4408 |
</doc:description> |
4409 |
</doc:doc> |
|
4410 |
</signal> |
|
16232 | 4411 |
+ <signal name="OpenSessionRequest"> |
4412 |
+ <arg name="ssid" type="o"> |
|
16129 | 4413 |
+ <doc:doc> |
16232 | 4414 |
+ <doc:summary>The session id of the session to add</doc:summary> |
4415 |
+ </doc:doc> |
|
4416 |
+ </arg> |
|
16540 | 4417 |
+ <arg name="session_type" type="s"> |
16232 | 4418 |
+ <doc:doc> |
4419 |
+ <doc:summary>The type of session to run (e.g. "LoginWindow", "Chooser", etc)</doc:summary> |
|
16129 | 4420 |
+ </doc:doc> |
4421 |
+ </arg> |
|
16540 | 4422 |
+ <arg name="display_template_name" type="s"> |
4423 |
+ <doc:doc> |
|
4424 |
+ <doc:summary>The name of display template </doc:summary> |
|
4425 |
+ </doc:doc> |
|
4426 |
+ </arg> |
|
16232 | 4427 |
+ <arg name="parameters" type="a{ss}"> |
4428 |
+ <doc:doc> |
|
4429 |
+ <doc:summary>Session type specific parameters</doc:summary> |
|
4430 |
+ </doc:doc> |
|
4431 |
+ </arg> |
|
4432 |
+ <arg name="display_type" type="s"> |
|
16129 | 4433 |
+ <doc:doc> |
16540 | 4434 |
+ <doc:summary>The type of display to use (e.g. "X11", "Command", "XDMCP", etc)</doc:summary> |
16232 | 4435 |
+ </doc:doc> |
4436 |
+ </arg> |
|
4437 |
+ <arg name="display_parameters" type="a{ss}"> |
|
4438 |
+ <doc:doc> |
|
4439 |
+ <doc:summary>Display type specific parameters</doc:summary> |
|
16129 | 4440 |
+ </doc:doc> |
4441 |
+ </arg> |
|
4442 |
+ <doc:doc> |
|
4443 |
+ <doc:description> |
|
16232 | 4444 |
+ <doc:para>Emitted when a new session should get added to the seat.</doc:para> |
16129 | 4445 |
+ </doc:description> |
4446 |
+ </doc:doc> |
|
4447 |
+ </signal> |
|
16232 | 4448 |
+ <signal name="CloseSessionRequest"> |
4449 |
+ <arg name="ssid" type="o"> |
|
16129 | 4450 |
+ <doc:doc> |
16232 | 4451 |
+ <doc:summary>The session id of the session to remove</doc:summary> |
16129 | 4452 |
+ </doc:doc> |
4453 |
+ </arg> |
|
4454 |
+ <doc:doc> |
|
4455 |
+ <doc:description> |
|
4456 |
+ <doc:para>Emitted when a session with given display number need to be removed.</doc:para> |
|
4457 |
+ </doc:description> |
|
4458 |
+ </doc:doc> |
|
4459 |
+ </signal> |
|
16232 | 4460 |
+ <signal name="RemoveRequest"> |
4461 |
+ <doc:doc> |
|
4462 |
+ <doc:description> |
|
4463 |
+ <doc:para>Emitted when seat needs to get removed.</doc:para> |
|
4464 |
+ </doc:description> |
|
4465 |
+ </doc:doc> |
|
4466 |
+ </signal> |
|
16129 | 4467 |
</interface> |
4468 |
</node> |
|
4469 |
diff --git a/src/org.freedesktop.ConsoleKit.Session.xml b/src/org.freedesktop.ConsoleKit.Session.xml |
|
16911 | 4470 |
index b6e1cdb..2652058 100644 |
16129 | 4471 |
--- a/src/org.freedesktop.ConsoleKit.Session.xml |
4472 |
+++ b/src/org.freedesktop.ConsoleKit.Session.xml |
|
16540 | 4473 |
@@ -52,6 +52,19 @@ |
16232 | 4474 |
<doc:seealso><doc:ref type="property" to="Session:session-type">session-type</doc:ref></doc:seealso> |
4475 |
</doc:doc> |
|
4476 |
</method> |
|
4477 |
+ <method name="GetDisplayType"> |
|
4478 |
+ <arg name="type" direction="out" type="s"> |
|
4479 |
+ <doc:doc> |
|
4480 |
+ <doc:summary>Display type</doc:summary> |
|
4481 |
+ </doc:doc> |
|
4482 |
+ </arg> |
|
4483 |
+ <doc:doc> |
|
4484 |
+ <doc:description> |
|
4485 |
+ <doc:para>Returns the display type of the session.</doc:para> |
|
4486 |
+ </doc:description> |
|
16540 | 4487 |
+ <doc:seealso><doc:ref type="property" to="Session:display-type">display-type</doc:ref></doc:seealso> |
16232 | 4488 |
+ </doc:doc> |
4489 |
+ </method> |
|
4490 |
<method name="GetUser"> |
|
4491 |
<arg name="uid" direction="out" type="u"> |
|
4492 |
<doc:doc> |
|
16911 | 4493 |
@@ -174,6 +187,18 @@ |
16129 | 4494 |
<doc:seealso><doc:ref type="property" to="Session:is-local">is-local</doc:ref></doc:seealso> |
4495 |
</doc:doc> |
|
4496 |
</method> |
|
16232 | 4497 |
+ <method name="IsOpen"> |
4498 |
+ <arg name="open" direction="out" type="b"> |
|
4499 |
+ <doc:doc> |
|
4500 |
+ <doc:summary>TRUE if the session is open, otherwise FALSE</doc:summary> |
|
4501 |
+ </doc:doc> |
|
4502 |
+ </arg> |
|
4503 |
+ <doc:doc> |
|
4504 |
+ <doc:description><doc:para>Returns whether the session is open</doc:para> |
|
4505 |
+ </doc:description> |
|
4506 |
+ <doc:seealso><doc:ref type="property" to="Session:is-open">is-open</doc:ref></doc:seealso> |
|
4507 |
+ </doc:doc> |
|
4508 |
+ </method> |
|
16129 | 4509 |
<method name="GetCreationTime"> |
4510 |
<arg name="iso8601_datetime" type="s" direction="out"> |
|
4511 |
<doc:doc> |
|
16911 | 4512 |
@@ -275,6 +300,21 @@ |
16475 | 4513 |
</doc:description> |
4514 |
</doc:doc> |
|
4515 |
</method> |
|
4516 |
+ <method name="SetRemoveOnClose"> |
|
4517 |
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> |
|
4518 |
+ <arg name="remove_on_close" type="b" direction="in"> |
|
4519 |
+ <doc:doc> |
|
4520 |
+ <doc:summary>boolean value to set the remove-on-close to</doc:summary> |
|
4521 |
+ </doc:doc> |
|
4522 |
+ </arg> |
|
4523 |
+ <doc:doc> |
|
4524 |
+ <doc:description> |
|
4525 |
+ <doc:para>This may be used by the session to indicate that |
|
4526 |
+ it should be respawn or not when it is closed. |
|
4527 |
+ </doc:para> |
|
4528 |
+ </doc:description> |
|
4529 |
+ </doc:doc> |
|
4530 |
+ </method> |
|
4531 |
||
4532 |
<signal name="ActiveChanged"> |
|
4533 |
<arg name="is_active" type="b"> |
|
16911 | 4534 |
@@ -317,6 +357,19 @@ |
16232 | 4535 |
</doc:doc> |
4536 |
</signal> |
|
4537 |
||
4538 |
+ <property name="session" type="o" access="readwrite"> |
|
4539 |
+ <doc:doc> |
|
4540 |
+ <doc:description> |
|
4541 |
+ <doc:para>The id of the session.</doc:para> |
|
4542 |
+ <doc:para> |
|
4543 |
+ The object path of the session. Typically this is set by a session leader during a call to the |
|
4544 |
+ <doc:ref type="method" to="Manager.OpenSessionWithParameters">OpenSessionWithParameters</doc:ref> method, when |
|
4545 |
+ opening a session in response to the <doc:ref type="signal" to="Seat::OpenSessionRequest">OpenSessionRequest</doc:ref> |
|
4546 |
+ signal. |
|
4547 |
+ </doc:para> |
|
4548 |
+ </doc:description> |
|
4549 |
+ </doc:doc> |
|
4550 |
+ </property> |
|
4551 |
<property name="unix-user" type="u" access="readwrite"> |
|
4552 |
<doc:doc> |
|
4553 |
<doc:description> |
|
16911 | 4554 |
@@ -342,6 +395,16 @@ |
16540 | 4555 |
</doc:description> |
4556 |
</doc:doc> |
|
4557 |
</property> |
|
4558 |
+ <property name="display-type" type="s" access="readwrite"> |
|
4559 |
+ <doc:doc> |
|
4560 |
+ <doc:description> |
|
4561 |
+ <doc:para>The display type of the session.</doc:para> |
|
4562 |
+ <doc:para>Indicate the display template name. All the display template configuration |
|
4563 |
+ files are under /etc/ConsoleKit/displays.d/. |
|
4564 |
+ </doc:para> |
|
4565 |
+ </doc:description> |
|
4566 |
+ </doc:doc> |
|
4567 |
+ </property> |
|
4568 |
<property name="remote-host-name" type="s" access="readwrite"> |
|
4569 |
<doc:doc> |
|
4570 |
<doc:description> |
|
16911 | 4571 |
@@ -396,6 +459,19 @@ |
16232 | 4572 |
</doc:description> |
4573 |
</doc:doc> |
|
4574 |
</property> |
|
4575 |
+ <property name="is-open" type="b" access="readwrite"> |
|
4576 |
+ <doc:doc> |
|
4577 |
+ <doc:description> |
|
4578 |
+ <doc:para> |
|
4579 |
+ Whether the session is open</doc:para> |
|
4580 |
+ <doc:para>Sessions added from static configuration or in direct response to a call to |
|
4581 |
+ the <doc:ref type="method" to="Manager.AddSession">AddSession</doc:ref> method are initialally |
|
4582 |
+ closed and aren't open until a call to the <doc:ref type="method" to="Manager.OpenSessionWithParameters">OpenSessionWithParameters</doc:ref> |
|
4583 |
+ method. |
|
4584 |
+ </doc:para> |
|
4585 |
+ </doc:description> |
|
4586 |
+ </doc:doc> |
|
4587 |
+ </property> |
|
4588 |
<property name="is-local" type="b" access="readwrite"> |
|
4589 |
<doc:doc> |
|
4590 |
<doc:description> |
|
16911 | 4591 |
@@ -408,6 +484,14 @@ |
16129 | 4592 |
</doc:description> |
4593 |
</doc:doc> |
|
4594 |
</property> |
|
4595 |
+ <property name="is-dynamic" type="b" access="readwrite"> |
|
4596 |
+ <doc:doc> |
|
4597 |
+ <doc:description> |
|
4598 |
+ <doc:para> |
|
4599 |
+ Whether the session is dynamic</doc:para> |
|
4600 |
+ </doc:description> |
|
4601 |
+ </doc:doc> |
|
4602 |
+ </property> |
|
4603 |
<property name="idle-hint" type="b" access="readwrite"> |
|
4604 |
<doc:doc> |
|
4605 |
<doc:description> |
|
16911 | 4606 |
@@ -430,6 +514,14 @@ |
16475 | 4607 |
</doc:description> |
4608 |
</doc:doc> |
|
4609 |
</property> |
|
4610 |
+ <property name="remove-on-close" type="b" access="readwrite"> |
|
4611 |
+ <doc:doc> |
|
4612 |
+ <doc:description> |
|
4613 |
+ <doc:para> |
|
4614 |
+ Whether the session respawn when it is closed</doc:para> |
|
4615 |
+ </doc:description> |
|
4616 |
+ </doc:doc> |
|
4617 |
+ </property> |
|
4618 |
||
4619 |
</interface> |
|
4620 |
</node> |
|
16647 | 4621 |
diff --git a/src/strverscmp.c b/src/strverscmp.c |
4622 |
new file mode 100644 |
|
4623 |
index 0000000..f077651 |
|
4624 |
--- /dev/null |
|
4625 |
+++ b/src/strverscmp.c |
|
4626 |
@@ -0,0 +1,131 @@ |
|
4627 |
+/* Compare strings while treating digits characters numerically. |
|
4628 |
+ Copyright (C) 1997, 2000, 2002, 2004, 2006 Free Software Foundation, Inc. |
|
4629 |
+ This file is part of the GNU C Library. |
|
4630 |
+ Contributed by Jean-François Bignolles <[email protected]>, 1997. |
|
4631 |
+ |
|
4632 |
+ This program is free software; you can redistribute it and/or modify |
|
4633 |
+ it under the terms of the GNU General Public License as published by |
|
4634 |
+ the Free Software Foundation; either version 2, or (at your option) |
|
4635 |
+ any later version. |
|
4636 |
+ |
|
4637 |
+ This program is distributed in the hope that it will be useful, |
|
4638 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
4639 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
4640 |
+ GNU General Public License for more details. |
|
4641 |
+ |
|
4642 |
+ You should have received a copy of the GNU General Public License along |
|
4643 |
+ with this program; if not, write to the Free Software Foundation, |
|
4644 |
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
|
4645 |
+ |
|
4646 |
+#if !_LIBC |
|
4647 |
+# include <config.h> |
|
4648 |
+#endif |
|
4649 |
+ |
|
4650 |
+#include <string.h> |
|
4651 |
+#include <ctype.h> |
|
4652 |
+ |
|
4653 |
+/* states: S_N: normal, S_I: comparing integral part, S_F: comparing |
|
4654 |
+ fractional parts, S_Z: idem but with leading Zeroes only */ |
|
4655 |
+#define S_N 0x0 |
|
4656 |
+#define S_I 0x4 |
|
4657 |
+#define S_F 0x8 |
|
4658 |
+#define S_Z 0xC |
|
4659 |
+ |
|
4660 |
+/* result_type: CMP: return diff; LEN: compare using len_diff/diff */ |
|
4661 |
+#define CMP 2 |
|
4662 |
+#define LEN 3 |
|
4663 |
+ |
|
4664 |
+ |
|
4665 |
+/* ISDIGIT differs from isdigit, as follows: |
|
4666 |
+ - Its arg may be any int or unsigned int; it need not be an unsigned char |
|
4667 |
+ or EOF. |
|
4668 |
+ - It's typically faster. |
|
4669 |
+ POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to |
|
4670 |
+ isdigit unless it's important to use the locale's definition |
|
4671 |
+ of `digit' even when the host does not conform to POSIX. */ |
|
4672 |
+#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9) |
|
4673 |
+ |
|
4674 |
+#undef __strverscmp |
|
4675 |
+#undef strverscmp |
|
4676 |
+ |
|
4677 |
+#ifndef weak_alias |
|
4678 |
+# define __strverscmp strverscmp |
|
4679 |
+#endif |
|
4680 |
+ |
|
4681 |
+/* Compare S1 and S2 as strings holding indices/version numbers, |
|
4682 |
+ returning less than, equal to or greater than zero if S1 is less than, |
|
4683 |
+ equal to or greater than S2 (for more info, see the texinfo doc). |
|
4684 |
+*/ |
|
4685 |
+ |
|
4686 |
+int |
|
4687 |
+__strverscmp (const char *s1, const char *s2) |
|
4688 |
+{ |
|
4689 |
+ const unsigned char *p1 = (const unsigned char *) s1; |
|
4690 |
+ const unsigned char *p2 = (const unsigned char *) s2; |
|
4691 |
+ unsigned char c1, c2; |
|
4692 |
+ int state; |
|
4693 |
+ int diff; |
|
4694 |
+ |
|
4695 |
+ /* Symbol(s) 0 [1-9] others (padding) |
|
4696 |
+ Transition (10) 0 (01) d (00) x (11) - */ |
|
4697 |
+ static const unsigned int next_state[] = |
|
4698 |
+ { |
|
4699 |
+ /* state x d 0 - */ |
|
4700 |
+ /* S_N */ S_N, S_I, S_Z, S_N, |
|
4701 |
+ /* S_I */ S_N, S_I, S_I, S_I, |
|
4702 |
+ /* S_F */ S_N, S_F, S_F, S_F, |
|
4703 |
+ /* S_Z */ S_N, S_F, S_Z, S_Z |
|
4704 |
+ }; |
|
4705 |
+ |
|
4706 |
+ static const int result_type[] = |
|
4707 |
+ { |
|
4708 |
+ /* state x/x x/d x/0 x/- d/x d/d d/0 d/- |
|
4709 |
+ 0/x 0/d 0/0 0/- -/x -/d -/0 -/- */ |
|
4710 |
+ |
|
4711 |
+ /* S_N */ CMP, CMP, CMP, CMP, CMP, LEN, CMP, CMP, |
|
4712 |
+ CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, |
|
4713 |
+ /* S_I */ CMP, -1, -1, CMP, 1, LEN, LEN, CMP, |
|
4714 |
+ 1, LEN, LEN, CMP, CMP, CMP, CMP, CMP, |
|
4715 |
+ /* S_F */ CMP, CMP, CMP, CMP, CMP, LEN, CMP, CMP, |
|
4716 |
+ CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, |
|
4717 |
+ /* S_Z */ CMP, 1, 1, CMP, -1, CMP, CMP, CMP, |
|
4718 |
+ -1, CMP, CMP, CMP |
|
4719 |
+ }; |
|
4720 |
+ |
|
4721 |
+ if (p1 == p2) |
|
4722 |
+ return 0; |
|
4723 |
+ |
|
4724 |
+ c1 = *p1++; |
|
4725 |
+ c2 = *p2++; |
|
4726 |
+ /* Hint: '0' is a digit too. */ |
|
4727 |
+ state = S_N | ((c1 == '0') + (ISDIGIT (c1) != 0)); |
|
4728 |
+ |
|
4729 |
+ while ((diff = c1 - c2) == 0 && c1 != '\0') |
|
4730 |
+ { |
|
4731 |
+ state = next_state[state]; |
|
4732 |
+ c1 = *p1++; |
|
4733 |
+ c2 = *p2++; |
|
4734 |
+ state |= (c1 == '0') + (ISDIGIT (c1) != 0); |
|
4735 |
+ } |
|
4736 |
+ |
|
4737 |
+ state = result_type[state << 2 | ((c2 == '0') + (ISDIGIT (c2) != 0))]; |
|
4738 |
+ |
|
4739 |
+ switch (state) |
|
4740 |
+ { |
|
4741 |
+ case CMP: |
|
4742 |
+ return diff; |
|
4743 |
+ |
|
4744 |
+ case LEN: |
|
4745 |
+ while (ISDIGIT (*p1++)) |
|
4746 |
+ if (!ISDIGIT (*p2++)) |
|
4747 |
+ return 1; |
|
4748 |
+ |
|
4749 |
+ return ISDIGIT (*p2) ? -1 : diff; |
|
4750 |
+ |
|
4751 |
+ default: |
|
4752 |
+ return state; |
|
4753 |
+ } |
|
4754 |
+} |
|
4755 |
+#ifdef weak_alias |
|
4756 |
+weak_alias (__strverscmp, strverscmp) |
|
4757 |
+#endif |
|
4758 |
diff --git a/src/strverscmp.h b/src/strverscmp.h |
|
4759 |
new file mode 100644 |
|
4760 |
index 0000000..48670c8 |
|
4761 |
--- /dev/null |
|
4762 |
+++ b/src/strverscmp.h |
|
4763 |
@@ -0,0 +1,25 @@ |
|
4764 |
+/* Compare strings while treating digits characters numerically. |
|
4765 |
+ Copyright (C) 1997, 2000, 2002, 2004, 2006 Free Software Foundation, Inc. |
|
4766 |
+ This file is part of the GNU C Library. |
|
4767 |
+ Contributed by Jean-François Bignolles <[email protected]>, 1997. |
|
4768 |
+ |
|
4769 |
+ This program is free software; you can redistribute it and/or modify |
|
4770 |
+ it under the terms of the GNU General Public License as published by |
|
4771 |
+ the Free Software Foundation; either version 2, or (at your option) |
|
4772 |
+ any later version. |
|
4773 |
+ |
|
4774 |
+ This program is distributed in the hope that it will be useful, |
|
4775 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
4776 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
4777 |
+ GNU General Public License for more details. |
|
4778 |
+ |
|
4779 |
+ You should have received a copy of the GNU General Public License along |
|
4780 |
+ with this program; if not, write to the Free Software Foundation, |
|
4781 |
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
|
4782 |
+ |
|
4783 |
+#ifndef STRVERSCMP_H_ |
|
4784 |
+# define STRVERSCMP_H_ |
|
4785 |
+ |
|
4786 |
+int strverscmp (const char *, const char *); |
|
4787 |
+ |
|
4788 |
+#endif /* not STRVERSCMP_H_ */ |
|
16129 | 4789 |
diff --git a/tools/Makefile.am b/tools/Makefile.am |
16232 | 4790 |
index 13c191f..fa16c68 100644 |
16129 | 4791 |
--- a/tools/Makefile.am |
4792 |
+++ b/tools/Makefile.am |
|
16232 | 4793 |
@@ -54,6 +54,7 @@ sbin_PROGRAMS = \ |
4794 |
ck-log-system-start \ |
|
4795 |
ck-log-system-restart \ |
|
4796 |
ck-log-system-stop \ |
|
4797 |
+ ck-seat-tool \ |
|
16129 | 4798 |
$(NULL) |
4799 |
||
16232 | 4800 |
ck_launch_session_SOURCES = \ |
16129 | 4801 |
@@ -83,6 +84,14 @@ ck_history_LDADD = \ |
4802 |
$(top_builddir)/src/libck-event-log.la \ |
|
4803 |
$(NULL) |
|
4804 |
||
16232 | 4805 |
+ck_seat_tool_SOURCES = \ |
4806 |
+ ck-seat-tool.c \ |
|
16129 | 4807 |
+ $(NULL) |
4808 |
+ |
|
16232 | 4809 |
+ck_seat_tool_LDADD = \ |
16129 | 4810 |
+ $(CONSOLE_KIT_LIBS) \ |
4811 |
+ $(NULL) |
|
4812 |
+ |
|
4813 |
ck_log_system_start_SOURCES = \ |
|
4814 |
ck-log-system-start.c \ |
|
4815 |
$(NULL) |
|
16232 | 4816 |
diff --git a/tools/ck-seat-tool.c b/tools/ck-seat-tool.c |
16129 | 4817 |
new file mode 100644 |
17790 | 4818 |
index 0000000..0879d0d |
16129 | 4819 |
--- /dev/null |
16232 | 4820 |
+++ b/tools/ck-seat-tool.c |
17790 | 4821 |
@@ -0,0 +1,443 @@ |
16129 | 4822 |
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- |
4823 |
+ * |
|
4824 |
+ * Copyright (C) 2009 Sun Microsystems, Inc. |
|
4825 |
+ * |
|
4826 |
+ * This program is free software; you can redistribute it and/or |
|
4827 |
+ * modify it under the terms of the GNU General Public License as |
|
4828 |
+ * published by the Free Software Foundation; either version 2 of the |
|
4829 |
+ * License, or (at your option) any later version. |
|
4830 |
+ * |
|
4831 |
+ * This program is distributed in the hope that it will be useful, but |
|
4832 |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of |
|
4833 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
4834 |
+ * General Public License for more details. |
|
4835 |
+ * |
|
4836 |
+ * You should have received a copy of the GNU General Public License |
|
4837 |
+ * along with this program; if not, write to the Free Software |
|
4838 |
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
|
4839 |
+ * 02111-1307, USA. |
|
4840 |
+ * |
|
4841 |
+ * Authors: Halton Huo <[email protected]> |
|
4842 |
+ * |
|
4843 |
+ */ |
|
4844 |
+ |
|
4845 |
+#include "config.h" |
|
4846 |
+ |
|
4847 |
+#include <stdlib.h> |
|
4848 |
+#include <stdio.h> |
|
4849 |
+#include <sys/types.h> |
|
4850 |
+#include <unistd.h> |
|
4851 |
+#include <strings.h> |
|
4852 |
+#include <glib/gi18n.h> |
|
4853 |
+#include <dbus/dbus-glib.h> |
|
4854 |
+#include <dbus/dbus-glib-lowlevel.h> |
|
4855 |
+ |
|
4856 |
+#define CK_NAME "org.freedesktop.ConsoleKit" |
|
4857 |
+#define CK_PATH "/org/freedesktop/ConsoleKit" |
|
4858 |
+#define CK_INTERFACE "org.freedesktop.ConsoleKit" |
|
4859 |
+#define CK_MANAGER_PATH "/org/freedesktop/ConsoleKit/Manager" |
|
4860 |
+#define CK_MANAGER_INTERFACE "org.freedesktop.ConsoleKit.Manager" |
|
4861 |
+#define CK_SEAT_INTERFACE "org.freedesktop.ConsoleKit.Seat" |
|
4862 |
+#define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session" |
|
4863 |
+ |
|
16232 | 4864 |
+#define CK_DBUS_TYPE_G_STRING_STRING_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING)) |
4865 |
+ |
|
4866 |
+#define IS_STR_SET(x) (x != NULL && x[0] != '\0') |
|
4867 |
+#define CK_PATH_PREFIX "/org/freedesktop/ConsoleKit/" |
|
4868 |
+ |
|
4869 |
+static gboolean add = FALSE; |
|
4870 |
+static gboolean delete = FALSE; |
|
4871 |
+static gboolean show_version = FALSE; |
|
4872 |
+static char *session_type = NULL; |
|
4873 |
+static char *display_type = NULL; |
|
4874 |
+static char *seat_id = NULL; |
|
4875 |
+static char *session_id = NULL; |
|
4876 |
+static gchar **remaining_args = NULL; |
|
4877 |
+ |
|
4878 |
+static const GOptionEntry options [] = { |
|
4879 |
+ { "add", 'a', 0, G_OPTION_ARG_NONE, &add, N_("Add a new session"), NULL}, |
|
4880 |
+ { "session-type", '\0', 0, G_OPTION_ARG_STRING, &session_type, N_("Specify session type when adding a session. Default is LoginWindow."), NULL}, |
|
4881 |
+ { "display-type", '\0', 0, G_OPTION_ARG_STRING, &display_type, N_("Specify display type under <etc>/ConsoleKit/displays.d/ when adding a session."), NULL}, |
|
4882 |
+ { "seat-id", '\0', 0, G_OPTION_ARG_STRING, &seat_id, N_("Specify seat id when adding a session. If not given, create a new seat."), NULL}, |
|
4883 |
+ { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &remaining_args, N_("Specify values of variables in display type. For example display=:10"), NULL }, |
|
4884 |
+ { "delete", 'd', 0, G_OPTION_ARG_NONE, &delete, N_("Delete a session"), NULL}, |
|
4885 |
+ { "session-id", '\0', 0, G_OPTION_ARG_STRING, &session_id, N_("Specify session id when deleting a session"), NULL}, |
|
4886 |
+ { "version", 'V', 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL }, |
|
4887 |
+ { NULL } |
|
4888 |
+}; |
|
4889 |
+ |
|
16129 | 4890 |
+static void |
16232 | 4891 |
+add_session (DBusGConnection *connection) |
16129 | 4892 |
+{ |
16232 | 4893 |
+ DBusGProxy *mgr_proxy = NULL; |
4894 |
+ DBusGProxy *seat_proxy = NULL; |
|
4895 |
+ GError *error = NULL; |
|
4896 |
+ gboolean res; |
|
4897 |
+ char *sid = NULL; |
|
16647 | 4898 |
+ GPtrArray *seats; |
16232 | 4899 |
+ char *ssid = NULL; |
4900 |
+ int i; |
|
16647 | 4901 |
+ gboolean found; |
16232 | 4902 |
+ char *sstype = NULL; |
4903 |
+ GHashTable *variables = NULL; |
|
4904 |
+ |
|
4905 |
+ if (! IS_STR_SET (session_type)) { |
|
4906 |
+ sstype = g_strdup ("LoginWindow"); |
|
4907 |
+ } else { |
|
4908 |
+ sstype = g_strdup (session_type); |
|
4909 |
+ } |
|
4910 |
+ |
|
4911 |
+ mgr_proxy = dbus_g_proxy_new_for_name (connection, |
|
4912 |
+ CK_NAME, |
|
4913 |
+ CK_MANAGER_PATH, |
|
4914 |
+ CK_MANAGER_INTERFACE); |
|
4915 |
+ if (mgr_proxy == NULL) { |
|
16129 | 4916 |
+ return; |
4917 |
+ } |
|
4918 |
+ |
|
16232 | 4919 |
+ if (! IS_STR_SET(seat_id)) { |
4920 |
+ |
|
4921 |
+ /* If seat id is not given, create a new seat */ |
|
4922 |
+ error = NULL; |
|
4923 |
+ res = dbus_g_proxy_call (mgr_proxy, |
|
4924 |
+ "AddSeat", |
|
4925 |
+ &error, |
|
4926 |
+ G_TYPE_STRING, "Default", |
|
4927 |
+ G_TYPE_INVALID, |
|
4928 |
+ DBUS_TYPE_G_OBJECT_PATH, &sid, |
|
4929 |
+ G_TYPE_INVALID); |
|
4930 |
+ if (!res) { |
|
4931 |
+ g_warning ("Unable to add seat: %s", error->message); |
|
4932 |
+ g_error_free (error); |
|
4933 |
+ g_object_unref (mgr_proxy); |
|
4934 |
+ return; |
|
4935 |
+ } |
|
4936 |
+ |
|
4937 |
+ } else { |
|
4938 |
+ if (!g_str_has_prefix (seat_id, CK_PATH_PREFIX)) { |
|
4939 |
+ sid = g_strdup_printf ("%s%s", CK_PATH_PREFIX, seat_id); |
|
16129 | 4940 |
+ } else { |
16232 | 4941 |
+ sid = g_strdup (seat_id); |
16129 | 4942 |
+ } |
16647 | 4943 |
+ /* Check whether seat is existing, if not, try to create it. */ |
4944 |
+ |
|
4945 |
+ error = NULL; |
|
4946 |
+ res = dbus_g_proxy_call (mgr_proxy, |
|
4947 |
+ "GetSeats", |
|
4948 |
+ &error, |
|
4949 |
+ G_TYPE_INVALID, |
|
4950 |
+ dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH), |
|
4951 |
+ &seats, |
|
4952 |
+ G_TYPE_INVALID); |
|
4953 |
+ if (!res) { |
|
4954 |
+ g_warning ("Unable to get seat list: %s", error->message); |
|
4955 |
+ g_error_free (error); |
|
4956 |
+ g_object_unref (mgr_proxy); |
|
4957 |
+ return; |
|
4958 |
+ } |
|
4959 |
+ |
|
4960 |
+ found = FALSE; |
|
4961 |
+ for (i = 0; i < seats->len; i++) { |
|
4962 |
+ char *tmp_sid; |
|
4963 |
+ |
|
4964 |
+ tmp_sid = g_ptr_array_index (seats, i); |
|
4965 |
+ if (g_str_equal (sid, tmp_sid)) { |
|
4966 |
+ found = TRUE; |
|
4967 |
+ g_free (tmp_sid); |
|
4968 |
+ break; |
|
4969 |
+ } |
|
4970 |
+ |
|
4971 |
+ g_free (tmp_sid); |
|
4972 |
+ } |
|
4973 |
+ |
|
4974 |
+ if (! found) { |
|
4975 |
+ error = NULL; |
|
4976 |
+ res = dbus_g_proxy_call (mgr_proxy, |
|
4977 |
+ "AddSeatById", |
|
4978 |
+ &error, |
|
4979 |
+ G_TYPE_STRING, "Default", |
|
4980 |
+ DBUS_TYPE_G_OBJECT_PATH, sid, |
|
4981 |
+ G_TYPE_INVALID, |
|
4982 |
+ G_TYPE_INVALID); |
|
4983 |
+ if (!res) { |
|
4984 |
+ g_warning ("Unable to add seat: %s", error->message); |
|
4985 |
+ g_error_free (error); |
|
4986 |
+ g_object_unref (mgr_proxy); |
|
4987 |
+ return; |
|
4988 |
+ } |
|
4989 |
+ } |
|
16129 | 4990 |
+ } |
4991 |
+ |
|
16232 | 4992 |
+ seat_proxy = dbus_g_proxy_new_for_name (connection, |
4993 |
+ CK_NAME, |
|
4994 |
+ sid, |
|
4995 |
+ CK_SEAT_INTERFACE); |
|
4996 |
+ |
|
4997 |
+ if (seat_proxy == NULL) { |
|
4998 |
+ g_warning ("Failed to talk to seat '%s'", sid); |
|
4999 |
+ g_object_unref (mgr_proxy); |
|
16129 | 5000 |
+ return; |
5001 |
+ } |
|
5002 |
+ |
|
16232 | 5003 |
+ variables = g_hash_table_new_full (g_str_hash, g_str_equal, |
5004 |
+ (GDestroyNotify) g_free, |
|
5005 |
+ (GDestroyNotify) g_free); |
|
5006 |
+ |
|
17790 | 5007 |
+ if (remaining_args) { |
5008 |
+ for (i = 0; i < G_N_ELEMENTS (remaining_args); i++) { |
|
5009 |
+ char **arr; |
|
5010 |
+ |
|
5011 |
+ /* split var=value */ |
|
5012 |
+ arr = g_strsplit (remaining_args [i], "=", 2); |
|
5013 |
+ if (arr[0] && arr[1]) { |
|
5014 |
+ g_hash_table_insert (variables, |
|
5015 |
+ g_strdup(arr[0]), |
|
5016 |
+ g_strdup (arr[1])); |
|
5017 |
+ } |
|
5018 |
+ g_strfreev (arr); |
|
16232 | 5019 |
+ } |
5020 |
+ } |
|
5021 |
+ |
|
5022 |
+ error = NULL; |
|
5023 |
+ res = dbus_g_proxy_call (mgr_proxy, |
|
5024 |
+ "AddSession", |
|
5025 |
+ &error, |
|
5026 |
+ DBUS_TYPE_G_OBJECT_PATH, sid, |
|
5027 |
+ G_TYPE_STRING, sstype, |
|
5028 |
+ G_TYPE_STRING, display_type, |
|
5029 |
+ CK_DBUS_TYPE_G_STRING_STRING_HASHTABLE, variables, |
|
5030 |
+ G_TYPE_INVALID, |
|
5031 |
+ DBUS_TYPE_G_OBJECT_PATH, &ssid, |
|
5032 |
+ G_TYPE_INVALID); |
|
5033 |
+ |
|
5034 |
+ if (!res) { |
|
5035 |
+ g_warning ("Unable to add dynamic session: %s", error->message); |
|
5036 |
+ g_error_free (error); |
|
5037 |
+ } else { |
|
5038 |
+ dbus_g_proxy_call_no_reply (seat_proxy, |
|
5039 |
+ "Manage", |
|
5040 |
+ G_TYPE_INVALID, |
|
5041 |
+ G_TYPE_INVALID); |
|
5042 |
+ g_print ("Seat %s with session %s has been added\n", sid, ssid); |
|
5043 |
+ } |
|
5044 |
+ |
|
5045 |
+ g_object_unref (seat_proxy); |
|
5046 |
+ g_object_unref (mgr_proxy); |
|
16129 | 5047 |
+} |
5048 |
+ |
|
5049 |
+static gboolean |
|
16232 | 5050 |
+is_session_on_seat (DBusGConnection *connection, |
5051 |
+ const char *sid, |
|
5052 |
+ const char *ssid, |
|
5053 |
+ gboolean *is_last_session) |
|
16129 | 5054 |
+{ |
16232 | 5055 |
+ |
5056 |
+ DBusGProxy *seat_proxy = NULL; |
|
5057 |
+ GPtrArray *sessions = NULL; |
|
5058 |
+ char *ssid_tmp = NULL; |
|
5059 |
+ gboolean res; |
|
5060 |
+ gboolean retval = FALSE; |
|
5061 |
+ int i; |
|
5062 |
+ GError *error = NULL; |
|
5063 |
+ |
|
5064 |
+ seat_proxy = dbus_g_proxy_new_for_name (connection, |
|
5065 |
+ CK_NAME, |
|
5066 |
+ sid, |
|
5067 |
+ CK_SEAT_INTERFACE); |
|
5068 |
+ |
|
5069 |
+ if (seat_proxy == NULL) { |
|
5070 |
+ g_warning ("Failed to talk to seat '%s'", sid); |
|
5071 |
+ return FALSE; |
|
5072 |
+ } |
|
16129 | 5073 |
+ |
5074 |
+ error = NULL; |
|
16232 | 5075 |
+ res = dbus_g_proxy_call (seat_proxy, |
16129 | 5076 |
+ "GetSessions", |
5077 |
+ &error, |
|
5078 |
+ G_TYPE_INVALID, |
|
5079 |
+ dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH), |
|
5080 |
+ &sessions, |
|
5081 |
+ G_TYPE_INVALID); |
|
5082 |
+ if (! res) { |
|
5083 |
+ g_warning ("Failed to get list of sessions for %s: %s", sid, error->message); |
|
5084 |
+ g_error_free (error); |
|
16232 | 5085 |
+ g_object_unref (seat_proxy); |
5086 |
+ return FALSE; |
|
16129 | 5087 |
+ } |
5088 |
+ |
|
5089 |
+ for (i = 0; i < sessions->len; i++) { |
|
16232 | 5090 |
+ |
5091 |
+ ssid_tmp = g_ptr_array_index (sessions, i); |
|
5092 |
+ |
|
5093 |
+ if (g_str_equal (ssid, ssid_tmp)) { |
|
5094 |
+ retval = TRUE; |
|
5095 |
+ break; |
|
5096 |
+ } |
|
5097 |
+ |
|
5098 |
+ g_free (ssid_tmp); |
|
5099 |
+ ssid_tmp = NULL; |
|
5100 |
+ } |
|
5101 |
+ |
|
5102 |
+ if (is_last_session != NULL) { |
|
5103 |
+ *is_last_session = sessions->len == 1; |
|
16129 | 5104 |
+ } |
5105 |
+ |
|
5106 |
+ g_ptr_array_free (sessions, TRUE); |
|
16232 | 5107 |
+ g_object_unref (seat_proxy); |
5108 |
+ |
|
5109 |
+ return retval; |
|
16129 | 5110 |
+} |
5111 |
+ |
|
16232 | 5112 |
+static char * |
5113 |
+find_seat_id_from_session_id (DBusGConnection *connection, |
|
5114 |
+ DBusGProxy *proxy, |
|
5115 |
+ const char *ssid, |
|
5116 |
+ gboolean *is_last_session) |
|
16129 | 5117 |
+{ |
5118 |
+ GError *error; |
|
5119 |
+ GPtrArray *seats; |
|
5120 |
+ int i; |
|
16232 | 5121 |
+ char *sid; |
5122 |
+ gboolean res; |
|
16129 | 5123 |
+ |
5124 |
+ error = NULL; |
|
5125 |
+ res = dbus_g_proxy_call (proxy, |
|
5126 |
+ "GetSeats", |
|
5127 |
+ &error, |
|
5128 |
+ G_TYPE_INVALID, |
|
5129 |
+ dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH), |
|
5130 |
+ &seats, |
|
5131 |
+ G_TYPE_INVALID); |
|
16232 | 5132 |
+ |
16129 | 5133 |
+ if (! res) { |
5134 |
+ g_warning ("Failed to get list of seats: %s", error->message); |
|
5135 |
+ g_error_free (error); |
|
16232 | 5136 |
+ return NULL; |
16129 | 5137 |
+ } |
5138 |
+ |
|
5139 |
+ for (i = 0; i < seats->len; i++) { |
|
5140 |
+ |
|
5141 |
+ sid = g_ptr_array_index (seats, i); |
|
16232 | 5142 |
+ if (is_session_on_seat (connection, sid, ssid, is_last_session)) { |
5143 |
+ break; |
|
5144 |
+ } |
|
16129 | 5145 |
+ |
5146 |
+ g_free (sid); |
|
5147 |
+ } |
|
5148 |
+ g_ptr_array_free (seats, TRUE); |
|
5149 |
+ |
|
16232 | 5150 |
+ return sid; |
5151 |
+} |
|
5152 |
+ |
|
5153 |
+static void |
|
5154 |
+delete_session (DBusGConnection *connection) |
|
5155 |
+{ |
|
5156 |
+ DBusGProxy *proxy; |
|
5157 |
+ char *ssid; |
|
5158 |
+ char *sid; |
|
5159 |
+ gboolean is_last_session; |
|
5160 |
+ |
|
5161 |
+ if (!g_str_has_prefix (session_id, CK_PATH_PREFIX)) { |
|
5162 |
+ ssid = g_strdup_printf ("%s%s", CK_PATH_PREFIX, session_id); |
|
16129 | 5163 |
+ } else { |
16232 | 5164 |
+ ssid = g_strdup (session_id); |
5165 |
+ } |
|
5166 |
+ |
|
5167 |
+ proxy = dbus_g_proxy_new_for_name (connection, |
|
5168 |
+ CK_NAME, |
|
5169 |
+ CK_MANAGER_PATH, |
|
5170 |
+ CK_MANAGER_INTERFACE); |
|
5171 |
+ if (proxy == NULL) { |
|
5172 |
+ return; |
|
16129 | 5173 |
+ } |
5174 |
+ |
|
16232 | 5175 |
+ sid = find_seat_id_from_session_id (connection, proxy, ssid, &is_last_session); |
5176 |
+ |
|
5177 |
+ dbus_g_proxy_call_no_reply (proxy, |
|
5178 |
+ "RemoveSession", |
|
5179 |
+ DBUS_TYPE_G_OBJECT_PATH, ssid, |
|
5180 |
+ G_TYPE_INVALID, |
|
5181 |
+ G_TYPE_INVALID); |
|
5182 |
+ |
|
5183 |
+ if (is_last_session) { |
|
5184 |
+ dbus_g_proxy_call_no_reply (proxy, |
|
5185 |
+ "RemoveSeat", |
|
5186 |
+ DBUS_TYPE_G_OBJECT_PATH, sid, |
|
5187 |
+ G_TYPE_INVALID, |
|
5188 |
+ G_TYPE_INVALID); |
|
5189 |
+ } |
|
16129 | 5190 |
+ |
5191 |
+ g_object_unref (proxy); |
|
5192 |
+} |
|
5193 |
+ |
|
5194 |
+int |
|
5195 |
+main (int argc, char *argv[]) |
|
5196 |
+{ |
|
5197 |
+ DBusGConnection *connection; |
|
5198 |
+ GOptionContext *ctx; |
|
5199 |
+ GError *error = NULL; |
|
5200 |
+ gboolean res; |
|
5201 |
+ |
|
5202 |
+ g_type_init (); |
|
5203 |
+ |
|
5204 |
+ /* Option parsing */ |
|
16232 | 5205 |
+ ctx = g_option_context_new (_("- Manage dynamic sessions")); |
5206 |
+ g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE); |
|
16129 | 5207 |
+ res = g_option_context_parse (ctx, &argc, &argv, &error); |
5208 |
+ |
|
5209 |
+ if (!res) { |
|
5210 |
+ if (error) { |
|
5211 |
+ g_warning ("%s", error->message); |
|
5212 |
+ g_error_free (error); |
|
5213 |
+ } |
|
5214 |
+ exit (1); |
|
5215 |
+ } |
|
5216 |
+ |
|
5217 |
+ g_option_context_free (ctx); |
|
5218 |
+ |
|
5219 |
+ if (show_version) { |
|
5220 |
+ g_print ("%s %s\n", argv[0], VERSION); |
|
5221 |
+ exit (0); |
|
5222 |
+ } |
|
5223 |
+ |
|
5224 |
+ if (add && delete) { |
|
5225 |
+ g_warning ("Can not specify -a and -d at the same time!"); |
|
5226 |
+ exit (1); |
|
5227 |
+ } |
|
5228 |
+ |
|
16232 | 5229 |
+ if (!add && !delete) { |
5230 |
+ g_warning ("Must specify -a, -d!"); |
|
16129 | 5231 |
+ exit (1); |
5232 |
+ } |
|
5233 |
+ |
|
16232 | 5234 |
+ if (delete && (! IS_STR_SET (session_id))) { |
5235 |
+ g_warning ("You must specify session id for deleting a session. You can get all sessions by ck-list-sessions"); |
|
16129 | 5236 |
+ exit (1); |
5237 |
+ } |
|
5238 |
+ |
|
16232 | 5239 |
+ if (add && (! IS_STR_SET (display_type)) ) { |
5240 |
+ g_warning ("You must specify display type for adding a session. You can get all display types under <etc>/ConsoleKit/displays.d/"); |
|
16129 | 5241 |
+ g_warning ("Invalid display type!"); |
5242 |
+ exit (1); |
|
5243 |
+ } |
|
5244 |
+ |
|
5245 |
+ error = NULL; |
|
5246 |
+ connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); |
|
5247 |
+ if (connection == NULL) { |
|
5248 |
+ g_message ("Failed to connect to the D-Bus daemon: %s", error->message); |
|
5249 |
+ g_error_free (error); |
|
5250 |
+ exit (1); |
|
5251 |
+ } |
|
5252 |
+ |
|
5253 |
+ |
|
5254 |
+ if (add) { |
|
16232 | 5255 |
+ add_session (connection); |
16129 | 5256 |
+ } else if (delete) { |
16232 | 5257 |
+ delete_session (connection); |
16129 | 5258 |
+ } else { |
5259 |
+ g_warning ("Invaild parameters!"); |
|
5260 |
+ exit (1); |
|
5261 |
+ } |
|
5262 |
+ |
|
5263 |
+ return 0; |
|
5264 |
+} |
|
5265 |
diff --git a/tools/list-sessions.c b/tools/list-sessions.c |
|
16540 | 5266 |
index 3933772..cc69d57 100644 |
16129 | 5267 |
--- a/tools/list-sessions.c |
5268 |
+++ b/tools/list-sessions.c |
|
16540 | 5269 |
@@ -46,6 +46,23 @@ |
16232 | 5270 |
#define CK_SEAT_INTERFACE "org.freedesktop.ConsoleKit.Seat" |
5271 |
#define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session" |
|
5272 |
||
5273 |
+#define IS_STR_SET(x) (x != NULL && x[0] != '\0') |
|
5274 |
+ |
|
5275 |
+typedef struct CkSessionOutput { |
|
5276 |
+ char *prop_name; |
|
5277 |
+ char *prop_value; |
|
5278 |
+} CkSessionOutput; |
|
5279 |
+ |
|
16475 | 5280 |
+static gboolean do_all = FALSE; |
16232 | 5281 |
+static gboolean do_version = FALSE; |
5282 |
+static char *do_format = NULL; |
|
5283 |
+static GOptionEntry entries [] = { |
|
16475 | 5284 |
+ { "all", 'a', 0, G_OPTION_ARG_NONE, &do_all, N_("List all sessions. If not given, only list open sessions"), NULL }, |
16232 | 5285 |
+ { "format", 'f', 0, G_OPTION_ARG_STRING, &do_format, N_("Prints information according to the given format"), NULL }, |
5286 |
+ { "version", 'V', 0, G_OPTION_ARG_NONE, &do_version, N_("Version of this application"), NULL }, |
|
5287 |
+ { NULL } |
|
5288 |
+}; |
|
5289 |
+ |
|
5290 |
static gboolean |
|
5291 |
get_uint (DBusGProxy *proxy, |
|
5292 |
const char *method, |
|
16540 | 5293 |
@@ -176,6 +193,7 @@ list_session (DBusGConnection *connection, |
16232 | 5294 |
char *sid; |
5295 |
char *lsid; |
|
5296 |
char *session_type; |
|
5297 |
+ char *display_type; |
|
5298 |
char *x11_display; |
|
5299 |
char *x11_display_device; |
|
5300 |
char *display_device; |
|
16540 | 5301 |
@@ -184,8 +202,11 @@ list_session (DBusGConnection *connection, |
16129 | 5302 |
char *idle_since_hint; |
5303 |
gboolean is_active; |
|
5304 |
gboolean is_local; |
|
16232 | 5305 |
+ gboolean is_open; |
16129 | 5306 |
char *short_sid; |
5307 |
const char *short_ssid; |
|
16540 | 5308 |
+ char **format_arr = NULL; |
5309 |
+ int i, j; |
|
16129 | 5310 |
|
16232 | 5311 |
proxy = dbus_g_proxy_new_for_name (connection, |
5312 |
CK_NAME, |
|
16540 | 5313 |
@@ -198,6 +219,7 @@ list_session (DBusGConnection *connection, |
16232 | 5314 |
sid = NULL; |
5315 |
lsid = NULL; |
|
5316 |
session_type = NULL; |
|
5317 |
+ display_type = NULL; |
|
5318 |
x11_display = NULL; |
|
5319 |
x11_display_device = NULL; |
|
5320 |
display_device = NULL; |
|
16540 | 5321 |
@@ -209,15 +231,21 @@ list_session (DBusGConnection *connection, |
16232 | 5322 |
get_path (proxy, "GetSeatId", &sid); |
5323 |
get_string (proxy, "GetLoginSessionId", &lsid); |
|
5324 |
get_string (proxy, "GetSessionType", &session_type); |
|
5325 |
+ get_string (proxy, "GetDisplayType", &display_type); |
|
5326 |
get_string (proxy, "GetX11Display", &x11_display); |
|
5327 |
get_string (proxy, "GetX11DisplayDevice", &x11_display_device); |
|
5328 |
get_string (proxy, "GetDisplayDevice", &display_device); |
|
16129 | 5329 |
get_string (proxy, "GetRemoteHostName", &remote_host_name); |
16232 | 5330 |
+ get_boolean (proxy, "IsOpen", &is_open); |
16129 | 5331 |
get_boolean (proxy, "IsActive", &is_active); |
5332 |
get_boolean (proxy, "IsLocal", &is_local); |
|
5333 |
get_string (proxy, "GetCreationTime", &creation_time); |
|
16475 | 5334 |
get_string (proxy, "GetIdleSinceHint", &idle_since_hint); |
5335 |
||
5336 |
+ if (!do_all && !is_open) { |
|
5337 |
+ return; |
|
5338 |
+ } |
|
5339 |
+ |
|
5340 |
realname = get_real_name (uid); |
|
5341 |
||
5342 |
short_sid = sid; |
|
16540 | 5343 |
@@ -230,24 +258,49 @@ list_session (DBusGConnection *connection, |
16129 | 5344 |
short_ssid = ssid + strlen (CK_PATH) + 1; |
5345 |
} |
|
5346 |
||
5347 |
- printf ("%s:\n\tunix-user = '%d'\n\trealname = '%s'\n\tseat = '%s'\n\tsession-type = '%s'\n\tactive = %s\n\tx11-display = '%s'\n\tx11-display-device = '%s'\n\tdisplay-device = '%s'\n\tremote-host-name = '%s'\n\tis-local = %s\n\ton-since = '%s'\n\tlogin-session-id = '%s'", |
|
16232 | 5348 |
- short_ssid, |
5349 |
- uid, |
|
5350 |
- realname, |
|
5351 |
- short_sid, |
|
5352 |
- session_type, |
|
5353 |
- is_active ? "TRUE" : "FALSE", |
|
5354 |
- x11_display, |
|
5355 |
- x11_display_device, |
|
5356 |
- display_device, |
|
5357 |
- remote_host_name, |
|
5358 |
- is_local ? "TRUE" : "FALSE", |
|
5359 |
- creation_time, |
|
5360 |
- lsid); |
|
5361 |
- if (idle_since_hint != NULL && idle_since_hint[0] != '\0') { |
|
5362 |
- printf ("\n\tidle-since-hint = '%s'", idle_since_hint); |
|
5363 |
+ CkSessionOutput output[] = { |
|
5364 |
+ {"session-id", g_strdup (short_ssid)}, |
|
5365 |
+ {"unix-user", g_strdup_printf ("%d", uid)}, |
|
5366 |
+ {"realname", g_strdup (realname)}, |
|
5367 |
+ {"seat", g_strdup (short_sid)}, |
|
5368 |
+ {"session-type", g_strdup (session_type)}, |
|
5369 |
+ {"display-type", g_strdup (display_type)}, |
|
5370 |
+ {"open", is_open ? "TRUE" : "FALSE"}, |
|
5371 |
+ {"active", is_active ? "TRUE" : "FALSE"}, |
|
5372 |
+ {"x11-display", g_strdup (x11_display)}, |
|
5373 |
+ {"x11-display-device", g_strdup (x11_display_device)}, |
|
5374 |
+ {"display-device", g_strdup (display_device)}, |
|
5375 |
+ {"remote-host-name", g_strdup (remote_host_name)}, |
|
5376 |
+ {"is-local", is_local ? "TRUE" : "FALSE"}, |
|
5377 |
+ {"on-since", g_strdup (creation_time)}, |
|
5378 |
+ {"login-session-id", g_strdup (lsid)}, |
|
5379 |
+ {"idle-since-hint", g_strdup (idle_since_hint)}, |
|
5380 |
+ }; |
|
5381 |
+ |
|
16540 | 5382 |
+ if (IS_STR_SET (do_format)) { |
5383 |
+ format_arr = g_strsplit (do_format, ",", -1); |
|
5384 |
+ |
|
5385 |
+ for (i = 0; format_arr[i] != NULL; ++i) { |
|
5386 |
+ for (j = 0; j < G_N_ELEMENTS (output); j++) { |
|
5387 |
+ if (g_str_equal (format_arr[i], output[j].prop_name)) { |
|
5388 |
+ printf ("'%s'\t", output[j].prop_value); |
|
5389 |
+ break; |
|
5390 |
+ } |
|
5391 |
+ } |
|
5392 |
+ } |
|
5393 |
+ printf ("\n"); |
|
5394 |
+ g_strfreev (format_arr); |
|
5395 |
+ |
|
5396 |
+ } else { |
|
5397 |
+ for (j = 0; j < G_N_ELEMENTS (output); j++) { |
|
5398 |
+ if (g_str_equal (output[j].prop_name, "session-id")) |
|
5399 |
+ printf ("%s:\n", output[j].prop_value); |
|
5400 |
+ else |
|
5401 |
+ printf ("\t%s = '%s'\n", |
|
5402 |
+ output[j].prop_name, |
|
5403 |
+ output[j].prop_value); |
|
5404 |
+ } |
|
16232 | 5405 |
} |
5406 |
- printf ("\n"); |
|
5407 |
||
5408 |
g_free (idle_since_hint); |
|
5409 |
g_free (creation_time); |
|
16540 | 5410 |
@@ -256,9 +309,11 @@ list_session (DBusGConnection *connection, |
16232 | 5411 |
g_free (sid); |
5412 |
g_free (lsid); |
|
5413 |
g_free (session_type); |
|
5414 |
+ g_free (display_type); |
|
5415 |
g_free (x11_display); |
|
5416 |
g_free (x11_display_device); |
|
5417 |
g_free (display_device); |
|
5418 |
+ |
|
5419 |
g_object_unref (proxy); |
|
5420 |
} |
|
5421 |
||
16540 | 5422 |
@@ -368,11 +423,6 @@ main (int argc, |
16232 | 5423 |
GOptionContext *context; |
5424 |
gboolean retval; |
|
5425 |
GError *error = NULL; |
|
5426 |
- static gboolean do_version = FALSE; |
|
5427 |
- static GOptionEntry entries [] = { |
|
5428 |
- { "version", 'V', 0, G_OPTION_ARG_NONE, &do_version, N_("Version of this application"), NULL }, |
|
5429 |
- { NULL } |
|
5430 |
- }; |
|
5431 |
||
5432 |
g_type_init (); |
|
5433 |