examples/verify: Prompt match/no-match report in callback

Promptly show the match/no-match result in the match callback instead of
waiting the verification process to be finished.

Also exit in case of an hard error, while permit to try again in case of a
retry error.
This commit is contained in:
Marco Trevisan (Treviño) 2020-01-17 17:22:15 +01:00
parent a87e9c546f
commit cdcc476325

View file

@ -86,23 +86,13 @@ on_verify_completed (FpDevice *dev, GAsyncResult *res, void *user_data)
if (!fp_device_verify_finish (dev, res, &match, &print, &error)) if (!fp_device_verify_finish (dev, res, &match, &print, &error))
{ {
g_warning ("Failed to verify print: %s", error->message); g_warning ("Failed to verify print: %s", error->message);
verify_data->ret_value = EXIT_FAILURE;
if (error->domain != FP_DEVICE_RETRY)
{
verify_quit (dev, verify_data); verify_quit (dev, verify_data);
return; return;
} }
if (print && fp_device_supports_capture (dev) &&
print_image_save (print, "verify.pgm"))
g_print ("Print image saved as verify.pgm\n");
if (match)
{
g_print ("MATCH!\n");
verify_data->ret_value = EXIT_SUCCESS;
}
else
{
g_print ("NO MATCH!\n");
verify_data->ret_value = EXIT_FAILURE;
} }
g_print ("Verify again? [Y/n]? "); g_print ("Verify again? [Y/n]? ");
@ -120,6 +110,8 @@ static void
on_match_cb (FpDevice *dev, FpPrint *match, FpPrint *print, on_match_cb (FpDevice *dev, FpPrint *match, FpPrint *print,
gpointer user_data, GError *error) gpointer user_data, GError *error)
{ {
VerifyData *verify_data = user_data;
if (error) if (error)
{ {
g_warning ("Match report: Finger not matched, retry error reported: %s", g_warning ("Match report: Finger not matched, retry error reported: %s",
@ -127,10 +119,16 @@ on_match_cb (FpDevice *dev, FpPrint *match, FpPrint *print,
return; return;
} }
if (print && fp_device_supports_capture (dev) &&
print_image_save (print, "verify.pgm"))
g_print ("Print image saved as verify.pgm\n");
if (match) if (match)
{ {
char date_str[128]; char date_str[128];
verify_data->ret_value = EXIT_SUCCESS;
g_date_strftime (date_str, G_N_ELEMENTS (date_str), "%Y-%m-%d\0", g_date_strftime (date_str, G_N_ELEMENTS (date_str), "%Y-%m-%d\0",
fp_print_get_enroll_date (match)); fp_print_get_enroll_date (match));
g_debug ("Match report: device %s matched finger %s successifully " g_debug ("Match report: device %s matched finger %s successifully "
@ -139,10 +137,13 @@ on_match_cb (FpDevice *dev, FpPrint *match, FpPrint *print,
finger_to_string (fp_print_get_finger (match)), finger_to_string (fp_print_get_finger (match)),
fp_print_get_description (match), date_str, fp_print_get_description (match), date_str,
fp_print_get_username (match)); fp_print_get_username (match));
g_print ("MATCH!\n");
} }
else else
{ {
g_debug ("Match report: Finger not matched"); g_debug ("Match report: Finger not matched");
g_print ("NO MATCH!\n");
} }
} }