lib_LTLIBRARIES = libplybootsplash.la
libplybootsplashdir = $(includedir)/plymouth-1/plybootsplash
-libplybootsplash_HEADERS = ply-answer.h ply-entry.h ply-progress-bar.h ply-text-pulser.h ply-throbber.h ply-window.h ply-label.h ply-boot-splash-plugin.h ply-label-plugin.h
+libplybootsplash_HEADERS = ply-entry.h ply-progress-bar.h ply-text-pulser.h ply-throbber.h ply-window.h ply-label.h ply-boot-splash-plugin.h ply-label-plugin.h
libplybootsplash_la_CFLAGS = $(PLYMOUTH_CFLAGS) \
-DPLYMOUTH_BACKGROUND_COLOR=$(background_color) \
-no-undefined
libplybootsplash_la_SOURCES = \
$(libplybootsplash_HEADERS) \
- ply-answer.c \
ply-entry.c \
ply-label.c \
ply-progress-bar.c \
+++ /dev/null
-/* ply-answer.h - Object that takes a string and triggers a closure
- * to use the string
- *
- * Copyright (C) 2007 Red Hat, Inc.
- *
- * 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
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- *
- * Written by: Ray Strode <rstrode@redhat.com>
- */
-#include "config.h"
-#include "ply-answer.h"
-
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "ply-logger.h"
-#include "ply-utils.h"
-
-struct _ply_answer
-{
- ply_answer_handler_t handler;
- void *user_data;
- char *string;
-};
-
-ply_answer_t *
-ply_answer_new (ply_answer_handler_t handler,
- void *user_data)
-{
- ply_answer_t *answer;
-
- answer = calloc (1, sizeof (ply_answer_t));
- answer->handler = handler;
- answer->user_data = user_data;
-
- return answer;
-}
-
-void
-ply_answer_free (ply_answer_t *answer)
-{
- if (answer == NULL)
- return;
-
- free (answer->string);
- free (answer);
-}
-
-void
-ply_answer_with_string (ply_answer_t *answer,
- const char *string)
-{
- assert (answer != NULL);
-
- answer->string = strdup (string);
-
- if (answer->handler != NULL)
- answer->handler (answer->user_data, string, answer);
-}
-
-char *
-ply_answer_get_string (ply_answer_t *answer)
-{
- return strdup (answer->string);
-}
-
-void
-ply_answer_unknown (ply_answer_t *answer)
-{
- assert (answer != NULL);
-
- if (answer->handler != NULL)
- answer->handler (answer->user_data, NULL, answer);
-}
-
-#ifdef PLY_ANSWER_ENABLE_TEST
-
-#include <stdio.h>
-
-#include "ply-event-loop.h"
-#include "ply-answer.h"
-
-static void
-on_timeout (ply_answer_t *answer,
- ply_event_loop_t *loop)
-{
- ply_event_loop_exit (loop, 0);
-}
-
-static void
-on_keypress (ply_answer_t *answer,
- const char *keyboard_input)
-{
- printf ("key '%c' (0x%x) was pressed\n",
- keyboard_input[0], (unsigned int) keyboard_input[0]);
-}
-
-int
-main (int argc,
- char **argv)
-{
- ply_event_loop_t *loop;
- ply_answer_t *answer;
- int exit_code;
- const char *tty_name;
-
- exit_code = 0;
-
- loop = ply_event_loop_new ();
-
- if (argc > 1)
- tty_name = argv[1];
- else
- tty_name = "/dev/tty1";
-
- answer = ply_answer_new (tty_name);
- ply_answer_attach_to_event_loop (answer, loop);
- ply_answer_set_keyboard_input_handler (answer,
- (ply_answer_keyboard_input_handler_t)
- on_keypress, answer);
-
- if (!ply_answer_open (answer))
- {
- ply_save_errno ();
- perror ("could not open answer");
- ply_restore_errno ();
- return errno;
- }
-
- if (!ply_answer_set_mode (answer, PLY_ANSWER_MODE_TEXT))
- {
- ply_save_errno ();
- perror ("could not set answer for graphics mode");
- ply_restore_errno ();
- }
-
- ply_event_loop_watch_for_timeout (loop,
- 15.0,
- (ply_event_loop_timeout_handler_t)
- on_timeout,
- answer);
- exit_code = ply_event_loop_run (loop);
-
- ply_answer_close (answer);
- ply_answer_free (answer);
-
- return exit_code;
-}
-
-#endif /* PLY_ANSWER_ENABLE_TEST */
-/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
+++ /dev/null
-/* ply-answer.h - Object that takes a string and triggers a closure
- * to use the string
- *
- * Copyright (C) 2008 Red Hat, Inc.
- *
- * 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
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- *
- * Written By: Ray Strode <rstrode@redhat.com>
- */
-#ifndef PLY_ANSWER_H
-#define PLY_ANSWER_H
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <unistd.h>
-
-#include "ply-buffer.h"
-#include "ply-event-loop.h"
-#include "ply-frame-buffer.h"
-
-typedef struct _ply_answer ply_answer_t;
-
-typedef void (* ply_answer_handler_t) (void *user_data,
- const char *string,
- ply_answer_t *answer);
-
-#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
-ply_answer_t *ply_answer_new (ply_answer_handler_t handler,
- void *user_data);
-void ply_answer_free (ply_answer_t *answer);
-
-void ply_answer_with_string (ply_answer_t *answer,
- const char *string);
-
-void ply_answer_unknown (ply_answer_t *answer);
-char *ply_answer_get_string (ply_answer_t *answer);
-#endif
-
-#endif /* PLY_ANSWER_H */
-/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
#include <stdint.h>
#include <unistd.h>
-#include "ply-answer.h"
#include "ply-buffer.h"
#include "ply-event-loop.h"
#include "ply-trigger.h"
void (* ask_for_password) (ply_boot_splash_plugin_t *plugin,
const char *prompt,
- ply_answer_t *answer);
+ ply_trigger_t *answer);
void (* become_idle) (ply_boot_splash_plugin_t *plugin,
ply_trigger_t *idle_trigger);
} ply_boot_splash_plugin_interface_t;
#include <linux/kd.h>
-#include "ply-answer.h"
#include "ply-boot-server.h"
#include "ply-boot-splash.h"
#include "ply-event-loop.h"
#include "ply-logger.h"
#include "ply-terminal-session.h"
+#include "ply-trigger.h"
#include "ply-utils.h"
#ifndef PLY_MAX_COMMAND_LINE_SIZE
static void
on_ask_for_password (state_t *state,
const char *prompt,
- ply_answer_t *answer)
+ ply_trigger_t *answer)
{
if (state->boot_splash == NULL)
{
show_detailed_splash (state);
if (state->boot_splash == NULL)
- ply_answer_with_string (answer, "");
+ ply_trigger_pull (answer, "");
return;
}
#include <wchar.h>
#include <values.h>
-#include "ply-answer.h"
#include "ply-boot-splash-plugin.h"
#include "ply-buffer.h"
#include "ply-event-loop.h"
#include "ply-logger.h"
#include "ply-frame-buffer.h"
#include "ply-image.h"
+#include "ply-trigger.h"
#include "ply-utils.h"
#include "ply-window.h"
void ask_for_password (ply_boot_splash_plugin_t *plugin,
const char *prompt,
- ply_answer_t *answer);
+ ply_trigger_t *answer);
ply_boot_splash_plugin_interface_t *ply_boot_splash_plugin_get_interface (void);
struct _ply_boot_splash_plugin
{
ply_event_loop_t *loop;
- ply_answer_t *pending_password_answer;
+ ply_trigger_t *pending_password_answer;
ply_window_t *window;
uint32_t keyboard_input_is_hidden : 1;
{
if (plugin->pending_password_answer != NULL)
{
- ply_answer_with_string (plugin->pending_password_answer, line);
+ ply_trigger_pull (plugin->pending_password_answer, line);
plugin->keyboard_input_is_hidden = false;
plugin->pending_password_answer = NULL;
write (STDOUT_FILENO, CLEAR_LINE_SEQUENCE, strlen (CLEAR_LINE_SEQUENCE));
if (plugin->pending_password_answer != NULL)
{
- ply_answer_with_string (plugin->pending_password_answer, "");
+ ply_trigger_pull (plugin->pending_password_answer, "");
plugin->pending_password_answer = NULL;
plugin->keyboard_input_is_hidden = false;
}
void
ask_for_password (ply_boot_splash_plugin_t *plugin,
const char *prompt,
- ply_answer_t *answer)
+ ply_trigger_t *answer)
{
plugin->pending_password_answer = answer;
#include <unistd.h>
#include <wchar.h>
-#include "ply-answer.h"
#include "ply-boot-splash-plugin.h"
#include "ply-buffer.h"
#include "ply-entry.h"
#include "ply-logger.h"
#include "ply-frame-buffer.h"
#include "ply-image.h"
+#include "ply-trigger.h"
#include "ply-utils.h"
#include "ply-window.h"
ply_entry_t *entry;
- ply_answer_t *pending_password_answer;
+ ply_trigger_t *pending_password_answer;
double start_time;
double now;
if (plugin->pending_password_answer == NULL)
return;
- ply_answer_with_string (plugin->pending_password_answer, text);
+ ply_trigger_pull (plugin->pending_password_answer, text);
plugin->pending_password_answer = NULL;
ply_entry_hide (plugin->entry);
if (plugin->pending_password_answer != NULL)
{
- ply_answer_with_string (plugin->pending_password_answer, "");
+ ply_trigger_pull (plugin->pending_password_answer, "");
plugin->pending_password_answer = NULL;
}
void
ask_for_password (ply_boot_splash_plugin_t *plugin,
const char *prompt,
- ply_answer_t *answer)
+ ply_trigger_t *answer)
{
plugin->pending_password_answer = answer;
#include <unistd.h>
#include <wchar.h>
-#include "ply-answer.h"
#include "ply-boot-splash-plugin.h"
#include "ply-buffer.h"
#include "ply-entry.h"
#include "ply-logger.h"
#include "ply-frame-buffer.h"
#include "ply-image.h"
+#include "ply-trigger.h"
#include "ply-utils.h"
#include "ply-window.h"
double start_time;
double wait_time;
- ply_answer_t *pending_password_answer;
+ ply_trigger_t *pending_password_answer;
ply_trigger_t *idle_trigger;
uint32_t root_is_mounted : 1;
if (plugin->pending_password_answer == NULL)
return;
- ply_answer_with_string (plugin->pending_password_answer, text);
+ ply_trigger_pull (plugin->pending_password_answer, text);
plugin->pending_password_answer = NULL;
ply_entry_hide (plugin->entry);
if (plugin->pending_password_answer != NULL)
{
- ply_answer_with_string (plugin->pending_password_answer, "");
+ ply_trigger_pull (plugin->pending_password_answer, "");
plugin->pending_password_answer = NULL;
}
void
ask_for_password (ply_boot_splash_plugin_t *plugin,
const char *prompt,
- ply_answer_t *answer)
+ ply_trigger_t *answer)
{
plugin->pending_password_answer = answer;
plugin->wait_time = ply_get_timestamp ();
#include <values.h>
#include <wchar.h>
-#include "ply-answer.h"
+#include "ply-trigger.h"
#include "ply-boot-splash-plugin.h"
#include "ply-buffer.h"
#include "ply-event-loop.h"
{
ply_event_loop_t *loop;
- ply_answer_t *pending_password_answer;
+ ply_trigger_t *pending_password_answer;
ply_window_t *window;
ply_text_pulser_t *pulser;
{
if (plugin->pending_password_answer != NULL)
{
- ply_answer_with_string (plugin->pending_password_answer, line);
+ ply_trigger_pull (plugin->pending_password_answer, line);
plugin->keyboard_input_is_hidden = false;
plugin->pending_password_answer = NULL;
if (plugin->pending_password_answer != NULL)
{
- ply_answer_with_string (plugin->pending_password_answer, "");
+ ply_trigger_pull (plugin->pending_password_answer, "");
plugin->pending_password_answer = NULL;
}
void
ask_for_password (ply_boot_splash_plugin_t *plugin,
const char *prompt,
- ply_answer_t *answer)
+ ply_trigger_t *answer)
{
int window_width, window_height;
#include <sys/types.h>
#include <unistd.h>
+#include "ply-buffer.h"
#include "ply-event-loop.h"
#include "ply-list.h"
#include "ply-logger.h"
+#include "ply-trigger.h"
#include "ply-utils.h"
typedef struct
{
ply_event_loop_t *loop;
ply_list_t *connections;
- ply_list_t *cached_answers;
+ ply_list_t *cached_passwords;
int socket_fd;
ply_boot_server_update_handler_t update_handler;
server = calloc (1, sizeof (ply_boot_server_t));
server->connections = ply_list_new ();
- server->cached_answers = ply_list_new ();
+ server->cached_passwords = ply_list_new ();
server->loop = NULL;
server->is_listening = false;
server->update_handler = update_handler;
ply_boot_connection_on_hangup (connection);
}
ply_list_free (server->connections);
- ply_list_free (server->cached_answers);
+ ply_list_free (server->cached_passwords);
free (server);
}
static void
ply_boot_connection_on_password_answer (ply_boot_connection_t *connection,
- const char *password,
- ply_answer_t *answer)
+ const char *password)
{
uint8_t size;
!ply_write (connection->fd,
password, size))
ply_error ("could not write bytes: %m");
+
+ ply_list_append_data (connection->server->cached_passwords,
+ strdup (password));
}
- ply_list_append_data (connection->server->cached_answers, answer);
}
static void
}
else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_PASSWORD) == 0)
{
- ply_answer_t *answer;
+ ply_trigger_t *answer;
- answer = ply_answer_new ((ply_answer_handler_t)
+ answer = ply_trigger_new (NULL);
+ ply_trigger_add_handler (answer,
+ (ply_trigger_handler_t)
ply_boot_connection_on_password_answer,
connection);
buffer = ply_buffer_new ();
- node = ply_list_get_first_node (server->cached_answers);
+ node = ply_list_get_first_node (server->cached_passwords);
/* Add each answer separated by their NUL terminators into
* a buffer that we write out to the client
while (node != NULL)
{
ply_list_node_t *next_node;
- ply_answer_t *answer;
- char *answer_string;
+ const char *password;
- next_node = ply_list_get_next_node (server->cached_answers, node);
- answer = ply_list_node_get_data (node);
- answer_string = ply_answer_get_string (answer);
- ply_buffer_append_bytes (buffer,
- answer_string,
- strlen (answer_string) + 1);
- free (answer_string);
+ next_node = ply_list_get_next_node (server->cached_passwords, node);
+ password = (const char *) ply_list_node_get_data (node);
+ ply_buffer_append_bytes (buffer,
+ password,
+ strlen (password) + 1);
node = next_node;
}
#include <stdint.h>
#include <unistd.h>
-#include "ply-answer.h"
+#include "ply-trigger.h"
#include "ply-boot-protocol.h"
#include "ply-event-loop.h"
ply_boot_server_t *server);
typedef void (* ply_boot_server_ask_for_password_handler_t) (void *user_data,
const char *prompt,
- ply_answer_t *answer,
+ ply_trigger_t *answer,
ply_boot_server_t *server);
typedef void (* ply_boot_server_system_initialized_handler_t) (void *user_data,
void
ply_boot_splash_ask_for_password (ply_boot_splash_t *splash,
const char *prompt,
- ply_answer_t *answer)
+ ply_trigger_t *trigger)
{
assert (splash != NULL);
if (splash->plugin_interface->ask_for_password == NULL)
{
- ply_answer_unknown (answer);
+ ply_trigger_pull (trigger, NULL);
return;
}
splash->plugin_interface->ask_for_password (splash->plugin,
prompt,
- answer);
+ trigger);
}
static void
#include <stdint.h>
#include <unistd.h>
-#include "ply-answer.h"
#include "ply-event-loop.h"
#include "ply-window.h"
#include "ply-buffer.h"
void ply_boot_splash_ask_for_password (ply_boot_splash_t *splash,
const char *prompt,
- ply_answer_t *answer);
+ ply_trigger_t *answer);
void ply_boot_splash_hide (ply_boot_splash_t *splash);
void ply_boot_splash_attach_to_event_loop (ply_boot_splash_t *splash,
ply_event_loop_t *loop);