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