diff options
author | Bastien Nocera <hadess@hadess.net> | 2014-02-18 18:32:08 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2014-02-18 18:32:08 +0100 |
commit | d7e326a776e8dc8d72e2834faccf8d2292d55bd2 (patch) | |
tree | 48e0f9c6aaadba030d63747080db41d9d411821f | |
parent | 7e4630ced2be4b7ecdfb9d60cfe0e0d3de594411 (diff) |
tests: List possible values for finger when enrolling
When the "-f" parameter of fprintd-enroll is incorrect, list
the possible values.
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rw-r--r-- | tests/enroll.c | 28 |
2 files changed, 29 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index aacf8c1..01e2184 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -9,7 +9,7 @@ fprintd_verify_CFLAGS = $(WARN_CFLAGS) $(GLIB_CFLAGS) fprintd_verify_LDADD = $(GLIB_LIBS) fprintd_enroll_SOURCES = enroll.c $(MARSHALFILES) -fprintd_enroll_CFLAGS = $(WARN_CFLAGS) $(GLIB_CFLAGS) +fprintd_enroll_CFLAGS = $(WARN_CFLAGS) $(GLIB_CFLAGS) -I$(top_srcdir)/pam fprintd_enroll_LDADD = $(GLIB_LIBS) fprintd_list_SOURCES = list.c diff --git a/tests/enroll.c b/tests/enroll.c index 15c273e..4a0fe09 100644 --- a/tests/enroll.c +++ b/tests/enroll.c @@ -24,6 +24,10 @@ #include "device-dbus-glue.h" #include "marshal.h" +#define N_(x) x +#define TR(x) x +#include "fingerprint-strings.h" + static DBusGProxy *manager = NULL; static DBusGConnection *connection = NULL; static char *finger_name = "right-index-finger"; @@ -87,11 +91,35 @@ static void do_enroll(DBusGProxy *dev) { GError *error = NULL; gboolean enroll_completed = FALSE; + gboolean found; + guint i; dbus_g_proxy_add_signal(dev, "EnrollStatus", G_TYPE_STRING, G_TYPE_BOOLEAN, NULL); dbus_g_proxy_connect_signal(dev, "EnrollStatus", G_CALLBACK(enroll_result), &enroll_completed, NULL); + found = FALSE; + for (i = 0; fingers[i].dbus_name != NULL; i++) { + if (g_strcmp0 (fingers[i].dbus_name, finger_name) == 0) { + found = TRUE; + break; + } + } + if (!found) { + GString *s; + + s = g_string_new (NULL); + g_string_append_printf (s, "Invalid finger name '%s'. Name must be one of ", finger_name); + for (i = 0; fingers[i].dbus_name != NULL; i++) { + g_string_append_printf (s, "%s", fingers[i].dbus_name); + if (fingers[i + 1].dbus_name != NULL) + g_string_append (s, ", "); + } + g_warning ("%s", s->str); + g_string_free (s, TRUE); + exit (1); + } + g_print("Enrolling %s finger.\n", finger_name); if (!net_reactivated_Fprint_Device_enroll_start(dev, finger_name, &error)) { g_print("EnrollStart failed: %s\n", error->message); |