From 481388968d987727e038597877cd752e8f7f6d65 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Mon, 21 Apr 2014 11:18:19 -0400 Subject: Revert "Add support for operation log messages" This reverts commit 52b91176ba46eba5816ee7ee9a3e079ae548fbb1. --- src/client/ply-boot-client.c | 126 ++++++-------------- src/client/ply-boot-client.h | 13 --- src/client/plymouth.c | 89 +-------------- src/libply-splash-core/ply-boot-splash-plugin.h | 9 +- src/libply-splash-core/ply-boot-splash.c | 32 +----- src/libply-splash-core/ply-boot-splash.h | 8 +- src/libply/ply-progress.c | 38 ++---- src/libply/ply-progress.h | 2 +- src/main.c | 35 +----- src/plugins/splash/details/plugin.c | 146 +----------------------- src/plugins/splash/fade-throbber/plugin.c | 3 +- src/plugins/splash/script/plugin.c | 28 +---- src/plugins/splash/script/script-lib-plymouth.c | 54 +-------- src/plugins/splash/script/script-lib-plymouth.h | 12 +- src/plugins/splash/space-flares/plugin.c | 3 +- src/plugins/splash/text/plugin.c | 3 +- src/plugins/splash/throbgress/plugin.c | 3 +- src/plugins/splash/two-step/plugin.c | 3 +- src/ply-boot-protocol.h | 2 - src/ply-boot-server.c | 120 +++++-------------- src/ply-boot-server.h | 14 +-- 21 files changed, 98 insertions(+), 645 deletions(-) diff --git a/src/client/ply-boot-client.c b/src/client/ply-boot-client.c index 2d80e98c..3480676a 100644 --- a/src/client/ply-boot-client.c +++ b/src/client/ply-boot-client.c @@ -1,7 +1,6 @@ /* ply-boot-client.h - APIs for talking to the boot status daemon * * Copyright (C) 2007 Red Hat, Inc. - * Copyright (C) 2012 Pali Rohár * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -56,8 +55,7 @@ typedef struct { ply_boot_client_t *client; char *command; - char *argument_1; - char *argument_2; + char *argument; ply_boot_client_response_handler_t handler; ply_boot_client_response_handler_t failed_handler; void *user_data; @@ -210,8 +208,7 @@ ply_boot_client_connect (ply_boot_client_t *client, static ply_boot_client_request_t * ply_boot_client_request_new (ply_boot_client_t *client, const char *request_command, - const char *request_argument_1, - const char *request_argument_2, + const char *request_argument, ply_boot_client_response_handler_t handler, ply_boot_client_response_handler_t failed_handler, void *user_data) @@ -224,10 +221,8 @@ ply_boot_client_request_new (ply_boot_client_t *client, request = calloc (1, sizeof (ply_boot_client_request_t)); request->client = client; request->command = strdup (request_command); - if (request_argument_1 != NULL) - request->argument_1 = strdup (request_argument_1); - if (request_argument_2 != NULL) - request->argument_2 = strdup (request_argument_2); + if (request_argument != NULL) + request->argument = strdup (request_argument); request->handler = handler; request->failed_handler = failed_handler; request->user_data = user_data; @@ -241,8 +236,8 @@ ply_boot_client_request_free (ply_boot_client_request_t *request) if (request == NULL) return; free (request->command); - free (request->argument_1); - free (request->argument_2); + if (request->argument != NULL) + free (request->argument); free (request); } @@ -394,7 +389,6 @@ ply_boot_client_get_request_string (ply_boot_client_t *client, size_t *request_size) { char *request_string; - int ret; assert (client != NULL); assert (request != NULL); @@ -402,37 +396,19 @@ ply_boot_client_get_request_string (ply_boot_client_t *client, assert (request->command != NULL); - if (request->argument_1 == NULL && request->argument_2 == NULL) + if (request->argument == NULL) { request_string = strdup (request->command); *request_size = strlen (request_string) + 1; return request_string; } - assert (strlen (request->argument_1) <= UCHAR_MAX); + assert (strlen (request->argument) <= UCHAR_MAX); request_string = NULL; - - if (request->argument_2 == NULL) - { - ret = asprintf (&request_string, "%s\002%c%s", request->command, - (char) (strlen (request->argument_1) + 1), request->argument_1); - } - else - { - assert (request->argument_1 != NULL); - assert (strlen (request->argument_2) <= UCHAR_MAX); - ret = asprintf (&request_string, "%s\003%c%s%c%c%s", request->command, - (char) (strlen (request->argument_1) + 1), - request->argument_1, - 0, - (char) (strlen (request->argument_2) + 1), - request->argument_2); - } - - assert (ret > 0); - - *request_size = (size_t)ret + 1; + asprintf (&request_string, "%s\002%c%s", request->command, + (char) (strlen (request->argument) + 1), request->argument); + *request_size = strlen (request_string) + 1; return request_string; } @@ -506,8 +482,7 @@ ply_boot_client_process_pending_requests (ply_boot_client_t *client) static void ply_boot_client_queue_request (ply_boot_client_t *client, const char *request_command, - const char *request_argument_1, - const char *request_argument_2, + const char *request_argument, ply_boot_client_response_handler_t handler, ply_boot_client_response_handler_t failed_handler, void *user_data) @@ -515,8 +490,7 @@ ply_boot_client_queue_request (ply_boot_client_t *client, assert (client != NULL); assert (client->loop != NULL); assert (request_command != NULL); - assert (request_argument_1 == NULL || strlen (request_argument_1) <= UCHAR_MAX); - assert (request_argument_2 == NULL || strlen (request_argument_2) <= UCHAR_MAX); + assert (request_argument == NULL || strlen (request_argument) <= UCHAR_MAX); if (client->daemon_can_take_request_watch == NULL && client->socket_fd >= 0) @@ -542,8 +516,7 @@ ply_boot_client_queue_request (ply_boot_client_t *client, ply_boot_client_request_t *request; request = ply_boot_client_request_new (client, request_command, - request_argument_1, - request_argument_2, + request_argument, handler, failed_handler, user_data); ply_list_append_data (client->requests_to_send, request); } @@ -558,39 +531,12 @@ ply_boot_client_ping_daemon (ply_boot_client_t *client, assert (client != NULL); ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_PING, - NULL, NULL, handler, failed_handler, user_data); -} - -void ply_boot_client_register_operation (ply_boot_client_t *client, - const char *operation_id, - const char *name, - 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_REGISTER, - operation_id, name, handler, failed_handler, user_data); - - -} -void ply_boot_client_unregister_operation (ply_boot_client_t *client, - const char *operation_id, - 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_UNREGISTER, - operation_id, NULL, handler, failed_handler, user_data); + NULL, handler, failed_handler, user_data); } void ply_boot_client_update_daemon (ply_boot_client_t *client, const char *status, - const char *operation_id, ply_boot_client_response_handler_t handler, ply_boot_client_response_handler_t failed_handler, void *user_data) @@ -598,7 +544,7 @@ ply_boot_client_update_daemon (ply_boot_client_t *client, assert (client != NULL); ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_UPDATE, - status, operation_id, handler, failed_handler, user_data); + status, handler, failed_handler, user_data); } void @@ -611,7 +557,7 @@ ply_boot_client_change_mode (ply_boot_client_t *client, assert (client != NULL); ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_CHANGE_MODE, - new_mode, NULL, handler, failed_handler, user_data); + new_mode, handler, failed_handler, user_data); } void @@ -624,7 +570,7 @@ ply_boot_client_system_update (ply_boot_client_t *client, assert (client != NULL); ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_SYSTEM_UPDATE, - progress, NULL, handler, failed_handler, user_data); + progress, handler, failed_handler, user_data); } void @@ -638,7 +584,7 @@ ply_boot_client_tell_daemon_to_change_root (ply_boot_client_t * assert (root_dir != NULL); ply_boot_client_queue_request(client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_NEWROOT, - root_dir, NULL, handler, failed_handler, user_data); + root_dir, handler, failed_handler, user_data); } void @@ -652,7 +598,7 @@ ply_boot_client_tell_daemon_to_display_message (ply_boot_client_t assert (message != NULL); ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_SHOW_MESSAGE, - message, NULL, handler, failed_handler, user_data); + message, handler, failed_handler, user_data); } void @@ -666,7 +612,7 @@ ply_boot_client_tell_daemon_to_hide_message (ply_boot_client_t assert (message != NULL); ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_HIDE_MESSAGE, - message, NULL, handler, failed_handler, user_data); + message, handler, failed_handler, user_data); } void @@ -679,7 +625,7 @@ ply_boot_client_tell_daemon_system_is_initialized (ply_boot_client_t ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_SYSTEM_INITIALIZED, - NULL, NULL, handler, failed_handler, user_data); + NULL, handler, failed_handler, user_data); } void @@ -693,7 +639,7 @@ ply_boot_client_ask_daemon_for_password (ply_boot_client_t *cli assert (client != NULL); ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_PASSWORD, - prompt, NULL, (ply_boot_client_response_handler_t) + prompt, (ply_boot_client_response_handler_t) handler, failed_handler, user_data); } @@ -706,7 +652,7 @@ ply_boot_client_ask_daemon_for_cached_passwords (ply_boot_client_t assert (client != NULL); ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_CACHED_PASSWORD, - NULL, NULL, (ply_boot_client_response_handler_t) + NULL, (ply_boot_client_response_handler_t) handler, failed_handler, user_data); } @@ -720,7 +666,7 @@ ply_boot_client_ask_daemon_question (ply_boot_client_t *c assert (client != NULL); ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_QUESTION, - prompt, NULL, (ply_boot_client_response_handler_t) + prompt, (ply_boot_client_response_handler_t) handler, failed_handler, user_data); } @@ -734,7 +680,7 @@ ply_boot_client_ask_daemon_to_watch_for_keystroke (ply_boot_client_t * assert (client != NULL); ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_KEYSTROKE, - keys, NULL, (ply_boot_client_response_handler_t) + keys, (ply_boot_client_response_handler_t) handler, failed_handler, user_data); } @@ -748,7 +694,7 @@ ply_boot_client_ask_daemon_to_ignore_keystroke (ply_boot_client_t assert (client != NULL); ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_KEYSTROKE_REMOVE, - keys, NULL, (ply_boot_client_response_handler_t) + keys, (ply_boot_client_response_handler_t) handler, failed_handler, user_data); } @@ -761,7 +707,7 @@ ply_boot_client_tell_daemon_to_show_splash (ply_boot_client_t * assert (client != NULL); ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_SHOW_SPLASH, - NULL, NULL, handler, failed_handler, user_data); + NULL, handler, failed_handler, user_data); } void @@ -773,7 +719,7 @@ ply_boot_client_tell_daemon_to_hide_splash (ply_boot_client_t * assert (client != NULL); ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_HIDE_SPLASH, - NULL, NULL, handler, failed_handler, user_data); + NULL, handler, failed_handler, user_data); } void @@ -785,7 +731,7 @@ ply_boot_client_tell_daemon_to_deactivate (ply_boot_client_t *c assert (client != NULL); ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_DEACTIVATE, - NULL, NULL, handler, failed_handler, user_data); + NULL, handler, failed_handler, user_data); } void @@ -797,7 +743,7 @@ ply_boot_client_tell_daemon_to_reactivate (ply_boot_client_t *c assert (client != NULL); ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_REACTIVATE, - NULL, NULL, handler, failed_handler, user_data); + NULL, handler, failed_handler, user_data); } void @@ -813,7 +759,7 @@ ply_boot_client_tell_daemon_to_quit (ply_boot_client_t *client, arg[0] = (char) (retain_splash != false); ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_QUIT, - arg, NULL, handler, failed_handler, user_data); + arg, handler, failed_handler, user_data); } void @@ -823,7 +769,7 @@ ply_boot_client_tell_daemon_to_progress_pause (ply_boot_client_t void *user_data) { ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_PROGRESS_PAUSE, - NULL, NULL, handler, failed_handler, user_data); + NULL, handler, failed_handler, user_data); } void @@ -833,7 +779,7 @@ ply_boot_client_tell_daemon_to_progress_unpause (ply_boot_client_t void *user_data) { ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_PROGRESS_UNPAUSE, - NULL, NULL, handler, failed_handler, user_data); + NULL, handler, failed_handler, user_data); } void @@ -843,7 +789,7 @@ ply_boot_client_ask_daemon_has_active_vt (ply_boot_client_t *cl void *user_data) { ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_HAS_ACTIVE_VT, - NULL, NULL, handler, failed_handler, user_data); + NULL, handler, failed_handler, user_data); } void @@ -853,7 +799,7 @@ ply_boot_client_tell_daemon_about_error (ply_boot_client_t *cli void *user_data) { ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_ERROR, - NULL, NULL, handler, failed_handler, user_data); + NULL, handler, failed_handler, user_data); } void diff --git a/src/client/ply-boot-client.h b/src/client/ply-boot-client.h index 8154a5cd..24939f76 100644 --- a/src/client/ply-boot-client.h +++ b/src/client/ply-boot-client.h @@ -1,7 +1,6 @@ /* ply-boot-client.h - APIs for talking to the boot status daemon * * Copyright (C) 2007 Red Hat, Inc. - * Copyright (C) 2012 Pali Rohár * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -54,20 +53,8 @@ void ply_boot_client_ping_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_register_operation (ply_boot_client_t *client, - const char *operation_id, - const char *name, - ply_boot_client_response_handler_t handler, - ply_boot_client_response_handler_t failed_handler, - void *user_data); -void ply_boot_client_unregister_operation (ply_boot_client_t *client, - const char *operation_id, - ply_boot_client_response_handler_t handler, - ply_boot_client_response_handler_t failed_handler, - void *user_data); void ply_boot_client_update_daemon (ply_boot_client_t *client, const char *new_status, - const char *operation_id, ply_boot_client_response_handler_t handler, ply_boot_client_response_handler_t failed_handler, void *user_data); diff --git a/src/client/plymouth.c b/src/client/plymouth.c index 23c4be94..b22e90cf 100644 --- a/src/client/plymouth.c +++ b/src/client/plymouth.c @@ -1,7 +1,6 @@ /* plymouth.c - updates boot status * * Copyright (C) 2007 Red Hat, Inc - * Copyright (C) 2012 Pali Rohár * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -841,85 +840,21 @@ on_hide_splash_request (state_t *state, on_failure, state); } -static void -on_register_operation_request (state_t *state, - const char *command) -{ - char *name; - char *operation_id; - - name = NULL; - operation_id = NULL; - ply_command_parser_get_command_options (state->command_parser, - command, - "name", &name, - "operation-id", &operation_id, - NULL); - - if (operation_id != NULL && name != NULL) - { - ply_boot_client_register_operation(state->client, operation_id, name, - (ply_boot_client_response_handler_t) - on_success, - (ply_boot_client_response_handler_t) - on_failure, state); - } - else - { - ply_error ("unknown operation id or name"); - ply_event_loop_exit (state->loop, 1); - } -} - -static void -on_unregister_operation_request (state_t *state, - const char *command) -{ - char *operation_id; - - operation_id = NULL; - ply_command_parser_get_command_options (state->command_parser, - command, - "operation-id", &operation_id, - NULL); - - if (operation_id != NULL) - { - ply_boot_client_unregister_operation(state->client, operation_id, - (ply_boot_client_response_handler_t) - on_success, - (ply_boot_client_response_handler_t) - on_failure, state); - } - else - { - ply_error ("unknown operation id"); - ply_event_loop_exit (state->loop, 1); - } -} - static void on_update_request (state_t *state, const char *command) { char *status; - const char *operation_id; status = NULL; - operation_id = NULL; ply_command_parser_get_command_options (state->command_parser, command, - "operation-id", &operation_id, "status", &status, NULL); - if (operation_id == NULL) - operation_id = ""; - if (status != NULL) { - - ply_boot_client_update_daemon (state->client, status, operation_id, + ply_boot_client_update_daemon (state->client, status, (ply_boot_client_response_handler_t) on_success, (ply_boot_client_response_handler_t) @@ -1064,30 +999,10 @@ main (int argc, PLY_COMMAND_OPTION_TYPE_INTEGER, NULL); - ply_command_parser_add_command (state.command_parser, - "register-operation", "Tell boot daemon to register operation", - (ply_command_handler_t) - on_register_operation_request, &state, - "operation-id", "Operation id", - PLY_COMMAND_OPTION_TYPE_STRING, - "name", "Operation name", - PLY_COMMAND_OPTION_TYPE_STRING, - NULL); - - ply_command_parser_add_command (state.command_parser, - "unregister-operation", "Tell boot daemon to unregister operation", - (ply_command_handler_t) - on_unregister_operation_request, &state, - "operation-id", "Operation id", - PLY_COMMAND_OPTION_TYPE_STRING, - NULL); - ply_command_parser_add_command (state.command_parser, "update", "Tell daemon about boot status changes", (ply_command_handler_t) on_update_request, &state, - "operation-id", "Tell daemon operation id", - PLY_COMMAND_OPTION_TYPE_STRING, "status", "Tell daemon the current boot status", PLY_COMMAND_OPTION_TYPE_STRING, NULL); @@ -1331,7 +1246,7 @@ main (int argc, (ply_boot_client_response_handler_t) on_failure, &state); else if (status != NULL) - ply_boot_client_update_daemon (state.client, status, NULL, + ply_boot_client_update_daemon (state.client, status, (ply_boot_client_response_handler_t) on_success, (ply_boot_client_response_handler_t) diff --git a/src/libply-splash-core/ply-boot-splash-plugin.h b/src/libply-splash-core/ply-boot-splash-plugin.h index c44a9a25..2d73d661 100644 --- a/src/libply-splash-core/ply-boot-splash-plugin.h +++ b/src/libply-splash-core/ply-boot-splash-plugin.h @@ -1,7 +1,6 @@ /* ply-boot-splash-plugin.h - plugin interface for ply_boot_splash_t * * Copyright (C) 2007 Red Hat, Inc. - * Copyright (C) 2012 Pali Rohár * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -68,14 +67,8 @@ typedef struct ply_boot_splash_mode_t mode); void (* system_update) (ply_boot_splash_plugin_t *plugin, int progress); - void (* register_operation) (ply_boot_splash_plugin_t *plugin, - const char *operation_id, - const char *name); - void (* unregister_operation) (ply_boot_splash_plugin_t *plugin, - const char *operation_id); void (* update_status) (ply_boot_splash_plugin_t *plugin, - const char *status, - const char *operation_id); + const char *status); void (* on_boot_output) (ply_boot_splash_plugin_t *plugin, const char *output, size_t size); diff --git a/src/libply-splash-core/ply-boot-splash.c b/src/libply-splash-core/ply-boot-splash.c index 1007cb6a..160ce45e 100644 --- a/src/libply-splash-core/ply-boot-splash.c +++ b/src/libply-splash-core/ply-boot-splash.c @@ -1,7 +1,6 @@ /* ply-boot-splash.h - APIs for putting up a splash screen * * Copyright (C) 2007 Red Hat, Inc. - * Copyright (C) 2012 Pali Rohár * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -550,36 +549,9 @@ ply_boot_splash_system_update (ply_boot_splash_t *splash, return true; } -void ply_boot_splash_register_operation (ply_boot_splash_t *splash, - const char *operation_id, - const char *name) -{ - assert (splash != NULL); - assert (operation_id != NULL); - assert (name != NULL); - assert (splash->plugin_interface != NULL); - assert (splash->plugin != NULL); - assert (splash->plugin_interface->register_operation != NULL); - - splash->plugin_interface->register_operation (splash->plugin, operation_id, name); -} - -void ply_boot_splash_unregister_operation (ply_boot_splash_t *splash, - const char *operation_id) -{ - assert (splash != NULL); - assert (operation_id != NULL); - assert (splash->plugin_interface != NULL); - assert (splash->plugin != NULL); - assert (splash->plugin_interface->register_operation != NULL); - - splash->plugin_interface->unregister_operation (splash->plugin, operation_id); -} - void ply_boot_splash_update_status (ply_boot_splash_t *splash, - const char *status, - const char *operation_id) + const char *status) { assert (splash != NULL); assert (status != NULL); @@ -588,7 +560,7 @@ ply_boot_splash_update_status (ply_boot_splash_t *splash, assert (splash->plugin_interface->update_status != NULL); assert (splash->mode != PLY_BOOT_SPLASH_MODE_INVALID); - splash->plugin_interface->update_status (splash->plugin, status, operation_id); + splash->plugin_interface->update_status (splash->plugin, status); } void diff --git a/src/libply-splash-core/ply-boot-splash.h b/src/libply-splash-core/ply-boot-splash.h index 23925300..335039ba 100644 --- a/src/libply-splash-core/ply-boot-splash.h +++ b/src/libply-splash-core/ply-boot-splash.h @@ -59,14 +59,8 @@ bool ply_boot_splash_show (ply_boot_splash_t *splash, ply_boot_splash_mode_t mode); bool ply_boot_splash_system_update (ply_boot_splash_t *splash, int progress); -void ply_boot_splash_register_operation (ply_boot_splash_t *splash, - const char *operation_id, - const char *name); -void ply_boot_splash_unregister_operation (ply_boot_splash_t *splash, - const char *operation_id); void ply_boot_splash_update_status (ply_boot_splash_t *splash, - const char *status, - const char *operation_id); + const char *status); void ply_boot_splash_update_output (ply_boot_splash_t *splash, const char *output, size_t size); diff --git a/src/libply/ply-progress.c b/src/libply/ply-progress.c index f6cb67fe..4a16556d 100644 --- a/src/libply/ply-progress.c +++ b/src/libply/ply-progress.c @@ -1,7 +1,6 @@ /* ply-progress.c - calculats boot progress * * Copyright (C) 2007 Red Hat, Inc. - * Copyright (C) 2012 Pali Rohár * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -69,7 +68,6 @@ struct _ply_progress typedef struct { double time; - char* id; char* string; uint32_t disabled : 1; } ply_progress_message_t; @@ -105,7 +103,6 @@ ply_progress_free (ply_progress_t* progress) ply_progress_message_t *message = ply_list_node_get_data (node); next_node = ply_list_get_next_node (progress->current_message_list, node); - free (message->id); free (message->string); free (message); node = next_node; @@ -120,7 +117,6 @@ ply_progress_free (ply_progress_t* progress) ply_progress_message_t *message = ply_list_node_get_data (node); next_node = ply_list_get_next_node (progress->previous_message_list, node); - free (message->id); free (message->string); free (message); node = next_node; @@ -132,7 +128,7 @@ ply_progress_free (ply_progress_t* progress) static ply_progress_message_t* -ply_progress_message_search (ply_list_t *message_list, const char* id, const char* string) +ply_progress_message_search (ply_list_t *message_list, const char* string) { ply_list_node_t *node; node = ply_list_get_first_node (message_list); @@ -140,7 +136,7 @@ ply_progress_message_search (ply_list_t *message_list, const char* id, const cha while (node) { ply_progress_message_t *message = ply_list_node_get_data (node); - if (strcmp(id, message->id)==0 && strcmp(string, message->string)==0) + if (strcmp(string, message->string)==0) return message; node = ply_list_get_next_node (message_list, node); } @@ -149,7 +145,7 @@ ply_progress_message_search (ply_list_t *message_list, const char* id, const cha static ply_progress_message_t* -ply_progress_message_search_next (ply_list_t *message_list, const char* id, double time) +ply_progress_message_search_next (ply_list_t *message_list, double time) { ply_list_node_t *node; node = ply_list_get_first_node (message_list); @@ -157,7 +153,7 @@ ply_progress_message_search_next (ply_list_t *message_list, const char* id, doub while (node) { ply_progress_message_t *message = ply_list_node_get_data (node); - if (strcmp(id, message->id)==0 && message->time > time && (!best || message->time < best->time)) + if (message->time > time && (!best || message->time < best->time)) best = message; node = ply_list_get_next_node (message_list, node); } @@ -179,8 +175,6 @@ ply_progress_load_cache (ply_progress_t* progress, int items_matched; double time; int string_size=81; - char *ptr; - char *id; char *string; char colon; int i=0; @@ -206,20 +200,8 @@ ply_progress_load_cache (ply_progress_t* progress, } i++; } - - ptr = strchr(string, ':'); - if (!ptr) - id = strdup(""); - else - { - *ptr = 0; - id = string; - string = strdup(ptr+1); - } - ply_progress_message_t* message = malloc(sizeof(ply_progress_message_t)); message->time = time; - message->id = id; message->string = string; ply_list_append_data(progress->previous_message_list, message); } @@ -250,7 +232,7 @@ ply_progress_save_cache (ply_progress_t* progress, ply_progress_message_t *message = ply_list_node_get_data (node); double percentage = message->time / cur_time; if (!message->disabled) - fprintf (fp, "%.3lf:%s:%s\n", percentage, message->id, message->string); + fprintf (fp, "%.3lf:%s\n", percentage, message->string); node = ply_list_get_next_node (progress->current_message_list, node); } fclose (fp); @@ -323,21 +305,20 @@ ply_progress_unpause (ply_progress_t* progress) void ply_progress_status_update (ply_progress_t* progress, - const char *status, - const char *operation_id) + const char *status) { ply_progress_message_t *message, *message_next; - message = ply_progress_message_search(progress->current_message_list, operation_id, status); + message = ply_progress_message_search(progress->current_message_list, status); if (message) { message->disabled = true; } /* Remove duplicates as they confuse things*/ else { - message = ply_progress_message_search(progress->previous_message_list, operation_id, status); + message = ply_progress_message_search(progress->previous_message_list, status); if (message) { - message_next = ply_progress_message_search_next(progress->previous_message_list, operation_id, message->time); + message_next = ply_progress_message_search_next(progress->previous_message_list, message->time); if (message_next) progress->next_message_percentage = message_next->time; else @@ -348,7 +329,6 @@ ply_progress_status_update (ply_progress_t* progress, } message = malloc(sizeof(ply_progress_message_t)); message->time = ply_progress_get_time (progress); - message->id = strdup(operation_id); message->string = strdup(status); message->disabled = false; ply_list_append_data(progress->current_message_list, message); diff --git a/src/libply/ply-progress.h b/src/libply/ply-progress.h index 54bb7b97..434636a6 100644 --- a/src/libply/ply-progress.h +++ b/src/libply/ply-progress.h @@ -36,7 +36,7 @@ double ply_progress_get_time (ply_progress_t* progress); void ply_progress_pause (ply_progress_t* progress); void ply_progress_unpause (ply_progress_t* progress); void ply_progress_save_cache (ply_progress_t* progress, const char *filename); -void ply_progress_status_update (ply_progress_t* progress, const char *status, const char *operation_id); +void ply_progress_status_update (ply_progress_t* progress, const char *status); #endif /* PLY_PROGRESS_H */ /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */ diff --git a/src/main.c b/src/main.c index 8a0770cb..c3daac0f 100644 --- a/src/main.c +++ b/src/main.c @@ -1,7 +1,6 @@ /* main.c - boot messages monitor * * Copyright (C) 2007 Red Hat, Inc - * Copyright (C) 2012 Pali Rohár * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -181,38 +180,16 @@ on_session_hangup (state_t *state) ply_trace ("got hang up on terminal session fd"); } -static void -on_register (state_t *state, - const char *operation_id, - const char *name) -{ - ply_trace ("register operation '%s' with name '%s'", operation_id, name); - if (state->boot_splash != NULL) - ply_boot_splash_register_operation (state->boot_splash, - operation_id, name); -} - -static void -on_unregister (state_t *state, - const char *operation_id) -{ - ply_trace ("register operation '%s'", operation_id); - if (state->boot_splash != NULL) - ply_boot_splash_unregister_operation (state->boot_splash, - operation_id); -} - static void on_update (state_t *state, - const char *status, - const char *operation_id) + const char *status) { - ply_trace ("updating status of operation '%s' to '%s'", operation_id, status); + ply_trace ("updating status to '%s'", status); ply_progress_status_update (state->progress, - status, operation_id); + status); if (state->boot_splash != NULL) ply_boot_splash_update_status (state->boot_splash, - status, operation_id); + status); } static void @@ -1393,9 +1370,7 @@ start_boot_server (state_t *state) { ply_boot_server_t *server; - server = ply_boot_server_new ((ply_boot_server_register_handler_t) on_register, - (ply_boot_server_unregister_handler_t) on_unregister, - (ply_boot_server_update_handler_t) on_update, + server = ply_boot_server_new ((ply_boot_server_update_handler_t) on_update, (ply_boot_server_change_mode_handler_t) on_change_mode, (ply_boot_server_system_update_handler_t) on_system_update, (ply_boot_server_ask_for_password_handler_t) on_ask_for_password, diff --git a/src/plugins/splash/details/plugin.c b/src/plugins/splash/details/plugin.c index ef62ffea..aff2f1c0 100644 --- a/src/plugins/splash/details/plugin.c +++ b/src/plugins/splash/details/plugin.c @@ -1,7 +1,6 @@ /* details.c - boot splash plugin * * Copyright (C) 2008 Red Hat, Inc. - * Copyright (C) 2012 Pali Rohár * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -67,12 +66,6 @@ typedef struct ply_text_display_t *display; } view_t; -typedef struct -{ - char *operation_id; - char *name; -} operation_t; - ply_boot_splash_plugin_interface_t *ply_boot_splash_plugin_get_interface (void); static void detach_from_event_loop (ply_boot_splash_plugin_t *plugin); @@ -83,7 +76,7 @@ struct _ply_boot_splash_plugin ply_list_t *views; ply_boot_splash_display_type_t state; ply_list_t *messages; - ply_list_t *operations; + }; static view_t * @@ -155,75 +148,6 @@ free_messages (ply_boot_splash_plugin_t *plugin) plugin->messages = NULL; } -static operation_t * -operation_new (ply_boot_splash_plugin_t *plugin, - const char *operation_id, - const char *name) -{ - operation_t *operation; - operation = malloc (sizeof(operation_t)); - operation->operation_id = strdup (operation_id); - operation->name = strdup (name); - return operation; -} - -static void -operation_free (operation_t *operation) -{ - free (operation->operation_id); - free (operation->name); - free (operation); -} - -static void -free_operations (ply_boot_splash_plugin_t *plugin) -{ - ply_list_node_t *node; - - node = ply_list_get_first_node (plugin->operations); - - while (node != NULL) - { - ply_list_node_t *next_node; - operation_t *operation; - - operation = ply_list_node_get_data (node); - next_node = ply_list_get_next_node (plugin->operations, node); - - operation_free (operation); - ply_list_remove_node (plugin->operations, node); - - node = next_node; - } - - ply_list_free (plugin->operations); - plugin->operations = NULL; -} - -static const char * -get_operation_name (ply_boot_splash_plugin_t *plugin, const char *id) -{ - ply_list_node_t *node; - - node = ply_list_get_first_node (plugin->operations); - - while (node != NULL) - { - operation_t *operation; - - operation = ply_list_node_get_data (node); - if (strcmp(operation->operation_id, id) == 0) - { - return operation->name; - } - - node = ply_list_get_next_node (plugin->operations, node); - - } - - return NULL; -} - static ply_boot_splash_plugin_t * create_plugin (ply_key_file_t *key_file) { @@ -234,7 +158,6 @@ 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->operations = ply_list_new (); plugin->messages = ply_list_new (); return plugin; } @@ -255,7 +178,6 @@ destroy_plugin (ply_boot_splash_plugin_t *plugin) detach_from_event_loop (plugin); } - free_operations (plugin); free_messages (plugin); free_views (plugin); @@ -376,75 +298,13 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin, return true; } -static void -register_operation (ply_boot_splash_plugin_t *plugin, - const char *operation_id, - const char *name) -{ - operation_t *operation; - assert (plugin != NULL); - assert (operation_id != NULL); - assert (name != NULL); - - ply_trace ("register operation"); - - operation = operation_new (plugin, operation_id, name); - ply_list_append_data (plugin->operations, operation); -} - -static void -unregister_operation (ply_boot_splash_plugin_t *plugin, - const char *operation_id) -{ - assert (plugin != NULL); - assert (operation_id != NULL); - - ply_trace ("unregister operation"); - - ply_list_node_t *node; - - node = ply_list_get_first_node (plugin->operations); - - while (node != NULL) - { - operation_t *operation; - - operation = ply_list_node_get_data (node); - if (strcmp(operation->operation_id, operation_id) == 0) - { - ply_list_remove_node(plugin->operations, node); - return; - } - - node = ply_list_get_next_node (plugin->operations, node); - - } -} - static void update_status (ply_boot_splash_plugin_t *plugin, - const char *status, - const char *operation_id) + const char *status) { assert (plugin != NULL); - assert (status != NULL); ply_trace ("status update"); - - if (operation_id != NULL) - { - const char *operation_name = get_operation_name (plugin, operation_id); - if (operation_name != NULL) - { - char *message; - asprintf (&message, "%s... [%s]\r\n", operation_name, status); - if (message != NULL) - { - write_on_views (plugin, message, strlen (message)); - free(message); - } - } - } } static void @@ -571,8 +431,6 @@ ply_boot_splash_plugin_get_interface (void) .add_text_display = add_text_display, .remove_text_display = remove_text_display, .show_splash_screen = show_splash_screen, - .register_operation = register_operation, - .unregister_operation = unregister_operation, .update_status = update_status, .on_boot_output = on_boot_output, .hide_splash_screen = hide_splash_screen, diff --git a/src/plugins/splash/fade-throbber/plugin.c b/src/plugins/splash/fade-throbber/plugin.c index 8ed79bf3..4af6cae7 100644 --- a/src/plugins/splash/fade-throbber/plugin.c +++ b/src/plugins/splash/fade-throbber/plugin.c @@ -927,8 +927,7 @@ add_stars (ply_boot_splash_plugin_t *plugin) static void update_status (ply_boot_splash_plugin_t *plugin, - const char *status, - const char *operation_id) + const char *status) { assert (plugin != NULL); diff --git a/src/plugins/splash/script/plugin.c b/src/plugins/splash/script/plugin.c index 6eccedf4..c5c1e169 100644 --- a/src/plugins/splash/script/plugin.c +++ b/src/plugins/splash/script/plugin.c @@ -429,35 +429,13 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin, return start_animation (plugin); } -static void -register_operation (ply_boot_splash_plugin_t *plugin, - const char *operation_id, - const char *name) -{ - script_lib_plymouth_on_register_operation (plugin->script_state, - plugin->script_plymouth_lib, - operation_id, - name); -} - -static void -unregister_operation (ply_boot_splash_plugin_t *plugin, - const char *operation_id) -{ - script_lib_plymouth_on_unregister_operation (plugin->script_state, - plugin->script_plymouth_lib, - operation_id); -} - static void update_status (ply_boot_splash_plugin_t *plugin, - const char *status, - const char *operation_id) + const char *status) { script_lib_plymouth_on_update_status (plugin->script_state, plugin->script_plymouth_lib, - status, - operation_id); + status); } static void @@ -561,8 +539,6 @@ ply_boot_splash_plugin_get_interface (void) .add_pixel_display = add_pixel_display, .remove_pixel_display = remove_pixel_display, .show_splash_screen = show_splash_screen, - .register_operation = register_operation, - .unregister_operation = unregister_operation, .update_status = update_status, .on_boot_progress = on_boot_progress, .hide_splash_screen = hide_splash_screen, diff --git a/src/plugins/splash/script/script-lib-plymouth.c b/src/plugins/splash/script/script-lib-plymouth.c index 6cb1a25d..ab2ec443 100644 --- a/src/plugins/splash/script/script-lib-plymouth.c +++ b/src/plugins/splash/script/script-lib-plymouth.c @@ -81,8 +81,6 @@ script_lib_plymouth_data_t *script_lib_plymouth_setup (script_state_t *s data->script_boot_progress_func = script_obj_new_null (); data->script_root_mounted_func = script_obj_new_null (); data->script_keyboard_input_func = script_obj_new_null (); - data->script_register_operation_func = script_obj_new_null (); - data->script_unregister_operation_func = script_obj_new_null (); data->script_update_status_func = script_obj_new_null (); data->script_display_normal_func = script_obj_new_null (); data->script_display_password_func = script_obj_new_null (); @@ -117,18 +115,6 @@ script_lib_plymouth_data_t *script_lib_plymouth_setup (script_state_t *s &data->script_keyboard_input_func, "function", NULL); - script_add_native_function (plymouth_hash, - "SetRegisterOperationFunction", - plymouth_set_function, - &data->script_register_operation_func, - "function", - NULL); - script_add_native_function (plymouth_hash, - "SetUnregisterOperationFunction", - plymouth_set_function, - &data->script_unregister_operation_func, - "function", - NULL); script_add_native_function (plymouth_hash, "SetUpdateStatusFunction", plymouth_set_function, @@ -192,8 +178,6 @@ void script_lib_plymouth_destroy (script_lib_plymouth_data_t *data) script_obj_unref (data->script_boot_progress_func); script_obj_unref (data->script_root_mounted_func); script_obj_unref (data->script_keyboard_input_func); - script_obj_unref (data->script_register_operation_func); - script_obj_unref (data->script_unregister_operation_func); script_obj_unref (data->script_update_status_func); script_obj_unref (data->script_display_normal_func); script_obj_unref (data->script_display_password_func); @@ -256,53 +240,17 @@ void script_lib_plymouth_on_keyboard_input (script_state_t *state, script_obj_unref (ret.object); } -void script_lib_plymouth_on_register_operation (script_state_t *state, - script_lib_plymouth_data_t *data, - const char *operation_id, - const char *name) -{ - script_obj_t *new_name_obj = script_obj_new_string (name); - script_obj_t *new_operation_id_obj = script_obj_new_string (operation_id); - script_return_t ret = script_execute_object (state, - data->script_register_operation_func, - NULL, - new_operation_id_obj, - new_name_obj, - NULL); - script_obj_unref (new_name_obj); - script_obj_unref (new_operation_id_obj); - script_obj_unref (ret.object); -} - -void script_lib_plymouth_on_unregister_operation (script_state_t *state, - script_lib_plymouth_data_t *data, - const char *operation_id) -{ - script_obj_t *new_operation_id_obj = script_obj_new_string (operation_id); - script_return_t ret = script_execute_object (state, - data->script_unregister_operation_func, - NULL, - new_operation_id_obj, - NULL); - script_obj_unref (new_operation_id_obj); - script_obj_unref (ret.object); -} - void script_lib_plymouth_on_update_status (script_state_t *state, script_lib_plymouth_data_t *data, - const char *new_status, - const char *operation_id) + const char *new_status) { script_obj_t *new_status_obj = script_obj_new_string (new_status); - script_obj_t *new_operation_id_obj = script_obj_new_string (operation_id); script_return_t ret = script_execute_object (state, data->script_update_status_func, NULL, new_status_obj, - new_operation_id_obj, NULL); script_obj_unref (new_status_obj); - script_obj_unref (new_operation_id_obj); script_obj_unref (ret.object); } diff --git a/src/plugins/splash/script/script-lib-plymouth.h b/src/plugins/splash/script/script-lib-plymouth.h index fef5a0f2..c4ec5a66 100644 --- a/src/plugins/splash/script/script-lib-plymouth.h +++ b/src/plugins/splash/script/script-lib-plymouth.h @@ -32,8 +32,6 @@ typedef struct script_obj_t *script_boot_progress_func; script_obj_t *script_root_mounted_func; script_obj_t *script_keyboard_input_func; - script_obj_t *script_register_operation_func; - script_obj_t *script_unregister_operation_func; script_obj_t *script_update_status_func; script_obj_t *script_display_normal_func; script_obj_t *script_display_password_func; @@ -59,17 +57,9 @@ void script_lib_plymouth_on_root_mounted (script_state_t *state, void script_lib_plymouth_on_keyboard_input (script_state_t *state, script_lib_plymouth_data_t *data, const char *keyboard_input); -void script_lib_plymouth_on_register_operation (script_state_t *state, - script_lib_plymouth_data_t *data, - const char *operation_id, - const char *name); -void script_lib_plymouth_on_unregister_operation (script_state_t *state, - script_lib_plymouth_data_t *data, - const char *operation_id); void script_lib_plymouth_on_update_status (script_state_t *state, script_lib_plymouth_data_t *data, - const char *new_status, - const char *operation_id); + const char *new_status); void script_lib_plymouth_on_display_normal (script_state_t *state, script_lib_plymouth_data_t *data); void script_lib_plymouth_on_display_password (script_state_t *state, diff --git a/src/plugins/splash/space-flares/plugin.c b/src/plugins/splash/space-flares/plugin.c index 05754e64..e31dce87 100644 --- a/src/plugins/splash/space-flares/plugin.c +++ b/src/plugins/splash/space-flares/plugin.c @@ -1708,8 +1708,7 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin, static void update_status (ply_boot_splash_plugin_t *plugin, - const char *status, - const char *operation_id) + const char *status) { assert (plugin != NULL); } diff --git a/src/plugins/splash/text/plugin.c b/src/plugins/splash/text/plugin.c index 078cd026..fb97c14c 100644 --- a/src/plugins/splash/text/plugin.c +++ b/src/plugins/splash/text/plugin.c @@ -537,8 +537,7 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin, static void update_status (ply_boot_splash_plugin_t *plugin, - const char *status, - const char *operation_id) + const char *status) { assert (plugin != NULL); diff --git a/src/plugins/splash/throbgress/plugin.c b/src/plugins/splash/throbgress/plugin.c index a10c5b35..fba809b8 100644 --- a/src/plugins/splash/throbgress/plugin.c +++ b/src/plugins/splash/throbgress/plugin.c @@ -713,8 +713,7 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin, static void update_status (ply_boot_splash_plugin_t *plugin, - const char *status, - const char *operation_id) + const char *status) { assert (plugin != NULL); } diff --git a/src/plugins/splash/two-step/plugin.c b/src/plugins/splash/two-step/plugin.c index 87794de9..f48b41e1 100644 --- a/src/plugins/splash/two-step/plugin.c +++ b/src/plugins/splash/two-step/plugin.c @@ -1111,8 +1111,7 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin, static void update_status (ply_boot_splash_plugin_t *plugin, - const char *status, - const char *operation_id) + const char *status) { assert (plugin != NULL); } diff --git a/src/ply-boot-protocol.h b/src/ply-boot-protocol.h index 31cff348..23dfc8da 100644 --- a/src/ply-boot-protocol.h +++ b/src/ply-boot-protocol.h @@ -25,8 +25,6 @@ #define PLY_BOOT_PROTOCOL_TRIMMED_ABSTRACT_SOCKET_PATH "/org/freedesktop/plymouthd" #define PLY_BOOT_PROTOCOL_OLD_ABSTRACT_SOCKET_PATH "/ply-boot-protocol" #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_PING "P" -#define PLY_BOOT_PROTOCOL_REQUEST_TYPE_REGISTER "O" -#define PLY_BOOT_PROTOCOL_REQUEST_TYPE_UNREGISTER "o" #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_UPDATE "U" #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_CHANGE_MODE "C" #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_SYSTEM_UPDATE "u" diff --git a/src/ply-boot-server.c b/src/ply-boot-server.c index e0ebf76e..3e67bfbf 100644 --- a/src/ply-boot-server.c +++ b/src/ply-boot-server.c @@ -1,7 +1,6 @@ /* ply-boot-server.c - listens for and processes boot-status events * * Copyright (C) 2007 Red Hat, Inc. - * Copyright (C) 2012 Pali Rohár * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,8 +57,6 @@ struct _ply_boot_server ply_list_t *cached_passwords; int socket_fd; - ply_boot_server_register_handler_t register_handler; - ply_boot_server_unregister_handler_t unregister_handler; ply_boot_server_update_handler_t update_handler; ply_boot_server_change_mode_handler_t change_mode_handler; ply_boot_server_system_update_handler_t system_update_handler; @@ -86,9 +83,7 @@ struct _ply_boot_server }; ply_boot_server_t * -ply_boot_server_new (ply_boot_server_register_handler_t register_handler, - ply_boot_server_unregister_handler_t unregister_handler, - ply_boot_server_update_handler_t update_handler, +ply_boot_server_new (ply_boot_server_update_handler_t update_handler, ply_boot_server_change_mode_handler_t change_mode_handler, ply_boot_server_system_update_handler_t system_update_handler, ply_boot_server_ask_for_password_handler_t ask_for_password_handler, @@ -117,8 +112,6 @@ ply_boot_server_new (ply_boot_server_register_handler_t register_handler, server->cached_passwords = ply_list_new (); server->loop = NULL; server->is_listening = false; - server->register_handler = register_handler; - server->unregister_handler = unregister_handler; server->update_handler = update_handler; server->change_mode_handler = change_mode_handler; server->system_update_handler = system_update_handler; @@ -210,12 +203,9 @@ ply_boot_server_stop_listening (ply_boot_server_t *server) static bool ply_boot_connection_read_request (ply_boot_connection_t *connection, char **command, - char **argument_1, - char **argument_2) + char **argument) { uint8_t header[2]; - uint8_t argument_1_size = 0; - uint8_t argument_2_size = 0; assert (connection != NULL); assert (connection->fd >= 0); @@ -228,41 +218,22 @@ ply_boot_connection_read_request (ply_boot_connection_t *connection, *command = calloc (2, sizeof (char)); *command[0] = header[0]; - *argument_1 = NULL; - *argument_2 = NULL; - if (header[1] == '\002' || header[1] == '\003') + *argument = NULL; + if (header[1] == '\002') { - if (!ply_read (connection->fd, &argument_1_size, sizeof (uint8_t))) - { - free (*command); - return false; - } + uint8_t argument_size; - *argument_1 = calloc (argument_1_size, sizeof (char)); - - if (!ply_read (connection->fd, *argument_1, argument_1_size)) + if (!ply_read (connection->fd, &argument_size, sizeof (uint8_t))) { - free (*argument_1); free (*command); return false; } - } - if (header[1] == '\003') - { - if (!ply_read (connection->fd, &argument_2_size, sizeof (uint8_t))) - { - free (*argument_1); - free (*command); - return false; - } - - *argument_2 = calloc (argument_2_size, sizeof (char)); + *argument = calloc (argument_size, sizeof (char)); - if (!ply_read (connection->fd, *argument_2, argument_2_size)) + if (!ply_read (connection->fd, *argument, argument_size)) { - free (*argument_1); - free (*argument_2); + free (*argument); free (*command); return false; } @@ -271,8 +242,7 @@ ply_boot_connection_read_request (ply_boot_connection_t *connection, if (!ply_get_credentials_from_fd (connection->fd, &connection->pid, &connection->uid, NULL)) { ply_trace ("couldn't read credentials from connection: %m"); - free (*argument_1); - free (*argument_2); + free (*argument); free (*command); return false; } @@ -409,7 +379,7 @@ static void ply_boot_connection_on_request (ply_boot_connection_t *connection) { ply_boot_server_t *server; - char *command, *argument_1, *argument_2; + char *command, *argument; assert (connection != NULL); assert (connection->fd >= 0); @@ -418,7 +388,7 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection) assert (server != NULL); if (!ply_boot_connection_read_request (connection, - &command, &argument_1, &argument_2)) + &command, &argument)) { ply_trace ("could not read connection request"); return; @@ -450,36 +420,8 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection) ply_trace ("got update request"); if (server->update_handler != NULL) - server->update_handler (server->user_data, argument_1, argument_2, server); - free (argument_1); - free (argument_2); - free (command); - return; - } - else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_REGISTER) == 0) - { - if (!ply_write (connection->fd, - PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ACK, - strlen (PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ACK))) - ply_trace ("could not finish writing update reply: %m"); - - if (server->register_handler != NULL) - server->register_handler (server->user_data, argument_1, argument_2, server); - free (argument_1); - free (argument_2); - free (command); - return; - } - else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_UNREGISTER) == 0) - { - if (!ply_write (connection->fd, - PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ACK, - strlen (PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ACK))) - ply_trace ("could not finish writing update reply: %m"); - - if (server->unregister_handler != NULL) - server->unregister_handler (server->user_data, argument_1, server); - free (argument_1); + server->update_handler (server->user_data, argument, server); + free (argument); free (command); return; } @@ -492,9 +434,8 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection) ply_trace ("got change mode notification"); if (server->change_mode_handler != NULL) - server->change_mode_handler (server->user_data, argument_1, server); - free (argument_1); - free (argument_2); + server->change_mode_handler (server->user_data, argument, server); + free (argument); free (command); return; } @@ -503,10 +444,10 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection) long int value; char *endptr = NULL; - value = strtol (argument_1, &endptr, 10); + value = strtol (argument, &endptr, 10); if (endptr == NULL || *endptr != '\0' || value < 0 || value > 100) { - ply_error ("failed to parse percentage %s", argument_1); + ply_error ("failed to parse percentage %s", argument); value = 0; } @@ -518,8 +459,7 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection) if (server->system_update_handler != NULL) server->system_update_handler (server->user_data, value, server); - free (argument_1); - free (argument_2); + free (argument); free (command); return; } @@ -563,8 +503,7 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection) if (server->deactivate_handler != NULL) server->deactivate_handler (server->user_data, deactivate_trigger, server); - free (argument_1); - free (argument_2); + free (argument); free (command); return; } @@ -579,7 +518,7 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection) bool retain_splash; ply_trigger_t *quit_trigger; - retain_splash = (bool) argument_1[0]; + retain_splash = (bool) argument[0]; ply_trace ("got quit %srequest", retain_splash? "--retain-splash " : ""); @@ -593,8 +532,7 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection) if (server->quit_handler != NULL) server->quit_handler (server->user_data, retain_splash, quit_trigger, server); - free(argument_1); - free(argument_2); + free(argument); free(command); return; } @@ -612,7 +550,7 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection) if (server->ask_for_password_handler != NULL) server->ask_for_password_handler (server->user_data, - argument_1, + argument, answer, server); /* will reply later @@ -700,7 +638,7 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection) if (server->ask_question_handler != NULL) server->ask_question_handler (server->user_data, - argument_1, + argument, answer, server); /* will reply later @@ -712,13 +650,13 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection) { ply_trace ("got show message request"); if (server->display_message_handler != NULL) - server->display_message_handler(server->user_data, argument_1, server); + server->display_message_handler(server->user_data, argument, server); } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_HIDE_MESSAGE) == 0) { ply_trace ("got hide message request"); if (server->hide_message_handler != NULL) - server->hide_message_handler(server->user_data, argument_1, server); + server->hide_message_handler(server->user_data, argument, server); } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_KEYSTROKE) == 0) { @@ -734,7 +672,7 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection) if (server->watch_for_keystroke_handler != NULL) server->watch_for_keystroke_handler (server->user_data, - argument_1, + argument, answer, server); /* will reply later @@ -747,7 +685,7 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection) ply_trace ("got keystroke remove request"); if (server->ignore_keystroke_handler != NULL) server->ignore_keystroke_handler (server->user_data, - argument_1, + argument, server); } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_PROGRESS_PAUSE) == 0) @@ -768,7 +706,7 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection) { ply_trace ("got newroot request"); if (server->newroot_handler != NULL) - server->newroot_handler(server->user_data, argument_1, server); + server->newroot_handler(server->user_data, argument, server); } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_HAS_ACTIVE_VT) == 0) { diff --git a/src/ply-boot-server.h b/src/ply-boot-server.h index 56e50bba..b885a81f 100644 --- a/src/ply-boot-server.h +++ b/src/ply-boot-server.h @@ -32,18 +32,8 @@ typedef struct _ply_boot_server ply_boot_server_t; -typedef void (* ply_boot_server_register_handler_t) (void *user_data, - const char *operation_id, - const char *name, - ply_boot_server_t *server); - -typedef void (* ply_boot_server_unregister_handler_t) (void *user_data, - const char *operation_id, - ply_boot_server_t *server); - typedef void (* ply_boot_server_update_handler_t) (void *user_data, const char *status, - const char *operation_id, ply_boot_server_t *server); typedef void (* ply_boot_server_change_mode_handler_t) (void *user_data, @@ -114,9 +104,7 @@ typedef bool (* ply_boot_server_has_active_vt_handler_t) (void *use ply_boot_server_t *server); #ifndef PLY_HIDE_FUNCTION_DECLARATIONS -ply_boot_server_t *ply_boot_server_new (ply_boot_server_register_handler_t register_handler, - ply_boot_server_unregister_handler_t unregister_handler, - ply_boot_server_update_handler_t update_handler, +ply_boot_server_t *ply_boot_server_new (ply_boot_server_update_handler_t update_handler, ply_boot_server_change_mode_handler_t change_mode_handler, ply_boot_server_system_update_handler_t system_update_handler, ply_boot_server_ask_for_password_handler_t ask_for_password_handler, -- cgit v1.2.3