diff options
author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2020-01-17 17:22:15 +0100 |
---|---|---|
committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2020-01-17 19:44:52 +0100 |
commit | cdcc4763250807b63a3af1f8fefb80dd74ea1d74 (patch) | |
tree | b179d001ae781b4a57278a11323111497b092cd5 /examples | |
parent | a87e9c546f44b0369c4855ca728d6e324ae9e505 (diff) |
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.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/verify.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/examples/verify.c b/examples/verify.c index 545539a..acfc9ef 100644 --- a/examples/verify.c +++ b/examples/verify.c @@ -86,23 +86,13 @@ on_verify_completed (FpDevice *dev, GAsyncResult *res, void *user_data) if (!fp_device_verify_finish (dev, res, &match, &print, &error)) { g_warning ("Failed to verify print: %s", error->message); - verify_quit (dev, verify_data); - 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; + + if (error->domain != FP_DEVICE_RETRY) + { + verify_quit (dev, verify_data); + return; + } } g_print ("Verify again? [Y/n]? "); @@ -120,6 +110,8 @@ static void on_match_cb (FpDevice *dev, FpPrint *match, FpPrint *print, gpointer user_data, GError *error) { + VerifyData *verify_data = user_data; + if (error) { 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; } + if (print && fp_device_supports_capture (dev) && + print_image_save (print, "verify.pgm")) + g_print ("Print image saved as verify.pgm\n"); + if (match) { char date_str[128]; + verify_data->ret_value = EXIT_SUCCESS; + g_date_strftime (date_str, G_N_ELEMENTS (date_str), "%Y-%m-%d\0", fp_print_get_enroll_date (match)); 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)), fp_print_get_description (match), date_str, fp_print_get_username (match)); + + g_print ("MATCH!\n"); } else { g_debug ("Match report: Finger not matched"); + g_print ("NO MATCH!\n"); } } |