]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
Clearword entry and moving password entry to a higher level. input-rework
authorCharles Brej <cbrej@cs.man.ac.uk>
Wed, 3 Dec 2008 16:03:25 +0000 (16:03 +0000)
committerCharles Brej <cbrej@cs.man.ac.uk>
Wed, 3 Dec 2008 16:03:25 +0000 (16:03 +0000)
21 files changed:
src/client/ply-boot-client.c
src/client/ply-boot-client.h
src/client/plymouth.c
src/libply/ply-buffer.c
src/libplybootsplash/ply-boot-splash-plugin.h
src/libplybootsplash/ply-entry.c
src/libplybootsplash/ply-entry.h
src/libplybootsplash/ply-window.c
src/main.c
src/plugins/splash/details/plugin.c
src/plugins/splash/fade-in/bullet.png
src/plugins/splash/fade-in/plugin.c
src/plugins/splash/pulser/plugin.c
src/plugins/splash/solar/plugin.c
src/plugins/splash/spinfinity/plugin.c
src/plugins/splash/text/plugin.c
src/ply-boot-protocol.h
src/ply-boot-server.c
src/ply-boot-server.h
src/ply-boot-splash.c
src/ply-boot-splash.h

index 43d550722b3b64750d7eff5e7ed6b6bf3dbbffea..7f81ceee156c57bc1e42d52493823139a5cd50e0 100644 (file)
@@ -569,6 +569,21 @@ ply_boot_client_ask_daemon_for_cached_passwords (ply_boot_client_t
                                  handler, failed_handler, user_data);
 }
 
+void
+ply_boot_client_ask_daemon_for_clearword (ply_boot_client_t                  *client,
+
+                                         const char *prompt,
+                                         ply_boot_client_answer_handler_t    handler,
+                                         ply_boot_client_response_handler_t  failed_handler,
+                                         void                               *user_data)
+{
+  assert (client != NULL);
+
+  ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_CLEARWORD,
+                                 prompt, (ply_boot_client_response_handler_t)
+                                 handler, failed_handler, user_data);
+}
+
 void
 ply_boot_client_ask_daemon_to_watch_for_keystroke (ply_boot_client_t                     *client,
                                          const char                             *keys,
index dcdf92400637ab9d70f7e60ae24dcbbddb4ef43b..7e157cfc54dcff40554563d548002559e9b4ddfe 100644 (file)
@@ -76,6 +76,11 @@ void ply_boot_client_ask_daemon_for_cached_passwords (ply_boot_client_t
                                                       ply_boot_client_multiple_answers_handler_t    handler,
                                                       ply_boot_client_response_handler_t  failed_handler,
                                                       void                               *user_data);
+void ply_boot_client_ask_daemon_for_clearword (ply_boot_client_t                  *client,
+                                              const char *prompt,
+                                              ply_boot_client_answer_handler_t    handler,
+                                              ply_boot_client_response_handler_t  failed_handler,
+                                              void                               *user_data);
 void ply_boot_client_ask_daemon_to_watch_for_keystroke (ply_boot_client_t                  *client,
                                          const char *keys,
                                          ply_boot_client_key_answer_handler_t    handler,
index 3b9fa8ccca4ccefa52e4f25b65d5f0f454c1aa83..9f6eca41457c2fa3e03a0f3c4872c05a8bcadb46 100644 (file)
@@ -52,12 +52,17 @@ typedef struct
   int      number_of_tries_left;
 } answer_state_t;
 
-
 typedef struct
 {
   state_t *state;
   char    *command;
   char    *prompt;
+} clearword_answer_state_t;
+
+typedef struct
+{
+  state_t *state;
+  char    *command;
   char    *keys;
 } key_answer_state_t;
 
@@ -105,7 +110,7 @@ split_string (const char *command,
 }
 
 static bool
-answer_via_command (answer_state_t *answer_state,
+answer_via_command (char           *command,
                     const char     *answer,
                     int            *exit_status)
 {
@@ -132,7 +137,7 @@ answer_via_command (answer_state_t *answer_state,
   if (pid == 0)
     {
       char **args;
-      args = split_string (answer_state->command, ' ');
+      args = split_string (command, ' ');
       if (answer != NULL)
         {
           close (command_input_sender_fd);
@@ -181,7 +186,7 @@ on_answer (answer_state_t   *answer_state,
       bool command_started = false;
 
       exit_status = 127;
-      command_started = answer_via_command (answer_state, answer,
+      command_started = answer_via_command (answer_state->command, answer,
                                             &exit_status);
 
       if (command_started && (!WIFEXITED (exit_status) ||
@@ -210,18 +215,36 @@ on_answer (answer_state_t   *answer_state,
   ply_event_loop_exit (answer_state->state->loop, WEXITSTATUS (exit_status));
 }
 
+static void
+on_clearword_reply (clearword_answer_state_t   *answer_state,
+           const char       *answer,
+           ply_boot_client_t *client)
+{
+  if (answer_state->command != NULL)
+    {
+      bool command_started = false;
+
+      command_started = answer_via_command (answer_state->command, answer, NULL);
+    }
+  else
+    {
+      if (answer) write (STDOUT_FILENO, answer, strlen (answer));
+    }
+
+  if (answer) ply_event_loop_exit (answer_state->state->loop, 0);
+  ply_event_loop_exit (answer_state->state->loop, 1);
+}
 
 static void
-on_key_reply (answer_state_t   *answer_state,
+on_key_reply (key_answer_state_t   *answer_state,
            const char       *answer,
            ply_boot_client_t *client)
 {
-  
   if (answer_state->command != NULL)
     {
       bool command_started = false;
 
-      command_started = answer_via_command (answer_state, answer, NULL);
+      command_started = answer_via_command (answer_state->command, answer, NULL);
     }
   else
     {
@@ -249,7 +272,7 @@ on_multiple_answers (answer_state_t     *answer_state,
       {
         bool command_started;
         exit_status = 127;
-        command_started = answer_via_command (answer_state, answers[i],
+        command_started = answer_via_command (answer_state->command, answers[i],
                                               &exit_status);
         if (command_started && WIFEXITED (exit_status) &&
             WEXITSTATUS (exit_status) == 0)
@@ -353,6 +376,37 @@ on_password_request (state_t    *state,
     }
 }
 
+static void
+on_clearword_request (state_t    *state,
+                     const char *command)
+{
+  char *prompt;
+  char *program;
+  int number_of_tries;
+  answer_state_t *answer_state;
+
+  prompt = NULL;
+  program = NULL;
+  number_of_tries = 0;
+  ply_command_parser_get_command_options (state->command_parser,
+                                          command,
+                                          "command", &program,
+                                          "prompt", &prompt,
+                                          NULL);
+
+  answer_state = calloc (1, sizeof (answer_state_t));
+  answer_state->state = state;
+  answer_state->command = program;
+  answer_state->prompt = prompt;
+
+  ply_boot_client_ask_daemon_for_clearword (state->client,
+                                           answer_state->prompt,
+                                           (ply_boot_client_answer_handler_t)
+                                           on_clearword_reply,
+                                           (ply_boot_client_response_handler_t)
+                                           on_failure, answer_state);
+}
+
 static void
 on_keystroke_request (state_t    *state,
                      const char *command)
@@ -461,6 +515,16 @@ main (int    argc,
                                   PLY_COMMAND_OPTION_TYPE_INTEGER,
                                   NULL);
 
+  ply_command_parser_add_command (state.command_parser,
+                                  "ask-for-clearword", "Ask user for password",
+                                  (ply_command_handler_t)
+                                  on_clearword_request, &state,
+                                  "command", "Command to send clearword to via standard input",
+                                  PLY_COMMAND_OPTION_TYPE_STRING,
+                                  "prompt", "Message to display when asking for clearword",
+                                  PLY_COMMAND_OPTION_TYPE_STRING,
+                                  NULL);
+
 
   ply_command_parser_add_command (state.command_parser,
                                   "watch-keystroke", "Become sensitive to a keystroke",
index 052195c8863d0238057b2bbb1cd2f57753946ec9..7c991f5a3060fec8e2dd6c31bcb66a6750838320 100644 (file)
@@ -83,6 +83,7 @@ ply_buffer_remove_bytes (ply_buffer_t *buffer,
                buffer->size - bytes_to_remove);
       buffer->size -= bytes_to_remove;
     }
+  buffer->data[buffer->size] = '\0';
 }
 
 void
@@ -94,6 +95,7 @@ ply_buffer_remove_bytes_at_end (ply_buffer_t *buffer,
   bytes_to_remove = MIN (buffer->size, bytes_to_remove);
 
   buffer->size -= bytes_to_remove;
+  buffer->data[buffer->size] = '\0';
 }
 
 ply_buffer_t *
@@ -182,16 +184,17 @@ ply_buffer_append_bytes (ply_buffer_t *buffer,
   assert (buffer != NULL);
   assert (bytes != NULL);
   assert (length != 0);
-
-  if ((buffer->size + length) >= buffer->capacity)
+  
+  if (length >PLY_BUFFER_MAX_BUFFER_CAPACITY){
+    bytes += length - (PLY_BUFFER_MAX_BUFFER_CAPACITY-1);
+    length = (PLY_BUFFER_MAX_BUFFER_CAPACITY-1);
+    }
+  
+  while ((buffer->size + length) >= buffer->capacity)
     {
       if (!ply_buffer_increase_capacity (buffer))
         {
           ply_buffer_remove_bytes (buffer, length);
-
-          if ((buffer->size + length) >= buffer->capacity)
-            if (!ply_buffer_increase_capacity (buffer))
-              return;
         }
     }
 
@@ -201,6 +204,7 @@ ply_buffer_append_bytes (ply_buffer_t *buffer,
           bytes, length);
 
   buffer->size += length;
+  buffer->data[buffer->size] = '\0';
 }
 
 void
index cf16f688828a32b8c514ea0a06677400763180f7..d24df011d6cba9ecaf3eba913ce9c8162a485e10 100644 (file)
 
 typedef struct _ply_boot_splash_plugin ply_boot_splash_plugin_t;
 
-typedef void (* ply_boot_splash_password_answer_handler_t) (void *answer_data, const char *password);
+typedef enum {
+  PLY_BOOT_SPLASH_DISPLAY_NORMAL,
+  PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY,
+  PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY
+} ply_boot_splash_display_type_t;
+
+typedef union {
+  struct {const char *prompt; const char *entry_text;} clearword;
+  struct {const char *prompt; int bullets;} password;
+} ply_boot_splash_display_info_t;
 
 typedef struct
 {
@@ -59,10 +68,9 @@ typedef struct
   void (* on_root_mounted) (ply_boot_splash_plugin_t *plugin);
   void (* hide_splash_screen) (ply_boot_splash_plugin_t *plugin,
                                ply_event_loop_t         *loop);
-
-  void (* ask_for_password) (ply_boot_splash_plugin_t *plugin,
-                             const char               *prompt,
-                             ply_trigger_t            *answer);
+  void (* update_display) (ply_boot_splash_plugin_t *plugin,
+                           ply_boot_splash_display_type_t type,
+                           ply_boot_splash_display_info_t *info);
   void (* become_idle) (ply_boot_splash_plugin_t       *plugin,
                         ply_trigger_t                  *idle_trigger);
 } ply_boot_splash_plugin_interface_t;
index 0a42416110e3da16aa230d301a73fe9e7454407e..686f4b197fcbc28652ab85b081149e8d67795860 100644 (file)
@@ -43,6 +43,7 @@
 #include "ply-entry.h"
 #include "ply-event-loop.h"
 #include "ply-array.h"
+#include "ply-label.h"
 #include "ply-logger.h"
 #include "ply-frame-buffer.h"
 #include "ply-image.h"
@@ -64,11 +65,14 @@ struct _ply_entry
   ply_frame_buffer_area_t  area;
   ply_image_t             *text_field_image;
   ply_image_t             *bullet_image;
+  ply_label_t             *label;
 
+  char* text;
   int number_of_bullets;
   int max_number_of_visible_bullets;
 
   uint32_t is_hidden : 1;
+  uint32_t is_password : 1;
 };
 
 ply_entry_t *
@@ -90,8 +94,13 @@ ply_entry_new (const char *image_dir)
   asprintf (&image_path, "%s/bullet.png", image_dir);
   entry->bullet_image = ply_image_new (image_path);
   free (image_path);
+  entry->label = ply_label_new ();
 
+  entry->number_of_bullets = 0;
+  entry->text = strdup("");
+  
   entry->is_hidden = true;
+  entry->is_password = true;
 
   return entry;
 }
@@ -103,6 +112,8 @@ ply_entry_free (ply_entry_t *entry)
     return;
   ply_image_free (entry->text_field_image);
   ply_image_free (entry->bullet_image);
+  ply_label_free (entry->label);
+
   free (entry);
 }
 
@@ -162,59 +173,95 @@ ply_entry_draw (ply_entry_t *entry)
   ply_frame_buffer_fill_with_argb32_data (entry->frame_buffer,
                                           &entry->area, 0, 0,
                                           text_field_data);
-
-  bullet_data = ply_image_get_data (entry->bullet_image);
-  bullet_area.width = ply_image_get_width (entry->bullet_image);
-  bullet_area.height = ply_image_get_height (entry->bullet_image);
-
-  if (entry->number_of_bullets < entry->max_number_of_visible_bullets)
-    number_of_visible_bullets = entry->number_of_bullets;
+  
+  if (entry->is_password)
+    {
+      bullet_data = ply_image_get_data (entry->bullet_image);
+      bullet_area.width = ply_image_get_width (entry->bullet_image);
+      bullet_area.height = ply_image_get_height (entry->bullet_image);
+
+      if (entry->number_of_bullets < entry->max_number_of_visible_bullets)
+        number_of_visible_bullets = entry->number_of_bullets;
+      else
+        {
+          number_of_visible_bullets = entry->max_number_of_visible_bullets;
+
+          /* We've got more bullets than we can show in the available space, so
+           * draw a little half bullet to indicate some bullets are offscreen
+           */
+          bullet_area.x = entry->area.x;
+          bullet_area.y = entry->area.y + entry->area.height / 2.0 - bullet_area.height / 2.0;
+
+          ply_frame_buffer_fill_with_argb32_data (entry->frame_buffer,
+                                                  &bullet_area, bullet_area.width / 2.0, 0,
+                                                  bullet_data);
+        }
+
+      for (i = 0; i < number_of_visible_bullets; i++)
+        {
+          bullet_area.x = entry->area.x + i * bullet_area.width + bullet_area.width / 2.0;
+          bullet_area.y = entry->area.y + entry->area.height / 2.0 - bullet_area.height / 2.0;
+
+          ply_frame_buffer_fill_with_argb32_data (entry->frame_buffer,
+                                                  &bullet_area, 0, 0,
+                                                  bullet_data);
+        }
+    }
   else
     {
-      number_of_visible_bullets = entry->max_number_of_visible_bullets;
-
-      /* We've got more bullets than we can show in the available space, so
-       * draw a little half bullet to indicate some bullets are offscreen
-       */
-      bullet_area.x = entry->area.x;
-      bullet_area.y = entry->area.y + entry->area.height / 2.0 - bullet_area.height / 2.0;
-
-      ply_frame_buffer_fill_with_argb32_data (entry->frame_buffer,
-                                              &bullet_area, bullet_area.width / 2.0, 0,
-                                              bullet_data);
+      ply_label_set_text (entry->label, entry->text);
+      ply_label_show (entry->label, entry->window, entry->area.x, entry->area.y);
+      
     }
+  ply_frame_buffer_unpause_updates (entry->frame_buffer);
+}
 
-  for (i = 0; i < number_of_visible_bullets; i++)
+void
+ply_entry_set_bullets (ply_entry_t *entry, int count)
+{
+  count = MAX(0, count);
+  if (!entry->is_password || entry->number_of_bullets != count)
     {
-      bullet_area.x = entry->area.x + i * bullet_area.width + bullet_area.width / 2.0;
-      bullet_area.y = entry->area.y + entry->area.height / 2.0 - bullet_area.height / 2.0;
-
-      ply_frame_buffer_fill_with_argb32_data (entry->frame_buffer,
-                                              &bullet_area, 0, 0,
-                                              bullet_data);
+      entry->is_password = true;
+      entry->number_of_bullets = count;
+      ply_entry_draw (entry);
     }
-  ply_frame_buffer_unpause_updates (entry->frame_buffer);
+}
+
+int
+ply_entry_get_bullets (ply_entry_t *entry)
+{
+  return entry->number_of_bullets;
 }
 
 void
 ply_entry_add_bullet (ply_entry_t *entry)
 {
-  entry->number_of_bullets++;
-  ply_entry_draw (entry);
+  ply_entry_set_bullets (entry, ply_entry_get_bullets (entry)+1);
 }
 
 void
 ply_entry_remove_bullet (ply_entry_t *entry)
 {
-  entry->number_of_bullets--;
-  ply_entry_draw (entry);
+  ply_entry_set_bullets (entry, ply_entry_get_bullets (entry)-1);
 }
 
 void
 ply_entry_remove_all_bullets (ply_entry_t *entry)
 {
-  entry->number_of_bullets = 0;
-  ply_entry_draw (entry);
+  ply_entry_set_bullets (entry, 0);
+}
+
+void
+ply_entry_set_text (ply_entry_t *entry, char* text)
+{
+  if (entry->is_password || strcmp(entry->text, text) != 0)
+    {
+      entry->is_password = false;
+      free(entry->text);
+      entry->text = strdup(text);
+      ply_entry_draw (entry);
+    }
 }
 
 void
index ac34a4c5e73ae67ba16c6f1af9e20bda6f7b4ae1..554e8aa81098346b79f88c05de53129ce9be080e 100644 (file)
@@ -49,6 +49,8 @@ bool ply_entry_is_hidden (ply_entry_t *entry);
 long ply_entry_get_width (ply_entry_t *entry);
 long ply_entry_get_height (ply_entry_t *entry);
 
+void ply_entry_set_bullets (ply_entry_t *entry, int count);
+int ply_entry_get_bullets (ply_entry_t *entry);
 void ply_entry_add_bullet (ply_entry_t *entry);
 void ply_entry_remove_bullet (ply_entry_t *entry);
 void ply_entry_remove_all_bullets (ply_entry_t *entry);
index 564ade43e78713fbbe60af8ac7dfa0dbf64aca62..d37379fa9f1881c652b4b5ad1d2e8a45fdb5c0bd 100644 (file)
@@ -234,7 +234,7 @@ process_backspace (ply_window_t *window)
   bytes = ply_buffer_get_bytes (window->line_buffer);
   size = ply_buffer_get_size (window->line_buffer);
 
-  bytes_to_remove = MB_CUR_MAX;
+  bytes_to_remove = MIN(size, MB_CUR_MAX);
   while ((previous_character_size = mbrlen (bytes + size - bytes_to_remove, bytes_to_remove, NULL)) < bytes_to_remove &&
          previous_character_size > 0)
     bytes_to_remove -= previous_character_size;
@@ -242,13 +242,13 @@ process_backspace (ply_window_t *window)
   if (bytes_to_remove <= size)
     {
       ply_buffer_remove_bytes_at_end (window->line_buffer, bytes_to_remove);
+    }
 
-      for (node = ply_list_get_first_node(window->backspace_handler_list); node; node = ply_list_get_next_node(window->backspace_handler_list, node))
-        {
-          ply_window_callback_t *callback = ply_list_node_get_data (node);
-          ply_window_backspace_handler_t backspace_handler = callback->function;
-          backspace_handler (callback->user_data);
-        }
+  for (node = ply_list_get_first_node(window->backspace_handler_list); node; node = ply_list_get_next_node(window->backspace_handler_list, node))
+    {
+      ply_window_callback_t *callback = ply_list_node_get_data (node);
+      ply_window_backspace_handler_t backspace_handler = callback->function;
+      backspace_handler (callback->user_data);
     }
 }
 
@@ -670,7 +670,8 @@ ply_window_set_text_cursor_position (ply_window_t *window,
                                      int           row)
 {
   char *sequence;
-
+  column = MAX(column, 0);
+  row = MAX(row, 0);
   sequence = NULL;
   asprintf (&sequence, MOVE_CURSOR_SEQUENCE, row, column);
   write (window->tty_fd, sequence, strlen (sequence));
index bbc57deaa114af95d3a4aee4db0f352b893fd264..5eec3d337c735522cb2d82ce02fecbe9320a61ce 100644 (file)
@@ -54,6 +54,15 @@ typedef struct
   ply_trigger_t *trigger;
 } ply_keystroke_trigger_t;
 
+typedef struct 
+{
+  enum {PLY_ENTRY_TRIGGER_TYPE_PASSWORD,
+        PLY_ENTRY_TRIGGER_TYPE_CLEARWORD}
+        type;
+  const char    *prompt;
+  ply_trigger_t *trigger;
+} ply_entry_trigger_t;
+
 typedef struct
 {
   ply_event_loop_t *loop;
@@ -64,6 +73,8 @@ typedef struct
   ply_buffer_t *boot_buffer;
   ply_progress_t *progress;
   ply_list_t *keystroke_triggers;
+  ply_list_t *entry_triggers;
+  ply_buffer_t *entry_buffer;
   long ptmx;
 
   char kernel_command_line[PLY_MAX_COMMAND_LINE_SIZE];
@@ -87,6 +98,7 @@ static ply_window_t *create_window (state_t    *state,
 static bool attach_to_running_session (state_t *state);
 static void on_escape_pressed (state_t *state);
 static void dump_details_and_quit_splash (state_t *state);
+static void update_display (state_t *state);
 
 static void
 on_session_output (state_t    *state,
@@ -155,18 +167,28 @@ on_ask_for_password (state_t      *state,
                      const char   *prompt,
                      ply_trigger_t *answer)
 {
-  if (state->boot_splash == NULL)
-    {
-      show_detailed_splash (state);
-      if (state->boot_splash == NULL)
-        ply_trigger_pull (answer, "");
-      return;
-    }
-
-  ply_boot_splash_ask_for_password (state->boot_splash,
-                                    prompt, answer);
+  ply_entry_trigger_t *entry_trigger =
+                                  calloc (1, sizeof (ply_entry_trigger_t));
+  entry_trigger->type = PLY_ENTRY_TRIGGER_TYPE_PASSWORD;
+  entry_trigger->prompt = prompt;
+  entry_trigger->trigger = answer;
+  ply_list_append_data (state->entry_triggers, entry_trigger);
+  update_display (state);
 }
 
+static void
+on_ask_for_clearword (state_t      *state,
+                     const char   *prompt,
+                     ply_trigger_t *answer)
+{
+  ply_entry_trigger_t *entry_trigger =
+                                  calloc (1, sizeof (ply_entry_trigger_t));
+  entry_trigger->type = PLY_ENTRY_TRIGGER_TYPE_CLEARWORD;
+  entry_trigger->prompt = prompt;
+  entry_trigger->trigger = answer;
+  ply_list_append_data (state->entry_triggers, entry_trigger);
+  update_display (state);
+}
 
 static void
 on_watch_for_keystroke (state_t      *state,
@@ -439,7 +461,7 @@ static void
 dump_details_and_quit_splash (state_t *state)
 {
   state->showing_details = false;
-  on_escape_pressed (state);
+/*  on_escape_pressed (state);      FIXME_brejc8 Check with halfline*/
 
   if (state->boot_splash != NULL)
     ply_boot_splash_hide (state->boot_splash);
@@ -504,6 +526,7 @@ start_boot_server (state_t *state)
 
   server = ply_boot_server_new ((ply_boot_server_update_handler_t) on_update,
                                 (ply_boot_server_ask_for_password_handler_t) on_ask_for_password,
+                                (ply_boot_server_ask_for_clearword_handler_t) on_ask_for_clearword,
                                 (ply_boot_server_watch_for_keystroke_handler_t) on_watch_for_keystroke,
                                 (ply_boot_server_ignore_keystroke_handler_t) on_ignore_keystroke,
                                 (ply_boot_server_show_splash_handler_t) on_show_splash,
@@ -527,6 +550,49 @@ start_boot_server (state_t *state)
   return server;
 }
 
+
+static void
+update_display (state_t *state)
+{
+  if (!state->boot_splash) return;
+  
+  ply_list_node_t *node;
+  node = ply_list_get_first_node (state->entry_triggers);
+  if (node)
+    {
+      ply_entry_trigger_t* entry_trigger = ply_list_node_get_data (node);
+      if (entry_trigger->type == PLY_ENTRY_TRIGGER_TYPE_PASSWORD)
+        {
+          ply_boot_splash_display_info_t info;
+          info.password.prompt = entry_trigger->prompt;
+          info.password.bullets = mbstowcs (NULL, ply_buffer_get_bytes (state->entry_buffer), 0);
+          info.password.bullets = MAX(info.password.bullets,0);
+          ply_boot_splash_update_display (state->boot_splash,
+                           PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY,
+                           &info);
+        }
+      else if (entry_trigger->type == PLY_ENTRY_TRIGGER_TYPE_CLEARWORD)
+        {
+          ply_boot_splash_display_info_t info;
+          info.clearword.prompt = entry_trigger->prompt;
+          info.clearword.entry_text = ply_buffer_get_bytes (state->entry_buffer);
+          ply_boot_splash_update_display (state->boot_splash,
+                           PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY,
+                           &info);
+        }
+      else {
+          ply_trace("unkown entry type");
+        }
+    }
+  else
+    {
+      ply_boot_splash_update_display (state->boot_splash,
+                           PLY_BOOT_SPLASH_DISPLAY_NORMAL,
+                           NULL);
+    }
+
+}
+
 static void
 on_escape_pressed (state_t *state)
 {
@@ -547,6 +613,7 @@ on_escape_pressed (state_t *state)
       show_default_splash (state);
       state->showing_details = false;
     }
+  update_display (state);
 }
 
 static void
@@ -555,21 +622,70 @@ on_keyboard_input (state_t                  *state,
                    size_t                    character_size)
 {
   ply_list_node_t *node;
-  
-  for (node = ply_list_get_first_node (state->keystroke_triggers); node;
-                    node = ply_list_get_next_node (state->keystroke_triggers, node))
+  node = ply_list_get_first_node (state->entry_triggers);
+  if (node)
     {
-      ply_keystroke_trigger_t* keystroke_trigger = ply_list_node_get_data (node);
-      if (!keystroke_trigger->keys || strstr(keystroke_trigger->keys, keyboard_input))  /* assume strstr works on utf8 arrays */
+      ply_buffer_append_bytes (state->entry_buffer, keyboard_input, character_size);
+      update_display (state);
+    }
+  else
+    {
+      for (node = ply_list_get_first_node (state->keystroke_triggers); node;
+                        node = ply_list_get_next_node (state->keystroke_triggers, node))
         {
-          ply_trigger_pull (keystroke_trigger->trigger, keyboard_input);
-          ply_list_remove_node (state->keystroke_triggers, node);
-          return;
+          ply_keystroke_trigger_t* keystroke_trigger = ply_list_node_get_data (node);
+          if (!keystroke_trigger->keys || strstr(keystroke_trigger->keys, keyboard_input))  /* assume strstr works on utf8 arrays */
+            {
+              ply_trigger_pull (keystroke_trigger->trigger, keyboard_input);
+              ply_list_remove_node (state->keystroke_triggers, node);
+              free(keystroke_trigger);
+              return;
+            }
         }
+      return;
+    }
+}
+void
+on_backspace (state_t                  *state)
+{
+  ssize_t bytes_to_remove;
+  ssize_t previous_character_size;
+  const char *bytes;
+  size_t size;
+  ply_list_node_t *node = ply_list_get_first_node (state->entry_triggers);
+  if (!node) return;
+
+  bytes = ply_buffer_get_bytes (state->entry_buffer);
+  size = ply_buffer_get_size (state->entry_buffer);
+
+  bytes_to_remove = MIN(size, MB_CUR_MAX);
+  while ((previous_character_size = mbrlen (&bytes[size - bytes_to_remove], bytes_to_remove, NULL)) < bytes_to_remove &&
+         previous_character_size > 0)
+    bytes_to_remove -= previous_character_size;
+
+  ply_buffer_remove_bytes_at_end (state->entry_buffer, bytes_to_remove);
+  update_display (state);
+}
+
+void
+on_enter (state_t                  *state,
+          const char               *line)
+{
+  ply_list_node_t *node;
+  node = ply_list_get_first_node (state->entry_triggers);
+  if (node)
+    {
+      ply_entry_trigger_t* entry_trigger = ply_list_node_get_data (node);
+      const char* reply_text = ply_buffer_get_bytes (state->entry_buffer);
+      ply_trigger_pull (entry_trigger->trigger, reply_text);
+      ply_buffer_clear (state->entry_buffer);
+      ply_list_remove_node (state->entry_triggers, node);
+      free(entry_trigger);
+      update_display (state);
     }
-  return;
 }
 
+
 static ply_window_t *
 create_window (state_t    *state,
                const char *tty_name)
@@ -606,12 +722,6 @@ add_windows_to_boot_splash (state_t           *state,
         {
           ply_trace ("adding window to boot splash");
           ply_boot_splash_add_window (splash, window);
-          ply_trace ("listening for escape key");
-          ply_window_add_escape_handler (window, (ply_window_escape_handler_t)
-                                         on_escape_pressed, state);
-          ply_trace ("listening for keystrokes");
-          ply_window_add_keyboard_input_handler (window,
-               (ply_window_keyboard_input_handler_t) on_keyboard_input, state);
         }
       node = next_node;
     }
@@ -644,7 +754,6 @@ start_boot_splash (state_t    *state,
 
   ply_trace ("adding windows to boot splash");
   add_windows_to_boot_splash (state, splash);
-
   ply_trace ("showing plugin");
   if (!ply_boot_splash_show (splash))
     {
@@ -654,6 +763,7 @@ start_boot_splash (state_t    *state,
       return NULL;
     }
 
+  update_display (state);
   return splash;
 }
 
@@ -848,6 +958,7 @@ static bool
 initialize_environment (state_t *state)
 {
   ply_trace ("initializing minimal work environment");
+  ply_list_node_t *node;
 
   if (!get_kernel_command_line (state))
     return false;
@@ -857,13 +968,36 @@ initialize_environment (state_t *state)
 
   state->windows = ply_list_new ();
   state->keystroke_triggers = ply_list_new ();
+  state->entry_triggers = ply_list_new ();
+  state->entry_buffer = ply_buffer_new();
   check_for_consoles (state);
 
   if (state->console != NULL)
     redirect_standard_io_to_device (state->console);
   else
     redirect_standard_io_to_device ("tty1");
-
+  
+  
+  for (node = ply_list_get_first_node (state->windows); node;
+                    node = ply_list_get_next_node (state->windows, node))
+    {
+      ply_window_t *window = ply_list_node_get_data (node);
+      
+      ply_trace ("listening for escape key");
+      ply_window_add_escape_handler (window, (ply_window_escape_handler_t)
+                                     on_escape_pressed, state);
+      ply_trace ("listening for keystrokes");
+      ply_window_add_keyboard_input_handler (window,
+           (ply_window_keyboard_input_handler_t) on_keyboard_input, state);
+      ply_trace ("listening for backspace");
+      ply_window_add_backspace_handler (window,
+           (ply_window_backspace_handler_t) on_backspace, state);
+      ply_trace ("listening for enter");
+      ply_window_add_enter_handler (window,
+           (ply_window_enter_handler_t) on_enter, state);
+    }
+  
+  
   ply_trace ("initialized minimal work environment");
   return true;
 }
index f7259fca2074ca6ad7099d2f9fe442aa2509ec32..00f255e5e3854dac79f2a8ed981b4dbaa3dd1c7b 100644 (file)
 
 #include <linux/kd.h>
 
-void ask_for_password (ply_boot_splash_plugin_t *plugin,
-                       const char               *prompt,
-                       ply_trigger_t            *answer);
+#define CLEAR_LINE_SEQUENCE "\033[2K\r"
+
 typedef void (* ply_boot_splash_plugin_window_handler_t) (ply_window_t *window, ply_boot_splash_plugin_t *, void *user_data, void *other_user_data);
 
 ply_boot_splash_plugin_interface_t *ply_boot_splash_plugin_get_interface (void);
 struct _ply_boot_splash_plugin
 {
   ply_event_loop_t *loop;
-
-  ply_trigger_t *pending_password_answer;
   ply_list_t *windows;
+  ply_boot_splash_display_type_t state;
 
-  uint32_t keyboard_input_is_hidden : 1;
 };
 
 ply_boot_splash_plugin_t *
@@ -78,7 +75,7 @@ create_plugin (void)
 
   plugin = calloc (1, sizeof (ply_boot_splash_plugin_t));
   plugin->windows = ply_list_new ();
-
+  plugin->state = PLY_BOOT_SPLASH_DISPLAY_NORMAL;
   return plugin;
 }
 
@@ -103,12 +100,6 @@ detach_from_event_loop (ply_boot_splash_plugin_t *plugin)
   ply_trace ("detaching from event loop");
 }
 
-
-static void
-write_text_on_window (ply_window_t             *window,
-                      ply_boot_splash_plugin_t *plugin,
-                      const char               *text,
-                      void                     *user_data);
 static void
 for_each_window (ply_boot_splash_plugin_t *plugin,
                  ply_boot_splash_plugin_window_handler_t handler,
@@ -149,45 +140,31 @@ write_text_on_window (ply_window_t             *window,
   write (fd, text, size);
 }
 
+static void
+clear_line_on_window (ply_window_t             *window,
+                      ply_boot_splash_plugin_t *plugin,
+                      void                     *user_data,
+                      void                     *more_user_data)
+{
+  ply_window_clear_text_line (window);
+}
+
 void
 on_keyboard_input (ply_boot_splash_plugin_t *plugin,
                    const char               *keyboard_input,
                    size_t                    character_size)
 {
-  if (plugin->keyboard_input_is_hidden)
-      for_each_window (plugin,
-                       (ply_boot_splash_plugin_window_handler_t)
-                       write_text_on_window, (void *) "*",
-                       (void *) strlen ("*"));
-  else
-      for_each_window (plugin,
-                       (ply_boot_splash_plugin_window_handler_t)
-                       write_text_on_window, (void *) keyboard_input,
-                       (void *) character_size);
 }
 
 void
 on_backspace (ply_boot_splash_plugin_t *plugin)
 {
-  for_each_window (plugin,
-                   (ply_boot_splash_plugin_window_handler_t)
-                   ply_window_clear_text_character, NULL, NULL);
 }
 
 void
 on_enter (ply_boot_splash_plugin_t *plugin,
           const char               *line)
 {
-  if (plugin->pending_password_answer != NULL)
-    {
-      ply_trigger_pull (plugin->pending_password_answer, line);
-      plugin->keyboard_input_is_hidden = false;
-      plugin->pending_password_answer = NULL;
-
-      for_each_window (plugin,
-                       (ply_boot_splash_plugin_window_handler_t)
-                       ply_window_clear_text_line, NULL, NULL);
-    }
 }
 
 void
@@ -221,10 +198,6 @@ initialize_window (ply_window_t             *window,
    ply_window_add_enter_handler (window,
                                  (ply_window_enter_handler_t)
                                  on_enter, plugin);
-
-  interface = ply_boot_splash_plugin_get_interface ();
-
-  interface->ask_for_password = ask_for_password;
 }
 
 static void
@@ -299,13 +272,6 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
                    (ply_boot_splash_plugin_window_handler_t)
                    uninitialize_window, NULL, NULL);
 
-  if (plugin->pending_password_answer != NULL)
-    {
-      ply_trigger_pull (plugin->pending_password_answer, "");
-      plugin->pending_password_answer = NULL;
-      plugin->keyboard_input_is_hidden = false;
-    }
-
   ply_event_loop_stop_watching_for_exit (plugin->loop,
                                          (ply_event_loop_exit_handler_t)
                                          detach_from_event_loop,
@@ -313,37 +279,93 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
   detach_from_event_loop (plugin);
 }
 
-static void
-ask_for_password_on_window (ply_window_t             *window,
-                            ply_boot_splash_plugin_t *plugin,
-                            const char               *prompt)
+void
+update_display (ply_boot_splash_plugin_t *plugin,
+                ply_boot_splash_display_type_t type,
+                ply_boot_splash_display_info_t *info)
 {
-  int fd;
-
-  ply_window_set_mode (window, PLY_WINDOW_MODE_TEXT);
-
-  fd = ply_window_get_tty_fd (window);
-
-  if (prompt != NULL)
+  if (type == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
     {
-      write (fd, "\r\n", strlen ("\r\n"));
-      write (fd, prompt, strlen (prompt));
+      if (plugin->state != type)
+        {
+          for_each_window (plugin,
+                     (ply_boot_splash_plugin_window_handler_t)
+                     write_text_on_window, 
+                     (void *) "\r\n", (void *) strlen ("\r\n"));
+        }
+      plugin->state = type;
+    }
+  else if (type == PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY || 
+           type == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY  )
+    {
+      if (plugin->state != type)
+        {
+          for_each_window (plugin,
+                     (ply_boot_splash_plugin_window_handler_t)
+                     write_text_on_window, 
+                     (void *) "\r\n", (void *) strlen ("\r\n"));
+        }
+      else
+        {
+          for_each_window (plugin,
+                     (ply_boot_splash_plugin_window_handler_t)
+                     write_text_on_window, 
+                     (void *) CLEAR_LINE_SEQUENCE,
+                     (void *) strlen (CLEAR_LINE_SEQUENCE));
+        }
+      plugin->state = type;
+      if (type == PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY)
+        {
+          if (info->clearword.prompt)
+              for_each_window (plugin,
+                         (ply_boot_splash_plugin_window_handler_t)
+                         write_text_on_window, 
+                         (void *) info->clearword.prompt,
+                         (void *) strlen (info->clearword.prompt));
+          for_each_window (plugin,
+                     (ply_boot_splash_plugin_window_handler_t)
+                     write_text_on_window, 
+                     (void *) ":",
+                     (void *) strlen (":"));
+          for_each_window (plugin,
+                     (ply_boot_splash_plugin_window_handler_t)
+                     write_text_on_window, 
+                     (void *) info->clearword.entry_text,
+                     (void *) strlen (info->clearword.entry_text));
+        }
+      if (type == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY)
+        {
+          int i;
+          if (info->password.prompt)
+              for_each_window (plugin,
+                         (ply_boot_splash_plugin_window_handler_t)
+                         write_text_on_window, 
+                         (void *) info->password.prompt,
+                         (void *) strlen (info->password.prompt));
+          else
+              for_each_window (plugin,
+                         (ply_boot_splash_plugin_window_handler_t)
+                         write_text_on_window, 
+                         (void *) "Password",
+                         (void *) strlen ("Password"));
+
+          for_each_window (plugin,
+                     (ply_boot_splash_plugin_window_handler_t)
+                     write_text_on_window, 
+                     (void *) ":",
+                     (void *) strlen (":"));
+          for (i=0; i<info->password.bullets; i++)
+              for_each_window (plugin,
+                     (ply_boot_splash_plugin_window_handler_t)
+                     write_text_on_window, 
+                     (void *) "*",
+                     (void *) strlen ("*"));
+        }
+    }
+  else
+    {
+      ply_trace ("unkown display type");
     }
-
-  write (fd, "\r\nPassword: ", strlen ("\r\nPassword: "));
-  plugin->keyboard_input_is_hidden = true;
-}
-
-void
-ask_for_password (ply_boot_splash_plugin_t *plugin,
-                  const char               *prompt,
-                  ply_trigger_t            *answer)
-{
-  plugin->pending_password_answer = answer;
-
-  for_each_window (plugin,
-                   (ply_boot_splash_plugin_window_handler_t)
-                   ask_for_password_on_window, (void *) prompt, NULL);
 }
 
 ply_boot_splash_plugin_interface_t *
@@ -359,6 +381,7 @@ ply_boot_splash_plugin_get_interface (void)
       .update_status = update_status,
       .on_boot_output = on_boot_output,
       .hide_splash_screen = hide_splash_screen,
+      .update_display = update_display,
     };
 
   return &plugin_interface;
index 691fb8033bf2c9747ff7b33e0b21e0709f74905c..97296fb468f86f2134eb20917f81507897923516 100644 (file)
Binary files a/src/plugins/splash/fade-in/bullet.png and b/src/plugins/splash/fade-in/bullet.png differ
index dad17aa8a6ff1ac781088557071629993b93c2eb..3eee1dc2fca352039474c76f0abd66a1f03d5a3c 100644 (file)
@@ -76,8 +76,7 @@ struct _ply_boot_splash_plugin
   ply_window_t *window;
 
   ply_entry_t *entry;
-
-  ply_trigger_t *pending_password_answer;
+  ply_boot_splash_display_type_t state;
 
   double start_time;
   double now;
@@ -98,6 +97,7 @@ create_plugin (void)
   plugin->star_image = ply_image_new (PLYMOUTH_IMAGE_DIR "fade-in/star.png");
   plugin->lock_image = ply_image_new (PLYMOUTH_IMAGE_DIR "fade-in/lock.png");
   plugin->entry = ply_entry_new (PLYMOUTH_IMAGE_DIR "fade-in");
+  plugin->state = PLY_BOOT_SPLASH_DISPLAY_NORMAL;
   plugin->stars = ply_list_new ();
 
   return plugin;
@@ -259,7 +259,6 @@ animate_at_time (ply_boot_splash_plugin_t *plugin,
   ply_frame_buffer_unpause_updates (plugin->frame_buffer);
 }
 
-static void draw_password_entry (ply_boot_splash_plugin_t *plugin);
 static void
 on_timeout (ply_boot_splash_plugin_t *plugin)
 {
@@ -381,31 +380,17 @@ on_keyboard_input (ply_boot_splash_plugin_t *plugin,
                    const char               *keyboard_input,
                    size_t                    character_size)
 {
-  if (plugin->pending_password_answer == NULL)
-    return;
-
-  ply_entry_add_bullet (plugin->entry);
 }
 
 void
 on_backspace (ply_boot_splash_plugin_t *plugin)
 {
-  ply_entry_remove_bullet (plugin->entry);
 }
 
 void
 on_enter (ply_boot_splash_plugin_t *plugin,
           const char               *text)
 {
-
-  if (plugin->pending_password_answer == NULL)
-    return;
-
-  ply_trigger_pull (plugin->pending_password_answer, text);
-  plugin->pending_password_answer = NULL;
-
-  ply_entry_hide (plugin->entry);
-  start_animation (plugin);
 }
 
 void
@@ -424,10 +409,10 @@ on_draw (ply_boot_splash_plugin_t *plugin,
 
   draw_background (plugin, &area);
 
-  if (plugin->pending_password_answer != NULL)
-    ply_entry_draw (plugin->entry);
-  else
+  if (plugin->state != PLY_BOOT_SPLASH_DISPLAY_NORMAL)
     animate_at_time (plugin, plugin->now);
+  else
+    ply_entry_draw (plugin->entry);
 }
 
 void
@@ -613,13 +598,6 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
 {
   assert (plugin != NULL);
 
-  if (plugin->pending_password_answer != NULL)
-    {
-      ply_trigger_pull (plugin->pending_password_answer, "");
-      plugin->pending_password_answer = NULL;
-    }
-
-    (plugin->window, NULL, NULL);
   ply_window_remove_keyboard_input_handler (plugin->window, (ply_window_keyboard_input_handler_t) on_keyboard_input);
   ply_window_remove_backspace_handler (plugin->window, (ply_window_backspace_handler_t) on_backspace);
   ply_window_remove_enter_handler (plugin->window, (ply_window_enter_handler_t) on_enter);
@@ -663,20 +641,46 @@ show_password_entry (ply_boot_splash_plugin_t *plugin)
   x = area.width / 2.0 - (lock_width + entry_width) / 2.0 + lock_width;
   y = area.height / 2.0 - entry_height / 2.0;
 
-  draw_background (plugin, NULL);
-
   ply_entry_show (plugin->entry, plugin->loop, plugin->window, x, y);
 }
 
 void
-ask_for_password (ply_boot_splash_plugin_t *plugin,
-                  const char               *prompt,
-                  ply_trigger_t            *answer)
+update_display (ply_boot_splash_plugin_t *plugin,
+                ply_boot_splash_display_type_t type,
+                ply_boot_splash_display_info_t *info)
 {
-  plugin->pending_password_answer = answer;
-
-  stop_animation (plugin);
-  show_password_entry (plugin);
+  if (type == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
+    {
+      if (plugin->state ==  PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY ||
+          plugin->state ==  PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY)
+        {
+          ply_entry_hide (plugin->entry);
+          start_animation(plugin);
+        }
+    }
+  else if (type == PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY || 
+           type == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY  )
+    {
+      if (plugin->state !=  PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY &&
+          plugin->state !=  PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY)
+        {
+          stop_animation (plugin);
+          show_password_entry (plugin);
+        }
+      if (type == PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY)
+        {
+          ply_entry_set_text (plugin->entry, info->clearword.entry_text);
+        }
+      if (type == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY)
+        {
+          ply_entry_set_bullets (plugin->entry, info->password.bullets);
+        }
+    }
+  else
+    {
+      ply_trace ("unkown display type");
+    }
+  plugin->state = type;
 }
 
 ply_boot_splash_plugin_interface_t *
@@ -691,7 +695,7 @@ ply_boot_splash_plugin_get_interface (void)
       .show_splash_screen = show_splash_screen,
       .update_status = update_status,
       .hide_splash_screen = hide_splash_screen,
-      .ask_for_password = ask_for_password,
+      .update_display = update_display,
     };
 
   return &plugin_interface;
index c2d4352e1ef74c3c40db8812cf444e8597705763..4468c050c5b6256b32a8985cb4c747e7f12df728 100644 (file)
@@ -61,7 +61,6 @@ struct _ply_boot_splash_plugin
 {
   ply_event_loop_t *loop;
 
-  ply_trigger_t *pending_password_answer;
   ply_window_t *window;
 
   ply_text_pulser_t *pulser;
@@ -169,30 +168,17 @@ on_keyboard_input (ply_boot_splash_plugin_t *plugin,
                    const char               *keyboard_input,
                    size_t                    character_size)
 {
-  if (plugin->keyboard_input_is_hidden)
-    write (STDOUT_FILENO, "•", strlen ("•"));
-  else
-    write (STDOUT_FILENO, keyboard_input, character_size);
 }
 
 void
 on_backspace (ply_boot_splash_plugin_t *plugin)
 {
-  write (STDOUT_FILENO, BACKSPACE, strlen (BACKSPACE));
 }
 
 void
 on_enter (ply_boot_splash_plugin_t *plugin,
           const char               *line)
 {
-  if (plugin->pending_password_answer != NULL)
-    {
-      ply_trigger_pull (plugin->pending_password_answer, line);
-      plugin->keyboard_input_is_hidden = false;
-      plugin->pending_password_answer = NULL;
-
-      start_animation (plugin);
-    }
 }
 
 void
@@ -283,12 +269,6 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
 
   ply_trace ("hiding splash screen");
 
-  if (plugin->pending_password_answer != NULL)
-    {
-      ply_trigger_pull (plugin->pending_password_answer, "");
-      plugin->pending_password_answer = NULL;
-    }
-
   if (plugin->loop != NULL)
     {
       stop_animation (plugin);
@@ -318,34 +298,71 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
 }
 
 void
-ask_for_password (ply_boot_splash_plugin_t *plugin,
-                  const char               *prompt,
-                  ply_trigger_t            *answer)
+update_display (ply_boot_splash_plugin_t *plugin,
+                ply_boot_splash_display_type_t type,
+                ply_boot_splash_display_info_t *info)
 {
-  int window_width, window_height;
-
-  plugin->pending_password_answer = answer;
-
-  stop_animation (plugin);
-  ply_window_set_background_color (plugin->window, PLY_WINDOW_COLOR_DEFAULT);
-  ply_window_clear_screen (plugin->window);
-
-  window_width = ply_window_get_number_of_text_columns (plugin->window);
-  window_height = ply_window_get_number_of_text_rows (plugin->window);
-
-  if (prompt != NULL)
+  if (type == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
+    {
+      start_animation(plugin);
+      return;
+    }
+  else if (type == PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY || 
+           type == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY  )
     {
+      int window_width, window_height;
+      int i;
+      const char* prompt;
+      stop_animation (plugin);
+      ply_window_set_background_color (plugin->window, PLY_WINDOW_COLOR_DEFAULT);
+      ply_window_clear_screen (plugin->window);
+
+      window_width = ply_window_get_number_of_text_columns (plugin->window);
+      window_height = ply_window_get_number_of_text_rows (plugin->window);
+      
+      prompt = "";
+      if (type == PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY)
+        {
+          prompt = info->clearword.prompt;
+          if (!prompt) prompt = "";
+        }
+      if (type == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY)
+        {
+          prompt = info->password.prompt;
+          if (!prompt) prompt = "Password";
+        }
+      
+      ply_window_set_text_cursor_position (plugin->window,
+                                        0, window_height / 2);
+      
+      for (i=0; i < window_width; i++)
+        {
+          write (STDOUT_FILENO, " ", strlen (" "));
+        }
       ply_window_set_text_cursor_position (plugin->window,
-                                           window_width / 2 - strlen (prompt) / 2,
-                                           window_height / 2 - 1);
+                                        window_width / 2 - (strlen (prompt)),
+                                        window_height / 2);
       write (STDOUT_FILENO, prompt, strlen (prompt));
+      write (STDOUT_FILENO, ":", strlen (":"));
+      
+      if (type == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY)
+        {
+          for (i=0; i < info->password.bullets; i++)
+            {
+              write (STDOUT_FILENO, "•", strlen ("•"));
+            }
+        }
+      else if (type == PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY)
+        {
+          const char* entry_text = info->clearword.entry_text;
+          write (STDOUT_FILENO, entry_text, strlen (entry_text));
+        }
+      ply_window_show_text_cursor (plugin->window);
+    }
+  else
+    {
+      ply_trace ("unkown display type");
     }
-  ply_window_set_text_cursor_position (plugin->window,
-                                       window_width / 2 - strlen ("Password:        "),
-                                       window_height / 2);
-  write (STDOUT_FILENO, "Password: ", strlen ("Password: "));
-  ply_window_show_text_cursor (plugin->window);
-  plugin->keyboard_input_is_hidden = true;
 }
 
 ply_boot_splash_plugin_interface_t *
@@ -360,7 +377,7 @@ ply_boot_splash_plugin_get_interface (void)
       .show_splash_screen = show_splash_screen,
       .update_status = update_status,
       .hide_splash_screen = hide_splash_screen,
-      .ask_for_password = ask_for_password,
+      .update_display = update_display,
     };
 
   return &plugin_interface;
index bd1e56813975fbae8703edbd7377c4eaac462cb8..473111c08edd7a960323b790b08bccba491932df 100644 (file)
@@ -179,8 +179,8 @@ struct _ply_boot_splash_plugin
 
   ply_entry_t *entry;
   ply_label_t *label;
+  ply_boot_splash_display_type_t state;
 
-  ply_trigger_t *pending_password_answer;
   ply_trigger_t *idle_trigger;
 
   ply_list_t *sprites;
@@ -224,6 +224,7 @@ create_plugin (void)
 #endif
   plugin->entry = ply_entry_new (PLYMOUTH_IMAGE_DIR "solar");
   plugin->label = ply_label_new ();
+  plugin->state = PLY_BOOT_SPLASH_DISPLAY_NORMAL;
   plugin->sprites = ply_list_new();
   plugin->progress = 0;
   plugin->progress_target = -1;
@@ -971,31 +972,17 @@ on_keyboard_input (ply_boot_splash_plugin_t *plugin,
                    const char               *keyboard_input,
                    size_t                    character_size)
 {
-  if (plugin->pending_password_answer == NULL)
-    return;
-
-  ply_entry_add_bullet (plugin->entry);
 }
 
 void
 on_backspace (ply_boot_splash_plugin_t *plugin)
 {
-  ply_entry_remove_bullet (plugin->entry);
 }
 
 void
 on_enter (ply_boot_splash_plugin_t *plugin,
           const char               *text)
 {
-  if (plugin->pending_password_answer == NULL)
-    return;
-
-  ply_trigger_pull (plugin->pending_password_answer, text);
-  plugin->pending_password_answer = NULL;
-
-  ply_entry_hide (plugin->entry);
-  ply_entry_remove_all_bullets (plugin->entry);
-  start_animation (plugin);
 }
 
 
@@ -1021,7 +1008,8 @@ on_draw (ply_boot_splash_plugin_t *plugin,
   else 
       ply_frame_buffer_pause_updates (plugin->frame_buffer);
 
-  if (plugin->pending_password_answer != NULL)
+  if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY || 
+      plugin->state == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY  )
     {
       draw_background (plugin, &clip_area);
       ply_entry_draw (plugin->entry);
@@ -1449,12 +1437,6 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
 {
   assert (plugin != NULL);
 
-  if (plugin->pending_password_answer != NULL)
-    {
-      ply_trigger_pull (plugin->pending_password_answer, "");
-      plugin->pending_password_answer = NULL;
-    }
-
   ply_window_remove_keyboard_input_handler (plugin->window, (ply_window_keyboard_input_handler_t) on_keyboard_input);
   ply_window_remove_backspace_handler (plugin->window, (ply_window_backspace_handler_t) on_backspace);
   ply_window_remove_enter_handler (plugin->window, (ply_window_enter_handler_t) on_enter);
@@ -1489,38 +1471,44 @@ show_password_prompt (ply_boot_splash_plugin_t *plugin,
 
   assert (plugin != NULL);
 
-  draw_background (plugin, NULL);
-
-  ply_frame_buffer_get_size (plugin->frame_buffer, &area);
-  plugin->box_area.width = ply_image_get_width (plugin->box_image);
-  plugin->box_area.height = ply_image_get_height (plugin->box_image);
-  plugin->box_area.x = area.width / 2.0 - plugin->box_area.width / 2.0;
-  plugin->box_area.y = area.height / 2.0 - plugin->box_area.height / 2.0;
+  if (ply_entry_is_hidden (plugin->entry))
+    {
+      draw_background (plugin, NULL);
 
-  plugin->lock_area.width = ply_image_get_width (plugin->lock_image);
-  plugin->lock_area.height = ply_image_get_height (plugin->lock_image);
+      ply_frame_buffer_get_size (plugin->frame_buffer, &area);
+      plugin->box_area.width = ply_image_get_width (plugin->box_image);
+      plugin->box_area.height = ply_image_get_height (plugin->box_image);
+      plugin->box_area.x = area.width / 2.0 - plugin->box_area.width / 2.0;
+      plugin->box_area.y = area.height / 2.0 - plugin->box_area.height / 2.0;
 
-  entry_width = ply_entry_get_width (plugin->entry);
-  entry_height = ply_entry_get_height (plugin->entry);
+      plugin->lock_area.width = ply_image_get_width (plugin->lock_image);
+      plugin->lock_area.height = ply_image_get_height (plugin->lock_image);
 
-  x = area.width / 2.0 - (plugin->lock_area.width + entry_width) / 2.0 + plugin->lock_area.width;
-  y = area.height / 2.0 - entry_height / 2.0;
+      entry_width = ply_entry_get_width (plugin->entry);
+      entry_height = ply_entry_get_height (plugin->entry);
 
-  plugin->lock_area.x = area.width / 2.0 - (plugin->lock_area.width + entry_width) / 2.0;
-  plugin->lock_area.y = area.height / 2.0 - plugin->lock_area.height / 2.0;
+      x = area.width / 2.0 - (plugin->lock_area.width + entry_width) / 2.0 + plugin->lock_area.width;
+      y = area.height / 2.0 - entry_height / 2.0;
 
-  box_data = ply_image_get_data (plugin->box_image);
-  ply_frame_buffer_fill_with_argb32_data (plugin->frame_buffer,
-                                          &plugin->box_area, 0, 0,
-                                          box_data);
+      plugin->lock_area.x = area.width / 2.0 - (plugin->lock_area.width + entry_width) / 2.0;
+      plugin->lock_area.y = area.height / 2.0 - plugin->lock_area.height / 2.0;
 
-  ply_entry_show (plugin->entry, plugin->loop, plugin->window, x, y);
+      box_data = ply_image_get_data (plugin->box_image);
+      ply_frame_buffer_fill_with_argb32_data (plugin->frame_buffer,
+                                              &plugin->box_area, 0, 0,
+                                              box_data);
 
-  lock_data = ply_image_get_data (plugin->lock_image);
-  ply_frame_buffer_fill_with_argb32_data (plugin->frame_buffer,
-                                          &plugin->lock_area, 0, 0,
-                                          lock_data);
+      ply_entry_show (plugin->entry, plugin->loop, plugin->window, x, y);
 
+      lock_data = ply_image_get_data (plugin->lock_image);
+      ply_frame_buffer_fill_with_argb32_data (plugin->frame_buffer,
+                                              &plugin->lock_area, 0, 0,
+                                              lock_data);
+    }
+  else
+    {
+      ply_entry_draw (plugin->entry);
+    }
   if (prompt != NULL)
     {
       int label_width, label_height;
@@ -1530,32 +1518,13 @@ show_password_prompt (ply_boot_splash_plugin_t *plugin,
       label_height = ply_label_get_height (plugin->label);
 
       x = plugin->box_area.x + plugin->lock_area.width / 2;
-      y = plugin->box_area.y + plugin->box_area.height + label_height;
+      y = plugin->box_area.y + plugin->box_area.height;
 
       ply_label_show (plugin->label, plugin->window, x, y);
     }
 
 }
 
-void
-ask_for_password (ply_boot_splash_plugin_t *plugin,
-                  const char               *prompt,
-                  ply_trigger_t             *answer)
-{
-  plugin->pending_password_answer = answer;
-
-  if (ply_entry_is_hidden (plugin->entry))
-    {
-      stop_animation (plugin, NULL);
-      show_password_prompt (plugin, prompt);
-    }
-  else
-    {
-      ply_entry_draw (plugin->entry);
-      ply_label_draw (plugin->label);
-    }
-}
-
 void
 on_root_mounted (ply_boot_splash_plugin_t *plugin)
 {
@@ -1569,6 +1538,49 @@ become_idle (ply_boot_splash_plugin_t *plugin,
   stop_animation (plugin, idle_trigger);
 }
 
+void
+update_display (ply_boot_splash_plugin_t *plugin,
+                ply_boot_splash_display_type_t type,
+                ply_boot_splash_display_info_t *info)
+{
+  if (type == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
+    {
+      if (plugin->state ==  PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY ||
+          plugin->state ==  PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY)
+        {
+          plugin->state = type;
+          ply_entry_hide (plugin->entry);
+          start_animation(plugin);
+        }
+    }
+  else if (type == PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY || 
+           type == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY  )
+    {
+      if (plugin->state !=  PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY &&
+          plugin->state !=  PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY)
+        {
+          stop_animation (plugin, NULL);
+        }
+      
+      plugin->state = type;
+      
+      if (type == PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY)
+        {
+          show_password_prompt (plugin, info->clearword.prompt);
+          ply_entry_set_text (plugin->entry, info->clearword.entry_text);
+        }
+      if (type == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY)
+        {
+          show_password_prompt (plugin, info->password.prompt);
+          ply_entry_set_bullets (plugin->entry, info->password.bullets);
+        }
+    }
+  else
+    {
+      ply_trace ("unkown display type");
+    }
+}
+
 ply_boot_splash_plugin_interface_t *
 ply_boot_splash_plugin_get_interface (void)
 {
@@ -1582,9 +1594,9 @@ ply_boot_splash_plugin_get_interface (void)
       .update_status = update_status,
       .on_boot_progress = on_boot_progress,
       .hide_splash_screen = hide_splash_screen,
-      .ask_for_password = ask_for_password,
       .on_root_mounted = on_root_mounted,
-      .become_idle = become_idle
+      .become_idle = become_idle,
+      .update_display = update_display,
     };
 
   return &plugin_interface;
index e94c89860d24fee97ed238388be6e29847e9bda5..c9b517218a2f6c6f02d3955686b52f2de68f5ad3 100644 (file)
@@ -80,8 +80,8 @@ struct _ply_boot_splash_plugin
   ply_throbber_t *throbber;
   ply_label_t *label;
   ply_progress_bar_t *progress_bar;
+  ply_boot_splash_display_type_t state;
 
-  ply_trigger_t *pending_password_answer;
   ply_trigger_t *idle_trigger;
 
   uint32_t root_is_mounted : 1;
@@ -264,10 +264,6 @@ on_keyboard_input (ply_boot_splash_plugin_t *plugin,
                    const char               *keyboard_input,
                    size_t                    character_size)
 {
-  if (plugin->pending_password_answer == NULL)
-    return;
-
-  ply_entry_add_bullet (plugin->entry);
 }
 
 void
@@ -280,15 +276,6 @@ void
 on_enter (ply_boot_splash_plugin_t *plugin,
           const char               *text)
 {
-  if (plugin->pending_password_answer == NULL)
-    return;
-
-  ply_trigger_pull (plugin->pending_password_answer, text);
-  plugin->pending_password_answer = NULL;
-
-  ply_entry_hide (plugin->entry);
-  ply_entry_remove_all_bullets (plugin->entry);
-  start_animation (plugin);
 }
 
 void
@@ -308,7 +295,8 @@ on_draw (ply_boot_splash_plugin_t *plugin,
   ply_frame_buffer_pause_updates (plugin->frame_buffer);
   draw_background (plugin, &area);
 
-  if (plugin->pending_password_answer != NULL)
+  if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY || 
+      plugin->state == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY  )
     {
       ply_entry_draw (plugin->entry);
       ply_label_draw (plugin->label);
@@ -458,11 +446,6 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
 {
   assert (plugin != NULL);
 
-  if (plugin->pending_password_answer != NULL)
-    {
-      ply_trigger_pull (plugin->pending_password_answer, "");
-      plugin->pending_password_answer = NULL;
-    }
 
   ply_window_remove_keyboard_input_handler (plugin->window, (ply_window_keyboard_input_handler_t) on_keyboard_input);
   ply_window_remove_backspace_handler (plugin->window, (ply_window_backspace_handler_t) on_backspace);
@@ -498,38 +481,44 @@ show_password_prompt (ply_boot_splash_plugin_t *plugin,
 
   assert (plugin != NULL);
 
-  draw_background (plugin, NULL);
-
-  ply_frame_buffer_get_size (plugin->frame_buffer, &area);
-  plugin->box_area.width = ply_image_get_width (plugin->box_image);
-  plugin->box_area.height = ply_image_get_height (plugin->box_image);
-  plugin->box_area.x = area.width / 2.0 - plugin->box_area.width / 2.0;
-  plugin->box_area.y = area.height / 2.0 - plugin->box_area.height / 2.0;
+  if (ply_entry_is_hidden (plugin->entry))
+    {
+      draw_background (plugin, NULL);
 
-  plugin->lock_area.width = ply_image_get_width (plugin->lock_image);
-  plugin->lock_area.height = ply_image_get_height (plugin->lock_image);
+      ply_frame_buffer_get_size (plugin->frame_buffer, &area);
+      plugin->box_area.width = ply_image_get_width (plugin->box_image);
+      plugin->box_area.height = ply_image_get_height (plugin->box_image);
+      plugin->box_area.x = area.width / 2.0 - plugin->box_area.width / 2.0;
+      plugin->box_area.y = area.height / 2.0 - plugin->box_area.height / 2.0;
 
-  entry_width = ply_entry_get_width (plugin->entry);
-  entry_height = ply_entry_get_height (plugin->entry);
+      plugin->lock_area.width = ply_image_get_width (plugin->lock_image);
+      plugin->lock_area.height = ply_image_get_height (plugin->lock_image);
 
-  x = area.width / 2.0 - (plugin->lock_area.width + entry_width) / 2.0 + plugin->lock_area.width;
-  y = area.height / 2.0 - entry_height / 2.0;
+      entry_width = ply_entry_get_width (plugin->entry);
+      entry_height = ply_entry_get_height (plugin->entry);
 
-  plugin->lock_area.x = area.width / 2.0 - (plugin->lock_area.width + entry_width) / 2.0;
-  plugin->lock_area.y = area.height / 2.0 - plugin->lock_area.height / 2.0;
+      x = area.width / 2.0 - (plugin->lock_area.width + entry_width) / 2.0 + plugin->lock_area.width;
+      y = area.height / 2.0 - entry_height / 2.0;
 
-  box_data = ply_image_get_data (plugin->box_image);
-  ply_frame_buffer_fill_with_argb32_data (plugin->frame_buffer,
-                                          &plugin->box_area, 0, 0,
-                                          box_data);
+      plugin->lock_area.x = area.width / 2.0 - (plugin->lock_area.width + entry_width) / 2.0;
+      plugin->lock_area.y = area.height / 2.0 - plugin->lock_area.height / 2.0;
 
-  ply_entry_show (plugin->entry, plugin->loop, plugin->window, x, y);
+      box_data = ply_image_get_data (plugin->box_image);
+      ply_frame_buffer_fill_with_argb32_data (plugin->frame_buffer,
+                                              &plugin->box_area, 0, 0,
+                                              box_data);
 
-  lock_data = ply_image_get_data (plugin->lock_image);
-  ply_frame_buffer_fill_with_argb32_data (plugin->frame_buffer,
-                                          &plugin->lock_area, 0, 0,
-                                          lock_data);
+      ply_entry_show (plugin->entry, plugin->loop, plugin->window, x, y);
 
+      lock_data = ply_image_get_data (plugin->lock_image);
+      ply_frame_buffer_fill_with_argb32_data (plugin->frame_buffer,
+                                              &plugin->lock_area, 0, 0,
+                                              lock_data);
+    }
+  else
+    {
+      ply_entry_draw (plugin->entry);
+    }
   if (prompt != NULL)
     {
       int label_width, label_height;
@@ -539,32 +528,13 @@ show_password_prompt (ply_boot_splash_plugin_t *plugin,
       label_height = ply_label_get_height (plugin->label);
 
       x = plugin->box_area.x + plugin->lock_area.width / 2;
-      y = plugin->box_area.y + plugin->box_area.height + label_height;
+      y = plugin->box_area.y + plugin->box_area.height;
 
       ply_label_show (plugin->label, plugin->window, x, y);
     }
 
 }
 
-void
-ask_for_password (ply_boot_splash_plugin_t *plugin,
-                  const char               *prompt,
-                  ply_trigger_t            *answer)
-{
-  plugin->pending_password_answer = answer;
-
-  if (ply_entry_is_hidden (plugin->entry))
-    {
-      stop_animation (plugin, NULL);
-      show_password_prompt (plugin, prompt);
-    }
-  else
-    {
-      ply_entry_draw (plugin->entry);
-      ply_label_draw (plugin->label);
-    }
-}
-
 void
 on_root_mounted (ply_boot_splash_plugin_t *plugin)
 {
@@ -578,6 +548,49 @@ become_idle (ply_boot_splash_plugin_t *plugin,
   stop_animation (plugin, idle_trigger);
 }
 
+void
+update_display (ply_boot_splash_plugin_t *plugin,
+                ply_boot_splash_display_type_t type,
+                ply_boot_splash_display_info_t *info)
+{
+  if (type == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
+    {
+      if (plugin->state ==  PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY ||
+          plugin->state ==  PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY)
+        {
+          plugin->state = type;
+          ply_entry_hide (plugin->entry);
+          start_animation(plugin);
+        }
+    }
+  else if (type == PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY || 
+           type == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY  )
+    {
+      if (plugin->state !=  PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY &&
+          plugin->state !=  PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY)
+        {
+          stop_animation (plugin, NULL);
+        }
+      
+      plugin->state = type;
+      
+      if (type == PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY)
+        {
+          show_password_prompt (plugin, info->clearword.prompt);
+          ply_entry_set_text (plugin->entry, info->clearword.entry_text);
+        }
+      if (type == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY)
+        {
+          show_password_prompt (plugin, info->password.prompt);
+          ply_entry_set_bullets (plugin->entry, info->password.bullets);
+        }
+    }
+  else
+    {
+      ply_trace ("unkown display type");
+    }
+}
+
 ply_boot_splash_plugin_interface_t *
 ply_boot_splash_plugin_get_interface (void)
 {
@@ -591,9 +604,9 @@ ply_boot_splash_plugin_get_interface (void)
       .update_status = update_status,
       .on_boot_progress = on_boot_progress,
       .hide_splash_screen = hide_splash_screen,
-      .ask_for_password = ask_for_password,
       .on_root_mounted = on_root_mounted,
       .become_idle = become_idle,
+      .update_display = update_display,
     };
 
   return &plugin_interface;
index 69e0e87d00a2b5995e016fcc5fb038d4a898241b..f08c1b7f5bc0858fc514929e46e961c019d76321 100644 (file)
@@ -62,12 +62,10 @@ struct _ply_boot_splash_plugin
 {
   ply_event_loop_t *loop;
 
-  ply_trigger_t *pending_password_answer;
   ply_window_t *window;
 
   ply_text_progress_bar_t *progress_bar;
 
-  uint32_t keyboard_input_is_hidden : 1;
   uint32_t is_animating : 1;
 };
 void hide_splash_screen (ply_boot_splash_plugin_t *plugin,
@@ -175,30 +173,17 @@ on_keyboard_input (ply_boot_splash_plugin_t *plugin,
                    const char               *keyboard_input,
                    size_t                    character_size)
 {
-  if (plugin->keyboard_input_is_hidden)
-    write (STDOUT_FILENO, "•", strlen ("•"));
-  else
-    write (STDOUT_FILENO, keyboard_input, character_size);
 }
 
 void
 on_backspace (ply_boot_splash_plugin_t *plugin)
 {
-  write (STDOUT_FILENO, BACKSPACE, strlen (BACKSPACE));
 }
 
 void
 on_enter (ply_boot_splash_plugin_t *plugin,
           const char               *line)
 {
-  if (plugin->pending_password_answer != NULL)
-    {
-      ply_trigger_pull (plugin->pending_password_answer, line);
-      plugin->keyboard_input_is_hidden = false;
-      plugin->pending_password_answer = NULL;
-
-      start_animation (plugin);
-    }
 }
 
 void
@@ -307,12 +292,6 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
 
   ply_trace ("hiding splash screen");
 
-  if (plugin->pending_password_answer != NULL)
-    {
-      ply_trigger_pull (plugin->pending_password_answer, "");
-      plugin->pending_password_answer = NULL;
-    }
-
   if (plugin->loop != NULL)
     {
       stop_animation (plugin);
@@ -342,36 +321,73 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
 }
 
 void
-ask_for_password (ply_boot_splash_plugin_t *plugin,
-                  const char               *prompt,
-                  ply_trigger_t            *answer)
+update_display (ply_boot_splash_plugin_t *plugin,
+                ply_boot_splash_display_type_t type,
+                ply_boot_splash_display_info_t *info)
 {
-  int window_width, window_height;
-
-  plugin->pending_password_answer = answer;
-
-  stop_animation (plugin);
-  ply_window_set_background_color (plugin->window, PLY_WINDOW_COLOR_DEFAULT);
-  ply_window_clear_screen (plugin->window);
-
-  window_width = ply_window_get_number_of_text_columns (plugin->window);
-  window_height = ply_window_get_number_of_text_rows (plugin->window);
-
-  if (prompt != NULL)
+  if (type == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
     {
+      start_animation(plugin);
+    }
+  else if (type == PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY || 
+           type == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY  )
+    {
+      int window_width, window_height;
+      int i;
+      const char* prompt;
+      stop_animation (plugin);
+      ply_window_set_background_color (plugin->window, PLY_WINDOW_COLOR_DEFAULT);
+      ply_window_clear_screen (plugin->window);
+
+      window_width = ply_window_get_number_of_text_columns (plugin->window);
+      window_height = ply_window_get_number_of_text_rows (plugin->window);
+      
+      prompt = "";
+      if (type == PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY)
+        {
+          prompt = info->clearword.prompt;
+          if (!prompt) prompt = "";
+        }
+      if (type == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY)
+        {
+          prompt = info->password.prompt;
+          if (!prompt) prompt = "Password";
+        }
+      
       ply_window_set_text_cursor_position (plugin->window,
-                                           window_width / 2 - strlen (prompt) / 2,
-                                           window_height / 2 - 1);
+                                        0, window_height / 2);
+      
+      for (i=0; i < window_width; i++)
+        {
+          write (STDOUT_FILENO, " ", strlen (" "));
+        }
+      ply_window_set_text_cursor_position (plugin->window,
+                                        window_width / 2 - (strlen (prompt)),
+                                        window_height / 2);
       write (STDOUT_FILENO, prompt, strlen (prompt));
+      write (STDOUT_FILENO, ":", strlen (":"));
+      
+      if (type == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY)
+        {
+          for (i=0; i < info->password.bullets; i++)
+            {
+              write (STDOUT_FILENO, "*", strlen ("*"));
+            }
+        }
+      else if (type == PLY_BOOT_SPLASH_DISPLAY_CLEARWORD_ENTRY)
+        {
+          const char* entry_text = info->clearword.entry_text;
+          write (STDOUT_FILENO, entry_text, strlen (entry_text));
+        }
+      ply_window_show_text_cursor (plugin->window);
+    }
+  else
+    {
+      ply_trace ("unkown display type");
     }
-  ply_window_set_text_cursor_position (plugin->window,
-                                       window_width / 2 - strlen ("Password:        "),
-                                       window_height / 2);
-  write (STDOUT_FILENO, "Password: ", strlen ("Password: "));
-  ply_window_show_text_cursor (plugin->window);
-  plugin->keyboard_input_is_hidden = true;
 }
 
+
 ply_boot_splash_plugin_interface_t *
 ply_boot_splash_plugin_get_interface (void)
 {
@@ -385,7 +401,7 @@ ply_boot_splash_plugin_get_interface (void)
       .update_status = update_status,
       .on_boot_progress = on_boot_progress,
       .hide_splash_screen = hide_splash_screen,
-      .ask_for_password = ask_for_password,
+      .update_display = update_display,
     };
 
   return &plugin_interface;
index a8a27b10ddd3a5d3e4d09257580f270d0eda881f..49bbcf8974c8aecf5afe66a88570a74fd8e350cb 100644 (file)
@@ -29,6 +29,7 @@
 #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_QUIT "Q"
 #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_PASSWORD "*"
 #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_CACHED_PASSWORD "c"
+#define PLY_BOOT_PROTOCOL_REQUEST_TYPE_CLEARWORD "W"
 #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_KEYSTROKE "K"
 #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_KEYSTROKE_REMOVE "L"
 #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_SHOW_SPLASH "$"
index 3a9d607739b7a357525548fb113401b9b8768cbb..8b54c37c3aea6005d4c6ae477eddcb5b3c889ac7 100644 (file)
@@ -60,6 +60,7 @@ struct _ply_boot_server
   ply_boot_server_show_splash_handler_t show_splash_handler;
   ply_boot_server_hide_splash_handler_t hide_splash_handler;
   ply_boot_server_ask_for_password_handler_t ask_for_password_handler;
+  ply_boot_server_ask_for_clearword_handler_t ask_for_clearword_handler;
   ply_boot_server_watch_for_keystroke_handler_t watch_for_keystroke_handler;
   ply_boot_server_ignore_keystroke_handler_t ignore_keystroke_handler;
   ply_boot_server_quit_handler_t quit_handler;
@@ -71,6 +72,7 @@ struct _ply_boot_server
 ply_boot_server_t *
 ply_boot_server_new (ply_boot_server_update_handler_t  update_handler,
                      ply_boot_server_ask_for_password_handler_t ask_for_password_handler,
+                     ply_boot_server_ask_for_clearword_handler_t ask_for_clearword_handler,
                      ply_boot_server_watch_for_keystroke_handler_t watch_for_keystroke_handler,
                      ply_boot_server_ignore_keystroke_handler_t ignore_keystroke_handler,
                      ply_boot_server_show_splash_handler_t show_splash_handler,
@@ -90,6 +92,7 @@ ply_boot_server_new (ply_boot_server_update_handler_t  update_handler,
   server->is_listening = false;
   server->update_handler = update_handler;
   server->ask_for_password_handler = ask_for_password_handler;
+  server->ask_for_clearword_handler = ask_for_clearword_handler;
   server->watch_for_keystroke_handler = watch_for_keystroke_handler;
   server->ignore_keystroke_handler = ignore_keystroke_handler;
   server->newroot_handler = newroot_handler;
@@ -221,9 +224,6 @@ ply_boot_connection_on_password_answer (ply_boot_connection_t *connection,
 
   uint8_t size;
 
-  /* splash plugin isn't able to ask for password,
-   * punt to client
-   */
   if (password == NULL)
     {
       if (!ply_write (connection->fd,
@@ -255,6 +255,42 @@ ply_boot_connection_on_password_answer (ply_boot_connection_t *connection,
 
 }
 
+
+static void
+ply_boot_connection_on_clearword_answer (ply_boot_connection_t *connection,
+                                        const char            *password)
+{
+
+  uint8_t size;
+
+  if (password == NULL)
+    {
+      if (!ply_write (connection->fd,
+                      PLY_BOOT_PROTOCOL_RESPONSE_TYPE_NO_ANSWER,
+                      strlen (PLY_BOOT_PROTOCOL_RESPONSE_TYPE_NO_ANSWER)))
+        ply_error ("could not write bytes: %m");
+    }
+  else
+    {
+      /* FIXME: support up to 4 billion
+      */
+      if (strlen (password) > 255)
+          ply_error ("password to long to fit in buffer");
+
+      size = (uint8_t) strlen (password);
+
+      if (!ply_write (connection->fd,
+                      PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ANSWER,
+                      strlen (PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ANSWER)) ||
+          !ply_write (connection->fd,
+                      &size, sizeof (uint8_t)) ||
+          !ply_write (connection->fd,
+                      password, size))
+          ply_error ("could not write bytes: %m");
+    }
+
+}
+
 static void
 ply_boot_connection_on_keystroke_answer (ply_boot_connection_t *connection,
                                         const char            *key)
@@ -262,9 +298,6 @@ ply_boot_connection_on_keystroke_answer (ply_boot_connection_t *connection,
 
   uint8_t size;
 
-  /* splash plugin isn't able to ask for password,
-   * punt to client
-   */
   if (key == NULL)
     {
       if (!ply_write (connection->fd,
@@ -442,6 +475,26 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection)
       free(command);
       return;
     }
+  else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_CLEARWORD) == 0)
+    {
+      ply_trigger_t *answer;
+
+      answer = ply_trigger_new (NULL);
+      ply_trigger_add_handler (answer,
+                               (ply_trigger_handler_t)
+                               ply_boot_connection_on_clearword_answer,
+                               connection);
+
+      if (server->ask_for_clearword_handler != NULL)
+        server->ask_for_clearword_handler (server->user_data,
+                                          argument,
+                                          answer,
+                                          server);
+      /* will reply later
+       */
+      free(command);
+      return;
+    }
   else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_KEYSTROKE) == 0)
     {
       ply_trigger_t *answer;
@@ -637,6 +690,14 @@ on_ask_for_password (ply_event_loop_t *loop)
   return;
 }
 
+static void
+on_ask_for_clearword (ply_event_loop_t *loop)
+{
+  printf ("got clearword request, returning 'password'...\n");
+
+  return;
+}
+
 static void
 on_watch_for_keystroke (ply_event_loop_t *loop)
 {
@@ -668,6 +729,7 @@ main (int    argc,
 
   server = ply_boot_server_new ((ply_boot_server_update_handler_t) on_update,
                                 (ply_boot_server_ask_for_password_handler_t) on_ask_for_password,
+                                (ply_boot_server_ask_for_clearword_handler_t) on_ask_for_clearword,
                                 (ply_boot_server_watch_for_keystroke_handler_t) on_watch_for_keystroke,
                                 (ply_boot_server_ignore_keystroke_handler_t) on_ignore_keystroke,
                                 (ply_boot_server_show_splash_handler_t) on_show_splash,
index 1c5c376bacd3e3deda7fd650f294557d2d9b8bce..1f38ef285ecfab5d9520324336ca9e3e3d1ad7d3 100644 (file)
@@ -53,7 +53,13 @@ typedef void (* ply_boot_server_ask_for_password_handler_t) (void              *
                                                              const char        *prompt,
                                                              ply_trigger_t     *answer,
                                                              ply_boot_server_t *server);
-
+typedef void (* ply_boot_server_clearword_answer_handler_t) (void              *answer_data,
+                                                            const char         *clearword,
+                                                            ply_boot_server_t  *server);
+typedef void (* ply_boot_server_ask_for_clearword_handler_t) (void              *user_data,
+                                                              const char        *prompt,
+                                                              ply_trigger_t     *answer,
+                                                              ply_boot_server_t *server);
 typedef void (* ply_boot_server_watch_for_keystroke_handler_t) (void             *user_data,
                                                              const char        *keys,
                                                              ply_trigger_t     *answer,
@@ -76,6 +82,7 @@ typedef void (* ply_boot_server_quit_handler_t) (void              *user_data,
 #ifndef PLY_HIDE_FUNCTION_DECLARATIONS
 ply_boot_server_t *ply_boot_server_new (ply_boot_server_update_handler_t update_handler,
                                         ply_boot_server_ask_for_password_handler_t ask_for_password_handler,
+                                        ply_boot_server_ask_for_clearword_handler_t ask_for_clearword_handler,
                                         ply_boot_server_watch_for_keystroke_handler_t watch_for_keystroke_handler,
                                         ply_boot_server_ignore_keystroke_handler_t ignore_keystroke_handler,
                                         ply_boot_server_show_splash_handler_t show_splash_handler,
index 02fbba19da1a2a70d2ea72c04500ca28f6986223..256a508c5c5eb20feedefb0c6a8f0194b220c397 100644 (file)
@@ -283,42 +283,6 @@ ply_boot_splash_root_mounted (ply_boot_splash_t *splash)
     splash->plugin_interface->on_root_mounted (splash->plugin);
 }
 
-static void
-on_password_answered (ply_boot_splash_t *splash)
-{
-  if (splash->progress)
-    ply_progress_unpause (splash->progress);
-}
-
-void
-ply_boot_splash_ask_for_password (ply_boot_splash_t *splash,
-                                  const char        *prompt,
-                                  ply_trigger_t     *trigger)
-{
-
-  assert (splash != NULL);
-  assert (splash->plugin_interface != NULL);
-  assert (splash->plugin != NULL);
-  assert (splash->is_shown);
-
-  if (splash->plugin_interface->ask_for_password == NULL)
-    {
-      ply_trigger_pull (trigger, NULL);
-      return;
-    }
-
-  if (splash->progress)
-    ply_progress_pause (splash->progress);
-  
-  ply_trigger_add_handler (trigger,
-                           (ply_trigger_handler_t)
-                           on_password_answered, splash);
-
-  splash->plugin_interface->ask_for_password (splash->plugin,
-                                              prompt,
-                                              trigger);
-}
-
 static void
 ply_boot_splash_detach_from_event_loop (ply_boot_splash_t *splash)
 {
@@ -354,6 +318,20 @@ ply_boot_splash_hide (ply_boot_splash_t *splash)
     }
 }
 
+
+void
+ply_boot_splash_update_display (ply_boot_splash_t *splash,
+                           ply_boot_splash_display_type_t type,
+                           ply_boot_splash_display_info_t *info)
+{
+  assert (splash != NULL);
+  assert (splash->plugin_interface != NULL);
+  assert (splash->plugin != NULL);
+  if (splash->plugin_interface->update_display != NULL)
+      splash->plugin_interface->update_display (splash->plugin, type, info);
+}
+
+
 void
 ply_boot_splash_attach_to_event_loop (ply_boot_splash_t *splash,
                                       ply_event_loop_t  *loop)
index d55f45f13a3f2a559b57d7e37a2294306ba61eb2..3c3fbcb6bf3b0de73b6ef5f18a769f2ca007a8b6 100644 (file)
@@ -53,11 +53,10 @@ void ply_boot_splash_update_output (ply_boot_splash_t *splash,
                                     const char        *output,
                                     size_t             size);
 void ply_boot_splash_root_mounted (ply_boot_splash_t *splash);
-
-void ply_boot_splash_ask_for_password (ply_boot_splash_t *splash,
-                                       const char        *prompt,
-                                       ply_trigger_t     *answer);
 void ply_boot_splash_hide (ply_boot_splash_t *splash);
+void ply_boot_splash_update_display (ply_boot_splash_t *splash,
+                           ply_boot_splash_display_type_t type,
+                           ply_boot_splash_display_info_t *info);
 void ply_boot_splash_attach_to_event_loop (ply_boot_splash_t *splash,
                                            ply_event_loop_t  *loop);
 void ply_boot_splash_attach_progress (ply_boot_splash_t *splash,