gpg: Also show when the most recently signed message was observed.
authorNeal H. Walfield <neal@g10code.com>
Tue, 3 Nov 2015 15:26:25 +0000 (16:26 +0100)
committerNeal H. Walfield <neal@g10code.com>
Tue, 3 Nov 2015 15:33:01 +0000 (16:33 +0100)
* g10/tofu.c (show_statistics): Also show when the most recently
signed message was observed.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
Suggested-by: MFPA <2014-667rhzu3dc-lists-groups@riseup.net>
g10/tofu.c

index 06183ed..4dcaa11 100644 (file)
@@ -2377,6 +2377,7 @@ show_statistics (struct dbs *dbs, const char *fingerprint,
       char *tail = NULL;
       signed long messages;
       signed long first_seen_ago;
+      signed long most_recent_seen_ago;
 
       assert (strlist_length (strlist) == 3);
 
@@ -2392,7 +2393,10 @@ show_statistics (struct dbs *dbs, const char *fingerprint,
 
       if (messages == 0 && *strlist->next->d == '\0')
        /* min(NULL) => NULL => "".  */
-       first_seen_ago = -1;
+        {
+          first_seen_ago = -1;
+          most_recent_seen_ago = -1;
+        }
       else
        {
          errno = 0;
@@ -2405,6 +2409,17 @@ show_statistics (struct dbs *dbs, const char *fingerprint,
                         strlist->next->d, strerror (errno));
              first_seen_ago = 0;
            }
+
+         errno = 0;
+         most_recent_seen_ago = strtol (strlist->next->next->d, &tail, 0);
+         if (errno || *tail != '\0')
+           /* Abort.  */
+           {
+             log_debug ("%s:%d: Couldn't convert %s (most_recent_seen) to an int: %s.\n",
+                        __func__, __LINE__,
+                        strlist->next->next->d, strerror (errno));
+             most_recent_seen_ago = 0;
+           }
        }
 
       if (messages == -1 || first_seen_ago == 0)
@@ -2428,6 +2443,8 @@ show_statistics (struct dbs *dbs, const char *fingerprint,
          else
            {
               char *first_seen_ago_str = time_ago_str (first_seen_ago);
+              char *most_recent_seen_ago_str =
+                time_ago_str (most_recent_seen_ago);
 
              es_fprintf (fp,
                          _("Verified %ld messages signed by \"%s\""
@@ -2436,8 +2453,13 @@ show_statistics (struct dbs *dbs, const char *fingerprint,
                          fingerprint_pp, tofu_policy_str (policy),
                           first_seen_ago_str);
 
+              if (messages > 1)
+                es_fprintf (fp,
+                            _("  The most recent message was verified %s ago."),
+                            most_recent_seen_ago_str);
 
               xfree (first_seen_ago_str);
+              xfree (most_recent_seen_ago_str);
             }
 
          es_fputc (0, fp);