diff options
| author | Ray Strode <rstrode@redhat.com> | 2008-05-19 18:17:42 -0400 |
|---|---|---|
| committer | Ray Strode <rstrode@redhat.com> | 2008-05-19 18:17:42 -0400 |
| commit | 3aca1c437010bc6ea6297ee350c2018e43b61d91 (patch) | |
| tree | 287658ff3ceb35055b052da6ff90a3ee0c30a2cb /src/splash-plugins/details | |
| parent | b144acddbc61f03f9c1f0a9a23ea7ea843b26408 (diff) | |
| download | plymouth-3aca1c437010bc6ea6297ee350c2018e43b61d91.tar.gz plymouth-3aca1c437010bc6ea6297ee350c2018e43b61d91.tar.xz plymouth-3aca1c437010bc6ea6297ee350c2018e43b61d91.zip | |
add stub plugin that will show details when the user presses escape
Diffstat (limited to 'src/splash-plugins/details')
| -rw-r--r-- | src/splash-plugins/details/Makefile.am | 16 | ||||
| -rw-r--r-- | src/splash-plugins/details/details.c | 189 |
2 files changed, 205 insertions, 0 deletions
diff --git a/src/splash-plugins/details/Makefile.am b/src/splash-plugins/details/Makefile.am new file mode 100644 index 0000000..ed2b6e9 --- /dev/null +++ b/src/splash-plugins/details/Makefile.am @@ -0,0 +1,16 @@ +INCLUDES = -I$(top_srcdir) \ + -I$(srcdir)/../../libply \ + -I$(srcdir)/../.. \ + -I$(srcdir)/.. \ + -I$(srcdir) + +plugindir = $(libdir)/plymouth +plugin_LTLIBRARIES = text.la + +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)/details.c + +MAINTAINERCLEANFILES = Makefile.in diff --git a/src/splash-plugins/details/details.c b/src/splash-plugins/details/details.c new file mode 100644 index 0000000..8456141 --- /dev/null +++ b/src/splash-plugins/details/details.c @@ -0,0 +1,189 @@ +/* details.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 <rstrode@redhat.com> + */ +#include "config.h" + +#include <assert.h> +#include <errno.h> +#include <fcntl.h> +#include <math.h> +#include <signal.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <sys/ioctl.h> +#include <sys/stat.h> +#include <sys/time.h> +#include <sys/types.h> +#include <termios.h> +#include <unistd.h> +#include <values.h> + +#include "ply-boot-splash-plugin.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 <linux/kd.h> + +struct _ply_boot_splash_plugin +{ + ply_event_loop_t *loop; +}; + +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)); + + return plugin; +} + +void +destroy_plugin (ply_boot_splash_plugin_t *plugin) +{ + ply_trace ("destroying plugin"); + + if (plugin == NULL) + return; + + free (plugin); +} + +bool +show_splash_screen (ply_boot_splash_plugin_t *plugin, + ply_window_t *window) +{ + assert (plugin != NULL); + + ply_trace ("show splash screen"); + + return true; +} + +void +update_status (ply_boot_splash_plugin_t *plugin, + const char *status) +{ + assert (plugin != NULL); + + ply_trace ("status update"); +} + +static void +detach_from_event_loop (ply_boot_splash_plugin_t *plugin) +{ + plugin->loop = NULL; + + ply_trace ("detaching from event loop"); +} + +void +hide_splash_screen (ply_boot_splash_plugin_t *plugin, + ply_window_t *window) +{ + assert (plugin != NULL); + + ply_trace ("hiding splash screen"); + + 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 +attach_to_event_loop (ply_boot_splash_plugin_t *plugin, + ply_event_loop_t *loop) +{ + ply_trace ("attaching to event loop"); + + plugin->loop = loop; + + ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t) + detach_from_event_loop, + plugin); +} + +char * +ask_for_password (ply_boot_splash_plugin_t *plugin) +{ + char answer[1024]; + struct termios initial_term_attributes; + struct termios noecho_term_attributes; + + tcgetattr (STDIN_FILENO, &initial_term_attributes); + noecho_term_attributes = initial_term_attributes; + noecho_term_attributes.c_lflag &= ~ECHO; + + printf ("Password: "); + + if (tcsetattr (STDIN_FILENO, TCSAFLUSH, &noecho_term_attributes) != 0) { + fprintf (stderr, "Could not set terminal attributes\n"); + return NULL; + } + + fgets (answer, sizeof (answer), stdin); + answer[strlen (answer) - 1] = '\0'; + + tcsetattr (STDIN_FILENO, TCSANOW, &initial_term_attributes); + + printf ("\n"); + + return strdup (answer); +} + +void +on_keyboard_input (ply_boot_splash_plugin_t *plugin, + const char *keyboard_input) +{ +} + +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, + .attach_to_event_loop = attach_to_event_loop, + .ask_for_password = ask_for_password, + .on_keyboard_input = on_keyboard_input + }; + + return &plugin_interface; +} + +/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */ |
