diff --git a/TODO b/TODO index 83cf03e..95ca738 100644 --- 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 diff --git a/src/ply-boot-splash-plugin.h b/src/ply-boot-splash-plugin.h index 6b04e06..a6fbb5d 100644 --- a/src/ply-boot-splash-plugin.h +++ b/src/ply-boot-splash-plugin.h @@ -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 */ diff --git a/src/ply-boot-splash.c b/src/ply-boot-splash.c index 0e7ab7f..92ec173 100644 --- a/src/ply-boot-splash.c +++ b/src/ply-boot-splash.c @@ -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; diff --git a/src/splash-plugins/details/plugin.c b/src/splash-plugins/details/plugin.c index eb16331..48d5ac9 100644 --- a/src/splash-plugins/details/plugin.c +++ b/src/splash-plugins/details/plugin.c @@ -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; diff --git a/src/splash-plugins/fade-in/plugin.c b/src/splash-plugins/fade-in/plugin.c index 2432fb2..4540413 100644 --- a/src/splash-plugins/fade-in/plugin.c +++ b/src/splash-plugins/fade-in/plugin.c @@ -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; diff --git a/src/splash-plugins/spinfinity/plugin.c b/src/splash-plugins/spinfinity/plugin.c index f1e9c11..62701b3 100644 --- a/src/splash-plugins/spinfinity/plugin.c +++ b/src/splash-plugins/spinfinity/plugin.c @@ -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; diff --git a/src/splash-plugins/text/plugin.c b/src/splash-plugins/text/plugin.c index bfa591a..a342fa7 100644 --- a/src/splash-plugins/text/plugin.c +++ b/src/splash-plugins/text/plugin.c @@ -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;