--- /dev/null
+Return-Path: <jrollins@finestructure.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 1A338431FB6\r
+ for <notmuch@notmuchmail.org>; Tue, 22 May 2012 18:44:01 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id hHqCh14u+q9e for <notmuch@notmuchmail.org>;\r
+ Tue, 22 May 2012 18:43:57 -0700 (PDT)\r
+Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu\r
+ [131.215.239.19])\r
+ by olra.theworths.org (Postfix) with ESMTP id CAED7431FBC\r
+ for <notmuch@notmuchmail.org>; Tue, 22 May 2012 18:43:56 -0700 (PDT)\r
+Received: from earth-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
+ by earth-doxen-postvirus (Postfix) with ESMTP id 7E49F66E0178\r
+ for <notmuch@notmuchmail.org>; Tue, 22 May 2012 18:43:56 -0700 (PDT)\r
+X-Spam-Scanned: at Caltech-IMSS on earth-doxen by amavisd-new\r
+Received: from finestructure.net (gwave-125.ligo.caltech.edu\r
+ [131.215.114.125]) (Authenticated sender: jrollins) by earth-doxen-submit\r
+ (Postfix) with ESMTP id 541F266E0169 for <notmuch@notmuchmail.org>; Tue, 22\r
+ May 2012 18:43:54 -0700 (PDT)\r
+Received: by finestructure.net (Postfix, from userid 1000)\r
+ id 35CCF1DF; Tue, 22 May 2012 18:43:54 -0700 (PDT)\r
+From: Jameson Graef Rollins <jrollins@finestructure.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH v3 2/6] cli: modify show and reply to use new crypto struct\r
+Date: Tue, 22 May 2012 18:43:46 -0700\r
+Message-Id: <1337737430-21160-3-git-send-email-jrollins@finestructure.net>\r
+X-Mailer: git-send-email 1.7.10\r
+In-Reply-To: <1337737430-21160-2-git-send-email-jrollins@finestructure.net>\r
+References: <1337737430-21160-1-git-send-email-jrollins@finestructure.net>\r
+ <1337737430-21160-2-git-send-email-jrollins@finestructure.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 23 May 2012 01:44:01 -0000\r
+\r
+notmuch_show_params_t is modified to use the new notmuch_crypto_t, and\r
+notmuch-show and notmuch-reply are modified accordingly.\r
+---\r
+ notmuch-client.h | 7 +------\r
+ notmuch-reply.c | 29 ++++++++++++++++-------------\r
+ notmuch-show.c | 30 +++++++++++++++++-------------\r
+ 3 files changed, 34 insertions(+), 32 deletions(-)\r
+\r
+diff --git a/notmuch-client.h b/notmuch-client.h\r
+index 14d1e2f..86c9697 100644\r
+--- a/notmuch-client.h\r
++++ b/notmuch-client.h\r
+@@ -88,12 +88,7 @@ typedef struct notmuch_show_params {\r
+ notmuch_bool_t omit_excluded;\r
+ notmuch_bool_t raw;\r
+ int part;\r
+-#ifdef GMIME_ATLEAST_26\r
+- GMimeCryptoContext* cryptoctx;\r
+-#else\r
+- GMimeCipherContext* cryptoctx;\r
+-#endif\r
+- notmuch_bool_t decrypt;\r
++ notmuch_crypto_t crypto;\r
+ } notmuch_show_params_t;\r
+ \r
+ /* There's no point in continuing when we've detected that we've done\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index 7184a5d..41b18e4 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -544,7 +544,7 @@ notmuch_reply_format_default(void *ctx,\r
+ g_object_unref (G_OBJECT (reply));\r
+ reply = NULL;\r
+ \r
+- if (mime_node_open (ctx, message, params->cryptoctx, params->decrypt,\r
++ if (mime_node_open (ctx, message, params->crypto.gpgctx, params->crypto.decrypt,\r
+ &root) == NOTMUCH_STATUS_SUCCESS) {\r
+ format_part_reply (root);\r
+ talloc_free (root);\r
+@@ -574,7 +574,7 @@ notmuch_reply_format_json(void *ctx,\r
+ \r
+ messages = notmuch_query_search_messages (query);\r
+ message = notmuch_messages_get (messages);\r
+- if (mime_node_open (ctx, message, params->cryptoctx, params->decrypt,\r
++ if (mime_node_open (ctx, message, params->crypto.gpgctx, params->crypto.decrypt,\r
+ &node) != NOTMUCH_STATUS_SUCCESS)\r
+ return 1;\r
+ \r
+@@ -675,7 +675,12 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+ char *query_string;\r
+ int opt_index, ret = 0;\r
+ int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t reply_all);\r
+- notmuch_show_params_t params = { .part = -1 };\r
++ notmuch_show_params_t params = {\r
++ .part = -1,\r
++ .crypto = {\r
++ .decrypt = FALSE\r
++ }\r
++ };\r
+ int format = FORMAT_DEFAULT;\r
+ int reply_all = TRUE;\r
+ \r
+@@ -689,7 +694,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+ (notmuch_keyword_t []){ { "all", TRUE },\r
+ { "sender", FALSE },\r
+ { 0, 0 } } },\r
+- { NOTMUCH_OPT_BOOLEAN, ¶ms.decrypt, "decrypt", 'd', 0 },\r
++ { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.decrypt, "decrypt", 'd', 0 },\r
+ { 0, 0, 0, 0, 0 }\r
+ };\r
+ \r
+@@ -706,18 +711,18 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+ else\r
+ reply_format_func = notmuch_reply_format_default;\r
+ \r
+- if (params.decrypt) {\r
++ if (params.crypto.decrypt) {\r
+ #ifdef GMIME_ATLEAST_26\r
+ /* TODO: GMimePasswordRequestFunc */\r
+- params.cryptoctx = g_mime_gpg_context_new (NULL, "gpg");\r
++ params.crypto.gpgctx = g_mime_gpg_context_new (NULL, "gpg");\r
+ #else\r
+ GMimeSession* session = g_object_new (g_mime_session_get_type(), NULL);\r
+- params.cryptoctx = g_mime_gpg_context_new (session, "gpg");\r
++ params.crypto.gpgctx = g_mime_gpg_context_new (session, "gpg");\r
+ #endif\r
+- if (params.cryptoctx) {\r
+- g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.cryptoctx, FALSE);\r
++ if (params.crypto.gpgctx) {\r
++ g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.crypto.gpgctx, FALSE);\r
+ } else {\r
+- params.decrypt = FALSE;\r
++ params.crypto.decrypt = FALSE;\r
+ fprintf (stderr, "Failed to construct gpg context.\n");\r
+ }\r
+ #ifndef GMIME_ATLEAST_26\r
+@@ -753,11 +758,9 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+ if (reply_format_func (ctx, config, query, ¶ms, reply_all) != 0)\r
+ return 1;\r
+ \r
++ notmuch_crypto_cleanup (¶ms.crypto);\r
+ notmuch_query_destroy (query);\r
+ notmuch_database_destroy (notmuch);\r
+ \r
+- if (params.cryptoctx)\r
+- g_object_unref(params.cryptoctx);\r
+-\r
+ return ret;\r
+ }\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index 95427d4..cc509a6 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -810,8 +810,8 @@ show_message (void *ctx,\r
+ mime_node_t *root, *part;\r
+ notmuch_status_t status;\r
+ \r
+- status = mime_node_open (local, message, params->cryptoctx,\r
+- params->decrypt, &root);\r
++ status = mime_node_open (local, message, params->crypto.gpgctx,\r
++ params->crypto.decrypt, &root);\r
+ if (status)\r
+ goto DONE;\r
+ part = mime_node_seek_dfs (root, (params->part < 0 ? 0 : params->part));\r
+@@ -984,7 +984,13 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+ char *query_string;\r
+ int opt_index, ret;\r
+ const notmuch_show_format_t *format = &format_text;\r
+- notmuch_show_params_t params = { .part = -1, .omit_excluded = TRUE };\r
++ notmuch_show_params_t params = {\r
++ .part = -1,\r
++ .omit_excluded = TRUE,\r
++ .crypto = {\r
++ .decrypt = FALSE\r
++ }\r
++ };\r
+ int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;\r
+ notmuch_bool_t verify = FALSE;\r
+ int exclude = EXCLUDE_TRUE;\r
+@@ -1002,7 +1008,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+ { 0, 0 } } },\r
+ { NOTMUCH_OPT_INT, ¶ms.part, "part", 'p', 0 },\r
+ { NOTMUCH_OPT_BOOLEAN, ¶ms.entire_thread, "entire-thread", 't', 0 },\r
+- { NOTMUCH_OPT_BOOLEAN, ¶ms.decrypt, "decrypt", 'd', 0 },\r
++ { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.decrypt, "decrypt", 'd', 0 },\r
+ { NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 },\r
+ { 0, 0, 0, 0, 0 }\r
+ };\r
+@@ -1047,18 +1053,18 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+ break;\r
+ }\r
+ \r
+- if (params.decrypt || verify) {\r
++ if (params.crypto.decrypt || verify) {\r
+ #ifdef GMIME_ATLEAST_26\r
+ /* TODO: GMimePasswordRequestFunc */\r
+- params.cryptoctx = g_mime_gpg_context_new (NULL, "gpg");\r
++ params.crypto.gpgctx = g_mime_gpg_context_new (NULL, "gpg");\r
+ #else\r
+ GMimeSession* session = g_object_new (g_mime_session_get_type(), NULL);\r
+- params.cryptoctx = g_mime_gpg_context_new (session, "gpg");\r
++ params.crypto.gpgctx = g_mime_gpg_context_new (session, "gpg");\r
+ #endif\r
+- if (params.cryptoctx) {\r
+- g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.cryptoctx, FALSE);\r
++ if (params.crypto.gpgctx) {\r
++ g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.crypto.gpgctx, FALSE);\r
+ } else {\r
+- params.decrypt = FALSE;\r
++ params.crypto.decrypt = FALSE;\r
+ fprintf (stderr, "Failed to construct gpg context.\n");\r
+ }\r
+ #ifndef GMIME_ATLEAST_26\r
+@@ -1115,11 +1121,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+ ret = do_show (ctx, query, format, ¶ms);\r
+ }\r
+ \r
++ notmuch_crypto_cleanup (¶ms.crypto);\r
+ notmuch_query_destroy (query);\r
+ notmuch_database_destroy (notmuch);\r
+ \r
+- if (params.cryptoctx)\r
+- g_object_unref(params.cryptoctx);\r
+-\r
+ return ret;\r
+ }\r
+-- \r
+1.7.10\r
+\r