From 0b0afb569b254e757ec00540fdd2e6bdb8180896 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Wed, 28 May 2008 22:07:20 -0400 Subject: Rename all the plugins from .c -> main.c Just makes things more consistent. --- src/splash-plugins/text/Makefile.am | 2 +- src/splash-plugins/text/plugin.c | 225 ++++++++++++++++++++++++++++++++++++ src/splash-plugins/text/text.c | 225 ------------------------------------ 3 files changed, 226 insertions(+), 226 deletions(-) create mode 100644 src/splash-plugins/text/plugin.c delete mode 100644 src/splash-plugins/text/text.c (limited to 'src/splash-plugins/text') diff --git a/src/splash-plugins/text/Makefile.am b/src/splash-plugins/text/Makefile.am index 0a0552a..9daad9e 100644 --- a/src/splash-plugins/text/Makefile.am +++ b/src/splash-plugins/text/Makefile.am @@ -11,6 +11,6 @@ text_la_CFLAGS = $(PLYMOUTH_CFLAGS) text_la_LDFLAGS = -module -avoid-version -export-dynamic text_la_LIBADD = $(PLYMOUTH_LIBS) ../../libply/libply.la text_la_SOURCES = $(srcdir)/../../ply-boot-splash-plugin.h \ - $(srcdir)/text.c + $(srcdir)/plugin.c MAINTAINERCLEANFILES = Makefile.in diff --git a/src/splash-plugins/text/plugin.c b/src/splash-plugins/text/plugin.c new file mode 100644 index 0000000..bfa591a --- /dev/null +++ b/src/splash-plugins/text/plugin.c @@ -0,0 +1,225 @@ +/* text.c - boot splash plugin + * + * 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 + */ +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ply-boot-splash-plugin.h" +#include "ply-buffer.h" +#include "ply-event-loop.h" +#include "ply-list.h" +#include "ply-logger.h" +#include "ply-frame-buffer.h" +#include "ply-image.h" +#include "ply-utils.h" +#include "ply-window.h" + +#include + +#define CLEAR_LINE_SEQUENCE "\033[2K\r\n" +#define BACKSPACE "\b\033[0K" + +struct _ply_boot_splash_plugin +{ + ply_event_loop_t *loop; + + int console_fd; + ply_boot_splash_password_answer_handler_t password_answer_handler; + void *password_answer_data; + + uint32_t keyboard_input_is_hidden : 1; +}; + +ply_boot_splash_plugin_t * +create_plugin (void) +{ + ply_boot_splash_plugin_t *plugin; + + ply_trace ("creating plugin"); + + plugin = calloc (1, sizeof (ply_boot_splash_plugin_t)); + plugin->console_fd = -1; + + return plugin; +} + +void +destroy_plugin (ply_boot_splash_plugin_t *plugin) +{ + ply_trace ("destroying plugin"); + + if (plugin == NULL) + return; + + free (plugin); +} + +static bool +open_console (ply_boot_splash_plugin_t *plugin) +{ + assert (plugin != NULL); + + plugin->console_fd = open ("/dev/tty1", O_RDWR | O_APPEND | O_NOCTTY); + + if (plugin->console_fd < 0) + return false; + + return true; +} + +static void +detach_from_event_loop (ply_boot_splash_plugin_t *plugin) +{ + plugin->loop = NULL; + + ply_trace ("detaching from event loop"); +} + +bool +show_splash_screen (ply_boot_splash_plugin_t *plugin, + ply_event_loop_t *loop, + ply_window_t *window, + ply_buffer_t *boot_buffer) +{ + assert (plugin != NULL); + + plugin->loop = loop; + ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t) + detach_from_event_loop, + plugin); + + ply_trace ("opening console"); + if (!open_console (plugin)) + return false; + + return true; +} + +void +update_status (ply_boot_splash_plugin_t *plugin, + const char *status) +{ + assert (plugin != NULL); + + ply_trace ("status update"); + write (plugin->console_fd, ".", 1); +} + +void +hide_splash_screen (ply_boot_splash_plugin_t *plugin, + ply_event_loop_t *loop, + ply_window_t *window) +{ + assert (plugin != NULL); + + ply_trace ("hiding splash screen"); + + if (plugin->loop != NULL) + { + ply_event_loop_stop_watching_for_exit (plugin->loop, + (ply_event_loop_exit_handler_t) + detach_from_event_loop, + plugin); + detach_from_event_loop (plugin); + } +} + +void +ask_for_password (ply_boot_splash_plugin_t *plugin, + ply_boot_splash_password_answer_handler_t answer_handler, + void *answer_data) +{ + plugin->password_answer_handler = answer_handler; + plugin->password_answer_data = answer_data; + + write (STDOUT_FILENO, "\nPassword: ", strlen ("\nPassword: ")); + plugin->keyboard_input_is_hidden = true; +} + +void +on_keyboard_input (ply_boot_splash_plugin_t *plugin, + const char *keyboard_input, + size_t character_size) +{ + if (plugin->keyboard_input_is_hidden) + write (STDOUT_FILENO, "•", strlen ("•")); + else + write (STDOUT_FILENO, keyboard_input, character_size); +} + +void +on_backspace (ply_boot_splash_plugin_t *plugin) +{ + write (STDOUT_FILENO, BACKSPACE, strlen (BACKSPACE)); +} + +void +on_enter (ply_boot_splash_plugin_t *plugin, + const char *line) +{ + if (plugin->password_answer_handler != NULL) + { + plugin->password_answer_handler (plugin->password_answer_data, + line); + plugin->keyboard_input_is_hidden = false; + plugin->password_answer_handler = NULL; + write (STDOUT_FILENO, CLEAR_LINE_SEQUENCE, strlen (CLEAR_LINE_SEQUENCE)); + } +} + +ply_boot_splash_plugin_interface_t * +ply_boot_splash_plugin_get_interface (void) +{ + static ply_boot_splash_plugin_interface_t plugin_interface = + { + .create_plugin = create_plugin, + .destroy_plugin = destroy_plugin, + .show_splash_screen = show_splash_screen, + .update_status = update_status, + .hide_splash_screen = hide_splash_screen, + .ask_for_password = ask_for_password, + .on_keyboard_input = on_keyboard_input, + .on_backspace = on_backspace, + .on_enter = on_enter + }; + + return &plugin_interface; +} + +/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */ diff --git a/src/splash-plugins/text/text.c b/src/splash-plugins/text/text.c deleted file mode 100644 index bfa591a..0000000 --- a/src/splash-plugins/text/text.c +++ /dev/null @@ -1,225 +0,0 @@ -/* text.c - boot splash plugin - * - * 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 - */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ply-boot-splash-plugin.h" -#include "ply-buffer.h" -#include "ply-event-loop.h" -#include "ply-list.h" -#include "ply-logger.h" -#include "ply-frame-buffer.h" -#include "ply-image.h" -#include "ply-utils.h" -#include "ply-window.h" - -#include - -#define CLEAR_LINE_SEQUENCE "\033[2K\r\n" -#define BACKSPACE "\b\033[0K" - -struct _ply_boot_splash_plugin -{ - ply_event_loop_t *loop; - - int console_fd; - ply_boot_splash_password_answer_handler_t password_answer_handler; - void *password_answer_data; - - uint32_t keyboard_input_is_hidden : 1; -}; - -ply_boot_splash_plugin_t * -create_plugin (void) -{ - ply_boot_splash_plugin_t *plugin; - - ply_trace ("creating plugin"); - - plugin = calloc (1, sizeof (ply_boot_splash_plugin_t)); - plugin->console_fd = -1; - - return plugin; -} - -void -destroy_plugin (ply_boot_splash_plugin_t *plugin) -{ - ply_trace ("destroying plugin"); - - if (plugin == NULL) - return; - - free (plugin); -} - -static bool -open_console (ply_boot_splash_plugin_t *plugin) -{ - assert (plugin != NULL); - - plugin->console_fd = open ("/dev/tty1", O_RDWR | O_APPEND | O_NOCTTY); - - if (plugin->console_fd < 0) - return false; - - return true; -} - -static void -detach_from_event_loop (ply_boot_splash_plugin_t *plugin) -{ - plugin->loop = NULL; - - ply_trace ("detaching from event loop"); -} - -bool -show_splash_screen (ply_boot_splash_plugin_t *plugin, - ply_event_loop_t *loop, - ply_window_t *window, - ply_buffer_t *boot_buffer) -{ - assert (plugin != NULL); - - plugin->loop = loop; - ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t) - detach_from_event_loop, - plugin); - - ply_trace ("opening console"); - if (!open_console (plugin)) - return false; - - return true; -} - -void -update_status (ply_boot_splash_plugin_t *plugin, - const char *status) -{ - assert (plugin != NULL); - - ply_trace ("status update"); - write (plugin->console_fd, ".", 1); -} - -void -hide_splash_screen (ply_boot_splash_plugin_t *plugin, - ply_event_loop_t *loop, - ply_window_t *window) -{ - assert (plugin != NULL); - - ply_trace ("hiding splash screen"); - - if (plugin->loop != NULL) - { - ply_event_loop_stop_watching_for_exit (plugin->loop, - (ply_event_loop_exit_handler_t) - detach_from_event_loop, - plugin); - detach_from_event_loop (plugin); - } -} - -void -ask_for_password (ply_boot_splash_plugin_t *plugin, - ply_boot_splash_password_answer_handler_t answer_handler, - void *answer_data) -{ - plugin->password_answer_handler = answer_handler; - plugin->password_answer_data = answer_data; - - write (STDOUT_FILENO, "\nPassword: ", strlen ("\nPassword: ")); - plugin->keyboard_input_is_hidden = true; -} - -void -on_keyboard_input (ply_boot_splash_plugin_t *plugin, - const char *keyboard_input, - size_t character_size) -{ - if (plugin->keyboard_input_is_hidden) - write (STDOUT_FILENO, "•", strlen ("•")); - else - write (STDOUT_FILENO, keyboard_input, character_size); -} - -void -on_backspace (ply_boot_splash_plugin_t *plugin) -{ - write (STDOUT_FILENO, BACKSPACE, strlen (BACKSPACE)); -} - -void -on_enter (ply_boot_splash_plugin_t *plugin, - const char *line) -{ - if (plugin->password_answer_handler != NULL) - { - plugin->password_answer_handler (plugin->password_answer_data, - line); - plugin->keyboard_input_is_hidden = false; - plugin->password_answer_handler = NULL; - write (STDOUT_FILENO, CLEAR_LINE_SEQUENCE, strlen (CLEAR_LINE_SEQUENCE)); - } -} - -ply_boot_splash_plugin_interface_t * -ply_boot_splash_plugin_get_interface (void) -{ - static ply_boot_splash_plugin_interface_t plugin_interface = - { - .create_plugin = create_plugin, - .destroy_plugin = destroy_plugin, - .show_splash_screen = show_splash_screen, - .update_status = update_status, - .hide_splash_screen = hide_splash_screen, - .ask_for_password = ask_for_password, - .on_keyboard_input = on_keyboard_input, - .on_backspace = on_backspace, - .on_enter = on_enter - }; - - return &plugin_interface; -} - -/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */ -- cgit