67 lines
2.6 KiB
Diff
67 lines
2.6 KiB
Diff
From 4c0a89257c713587bf570298a9cefdb6f5f0e302 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
|
|
Date: Wed, 27 Nov 2019 19:14:35 +0100
|
|
Subject: [PATCH 027/181] examples: Handle the cases where the print date is
|
|
not set
|
|
|
|
---
|
|
examples/manage-prints.c | 17 +++++++++++------
|
|
examples/verify.c | 11 ++++++++---
|
|
2 files changed, 19 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/examples/manage-prints.c b/examples/manage-prints.c
|
|
index b865af7..7bbbc5e 100644
|
|
--- a/examples/manage-prints.c
|
|
+++ b/examples/manage-prints.c
|
|
@@ -153,14 +153,19 @@ on_list_completed (FpDevice *dev,
|
|
for (i = 0; i < prints->len; ++i)
|
|
{
|
|
FpPrint * print = prints->pdata[i];
|
|
+ const GDate *date = fp_print_get_enroll_date (print);
|
|
|
|
- g_date_strftime (buf, G_N_ELEMENTS (buf), "%Y-%m-%d",
|
|
- fp_print_get_enroll_date (print));
|
|
- g_print ("[%d] Print of %s finger for username %s, enrolled "
|
|
- "on %s. Description: %s\n", i + 1,
|
|
+ g_print ("[%d] Print of %s finger for username %s", i + 1,
|
|
finger_to_string (fp_print_get_finger (print)),
|
|
- fp_print_get_username (print), buf,
|
|
- fp_print_get_description (print));
|
|
+ fp_print_get_username (print));
|
|
+
|
|
+ if (date)
|
|
+ {
|
|
+ g_date_strftime (buf, G_N_ELEMENTS (buf), "%Y-%m-%d\0", date);
|
|
+ g_print (", enrolled on %s", buf);
|
|
+ }
|
|
+
|
|
+ g_print (". Description: %s\n", fp_print_get_description (print));
|
|
}
|
|
|
|
if (prints->len)
|
|
diff --git a/examples/verify.c b/examples/verify.c
|
|
index 4e1c988..1249dce 100644
|
|
--- a/examples/verify.c
|
|
+++ b/examples/verify.c
|
|
@@ -127,9 +127,14 @@ on_list_completed (FpDevice *dev, GAsyncResult *res, gpointer user_data)
|
|
if (fp_print_get_finger (print) == verify_data->finger &&
|
|
g_strcmp0 (fp_print_get_username (print), g_get_user_name ()) == 0)
|
|
{
|
|
- if (!verify_print ||
|
|
- (g_date_compare (fp_print_get_enroll_date (print),
|
|
- fp_print_get_enroll_date (verify_print)) >= 0))
|
|
+ const GDate *verify_print_date = NULL;
|
|
+ const GDate *print_date = fp_print_get_enroll_date (print);
|
|
+
|
|
+ if (verify_print)
|
|
+ verify_print_date = fp_print_get_enroll_date (verify_print);
|
|
+
|
|
+ if (!verify_print || !print_date || !verify_print_date ||
|
|
+ g_date_compare (print_date, verify_print_date) >= 0)
|
|
verify_print = print;
|
|
}
|
|
}
|
|
--
|
|
2.24.1
|
|
|