summaryrefslogtreecommitdiff
path: root/user/consolekit2/add-listseats.patch
blob: 44bc034c88e310cc7156786bf7b8ec39da035f72 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
diff --git a/data/ConsoleKit.conf b/data/ConsoleKit.conf
index 6c10476..216a0e9 100644
--- a/data/ConsoleKit.conf
+++ b/data/ConsoleKit.conf
@@ -80,6 +80,9 @@
            send_member="CloseSession"/>
     <allow send_destination="org.freedesktop.ConsoleKit"
            send_interface="org.freedesktop.ConsoleKit.Manager"
+           send_member="ListSeats"/>
+    <allow send_destination="org.freedesktop.ConsoleKit"
+           send_interface="org.freedesktop.ConsoleKit.Manager"
            send_member="GetSeats"/>
     <allow send_destination="org.freedesktop.ConsoleKit"
            send_interface="org.freedesktop.ConsoleKit.Manager"
diff --git a/src/ck-manager.c b/src/ck-manager.c
index 4722bdb..7d8b8b2 100644
--- a/src/ck-manager.c
+++ b/src/ck-manager.c
@@ -3841,6 +3841,44 @@ dbus_unlock_session (ConsoleKitManager *ckmanager,
 }
 
 static gboolean
+dbus_list_seats (ConsoleKitManager     *ckmanager,
+                 GDBusMethodInvocation *context)
+{
+        CkManager       *manager;
+        GVariantBuilder  seat_builder;
+        GVariant        *seat;
+        GHashTableIter   seat_iter;
+        const gchar     *key;
+        CkSeat          *value;
+
+        TRACE ();
+
+        manager = CK_MANAGER (ckmanager);
+
+        g_return_val_if_fail (CK_IS_MANAGER (manager), FALSE);
+
+        /* if we don't have seats, we need to return NULL */
+        if (g_hash_table_size (manager->priv->seats) == 0) {
+                throw_error (context, CK_MANAGER_ERROR_NO_SEATS, _("User has no seats"));
+                return TRUE;
+        }
+
+        g_variant_builder_init (&seat_builder, G_VARIANT_TYPE_ARRAY);
+
+        g_hash_table_iter_init (&seat_iter, manager->priv->seats);
+        while (g_hash_table_iter_next (&seat_iter, &key, &value)) {
+                seat = g_variant_new("(so)",
+                                     console_kit_seat_get_name( CONSOLE_KIT_SEAT(value) ),
+                                     key);
+
+                g_variant_builder_add_value (&seat_builder, seat);
+        }
+
+        console_kit_manager_complete_list_seats (ckmanager, context, g_variant_builder_end (&seat_builder));
+        return TRUE;
+}
+
+static gboolean
 dbus_get_seats (ConsoleKitManager     *ckmanager,
                 GDBusMethodInvocation *context)
 {
@@ -4134,6 +4172,7 @@ ck_manager_iface_init (ConsoleKitManagerIface *iface)
         iface->handle_stop                         = dbus_stop;
         iface->handle_suspend                      = dbus_suspend;
         iface->handle_close_session                = dbus_close_session;
+        iface->handle_list_seats                   = dbus_list_seats;
         iface->handle_get_seats                    = dbus_get_seats;
         iface->handle_get_sessions                 = dbus_get_sessions;
         iface->handle_get_sessions_for_unix_user   = dbus_get_sessions_for_unix_user;
diff --git a/src/org.freedesktop.ConsoleKit.Manager.xml b/src/org.freedesktop.ConsoleKit.Manager.xml
index a44880c..024a3e2 100644
--- a/src/org.freedesktop.ConsoleKit.Manager.xml
+++ b/src/org.freedesktop.ConsoleKit.Manager.xml
@@ -531,6 +531,24 @@
       </doc:doc>
     </method>
 
+    <method name="ListSeats">
+      <arg name="seats" direction="out" type="a(so)">
+        <doc:doc>
+          <doc:summary>an array of seat names and IDs</doc:summary>
+        </doc:doc>
+      </arg>
+      <doc:doc>
+        <doc:description>
+          <doc:para>Retrieves a list of all <doc:ref type="interface" to="Seat">Seats</doc:ref>
+          that are present on the system.</doc:para>
+          <doc:para>Like the logind method of the same name, this returns both the seat's name
+          (such as "seat0") and the D-Bus object path for the seat object that implements the
+          <doc:ref type="interface" to="Seat">Seat</doc:ref> interface.</doc:para>
+        </doc:description>
+        <doc:seealso><doc:ref type="method" to="Manager.GetSeats">GetSeats()</doc:ref></doc:seealso>
+      </doc:doc>
+    </method>
+
     <method name="GetSeats">
       <arg name="seats" direction="out" type="ao">
         <doc:doc>