From: Ray Strode Date: Mon, 19 May 2008 22:17:42 +0000 (-0400) Subject: add stub plugin that will show details when the user presses escape X-Git-Tag: 0.1.0~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3aca1c437010bc6ea6297ee350c2018e43b61d91;p=thirdparty%2Fplymouth.git add stub plugin that will show details when the user presses escape --- diff --git a/configure.ac b/configure.ac index 6dfe974a..71c6fb1d 100644 --- a/configure.ac +++ b/configure.ac @@ -47,6 +47,7 @@ AC_OUTPUT([Makefile src/splash-plugins/Makefile src/splash-plugins/fedora-fade-in/Makefile src/splash-plugins/text/Makefile + src/splash-plugins/details/Makefile src/Makefile src/rhgb-client/Makefile src/tests/Makefile diff --git a/src/splash-plugins/details/Makefile.am b/src/splash-plugins/details/Makefile.am new file mode 100644 index 00000000..ed2b6e93 --- /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 00000000..84561412 --- /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 + */ +#include "config.h" + +#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-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 + +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: */