static void on_progress_pause_request (state_t *state, const char *command) { ply_boot_client_tell_daemon_to_progress_pause (state->client, (ply_boot_client_response_handler_t) on_success, (ply_boot_client_response_handler_t) on_failure, state); }
static void on_password_request (state_t *state, const char *command) { char *prompt; char *program; int number_of_tries; bool dont_pause; password_answer_state_t *password_answer_state; prompt = NULL; program = NULL; number_of_tries = 0; dont_pause = false; ply_trace ("Password request"); ply_command_parser_get_command_options (state->command_parser, command, "command", &program, "prompt", &prompt, "number-of-tries", &number_of_tries, "dont-pause-progress", &dont_pause, NULL); if (number_of_tries <= 0) number_of_tries = INT_MAX; password_answer_state = calloc (1, sizeof (password_answer_state_t)); password_answer_state->state = state; password_answer_state->command = program; password_answer_state->prompt = prompt; password_answer_state->number_of_tries_left = number_of_tries; password_answer_state->pause = !dont_pause; if (password_answer_state->pause) { ply_boot_client_tell_daemon_to_progress_pause (state->client, (ply_boot_client_response_handler_t) on_password_request_execute, (ply_boot_client_response_handler_t) on_password_answer_failure, password_answer_state); } else { on_password_request_execute (password_answer_state, state->client); } }
static void on_question_request (state_t *state, const char *command) { char *prompt; char *program; int number_of_tries; bool dont_pause; question_answer_state_t *question_answer_state; prompt = NULL; program = NULL; number_of_tries = 0; dont_pause = false; ply_command_parser_get_command_options (state->command_parser, command, "command", &program, "prompt", &prompt, "dont-pause-progress", &dont_pause, NULL); question_answer_state = calloc (1, sizeof (question_answer_state_t)); question_answer_state->state = state; question_answer_state->command = program; question_answer_state->prompt = prompt; question_answer_state->pause = !dont_pause; if (question_answer_state->pause) { ply_boot_client_tell_daemon_to_progress_pause (state->client, (ply_boot_client_response_handler_t) on_question_request_execute, (ply_boot_client_response_handler_t) on_question_answer_failure, question_answer_state); } else { on_question_request_execute (question_answer_state, state->client); } }
Plymouth::answer_t Plymouth::pause(bool do_pause){ ply_boot_client_attach_to_event_loop(_ply_client, _ply_event_loop); auto response_helper = [this] (int exit_status) -> void { ply_event_loop_exit(_ply_event_loop, exit_status); }; typedef decltype(response_helper) answer_helper_t; auto success_hdl = [] (void * data, ply_boot_client_t *) -> void{ (*reinterpret_cast<answer_helper_t*>(data))(OK); }; auto fail_hdl = [] (void *data, ply_boot_client_t*) -> void{ (*reinterpret_cast<answer_helper_t*>(data))(FAILED); }; if (do_pause){ ply_boot_client_tell_daemon_to_progress_pause(_ply_client, success_hdl, fail_hdl, &response_helper); } else { ply_boot_client_tell_daemon_to_progress_unpause(_ply_client, success_hdl, fail_hdl, &response_helper); } return static_cast<answer_t>(ply_event_loop_run(_ply_event_loop)); }