]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-reply.c
emacs: Escape tag queries suggested by tab completion
[notmuch] / notmuch-reply.c
index 11f269f4c984938aa913f20ff2ab2e99a843a403..e60a264b5d30acf8cec96412f17e150789e43c5c 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "notmuch-client.h"
 #include "gmime-filter-headers.h"
+#include "sprinter.h"
 
 static void
 show_reply_headers (GMimeMessage *message)
@@ -575,8 +576,7 @@ notmuch_reply_format_default(void *ctx,
        g_object_unref (G_OBJECT (reply));
        reply = NULL;
 
-       if (mime_node_open (ctx, message, params->crypto.gpgctx, params->crypto.decrypt,
-                           &root) == NOTMUCH_STATUS_SUCCESS) {
+       if (mime_node_open (ctx, message, &(params->crypto), &root) == NOTMUCH_STATUS_SUCCESS) {
            format_part_reply (root);
            talloc_free (root);
        }
@@ -597,6 +597,7 @@ notmuch_reply_format_json(void *ctx,
     notmuch_messages_t *messages;
     notmuch_message_t *message;
     mime_node_t *node;
+    sprinter_t *sp;
 
     if (notmuch_query_count_messages (query) != 1) {
        fprintf (stderr, "Error: search term did not match precisely one message.\n");
@@ -605,27 +606,28 @@ notmuch_reply_format_json(void *ctx,
 
     messages = notmuch_query_search_messages (query);
     message = notmuch_messages_get (messages);
-    if (mime_node_open (ctx, message, params->crypto.gpgctx, params->crypto.decrypt,
-                       &node) != NOTMUCH_STATUS_SUCCESS)
+    if (mime_node_open (ctx, message, &(params->crypto), &node) != NOTMUCH_STATUS_SUCCESS)
        return 1;
 
     reply = create_reply_message (ctx, config, message, reply_all);
     if (!reply)
        return 1;
 
+    sp = sprinter_json_create (ctx, stdout);
+    sp->begin_map (sp);
+
     /* The headers of the reply message we've created */
-    printf ("{\"reply-headers\": ");
-    format_headers_json (ctx, reply, TRUE);
+    sp->map_key (sp, "reply-headers");
+    format_headers_json (sp, reply, TRUE);
     g_object_unref (G_OBJECT (reply));
     reply = NULL;
 
     /* Start the original */
-    printf (", \"original\": ");
-
-    format_part_json (ctx, node, TRUE);
+    sp->map_key (sp, "original");
+    format_part_json (ctx, sp, node, TRUE, TRUE);
 
     /* End */
-    printf ("}\n");
+    sp->end (sp);
     notmuch_message_destroy (message);
 
     return 0;
@@ -709,6 +711,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
     notmuch_show_params_t params = {
        .part = -1,
        .crypto = {
+           .verify = FALSE,
            .decrypt = FALSE
        }
     };
@@ -742,25 +745,6 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
     else
        reply_format_func = notmuch_reply_format_default;
 
-    if (params.crypto.decrypt) {
-#ifdef GMIME_ATLEAST_26
-       /* TODO: GMimePasswordRequestFunc */
-       params.crypto.gpgctx = g_mime_gpg_context_new (NULL, "gpg");
-#else
-       GMimeSession* session = g_object_new (g_mime_session_get_type(), NULL);
-       params.crypto.gpgctx = g_mime_gpg_context_new (session, "gpg");
-#endif
-       if (params.crypto.gpgctx) {
-           g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.crypto.gpgctx, FALSE);
-       } else {
-           params.crypto.decrypt = FALSE;
-           fprintf (stderr, "Failed to construct gpg context.\n");
-       }
-#ifndef GMIME_ATLEAST_26
-       g_object_unref (session);
-#endif
-    }
-
     config = notmuch_config_open (ctx, NULL, NULL);
     if (config == NULL)
        return 1;