[PATCH v2 3/5] cli: modify mime_node_context to use the new notmuch_crypto_t
authorJameson Graef Rollins <jrollins@finestructure.net>
Fri, 18 May 2012 17:32:35 +0000 (10:32 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:13 +0000 (09:47 -0800)
ac/e61fb7492e7a7f5aa6530865a3c2d0a90c4f5f [new file with mode: 0644]

diff --git a/ac/e61fb7492e7a7f5aa6530865a3c2d0a90c4f5f b/ac/e61fb7492e7a7f5aa6530865a3c2d0a90c4f5f
new file mode 100644 (file)
index 0000000..1142a8b
--- /dev/null
@@ -0,0 +1,140 @@
+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 0B773431FBC\r
+       for <notmuch@notmuchmail.org>; Fri, 18 May 2012 10:32:51 -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 yx-xTarr8auM for <notmuch@notmuchmail.org>;\r
+       Fri, 18 May 2012 10:32:49 -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 B7FED431FC0\r
+       for <notmuch@notmuchmail.org>; Fri, 18 May 2012 10:32:46 -0700 (PDT)\r
+Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
+       by fire-doxen-postvirus (Postfix) with ESMTP id 492D1328090\r
+       for <notmuch@notmuchmail.org>; Fri, 18 May 2012 10:32:44 -0700 (PDT)\r
+X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new\r
+Received: from finestructure.net (cpe-98-14-81-93.nyc.res.rr.com\r
+ [98.14.81.93])        (Authenticated sender: jrollins)        by fire-doxen-submit\r
+ (Postfix) with ESMTP id DF6ED32807A   for <notmuch@notmuchmail.org>; Fri, 18\r
+ May 2012 10:32:41 -0700 (PDT)\r
+Received: by finestructure.net (Postfix, from userid 1000)\r
+       id 45C7F61B; Fri, 18 May 2012 10:32:40 -0700 (PDT)\r
+From: Jameson Graef Rollins <jrollins@finestructure.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH v2 3/5] cli: modify mime_node_context to use the new\r
+       notmuch_crypto_t\r
+Date: Fri, 18 May 2012 10:32:35 -0700\r
+Message-Id: <1337362357-31281-4-git-send-email-jrollins@finestructure.net>\r
+X-Mailer: git-send-email 1.7.10\r
+In-Reply-To: <1337362357-31281-3-git-send-email-jrollins@finestructure.net>\r
+References: <1337362357-31281-1-git-send-email-jrollins@finestructure.net>\r
+       <1337362357-31281-2-git-send-email-jrollins@finestructure.net>\r
+       <1337362357-31281-3-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: Fri, 18 May 2012 17:32:51 -0000\r
+\r
+This simplifies some more interfaces and gets rid of another #ifdef.\r
+---\r
+ mime-node.c |   22 ++++++++--------------\r
+ 1 file changed, 8 insertions(+), 14 deletions(-)\r
+\r
+diff --git a/mime-node.c b/mime-node.c\r
+index 183ff5d..3dda900 100644\r
+--- a/mime-node.c\r
++++ b/mime-node.c\r
+@@ -33,12 +33,7 @@ typedef struct mime_node_context {\r
+     GMimeMessage *mime_message;\r
\r
+     /* Context provided by the caller. */\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
+ } mime_node_context_t;\r
\r
+ static int\r
+@@ -113,8 +108,7 @@ mime_node_open (const void *ctx, notmuch_message_t *message,\r
+       goto DONE;\r
+     }\r
\r
+-    mctx->cryptoctx = crypto->gpgctx;\r
+-    mctx->decrypt = crypto->decrypt;\r
++    mctx->crypto = crypto;\r
\r
+     /* Create the root node */\r
+     root->part = GMIME_OBJECT (mctx->mime_message);\r
+@@ -190,7 +184,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)\r
\r
+     /* Handle PGP/MIME parts */\r
+     if (GMIME_IS_MULTIPART_ENCRYPTED (part)\r
+-      && node->ctx->cryptoctx && node->ctx->decrypt) {\r
++      && node->ctx->crypto->gpgctx && node->ctx->crypto->decrypt) {\r
+       if (node->nchildren != 2) {\r
+           /* this violates RFC 3156 section 4, so we won't bother with it. */\r
+           fprintf (stderr, "Error: %d part(s) for a multipart/encrypted "\r
+@@ -203,10 +197,10 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)\r
+ #ifdef GMIME_ATLEAST_26\r
+           GMimeDecryptResult *decrypt_result = NULL;\r
+           node->decrypted_child = g_mime_multipart_encrypted_decrypt\r
+-              (encrypteddata, node->ctx->cryptoctx, &decrypt_result, &err);\r
++              (encrypteddata, node->ctx->crypto->gpgctx, &decrypt_result, &err);\r
+ #else\r
+           node->decrypted_child = g_mime_multipart_encrypted_decrypt\r
+-              (encrypteddata, node->ctx->cryptoctx, &err);\r
++              (encrypteddata, node->ctx->crypto->gpgctx, &err);\r
+ #endif\r
+           if (node->decrypted_child) {\r
+               node->decrypt_success = node->verify_attempted = TRUE;\r
+@@ -224,7 +218,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)\r
+                        (err ? err->message : "no error explanation given"));\r
+           }\r
+       }\r
+-    } else if (GMIME_IS_MULTIPART_SIGNED (part) && node->ctx->cryptoctx) {\r
++    } else if (GMIME_IS_MULTIPART_SIGNED (part) && node->ctx->crypto->gpgctx) {\r
+       if (node->nchildren != 2) {\r
+           /* this violates RFC 3156 section 5, so we won't bother with it. */\r
+           fprintf (stderr, "Error: %d part(s) for a multipart/signed message "\r
+@@ -233,7 +227,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)\r
+       } else {\r
+ #ifdef GMIME_ATLEAST_26\r
+           node->sig_list = g_mime_multipart_signed_verify\r
+-              (GMIME_MULTIPART_SIGNED (part), node->ctx->cryptoctx, &err);\r
++              (GMIME_MULTIPART_SIGNED (part), node->ctx->crypto->gpgctx, &err);\r
+           node->verify_attempted = TRUE;\r
\r
+           if (!node->sig_list)\r
+@@ -249,7 +243,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)\r
+            * In GMime 2.6, they're both non-const, so we'll be able\r
+            * to clean up this asymmetry. */\r
+           GMimeSignatureValidity *sig_validity = g_mime_multipart_signed_verify\r
+-              (GMIME_MULTIPART_SIGNED (part), node->ctx->cryptoctx, &err);\r
++              (GMIME_MULTIPART_SIGNED (part), node->ctx->crypto.gpgctx, &err);\r
+           node->verify_attempted = TRUE;\r
+           node->sig_validity = sig_validity;\r
+           if (sig_validity) {\r
+-- \r
+1.7.10\r
+\r