|
|
09aee3 |
From ae48268a110722927cc9deb2f667f6327634436c Mon Sep 17 00:00:00 2001
|
|
|
09aee3 |
From: Ray Strode <rstrode@redhat.com>
|
|
|
09aee3 |
Date: Mon, 15 Jun 2020 10:22:20 -0400
|
|
|
09aee3 |
Subject: [PATCH 1/2] Revert "throbgress: Remove the throbgress plugin"
|
|
|
09aee3 |
|
|
|
09aee3 |
This reverts commit a76638856d600496f8f69b308fbcf7d623430851.
|
|
|
09aee3 |
---
|
|
|
09aee3 |
configure.ac | 1 +
|
|
|
09aee3 |
src/plugins/splash/Makefile.am | 2 +-
|
|
|
09aee3 |
src/plugins/splash/throbgress/Makefile.am | 28 +
|
|
|
09aee3 |
src/plugins/splash/throbgress/plugin.c | 980 ++++++++++++++++++++++
|
|
|
09aee3 |
4 files changed, 1010 insertions(+), 1 deletion(-)
|
|
|
09aee3 |
create mode 100644 src/plugins/splash/throbgress/Makefile.am
|
|
|
09aee3 |
create mode 100644 src/plugins/splash/throbgress/plugin.c
|
|
|
09aee3 |
|
|
|
09aee3 |
diff --git a/configure.ac b/configure.ac
|
|
|
09aee3 |
index d34245a..970e19f 100644
|
|
|
09aee3 |
--- a/configure.ac
|
|
|
09aee3 |
+++ b/configure.ac
|
|
|
09aee3 |
@@ -280,60 +280,61 @@ plymouththemedir=$datadir/plymouth/themes
|
|
|
09aee3 |
AS_AC_EXPAND(PLYMOUTH_THEME_PATH, $plymouththemedir)
|
|
|
09aee3 |
|
|
|
09aee3 |
plymouthruntimethemedir=$plymouthruntimedir/themes
|
|
|
09aee3 |
AS_AC_EXPAND(PLYMOUTH_RUNTIME_THEME_PATH, $plymouthruntimethemedir)
|
|
|
09aee3 |
|
|
|
09aee3 |
plymouthplugindir=$libdir/plymouth/
|
|
|
09aee3 |
AS_AC_EXPAND(PLYMOUTH_PLUGIN_PATH, $plymouthplugindir)
|
|
|
09aee3 |
|
|
|
09aee3 |
plymouthpolicydir=$datadir/plymouth/
|
|
|
09aee3 |
AS_AC_EXPAND(PLYMOUTH_POLICY_DIR, $plymouthpolicydir)
|
|
|
09aee3 |
|
|
|
09aee3 |
plymouthconfdir=$sysconfdir/plymouth/
|
|
|
09aee3 |
AS_AC_EXPAND(PLYMOUTH_CONF_DIR, $plymouthconfdir)
|
|
|
09aee3 |
|
|
|
09aee3 |
AS_AC_EXPAND(PLYMOUTH_LIBDIR, $libdir)
|
|
|
09aee3 |
AS_AC_EXPAND(PLYMOUTH_LIBEXECDIR, $libexecdir)
|
|
|
09aee3 |
AS_AC_EXPAND(PLYMOUTH_DATADIR, $datadir)
|
|
|
09aee3 |
|
|
|
09aee3 |
AC_CONFIG_FILES([Makefile po/Makefile.in
|
|
|
09aee3 |
src/libply/Makefile
|
|
|
09aee3 |
src/libply-splash-core/Makefile
|
|
|
09aee3 |
src/libply-splash-graphics/Makefile
|
|
|
09aee3 |
src/ply-splash-core.pc
|
|
|
09aee3 |
src/ply-splash-graphics.pc
|
|
|
09aee3 |
src/plugins/Makefile
|
|
|
09aee3 |
src/plugins/renderers/Makefile
|
|
|
09aee3 |
src/plugins/renderers/frame-buffer/Makefile
|
|
|
09aee3 |
src/plugins/renderers/drm/Makefile
|
|
|
09aee3 |
src/plugins/renderers/x11/Makefile
|
|
|
09aee3 |
src/plugins/splash/Makefile
|
|
|
09aee3 |
+ src/plugins/splash/throbgress/Makefile
|
|
|
09aee3 |
src/plugins/splash/fade-throbber/Makefile
|
|
|
09aee3 |
src/plugins/splash/tribar/Makefile
|
|
|
09aee3 |
src/plugins/splash/text/Makefile
|
|
|
09aee3 |
src/plugins/splash/details/Makefile
|
|
|
09aee3 |
src/plugins/splash/space-flares/Makefile
|
|
|
09aee3 |
src/plugins/splash/two-step/Makefile
|
|
|
09aee3 |
src/plugins/splash/script/Makefile
|
|
|
09aee3 |
src/plugins/controls/Makefile
|
|
|
09aee3 |
src/plugins/controls/label/Makefile
|
|
|
09aee3 |
src/Makefile
|
|
|
09aee3 |
src/client/ply-boot-client.pc
|
|
|
09aee3 |
src/client/Makefile
|
|
|
09aee3 |
src/upstart-bridge/Makefile
|
|
|
09aee3 |
themes/Makefile
|
|
|
09aee3 |
themes/spinfinity/Makefile
|
|
|
09aee3 |
themes/fade-in/Makefile
|
|
|
09aee3 |
themes/tribar/Makefile
|
|
|
09aee3 |
themes/text/Makefile
|
|
|
09aee3 |
themes/details/Makefile
|
|
|
09aee3 |
themes/solar/Makefile
|
|
|
09aee3 |
themes/glow/Makefile
|
|
|
09aee3 |
themes/spinner/Makefile
|
|
|
09aee3 |
themes/script/Makefile
|
|
|
09aee3 |
themes/bgrt/Makefile
|
|
|
09aee3 |
images/Makefile
|
|
|
09aee3 |
scripts/plymouth-generate-initrd
|
|
|
09aee3 |
scripts/plymouth-populate-initrd
|
|
|
09aee3 |
scripts/plymouth-set-default-theme
|
|
|
09aee3 |
scripts/Makefile
|
|
|
09aee3 |
systemd-units/plymouth-halt.service
|
|
|
09aee3 |
diff --git a/src/plugins/splash/Makefile.am b/src/plugins/splash/Makefile.am
|
|
|
09aee3 |
index d167530..a19197b 100644
|
|
|
09aee3 |
--- a/src/plugins/splash/Makefile.am
|
|
|
09aee3 |
+++ b/src/plugins/splash/Makefile.am
|
|
|
09aee3 |
@@ -1,2 +1,2 @@
|
|
|
09aee3 |
-SUBDIRS = fade-throbber text details space-flares two-step script tribar
|
|
|
09aee3 |
+SUBDIRS = throbgress fade-throbber text details space-flares two-step script tribar
|
|
|
09aee3 |
MAINTAINERCLEANFILES = Makefile.in
|
|
|
09aee3 |
diff --git a/src/plugins/splash/throbgress/Makefile.am b/src/plugins/splash/throbgress/Makefile.am
|
|
|
09aee3 |
new file mode 100644
|
|
|
09aee3 |
index 0000000..2ac1b0c
|
|
|
09aee3 |
--- /dev/null
|
|
|
09aee3 |
+++ b/src/plugins/splash/throbgress/Makefile.am
|
|
|
09aee3 |
@@ -0,0 +1,28 @@
|
|
|
09aee3 |
+AM_CPPFLAGS = -I$(top_srcdir) \
|
|
|
09aee3 |
+ -I$(srcdir)/../../../libply \
|
|
|
09aee3 |
+ -I$(srcdir)/../../../libply-splash-core \
|
|
|
09aee3 |
+ -I$(srcdir)/../../../libply-splash-graphics \
|
|
|
09aee3 |
+ -I$(srcdir)/../../.. \
|
|
|
09aee3 |
+ -I$(srcdir)/../.. \
|
|
|
09aee3 |
+ -I$(srcdir)/.. \
|
|
|
09aee3 |
+ -I$(srcdir)
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+plugindir = $(libdir)/plymouth
|
|
|
09aee3 |
+plugin_LTLIBRARIES = throbgress.la
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+throbgress_la_CFLAGS = $(PLYMOUTH_CFLAGS) \
|
|
|
09aee3 |
+ -DPLYMOUTH_IMAGE_DIR=\"$(datadir)/plymouth/\" \
|
|
|
09aee3 |
+ -DPLYMOUTH_TIME_DIR=\"$(localstatedir)/lib/plymouth/\"\
|
|
|
09aee3 |
+ -DPLYMOUTH_LOGO_FILE=\"$(logofile)\" \
|
|
|
09aee3 |
+ -DPLYMOUTH_BACKGROUND_COLOR=$(background_color) \
|
|
|
09aee3 |
+ -DPLYMOUTH_BACKGROUND_END_COLOR=$(background_end_color) \
|
|
|
09aee3 |
+ -DPLYMOUTH_BACKGROUND_START_COLOR=$(background_start_color)
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+throbgress_la_LDFLAGS = -module -avoid-version -export-dynamic
|
|
|
09aee3 |
+throbgress_la_LIBADD = $(PLYMOUTH_LIBS) \
|
|
|
09aee3 |
+ ../../../libply/libply.la \
|
|
|
09aee3 |
+ ../../../libply-splash-core/libply-splash-core.la \
|
|
|
09aee3 |
+ ../../../libply-splash-graphics/libply-splash-graphics.la
|
|
|
09aee3 |
+throbgress_la_SOURCES = $(srcdir)/plugin.c
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+MAINTAINERCLEANFILES = Makefile.in
|
|
|
09aee3 |
diff --git a/src/plugins/splash/throbgress/plugin.c b/src/plugins/splash/throbgress/plugin.c
|
|
|
09aee3 |
new file mode 100644
|
|
|
09aee3 |
index 0000000..86be064
|
|
|
09aee3 |
--- /dev/null
|
|
|
09aee3 |
+++ b/src/plugins/splash/throbgress/plugin.c
|
|
|
09aee3 |
@@ -0,0 +1,980 @@
|
|
|
09aee3 |
+/* throbgress.c - boot splash plugin
|
|
|
09aee3 |
+ *
|
|
|
09aee3 |
+ * Copyright (C) 2007, 2008 Red Hat, Inc.
|
|
|
09aee3 |
+ *
|
|
|
09aee3 |
+ * This program is free software; you can redistribute it and/or modify
|
|
|
09aee3 |
+ * it under the terms of the GNU General Public License as published by
|
|
|
09aee3 |
+ * the Free Software Foundation; either version 2, or (at your option)
|
|
|
09aee3 |
+ * any later version.
|
|
|
09aee3 |
+ *
|
|
|
09aee3 |
+ * This program is distributed in the hope that it will be useful,
|
|
|
09aee3 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
09aee3 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
09aee3 |
+ * GNU General Public License for more details.
|
|
|
09aee3 |
+ *
|
|
|
09aee3 |
+ * You should have received a copy of the GNU General Public License
|
|
|
09aee3 |
+ * along with this program; if not, write to the Free Software
|
|
|
09aee3 |
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
09aee3 |
+ * 02111-1307, USA.
|
|
|
09aee3 |
+ *
|
|
|
09aee3 |
+ * Written by: Ray Strode <rstrode@redhat.com>
|
|
|
09aee3 |
+ * Will Woods <wwoods@redhat.com>
|
|
|
09aee3 |
+ */
|
|
|
09aee3 |
+#include "config.h"
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+#include <assert.h>
|
|
|
09aee3 |
+#include <errno.h>
|
|
|
09aee3 |
+#include <fcntl.h>
|
|
|
09aee3 |
+#include <math.h>
|
|
|
09aee3 |
+#include <signal.h>
|
|
|
09aee3 |
+#include <stdbool.h>
|
|
|
09aee3 |
+#include <stdio.h>
|
|
|
09aee3 |
+#include <stdint.h>
|
|
|
09aee3 |
+#include <stdlib.h>
|
|
|
09aee3 |
+#include <string.h>
|
|
|
09aee3 |
+#include <sys/ioctl.h>
|
|
|
09aee3 |
+#include <sys/stat.h>
|
|
|
09aee3 |
+#include <sys/time.h>
|
|
|
09aee3 |
+#include <sys/types.h>
|
|
|
09aee3 |
+#include <values.h>
|
|
|
09aee3 |
+#include <unistd.h>
|
|
|
09aee3 |
+#include <wchar.h>
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+#include "ply-boot-splash-plugin.h"
|
|
|
09aee3 |
+#include "ply-buffer.h"
|
|
|
09aee3 |
+#include "ply-entry.h"
|
|
|
09aee3 |
+#include "ply-event-loop.h"
|
|
|
09aee3 |
+#include "ply-key-file.h"
|
|
|
09aee3 |
+#include "ply-label.h"
|
|
|
09aee3 |
+#include "ply-list.h"
|
|
|
09aee3 |
+#include "ply-progress-bar.h"
|
|
|
09aee3 |
+#include "ply-logger.h"
|
|
|
09aee3 |
+#include "ply-image.h"
|
|
|
09aee3 |
+#include "ply-trigger.h"
|
|
|
09aee3 |
+#include "ply-pixel-buffer.h"
|
|
|
09aee3 |
+#include "ply-pixel-display.h"
|
|
|
09aee3 |
+#include "ply-utils.h"
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+#include "ply-throbber.h"
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+#ifndef FRAMES_PER_SECOND
|
|
|
09aee3 |
+#define FRAMES_PER_SECOND 30
|
|
|
09aee3 |
+#endif
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+#ifndef BAR_HEIGHT
|
|
|
09aee3 |
+#define BAR_HEIGHT 16
|
|
|
09aee3 |
+#endif
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+typedef enum
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ PLY_BOOT_SPLASH_DISPLAY_NORMAL,
|
|
|
09aee3 |
+ PLY_BOOT_SPLASH_DISPLAY_QUESTION_ENTRY,
|
|
|
09aee3 |
+ PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY
|
|
|
09aee3 |
+} ply_boot_splash_display_type_t;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+typedef struct
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_boot_splash_plugin_t *plugin;
|
|
|
09aee3 |
+ ply_pixel_display_t *display;
|
|
|
09aee3 |
+ ply_entry_t *entry;
|
|
|
09aee3 |
+ ply_throbber_t *throbber;
|
|
|
09aee3 |
+ ply_progress_bar_t *progress_bar;
|
|
|
09aee3 |
+ ply_label_t *label;
|
|
|
09aee3 |
+ ply_label_t *message_label;
|
|
|
09aee3 |
+ ply_rectangle_t box_area, lock_area, logo_area, bar_area;
|
|
|
09aee3 |
+} view_t;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+struct _ply_boot_splash_plugin
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_event_loop_t *loop;
|
|
|
09aee3 |
+ ply_boot_splash_mode_t mode;
|
|
|
09aee3 |
+ ply_image_t *logo_image;
|
|
|
09aee3 |
+ ply_image_t *lock_image;
|
|
|
09aee3 |
+ ply_image_t *box_image;
|
|
|
09aee3 |
+ ply_list_t *views;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ char *image_dir;
|
|
|
09aee3 |
+ ply_boot_splash_display_type_t state;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ uint32_t background_start_color;
|
|
|
09aee3 |
+ uint32_t background_end_color;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_trigger_t *idle_trigger;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ uint32_t root_is_mounted : 1;
|
|
|
09aee3 |
+ uint32_t is_visible : 1;
|
|
|
09aee3 |
+ uint32_t is_animating : 1;
|
|
|
09aee3 |
+ uint32_t is_idle : 1;
|
|
|
09aee3 |
+};
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ply_boot_splash_plugin_interface_t *ply_boot_splash_plugin_get_interface (void);
|
|
|
09aee3 |
+static void detach_from_event_loop (ply_boot_splash_plugin_t *plugin);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void become_idle (ply_boot_splash_plugin_t *plugin,
|
|
|
09aee3 |
+ ply_trigger_t *idle_trigger);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static view_t *
|
|
|
09aee3 |
+view_new (ply_boot_splash_plugin_t *plugin,
|
|
|
09aee3 |
+ ply_pixel_display_t *display)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ view_t *view;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view = calloc (1, sizeof(view_t));
|
|
|
09aee3 |
+ view->plugin = plugin;
|
|
|
09aee3 |
+ view->display = display;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view->entry = ply_entry_new (plugin->image_dir);
|
|
|
09aee3 |
+ view->throbber = ply_throbber_new (plugin->image_dir,
|
|
|
09aee3 |
+ "throbber-");
|
|
|
09aee3 |
+ view->progress_bar = ply_progress_bar_new ();
|
|
|
09aee3 |
+ view->label = ply_label_new ();
|
|
|
09aee3 |
+ view->message_label = ply_label_new ();
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ return view;
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+view_free (view_t *view)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_entry_free (view->entry);
|
|
|
09aee3 |
+ ply_throbber_free (view->throbber);
|
|
|
09aee3 |
+ ply_progress_bar_free (view->progress_bar);
|
|
|
09aee3 |
+ ply_label_free (view->label);
|
|
|
09aee3 |
+ ply_label_free (view->message_label);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ free (view);
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+free_views (ply_boot_splash_plugin_t *plugin)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_list_node_t *node;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = ply_list_get_first_node (plugin->views);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ while (node != NULL) {
|
|
|
09aee3 |
+ ply_list_node_t *next_node;
|
|
|
09aee3 |
+ view_t *view;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view = ply_list_node_get_data (node);
|
|
|
09aee3 |
+ next_node = ply_list_get_next_node (plugin->views, node);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view_free (view);
|
|
|
09aee3 |
+ ply_list_remove_node (plugin->views, node);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = next_node;
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_list_free (plugin->views);
|
|
|
09aee3 |
+ plugin->views = NULL;
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static bool
|
|
|
09aee3 |
+view_load (view_t *view)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_trace ("loading entry");
|
|
|
09aee3 |
+ if (!ply_entry_load (view->entry))
|
|
|
09aee3 |
+ return false;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_trace ("loading throbber");
|
|
|
09aee3 |
+ if (!ply_throbber_load (view->throbber))
|
|
|
09aee3 |
+ return false;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ return true;
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static bool
|
|
|
09aee3 |
+load_views (ply_boot_splash_plugin_t *plugin)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_list_node_t *node;
|
|
|
09aee3 |
+ bool view_loaded;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view_loaded = false;
|
|
|
09aee3 |
+ node = ply_list_get_first_node (plugin->views);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ while (node != NULL) {
|
|
|
09aee3 |
+ ply_list_node_t *next_node;
|
|
|
09aee3 |
+ view_t *view;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view = ply_list_node_get_data (node);
|
|
|
09aee3 |
+ next_node = ply_list_get_next_node (plugin->views, node);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ if (view_load (view))
|
|
|
09aee3 |
+ view_loaded = true;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = next_node;
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ return view_loaded;
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+view_redraw (view_t *view)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ unsigned long screen_width, screen_height;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ screen_width = ply_pixel_display_get_width (view->display);
|
|
|
09aee3 |
+ screen_height = ply_pixel_display_get_height (view->display);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_pixel_display_draw_area (view->display, 0, 0,
|
|
|
09aee3 |
+ screen_width, screen_height);
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+redraw_views (ply_boot_splash_plugin_t *plugin)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_list_node_t *node;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = ply_list_get_first_node (plugin->views);
|
|
|
09aee3 |
+ while (node != NULL) {
|
|
|
09aee3 |
+ ply_list_node_t *next_node;
|
|
|
09aee3 |
+ view_t *view;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view = ply_list_node_get_data (node);
|
|
|
09aee3 |
+ next_node = ply_list_get_next_node (plugin->views, node);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view_redraw (view);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = next_node;
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+pause_views (ply_boot_splash_plugin_t *plugin)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_list_node_t *node;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_trace ("pausing views");
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = ply_list_get_first_node (plugin->views);
|
|
|
09aee3 |
+ while (node != NULL) {
|
|
|
09aee3 |
+ ply_list_node_t *next_node;
|
|
|
09aee3 |
+ view_t *view;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view = ply_list_node_get_data (node);
|
|
|
09aee3 |
+ next_node = ply_list_get_next_node (plugin->views, node);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_pixel_display_pause_updates (view->display);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = next_node;
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+unpause_views (ply_boot_splash_plugin_t *plugin)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_list_node_t *node;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_trace ("unpausing views");
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = ply_list_get_first_node (plugin->views);
|
|
|
09aee3 |
+ while (node != NULL) {
|
|
|
09aee3 |
+ ply_list_node_t *next_node;
|
|
|
09aee3 |
+ view_t *view;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view = ply_list_node_get_data (node);
|
|
|
09aee3 |
+ next_node = ply_list_get_next_node (plugin->views, node);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_pixel_display_unpause_updates (view->display);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = next_node;
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+view_start_animation (view_t *view)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_boot_splash_plugin_t *plugin;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ unsigned long screen_width, screen_height;
|
|
|
09aee3 |
+ long width, height;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ assert (view != NULL);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ plugin = view->plugin;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ assert (plugin != NULL);
|
|
|
09aee3 |
+ assert (plugin->loop != NULL);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ screen_width = ply_pixel_display_get_width (view->display);
|
|
|
09aee3 |
+ screen_height = ply_pixel_display_get_height (view->display);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_pixel_display_draw_area (view->display, 0, 0,
|
|
|
09aee3 |
+ screen_width, screen_height);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ if (plugin->mode == PLY_BOOT_SPLASH_MODE_SHUTDOWN ||
|
|
|
09aee3 |
+ plugin->mode == PLY_BOOT_SPLASH_MODE_REBOOT)
|
|
|
09aee3 |
+ return;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ plugin->is_idle = false;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ width = ply_throbber_get_width (view->throbber);
|
|
|
09aee3 |
+ height = ply_throbber_get_height (view->throbber);
|
|
|
09aee3 |
+ ply_throbber_start (view->throbber,
|
|
|
09aee3 |
+ plugin->loop,
|
|
|
09aee3 |
+ view->display,
|
|
|
09aee3 |
+ screen_width / 2.0 - width / 2.0,
|
|
|
09aee3 |
+ view->logo_area.y + view->logo_area.height + height / 2);
|
|
|
09aee3 |
+ ply_progress_bar_show (view->progress_bar,
|
|
|
09aee3 |
+ view->display,
|
|
|
09aee3 |
+ 0,
|
|
|
09aee3 |
+ screen_height - BAR_HEIGHT,
|
|
|
09aee3 |
+ screen_width,
|
|
|
09aee3 |
+ BAR_HEIGHT);
|
|
|
09aee3 |
+ view_redraw (view);
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+view_show_prompt (view_t *view,
|
|
|
09aee3 |
+ const char *prompt)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_boot_splash_plugin_t *plugin;
|
|
|
09aee3 |
+ int x, y;
|
|
|
09aee3 |
+ int entry_width, entry_height;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ assert (view != NULL);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ plugin = view->plugin;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ if (ply_entry_is_hidden (view->entry)) {
|
|
|
09aee3 |
+ unsigned long screen_width, screen_height;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ screen_width = ply_pixel_display_get_width (view->display);
|
|
|
09aee3 |
+ screen_height = ply_pixel_display_get_height (view->display);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view->box_area.width = ply_image_get_width (plugin->box_image);
|
|
|
09aee3 |
+ view->box_area.height = ply_image_get_height (plugin->box_image);
|
|
|
09aee3 |
+ view->box_area.x = screen_width / 2.0 - view->box_area.width / 2.0;
|
|
|
09aee3 |
+ view->box_area.y = screen_height / 2.0 - view->box_area.height / 2.0;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view->lock_area.width = ply_image_get_width (plugin->lock_image);
|
|
|
09aee3 |
+ view->lock_area.height = ply_image_get_height (plugin->lock_image);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ entry_width = ply_entry_get_width (view->entry);
|
|
|
09aee3 |
+ entry_height = ply_entry_get_height (view->entry);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ x = screen_width / 2.0 - (view->lock_area.width + entry_width) / 2.0 + view->lock_area.width;
|
|
|
09aee3 |
+ y = screen_height / 2.0 - entry_height / 2.0;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view->lock_area.x = screen_width / 2.0 - (view->lock_area.width + entry_width) / 2.0;
|
|
|
09aee3 |
+ view->lock_area.y = screen_height / 2.0 - view->lock_area.height / 2.0;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_entry_show (view->entry, plugin->loop, view->display, x, y);
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ if (prompt != NULL) {
|
|
|
09aee3 |
+ ply_label_set_text (view->label, prompt);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ x = view->box_area.x + view->lock_area.width / 2;
|
|
|
09aee3 |
+ y = view->box_area.y + view->box_area.height;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_label_show (view->label, view->display, x, y);
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+view_hide_prompt (view_t *view)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ assert (view != NULL);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_entry_hide (view->entry);
|
|
|
09aee3 |
+ ply_label_hide (view->label);
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static ply_boot_splash_plugin_t *
|
|
|
09aee3 |
+create_plugin (ply_key_file_t *key_file)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_boot_splash_plugin_t *plugin;
|
|
|
09aee3 |
+ char *image_dir, *image_path;
|
|
|
09aee3 |
+ char *color;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ srand ((int) ply_get_timestamp ());
|
|
|
09aee3 |
+ plugin = calloc (1, sizeof(ply_boot_splash_plugin_t));
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ plugin->logo_image = ply_image_new (PLYMOUTH_LOGO_FILE);
|
|
|
09aee3 |
+ image_dir = ply_key_file_get_value (key_file, "throbgress", "ImageDir");
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ asprintf (&image_path, "%s/lock.png", image_dir);
|
|
|
09aee3 |
+ plugin->lock_image = ply_image_new (image_path);
|
|
|
09aee3 |
+ free (image_path);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ asprintf (&image_path, "%s/box.png", image_dir);
|
|
|
09aee3 |
+ plugin->box_image = ply_image_new (image_path);
|
|
|
09aee3 |
+ free (image_path);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ plugin->image_dir = image_dir;
|
|
|
09aee3 |
+ plugin->views = ply_list_new ();
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ color = ply_key_file_get_value (key_file, "throbgress", "BackgroundStartColor");
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ if (color != NULL)
|
|
|
09aee3 |
+ plugin->background_start_color = strtol (color, NULL, 0);
|
|
|
09aee3 |
+ else
|
|
|
09aee3 |
+ plugin->background_start_color = PLYMOUTH_BACKGROUND_START_COLOR;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ free (color);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ color = ply_key_file_get_value (key_file, "throbgress", "BackgroundEndColor");
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ if (color != NULL)
|
|
|
09aee3 |
+ plugin->background_end_color = strtol (color, NULL, 0);
|
|
|
09aee3 |
+ else
|
|
|
09aee3 |
+ plugin->background_end_color = PLYMOUTH_BACKGROUND_END_COLOR;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ free (color);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ return plugin;
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+destroy_plugin (ply_boot_splash_plugin_t *plugin)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ if (plugin == NULL)
|
|
|
09aee3 |
+ return;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_trace ("destroying plugin");
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ if (plugin->loop != NULL) {
|
|
|
09aee3 |
+ ply_event_loop_stop_watching_for_exit (plugin->loop, (ply_event_loop_exit_handler_t)
|
|
|
09aee3 |
+ detach_from_event_loop,
|
|
|
09aee3 |
+ plugin);
|
|
|
09aee3 |
+ detach_from_event_loop (plugin);
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_image_free (plugin->logo_image);
|
|
|
09aee3 |
+ ply_image_free (plugin->box_image);
|
|
|
09aee3 |
+ ply_image_free (plugin->lock_image);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ free_views (plugin);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ free (plugin);
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+draw_background (view_t *view,
|
|
|
09aee3 |
+ ply_pixel_buffer_t *pixel_buffer,
|
|
|
09aee3 |
+ int x,
|
|
|
09aee3 |
+ int y,
|
|
|
09aee3 |
+ int width,
|
|
|
09aee3 |
+ int height)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_boot_splash_plugin_t *plugin;
|
|
|
09aee3 |
+ ply_rectangle_t area;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ plugin = view->plugin;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ area.x = x;
|
|
|
09aee3 |
+ area.y = y;
|
|
|
09aee3 |
+ area.width = width;
|
|
|
09aee3 |
+ area.height = height;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ if (plugin->background_start_color != plugin->background_end_color)
|
|
|
09aee3 |
+ ply_pixel_buffer_fill_with_gradient (pixel_buffer, &area,
|
|
|
09aee3 |
+ plugin->background_start_color,
|
|
|
09aee3 |
+ plugin->background_end_color);
|
|
|
09aee3 |
+ else
|
|
|
09aee3 |
+ ply_pixel_buffer_fill_with_hex_color (pixel_buffer, &area,
|
|
|
09aee3 |
+ plugin->background_start_color);
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+draw_logo (view_t *view,
|
|
|
09aee3 |
+ ply_pixel_buffer_t *pixel_buffer)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_boot_splash_plugin_t *plugin;
|
|
|
09aee3 |
+ uint32_t *logo_data;
|
|
|
09aee3 |
+ unsigned long screen_width, screen_height;
|
|
|
09aee3 |
+ long width, height;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ plugin = view->plugin;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ screen_width = ply_pixel_display_get_width (view->display);
|
|
|
09aee3 |
+ screen_height = ply_pixel_display_get_height (view->display);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ width = ply_image_get_width (plugin->logo_image);
|
|
|
09aee3 |
+ height = ply_image_get_height (plugin->logo_image);
|
|
|
09aee3 |
+ logo_data = ply_image_get_data (plugin->logo_image);
|
|
|
09aee3 |
+ view->logo_area.x = (screen_width / 2) - (width / 2);
|
|
|
09aee3 |
+ view->logo_area.y = (screen_height / 2) - (height / 2);
|
|
|
09aee3 |
+ view->logo_area.width = width;
|
|
|
09aee3 |
+ view->logo_area.height = height;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_pixel_buffer_fill_with_argb32_data (pixel_buffer,
|
|
|
09aee3 |
+ &view->logo_area,
|
|
|
09aee3 |
+ logo_data);
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+start_animation (ply_boot_splash_plugin_t *plugin)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_list_node_t *node;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ if (plugin->is_animating)
|
|
|
09aee3 |
+ return;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_trace ("starting animation");
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = ply_list_get_first_node (plugin->views);
|
|
|
09aee3 |
+ while (node != NULL) {
|
|
|
09aee3 |
+ ply_list_node_t *next_node;
|
|
|
09aee3 |
+ view_t *view;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view = ply_list_node_get_data (node);
|
|
|
09aee3 |
+ next_node = ply_list_get_next_node (plugin->views, node);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view_start_animation (view);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = next_node;
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ plugin->is_animating = true;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ if (plugin->mode == PLY_BOOT_SPLASH_MODE_SHUTDOWN ||
|
|
|
09aee3 |
+ plugin->mode == PLY_BOOT_SPLASH_MODE_REBOOT)
|
|
|
09aee3 |
+ plugin->is_idle = true;
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+stop_animation (ply_boot_splash_plugin_t *plugin,
|
|
|
09aee3 |
+ ply_trigger_t *trigger)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_list_node_t *node;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ assert (plugin != NULL);
|
|
|
09aee3 |
+ assert (plugin->loop != NULL);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ if (!plugin->is_animating)
|
|
|
09aee3 |
+ return;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_trace ("stopping animation%s",
|
|
|
09aee3 |
+ trigger != NULL ? " with trigger" : "");
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ plugin->is_animating = false;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = ply_list_get_first_node (plugin->views);
|
|
|
09aee3 |
+ while (node != NULL) {
|
|
|
09aee3 |
+ ply_list_node_t *next_node;
|
|
|
09aee3 |
+ view_t *view;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view = ply_list_node_get_data (node);
|
|
|
09aee3 |
+ next_node = ply_list_get_next_node (plugin->views, node);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_progress_bar_hide (view->progress_bar);
|
|
|
09aee3 |
+ if (trigger != NULL)
|
|
|
09aee3 |
+ ply_trigger_ignore_next_pull (trigger);
|
|
|
09aee3 |
+ ply_throbber_stop (view->throbber, trigger);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = next_node;
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ if (trigger != NULL)
|
|
|
09aee3 |
+ ply_trigger_pull (trigger, NULL);
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+detach_from_event_loop (ply_boot_splash_plugin_t *plugin)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ plugin->loop = NULL;
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+on_draw (view_t *view,
|
|
|
09aee3 |
+ ply_pixel_buffer_t *pixel_buffer,
|
|
|
09aee3 |
+ int x,
|
|
|
09aee3 |
+ int y,
|
|
|
09aee3 |
+ int width,
|
|
|
09aee3 |
+ int height)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_boot_splash_plugin_t *plugin;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ plugin = view->plugin;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ draw_background (view, pixel_buffer, x, y, width, height);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_QUESTION_ENTRY ||
|
|
|
09aee3 |
+ plugin->state == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY) {
|
|
|
09aee3 |
+ uint32_t *box_data, *lock_data;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ box_data = ply_image_get_data (plugin->box_image);
|
|
|
09aee3 |
+ ply_pixel_buffer_fill_with_argb32_data (pixel_buffer,
|
|
|
09aee3 |
+ &view->box_area,
|
|
|
09aee3 |
+ box_data);
|
|
|
09aee3 |
+ ply_entry_draw_area (view->entry, pixel_buffer, x, y, width, height);
|
|
|
09aee3 |
+ ply_label_draw_area (view->label, pixel_buffer, x, y, width, height);
|
|
|
09aee3 |
+ lock_data = ply_image_get_data (plugin->lock_image);
|
|
|
09aee3 |
+ ply_pixel_buffer_fill_with_argb32_data (pixel_buffer,
|
|
|
09aee3 |
+ &view->lock_area,
|
|
|
09aee3 |
+ lock_data);
|
|
|
09aee3 |
+ } else {
|
|
|
09aee3 |
+ draw_logo (view, pixel_buffer);
|
|
|
09aee3 |
+ ply_throbber_draw_area (view->throbber,
|
|
|
09aee3 |
+ pixel_buffer, x, y, width, height);
|
|
|
09aee3 |
+ ply_progress_bar_draw_area (view->progress_bar,
|
|
|
09aee3 |
+ pixel_buffer, x, y, width, height);
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+ ply_label_draw_area (view->message_label,
|
|
|
09aee3 |
+ pixel_buffer,
|
|
|
09aee3 |
+ x, y, width, height);
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+add_pixel_display (ply_boot_splash_plugin_t *plugin,
|
|
|
09aee3 |
+ ply_pixel_display_t *display)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ view_t *view;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_trace ("adding pixel display to plugin");
|
|
|
09aee3 |
+ view = view_new (plugin, display);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_pixel_display_set_draw_handler (view->display,
|
|
|
09aee3 |
+ (ply_pixel_display_draw_handler_t)
|
|
|
09aee3 |
+ on_draw, view);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ if (plugin->is_visible) {
|
|
|
09aee3 |
+ if (view_load (view))
|
|
|
09aee3 |
+ ply_list_append_data (plugin->views, view);
|
|
|
09aee3 |
+ else
|
|
|
09aee3 |
+ view_free (view);
|
|
|
09aee3 |
+ } else {
|
|
|
09aee3 |
+ ply_list_append_data (plugin->views, view);
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+remove_pixel_display (ply_boot_splash_plugin_t *plugin,
|
|
|
09aee3 |
+ ply_pixel_display_t *display)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_list_node_t *node;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_trace ("removing pixel display from plugin");
|
|
|
09aee3 |
+ node = ply_list_get_first_node (plugin->views);
|
|
|
09aee3 |
+ while (node != NULL) {
|
|
|
09aee3 |
+ view_t *view;
|
|
|
09aee3 |
+ ply_list_node_t *next_node;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view = ply_list_node_get_data (node);
|
|
|
09aee3 |
+ next_node = ply_list_get_next_node (plugin->views, node);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ if (view->display == display) {
|
|
|
09aee3 |
+ ply_pixel_display_set_draw_handler (view->display, NULL, NULL);
|
|
|
09aee3 |
+ view_free (view);
|
|
|
09aee3 |
+ ply_list_remove_node (plugin->views, node);
|
|
|
09aee3 |
+ return;
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = next_node;
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static bool
|
|
|
09aee3 |
+show_splash_screen (ply_boot_splash_plugin_t *plugin,
|
|
|
09aee3 |
+ ply_event_loop_t *loop,
|
|
|
09aee3 |
+ ply_buffer_t *boot_buffer,
|
|
|
09aee3 |
+ ply_boot_splash_mode_t mode)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ assert (plugin != NULL);
|
|
|
09aee3 |
+ assert (plugin->logo_image != NULL);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ plugin->loop = loop;
|
|
|
09aee3 |
+ plugin->mode = mode;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_trace ("loading logo image");
|
|
|
09aee3 |
+ if (!ply_image_load (plugin->logo_image))
|
|
|
09aee3 |
+ return false;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_trace ("loading lock image");
|
|
|
09aee3 |
+ if (!ply_image_load (plugin->lock_image))
|
|
|
09aee3 |
+ return false;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_trace ("loading box image");
|
|
|
09aee3 |
+ if (!ply_image_load (plugin->box_image))
|
|
|
09aee3 |
+ return false;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ if (!load_views (plugin)) {
|
|
|
09aee3 |
+ ply_trace ("couldn't load views");
|
|
|
09aee3 |
+ return false;
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t)
|
|
|
09aee3 |
+ detach_from_event_loop,
|
|
|
09aee3 |
+ plugin);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_trace ("starting boot animation");
|
|
|
09aee3 |
+ start_animation (plugin);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ plugin->is_visible = true;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ return true;
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+update_status (ply_boot_splash_plugin_t *plugin,
|
|
|
09aee3 |
+ const char *status)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ assert (plugin != NULL);
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+on_boot_progress (ply_boot_splash_plugin_t *plugin,
|
|
|
09aee3 |
+ double duration,
|
|
|
09aee3 |
+ double percent_done)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_list_node_t *node;
|
|
|
09aee3 |
+ double total_duration;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ if (plugin->mode == PLY_BOOT_SPLASH_MODE_UPDATES ||
|
|
|
09aee3 |
+ plugin->mode == PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE ||
|
|
|
09aee3 |
+ plugin->mode == PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE)
|
|
|
09aee3 |
+ return;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ total_duration = duration / percent_done;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ /* Fun made-up smoothing function to make the growth asymptotic:
|
|
|
09aee3 |
+ * fraction(time,estimate)=1-2^(-(time^1.45)/estimate) */
|
|
|
09aee3 |
+ percent_done = 1.0 - pow (2.0, -pow (duration, 1.45) / total_duration) * (1.0 - percent_done);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = ply_list_get_first_node (plugin->views);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ while (node != NULL) {
|
|
|
09aee3 |
+ ply_list_node_t *next_node;
|
|
|
09aee3 |
+ view_t *view;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view = ply_list_node_get_data (node);
|
|
|
09aee3 |
+ next_node = ply_list_get_next_node (plugin->views, node);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_progress_bar_set_percent_done (view->progress_bar, percent_done);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = next_node;
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+hide_splash_screen (ply_boot_splash_plugin_t *plugin,
|
|
|
09aee3 |
+ ply_event_loop_t *loop)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ assert (plugin != NULL);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_trace ("hiding splash");
|
|
|
09aee3 |
+ if (plugin->loop != NULL) {
|
|
|
09aee3 |
+ stop_animation (plugin, NULL);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_event_loop_stop_watching_for_exit (plugin->loop, (ply_event_loop_exit_handler_t)
|
|
|
09aee3 |
+ detach_from_event_loop,
|
|
|
09aee3 |
+ plugin);
|
|
|
09aee3 |
+ detach_from_event_loop (plugin);
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ plugin->is_visible = false;
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+show_password_prompt (ply_boot_splash_plugin_t *plugin,
|
|
|
09aee3 |
+ const char *text,
|
|
|
09aee3 |
+ int number_of_bullets)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_list_node_t *node;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_trace ("showing password prompt");
|
|
|
09aee3 |
+ node = ply_list_get_first_node (plugin->views);
|
|
|
09aee3 |
+ while (node != NULL) {
|
|
|
09aee3 |
+ ply_list_node_t *next_node;
|
|
|
09aee3 |
+ view_t *view;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view = ply_list_node_get_data (node);
|
|
|
09aee3 |
+ next_node = ply_list_get_next_node (plugin->views, node);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view_show_prompt (view, text);
|
|
|
09aee3 |
+ ply_entry_set_bullet_count (view->entry, number_of_bullets);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = next_node;
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+show_prompt (ply_boot_splash_plugin_t *plugin,
|
|
|
09aee3 |
+ const char *prompt,
|
|
|
09aee3 |
+ const char *entry_text)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_list_node_t *node;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_trace ("showing prompt");
|
|
|
09aee3 |
+ node = ply_list_get_first_node (plugin->views);
|
|
|
09aee3 |
+ while (node != NULL) {
|
|
|
09aee3 |
+ ply_list_node_t *next_node;
|
|
|
09aee3 |
+ view_t *view;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view = ply_list_node_get_data (node);
|
|
|
09aee3 |
+ next_node = ply_list_get_next_node (plugin->views, node);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view_show_prompt (view, prompt);
|
|
|
09aee3 |
+ ply_entry_set_text (view->entry, entry_text);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = next_node;
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+on_root_mounted (ply_boot_splash_plugin_t *plugin)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_trace ("root filesystem mounted");
|
|
|
09aee3 |
+ plugin->root_is_mounted = true;
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+become_idle (ply_boot_splash_plugin_t *plugin,
|
|
|
09aee3 |
+ ply_trigger_t *idle_trigger)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_trace ("deactivation requested");
|
|
|
09aee3 |
+ if (plugin->is_idle) {
|
|
|
09aee3 |
+ ply_trace ("plugin is already idle");
|
|
|
09aee3 |
+ ply_trigger_pull (idle_trigger, NULL);
|
|
|
09aee3 |
+ return;
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ stop_animation (plugin, idle_trigger);
|
|
|
09aee3 |
+ plugin->is_idle = true;
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+hide_prompt (ply_boot_splash_plugin_t *plugin)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_list_node_t *node;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_trace ("hiding prompt");
|
|
|
09aee3 |
+ node = ply_list_get_first_node (plugin->views);
|
|
|
09aee3 |
+ while (node != NULL) {
|
|
|
09aee3 |
+ ply_list_node_t *next_node;
|
|
|
09aee3 |
+ view_t *view;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view = ply_list_node_get_data (node);
|
|
|
09aee3 |
+ next_node = ply_list_get_next_node (plugin->views, node);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view_hide_prompt (view);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = next_node;
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+show_message (ply_boot_splash_plugin_t *plugin,
|
|
|
09aee3 |
+ const char *message)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_trace ("Showing message '%s'", message);
|
|
|
09aee3 |
+ ply_list_node_t *node;
|
|
|
09aee3 |
+ node = ply_list_get_first_node (plugin->views);
|
|
|
09aee3 |
+ while (node != NULL) {
|
|
|
09aee3 |
+ ply_list_node_t *next_node;
|
|
|
09aee3 |
+ view_t *view;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view = ply_list_node_get_data (node);
|
|
|
09aee3 |
+ next_node = ply_list_get_next_node (plugin->views, node);
|
|
|
09aee3 |
+ ply_label_set_text (view->message_label, message);
|
|
|
09aee3 |
+ ply_label_show (view->message_label, view->display, 10, 10);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ ply_pixel_display_draw_area (view->display, 10, 10,
|
|
|
09aee3 |
+ ply_label_get_width (view->message_label),
|
|
|
09aee3 |
+ ply_label_get_height (view->message_label));
|
|
|
09aee3 |
+ node = next_node;
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+display_normal (ply_boot_splash_plugin_t *plugin)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ pause_views (plugin);
|
|
|
09aee3 |
+ if (plugin->state != PLY_BOOT_SPLASH_DISPLAY_NORMAL)
|
|
|
09aee3 |
+ hide_prompt (plugin);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ plugin->state = PLY_BOOT_SPLASH_DISPLAY_NORMAL;
|
|
|
09aee3 |
+ start_animation (plugin);
|
|
|
09aee3 |
+ redraw_views (plugin);
|
|
|
09aee3 |
+ unpause_views (plugin);
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+display_password (ply_boot_splash_plugin_t *plugin,
|
|
|
09aee3 |
+ const char *prompt,
|
|
|
09aee3 |
+ int bullets)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ pause_views (plugin);
|
|
|
09aee3 |
+ if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
|
|
|
09aee3 |
+ stop_animation (plugin, NULL);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ plugin->state = PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY;
|
|
|
09aee3 |
+ show_password_prompt (plugin, prompt, bullets);
|
|
|
09aee3 |
+ redraw_views (plugin);
|
|
|
09aee3 |
+ unpause_views (plugin);
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+display_question (ply_boot_splash_plugin_t *plugin,
|
|
|
09aee3 |
+ const char *prompt,
|
|
|
09aee3 |
+ const char *entry_text)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ pause_views (plugin);
|
|
|
09aee3 |
+ if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
|
|
|
09aee3 |
+ stop_animation (plugin, NULL);
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ plugin->state = PLY_BOOT_SPLASH_DISPLAY_QUESTION_ENTRY;
|
|
|
09aee3 |
+ show_prompt (plugin, prompt, entry_text);
|
|
|
09aee3 |
+ redraw_views (plugin);
|
|
|
09aee3 |
+ unpause_views (plugin);
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+display_message (ply_boot_splash_plugin_t *plugin,
|
|
|
09aee3 |
+ const char *message)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ show_message (plugin, message);
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+static void
|
|
|
09aee3 |
+system_update (ply_boot_splash_plugin_t *plugin,
|
|
|
09aee3 |
+ int progress)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ ply_list_node_t *node;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ if (plugin->mode != PLY_BOOT_SPLASH_MODE_UPDATES &&
|
|
|
09aee3 |
+ plugin->mode != PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE &&
|
|
|
09aee3 |
+ plugin->mode != PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE)
|
|
|
09aee3 |
+ return;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ node = ply_list_get_first_node (plugin->views);
|
|
|
09aee3 |
+ while (node != NULL) {
|
|
|
09aee3 |
+ ply_list_node_t *next_node;
|
|
|
09aee3 |
+ view_t *view;
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ view = ply_list_node_get_data (node);
|
|
|
09aee3 |
+ next_node = ply_list_get_next_node (plugin->views, node);
|
|
|
09aee3 |
+ ply_progress_bar_set_percent_done (view->progress_bar, (double) progress / 100.f);
|
|
|
09aee3 |
+ node = next_node;
|
|
|
09aee3 |
+ }
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ply_boot_splash_plugin_interface_t *
|
|
|
09aee3 |
+ply_boot_splash_plugin_get_interface (void)
|
|
|
09aee3 |
+{
|
|
|
09aee3 |
+ static ply_boot_splash_plugin_interface_t plugin_interface =
|
|
|
09aee3 |
+ {
|
|
|
09aee3 |
+ .create_plugin = create_plugin,
|
|
|
09aee3 |
+ .destroy_plugin = destroy_plugin,
|
|
|
09aee3 |
+ .add_pixel_display = add_pixel_display,
|
|
|
09aee3 |
+ .remove_pixel_display = remove_pixel_display,
|
|
|
09aee3 |
+ .show_splash_screen = show_splash_screen,
|
|
|
09aee3 |
+ .update_status = update_status,
|
|
|
09aee3 |
+ .on_boot_progress = on_boot_progress,
|
|
|
09aee3 |
+ .hide_splash_screen = hide_splash_screen,
|
|
|
09aee3 |
+ .on_root_mounted = on_root_mounted,
|
|
|
09aee3 |
+ .become_idle = become_idle,
|
|
|
09aee3 |
+ .display_normal = display_normal,
|
|
|
09aee3 |
+ .display_password = display_password,
|
|
|
09aee3 |
+ .display_question = display_question,
|
|
|
09aee3 |
+ .display_message = display_message,
|
|
|
09aee3 |
+ .system_update = system_update,
|
|
|
09aee3 |
+ };
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+ return &plugin_interface;
|
|
|
09aee3 |
+}
|
|
|
09aee3 |
+
|
|
|
09aee3 |
+/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
|
|
|
09aee3 |
--
|
|
|
09aee3 |
2.21.0
|
|
|
09aee3 |
|