Blame SOURCES/0027-examples-Handle-the-cases-where-the-print-date-is-no.patch

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