Commit 26aab5dc authored by Bastien Nocera's avatar Bastien Nocera Committed by Daniel Drake

Add a done argument to result signals

For verify and enroll, add a done argument so that front-end
know easily when they should be closing the device.
parent 0636c779
......@@ -24,5 +24,3 @@ Add POS use case
Review error cases, and possible errors
Add a "done" argument to verify and enroll result signals, make it easier
to know when we're done.
......@@ -254,15 +254,13 @@ typedef struct {
char *driver;
} verify_data;
static void verify_result(GObject *object, const char *result, gpointer user_data)
static void verify_result(GObject *object, const char *result, gboolean done, gpointer user_data)
{
verify_data *data = user_data;
const char *msg;
D(g_message("Verify result: %s\n", result));
if (g_str_equal (result, "verify-no-match") ||
g_str_equal (result, "verify-match") ||
g_str_equal (result, "verify-unknown-error")) {
if (done != FALSE) {
data->result = g_strdup (result);
g_main_loop_quit (data->loop);
return;
......
BUILT_SOURCES = manager-dbus-glue.h device-dbus-glue.h
BUILT_SOURCES = manager-dbus-glue.h device-dbus-glue.h $(MARSHALFILES)
noinst_HEADERS = $(BUILT_SOURCES)
CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = manager.xml device.xml
EXTRA_DIST = manager.xml device.xml fprintd-marshal.list
libexec_PROGRAMS = fprintd
......@@ -11,7 +11,8 @@ fprintd_SOURCES = \
manager.c \
device.c \
file_storage.c file_storage.h storage.h \
egg-dbus-monitor.c egg-dbus-monitor.h
egg-dbus-monitor.c egg-dbus-monitor.h \
$(MARSHALFILES)
fprintd_LDADD = $(FPRINT_LIBS) $(DAEMON_LIBS)
fprintd_CFLAGS = $(WARN_CFLAGS) $(FPRINT_CFLAGS) $(DAEMON_CFLAGS) -DLOCALEDIR=\""$(datadir)/locale"\" -DPLUGINDIR=\""$(libdir)/fprintd/modules"\"
......@@ -22,3 +23,11 @@ manager-dbus-glue.h: manager.xml
device-dbus-glue.h: device.xml
dbus-binding-tool --prefix=fprint_device --mode=glib-server $< --output=$@
MARSHALFILES = fprintd-marshal.c fprintd-marshal.h
GLIB_GENMARSHAL=`pkg-config --variable=glib_genmarshal glib-2.0`
fprintd-marshal.h: fprintd-marshal.list
( $(GLIB_GENMARSHAL) --prefix=fprintd_marshal $(srcdir)/fprintd-marshal.list --header > fprintd-marshal.h )
fprintd-marshal.c: fprintd-marshal.h
( $(GLIB_GENMARSHAL) --prefix=fprintd_marshal $(srcdir)/fprintd-marshal.list --body --header > fprintd-marshal.c )
......@@ -29,6 +29,7 @@
#include <sys/types.h>
#include <pwd.h>
#include "fprintd-marshal.h"
#include "fprintd.h"
#include "storage.h"
#include "egg-dbus-monitor.h"
......@@ -203,10 +204,10 @@ static void fprint_device_class_init(FprintDeviceClass *klass)
signals[SIGNAL_VERIFY_STATUS] = g_signal_new("verify-status",
G_TYPE_FROM_CLASS(gobject_class), G_SIGNAL_RUN_LAST, 0, NULL, NULL,
g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
fprintd_marshal_VOID__STRING_BOOLEAN, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_BOOLEAN);
signals[SIGNAL_ENROLL_STATUS] = g_signal_new("enroll-status",
G_TYPE_FROM_CLASS(gobject_class), G_SIGNAL_RUN_LAST, 0, NULL, NULL,
g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
fprintd_marshal_VOID__STRING_BOOLEAN, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_BOOLEAN);
signals[SIGNAL_VERIFY_FINGER_SELECTED] = g_signal_new("verify-finger-selected",
G_TYPE_FROM_CLASS(gobject_class), G_SIGNAL_RUN_LAST, 0, NULL, NULL,
g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
......@@ -733,9 +734,13 @@ static void verify_cb(struct fp_dev *dev, int r, struct fp_img *img,
{
struct FprintDevice *rdev = user_data;
const char *name = verify_result_to_name (r);
gboolean done = FALSE;
g_message("verify_cb: result %s (%d)", name, r);
g_signal_emit(rdev, signals[SIGNAL_VERIFY_STATUS], 0, name);
if (r == FP_VERIFY_NO_MATCH || r == FP_VERIFY_MATCH || r < 0)
done = TRUE;
g_signal_emit(rdev, signals[SIGNAL_VERIFY_STATUS], 0, name, done);
fp_img_free(img);
}
......@@ -744,9 +749,13 @@ static void identify_cb(struct fp_dev *dev, int r,
{
struct FprintDevice *rdev = user_data;
const char *name = verify_result_to_name (r);
gboolean done = FALSE;
g_message("identify_cb: result %s (%d)", name, r);
g_signal_emit(rdev, signals[SIGNAL_VERIFY_STATUS], 0, name);
if (r == FP_VERIFY_NO_MATCH || r == FP_VERIFY_MATCH || r < 0)
done = TRUE;
g_signal_emit(rdev, signals[SIGNAL_VERIFY_STATUS], 0, name, done);
fp_img_free(img);
}
......@@ -933,6 +942,7 @@ static void enroll_stage_cb(struct fp_dev *dev, int result,
struct FprintDevice *rdev = user_data;
FprintDevicePrivate *priv = DEVICE_GET_PRIVATE(rdev);
struct session_data *session = priv->session;
gboolean done = FALSE;
int r;
g_message("enroll_stage_cb: result %d", result);
......@@ -942,7 +952,9 @@ static void enroll_stage_cb(struct fp_dev *dev, int result,
result = FP_ENROLL_FAIL;
}
g_signal_emit(rdev, signals[SIGNAL_ENROLL_STATUS], 0, enroll_result_to_name (result));
if (result == FP_ENROLL_COMPLETE || result == FP_ENROLL_FAIL || result < 0)
done = TRUE;
g_signal_emit(rdev, signals[SIGNAL_ENROLL_STATUS], 0, enroll_result_to_name (result), done);
fp_img_free(img);
fp_print_data_free(print);
}
......
......@@ -39,6 +39,7 @@
<signal name="VerifyStatus">
<arg type="s" name="result" />
<arg type="b" name="done" />
</signal>
<method name="EnrollStart">
......@@ -52,6 +53,7 @@
<signal name="EnrollStatus">
<arg type="s" name="result" />
<arg type="b" name="done" />
</signal>
<method name="GetProperties">
......
VOID:STRING,BOOLEAN
......@@ -65,13 +65,12 @@ static DBusGProxy *open_device(const char *username)
return dev;
}
static void enroll_result(GObject *object, const char *result, void *user_data)
static void enroll_result(GObject *object, const char *result, gboolean done, void *user_data)
{
gboolean *enroll_completed = user_data;
g_print("Enroll result: %s\n", result);
if (g_str_equal(result, "enroll-completed") ||
g_str_equal(result, "enroll-failed") ||
g_str_equal(result, "enroll-unknown-error"))
if (done != FALSE)
*enroll_completed = TRUE;
*enroll_completed = TRUE;
}
......
......@@ -96,13 +96,11 @@ static void find_finger(DBusGProxy *dev, const char *username)
g_strfreev (fingers);
}
static void verify_result(GObject *object, const char *result, void *user_data)
static void verify_result(GObject *object, const char *result, gboolean done, void *user_data)
{
gboolean *verify_completed = user_data;
g_print("Verify result: %s\n", result);
if (g_str_equal (result, "verify-no-match") ||
g_str_equal (result, "verify-match") ||
g_str_equal (result, "verify-unknown-error"))
if (done != FALSE)
*verify_completed = TRUE;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment