diff options
| author | William Jon McCann <mccann@jhu.edu> | 2008-01-23 11:04:23 -0500 | 
|---|---|---|
| committer | William Jon McCann <mccann@jhu.edu> | 2008-01-23 11:04:23 -0500 | 
| commit | 6ad7516f69f08c9c5e30332f95b50c0dd0cd1cb1 (patch) | |
| tree | cd62f5c26ff39e03d038caec178ff8bda19e15e3 | |
| parent | 4b866a4af70fb19e8b0652637815ab24ad630065 (diff) | |
add GetSessions method to Manager interface
| -rw-r--r-- | doc/spec/ck-manager.xml | 17 | ||||
| -rw-r--r-- | doc/xml/ref-ck-manager.xml | 10 | ||||
| -rw-r--r-- | src/ck-manager.c | 25 | ||||
| -rw-r--r-- | src/ck-manager.h | 3 | ||||
| -rw-r--r-- | src/ck-manager.xml | 3 | 
5 files changed, 57 insertions, 1 deletions
diff --git a/doc/spec/ck-manager.xml b/doc/spec/ck-manager.xml index acc065b..f405c25 100644 --- a/doc/spec/ck-manager.xml +++ b/doc/spec/ck-manager.xml @@ -150,6 +150,23 @@        </doc:doc>      </method> +    <method name="GetSessions"> +      <arg name="sessions" direction="out" type="ao"> +        <doc:doc> +          <doc:summary>an array of Session IDs</doc:summary> +        </doc:doc> +      </arg> +      <doc:doc> +        <doc:description> +          <doc:para>This gets a list of all the <doc:ref type="interface" to="Sessions">Sessions</doc:ref> +          that are currently present on the system.</doc:para> +          <doc:para>Each Session ID is an D-Bus object path for the object that implements the +          <doc:ref type="interface" to="Session">Session</doc:ref> interface.</doc:para> +        </doc:description> +        <doc:seealso><doc:ref type="interface" to="Session">org.freedesktop.ConsoleKit.Session</doc:ref></doc:seealso> +      </doc:doc> +    </method> +      <method name="GetSessionForCookie">        <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>        <arg name="cookie" direction="in" type="s"> diff --git a/doc/xml/ref-ck-manager.xml b/doc/xml/ref-ck-manager.xml index f964295..3eb3a92 100644 --- a/doc/xml/ref-ck-manager.xml +++ b/doc/xml/ref-ck-manager.xml @@ -16,6 +16,7 @@  <link linkend="Manager.CloseSession">CloseSession</link>              (in  's'     cookie,                             out 'b'     result)  <link linkend="Manager.GetSeats">GetSeats</link>                  (out 'ao'    seats) +<link linkend="Manager.GetSessions">GetSessions</link>               (out 'ao'    sessions)  <link linkend="Manager.GetSessionForCookie">GetSessionForCookie</link>       (in  's'     cookie,                             out 'o'     ssid)  <link linkend="Manager.GetSessionForUnixProcess">GetSessionForUnixProcess</link>  (in  'u'     pid, @@ -132,7 +133,14 @@ See also:            <link linkend="Seat">Seat</link> interface.</para>          <variablelist role="params"><varlistentry><term><parameter>seats</parameter>:</term><listitem><simpara>an array of Seat IDs</simpara></listitem></varlistentry></variablelist><para>  See also: -<link linkend="Seat">org.freedesktop.ConsoleKit.Seat</link></para><refsect2><title><anchor role="function" id="Manager.GetSessionForCookie"/>GetSessionForCookie ()</title><indexterm><primary>GetSessionForCookie</primary><secondary>Manager</secondary></indexterm><programlisting>GetSessionForCookie (in  's' cookie, +<link linkend="Seat">org.freedesktop.ConsoleKit.Seat</link></para><refsect2><title><anchor role="function" id="Manager.GetSessions"/>GetSessions ()</title><indexterm><primary>GetSessions</primary><secondary>Manager</secondary></indexterm><programlisting>GetSessions (out 'ao' sessions)</programlisting></refsect2> +          <para>This gets a list of all the <link linkend="Sessions">Sessions</link> +          that are currently present on the system.</para> +          <para>Each Session ID is an D-Bus object path for the object that implements the +          <link linkend="Session">Session</link> interface.</para> +        <variablelist role="params"><varlistentry><term><parameter>sessions</parameter>:</term><listitem><simpara>an array of Session IDs</simpara></listitem></varlistentry></variablelist><para> +See also: +<link linkend="Session">org.freedesktop.ConsoleKit.Session</link></para><refsect2><title><anchor role="function" id="Manager.GetSessionForCookie"/>GetSessionForCookie ()</title><indexterm><primary>GetSessionForCookie</primary><secondary>Manager</secondary></indexterm><programlisting>GetSessionForCookie (in  's' cookie,                       out 'o' ssid)</programlisting></refsect2>            <para>Returns the session ID that is associated with the specified cookie.            </para> diff --git a/src/ck-manager.c b/src/ck-manager.c index 9771d30..156ea93 100644 --- a/src/ck-manager.c +++ b/src/ck-manager.c @@ -2412,6 +2412,31 @@ ck_manager_get_seats (CkManager  *manager,  }  static void +listify_session_ids (char       *id, +                     CkSession  *session, +                     GPtrArray **array) +{ +        g_ptr_array_add (*array, g_strdup (id)); +} + +gboolean +ck_manager_get_sessions (CkManager  *manager, +                         GPtrArray **sessions, +                         GError    **error) +{ +        g_return_val_if_fail (CK_IS_MANAGER (manager), FALSE); + +        if (sessions == NULL) { +                return FALSE; +        } + +        *sessions = g_ptr_array_new (); +        g_hash_table_foreach (manager->priv->sessions, (GHFunc)listify_session_ids, sessions); + +        return TRUE; +} + +static void  add_seat_for_file (CkManager  *manager,                     const char *filename)  { diff --git a/src/ck-manager.h b/src/ck-manager.h index 55cb5cb..45910b7 100644 --- a/src/ck-manager.h +++ b/src/ck-manager.h @@ -85,6 +85,9 @@ gboolean            ck_manager_restart                        (CkManager  /* Authoritative properties */  gboolean            ck_manager_open_session                   (CkManager             *manager,                                                                 DBusGMethodInvocation *context); +gboolean            ck_manager_get_sessions                   (CkManager             *manager, +                                                               GPtrArray            **sessions, +                                                               GError               **error);  gboolean            ck_manager_get_seats                      (CkManager             *manager,                                                                 GPtrArray            **seats,                                                                 GError               **error); diff --git a/src/ck-manager.xml b/src/ck-manager.xml index 031d8a1..0ca74fa 100644 --- a/src/ck-manager.xml +++ b/src/ck-manager.xml @@ -24,6 +24,9 @@      <method name="GetSeats">        <arg name="seats" direction="out" type="ao"/>      </method> +    <method name="GetSessions"> +      <arg name="sessions" direction="out" type="ao"/> +    </method>      <method name="GetSessionForCookie">        <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>        <arg name="cookie" direction="in" type="s"/>  | 
