]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
main: Add "reload" command
authorValentin David <valentin.david@canonical.com>
Tue, 30 Aug 2022 13:20:03 +0000 (15:20 +0200)
committerRay Strode <halfline@gmail.com>
Sat, 15 Oct 2022 18:02:01 +0000 (18:02 +0000)
If an initramfs does not yet have all configuration, it might want
to start with a fallback theme, and re-load the correct theme is
accessible.

src/client/ply-boot-client.c
src/client/ply-boot-client.h
src/client/plymouth.c
src/main.c
src/ply-boot-protocol.h
src/ply-boot-server.c
src/ply-boot-server.h

index ba367d21b3546a9ec3a630da68d9a9934e067050..270d1d7a0120c1e46efd0f641ca6b5fadeac9bcd 100644 (file)
@@ -728,6 +728,18 @@ ply_boot_client_tell_daemon_to_quit (ply_boot_client_t                 *client,
                                        arg, handler, failed_handler, user_data);
 }
 
+void
+ply_boot_client_tell_daemon_to_reload (ply_boot_client_t                 *client,
+                                       ply_boot_client_response_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_RELOAD,
+                                       NULL, handler, failed_handler, user_data);
+}
+
 void
 ply_boot_client_tell_daemon_to_progress_pause (ply_boot_client_t                 *client,
                                                ply_boot_client_response_handler_t handler,
index 842b48abd9dad11823032518d9e912d77c4224fa..501e6dbd6bc62440a82a07ac75ddc2031fe0b120 100644 (file)
@@ -132,6 +132,10 @@ void ply_boot_client_tell_daemon_to_quit (ply_boot_client_t                 *cli
                                           ply_boot_client_response_handler_t handler,
                                           ply_boot_client_response_handler_t failed_handler,
                                           void                              *user_data);
+void ply_boot_client_tell_daemon_to_reload (ply_boot_client_t                 *client,
+                                            ply_boot_client_response_handler_t handler,
+                                            ply_boot_client_response_handler_t failed_handler,
+                                            void                              *user_data);
 void ply_boot_client_tell_daemon_to_progress_pause (ply_boot_client_t                 *client,
                                                     ply_boot_client_response_handler_t handler,
                                                     ply_boot_client_response_handler_t failed_handler,
index d9beeb245d0236e15a395a6d6af5556cff6072ee..7e6214a7e3db992e926922f147252722e220e904 100644 (file)
@@ -716,6 +716,17 @@ on_quit_request (state_t    *state,
                                              on_failure, state);
 }
 
+static void
+on_reload_request (state_t    *state,
+                   const char *command)
+{
+        ply_boot_client_tell_daemon_to_reload (state->client,
+                                               (ply_boot_client_response_handler_t)
+                                               on_success,
+                                               (ply_boot_client_response_handler_t)
+                                               on_failure, state);
+}
+
 static void
 on_update_root_fs_request (state_t    *state,
                            const char *command)
@@ -1057,6 +1068,11 @@ main (int    argc,
                                         "retain-splash", "Don't explicitly hide boot splash on exit",
                                         PLY_COMMAND_OPTION_TYPE_FLAG, NULL);
 
+        ply_command_parser_add_command (state.command_parser,
+                                        "reload", "Tell the daemon to reload the theme",
+                                        (ply_command_handler_t)
+                                        on_reload_request, &state, NULL);
+
         if (!ply_command_parser_parse_arguments (state.command_parser, state.loop, argv, argc)) {
                 char *help_string;
 
index debe3f8924a0680455d2fb20db7d1800c2a2b5df..2ec15de862f1685d5728c8c0c8cb7c3c10f4ec94 100644 (file)
@@ -911,6 +911,45 @@ plymouth_should_show_default_splash (state_t *state)
         return false;
 }
 
+static void
+on_reload (state_t *state)
+{
+        ply_trace ("reloading");
+        if (state->boot_splash != NULL) {
+                ply_boot_splash_hide (state->boot_splash);
+                ply_boot_splash_free (state->boot_splash);
+                state->boot_splash = NULL;
+        }
+
+        free (state->override_splash_path);
+        state->override_splash_path = NULL;
+        free (state->system_default_splash_path);
+        state->system_default_splash_path = NULL;
+        free (state->distribution_default_splash_path);
+        state->distribution_default_splash_path = NULL;
+
+        find_override_splash (state);
+        find_system_default_splash (state);
+        find_distribution_default_splash (state);
+
+        if (state->is_inactive) {
+                ply_trace ("reload while inactive");
+                return;
+        }
+
+        if (!state->is_shown) {
+                ply_trace ("reload while not shown");
+                return;
+        }
+
+        if (state->showing_details) {
+                show_detailed_splash (state);
+        } else {
+                show_default_splash (state);
+        }
+}
+
+
 static void
 on_show_splash (state_t *state)
 {
@@ -1430,6 +1469,7 @@ start_boot_server (state_t *state)
                                       (ply_boot_server_reactivate_handler_t) on_reactivate,
                                       (ply_boot_server_quit_handler_t) on_quit,
                                       (ply_boot_server_has_active_vt_handler_t) on_has_active_vt,
+                                      (ply_boot_server_reload_handler_t) on_reload,
                                       state);
 
         if (!ply_boot_server_listen (server)) {
index a9a926065ea22a940e4052a6375b3e86058f850d..1857636710769efaf4e62db92624648796881939 100644 (file)
@@ -32,6 +32,7 @@
 #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_DEACTIVATE "D"
 #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_REACTIVATE "r"
 #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_QUIT "Q"
+#define PLY_BOOT_PROTOCOL_REQUEST_TYPE_RELOAD "l"
 #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_PASSWORD "*"
 #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_CACHED_PASSWORD "c"
 #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_QUESTION "W"
index 1749a3e64cb6b6db4ce514c64099d9540911df58..07aa8c4d259c0403c77b2a37a3a07b5b7a78027c 100644 (file)
@@ -80,6 +80,7 @@ struct _ply_boot_server
         ply_boot_server_reactivate_handler_t          reactivate_handler;
         ply_boot_server_quit_handler_t                quit_handler;
         ply_boot_server_has_active_vt_handler_t       has_active_vt_handler;
+        ply_boot_server_reload_handler_t              reload_handler;
         void                                         *user_data;
 
         uint32_t                                      is_listening : 1;
@@ -106,6 +107,7 @@ ply_boot_server_new (ply_boot_server_update_handler_t              update_handle
                      ply_boot_server_reactivate_handler_t          reactivate_handler,
                      ply_boot_server_quit_handler_t                quit_handler,
                      ply_boot_server_has_active_vt_handler_t       has_active_vt_handler,
+                     ply_boot_server_reload_handler_t              reload_handler,
                      void                                         *user_data)
 {
         ply_boot_server_t *server;
@@ -135,6 +137,7 @@ ply_boot_server_new (ply_boot_server_update_handler_t              update_handle
         server->reactivate_handler = reactivate_handler;
         server->quit_handler = quit_handler;
         server->has_active_vt_handler = has_active_vt_handler;
+        server->reload_handler = reload_handler;
         server->user_data = user_data;
 
         return server;
@@ -545,6 +548,10 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection)
                 free (argument);
                 free (command);
                 return;
+        } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_RELOAD) == 0) {
+                ply_trace ("got reload request");
+                if (server->reload_handler != NULL)
+                        server->reload_handler (server->user_data, server);
         } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_PASSWORD) == 0) {
                 ply_trigger_t *answer;
 
index 48db9dd5d58712993825d19981ed792be5692aca..e79aa3353dd656cc3bcaee732b7549c8b3da5e25 100644 (file)
@@ -102,6 +102,8 @@ typedef void (*ply_boot_server_quit_handler_t) (void              *user_data,
                                                 ply_boot_server_t *server);
 typedef bool (*ply_boot_server_has_active_vt_handler_t) (void              *user_data,
                                                          ply_boot_server_t *server);
+typedef bool (*ply_boot_server_reload_handler_t) (void              *user_data,
+                                                  ply_boot_server_t *server);
 
 #ifndef PLY_HIDE_FUNCTION_DECLARATIONS
 ply_boot_server_t *ply_boot_server_new (ply_boot_server_update_handler_t              update_handler,
@@ -124,6 +126,7 @@ ply_boot_server_t *ply_boot_server_new (ply_boot_server_update_handler_t
                                         ply_boot_server_reactivate_handler_t          reactivate_handler,
                                         ply_boot_server_quit_handler_t                quit_handler,
                                         ply_boot_server_has_active_vt_handler_t       has_active_vt_handler,
+                                        ply_boot_server_reload_handler_t              reload_handler,
                                         void                                         *user_data);
 
 void ply_boot_server_free (ply_boot_server_t *server);