summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2008-06-02 11:49:00 -0400
committerRay Strode <rstrode@redhat.com>2008-06-02 11:49:00 -0400
commitf5a15611fb5fe1d36f8922e1c2a6f751ab0b8df7 (patch)
treef44de427f359bdc19b76bf440cde0c4181d27d9e /src
parentccd95672582f2cfc98d0d6985603bda84f48f170 (diff)
Port password handling over to using new answer object
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/main.c33
-rw-r--r--src/ply-boot-server.c13
-rw-r--r--src/ply-boot-server.h4
-rw-r--r--src/ply-boot-splash-plugin.h4
-rw-r--r--src/ply-boot-splash.c7
-rw-r--r--src/ply-boot-splash.h4
-rw-r--r--src/splash-plugins/details/Makefile.am2
-rw-r--r--src/splash-plugins/details/plugin.c17
-rw-r--r--src/splash-plugins/fade-in/Makefile.am2
-rw-r--r--src/splash-plugins/fade-in/plugin.c21
-rw-r--r--src/splash-plugins/spinfinity/Makefile.am2
-rw-r--r--src/splash-plugins/spinfinity/plugin.c18
-rw-r--r--src/splash-plugins/text/Makefile.am2
-rw-r--r--src/splash-plugins/text/plugin.c18
-rw-r--r--src/tests/ply-boot-server-test.am2
-rw-r--r--src/tests/ply-boot-splash-test.am2
17 files changed, 73 insertions, 80 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 3aba79b..a0e6c9d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,6 +10,8 @@ plymouthdbin_PROGRAMS = plymouthd
plymouthd_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLYMOUTH_PLUGIN_PATH=\"$(libdir)/plymouth/\"
plymouthd_LDADD = $(PLYMOUTH_LIBS) libply/libply.la
plymouthd_SOURCES = \
+ ply-answer.h \
+ ply-answer.c \
ply-boot-protocol.h \
ply-boot-server.h \
ply-boot-server.c \
diff --git a/src/main.c b/src/main.c
index 70916fb..1cf01f8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -31,6 +31,7 @@
#include <sysexits.h>
#include <unistd.h>
+#include "ply-answer.h"
#include "ply-boot-server.h"
#include "ply-boot-splash.h"
#include "ply-event-loop.h"
@@ -105,41 +106,17 @@ on_update (state_t *state,
status);
}
-typedef struct
-{
- ply_boot_server_password_answer_handler_t handler;
- void *data;
- state_t *state;
-} password_answer_closure_t;
-
static void
-on_password_answer (password_answer_closure_t *closure,
- const char *password)
+on_ask_for_password (state_t *state,
+ ply_answer_t *answer)
{
- closure->handler (closure->data, password, closure->state->boot_server);
-}
-
-static void
-on_ask_for_password (state_t *state,
- ply_boot_server_password_answer_handler_t answer_handler,
- void *answer_data)
-{
- password_answer_closure_t *closure;
-
if (state->boot_splash != NULL)
{
- answer_handler (answer_data, "", state->boot_server);
+ ply_answer_with_string (answer, "");
return;
}
- closure = malloc (sizeof (password_answer_closure_t));
- closure->handler = answer_handler;
- closure->data = answer_data;
- closure->state = state;
-
- ply_boot_splash_ask_for_password (state->boot_splash,
- (ply_boot_splash_password_answer_handler_t)
- on_password_answer, closure);
+ ply_boot_splash_ask_for_password (state->boot_splash, answer);
}
static void
diff --git a/src/ply-boot-server.c b/src/ply-boot-server.c
index 84e4ad2..898ca21 100644
--- a/src/ply-boot-server.c
+++ b/src/ply-boot-server.c
@@ -183,7 +183,7 @@ ply_boot_connection_is_from_root (ply_boot_connection_t *connection)
static void
ply_boot_connection_on_password_answer (ply_boot_connection_t *connection,
const char *password,
- ply_boot_server_t *server)
+ ply_answer_t *answer)
{
size_t size;
@@ -203,6 +203,8 @@ ply_boot_connection_on_password_answer (ply_boot_connection_t *connection,
!ply_write (connection->fd,
password, size))
ply_error ("could not write bytes: %m");
+
+ ply_answer_free (answer);
}
static void
@@ -256,10 +258,15 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection)
}
else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_PASSWORD) == 0)
{
+ ply_answer_t *answer;
+
+ answer = ply_answer_new ((ply_answer_handler_t)
+ ply_boot_connection_on_password_answer,
+ connection);
+
if (server->ask_for_password_handler != NULL)
server->ask_for_password_handler (server->user_data,
- ply_boot_connection_on_password_answer,
- connection,
+ answer,
server);
/* will reply later
*/
diff --git a/src/ply-boot-server.h b/src/ply-boot-server.h
index dd9f386..a8eb7b2 100644
--- a/src/ply-boot-server.h
+++ b/src/ply-boot-server.h
@@ -26,6 +26,7 @@
#include <stdint.h>
#include <unistd.h>
+#include "ply-answer.h"
#include "ply-boot-protocol.h"
#include "ply-event-loop.h"
@@ -42,8 +43,7 @@ typedef void (* ply_boot_server_password_answer_handler_t) (void *a
const char *password,
ply_boot_server_t *server);
typedef void (* ply_boot_server_ask_for_password_handler_t) (void *user_data,
- ply_boot_server_password_answer_handler_t on_answer_handler,
- void *answer_data,
+ ply_answer_t *answer,
ply_boot_server_t *server);
typedef void (* ply_boot_server_system_initialized_handler_t) (void *user_data,
diff --git a/src/ply-boot-splash-plugin.h b/src/ply-boot-splash-plugin.h
index a6fbb5d..cc4b39a 100644
--- a/src/ply-boot-splash-plugin.h
+++ b/src/ply-boot-splash-plugin.h
@@ -26,6 +26,7 @@
#include <stdint.h>
#include <unistd.h>
+#include "ply-answer.h"
#include "ply-event-loop.h"
#include "ply-window.h"
#include "ply-buffer.h"
@@ -53,8 +54,7 @@ typedef struct
ply_window_t *window);
void (* ask_for_password) (ply_boot_splash_plugin_t *plugin,
- ply_boot_splash_password_answer_handler_t answer_handler,
- void *answer_data);
+ ply_answer_t *answer);
} ply_boot_splash_plugin_interface_t;
#endif /* PLY_BOOT_SPLASH_PLUGIN_H */
diff --git a/src/ply-boot-splash.c b/src/ply-boot-splash.c
index 4811b1e..8266212 100644
--- a/src/ply-boot-splash.c
+++ b/src/ply-boot-splash.c
@@ -216,8 +216,7 @@ ply_boot_splash_update_output (ply_boot_splash_t *splash,
void
ply_boot_splash_ask_for_password (ply_boot_splash_t *splash,
- ply_boot_splash_password_answer_handler_t answer_handler,
- void *answer_data)
+ ply_answer_t *answer)
{
assert (splash != NULL);
@@ -227,12 +226,12 @@ ply_boot_splash_ask_for_password (ply_boot_splash_t *splash,
if (splash->plugin_interface->ask_for_password == NULL)
{
- answer_handler (answer_data, "");
+ ply_answer_with_string (answer, "");
return;
}
splash->plugin_interface->ask_for_password (splash->plugin,
- answer_handler, answer_data);
+ answer);
}
static void
diff --git a/src/ply-boot-splash.h b/src/ply-boot-splash.h
index 64006b4..367af1e 100644
--- a/src/ply-boot-splash.h
+++ b/src/ply-boot-splash.h
@@ -26,6 +26,7 @@
#include <stdint.h>
#include <unistd.h>
+#include "ply-answer.h"
#include "ply-event-loop.h"
#include "ply-window.h"
#include "ply-buffer.h"
@@ -46,8 +47,7 @@ void ply_boot_splash_update_output (ply_boot_splash_t *splash,
size_t size);
void ply_boot_splash_ask_for_password (ply_boot_splash_t *splash,
- ply_boot_splash_password_answer_handler_t answer_handler,
- void *answer_data);
+ ply_answer_t *answer);
void ply_boot_splash_hide (ply_boot_splash_t *splash);
void ply_boot_splash_attach_to_event_loop (ply_boot_splash_t *splash,
ply_event_loop_t *loop);
diff --git a/src/splash-plugins/details/Makefile.am b/src/splash-plugins/details/Makefile.am
index 0550db0..b289d52 100644
--- a/src/splash-plugins/details/Makefile.am
+++ b/src/splash-plugins/details/Makefile.am
@@ -11,6 +11,8 @@ details_la_CFLAGS = $(PLYMOUTH_CFLAGS)
details_la_LDFLAGS = -module -avoid-version -export-dynamic
details_la_LIBADD = $(PLYMOUTH_LIBS) ../../libply/libply.la
details_la_SOURCES = $(srcdir)/../../ply-boot-splash-plugin.h \
+ $(srcdir)/../../ply-answer.h \
+ $(srcdir)/../../ply-answer.c \
$(srcdir)/../../ply-window.h \
$(srcdir)/../../ply-window.c \
$(srcdir)/plugin.c
diff --git a/src/splash-plugins/details/plugin.c b/src/splash-plugins/details/plugin.c
index 48d5ac9..9c9f5f4 100644
--- a/src/splash-plugins/details/plugin.c
+++ b/src/splash-plugins/details/plugin.c
@@ -40,6 +40,7 @@
#include <wchar.h>
#include <values.h>
+#include "ply-answer.h"
#include "ply-boot-splash-plugin.h"
#include "ply-buffer.h"
#include "ply-event-loop.h"
@@ -59,8 +60,7 @@ struct _ply_boot_splash_plugin
{
ply_event_loop_t *loop;
- ply_boot_splash_password_answer_handler_t password_answer_handler;
- void *password_answer_data;
+ ply_answer_t *pending_password_answer;
uint32_t keyboard_input_is_hidden : 1;
};
@@ -117,12 +117,11 @@ void
on_enter (ply_boot_splash_plugin_t *plugin,
const char *line)
{
- if (plugin->password_answer_handler != NULL)
+ if (plugin->pending_password_answer != NULL)
{
- plugin->password_answer_handler (plugin->password_answer_data,
- line);
+ ply_answer_with_string (plugin->pending_password_answer, line);
plugin->keyboard_input_is_hidden = false;
- plugin->password_answer_handler = NULL;
+ plugin->pending_password_answer = NULL;
write (STDOUT_FILENO, CLEAR_LINE_SEQUENCE, strlen (CLEAR_LINE_SEQUENCE));
}
}
@@ -203,11 +202,9 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
void
ask_for_password (ply_boot_splash_plugin_t *plugin,
- ply_boot_splash_password_answer_handler_t answer_handler,
- void *answer_data)
+ ply_answer_t *answer)
{
- plugin->password_answer_handler = answer_handler;
- plugin->password_answer_data = answer_data;
+ plugin->pending_password_answer = answer;
write (STDOUT_FILENO, "\nPassword: ", strlen ("\nPassword: "));
plugin->keyboard_input_is_hidden = true;
diff --git a/src/splash-plugins/fade-in/Makefile.am b/src/splash-plugins/fade-in/Makefile.am
index bc37f28..4e26835 100644
--- a/src/splash-plugins/fade-in/Makefile.am
+++ b/src/splash-plugins/fade-in/Makefile.am
@@ -14,6 +14,8 @@ fade_in_la_CFLAGS = $(PLYMOUTH_CFLAGS) \
fade_in_la_LDFLAGS = -module -avoid-version -export-dynamic
fade_in_la_LIBADD = $(PLYMOUTH_LIBS) ../../libply/libply.la
fade_in_la_SOURCES = $(srcdir)/../../ply-boot-splash-plugin.h \
+ $(srcdir)/../../ply-answer.h \
+ $(srcdir)/../../ply-answer.c \
$(srcdir)/../../ply-window.h \
$(srcdir)/../../ply-window.c \
$(srcdir)/plugin.c
diff --git a/src/splash-plugins/fade-in/plugin.c b/src/splash-plugins/fade-in/plugin.c
index c30e943..13236d3 100644
--- a/src/splash-plugins/fade-in/plugin.c
+++ b/src/splash-plugins/fade-in/plugin.c
@@ -39,6 +39,7 @@
#include <unistd.h>
#include <wchar.h>
+#include "ply-answer.h"
#include "ply-boot-splash-plugin.h"
#include "ply-buffer.h"
#include "ply-event-loop.h"
@@ -84,8 +85,7 @@ struct _ply_boot_splash_plugin
entry_t *entry;
- ply_boot_splash_password_answer_handler_t password_answer_handler;
- void *password_answer_data;
+ ply_answer_t *pending_password_answer;
double start_time;
double now;
@@ -376,7 +376,7 @@ on_keyboard_input (ply_boot_splash_plugin_t *plugin,
const char *keyboard_input,
size_t character_size)
{
- if (plugin->password_answer_handler == NULL)
+ if (plugin->pending_password_answer == NULL)
return;
plugin->entry->number_of_bullets++;
@@ -394,8 +394,13 @@ void
on_enter (ply_boot_splash_plugin_t *plugin,
const char *text)
{
- plugin->password_answer_handler (plugin->password_answer_data,
- text);
+
+ if (plugin->pending_password_answer == NULL)
+ return;
+
+ ply_answer_with_string (plugin->pending_password_answer, text);
+ plugin->pending_password_answer = NULL;
+
plugin->entry->number_of_bullets = 0;
entry_free (plugin->entry);
plugin->entry = NULL;
@@ -650,11 +655,9 @@ show_password_entry (ply_boot_splash_plugin_t *plugin)
void
ask_for_password (ply_boot_splash_plugin_t *plugin,
- ply_boot_splash_password_answer_handler_t answer_handler,
- void *answer_data)
+ ply_answer_t *answer)
{
- plugin->password_answer_handler = answer_handler;
- plugin->password_answer_data = answer_data;
+ plugin->pending_password_answer = answer;
stop_animation (plugin);
show_password_entry (plugin);
diff --git a/src/splash-plugins/spinfinity/Makefile.am b/src/splash-plugins/spinfinity/Makefile.am
index fa6784d..23cdd54 100644
--- a/src/splash-plugins/spinfinity/Makefile.am
+++ b/src/splash-plugins/spinfinity/Makefile.am
@@ -15,6 +15,8 @@ spinfinity_la_CFLAGS = $(PLYMOUTH_CFLAGS) \
spinfinity_la_LDFLAGS = -module -avoid-version -export-dynamic
spinfinity_la_LIBADD = $(PLYMOUTH_LIBS) ../../libply/libply.la
spinfinity_la_SOURCES = $(srcdir)/../../ply-boot-splash-plugin.h \
+ $(srcdir)/../../ply-answer.h \
+ $(srcdir)/../../ply-answer.c \
$(srcdir)/../../ply-window.h \
$(srcdir)/../../ply-window.c \
$(srcdir)/throbber.h \
diff --git a/src/splash-plugins/spinfinity/plugin.c b/src/splash-plugins/spinfinity/plugin.c
index 24298e7..b8f9b53 100644
--- a/src/splash-plugins/spinfinity/plugin.c
+++ b/src/splash-plugins/spinfinity/plugin.c
@@ -39,6 +39,7 @@
#include <unistd.h>
#include <wchar.h>
+#include "ply-answer.h"
#include "ply-boot-splash-plugin.h"
#include "ply-buffer.h"
#include "ply-event-loop.h"
@@ -78,8 +79,7 @@ struct _ply_boot_splash_plugin
entry_t *entry;
throbber_t *throbber;
- ply_boot_splash_password_answer_handler_t password_answer_handler;
- void *password_answer_data;
+ ply_answer_t *pending_password_answer;
};
static void detach_from_event_loop (ply_boot_splash_plugin_t *plugin);
@@ -245,7 +245,7 @@ on_keyboard_input (ply_boot_splash_plugin_t *plugin,
const char *keyboard_input,
size_t character_size)
{
- if (plugin->password_answer_handler == NULL)
+ if (plugin->pending_password_answer == NULL)
return;
plugin->entry->number_of_bullets++;
@@ -263,11 +263,11 @@ void
on_enter (ply_boot_splash_plugin_t *plugin,
const char *text)
{
- if (plugin->password_answer_handler == NULL)
+ if (plugin->pending_password_answer == NULL)
return;
- plugin->password_answer_handler (plugin->password_answer_data,
- text);
+ ply_answer_with_string (plugin->pending_password_answer, text);
+ plugin->pending_password_answer = NULL;
if (plugin->entry != NULL)
{
@@ -456,11 +456,9 @@ show_password_entry (ply_boot_splash_plugin_t *plugin)
void
ask_for_password (ply_boot_splash_plugin_t *plugin,
- ply_boot_splash_password_answer_handler_t answer_handler,
- void *answer_data)
+ ply_answer_t *answer)
{
- plugin->password_answer_handler = answer_handler;
- plugin->password_answer_data = answer_data;
+ plugin->pending_password_answer = answer;
stop_animation (plugin);
show_password_entry (plugin);
diff --git a/src/splash-plugins/text/Makefile.am b/src/splash-plugins/text/Makefile.am
index 27b2cf7..2d9ba73 100644
--- a/src/splash-plugins/text/Makefile.am
+++ b/src/splash-plugins/text/Makefile.am
@@ -11,6 +11,8 @@ 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)/../../ply-answer.h \
+ $(srcdir)/../../ply-answer.c \
$(srcdir)/../../ply-window.h \
$(srcdir)/../../ply-window.c \
$(srcdir)/plugin.c
diff --git a/src/splash-plugins/text/plugin.c b/src/splash-plugins/text/plugin.c
index a342fa7..3ad9234 100644
--- a/src/splash-plugins/text/plugin.c
+++ b/src/splash-plugins/text/plugin.c
@@ -40,6 +40,7 @@
#include <values.h>
#include <wchar.h>
+#include "ply-answer.h"
#include "ply-boot-splash-plugin.h"
#include "ply-buffer.h"
#include "ply-event-loop.h"
@@ -60,8 +61,8 @@ struct _ply_boot_splash_plugin
ply_event_loop_t *loop;
int console_fd;
- ply_boot_splash_password_answer_handler_t password_answer_handler;
- void *password_answer_data;
+
+ ply_answer_t *pending_password_answer;
uint32_t keyboard_input_is_hidden : 1;
};
@@ -132,12 +133,11 @@ void
on_enter (ply_boot_splash_plugin_t *plugin,
const char *line)
{
- if (plugin->password_answer_handler != NULL)
+ if (plugin->pending_password_answer != NULL)
{
- plugin->password_answer_handler (plugin->password_answer_data,
- line);
+ ply_answer_with_string (plugin->pending_password_answer, line);
plugin->keyboard_input_is_hidden = false;
- plugin->password_answer_handler = NULL;
+ plugin->pending_password_answer = NULL;
write (STDOUT_FILENO, CLEAR_LINE_SEQUENCE, strlen (CLEAR_LINE_SEQUENCE));
}
}
@@ -207,11 +207,9 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
void
ask_for_password (ply_boot_splash_plugin_t *plugin,
- ply_boot_splash_password_answer_handler_t answer_handler,
- void *answer_data)
+ ply_answer_t *answer)
{
- plugin->password_answer_handler = answer_handler;
- plugin->password_answer_data = answer_data;
+ plugin->pending_password_answer = answer;
write (STDOUT_FILENO, "\nPassword: ", strlen ("\nPassword: "));
plugin->keyboard_input_is_hidden = true;
diff --git a/src/tests/ply-boot-server-test.am b/src/tests/ply-boot-server-test.am
index cc28348..028edce 100644
--- a/src/tests/ply-boot-server-test.am
+++ b/src/tests/ply-boot-server-test.am
@@ -4,5 +4,7 @@ ply_boot_server_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_BOOT_SERVER_ENABLE_TEST
ply_boot_server_test_LDADD = $(PLYMOUTH_LIBS) ../libply/libply.la
ply_boot_server_test_SOURCES = \
+ $(srcdir)/../ply-answer.h \
+ $(srcdir)/../ply-answer.c \
$(srcdir)/../ply-boot-server.h \
$(srcdir)/../ply-boot-server.c
diff --git a/src/tests/ply-boot-splash-test.am b/src/tests/ply-boot-splash-test.am
index af67aad..063bdcc 100644
--- a/src/tests/ply-boot-splash-test.am
+++ b/src/tests/ply-boot-splash-test.am
@@ -4,6 +4,8 @@ ply_boot_splash_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_BOOT_SPLASH_ENABLE_TEST
ply_boot_splash_test_LDADD = $(PLYMOUTH_LIBS) ../libply/libply.la
ply_boot_splash_test_SOURCES = \
+ $(srcdir)/../ply-answer.h \
+ $(srcdir)/../ply-answer.c \
$(srcdir)/../ply-boot-splash-plugin.h \
$(srcdir)/../ply-window.h \
$(srcdir)/../ply-window.c \