From: Valentin David Date: Tue, 30 Aug 2022 13:20:03 +0000 (+0200) Subject: main: Add "reload" command X-Git-Tag: 23.51.283~73^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8d1c0e622e771880342e28a016fadc88e191235b;p=thirdparty%2Fplymouth.git main: Add "reload" command 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. --- diff --git a/src/client/ply-boot-client.c b/src/client/ply-boot-client.c index ba367d21..270d1d7a 100644 --- a/src/client/ply-boot-client.c +++ b/src/client/ply-boot-client.c @@ -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, diff --git a/src/client/ply-boot-client.h b/src/client/ply-boot-client.h index 842b48ab..501e6dbd 100644 --- a/src/client/ply-boot-client.h +++ b/src/client/ply-boot-client.h @@ -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, diff --git a/src/client/plymouth.c b/src/client/plymouth.c index d9beeb24..7e6214a7 100644 --- a/src/client/plymouth.c +++ b/src/client/plymouth.c @@ -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; diff --git a/src/main.c b/src/main.c index debe3f89..2ec15de8 100644 --- a/src/main.c +++ b/src/main.c @@ -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)) { diff --git a/src/ply-boot-protocol.h b/src/ply-boot-protocol.h index a9a92606..18576367 100644 --- a/src/ply-boot-protocol.h +++ b/src/ply-boot-protocol.h @@ -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" diff --git a/src/ply-boot-server.c b/src/ply-boot-server.c index 1749a3e6..07aa8c4d 100644 --- a/src/ply-boot-server.c +++ b/src/ply-boot-server.c @@ -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; diff --git a/src/ply-boot-server.h b/src/ply-boot-server.h index 48db9dd5..e79aa335 100644 --- a/src/ply-boot-server.h +++ b/src/ply-boot-server.h @@ -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);