]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
add stub plugin that will show details when the user presses escape
authorRay Strode <rstrode@redhat.com>
Mon, 19 May 2008 22:17:42 +0000 (18:17 -0400)
committerRay Strode <rstrode@redhat.com>
Mon, 19 May 2008 22:17:42 +0000 (18:17 -0400)
configure.ac
src/splash-plugins/details/Makefile.am [new file with mode: 0644]
src/splash-plugins/details/details.c [new file with mode: 0644]

index 6dfe974a0fd46ba95ad1d0dd9af1ec7e854b70fa..71c6fb1d6429bb58f2732724d29bd23dba9fae5a 100644 (file)
@@ -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 (file)
index 0000000..ed2b6e9
--- /dev/null
@@ -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 (file)
index 0000000..8456141
--- /dev/null
@@ -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: */