예제 #1
0
파일: plymouth.c 프로젝트: pkt/pkt-plymouth
static void
on_progress_unpause_request (state_t    *state,
                             const char *command)
{
  ply_boot_client_tell_daemon_to_progress_unpause (state->client,
                                                  (ply_boot_client_response_handler_t)
                                                  on_success,
                                                  (ply_boot_client_response_handler_t)
                                                  on_failure, state);
}
예제 #2
0
파일: plymouth.c 프로젝트: pkt/pkt-plymouth
static void
on_question_answer (question_answer_state_t   *answer_state,
                   const char                 *answer,
                   ply_boot_client_t          *client)
{
  if (answer != NULL)
    {
      if (answer_state->command != NULL)
        {
          answer_via_command (answer_state->command, answer, NULL);
        }
      else
        {
          write (STDOUT_FILENO, answer, strlen (answer));
        }
      if (answer_state->pause)
        ply_boot_client_tell_daemon_to_progress_unpause (client,
                                                         (ply_boot_client_response_handler_t)
                                                         on_success,
                                                         (ply_boot_client_response_handler_t)
                                                         on_failure,
                                                         answer_state->state);
      else
        ply_event_loop_exit (answer_state->state->loop, 0);
    }
  else
    {
      if (answer_state->pause)
        ply_boot_client_tell_daemon_to_progress_unpause (client,
                                                         (ply_boot_client_response_handler_t)
                                                         on_failure,
                                                         (ply_boot_client_response_handler_t)
                                                         on_failure,
                                                         answer_state->state);
      else
        ply_event_loop_exit (answer_state->state->loop, 1);
    }
}
예제 #3
0
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));
}
예제 #4
0
파일: plymouth.c 프로젝트: pkt/pkt-plymouth
static void
on_password_answer (password_answer_state_t   *answer_state,
                    const char                *answer,
                    ply_boot_client_t         *client)
{
  int exit_status;

  exit_status = 127;
  if (answer != NULL && answer[0] != KEY_CTRL_C)  /* a CTRL-C answer means the user canceled */
    {
      if (answer_state->command != NULL)
        {
          bool command_started = false;

          command_started = answer_via_command (answer_state->command, answer,
                                                &exit_status);

          if (command_started && (!WIFEXITED (exit_status) ||
              WEXITSTATUS (exit_status) != 0))
            {
              answer_state->number_of_tries_left--;

              if (answer_state->number_of_tries_left > 0)
                {
                  ply_boot_client_ask_daemon_for_password (answer_state->state->client,
                                                           answer_state->prompt,
                                                           (ply_boot_client_answer_handler_t)
                                                           on_password_answer,
                                                           (ply_boot_client_response_handler_t)
                                                           on_password_answer_failure,
                                                           answer_state);
                  return;
                }
            }
        }
      else
        {
          write (STDOUT_FILENO, answer, strlen (answer));
          exit_status = 0;
        }
    }
  else if (answer == NULL)
    {
      on_password_answer_failure (answer_state, answer_state->state->client);
    }

  if (WIFSIGNALED (exit_status))
    raise (WTERMSIG (exit_status));
  
  if (answer_state->pause)
    {
      ply_boot_client_tell_daemon_to_progress_unpause (client,
                                                       (ply_boot_client_response_handler_t)
                                                       (WEXITSTATUS (exit_status) ? on_failure : on_success),
                                                       (ply_boot_client_response_handler_t)
                                                       on_failure,
                                                       answer_state->state);
    }
  else
    ply_event_loop_exit (answer_state->state->loop, WEXITSTATUS (exit_status));
}