From 5675e79cf8c5fe5c063091c0105394a0fdfcd468 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 7 Sep 2010 18:56:37 +0100 Subject: [PATCH] [details] Implement display_message Messages are queued until any question or password entry prompts complete. --- src/plugins/splash/details/plugin.c | 67 +++++++++++++++++++++++++++++++++++ 1 files changed, 67 insertions(+), 0 deletions(-) diff --git a/src/plugins/splash/details/plugin.c b/src/plugins/splash/details/plugin.c index 763e128..2871b35 100644 --- a/src/plugins/splash/details/plugin.c +++ b/src/plugins/splash/details/plugin.c @@ -75,6 +75,7 @@ struct _ply_boot_splash_plugin ply_boot_splash_mode_t mode; ply_list_t *views; ply_boot_splash_display_type_t state; + ply_list_t *messages; }; @@ -122,6 +123,31 @@ free_views (ply_boot_splash_plugin_t *plugin) plugin->views = NULL; } +static void +free_messages (ply_boot_splash_plugin_t *plugin) +{ + ply_list_node_t *node; + + node = ply_list_get_first_node (plugin->messages); + + while (node != NULL) + { + ply_list_node_t *next_node; + char *message; + + message = ply_list_node_get_data (node); + next_node = ply_list_get_next_node (plugin->messages, node); + + free (message); + ply_list_remove_node (plugin->messages, node); + + node = next_node; + } + + ply_list_free (plugin->messages); + plugin->messages = NULL; +} + static ply_boot_splash_plugin_t * create_plugin (ply_key_file_t *key_file) { @@ -132,6 +158,7 @@ create_plugin (ply_key_file_t *key_file) plugin = calloc (1, sizeof (ply_boot_splash_plugin_t)); plugin->views = ply_list_new (); plugin->state = PLY_BOOT_SPLASH_DISPLAY_NORMAL; + plugin->messages = ply_list_new (); return plugin; } @@ -151,6 +178,7 @@ destroy_plugin (ply_boot_splash_plugin_t *plugin) detach_from_event_loop (plugin); } + free_messages (plugin); free_views (plugin); free (plugin); @@ -307,10 +335,28 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin, static void display_normal (ply_boot_splash_plugin_t *plugin) { + ply_list_node_t *node; + if (plugin->state != PLY_BOOT_SPLASH_DISPLAY_NORMAL) write_on_views (plugin, "\r\n", strlen ("\r\n")); plugin->state = PLY_BOOT_SPLASH_DISPLAY_NORMAL; + + node = ply_list_get_first_node (plugin->messages); + while (node != NULL) + { + const char *message; + ply_list_node_t *next_node; + + message = ply_list_node_get_data (node); + next_node = ply_list_get_next_node (plugin->messages, node); + + write_on_views (plugin, message, strlen (message)); + write_on_views (plugin, "\r\n", strlen ("\r\n")); + + ply_list_remove_node (plugin->messages, node); + node = next_node; + } } static void @@ -362,6 +408,26 @@ display_question (ply_boot_splash_plugin_t *plugin, write_on_views (plugin, entry_text, strlen (entry_text)); } +static void +display_message (ply_boot_splash_plugin_t *plugin, + const char *message) +{ + const char *message_to_display; + + if (!strncmp (message, "keys:", strlen ("keys:"))) + message_to_display = message + strlen ("keys:"); + else + message_to_display = message; + + if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_NORMAL) + { + write_on_views (plugin, message_to_display, strlen (message_to_display)); + write_on_views (plugin, "\r\n", strlen ("\r\n")); + } + else + ply_list_append_data (plugin->messages, strdup (message_to_display)); +} + ply_boot_splash_plugin_interface_t * ply_boot_splash_plugin_get_interface (void) { @@ -378,6 +444,7 @@ ply_boot_splash_plugin_get_interface (void) .display_normal = display_normal, .display_password = display_password, .display_question = display_question, + .display_message = display_message, }; return &plugin_interface; -- 1.7.1