summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2012-06-07 17:01:53 +0100
committerRay Strode <rstrode@redhat.com>2012-06-08 18:14:40 -0400
commit0880f04eabfcd0783a261f351be80938d4bcbf3b (patch)
tree644c87200eb0318fcdfefdf58aff2c72e7e5a018 /src/client
parentd5ad5d3db87d457b6537fd63b880a5d80821a7de (diff)
main: add a change-mode command to be able to switch the splash mode at runtime
https://bugs.freedesktop.org/show_bug.cgi?id=50847
Diffstat (limited to 'src/client')
-rw-r--r--src/client/ply-boot-client.c13
-rw-r--r--src/client/ply-boot-client.h5
-rw-r--r--src/client/plymouth.c59
3 files changed, 77 insertions, 0 deletions
diff --git a/src/client/ply-boot-client.c b/src/client/ply-boot-client.c
index 5d3965d5..73650f65 100644
--- a/src/client/ply-boot-client.c
+++ b/src/client/ply-boot-client.c
@@ -548,6 +548,19 @@ ply_boot_client_update_daemon (ply_boot_client_t *client,
}
void
+ply_boot_client_change_mode (ply_boot_client_t *client,
+ const char *new_mode,
+ 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_CHANGE_MODE,
+ new_mode, handler, failed_handler, user_data);
+}
+
+void
ply_boot_client_tell_daemon_to_change_root (ply_boot_client_t *client,
const char *root_dir,
ply_boot_client_response_handler_t handler,
diff --git a/src/client/ply-boot-client.h b/src/client/ply-boot-client.h
index ca6f37a0..4e7607a1 100644
--- a/src/client/ply-boot-client.h
+++ b/src/client/ply-boot-client.h
@@ -58,6 +58,11 @@ void ply_boot_client_update_daemon (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_change_mode (ply_boot_client_t *client,
+ const char *new_mode,
+ 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_change_root (ply_boot_client_t *client,
const char *chroot_dir,
ply_boot_client_response_handler_t handler,
diff --git a/src/client/plymouth.c b/src/client/plymouth.c
index 72574180..245e4e5e 100644
--- a/src/client/plymouth.c
+++ b/src/client/plymouth.c
@@ -863,6 +863,53 @@ on_update_request (state_t *state,
}
}
+static void
+on_change_mode_request (state_t *state,
+ const char *command)
+{
+ bool boot_up;
+ bool shutdown;
+ bool updates;
+
+ boot_up = false;
+ shutdown = false;
+ updates = false;
+ ply_command_parser_get_command_options (state->command_parser,
+ command,
+ "boot-up", &boot_up,
+ "shutdown", &shutdown,
+ "updates", &updates,
+ NULL);
+
+ if (boot_up)
+ {
+ ply_boot_client_change_mode (state->client, "boot-up",
+ (ply_boot_client_response_handler_t)
+ on_success,
+ (ply_boot_client_response_handler_t)
+ on_failure, state);
+
+ }
+ else if (shutdown)
+ {
+ ply_boot_client_change_mode (state->client, "shutdown",
+ (ply_boot_client_response_handler_t)
+ on_success,
+ (ply_boot_client_response_handler_t)
+ on_failure, state);
+
+ }
+ else if (updates)
+ {
+ ply_boot_client_change_mode (state->client, "updates",
+ (ply_boot_client_response_handler_t)
+ on_success,
+ (ply_boot_client_response_handler_t)
+ on_failure, state);
+
+ }
+}
+
int
main (int argc,
char **argv)
@@ -900,6 +947,18 @@ main (int argc,
NULL);
ply_command_parser_add_command (state.command_parser,
+ "change-mode", "Change the operation mode",
+ (ply_command_handler_t)
+ on_change_mode_request, &state,
+ "boot-up", "Starting the system up",
+ PLY_COMMAND_OPTION_TYPE_FLAG,
+ "shutdown", "Shutting the system down",
+ PLY_COMMAND_OPTION_TYPE_FLAG,
+ "updates", "Applying updates",
+ PLY_COMMAND_OPTION_TYPE_FLAG,
+ NULL);
+
+ ply_command_parser_add_command (state.command_parser,
"update", "Tell daemon about boot status changes",
(ply_command_handler_t)
on_update_request, &state,