patches/ConsoleKit-01-ck-dynamic.diff
author yippi
Mon, 27 Sep 2010 21:07:51 +0000
changeset 20108 51df67ca9307
parent 20041 0f108313f190
child 21492 35f92dfb2e7b
permissions -rw-r--r--
I had these modules listed as being owned by me, but they are really owned by wangke, correcting.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
     1
diff --git a/configure.ac b/configure.ac
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
     2
index 117d788..2ff6020 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
     3
--- a/configure.ac
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
     4
+++ b/configure.ac
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
     5
@@ -203,6 +203,18 @@ AM_CONDITIONAL(CK_COMPILE_SOLARIS, test x$CK_BACKEND = xsolaris, [Compiling for
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
     6
 AC_SUBST(CK_BACKEND)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
     7
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
     8
 dnl ---------------------------------------------------------------------------
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
     9
+dnl Check for X11 DIR
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    10
+dnl ---------------------------------------------------------------------------
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    11
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    12
+X11_DIR=`$PKG_CONFIG --variable=bindir xorg-server 2>/dev/null`
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    13
+if test "x$X11_DIR" = x; then
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    14
+    AC_PATH_PROGS([XSERVER], [Xorg X],,[$PATH:/usr/X11/bin:/usr/bin])
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    15
+    test "x$XSERVER" != x && X11_DIR=`dirname "$XSERVER"`
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    16
+fi
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    17
+test "x$X11_DIR" = x && X11_DIR=$bindir
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    18
+AC_SUBST([X11_DIR])
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    19
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    20
+dnl ---------------------------------------------------------------------------
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    21
 dnl Check for PAM
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    22
 dnl ---------------------------------------------------------------------------
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    23
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    24
@@ -303,6 +315,14 @@ if test "x$enable_inotify" = "xyes" ; then
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    25
 fi
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    26
 
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    27
 dnl ---------------------------------------------------------------------------
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    28
+dnl check for strverscmp
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    29
+dnl ---------------------------------------------------------------------------
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    30
+have_strverscmp=no
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    31
+AC_CHECK_FUNCS(strverscmp, [have_strverscmp=yes], [])
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    32
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    33
+AM_CONDITIONAL(USE_SELF_STRVERSCMP, test "x$have_strverscmp" = "xno", [Define if we do not have strverscmp])
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    34
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    35
+dnl ---------------------------------------------------------------------------
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    36
 dnl check for RBAC
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    37
 dnl ---------------------------------------------------------------------------
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    38
 
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    39
@@ -401,6 +421,8 @@ tools/linux/Makefile
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    40
 tools/freebsd/Makefile
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    41
 tools/solaris/Makefile
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    42
 data/Makefile
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    43
+data/displays.d/Makefile
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
    44
+data/sessions.d/Makefile
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    45
 doc/Makefile
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    46
 doc/dbus/ConsoleKit.xml
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    47
 doc/dbus/Makefile
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    48
diff --git a/data/00-primary.seat b/data/00-primary.seat
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    49
index 6e61db4..0632382 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    50
--- a/data/00-primary.seat
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    51
+++ b/data/00-primary.seat
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    52
@@ -1,5 +1,26 @@
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    53
 [Seat Entry]
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    54
 Version=1.0
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    55
 Name=Primary seat
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    56
+# Specified Seat ID, if this value is NULL, ConsoleKit will decide one.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    57
+# The ID only contain the ASICC characters "[A-Z][a-z][0-9]_" 
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
    58
+ID=StaticSeat1
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    59
+Description=start one static local display at :0
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    60
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    61
+# Indicate whether to create this seat or not. If it is set true, then CK will
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    62
+# not create this seat. Default value is false.
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    63
 Hidden=false
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    64
-Devices=
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    65
\ No newline at end of file
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    66
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    67
+# Indicate input/output devices including keyboard-pointer-video
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    68
+# card-monitor-sound-usb devices,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    69
+# This key will not implemented now, it might need be divided into
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    70
+# several keys in the future:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    71
+# Pointer=
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    72
+# Monitor=
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    73
+# VideoCard=
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    74
+# Monitor=
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    75
+# UsbHub=
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    76
+Devices=
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    77
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
    78
+# List of sessions to start on the seat, separated by ';'
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
    79
+# Each session is defined in sessions.d/
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
    80
+Sessions=Local;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    81
diff --git a/data/ConsoleKit.conf b/data/ConsoleKit.conf
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
    82
index 948f95f..8cf490a 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    83
--- a/data/ConsoleKit.conf
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
    84
+++ b/data/ConsoleKit.conf
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
    85
@@ -44,6 +44,9 @@
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
    86
            send_member="CloseSession"/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
    87
     <allow send_destination="org.freedesktop.ConsoleKit"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
    88
            send_interface="org.freedesktop.ConsoleKit.Manager"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
    89
+           send_member="GetUnmanagedSeats"/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
    90
+    <allow send_destination="org.freedesktop.ConsoleKit"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
    91
+           send_interface="org.freedesktop.ConsoleKit.Manager"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
    92
            send_member="GetSeats"/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
    93
     <allow send_destination="org.freedesktop.ConsoleKit"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
    94
            send_interface="org.freedesktop.ConsoleKit.Manager"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
    95
@@ -69,6 +72,18 @@
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
    96
     <allow send_destination="org.freedesktop.ConsoleKit"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
    97
            send_interface="org.freedesktop.ConsoleKit.Manager"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
    98
            send_member="GetSystemIdleSinceHint"/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
    99
+    <allow send_destination="org.freedesktop.ConsoleKit"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   100
+           send_interface="org.freedesktop.ConsoleKit.Manager"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   101
+           send_member="AddSeat"/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   102
+    <allow send_destination="org.freedesktop.ConsoleKit"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   103
+           send_interface="org.freedesktop.ConsoleKit.Manager"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   104
+           send_member="RemoveSeat"/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   105
+    <allow send_destination="org.freedesktop.ConsoleKit"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   106
+           send_interface="org.freedesktop.ConsoleKit.Manager"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   107
+           send_member="AddSession"/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   108
+    <allow send_destination="org.freedesktop.ConsoleKit"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   109
+           send_interface="org.freedesktop.ConsoleKit.Manager"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   110
+           send_member="RemoveSession"/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   111
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   112
     <allow send_destination="org.freedesktop.ConsoleKit"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   113
            send_interface="org.freedesktop.ConsoleKit.Seat"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   114
@@ -88,6 +103,9 @@
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   115
     <allow send_destination="org.freedesktop.ConsoleKit"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   116
            send_interface="org.freedesktop.ConsoleKit.Seat"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   117
            send_member="ActivateSession"/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   118
+    <allow send_destination="org.freedesktop.ConsoleKit"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   119
+           send_interface="org.freedesktop.ConsoleKit.Seat"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   120
+           send_member="ManageSeat"/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   121
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   122
     <allow send_destination="org.freedesktop.ConsoleKit"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   123
            send_interface="org.freedesktop.ConsoleKit.Session"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   124
@@ -103,6 +121,9 @@
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   125
            send_member="GetSessionType"/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   126
     <allow send_destination="org.freedesktop.ConsoleKit"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   127
            send_interface="org.freedesktop.ConsoleKit.Session"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   128
+           send_member="GetDisplayType"/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   129
+    <allow send_destination="org.freedesktop.ConsoleKit"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   130
+           send_interface="org.freedesktop.ConsoleKit.Session"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   131
            send_member="GetUser"/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   132
     <allow send_destination="org.freedesktop.ConsoleKit"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   133
            send_interface="org.freedesktop.ConsoleKit.Session"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   134
@@ -127,6 +148,12 @@
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   135
            send_member="IsLocal"/>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   136
     <allow send_destination="org.freedesktop.ConsoleKit"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   137
            send_interface="org.freedesktop.ConsoleKit.Session"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   138
+           send_member="IsDynamic"/>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   139
+    <allow send_destination="org.freedesktop.ConsoleKit"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   140
+           send_interface="org.freedesktop.ConsoleKit.Session"
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   141
+           send_member="IsOpen"/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   142
+    <allow send_destination="org.freedesktop.ConsoleKit"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   143
+           send_interface="org.freedesktop.ConsoleKit.Session"
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   144
            send_member="GetCreationTime"/>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   145
     <allow send_destination="org.freedesktop.ConsoleKit"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   146
            send_interface="org.freedesktop.ConsoleKit.Session"
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
   147
@@ -136,12 +163,11 @@
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
   148
            send_member="GetIdleHint"/>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
   149
     <allow send_destination="org.freedesktop.ConsoleKit"
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
   150
            send_interface="org.freedesktop.ConsoleKit.Session"
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
   151
-           send_member="SetIdleHint"/>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
   152
-    <allow send_destination="org.freedesktop.ConsoleKit"
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
   153
-           send_interface="org.freedesktop.ConsoleKit.Session"
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
   154
            send_member="GetIdleSinceHint"/>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
   155
     <allow send_interface="org.freedesktop.ConsoleKit.Session"
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
   156
            send_member="SetIdleHint"/>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
   157
+    <allow send_interface="org.freedesktop.ConsoleKit.Session"
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
   158
+           send_member="SetRemoveOnClose"/>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
   159
   </policy>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
   160
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
   161
 </busconfig>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   162
diff --git a/data/Makefile.am b/data/Makefile.am
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   163
index 041b431..2054e96 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   164
--- a/data/Makefile.am
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   165
+++ b/data/Makefile.am
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   166
@@ -1,5 +1,10 @@
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   167
 NULL =
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   168
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   169
+SUBDIRS = \
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   170
+	displays.d	\
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   171
+	sessions.d	\
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   172
+        $(NULL)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   173
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   174
 dbusconfdir = $(DBUS_SYS_DIR)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   175
 dbusconf_DATA = ConsoleKit.conf
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   176
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   177
diff --git a/data/displays.d/Headless.display.in b/data/displays.d/Headless.display.in
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   178
new file mode 100644
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   179
index 0000000..754d2bf
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   180
--- /dev/null
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   181
+++ b/data/displays.d/Headless.display.in
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   182
@@ -0,0 +1,5 @@
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   183
+[Display]
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   184
+Type=X11
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   185
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   186
+[X11]
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   187
+Exec=@X11_DIR@/Xvfb $display -auth $auth
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   188
diff --git a/data/displays.d/Local.display.in b/data/displays.d/Local.display.in
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   189
new file mode 100644
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   190
index 0000000..b845a7b
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   191
--- /dev/null
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   192
+++ b/data/displays.d/Local.display.in
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   193
@@ -0,0 +1,5 @@
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   194
+[Display]
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   195
+Type=X11
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   196
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   197
+[X11]
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   198
+Exec=@X11_DIR@/Xorg $display -br -verbose -auth $auth -nolisten tcp $vt
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   199
diff --git a/data/displays.d/LocalVNC.display.in b/data/displays.d/LocalVNC.display.in
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   200
new file mode 100644
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   201
index 0000000..6ad336b
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   202
--- /dev/null
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   203
+++ b/data/displays.d/LocalVNC.display.in
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   204
@@ -0,0 +1,5 @@
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   205
+[Display]
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   206
+Type=X11
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   207
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   208
+[X11]
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   209
+Exec=@X11_DIR@/Xvnc $display -auth $auth -query localhost
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   210
diff --git a/data/displays.d/Makefile.am b/data/displays.d/Makefile.am
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   211
new file mode 100644
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   212
index 0000000..1fab1d2
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   213
--- /dev/null
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   214
+++ b/data/displays.d/Makefile.am
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   215
@@ -0,0 +1,29 @@
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   216
+NULL =
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   217
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   218
+displaydir = $(sysconfdir)/ConsoleKit/displays.d
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   219
+display_in_files = \
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   220
+	Local.display.in \
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   221
+	RemoteMachine.display.in \
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   222
+	LocalVNC.display.in \
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   223
+	Headless.display.in
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   224
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   225
+display_DATA = $(display_in_files:.display.in=.display)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   226
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   227
+Local.display: Local.display.in Makefile
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   228
+	sed -e "s|\@X11_DIR\@|$(X11_DIR)|" $< > $@
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   229
+RemoteMachine.display: RemoteMachine.display.in Makefile
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   230
+	sed -e "s|\@X11_DIR\@|$(X11_DIR)|" $< > $@
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   231
+LocalVNC.display: LocalVNC.display.in Makefile
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   232
+	sed -e "s|\@X11_DIR\@|$(X11_DIR)|" $< > $@
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   233
+Headless.display: Headless.display.in Makefile
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   234
+	sed -e "s|\@X11_DIR\@|$(X11_DIR)|" $< > $@
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   235
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   236
+EXTRA_DIST =						\
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   237
+	$(display_in_files)				\
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   238
+	$(NULL)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   239
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   240
+MAINTAINERCLEANFILES =			\
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   241
+	*~				\
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   242
+	Makefile.in
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   243
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   244
+CLEANFILES = $(display_DATA)
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   245
diff --git a/data/displays.d/RemoteMachine.display.in b/data/displays.d/RemoteMachine.display.in
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   246
new file mode 100644
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   247
index 0000000..7c69451
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   248
--- /dev/null
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   249
+++ b/data/displays.d/RemoteMachine.display.in
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   250
@@ -0,0 +1,5 @@
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   251
+[Display]
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   252
+Type=X11
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   253
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   254
+[X11]
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   255
+Exec=@X11_DIR@/Xorg $display -br -verbose -auth $auth -indirect $vt
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   256
diff --git a/data/sessions.d/Headless.session b/data/sessions.d/Headless.session
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   257
new file mode 100644
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   258
index 0000000..d376af9
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   259
--- /dev/null
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   260
+++ b/data/sessions.d/Headless.session
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   261
@@ -0,0 +1,8 @@
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   262
+[Session Entry]
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   263
+Name=Headless
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   264
+Type=LoginWindow
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   265
+Description=Login Window running on headless display
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   266
+DisplayTemplate=Headless
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   267
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   268
+[Headless]
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   269
+display=:32
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   270
diff --git a/data/sessions.d/Local.session b/data/sessions.d/Local.session
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   271
new file mode 100644
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   272
index 0000000..9d3b975
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   273
--- /dev/null
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   274
+++ b/data/sessions.d/Local.session
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   275
@@ -0,0 +1,9 @@
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   276
+[Session Entry]
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   277
+Name=Local
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   278
+Type=LoginWindow
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   279
+Description=Local Login Screen
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   280
+DisplayTemplate=Local
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   281
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   282
+[Local]
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   283
+display=:0
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   284
+vt=vt1
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   285
diff --git a/data/sessions.d/LocalVNC.session b/data/sessions.d/LocalVNC.session
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   286
new file mode 100644
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   287
index 0000000..c05802f
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   288
--- /dev/null
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   289
+++ b/data/sessions.d/LocalVNC.session
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   290
@@ -0,0 +1,8 @@
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   291
+[Session Entry]
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   292
+Name=LocalVNC
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   293
+Type=LoginWindow
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   294
+Description=Connect to local VNC server running on same machine
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   295
+DisplayTemplate=LocalVNC
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   296
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   297
+[LocalVNC]
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   298
+display=:64
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   299
diff --git a/data/sessions.d/Makefile.am b/data/sessions.d/Makefile.am
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   300
new file mode 100644
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   301
index 0000000..f17ffdc
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   302
--- /dev/null
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   303
+++ b/data/sessions.d/Makefile.am
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   304
@@ -0,0 +1,16 @@
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   305
+NULL =
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   306
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   307
+sessiondir = $(sysconfdir)/ConsoleKit/sessions.d
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   308
+session_DATA = \
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   309
+	Headless.session		\
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   310
+	Local.session			\
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   311
+	LocalVNC.session		\
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   312
+	Remote.session
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   313
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   314
+EXTRA_DIST =				\
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   315
+	$(session_DATA)			\
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   316
+	$(NULL)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   317
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   318
+MAINTAINERCLEANFILES =			\
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   319
+	*~				\
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   320
+	Makefile.in
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   321
diff --git a/data/sessions.d/Remote.session b/data/sessions.d/Remote.session
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   322
new file mode 100644
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   323
index 0000000..e88f975
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   324
--- /dev/null
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   325
+++ b/data/sessions.d/Remote.session
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   326
@@ -0,0 +1,9 @@
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   327
+[Session Entry]
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   328
+Name=Remote Chooser
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   329
+Type=Remote
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   330
+Description=Connect to chooser on nearby remote machine
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   331
+DisplayTemplate=RemoteMachine
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   332
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   333
+[RemoteMachine]
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   334
+display=:96
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   335
+vt=vt10
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   336
diff --git a/doc/dbus/ck-terms.xml b/doc/dbus/ck-terms.xml
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   337
index d3d544d..1b43ca6 100644
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   338
--- a/doc/dbus/ck-terms.xml
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   339
+++ b/doc/dbus/ck-terms.xml
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   340
@@ -64,4 +64,11 @@ True, hardware, multi-seat capabilities will be added in a later release.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   341
     </para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   342
   </sect1>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   343
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   344
+  <sect1>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   345
+    <title>Seat manager</title>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   346
+    <para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   347
+The seat manager is the process responsible for starting and stopping sessions on a seat.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   348
+    </para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   349
+  </sect1>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   350
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   351
 </chapter>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   352
diff --git a/libck-connector/ck-connector.c b/libck-connector/ck-connector.c
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   353
index 7f6f87f..87a7d4a 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   354
--- a/libck-connector/ck-connector.c
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   355
+++ b/libck-connector/ck-connector.c
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   356
@@ -76,8 +76,11 @@ static struct {
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   357
         { "display-device",     DBUS_TYPE_STRING },
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   358
         { "x11-display-device", DBUS_TYPE_STRING },
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   359
         { "x11-display",        DBUS_TYPE_STRING },
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   360
+        { "seat-id",            DBUS_TYPE_STRING },
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   361
+        { "session",            DBUS_TYPE_STRING },
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   362
         { "remote-host-name",   DBUS_TYPE_STRING },
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   363
         { "session-type",       DBUS_TYPE_STRING },
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   364
+        { "display-type",       DBUS_TYPE_STRING },
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   365
         { "is-local",           DBUS_TYPE_BOOLEAN },
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   366
         { "unix-user",          DBUS_TYPE_INT32 },
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   367
 };
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   368
diff --git a/src/Makefile.am b/src/Makefile.am
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   369
index 6ab05c8..97a59ef 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   370
--- a/src/Makefile.am
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   371
+++ b/src/Makefile.am
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   372
@@ -107,6 +107,8 @@ console_kit_daemon_SOURCES =	\
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   373
 	ck-file-monitor.h	\
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   374
 	ck-job.h		\
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   375
 	ck-job.c		\
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   376
+	ck-display-template.h	\
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   377
+	ck-display-template.c	\
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   378
 	ck-seat.h		\
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   379
 	ck-seat.c		\
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   380
 	ck-session-leader.h	\
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   381
@@ -122,6 +124,13 @@ console_kit_daemon_SOURCES =	\
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   382
 	$(BUILT_SOURCES)	\
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   383
 	$(NULL)
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   384
 
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   385
+if USE_SELF_STRVERSCMP
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   386
+console_kit_daemon_SOURCES +=	\
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   387
+	strverscmp.c		\
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   388
+	strverscmp.h		\
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   389
+	$(NULL)
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   390
+endif
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   391
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   392
 if ENABLE_INOTIFY
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   393
 FILE_MONITOR_BACKEND = ck-file-monitor-inotify.c
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   394
 else
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   395
diff --git a/src/ck-display-template.c b/src/ck-display-template.c
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   396
new file mode 100644
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   397
index 0000000..9206103
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   398
--- /dev/null
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   399
+++ b/src/ck-display-template.c
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   400
@@ -0,0 +1,341 @@
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   401
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   402
+ *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   403
+ * Authors: [email protected], Ray Strode <[email protected]>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   404
+ * Copyright (C) 2009 Sun Microsystems, Inc.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   405
+ *                    Red Hat, Inc.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   406
+ *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   407
+ * This program is free software; you can redistribute it and/or modify
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   408
+ * it under the terms of the GNU General Public License as published by
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   409
+ * the Free Software Foundation; either version 2 of the License, or
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   410
+ * (at your option) any later version.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   411
+ *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   412
+ * This program is distributed in the hope that it will be useful,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   413
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   414
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   415
+ * GNU General Public License for more details.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   416
+ *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   417
+ * You should have received a copy of the GNU General Public License
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   418
+ * along with this program; if not, write to the Free Software
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   419
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   420
+ *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   421
+ */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   422
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   423
+#include "config.h"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   424
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   425
+#include <string.h>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   426
+#include <glib.h>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   427
+#include <glib-object.h>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   428
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   429
+#include "ck-display-template.h"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   430
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   431
+#define CK_DISPLAY_TEMPLATE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CK_TYPE_DISPLAY_TEMPLATE, CkDisplayTemplatePrivate))
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   432
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   433
+#define CK_DISPLAY_TEMPLATES_DIR     SYSCONFDIR "/ConsoleKit/displays.d"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   434
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   435
+struct CkDisplayTemplatePrivate
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   436
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   437
+        char            *name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   438
+        char            *type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   439
+        GHashTable      *parameters;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   440
+};
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   441
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   442
+enum {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   443
+        PROP_0,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   444
+        PROP_NAME,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   445
+        PROP_TYPE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   446
+        PROP_PARAMETERS,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   447
+};
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   448
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   449
+static void     ck_display_template_class_init  (CkDisplayTemplateClass *klass);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   450
+static void     ck_display_template_init        (CkDisplayTemplate      *display);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   451
+static void     ck_display_template_finalize    (GObject            *object);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   452
+static gboolean ck_display_template_load        (CkDisplayTemplate      *display);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   453
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   454
+static GHashTable *ck_display_templates;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   455
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   456
+G_DEFINE_TYPE (CkDisplayTemplate, ck_display_template, G_TYPE_OBJECT)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   457
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   458
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   459
+_ck_display_template_set_name (CkDisplayTemplate  *display,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   460
+                               const char     *name)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   461
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   462
+        g_free (display->priv->name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   463
+        display->priv->name = g_strdup (name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   464
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   465
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   466
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   467
+_ck_display_template_set_type_string (CkDisplayTemplate  *display,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   468
+                                      const char     *type)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   469
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   470
+        g_free (display->priv->type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   471
+        display->priv->type = g_strdup (type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   472
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   473
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   474
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   475
+_ck_display_template_set_parameters (CkDisplayTemplate  *display,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   476
+                                     GHashTable     *parameters)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   477
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   478
+        if (display->priv->parameters != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   479
+                g_hash_table_unref (display->priv->parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   480
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   481
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   482
+        if (parameters == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   483
+                display->priv->parameters = g_hash_table_new_full (g_str_hash, g_str_equal,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   484
+                                                                   (GDestroyNotify) g_free,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   485
+                                                                   (GDestroyNotify) g_free);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   486
+        } else {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   487
+                display->priv->parameters = g_hash_table_ref (parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   488
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   489
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   490
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   491
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   492
+ck_display_template_set_property (GObject      *object,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   493
+                                  guint         prop_id,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   494
+                                  const GValue *value,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   495
+                                  GParamSpec   *pspec)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   496
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   497
+        CkDisplayTemplate *self;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   498
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   499
+        self = CK_DISPLAY_TEMPLATE (object);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   500
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   501
+        switch (prop_id) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   502
+        case PROP_NAME:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   503
+                _ck_display_template_set_name (self, g_value_get_string (value));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   504
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   505
+        case PROP_TYPE:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   506
+                _ck_display_template_set_type_string (self, g_value_get_string (value));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   507
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   508
+        case PROP_PARAMETERS:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   509
+                _ck_display_template_set_parameters (self, g_value_get_boxed (value));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   510
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   511
+        default:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   512
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   513
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   514
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   515
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   516
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   517
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   518
+ck_display_template_get_property (GObject    *object,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   519
+                                  guint       prop_id,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   520
+                                  GValue     *value,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   521
+                                  GParamSpec *pspec)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   522
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   523
+        CkDisplayTemplate *self;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   524
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   525
+        self = CK_DISPLAY_TEMPLATE (object);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   526
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   527
+        switch (prop_id) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   528
+        case PROP_NAME:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   529
+                g_value_set_string (value, self->priv->name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   530
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   531
+        case PROP_TYPE:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   532
+                g_value_set_string (value, self->priv->type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   533
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   534
+        case PROP_PARAMETERS:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   535
+                g_value_set_boxed (value, self->priv->parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   536
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   537
+        default:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   538
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   539
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   540
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   541
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   542
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   543
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   544
+ck_display_template_class_init (CkDisplayTemplateClass *klass)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   545
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   546
+        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   547
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   548
+        object_class->get_property = ck_display_template_get_property;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   549
+        object_class->set_property = ck_display_template_set_property;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   550
+        object_class->finalize = ck_display_template_finalize;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   551
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   552
+        g_object_class_install_property (object_class,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   553
+                                         PROP_NAME,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   554
+                                         g_param_spec_string ("name",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   555
+                                                              "display type name",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   556
+                                                              "display type name",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   557
+                                                              NULL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   558
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   559
+        g_object_class_install_property (object_class,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   560
+                                         PROP_TYPE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   561
+                                         g_param_spec_string ("type",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   562
+                                                              "type",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   563
+                                                              "Type",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   564
+                                                              NULL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   565
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   566
+        g_object_class_install_property (object_class,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   567
+                                         PROP_PARAMETERS,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   568
+                                         g_param_spec_boxed ("parameters",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   569
+                                                              "Parameters",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   570
+                                                              "Parameters",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   571
+                                                              G_TYPE_HASH_TABLE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   572
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   573
+        g_type_class_add_private (klass, sizeof (CkDisplayTemplatePrivate));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   574
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   575
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   576
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   577
+ck_display_template_init (CkDisplayTemplate *display)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   578
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   579
+        display->priv = CK_DISPLAY_TEMPLATE_GET_PRIVATE (display);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   580
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   581
+        display->priv->name = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   582
+        display->priv->type = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   583
+        display->priv->parameters = g_hash_table_new_full (g_str_hash, g_str_equal,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   584
+                                                           (GDestroyNotify) g_free,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   585
+                                                           (GDestroyNotify) g_free);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   586
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   587
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   588
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   589
+ck_display_template_finalize (GObject *object)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   590
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   591
+        CkDisplayTemplate *display;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   592
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   593
+        g_return_if_fail (object != NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   594
+        g_return_if_fail (CK_IS_DISPLAY_TEMPLATE (object));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   595
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   596
+        display = CK_DISPLAY_TEMPLATE (object);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   597
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   598
+        g_return_if_fail (display->priv != NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   599
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   600
+        g_free (display->priv->name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   601
+        g_free (display->priv->type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   602
+        g_hash_table_unref (display->priv->parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   603
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   604
+        G_OBJECT_CLASS (ck_display_template_parent_class)->finalize (object);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   605
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   606
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   607
+static gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   608
+ck_display_template_load (CkDisplayTemplate *display)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   609
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   610
+        GKeyFile   *key_file;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   611
+        const char *name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   612
+        char       *group;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   613
+        char       *filename;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   614
+        gboolean    hidden;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   615
+        char       *type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   616
+        gboolean    res;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   617
+        GError     *error;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   618
+        char      **type_keys;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   619
+        GHashTable *parameters;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   620
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   621
+        name = ck_display_template_get_name (display);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   622
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   623
+        g_return_val_if_fail (name && !g_str_equal (name, ""), FALSE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   624
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   625
+        filename = g_strdup_printf ("%s/%s.display", CK_DISPLAY_TEMPLATES_DIR, name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   626
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   627
+        key_file = g_key_file_new ();
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   628
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   629
+        error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   630
+        res = g_key_file_load_from_file (key_file,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   631
+                                         filename,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   632
+                                         G_KEY_FILE_NONE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   633
+                                         &error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   634
+        if (! res) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   635
+                g_warning ("Unable to load display from file %s: %s", filename, error->message);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   636
+                g_error_free (error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   637
+                return FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   638
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   639
+        g_free (filename);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   640
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   641
+        group = g_key_file_get_start_group (key_file);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   642
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   643
+        if (group == NULL || strcmp (group, "Display") != 0) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   644
+                g_warning ("Not a display type file: %s", filename);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   645
+                g_free (group);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   646
+                g_key_file_free (key_file);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   647
+                return FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   648
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   649
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   650
+        hidden = g_key_file_get_boolean (key_file, group, "Hidden", NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   651
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   652
+        type = g_key_file_get_string (key_file, group, "Type", NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   653
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   654
+        if (type == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   655
+                g_warning ("Unable to read type from display file");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   656
+                g_free (group);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   657
+                g_key_file_free (key_file);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   658
+                return FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   659
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   660
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   661
+        display->priv->type = type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   662
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   663
+        parameters = g_hash_table_new_full (g_str_hash, g_str_equal,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   664
+                                            (GDestroyNotify) g_free,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   665
+                                            (GDestroyNotify) g_free);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   666
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   667
+        type_keys = g_key_file_get_keys (key_file, type, NULL, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   668
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   669
+        if (type_keys != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   670
+                int        i;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   671
+                for (i = 0; type_keys[i] != NULL; i++) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   672
+                        char   *string;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   673
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   674
+                        string = g_key_file_get_string (key_file, type, type_keys[i], NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   675
+                        g_hash_table_insert (parameters, g_strdup (type_keys[i]), string);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   676
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   677
+                g_strfreev (type_keys);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   678
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   679
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   680
+        _ck_display_template_set_parameters (display, parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   681
+        g_hash_table_unref (parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   682
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   683
+        g_free (group);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   684
+        g_key_file_free (key_file);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   685
+        return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   686
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   687
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   688
+CkDisplayTemplate *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   689
+ck_display_template_get_from_name (const char *name)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   690
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   691
+        CkDisplayTemplate *display_template;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   692
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   693
+        if (ck_display_templates == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   694
+                ck_display_templates = g_hash_table_new_full (g_str_hash, g_str_equal,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   695
+                                                          (GDestroyNotify) g_free,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   696
+                                                          (GDestroyNotify) g_object_unref);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   697
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   698
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   699
+        display_template = g_hash_table_lookup (ck_display_templates, name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   700
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   701
+        if (display_template == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   702
+                GObject *object;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   703
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   704
+                object = g_object_new (CK_TYPE_DISPLAY_TEMPLATE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   705
+                                       "name", name,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   706
+                                       NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   707
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   708
+                if (!ck_display_template_load (CK_DISPLAY_TEMPLATE (object))) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   709
+                        g_object_unref (object);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   710
+                        return NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   711
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   712
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   713
+                g_hash_table_insert (ck_display_templates, g_strdup (name), object);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   714
+                display_template = CK_DISPLAY_TEMPLATE (object);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   715
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   716
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   717
+        return g_object_ref (display_template);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   718
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   719
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   720
+G_CONST_RETURN char*
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   721
+ck_display_template_get_name (CkDisplayTemplate   *display)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   722
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   723
+        g_return_val_if_fail (CK_IS_DISPLAY_TEMPLATE (display), NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   724
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   725
+        return display->priv->name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   726
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   727
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   728
+G_CONST_RETURN char *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   729
+ck_display_template_get_type_string (CkDisplayTemplate  *display)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   730
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   731
+        return display->priv->type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   732
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   733
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   734
+GHashTable *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   735
+ck_display_template_get_parameters (CkDisplayTemplate   *display)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   736
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   737
+        g_return_val_if_fail (CK_IS_DISPLAY_TEMPLATE (display), NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   738
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   739
+        return g_hash_table_ref (display->priv->parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   740
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   741
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   742
diff --git a/src/ck-display-template.h b/src/ck-display-template.h
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   743
new file mode 100644
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   744
index 0000000..fa74e67
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   745
--- /dev/null
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   746
+++ b/src/ck-display-template.h
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   747
@@ -0,0 +1,57 @@
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   748
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   749
+ *
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   750
+ * Authors: [email protected]
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   751
+ * Copyright (C) 2009 Sun Microsystems, Inc.
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   752
+ *
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   753
+ * This program is free software; you can redistribute it and/or modify
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   754
+ * it under the terms of the GNU General Public License as published by
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   755
+ * the Free Software Foundation; either version 2 of the License, or
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   756
+ * (at your option) any later version.
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   757
+ *
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   758
+ * This program is distributed in the hope that it will be useful,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   759
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   760
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   761
+ * GNU General Public License for more details.
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   762
+ *
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   763
+ * You should have received a copy of the GNU General Public License
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   764
+ * along with this program; if not, write to the Free Software
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   765
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   766
+ *
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   767
+ */
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   768
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   769
+#ifndef __CK_DISPLAY_TEMPLATE_H
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   770
+#define __CK_DISPLAY_TEMPLATE_H
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   771
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   772
+#include <glib-object.h>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   773
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   774
+G_BEGIN_DECLS
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   775
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   776
+#define CK_TYPE_DISPLAY_TEMPLATE         (ck_display_template_get_type ())
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   777
+#define CK_DISPLAY_TEMPLATE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), CK_TYPE_DISPLAY_TEMPLATE, CkDisplayTemplate))
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   778
+#define CK_DISPLAY_TEMPLATE_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), CK_TYPE_DISPLAY_TEMPLATE, CkDisplayTemplateClass))
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   779
+#define CK_IS_DISPLAY_TEMPLATE(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), CK_TYPE_DISPLAY_TEMPLATE))
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   780
+#define CK_IS_DISPLAY_TEMPLATE_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), CK_TYPE_DISPLAY_TEMPLATE))
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   781
+#define CK_DISPLAY_TEMPLATE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CK_TYPE_DISPLAY_TEMPLATE, CkDisplayTemplateClass))
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   782
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   783
+typedef struct CkDisplayTemplatePrivate CkDisplayTemplatePrivate;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   784
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   785
+typedef struct
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   786
+{
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   787
+        GObject        parent;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   788
+        CkDisplayTemplatePrivate *priv;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   789
+} CkDisplayTemplate;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   790
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   791
+typedef struct
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   792
+{
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   793
+        GObjectClass   parent_class;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   794
+} CkDisplayTemplateClass;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   795
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   796
+GType                 ck_display_template_get_type            (void);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   797
+CkDisplayTemplate   * ck_display_template_get_from_name       (const char      *name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   798
+G_CONST_RETURN char * ck_display_template_get_name            (CkDisplayTemplate   *display);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   799
+G_CONST_RETURN char * ck_display_template_get_type_string     (CkDisplayTemplate   *display);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   800
+GHashTable          * ck_display_template_get_parameters      (CkDisplayTemplate   *display);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   801
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   802
+G_END_DECLS
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   803
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   804
+#endif /* __CK_DISPLAY_TEMPLATE_H */
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   805
diff --git a/src/ck-log-event.c b/src/ck-log-event.c
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   806
index 66f439c..d13a0f8 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   807
--- a/src/ck-log-event.c
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   808
+++ b/src/ck-log-event.c
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
   809
@@ -79,6 +79,8 @@ event_seat_session_added_free (CkLogSeat
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   810
         event->session_id = NULL;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   811
         g_free (event->session_type);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   812
         event->session_type = NULL;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   813
+        g_free (event->display_type);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   814
+        event->display_type = NULL;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   815
         g_free (event->session_x11_display);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   816
         event->session_x11_display = NULL;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   817
         g_free (event->session_x11_display_device);
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
   818
@@ -103,6 +105,8 @@ event_seat_session_removed_free (CkLogSe
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   819
         event->session_id = NULL;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   820
         g_free (event->session_type);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   821
         event->session_type = NULL;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   822
+        g_free (event->display_type);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   823
+        event->display_type = NULL;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   824
         g_free (event->session_x11_display);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   825
         event->session_x11_display = NULL;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   826
         g_free (event->session_x11_display_device);
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
   827
@@ -213,6 +217,7 @@ event_seat_session_added_copy (CkLogSeat
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   828
         event_copy->seat_id = g_strdup (event->seat_id);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   829
         event_copy->session_id = g_strdup (event->session_id);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   830
         event_copy->session_type = g_strdup (event->session_type);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   831
+        event_copy->display_type = g_strdup (event->display_type);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   832
         event_copy->session_x11_display = g_strdup (event->session_x11_display);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   833
         event_copy->session_x11_display_device = g_strdup (event->session_x11_display_device);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   834
         event_copy->session_display_device = g_strdup (event->session_display_device);
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
   835
@@ -232,6 +237,7 @@ event_seat_session_removed_copy (CkLogSe
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   836
         event_copy->seat_id = g_strdup (event->seat_id);
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   837
         event_copy->session_id = g_strdup (event->session_id);
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   838
         event_copy->session_type = g_strdup (event->session_type);
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   839
+        event_copy->display_type = g_strdup (event->display_type);
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   840
         event_copy->session_x11_display = g_strdup (event->session_x11_display);
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   841
         event_copy->session_x11_display_device = g_strdup (event->session_x11_display_device);
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   842
         event_copy->session_display_device = g_strdup (event->session_display_device);
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
   843
@@ -415,10 +421,11 @@ add_log_for_seat_session_added (GString 
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   844
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   845
         e = (CkLogSeatSessionAddedEvent *)event;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   846
         g_string_append_printf (str,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   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
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   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
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   849
                                 e->seat_id ? e->seat_id : "",
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   850
                                 e->session_id ? e->session_id : "",
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   851
                                 e->session_type ? e->session_type : "",
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   852
+                                e->display_type ? e->display_type : "",
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   853
                                 e->session_x11_display ? e->session_x11_display : "",
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   854
                                 e->session_x11_display_device ? e->session_x11_display_device : "",
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   855
                                 e->session_display_device ? e->session_display_device : "",
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
   856
@@ -436,10 +443,11 @@ add_log_for_seat_session_removed (GStrin
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   857
 
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   858
         e = (CkLogSeatSessionRemovedEvent *)event;
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   859
         g_string_append_printf (str,
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   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'",
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   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'",
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   862
                                 e->seat_id ? e->seat_id : "",
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   863
                                 e->session_id ? e->session_id : "",
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   864
                                 e->session_type ? e->session_type : "",
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   865
+                                e->display_type ? e->display_type : "",
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   866
                                 e->session_x11_display ? e->session_x11_display : "",
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   867
                                 e->session_x11_display_device ? e->session_x11_display_device : "",
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   868
                                 e->session_display_device ? e->session_display_device : "",
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
   869
@@ -939,7 +947,7 @@ parse_log_for_seat_session_added (const 
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   870
         }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   871
 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   872
         error = NULL;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   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);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   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);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   875
         if (re == NULL) {
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
   876
                 g_warning ("%s", error->message);
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   877
                 goto out;
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
   878
@@ -957,6 +965,7 @@ parse_log_for_seat_session_added (const 
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   879
         e->seat_id = g_match_info_fetch_named (match_info, "seatid");
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   880
         e->session_id = g_match_info_fetch_named (match_info, "sessionid");
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   881
         e->session_type = g_match_info_fetch_named (match_info, "sessiontype");
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   882
+        e->display_type = g_match_info_fetch_named (match_info, "displaytype");
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   883
         e->session_x11_display = g_match_info_fetch_named (match_info, "sessionx11display");
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   884
         e->session_x11_display_device = g_match_info_fetch_named (match_info, "sessionx11displaydevice");
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   885
         e->session_display_device = g_match_info_fetch_named (match_info, "sessiondisplaydevice");
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
   886
@@ -1014,7 +1023,7 @@ parse_log_for_seat_session_removed (cons
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   887
         }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   888
 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   889
         error = NULL;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   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);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   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);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   892
         if (re == NULL) {
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
   893
                 g_warning ("%s", error->message);
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   894
                 goto out;
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
   895
@@ -1032,6 +1041,7 @@ parse_log_for_seat_session_removed (cons
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   896
         e->seat_id = g_match_info_fetch_named (match_info, "seatid");
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   897
         e->session_id = g_match_info_fetch_named (match_info, "sessionid");
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   898
         e->session_type = g_match_info_fetch_named (match_info, "sessiontype");
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   899
+        e->display_type = g_match_info_fetch_named (match_info, "displaytype");
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   900
         e->session_x11_display = g_match_info_fetch_named (match_info, "sessionx11display");
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   901
         e->session_x11_display_device = g_match_info_fetch_named (match_info, "sessionx11displaydevice");
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   902
         e->session_display_device = g_match_info_fetch_named (match_info, "sessiondisplaydevice");
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   903
diff --git a/src/ck-log-event.h b/src/ck-log-event.h
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   904
index 65571f0..2d4ed4e 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   905
--- a/src/ck-log-event.h
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   906
+++ b/src/ck-log-event.h
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   907
@@ -68,6 +68,7 @@ typedef struct
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   908
 {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   909
         char *seat_id;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   910
         int   seat_kind;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   911
+        char *seat_type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   912
 } CkLogSeatAddedEvent;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   913
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   914
 typedef struct
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   915
@@ -81,11 +82,13 @@ typedef struct
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   916
         char    *seat_id;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   917
         char    *session_id;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   918
         char    *session_type;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   919
+        char    *display_type;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   920
         char    *session_x11_display;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   921
         char    *session_x11_display_device;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   922
         char    *session_display_device;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   923
         char    *session_remote_host_name;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   924
         gboolean session_is_local;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   925
+        gboolean session_is_dynamic;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   926
         guint    session_unix_user;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   927
         char    *session_creation_time;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   928
 } CkLogSeatSessionAddedEvent;
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   929
@@ -95,11 +98,13 @@ typedef struct
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   930
         char    *seat_id;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   931
         char    *session_id;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   932
         char    *session_type;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   933
+        char    *display_type;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   934
         char    *session_x11_display;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   935
         char    *session_x11_display_device;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   936
         char    *session_display_device;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   937
         char    *session_remote_host_name;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   938
         gboolean session_is_local;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   939
+        gboolean session_is_dynamic;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   940
         guint    session_unix_user;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   941
         char    *session_creation_time;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   942
 } CkLogSeatSessionRemovedEvent;
20040
4e5dc19e0780 Fix for bugster #6979440
qc161282
parents: 17996
diff changeset
   943
--- ConsoleKit-0.4.1/src/ck-manager.c.orig	2010-09-06 11:20:51.908499864 +0800
4e5dc19e0780 Fix for bugster #6979440
qc161282
parents: 17996
diff changeset
   944
+++ ConsoleKit-0.4.1/src/ck-manager.c	2010-09-06 11:20:56.996728793 +0800
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   945
@@ -46,9 +46,14 @@
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   946
 #include <secdb.h>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   947
 #endif
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   948
 
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   949
+#ifndef HAVE_STRVERSCMP
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   950
+#include "strverscmp.h"
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   951
+#endif
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   952
+
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   953
 #include "ck-manager.h"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   954
 #include "ck-manager-glue.h"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   955
 #include "ck-seat.h"
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   956
+#include "ck-display-template.h"
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   957
 #include "ck-session-leader.h"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   958
 #include "ck-session.h"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   959
 #include "ck-marshal.h"
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   960
@@ -58,12 +63,19 @@
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   961
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   962
 #define CK_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CK_TYPE_MANAGER, CkManagerPrivate))
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   963
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   964
+#define CK_TYPE_PARAMETER_STRUCT (dbus_g_type_get_struct ("GValueArray", \
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   965
+                                                          G_TYPE_STRING, \
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   966
+                                                          G_TYPE_VALUE, \
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   967
+                                                          G_TYPE_INVALID))
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   968
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   969
 #define CK_SEAT_DIR          SYSCONFDIR "/ConsoleKit/seats.d"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   970
 #define LOG_FILE             LOCALSTATEDIR "/log/ConsoleKit/history"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   971
 #define CK_DBUS_PATH         "/org/freedesktop/ConsoleKit"
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   972
 #define CK_MANAGER_DBUS_PATH CK_DBUS_PATH "/Manager"
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   973
 #define CK_MANAGER_DBUS_NAME "org.freedesktop.ConsoleKit.Manager"
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   974
 
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   975
+#define IS_STR_SET(x) (x != NULL && x[0] != '\0')
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   976
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   977
 struct CkManagerPrivate
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   978
 {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   979
 #ifdef HAVE_POLKIT
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
   980
@@ -392,6 +404,7 @@ log_seat_added_event (CkManager  *manage
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   981
         GError            *error;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   982
         char              *sid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   983
         CkSeatKind         seat_kind;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   984
+        char              *seat_type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   985
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   986
         memset (&event, 0, sizeof (CkLogEvent));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   987
 
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
   988
@@ -401,9 +414,11 @@ log_seat_added_event (CkManager  *manage
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   989
         sid = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   990
         ck_seat_get_id (seat, &sid, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   991
         ck_seat_get_kind (seat, &seat_kind, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   992
+        ck_seat_get_type_string (seat, &seat_type, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   993
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   994
         event.event.seat_added.seat_id = (char *)get_object_id_basename (sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   995
         event.event.seat_added.seat_kind = (int)seat_kind;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   996
+        event.event.seat_added.seat_type = (char *)seat_type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   997
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   998
         error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   999
         res = ck_event_logger_queue_event (manager->priv->logger, &event, &error);
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1000
@@ -413,6 +428,7 @@ log_seat_added_event (CkManager  *manage
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1001
         }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1002
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1003
         g_free (sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1004
+        g_free (seat_type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1005
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1006
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1007
 static void
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1008
@@ -517,6 +533,7 @@ log_seat_session_added_event (CkManager 
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1009
         if (session != NULL) {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1010
                 g_object_get (session,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1011
                               "session-type", &event.event.seat_session_added.session_type,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1012
+                              "display-type", &event.event.seat_session_added.display_type,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1013
                               "x11-display", &event.event.seat_session_added.session_x11_display,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1014
                               "x11-display-device", &event.event.seat_session_added.session_x11_display_device,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1015
                               "display-device", &event.event.seat_session_added.session_display_device,
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1016
@@ -572,6 +589,7 @@ log_seat_session_removed_event (CkManage
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1017
         if (session != NULL) {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1018
                 g_object_get (session,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1019
                               "session-type", &event.event.seat_session_removed.session_type,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1020
+                              "display-type", &event.event.seat_session_removed.display_type,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1021
                               "x11-display", &event.event.seat_session_removed.session_x11_display,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1022
                               "x11-display-device", &event.event.seat_session_removed.session_x11_display_device,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1023
                               "display-device", &event.event.seat_session_removed.session_display_device,
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1024
@@ -1330,15 +1348,21 @@ disconnect_seat_signals (CkManager *mana
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1025
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1026
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1027
 static CkSeat *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1028
-add_new_seat (CkManager *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1029
-              CkSeatKind kind)
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1030
+add_new_seat (CkManager  *manager,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1031
+              const char *give_sid,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1032
+              CkSeatKind  kind,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1033
+              const char *type)
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1034
 {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1035
         char   *sid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1036
         CkSeat *seat;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1037
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1038
-        sid = generate_seat_id (manager);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1039
+        if (IS_STR_SET (give_sid)) {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1040
+                sid = g_strdup (give_sid);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1041
+        } else {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1042
+                sid = generate_seat_id (manager);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1043
+        }
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1044
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1045
-        seat = ck_seat_new (sid, kind);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1046
+        seat = ck_seat_new (sid, kind, type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1047
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1048
         /* First we connect our own signals to the seat, followed by
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1049
          * the D-Bus signal hookup to make sure we can first dump the
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1050
@@ -1363,7 +1387,7 @@ add_new_seat (CkManager *manager,
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1051
         ck_seat_run_programs (seat, NULL, NULL, "seat_added");
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1052
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1053
         g_debug ("Emitting seat-added: %s", sid);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1054
-        g_signal_emit (manager, signals [SEAT_ADDED], 0, sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1055
+        g_signal_emit (manager, signals [SEAT_ADDED], 0, sid, type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1056
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1057
         log_seat_added_event (manager, seat);
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1058
 
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1059
@@ -1421,64 +1445,22 @@ remove_seat (CkManager *manager,
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1060
         g_free (sid);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1061
 }
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1062
 
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1063
-#define IS_STR_SET(x) (x != NULL && x[0] != '\0')
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1064
-
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1065
 static CkSeat *
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1066
 find_seat_for_session (CkManager *manager,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1067
                        CkSession *session)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1068
 {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1069
         CkSeat  *seat;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1070
-        gboolean is_static_x11;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1071
-        gboolean is_static_text;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1072
-        char    *display_device;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1073
-        char    *x11_display_device;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1074
-        char    *x11_display;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1075
-        char    *remote_host_name;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1076
-        gboolean is_local;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1077
-
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1078
-        is_static_text = FALSE;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1079
-        is_static_x11 = FALSE;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1080
-
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1081
-        seat = NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1082
-        display_device = NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1083
-        x11_display_device = NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1084
-        x11_display = NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1085
-        remote_host_name = NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1086
-        is_local = FALSE;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1087
-
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1088
-        /* FIXME: use matching to group entries? */
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1089
-
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1090
-        ck_session_get_display_device (session, &display_device, NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1091
-        ck_session_get_x11_display_device (session, &x11_display_device, NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1092
-        ck_session_get_x11_display (session, &x11_display, NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1093
-        ck_session_get_remote_host_name (session, &remote_host_name, NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1094
-        ck_session_is_local (session, &is_local, NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1095
-
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1096
-        if (IS_STR_SET (x11_display)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1097
-            && IS_STR_SET (x11_display_device)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1098
-            && ! IS_STR_SET (remote_host_name)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1099
-            && is_local == TRUE) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1100
-                is_static_x11 = TRUE;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1101
-        } else if (! IS_STR_SET (x11_display)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1102
-                   && ! IS_STR_SET (x11_display_device)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1103
-                   && IS_STR_SET (display_device)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1104
-                   && ! IS_STR_SET (remote_host_name)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1105
-                   && is_local == TRUE) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1106
-                is_static_text = TRUE;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1107
-        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1108
+        char    *sid = NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1109
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1110
+        ck_session_get_seat_id (session, &sid, NULL);
20040
4e5dc19e0780 Fix for bugster #6979440
qc161282
parents: 17996
diff changeset
  1111
 
4e5dc19e0780 Fix for bugster #6979440
qc161282
parents: 17996
diff changeset
  1112
-        if (is_static_x11 || is_static_text) {
4e5dc19e0780 Fix for bugster #6979440
qc161282
parents: 17996
diff changeset
  1113
-                char *sid;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1114
+        if (! IS_STR_SET (sid)) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1115
                 sid = g_strdup_printf ("%s/Seat%u", CK_DBUS_PATH, 1);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1116
-                seat = g_hash_table_lookup (manager->priv->seats, sid);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1117
-                g_free (sid);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1118
         }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1119
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1120
-        g_free (display_device);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1121
-        g_free (x11_display_device);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1122
-        g_free (x11_display);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1123
-        g_free (remote_host_name);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1124
+        seat = g_hash_table_lookup (manager->priv->seats, sid);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1125
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1126
+        g_free (sid);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1127
         return seat;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1128
 }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1129
 
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1130
@@ -1613,36 +1595,49 @@ open_session_for_leader (CkManager      
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1131
         CkSession   *session;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1132
         CkSeat      *seat;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1133
         const char  *ssid;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1134
+        char        *sid;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1135
         const char  *cookie;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1136
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1137
         ssid = ck_session_leader_peek_session_id (leader);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1138
         cookie = ck_session_leader_peek_cookie (leader);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1139
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1140
-        session = ck_session_new_with_parameters (ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1141
-                                                  cookie,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1142
-                                                  parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1143
+        session = g_hash_table_lookup (manager->priv->sessions, ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1144
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1145
         if (session == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1146
-                GError *error;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1147
-                g_debug ("Unable to create new session");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1148
-                error = g_error_new (CK_MANAGER_ERROR,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1149
-                                     CK_MANAGER_ERROR_GENERAL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1150
-                                     "Unable to create new session");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1151
-                dbus_g_method_return_error (context, error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1152
-                g_error_free (error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1153
+                session = ck_session_new_with_parameters (ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1154
+                                                          parameters);
20040
4e5dc19e0780 Fix for bugster #6979440
qc161282
parents: 17996
diff changeset
  1155
 
4e5dc19e0780 Fix for bugster #6979440
qc161282
parents: 17996
diff changeset
  1156
-                return;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1157
+                if (session == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1158
+                        GError *error;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1159
+                        g_debug ("Unable to create new session");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1160
+                        error = g_error_new (CK_MANAGER_ERROR,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1161
+                                             CK_MANAGER_ERROR_GENERAL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1162
+                                             "Unable to create new session");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1163
+                        dbus_g_method_return_error (context, error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1164
+                        g_error_free (error);
20040
4e5dc19e0780 Fix for bugster #6979440
qc161282
parents: 17996
diff changeset
  1165
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1166
+                        return;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1167
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1168
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1169
+                g_hash_table_insert (manager->priv->sessions,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1170
+                                     g_strdup (ssid),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1171
+                                     g_object_ref (session));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1172
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1173
+        } else {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1174
+                ck_session_set_parameters (session, parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1175
         }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1176
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1177
-        g_hash_table_insert (manager->priv->sessions,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1178
-                             g_strdup (ssid),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1179
-                             g_object_ref (session));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1180
+        ck_session_set_cookie (session, cookie, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1181
+        ck_session_set_is_open (session, TRUE, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1182
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1183
         /* Add to seat */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1184
         seat = find_seat_for_session (manager, session);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1185
         if (seat == NULL) {
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1186
+                sid = NULL;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1187
+                ck_session_get_seat_id (session, &sid, NULL);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1188
                 /* create a new seat */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1189
-                seat = add_new_seat (manager, CK_SEAT_KIND_DYNAMIC);
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1190
+                seat = add_new_seat (manager, sid, CK_SEAT_KIND_DYNAMIC, "Default");
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1191
+                g_free (sid);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1192
         }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1193
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1194
         ck_seat_add_session (seat, session, NULL);
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1195
@@ -1878,11 +1873,57 @@ generate_session_for_leader (CkManager  
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1196
         }
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1197
 }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1198
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1199
+static char *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1200
+check_parameters_for_ssid (const GPtrArray *parameters)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1201
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1202
+        int i;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1203
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1204
+        if (parameters == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1205
+                return NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1206
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1207
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1208
+        for (i = 0; i < parameters->len; i++) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1209
+                GValue   val_struct = { 0, };
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1210
+                char    *prop_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1211
+                gboolean res;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1212
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1213
+                g_value_init (&val_struct, CK_TYPE_PARAMETER_STRUCT);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1214
+                g_value_set_static_boxed (&val_struct, g_ptr_array_index (parameters, i));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1215
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1216
+                res = dbus_g_type_struct_get (&val_struct,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1217
+                                              0, &prop_name,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1218
+                                              G_MAXUINT);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1219
+                if (! res) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1220
+                        g_debug ("Unable to read parameter name");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1221
+                        continue;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1222
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1223
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1224
+                if (prop_name != NULL && strcmp (prop_name, "session") == 0) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1225
+                        GValue   prop_val = { 0, };
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1226
+                        GValue  *session_val;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1227
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1228
+                        g_value_init (&prop_val, G_TYPE_VALUE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1229
+                        res = dbus_g_type_struct_get_member (&val_struct, 1, &prop_val);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1230
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1231
+                        if (! res) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1232
+                                g_debug ("Unable to read parameter value");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1233
+                                continue;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1234
+                        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1235
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1236
+                        session_val = g_value_get_boxed (&prop_val);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1237
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1238
+                        return g_value_dup_string (session_val);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1239
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1240
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1241
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1242
+        return NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1243
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1244
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1245
 static gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1246
-create_session_for_sender (CkManager             *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1247
-                           const char            *sender,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1248
-                           const GPtrArray       *parameters,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1249
-                           DBusGMethodInvocation *context)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1250
+open_session_for_sender (CkManager             *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1251
+                         const char            *sender,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1252
+                         const GPtrArray       *parameters,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1253
+                         DBusGMethodInvocation *context)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1254
 {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1255
         pid_t           pid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1256
         uid_t           uid;
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1257
@@ -1890,6 +1931,7 @@ create_session_for_sender (CkManager    
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1258
         char            *cookie;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1259
         char            *ssid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1260
         CkSessionLeader *leader;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1261
+        CkSession       *session;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1262
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1263
         g_debug ("CkManager: create session for sender: %s", sender);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1264
 
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1265
@@ -1908,9 +1950,21 @@ create_session_for_sender (CkManager    
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1266
         }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1267
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1268
         cookie = generate_session_cookie (manager);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1269
-        ssid = generate_session_id (manager);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1270
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1271
-        g_debug ("Creating new session ssid: %s", ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1272
+        ssid = check_parameters_for_ssid (parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1273
+
16491
cfe4ca1d31ab 2009-09-08 Halton Huo <[email protected]>
halton
parents: 16486
diff changeset
  1274
+        if (IS_STR_SET (ssid)) {
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1275
+                session = g_hash_table_lookup (manager->priv->sessions, ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1276
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1277
+                /* FIXME: Need to verify that the session belongs to a seat
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1278
+                 * managed by the sender
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1279
+                 */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1280
+                g_debug ("Managing existing session ssid: %s", ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1281
+        } else {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1282
+                ssid = generate_session_id (manager);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1283
+                session = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1284
+                g_debug ("Creating new session ssid: %s", ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1285
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1286
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1287
         leader = ck_session_leader_new ();
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1288
         ck_session_leader_set_uid (leader, uid);
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1289
@@ -2149,7 +2203,7 @@ ck_manager_open_session (CkManager      
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1290
         gboolean ret;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1291
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1292
         sender = dbus_g_method_get_sender (context);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1293
-        ret = create_session_for_sender (manager, sender, NULL, context);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1294
+        ret = open_session_for_sender (manager, sender, NULL, context);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1295
         g_free (sender);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1296
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1297
         return ret;
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1298
@@ -2164,7 +2218,7 @@ ck_manager_open_session_with_parameters 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1299
         gboolean ret;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1300
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1301
         sender = dbus_g_method_get_sender (context);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1302
-        ret = create_session_for_sender (manager, sender, parameters, context);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1303
+        ret = open_session_for_sender (manager, sender, parameters, context);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1304
         g_free (sender);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1305
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1306
         return ret;
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1307
@@ -2181,10 +2235,12 @@ remove_session_for_cookie (CkManager  *m
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1308
         char            *sid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1309
         gboolean         res;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1310
         gboolean         ret;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1311
+        gboolean         should_remove_session;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1312
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1313
         ret = FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1314
         orig_ssid = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1315
         orig_session = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1316
+        should_remove_session = FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1317
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1318
         g_debug ("Removing session for cookie: %s", cookie);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1319
 
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1320
@@ -2211,6 +2267,17 @@ remove_session_for_cookie (CkManager  *m
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1321
                 goto out;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1322
         }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1323
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1324
+        ck_session_set_is_open (orig_session, FALSE, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1325
+        ck_session_set_cookie (orig_session, NULL, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1326
+        ck_session_set_active (orig_session, FALSE, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1327
+        ck_session_set_unix_user (orig_session, 0, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1328
+        ck_session_set_x11_display (orig_session, NULL, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1329
+        ck_session_set_x11_display_device (orig_session, NULL, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1330
+        ck_session_set_display_device (orig_session, NULL, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1331
+        ck_session_set_login_session_id (orig_session, NULL, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1332
+        ck_session_set_remote_host_name (orig_session, NULL, NULL);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1333
+        ck_session_set_under_request (orig_session, FALSE, NULL);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1334
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1335
         /* Must keep a reference to the session in the manager until
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1336
          * all events for seats are cleared.  So don't remove
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1337
          * or steal the session from the master list until
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1338
@@ -2218,31 +2285,32 @@ remove_session_for_cookie (CkManager  *m
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1339
          * for seat removals doesn't work.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1340
          */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1341
 
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1342
-        /* remove from seat */
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1343
-        sid = NULL;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1344
-        ck_session_get_seat_id (orig_session, &sid, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1345
-        if (sid != NULL) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1346
-                CkSeat *seat;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1347
-                seat = g_hash_table_lookup (manager->priv->seats, sid);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1348
-                if (seat != NULL) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1349
-                        CkSeatKind kind;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1350
-
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1351
-                        ck_seat_remove_session (seat, orig_session, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1352
-
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1353
-                        kind = CK_SEAT_KIND_STATIC;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1354
-                        /* if dynamic seat has no sessions then remove it */
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1355
-                        ck_seat_get_kind (seat, &kind, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1356
-                        if (kind == CK_SEAT_KIND_DYNAMIC) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1357
-                                remove_seat (manager, seat);
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  1358
+        ck_session_get_remove_on_close (orig_session, &should_remove_session, NULL);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  1359
+
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1360
+        if (should_remove_session) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1361
+                /* remove from seat */
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1362
+                sid = NULL;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1363
+                ck_session_get_seat_id (orig_session, &sid, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1364
+                if (sid != NULL) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1365
+                        CkSeat *seat;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1366
+                        seat = g_hash_table_lookup (manager->priv->seats, sid);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1367
+                        if (seat != NULL) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1368
+                                CkSeatKind kind;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1369
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1370
+                                ck_seat_remove_session (seat, orig_session, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1371
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1372
+                                kind = CK_SEAT_KIND_STATIC;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1373
+                                /* if dynamic seat has no sessions then remove it */
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1374
+                                ck_seat_get_kind (seat, &kind, NULL);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1375
                         }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1376
                 }
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1377
-        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1378
-        g_free (sid);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1379
+                g_free (sid);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1380
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1381
-        /* Remove the session from the list but don't call
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1382
-         * unref until we are done with it */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1383
-        g_hash_table_steal (manager->priv->sessions,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1384
-                            ck_session_leader_peek_session_id (leader));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1385
+                /* Remove the session from the list but don't call
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1386
+                 * unref until we are done with it */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1387
+                g_hash_table_steal (manager->priv->sessions,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1388
+                                    ck_session_leader_peek_session_id (leader));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1389
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1390
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1391
         ck_manager_dump (manager);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1392
 
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1393
@@ -2250,11 +2318,13 @@ remove_session_for_cookie (CkManager  *m
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1394
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1395
         ret = TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1396
  out:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1397
-        if (orig_session != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1398
-                g_object_unref (orig_session);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1399
-        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1400
-        g_free (orig_ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1401
+        if (should_remove_session) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1402
+                if (orig_session != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1403
+                        g_object_unref (orig_session);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1404
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1405
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1406
+                g_free (orig_ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1407
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1408
         return ret;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1409
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1410
 
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1411
@@ -2472,9 +2542,11 @@ ck_manager_class_init (CkManagerClass *k
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1412
                               G_STRUCT_OFFSET (CkManagerClass, seat_added),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1413
                               NULL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1414
                               NULL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1415
-                              g_cclosure_marshal_VOID__BOXED,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1416
+                              ck_marshal_VOID__STRING_STRING,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1417
                               G_TYPE_NONE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1418
-                              1, DBUS_TYPE_G_OBJECT_PATH);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1419
+                              2,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1420
+                              G_TYPE_STRING,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1421
+                              G_TYPE_STRING);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1422
         signals [SEAT_REMOVED] =
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1423
                 g_signal_new ("seat-removed",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1424
                               G_TYPE_FROM_CLASS (object_class),
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1425
@@ -2581,6 +2653,43 @@ ck_manager_get_seats (CkManager  *manage
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1426
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1427
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1428
 static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1429
+listify_unmanaged_seat_ids (char       *id,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1430
+                            CkSeat     *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1431
+                            GPtrArray **array)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1432
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1433
+        if (ck_seat_is_managed (seat)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1434
+                return;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1435
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1436
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1437
+        g_ptr_array_add (*array, g_strdup (id));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1438
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1439
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1440
+
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1441
+/*
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1442
+  Example:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1443
+  dbus-send --system --dest=org.freedesktop.ConsoleKit \
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1444
+  --type=method_call --print-reply --reply-timeout=2000 \
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1445
+  /org/freedesktop/ConsoleKit/Manager \
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1446
+  org.freedesktop.ConsoleKit.Manager.GetUnmanagedSeats
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1447
+*/
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1448
+gboolean
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1449
+ck_manager_get_unmanaged_seats (CkManager  *manager,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1450
+                                GPtrArray **seats,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1451
+                                GError    **error)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1452
+{
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1453
+        g_return_val_if_fail (CK_IS_MANAGER (manager), FALSE);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1454
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1455
+        if (seats == NULL) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1456
+                return FALSE;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1457
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1458
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1459
+        *seats = g_ptr_array_new ();
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1460
+        g_hash_table_foreach (manager->priv->seats, (GHFunc)listify_unmanaged_seat_ids, seats);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1461
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1462
+        return TRUE;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1463
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1464
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1465
+static void
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1466
 listify_session_ids (char       *id,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1467
                      CkSession  *session,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1468
                      GPtrArray **array)
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1469
@@ -2605,16 +2714,311 @@ ck_manager_get_sessions (CkManager  *man
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1470
         return TRUE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1471
 }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1472
 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1473
+/*
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1474
+  Example:
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1475
+  dbus-send --system --dest=org.freedesktop.ConsoleKit \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1476
+  --type=method_call --print-reply --reply-timeout=2000 \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1477
+  /org/freedesktop/ConsoleKit/Manager \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1478
+  org.freedesktop.ConsoleKit.Manager.AddSeat string:Default
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1479
+*/
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1480
+gboolean
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1481
+ck_manager_add_seat (CkManager  *manager,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1482
+                     const char *type,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1483
+                     char      **sid,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1484
+                     GError    **error)
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1485
+{
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1486
+        CkSeat    *seat;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1487
+                
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1488
+        g_return_val_if_fail (CK_IS_MANAGER (manager), FALSE);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1489
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1490
+        seat = add_new_seat (manager, NULL, CK_SEAT_KIND_DYNAMIC, type);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1491
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1492
+        if (!ck_seat_get_id (seat, sid, error)) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1493
+                return FALSE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1494
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1495
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1496
+        return TRUE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1497
+}
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1498
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1499
+/*
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1500
+  Example:
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1501
+  dbus-send --system --dest=org.freedesktop.ConsoleKit \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1502
+  --type=method_call --print-reply --reply-timeout=2000 \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1503
+  /org/freedesktop/ConsoleKit/Manager \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1504
+  org.freedesktop.ConsoleKit.Manager.AddSeatById \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1505
+  objpath:/org/freedesktop/ConsoleKit/SeatTest \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1506
+*/
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1507
+gboolean
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1508
+ck_manager_add_seat_by_id (CkManager  *manager,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1509
+                           const char *type,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1510
+                           const char *sid,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1511
+                           GError    **error) 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1512
+{
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1513
+        CkSeat    *seat;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1514
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1515
+        g_return_val_if_fail (CK_IS_MANAGER (manager), FALSE);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1516
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1517
+        seat = add_new_seat (manager, sid, CK_SEAT_KIND_DYNAMIC, type);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1518
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1519
+        return !(seat == NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1520
+}
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1521
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1522
+/*
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1523
+  Example:
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1524
+  dbus-send --system --dest=org.freedesktop.ConsoleKit \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1525
+  --type=method_call --print-reply --reply-timeout=2000 \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1526
+  /org/freedesktop/ConsoleKit/Manager \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1527
+  org.freedesktop.ConsoleKit.Manager.RemoveSeat \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1528
+  obj:/org/freedesktop/ConsoleKit/Seat2
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1529
+*/
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1530
+gboolean
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1531
+ck_manager_remove_seat (CkManager             *manager,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1532
+                        const char            *sid,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1533
+                        DBusGMethodInvocation *context)
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1534
+{
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1535
+        CkSeat     *seat = NULL;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1536
+        CkSeatKind kind;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1537
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1538
+        g_return_val_if_fail (CK_IS_MANAGER (manager), FALSE);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1539
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1540
+        seat = g_hash_table_lookup (manager->priv->seats, sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1541
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1542
+        if (seat == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1543
+                GError *error;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1544
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1545
+                error = g_error_new (CK_SEAT_ERROR,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1546
+                                     CK_SEAT_ERROR_GENERAL,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1547
+                                     _("Seat '%s' doesn't exist"),
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1548
+                                     sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1549
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1550
+                dbus_g_method_return_error (context, error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1551
+                g_error_free (error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1552
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1553
+                return FALSE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1554
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1555
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1556
+        ck_seat_get_kind (seat, &kind, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1557
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1558
+        if (kind == CK_SEAT_KIND_STATIC) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1559
+                GError *error;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1560
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1561
+                error = g_error_new (CK_SEAT_ERROR,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1562
+                                     CK_SEAT_ERROR_GENERAL,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1563
+                                     _("Seat '%s' is static and can't be removed"),
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1564
+                                     sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1565
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1566
+                dbus_g_method_return_error (context, error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1567
+                g_error_free (error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1568
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1569
+                return FALSE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1570
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1571
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1572
+        if (ck_seat_is_managed (seat)) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1573
+                ck_seat_request_removal (seat);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1574
+        } else {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1575
+                remove_seat (manager, seat);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1576
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1577
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1578
+        return TRUE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1579
+}
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1580
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1581
+/*
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1582
+  Example:
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1583
+  dbus-send --system --dest=org.freedesktop.ConsoleKit \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1584
+  --type=method_call --print-reply --reply-timeout=2000 \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1585
+  /org/freedesktop/ConsoleKit/Manager \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1586
+  org.freedesktop.ConsoleKit.Manager.AddSession \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1587
+  objpath:/org/freedesktop/ConsoleKit/Seat2 \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1588
+  string:"LoginWindow" \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1589
+  dict:string:string:"vt","vt9","display",":123"
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1590
+*/
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1591
+gboolean
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1592
+ck_manager_add_session (CkManager             *manager,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1593
+                        const char            *sid,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1594
+                        const char            *type,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1595
+                        const char            *display_type,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1596
+                        GHashTable            *variables,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1597
+                        DBusGMethodInvocation *context)
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1598
+{
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1599
+        CkSeat    *seat;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1600
+        CkSession *session;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1601
+        char      *ssid;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1602
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1603
+        seat = g_hash_table_lookup (manager->priv->seats, sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1604
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1605
+        if (seat == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1606
+                GError *error;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1607
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1608
+                error = g_error_new (CK_SEAT_ERROR,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1609
+                                     CK_SEAT_ERROR_GENERAL, 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1610
+                                     _("Seat '%s' doesn't exist"),
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1611
+                                     sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1612
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1613
+                dbus_g_method_return_error (context, error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1614
+                g_error_free (error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1615
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1616
+                return FALSE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1617
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1618
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1619
+        ssid = generate_session_id (manager);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1620
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1621
+        session = ck_session_new (ssid, type, display_type, variables);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1622
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1623
+        if (session == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1624
+                GError *error;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1625
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1626
+                error = g_error_new (CK_SEAT_ERROR, 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1627
+                                     CK_SEAT_ERROR_GENERAL,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1628
+                                     _("Session could not be added to seat '%s'"),
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1629
+                                     sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1630
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1631
+                dbus_g_method_return_error (context, error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1632
+                g_error_free (error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1633
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1634
+                return FALSE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1635
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1636
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1637
+        ck_session_set_seat_id (session, sid, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1638
+        if (IS_STR_SET (type) && g_str_equal (type, "LoginWindow")) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1639
+                session_set_remove_on_close (session, FALSE, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1640
+        } else {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1641
+                session_set_remove_on_close (session, TRUE, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1642
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1643
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1644
+        ck_seat_add_session (seat, session, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1645
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1646
+        g_hash_table_insert (manager->priv->sessions,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1647
+                             ssid,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1648
+                             session);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1649
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1650
+        dbus_g_method_return (context, ssid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1651
+        return TRUE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1652
+}
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1653
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1654
+/*
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1655
+  Example:
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1656
+  dbus-send --system --dest=org.freedesktop.ConsoleKit \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1657
+  --type=method_call --print-reply --reply-timeout=2000 \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1658
+  /org/freedesktop/ConsoleKit/Manager \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1659
+  org.freedesktop.ConsoleKit.Manager.RemoveSession \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1660
+  objpath:/org/freedesktop/ConsoleKit/Session2
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1661
+*/
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1662
+gboolean
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1663
+ck_manager_remove_session (CkManager             *manager,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1664
+                           const char            *ssid,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1665
+                           DBusGMethodInvocation *context)
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1666
+{
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1667
+        CkSession *session;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1668
+        CkSeat *seat;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1669
+        GError *error; 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1670
+        char *sid;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1671
+        gboolean is_open;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1672
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1673
+        session = g_hash_table_lookup (manager->priv->sessions, ssid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1674
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1675
+        if (session == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1676
+                GError *error;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1677
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1678
+                error = g_error_new (CK_SEAT_ERROR,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1679
+                                     CK_SEAT_ERROR_GENERAL,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1680
+                                     _("Session '%s' doesn't exist"),
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1681
+                                     ssid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1682
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1683
+                dbus_g_method_return_error (context, error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1684
+                g_error_free (error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1685
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1686
+                return FALSE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1687
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1688
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1689
+        ck_session_get_seat_id (session, &sid, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1690
+        seat = g_hash_table_lookup (manager->priv->seats, sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1691
+        g_free (sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1692
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1693
+        if (seat == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1694
+                g_warning ("Session '%s' is not associated with a seat", ssid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1695
+                g_hash_table_remove (manager->priv->sessions, ssid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1696
+                return TRUE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1697
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1698
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1699
+        error = NULL;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1700
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1701
+        ck_session_is_open (session, &is_open, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1702
+        session_set_remove_on_close (session, TRUE, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1703
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1704
+        /* We'll let the seat manager close us when it's ready
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1705
+         */
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1706
+        if (ck_seat_is_managed (seat) && is_open) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1707
+                ck_seat_request_close_session (seat, session, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1708
+                dbus_g_method_return (context);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1709
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1710
+                return TRUE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1711
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1712
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1713
+        if (!ck_seat_remove_session (seat, session, &error)) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1714
+                if (error == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1715
+                        return TRUE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1716
+                }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1717
+                
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1718
+                dbus_g_method_return_error (context, error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1719
+                g_error_free (error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1720
+                return FALSE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1721
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1722
+        
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1723
+        g_hash_table_remove (manager->priv->sessions, ssid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1724
+        dbus_g_method_return (context);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1725
+        return TRUE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1726
+}
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1727
+ 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1728
+static void
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1729
+add_sessions_from_seat (CkManager *manager,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1730
+                        CkSeat    *seat)
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1731
+{
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1732
+        GPtrArray *sessions;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1733
+        int i;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1734
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1735
+        ck_seat_get_sessions (seat, &sessions, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1736
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1737
+        for (i = 0; i < sessions->len; i++) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1738
+                char *ssid;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1739
+                CkSession *session; 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1740
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1741
+                ssid = g_ptr_array_index (sessions, i);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1742
+                session = ck_seat_get_session (seat, ssid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1743
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1744
+                g_hash_table_insert (manager->priv->sessions,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1745
+                                     ssid,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1746
+                                     session);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1747
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1748
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1749
+        g_ptr_array_free (sessions, TRUE);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1750
+}
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1751
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1752
 static void
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1753
 add_seat_for_file (CkManager  *manager,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1754
                    const char *filename)
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1755
 {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1756
         char   *sid;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1757
+        char   *orig_sid;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1758
         CkSeat *seat;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1759
 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1760
         sid = generate_seat_id (manager);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1761
+        orig_sid = g_strdup (sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1762
+        seat = ck_seat_new_from_file (&sid, filename);
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1763
+
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1764
+        if (seat == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1765
+                /* returns null if connection to bus fails */
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1766
+                g_free (sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1767
+                g_free (orig_sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1768
+                manager->priv->seat_serial--;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1769
+                return;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1770
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1771
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1772
+        if (!g_str_equal (orig_sid, sid)) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1773
+                manager->priv->seat_serial--;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1774
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1775
+        g_free (orig_sid);
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1776
 
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1777
-        seat = ck_seat_new_from_file (sid, filename);
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1778
+        add_sessions_from_seat (manager, seat);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1779
 
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1780
         if (seat == NULL) {
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1781
                 return;
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1782
@@ -2637,7 +3041,7 @@ add_seat_for_file (CkManager  *manager,
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1783
         ck_seat_run_programs (seat, NULL, NULL, "seat_added");
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1784
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1785
         g_debug ("Emitting seat-added: %s", sid);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1786
-        g_signal_emit (manager, signals [SEAT_ADDED], 0, sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1787
+        g_signal_emit (manager, signals [SEAT_ADDED], 0, sid, "Default");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1788
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1789
         log_seat_added_event (manager, seat);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1790
 }
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1791
@@ -2648,6 +3052,7 @@ load_seats_from_dir (CkManager *manager)
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1792
         GDir       *d;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1793
         GError     *error;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1794
         const char *file;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1795
+        GQueue      seat_queue;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1796
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1797
         error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1798
         d = g_dir_open (CK_SEAT_DIR,
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1799
@@ -2659,17 +3064,26 @@ load_seats_from_dir (CkManager *manager)
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1800
                 return FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1801
         }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1802
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1803
+        g_queue_init (&seat_queue);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1804
         while ((file = g_dir_read_name (d)) != NULL) {
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1805
                 if (g_str_has_suffix (file, ".seat")) {
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1806
                         char *path;
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1807
                         path = g_build_filename (CK_SEAT_DIR, file, NULL);
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1808
-                        add_seat_for_file (manager, path);
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1809
-                        g_free (path);
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1810
+                        g_queue_push_tail (&seat_queue, path);
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1811
                 }
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1812
         }
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1813
-
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1814
         g_dir_close (d);
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1815
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1816
+        g_queue_sort (&seat_queue, (GCompareDataFunc) strverscmp, NULL);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1817
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1818
+        while (!g_queue_is_empty (&seat_queue)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1819
+                char *path;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1820
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1821
+                path = g_queue_pop_head (&seat_queue);
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1822
+                add_seat_for_file (manager, path);
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1823
+                g_free (path);
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1824
+        }
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1825
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1826
         return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1827
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1828
 
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1829
@@ -2705,8 +3119,6 @@ ck_manager_init (CkManager *manager)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1830
                                                         (GDestroyNotify) g_object_unref);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1831
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1832
         manager->priv->logger = ck_event_logger_new (LOG_FILE);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1833
-
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1834
-        create_seats (manager);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1835
 }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1836
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1837
 static void
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  1838
@@ -2751,6 +3163,8 @@ ck_manager_new (void)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1839
                         g_object_unref (manager_object);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1840
                         return NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1841
                 }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1842
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1843
+                create_seats (CK_MANAGER (manager_object));
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1844
         }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1845
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1846
         return CK_MANAGER (manager_object);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1847
diff --git a/src/ck-manager.h b/src/ck-manager.h
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1848
index 4bd56e8..4304e71 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1849
--- a/src/ck-manager.h
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1850
+++ b/src/ck-manager.h
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1851
@@ -49,7 +49,8 @@ typedef struct
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1852
         GObjectClass   parent_class;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1853
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1854
         void          (* seat_added)               (CkManager  *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1855
-                                                    const char *sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1856
+                                                    const char *sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1857
+                                                    const char *type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1858
         void          (* seat_removed)             (CkManager  *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1859
                                                     const char *sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1860
         void          (* system_idle_hint_changed) (CkManager  *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1861
@@ -96,6 +97,9 @@ gboolean            ck_manager_get_sessions                   (CkManager
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1862
 gboolean            ck_manager_get_seats                      (CkManager             *manager,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1863
                                                                GPtrArray            **seats,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1864
                                                                GError               **error);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1865
+gboolean            ck_manager_get_unmanaged_seats            (CkManager             *manager,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1866
+                                                               GPtrArray            **seats,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1867
+                                                               GError               **error);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1868
 gboolean            ck_manager_close_session                  (CkManager             *manager,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1869
                                                                const char            *cookie,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1870
                                                                DBusGMethodInvocation *context);
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1871
@@ -128,6 +132,28 @@ gboolean            ck_manager_open_session_with_parameters   (CkManager
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1872
                                                                const GPtrArray       *parameters,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1873
                                                                DBusGMethodInvocation *context);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1874
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1875
+gboolean            ck_manager_add_seat                       (CkManager             *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1876
+                                                               const char            *type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1877
+                                                               char                 **sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1878
+                                                               GError               **error);
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1879
+gboolean            ck_manager_add_seat_by_id                 (CkManager             *manager,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1880
+                                                               const char            *type,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1881
+                                                               const char            *sid,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1882
+                                                               GError               **error);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1883
+gboolean            ck_manager_remove_seat                    (CkManager             *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1884
+                                                               const char            *sid,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1885
+                                                               DBusGMethodInvocation *context);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1886
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1887
+gboolean            ck_manager_add_session                    (CkManager             *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1888
+                                                               const char            *sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1889
+                                                               const char            *type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1890
+                                                               const char            *display_type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1891
+                                                               GHashTable            *parameters,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1892
+                                                               DBusGMethodInvocation *context);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1893
+gboolean            ck_manager_remove_session                  (CkManager             *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1894
+                                                                const char            *ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1895
+                                                                DBusGMethodInvocation *context);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1896
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1897
 G_END_DECLS
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1898
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1899
 #endif /* __CK_MANAGER_H */
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1900
diff --git a/src/ck-marshal.list b/src/ck-marshal.list
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1901
index 7f60efc..f8029a6 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1902
--- a/src/ck-marshal.list
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1903
+++ b/src/ck-marshal.list
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1904
@@ -1,3 +1,5 @@
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1905
 VOID:UINT,STRING
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1906
 BOOLEAN:POINTER
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1907
+VOID:STRING,STRING
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1908
+VOID:STRING,BOOLEAN,STRING,POINTER,STRING,POINTER
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1909
 VOID:OBJECT,OBJECT
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1910
diff --git a/src/ck-seat.c b/src/ck-seat.c
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  1911
index af7db59..dd2a387 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1912
--- a/src/ck-seat.c
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1913
+++ b/src/ck-seat.c
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1914
@@ -40,21 +40,30 @@
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1915
 #include "ck-seat-glue.h"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1916
 #include "ck-marshal.h"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1917
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1918
+#include "ck-display-template.h"
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1919
 #include "ck-session.h"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1920
 #include "ck-vt-monitor.h"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1921
 #include "ck-run-programs.h"
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1922
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1923
 #define CK_SEAT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CK_TYPE_SEAT, CkSeatPrivate))
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1924
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1925
+#define CK_SESSION_DIR SYSCONFDIR "/ConsoleKit/sessions.d"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1926
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1927
 #define CK_DBUS_PATH "/org/freedesktop/ConsoleKit"
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1928
 #define CK_DBUS_NAME "org.freedesktop.ConsoleKit"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1929
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1930
 #define NONULL_STRING(x) ((x) != NULL ? (x) : "")
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1931
+#define N_ELEMENTS(arr)  (sizeof (arr) / sizeof ((arr)[0]))
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1932
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1933
+#define IS_STR_SET(x) (x != NULL && x[0] != '\0')
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1934
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1935
+#define CK_DBUS_TYPE_G_STRING_STRING_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING))
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1936
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1937
 struct CkSeatPrivate
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1938
 {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1939
         char            *id;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1940
         CkSeatKind       kind;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1941
+        char            *type;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1942
         GHashTable      *sessions;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1943
         GPtrArray       *devices;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1944
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1945
@@ -63,6 +72,8 @@ struct CkSeatPrivate
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1946
         CkVtMonitor     *vt_monitor;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1947
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1948
         DBusGConnection *connection;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1949
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1950
+        DBusGProxy      *manager_proxy;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1951
 };
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1952
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1953
 enum {
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1954
@@ -74,6 +85,7 @@ enum {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1955
         SESSION_REMOVED_FULL,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1956
         DEVICE_ADDED,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1957
         DEVICE_REMOVED,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1958
+        REMOVE_REQUEST,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1959
         LAST_SIGNAL
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1960
 };
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1961
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1962
@@ -81,6 +93,7 @@ enum {
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1963
         PROP_0,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1964
         PROP_ID,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1965
         PROP_KIND,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1966
+        PROP_TYPE
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1967
 };
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1968
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1969
 static guint signals [LAST_SIGNAL] = { 0, };
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1970
@@ -287,6 +300,7 @@ ck_seat_activate_session (CkSeat                *seat,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1971
 {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1972
         CkSession *session;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1973
         gboolean   ret;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1974
+        gboolean   is_open;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1975
 
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1976
         g_return_val_if_fail (CK_IS_SEAT (seat), FALSE);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1977
 
17338
0c396fbcf0fa 2010-01-14 Halton Huo <[email protected]>
halton
parents: 17046
diff changeset
  1978
@@ -298,12 +312,390 @@ ck_seat_activate_session (CkSeat                *seat,
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1979
                 session = g_hash_table_lookup (seat->priv->sessions, ssid);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1980
         }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1981
 
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1982
-        ret = _seat_activate_session (seat, session, context);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1983
+        ck_session_is_open (session, &is_open, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1984
+        if (!is_open) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1985
+                ret = ck_seat_request_open_session (seat, session, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1986
+                dbus_g_method_return (context, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1987
+        } else {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1988
+                ret = _seat_activate_session (seat, session, context);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1989
+        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1990
 
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1991
         return ret;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1992
 }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1993
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1994
 static gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1995
+on_substitution_match (const GMatchInfo *match_info,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1996
+                       GString          *result,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1997
+                       GHashTable       *substitution_variables)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1998
+{
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1999
+        char *match;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2000
+        char *value;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2001
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2002
+        match = g_match_info_fetch (match_info, 1);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2003
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2004
+        value = g_hash_table_lookup (substitution_variables, match);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2005
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2006
+        if (value != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2007
+                g_string_append (result, value);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2008
+        } else {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2009
+                char *original_string;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2010
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2011
+                original_string = g_match_info_fetch (match_info, 0);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2012
+                g_string_append (result, original_string);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2013
+                g_free (original_string);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2014
+        }
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2015
+        g_free (match);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2016
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2017
+        return FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2018
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2019
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2020
+static char *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2021
+apply_substitutions (const char *value,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2022
+                     GHashTable *substitution_variables)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2023
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2024
+        GRegex *expression;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2025
+        char *expanded_string;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2026
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2027
+        expression = g_regex_new ("\\$([^[:space:]]+)", 0, 0, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2028
+        expanded_string = g_regex_replace_eval (expression,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2029
+                                                value,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2030
+                                                -1, 0, 0,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2031
+                                                (GRegexEvalCallback)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2032
+                                                on_substitution_match,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2033
+                                                substitution_variables,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2034
+                                                NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2035
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2036
+        if (expanded_string == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2037
+                expanded_string = g_strdup (value);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2038
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2039
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2040
+        return expanded_string;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2041
+}
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2042
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2043
+static GHashTable *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2044
+get_evaluated_parameter_map (GHashTable    *parameters,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2045
+                             GHashTable    *substitution_variables)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2046
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2047
+        GHashTable *evaluated_parameters;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2048
+        GHashTableIter iter;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2049
+        gpointer key, value;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2050
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2051
+        evaluated_parameters = g_hash_table_new_full (g_str_hash, g_str_equal,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2052
+                                                      (GDestroyNotify) g_free,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2053
+                                                      (GDestroyNotify) g_free);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2054
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2055
+        g_hash_table_iter_init (&iter, parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2056
+        while (g_hash_table_iter_next (&iter, &key, &value)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2057
+                char *expanded_string;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2058
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2059
+                expanded_string = apply_substitutions ((char *) value,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2060
+                                                       substitution_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2061
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2062
+                g_hash_table_insert (evaluated_parameters,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2063
+                                     g_strdup ((char *) key),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2064
+                                     expanded_string);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2065
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2066
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2067
+        return evaluated_parameters;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2068
+}
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2069
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2070
+static void
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2071
+request_session (gpointer key,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2072
+                 gpointer value,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2073
+                 gpointer user_data)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2074
+{
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2075
+        CkSeat      *seat = CK_SEAT (user_data);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2076
+        CkSession   *session = (CkSession *) value;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2077
+
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  2078
+        ck_session_set_ever_open (session, FALSE, NULL);
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  2079
+        ck_session_set_under_request (session, FALSE, NULL);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2080
+        ck_seat_request_open_session (seat, session, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2081
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2082
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2083
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2084
+append_hash_table_to_dbus_message_iter (DBusMessageIter *iter,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2085
+                                        GHashTable      *hash_table)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2086
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2087
+        GHashTableIter hash_table_iter;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2088
+        gpointer key, value;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2089
+        DBusMessageIter array_iter;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2090
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2091
+        dbus_message_iter_open_container (iter,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2092
+                                          DBUS_TYPE_ARRAY,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2093
+                                          DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2094
+                                          DBUS_TYPE_STRING_AS_STRING
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2095
+                                          DBUS_TYPE_STRING_AS_STRING
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2096
+                                          DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2097
+                                          &array_iter);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2098
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2099
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2100
+        g_hash_table_iter_init (&hash_table_iter, hash_table);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2101
+        while (g_hash_table_iter_next (&hash_table_iter, &key, &value)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2102
+                DBusMessageIter dict_iter;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2103
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2104
+                dbus_message_iter_open_container (&array_iter,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2105
+                                                  DBUS_TYPE_DICT_ENTRY,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2106
+                                                  NULL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2107
+                                                  &dict_iter);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2108
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2109
+                dbus_message_iter_append_basic (&dict_iter, DBUS_TYPE_STRING, &key);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2110
+                dbus_message_iter_append_basic (&dict_iter, DBUS_TYPE_STRING, &value);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2111
+                dbus_message_iter_close_container (&array_iter, &dict_iter);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2112
+        }
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2113
+        dbus_message_iter_close_container (iter, &array_iter);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2114
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2115
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2116
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2117
+emit_session_open_request (CkSeat     *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2118
+                          const char *ssid,
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2119
+                          const char *session_type,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2120
+                          const char *display_template_name,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2121
+                          GHashTable *display_variables,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2122
+                          const char *display_type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2123
+                          GHashTable *evaluated_parameters)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2124
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2125
+        DBusMessage    *message;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2126
+        DBusConnection *connection;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2127
+        DBusMessageIter iter;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2128
+
17338
0c396fbcf0fa 2010-01-14 Halton Huo <[email protected]>
halton
parents: 17046
diff changeset
  2129
+        if (!ck_seat_is_managed (seat))
0c396fbcf0fa 2010-01-14 Halton Huo <[email protected]>
halton
parents: 17046
diff changeset
  2130
+                return;
0c396fbcf0fa 2010-01-14 Halton Huo <[email protected]>
halton
parents: 17046
diff changeset
  2131
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2132
+        message = dbus_message_new_signal (seat->priv->id,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2133
+                                           "org.freedesktop.ConsoleKit.Seat",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2134
+                                           "OpenSessionRequest");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2135
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2136
+        dbus_message_set_destination (message,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2137
+                                      dbus_g_proxy_get_bus_name (seat->priv->manager_proxy));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2138
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2139
+        dbus_message_iter_init_append (message, &iter);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2140
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_OBJECT_PATH, &ssid);
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2141
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session_type);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2142
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_template_name);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2143
+        append_hash_table_to_dbus_message_iter (&iter, display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2144
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2145
+        append_hash_table_to_dbus_message_iter (&iter, evaluated_parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2146
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2147
+        connection = dbus_bus_get (DBUS_BUS_SYSTEM, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2148
+        dbus_connection_send (connection, message, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2149
+        dbus_connection_unref (connection);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2150
+        dbus_message_unref (message);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2151
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2152
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2153
+gboolean
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2154
+ck_seat_request_open_session (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2155
+                              CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2156
+                              GError               **error)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2157
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2158
+        char        *ssid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2159
+        char        *type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2160
+        CkDisplayTemplate *display_template;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2161
+        GHashTable  *display_variables;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2162
+        GHashTable  *display_parameters;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2163
+        GHashTable  *evaluated_parameters;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2164
+        gboolean    is_open;
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2165
+        gboolean    ever_open;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2166
+        gboolean    under_request;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2167
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2168
+        ck_session_is_open (session, &is_open, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2169
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2170
+        if (is_open) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2171
+                return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2172
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2173
+
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2174
+        ck_session_get_under_request (session, &under_request, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2175
+        if (under_request) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2176
+                return TRUE;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2177
+        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2178
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2179
+        ck_session_set_under_request (session, TRUE, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2180
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2181
+        ck_session_get_ever_open (session, &ever_open, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2182
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2183
+        display_template = ck_session_get_display_template (session);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2184
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2185
+        if (display_template == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2186
+                return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2187
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2188
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2189
+        ck_session_get_session_type (session, &type, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2190
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2191
+        if (type == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2192
+                g_object_unref (display_template);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2193
+                return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2194
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2195
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2196
+        /* substitute $display $vt etc */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2197
+        display_variables = ck_session_get_display_variables (session);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2198
+        display_parameters = ck_display_template_get_parameters (display_template);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2199
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2200
+        if (display_parameters == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2201
+                g_free (type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2202
+                g_object_unref (display_template);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2203
+                g_hash_table_unref (display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2204
+                return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2205
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2206
+
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2207
+        if (!ever_open) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2208
+                evaluated_parameters = get_evaluated_parameter_map (display_parameters, display_variables);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2209
+        } else {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2210
+                evaluated_parameters = get_evaluated_parameter_map (display_parameters, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2211
+        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2212
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2213
+        g_hash_table_unref (display_parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2214
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2215
+        ck_session_get_id (session, &ssid, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2216
+
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2217
+        emit_session_open_request (seat, ssid, type,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2218
+                                   ck_display_template_get_name (display_template),
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2219
+                                   display_variables,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2220
+                                   ck_display_template_get_type_string (display_template),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2221
+                                   evaluated_parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2222
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2223
+        g_free (ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2224
+        g_free (type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2225
+        g_hash_table_unref (evaluated_parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2226
+        g_hash_table_unref (display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2227
+        g_object_unref (display_template);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2228
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2229
+        return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2230
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2231
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2232
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2233
+on_seat_manager_disappeared (CkSeat *seat)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2234
+{
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2235
+        g_signal_handlers_disconnect_by_func (seat->priv->manager_proxy,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2236
+                                              G_CALLBACK (on_seat_manager_disappeared),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2237
+                                              seat);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2238
+        g_object_unref (seat->priv->manager_proxy);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2239
+        seat->priv->manager_proxy = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2240
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2241
+        /* FIXME: should probably emit a signal so a new display manager
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2242
+         * knows that the seat is now unmanaged
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2243
+         *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2244
+         * (maybe only if its kind is static?)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2245
+         */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2246
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2247
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2248
+gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2249
+ck_seat_manage (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2250
+                DBusGMethodInvocation *context)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2251
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2252
+        char *sender_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2253
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2254
+        sender_name = dbus_g_method_get_sender (context);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2255
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2256
+        if (seat->priv->manager_proxy != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2257
+                GError *error;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2258
+                const char   *existing_manager_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2259
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2260
+                existing_manager_name = dbus_g_proxy_get_bus_name (seat->priv->manager_proxy);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2261
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2262
+                if (existing_manager_name == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2263
+                        g_warning ("Seat manager lacks bus unique name");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2264
+                        existing_manager_name = "<unknown>";
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2265
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2266
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2267
+                error = g_error_new (CK_SEAT_ERROR,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2268
+                                     CK_SEAT_ERROR_GENERAL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2269
+                                     _("Seat already managed (by '%s')"),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2270
+                                     existing_manager_name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2271
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2272
+                dbus_g_method_return_error (context, error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2273
+                g_error_free (error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2274
+                return FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2275
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2276
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2277
+        /* FIXME: We pass in a bogus object path (the path we use on this side of
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2278
+         * the pipe) and interface here.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2279
+         *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2280
+         * We only use the proxy to watch for when the other side disappears, not
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2281
+         * for communicating with it.  All communication is one-way using signals.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2282
+         */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2283
+        seat->priv->manager_proxy = dbus_g_proxy_new_for_name (seat->priv->connection,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2284
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2285
+                                                               sender_name,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2286
+                                                               seat->priv->id,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2287
+                                                               "org.freedesktop.ConsoleKit.SeatManager");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2288
+        g_free (sender_name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2289
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2290
+        g_signal_connect_swapped (seat->priv->manager_proxy,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2291
+                                  "destroy",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2292
+                                  G_CALLBACK (on_seat_manager_disappeared),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2293
+                                  seat);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2294
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2295
+        g_hash_table_foreach (seat->priv->sessions, request_session, seat);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2296
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2297
+        dbus_g_method_return (context);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2298
+        return TRUE;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2299
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2300
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2301
+gboolean
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2302
+ck_seat_unmanage (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2303
+                  DBusGMethodInvocation *context)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2304
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2305
+        GError *error;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2306
+        const char   *existing_manager_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2307
+        char *sender_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2308
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2309
+        if (seat->priv->manager_proxy == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2310
+                GError *error;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2311
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2312
+                error = g_error_new (CK_SEAT_ERROR,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2313
+                                     CK_SEAT_ERROR_GENERAL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2314
+                                     _("Seat not managed"));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2315
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2316
+                dbus_g_method_return_error (context, error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2317
+                g_error_free (error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2318
+                return FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2319
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2320
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2321
+        sender_name = dbus_g_method_get_sender (context);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2322
+        existing_manager_name = dbus_g_proxy_get_bus_name (seat->priv->manager_proxy);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2323
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2324
+        if (strcmp (sender_name, existing_manager_name) != 0) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2325
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2326
+            error = g_error_new (CK_SEAT_ERROR,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2327
+                                 CK_SEAT_ERROR_GENERAL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2328
+                                 _("Seat managed by '%s' not '%s'"),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2329
+                                 existing_manager_name,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2330
+                                 sender_name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2331
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2332
+            dbus_g_method_return_error (context, error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2333
+            g_error_free (error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2334
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2335
+            return FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2336
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2337
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2338
+        on_seat_manager_disappeared (seat);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2339
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2340
+        dbus_g_method_return (context);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2341
+        return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2342
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2343
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2344
+void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2345
+ck_seat_request_removal (CkSeat *seat)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2346
+{
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2347
+        DBusMessage    *message;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2348
+        DBusConnection *connection;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2349
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2350
+        g_return_if_fail (CK_IS_SEAT (seat));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2351
+        g_return_if_fail (ck_seat_is_managed (seat));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2352
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2353
+        message = dbus_message_new_signal (seat->priv->id,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2354
+                                           "org.freedesktop.ConsoleKit.Seat",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2355
+                                           "RemoveRequest");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2356
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2357
+        dbus_message_set_destination (message,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2358
+                                      dbus_g_proxy_get_bus_name (seat->priv->manager_proxy));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2359
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2360
+        connection = dbus_bus_get (DBUS_BUS_SYSTEM, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2361
+        dbus_connection_send (connection, message, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2362
+        dbus_connection_unref (connection);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2363
+        dbus_message_unref (message);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2364
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2365
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2366
+static gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2367
 match_session_display_device (const char *key,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2368
                               CkSession  *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2369
                               const char *display_device)
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2370
@@ -526,6 +918,41 @@ change_active_session (CkSeat    *seat,
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2371
 }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2372
 
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2373
 static void
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2374
+find_possible_session_to_activate (CkSeat *seat)
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2375
+{
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2376
+        GHashTableIter iter;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2377
+        gpointer       key, value;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2378
+        gboolean       is_open;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2379
+        char          *session_type = NULL;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2380
+        CkSession     *login_session = NULL;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2381
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2382
+        g_hash_table_iter_init (&iter, seat->priv->sessions);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2383
+        while (g_hash_table_iter_next (&iter, &key, &value)) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2384
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2385
+                ck_session_is_open (value, &is_open, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2386
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2387
+                if (is_open) {
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2388
+                        login_session = NULL;
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2389
+                        change_active_session (seat, value);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2390
+                        break;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2391
+                }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2392
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2393
+                ck_session_get_session_type (value, &session_type, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2394
+                if (IS_STR_SET (session_type) &&
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2395
+                    g_str_equal (session_type, "LoginWindow")) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2396
+                        login_session = value;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2397
+                        g_free (session_type);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2398
+                }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2399
+        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2400
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2401
+        if (login_session != NULL) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2402
+                ck_session_set_ever_open (login_session, FALSE, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2403
+                ck_seat_request_open_session (seat, login_session, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2404
+        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2405
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2406
+}
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2407
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2408
+static void
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2409
 update_active_vt (CkSeat *seat,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2410
                   guint   num)
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2411
 {
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2412
@@ -537,7 +964,12 @@ update_active_vt (CkSeat *seat,
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2413
         g_debug ("Active device: %s", device);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2414
 
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2415
         session = find_session_for_display_device (seat, device);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2416
-        change_active_session (seat, session);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2417
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2418
+        if (session == NULL) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2419
+                find_possible_session_to_activate (seat);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2420
+        } else {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2421
+                change_active_session (seat, session);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2422
+        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2423
 
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2424
         g_free (device);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2425
 }
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2426
@@ -547,12 +979,18 @@ maybe_update_active_session (CkSeat *seat)
17046
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2427
 {
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2428
         guint num;
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2429
 
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2430
-        if (seat->priv->kind != CK_SEAT_KIND_STATIC) {
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2431
-                return;
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2432
-        }
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2433
-
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2434
-        if (ck_vt_monitor_get_active (seat->priv->vt_monitor, &num, NULL)) {
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2435
-                update_active_vt (seat, num);
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2436
+        switch (seat->priv->kind){
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2437
+        case CK_SEAT_KIND_STATIC:
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2438
+                if (ck_vt_monitor_get_active (seat->priv->vt_monitor,
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2439
+                                              &num, NULL)) {
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2440
+                        update_active_vt (seat, num);
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2441
+                }
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2442
+                break;
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2443
+        case CK_SEAT_KIND_DYNAMIC:
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2444
+                find_possible_session_to_activate (seat);
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2445
+                break;
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2446
+        default:
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2447
+                break;
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2448
         }
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2449
 }
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2450
 
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2451
@@ -628,18 +1066,77 @@ ck_seat_remove_session (CkSeat         *seat,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2452
         return ret;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2453
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2454
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2455
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2456
+emit_session_close_request (CkSeat     *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2457
+                            const char *ssid)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2458
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2459
+        DBusMessage    *message;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2460
+        DBusConnection *connection;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2461
+        DBusMessageIter iter;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2462
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2463
+        message = dbus_message_new_signal (seat->priv->id,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2464
+                                           "org.freedesktop.ConsoleKit.Seat",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2465
+                                           "CloseSessionRequest");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2466
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2467
+        dbus_message_set_destination (message,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2468
+                                      dbus_g_proxy_get_bus_name (seat->priv->manager_proxy));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2469
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2470
+        dbus_message_iter_init_append (message, &iter);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2471
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_OBJECT_PATH, &ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2472
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2473
+        connection = dbus_bus_get (DBUS_BUS_SYSTEM, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2474
+        dbus_connection_send (connection, message, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2475
+        dbus_connection_unref (connection);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2476
+        dbus_message_unref (message);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2477
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2478
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2479
+gboolean
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2480
+ck_seat_request_close_session (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2481
+                               CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2482
+                               GError               **error)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2483
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2484
+        char      *ssid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2485
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2486
+        g_return_val_if_fail (CK_IS_SEAT (seat), FALSE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2487
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2488
+        g_return_val_if_fail (ck_seat_is_managed (seat), FALSE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2489
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2490
+        ck_session_get_id (session, &ssid, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2491
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2492
+        emit_session_close_request (seat, ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2493
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2494
+        g_free (ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2495
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2496
+        return FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2497
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2498
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2499
 gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2500
 ck_seat_add_session (CkSeat         *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2501
                      CkSession      *session,
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2502
                      GError        **error)
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2503
 {
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2504
         char *ssid;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2505
+        GHashTableIter iter;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2506
+        gpointer key, value;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2507
+        gboolean found;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2508
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2509
         g_return_val_if_fail (CK_IS_SEAT (seat), FALSE);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2510
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2511
         ck_session_get_id (session, &ssid, NULL);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2512
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2513
-        g_hash_table_insert (seat->priv->sessions, g_strdup (ssid), g_object_ref (session));
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2514
+        found = FALSE;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2515
+        g_hash_table_iter_init (&iter, seat->priv->sessions);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2516
+        while (g_hash_table_iter_next (&iter, &key, &value)) {
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2517
+                if (g_str_equal ((gchar *)key, ssid)) {
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2518
+                        found = TRUE;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2519
+                        break;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2520
+                }
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2521
+        }
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2522
+
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2523
+        if (! found)
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2524
+                g_hash_table_insert (seat->priv->sessions, g_strdup (ssid), g_object_ref (session));
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2525
+        else
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2526
+                g_object_ref (session);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2527
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2528
         ck_session_set_seat_id (session, seat->priv->id, NULL);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2529
 
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2530
@@ -656,6 +1153,10 @@ ck_seat_add_session (CkSeat         *seat,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2531
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2532
         maybe_update_active_session (seat);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2533
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2534
+        if (ck_seat_is_managed (seat)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2535
+                ck_seat_request_open_session (seat, session, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2536
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2537
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2538
         g_free (ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2539
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2540
         return TRUE;
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2541
@@ -742,6 +1243,20 @@ ck_seat_get_kind (CkSeat        *seat,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2542
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2543
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2544
 gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2545
+ck_seat_get_type_string (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2546
+                         char                 **type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2547
+                         GError               **error)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2548
+{
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2549
+        g_return_val_if_fail (CK_IS_SEAT (seat), FALSE);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2550
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2551
+        if (type != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2552
+                *type = g_strdup (seat->priv->type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2553
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2554
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2555
+        return TRUE;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2556
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2557
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2558
+gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2559
 ck_seat_get_id (CkSeat         *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2560
                 char          **id,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2561
                 GError        **error)
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2562
@@ -858,6 +1373,14 @@ _ck_seat_set_kind (CkSeat    *seat,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2563
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2564
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2565
 static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2566
+_ck_seat_set_type_string (CkSeat         *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2567
+                          const char     *type)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2568
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2569
+        g_free (seat->priv->type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2570
+        seat->priv->type = g_strdup (type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2571
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2572
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2573
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2574
 ck_seat_set_property (GObject            *object,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2575
                       guint               prop_id,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2576
                       const GValue       *value,
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2577
@@ -874,6 +1397,9 @@ ck_seat_set_property (GObject            *object,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2578
         case PROP_KIND:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2579
                 _ck_seat_set_kind (self, g_value_get_enum (value));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2580
                 break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2581
+        case PROP_TYPE:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2582
+                _ck_seat_set_type_string (self, g_value_get_string (value));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2583
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2584
         default:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2585
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2586
                 break;
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2587
@@ -895,7 +1421,10 @@ ck_seat_get_property (GObject    *object,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2588
                 g_value_set_string (value, self->priv->id);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2589
                 break;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2590
         case PROP_KIND:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2591
-                g_value_set_string (value, self->priv->id);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2592
+                g_value_set_enum (value, self->priv->kind);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2593
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2594
+        case PROP_TYPE:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2595
+                g_value_set_string (value, self->priv->type);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2596
                 break;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2597
         default:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2598
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2599
@@ -1008,6 +1537,15 @@ ck_seat_class_init (CkSeatClass *klass)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2600
                                                  G_TYPE_NONE,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2601
                                                  1, CK_TYPE_DEVICE);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2602
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2603
+        signals [REMOVE_REQUEST] = g_signal_new ("remove-request",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2604
+                                                  G_TYPE_FROM_CLASS (object_class),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2605
+                                                  G_SIGNAL_RUN_LAST,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2606
+                                                  G_STRUCT_OFFSET (CkSeatClass, remove_request),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2607
+                                                  NULL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2608
+                                                  NULL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2609
+                                                  g_cclosure_marshal_VOID__VOID,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2610
+                                                  G_TYPE_NONE, 0);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2611
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2612
         g_object_class_install_property (object_class,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2613
                                          PROP_ID,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2614
                                          g_param_spec_string ("id",
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2615
@@ -1024,6 +1562,13 @@ ck_seat_class_init (CkSeatClass *klass)
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2616
                                                             CK_SEAT_KIND_DYNAMIC,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2617
                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2618
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2619
+        g_object_class_install_property (object_class,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2620
+                                         PROP_TYPE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2621
+                                         g_param_spec_string ("type",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2622
+                                                              "type",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2623
+                                                              "type",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2624
+                                                              NULL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2625
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2626
         g_type_class_add_private (klass, sizeof (CkSeatPrivate));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2627
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2628
         dbus_g_object_type_install_info (CK_TYPE_SEAT, &dbus_glib_ck_seat_object_info);
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2629
@@ -1039,6 +1584,7 @@ ck_seat_init (CkSeat *seat)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2630
                                                       g_free,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2631
                                                       (GDestroyNotify) g_object_unref);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2632
         seat->priv->devices = g_ptr_array_new ();
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2633
+        seat->priv->manager_proxy = NULL;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2634
 }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2635
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2636
 static void
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2637
@@ -1064,28 +1610,32 @@ ck_seat_finalize (GObject *object)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2638
         g_ptr_array_free (seat->priv->devices, TRUE);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2639
         g_hash_table_destroy (seat->priv->sessions);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2640
         g_free (seat->priv->id);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2641
+        g_free (seat->priv->type);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2642
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2643
         G_OBJECT_CLASS (ck_seat_parent_class)->finalize (object);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2644
 }
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2645
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2646
 CkSeat *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2647
 ck_seat_new (const char *sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2648
-             CkSeatKind  kind)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2649
+             CkSeatKind  kind,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2650
+             const char *type)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2651
 {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2652
         GObject *object;
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2653
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2654
         object = g_object_new (CK_TYPE_SEAT,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2655
                                "id", sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2656
                                "kind", kind,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2657
+                               "type", type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2658
                                NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2659
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2660
         return CK_SEAT (object);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2661
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2662
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2663
 CkSeat *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2664
-ck_seat_new_with_devices (const char *sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2665
-                          CkSeatKind  kind,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2666
-                          GPtrArray  *devices)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2667
+ck_seat_new_with_devices_and_sessions (const char *sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2668
+                                       CkSeatKind  kind,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2669
+                                       GPtrArray  *devices,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2670
+                                       GPtrArray  *sessions)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2671
 {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2672
         GObject *object;
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2673
         int      i;
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2674
@@ -1100,24 +1650,57 @@ ck_seat_new_with_devices (const char *sid,
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2675
                         ck_seat_add_device (CK_SEAT (object), g_ptr_array_index (devices, i), NULL);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2676
                 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2677
         }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2678
+        if (sessions != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2679
+                for (i = 0; i < sessions->len; i++) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2680
+                        ck_seat_add_session (CK_SEAT (object), g_ptr_array_index (sessions, i), NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2681
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2682
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2683
+
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2684
 
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2685
         return CK_SEAT (object);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2686
 }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2687
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2688
+static char *
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2689
+generate_static_session_id (const char *sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2690
+                            const char *session_name)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2691
+{
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2692
+        const char *seat_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2693
+        char *ssid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2694
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2695
+        seat_name = strrchr (sid, '/');
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2696
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2697
+        if (seat_name == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2698
+                g_warning ("Seat id '%s' lacks a /", sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2699
+                seat_name = sid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2700
+        } else {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2701
+                seat_name++;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2702
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2703
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2704
+        ssid = g_strdup_printf ("%s/Session%s%s",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2705
+                                CK_DBUS_PATH, seat_name,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2706
+                                session_name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2707
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2708
+        return ssid;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2709
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2710
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2711
 CkSeat *
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2712
-ck_seat_new_from_file (const char *sid,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2713
+ck_seat_new_from_file (char       **sid,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2714
                        const char *path)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2715
 {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2716
-        GKeyFile  *key_file;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2717
-        gboolean   res;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2718
-        GError    *error;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2719
-        char      *group;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2720
-        CkSeat    *seat;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2721
-        gboolean   hidden;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2722
-        GPtrArray *devices;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2723
-        char     **device_list;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2724
-        gsize      ndevices;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2725
-        gsize      i;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2726
+        GKeyFile      *key_file;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2727
+        gboolean       res;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2728
+        GError        *error;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2729
+        char          *group;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2730
+        CkSeat        *seat;
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2731
+        char          *read_sid;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2732
+        gboolean       hidden;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2733
+        GPtrArray     *sessions;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2734
+        char         **session_list;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2735
+        gsize          nsessions;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2736
+        GPtrArray     *devices;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2737
+        char         **device_list;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2738
+        gsize          ndevices;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2739
+        gsize          i;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2740
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2741
         seat = NULL;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2742
 
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2743
@@ -1145,6 +1728,49 @@ ck_seat_new_from_file (const char *sid,
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2744
                 goto out;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2745
         }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2746
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2747
+        read_sid = g_key_file_get_string (key_file, group, "ID", NULL);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2748
+        if (IS_STR_SET (read_sid)) {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2749
+                g_free (*sid);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2750
+                *sid = g_strdup_printf ("%s/%s", CK_DBUS_PATH, read_sid);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2751
+        } else {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2752
+                g_free (read_sid);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2753
+        }
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2754
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2755
+        session_list = g_key_file_get_string_list (key_file, group, "Sessions", &nsessions, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2756
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2757
+        sessions = g_ptr_array_sized_new (nsessions);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2758
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2759
+        for (i = 0; i < nsessions; i++) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2760
+                char *path;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2761
+                char *file;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2762
+                char *ssid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2763
+                CkSession *session;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2764
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2765
+                file = g_strconcat (session_list[i], ".session", NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2766
+                path = g_build_filename (CK_SESSION_DIR, file, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2767
+                g_free (file);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2768
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2769
+                /* FIXME: we should probably use the same naming pool as
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2770
+                 * sessions generated from ck-manager.  We mangle the name
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2771
+                 * here so we don't clash with names from ck-manager
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2772
+                 */
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2773
+                ssid = generate_static_session_id (*sid, session_list[i]);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2774
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2775
+                session = ck_session_new_from_file (ssid, path);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2776
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2777
+                if (session == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2778
+                        g_warning ("Unable to load session from file %s", path);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2779
+                        g_free (path);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2780
+                        continue;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2781
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2782
+                g_free (path);
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2783
+                ck_session_set_seat_id (session, *sid, NULL);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2784
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2785
+                g_ptr_array_add (sessions, session);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2786
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2787
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2788
+        g_strfreev (session_list);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2789
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2790
         device_list = g_key_file_get_string_list (key_file, group, "Devices", &ndevices, NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2791
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2792
         g_debug ("Creating seat %s with %zd devices", sid, ndevices);
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2793
@@ -1176,11 +1802,12 @@ ck_seat_new_from_file (const char *sid,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2794
                 g_strfreev (split);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2795
         }
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2796
         g_strfreev (device_list);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2797
-        g_free (group);
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2798
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2799
-        seat = ck_seat_new_with_devices (sid, CK_SEAT_KIND_STATIC, devices);
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2800
+        seat = ck_seat_new_with_devices_and_sessions (*sid, CK_SEAT_KIND_STATIC, devices, sessions);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2801
         g_ptr_array_free (devices, TRUE);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2802
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2803
+        g_free (group);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2804
+
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2805
 out:
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2806
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2807
         g_key_file_free (key_file);
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2808
@@ -1355,10 +1982,15 @@ ck_seat_dump (CkSeat   *seat,
17046
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2809
 
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2810
                 error = NULL;
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2811
                 if (! ck_session_get_id (seat->priv->active_session, &session_id, &error)) {
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2812
-                        g_warning ("Cannot get session id for active session on seat %s: %s",
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2813
-                                   seat->priv->id,
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2814
-                                   error->message);
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2815
-                        g_error_free (error);
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2816
+                        if (error) {
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2817
+                                g_warning ("Cannot get session id for active session on seat %s: %s",
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2818
+                                           seat->priv->id,
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2819
+                                           error->message);
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2820
+                                g_error_free (error);
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2821
+                        } else {
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2822
+                                g_warning ("Cannot get session id for active session on seat %s",
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2823
+                                           seat->priv->id);
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2824
+                        }
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2825
                 } else {
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2826
                         g_key_file_set_string (key_file,
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2827
                                                group_name,
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2828
@@ -1370,3 +2002,24 @@ ck_seat_dump (CkSeat   *seat,
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2829
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2830
         g_free (group_name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2831
 }
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2832
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2833
+gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2834
+ck_seat_is_managed (CkSeat *seat)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2835
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2836
+        return seat->priv->manager_proxy != NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2837
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2838
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2839
+CkSession *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2840
+ck_seat_get_session (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2841
+                     const char            *ssid)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2842
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2843
+        CkSession *session;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2844
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2845
+        session = g_hash_table_lookup (seat->priv->sessions, ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2846
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2847
+        if (session == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2848
+                return NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2849
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2850
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2851
+        return g_object_ref (session);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2852
+}
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2853
diff --git a/src/ck-seat.h b/src/ck-seat.h
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2854
index fb9a955..6276021 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2855
--- a/src/ck-seat.h
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2856
+++ b/src/ck-seat.h
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2857
@@ -47,6 +47,7 @@ typedef struct
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2858
 {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2859
         GObjectClass   parent_class;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2860
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2861
+        void          (* remove_request)         (CkSeat      *seat);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2862
         void          (* active_session_changed) (CkSeat      *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2863
                                                   const char  *ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2864
         void          (* session_added)          (CkSeat      *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2865
@@ -57,6 +58,11 @@ typedef struct
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2866
                                                   GValueArray *device);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2867
         void          (* device_removed)         (CkSeat      *seat,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2868
                                                   GValueArray *device);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2869
+        void          (* session_to_add)         (CkSeat      *seat,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2870
+                                                  gboolean     is_dynamic,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2871
+                                                  const char  *command);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2872
+        void          (* session_to_remove)      (CkSeat      *seat,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2873
+                                                  int          display_number);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2874
 } CkSeatClass;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2875
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2876
 typedef enum
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2877
@@ -84,12 +90,14 @@ typedef enum
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2878
 GQuark              ck_seat_error_quark         (void);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2879
 GType               ck_seat_get_type            (void);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2880
 CkSeat            * ck_seat_new                 (const char            *sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2881
-                                                 CkSeatKind             kind);
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2882
-CkSeat            * ck_seat_new_from_file       (const char            *sid,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2883
-                                                 const char            *path);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2884
-CkSeat            * ck_seat_new_with_devices    (const char            *sid,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2885
                                                  CkSeatKind             kind,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2886
-                                                 GPtrArray             *devices);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2887
+                                                 const char            *type);
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2888
+CkSeat            * ck_seat_new_from_file       (char                 **sid,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2889
+                                                 const char            *path);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2890
+CkSeat            * ck_seat_new_with_devices_and_sessions    (const char            *sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2891
+                                                              CkSeatKind             kind,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2892
+                                                              GPtrArray             *devices,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2893
+                                                              GPtrArray             *sessions);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2894
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2895
 gboolean            ck_seat_register            (CkSeat                *seat);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2896
 
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2897
@@ -104,18 +112,31 @@ void                ck_seat_dump                (CkSeat                *seat,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2898
 gboolean            ck_seat_get_kind            (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2899
                                                  CkSeatKind            *kind,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2900
                                                  GError               **error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2901
+gboolean            ck_seat_get_type_string     (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2902
+                                                 char                 **type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2903
+                                                 GError               **error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2904
 gboolean            ck_seat_add_session         (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2905
                                                  CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2906
                                                  GError               **error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2907
 gboolean            ck_seat_remove_session      (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2908
                                                  CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2909
                                                  GError               **error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2910
+gboolean            ck_seat_request_open_session (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2911
+                                                  CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2912
+                                                  GError               **error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2913
+gboolean            ck_seat_request_close_session (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2914
+                                                   CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2915
+                                                   GError               **error);
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2916
 gboolean            ck_seat_add_device          (CkSeat                *seat,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2917
                                                  GValueArray           *device,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2918
                                                  GError               **error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2919
 gboolean            ck_seat_remove_device       (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2920
                                                  GValueArray           *device,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2921
                                                  GError               **error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2922
+gboolean            ck_seat_is_managed          (CkSeat                *seat);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2923
+CkSession          *ck_seat_get_session         (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2924
+                                                 const char            *ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2925
+void                ck_seat_request_removal     (CkSeat                *seat);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2926
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2927
 /* exported methods */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2928
 gboolean            ck_seat_get_id                (CkSeat                *seat,
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2929
@@ -137,6 +158,10 @@ gboolean            ck_seat_can_activate_sessions (CkSeat                *seat,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2930
 gboolean            ck_seat_activate_session      (CkSeat                *seat,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2931
                                                    const char            *ssid,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2932
                                                    DBusGMethodInvocation *context);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2933
+gboolean            ck_seat_manage                (CkSeat                *seat,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2934
+                                                   DBusGMethodInvocation *context);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2935
+gboolean            ck_seat_unmanage              (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2936
+                                                   DBusGMethodInvocation *context);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2937
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2938
 G_END_DECLS
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2939
 
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2940
diff --git a/src/ck-session-leader.c b/src/ck-session-leader.c
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2941
index 3702602..908d2bb 100644
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2942
--- a/src/ck-session-leader.c
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2943
+++ b/src/ck-session-leader.c
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2944
@@ -238,6 +238,7 @@ static struct {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2945
         { "x11-display",        add_param_string },
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2946
         { "remote-host-name",   add_param_string },
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2947
         { "session-type",       add_param_string },
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2948
+        { "display-type",       add_param_string },
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2949
         { "is-local",           add_param_boolean },
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2950
         { "unix-user",          add_param_int },
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2951
 };
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2952
diff --git a/src/ck-session.c b/src/ck-session.c
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  2953
index d8db9dd..0354dd5 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2954
--- a/src/ck-session.c
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2955
+++ b/src/ck-session.c
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2956
@@ -41,6 +41,7 @@
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2957
 #include "ck-session-glue.h"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2958
 #include "ck-marshal.h"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2959
 #include "ck-run-programs.h"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2960
+#include "ck-display-template.h"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2961
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2962
 #define CK_SESSION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CK_TYPE_SESSION, CkSessionPrivate))
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2963
 
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2964
@@ -58,6 +59,7 @@ struct CkSessionPrivate
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2965
         char            *seat_id;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2966
 
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2967
         char            *session_type;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2968
+        char            *display_type;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2969
         char            *login_session_id;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2970
         char            *display_device;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2971
         char            *x11_display_device;
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  2972
@@ -65,8 +67,15 @@ struct CkSessionPrivate
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2973
         char            *remote_host_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2974
         guint            uid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2975
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2976
+        CkDisplayTemplate *display_template;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2977
+        GHashTable      *display_variables;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2978
+
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2979
         gboolean         active;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2980
         gboolean         is_local;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2981
+        gboolean         is_open;
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2982
+        gboolean         ever_open;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2983
+        gboolean         under_request;
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  2984
+        GMutex          *mutex_under_request;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2985
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2986
         GTimeVal         creation_time;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2987
 
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  2988
@@ -75,6 +84,8 @@ struct CkSessionPrivate
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2989
         gboolean         idle_hint;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2990
         GTimeVal         idle_since_hint;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2991
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2992
+        gboolean         remove_on_close;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2993
+
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2994
         DBusGConnection *connection;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2995
         DBusGProxy      *bus_proxy;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2996
 };
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  2997
@@ -92,17 +103,24 @@ enum {
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2998
         PROP_0,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2999
         PROP_ID,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3000
         PROP_COOKIE,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3001
+        PROP_SEAT_ID,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3002
         PROP_USER,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3003
         PROP_UNIX_USER,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3004
         PROP_X11_DISPLAY,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3005
         PROP_X11_DISPLAY_DEVICE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3006
         PROP_DISPLAY_DEVICE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3007
         PROP_SESSION_TYPE,
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3008
+        PROP_DISPLAY_TYPE,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3009
+        PROP_DISPLAY_TEMPLATE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3010
+        PROP_DISPLAY_VARIABLES,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3011
         PROP_REMOTE_HOST_NAME,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3012
         PROP_LOGIN_SESSION_ID,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3013
         PROP_IS_LOCAL,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3014
+        PROP_IS_OPEN,
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3015
+        PROP_EVER_OPEN,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3016
         PROP_ACTIVE,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3017
         PROP_IDLE_HINT,
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3018
+        PROP_REMOVE_ON_CLOSE,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3019
 };
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3020
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3021
 static guint signals [LAST_SIGNAL] = { 0, };
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3022
@@ -128,6 +146,7 @@ static gboolean
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3023
 register_session (CkSession *session)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3024
 {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3025
         GError *error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3026
+        GObject *existing_session;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3027
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3028
         error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3029
         session->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3030
@@ -144,6 +163,15 @@ register_session (CkSession *session)
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3031
                                                               DBUS_PATH_DBUS,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3032
                                                               DBUS_INTERFACE_DBUS);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3033
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3034
+        existing_session = dbus_g_connection_lookup_g_object (session->priv->connection,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3035
+                                                              session->priv->id);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3036
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3037
+        if (existing_session != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3038
+                g_warning ("Session '%s' was registered twice!",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3039
+                           session->priv->id);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3040
+                return FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3041
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3042
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3043
         dbus_g_connection_register_g_object (session->priv->connection, session->priv->id, G_OBJECT (session));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3044
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3045
         return TRUE;
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3046
@@ -302,6 +330,35 @@ ck_session_set_idle_hint (CkSession     
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3047
 }
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3048
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3049
 gboolean
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3050
+session_set_remove_on_close (CkSession      *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3051
+                             gboolean        remove_on_close,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3052
+                             GError        **error)
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3053
+{
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3054
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3055
+
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3056
+        if (session->priv->remove_on_close != remove_on_close) {
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3057
+                session->priv->remove_on_close = remove_on_close;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3058
+        }
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3059
+
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3060
+        return TRUE;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3061
+}
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3062
+
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3063
+/*
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3064
+  Example:
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3065
+  dbus-send --system --dest=org.freedesktop.ConsoleKit \
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3066
+  --type=method_call --print-reply --reply-timeout=2000 \
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3067
+  /org/freedesktop/ConsoleKit/Session1 \
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3068
+  org.freedesktop.ConsoleKit.Session.SetRemoveOnClose boolean:TRUE
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3069
+*/
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3070
+gboolean
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3071
+ck_session_set_remove_on_close (CkSession             *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3072
+                                gboolean               remove_on_close,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3073
+                                DBusGMethodInvocation *context)
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3074
+{
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3075
+        return session_set_remove_on_close (session, remove_on_close, NULL);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3076
+}
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3077
+
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3078
+gboolean
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3079
 ck_session_get_idle_hint (CkSession *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3080
                           gboolean  *idle_hint,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3081
                           GError   **error)
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3082
@@ -420,6 +477,68 @@ ck_session_set_is_local (CkSession      
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3083
 }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3084
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3085
 gboolean
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3086
+ck_session_set_is_open (CkSession    *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3087
+                        gboolean      is_open,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3088
+                        GError      **error)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3089
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3090
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3091
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3092
+        if (session->priv->is_open != is_open) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3093
+                session->priv->is_open = is_open;
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3094
+                session->priv->ever_open = TRUE;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3095
+        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3096
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3097
+        return TRUE;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3098
+}
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3099
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3100
+gboolean
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3101
+ck_session_set_ever_open (CkSession    *session,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3102
+                          gboolean      ever_open,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3103
+                          GError      **error)
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3104
+{
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3105
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3106
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3107
+        if (session->priv->ever_open != ever_open) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3108
+                session->priv->ever_open = ever_open;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3109
+        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3110
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3111
+        return TRUE;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3112
+}
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3113
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3114
+static gboolean
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3115
+timeout_for_under_request (gpointer data)
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3116
+{
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3117
+        CkSession *session = CK_SESSION (data);
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3118
+        g_mutex_lock (session->priv->mutex_under_request);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3119
+        session->priv->under_request = FALSE;
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3120
+        g_mutex_unlock (session->priv->mutex_under_request);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3121
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3122
+        g_debug ("timeout for under request of session %s", session->priv->id);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3123
+        return FALSE;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3124
+}
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3125
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3126
+gboolean
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3127
+ck_session_set_under_request (CkSession    *session,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3128
+                              gboolean      under_request,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3129
+                              GError      **error)
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3130
+{
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3131
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3132
+
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3133
+        g_mutex_lock (session->priv->mutex_under_request);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3134
+        if (!under_request) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3135
+                session->priv->under_request = FALSE;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3136
+        } else {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3137
+                if (!session->priv->under_request) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3138
+                        session->priv->under_request = TRUE;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3139
+                        g_timeout_add_seconds (1, timeout_for_under_request, session);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3140
+                }
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3141
+        }
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3142
+        g_mutex_unlock (session->priv->mutex_under_request);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3143
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3144
+        return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3145
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3146
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3147
+gboolean
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3148
 ck_session_get_id (CkSession      *session,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3149
                    char          **id,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3150
                    GError        **error)
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3151
@@ -555,6 +674,20 @@ ck_session_get_creation_time (CkSession 
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3152
 }
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3153
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3154
 gboolean
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3155
+ck_session_get_remove_on_close (CkSession   *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3156
+                                gboolean    *remove_on_close,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3157
+                                GError     **error)
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3158
+{
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3159
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3160
+
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3161
+        if (remove_on_close != NULL) {
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3162
+                *remove_on_close = session->priv->remove_on_close;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3163
+        }
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3164
+
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3165
+        return TRUE;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3166
+}
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3167
+
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3168
+gboolean
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3169
 ck_session_get_session_type (CkSession      *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3170
                              char          **type,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3171
                              GError        **error)
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3172
@@ -569,6 +702,20 @@ ck_session_get_session_type (CkSession  
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3173
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3174
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3175
 gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3176
+ck_session_get_display_type (CkSession      *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3177
+                             char          **type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3178
+                             GError        **error)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3179
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3180
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3181
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3182
+        if (type != NULL) {
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3183
+                *type = g_strdup (session->priv->display_type);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3184
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3185
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3186
+        return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3187
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3188
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3189
+gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3190
 ck_session_is_active (CkSession      *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3191
                       gboolean       *active,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3192
                       GError        **error)
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3193
@@ -597,6 +744,50 @@ ck_session_is_local (CkSession      *ses
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3194
 }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3195
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3196
 gboolean
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3197
+ck_session_is_open (CkSession      *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3198
+                    gboolean       *open,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3199
+                    GError        **error)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3200
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3201
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3202
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3203
+        if (open != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3204
+                *open = session->priv->is_open;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3205
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3206
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3207
+        return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3208
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3209
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3210
+gboolean
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3211
+ck_session_get_ever_open (CkSession      *session,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3212
+                          gboolean       *open,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3213
+                          GError        **error)
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3214
+{
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3215
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3216
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3217
+        if (open != NULL) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3218
+                *open = session->priv->ever_open;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3219
+        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3220
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3221
+        return TRUE;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3222
+}
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3223
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3224
+gboolean
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3225
+ck_session_get_under_request (CkSession      *session,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3226
+                              gboolean       *under_request,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3227
+                              GError        **error)
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3228
+{
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3229
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3230
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3231
+        if (under_request != NULL) {
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3232
+                g_mutex_lock (session->priv->mutex_under_request);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3233
+                *under_request = session->priv->under_request;
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3234
+                g_mutex_unlock (session->priv->mutex_under_request);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3235
+        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3236
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3237
+        return TRUE;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3238
+}
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3239
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3240
+gboolean
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3241
 ck_session_set_id (CkSession      *session,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3242
                    const char     *id,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3243
                    GError        **error)
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3244
@@ -609,6 +800,21 @@ ck_session_set_id (CkSession      *sessi
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3245
         return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3246
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3247
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3248
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3249
+ck_session_set_display_variables (CkSession  *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3250
+                                  GHashTable *display_variables)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3251
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3252
+        if (session->priv->display_variables != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3253
+                g_hash_table_unref (session->priv->display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3254
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3255
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3256
+        if (display_variables != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3257
+                session->priv->display_variables = g_hash_table_ref (display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3258
+        } else {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3259
+                session->priv->display_variables = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3260
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3261
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3262
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3263
 gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3264
 ck_session_set_cookie (CkSession      *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3265
                        const char     *cookie,
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3266
@@ -725,6 +931,54 @@ ck_session_set_session_type (CkSession  
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3267
         return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3268
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3269
 
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3270
+gboolean
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3271
+ck_session_set_display_type (CkSession      *session,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3272
+                             const char     *type,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3273
+                             GError        **error)
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3274
+{
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3275
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3276
+
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3277
+        g_free (session->priv->display_type);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3278
+        session->priv->display_type = g_strdup (type);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3279
+
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3280
+        return TRUE;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3281
+}
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3282
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3283
+static gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3284
+ck_session_set_display_template (CkSession      *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3285
+                             CkDisplayTemplate  *display_template,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3286
+                             GError        **error)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3287
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3288
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3289
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3290
+        if (session->priv->display_template != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3291
+                g_object_unref (session->priv->display_template);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3292
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3293
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3294
+        if (display_template != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3295
+                session->priv->display_template = g_object_ref (display_template);
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3296
+                ck_session_set_display_type (session, ck_display_template_get_name (display_template), error);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3297
+        } else {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3298
+                session->priv->display_template = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3299
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3300
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3301
+        return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3302
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3303
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3304
+GHashTable *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3305
+ck_session_get_display_variables (CkSession *session)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3306
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3307
+        return g_hash_table_ref (session->priv->display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3308
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3309
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3310
+CkDisplayTemplate *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3311
+ck_session_get_display_template (CkSession      *session)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3312
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3313
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3314
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3315
+        return g_object_ref (session->priv->display_template);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3316
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3317
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3318
 static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3319
 ck_session_set_property (GObject            *object,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3320
                          guint               prop_id,
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3321
@@ -742,15 +996,33 @@ ck_session_set_property (GObject        
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3322
         case PROP_IS_LOCAL:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3323
                 ck_session_set_is_local (self, g_value_get_boolean (value), NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3324
                 break;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3325
+        case PROP_IS_OPEN:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3326
+                ck_session_set_is_open (self, g_value_get_boolean (value), NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3327
+                break;
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3328
+        case PROP_EVER_OPEN:
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3329
+                ck_session_set_ever_open (self, g_value_get_boolean (value), NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3330
+                break;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3331
         case PROP_ID:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3332
                 ck_session_set_id (self, g_value_get_string (value), NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3333
                 break;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3334
         case PROP_COOKIE:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3335
                 ck_session_set_cookie (self, g_value_get_string (value), NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3336
                 break;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3337
+        case PROP_SEAT_ID:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3338
+                ck_session_set_seat_id (self, g_value_get_string (value), NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3339
+                break;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3340
         case PROP_SESSION_TYPE:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3341
                 ck_session_set_session_type (self, g_value_get_string (value), NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3342
                 break;
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3343
+        case PROP_DISPLAY_TYPE:
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3344
+                ck_session_set_display_type (self, g_value_get_string (value), NULL);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3345
+                break;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3346
+        case PROP_DISPLAY_TEMPLATE:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3347
+                ck_session_set_display_template (self, g_value_get_object (value), NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3348
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3349
+        case PROP_DISPLAY_VARIABLES:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3350
+                ck_session_set_display_variables (self, g_value_get_boxed (value));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3351
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3352
         case PROP_X11_DISPLAY:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3353
                 ck_session_set_x11_display (self, g_value_get_string (value), NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3354
                 break;
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3355
@@ -775,6 +1047,9 @@ ck_session_set_property (GObject        
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3356
         case PROP_IDLE_HINT:
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3357
                 session_set_idle_hint_internal (self, g_value_get_boolean (value));
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3358
                 break;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3359
+        case PROP_REMOVE_ON_CLOSE:
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3360
+                session_set_remove_on_close (self, g_value_get_boolean (value), NULL);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3361
+                break;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3362
         default:
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3363
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3364
                 break;
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3365
@@ -798,15 +1073,33 @@ ck_session_get_property (GObject    *obj
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3366
         case PROP_IS_LOCAL:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3367
                 g_value_set_boolean (value, self->priv->is_local);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3368
                 break;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3369
+        case PROP_IS_OPEN:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3370
+                g_value_set_boolean (value, self->priv->is_open);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3371
+                break;
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3372
+        case PROP_EVER_OPEN:
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3373
+                g_value_set_boolean (value, self->priv->ever_open);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3374
+                break;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3375
         case PROP_ID:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3376
                 g_value_set_string (value, self->priv->id);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3377
                 break;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3378
         case PROP_COOKIE:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3379
                 g_value_set_string (value, self->priv->cookie);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3380
                 break;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3381
+        case PROP_SEAT_ID:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3382
+                g_value_set_string (value, self->priv->seat_id);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3383
+                break;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3384
         case PROP_SESSION_TYPE:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3385
                 g_value_set_string (value, self->priv->session_type);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3386
                 break;
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3387
+        case PROP_DISPLAY_TYPE:
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3388
+                g_value_set_string (value, self->priv->display_type);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3389
+                break;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3390
+        case PROP_DISPLAY_TEMPLATE:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3391
+                g_value_set_object (value, self->priv->display_template);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3392
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3393
+        case PROP_DISPLAY_VARIABLES:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3394
+                g_value_set_boxed (value, self->priv->display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3395
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3396
         case PROP_X11_DISPLAY:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3397
                 g_value_set_string (value, self->priv->x11_display);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3398
                 break;
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3399
@@ -831,6 +1124,9 @@ ck_session_get_property (GObject    *obj
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3400
         case PROP_IDLE_HINT:
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3401
                 g_value_set_boolean (value, self->priv->idle_hint);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3402
                 break;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3403
+        case PROP_REMOVE_ON_CLOSE:
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3404
+                g_value_set_boolean (value, self->priv->remove_on_close);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3405
+                break;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3406
         default:
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3407
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3408
                 break;
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3409
@@ -1000,6 +1296,13 @@ ck_session_class_init (CkSessionClass *k
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3410
                                                               "cookie",
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3411
                                                               NULL,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3412
                                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3413
+        g_object_class_install_property (object_class,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3414
+                                         PROP_SEAT_ID,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3415
+                                         g_param_spec_string ("seat-id",
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3416
+                                                              "seat id",
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3417
+                                                              "seat id",
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3418
+                                                              NULL,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3419
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3420
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3421
         g_object_class_install_property (object_class,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3422
                                          PROP_SESSION_TYPE,
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3423
@@ -1009,6 +1312,27 @@ ck_session_class_init (CkSessionClass *k
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3424
                                                               NULL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3425
                                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3426
         g_object_class_install_property (object_class,
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3427
+                                         PROP_DISPLAY_TYPE,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3428
+                                         g_param_spec_string ("display-type",
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3429
+                                                              "session-type",
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3430
+                                                              "session type",
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3431
+                                                              NULL,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3432
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3433
+        g_object_class_install_property (object_class,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3434
+                                         PROP_DISPLAY_TEMPLATE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3435
+                                         g_param_spec_object ("display-template",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3436
+                                                              "Display Template",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3437
+                                                              "The display template",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3438
+                                                              CK_TYPE_DISPLAY_TEMPLATE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3439
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3440
+        g_object_class_install_property (object_class,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3441
+                                         PROP_DISPLAY_VARIABLES,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3442
+                                         g_param_spec_boxed ("display-variables",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3443
+                                                             "Display Variables",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3444
+                                                             "Display type specific variables",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3445
+                                                             G_TYPE_HASH_TABLE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3446
+                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3447
+        g_object_class_install_property (object_class,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3448
                                          PROP_LOGIN_SESSION_ID,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3449
                                          g_param_spec_string ("login-session-id",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3450
                                                               "login-session-id",
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3451
@@ -1071,6 +1395,14 @@ ck_session_class_init (CkSessionClass *k
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3452
                                                                FALSE,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3453
                                                                G_PARAM_READWRITE));
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3454
 
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3455
+        g_object_class_install_property (object_class,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3456
+                                         PROP_REMOVE_ON_CLOSE,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3457
+                                         g_param_spec_boolean ("remove-on-close",
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3458
+                                                               NULL,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3459
+                                                               NULL,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3460
+                                                               FALSE,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3461
+                                                               G_PARAM_READWRITE));
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3462
+
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3463
         g_type_class_add_private (klass, sizeof (CkSessionPrivate));
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3464
 
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3465
         dbus_g_object_type_install_info (CK_TYPE_SESSION, &dbus_glib_ck_session_object_info);
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3466
@@ -1081,8 +1413,16 @@ ck_session_init (CkSession *session)
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3467
 {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3468
         session->priv = CK_SESSION_GET_PRIVATE (session);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3469
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3470
+        session->priv->display_variables = g_hash_table_new_full (g_str_hash,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3471
+                                                                  g_str_equal,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3472
+                                                                  (GDestroyNotify) g_free,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3473
+                                                                  (GDestroyNotify) g_free);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3474
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3475
         /* FIXME: should we have a property for this? */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3476
         g_get_current_time (&session->priv->creation_time);
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3477
+
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3478
+        if (!session->priv->mutex_under_request)
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3479
+                session->priv->mutex_under_request = g_mutex_new ();
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3480
 }
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3481
 
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3482
 static void
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3483
@@ -1105,6 +1445,7 @@ ck_session_finalize (GObject *object)
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3484
         g_free (session->priv->cookie);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3485
         g_free (session->priv->seat_id);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3486
         g_free (session->priv->session_type);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3487
+        g_free (session->priv->display_type);
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3488
         g_free (session->priv->login_session_id);
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3489
         g_free (session->priv->display_device);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3490
         g_free (session->priv->x11_display_device);
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3491
@@ -1115,16 +1456,135 @@ ck_session_finalize (GObject *object)
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3492
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3493
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3494
 CkSession *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3495
+ck_session_new_from_file (const char *ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3496
+                          const char *path)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3497
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3498
+        GKeyFile  *key_file;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3499
+        gboolean   res;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3500
+        GError    *error;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3501
+        char      *group;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3502
+        char      *name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3503
+        gboolean   hidden;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3504
+        char      *type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3505
+        char      *display_template_string;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3506
+        CkSession *session;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3507
+        GHashTable *display_variables;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3508
+        char     **type_keys;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3509
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3510
+        key_file = g_key_file_new ();
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3511
+        error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3512
+        res = g_key_file_load_from_file (key_file,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3513
+                                         path,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3514
+                                         G_KEY_FILE_NONE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3515
+                                         &error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3516
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3517
+        if (! res) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3518
+                g_warning ("Unable to load sessions from file %s: %s",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3519
+                           path, error->message);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3520
+                g_error_free (error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3521
+                return NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3522
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3523
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3524
+        group = g_key_file_get_start_group (key_file);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3525
+        if (group == NULL || strcmp (group, "Session Entry") != 0) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3526
+                g_warning ("Not a session file: %s", path);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3527
+                g_key_file_free (key_file);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3528
+                return NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3529
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3530
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3531
+        hidden = g_key_file_get_boolean (key_file, group, "Hidden", NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3532
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3533
+        if (hidden) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3534
+                g_debug ("Session is hidden");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3535
+                g_free (group);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3536
+                g_key_file_free (key_file);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3537
+                return NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3538
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3539
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3540
+        name = g_key_file_get_string (key_file, group, "Name", NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3541
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3542
+        if (name == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3543
+                g_warning ("Session file %s doesn't contain a name", path);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3544
+                g_free (group);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3545
+                g_key_file_free (key_file);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3546
+                return NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3547
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3548
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3549
+        type = g_key_file_get_string (key_file, group, "Type", NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3550
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3551
+        if (type == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3552
+                g_warning ("Session file %s doesn't contain a type", path);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3553
+                g_free (group);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3554
+                g_key_file_free (key_file);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3555
+                return NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3556
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3557
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3558
+        display_template_string = g_key_file_get_string (key_file, group, "DisplayTemplate", NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3559
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3560
+        if (display_template_string == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3561
+                g_warning ("Session file %s doesn't contain a display type", path);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3562
+                g_free (group);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3563
+                g_key_file_free (key_file);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3564
+                return NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3565
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3566
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3567
+        /* Find a group in the key file named after the display type and stuff
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3568
+         * all its entries into a hash table for later.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3569
+         *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3570
+         * Those keys are for things like the display number and the vt to
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3571
+         * run X with.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3572
+         */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3573
+        display_variables = g_hash_table_new_full (g_str_hash, g_str_equal,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3574
+                                                   (GDestroyNotify) g_free,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3575
+                                                   (GDestroyNotify) g_free);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3576
+        type_keys = g_key_file_get_keys (key_file, display_template_string, NULL, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3577
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3578
+        if (type_keys != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3579
+                int i;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3580
+                for (i = 0; type_keys[i] != NULL; i++) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3581
+                        char    *string;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3582
+                        string = g_key_file_get_string (key_file, display_template_string, type_keys[i], NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3583
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3584
+                        g_hash_table_insert (display_variables, g_strdup (type_keys[i]), string);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3585
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3586
+                g_strfreev (type_keys);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3587
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3588
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3589
+        session = ck_session_new (ssid, type, display_template_string, display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3590
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3591
+        g_free (display_template_string);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3592
+        g_free (group);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3593
+        g_free (type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3594
+        g_hash_table_unref (display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3595
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3596
+        return session;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3597
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3598
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3599
+CkSession *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3600
 ck_session_new (const char *ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3601
-                const char *cookie)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3602
+                const char *type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3603
+                const char *display_template_string,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3604
+                GHashTable *display_variables)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3605
 {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3606
+        CkDisplayTemplate *display_template;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3607
         GObject *object;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3608
         gboolean res;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3609
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3610
+        display_template = ck_display_template_get_from_name (display_template_string);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3611
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3612
+        if (display_template == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3613
+                g_warning ("Unable to load display type %s", display_template_string);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3614
+                return NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3615
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3616
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3617
         object = g_object_new (CK_TYPE_SESSION,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3618
                                "id", ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3619
-                               "cookie", cookie,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3620
+                               "session-type", type,
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3621
+                               "display-type", display_template_string,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3622
+                               "display-template", display_template,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3623
+                               "display-variables", display_variables,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3624
                                NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3625
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3626
         res = register_session (CK_SESSION (object));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3627
         if (! res) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3628
                 g_object_unref (object);
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3629
@@ -1139,9 +1599,80 @@ ck_session_new (const char *ssid,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3630
                                                           G_TYPE_VALUE, \
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3631
                                                           G_TYPE_INVALID))
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3632
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3633
+void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3634
+ck_session_set_parameters (CkSession       *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3635
+                           const GPtrArray *parameters)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3636
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3637
+        int           i;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3638
+        GObjectClass *class;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3639
+        GType         object_type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3640
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3641
+        object_type = CK_TYPE_SESSION;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3642
+        class = g_type_class_ref (object_type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3643
+        for (i = 0; i < parameters->len; i++) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3644
+                gboolean    res;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3645
+                GValue      val_struct = { 0, };
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3646
+                GValue      value = { 0, };
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3647
+                char       *prop_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3648
+                GValue     *prop_val;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3649
+                GParamSpec *pspec;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3650
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3651
+                g_value_init (&val_struct, CK_TYPE_PARAMETER_STRUCT);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3652
+                g_value_set_static_boxed (&val_struct, g_ptr_array_index (parameters, i));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3653
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3654
+                res = dbus_g_type_struct_get (&val_struct,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3655
+                                              0, &prop_name,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3656
+                                              1, &prop_val,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3657
+                                              G_MAXUINT);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3658
+                if (! res) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3659
+                        g_debug ("Unable to extract parameter input");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3660
+                        goto cont;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3661
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3662
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3663
+                if (prop_name == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3664
+                        g_debug ("Skipping NULL parameter");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3665
+                        goto cont;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3666
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3667
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3668
+                if (strcmp (prop_name, "id") == 0
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3669
+                    || strcmp (prop_name, "cookie") == 0) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3670
+                        g_debug ("Skipping restricted parameter: %s", prop_name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3671
+                        goto cont;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3672
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3673
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3674
+                pspec = g_object_class_find_property (class, prop_name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3675
+                if (! pspec) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3676
+                        g_debug ("Skipping unknown parameter: %s", prop_name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3677
+                        goto cont;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3678
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3679
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3680
+                if (!(pspec->flags & G_PARAM_WRITABLE)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3681
+                        g_debug ("property '%s' is not writable", pspec->name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3682
+                        goto cont;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3683
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3684
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3685
+                g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3686
+                res = g_value_transform (prop_val, &value);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3687
+                if (! res) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3688
+                        g_debug ("unable to transform property value for '%s'", pspec->name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3689
+                        goto cont;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3690
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3691
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3692
+                g_object_set_property (G_OBJECT (session), prop_name, &value);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3693
+                g_value_unset (&value);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3694
+        cont:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3695
+                g_free (prop_name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3696
+                if (prop_val != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3697
+                        g_value_unset (prop_val);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3698
+                        g_free (prop_val);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3699
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3700
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3701
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3702
+        g_type_class_unref (class);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3703
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3704
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3705
 CkSession *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3706
 ck_session_new_with_parameters (const char      *ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3707
-                                const char      *cookie,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3708
                                 const GPtrArray *parameters)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3709
 {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3710
         GObject      *object;
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3711
@@ -1170,12 +1701,6 @@ ck_session_new_with_parameters (const ch
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3712
         g_value_set_string (&params[n_params].value, ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3713
         n_params++;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3714
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3715
-        params[n_params].name = g_strdup ("cookie");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3716
-        params[n_params].value.g_type = 0;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3717
-        g_value_init (&params[n_params].value, G_TYPE_STRING);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3718
-        g_value_set_string (&params[n_params].value, cookie);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3719
-        n_params++;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3720
-
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3721
         if (parameters != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3722
                 for (i = 0; i < parameters->len; i++) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3723
                         gboolean    res;
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3724
@@ -1260,7 +1785,7 @@ ck_session_run_programs (CkSession  *ses
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3725
                          const char *action)
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3726
 {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3727
         int   n;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3728
-        char *extra_env[11]; /* be sure to adjust this as needed */
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3729
+        char *extra_env[12]; /* be sure to adjust this as needed */
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3730
 
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3731
         n = 0;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3732
 
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3733
@@ -1268,6 +1793,9 @@ ck_session_run_programs (CkSession  *ses
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3734
         if (session->priv->session_type != NULL) {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3735
                 extra_env[n++] = g_strdup_printf ("CK_SESSION_TYPE=%s", session->priv->session_type);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3736
         }
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3737
+        if (session->priv->display_type != NULL) {
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  3738
+                extra_env[n++] = g_strdup_printf ("CK_SESSION_DISPLAY_TYPE=%s", session->priv->display_type);
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3739
+        }
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3740
         extra_env[n++] = g_strdup_printf ("CK_SESSION_SEAT_ID=%s", session->priv->seat_id);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3741
         extra_env[n++] = g_strdup_printf ("CK_SESSION_USER_UID=%d", session->priv->uid);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3742
         if (session->priv->display_device != NULL && strlen (session->priv->display_device) > 0) {
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3743
@@ -1302,6 +1830,10 @@ ck_session_dump (CkSession *session,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3744
         char *s;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3745
         char *group_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3746
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3747
+        if (!session->priv->is_open) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3748
+                return;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3749
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3750
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3751
         group_name = g_strdup_printf ("Session %s", session->priv->id);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3752
         g_key_file_set_integer (key_file, group_name, "uid", session->priv->uid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3753
         g_key_file_set_string (key_file,
20041
0f108313f190 2010-09-07 Brian Cameron <[email protected]>
yippi
parents: 20040
diff changeset
  3754
@@ -1314,6 +1846,12 @@ ck_session_dump (CkSession *session,
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  3755
                                        "type",
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  3756
                                        NONULL_STRING (session->priv->session_type));
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  3757
         }
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  3758
+        if (session->priv->display_type != NULL) {
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  3759
+                g_key_file_set_string (key_file,
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  3760
+                                       group_name,
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  3761
+                                       "display_type",
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  3762
+                                       NONULL_STRING (session->priv->display_type));
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  3763
+        }
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  3764
         if (session->priv->login_session_id != NULL && strlen (session->priv->login_session_id) > 0) {
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  3765
                 g_key_file_set_string (key_file,
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  3766
                                        group_name,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3767
diff --git a/src/ck-session.h b/src/ck-session.h
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  3768
index b6b565b..a24d0a8 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3769
--- a/src/ck-session.h
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3770
+++ b/src/ck-session.h
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3771
@@ -25,6 +25,8 @@
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3772
 #include <glib-object.h>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3773
 #include <dbus/dbus-glib.h>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3774
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3775
+#include "ck-display-template.h"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3776
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3777
 G_BEGIN_DECLS
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3778
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3779
 #define CK_TYPE_SESSION         (ck_session_get_type ())
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3780
@@ -68,10 +70,15 @@ typedef enum
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3781
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3782
 GQuark              ck_session_error_quark            (void);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3783
 GType               ck_session_get_type               (void);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3784
+CkSession         * ck_session_new_from_file          (const char            *ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3785
+                                                       const char            *path);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3786
 CkSession         * ck_session_new                    (const char            *ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3787
-                                                       const char            *cookie);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3788
+                                                       const char            *type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3789
+                                                       const char            *display_type_string,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3790
+                                                       GHashTable            *display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3791
 CkSession         * ck_session_new_with_parameters    (const char            *ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3792
-                                                       const char            *cookie,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3793
+                                                       const GPtrArray       *parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3794
+void                ck_session_set_parameters         (CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3795
                                                        const GPtrArray       *parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3796
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3797
 void                ck_session_dump                   (CkSession             *session,
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  3798
@@ -86,6 +93,15 @@ gboolean            ck_session_set_active             (CkSession             *se
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3799
 gboolean            ck_session_set_is_local           (CkSession             *session,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3800
                                                        gboolean               is_local,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3801
                                                        GError               **error);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3802
+gboolean            ck_session_set_is_open            (CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3803
+                                                       gboolean               is_open,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3804
+                                                       GError               **error);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3805
+gboolean            ck_session_set_ever_open          (CkSession             *session,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3806
+                                                       gboolean               ever_open,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3807
+                                                       GError               **error);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3808
+gboolean            ck_session_set_under_request      (CkSession             *session,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3809
+                                                       gboolean               under_request,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3810
+                                                       GError               **error);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3811
 gboolean            ck_session_set_id                 (CkSession             *session,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3812
                                                        const char            *ssid,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3813
                                                        GError               **error);
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  3814
@@ -116,6 +132,11 @@ gboolean            ck_session_set_remote_host_name   (CkSession             *se
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3815
 gboolean            ck_session_set_session_type       (CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3816
                                                        const char            *type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3817
                                                        GError               **error);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3818
+gboolean            ck_session_set_display_type       (CkSession             *session,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3819
+                                                       const char            *type,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3820
+                                                       GError               **error);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3821
+GHashTable         *ck_session_get_display_variables  (CkSession             *session);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3822
+CkDisplayTemplate  *ck_session_get_display_template   (CkSession             *session);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3823
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3824
 /* Exported methods */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3825
 
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  3826
@@ -132,6 +153,15 @@ gboolean            ck_session_is_active              (CkSession             *se
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3827
 gboolean            ck_session_is_local               (CkSession             *session,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3828
                                                        gboolean              *local,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3829
                                                        GError               **error);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3830
+gboolean            ck_session_is_open                (CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3831
+                                                       gboolean              *open,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3832
+                                                       GError               **error);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3833
+gboolean            ck_session_get_ever_open          (CkSession             *session,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3834
+                                                       gboolean              *open,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3835
+                                                       GError               **error);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3836
+gboolean            ck_session_get_under_request      (CkSession             *session,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3837
+                                                       gboolean              *under_request,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3838
+                                                       GError               **error);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3839
 gboolean            ck_session_get_unix_user          (CkSession             *session,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3840
                                                        guint                 *uid,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3841
                                                        GError               **error);
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  3842
@@ -150,12 +180,18 @@ gboolean            ck_session_get_login_session_id   (CkSession             *se
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3843
 gboolean            ck_session_get_session_type       (CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3844
                                                        char                 **type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3845
                                                        GError               **error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3846
+gboolean            ck_session_get_display_type       (CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3847
+                                                       char                 **type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3848
+                                                       GError               **error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3849
 gboolean            ck_session_get_remote_host_name   (CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3850
                                                        char                 **host_name,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3851
                                                        GError               **error);
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3852
 gboolean            ck_session_get_creation_time      (CkSession             *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3853
                                                        char                 **iso8601_datetime,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3854
                                                        GError               **error);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3855
+gboolean            ck_session_get_remove_on_close    (CkSession             *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3856
+                                                       gboolean              *remove_on_close,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3857
+                                                       GError               **error);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3858
 /*deprecated*/
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3859
 gboolean            ck_session_get_user               (CkSession             *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3860
                                                        guint                 *uid,
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  3861
@@ -171,6 +207,12 @@ gboolean            ck_session_get_idle_since_hint    (CkSession             *se
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3862
 gboolean            ck_session_set_idle_hint          (CkSession             *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3863
                                                        gboolean               idle_hint,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3864
                                                        DBusGMethodInvocation *context);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3865
+gboolean            session_set_remove_on_close       (CkSession             *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3866
+                                                       gboolean               remove_on_close,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3867
+                                                       GError               **error);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3868
+gboolean            ck_session_set_remove_on_close    (CkSession             *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3869
+                                                       gboolean               remove_on_close,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3870
+                                                       DBusGMethodInvocation *context);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3871
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3872
 /* Privileged actions */
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3873
 gboolean            ck_session_activate               (CkSession             *session,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3874
diff --git a/src/org.freedesktop.ConsoleKit.Manager.xml b/src/org.freedesktop.ConsoleKit.Manager.xml
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3875
index f903b55..34a6d04 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3876
--- a/src/org.freedesktop.ConsoleKit.Manager.xml
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3877
+++ b/src/org.freedesktop.ConsoleKit.Manager.xml
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3878
@@ -160,6 +160,23 @@
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3879
       </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3880
     </method>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3881
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3882
+    <method name="GetUnmanagedSeats">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3883
+      <arg name="seats" direction="out" type="ao">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3884
+        <doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3885
+          <doc:summary>an array of unmanaged Seat IDs</doc:summary>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3886
+        </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3887
+      </arg>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3888
+      <doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3889
+        <doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3890
+          <doc:para>This gets a list of the unmanaged <doc:ref type="interface" to="Seat">Seats</doc:ref>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3891
+          that are statically configured under /etc/ConsoleKit/seats.d</doc:para>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3892
+          <doc:para>Each Seat ID is an D-Bus object path for the object that implements the
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3893
+          <doc:ref type="interface" to="Seat">Seat</doc:ref> interface.</doc:para>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3894
+        </doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3895
+        <doc:seealso><doc:ref type="interface" to="Seat">org.freedesktop.ConsoleKit.Seat</doc:ref></doc:seealso>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3896
+      </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3897
+    </method>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3898
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3899
     <method name="GetSessions">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3900
       <arg name="sessions" direction="out" type="ao">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3901
         <doc:doc>
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3902
@@ -310,12 +327,115 @@
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3903
       </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3904
     </method>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3905
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3906
+    <method name="AddSeat">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3907
+      <arg name="type" type="s" direction="in">
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3908
+        <doc:doc>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3909
+          <doc:summary>The type of seat to add</doc:summary>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3910
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3911
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3912
+      <arg name="sid" type="o" direction="out">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3913
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3914
+          <doc:summary>The Seat ID of the added seat</doc:summary>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3915
+        </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3916
+      </arg>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3917
+      <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3918
+        <doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3919
+          <doc:para>This method is to create a new seat
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3920
+          </doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3921
+        </doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3922
+      </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3923
+    </method>
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3924
+    <method name="AddSeatById">
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3925
+      <arg name="type" type="s" direction="in">
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3926
+        <doc:doc>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3927
+          <doc:summary>The type of seat to add</doc:summary>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3928
+        </doc:doc>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3929
+      </arg>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3930
+      <arg name="sid" type="o" direction="in">
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3931
+        <doc:doc>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3932
+          <doc:summary>The Seat ID of to be added seat</doc:summary>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3933
+        </doc:doc>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3934
+      </arg>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3935
+      <doc:doc>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3936
+        <doc:description>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3937
+          <doc:para>This method is to create a new seat by specify given sid
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3938
+          </doc:para>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3939
+        </doc:description>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3940
+      </doc:doc>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3941
+    </method>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3942
+    <method name="RemoveSeat">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3943
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3944
+      <arg name="sid" type="o" direction="in">
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3945
+        <doc:doc>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3946
+          <doc:summary>The Seat ID of the seat to remove</doc:summary>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3947
+        </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3948
+      </arg>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3949
+      <doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3950
+        <doc:description>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3951
+          <doc:para>This method is to remove a seat
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3952
+          </doc:para>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3953
+        </doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3954
+      </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3955
+    </method>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3956
+    <method name="AddSession">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3957
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3958
+      <arg name="sid" type="o">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3959
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3960
+          <doc:summary>The seat to add the session to</doc:summary>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3961
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3962
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3963
+      <arg name="type" type="s">
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3964
+        <doc:doc>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3965
+          <doc:summary>The type of session to run (e.g. "LoginWindow", "Chooser", etc)</doc:summary>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3966
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3967
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3968
+      <arg name="display_type" type="s">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3969
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3970
+          <doc:summary>The name of the display type to use (defined in displays.d)</doc:summary>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3971
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3972
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3973
+      <arg name="variables" type="a{ss}">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3974
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3975
+          <doc:summary>Session type specific parameters</doc:summary>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3976
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3977
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3978
+      <arg name="ssid" direction="out" type="o">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3979
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3980
+          <doc:summary>Session ID</doc:summary>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3981
+        </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3982
+      </arg>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3983
+      <doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3984
+        <doc:description>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3985
+          <doc:para>Request a new session gets added to seat.</doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3986
+        </doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3987
+      </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3988
+    </method>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3989
+    <method name="RemoveSession">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3990
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3991
+      <arg name="ssid" type="o" direction="in">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3992
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3993
+          <doc:summary>The session id of the session to remove</doc:summary>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3994
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3995
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3996
+      <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3997
+        <doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3998
+          <doc:para>This method is to remove a session from a seat
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3999
+          </doc:para>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4000
+        </doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4001
+      </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4002
+    </method>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4003
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4004
     <signal name="SeatAdded">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4005
       <arg name="sid" type="o">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4006
         <doc:doc>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4007
           <doc:summary>The Seat ID for the added seat</doc:summary>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4008
         </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4009
       </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4010
+      <arg name="type" type="s">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4011
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4012
+          <doc:summary>The type of seat added.</doc:summary>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4013
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4014
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4015
       <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4016
         <doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4017
           <doc:para>Emitted when a Seat has been added to the system.
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4018
diff --git a/src/org.freedesktop.ConsoleKit.Seat.xml b/src/org.freedesktop.ConsoleKit.Seat.xml
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4019
index d95990b..1f6c46f 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4020
--- a/src/org.freedesktop.ConsoleKit.Seat.xml
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4021
+++ b/src/org.freedesktop.ConsoleKit.Seat.xml
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4022
@@ -100,6 +100,24 @@ seat at a time.</doc:para>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4023
       </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4024
     </method>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4025
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4026
+    <method name="Manage">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4027
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4028
+      <doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4029
+        <doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4030
+          <doc:para>Attempt to create unmanaged sessions for this seat.</doc:para>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4031
+        </doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4032
+      </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4033
+    </method>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4034
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4035
+    <method name="Unmanage">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4036
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4037
+      <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4038
+        <doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4039
+          <doc:para>Stop managing seat.</doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4040
+        </doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4041
+      </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4042
+    </method>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4043
+
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4044
     <signal name="ActiveSessionChanged">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4045
       <arg name="ssid" type="o">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4046
         <doc:doc>
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4047
@@ -160,5 +178,61 @@ seat at a time.</doc:para>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4048
         </doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4049
       </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4050
     </signal>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4051
+    <signal name="OpenSessionRequest">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4052
+      <arg name="ssid" type="o">
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4053
+        <doc:doc>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4054
+          <doc:summary>The session id of the session to add</doc:summary>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4055
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4056
+      </arg>
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4057
+      <arg name="session_type" type="s">
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4058
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4059
+          <doc:summary>The type of session to run (e.g. "LoginWindow", "Chooser", etc)</doc:summary>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4060
+        </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4061
+      </arg>
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4062
+      <arg name="display_template_name" type="s">
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4063
+        <doc:doc>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4064
+          <doc:summary>The name of display template </doc:summary>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4065
+        </doc:doc>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4066
+      </arg>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4067
+      <arg name="parameters" type="a{ss}">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4068
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4069
+          <doc:summary>Session type specific parameters</doc:summary>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4070
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4071
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4072
+      <arg name="display_type" type="s">
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4073
+        <doc:doc>
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4074
+          <doc:summary>The type of display to use (e.g. "X11", "Command", "XDMCP", etc)</doc:summary>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4075
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4076
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4077
+      <arg name="display_parameters" type="a{ss}">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4078
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4079
+          <doc:summary>Display type specific parameters</doc:summary>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4080
+        </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4081
+      </arg>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4082
+      <doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4083
+        <doc:description>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4084
+          <doc:para>Emitted when a new session should get added to the seat.</doc:para>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4085
+        </doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4086
+      </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4087
+    </signal>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4088
+    <signal name="CloseSessionRequest">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4089
+      <arg name="ssid" type="o">
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4090
+        <doc:doc>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4091
+          <doc:summary>The session id of the session to remove</doc:summary>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4092
+        </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4093
+      </arg>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4094
+      <doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4095
+        <doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4096
+          <doc:para>Emitted when a session with given display number need to be removed.</doc:para>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4097
+        </doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4098
+      </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4099
+    </signal>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4100
+    <signal name="RemoveRequest">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4101
+      <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4102
+        <doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4103
+          <doc:para>Emitted when seat needs to get removed.</doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4104
+        </doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4105
+      </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4106
+    </signal>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4107
   </interface>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4108
 </node>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4109
diff --git a/src/org.freedesktop.ConsoleKit.Session.xml b/src/org.freedesktop.ConsoleKit.Session.xml
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4110
index b6e1cdb..2652058 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4111
--- a/src/org.freedesktop.ConsoleKit.Session.xml
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4112
+++ b/src/org.freedesktop.ConsoleKit.Session.xml
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4113
@@ -52,6 +52,19 @@
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4114
         <doc:seealso><doc:ref type="property" to="Session:session-type">session-type</doc:ref></doc:seealso>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4115
       </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4116
     </method>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4117
+    <method name="GetDisplayType">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4118
+      <arg name="type" direction="out" type="s">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4119
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4120
+          <doc:summary>Display type</doc:summary>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4121
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4122
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4123
+      <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4124
+        <doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4125
+          <doc:para>Returns the display type of the session.</doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4126
+        </doc:description>
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4127
+        <doc:seealso><doc:ref type="property" to="Session:display-type">display-type</doc:ref></doc:seealso>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4128
+      </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4129
+    </method>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4130
     <method name="GetUser">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4131
       <arg name="uid" direction="out" type="u">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4132
         <doc:doc>
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4133
@@ -174,6 +187,18 @@
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4134
         <doc:seealso><doc:ref type="property" to="Session:is-local">is-local</doc:ref></doc:seealso>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4135
       </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4136
     </method>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4137
+    <method name="IsOpen">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4138
+      <arg name="open" direction="out" type="b">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4139
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4140
+          <doc:summary>TRUE if the session is open, otherwise FALSE</doc:summary>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4141
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4142
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4143
+      <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4144
+        <doc:description><doc:para>Returns whether the session is open</doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4145
+        </doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4146
+        <doc:seealso><doc:ref type="property" to="Session:is-open">is-open</doc:ref></doc:seealso>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4147
+      </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4148
+    </method>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4149
     <method name="GetCreationTime">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4150
       <arg name="iso8601_datetime" type="s" direction="out">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4151
         <doc:doc>
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4152
@@ -275,6 +300,21 @@
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4153
         </doc:description>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4154
       </doc:doc>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4155
     </method>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4156
+    <method name="SetRemoveOnClose">
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4157
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4158
+      <arg name="remove_on_close" type="b" direction="in">
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4159
+        <doc:doc>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4160
+          <doc:summary>boolean value to set the remove-on-close to</doc:summary>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4161
+        </doc:doc>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4162
+      </arg>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4163
+      <doc:doc>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4164
+        <doc:description>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4165
+          <doc:para>This may be used by the session to indicate that
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4166
+          it should be respawn or not when it is closed.
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4167
+          </doc:para>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4168
+        </doc:description>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4169
+      </doc:doc>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4170
+    </method>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4171
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4172
     <signal name="ActiveChanged">
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4173
       <arg name="is_active" type="b">
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4174
@@ -317,6 +357,19 @@
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4175
       </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4176
     </signal>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4177
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4178
+    <property name="session" type="o" access="readwrite">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4179
+      <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4180
+        <doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4181
+          <doc:para>The id of the session.</doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4182
+          <doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4183
+          The object path of the session.  Typically this is set by a session leader during a call to the
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4184
+          <doc:ref type="method" to="Manager.OpenSessionWithParameters">OpenSessionWithParameters</doc:ref> method, when
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4185
+          opening a session in response to the <doc:ref type="signal" to="Seat::OpenSessionRequest">OpenSessionRequest</doc:ref>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4186
+          signal.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4187
+          </doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4188
+        </doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4189
+      </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4190
+    </property>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4191
     <property name="unix-user" type="u" access="readwrite">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4192
       <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4193
         <doc:description>
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4194
@@ -342,6 +395,16 @@
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4195
         </doc:description>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4196
       </doc:doc>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4197
     </property>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4198
+    <property name="display-type" type="s" access="readwrite">
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4199
+      <doc:doc>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4200
+        <doc:description>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4201
+          <doc:para>The display type of the session.</doc:para>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4202
+          <doc:para>Indicate the display template name. All the display template configuration
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4203
+          files are under /etc/ConsoleKit/displays.d/.
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4204
+          </doc:para>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4205
+        </doc:description>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4206
+      </doc:doc>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4207
+    </property>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4208
     <property name="remote-host-name" type="s" access="readwrite">
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4209
       <doc:doc>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4210
         <doc:description>
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4211
@@ -396,6 +459,19 @@
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4212
         </doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4213
       </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4214
     </property>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4215
+    <property name="is-open" type="b" access="readwrite">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4216
+      <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4217
+        <doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4218
+          <doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4219
+          Whether the session is open</doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4220
+          <doc:para>Sessions added from static configuration or in direct response to a call to
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4221
+          the <doc:ref type="method" to="Manager.AddSession">AddSession</doc:ref> method are initialally
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4222
+          closed and aren't open until a call to the <doc:ref type="method" to="Manager.OpenSessionWithParameters">OpenSessionWithParameters</doc:ref>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4223
+          method.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4224
+          </doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4225
+        </doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4226
+      </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4227
+    </property>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4228
     <property name="is-local" type="b" access="readwrite">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4229
       <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4230
         <doc:description>
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4231
@@ -408,6 +484,14 @@
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4232
         </doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4233
       </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4234
     </property>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4235
+    <property name="is-dynamic" type="b" access="readwrite">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4236
+      <doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4237
+        <doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4238
+          <doc:para>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4239
+          Whether the session is dynamic</doc:para>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4240
+        </doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4241
+      </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4242
+    </property>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4243
     <property name="idle-hint" type="b" access="readwrite">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4244
       <doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4245
         <doc:description>
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4246
@@ -430,6 +514,14 @@
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4247
         </doc:description>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4248
       </doc:doc>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4249
     </property>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4250
+    <property name="remove-on-close" type="b" access="readwrite">
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4251
+      <doc:doc>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4252
+        <doc:description>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4253
+          <doc:para>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4254
+          Whether the session respawn when it is closed</doc:para>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4255
+        </doc:description>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4256
+      </doc:doc>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4257
+    </property>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4258
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4259
   </interface>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4260
 </node>
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4261
diff --git a/src/strverscmp.c b/src/strverscmp.c
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4262
new file mode 100644
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4263
index 0000000..f077651
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4264
--- /dev/null
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4265
+++ b/src/strverscmp.c
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4266
@@ -0,0 +1,131 @@
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4267
+/* Compare strings while treating digits characters numerically.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4268
+   Copyright (C) 1997, 2000, 2002, 2004, 2006 Free Software Foundation, Inc.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4269
+   This file is part of the GNU C Library.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4270
+   Contributed by Jean-François Bignolles <[email protected]>, 1997.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4271
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4272
+   This program is free software; you can redistribute it and/or modify
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4273
+   it under the terms of the GNU General Public License as published by
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4274
+   the Free Software Foundation; either version 2, or (at your option)
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4275
+   any later version.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4276
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4277
+   This program is distributed in the hope that it will be useful,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4278
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4279
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4280
+   GNU General Public License for more details.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4281
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4282
+   You should have received a copy of the GNU General Public License along
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4283
+   with this program; if not, write to the Free Software Foundation,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4284
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4285
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4286
+#if !_LIBC
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4287
+# include <config.h>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4288
+#endif
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4289
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4290
+#include <string.h>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4291
+#include <ctype.h>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4292
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4293
+/* states: S_N: normal, S_I: comparing integral part, S_F: comparing
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4294
+           fractional parts, S_Z: idem but with leading Zeroes only */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4295
+#define S_N    0x0
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4296
+#define S_I    0x4
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4297
+#define S_F    0x8
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4298
+#define S_Z    0xC
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4299
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4300
+/* result_type: CMP: return diff; LEN: compare using len_diff/diff */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4301
+#define CMP    2
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4302
+#define LEN    3
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4303
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4304
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4305
+/* ISDIGIT differs from isdigit, as follows:
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4306
+   - Its arg may be any int or unsigned int; it need not be an unsigned char
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4307
+     or EOF.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4308
+   - It's typically faster.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4309
+   POSIX says that only '0' through '9' are digits.  Prefer ISDIGIT to
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4310
+   isdigit unless it's important to use the locale's definition
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4311
+   of `digit' even when the host does not conform to POSIX.  */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4312
+#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4313
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4314
+#undef __strverscmp
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4315
+#undef strverscmp
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4316
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4317
+#ifndef weak_alias
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4318
+# define __strverscmp strverscmp
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4319
+#endif
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4320
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4321
+/* Compare S1 and S2 as strings holding indices/version numbers,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4322
+   returning less than, equal to or greater than zero if S1 is less than,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4323
+   equal to or greater than S2 (for more info, see the texinfo doc).
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4324
+*/
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4325
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4326
+int
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4327
+__strverscmp (const char *s1, const char *s2)
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4328
+{
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4329
+  const unsigned char *p1 = (const unsigned char *) s1;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4330
+  const unsigned char *p2 = (const unsigned char *) s2;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4331
+  unsigned char c1, c2;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4332
+  int state;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4333
+  int diff;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4334
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4335
+  /* Symbol(s)    0       [1-9]   others  (padding)
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4336
+     Transition   (10) 0  (01) d  (00) x  (11) -   */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4337
+  static const unsigned int next_state[] =
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4338
+  {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4339
+      /* state    x    d    0    - */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4340
+      /* S_N */  S_N, S_I, S_Z, S_N,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4341
+      /* S_I */  S_N, S_I, S_I, S_I,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4342
+      /* S_F */  S_N, S_F, S_F, S_F,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4343
+      /* S_Z */  S_N, S_F, S_Z, S_Z
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4344
+  };
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4345
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4346
+  static const int result_type[] =
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4347
+  {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4348
+      /* state   x/x  x/d  x/0  x/-  d/x  d/d  d/0  d/-
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4349
+                 0/x  0/d  0/0  0/-  -/x  -/d  -/0  -/- */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4350
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4351
+      /* S_N */  CMP, CMP, CMP, CMP, CMP, LEN, CMP, CMP,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4352
+                 CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4353
+      /* S_I */  CMP, -1,  -1,  CMP,  1,  LEN, LEN, CMP,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4354
+                  1,  LEN, LEN, CMP, CMP, CMP, CMP, CMP,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4355
+      /* S_F */  CMP, CMP, CMP, CMP, CMP, LEN, CMP, CMP,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4356
+                 CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4357
+      /* S_Z */  CMP,  1,   1,  CMP, -1,  CMP, CMP, CMP,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4358
+                 -1,  CMP, CMP, CMP
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4359
+  };
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4360
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4361
+  if (p1 == p2)
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4362
+    return 0;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4363
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4364
+  c1 = *p1++;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4365
+  c2 = *p2++;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4366
+  /* Hint: '0' is a digit too.  */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4367
+  state = S_N | ((c1 == '0') + (ISDIGIT (c1) != 0));
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4368
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4369
+  while ((diff = c1 - c2) == 0 && c1 != '\0')
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4370
+    {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4371
+      state = next_state[state];
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4372
+      c1 = *p1++;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4373
+      c2 = *p2++;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4374
+      state |= (c1 == '0') + (ISDIGIT (c1) != 0);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4375
+    }
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4376
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4377
+  state = result_type[state << 2 | ((c2 == '0') + (ISDIGIT (c2) != 0))];
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4378
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4379
+  switch (state)
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4380
+    {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4381
+    case CMP:
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4382
+      return diff;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4383
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4384
+    case LEN:
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4385
+      while (ISDIGIT (*p1++))
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4386
+	if (!ISDIGIT (*p2++))
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4387
+	  return 1;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4388
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4389
+      return ISDIGIT (*p2) ? -1 : diff;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4390
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4391
+    default:
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4392
+      return state;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4393
+    }
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4394
+}
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4395
+#ifdef weak_alias
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4396
+weak_alias (__strverscmp, strverscmp)
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4397
+#endif
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4398
diff --git a/src/strverscmp.h b/src/strverscmp.h
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4399
new file mode 100644
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4400
index 0000000..48670c8
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4401
--- /dev/null
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4402
+++ b/src/strverscmp.h
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4403
@@ -0,0 +1,25 @@
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4404
+/* Compare strings while treating digits characters numerically.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4405
+   Copyright (C) 1997, 2000, 2002, 2004, 2006 Free Software Foundation, Inc.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4406
+   This file is part of the GNU C Library.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4407
+   Contributed by Jean-François Bignolles <[email protected]>, 1997.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4408
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4409
+   This program is free software; you can redistribute it and/or modify
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4410
+   it under the terms of the GNU General Public License as published by
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4411
+   the Free Software Foundation; either version 2, or (at your option)
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4412
+   any later version.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4413
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4414
+   This program is distributed in the hope that it will be useful,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4415
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4416
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4417
+   GNU General Public License for more details.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4418
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4419
+   You should have received a copy of the GNU General Public License along
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4420
+   with this program; if not, write to the Free Software Foundation,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4421
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4422
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4423
+#ifndef STRVERSCMP_H_
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4424
+# define STRVERSCMP_H_
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4425
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4426
+int strverscmp (const char *, const char *);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4427
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4428
+#endif /* not STRVERSCMP_H_ */
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4429
diff --git a/tools/Makefile.am b/tools/Makefile.am
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4430
index 13c191f..fa16c68 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4431
--- a/tools/Makefile.am
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4432
+++ b/tools/Makefile.am
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4433
@@ -54,6 +54,7 @@ sbin_PROGRAMS = \
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4434
 	ck-log-system-start		\
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4435
 	ck-log-system-restart		\
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4436
 	ck-log-system-stop		\
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4437
+	ck-seat-tool			\
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4438
 	$(NULL)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4439
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4440
 ck_launch_session_SOURCES =		\
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4441
@@ -83,6 +84,14 @@ ck_history_LDADD =			\
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4442
 	$(top_builddir)/src/libck-event-log.la	\
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4443
 	$(NULL)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4444
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4445
+ck_seat_tool_SOURCES =			\
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4446
+	ck-seat-tool.c			\
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4447
+	$(NULL)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4448
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4449
+ck_seat_tool_LDADD =			\
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4450
+	$(CONSOLE_KIT_LIBS)		\
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4451
+	$(NULL)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4452
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4453
 ck_log_system_start_SOURCES =		\
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4454
 	ck-log-system-start.c		\
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4455
 	$(NULL)
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4456
diff --git a/tools/ck-seat-tool.c b/tools/ck-seat-tool.c
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4457
new file mode 100644
17790
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  4458
index 0000000..0879d0d
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4459
--- /dev/null
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4460
+++ b/tools/ck-seat-tool.c
17790
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  4461
@@ -0,0 +1,443 @@
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4462
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4463
+ *
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4464
+ * Copyright (C) 2009 Sun Microsystems, Inc.
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4465
+ *
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4466
+ * This program is free software; you can redistribute it and/or
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4467
+ * modify it under the terms of the GNU General Public License as
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4468
+ * published by the Free Software Foundation; either version 2 of the
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4469
+ * License, or (at your option) any later version.
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4470
+ *
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4471
+ * This program is distributed in the hope that it will be useful, but
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4472
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4473
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4474
+ * General Public License for more details.
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4475
+ *
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4476
+ * You should have received a copy of the GNU General Public License
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4477
+ * along with this program; if not, write to the Free Software
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4478
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4479
+ * 02111-1307, USA.
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4480
+ *
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4481
+ * Authors: Halton Huo <[email protected]>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4482
+ *
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4483
+ */
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4484
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4485
+#include "config.h"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4486
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4487
+#include <stdlib.h>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4488
+#include <stdio.h>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4489
+#include <sys/types.h>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4490
+#include <unistd.h>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4491
+#include <strings.h>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4492
+#include <glib/gi18n.h>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4493
+#include <dbus/dbus-glib.h>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4494
+#include <dbus/dbus-glib-lowlevel.h>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4495
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4496
+#define CK_NAME              "org.freedesktop.ConsoleKit"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4497
+#define CK_PATH              "/org/freedesktop/ConsoleKit"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4498
+#define CK_INTERFACE         "org.freedesktop.ConsoleKit"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4499
+#define CK_MANAGER_PATH      "/org/freedesktop/ConsoleKit/Manager"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4500
+#define CK_MANAGER_INTERFACE "org.freedesktop.ConsoleKit.Manager"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4501
+#define CK_SEAT_INTERFACE    "org.freedesktop.ConsoleKit.Seat"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4502
+#define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4503
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4504
+#define CK_DBUS_TYPE_G_STRING_STRING_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING))
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4505
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4506
+#define IS_STR_SET(x) (x != NULL && x[0] != '\0')
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4507
+#define CK_PATH_PREFIX       "/org/freedesktop/ConsoleKit/"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4508
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4509
+static gboolean  add = FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4510
+static gboolean  delete = FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4511
+static gboolean  show_version = FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4512
+static char     *session_type = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4513
+static char     *display_type = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4514
+static char     *seat_id = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4515
+static char     *session_id = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4516
+static gchar   **remaining_args = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4517
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4518
+static const GOptionEntry options [] = {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4519
+        { "add", 'a', 0, G_OPTION_ARG_NONE, &add, N_("Add a new session"), NULL},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4520
+        { "session-type", '\0', 0, G_OPTION_ARG_STRING, &session_type, N_("Specify session type when adding a session. Default is LoginWindow."), NULL},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  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},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  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},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  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 },
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4524
+        { "delete", 'd', 0, G_OPTION_ARG_NONE, &delete, N_("Delete a session"), NULL},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4525
+        { "session-id", '\0', 0, G_OPTION_ARG_STRING, &session_id, N_("Specify session id when deleting a session"), NULL},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4526
+        { "version", 'V', 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL },
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4527
+        { NULL }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4528
+};
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4529
+
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4530
+static void
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4531
+add_session (DBusGConnection  *connection)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4532
+{
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4533
+        DBusGProxy *mgr_proxy = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4534
+        DBusGProxy *seat_proxy = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4535
+        GError     *error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4536
+        gboolean    res;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4537
+        char       *sid = NULL;
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4538
+        GPtrArray  *seats;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4539
+        char       *ssid = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4540
+        int         i;
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4541
+        gboolean    found;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4542
+        char       *sstype = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4543
+        GHashTable *variables = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4544
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4545
+        if (! IS_STR_SET (session_type)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4546
+                sstype = g_strdup ("LoginWindow");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4547
+        } else {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4548
+                sstype = g_strdup (session_type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4549
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4550
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4551
+        mgr_proxy = dbus_g_proxy_new_for_name (connection,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4552
+                                               CK_NAME,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4553
+                                               CK_MANAGER_PATH,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4554
+                                               CK_MANAGER_INTERFACE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4555
+        if (mgr_proxy == NULL) {
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4556
+                return;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4557
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4558
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4559
+        if (! IS_STR_SET(seat_id)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4560
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4561
+                /* If seat id is not given, create a new seat */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4562
+                error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4563
+                res = dbus_g_proxy_call (mgr_proxy,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4564
+                                         "AddSeat",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4565
+                                         &error,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4566
+                                         G_TYPE_STRING, "Default",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4567
+                                         G_TYPE_INVALID,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4568
+                                         DBUS_TYPE_G_OBJECT_PATH, &sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4569
+                                         G_TYPE_INVALID);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4570
+                if (!res) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4571
+                        g_warning ("Unable to add seat: %s", error->message);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4572
+                        g_error_free (error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4573
+                        g_object_unref (mgr_proxy);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4574
+                        return;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4575
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4576
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4577
+        } else {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4578
+                if (!g_str_has_prefix (seat_id, CK_PATH_PREFIX)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4579
+                        sid = g_strdup_printf ("%s%s", CK_PATH_PREFIX, seat_id);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4580
+                } else {
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4581
+                        sid = g_strdup (seat_id);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4582
+                }
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4583
+                /* Check whether seat is existing, if not, try to create it. */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4584
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4585
+                error = NULL;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4586
+                res = dbus_g_proxy_call (mgr_proxy,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4587
+                                         "GetSeats",
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4588
+                                         &error,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4589
+                                         G_TYPE_INVALID,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4590
+                                         dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4591
+                                         &seats,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4592
+                                         G_TYPE_INVALID);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4593
+                if (!res) {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4594
+                        g_warning ("Unable to get seat list: %s", error->message);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4595
+                        g_error_free (error);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4596
+                        g_object_unref (mgr_proxy);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4597
+                        return;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4598
+                }
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4599
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4600
+                found = FALSE;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4601
+                for (i = 0; i < seats->len; i++) {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4602
+                        char *tmp_sid;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4603
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4604
+                        tmp_sid = g_ptr_array_index (seats, i);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4605
+                        if (g_str_equal (sid, tmp_sid)) {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4606
+                                found = TRUE;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4607
+                                g_free (tmp_sid);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4608
+                                break;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4609
+                        }
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4610
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4611
+                        g_free (tmp_sid);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4612
+                }
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4613
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4614
+                if (! found) {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4615
+                        error = NULL;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4616
+                        res = dbus_g_proxy_call (mgr_proxy,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4617
+                                                 "AddSeatById",
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4618
+                                                 &error,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4619
+                                                 G_TYPE_STRING, "Default",
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4620
+                                                 DBUS_TYPE_G_OBJECT_PATH, sid,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4621
+                                                 G_TYPE_INVALID,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4622
+                                                 G_TYPE_INVALID);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4623
+                        if (!res) {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4624
+                                g_warning ("Unable to add seat: %s", error->message);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4625
+                                g_error_free (error);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4626
+                                g_object_unref (mgr_proxy);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4627
+                                return;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4628
+                        }
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4629
+                }
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4630
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4631
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4632
+        seat_proxy = dbus_g_proxy_new_for_name (connection,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4633
+                                                CK_NAME,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4634
+                                                sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4635
+                                                CK_SEAT_INTERFACE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4636
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4637
+        if (seat_proxy == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4638
+                g_warning ("Failed to talk to seat '%s'", sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4639
+                g_object_unref (mgr_proxy);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4640
+                return;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4641
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4642
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4643
+        variables = g_hash_table_new_full (g_str_hash, g_str_equal,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4644
+                                           (GDestroyNotify) g_free,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4645
+                                           (GDestroyNotify) g_free);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4646
+
17790
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  4647
+        if (remaining_args) {
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  4648
+                for (i = 0; i < G_N_ELEMENTS (remaining_args); i++) {
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  4649
+                        char **arr;
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  4650
+
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  4651
+                        /* split var=value */
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  4652
+                        arr = g_strsplit (remaining_args [i], "=", 2);
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  4653
+                        if (arr[0] && arr[1]) {
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  4654
+                                g_hash_table_insert (variables,
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  4655
+                                                     g_strdup(arr[0]),
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  4656
+                                                     g_strdup (arr[1]));
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  4657
+                        }
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  4658
+                        g_strfreev (arr);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4659
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4660
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4661
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4662
+        error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4663
+        res = dbus_g_proxy_call (mgr_proxy,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4664
+                                 "AddSession",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4665
+                                 &error,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4666
+                                 DBUS_TYPE_G_OBJECT_PATH, sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4667
+                                 G_TYPE_STRING, sstype,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4668
+                                 G_TYPE_STRING, display_type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4669
+                                 CK_DBUS_TYPE_G_STRING_STRING_HASHTABLE, variables,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4670
+                                 G_TYPE_INVALID,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4671
+                                 DBUS_TYPE_G_OBJECT_PATH, &ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4672
+                                 G_TYPE_INVALID);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4673
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4674
+        if (!res) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4675
+                g_warning ("Unable to add dynamic session: %s", error->message);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4676
+                g_error_free (error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4677
+        } else {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4678
+                dbus_g_proxy_call_no_reply (seat_proxy,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4679
+                                            "Manage",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4680
+                                            G_TYPE_INVALID,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4681
+                                            G_TYPE_INVALID);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4682
+                g_print ("Seat %s with session %s has been added\n", sid, ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4683
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4684
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4685
+        g_object_unref (seat_proxy);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4686
+        g_object_unref (mgr_proxy);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4687
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4688
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4689
+static gboolean
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4690
+is_session_on_seat (DBusGConnection *connection,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4691
+                    const char      *sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4692
+                    const char      *ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4693
+                    gboolean        *is_last_session)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4694
+{
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4695
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4696
+        DBusGProxy *seat_proxy = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4697
+        GPtrArray  *sessions = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4698
+        char       *ssid_tmp = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4699
+        gboolean    res;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4700
+        gboolean    retval = FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4701
+        int         i;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4702
+        GError     *error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4703
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4704
+        seat_proxy = dbus_g_proxy_new_for_name (connection,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4705
+                                                CK_NAME,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4706
+                                                sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4707
+                                                CK_SEAT_INTERFACE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4708
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4709
+        if (seat_proxy == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4710
+                g_warning ("Failed to talk to seat '%s'", sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4711
+                return FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4712
+        }
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4713
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4714
+        error = NULL;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4715
+        res = dbus_g_proxy_call (seat_proxy,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4716
+                                 "GetSessions",
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4717
+                                 &error,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4718
+                                 G_TYPE_INVALID,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4719
+                                 dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4720
+                                 &sessions,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4721
+                                 G_TYPE_INVALID);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4722
+        if (! res) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4723
+                g_warning ("Failed to get list of sessions for %s: %s", sid, error->message);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4724
+                g_error_free (error);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4725
+                g_object_unref (seat_proxy);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4726
+                return FALSE;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4727
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4728
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4729
+        for (i = 0; i < sessions->len; i++) {
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4730
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4731
+                ssid_tmp = g_ptr_array_index (sessions, i);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4732
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4733
+                if (g_str_equal (ssid, ssid_tmp)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4734
+                        retval = TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4735
+                        break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4736
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4737
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4738
+                g_free (ssid_tmp);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4739
+                ssid_tmp = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4740
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4741
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4742
+        if (is_last_session != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4743
+                *is_last_session = sessions->len == 1;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4744
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4745
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4746
+        g_ptr_array_free (sessions, TRUE);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4747
+        g_object_unref (seat_proxy);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4748
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4749
+        return retval;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4750
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4751
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4752
+static char *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4753
+find_seat_id_from_session_id (DBusGConnection *connection,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4754
+                              DBusGProxy      *proxy,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4755
+                              const char      *ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4756
+                              gboolean        *is_last_session)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4757
+{
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4758
+        GError     *error;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4759
+        GPtrArray  *seats;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4760
+        int         i;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4761
+        char       *sid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4762
+        gboolean    res;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4763
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4764
+        error = NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4765
+        res = dbus_g_proxy_call (proxy,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4766
+                                 "GetSeats",
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4767
+                                 &error,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4768
+                                 G_TYPE_INVALID,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4769
+                                 dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4770
+                                 &seats,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4771
+                                 G_TYPE_INVALID);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4772
+
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4773
+        if (! res) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4774
+                g_warning ("Failed to get list of seats: %s", error->message);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4775
+                g_error_free (error);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4776
+                return NULL;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4777
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4778
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4779
+        for (i = 0; i < seats->len; i++) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4780
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4781
+                sid = g_ptr_array_index (seats, i);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4782
+                if (is_session_on_seat (connection, sid, ssid, is_last_session)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4783
+                        break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4784
+                }
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4785
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4786
+                g_free (sid);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4787
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4788
+        g_ptr_array_free (seats, TRUE);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4789
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4790
+        return sid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4791
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4792
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4793
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4794
+delete_session (DBusGConnection *connection)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4795
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4796
+        DBusGProxy *proxy;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4797
+        char       *ssid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4798
+        char       *sid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4799
+        gboolean    is_last_session;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4800
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4801
+        if (!g_str_has_prefix (session_id, CK_PATH_PREFIX)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4802
+                ssid = g_strdup_printf ("%s%s", CK_PATH_PREFIX, session_id);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4803
+        } else {
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4804
+                ssid = g_strdup (session_id);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4805
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4806
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4807
+        proxy = dbus_g_proxy_new_for_name (connection,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4808
+                                           CK_NAME,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4809
+                                           CK_MANAGER_PATH,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4810
+                                           CK_MANAGER_INTERFACE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4811
+        if (proxy == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4812
+                return;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4813
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4814
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4815
+        sid = find_seat_id_from_session_id (connection, proxy, ssid, &is_last_session);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4816
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4817
+        dbus_g_proxy_call_no_reply (proxy,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4818
+                                   "RemoveSession",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4819
+                                   DBUS_TYPE_G_OBJECT_PATH, ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4820
+                                   G_TYPE_INVALID,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4821
+                                   G_TYPE_INVALID);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4822
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4823
+        if (is_last_session) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4824
+                dbus_g_proxy_call_no_reply (proxy,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4825
+                                           "RemoveSeat",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4826
+                                           DBUS_TYPE_G_OBJECT_PATH, sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4827
+                                           G_TYPE_INVALID,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4828
+                                           G_TYPE_INVALID);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4829
+        }
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4830
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4831
+        g_object_unref (proxy);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4832
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4833
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4834
+int
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4835
+main (int argc, char *argv[])
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4836
+{
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4837
+        DBusGConnection *connection;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4838
+        GOptionContext  *ctx;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4839
+        GError          *error = NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4840
+        gboolean         res;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4841
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4842
+        g_type_init ();
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4843
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4844
+        /* Option parsing */
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4845
+        ctx = g_option_context_new (_("- Manage dynamic sessions"));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4846
+        g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4847
+        res = g_option_context_parse (ctx, &argc, &argv, &error);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4848
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4849
+        if (!res) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4850
+                if (error) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4851
+                        g_warning ("%s", error->message);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4852
+                        g_error_free (error);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4853
+                }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4854
+                exit (1);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4855
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4856
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4857
+        g_option_context_free (ctx);    
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4858
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4859
+        if (show_version) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4860
+                g_print ("%s %s\n", argv[0], VERSION);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4861
+                exit (0);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4862
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4863
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4864
+        if (add && delete) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4865
+                g_warning ("Can not specify -a and -d at the same time!");
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4866
+                exit (1);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4867
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4868
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4869
+        if (!add && !delete) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4870
+                g_warning ("Must specify -a, -d!");
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4871
+                exit (1);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4872
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4873
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4874
+        if (delete && (! IS_STR_SET (session_id))) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4875
+                g_warning ("You must specify session id for deleting a session. You can get all sessions by ck-list-sessions");
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4876
+                exit (1);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4877
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4878
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4879
+        if (add && (! IS_STR_SET (display_type)) ) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4880
+                g_warning ("You must specify display type for adding a session. You can get all display types under <etc>/ConsoleKit/displays.d/");
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4881
+                g_warning ("Invalid display type!");
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4882
+                exit (1);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4883
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4884
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4885
+        error = NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4886
+        connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4887
+        if (connection == NULL) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4888
+                g_message ("Failed to connect to the D-Bus daemon: %s", error->message);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4889
+                g_error_free (error);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4890
+                exit (1);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4891
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4892
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4893
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4894
+        if (add) {
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4895
+                add_session (connection);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4896
+        } else if (delete) {
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4897
+                delete_session (connection);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4898
+        } else {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4899
+                g_warning ("Invaild parameters!");
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4900
+                exit (1);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4901
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4902
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4903
+        return 0;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4904
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4905
diff --git a/tools/list-sessions.c b/tools/list-sessions.c
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4906
index 3933772..cc69d57 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4907
--- a/tools/list-sessions.c
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4908
+++ b/tools/list-sessions.c
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4909
@@ -46,6 +46,23 @@
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4910
 #define CK_SEAT_INTERFACE    "org.freedesktop.ConsoleKit.Seat"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4911
 #define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4912
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4913
+#define IS_STR_SET(x) (x != NULL && x[0] != '\0')
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4914
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4915
+typedef struct CkSessionOutput {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4916
+        char    *prop_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4917
+        char    *prop_value;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4918
+} CkSessionOutput;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4919
+
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4920
+static gboolean do_all = FALSE;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4921
+static gboolean do_version = FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4922
+static char *do_format = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4923
+static GOptionEntry entries [] = {
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4924
+        { "all", 'a', 0, G_OPTION_ARG_NONE, &do_all, N_("List all sessions. If not given, only list open sessions"), NULL },
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4925
+        { "format", 'f', 0, G_OPTION_ARG_STRING, &do_format, N_("Prints information according to the given format"), NULL },
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4926
+        { "version", 'V', 0, G_OPTION_ARG_NONE, &do_version, N_("Version of this application"), NULL },
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4927
+        { NULL }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4928
+};
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4929
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4930
 static gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4931
 get_uint (DBusGProxy *proxy,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4932
           const char *method,
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4933
@@ -176,6 +193,7 @@ list_session (DBusGConnection *connection,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4934
         char       *sid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4935
         char       *lsid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4936
         char       *session_type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4937
+        char       *display_type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4938
         char       *x11_display;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4939
         char       *x11_display_device;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4940
         char       *display_device;
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4941
@@ -184,8 +202,11 @@ list_session (DBusGConnection *connection,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4942
         char       *idle_since_hint;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4943
         gboolean    is_active;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4944
         gboolean    is_local;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4945
+        gboolean    is_open;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4946
         char       *short_sid;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4947
         const char *short_ssid;
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4948
+        char      **format_arr = NULL;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4949
+        int         i, j;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4950
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4951
         proxy = dbus_g_proxy_new_for_name (connection,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4952
                                            CK_NAME,
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4953
@@ -198,6 +219,7 @@ list_session (DBusGConnection *connection,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4954
         sid = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4955
         lsid = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4956
         session_type = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4957
+        display_type = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4958
         x11_display = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4959
         x11_display_device = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4960
         display_device = NULL;
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4961
@@ -209,15 +231,21 @@ list_session (DBusGConnection *connection,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4962
         get_path (proxy, "GetSeatId", &sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4963
         get_string (proxy, "GetLoginSessionId", &lsid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4964
         get_string (proxy, "GetSessionType", &session_type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4965
+        get_string (proxy, "GetDisplayType", &display_type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4966
         get_string (proxy, "GetX11Display", &x11_display);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4967
         get_string (proxy, "GetX11DisplayDevice", &x11_display_device);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4968
         get_string (proxy, "GetDisplayDevice", &display_device);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4969
         get_string (proxy, "GetRemoteHostName", &remote_host_name);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4970
+        get_boolean (proxy, "IsOpen", &is_open);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4971
         get_boolean (proxy, "IsActive", &is_active);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4972
         get_boolean (proxy, "IsLocal", &is_local);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4973
         get_string (proxy, "GetCreationTime", &creation_time);
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4974
         get_string (proxy, "GetIdleSinceHint", &idle_since_hint);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4975
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4976
+        if (!do_all && !is_open) {
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4977
+                return;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4978
+        }
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4979
+
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4980
         realname = get_real_name (uid);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4981
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4982
         short_sid = sid;
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4983
@@ -230,24 +258,49 @@ list_session (DBusGConnection *connection,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4984
                 short_ssid = ssid + strlen (CK_PATH) + 1;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4985
         }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4986
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  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
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4988
-                short_ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4989
-                uid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4990
-                realname,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4991
-                short_sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4992
-                session_type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4993
-                is_active ? "TRUE" : "FALSE",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4994
-                x11_display,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4995
-                x11_display_device,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4996
-                display_device,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4997
-                remote_host_name,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4998
-                is_local ? "TRUE" : "FALSE",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4999
-                creation_time,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5000
-                lsid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5001
-        if (idle_since_hint != NULL && idle_since_hint[0] != '\0') {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5002
-                printf ("\n\tidle-since-hint = '%s'", idle_since_hint);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5003
+        CkSessionOutput output[] = {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5004
+                {"session-id", g_strdup (short_ssid)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5005
+                {"unix-user", g_strdup_printf ("%d", uid)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5006
+                {"realname", g_strdup (realname)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5007
+                {"seat", g_strdup (short_sid)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5008
+                {"session-type", g_strdup (session_type)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5009
+                {"display-type", g_strdup (display_type)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5010
+                {"open", is_open ? "TRUE" : "FALSE"},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5011
+                {"active", is_active ? "TRUE" : "FALSE"},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5012
+                {"x11-display", g_strdup (x11_display)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5013
+                {"x11-display-device", g_strdup (x11_display_device)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5014
+                {"display-device", g_strdup (display_device)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5015
+                {"remote-host-name", g_strdup (remote_host_name)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5016
+                {"is-local", is_local ? "TRUE" : "FALSE"},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5017
+                {"on-since", g_strdup (creation_time)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5018
+                {"login-session-id", g_strdup (lsid)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5019
+                {"idle-since-hint", g_strdup (idle_since_hint)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5020
+        };
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5021
+
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5022
+        if (IS_STR_SET (do_format)) {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5023
+                format_arr = g_strsplit (do_format, ",", -1);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5024
+
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5025
+                for (i = 0; format_arr[i] != NULL; ++i) {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5026
+                        for (j = 0; j < G_N_ELEMENTS (output); j++) {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5027
+                                if (g_str_equal (format_arr[i], output[j].prop_name)) {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5028
+                                        printf ("'%s'\t", output[j].prop_value);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5029
+                                        break;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5030
+                                }
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5031
+                        }
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5032
+                }
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5033
+                printf ("\n");
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5034
+                g_strfreev (format_arr);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5035
+
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5036
+        } else {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5037
+                for (j = 0; j < G_N_ELEMENTS (output); j++) {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5038
+                        if (g_str_equal (output[j].prop_name, "session-id"))
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5039
+                                printf ("%s:\n", output[j].prop_value);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5040
+                        else
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5041
+                                printf ("\t%s = '%s'\n",
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5042
+                                        output[j].prop_name,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5043
+                                        output[j].prop_value);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5044
+                }
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5045
         }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5046
-        printf ("\n");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5047
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5048
         g_free (idle_since_hint);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5049
         g_free (creation_time);
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5050
@@ -256,9 +309,11 @@ list_session (DBusGConnection *connection,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5051
         g_free (sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5052
         g_free (lsid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5053
         g_free (session_type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5054
+        g_free (display_type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5055
         g_free (x11_display);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5056
         g_free (x11_display_device);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5057
         g_free (display_device);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5058
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5059
         g_object_unref (proxy);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5060
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5061
 
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5062
@@ -368,11 +423,6 @@ main (int    argc,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5063
         GOptionContext *context;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5064
         gboolean        retval;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5065
         GError         *error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5066
-        static gboolean do_version = FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5067
-        static GOptionEntry entries [] = {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5068
-                { "version", 'V', 0, G_OPTION_ARG_NONE, &do_version, N_("Version of this application"), NULL },
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5069
-                { NULL }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5070
-        };
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5071
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5072
         g_type_init ();
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5073