patches/ConsoleKit-01-ck-dynamic.diff
author yippi
Thu, 28 Jul 2011 03:50:58 +0000
branchgnome-2-30
changeset 22037 6bbc65b301fa
parent 21940 435c776c0f32
child 22042 d88ef0594f24
permissions -rw-r--r--
2011-07-28 Brian Cameron <[email protected]> * patches/gdm-01-dynamic-display.diff: Fix GDM so that if the Xserver dies with a non-zero return code that the GDM daemon respawns the display. This is needed to make GDM work when the display is killed with Ctrl-Alt-Bksp (or Ctrl-Alt-Bksp-Bksp on Sun Ray). * patches/ConsoleKit-01-ck-dynamic.diff: Fix crashing problem caused by referencing a pointer improperly. * patches/gdm-09-lang.diff: Fix spacing.
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
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   809
@@ -79,6 +79,8 @@ event_seat_session_added_free (CkLogSeatSessionAddedEvent *event)
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);
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   818
@@ -103,6 +105,8 @@ event_seat_session_removed_free (CkLogSeatSessionRemovedEvent *event)
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);
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   827
@@ -213,6 +217,7 @@ event_seat_session_added_copy (CkLogSeatSessionAddedEvent *event,
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);
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   835
@@ -232,6 +237,7 @@ event_seat_session_removed_copy (CkLogSeatSessionRemovedEvent *event,
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);
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   843
@@ -415,10 +421,11 @@ add_log_for_seat_session_added (GString    *str,
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 : "",
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   856
@@ -436,10 +443,11 @@ add_log_for_seat_session_removed (GString    *str,
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 : "",
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   869
@@ -721,7 +729,7 @@ parse_log_for_seat_added (const GString *str,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   870
         error = NULL;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   871
         re = g_regex_new ("seat-id='(?P<seatid>[a-zA-Z0-9/]+)' seat-kind=(?P<sessionid>[0-9]*)", 0, 0, &error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   872
         if (re == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   873
-                g_warning (error->message);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   874
+                g_warning ("%s", error->message);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   875
                 goto out;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   876
         }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   877
 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   878
@@ -781,7 +789,7 @@ parse_log_for_seat_removed (const GString *str,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   879
         error = NULL;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   880
         re = g_regex_new ("seat-id='(?P<seatid>[a-zA-Z0-9/]+)' seat-kind=(?P<sessionid>[0-9]*)", 0, 0, &error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   881
         if (re == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   882
-                g_warning (error->message);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   883
+                g_warning ("%s", error->message);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   884
                 goto out;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   885
         }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   886
 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   887
@@ -887,7 +895,7 @@ parse_log_for_system_start (const GString *str,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   888
         error = NULL;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   889
         re = g_regex_new ("(kernel-release='(?P<release>[^']+)')?[ ]?(boot-arguments='(?P<arguments>.*)')?", 0, 0, &error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   890
         if (re == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   891
-                g_warning (error->message);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   892
+                g_warning ("%s", error->message);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   893
                 goto out;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   894
         }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   895
 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   896
@@ -939,9 +947,9 @@ parse_log_for_seat_session_added (const GString *str,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   897
         }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   898
 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   899
         error = NULL;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   900
-        re = g_regex_new ("seat-id='(?P<seatid>[a-zA-Z0-9/]+)' session-id='(?P<sessionid>[a-zA-Z0-9/]+)' session-type='(?P<sessiontype>[a-zA-Z0-9 ]*)' session-x11-display='(?P<sessionx11display>[0-9a-zA-Z.:]*)' session-x11-display-device='(?P<sessionx11displaydevice>[^']*)' session-display-device='(?P<sessiondisplaydevice>[^']*)' session-remote-host-name='(?P<sessionremovehostname>[^']*)' session-is-local=(?P<sessionislocal>[a-zA-Z]*) session-unix-user=(?P<sessionunixuser>[0-9]*) session-creation-time='(?P<sessioncreationtime>[^']*)'", 0, 0, &error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   901
+        re = g_regex_new ("seat-id='(?P<seatid>[a-zA-Z0-9/]+)' session-id='(?P<sessionid>[a-zA-Z0-9/]+)' session-type='(?P<sessiontype>[a-zA-Z0-9 ]*)' display-type='(?P<displaytype>[a-zA-Z0-9 ]*)' session-x11-display='(?P<sessionx11display>[0-9a-zA-Z.:]*)' session-x11-display-device='(?P<sessionx11displaydevice>[^']*)' session-display-device='(?P<sessiondisplaydevice>[^']*)' session-remote-host-name='(?P<sessionremovehostname>[^']*)' session-is-local=(?P<sessionislocal>[a-zA-Z]*) session-unix-user=(?P<sessionunixuser>[0-9]*) session-creation-time='(?P<sessioncreationtime>[^']*)'", 0, 0, &error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   902
         if (re == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   903
-                g_warning (error->message);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   904
+                g_warning ("%s", error->message);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   905
                 goto out;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   906
         }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   907
 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   908
@@ -957,6 +965,7 @@ parse_log_for_seat_session_added (const GString *str,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   909
         e->seat_id = g_match_info_fetch_named (match_info, "seatid");
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   910
         e->session_id = g_match_info_fetch_named (match_info, "sessionid");
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   911
         e->session_type = g_match_info_fetch_named (match_info, "sessiontype");
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   912
+        e->display_type = g_match_info_fetch_named (match_info, "displaytype");
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   913
         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
   914
         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
   915
         e->session_display_device = g_match_info_fetch_named (match_info, "sessiondisplaydevice");
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   916
@@ -1014,9 +1023,9 @@ parse_log_for_seat_session_removed (const GString *str,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   917
         }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   918
 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   919
         error = NULL;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   920
-        re = g_regex_new ("seat-id='(?P<seatid>[a-zA-Z0-9/]+)' session-id='(?P<sessionid>[a-zA-Z0-9/]+)' session-type='(?P<sessiontype>[a-zA-Z0-9 ]*)' session-x11-display='(?P<sessionx11display>[0-9a-zA-Z.:]*)' session-x11-display-device='(?P<sessionx11displaydevice>[^']*)' session-display-device='(?P<sessiondisplaydevice>[^']*)' session-remote-host-name='(?P<sessionremovehostname>[^']*)' session-is-local=(?P<sessionislocal>[a-zA-Z]*) session-unix-user=(?P<sessionunixuser>[0-9]*) session-creation-time='(?P<sessioncreationtime>[^']*)'", 0, 0, &error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   921
+        re = g_regex_new ("seat-id='(?P<seatid>[a-zA-Z0-9/]+)' session-id='(?P<sessionid>[a-zA-Z0-9/]+)' session-type='(?P<sessiontype>[a-zA-Z0-9 ]*)' display-type='(?P<displaytype>[a-zA-Z0-9 ]*)' session-x11-display='(?P<sessionx11display>[0-9a-zA-Z.:]*)' session-x11-display-device='(?P<sessionx11displaydevice>[^']*)' session-display-device='(?P<sessiondisplaydevice>[^']*)' session-remote-host-name='(?P<sessionremovehostname>[^']*)' session-is-local=(?P<sessionislocal>[a-zA-Z]*) session-unix-user=(?P<sessionunixuser>[0-9]*) session-creation-time='(?P<sessioncreationtime>[^']*)'", 0, 0, &error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   922
         if (re == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   923
-                g_warning (error->message);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   924
+                g_warning ("%s", error->message);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   925
                 goto out;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   926
         }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   927
 
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
   928
@@ -1032,6 +1041,7 @@ parse_log_for_seat_session_removed (const GString *str,
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   929
         e->seat_id = g_match_info_fetch_named (match_info, "seatid");
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   930
         e->session_id = g_match_info_fetch_named (match_info, "sessionid");
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   931
         e->session_type = g_match_info_fetch_named (match_info, "sessiontype");
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   932
+        e->display_type = g_match_info_fetch_named (match_info, "displaytype");
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   933
         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
   934
         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
   935
         e->session_display_device = g_match_info_fetch_named (match_info, "sessiondisplaydevice");
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   936
@@ -1090,7 +1100,7 @@ parse_log_for_seat_active_session_changed (const GString *str,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   937
         error = NULL;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   938
         re = g_regex_new ("seat-id='(?P<seatid>[a-zA-Z0-9/]+)' session-id='(?P<sessionid>[a-zA-Z0-9/]*)'", 0, 0, &error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   939
         if (re == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   940
-                g_warning (error->message);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   941
+                g_warning ("%s", error->message);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   942
                 goto out;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   943
         }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   944
 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   945
@@ -1142,7 +1152,7 @@ parse_log_for_seat_device_added (const GString *str,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   946
         error = NULL;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   947
         re = g_regex_new ("seat-id='(?P<seatid>[a-zA-Z0-9/]+)' device-id='(?P<deviceid>[^']+)' device-type='(?P<devicetype>[^']+)'", 0, 0, &error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   948
         if (re == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   949
-                g_warning (error->message);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   950
+                g_warning ("%s", error->message);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   951
                 goto out;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   952
         }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   953
 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   954
@@ -1195,7 +1205,7 @@ parse_log_for_seat_device_removed (const GString *str,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   955
         error = NULL;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   956
         re = g_regex_new ("seat-id='(?P<seatid>[a-zA-Z0-9/]+)' device-id='(?P<deviceid>[^']+)' device-type='(?P<devicetype>[^']+)'", 0, 0, &error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   957
         if (re == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   958
-                g_warning (error->message);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   959
+                g_warning ("%s", error->message);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   960
                 goto out;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   961
         }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
   962
 
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   963
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
   964
index 65571f0..2d4ed4e 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   965
--- a/src/ck-log-event.h
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   966
+++ b/src/ck-log-event.h
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   967
@@ -68,6 +68,7 @@ typedef struct
16232
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
         char *seat_id;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   970
         int   seat_kind;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   971
+        char *seat_type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   972
 } CkLogSeatAddedEvent;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   973
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
   974
 typedef struct
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   975
@@ -81,11 +82,13 @@ typedef struct
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   976
         char    *seat_id;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   977
         char    *session_id;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   978
         char    *session_type;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   979
+        char    *display_type;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   980
         char    *session_x11_display;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   981
         char    *session_x11_display_device;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   982
         char    *session_display_device;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   983
         char    *session_remote_host_name;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   984
         gboolean session_is_local;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   985
+        gboolean session_is_dynamic;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   986
         guint    session_unix_user;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   987
         char    *session_creation_time;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   988
 } CkLogSeatSessionAddedEvent;
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
   989
@@ -95,11 +98,13 @@ typedef struct
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   990
         char    *seat_id;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   991
         char    *session_id;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   992
         char    *session_type;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   993
+        char    *display_type;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   994
         char    *session_x11_display;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
   995
         char    *session_x11_display_device;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   996
         char    *session_display_device;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   997
         char    *session_remote_host_name;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   998
         gboolean session_is_local;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
   999
+        gboolean session_is_dynamic;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1000
         guint    session_unix_user;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1001
         char    *session_creation_time;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1002
 } CkLogSeatSessionRemovedEvent;
20076
25ffad964372 2010-09-06 Jeff Cai <[email protected]>
qc161282
parents: 17996
diff changeset
  1003
--- ConsoleKit-0.4.1/src/ck-manager.c.1	2010-09-06 17:41:32.942210394 +0800
25ffad964372 2010-09-06 Jeff Cai <[email protected]>
qc161282
parents: 17996
diff changeset
  1004
+++ ConsoleKit-0.4.1/src/ck-manager.c	2010-09-06 17:41:56.671280731 +0800
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1005
@@ -46,9 +46,14 @@
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1006
 #include <secdb.h>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1007
 #endif
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1008
 
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1009
+#ifndef HAVE_STRVERSCMP
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1010
+#include "strverscmp.h"
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1011
+#endif
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1012
+
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1013
 #include "ck-manager.h"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1014
 #include "ck-manager-glue.h"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1015
 #include "ck-seat.h"
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1016
+#include "ck-display-template.h"
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1017
 #include "ck-session-leader.h"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1018
 #include "ck-session.h"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1019
 #include "ck-marshal.h"
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1020
@@ -58,12 +63,19 @@
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1021
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1022
 #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
  1023
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1024
+#define CK_TYPE_PARAMETER_STRUCT (dbus_g_type_get_struct ("GValueArray", \
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1025
+                                                          G_TYPE_STRING, \
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1026
+                                                          G_TYPE_VALUE, \
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1027
+                                                          G_TYPE_INVALID))
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1028
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1029
 #define CK_SEAT_DIR          SYSCONFDIR "/ConsoleKit/seats.d"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1030
 #define LOG_FILE             LOCALSTATEDIR "/log/ConsoleKit/history"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1031
 #define CK_DBUS_PATH         "/org/freedesktop/ConsoleKit"
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1032
 #define CK_MANAGER_DBUS_PATH CK_DBUS_PATH "/Manager"
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1033
 #define CK_MANAGER_DBUS_NAME "org.freedesktop.ConsoleKit.Manager"
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1034
 
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1035
+#define IS_STR_SET(x) (x != NULL && x[0] != '\0')
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1036
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1037
 struct CkManagerPrivate
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1038
 {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1039
 #ifdef HAVE_POLKIT
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1040
@@ -392,6 +404,7 @@ log_seat_added_event (CkManager  *manage
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1041
         GError            *error;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1042
         char              *sid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1043
         CkSeatKind         seat_kind;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1044
+        char              *seat_type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1045
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1046
         memset (&event, 0, sizeof (CkLogEvent));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1047
 
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1048
@@ -401,9 +414,11 @@ log_seat_added_event (CkManager  *manage
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1049
         sid = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1050
         ck_seat_get_id (seat, &sid, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1051
         ck_seat_get_kind (seat, &seat_kind, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1052
+        ck_seat_get_type_string (seat, &seat_type, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1053
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1054
         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
  1055
         event.event.seat_added.seat_kind = (int)seat_kind;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1056
+        event.event.seat_added.seat_type = (char *)seat_type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1057
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1058
         error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1059
         res = ck_event_logger_queue_event (manager->priv->logger, &event, &error);
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1060
@@ -413,6 +428,7 @@ log_seat_added_event (CkManager  *manage
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1061
         }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1062
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1063
         g_free (sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1064
+        g_free (seat_type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1065
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1066
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1067
 static void
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1068
@@ -517,6 +533,7 @@ log_seat_session_added_event (CkManager 
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1069
         if (session != NULL) {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1070
                 g_object_get (session,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1071
                               "session-type", &event.event.seat_session_added.session_type,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1072
+                              "display-type", &event.event.seat_session_added.display_type,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1073
                               "x11-display", &event.event.seat_session_added.session_x11_display,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1074
                               "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
  1075
                               "display-device", &event.event.seat_session_added.session_display_device,
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1076
@@ -572,6 +589,7 @@ log_seat_session_removed_event (CkManage
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1077
         if (session != NULL) {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1078
                 g_object_get (session,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1079
                               "session-type", &event.event.seat_session_removed.session_type,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1080
+                              "display-type", &event.event.seat_session_removed.display_type,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1081
                               "x11-display", &event.event.seat_session_removed.session_x11_display,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  1082
                               "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
  1083
                               "display-device", &event.event.seat_session_removed.session_display_device,
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1084
@@ -845,6 +863,8 @@ ready_cb (PolkitAuthority *authority,
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1085
         PolkitAuthorizationResult *ret;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1086
         GError *error;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1087
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1088
+        g_debug ("CkManager: Ready.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1089
+
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1090
         error = NULL;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1091
         ret = polkit_authority_check_authorization_finish (authority, res, &error);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1092
         if (error != NULL) {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1093
@@ -975,6 +995,7 @@ session_is_real_user (CkSession *session
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1094
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1095
         /* filter out GDM user */
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1096
         if (username != NULL && strcmp (username, "gdm") == 0) {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1097
+                g_debug ("CkManager: Session is not real user");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1098
                 ret = FALSE;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1099
                 goto out;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1100
         }
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1101
@@ -983,6 +1004,7 @@ session_is_real_user (CkSession *session
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1102
                 *userp = g_strdup (username);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1103
         }
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1104
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1105
+        g_debug ("CkManager: Session is real user");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1106
         ret = TRUE;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1107
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1108
  out:
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1109
@@ -1230,6 +1252,7 @@ on_seat_active_session_changed_full (CkS
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1110
 {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1111
         char *ssid = NULL;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1112
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1113
+        g_debug ("CkManager: Active session changed.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1114
         if (session != NULL) {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1115
                 ck_session_get_id (session, &ssid, NULL);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1116
         }
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1117
@@ -1247,6 +1270,7 @@ on_seat_session_added_full (CkSeat     *
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1118
 {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1119
         char *ssid = NULL;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1120
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1121
+        g_debug ("CkManager: Session added.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1122
         ck_session_get_id (session, &ssid, NULL);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1123
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1124
         ck_manager_dump (manager);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1125
@@ -1262,6 +1286,7 @@ on_seat_session_removed_full (CkSeat    
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1126
 {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1127
         char *ssid = NULL;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1128
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1129
+        g_debug ("CkManager: Seat Session removed.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1130
         ck_session_get_id (session, &ssid, NULL);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1131
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1132
         ck_manager_dump (manager);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1133
@@ -1275,6 +1300,7 @@ on_seat_device_added (CkSeat      *seat,
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1134
                       GValueArray *device,
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1135
                       CkManager   *manager)
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1136
 {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1137
+        g_debug ("CkManager: Seat device added.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1138
         ck_manager_dump (manager);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1139
         log_seat_device_added_event (manager, seat, device);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1140
 }
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1141
@@ -1284,6 +1310,7 @@ on_seat_device_removed (CkSeat      *sea
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1142
                         GValueArray *device,
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1143
                         CkManager   *manager)
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1144
 {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1145
+        g_debug ("CkManager: Seat device removed.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1146
         ck_manager_dump (manager);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1147
         log_seat_device_removed_event (manager, seat, device);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1148
 }
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1149
@@ -1311,15 +1338,23 @@ disconnect_seat_signals (CkManager *mana
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1150
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1151
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1152
 static CkSeat *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1153
-add_new_seat (CkManager *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1154
-              CkSeatKind kind)
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1155
+add_new_seat (CkManager  *manager,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1156
+              const char *give_sid,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1157
+              CkSeatKind  kind,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1158
+              const char *type)
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1159
 {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1160
         char   *sid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1161
         CkSeat *seat;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1162
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1163
-        sid = generate_seat_id (manager);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1164
+        if (IS_STR_SET (give_sid)) {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1165
+                sid = g_strdup (give_sid);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1166
+        } else {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1167
+                sid = generate_seat_id (manager);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1168
+        }
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1169
+
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1170
+        g_debug ("CkManager: Add new seat '%s'.", sid);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1171
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1172
-        seat = ck_seat_new (sid, kind);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1173
+        seat = ck_seat_new (sid, kind, type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1174
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1175
         /* First we connect our own signals to the seat, followed by
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1176
          * the D-Bus signal hookup to make sure we can first dump the
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1177
@@ -1344,7 +1379,7 @@ add_new_seat (CkManager *manager,
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1178
         ck_seat_run_programs (seat, NULL, NULL, "seat_added");
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1179
 
21939
7d28343f0da4 Fix so patch applies.
yippi
parents: 21938
diff changeset
  1180
         g_debug ("Emitting seat-added: %s", sid);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1181
-        g_signal_emit (manager, signals [SEAT_ADDED], 0, sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1182
+        g_signal_emit (manager, signals [SEAT_ADDED], 0, sid, type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1183
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1184
         log_seat_added_event (manager, seat);
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1185
 
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1186
@@ -1363,6 +1398,8 @@ remove_seat (CkManager *manager,
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1187
         sid = NULL;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1188
         ck_seat_get_id (seat, &sid, NULL);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1189
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1190
+        g_debug ("CkManager: Remove seat '%s'", sid);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1191
+
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1192
         /* Need to get the original key/value */
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1193
         res = g_hash_table_lookup_extended (manager->priv->seats,
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1194
                                             sid,
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1195
@@ -1402,64 +1439,22 @@ remove_seat (CkManager *manager,
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1196
         g_free (sid);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1197
 }
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1198
 
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1199
-#define IS_STR_SET(x) (x != NULL && x[0] != '\0')
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1200
-
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1201
 static CkSeat *
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1202
 find_seat_for_session (CkManager *manager,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1203
                        CkSession *session)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1204
 {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1205
         CkSeat  *seat;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1206
-        gboolean is_static_x11;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1207
-        gboolean is_static_text;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1208
-        char    *display_device;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1209
-        char    *x11_display_device;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1210
-        char    *x11_display;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1211
-        char    *remote_host_name;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1212
-        gboolean is_local;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1213
-
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1214
-        is_static_text = FALSE;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1215
-        is_static_x11 = FALSE;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1216
-
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1217
-        seat = NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1218
-        display_device = NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1219
-        x11_display_device = NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1220
-        x11_display = NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1221
-        remote_host_name = NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1222
-        is_local = FALSE;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1223
-
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1224
-        /* FIXME: use matching to group entries? */
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1225
-
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1226
-        ck_session_get_display_device (session, &display_device, NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1227
-        ck_session_get_x11_display_device (session, &x11_display_device, NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1228
-        ck_session_get_x11_display (session, &x11_display, NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1229
-        ck_session_get_remote_host_name (session, &remote_host_name, NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1230
-        ck_session_is_local (session, &is_local, NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1231
-
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1232
-        if (IS_STR_SET (x11_display)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1233
-            && IS_STR_SET (x11_display_device)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1234
-            && ! IS_STR_SET (remote_host_name)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1235
-            && is_local == TRUE) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1236
-                is_static_x11 = TRUE;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1237
-        } else if (! IS_STR_SET (x11_display)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1238
-                   && ! IS_STR_SET (x11_display_device)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1239
-                   && IS_STR_SET (display_device)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1240
-                   && ! IS_STR_SET (remote_host_name)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1241
-                   && is_local == TRUE) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1242
-                is_static_text = TRUE;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1243
-        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1244
+        char    *sid = NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1245
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1246
+        ck_session_get_seat_id (session, &sid, NULL);
20076
25ffad964372 2010-09-06 Jeff Cai <[email protected]>
qc161282
parents: 17996
diff changeset
  1247
 
25ffad964372 2010-09-06 Jeff Cai <[email protected]>
qc161282
parents: 17996
diff changeset
  1248
-        if (is_static_x11 || is_static_text) {
25ffad964372 2010-09-06 Jeff Cai <[email protected]>
qc161282
parents: 17996
diff changeset
  1249
-                char *sid;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1250
+        if (! IS_STR_SET (sid)) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1251
                 sid = g_strdup_printf ("%s/Seat%u", CK_DBUS_PATH, 1);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1252
-                seat = g_hash_table_lookup (manager->priv->seats, sid);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1253
-                g_free (sid);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1254
         }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1255
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1256
-        g_free (display_device);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1257
-        g_free (x11_display_device);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1258
-        g_free (x11_display);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1259
-        g_free (remote_host_name);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1260
+        seat = g_hash_table_lookup (manager->priv->seats, sid);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1261
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1262
+        g_free (sid);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1263
         return seat;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1264
 }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1265
 
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1266
@@ -1594,36 +1589,52 @@ open_session_for_leader (CkManager      
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1267
         CkSession   *session;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1268
         CkSeat      *seat;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1269
         const char  *ssid;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1270
+        char        *sid;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1271
         const char  *cookie;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1272
 
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1273
+        g_debug ("CkManager: Open session for leader.");
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1274
         ssid = ck_session_leader_peek_session_id (leader);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1275
         cookie = ck_session_leader_peek_cookie (leader);
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
-        session = ck_session_new_with_parameters (ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1278
-                                                  cookie,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1279
-                                                  parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1280
+        session = g_hash_table_lookup (manager->priv->sessions, ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1281
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1282
         if (session == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1283
-                GError *error;
21939
7d28343f0da4 Fix so patch applies.
yippi
parents: 21938
diff changeset
  1284
-                g_debug ("Unable to create new session");
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1285
-                error = g_error_new (CK_MANAGER_ERROR,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1286
-                                     CK_MANAGER_ERROR_GENERAL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1287
-                                     "Unable to create new session");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1288
-                dbus_g_method_return_error (context, error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1289
-                g_error_free (error);
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1290
+                g_debug ("CkManager: Creating new session.");
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1291
+                session = ck_session_new_with_parameters (ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1292
+                                                          parameters);
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1293
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1294
+                if (session == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1295
+                        GError *error;
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1296
+                        g_debug ("CkManager: Unable to create new session");
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1297
+                        error = g_error_new (CK_MANAGER_ERROR,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1298
+                                             CK_MANAGER_ERROR_GENERAL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1299
+                                             "Unable to create new session");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1300
+                        dbus_g_method_return_error (context, error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1301
+                        g_error_free (error);
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1302
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1303
-                return;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1304
+                        return;
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
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1307
+                g_hash_table_insert (manager->priv->sessions,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1308
+                                     g_strdup (ssid),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1309
+                                     g_object_ref (session));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1310
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1311
+        } else {
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1312
+                g_debug ("CkManager: Using found session.");
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1313
+                ck_session_set_parameters (session, parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1314
         }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1315
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1316
-        g_hash_table_insert (manager->priv->sessions,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1317
-                             g_strdup (ssid),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1318
-                             g_object_ref (session));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1319
+        ck_session_set_cookie (session, cookie, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1320
+        ck_session_set_is_open (session, TRUE, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1321
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1322
         /* Add to seat */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1323
         seat = find_seat_for_session (manager, session);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1324
         if (seat == NULL) {
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1325
+                sid = NULL;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1326
+                ck_session_get_seat_id (session, &sid, NULL);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1327
                 /* create a new seat */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1328
-                seat = add_new_seat (manager, CK_SEAT_KIND_DYNAMIC);
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1329
+                seat = add_new_seat (manager, sid, CK_SEAT_KIND_DYNAMIC, "Default");
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1330
+                g_free (sid);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1331
         }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1332
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1333
         ck_seat_add_session (seat, session, NULL);
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1334
@@ -1683,6 +1694,7 @@ generate_session_for_leader (CkManager  
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1335
 {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1336
         gboolean res;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1337
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1338
+        g_debug ("CkManager: Generate session for leader.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1339
         res = ck_session_leader_collect_parameters (leader,
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1340
                                                     context,
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1341
                                                     (CkSessionLeaderDoneFunc)collect_parameters_cb,
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1342
@@ -1697,11 +1709,57 @@ generate_session_for_leader (CkManager  
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1343
         }
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1344
 }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1345
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1346
+static char *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1347
+check_parameters_for_ssid (const GPtrArray *parameters)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1348
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1349
+        int i;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1350
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1351
+        if (parameters == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1352
+                return NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1353
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1354
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1355
+        for (i = 0; i < parameters->len; i++) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1356
+                GValue   val_struct = { 0, };
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1357
+                char    *prop_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1358
+                gboolean res;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1359
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1360
+                g_value_init (&val_struct, CK_TYPE_PARAMETER_STRUCT);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1361
+                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
  1362
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1363
+                res = dbus_g_type_struct_get (&val_struct,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1364
+                                              0, &prop_name,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1365
+                                              G_MAXUINT);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1366
+                if (! res) {
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1367
+                        g_debug ("CkManager: Unable to read parameter name");
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1368
+                        continue;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1369
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1370
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1371
+                if (prop_name != NULL && strcmp (prop_name, "session") == 0) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1372
+                        GValue   prop_val = { 0, };
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1373
+                        GValue  *session_val;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1374
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1375
+                        g_value_init (&prop_val, G_TYPE_VALUE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1376
+                        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
  1377
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1378
+                        if (! res) {
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1379
+                                g_debug ("CkManager: Unable to read parameter value");
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1380
+                                continue;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1381
+                        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1382
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1383
+                        session_val = g_value_get_boxed (&prop_val);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1384
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1385
+                        return g_value_dup_string (session_val);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1386
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1387
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1388
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1389
+        return NULL;
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
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1392
 static gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1393
-create_session_for_sender (CkManager             *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1394
-                           const char            *sender,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1395
-                           const GPtrArray       *parameters,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1396
-                           DBusGMethodInvocation *context)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1397
+open_session_for_sender (CkManager             *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1398
+                         const char            *sender,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1399
+                         const GPtrArray       *parameters,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1400
+                         DBusGMethodInvocation *context)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1401
 {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1402
         pid_t           pid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1403
         uid_t           uid;
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1404
@@ -1709,6 +1767,7 @@ create_session_for_sender (CkManager    
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1405
         char            *cookie;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1406
         char            *ssid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1407
         CkSessionLeader *leader;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1408
+        CkSession       *session;
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
         g_debug ("CkManager: create session for sender: %s", sender);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1411
 
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1412
@@ -1727,9 +1786,21 @@ create_session_for_sender (CkManager    
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1413
         }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1414
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1415
         cookie = generate_session_cookie (manager);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1416
-        ssid = generate_session_id (manager);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1417
 
21939
7d28343f0da4 Fix so patch applies.
yippi
parents: 21938
diff changeset
  1418
-        g_debug ("Creating new session ssid: %s", ssid);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1419
+        ssid = check_parameters_for_ssid (parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1420
+
16491
cfe4ca1d31ab 2009-09-08 Halton Huo <[email protected]>
halton
parents: 16486
diff changeset
  1421
+        if (IS_STR_SET (ssid)) {
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1422
+                session = g_hash_table_lookup (manager->priv->sessions, ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1423
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1424
+                /* FIXME: Need to verify that the session belongs to a seat
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1425
+                 * managed by the sender
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1426
+                 */
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1427
+                g_debug ("CkManager: Managing existing session ssid: %s", ssid);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1428
+        } else {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1429
+                ssid = generate_session_id (manager);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1430
+                session = NULL;
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1431
+                g_debug ("CkManager: Creating new session ssid: %s", ssid);
16232
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
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1434
         leader = ck_session_leader_new ();
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1435
         ck_session_leader_set_uid (leader, uid);
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1436
@@ -1967,7 +2038,7 @@ ck_manager_open_session (CkManager      
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1437
         gboolean ret;
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
         sender = dbus_g_method_get_sender (context);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1440
-        ret = create_session_for_sender (manager, sender, NULL, context);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1441
+        ret = open_session_for_sender (manager, sender, NULL, context);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1442
         g_free (sender);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1443
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1444
         return ret;
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1445
@@ -1982,7 +2053,7 @@ ck_manager_open_session_with_parameters 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1446
         gboolean ret;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1447
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1448
         sender = dbus_g_method_get_sender (context);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1449
-        ret = create_session_for_sender (manager, sender, parameters, context);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1450
+        ret = open_session_for_sender (manager, sender, parameters, context);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1451
         g_free (sender);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1452
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1453
         return ret;
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1454
@@ -1999,10 +2070,12 @@ remove_session_for_cookie (CkManager  *m
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1455
         char            *sid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1456
         gboolean         res;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1457
         gboolean         ret;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1458
+        gboolean         should_remove_session;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1459
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1460
         ret = FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1461
         orig_ssid = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1462
         orig_session = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1463
+        should_remove_session = FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1464
 
21939
7d28343f0da4 Fix so patch applies.
yippi
parents: 21938
diff changeset
  1465
         g_debug ("Removing session for cookie: %s", cookie);
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1466
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1467
@@ -2029,6 +2102,17 @@ remove_session_for_cookie (CkManager  *m
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1468
                 goto out;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1469
         }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1470
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1471
+        ck_session_set_is_open (orig_session, FALSE, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1472
+        ck_session_set_cookie (orig_session, NULL, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1473
+        ck_session_set_active (orig_session, FALSE, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1474
+        ck_session_set_unix_user (orig_session, 0, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1475
+        ck_session_set_x11_display (orig_session, NULL, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1476
+        ck_session_set_x11_display_device (orig_session, NULL, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1477
+        ck_session_set_display_device (orig_session, NULL, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1478
+        ck_session_set_login_session_id (orig_session, NULL, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1479
+        ck_session_set_remote_host_name (orig_session, NULL, NULL);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1480
+        ck_session_set_under_request (orig_session, FALSE, NULL);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1481
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1482
         /* Must keep a reference to the session in the manager until
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1483
          * all events for seats are cleared.  So don't remove
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1484
          * or steal the session from the master list until
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1485
@@ -2036,31 +2120,33 @@ remove_session_for_cookie (CkManager  *m
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1486
          * for seat removals doesn't work.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1487
          */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1488
 
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1489
-        /* remove from seat */
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1490
-        sid = NULL;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1491
-        ck_session_get_seat_id (orig_session, &sid, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1492
-        if (sid != NULL) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1493
-                CkSeat *seat;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1494
-                seat = g_hash_table_lookup (manager->priv->seats, sid);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1495
-                if (seat != NULL) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1496
-                        CkSeatKind kind;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1497
-
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1498
-                        ck_seat_remove_session (seat, orig_session, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1499
-
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1500
-                        kind = CK_SEAT_KIND_STATIC;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1501
-                        /* if dynamic seat has no sessions then remove it */
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1502
-                        ck_seat_get_kind (seat, &kind, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1503
-                        if (kind == CK_SEAT_KIND_DYNAMIC) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1504
-                                remove_seat (manager, seat);
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  1505
+        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
  1506
+
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1507
+        if (should_remove_session) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1508
+                /* remove from seat */
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1509
+                g_debug ("CkManager: Should remove session");
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1510
+                sid = NULL;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1511
+                ck_session_get_seat_id (orig_session, &sid, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1512
+                if (sid != NULL) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1513
+                        CkSeat *seat;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1514
+                        seat = g_hash_table_lookup (manager->priv->seats, sid);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1515
+                        if (seat != NULL) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1516
+                                CkSeatKind kind;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1517
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1518
+                                ck_seat_remove_session (seat, orig_session, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1519
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1520
+                                kind = CK_SEAT_KIND_STATIC;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1521
+                                /* if dynamic seat has no sessions then remove it */
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1522
+                                ck_seat_get_kind (seat, &kind, NULL);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1523
                         }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1524
                 }
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1525
-        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1526
-        g_free (sid);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  1527
+                g_free (sid);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1528
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1529
-        /* Remove the session from the list but don't call
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1530
-         * unref until we are done with it */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1531
-        g_hash_table_steal (manager->priv->sessions,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1532
-                            ck_session_leader_peek_session_id (leader));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1533
+                /* Remove the session from the list but don't call
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1534
+                 * unref until we are done with it */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1535
+                g_hash_table_steal (manager->priv->sessions,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1536
+                                    ck_session_leader_peek_session_id (leader));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1537
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1538
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1539
         ck_manager_dump (manager);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1540
 
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1541
@@ -2068,11 +2154,13 @@ remove_session_for_cookie (CkManager  *m
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1542
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1543
         ret = TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1544
  out:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1545
-        if (orig_session != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1546
-                g_object_unref (orig_session);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1547
-        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1548
-        g_free (orig_ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1549
+        if (should_remove_session) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1550
+                if (orig_session != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1551
+                        g_object_unref (orig_session);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1552
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1553
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1554
+                g_free (orig_ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1555
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1556
         return ret;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1557
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1558
 
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1559
@@ -2193,6 +2281,7 @@ remove_leader_for_connection (const char
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1560
         g_assert (leader != NULL);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1561
         g_assert (data->service_name != NULL);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1562
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1563
+        g_debug ("CkManager: Remove leader for connection");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1564
         name = ck_session_leader_peek_service_name (leader);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1565
         if (strcmp (name, data->service_name) == 0) {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1566
                 remove_session_for_cookie (data->manager, cookie, NULL);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1567
@@ -2210,6 +2299,8 @@ remove_sessions_for_connection (CkManage
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1568
         guint            n_removed;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1569
         RemoveLeaderData data;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1570
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1571
+        g_debug ("CkManager: Remove sessions for connection");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1572
+
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1573
         data.service_name = service_name;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1574
         data.manager = manager;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1575
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1576
@@ -2245,6 +2336,8 @@ register_manager (CkManager *manager)
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1577
         manager->priv->pol_ctx = polkit_authority_get ();
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1578
 #endif
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1579
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1580
+        g_debug ("CkManager: Registering manager");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1581
+
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1582
         error = NULL;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1583
         manager->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1584
         if (manager->priv->connection == NULL) {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1585
@@ -2290,9 +2383,11 @@ ck_manager_class_init (CkManagerClass *k
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1586
                               G_STRUCT_OFFSET (CkManagerClass, seat_added),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1587
                               NULL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1588
                               NULL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1589
-                              g_cclosure_marshal_VOID__BOXED,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1590
+                              ck_marshal_VOID__STRING_STRING,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1591
                               G_TYPE_NONE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1592
-                              1, DBUS_TYPE_G_OBJECT_PATH);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1593
+                              2,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1594
+                              G_TYPE_STRING,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1595
+                              G_TYPE_STRING);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1596
         signals [SEAT_REMOVED] =
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1597
                 g_signal_new ("seat-removed",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1598
                               G_TYPE_FROM_CLASS (object_class),
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1599
@@ -2399,6 +2494,43 @@ ck_manager_get_seats (CkManager  *manage
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1600
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1601
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1602
 static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1603
+listify_unmanaged_seat_ids (char       *id,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1604
+                            CkSeat     *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1605
+                            GPtrArray **array)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1606
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1607
+        if (ck_seat_is_managed (seat)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1608
+                return;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1609
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1610
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1611
+        g_ptr_array_add (*array, g_strdup (id));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1612
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1613
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1614
+
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1615
+/*
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1616
+  Example:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1617
+  dbus-send --system --dest=org.freedesktop.ConsoleKit \
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1618
+  --type=method_call --print-reply --reply-timeout=2000 \
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1619
+  /org/freedesktop/ConsoleKit/Manager \
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1620
+  org.freedesktop.ConsoleKit.Manager.GetUnmanagedSeats
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1621
+*/
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1622
+gboolean
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1623
+ck_manager_get_unmanaged_seats (CkManager  *manager,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1624
+                                GPtrArray **seats,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1625
+                                GError    **error)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1626
+{
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1627
+        g_return_val_if_fail (CK_IS_MANAGER (manager), FALSE);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1628
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1629
+        if (seats == NULL) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1630
+                return FALSE;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1631
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1632
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1633
+        *seats = g_ptr_array_new ();
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1634
+        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
  1635
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1636
+        return TRUE;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1637
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1638
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1639
+static void
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1640
 listify_session_ids (char       *id,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  1641
                      CkSession  *session,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1642
                      GPtrArray **array)
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1643
@@ -2423,16 +2555,321 @@ ck_manager_get_sessions (CkManager  *man
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1644
         return TRUE;
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
 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1647
+/*
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1648
+  Example:
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1649
+  dbus-send --system --dest=org.freedesktop.ConsoleKit \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1650
+  --type=method_call --print-reply --reply-timeout=2000 \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1651
+  /org/freedesktop/ConsoleKit/Manager \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1652
+  org.freedesktop.ConsoleKit.Manager.AddSeat string:Default
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
+gboolean
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1655
+ck_manager_add_seat (CkManager  *manager,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1656
+                     const char *type,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1657
+                     char      **sid,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1658
+                     GError    **error)
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1659
+{
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1660
+        CkSeat    *seat;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1661
+                
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1662
+        g_debug ("CkManager: Add seat '%s'.", *sid);
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1663
+        g_return_val_if_fail (CK_IS_MANAGER (manager), FALSE);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1664
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1665
+        seat = add_new_seat (manager, NULL, CK_SEAT_KIND_DYNAMIC, type);
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
+        if (!ck_seat_get_id (seat, sid, error)) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1668
+                return FALSE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1669
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1670
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1671
+        return TRUE;
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
+
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
+  Example:
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1676
+  dbus-send --system --dest=org.freedesktop.ConsoleKit \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1677
+  --type=method_call --print-reply --reply-timeout=2000 \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1678
+  /org/freedesktop/ConsoleKit/Manager \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1679
+  org.freedesktop.ConsoleKit.Manager.AddSeatById \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1680
+  objpath:/org/freedesktop/ConsoleKit/SeatTest \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1681
+*/
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1682
+gboolean
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1683
+ck_manager_add_seat_by_id (CkManager  *manager,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1684
+                           const char *type,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1685
+                           const char *sid,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1686
+                           GError    **error) 
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
+        CkSeat    *seat;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1689
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1690
+        g_return_val_if_fail (CK_IS_MANAGER (manager), FALSE);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1691
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1692
+        seat = add_new_seat (manager, sid, CK_SEAT_KIND_DYNAMIC, type);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1693
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1694
+        return !(seat == NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1695
+}
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1696
+
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
+  Example:
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1699
+  dbus-send --system --dest=org.freedesktop.ConsoleKit \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1700
+  --type=method_call --print-reply --reply-timeout=2000 \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1701
+  /org/freedesktop/ConsoleKit/Manager \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1702
+  org.freedesktop.ConsoleKit.Manager.RemoveSeat \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1703
+  obj:/org/freedesktop/ConsoleKit/Seat2
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1704
+*/
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1705
+gboolean
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1706
+ck_manager_remove_seat (CkManager             *manager,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1707
+                        const char            *sid,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1708
+                        DBusGMethodInvocation *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
+        CkSeat     *seat = NULL;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1711
+        CkSeatKind kind;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1712
+
22037
6bbc65b301fa 2011-07-28 Brian Cameron <[email protected]>
yippi
parents: 21940
diff changeset
  1713
+        g_debug ("CkManager: Remove seat '%s'.", sid);
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1714
+        g_return_val_if_fail (CK_IS_MANAGER (manager), FALSE);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1715
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1716
+        seat = g_hash_table_lookup (manager->priv->seats, sid);
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
+        if (seat == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1719
+                GError *error;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1720
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1721
+                error = g_error_new (CK_SEAT_ERROR,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1722
+                                     CK_SEAT_ERROR_GENERAL,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1723
+                                     _("Seat '%s' doesn't exist"),
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1724
+                                     sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1725
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1726
+                dbus_g_method_return_error (context, error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1727
+                g_error_free (error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1728
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1729
+                return FALSE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1730
+        }
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
+        ck_seat_get_kind (seat, &kind, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1733
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1734
+        if (kind == CK_SEAT_KIND_STATIC) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1735
+                GError *error;
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
+                error = g_error_new (CK_SEAT_ERROR,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1738
+                                     CK_SEAT_ERROR_GENERAL,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1739
+                                     _("Seat '%s' is static and can't be removed"),
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1740
+                                     sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1741
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1742
+                dbus_g_method_return_error (context, error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1743
+                g_error_free (error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1744
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1745
+                return FALSE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1746
+        }
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
+        if (ck_seat_is_managed (seat)) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1749
+                ck_seat_request_removal (seat);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1750
+        } else {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1751
+                remove_seat (manager, seat);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1752
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1753
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1754
+        return TRUE;
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
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1757
+/*
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1758
+  Example:
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1759
+  dbus-send --system --dest=org.freedesktop.ConsoleKit \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1760
+  --type=method_call --print-reply --reply-timeout=2000 \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1761
+  /org/freedesktop/ConsoleKit/Manager \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1762
+  org.freedesktop.ConsoleKit.Manager.AddSession \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1763
+  objpath:/org/freedesktop/ConsoleKit/Seat2 \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1764
+  string:"LoginWindow" \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1765
+  dict:string:string:"vt","vt9","display",":123"
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1766
+*/
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1767
+gboolean
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1768
+ck_manager_add_session (CkManager             *manager,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1769
+                        const char            *sid,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1770
+                        const char            *type,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1771
+                        const char            *display_type,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1772
+                        GHashTable            *variables,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1773
+                        DBusGMethodInvocation *context)
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
+        CkSeat    *seat;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1776
+        CkSession *session;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1777
+        char      *ssid;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1778
+
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1779
+        g_debug ("CkManager: Add session");
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1780
+        seat = g_hash_table_lookup (manager->priv->seats, sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1781
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1782
+        if (seat == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1783
+                GError *error;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1784
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1785
+                error = g_error_new (CK_SEAT_ERROR,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1786
+                                     CK_SEAT_ERROR_GENERAL, 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1787
+                                     _("Seat '%s' doesn't exist"),
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1788
+                                     sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1789
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1790
+                dbus_g_method_return_error (context, error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1791
+                g_error_free (error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1792
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1793
+                return FALSE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1794
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1795
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1796
+        ssid = generate_session_id (manager);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1797
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1798
+        session = ck_session_new (ssid, type, display_type, variables);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1799
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1800
+        if (session == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1801
+                GError *error;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1802
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1803
+                error = g_error_new (CK_SEAT_ERROR, 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1804
+                                     CK_SEAT_ERROR_GENERAL,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1805
+                                     _("Session could not be added to seat '%s'"),
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1806
+                                     sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1807
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1808
+                dbus_g_method_return_error (context, error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1809
+                g_error_free (error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1810
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1811
+                return FALSE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1812
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1813
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1814
+        ck_session_set_seat_id (session, sid, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1815
+        if (IS_STR_SET (type) && g_str_equal (type, "LoginWindow")) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1816
+                session_set_remove_on_close (session, FALSE, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1817
+        } else {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1818
+                session_set_remove_on_close (session, TRUE, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1819
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1820
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1821
+        ck_seat_add_session (seat, session, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1822
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1823
+        g_hash_table_insert (manager->priv->sessions,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1824
+                             ssid,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1825
+                             session);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1826
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1827
+        dbus_g_method_return (context, ssid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1828
+        return TRUE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1829
+}
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1830
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1831
+/*
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1832
+  Example:
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1833
+  dbus-send --system --dest=org.freedesktop.ConsoleKit \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1834
+  --type=method_call --print-reply --reply-timeout=2000 \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1835
+  /org/freedesktop/ConsoleKit/Manager \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1836
+  org.freedesktop.ConsoleKit.Manager.RemoveSession \
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1837
+  objpath:/org/freedesktop/ConsoleKit/Session2
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1838
+*/
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1839
+gboolean
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1840
+ck_manager_remove_session (CkManager             *manager,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1841
+                           const char            *ssid,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1842
+                           DBusGMethodInvocation *context)
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1843
+{
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1844
+        CkSession *session;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1845
+        CkSeat *seat;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1846
+        GError *error; 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1847
+        char *sid;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1848
+        gboolean is_open;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1849
+
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1850
+        g_debug ("CkManager: Remove session.");
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1851
+        session = g_hash_table_lookup (manager->priv->sessions, ssid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1852
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1853
+        if (session == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1854
+                GError *error;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1855
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1856
+                error = g_error_new (CK_SEAT_ERROR,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1857
+                                     CK_SEAT_ERROR_GENERAL,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1858
+                                     _("Session '%s' doesn't exist"),
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1859
+                                     ssid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1860
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1861
+                dbus_g_method_return_error (context, error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1862
+                g_error_free (error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1863
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1864
+                return FALSE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1865
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1866
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1867
+        ck_session_get_seat_id (session, &sid, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1868
+        seat = g_hash_table_lookup (manager->priv->seats, sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1869
+        g_free (sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1870
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1871
+        if (seat == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1872
+                g_warning ("Session '%s' is not associated with a seat", ssid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1873
+                g_hash_table_remove (manager->priv->sessions, ssid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1874
+                return TRUE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1875
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1876
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1877
+        error = NULL;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1878
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1879
+        ck_session_is_open (session, &is_open, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1880
+        session_set_remove_on_close (session, TRUE, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1881
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1882
+        /* 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
  1883
+         */
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1884
+        if (ck_seat_is_managed (seat) && is_open) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1885
+                ck_seat_request_close_session (seat, session, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1886
+                dbus_g_method_return (context);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1887
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1888
+                return TRUE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1889
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1890
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1891
+        if (!ck_seat_remove_session (seat, session, &error)) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1892
+                if (error == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1893
+                        return TRUE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1894
+                }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1895
+                
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1896
+                dbus_g_method_return_error (context, error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1897
+                g_error_free (error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1898
+                return FALSE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1899
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1900
+        
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1901
+        g_hash_table_remove (manager->priv->sessions, ssid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1902
+        dbus_g_method_return (context);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1903
+        return TRUE;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1904
+}
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1905
+ 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1906
+static void
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1907
+add_sessions_from_seat (CkManager *manager,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1908
+                        CkSeat    *seat)
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1909
+{
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1910
+        GPtrArray *sessions;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1911
+        int i;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1912
+
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1913
+        g_debug ("CkManager: Add session from seat.");
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1914
+        ck_seat_get_sessions (seat, &sessions, NULL);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1915
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1916
+        for (i = 0; i < sessions->len; i++) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1917
+                char *ssid;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1918
+                CkSession *session; 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1919
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1920
+                ssid = g_ptr_array_index (sessions, i);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1921
+                session = ck_seat_get_session (seat, ssid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1922
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1923
+                g_hash_table_insert (manager->priv->sessions,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1924
+                                     ssid,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1925
+                                     session);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1926
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1927
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1928
+        g_ptr_array_free (sessions, TRUE);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1929
+}
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1930
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1931
 static void
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1932
 add_seat_for_file (CkManager  *manager,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1933
                    const char *filename)
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1934
 {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1935
         char   *sid;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1936
+        char   *orig_sid;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1937
         CkSeat *seat;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1938
 
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1939
+        g_debug ("CkManager: Add seat for file.");
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1940
         sid = generate_seat_id (manager);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1941
+        orig_sid = g_strdup (sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1942
+        seat = ck_seat_new_from_file (&sid, filename);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1943
 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1944
-        seat = ck_seat_new_from_file (sid, filename);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1945
+        if (seat == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1946
+                /* returns null if connection to bus fails */
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1947
+                g_free (sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1948
+                g_free (orig_sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1949
+                manager->priv->seat_serial--;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1950
+                return;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1951
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1952
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1953
+        if (!g_str_equal (orig_sid, sid)) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1954
+                manager->priv->seat_serial--;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1955
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1956
+        g_free (orig_sid);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1957
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1958
+        add_sessions_from_seat (manager, seat);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1959
+
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1960
+        if (seat == NULL) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1961
+                return;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1962
+        }
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1963
 
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1964
         connect_seat_signals (manager, seat);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  1965
         if (!ck_seat_register (seat)) {
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1966
@@ -2451,7 +2888,7 @@ add_seat_for_file (CkManager  *manager,
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1967
         ck_seat_run_programs (seat, NULL, NULL, "seat_added");
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1968
 
21939
7d28343f0da4 Fix so patch applies.
yippi
parents: 21938
diff changeset
  1969
         g_debug ("Emitting seat-added: %s", sid);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1970
-        g_signal_emit (manager, signals [SEAT_ADDED], 0, sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1971
+        g_signal_emit (manager, signals [SEAT_ADDED], 0, sid, "Default");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1972
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1973
         log_seat_added_event (manager, seat);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1974
 }
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1975
@@ -2462,6 +2899,7 @@ load_seats_from_dir (CkManager *manager)
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1976
         GDir       *d;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1977
         GError     *error;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1978
         const char *file;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1979
+        GQueue      seat_queue;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1980
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1981
         error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1982
         d = g_dir_open (CK_SEAT_DIR,
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  1983
@@ -2473,15 +2911,26 @@ load_seats_from_dir (CkManager *manager)
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1984
                 return FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1985
         }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1986
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1987
+        g_queue_init (&seat_queue);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1988
         while ((file = g_dir_read_name (d)) != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1989
                 char *path;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1990
                 path = g_build_filename (CK_SEAT_DIR, file, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1991
+                g_queue_push_tail (&seat_queue, path);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1992
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1993
+        g_dir_close (d);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1994
+
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  1995
+        g_queue_sort (&seat_queue, (GCompareDataFunc) strverscmp, NULL);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1996
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1997
+        while (!g_queue_is_empty (&seat_queue)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1998
+                char *path;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  1999
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2000
+                path = g_queue_pop_head (&seat_queue);
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
                 add_seat_for_file (manager, path);
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
                 g_free (path);
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
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2007
-        g_dir_close (d);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2008
-
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2009
         return TRUE;
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
 
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2012
@@ -2517,8 +2966,6 @@ ck_manager_init (CkManager *manager)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2013
                                                         (GDestroyNotify) g_object_unref);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2014
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2015
         manager->priv->logger = ck_event_logger_new (LOG_FILE);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2016
-
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2017
-        create_seats (manager);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2018
 }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2019
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2020
 static void
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2021
@@ -2563,6 +3010,8 @@ ck_manager_new (void)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2022
                         g_object_unref (manager_object);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2023
                         return NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2024
                 }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2025
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2026
+                create_seats (CK_MANAGER (manager_object));
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2027
         }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2028
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2029
         return CK_MANAGER (manager_object);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2030
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
  2031
index 4bd56e8..4304e71 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2032
--- a/src/ck-manager.h
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2033
+++ b/src/ck-manager.h
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2034
@@ -49,7 +49,8 @@ typedef struct
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2035
         GObjectClass   parent_class;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2036
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2037
         void          (* seat_added)               (CkManager  *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2038
-                                                    const char *sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2039
+                                                    const char *sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2040
+                                                    const char *type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2041
         void          (* seat_removed)             (CkManager  *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2042
                                                     const char *sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2043
         void          (* system_idle_hint_changed) (CkManager  *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2044
@@ -96,6 +97,9 @@ gboolean            ck_manager_get_sessions                   (CkManager
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2045
 gboolean            ck_manager_get_seats                      (CkManager             *manager,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2046
                                                                GPtrArray            **seats,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2047
                                                                GError               **error);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2048
+gboolean            ck_manager_get_unmanaged_seats            (CkManager             *manager,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2049
+                                                               GPtrArray            **seats,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2050
+                                                               GError               **error);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2051
 gboolean            ck_manager_close_session                  (CkManager             *manager,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2052
                                                                const char            *cookie,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2053
                                                                DBusGMethodInvocation *context);
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2054
@@ -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
  2055
                                                                const GPtrArray       *parameters,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2056
                                                                DBusGMethodInvocation *context);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2057
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2058
+gboolean            ck_manager_add_seat                       (CkManager             *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2059
+                                                               const char            *type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2060
+                                                               char                 **sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2061
+                                                               GError               **error);
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2062
+gboolean            ck_manager_add_seat_by_id                 (CkManager             *manager,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2063
+                                                               const char            *type,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2064
+                                                               const char            *sid,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2065
+                                                               GError               **error);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2066
+gboolean            ck_manager_remove_seat                    (CkManager             *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2067
+                                                               const char            *sid,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2068
+                                                               DBusGMethodInvocation *context);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2069
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2070
+gboolean            ck_manager_add_session                    (CkManager             *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2071
+                                                               const char            *sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2072
+                                                               const char            *type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2073
+                                                               const char            *display_type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2074
+                                                               GHashTable            *parameters,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2075
+                                                               DBusGMethodInvocation *context);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2076
+gboolean            ck_manager_remove_session                  (CkManager             *manager,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2077
+                                                                const char            *ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2078
+                                                                DBusGMethodInvocation *context);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2079
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2080
 G_END_DECLS
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2081
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2082
 #endif /* __CK_MANAGER_H */
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2083
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
  2084
index 7f60efc..f8029a6 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2085
--- a/src/ck-marshal.list
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2086
+++ b/src/ck-marshal.list
21493
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2087
@@ -1,3 +1,6 @@
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2088
 VOID:UINT,STRING
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2089
 BOOLEAN:POINTER
21493
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2090
 VOID:OBJECT,OBJECT
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2091
+VOID:STRING,STRING
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2092
+VOID:STRING,BOOLEAN,STRING,POINTER,STRING,POINTER
21493
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2093
+VOID:STRING,STRING,STRING,POINTER,STRING,POINTER
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2094
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
  2095
index af7db59..dd2a387 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2096
--- a/src/ck-seat.c
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2097
+++ b/src/ck-seat.c
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2098
@@ -40,21 +40,30 @@
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2099
 #include "ck-seat-glue.h"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2100
 #include "ck-marshal.h"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2101
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2102
+#include "ck-display-template.h"
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2103
 #include "ck-session.h"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2104
 #include "ck-vt-monitor.h"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2105
 #include "ck-run-programs.h"
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2106
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2107
 #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
  2108
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2109
+#define CK_SESSION_DIR SYSCONFDIR "/ConsoleKit/sessions.d"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2110
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2111
 #define CK_DBUS_PATH "/org/freedesktop/ConsoleKit"
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2112
 #define CK_DBUS_NAME "org.freedesktop.ConsoleKit"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2113
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2114
 #define NONULL_STRING(x) ((x) != NULL ? (x) : "")
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2115
+#define N_ELEMENTS(arr)  (sizeof (arr) / sizeof ((arr)[0]))
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2116
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2117
+#define IS_STR_SET(x) (x != NULL && x[0] != '\0')
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2118
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2119
+#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
  2120
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2121
 struct CkSeatPrivate
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2122
 {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2123
         char            *id;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2124
         CkSeatKind       kind;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2125
+        char            *type;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2126
         GHashTable      *sessions;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2127
         GPtrArray       *devices;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2128
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2129
@@ -63,6 +72,8 @@ struct CkSeatPrivate
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2130
         CkVtMonitor     *vt_monitor;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2131
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2132
         DBusGConnection *connection;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2133
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2134
+        DBusGProxy      *manager_proxy;
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
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2137
 enum {
21493
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2138
@@ -74,6 +85,9 @@ enum {
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2139
         SESSION_REMOVED_FULL,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2140
         DEVICE_ADDED,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2141
         DEVICE_REMOVED,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2142
+        REMOVE_REQUEST,
21493
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2143
+        OPEN_SESSION_REQUEST,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2144
+        CLOSE_SESSION_REQUEST,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2145
         LAST_SIGNAL
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2146
 };
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2147
 
21493
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2148
@@ -81,6 +95,7 @@ enum {
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2149
         PROP_0,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2150
         PROP_ID,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2151
         PROP_KIND,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2152
+        PROP_TYPE
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2153
 };
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2154
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2155
 static guint signals [LAST_SIGNAL] = { 0, };
21493
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2156
@@ -287,6 +302,7 @@ ck_seat_activate_session (CkSeat        
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2157
 {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2158
         CkSession *session;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2159
         gboolean   ret;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2160
+        gboolean   is_open;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2161
 
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2162
         g_return_val_if_fail (CK_IS_SEAT (seat), FALSE);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2163
 
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2164
@@ -298,12 +314,398 @@ ck_seat_activate_session (CkSeat        
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2165
                 session = g_hash_table_lookup (seat->priv->sessions, ssid);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2166
         }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2167
 
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2168
-        ret = _seat_activate_session (seat, session, context);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2169
+        ck_session_is_open (session, &is_open, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2170
+        if (!is_open) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2171
+                ret = ck_seat_request_open_session (seat, session, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2172
+                dbus_g_method_return (context, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2173
+        } else {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2174
+                ret = _seat_activate_session (seat, session, context);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2175
+        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2176
 
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2177
         return ret;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2178
 }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2179
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2180
 static gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2181
+on_substitution_match (const GMatchInfo *match_info,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2182
+                       GString          *result,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2183
+                       GHashTable       *substitution_variables)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2184
+{
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2185
+        char *match;
21751
93070d8a50d7 2011-04-29 Brian Cameron <[email protected]>
yippi
parents: 21493
diff changeset
  2186
+        char *value = NULL;
16232
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
+        match = g_match_info_fetch (match_info, 1);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2189
+
21751
93070d8a50d7 2011-04-29 Brian Cameron <[email protected]>
yippi
parents: 21493
diff changeset
  2190
+        if (substitution_variables != NULL)
93070d8a50d7 2011-04-29 Brian Cameron <[email protected]>
yippi
parents: 21493
diff changeset
  2191
+                value = g_hash_table_lookup (substitution_variables, match);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2192
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2193
+        if (value != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2194
+                g_string_append (result, value);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2195
+        } else {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2196
+                char *original_string;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2197
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2198
+                original_string = g_match_info_fetch (match_info, 0);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2199
+                g_string_append (result, original_string);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2200
+                g_free (original_string);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2201
+        }
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2202
+        g_free (match);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2203
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2204
+        return FALSE;
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
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2207
+static char *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2208
+apply_substitutions (const char *value,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2209
+                     GHashTable *substitution_variables)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2210
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2211
+        GRegex *expression;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2212
+        char *expanded_string;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2213
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2214
+        expression = g_regex_new ("\\$([^[:space:]]+)", 0, 0, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2215
+        expanded_string = g_regex_replace_eval (expression,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2216
+                                                value,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2217
+                                                -1, 0, 0,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2218
+                                                (GRegexEvalCallback)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2219
+                                                on_substitution_match,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2220
+                                                substitution_variables,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2221
+                                                NULL);
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
+        if (expanded_string == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2224
+                expanded_string = g_strdup (value);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2225
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2226
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2227
+        return expanded_string;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2228
+}
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2229
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2230
+static GHashTable *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2231
+get_evaluated_parameter_map (GHashTable    *parameters,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2232
+                             GHashTable    *substitution_variables)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2233
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2234
+        GHashTable *evaluated_parameters;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2235
+        GHashTableIter iter;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2236
+        gpointer key, value;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2237
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2238
+        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
  2239
+                                                      (GDestroyNotify) g_free,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2240
+                                                      (GDestroyNotify) g_free);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2241
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2242
+        g_hash_table_iter_init (&iter, parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2243
+        while (g_hash_table_iter_next (&iter, &key, &value)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2244
+                char *expanded_string;
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
+                expanded_string = apply_substitutions ((char *) value,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2247
+                                                       substitution_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2248
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2249
+                g_hash_table_insert (evaluated_parameters,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2250
+                                     g_strdup ((char *) key),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2251
+                                     expanded_string);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2252
+        }
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
+        return evaluated_parameters;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2255
+}
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2256
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2257
+static void
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2258
+request_session (gpointer key,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2259
+                 gpointer value,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2260
+                 gpointer user_data)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2261
+{
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2262
+        CkSeat      *seat = CK_SEAT (user_data);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2263
+        CkSession   *session = (CkSession *) value;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2264
+
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2265
+        g_debug ("CkSeat: Request session");
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  2266
+        ck_session_set_ever_open (session, FALSE, NULL);
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  2267
+        ck_session_set_under_request (session, FALSE, NULL);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2268
+        ck_seat_request_open_session (seat, session, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2269
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2270
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2271
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2272
+append_hash_table_to_dbus_message_iter (DBusMessageIter *iter,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2273
+                                        GHashTable      *hash_table)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2274
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2275
+        GHashTableIter hash_table_iter;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2276
+        gpointer key, value;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2277
+        DBusMessageIter array_iter;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2278
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2279
+        dbus_message_iter_open_container (iter,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2280
+                                          DBUS_TYPE_ARRAY,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2281
+                                          DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2282
+                                          DBUS_TYPE_STRING_AS_STRING
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2283
+                                          DBUS_TYPE_STRING_AS_STRING
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2284
+                                          DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2285
+                                          &array_iter);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2286
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2287
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2288
+        g_hash_table_iter_init (&hash_table_iter, hash_table);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2289
+        while (g_hash_table_iter_next (&hash_table_iter, &key, &value)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2290
+                DBusMessageIter dict_iter;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2291
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2292
+                dbus_message_iter_open_container (&array_iter,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2293
+                                                  DBUS_TYPE_DICT_ENTRY,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2294
+                                                  NULL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2295
+                                                  &dict_iter);
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_message_iter_append_basic (&dict_iter, DBUS_TYPE_STRING, &key);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2298
+                dbus_message_iter_append_basic (&dict_iter, DBUS_TYPE_STRING, &value);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2299
+                dbus_message_iter_close_container (&array_iter, &dict_iter);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2300
+        }
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2301
+        dbus_message_iter_close_container (iter, &array_iter);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2302
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2303
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2304
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2305
+emit_session_open_request (CkSeat     *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2306
+                          const char *ssid,
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2307
+                          const char *session_type,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2308
+                          const char *display_template_name,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2309
+                          GHashTable *display_variables,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2310
+                          const char *display_type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2311
+                          GHashTable *evaluated_parameters)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2312
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2313
+        DBusMessage    *message;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2314
+        DBusConnection *connection;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2315
+        DBusMessageIter iter;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2316
+
17338
0c396fbcf0fa 2010-01-14 Halton Huo <[email protected]>
halton
parents: 17046
diff changeset
  2317
+        if (!ck_seat_is_managed (seat))
0c396fbcf0fa 2010-01-14 Halton Huo <[email protected]>
halton
parents: 17046
diff changeset
  2318
+                return;
0c396fbcf0fa 2010-01-14 Halton Huo <[email protected]>
halton
parents: 17046
diff changeset
  2319
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2320
+        message = dbus_message_new_signal (seat->priv->id,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2321
+                                           "org.freedesktop.ConsoleKit.Seat",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2322
+                                           "OpenSessionRequest");
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
+        dbus_message_set_destination (message,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2325
+                                      dbus_g_proxy_get_bus_name (seat->priv->manager_proxy));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2326
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2327
+        dbus_message_iter_init_append (message, &iter);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2328
+        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
  2329
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session_type);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2330
+        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
  2331
+        append_hash_table_to_dbus_message_iter (&iter, display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2332
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2333
+        append_hash_table_to_dbus_message_iter (&iter, evaluated_parameters);
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
+        connection = dbus_bus_get (DBUS_BUS_SYSTEM, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2336
+        dbus_connection_send (connection, message, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2337
+        dbus_connection_unref (connection);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2338
+        dbus_message_unref (message);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2339
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2340
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2341
+gboolean
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2342
+ck_seat_request_open_session (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2343
+                              CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2344
+                              GError               **error)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2345
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2346
+        char        *ssid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2347
+        char        *type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2348
+        CkDisplayTemplate *display_template;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2349
+        GHashTable  *display_variables;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2350
+        GHashTable  *display_parameters;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2351
+        GHashTable  *evaluated_parameters;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2352
+        gboolean    is_open;
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2353
+        gboolean    ever_open;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2354
+        gboolean    under_request;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2355
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2356
+        ck_session_is_open (session, &is_open, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2357
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2358
+        if (is_open) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2359
+                return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2360
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2361
+
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2362
+        ck_session_get_under_request (session, &under_request, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2363
+        if (under_request) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2364
+                return TRUE;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2365
+        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2366
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2367
+        ck_session_set_under_request (session, TRUE, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2368
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2369
+        ck_session_get_ever_open (session, &ever_open, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2370
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2371
+        display_template = ck_session_get_display_template (session);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2372
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2373
+        if (display_template == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2374
+                return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2375
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2376
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2377
+        ck_session_get_session_type (session, &type, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2378
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2379
+        if (type == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2380
+                g_object_unref (display_template);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2381
+                return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2382
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2383
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2384
+        /* substitute $display $vt etc */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2385
+        display_variables = ck_session_get_display_variables (session);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2386
+        display_parameters = ck_display_template_get_parameters (display_template);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2387
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2388
+        if (display_parameters == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2389
+                g_free (type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2390
+                g_object_unref (display_template);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2391
+                g_hash_table_unref (display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2392
+                return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2393
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2394
+
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2395
+        if (!ever_open) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2396
+                evaluated_parameters = get_evaluated_parameter_map (display_parameters, display_variables);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2397
+        } else {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2398
+                evaluated_parameters = get_evaluated_parameter_map (display_parameters, NULL);
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
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2401
+        g_hash_table_unref (display_parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2402
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2403
+        ck_session_get_id (session, &ssid, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2404
+
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2405
+        emit_session_open_request (seat, ssid, type,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2406
+                                   ck_display_template_get_name (display_template),
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  2407
+                                   display_variables,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2408
+                                   ck_display_template_get_type_string (display_template),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2409
+                                   evaluated_parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2410
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2411
+        g_free (ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2412
+        g_free (type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2413
+        g_hash_table_unref (evaluated_parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2414
+        g_hash_table_unref (display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2415
+        g_object_unref (display_template);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2416
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2417
+        return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2418
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2419
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2420
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2421
+on_seat_manager_disappeared (CkSeat *seat)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2422
+{
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2423
+        g_debug ("CkSeat: Seat Manager Disappeared.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2424
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2425
+        g_signal_handlers_disconnect_by_func (seat->priv->manager_proxy,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2426
+                                              G_CALLBACK (on_seat_manager_disappeared),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2427
+                                              seat);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2428
+        g_object_unref (seat->priv->manager_proxy);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2429
+        seat->priv->manager_proxy = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2430
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2431
+        /* FIXME: should probably emit a signal so a new display manager
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2432
+         * knows that the seat is now unmanaged
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2433
+         *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2434
+         * (maybe only if its kind is static?)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2435
+         */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2436
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2437
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2438
+gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2439
+ck_seat_manage (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2440
+                DBusGMethodInvocation *context)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2441
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2442
+        char *sender_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2443
+
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2444
+        g_debug ("CkSeat: Seat manage.");
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2445
+        sender_name = dbus_g_method_get_sender (context);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2446
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2447
+        if (seat->priv->manager_proxy != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2448
+                GError *error;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2449
+                const char   *existing_manager_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2450
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2451
+                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
  2452
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2453
+                if (existing_manager_name == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2454
+                        g_warning ("Seat manager lacks bus unique name");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2455
+                        existing_manager_name = "<unknown>";
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2456
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2457
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2458
+                error = g_error_new (CK_SEAT_ERROR,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2459
+                                     CK_SEAT_ERROR_GENERAL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2460
+                                     _("Seat already managed (by '%s')"),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2461
+                                     existing_manager_name);
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
+                dbus_g_method_return_error (context, error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2464
+                g_error_free (error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2465
+                return FALSE;
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
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2468
+        /* 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
  2469
+         * the pipe) and interface here.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2470
+         *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2471
+         * 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
  2472
+         * for communicating with it.  All communication is one-way using signals.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2473
+         */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2474
+        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
  2475
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2476
+                                                               sender_name,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2477
+                                                               seat->priv->id,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2478
+                                                               "org.freedesktop.ConsoleKit.SeatManager");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2479
+        g_free (sender_name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2480
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2481
+        g_signal_connect_swapped (seat->priv->manager_proxy,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2482
+                                  "destroy",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2483
+                                  G_CALLBACK (on_seat_manager_disappeared),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2484
+                                  seat);
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_hash_table_foreach (seat->priv->sessions, request_session, seat);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2487
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2488
+        dbus_g_method_return (context);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2489
+        return TRUE;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2490
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2491
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2492
+gboolean
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2493
+ck_seat_unmanage (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2494
+                  DBusGMethodInvocation *context)
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
+        GError *error;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2497
+        const char   *existing_manager_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2498
+        char *sender_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2499
+
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2500
+        g_debug ("CkSeat: Seat unmanage.");
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2501
+        if (seat->priv->manager_proxy == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2502
+                GError *error;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2503
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2504
+                error = g_error_new (CK_SEAT_ERROR,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2505
+                                     CK_SEAT_ERROR_GENERAL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2506
+                                     _("Seat not managed"));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2507
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2508
+                dbus_g_method_return_error (context, error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2509
+                g_error_free (error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2510
+                return FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2511
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2512
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2513
+        sender_name = dbus_g_method_get_sender (context);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2514
+        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
  2515
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2516
+        if (strcmp (sender_name, existing_manager_name) != 0) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2517
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2518
+            error = g_error_new (CK_SEAT_ERROR,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2519
+                                 CK_SEAT_ERROR_GENERAL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2520
+                                 _("Seat managed by '%s' not '%s'"),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2521
+                                 existing_manager_name,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2522
+                                 sender_name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2523
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2524
+            dbus_g_method_return_error (context, error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2525
+            g_error_free (error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2526
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2527
+            return FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2528
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2529
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2530
+        on_seat_manager_disappeared (seat);
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
+        dbus_g_method_return (context);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2533
+        return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2534
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2535
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2536
+void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2537
+ck_seat_request_removal (CkSeat *seat)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2538
+{
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2539
+        DBusMessage    *message;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2540
+        DBusConnection *connection;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2541
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2542
+        g_return_if_fail (CK_IS_SEAT (seat));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2543
+        g_return_if_fail (ck_seat_is_managed (seat));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2544
+
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2545
+        g_debug ("CkSeat: Seat request removal.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2546
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2547
+        message = dbus_message_new_signal (seat->priv->id,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2548
+                                           "org.freedesktop.ConsoleKit.Seat",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2549
+                                           "RemoveRequest");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2550
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2551
+        dbus_message_set_destination (message,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2552
+                                      dbus_g_proxy_get_bus_name (seat->priv->manager_proxy));
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
+        connection = dbus_bus_get (DBUS_BUS_SYSTEM, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2555
+        dbus_connection_send (connection, message, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2556
+        dbus_connection_unref (connection);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2557
+        dbus_message_unref (message);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2558
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2559
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2560
+static gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2561
 match_session_display_device (const char *key,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2562
                               CkSession  *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2563
                               const char *display_device)
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2564
@@ -314,6 +716,8 @@ match_session_display_device (const char
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2565
         device = NULL;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2566
         ret = FALSE;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2567
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2568
+        g_debug ("CkSeat: Session display device.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2569
+
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2570
         if (session == NULL) {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2571
                 goto out;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2572
         }
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2573
@@ -486,6 +890,8 @@ change_active_session (CkSeat    *seat,
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2574
         char      *ssid;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2575
         CkSession *old_session;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2576
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2577
+        g_debug ("CkSeat: Change active session.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2578
+
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2579
         if (seat->priv->active_session == session) {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2580
                 return;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2581
         }
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2582
@@ -515,7 +921,10 @@ change_active_session (CkSeat    *seat,
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2583
          * must be sent when the database dump is finished it is
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2584
          * important that the '-full' signalled is emitted first. */
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2585
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2586
-        g_signal_emit (seat, signals [ACTIVE_SESSION_CHANGED_FULL], 0, old_session, session);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2587
+        if (CK_IS_SESSION (old_session)) {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2588
+                g_signal_emit (seat, signals [ACTIVE_SESSION_CHANGED_FULL], 0, old_session, session);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2589
+        }
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2590
+
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2591
         g_signal_emit (seat, signals [ACTIVE_SESSION_CHANGED], 0, ssid);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2592
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2593
         if (old_session != NULL) {
21940
435c776c0f32 Another minor fix to correct an issue with a new debug statement found in testing.
yippi
parents: 21939
diff changeset
  2594
@@ -526,18 +935,59 @@ change_active_session (CkSeat    *seat,
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2595
 }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2596
 
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2597
 static void
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2598
+find_possible_session_to_activate (CkSeat *seat)
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2599
+{
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2600
+        GHashTableIter iter;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2601
+        gpointer       key, value;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2602
+        gboolean       is_open;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2603
+        char          *session_type = NULL;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2604
+        CkSession     *login_session = NULL;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2605
+
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2606
+        g_debug ("CkSeat: Find possible session to activate");
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2607
+        g_hash_table_iter_init (&iter, seat->priv->sessions);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2608
+        while (g_hash_table_iter_next (&iter, &key, &value)) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2609
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2610
+                ck_session_is_open (value, &is_open, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2611
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2612
+                if (is_open) {
17996
2d7a4bd8daaf 2010-05-18 Halton Huo <[email protected]>
halton
parents: 17862
diff changeset
  2613
+                        login_session = NULL;
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2614
+                        change_active_session (seat, value);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2615
+                        break;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2616
+                }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2617
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2618
+                ck_session_get_session_type (value, &session_type, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2619
+                if (IS_STR_SET (session_type) &&
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2620
+                    g_str_equal (session_type, "LoginWindow")) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2621
+                        login_session = value;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2622
+                        g_free (session_type);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2623
+                }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2624
+        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2625
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2626
+        if (login_session != NULL) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2627
+                ck_session_set_ever_open (login_session, FALSE, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2628
+                ck_seat_request_open_session (seat, login_session, NULL);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2629
+        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2630
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2631
+}
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2632
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2633
+static void
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2634
 update_active_vt (CkSeat *seat,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2635
                   guint   num)
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2636
 {
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2637
         CkSession *session;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2638
         char      *device;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2639
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2640
         device = ck_get_console_device_for_num (num);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2641
 
21939
7d28343f0da4 Fix so patch applies.
yippi
parents: 21938
diff changeset
  2642
         g_debug ("Active device: %s", device);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2643
 
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2644
         session = find_session_for_display_device (seat, device);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2645
-        change_active_session (seat, session);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2646
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2647
+        if (session == NULL) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2648
+                find_possible_session_to_activate (seat);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2649
+        } else {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2650
+                change_active_session (seat, session);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2651
+        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2652
 
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2653
         g_free (device);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  2654
 }
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2655
@@ -547,12 +998,20 @@ maybe_update_active_session (CkSeat *sea
17046
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2656
 {
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2657
         guint num;
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2658
 
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2659
-        if (seat->priv->kind != CK_SEAT_KIND_STATIC) {
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2660
-                return;
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2661
-        }
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2662
+        g_debug ("CkSeat: Check to see if we should update active session");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2663
 
17046
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2664
-        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
  2665
-                update_active_vt (seat, num);
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2666
+        switch (seat->priv->kind){
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2667
+        case CK_SEAT_KIND_STATIC:
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2668
+                if (ck_vt_monitor_get_active (seat->priv->vt_monitor,
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2669
+                                              &num, NULL)) {
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2670
+                        update_active_vt (seat, num);
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2671
+                }
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2672
+                break;
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2673
+        case CK_SEAT_KIND_DYNAMIC:
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2674
+                find_possible_session_to_activate (seat);
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2675
+                break;
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2676
+        default:
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2677
+                break;
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2678
         }
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2679
 }
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  2680
 
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2681
@@ -561,6 +1020,7 @@ session_activate (CkSession             
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2682
                   DBusGMethodInvocation *context,
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2683
                   CkSeat                *seat)
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2684
 {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2685
+        g_debug ("CkSeat: Session activate.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2686
         _seat_activate_session (seat, session, context);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2687
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2688
         /* always return TRUE to indicate that the signal was handled */
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2689
@@ -584,6 +1044,8 @@ ck_seat_remove_session (CkSeat         *
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2690
         ssid = NULL;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2691
         ck_session_get_id (session, &ssid, NULL);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2692
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2693
+        g_debug ("CkSeat: Removing session '%s'", ssid);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2694
+
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2695
         /* Need to get the original key/value */
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2696
         res = g_hash_table_lookup_extended (seat->priv->sessions,
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2697
                                             ssid,
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2698
@@ -628,18 +1090,81 @@ ck_seat_remove_session (CkSeat         *
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2699
         return ret;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2700
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2701
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2702
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2703
+emit_session_close_request (CkSeat     *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2704
+                            const char *ssid)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2705
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2706
+        DBusMessage    *message;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2707
+        DBusConnection *connection;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2708
+        DBusMessageIter iter;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2709
+
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2710
+        g_debug ("CkSeat: Emit Session Close request");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2711
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2712
+        message = dbus_message_new_signal (seat->priv->id,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2713
+                                           "org.freedesktop.ConsoleKit.Seat",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2714
+                                           "CloseSessionRequest");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2715
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2716
+        dbus_message_set_destination (message,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2717
+                                      dbus_g_proxy_get_bus_name (seat->priv->manager_proxy));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2718
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2719
+        dbus_message_iter_init_append (message, &iter);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2720
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_OBJECT_PATH, &ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2721
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2722
+        connection = dbus_bus_get (DBUS_BUS_SYSTEM, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2723
+        dbus_connection_send (connection, message, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2724
+        dbus_connection_unref (connection);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2725
+        dbus_message_unref (message);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2726
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2727
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2728
+gboolean
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2729
+ck_seat_request_close_session (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2730
+                               CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2731
+                               GError               **error)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2732
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2733
+        char      *ssid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2734
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2735
+        g_return_val_if_fail (CK_IS_SEAT (seat), FALSE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2736
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2737
+        g_return_val_if_fail (ck_seat_is_managed (seat), FALSE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2738
+
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2739
+        g_debug ("CkSeat: Request close session.");
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2740
+        ck_session_get_id (session, &ssid, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2741
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2742
+        emit_session_close_request (seat, ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2743
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2744
+        g_free (ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2745
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2746
+        return FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2747
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2748
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2749
 gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2750
 ck_seat_add_session (CkSeat         *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2751
                      CkSession      *session,
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2752
                      GError        **error)
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2753
 {
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2754
         char *ssid;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2755
+        GHashTableIter iter;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2756
+        gpointer key, value;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2757
+        gboolean found;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2758
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2759
         g_return_val_if_fail (CK_IS_SEAT (seat), FALSE);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2760
 
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2761
+        g_debug ("CkSeat: Add session.");
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2762
         ck_session_get_id (session, &ssid, NULL);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2763
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2764
-        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
  2765
+        found = FALSE;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2766
+        g_hash_table_iter_init (&iter, seat->priv->sessions);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2767
+        while (g_hash_table_iter_next (&iter, &key, &value)) {
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2768
+                if (g_str_equal ((gchar *)key, ssid)) {
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2769
+                        found = TRUE;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2770
+                        break;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2771
+                }
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2772
+        }
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2773
+
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2774
+        if (! found)
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2775
+                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
  2776
+        else
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2777
+                g_object_ref (session);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2778
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2779
         ck_session_set_seat_id (session, seat->priv->id, NULL);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  2780
 
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2781
@@ -656,6 +1181,10 @@ ck_seat_add_session (CkSeat         *sea
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2782
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2783
         maybe_update_active_session (seat);
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
+        if (ck_seat_is_managed (seat)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2786
+                ck_seat_request_open_session (seat, session, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2787
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2788
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2789
         g_free (ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2790
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2791
         return TRUE;
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2792
@@ -742,6 +1271,20 @@ ck_seat_get_kind (CkSeat        *seat,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2793
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2794
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2795
 gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2796
+ck_seat_get_type_string (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2797
+                         char                 **type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2798
+                         GError               **error)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2799
+{
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2800
+        g_return_val_if_fail (CK_IS_SEAT (seat), FALSE);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2801
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2802
+        if (type != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2803
+                *type = g_strdup (seat->priv->type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2804
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2805
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2806
+        return TRUE;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2807
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2808
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2809
+gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2810
 ck_seat_get_id (CkSeat         *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2811
                 char          **id,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2812
                 GError        **error)
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2813
@@ -771,6 +1314,7 @@ ck_seat_register (CkSeat *seat)
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2814
         GError *error = NULL;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2815
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2816
         error = NULL;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2817
+        g_debug ("CkSeat: Register seat.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2818
         seat->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2819
         if (seat->priv->connection == NULL) {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2820
                 if (error != NULL) {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2821
@@ -858,6 +1402,14 @@ _ck_seat_set_kind (CkSeat    *seat,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2822
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2823
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2824
 static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2825
+_ck_seat_set_type_string (CkSeat         *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2826
+                          const char     *type)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2827
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2828
+        g_free (seat->priv->type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2829
+        seat->priv->type = g_strdup (type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2830
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2831
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2832
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2833
 ck_seat_set_property (GObject            *object,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2834
                       guint               prop_id,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2835
                       const GValue       *value,
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2836
@@ -874,6 +1426,9 @@ ck_seat_set_property (GObject           
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2837
         case PROP_KIND:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2838
                 _ck_seat_set_kind (self, g_value_get_enum (value));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2839
                 break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2840
+        case PROP_TYPE:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2841
+                _ck_seat_set_type_string (self, g_value_get_string (value));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2842
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2843
         default:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2844
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2845
                 break;
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2846
@@ -895,7 +1450,10 @@ ck_seat_get_property (GObject    *object
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2847
                 g_value_set_string (value, self->priv->id);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2848
                 break;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2849
         case PROP_KIND:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2850
-                g_value_set_string (value, self->priv->id);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2851
+                g_value_set_enum (value, self->priv->kind);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2852
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2853
+        case PROP_TYPE:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2854
+                g_value_set_string (value, self->priv->type);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2855
                 break;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2856
         default:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2857
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2858
@@ -1008,6 +1566,43 @@ ck_seat_class_init (CkSeatClass *klass)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2859
                                                  G_TYPE_NONE,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2860
                                                  1, CK_TYPE_DEVICE);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2861
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2862
+        signals [REMOVE_REQUEST] = g_signal_new ("remove-request",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2863
+                                                  G_TYPE_FROM_CLASS (object_class),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2864
+                                                  G_SIGNAL_RUN_LAST,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2865
+                                                  G_STRUCT_OFFSET (CkSeatClass, remove_request),
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2866
+                                                  NULL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2867
+                                                  NULL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2868
+                                                  g_cclosure_marshal_VOID__VOID,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2869
+                                                  G_TYPE_NONE, 0);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2870
+
21493
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2871
+        signals [OPEN_SESSION_REQUEST] = g_signal_new ("open-session-request",
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2872
+                                                       G_TYPE_FROM_CLASS (object_class),
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2873
+                                                       G_SIGNAL_RUN_LAST,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2874
+                                                       0,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2875
+                                                       NULL,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2876
+                                                       NULL,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2877
+                                                       ck_marshal_VOID__STRING_STRING_STRING_POINTER_STRING_POINTER,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2878
+                                                       G_TYPE_NONE,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2879
+                                                       6,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2880
+                                                       DBUS_TYPE_G_OBJECT_PATH,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2881
+                                                       G_TYPE_STRING,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2882
+                                                       G_TYPE_STRING,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2883
+                                                       CK_DBUS_TYPE_G_STRING_STRING_HASHTABLE,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2884
+                                                       G_TYPE_STRING,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2885
+                                                       CK_DBUS_TYPE_G_STRING_STRING_HASHTABLE,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2886
+                                                       G_TYPE_INVALID);
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2887
+
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2888
+
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2889
+        signals [CLOSE_SESSION_REQUEST] = g_signal_new ("close-session-request",
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2890
+                                                        G_TYPE_FROM_CLASS (object_class),
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2891
+                                                        G_SIGNAL_RUN_LAST,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2892
+                                                        0,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2893
+                                                        NULL,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2894
+                                                        NULL,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2895
+                                                        g_cclosure_marshal_VOID__VOID,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2896
+                                                        G_TYPE_NONE,
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2897
+                                                        1, DBUS_TYPE_G_OBJECT_PATH);
2c2f10c95207 2011-02-23 Brian Cameron <[email protected]>
yippi
parents: 20076
diff changeset
  2898
+
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2899
         g_object_class_install_property (object_class,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2900
                                          PROP_ID,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2901
                                          g_param_spec_string ("id",
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2902
@@ -1024,6 +1619,13 @@ ck_seat_class_init (CkSeatClass *klass)
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2903
                                                             CK_SEAT_KIND_DYNAMIC,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2904
                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2905
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2906
+        g_object_class_install_property (object_class,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2907
+                                         PROP_TYPE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2908
+                                         g_param_spec_string ("type",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2909
+                                                              "type",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2910
+                                                              "type",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2911
+                                                              NULL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2912
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2913
         g_type_class_add_private (klass, sizeof (CkSeatPrivate));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2914
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2915
         dbus_g_object_type_install_info (CK_TYPE_SEAT, &dbus_glib_ck_seat_object_info);
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2916
@@ -1039,6 +1641,7 @@ ck_seat_init (CkSeat *seat)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2917
                                                       g_free,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2918
                                                       (GDestroyNotify) g_object_unref);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2919
         seat->priv->devices = g_ptr_array_new ();
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2920
+        seat->priv->manager_proxy = NULL;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2921
 }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2922
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2923
 static void
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2924
@@ -1064,28 +1667,32 @@ ck_seat_finalize (GObject *object)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2925
         g_ptr_array_free (seat->priv->devices, TRUE);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2926
         g_hash_table_destroy (seat->priv->sessions);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2927
         g_free (seat->priv->id);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2928
+        g_free (seat->priv->type);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2929
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2930
         G_OBJECT_CLASS (ck_seat_parent_class)->finalize (object);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2931
 }
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2932
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2933
 CkSeat *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2934
 ck_seat_new (const char *sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2935
-             CkSeatKind  kind)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2936
+             CkSeatKind  kind,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2937
+             const char *type)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2938
 {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2939
         GObject *object;
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2940
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2941
         object = g_object_new (CK_TYPE_SEAT,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2942
                                "id", sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2943
                                "kind", kind,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2944
+                               "type", type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2945
                                NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2946
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2947
         return CK_SEAT (object);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2948
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2949
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2950
 CkSeat *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2951
-ck_seat_new_with_devices (const char *sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2952
-                          CkSeatKind  kind,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2953
-                          GPtrArray  *devices)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2954
+ck_seat_new_with_devices_and_sessions (const char *sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2955
+                                       CkSeatKind  kind,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2956
+                                       GPtrArray  *devices,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2957
+                                       GPtrArray  *sessions)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2958
 {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2959
         GObject *object;
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2960
         int      i;
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  2961
@@ -1100,27 +1707,62 @@ ck_seat_new_with_devices (const char *si
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2962
                         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
  2963
                 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2964
         }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2965
+        if (sessions != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2966
+                for (i = 0; i < sessions->len; i++) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2967
+                        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
  2968
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2969
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2970
+
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2971
 
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2972
         return CK_SEAT (object);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2973
 }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2974
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2975
+static char *
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2976
+generate_static_session_id (const char *sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2977
+                            const char *session_name)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2978
+{
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2979
+        const char *seat_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2980
+        char *ssid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2981
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2982
+        seat_name = strrchr (sid, '/');
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2983
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2984
+        if (seat_name == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2985
+                g_warning ("Seat id '%s' lacks a /", sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2986
+                seat_name = sid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2987
+        } else {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2988
+                seat_name++;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2989
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2990
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2991
+        ssid = g_strdup_printf ("%s/Session%s%s",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2992
+                                CK_DBUS_PATH, seat_name,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2993
+                                session_name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2994
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  2995
+        return ssid;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2996
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2997
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  2998
 CkSeat *
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  2999
-ck_seat_new_from_file (const char *sid,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3000
+ck_seat_new_from_file (char       **sid,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3001
                        const char *path)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3002
 {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3003
-        GKeyFile  *key_file;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3004
-        gboolean   res;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3005
-        GError    *error;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3006
-        char      *group;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3007
-        CkSeat    *seat;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3008
-        gboolean   hidden;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3009
-        GPtrArray *devices;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3010
-        char     **device_list;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3011
-        gsize      ndevices;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3012
-        gsize      i;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3013
+        GKeyFile      *key_file;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3014
+        gboolean       res;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3015
+        GError        *error;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3016
+        char          *group;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3017
+        CkSeat        *seat;
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3018
+        char          *read_sid;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3019
+        gboolean       hidden;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3020
+        GPtrArray     *sessions;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3021
+        char         **session_list;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3022
+        gsize          nsessions;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3023
+        GPtrArray     *devices;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3024
+        char         **device_list;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3025
+        gsize          ndevices;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3026
+        gsize          i;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3027
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3028
         seat = NULL;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3029
 
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3030
+        g_debug ("CkSeat: New seat from file.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3031
+
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3032
         key_file = g_key_file_new ();
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3033
         error = NULL;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3034
         res = g_key_file_load_from_file (key_file,
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3035
@@ -1145,9 +1787,52 @@ ck_seat_new_from_file (const char *sid,
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3036
                 goto out;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3037
         }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3038
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3039
+        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
  3040
+        if (IS_STR_SET (read_sid)) {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3041
+                g_free (*sid);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3042
+                *sid = g_strdup_printf ("%s/%s", CK_DBUS_PATH, read_sid);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3043
+        } else {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3044
+                g_free (read_sid);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3045
+        }
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3046
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3047
+        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
  3048
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3049
+        sessions = g_ptr_array_sized_new (nsessions);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3050
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3051
+        for (i = 0; i < nsessions; i++) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3052
+                char *path;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3053
+                char *file;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3054
+                char *ssid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3055
+                CkSession *session;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3056
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3057
+                file = g_strconcat (session_list[i], ".session", NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3058
+                path = g_build_filename (CK_SESSION_DIR, file, NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3059
+                g_free (file);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3060
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3061
+                /* FIXME: we should probably use the same naming pool as
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3062
+                 * sessions generated from ck-manager.  We mangle the name
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3063
+                 * here so we don't clash with names from ck-manager
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3064
+                 */
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3065
+                ssid = generate_static_session_id (*sid, session_list[i]);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3066
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3067
+                session = ck_session_new_from_file (ssid, path);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3068
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3069
+                if (session == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3070
+                        g_warning ("Unable to load session from file %s", path);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3071
+                        g_free (path);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3072
+                        continue;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3073
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3074
+                g_free (path);
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3075
+                ck_session_set_seat_id (session, *sid, NULL);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3076
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3077
+                g_ptr_array_add (sessions, session);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3078
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3079
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3080
+        g_strfreev (session_list);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3081
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3082
         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
  3083
 
21939
7d28343f0da4 Fix so patch applies.
yippi
parents: 21938
diff changeset
  3084
-        g_debug ("Creating seat %s with %zd devices", sid, ndevices);
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3085
+        g_debug ("CkSeat: Creating seat %s with %zd devices", *sid, ndevices);
21751
93070d8a50d7 2011-04-29 Brian Cameron <[email protected]>
yippi
parents: 21493
diff changeset
  3086
 
93070d8a50d7 2011-04-29 Brian Cameron <[email protected]>
yippi
parents: 21493
diff changeset
  3087
         devices = g_ptr_array_sized_new (ndevices);
93070d8a50d7 2011-04-29 Brian Cameron <[email protected]>
yippi
parents: 21493
diff changeset
  3088
 
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3089
@@ -1176,11 +1861,12 @@ ck_seat_new_from_file (const char *sid,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3090
                 g_strfreev (split);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3091
         }
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3092
         g_strfreev (device_list);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3093
-        g_free (group);
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3094
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3095
-        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
  3096
+        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
  3097
         g_ptr_array_free (devices, TRUE);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3098
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3099
+        g_free (group);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3100
+
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3101
 out:
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3102
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3103
         g_key_file_free (key_file);
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3104
@@ -1348,10 +2034,15 @@ ck_seat_dump (CkSeat   *seat,
17046
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  3105
 
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  3106
                 error = NULL;
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  3107
                 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
  3108
-                        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
  3109
-                                   seat->priv->id,
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  3110
-                                   error->message);
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  3111
-                        g_error_free (error);
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  3112
+                        if (error) {
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  3113
+                                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
  3114
+                                           seat->priv->id,
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  3115
+                                           error->message);
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  3116
+                                g_error_free (error);
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  3117
+                        } else {
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  3118
+                                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
  3119
+                                           seat->priv->id);
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  3120
+                        }
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  3121
                 } else {
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  3122
                         g_key_file_set_string (key_file,
bd28dae03d8a 2009-11-27 Halton Huo <[email protected]>
halton
parents: 17003
diff changeset
  3123
                                                group_name,
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3124
@@ -1363,3 +2054,24 @@ ck_seat_dump (CkSeat   *seat,
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3125
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3126
         g_free (group_name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3127
 }
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3128
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3129
+gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3130
+ck_seat_is_managed (CkSeat *seat)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3131
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3132
+        return seat->priv->manager_proxy != NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3133
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3134
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3135
+CkSession *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3136
+ck_seat_get_session (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3137
+                     const char            *ssid)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3138
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3139
+        CkSession *session;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3140
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3141
+        session = g_hash_table_lookup (seat->priv->sessions, ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3142
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3143
+        if (session == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3144
+                return NULL;
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
+        return g_object_ref (session);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3148
+}
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3149
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
  3150
index fb9a955..6276021 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3151
--- a/src/ck-seat.h
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3152
+++ b/src/ck-seat.h
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3153
@@ -47,6 +47,7 @@ typedef struct
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3154
 {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3155
         GObjectClass   parent_class;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3156
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3157
+        void          (* remove_request)         (CkSeat      *seat);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3158
         void          (* active_session_changed) (CkSeat      *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3159
                                                   const char  *ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3160
         void          (* session_added)          (CkSeat      *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3161
@@ -57,6 +58,11 @@ typedef struct
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3162
                                                   GValueArray *device);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3163
         void          (* device_removed)         (CkSeat      *seat,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3164
                                                   GValueArray *device);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3165
+        void          (* session_to_add)         (CkSeat      *seat,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3166
+                                                  gboolean     is_dynamic,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3167
+                                                  const char  *command);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3168
+        void          (* session_to_remove)      (CkSeat      *seat,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3169
+                                                  int          display_number);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3170
 } CkSeatClass;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3171
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3172
 typedef enum
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3173
@@ -84,12 +90,14 @@ typedef enum
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3174
 GQuark              ck_seat_error_quark         (void);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3175
 GType               ck_seat_get_type            (void);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3176
 CkSeat            * ck_seat_new                 (const char            *sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3177
-                                                 CkSeatKind             kind);
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3178
-CkSeat            * ck_seat_new_from_file       (const char            *sid,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3179
-                                                 const char            *path);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3180
-CkSeat            * ck_seat_new_with_devices    (const char            *sid,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3181
                                                  CkSeatKind             kind,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3182
-                                                 GPtrArray             *devices);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3183
+                                                 const char            *type);
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3184
+CkSeat            * ck_seat_new_from_file       (char                 **sid,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3185
+                                                 const char            *path);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3186
+CkSeat            * ck_seat_new_with_devices_and_sessions    (const char            *sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3187
+                                                              CkSeatKind             kind,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3188
+                                                              GPtrArray             *devices,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3189
+                                                              GPtrArray             *sessions);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3190
 
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3191
 gboolean            ck_seat_register            (CkSeat                *seat);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3192
 
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3193
@@ -104,18 +112,31 @@ void                ck_seat_dump                (CkSeat                *seat,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3194
 gboolean            ck_seat_get_kind            (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3195
                                                  CkSeatKind            *kind,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3196
                                                  GError               **error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3197
+gboolean            ck_seat_get_type_string     (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3198
+                                                 char                 **type,
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
 gboolean            ck_seat_add_session         (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3201
                                                  CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3202
                                                  GError               **error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3203
 gboolean            ck_seat_remove_session      (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3204
                                                  CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3205
                                                  GError               **error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3206
+gboolean            ck_seat_request_open_session (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3207
+                                                  CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3208
+                                                  GError               **error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3209
+gboolean            ck_seat_request_close_session (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3210
+                                                   CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3211
+                                                   GError               **error);
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3212
 gboolean            ck_seat_add_device          (CkSeat                *seat,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3213
                                                  GValueArray           *device,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3214
                                                  GError               **error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3215
 gboolean            ck_seat_remove_device       (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3216
                                                  GValueArray           *device,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3217
                                                  GError               **error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3218
+gboolean            ck_seat_is_managed          (CkSeat                *seat);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3219
+CkSession          *ck_seat_get_session         (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3220
+                                                 const char            *ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3221
+void                ck_seat_request_removal     (CkSeat                *seat);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3222
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3223
 /* exported methods */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3224
 gboolean            ck_seat_get_id                (CkSeat                *seat,
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  3225
@@ -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
  3226
 gboolean            ck_seat_activate_session      (CkSeat                *seat,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3227
                                                    const char            *ssid,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3228
                                                    DBusGMethodInvocation *context);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3229
+gboolean            ck_seat_manage                (CkSeat                *seat,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3230
+                                                   DBusGMethodInvocation *context);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3231
+gboolean            ck_seat_unmanage              (CkSeat                *seat,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3232
+                                                   DBusGMethodInvocation *context);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3233
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3234
 G_END_DECLS
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3235
 
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3236
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
  3237
index 3702602..908d2bb 100644
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3238
--- a/src/ck-session-leader.c
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3239
+++ b/src/ck-session-leader.c
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3240
@@ -238,6 +238,7 @@ static struct {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3241
         { "x11-display",        add_param_string },
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3242
         { "remote-host-name",   add_param_string },
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3243
         { "session-type",       add_param_string },
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3244
+        { "display-type",       add_param_string },
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3245
         { "is-local",           add_param_boolean },
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3246
         { "unix-user",          add_param_int },
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3247
 };
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3248
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
  3249
index d8db9dd..0354dd5 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3250
--- a/src/ck-session.c
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3251
+++ b/src/ck-session.c
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3252
@@ -41,6 +41,7 @@
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3253
 #include "ck-session-glue.h"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3254
 #include "ck-marshal.h"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3255
 #include "ck-run-programs.h"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3256
+#include "ck-display-template.h"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3257
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3258
 #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
  3259
 
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3260
@@ -58,6 +59,7 @@ struct CkSessionPrivate
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3261
         char            *seat_id;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3262
 
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3263
         char            *session_type;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3264
+        char            *display_type;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3265
         char            *login_session_id;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3266
         char            *display_device;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3267
         char            *x11_display_device;
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3268
@@ -65,8 +67,15 @@ struct CkSessionPrivate
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3269
         char            *remote_host_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3270
         guint            uid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3271
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3272
+        CkDisplayTemplate *display_template;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3273
+        GHashTable      *display_variables;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3274
+
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3275
         gboolean         active;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3276
         gboolean         is_local;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3277
+        gboolean         is_open;
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3278
+        gboolean         ever_open;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3279
+        gboolean         under_request;
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3280
+        GMutex          *mutex_under_request;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3281
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3282
         GTimeVal         creation_time;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3283
 
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3284
@@ -75,6 +84,8 @@ struct CkSessionPrivate
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3285
         gboolean         idle_hint;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3286
         GTimeVal         idle_since_hint;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3287
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3288
+        gboolean         remove_on_close;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3289
+
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3290
         DBusGConnection *connection;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3291
         DBusGProxy      *bus_proxy;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3292
 };
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3293
@@ -92,17 +103,24 @@ enum {
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3294
         PROP_0,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3295
         PROP_ID,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3296
         PROP_COOKIE,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3297
+        PROP_SEAT_ID,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3298
         PROP_USER,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3299
         PROP_UNIX_USER,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3300
         PROP_X11_DISPLAY,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3301
         PROP_X11_DISPLAY_DEVICE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3302
         PROP_DISPLAY_DEVICE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3303
         PROP_SESSION_TYPE,
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3304
+        PROP_DISPLAY_TYPE,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3305
+        PROP_DISPLAY_TEMPLATE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3306
+        PROP_DISPLAY_VARIABLES,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3307
         PROP_REMOTE_HOST_NAME,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3308
         PROP_LOGIN_SESSION_ID,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3309
         PROP_IS_LOCAL,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3310
+        PROP_IS_OPEN,
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3311
+        PROP_EVER_OPEN,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3312
         PROP_ACTIVE,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3313
         PROP_IDLE_HINT,
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3314
+        PROP_REMOVE_ON_CLOSE,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3315
 };
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3316
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3317
 static guint signals [LAST_SIGNAL] = { 0, };
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3318
@@ -128,7 +146,9 @@ static gboolean
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3319
 register_session (CkSession *session)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3320
 {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3321
         GError *error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3322
+        GObject *existing_session;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3323
 
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3324
+        g_debug ("CkSession: Register session.");
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3325
         error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3326
         session->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3327
         if (session->priv->connection == NULL) {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3328
@@ -144,6 +164,15 @@ register_session (CkSession *session)
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3329
                                                               DBUS_PATH_DBUS,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3330
                                                               DBUS_INTERFACE_DBUS);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3331
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3332
+        existing_session = dbus_g_connection_lookup_g_object (session->priv->connection,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3333
+                                                              session->priv->id);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3334
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3335
+        if (existing_session != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3336
+                g_warning ("Session '%s' was registered twice!",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3337
+                           session->priv->id);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3338
+                return FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3339
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3340
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3341
         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
  3342
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3343
         return TRUE;
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3344
@@ -302,6 +331,40 @@ ck_session_set_idle_hint (CkSession     
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3345
 }
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3346
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3347
 gboolean
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3348
+session_set_remove_on_close (CkSession      *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3349
+                             gboolean        remove_on_close,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3350
+                             GError        **error)
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3351
+{
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3352
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3353
+
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3354
+        if (session->priv->remove_on_close != remove_on_close) {
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3355
+                session->priv->remove_on_close = remove_on_close;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3356
+        }
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3357
+
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3358
+        if (session->priv->remove_on_close == TRUE)
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3359
+                g_debug ("CkSession: Setting remove on close to true.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3360
+        else
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3361
+                g_debug ("CkSession: Setting remove on close to false.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3362
+
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3363
+        return TRUE;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3364
+}
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3365
+
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3366
+/*
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3367
+  Example:
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3368
+  dbus-send --system --dest=org.freedesktop.ConsoleKit \
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3369
+  --type=method_call --print-reply --reply-timeout=2000 \
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3370
+  /org/freedesktop/ConsoleKit/Session1 \
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3371
+  org.freedesktop.ConsoleKit.Session.SetRemoveOnClose boolean:TRUE
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3372
+*/
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3373
+gboolean
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3374
+ck_session_set_remove_on_close (CkSession             *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3375
+                                gboolean               remove_on_close,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3376
+                                DBusGMethodInvocation *context)
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3377
+{
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3378
+        return session_set_remove_on_close (session, remove_on_close, NULL);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3379
+}
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3380
+
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3381
+gboolean
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3382
 ck_session_get_idle_hint (CkSession *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3383
                           gboolean  *idle_hint,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3384
                           GError   **error)
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3385
@@ -367,6 +430,7 @@ ck_session_activate (CkSession          
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3386
 {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3387
         gboolean res;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3388
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3389
+        g_debug ("CkSession: Session activate.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3390
         g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3391
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3392
         res = FALSE;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3393
@@ -397,6 +461,8 @@ ck_session_set_active (CkSession      *s
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3394
 {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3395
         g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3396
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3397
+        g_debug ("CkSession: Session set active.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3398
+
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3399
         if (session->priv->active != active) {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3400
                 session->priv->active = active;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3401
                 g_signal_emit (session, signals [ACTIVE_CHANGED], 0, active);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3402
@@ -420,6 +486,68 @@ ck_session_set_is_local (CkSession      
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3403
 }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3404
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3405
 gboolean
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3406
+ck_session_set_is_open (CkSession    *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3407
+                        gboolean      is_open,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3408
+                        GError      **error)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3409
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3410
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3411
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3412
+        if (session->priv->is_open != is_open) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3413
+                session->priv->is_open = is_open;
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3414
+                session->priv->ever_open = TRUE;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3415
+        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3416
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3417
+        return TRUE;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3418
+}
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3419
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3420
+gboolean
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3421
+ck_session_set_ever_open (CkSession    *session,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3422
+                          gboolean      ever_open,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3423
+                          GError      **error)
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3424
+{
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3425
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3426
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3427
+        if (session->priv->ever_open != ever_open) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3428
+                session->priv->ever_open = ever_open;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3429
+        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3430
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3431
+        return TRUE;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3432
+}
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3433
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3434
+static gboolean
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3435
+timeout_for_under_request (gpointer data)
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3436
+{
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3437
+        CkSession *session = CK_SESSION (data);
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3438
+        g_mutex_lock (session->priv->mutex_under_request);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3439
+        session->priv->under_request = FALSE;
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3440
+        g_mutex_unlock (session->priv->mutex_under_request);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3441
+
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3442
+        g_debug ("CkSession: timeout for under request of session %s", session->priv->id);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3443
+        return FALSE;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3444
+}
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3445
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3446
+gboolean
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3447
+ck_session_set_under_request (CkSession    *session,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3448
+                              gboolean      under_request,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3449
+                              GError      **error)
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3450
+{
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3451
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3452
+
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3453
+        g_mutex_lock (session->priv->mutex_under_request);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3454
+        if (!under_request) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3455
+                session->priv->under_request = FALSE;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3456
+        } else {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3457
+                if (!session->priv->under_request) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3458
+                        session->priv->under_request = TRUE;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3459
+                        g_timeout_add_seconds (1, timeout_for_under_request, session);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3460
+                }
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3461
+        }
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3462
+        g_mutex_unlock (session->priv->mutex_under_request);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3463
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3464
+        return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3465
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3466
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3467
+gboolean
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3468
 ck_session_get_id (CkSession      *session,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3469
                    char          **id,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3470
                    GError        **error)
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3471
@@ -555,6 +683,20 @@ ck_session_get_creation_time (CkSession 
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3472
 }
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3473
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3474
 gboolean
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3475
+ck_session_get_remove_on_close (CkSession   *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3476
+                                gboolean    *remove_on_close,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3477
+                                GError     **error)
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3478
+{
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3479
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3480
+
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3481
+        if (remove_on_close != NULL) {
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3482
+                *remove_on_close = session->priv->remove_on_close;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3483
+        }
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3484
+
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3485
+        return TRUE;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3486
+}
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3487
+
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3488
+gboolean
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3489
 ck_session_get_session_type (CkSession      *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3490
                              char          **type,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3491
                              GError        **error)
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3492
@@ -569,6 +711,20 @@ ck_session_get_session_type (CkSession  
16232
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
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3495
 gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3496
+ck_session_get_display_type (CkSession      *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3497
+                             char          **type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3498
+                             GError        **error)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3499
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3500
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3501
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3502
+        if (type != NULL) {
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3503
+                *type = g_strdup (session->priv->display_type);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3504
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3505
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3506
+        return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3507
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3508
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3509
+gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3510
 ck_session_is_active (CkSession      *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3511
                       gboolean       *active,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3512
                       GError        **error)
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3513
@@ -597,6 +753,50 @@ ck_session_is_local (CkSession      *ses
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3514
 }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3515
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3516
 gboolean
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3517
+ck_session_is_open (CkSession      *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3518
+                    gboolean       *open,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3519
+                    GError        **error)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3520
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3521
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
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
+        if (open != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3524
+                *open = session->priv->is_open;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3525
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3526
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3527
+        return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3528
+}
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
+gboolean
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3531
+ck_session_get_ever_open (CkSession      *session,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3532
+                          gboolean       *open,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3533
+                          GError        **error)
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3534
+{
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3535
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3536
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3537
+        if (open != NULL) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3538
+                *open = session->priv->ever_open;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3539
+        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3540
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3541
+        return TRUE;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3542
+}
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3543
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3544
+gboolean
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3545
+ck_session_get_under_request (CkSession      *session,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3546
+                              gboolean       *under_request,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3547
+                              GError        **error)
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3548
+{
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3549
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3550
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3551
+        if (under_request != NULL) {
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3552
+                g_mutex_lock (session->priv->mutex_under_request);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3553
+                *under_request = session->priv->under_request;
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3554
+                g_mutex_unlock (session->priv->mutex_under_request);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3555
+        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3556
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3557
+        return TRUE;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3558
+}
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3559
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3560
+gboolean
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3561
 ck_session_set_id (CkSession      *session,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3562
                    const char     *id,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3563
                    GError        **error)
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3564
@@ -609,6 +809,21 @@ ck_session_set_id (CkSession      *sessi
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3565
         return TRUE;
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
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3568
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3569
+ck_session_set_display_variables (CkSession  *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3570
+                                  GHashTable *display_variables)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3571
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3572
+        if (session->priv->display_variables != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3573
+                g_hash_table_unref (session->priv->display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3574
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3575
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3576
+        if (display_variables != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3577
+                session->priv->display_variables = g_hash_table_ref (display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3578
+        } else {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3579
+                session->priv->display_variables = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3580
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3581
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3582
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3583
 gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3584
 ck_session_set_cookie (CkSession      *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3585
                        const char     *cookie,
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3586
@@ -725,6 +940,54 @@ ck_session_set_session_type (CkSession  
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3587
         return TRUE;
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
 
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3590
+gboolean
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3591
+ck_session_set_display_type (CkSession      *session,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3592
+                             const char     *type,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3593
+                             GError        **error)
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3594
+{
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3595
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3596
+
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3597
+        g_free (session->priv->display_type);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3598
+        session->priv->display_type = g_strdup (type);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3599
+
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3600
+        return TRUE;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3601
+}
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3602
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3603
+static gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3604
+ck_session_set_display_template (CkSession      *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3605
+                             CkDisplayTemplate  *display_template,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3606
+                             GError        **error)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3607
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3608
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
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
+        if (session->priv->display_template != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3611
+                g_object_unref (session->priv->display_template);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3612
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3613
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3614
+        if (display_template != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3615
+                session->priv->display_template = g_object_ref (display_template);
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3616
+                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
  3617
+        } else {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3618
+                session->priv->display_template = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3619
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3620
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3621
+        return TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3622
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3623
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3624
+GHashTable *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3625
+ck_session_get_display_variables (CkSession *session)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3626
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3627
+        return g_hash_table_ref (session->priv->display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3628
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3629
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3630
+CkDisplayTemplate *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3631
+ck_session_get_display_template (CkSession      *session)
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
+        g_return_val_if_fail (CK_IS_SESSION (session), FALSE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3634
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3635
+        return g_object_ref (session->priv->display_template);
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
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3638
 static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3639
 ck_session_set_property (GObject            *object,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3640
                          guint               prop_id,
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3641
@@ -742,15 +1005,33 @@ ck_session_set_property (GObject        
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3642
         case PROP_IS_LOCAL:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3643
                 ck_session_set_is_local (self, g_value_get_boolean (value), NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3644
                 break;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3645
+        case PROP_IS_OPEN:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3646
+                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
  3647
+                break;
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3648
+        case PROP_EVER_OPEN:
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3649
+                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
  3650
+                break;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3651
         case PROP_ID:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3652
                 ck_session_set_id (self, g_value_get_string (value), NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3653
                 break;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3654
         case PROP_COOKIE:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3655
                 ck_session_set_cookie (self, g_value_get_string (value), NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3656
                 break;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3657
+        case PROP_SEAT_ID:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3658
+                ck_session_set_seat_id (self, g_value_get_string (value), NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3659
+                break;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3660
         case PROP_SESSION_TYPE:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3661
                 ck_session_set_session_type (self, g_value_get_string (value), NULL);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3662
                 break;
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3663
+        case PROP_DISPLAY_TYPE:
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3664
+                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
  3665
+                break;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3666
+        case PROP_DISPLAY_TEMPLATE:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3667
+                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
  3668
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3669
+        case PROP_DISPLAY_VARIABLES:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3670
+                ck_session_set_display_variables (self, g_value_get_boxed (value));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3671
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3672
         case PROP_X11_DISPLAY:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3673
                 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
  3674
                 break;
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3675
@@ -775,6 +1056,9 @@ ck_session_set_property (GObject        
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3676
         case PROP_IDLE_HINT:
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3677
                 session_set_idle_hint_internal (self, g_value_get_boolean (value));
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3678
                 break;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3679
+        case PROP_REMOVE_ON_CLOSE:
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3680
+                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
  3681
+                break;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3682
         default:
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3683
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3684
                 break;
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3685
@@ -798,15 +1082,33 @@ ck_session_get_property (GObject    *obj
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3686
         case PROP_IS_LOCAL:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3687
                 g_value_set_boolean (value, self->priv->is_local);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3688
                 break;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3689
+        case PROP_IS_OPEN:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3690
+                g_value_set_boolean (value, self->priv->is_open);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3691
+                break;
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3692
+        case PROP_EVER_OPEN:
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3693
+                g_value_set_boolean (value, self->priv->ever_open);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  3694
+                break;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3695
         case PROP_ID:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3696
                 g_value_set_string (value, self->priv->id);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3697
                 break;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3698
         case PROP_COOKIE:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3699
                 g_value_set_string (value, self->priv->cookie);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3700
                 break;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3701
+        case PROP_SEAT_ID:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3702
+                g_value_set_string (value, self->priv->seat_id);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3703
+                break;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3704
         case PROP_SESSION_TYPE:
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3705
                 g_value_set_string (value, self->priv->session_type);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3706
                 break;
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3707
+        case PROP_DISPLAY_TYPE:
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3708
+                g_value_set_string (value, self->priv->display_type);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3709
+                break;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3710
+        case PROP_DISPLAY_TEMPLATE:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3711
+                g_value_set_object (value, self->priv->display_template);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3712
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3713
+        case PROP_DISPLAY_VARIABLES:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3714
+                g_value_set_boxed (value, self->priv->display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3715
+                break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3716
         case PROP_X11_DISPLAY:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3717
                 g_value_set_string (value, self->priv->x11_display);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3718
                 break;
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3719
@@ -831,6 +1133,9 @@ ck_session_get_property (GObject    *obj
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3720
         case PROP_IDLE_HINT:
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3721
                 g_value_set_boolean (value, self->priv->idle_hint);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3722
                 break;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3723
+        case PROP_REMOVE_ON_CLOSE:
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3724
+                g_value_set_boolean (value, self->priv->remove_on_close);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3725
+                break;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3726
         default:
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3727
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3728
                 break;
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3729
@@ -882,6 +1187,8 @@ session_add_activity_watch (CkSession *s
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3730
 static void
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3731
 session_remove_activity_watch (CkSession *session)
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3732
 {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3733
+        g_debug ("CkSession: Remove activity watch.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3734
+
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3735
         if (session->priv->idle_monitor == NULL) {
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3736
                 return;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3737
         }
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3738
@@ -1000,6 +1307,13 @@ ck_session_class_init (CkSessionClass *k
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3739
                                                               "cookie",
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3740
                                                               NULL,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3741
                                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3742
+        g_object_class_install_property (object_class,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3743
+                                         PROP_SEAT_ID,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3744
+                                         g_param_spec_string ("seat-id",
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3745
+                                                              "seat id",
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3746
+                                                              "seat id",
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3747
+                                                              NULL,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3748
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3749
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3750
         g_object_class_install_property (object_class,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  3751
                                          PROP_SESSION_TYPE,
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3752
@@ -1009,6 +1323,27 @@ ck_session_class_init (CkSessionClass *k
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3753
                                                               NULL,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3754
                                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3755
         g_object_class_install_property (object_class,
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3756
+                                         PROP_DISPLAY_TYPE,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3757
+                                         g_param_spec_string ("display-type",
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3758
+                                                              "session-type",
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3759
+                                                              "session type",
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3760
+                                                              NULL,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3761
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3762
+        g_object_class_install_property (object_class,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3763
+                                         PROP_DISPLAY_TEMPLATE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3764
+                                         g_param_spec_object ("display-template",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3765
+                                                              "Display Template",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3766
+                                                              "The display template",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3767
+                                                              CK_TYPE_DISPLAY_TEMPLATE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3768
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3769
+        g_object_class_install_property (object_class,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3770
+                                         PROP_DISPLAY_VARIABLES,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3771
+                                         g_param_spec_boxed ("display-variables",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3772
+                                                             "Display Variables",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3773
+                                                             "Display type specific variables",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3774
+                                                             G_TYPE_HASH_TABLE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3775
+                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3776
+        g_object_class_install_property (object_class,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3777
                                          PROP_LOGIN_SESSION_ID,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3778
                                          g_param_spec_string ("login-session-id",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3779
                                                               "login-session-id",
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3780
@@ -1064,12 +1399,19 @@ ck_session_class_init (CkSessionClass *k
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  3781
                                                             0,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  3782
                                                             G_PARAM_READWRITE));
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  3783
         g_object_class_install_property (object_class,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  3784
-                                         PROP_ACTIVE,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  3785
+                                         PROP_IDLE_HINT,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  3786
                                          g_param_spec_boolean ("idle-hint",
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  3787
                                                                NULL,
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3788
                                                                NULL,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3789
                                                                FALSE,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3790
                                                                G_PARAM_READWRITE));
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3791
+        g_object_class_install_property (object_class,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3792
+                                         PROP_REMOVE_ON_CLOSE,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3793
+                                         g_param_spec_boolean ("remove-on-close",
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3794
+                                                               NULL,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3795
+                                                               NULL,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3796
+                                                               FALSE,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3797
+                                                               G_PARAM_READWRITE));
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3798
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3799
         g_type_class_add_private (klass, sizeof (CkSessionPrivate));
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  3800
 
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3801
@@ -1081,8 +1423,16 @@ ck_session_init (CkSession *session)
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3802
 {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3803
         session->priv = CK_SESSION_GET_PRIVATE (session);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3804
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3805
+        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
  3806
+                                                                  g_str_equal,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3807
+                                                                  (GDestroyNotify) g_free,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3808
+                                                                  (GDestroyNotify) g_free);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3809
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3810
         /* FIXME: should we have a property for this? */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3811
         g_get_current_time (&session->priv->creation_time);
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3812
+
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3813
+        if (!session->priv->mutex_under_request)
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3814
+                session->priv->mutex_under_request = g_mutex_new ();
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3815
 }
17003
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3816
 
db8f1f788e76 2009-11-20 Halton Huo <[email protected]>
halton
parents: 17002
diff changeset
  3817
 static void
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3818
@@ -1105,6 +1455,7 @@ ck_session_finalize (GObject *object)
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3819
         g_free (session->priv->cookie);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3820
         g_free (session->priv->seat_id);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3821
         g_free (session->priv->session_type);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3822
+        g_free (session->priv->display_type);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3823
         g_free (session->priv->x11_display);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3824
         g_free (session->priv->display_device);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3825
         g_free (session->priv->x11_display_device);
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3826
@@ -1114,16 +1465,138 @@ ck_session_finalize (GObject *object)
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3827
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3828
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3829
 CkSession *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3830
+ck_session_new_from_file (const char *ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3831
+                          const char *path)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3832
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3833
+        GKeyFile  *key_file;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3834
+        gboolean   res;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3835
+        GError    *error;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3836
+        char      *group;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3837
+        char      *name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3838
+        gboolean   hidden;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3839
+        char      *type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3840
+        char      *display_template_string;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3841
+        CkSession *session;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3842
+        GHashTable *display_variables;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3843
+        char     **type_keys;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3844
+
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3845
+        g_debug ("CkSession: New session from file.");
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3846
+        key_file = g_key_file_new ();
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3847
+        error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3848
+        res = g_key_file_load_from_file (key_file,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3849
+                                         path,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3850
+                                         G_KEY_FILE_NONE,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3851
+                                         &error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3852
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3853
+        if (! res) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3854
+                g_warning ("Unable to load sessions from file %s: %s",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3855
+                           path, error->message);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3856
+                g_error_free (error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3857
+                return NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3858
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3859
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3860
+        group = g_key_file_get_start_group (key_file);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3861
+        if (group == NULL || strcmp (group, "Session Entry") != 0) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3862
+                g_warning ("Not a session file: %s", path);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3863
+                g_key_file_free (key_file);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3864
+                return NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3865
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3866
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3867
+        hidden = g_key_file_get_boolean (key_file, group, "Hidden", NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3868
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3869
+        if (hidden) {
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3870
+                g_debug ("CkSession: Session is hidden");
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3871
+                g_free (group);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3872
+                g_key_file_free (key_file);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3873
+                return NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3874
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3875
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3876
+        name = g_key_file_get_string (key_file, group, "Name", NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3877
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3878
+        if (name == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3879
+                g_warning ("Session file %s doesn't contain a name", path);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3880
+                g_free (group);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3881
+                g_key_file_free (key_file);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3882
+                return NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3883
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3884
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3885
+        type = g_key_file_get_string (key_file, group, "Type", NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3886
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3887
+        if (type == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3888
+                g_warning ("Session file %s doesn't contain a type", path);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3889
+                g_free (group);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3890
+                g_key_file_free (key_file);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3891
+                return NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3892
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3893
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3894
+        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
  3895
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3896
+        if (display_template_string == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3897
+                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
  3898
+                g_free (group);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3899
+                g_key_file_free (key_file);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3900
+                return NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3901
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3902
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3903
+        /* 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
  3904
+         * all its entries into a hash table for later.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3905
+         *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3906
+         * 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
  3907
+         * run X with.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3908
+         */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3909
+        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
  3910
+                                                   (GDestroyNotify) g_free,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3911
+                                                   (GDestroyNotify) g_free);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3912
+        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
  3913
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3914
+        if (type_keys != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3915
+                int i;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3916
+                for (i = 0; type_keys[i] != NULL; i++) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3917
+                        char    *string;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3918
+                        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
  3919
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3920
+                        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
  3921
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3922
+                g_strfreev (type_keys);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3923
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3924
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3925
+        session = ck_session_new (ssid, type, display_template_string, display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3926
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3927
+        g_free (display_template_string);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3928
+        g_free (group);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3929
+        g_free (type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3930
+        g_hash_table_unref (display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3931
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3932
+        return session;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3933
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3934
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3935
+CkSession *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3936
 ck_session_new (const char *ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3937
-                const char *cookie)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3938
+                const char *type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3939
+                const char *display_template_string,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3940
+                GHashTable *display_variables)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3941
 {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3942
+        CkDisplayTemplate *display_template;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3943
         GObject *object;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3944
         gboolean res;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3945
 
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3946
+        g_debug ("CkSession: New Session.");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3947
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3948
+        display_template = ck_display_template_get_from_name (display_template_string);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3949
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3950
+        if (display_template == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3951
+                g_warning ("Unable to load display type %s", display_template_string);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3952
+                return NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3953
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3954
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3955
         object = g_object_new (CK_TYPE_SESSION,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3956
                                "id", ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3957
-                               "cookie", cookie,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3958
+                               "session-type", type,
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  3959
+                               "display-type", display_template_string,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3960
+                               "display-template", display_template,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3961
+                               "display-variables", display_variables,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3962
                                NULL);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3963
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3964
         res = register_session (CK_SESSION (object));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3965
         if (! res) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3966
                 g_object_unref (object);
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3967
@@ -1138,9 +1611,80 @@ ck_session_new (const char *ssid,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3968
                                                           G_TYPE_VALUE, \
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3969
                                                           G_TYPE_INVALID))
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3970
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3971
+void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3972
+ck_session_set_parameters (CkSession       *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3973
+                           const GPtrArray *parameters)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3974
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3975
+        int           i;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3976
+        GObjectClass *class;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3977
+        GType         object_type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3978
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3979
+        object_type = CK_TYPE_SESSION;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3980
+        class = g_type_class_ref (object_type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3981
+        for (i = 0; i < parameters->len; i++) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3982
+                gboolean    res;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3983
+                GValue      val_struct = { 0, };
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3984
+                GValue      value = { 0, };
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3985
+                char       *prop_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3986
+                GValue     *prop_val;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3987
+                GParamSpec *pspec;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3988
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3989
+                g_value_init (&val_struct, CK_TYPE_PARAMETER_STRUCT);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3990
+                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
  3991
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3992
+                res = dbus_g_type_struct_get (&val_struct,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3993
+                                              0, &prop_name,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3994
+                                              1, &prop_val,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3995
+                                              G_MAXUINT);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3996
+                if (! res) {
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  3997
+                        g_debug ("CkSession: Unable to extract parameter input");
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3998
+                        goto cont;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  3999
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4000
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4001
+                if (prop_name == NULL) {
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  4002
+                        g_debug ("CkSession: Skipping NULL parameter");
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4003
+                        goto cont;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4004
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4005
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4006
+                if (strcmp (prop_name, "id") == 0
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4007
+                    || strcmp (prop_name, "cookie") == 0) {
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  4008
+                        g_debug ("CkSession: Skipping restricted parameter: %s", prop_name);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4009
+                        goto cont;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4010
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4011
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4012
+                pspec = g_object_class_find_property (class, prop_name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4013
+                if (! pspec) {
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  4014
+                        g_debug ("CkSession: Skipping unknown parameter: %s", prop_name);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4015
+                        goto cont;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4016
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4017
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4018
+                if (!(pspec->flags & G_PARAM_WRITABLE)) {
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  4019
+                        g_debug ("CkSession: property '%s' is not writable", pspec->name);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4020
+                        goto cont;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4021
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4022
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4023
+                g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4024
+                res = g_value_transform (prop_val, &value);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4025
+                if (! res) {
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  4026
+                        g_debug ("CkSession: unable to transform property value for '%s'", pspec->name);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4027
+                        goto cont;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4028
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4029
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4030
+                g_object_set_property (G_OBJECT (session), prop_name, &value);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4031
+                g_value_unset (&value);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4032
+        cont:
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4033
+                g_free (prop_name);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4034
+                if (prop_val != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4035
+                        g_value_unset (prop_val);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4036
+                        g_free (prop_val);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4037
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4038
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4039
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4040
+        g_type_class_unref (class);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4041
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4042
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4043
 CkSession *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4044
 ck_session_new_with_parameters (const char      *ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4045
-                                const char      *cookie,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4046
                                 const GPtrArray *parameters)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4047
 {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4048
         GObject      *object;
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  4049
@@ -1152,6 +1696,8 @@ ck_session_new_with_parameters (const ch
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  4050
         GObjectClass *class;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  4051
         GType         object_type;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  4052
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  4053
+        g_debug ("CkSession: New session with parameters");
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  4054
+
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  4055
         object_type = CK_TYPE_SESSION;
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  4056
         class = g_type_class_ref (object_type);
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  4057
 
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  4058
@@ -1169,12 +1715,6 @@ ck_session_new_with_parameters (const ch
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4059
         g_value_set_string (&params[n_params].value, ssid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4060
         n_params++;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4061
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4062
-        params[n_params].name = g_strdup ("cookie");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4063
-        params[n_params].value.g_type = 0;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4064
-        g_value_init (&params[n_params].value, G_TYPE_STRING);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4065
-        g_value_set_string (&params[n_params].value, cookie);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4066
-        n_params++;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4067
-
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4068
         if (parameters != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4069
                 for (i = 0; i < parameters->len; i++) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4070
                         gboolean    res;
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  4071
@@ -1259,7 +1799,7 @@ ck_session_run_programs (CkSession  *ses
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4072
                          const char *action)
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4073
 {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4074
         int   n;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4075
-        char *extra_env[11]; /* be sure to adjust this as needed */
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4076
+        char *extra_env[12]; /* be sure to adjust this as needed */
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4077
 
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4078
         n = 0;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4079
 
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  4080
@@ -1267,6 +1807,9 @@ ck_session_run_programs (CkSession  *ses
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4081
         if (session->priv->session_type != NULL) {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4082
                 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
  4083
         }
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4084
+        if (session->priv->display_type != NULL) {
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4085
+                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
  4086
+        }
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4087
         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
  4088
         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
  4089
         if (session->priv->display_device != NULL && strlen (session->priv->display_device) > 0) {
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  4090
@@ -1301,6 +1844,10 @@ ck_session_dump (CkSession *session,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4091
         char *s;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4092
         char *group_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4093
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4094
+        if (!session->priv->is_open) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4095
+                return;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4096
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4097
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4098
         group_name = g_strdup_printf ("Session %s", session->priv->id);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4099
         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
  4100
         g_key_file_set_string (key_file,
21938
1df9aeefafa6 2011-07-01 Brian Cameron <[email protected]>
yippi
parents: 21751
diff changeset
  4101
@@ -1313,6 +1860,12 @@ ck_session_dump (CkSession *session,
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4102
                                        "type",
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4103
                                        NONULL_STRING (session->priv->session_type));
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4104
         }
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4105
+        if (session->priv->display_type != NULL) {
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4106
+                g_key_file_set_string (key_file,
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4107
+                                       group_name,
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4108
+                                       "display_type",
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4109
+                                       NONULL_STRING (session->priv->display_type));
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4110
+        }
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4111
         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
  4112
                 g_key_file_set_string (key_file,
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4113
                                        group_name,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4114
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
  4115
index b6b565b..a24d0a8 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4116
--- a/src/ck-session.h
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4117
+++ b/src/ck-session.h
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4118
@@ -25,6 +25,8 @@
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4119
 #include <glib-object.h>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4120
 #include <dbus/dbus-glib.h>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4121
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4122
+#include "ck-display-template.h"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4123
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4124
 G_BEGIN_DECLS
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4125
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4126
 #define CK_TYPE_SESSION         (ck_session_get_type ())
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4127
@@ -68,10 +70,15 @@ typedef enum
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4128
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4129
 GQuark              ck_session_error_quark            (void);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4130
 GType               ck_session_get_type               (void);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4131
+CkSession         * ck_session_new_from_file          (const char            *ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4132
+                                                       const char            *path);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4133
 CkSession         * ck_session_new                    (const char            *ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4134
-                                                       const char            *cookie);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4135
+                                                       const char            *type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4136
+                                                       const char            *display_type_string,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4137
+                                                       GHashTable            *display_variables);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4138
 CkSession         * ck_session_new_with_parameters    (const char            *ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4139
-                                                       const char            *cookie,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4140
+                                                       const GPtrArray       *parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4141
+void                ck_session_set_parameters         (CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4142
                                                        const GPtrArray       *parameters);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4143
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4144
 void                ck_session_dump                   (CkSession             *session,
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4145
@@ -86,6 +93,15 @@ gboolean            ck_session_set_active             (CkSession             *se
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4146
 gboolean            ck_session_set_is_local           (CkSession             *session,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4147
                                                        gboolean               is_local,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4148
                                                        GError               **error);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4149
+gboolean            ck_session_set_is_open            (CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4150
+                                                       gboolean               is_open,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4151
+                                                       GError               **error);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  4152
+gboolean            ck_session_set_ever_open          (CkSession             *session,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  4153
+                                                       gboolean               ever_open,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  4154
+                                                       GError               **error);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  4155
+gboolean            ck_session_set_under_request      (CkSession             *session,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  4156
+                                                       gboolean               under_request,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  4157
+                                                       GError               **error);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4158
 gboolean            ck_session_set_id                 (CkSession             *session,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4159
                                                        const char            *ssid,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4160
                                                        GError               **error);
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4161
@@ -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
  4162
 gboolean            ck_session_set_session_type       (CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4163
                                                        const char            *type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4164
                                                        GError               **error);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  4165
+gboolean            ck_session_set_display_type       (CkSession             *session,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  4166
+                                                       const char            *type,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  4167
+                                                       GError               **error);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4168
+GHashTable         *ck_session_get_display_variables  (CkSession             *session);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4169
+CkDisplayTemplate  *ck_session_get_display_template   (CkSession             *session);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4170
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4171
 /* Exported methods */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4172
 
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4173
@@ -132,6 +153,15 @@ gboolean            ck_session_is_active              (CkSession             *se
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4174
 gboolean            ck_session_is_local               (CkSession             *session,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4175
                                                        gboolean              *local,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4176
                                                        GError               **error);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4177
+gboolean            ck_session_is_open                (CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4178
+                                                       gboolean              *open,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4179
+                                                       GError               **error);
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  4180
+gboolean            ck_session_get_ever_open          (CkSession             *session,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  4181
+                                                       gboolean              *open,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  4182
+                                                       GError               **error);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  4183
+gboolean            ck_session_get_under_request      (CkSession             *session,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  4184
+                                                       gboolean              *under_request,
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16647
diff changeset
  4185
+                                                       GError               **error);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4186
 gboolean            ck_session_get_unix_user          (CkSession             *session,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4187
                                                        guint                 *uid,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4188
                                                        GError               **error);
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4189
@@ -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
  4190
 gboolean            ck_session_get_session_type       (CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4191
                                                        char                 **type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4192
                                                        GError               **error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4193
+gboolean            ck_session_get_display_type       (CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4194
+                                                       char                 **type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4195
+                                                       GError               **error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4196
 gboolean            ck_session_get_remote_host_name   (CkSession             *session,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4197
                                                        char                 **host_name,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4198
                                                        GError               **error);
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4199
 gboolean            ck_session_get_creation_time      (CkSession             *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4200
                                                        char                 **iso8601_datetime,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4201
                                                        GError               **error);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4202
+gboolean            ck_session_get_remove_on_close    (CkSession             *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4203
+                                                       gboolean              *remove_on_close,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4204
+                                                       GError               **error);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4205
 /*deprecated*/
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4206
 gboolean            ck_session_get_user               (CkSession             *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4207
                                                        guint                 *uid,
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4208
@@ -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
  4209
 gboolean            ck_session_set_idle_hint          (CkSession             *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4210
                                                        gboolean               idle_hint,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4211
                                                        DBusGMethodInvocation *context);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4212
+gboolean            session_set_remove_on_close       (CkSession             *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4213
+                                                       gboolean               remove_on_close,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4214
+                                                       GError               **error);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4215
+gboolean            ck_session_set_remove_on_close    (CkSession             *session,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4216
+                                                       gboolean               remove_on_close,
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4217
+                                                       DBusGMethodInvocation *context);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4218
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4219
 /* Privileged actions */
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4220
 gboolean            ck_session_activate               (CkSession             *session,
17862
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  4221
diff --git a/src/main.c b/src/main.c
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  4222
index b8f698f..f685026 100644
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  4223
--- a/src/main.c
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  4224
+++ b/src/main.c
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  4225
@@ -283,7 +283,7 @@ main (int    argc,
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  4226
         res = g_option_context_parse (context, &argc, &argv, &error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  4227
         g_option_context_free (context);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  4228
         if (! res) {
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  4229
-                g_warning (error->message);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  4230
+                g_warning ("%s", error->message);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  4231
                 g_error_free (error);
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  4232
                 goto out;
aa8b4b62b23f 2010-04-19 Halton Huo <[email protected]>
halton
parents: 17800
diff changeset
  4233
         }
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4234
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
  4235
index f903b55..34a6d04 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4236
--- a/src/org.freedesktop.ConsoleKit.Manager.xml
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4237
+++ b/src/org.freedesktop.ConsoleKit.Manager.xml
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4238
@@ -160,6 +160,23 @@
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4239
       </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4240
     </method>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4241
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4242
+    <method name="GetUnmanagedSeats">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4243
+      <arg name="seats" direction="out" type="ao">
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:summary>an array of unmanaged Seat IDs</doc:summary>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4246
+        </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4247
+      </arg>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4248
+      <doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4249
+        <doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4250
+          <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
  4251
+          that are statically configured under /etc/ConsoleKit/seats.d</doc:para>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4252
+          <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
  4253
+          <doc:ref type="interface" to="Seat">Seat</doc:ref> interface.</doc:para>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4254
+        </doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4255
+        <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
  4256
+      </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4257
+    </method>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4258
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4259
     <method name="GetSessions">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4260
       <arg name="sessions" direction="out" type="ao">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4261
         <doc:doc>
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4262
@@ -310,12 +327,115 @@
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4263
       </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4264
     </method>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4265
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4266
+    <method name="AddSeat">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4267
+      <arg name="type" type="s" direction="in">
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4268
+        <doc:doc>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4269
+          <doc:summary>The type of seat to add</doc:summary>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4270
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4271
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4272
+      <arg name="sid" type="o" direction="out">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4273
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4274
+          <doc:summary>The Seat ID of the added seat</doc:summary>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4275
+        </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4276
+      </arg>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4277
+      <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4278
+        <doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4279
+          <doc:para>This method is to create a new seat
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4280
+          </doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4281
+        </doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4282
+      </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4283
+    </method>
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4284
+    <method name="AddSeatById">
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4285
+      <arg name="type" type="s" direction="in">
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4286
+        <doc:doc>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4287
+          <doc:summary>The type of seat to add</doc:summary>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4288
+        </doc:doc>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4289
+      </arg>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4290
+      <arg name="sid" type="o" direction="in">
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4291
+        <doc:doc>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4292
+          <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
  4293
+        </doc:doc>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4294
+      </arg>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4295
+      <doc:doc>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4296
+        <doc:description>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4297
+          <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
  4298
+          </doc:para>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4299
+        </doc:description>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4300
+      </doc:doc>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4301
+    </method>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4302
+    <method name="RemoveSeat">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4303
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4304
+      <arg name="sid" type="o" direction="in">
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4305
+        <doc:doc>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4306
+          <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
  4307
+        </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4308
+      </arg>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4309
+      <doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4310
+        <doc:description>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4311
+          <doc:para>This method is to remove a seat
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4312
+          </doc:para>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4313
+        </doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4314
+      </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4315
+    </method>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4316
+    <method name="AddSession">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4317
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4318
+      <arg name="sid" type="o">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4319
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4320
+          <doc:summary>The seat to add the session to</doc:summary>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4321
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4322
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4323
+      <arg name="type" type="s">
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4324
+        <doc:doc>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4325
+          <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
  4326
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4327
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4328
+      <arg name="display_type" type="s">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4329
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4330
+          <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
  4331
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4332
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4333
+      <arg name="variables" type="a{ss}">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4334
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4335
+          <doc:summary>Session type specific parameters</doc:summary>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4336
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4337
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4338
+      <arg name="ssid" direction="out" type="o">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4339
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4340
+          <doc:summary>Session ID</doc:summary>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4341
+        </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4342
+      </arg>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4343
+      <doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4344
+        <doc:description>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4345
+          <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
  4346
+        </doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4347
+      </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4348
+    </method>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4349
+    <method name="RemoveSession">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4350
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4351
+      <arg name="ssid" type="o" direction="in">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4352
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4353
+          <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
  4354
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4355
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4356
+      <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4357
+        <doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4358
+          <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
  4359
+          </doc:para>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4360
+        </doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4361
+      </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4362
+    </method>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4363
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4364
     <signal name="SeatAdded">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4365
       <arg name="sid" type="o">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4366
         <doc:doc>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4367
           <doc:summary>The Seat ID for the added seat</doc:summary>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4368
         </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4369
       </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4370
+      <arg name="type" type="s">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4371
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4372
+          <doc:summary>The type of seat added.</doc:summary>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4373
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4374
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4375
       <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4376
         <doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4377
           <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
  4378
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
  4379
index d95990b..1f6c46f 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4380
--- a/src/org.freedesktop.ConsoleKit.Seat.xml
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4381
+++ b/src/org.freedesktop.ConsoleKit.Seat.xml
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4382
@@ -100,6 +100,24 @@ seat at a time.</doc:para>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4383
       </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4384
     </method>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4385
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4386
+    <method name="Manage">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4387
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4388
+      <doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4389
+        <doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4390
+          <doc:para>Attempt to create unmanaged sessions for this seat.</doc:para>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4391
+        </doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4392
+      </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4393
+    </method>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4394
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4395
+    <method name="Unmanage">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4396
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4397
+      <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4398
+        <doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4399
+          <doc:para>Stop managing seat.</doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4400
+        </doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4401
+      </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4402
+    </method>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4403
+
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4404
     <signal name="ActiveSessionChanged">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4405
       <arg name="ssid" type="o">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4406
         <doc:doc>
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4407
@@ -160,5 +178,61 @@ seat at a time.</doc:para>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4408
         </doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4409
       </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4410
     </signal>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4411
+    <signal name="OpenSessionRequest">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4412
+      <arg name="ssid" type="o">
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4413
+        <doc:doc>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4414
+          <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
  4415
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4416
+      </arg>
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4417
+      <arg name="session_type" type="s">
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4418
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4419
+          <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
  4420
+        </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4421
+      </arg>
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4422
+      <arg name="display_template_name" type="s">
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4423
+        <doc:doc>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4424
+          <doc:summary>The name of display template </doc:summary>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4425
+        </doc:doc>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4426
+      </arg>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4427
+      <arg name="parameters" type="a{ss}">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4428
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4429
+          <doc:summary>Session type specific parameters</doc:summary>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4430
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4431
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4432
+      <arg name="display_type" type="s">
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4433
+        <doc:doc>
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4434
+          <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
  4435
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4436
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4437
+      <arg name="display_parameters" type="a{ss}">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4438
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4439
+          <doc:summary>Display type specific parameters</doc:summary>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4440
+        </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4441
+      </arg>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4442
+      <doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4443
+        <doc:description>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4444
+          <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
  4445
+        </doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4446
+      </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4447
+    </signal>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4448
+    <signal name="CloseSessionRequest">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4449
+      <arg name="ssid" type="o">
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4450
+        <doc:doc>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4451
+          <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
  4452
+        </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4453
+      </arg>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4454
+      <doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4455
+        <doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4456
+          <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
  4457
+        </doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4458
+      </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4459
+    </signal>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4460
+    <signal name="RemoveRequest">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4461
+      <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4462
+        <doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4463
+          <doc:para>Emitted when seat needs to get removed.</doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4464
+        </doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4465
+      </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4466
+    </signal>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4467
   </interface>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4468
 </node>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4469
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
  4470
index b6e1cdb..2652058 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4471
--- a/src/org.freedesktop.ConsoleKit.Session.xml
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4472
+++ b/src/org.freedesktop.ConsoleKit.Session.xml
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4473
@@ -52,6 +52,19 @@
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4474
         <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
  4475
       </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4476
     </method>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4477
+    <method name="GetDisplayType">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4478
+      <arg name="type" direction="out" type="s">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4479
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4480
+          <doc:summary>Display type</doc:summary>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4481
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4482
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4483
+      <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4484
+        <doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4485
+          <doc:para>Returns the display type of the session.</doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4486
+        </doc:description>
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4487
+        <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
  4488
+      </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4489
+    </method>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4490
     <method name="GetUser">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4491
       <arg name="uid" direction="out" type="u">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4492
         <doc:doc>
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4493
@@ -174,6 +187,18 @@
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4494
         <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
  4495
       </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4496
     </method>
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4497
+    <method name="IsOpen">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4498
+      <arg name="open" direction="out" type="b">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4499
+        <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4500
+          <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
  4501
+        </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4502
+      </arg>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4503
+      <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4504
+        <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
  4505
+        </doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4506
+        <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
  4507
+      </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4508
+    </method>
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4509
     <method name="GetCreationTime">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4510
       <arg name="iso8601_datetime" type="s" direction="out">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4511
         <doc:doc>
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4512
@@ -275,6 +300,21 @@
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4513
         </doc:description>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4514
       </doc:doc>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4515
     </method>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4516
+    <method name="SetRemoveOnClose">
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4517
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4518
+      <arg name="remove_on_close" type="b" direction="in">
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4519
+        <doc:doc>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4520
+          <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
  4521
+        </doc:doc>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4522
+      </arg>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4523
+      <doc:doc>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4524
+        <doc:description>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4525
+          <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
  4526
+          it should be respawn or not when it is closed.
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4527
+          </doc:para>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4528
+        </doc:description>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4529
+      </doc:doc>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4530
+    </method>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4531
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4532
     <signal name="ActiveChanged">
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4533
       <arg name="is_active" type="b">
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4534
@@ -317,6 +357,19 @@
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4535
       </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4536
     </signal>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4537
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4538
+    <property name="session" type="o" access="readwrite">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4539
+      <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4540
+        <doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4541
+          <doc:para>The id of the session.</doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4542
+          <doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4543
+          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
  4544
+          <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
  4545
+          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
  4546
+          signal.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4547
+          </doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4548
+        </doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4549
+      </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4550
+    </property>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4551
     <property name="unix-user" type="u" access="readwrite">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4552
       <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4553
         <doc:description>
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4554
@@ -342,6 +395,16 @@
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4555
         </doc:description>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4556
       </doc:doc>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4557
     </property>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4558
+    <property name="display-type" type="s" access="readwrite">
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4559
+      <doc:doc>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4560
+        <doc:description>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4561
+          <doc:para>The display type of the session.</doc:para>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4562
+          <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
  4563
+          files are under /etc/ConsoleKit/displays.d/.
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4564
+          </doc:para>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4565
+        </doc:description>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4566
+      </doc:doc>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4567
+    </property>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4568
     <property name="remote-host-name" type="s" access="readwrite">
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4569
       <doc:doc>
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  4570
         <doc:description>
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4571
@@ -396,6 +459,19 @@
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4572
         </doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4573
       </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4574
     </property>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4575
+    <property name="is-open" type="b" access="readwrite">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4576
+      <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4577
+        <doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4578
+          <doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4579
+          Whether the session is open</doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4580
+          <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
  4581
+          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
  4582
+          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
  4583
+          method.
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4584
+          </doc:para>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4585
+        </doc:description>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4586
+      </doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4587
+    </property>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4588
     <property name="is-local" type="b" access="readwrite">
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4589
       <doc:doc>
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4590
         <doc:description>
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4591
@@ -408,6 +484,14 @@
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4592
         </doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4593
       </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4594
     </property>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4595
+    <property name="is-dynamic" type="b" access="readwrite">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4596
+      <doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4597
+        <doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4598
+          <doc:para>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4599
+          Whether the session is dynamic</doc:para>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4600
+        </doc:description>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4601
+      </doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4602
+    </property>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4603
     <property name="idle-hint" type="b" access="readwrite">
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4604
       <doc:doc>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4605
         <doc:description>
16911
31e2f6cba93e 2009-11-05 Halton Huo <[email protected]>
halton
parents: 16844
diff changeset
  4606
@@ -430,6 +514,14 @@
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4607
         </doc:description>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4608
       </doc:doc>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4609
     </property>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4610
+    <property name="remove-on-close" type="b" access="readwrite">
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4611
+      <doc:doc>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4612
+        <doc:description>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4613
+          <doc:para>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4614
+          Whether the session respawn when it is closed</doc:para>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4615
+        </doc:description>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4616
+      </doc:doc>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4617
+    </property>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4618
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4619
   </interface>
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  4620
 </node>
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4621
diff --git a/src/strverscmp.c b/src/strverscmp.c
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4622
new file mode 100644
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4623
index 0000000..f077651
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4624
--- /dev/null
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4625
+++ b/src/strverscmp.c
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4626
@@ -0,0 +1,131 @@
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4627
+/* Compare strings while treating digits characters numerically.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4628
+   Copyright (C) 1997, 2000, 2002, 2004, 2006 Free Software Foundation, Inc.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4629
+   This file is part of the GNU C Library.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4630
+   Contributed by Jean-François Bignolles <[email protected]>, 1997.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4631
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4632
+   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
  4633
+   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
  4634
+   the Free Software Foundation; either version 2, or (at your option)
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4635
+   any later version.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4636
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4637
+   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
  4638
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4639
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4640
+   GNU General Public License for more details.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4641
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4642
+   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
  4643
+   with this program; if not, write to the Free Software Foundation,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4644
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4645
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4646
+#if !_LIBC
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4647
+# include <config.h>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4648
+#endif
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4649
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4650
+#include <string.h>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4651
+#include <ctype.h>
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4652
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4653
+/* 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
  4654
+           fractional parts, S_Z: idem but with leading Zeroes only */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4655
+#define S_N    0x0
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4656
+#define S_I    0x4
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4657
+#define S_F    0x8
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4658
+#define S_Z    0xC
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4659
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4660
+/* result_type: CMP: return diff; LEN: compare using len_diff/diff */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4661
+#define CMP    2
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4662
+#define LEN    3
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4663
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4664
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4665
+/* ISDIGIT differs from isdigit, as follows:
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4666
+   - 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
  4667
+     or EOF.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4668
+   - It's typically faster.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4669
+   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
  4670
+   isdigit unless it's important to use the locale's definition
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4671
+   of `digit' even when the host does not conform to POSIX.  */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4672
+#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4673
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4674
+#undef __strverscmp
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4675
+#undef strverscmp
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4676
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4677
+#ifndef weak_alias
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4678
+# define __strverscmp strverscmp
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4679
+#endif
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4680
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4681
+/* Compare S1 and S2 as strings holding indices/version numbers,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4682
+   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
  4683
+   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
  4684
+*/
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4685
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4686
+int
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4687
+__strverscmp (const char *s1, const char *s2)
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4688
+{
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4689
+  const unsigned char *p1 = (const unsigned char *) s1;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4690
+  const unsigned char *p2 = (const unsigned char *) s2;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4691
+  unsigned char c1, c2;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4692
+  int state;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4693
+  int diff;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4694
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4695
+  /* Symbol(s)    0       [1-9]   others  (padding)
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4696
+     Transition   (10) 0  (01) d  (00) x  (11) -   */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4697
+  static const unsigned int next_state[] =
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4698
+  {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4699
+      /* state    x    d    0    - */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4700
+      /* S_N */  S_N, S_I, S_Z, S_N,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4701
+      /* S_I */  S_N, S_I, S_I, S_I,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4702
+      /* S_F */  S_N, S_F, S_F, S_F,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4703
+      /* S_Z */  S_N, S_F, S_Z, S_Z
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4704
+  };
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4705
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4706
+  static const int result_type[] =
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4707
+  {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4708
+      /* 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
  4709
+                 0/x  0/d  0/0  0/-  -/x  -/d  -/0  -/- */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4710
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4711
+      /* S_N */  CMP, CMP, CMP, CMP, CMP, LEN, CMP, CMP,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4712
+                 CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4713
+      /* S_I */  CMP, -1,  -1,  CMP,  1,  LEN, LEN, CMP,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4714
+                  1,  LEN, LEN, CMP, CMP, CMP, CMP, CMP,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4715
+      /* S_F */  CMP, CMP, CMP, CMP, CMP, LEN, CMP, CMP,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4716
+                 CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4717
+      /* S_Z */  CMP,  1,   1,  CMP, -1,  CMP, CMP, CMP,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4718
+                 -1,  CMP, CMP, CMP
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4719
+  };
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4720
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4721
+  if (p1 == p2)
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4722
+    return 0;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4723
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4724
+  c1 = *p1++;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4725
+  c2 = *p2++;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4726
+  /* Hint: '0' is a digit too.  */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4727
+  state = S_N | ((c1 == '0') + (ISDIGIT (c1) != 0));
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4728
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4729
+  while ((diff = c1 - c2) == 0 && c1 != '\0')
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4730
+    {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4731
+      state = next_state[state];
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4732
+      c1 = *p1++;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4733
+      c2 = *p2++;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4734
+      state |= (c1 == '0') + (ISDIGIT (c1) != 0);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4735
+    }
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4736
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4737
+  state = result_type[state << 2 | ((c2 == '0') + (ISDIGIT (c2) != 0))];
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4738
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4739
+  switch (state)
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4740
+    {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4741
+    case CMP:
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4742
+      return diff;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4743
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4744
+    case LEN:
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4745
+      while (ISDIGIT (*p1++))
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4746
+	if (!ISDIGIT (*p2++))
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4747
+	  return 1;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4748
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4749
+      return ISDIGIT (*p2) ? -1 : diff;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4750
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4751
+    default:
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4752
+      return state;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4753
+    }
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4754
+}
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4755
+#ifdef weak_alias
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4756
+weak_alias (__strverscmp, strverscmp)
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4757
+#endif
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4758
diff --git a/src/strverscmp.h b/src/strverscmp.h
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4759
new file mode 100644
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4760
index 0000000..48670c8
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4761
--- /dev/null
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4762
+++ b/src/strverscmp.h
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4763
@@ -0,0 +1,25 @@
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4764
+/* Compare strings while treating digits characters numerically.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4765
+   Copyright (C) 1997, 2000, 2002, 2004, 2006 Free Software Foundation, Inc.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4766
+   This file is part of the GNU C Library.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4767
+   Contributed by Jean-François Bignolles <[email protected]>, 1997.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4768
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4769
+   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
  4770
+   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
  4771
+   the Free Software Foundation; either version 2, or (at your option)
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4772
+   any later version.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4773
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4774
+   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
  4775
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4776
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4777
+   GNU General Public License for more details.
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4778
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4779
+   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
  4780
+   with this program; if not, write to the Free Software Foundation,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4781
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4782
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4783
+#ifndef STRVERSCMP_H_
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4784
+# define STRVERSCMP_H_
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4785
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4786
+int strverscmp (const char *, const char *);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4787
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4788
+#endif /* not STRVERSCMP_H_ */
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4789
diff --git a/tools/Makefile.am b/tools/Makefile.am
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4790
index 13c191f..fa16c68 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4791
--- a/tools/Makefile.am
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4792
+++ b/tools/Makefile.am
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4793
@@ -54,6 +54,7 @@ sbin_PROGRAMS = \
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4794
 	ck-log-system-start		\
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4795
 	ck-log-system-restart		\
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4796
 	ck-log-system-stop		\
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4797
+	ck-seat-tool			\
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4798
 	$(NULL)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4799
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4800
 ck_launch_session_SOURCES =		\
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4801
@@ -83,6 +84,14 @@ ck_history_LDADD =			\
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4802
 	$(top_builddir)/src/libck-event-log.la	\
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4803
 	$(NULL)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4804
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4805
+ck_seat_tool_SOURCES =			\
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4806
+	ck-seat-tool.c			\
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4807
+	$(NULL)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4808
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4809
+ck_seat_tool_LDADD =			\
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4810
+	$(CONSOLE_KIT_LIBS)		\
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4811
+	$(NULL)
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4812
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4813
 ck_log_system_start_SOURCES =		\
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4814
 	ck-log-system-start.c		\
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4815
 	$(NULL)
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4816
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
  4817
new file mode 100644
17790
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  4818
index 0000000..0879d0d
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4819
--- /dev/null
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4820
+++ b/tools/ck-seat-tool.c
17790
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  4821
@@ -0,0 +1,443 @@
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4822
+/* -*- 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
  4823
+ *
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4824
+ * Copyright (C) 2009 Sun Microsystems, Inc.
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4825
+ *
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4826
+ * This program is free software; you can redistribute it and/or
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4827
+ * modify it under the terms of the GNU General Public License as
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4828
+ * published by the Free Software Foundation; either version 2 of the
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4829
+ * License, or (at your option) any later version.
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
+ * 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
  4832
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4833
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4834
+ * General Public License for more details.
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4835
+ *
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4836
+ * You should have received a copy of the GNU General Public License
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4837
+ * along with this program; if not, write to the Free Software
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4838
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4839
+ * 02111-1307, USA.
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4840
+ *
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4841
+ * Authors: Halton Huo <[email protected]>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4842
+ *
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
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4845
+#include "config.h"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4846
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4847
+#include <stdlib.h>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4848
+#include <stdio.h>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4849
+#include <sys/types.h>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4850
+#include <unistd.h>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4851
+#include <strings.h>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4852
+#include <glib/gi18n.h>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4853
+#include <dbus/dbus-glib.h>
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4854
+#include <dbus/dbus-glib-lowlevel.h>
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
+#define CK_NAME              "org.freedesktop.ConsoleKit"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4857
+#define CK_PATH              "/org/freedesktop/ConsoleKit"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4858
+#define CK_INTERFACE         "org.freedesktop.ConsoleKit"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4859
+#define CK_MANAGER_PATH      "/org/freedesktop/ConsoleKit/Manager"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4860
+#define CK_MANAGER_INTERFACE "org.freedesktop.ConsoleKit.Manager"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4861
+#define CK_SEAT_INTERFACE    "org.freedesktop.ConsoleKit.Seat"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4862
+#define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session"
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4863
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4864
+#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
  4865
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4866
+#define IS_STR_SET(x) (x != NULL && x[0] != '\0')
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4867
+#define CK_PATH_PREFIX       "/org/freedesktop/ConsoleKit/"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4868
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4869
+static gboolean  add = FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4870
+static gboolean  delete = FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4871
+static gboolean  show_version = FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4872
+static char     *session_type = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4873
+static char     *display_type = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4874
+static char     *seat_id = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4875
+static char     *session_id = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4876
+static gchar   **remaining_args = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4877
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4878
+static const GOptionEntry options [] = {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4879
+        { "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
  4880
+        { "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
  4881
+        { "display-type", '\0', 0, G_OPTION_ARG_STRING, &display_type, N_("Specify display type under <etc>/ConsoleKit/displays.d/ when adding a session."), NULL},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4882
+        { "seat-id", '\0', 0, G_OPTION_ARG_STRING, &seat_id, N_("Specify seat id when adding a session. If not given, create a new seat."), NULL},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4883
+        { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &remaining_args, N_("Specify values of variables in display type. For example display=:10"), NULL },
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4884
+        { "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
  4885
+        { "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
  4886
+        { "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
  4887
+        { NULL }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4888
+};
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4889
+
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4890
+static void
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4891
+add_session (DBusGConnection  *connection)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4892
+{
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4893
+        DBusGProxy *mgr_proxy = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4894
+        DBusGProxy *seat_proxy = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4895
+        GError     *error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4896
+        gboolean    res;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4897
+        char       *sid = NULL;
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4898
+        GPtrArray  *seats;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4899
+        char       *ssid = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4900
+        int         i;
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4901
+        gboolean    found;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4902
+        char       *sstype = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4903
+        GHashTable *variables = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4904
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4905
+        if (! IS_STR_SET (session_type)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4906
+                sstype = g_strdup ("LoginWindow");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4907
+        } else {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4908
+                sstype = g_strdup (session_type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4909
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4910
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4911
+        mgr_proxy = dbus_g_proxy_new_for_name (connection,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4912
+                                               CK_NAME,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4913
+                                               CK_MANAGER_PATH,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4914
+                                               CK_MANAGER_INTERFACE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4915
+        if (mgr_proxy == NULL) {
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4916
+                return;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4917
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4918
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4919
+        if (! IS_STR_SET(seat_id)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4920
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4921
+                /* If seat id is not given, create a new seat */
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4922
+                error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4923
+                res = dbus_g_proxy_call (mgr_proxy,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4924
+                                         "AddSeat",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4925
+                                         &error,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4926
+                                         G_TYPE_STRING, "Default",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4927
+                                         G_TYPE_INVALID,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4928
+                                         DBUS_TYPE_G_OBJECT_PATH, &sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4929
+                                         G_TYPE_INVALID);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4930
+                if (!res) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4931
+                        g_warning ("Unable to add seat: %s", error->message);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4932
+                        g_error_free (error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4933
+                        g_object_unref (mgr_proxy);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4934
+                        return;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4935
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4936
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4937
+        } else {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4938
+                if (!g_str_has_prefix (seat_id, CK_PATH_PREFIX)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4939
+                        sid = g_strdup_printf ("%s%s", CK_PATH_PREFIX, seat_id);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4940
+                } else {
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4941
+                        sid = g_strdup (seat_id);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4942
+                }
16647
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4943
+                /* Check whether seat is existing, if not, try to create it. */
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4944
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4945
+                error = NULL;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4946
+                res = dbus_g_proxy_call (mgr_proxy,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4947
+                                         "GetSeats",
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4948
+                                         &error,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4949
+                                         G_TYPE_INVALID,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4950
+                                         dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4951
+                                         &seats,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4952
+                                         G_TYPE_INVALID);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4953
+                if (!res) {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4954
+                        g_warning ("Unable to get seat list: %s", error->message);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4955
+                        g_error_free (error);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4956
+                        g_object_unref (mgr_proxy);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4957
+                        return;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4958
+                }
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4959
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4960
+                found = FALSE;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4961
+                for (i = 0; i < seats->len; i++) {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4962
+                        char *tmp_sid;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4963
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4964
+                        tmp_sid = g_ptr_array_index (seats, i);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4965
+                        if (g_str_equal (sid, tmp_sid)) {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4966
+                                found = TRUE;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4967
+                                g_free (tmp_sid);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4968
+                                break;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4969
+                        }
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4970
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4971
+                        g_free (tmp_sid);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4972
+                }
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4973
+
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4974
+                if (! found) {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4975
+                        error = NULL;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4976
+                        res = dbus_g_proxy_call (mgr_proxy,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4977
+                                                 "AddSeatById",
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4978
+                                                 &error,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4979
+                                                 G_TYPE_STRING, "Default",
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4980
+                                                 DBUS_TYPE_G_OBJECT_PATH, sid,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4981
+                                                 G_TYPE_INVALID,
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4982
+                                                 G_TYPE_INVALID);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4983
+                        if (!res) {
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4984
+                                g_warning ("Unable to add seat: %s", error->message);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4985
+                                g_error_free (error);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4986
+                                g_object_unref (mgr_proxy);
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4987
+                                return;
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4988
+                        }
01605ef551e5 2009-09-24 Halton Huo <[email protected]>
halton
parents: 16540
diff changeset
  4989
+                }
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4990
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  4991
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4992
+        seat_proxy = dbus_g_proxy_new_for_name (connection,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4993
+                                                CK_NAME,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4994
+                                                sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4995
+                                                CK_SEAT_INTERFACE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4996
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4997
+        if (seat_proxy == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4998
+                g_warning ("Failed to talk to seat '%s'", sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  4999
+                g_object_unref (mgr_proxy);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5000
+                return;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5001
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5002
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5003
+        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
  5004
+                                           (GDestroyNotify) g_free,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5005
+                                           (GDestroyNotify) g_free);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5006
+
17790
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  5007
+        if (remaining_args) {
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  5008
+                for (i = 0; i < G_N_ELEMENTS (remaining_args); i++) {
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  5009
+                        char **arr;
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  5010
+
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  5011
+                        /* split var=value */
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  5012
+                        arr = g_strsplit (remaining_args [i], "=", 2);
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  5013
+                        if (arr[0] && arr[1]) {
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  5014
+                                g_hash_table_insert (variables,
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  5015
+                                                     g_strdup(arr[0]),
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  5016
+                                                     g_strdup (arr[1]));
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  5017
+                        }
1531dbee2f22 2010-04-01 Halton Huo <[email protected]>
halton
parents: 17338
diff changeset
  5018
+                        g_strfreev (arr);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5019
+                }
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
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5022
+        error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5023
+        res = dbus_g_proxy_call (mgr_proxy,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5024
+                                 "AddSession",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5025
+                                 &error,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5026
+                                 DBUS_TYPE_G_OBJECT_PATH, sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5027
+                                 G_TYPE_STRING, sstype,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5028
+                                 G_TYPE_STRING, display_type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5029
+                                 CK_DBUS_TYPE_G_STRING_STRING_HASHTABLE, variables,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5030
+                                 G_TYPE_INVALID,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5031
+                                 DBUS_TYPE_G_OBJECT_PATH, &ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5032
+                                 G_TYPE_INVALID);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5033
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5034
+        if (!res) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5035
+                g_warning ("Unable to add dynamic session: %s", error->message);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5036
+                g_error_free (error);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5037
+        } else {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5038
+                dbus_g_proxy_call_no_reply (seat_proxy,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5039
+                                            "Manage",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5040
+                                            G_TYPE_INVALID,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5041
+                                            G_TYPE_INVALID);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5042
+                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
  5043
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5044
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5045
+        g_object_unref (seat_proxy);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5046
+        g_object_unref (mgr_proxy);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5047
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5048
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5049
+static gboolean
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5050
+is_session_on_seat (DBusGConnection *connection,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5051
+                    const char      *sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5052
+                    const char      *ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5053
+                    gboolean        *is_last_session)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5054
+{
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5055
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5056
+        DBusGProxy *seat_proxy = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5057
+        GPtrArray  *sessions = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5058
+        char       *ssid_tmp = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5059
+        gboolean    res;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5060
+        gboolean    retval = FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5061
+        int         i;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5062
+        GError     *error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5063
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5064
+        seat_proxy = dbus_g_proxy_new_for_name (connection,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5065
+                                                CK_NAME,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5066
+                                                sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5067
+                                                CK_SEAT_INTERFACE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5068
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5069
+        if (seat_proxy == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5070
+                g_warning ("Failed to talk to seat '%s'", sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5071
+                return FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5072
+        }
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5073
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5074
+        error = NULL;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5075
+        res = dbus_g_proxy_call (seat_proxy,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5076
+                                 "GetSessions",
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5077
+                                 &error,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5078
+                                 G_TYPE_INVALID,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5079
+                                 dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5080
+                                 &sessions,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5081
+                                 G_TYPE_INVALID);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5082
+        if (! res) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5083
+                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
  5084
+                g_error_free (error);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5085
+                g_object_unref (seat_proxy);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5086
+                return FALSE;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5087
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5088
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5089
+        for (i = 0; i < sessions->len; i++) {
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5090
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5091
+                ssid_tmp = g_ptr_array_index (sessions, i);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5092
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5093
+                if (g_str_equal (ssid, ssid_tmp)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5094
+                        retval = TRUE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5095
+                        break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5096
+                }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5097
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5098
+                g_free (ssid_tmp);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5099
+                ssid_tmp = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5100
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5101
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5102
+        if (is_last_session != NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5103
+                *is_last_session = sessions->len == 1;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5104
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5105
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5106
+        g_ptr_array_free (sessions, TRUE);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5107
+        g_object_unref (seat_proxy);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5108
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5109
+        return retval;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5110
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5111
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5112
+static char *
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5113
+find_seat_id_from_session_id (DBusGConnection *connection,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5114
+                              DBusGProxy      *proxy,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5115
+                              const char      *ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5116
+                              gboolean        *is_last_session)
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5117
+{
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5118
+        GError     *error;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5119
+        GPtrArray  *seats;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5120
+        int         i;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5121
+        char       *sid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5122
+        gboolean    res;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5123
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5124
+        error = NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5125
+        res = dbus_g_proxy_call (proxy,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5126
+                                 "GetSeats",
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5127
+                                 &error,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5128
+                                 G_TYPE_INVALID,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5129
+                                 dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5130
+                                 &seats,
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5131
+                                 G_TYPE_INVALID);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5132
+
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5133
+        if (! res) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5134
+                g_warning ("Failed to get list of seats: %s", error->message);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5135
+                g_error_free (error);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5136
+                return NULL;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5137
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5138
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5139
+        for (i = 0; i < seats->len; i++) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5140
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5141
+                sid = g_ptr_array_index (seats, i);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5142
+                if (is_session_on_seat (connection, sid, ssid, is_last_session)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5143
+                        break;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5144
+                }
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5145
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5146
+                g_free (sid);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5147
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5148
+        g_ptr_array_free (seats, TRUE);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5149
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5150
+        return sid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5151
+}
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5152
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5153
+static void
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5154
+delete_session (DBusGConnection *connection)
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5155
+{
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5156
+        DBusGProxy *proxy;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5157
+        char       *ssid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5158
+        char       *sid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5159
+        gboolean    is_last_session;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5160
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5161
+        if (!g_str_has_prefix (session_id, CK_PATH_PREFIX)) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5162
+                ssid = g_strdup_printf ("%s%s", CK_PATH_PREFIX, session_id);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5163
+        } else {
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5164
+                ssid = g_strdup (session_id);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5165
+        }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5166
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5167
+        proxy = dbus_g_proxy_new_for_name (connection,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5168
+                                           CK_NAME,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5169
+                                           CK_MANAGER_PATH,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5170
+                                           CK_MANAGER_INTERFACE);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5171
+        if (proxy == NULL) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5172
+                return;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5173
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5174
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5175
+        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
  5176
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5177
+        dbus_g_proxy_call_no_reply (proxy,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5178
+                                   "RemoveSession",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5179
+                                   DBUS_TYPE_G_OBJECT_PATH, ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5180
+                                   G_TYPE_INVALID,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5181
+                                   G_TYPE_INVALID);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5182
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5183
+        if (is_last_session) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5184
+                dbus_g_proxy_call_no_reply (proxy,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5185
+                                           "RemoveSeat",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5186
+                                           DBUS_TYPE_G_OBJECT_PATH, sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5187
+                                           G_TYPE_INVALID,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5188
+                                           G_TYPE_INVALID);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5189
+        }
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5190
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5191
+        g_object_unref (proxy);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5192
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5193
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5194
+int
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5195
+main (int argc, char *argv[])
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5196
+{
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5197
+        DBusGConnection *connection;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5198
+        GOptionContext  *ctx;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5199
+        GError          *error = NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5200
+        gboolean         res;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5201
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5202
+        g_type_init ();
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5203
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5204
+        /* Option parsing */
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5205
+        ctx = g_option_context_new (_("- Manage dynamic sessions"));
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5206
+        g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5207
+        res = g_option_context_parse (ctx, &argc, &argv, &error);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5208
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5209
+        if (!res) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5210
+                if (error) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5211
+                        g_warning ("%s", error->message);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5212
+                        g_error_free (error);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5213
+                }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5214
+                exit (1);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5215
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5216
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5217
+        g_option_context_free (ctx);    
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5218
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5219
+        if (show_version) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5220
+                g_print ("%s %s\n", argv[0], VERSION);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5221
+                exit (0);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5222
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5223
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5224
+        if (add && delete) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5225
+                g_warning ("Can not specify -a and -d at the same time!");
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5226
+                exit (1);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5227
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5228
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5229
+        if (!add && !delete) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5230
+                g_warning ("Must specify -a, -d!");
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5231
+                exit (1);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5232
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5233
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5234
+        if (delete && (! IS_STR_SET (session_id))) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5235
+                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
  5236
+                exit (1);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5237
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5238
+
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5239
+        if (add && (! IS_STR_SET (display_type)) ) {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5240
+                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
  5241
+                g_warning ("Invalid display type!");
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5242
+                exit (1);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5243
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5244
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5245
+        error = NULL;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5246
+        connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5247
+        if (connection == NULL) {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5248
+                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
  5249
+                g_error_free (error);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5250
+                exit (1);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5251
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5252
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5253
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5254
+        if (add) {
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5255
+                add_session (connection);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5256
+        } else if (delete) {
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5257
+                delete_session (connection);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5258
+        } else {
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5259
+                g_warning ("Invaild parameters!");
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5260
+                exit (1);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5261
+        }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5262
+
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5263
+        return 0;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5264
+}
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5265
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
  5266
index 3933772..cc69d57 100644
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5267
--- a/tools/list-sessions.c
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5268
+++ b/tools/list-sessions.c
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5269
@@ -46,6 +46,23 @@
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5270
 #define CK_SEAT_INTERFACE    "org.freedesktop.ConsoleKit.Seat"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5271
 #define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session"
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5272
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5273
+#define IS_STR_SET(x) (x != NULL && x[0] != '\0')
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5274
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5275
+typedef struct CkSessionOutput {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5276
+        char    *prop_name;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5277
+        char    *prop_value;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5278
+} CkSessionOutput;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5279
+
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  5280
+static gboolean do_all = FALSE;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5281
+static gboolean do_version = FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5282
+static char *do_format = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5283
+static GOptionEntry entries [] = {
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  5284
+        { "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
  5285
+        { "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
  5286
+        { "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
  5287
+        { NULL }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5288
+};
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5289
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5290
 static gboolean
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5291
 get_uint (DBusGProxy *proxy,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5292
           const char *method,
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5293
@@ -176,6 +193,7 @@ list_session (DBusGConnection *connection,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5294
         char       *sid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5295
         char       *lsid;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5296
         char       *session_type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5297
+        char       *display_type;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5298
         char       *x11_display;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5299
         char       *x11_display_device;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5300
         char       *display_device;
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5301
@@ -184,8 +202,11 @@ list_session (DBusGConnection *connection,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5302
         char       *idle_since_hint;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5303
         gboolean    is_active;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5304
         gboolean    is_local;
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5305
+        gboolean    is_open;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5306
         char       *short_sid;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5307
         const char *short_ssid;
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5308
+        char      **format_arr = NULL;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5309
+        int         i, j;
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5310
 
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5311
         proxy = dbus_g_proxy_new_for_name (connection,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5312
                                            CK_NAME,
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5313
@@ -198,6 +219,7 @@ list_session (DBusGConnection *connection,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5314
         sid = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5315
         lsid = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5316
         session_type = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5317
+        display_type = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5318
         x11_display = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5319
         x11_display_device = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5320
         display_device = NULL;
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5321
@@ -209,15 +231,21 @@ list_session (DBusGConnection *connection,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5322
         get_path (proxy, "GetSeatId", &sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5323
         get_string (proxy, "GetLoginSessionId", &lsid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5324
         get_string (proxy, "GetSessionType", &session_type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5325
+        get_string (proxy, "GetDisplayType", &display_type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5326
         get_string (proxy, "GetX11Display", &x11_display);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5327
         get_string (proxy, "GetX11DisplayDevice", &x11_display_device);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5328
         get_string (proxy, "GetDisplayDevice", &display_device);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5329
         get_string (proxy, "GetRemoteHostName", &remote_host_name);
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5330
+        get_boolean (proxy, "IsOpen", &is_open);
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5331
         get_boolean (proxy, "IsActive", &is_active);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5332
         get_boolean (proxy, "IsLocal", &is_local);
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5333
         get_string (proxy, "GetCreationTime", &creation_time);
16475
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  5334
         get_string (proxy, "GetIdleSinceHint", &idle_since_hint);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  5335
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  5336
+        if (!do_all && !is_open) {
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  5337
+                return;
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  5338
+        }
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  5339
+
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  5340
         realname = get_real_name (uid);
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  5341
 
32822089fdde 2009-09-04 Halton Huo <[email protected]>
halton
parents: 16232
diff changeset
  5342
         short_sid = sid;
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5343
@@ -230,24 +258,49 @@ list_session (DBusGConnection *connection,
16129
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5344
                 short_ssid = ssid + strlen (CK_PATH) + 1;
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5345
         }
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5346
 
0eb6a33bac3f 2009-07-27 Halton Huo <[email protected]>
halton
parents:
diff changeset
  5347
-        printf ("%s:\n\tunix-user = '%d'\n\trealname = '%s'\n\tseat = '%s'\n\tsession-type = '%s'\n\tactive = %s\n\tx11-display = '%s'\n\tx11-display-device = '%s'\n\tdisplay-device = '%s'\n\tremote-host-name = '%s'\n\tis-local = %s\n\ton-since = '%s'\n\tlogin-session-id = '%s'",
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5348
-                short_ssid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5349
-                uid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5350
-                realname,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5351
-                short_sid,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5352
-                session_type,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5353
-                is_active ? "TRUE" : "FALSE",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5354
-                x11_display,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5355
-                x11_display_device,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5356
-                display_device,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5357
-                remote_host_name,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5358
-                is_local ? "TRUE" : "FALSE",
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5359
-                creation_time,
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5360
-                lsid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5361
-        if (idle_since_hint != NULL && idle_since_hint[0] != '\0') {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5362
-                printf ("\n\tidle-since-hint = '%s'", idle_since_hint);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5363
+        CkSessionOutput output[] = {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5364
+                {"session-id", g_strdup (short_ssid)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5365
+                {"unix-user", g_strdup_printf ("%d", uid)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5366
+                {"realname", g_strdup (realname)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5367
+                {"seat", g_strdup (short_sid)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5368
+                {"session-type", g_strdup (session_type)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5369
+                {"display-type", g_strdup (display_type)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5370
+                {"open", is_open ? "TRUE" : "FALSE"},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5371
+                {"active", is_active ? "TRUE" : "FALSE"},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5372
+                {"x11-display", g_strdup (x11_display)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5373
+                {"x11-display-device", g_strdup (x11_display_device)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5374
+                {"display-device", g_strdup (display_device)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5375
+                {"remote-host-name", g_strdup (remote_host_name)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5376
+                {"is-local", is_local ? "TRUE" : "FALSE"},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5377
+                {"on-since", g_strdup (creation_time)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5378
+                {"login-session-id", g_strdup (lsid)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5379
+                {"idle-since-hint", g_strdup (idle_since_hint)},
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5380
+        };
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5381
+
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5382
+        if (IS_STR_SET (do_format)) {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5383
+                format_arr = g_strsplit (do_format, ",", -1);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5384
+
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5385
+                for (i = 0; format_arr[i] != NULL; ++i) {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5386
+                        for (j = 0; j < G_N_ELEMENTS (output); j++) {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5387
+                                if (g_str_equal (format_arr[i], output[j].prop_name)) {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5388
+                                        printf ("'%s'\t", output[j].prop_value);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5389
+                                        break;
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5390
+                                }
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5391
+                        }
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5392
+                }
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5393
+                printf ("\n");
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5394
+                g_strfreev (format_arr);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5395
+
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5396
+        } else {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5397
+                for (j = 0; j < G_N_ELEMENTS (output); j++) {
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5398
+                        if (g_str_equal (output[j].prop_name, "session-id"))
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5399
+                                printf ("%s:\n", output[j].prop_value);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5400
+                        else
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5401
+                                printf ("\t%s = '%s'\n",
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5402
+                                        output[j].prop_name,
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5403
+                                        output[j].prop_value);
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5404
+                }
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5405
         }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5406
-        printf ("\n");
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5407
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5408
         g_free (idle_since_hint);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5409
         g_free (creation_time);
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5410
@@ -256,9 +309,11 @@ list_session (DBusGConnection *connection,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5411
         g_free (sid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5412
         g_free (lsid);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5413
         g_free (session_type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5414
+        g_free (display_type);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5415
         g_free (x11_display);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5416
         g_free (x11_display_device);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5417
         g_free (display_device);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5418
+
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5419
         g_object_unref (proxy);
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5420
 }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5421
 
16540
e60b1f38ebfc 2009-09-11 Halton Huo <[email protected]>
halton
parents: 16491
diff changeset
  5422
@@ -368,11 +423,6 @@ main (int    argc,
16232
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5423
         GOptionContext *context;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5424
         gboolean        retval;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5425
         GError         *error = NULL;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5426
-        static gboolean do_version = FALSE;
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5427
-        static GOptionEntry entries [] = {
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5428
-                { "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
  5429
-                { NULL }
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5430
-        };
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5431
 
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5432
         g_type_init ();
91d6b1a00d88 2009-08-11 Halton Huo <[email protected]>
halton
parents: 16129
diff changeset
  5433