mirror of
https://gitlab.freedesktop.org/plymouth/plymouth.git
synced 2026-05-07 06:08:00 +02:00
Add preliminary password support to fedora-fade-in
We should really move a lot of the duplicate code between the various splash plugins to the window code. We also need line editing support.
This commit is contained in:
parent
c8a5e1d318
commit
4335d4352e
7 changed files with 184 additions and 7 deletions
2
TODO
2
TODO
|
|
@ -3,4 +3,4 @@
|
|||
- Drop all the make ram disk and copy code. That was just to make bolting things on easier. We can integrate now.
|
||||
- allow longer than 255 byte replies from server to client
|
||||
- make server send immediate ACK for password request and then ANSWER later with a link back to original request in ANSWER
|
||||
- add ask-for-password support to fedora-fade-in and details plugins
|
||||
- buffer keyboard input from window instead of individual splash plugins
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ TMPDIR="$(mktemp -d $PWD/initrd.XXXXXXXXXX)"
|
|||
(cd $TMPDIR
|
||||
zcat $INITRD | cpio --quiet -Hnewc -i --make-directories
|
||||
sed -i -e 's@^#!\(.*\)@#!/bin/plymouthd \1\n@' init
|
||||
sed -i -e 's@setquiet@&\n/bin/plymouth --show-splash\n/bin/plymouth --ask-for-password@' init
|
||||
sed -i -e 's@setquiet@&\n/bin/plymouth --show-splash\n/bin/plymouth --ask-for-password\n@' init
|
||||
(cd $LIBDIR
|
||||
DEPS=$(get_lib_deps ${LIBEXECDIR}/plymouth/plymouth ${LIBDIR}/plymouth/fedora-fade-in.so ${LIBDIR}/plymouth/text.so ${LIBDIR}/plymouth/details.so)
|
||||
for dep in $DEPS; do
|
||||
|
|
@ -48,6 +48,9 @@ TMPDIR="$(mktemp -d $PWD/initrd.XXXXXXXXXX)"
|
|||
|
||||
install -m644 ${DATADIR}/pixmaps/fedora-logo.png ${TMPDIR}${DATADIR}/plymouth
|
||||
install -m644 ${DATADIR}/plymouth/star.png ${TMPDIR}${DATADIR}/plymouth
|
||||
install -m644 ${DATADIR}/plymouth/lock.png ${TMPDIR}${DATADIR}/plymouth
|
||||
install -m644 ${DATADIR}/plymouth/entry.png ${TMPDIR}${DATADIR}/plymouth
|
||||
install -m644 ${DATADIR}/plymouth/bullet.png ${TMPDIR}${DATADIR}/plymouth
|
||||
|
||||
mkdir -p ${TMPDIR}${LIBDIR}/plymouth
|
||||
install -m755 ${LIBDIR}/plymouth/fedora-fade-in.so ${TMPDIR}${LIBDIR}/plymouth
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ fedora_fade_in_la_SOURCES = $(srcdir)/../../ply-boot-splash-plugin.h \
|
|||
$(srcdir)/fedora-fade-in.c
|
||||
|
||||
plymouthdir = $(datadir)/plymouth
|
||||
plymouth_DATA = star.png
|
||||
plymouth_DATA = star.png bullet.png entry.png lock.png
|
||||
|
||||
EXTRA_DIST = $(plymouth_DATA)
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
|
|
|||
BIN
src/splash-plugins/fedora-fade-in/bullet.png
Normal file
BIN
src/splash-plugins/fedora-fade-in/bullet.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 745 B |
BIN
src/splash-plugins/fedora-fade-in/entry.png
Normal file
BIN
src/splash-plugins/fedora-fade-in/entry.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 857 B |
|
|
@ -1,6 +1,6 @@
|
|||
/* fedora-fade-in.c - boot splash plugin
|
||||
*
|
||||
* Copyright (C) 2007 Red Hat, Inc.
|
||||
* Copyright (C) 2007, 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
|
||||
|
|
@ -37,8 +37,10 @@
|
|||
#include <sys/types.h>
|
||||
#include <values.h>
|
||||
#include <unistd.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include "ply-boot-splash-plugin.h"
|
||||
#include "ply-buffer.h"
|
||||
#include "ply-event-loop.h"
|
||||
#include "ply-list.h"
|
||||
#include "ply-logger.h"
|
||||
|
|
@ -61,15 +63,32 @@ typedef struct
|
|||
double speed;
|
||||
} star_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int number_of_bullets;
|
||||
} entry_t;
|
||||
|
||||
struct _ply_boot_splash_plugin
|
||||
{
|
||||
ply_event_loop_t *loop;
|
||||
ply_frame_buffer_t *frame_buffer;
|
||||
ply_image_t *logo_image;
|
||||
ply_image_t *star_image;
|
||||
ply_image_t *bullet_image;
|
||||
ply_image_t *lock_image;
|
||||
ply_image_t *entry_image;
|
||||
ply_list_t *stars;
|
||||
ply_window_t *window;
|
||||
|
||||
entry_t *entry;
|
||||
|
||||
ply_boot_splash_password_answer_handler_t password_answer_handler;
|
||||
void *password_answer_data;
|
||||
|
||||
ply_buffer_t *keyboard_input_buffer;
|
||||
|
||||
double start_time;
|
||||
double now;
|
||||
};
|
||||
|
|
@ -83,14 +102,39 @@ create_plugin (void)
|
|||
plugin = calloc (1, sizeof (ply_boot_splash_plugin_t));
|
||||
plugin->start_time = 0.0;
|
||||
|
||||
plugin->keyboard_input_buffer = ply_buffer_new ();
|
||||
|
||||
plugin->frame_buffer = ply_frame_buffer_new (NULL);
|
||||
plugin->logo_image = ply_image_new (PLYMOUTH_IMAGE_DIR "fedora-logo.png");
|
||||
plugin->star_image = ply_image_new (PLYMOUTH_IMAGE_DIR "star.png");
|
||||
plugin->lock_image = ply_image_new (PLYMOUTH_IMAGE_DIR "lock.png");
|
||||
plugin->bullet_image = ply_image_new (PLYMOUTH_IMAGE_DIR "bullet.png");
|
||||
plugin->entry_image = ply_image_new (PLYMOUTH_IMAGE_DIR "entry.png");
|
||||
plugin->stars = ply_list_new ();
|
||||
|
||||
return plugin;
|
||||
}
|
||||
|
||||
static entry_t *
|
||||
entry_new (int x,
|
||||
int y)
|
||||
{
|
||||
|
||||
entry_t *entry;
|
||||
|
||||
entry = calloc (1, sizeof (entry_t));
|
||||
entry->x = x;
|
||||
entry->y = y;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static void
|
||||
entry_free (entry_t *entry)
|
||||
{
|
||||
free (entry);
|
||||
}
|
||||
|
||||
star_t *
|
||||
star_new (int x,
|
||||
int y,
|
||||
|
|
@ -146,9 +190,14 @@ destroy_plugin (ply_boot_splash_plugin_t *plugin)
|
|||
if (plugin == NULL)
|
||||
return;
|
||||
|
||||
ply_buffer_free (plugin->keyboard_input_buffer);
|
||||
|
||||
free_stars (plugin);
|
||||
ply_image_free (plugin->logo_image);
|
||||
ply_image_free (plugin->star_image);
|
||||
ply_image_free (plugin->bullet_image);
|
||||
ply_image_free (plugin->entry_image);
|
||||
ply_image_free (plugin->lock_image);
|
||||
ply_frame_buffer_free (plugin->frame_buffer);
|
||||
free (plugin);
|
||||
}
|
||||
|
|
@ -222,6 +271,7 @@ animate_at_time (ply_boot_splash_plugin_t *plugin,
|
|||
ply_frame_buffer_unpause_updates (plugin->frame_buffer);
|
||||
}
|
||||
|
||||
static void draw_password_entry (ply_boot_splash_plugin_t *plugin);
|
||||
static void
|
||||
on_timeout (ply_boot_splash_plugin_t *plugin)
|
||||
{
|
||||
|
|
@ -230,7 +280,6 @@ on_timeout (ply_boot_splash_plugin_t *plugin)
|
|||
ply_window_set_mode (plugin->window, PLY_WINDOW_MODE_GRAPHICS);
|
||||
plugin->now = ply_get_timestamp ();
|
||||
|
||||
|
||||
/* The choice below is between
|
||||
*
|
||||
* 1) keeping a constant animation speed, and dropping
|
||||
|
|
@ -304,8 +353,6 @@ stop_animation (ply_boot_splash_plugin_t *plugin)
|
|||
ply_frame_buffer_fill_with_color (plugin->frame_buffer, NULL,
|
||||
0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
ply_window_set_mode (plugin->window, PLY_WINDOW_MODE_TEXT);
|
||||
|
||||
if (plugin->loop != NULL)
|
||||
{
|
||||
ply_event_loop_stop_watching_for_timeout (plugin->loop,
|
||||
|
|
@ -319,6 +366,7 @@ on_interrupt (ply_boot_splash_plugin_t *plugin)
|
|||
{
|
||||
ply_event_loop_exit (plugin->loop, 1);
|
||||
stop_animation (plugin);
|
||||
ply_window_set_mode (plugin->window, PLY_WINDOW_MODE_TEXT);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -352,6 +400,18 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
|
|||
if (!ply_image_load (plugin->star_image))
|
||||
return false;
|
||||
|
||||
ply_trace ("loading lock image");
|
||||
if (!ply_image_load (plugin->lock_image))
|
||||
return false;
|
||||
|
||||
ply_trace ("loading bullet image");
|
||||
if (!ply_image_load (plugin->bullet_image))
|
||||
return false;
|
||||
|
||||
ply_trace ("loading entry image");
|
||||
if (!ply_image_load (plugin->entry_image))
|
||||
return false;
|
||||
|
||||
ply_trace ("opening frame buffer");
|
||||
if (!ply_frame_buffer_open (plugin->frame_buffer))
|
||||
{
|
||||
|
|
@ -473,12 +533,125 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
|
|||
}
|
||||
|
||||
ply_frame_buffer_close (plugin->frame_buffer);
|
||||
ply_window_set_mode (plugin->window, PLY_WINDOW_MODE_TEXT);
|
||||
}
|
||||
static void
|
||||
draw_password_entry (ply_boot_splash_plugin_t *plugin)
|
||||
{
|
||||
ply_frame_buffer_area_t lock_area, entry_area, bullet_area;
|
||||
uint32_t *lock_data, *entry_data, *bullet_data;
|
||||
int x, y, i;
|
||||
|
||||
ply_frame_buffer_pause_updates (plugin->frame_buffer);
|
||||
entry_data = ply_image_get_data (plugin->entry_image);
|
||||
entry_area.width = ply_image_get_width (plugin->entry_image);
|
||||
entry_area.height = ply_image_get_height (plugin->entry_image);
|
||||
entry_area.x = plugin->entry->x;
|
||||
entry_area.y = plugin->entry->y;
|
||||
|
||||
ply_frame_buffer_fill_with_argb32_data (plugin->frame_buffer,
|
||||
&entry_area, 0, 0,
|
||||
entry_data);
|
||||
|
||||
lock_data = ply_image_get_data (plugin->lock_image);
|
||||
lock_area.width = ply_image_get_width (plugin->lock_image);
|
||||
lock_area.height = ply_image_get_height (plugin->lock_image);
|
||||
|
||||
x = plugin->entry->x - lock_area.width;
|
||||
y = plugin->entry->y + entry_area.height / 2.0 - lock_area.height / 2.0;
|
||||
|
||||
lock_area.x = x;
|
||||
lock_area.y = y;
|
||||
ply_frame_buffer_fill_with_argb32_data (plugin->frame_buffer,
|
||||
&lock_area, 0, 0,
|
||||
lock_data);
|
||||
|
||||
|
||||
bullet_data = ply_image_get_data (plugin->bullet_image);
|
||||
bullet_area.width = ply_image_get_width (plugin->bullet_image);
|
||||
bullet_area.height = ply_image_get_height (plugin->bullet_image);
|
||||
|
||||
for (i = 0; i < plugin->entry->number_of_bullets; i++)
|
||||
{
|
||||
bullet_area.x = plugin->entry->x + (i + 1) * bullet_area.width;
|
||||
bullet_area.y = plugin->entry->y + entry_area.height / 2.0 - bullet_area.height / 2.0;
|
||||
|
||||
ply_frame_buffer_fill_with_argb32_data (plugin->frame_buffer,
|
||||
&bullet_area, 0, 0,
|
||||
bullet_data);
|
||||
}
|
||||
ply_frame_buffer_unpause_updates (plugin->frame_buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
show_password_entry (ply_boot_splash_plugin_t *plugin)
|
||||
{
|
||||
ply_frame_buffer_area_t area;
|
||||
int x, y;
|
||||
int lock_width, lock_height;
|
||||
int entry_width, entry_height;
|
||||
|
||||
assert (plugin != NULL);
|
||||
|
||||
ply_frame_buffer_get_size (plugin->frame_buffer, &area);
|
||||
lock_width = ply_image_get_width (plugin->lock_image);
|
||||
lock_height = ply_image_get_height (plugin->lock_image);
|
||||
|
||||
entry_width = ply_image_get_width (plugin->entry_image);
|
||||
entry_height = ply_image_get_height (plugin->entry_image);
|
||||
|
||||
x = area.width / 2.0 - (lock_width + entry_width) / 2.0 + lock_width;
|
||||
y = area.height / 2.0 - entry_height / 2.0;
|
||||
|
||||
plugin->entry = entry_new (x, y);
|
||||
ply_frame_buffer_fill_with_color (plugin->frame_buffer, NULL,
|
||||
0.1, 0.1, .7, 1.0);
|
||||
draw_password_entry (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;
|
||||
|
||||
stop_animation (plugin);
|
||||
show_password_entry (plugin);
|
||||
}
|
||||
|
||||
void
|
||||
on_keyboard_input (ply_boot_splash_plugin_t *plugin,
|
||||
const char *keyboard_input)
|
||||
{
|
||||
|
||||
ssize_t character_size;
|
||||
|
||||
character_size = (ssize_t) mbrlen (keyboard_input, MB_CUR_MAX, NULL);
|
||||
|
||||
if (character_size < 0)
|
||||
return;
|
||||
|
||||
if (plugin->password_answer_handler == NULL)
|
||||
return;
|
||||
|
||||
if (character_size == 1 && keyboard_input[0] == '\r')
|
||||
{
|
||||
plugin->password_answer_handler (plugin->password_answer_data,
|
||||
ply_buffer_get_bytes (plugin->keyboard_input_buffer));
|
||||
ply_buffer_clear (plugin->keyboard_input_buffer);
|
||||
plugin->password_answer_handler = NULL;
|
||||
|
||||
start_animation (plugin);
|
||||
return;
|
||||
}
|
||||
|
||||
ply_buffer_append_bytes (plugin->keyboard_input_buffer,
|
||||
keyboard_input, character_size);
|
||||
|
||||
plugin->entry->number_of_bullets++;
|
||||
draw_password_entry (plugin);
|
||||
}
|
||||
|
||||
ply_boot_splash_plugin_interface_t *
|
||||
|
|
@ -491,6 +664,7 @@ ply_boot_splash_plugin_get_interface (void)
|
|||
.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
|
||||
};
|
||||
|
||||
|
|
|
|||
BIN
src/splash-plugins/fedora-fade-in/lock.png
Normal file
BIN
src/splash-plugins/fedora-fade-in/lock.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
Loading…
Add table
Reference in a new issue