[PATCH 20/20] [client] add has active vt? request

Scott James Remnant scott at ubuntu.com
Thu Mar 18 14:10:52 PDT 2010


This asks the daemon whether it has an active VT, used for a smooth
transition into X.

I've implemented this to look like ping.
---
 src/client/ply-boot-client.c |   10 ++++++++++
 src/client/ply-boot-client.h |    4 ++++
 src/client/plymouth.c        |   15 ++++++++++++++-
 3 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/src/client/ply-boot-client.c b/src/client/ply-boot-client.c
index 58c5e44..c3373f0 100644
--- a/src/client/ply-boot-client.c
+++ b/src/client/ply-boot-client.c
@@ -723,6 +723,16 @@ ply_boot_client_tell_daemon_to_progress_unpause (ply_boot_client_t
 }
 
 void
+ply_boot_client_ask_daemon_has_active_vt (ply_boot_client_t                  *client,
+                                          ply_boot_client_response_handler_t  handler,
+                                          ply_boot_client_response_handler_t  failed_handler,
+                                          void                               *user_data)
+{
+  ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_HAS_ACTIVE_VT,
+                                 NULL, handler, failed_handler, user_data);
+}
+
+void
 ply_boot_client_tell_daemon_about_error (ply_boot_client_t                  *client,
                                          ply_boot_client_response_handler_t  handler,
                                          ply_boot_client_response_handler_t  failed_handler,
diff --git a/src/client/ply-boot-client.h b/src/client/ply-boot-client.h
index 046b6f7..1608876 100644
--- a/src/client/ply-boot-client.h
+++ b/src/client/ply-boot-client.h
@@ -125,6 +125,10 @@ void ply_boot_client_tell_daemon_to_progress_unpause (ply_boot_client_t
                                                       ply_boot_client_response_handler_t  handler,
                                                       ply_boot_client_response_handler_t  failed_handler,
                                                       void                               *user_data);
+void ply_boot_client_ask_daemon_has_active_vt (ply_boot_client_t                  *client,
+                                               ply_boot_client_response_handler_t  handler,
+                                               ply_boot_client_response_handler_t  failed_handler,
+                                               void                               *user_data);
 void ply_boot_client_disconnect (ply_boot_client_t *client);
 void ply_boot_client_attach_to_event_loop (ply_boot_client_t *client,
                                            ply_event_loop_t  *loop);
diff --git a/src/client/plymouth.c b/src/client/plymouth.c
index 5dffba8..544c557 100644
--- a/src/client/plymouth.c
+++ b/src/client/plymouth.c
@@ -740,7 +740,7 @@ main (int    argc,
       char **argv)
 {
   state_t state = { 0 };
-  bool should_help, should_quit, should_ping, should_sysinit, should_ask_for_password, should_show_splash, should_hide_splash, should_wait, should_be_verbose, report_error, should_get_plugin_path;
+  bool should_help, should_quit, should_ping, should_have_active_vt, should_sysinit, should_ask_for_password, should_show_splash, should_hide_splash, should_wait, should_be_verbose, report_error, should_get_plugin_path;
   bool is_connected;
   char *status, *chroot_dir, *ignore_keystroke;
   int exit_code;
@@ -760,6 +760,7 @@ main (int    argc,
                                   "newroot", "Tell boot daemon that new root filesystem is mounted", PLY_COMMAND_OPTION_TYPE_STRING,
                                   "quit", "Tell boot daemon to quit", PLY_COMMAND_OPTION_TYPE_FLAG,
                                   "ping", "Check of boot daemon is running", PLY_COMMAND_OPTION_TYPE_FLAG,
+                                  "has-active-vt", "Check if boot daemon has an active vt", PLY_COMMAND_OPTION_TYPE_FLAG,
                                   "sysinit", "Tell boot daemon root filesystem is mounted read-write", PLY_COMMAND_OPTION_TYPE_FLAG,
                                   "show-splash", "Show splash screen", PLY_COMMAND_OPTION_TYPE_FLAG,
                                   "hide-splash", "Hide splash screen", PLY_COMMAND_OPTION_TYPE_FLAG,
@@ -868,6 +869,7 @@ main (int    argc,
                                   "newroot", &chroot_dir,
                                   "quit", &should_quit,
                                   "ping", &should_ping,
+                                  "has-active-vt", &should_has_active_vt,
                                   "sysinit", &should_sysinit,
                                   "show-splash", &should_show_splash,
                                   "hide-splash", &should_hide_splash,
@@ -921,6 +923,11 @@ main (int    argc,
           ply_trace ("ping failed");
           return 1;
         }
+      if (should_has_active_vt)
+        {
+          ply_trace ("has active vt? failed");
+          return 1;
+        }
     }
 
   ply_boot_client_attach_to_event_loop (state.client, state.loop);
@@ -950,6 +957,12 @@ main (int    argc,
                                  on_success, 
                                  (ply_boot_client_response_handler_t)
                                  on_failure, &state);
+  else if (should_has_active_vt)
+    ply_boot_client_ask_daemon_has_active_vt (state.client,
+                                              (ply_boot_client_response_handler_t)
+                                              on_success, 
+                                              (ply_boot_client_response_handler_t)
+                                              on_failure, &state);
   else if (status != NULL)
     ply_boot_client_update_daemon (state.client, status,
                                    (ply_boot_client_response_handler_t)
-- 
1.7.0



More information about the plymouth mailing list