[Fingerforce-commits] [fprintd] 03/12: tests: List possible values for finger when enrolling

Didier Raboud odyx at moszumanska.debian.org
Sun Apr 12 13:12:06 UTC 2015


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch master
in repository fprintd.

commit d7e326a776e8dc8d72e2834faccf8d2292d55bd2
Author: Bastien Nocera <hadess at hadess.net>
Date:   Tue Feb 18 18:32:08 2014 +0100

    tests: List possible values for finger when enrolling
    
    When the "-f" parameter of fprintd-enroll is incorrect, list
    the possible values.
---
 tests/Makefile.am |  2 +-
 tests/enroll.c    | 28 ++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)

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);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/fingerforce/fprintd.git



More information about the Fingerforce-commits mailing list