Introduce an early reporting mechanism for verify and match

It is a good idea to report match results early, to e.g. log in a user
immediately even if more device interaction is needed. Add new _full
variants for the verify/identify functions, with a corresponding
callback. Also move driver result reporting into new
fpi_device_{identify,verify}_report functions and remove the reporting
from the fpi_device_{identify,verify}_complete calls.

Basic updates to code is done in places. Only the upekts driver is
actually modified from a behaviour point of view. The image driver code
should be restructured quite a bit to split the reporting and only
report completion after device deactivation. This should simplifiy the
code quite a bit again.
This commit is contained in:
Benjamin Berg
2020-01-13 14:37:39 +01:00
parent 8292c449f7
commit 4d5c34e11a
13 changed files with 385 additions and 102 deletions
+15 -8
View File
@@ -832,7 +832,7 @@ initsm_done (FpiSsm *ssm, FpDevice *dev, GError *error)
}
static FpiSsm *
deinitsm_new (FpDevice *dev)
deinitsm_new (FpDevice *dev, void *user_data)
{
return fpi_ssm_new (dev, deinitsm_state_handler, DEINITSM_NUM_STATES);
}
@@ -988,7 +988,7 @@ static void
do_enroll_stop (FpDevice *dev, FpPrint *print, GError *error)
{
EnrollStopData *data = g_new0 (EnrollStopData, 1);
FpiSsm *ssm = deinitsm_new (dev);
FpiSsm *ssm = deinitsm_new (dev, data);
data->print = g_object_ref (print);
data->error = error;
@@ -1225,8 +1225,7 @@ enroll (FpDevice *dev)
typedef struct
{
FpiMatchResult res;
GError *error;
GError *error;
} VerifyStopData;
static void
@@ -1244,17 +1243,25 @@ verify_stop_deinit_cb (FpiSsm *ssm, FpDevice *dev, GError *error)
if (error)
fp_warn ("Error deinitializing: %s", error->message);
fpi_device_verify_complete (dev, data->res, NULL, data->error);
if (data->error)
fpi_device_verify_complete (dev, data->error);
else
fpi_device_verify_complete (dev, g_steal_pointer (&error));
g_error_free (error);
}
static void
do_verify_stop (FpDevice *dev, FpiMatchResult res, GError *error)
{
VerifyStopData *data = g_new0 (VerifyStopData, 1);
FpiSsm *ssm = deinitsm_new (dev);
FpiSsm *ssm = deinitsm_new (dev, data);
data->res = res;
data->error = error;
/* Report the error immediately if possible, otherwise delay it. */
if (!error && error->domain != FP_DEVICE_RETRY)
fpi_device_verify_report (dev, res, NULL, error);
else
data->error = error;
fpi_ssm_start (ssm, verify_stop_deinit_cb);
fpi_ssm_set_data (ssm, data, (GDestroyNotify) verify_stop_data_free);