]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-show.c
lib: consider all instances of Delivered-To header
[notmuch] / notmuch-show.c
index b6b53991c652688e5d8108e357bbe8146623dded..c8f1a40f2e2803bfa93db1f5eb58132ddbd8b230 100644 (file)
@@ -475,6 +475,11 @@ format_part_sigstatus_sprinter (sprinter_t *sp, GMimeSignatureList *siglist)
                    sp->map_key (sp, "userid");
                    sp->string (sp, uid);
                }
+               const char *email = g_mime_certificate_get_valid_email (certificate);
+               if (email) {
+                   sp->map_key (sp, "email");
+                   sp->string (sp, email);
+               }
            }
        } else if (certificate) {
            const char *key_id = g_mime_certificate_get_fpr16 (certificate);
@@ -1225,10 +1230,8 @@ static const notmuch_show_format_t *formatters[] = {
 };
 
 int
-notmuch_show_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch),
-                     int argc, char *argv[])
+notmuch_show_command (notmuch_database_t *notmuch, int argc, char *argv[])
 {
-    notmuch_database_t *notmuch;
     notmuch_query_t *query;
     char *query_string;
     int opt_index, ret;
@@ -1245,9 +1248,14 @@ notmuch_show_command (notmuch_config_t *config, unused(notmuch_database_t *notmu
     bool entire_thread_set = false;
     bool single_message;
     bool unthreaded = FALSE;
-    char *status_string = NULL;
+    notmuch_status_t status;
+    int sort = NOTMUCH_SORT_NEWEST_FIRST;
 
     notmuch_opt_desc_t options[] = {
+       { .opt_keyword = &sort, .name = "sort", .keywords =
+             (notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST },
+                                     { "newest-first", NOTMUCH_SORT_NEWEST_FIRST },
+                                     { 0, 0 } } },
        { .opt_keyword = &format, .name = "format", .keywords =
              (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
                                      { "text", NOTMUCH_FORMAT_TEXT },
@@ -1336,26 +1344,15 @@ notmuch_show_command (notmuch_config_t *config, unused(notmuch_database_t *notmu
                 "Warning: --include-html only implemented for format=text, format=json and format=sexp\n");
     }
 
-    notmuch_database_mode_t mode = NOTMUCH_DATABASE_MODE_READ_ONLY;
-
-    if (params.crypto.decrypt == NOTMUCH_DECRYPT_TRUE)
-       mode = NOTMUCH_DATABASE_MODE_READ_WRITE;
-    if (notmuch_database_open_with_config (NULL,
-                                          mode,
-                                          _notmuch_config_get_path (config),
-                                          NULL,
-                                          &notmuch,
-                                          &status_string)) {
-       if (status_string) {
-           fputs (status_string, stderr);
-           free (status_string);
+    if (params.crypto.decrypt == NOTMUCH_DECRYPT_TRUE) {
+       status = notmuch_database_reopen (notmuch, NOTMUCH_DATABASE_MODE_READ_WRITE);
+       if (status) {
+           fprintf (stderr, "Error reopening database for READ_WRITE: %s\n",
+                    notmuch_status_to_string (status));
+           return EXIT_FAILURE;
        }
-
-       return EXIT_FAILURE;
     }
 
-    config = NULL;
-
     notmuch_exit_if_unmatched_db_uuid (notmuch);
 
     query_string = query_string_from_args (notmuch, argc - opt_index, argv + opt_index);
@@ -1375,6 +1372,8 @@ notmuch_show_command (notmuch_config_t *config, unused(notmuch_database_t *notmu
        return EXIT_FAILURE;
     }
 
+    notmuch_query_set_sort (query, sort);
+
     /* Create structure printer. */
     formatter = formatters[format];
     sprinter = formatter->new_sprinter (notmuch, stdout);