chiark / gitweb /
login: wrap CanTTY and CanGraphical seat attributes in libsystemd-login
authorLennart Poettering <lennart@poettering.net>
Thu, 21 Jun 2012 14:52:54 +0000 (16:52 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 21 Jun 2012 14:52:54 +0000 (16:52 +0200)
man/sd_seat_get_active.xml
man/sd_session_is_active.xml
src/login/libsystemd-login.sym
src/login/sd-login.c
src/login/test-login.c
src/systemd/sd-login.h

index 997c3889012e1bc4ef53fbda53459ca6ba7b133e..82a1ea0481cd11ed811563638006fcd2b53f1865 100644 (file)
                                 <funcdef>int <function>sd_seat_can_multi_session</function></funcdef>
                                 <paramdef>const char* <parameter>seat</parameter></paramdef>
                         </funcprototype>
+
+                        <funcprototype>
+                                <funcdef>int <function>sd_seat_can_tty</function></funcdef>
+                                <paramdef>const char* <parameter>seat</parameter></paramdef>
+                        </funcprototype>
+
+                        <funcprototype>
+                                <funcdef>int <function>sd_seat_can_graphical</function></funcdef>
+                                <paramdef>const char* <parameter>seat</parameter></paramdef>
+                        </funcprototype>
                 </funcsynopsis>
         </refsynopsisdiv>
 
                 sessions in parallel (whith only one being active at a
                 time).</para>
 
+                <para><function>sd_seat_can_tty()</function> may be
+                used to determine whether a specific seat provides TTY
+                functionality, i.e. is useful as a text console.</para>
+
+                <para><function>sd_seat_can_graphical()</function> may
+                be used to determine whether a specific seat provides
+                graphics functionality, i.e. is useful as a graphics
+                display.</para>
+
                 <para>If the <literal>seat</literal> parameter of any
                 of these functions is passed as NULL the operation is
                 executed for the seat of the session of the calling
                 <function>sd_seat_get_sessions()</function> returns
                 the number of entries in the session identifier
                 array. If the test succeeds
-                <function>sd_seat_can_multi_session</function> returns
-                a positive integer, if it fails 0. On failure, these
+                <function>sd_seat_can_multi_session</function>,
+                <function>sd_seat_can_tty</function> and
+                <function>sd_seat_can_graphical</function> return a
+                positive integer, if it fails 0. On failure, these
                 calls return a negative errno-style error code.</para>
         </refsect1>
 
                 <title>Notes</title>
 
                 <para>The <function>sd_seat_get_active()</function>,
-                <function>sd_seat_get_sessions()</function>, and
-                <function>sd_seat_can_multi_session()</function> interfaces
+                <function>sd_seat_get_sessions()</function>,
+                <function>sd_seat_can_multi_session()</function>,
+                <function>sd_seat_can_tty()</function> and
+                <function>sd_seat_can_grapical()</function> interfaces
                 are available as shared library, which can be compiled
                 and linked to with the
                 <literal>libsystemd-login</literal>
index f9b287454140fe5f4b18c199875b3f9ee2b554e4..a14286aeabf4bf3387d5259a05f465f0a7e6ecee 100644 (file)
                 <para>If the test succeeds
                 <function>sd_session_is_active()</function> returns a
                 positive integer, if it fails 0.  On success
+                <function>sd_session_get_state()</function>,
                 <function>sd_session_get_uid()</function>,
-                <function>sd_session_get_service()</function> and
-                <function>sd_session_get_seat()</function> return 0 or
+                <function>sd_session_get_seat()</function>,
+                <function>sd_session_get_service()</function>,
+                <function>sd_session_get_type()</function>,
+                <function>sd_session_get_class()</function> and
+                <function>sd_session_get_display()</function> return 0 or
                 a positive integer. On failure, these calls return a
                 negative errno-style error code.</para>
         </refsect1>
                 <title>Notes</title>
 
                 <para>The <function>sd_session_is_active()</function>,
+                <function>sd_session_get_state()</function>,
                 <function>sd_session_get_uid()</function>,
-                <function>sd_session_get_service()</function> and
-                <function>sd_session_get_seat()</function> interfaces
+                <function>sd_session_get_seat()</function>,
+                <function>sd_session_get_service()</function>,
+                <function>sd_session_get_type()</function>,
+                <function>sd_session_get_class()</function> and
+                <function>sd_session_get_display()</function> interfaces
                 are available as shared library, which can be compiled
                 and linked to with the
                 <literal>libsystemd-login</literal>
index 347e0730a6e8fb6fc8803b2c5f865f22ca1cac9d..ff51be729bf1849b3c6ce09548c8f3143a4da302 100644 (file)
@@ -50,4 +50,6 @@ global:
 LIBSYSTEMD_LOGIN_186 {
 global:
         sd_session_get_state;
+        sd_seat_can_tty;
+        sd_seat_can_graphical;
 } LIBSYSTEMD_LOGIN_43;
index 223e121bed3614a6fd2f4ad39e5e4ec954b9fd37..1978a05dc02809e887c7330d425bb06b1c5b4f6e 100644 (file)
@@ -583,7 +583,7 @@ _public_ int sd_seat_get_sessions(const char *seat, char ***sessions, uid_t **ui
         return r;
 }
 
-_public_ int sd_seat_can_multi_session(const char *seat) {
+static int seat_get_can(const char *seat, const char *variable) {
         char *p, *s = NULL;
         int r;
 
@@ -592,7 +592,7 @@ _public_ int sd_seat_can_multi_session(const char *seat) {
                 return r;
 
         r = parse_env_file(p, NEWLINE,
-                           "CAN_MULTI_SESSION", &s,
+                           variable, &s,
                            NULL);
         free(p);
 
@@ -610,6 +610,18 @@ _public_ int sd_seat_can_multi_session(const char *seat) {
         return r;
 }
 
+_public_ int sd_seat_can_multi_session(const char *seat) {
+        return seat_get_can(seat, "CAN_MULTI_SESSION");
+}
+
+_public_ int sd_seat_can_tty(const char *seat) {
+        return seat_get_can(seat, "CAN_TTY");
+}
+
+_public_ int sd_seat_can_graphical(const char *seat) {
+        return seat_get_can(seat, "CAN_GRAPHICAL");
+}
+
 _public_ int sd_get_seats(char ***seats) {
         return get_files_in_directory("/run/systemd/seats/", seats);
 }
index d0916ced6a11a6d1b67b4a72417ea42ad4755d6a..159ff3efc5b3f07fa1bacfaad7a2a5055d51ffdd 100644 (file)
@@ -99,6 +99,14 @@ int main(int argc, char* argv[]) {
         assert_se(r >= 0);
         printf("can do multi session = %s\n", yes_no(r));
 
+        r = sd_seat_can_tty(seat);
+        assert_se(r >= 0);
+        printf("can do tty = %s\n", yes_no(r));
+
+        r = sd_seat_can_graphical(seat);
+        assert_se(r >= 0);
+        printf("can do graphical = %s\n", yes_no(r));
+
         assert_se(sd_uid_get_state(u, &state) >= 0);
         printf("state = %s\n", state);
 
index bddc74e729404fb9d5541e1a55b850561d77994c..1a36a56b12c9060c782e39e6d13e779f28c6cf6b 100644 (file)
@@ -117,6 +117,12 @@ int sd_seat_get_sessions(const char *seat, char ***sessions, uid_t **uid, unsign
 /* Return whether the seat is multi-session capable */
 int sd_seat_can_multi_session(const char *seat);
 
+/* Return whether the seat is TTY capable, i.e. suitable for showing console UIs */
+int sd_seat_can_tty(const char *seat);
+
+/* Return whether the seat is graphics capable, i.e. suitable for showing graphical UIs */
+int sd_seat_can_graphical(const char *seat);
+
 /* Get all seats, store in *seats. Returns the number of seats. If
  * seats is NULL only returns number of seats. */
 int sd_get_seats(char ***seats);