]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
Drop line editing plugin vtable functions. Use window directly.
authorRay Strode <rstrode@redhat.com>
Thu, 29 May 2008 04:02:22 +0000 (00:02 -0400)
committerRay Strode <rstrode@redhat.com>
Thu, 29 May 2008 04:02:22 +0000 (00:02 -0400)
There was a sort useless layer of indirection between the
window object and splash plugins.  It ended up with
functions like:

void
on_backspace (ply_splash_plugin_t *plugin)
{
  plugin->interface->on_backspace (plugin);
}

Since the individual plugins are aware of the window object
anyway, they can register their own on_backspace et al handlers
without going through the ply_splash_plugin_t layer.

TODO
src/ply-boot-splash-plugin.h
src/ply-boot-splash.c
src/splash-plugins/details/plugin.c
src/splash-plugins/fade-in/plugin.c
src/splash-plugins/spinfinity/plugin.c
src/splash-plugins/text/plugin.c

diff --git a/TODO b/TODO
index 83cf03e189241c85033e7d295e611479f6cdc523..95ca7383739cc8d9605378e2b95c87a34228fb07 100644 (file)
--- a/TODO
+++ b/TODO
@@ -3,7 +3,6 @@
 - Drop all the make ram disk and copy code.  That was just to make bolting things on easier.  We can integrate now.
 - allow longer than 255 byte replies from server to client
 - make server send immediate ACK for password request and then ANSWER later with a link back to original request in ANSWER
-- have plugins hook into line editing through window directly, instead of via vtable functions
 - Add limited text support
 - Make --ask-for-password take a prompt message
 - consider making details plugin have stdin hooked up to the pty instead of tty so input works
index 6b04e06e5d846a258b3f438778d29812faf33e48..a6fbb5d7f951924a4fe0bd86e95ccaa15a29b99e 100644 (file)
@@ -55,14 +55,6 @@ typedef struct
   void (* ask_for_password) (ply_boot_splash_plugin_t *plugin,
                              ply_boot_splash_password_answer_handler_t answer_handler,
                              void                     *answer_data);
-  void (* on_keyboard_input) (ply_boot_splash_plugin_t *plugin,
-                              const char               *keyboard_input,
-                              size_t                    character_size);
-
-  void (* on_backspace) (ply_boot_splash_plugin_t *plugin);
-  void (* on_enter) (ply_boot_splash_plugin_t *plugin,
-                     const char               *line);
-
 } ply_boot_splash_plugin_interface_t;
 
 #endif /* PLY_BOOT_SPLASH_PLUGIN_H */
index 0e7ab7fc5fe15b16ecfc884eaf12b27fdbe8b6ff..92ec17320838171d221a39dc808f4d387f155429 100644 (file)
@@ -150,30 +150,6 @@ ply_boot_splash_unload_plugin (ply_boot_splash_t *splash)
   splash->module_handle = NULL;
 }
 
-static void
-on_keyboard_input (ply_boot_splash_t *splash,
-                   const char        *keyboard_input,
-                   size_t             character_size)
-{
-  if (splash->plugin_interface->on_keyboard_input != NULL)
-    splash->plugin_interface->on_keyboard_input (splash->plugin, keyboard_input, character_size);
-}
-
-static void
-on_backspace (ply_boot_splash_t *splash)
-{
-  if (splash->plugin_interface->on_backspace != NULL)
-    splash->plugin_interface->on_backspace (splash->plugin);
-}
-
-static void
-on_enter (ply_boot_splash_t *splash,
-          const char        *line)
-{
-  if (splash->plugin_interface->on_enter != NULL)
-    splash->plugin_interface->on_enter (splash->plugin, line);
-}
-
 bool
 ply_boot_splash_show (ply_boot_splash_t *splash)
 {
@@ -195,16 +171,6 @@ ply_boot_splash_show (ply_boot_splash_t *splash)
   assert (splash->plugin_interface->show_splash_screen != NULL);
   assert (splash->window != NULL);
 
-  ply_window_set_keyboard_input_handler (splash->window,
-                                         (ply_window_keyboard_input_handler_t)
-                                         on_keyboard_input, splash);
-  ply_window_set_backspace_handler (splash->window,
-                                    (ply_window_backspace_handler_t)
-                                    on_backspace, splash);
-  ply_window_set_enter_handler (splash->window,
-                                (ply_window_enter_handler_t)
-                                on_enter, splash);
-
   ply_trace ("showing splash screen\n");
   if (!splash->plugin_interface->show_splash_screen (splash->plugin,
                                                      splash->loop,
@@ -283,9 +249,6 @@ ply_boot_splash_hide (ply_boot_splash_t *splash)
                                                 splash->loop,
                                                 splash->window);
 
-  ply_window_set_keyboard_input_handler (splash->window, NULL, NULL);
-  ply_window_set_backspace_handler (splash->window, NULL, NULL);
-
   ply_boot_splash_unload_plugin (splash);
   splash->is_shown = false;
 
index eb163312c3b96b3e2c2322d4e060db5e6df82390..48d5ac99f6e61726e3a7facf989c7af0b57a74f8 100644 (file)
@@ -96,6 +96,37 @@ detach_from_event_loop (ply_boot_splash_plugin_t *plugin)
   ply_trace ("detaching from event loop");
 }
 
+void
+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->password_answer_handler != NULL)
+    {
+      plugin->password_answer_handler (plugin->password_answer_data,
+                                       line);
+      plugin->keyboard_input_is_hidden = false;
+      plugin->password_answer_handler = NULL;
+      write (STDOUT_FILENO, CLEAR_LINE_SEQUENCE, strlen (CLEAR_LINE_SEQUENCE));
+    }
+}
+
 bool
 show_splash_screen (ply_boot_splash_plugin_t *plugin,
                     ply_event_loop_t         *loop,
@@ -106,6 +137,16 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
 
   assert (plugin != NULL);
 
+  ply_window_set_keyboard_input_handler (window,
+                                         (ply_window_keyboard_input_handler_t)
+                                         on_keyboard_input, plugin);
+  ply_window_set_backspace_handler (window,
+                                    (ply_window_backspace_handler_t)
+                                    on_backspace, plugin);
+  ply_window_set_enter_handler (window,
+                                (ply_window_enter_handler_t)
+                                on_enter, plugin);
+
   plugin->loop = loop;
 
   ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t)
@@ -149,6 +190,10 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
 
   ply_trace ("hiding splash screen");
 
+  ply_window_set_keyboard_input_handler (window, NULL, NULL);
+  ply_window_set_backspace_handler (window, NULL, NULL);
+  ply_window_set_enter_handler (window, NULL, NULL);
+
   ply_event_loop_stop_watching_for_exit (plugin->loop,
                                          (ply_event_loop_exit_handler_t)
                                          detach_from_event_loop,
@@ -168,38 +213,6 @@ ask_for_password (ply_boot_splash_plugin_t *plugin,
   plugin->keyboard_input_is_hidden = true;
 }
 
-void
-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->password_answer_handler != NULL)
-    {
-      plugin->password_answer_handler (plugin->password_answer_data,
-                                       line);
-      plugin->keyboard_input_is_hidden = false;
-      plugin->password_answer_handler = NULL;
-      write (STDOUT_FILENO, CLEAR_LINE_SEQUENCE, strlen (CLEAR_LINE_SEQUENCE));
-    }
-}
-
-
 ply_boot_splash_plugin_interface_t *
 ply_boot_splash_plugin_get_interface (void)
 {
@@ -212,9 +225,6 @@ ply_boot_splash_plugin_get_interface (void)
       .on_boot_output = on_boot_output,
       .hide_splash_screen = hide_splash_screen,
       .ask_for_password = ask_for_password,
-      .on_keyboard_input = on_keyboard_input,
-      .on_backspace = on_backspace,
-      .on_enter = on_enter
     };
 
   return &plugin_interface;
index 2432fb2f5f78180a290a3765d3951f00f8eff671..4540413aaf30458be457065ce3d1bf5219ae53cf 100644 (file)
@@ -371,6 +371,37 @@ detach_from_event_loop (ply_boot_splash_plugin_t *plugin)
   ply_window_set_mode (plugin->window, PLY_WINDOW_MODE_TEXT);
 }
 
+void
+on_keyboard_input (ply_boot_splash_plugin_t *plugin,
+                   const char               *keyboard_input,
+                   size_t                    character_size)
+{
+  if (plugin->password_answer_handler == NULL)
+    return;
+
+  plugin->entry->number_of_bullets++;
+  draw_password_entry (plugin);
+}
+
+void
+on_backspace (ply_boot_splash_plugin_t *plugin)
+{
+  plugin->entry->number_of_bullets--;
+  draw_password_entry (plugin);
+}
+
+void
+on_enter (ply_boot_splash_plugin_t *plugin,
+          const char               *text)
+{
+  plugin->password_answer_handler (plugin->password_answer_data,
+                                   text);
+  plugin->entry->number_of_bullets = 0;
+  entry_free (plugin->entry);
+  plugin->entry = NULL;
+  start_animation (plugin);
+}
+
 bool
 show_splash_screen (ply_boot_splash_plugin_t *plugin,
                     ply_event_loop_t         *loop,
@@ -381,6 +412,16 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
   assert (plugin->logo_image != NULL);
   assert (plugin->frame_buffer != NULL);
 
+  ply_window_set_keyboard_input_handler (window,
+                                         (ply_window_keyboard_input_handler_t)
+                                         on_keyboard_input, plugin);
+  ply_window_set_backspace_handler (window,
+                                    (ply_window_backspace_handler_t)
+                                    on_backspace, plugin);
+  ply_window_set_enter_handler (window,
+                                (ply_window_enter_handler_t)
+                                on_enter, plugin);
+
   plugin->loop = loop;
   ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t)
                                  detach_from_event_loop,
@@ -516,6 +557,10 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
 {
   assert (plugin != NULL);
 
+  ply_window_set_keyboard_input_handler (window, NULL, NULL);
+  ply_window_set_backspace_handler (window, NULL, NULL);
+  ply_window_set_enter_handler (window, NULL, NULL);
+
   if (plugin->loop != NULL)
     {
       stop_animation (plugin);
@@ -620,37 +665,6 @@ ask_for_password (ply_boot_splash_plugin_t *plugin,
   show_password_entry (plugin);
 }
 
-void
-on_keyboard_input (ply_boot_splash_plugin_t *plugin,
-                   const char               *keyboard_input,
-                   size_t                    character_size)
-{
-  if (plugin->password_answer_handler == NULL)
-    return;
-
-  plugin->entry->number_of_bullets++;
-  draw_password_entry (plugin);
-}
-
-void
-on_backspace (ply_boot_splash_plugin_t *plugin)
-{
-  plugin->entry->number_of_bullets--;
-  draw_password_entry (plugin);
-}
-
-void
-on_enter (ply_boot_splash_plugin_t *plugin,
-          const char               *text)
-{
-  plugin->password_answer_handler (plugin->password_answer_data,
-                                   text);
-  plugin->entry->number_of_bullets = 0;
-  entry_free (plugin->entry);
-  plugin->entry = NULL;
-  start_animation (plugin);
-}
-
 ply_boot_splash_plugin_interface_t *
 ply_boot_splash_plugin_get_interface (void)
 {
@@ -662,9 +676,6 @@ ply_boot_splash_plugin_get_interface (void)
       .update_status = update_status,
       .hide_splash_screen = hide_splash_screen,
       .ask_for_password = ask_for_password,
-      .on_keyboard_input = on_keyboard_input,
-      .on_backspace = on_backspace,
-      .on_enter = on_enter
     };
 
   return &plugin_interface;
index f1e9c11f485d9cbf737e0e6adda72495e0b72605..62701b38450523d7bc62519cc5aefb6db197caba 100644 (file)
@@ -241,6 +241,45 @@ detach_from_event_loop (ply_boot_splash_plugin_t *plugin)
   ply_window_set_mode (plugin->window, PLY_WINDOW_MODE_TEXT);
 }
 
+void
+on_keyboard_input (ply_boot_splash_plugin_t *plugin,
+                   const char               *keyboard_input,
+                   size_t                    character_size)
+{
+  if (plugin->password_answer_handler == NULL)
+    return;
+
+  plugin->entry->number_of_bullets++;
+  draw_password_entry (plugin);
+}
+
+void
+on_backspace (ply_boot_splash_plugin_t *plugin)
+{
+  plugin->entry->number_of_bullets--;
+  draw_password_entry (plugin);
+}
+
+void
+on_enter (ply_boot_splash_plugin_t *plugin,
+          const char               *text)
+{
+  if (plugin->password_answer_handler == NULL)
+    return;
+
+  plugin->password_answer_handler (plugin->password_answer_data,
+                                   text);
+
+  if (plugin->entry != NULL)
+    {
+      plugin->entry->number_of_bullets = 0;
+      entry_free (plugin->entry);
+      plugin->entry = NULL;
+    }
+
+  start_animation (plugin);
+}
+
 bool
 show_splash_screen (ply_boot_splash_plugin_t *plugin,
                     ply_event_loop_t         *loop,
@@ -251,6 +290,16 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
   assert (plugin->logo_image != NULL);
   assert (plugin->frame_buffer != NULL);
 
+  ply_window_set_keyboard_input_handler (window,
+                                         (ply_window_keyboard_input_handler_t)
+                                         on_keyboard_input, plugin);
+  ply_window_set_backspace_handler (window,
+                                    (ply_window_backspace_handler_t)
+                                    on_backspace, plugin);
+  ply_window_set_enter_handler (window,
+                                (ply_window_enter_handler_t)
+                                on_enter, plugin);
+
   plugin->loop = loop;
   ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t)
                                  detach_from_event_loop,
@@ -315,6 +364,10 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
 {
   assert (plugin != NULL);
 
+  ply_window_set_keyboard_input_handler (window, NULL, NULL);
+  ply_window_set_backspace_handler (window, NULL, NULL);
+  ply_window_set_enter_handler (window, NULL, NULL);
+
   if (plugin->loop != NULL)
     {
       stop_animation (plugin);
@@ -418,45 +471,6 @@ ask_for_password (ply_boot_splash_plugin_t *plugin,
   show_password_entry (plugin);
 }
 
-void
-on_keyboard_input (ply_boot_splash_plugin_t *plugin,
-                   const char               *keyboard_input,
-                   size_t                    character_size)
-{
-  if (plugin->password_answer_handler == NULL)
-    return;
-
-  plugin->entry->number_of_bullets++;
-  draw_password_entry (plugin);
-}
-
-void
-on_backspace (ply_boot_splash_plugin_t *plugin)
-{
-  plugin->entry->number_of_bullets--;
-  draw_password_entry (plugin);
-}
-
-void
-on_enter (ply_boot_splash_plugin_t *plugin,
-          const char               *text)
-{
-  if (plugin->password_answer_handler == NULL)
-    return;
-
-  plugin->password_answer_handler (plugin->password_answer_data,
-                                   text);
-
-  if (plugin->entry != NULL)
-    {
-      plugin->entry->number_of_bullets = 0;
-      entry_free (plugin->entry);
-      plugin->entry = NULL;
-    }
-
-  start_animation (plugin);
-}
-
 ply_boot_splash_plugin_interface_t *
 ply_boot_splash_plugin_get_interface (void)
 {
@@ -468,9 +482,6 @@ ply_boot_splash_plugin_get_interface (void)
       .update_status = update_status,
       .hide_splash_screen = hide_splash_screen,
       .ask_for_password = ask_for_password,
-      .on_keyboard_input = on_keyboard_input,
-      .on_backspace = on_backspace,
-      .on_enter = on_enter
     };
 
   return &plugin_interface;
index bfa591afb827bdac114ebcc7120e2ca3728d73b1..a342fa75b720783f2ca7346133e1c4ca7fd0762e 100644 (file)
@@ -111,6 +111,37 @@ detach_from_event_loop (ply_boot_splash_plugin_t *plugin)
   ply_trace ("detaching from event loop");
 }
 
+void
+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->password_answer_handler != NULL)
+    {
+      plugin->password_answer_handler (plugin->password_answer_data,
+                                       line);
+      plugin->keyboard_input_is_hidden = false;
+      plugin->password_answer_handler = NULL;
+      write (STDOUT_FILENO, CLEAR_LINE_SEQUENCE, strlen (CLEAR_LINE_SEQUENCE));
+    }
+}
+
 bool
 show_splash_screen (ply_boot_splash_plugin_t *plugin,
                     ply_event_loop_t         *loop,
@@ -119,6 +150,16 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
 {
   assert (plugin != NULL);
 
+  ply_window_set_keyboard_input_handler (window,
+                                         (ply_window_keyboard_input_handler_t)
+                                         on_keyboard_input, plugin);
+  ply_window_set_backspace_handler (window,
+                                    (ply_window_backspace_handler_t)
+                                    on_backspace, plugin);
+  ply_window_set_enter_handler (window,
+                                (ply_window_enter_handler_t)
+                                on_enter, plugin);
+
   plugin->loop = loop;
   ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t)
                                  detach_from_event_loop,
@@ -150,6 +191,10 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
 
   ply_trace ("hiding splash screen");
 
+  ply_window_set_keyboard_input_handler (window, NULL, NULL);
+  ply_window_set_backspace_handler (window, NULL, NULL);
+  ply_window_set_enter_handler (window, NULL, NULL);
+
   if (plugin->loop != NULL)
     {
       ply_event_loop_stop_watching_for_exit (plugin->loop,
@@ -172,37 +217,6 @@ ask_for_password (ply_boot_splash_plugin_t *plugin,
   plugin->keyboard_input_is_hidden = true;
 }
 
-void
-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->password_answer_handler != NULL)
-    {
-      plugin->password_answer_handler (plugin->password_answer_data,
-                                       line);
-      plugin->keyboard_input_is_hidden = false;
-      plugin->password_answer_handler = NULL;
-      write (STDOUT_FILENO, CLEAR_LINE_SEQUENCE, strlen (CLEAR_LINE_SEQUENCE));
-    }
-}
-
 ply_boot_splash_plugin_interface_t *
 ply_boot_splash_plugin_get_interface (void)
 {
@@ -214,9 +228,6 @@ ply_boot_splash_plugin_get_interface (void)
       .update_status = update_status,
       .hide_splash_screen = hide_splash_screen,
       .ask_for_password = ask_for_password,
-      .on_keyboard_input = on_keyboard_input,
-      .on_backspace = on_backspace,
-      .on_enter = on_enter
     };
 
   return &plugin_interface;