]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
details: Implement display_message
authorColin Watson <cjwatson@ubuntu.com>
Tue, 7 Sep 2010 17:56:37 +0000 (18:56 +0100)
committerRay Strode <rstrode@redhat.com>
Tue, 7 Sep 2010 18:32:48 +0000 (14:32 -0400)
Messages are queued until any question or password entry prompts
complete.

https://bugs.freedesktop.org/show_bug.cgi?id=29035

src/plugins/splash/details/plugin.c

index 763e128fab1898d486430bce69e926ebfd7f4778..aff2f1c0620015307b289b273f34880552b5f286 100644 (file)
@@ -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,19 @@ 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)
+{
+  if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
+    {
+      write_on_views (plugin, message, strlen (message));
+      write_on_views (plugin, "\r\n", strlen ("\r\n"));
+    }
+  else
+    ply_list_append_data (plugin->messages, strdup (message));
+}
+
 ply_boot_splash_plugin_interface_t *
 ply_boot_splash_plugin_get_interface (void)
 {
@@ -378,6 +437,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;