Re: [PATCH 3/6] cli: modify mime_node_open to take crypto struct as argument
authorAustin Clements <amdragon@MIT.EDU>
Thu, 17 May 2012 22:26:47 +0000 (18:26 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:11 +0000 (09:47 -0800)
ee/c16599724cd58f6c6a82e5e8701aaafa429d30 [new file with mode: 0644]

diff --git a/ee/c16599724cd58f6c6a82e5e8701aaafa429d30 b/ee/c16599724cd58f6c6a82e5e8701aaafa429d30
new file mode 100644 (file)
index 0000000..7c7ce07
--- /dev/null
@@ -0,0 +1,194 @@
+Return-Path: <amdragon@mit.edu>\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 77C3F431FAF\r
+       for <notmuch@notmuchmail.org>; Thu, 17 May 2012 15:26:52 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 BZE9yOo0wKQv for <notmuch@notmuchmail.org>;\r
+       Thu, 17 May 2012 15:26:51 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU\r
+       [18.7.68.37])\r
+       by olra.theworths.org (Postfix) with ESMTP id A261C431FAE\r
+       for <notmuch@notmuchmail.org>; Thu, 17 May 2012 15:26:51 -0700 (PDT)\r
+X-AuditID: 12074425-b7f966d0000008b6-89-4fb57b2ade8f\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+       by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 54.B9.02230.A2B75BF4; Thu, 17 May 2012 18:26:50 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q4HMQn9e030332; \r
+       Thu, 17 May 2012 18:26:50 -0400\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q4HMQmFc010903\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Thu, 17 May 2012 18:26:49 -0400 (EDT)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1SV99j-0003Uc-Q4; Thu, 17 May 2012 18:26:47 -0400\r
+Date: Thu, 17 May 2012 18:26:47 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Jameson Graef Rollins <jrollins@finestructure.net>\r
+Subject: Re: [PATCH 3/6] cli: modify mime_node_open to take crypto struct as\r
+       argument\r
+Message-ID: <20120517222647.GP11804@mit.edu>\r
+References: <1337205359-2444-1-git-send-email-jrollins@finestructure.net>\r
+       <1337205359-2444-2-git-send-email-jrollins@finestructure.net>\r
+       <1337205359-2444-3-git-send-email-jrollins@finestructure.net>\r
+       <1337205359-2444-4-git-send-email-jrollins@finestructure.net>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <1337205359-2444-4-git-send-email-jrollins@finestructure.net>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFuplleLIzCtJLcpLzFFi42IR4hTV1tWq3upvcPyztMWefV4W12/OZHZg\r
+       8rh7msvj2apbzAFMUVw2Kak5mWWpRfp2CVwZ2xsvMRU8Vqro2X2BrYHxqHQXIyeHhICJxNOn\r
+       HSwQtpjEhXvr2UBsIYF9jBLNLy26GLmA7A2MEve3v2WDcE4ySXTcPw7lLGGUuDn9AhNIC4uA\r
+       qsTZ0w2sIDabgIbEtv3LGUFsEQEziZ4vf8BsZgEtia0bP4DZwgLhEutungar5xXQkehZO40V\r
+       Ymgnk8SlG7uZIBKCEidnPmGBab7x7yVQnAPIlpZY/o8DxOQU8JKYvZIZpEJUQEViysltbBMY\r
+       hWYhaZ6FpHkWQvMCRuZVjLIpuVW6uYmZOcWpybrFyYl5ealFuhZ6uZkleqkppZsYQSHN7qK6\r
+       g3HCIaVDjAIcjEo8vAGnNvsLsSaWFVfmHmKU5GBSEuV9UrnVX4gvKT+lMiOxOCO+qDQntfgQ\r
+       owQHs5II7351oBxvSmJlVWpRPkxKmoNFSZxXU+udn5BAemJJanZqakFqEUxWhoNDSYL3G8hQ\r
+       waLU9NSKtMycEoQ0EwcnyHAeoOHfQWp4iwsSc4sz0yHypxh1Of48XHSNUYglLz8vVUqc9wFI\r
+       kQBIUUZpHtwcWCp6xSgO9JYwL08VUBUPMI3BTXoFtIQJaElZ7iaQJSWJCCmpBkYzBS5eRkYX\r
+       pr3hnO+EdQ4fPj+PtyF9ztbls5y/7svpjNDduuXGvK37Pmqe/2WwmF9/1SrBKds3KHVZ5Grc\r
+       9Qh9LOS03K7IYy37XbcWO2W5wMklYt5bLgZ92n+1hvNvc2/H2Xh3jcgK1hl5EkFxl0/f7HH9\r
+       7Py6y6Bs91G9BvE9G4/HTng+5ZoSS3FGoqEWc1FxIgAch6QCIAMAAA==\r
+Cc: Notmuch Mail <notmuch@notmuchmail.org>\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: Thu, 17 May 2012 22:26:52 -0000\r
+\r
+Quoth Jameson Graef Rollins on May 16 at  2:55 pm:\r
+> Again, for interface simplification and getting rid of more #ifdefs.\r
+> ---\r
+>  mime-node.c      |   10 ++--------\r
+>  notmuch-client.h |   14 +++++---------\r
+>  notmuch-reply.c  |    6 ++----\r
+>  notmuch-show.c   |    3 +--\r
+>  4 files changed, 10 insertions(+), 23 deletions(-)\r
+> \r
+> diff --git a/mime-node.c b/mime-node.c\r
+> index 79a3654..4faeffc 100644\r
+> --- a/mime-node.c\r
+> +++ b/mime-node.c\r
+> @@ -56,12 +56,7 @@ _mime_node_context_free (mime_node_context_t *res)\r
+>  \r
+>  notmuch_status_t\r
+>  mime_node_open (const void *ctx, notmuch_message_t *message,\r
+> -#ifdef GMIME_ATLEAST_26\r
+> -            GMimeCryptoContext *cryptoctx,\r
+> -#else\r
+> -            GMimeCipherContext *cryptoctx,\r
+> -#endif\r
+> -            notmuch_bool_t decrypt, mime_node_t **root_out)\r
+> +            notmuch_crypto_t *crypto, mime_node_t **root_out)\r
+>  {\r
+>      const char *filename = notmuch_message_get_filename (message);\r
+>      mime_node_context_t *mctx;\r
+> @@ -113,8 +108,7 @@ mime_node_open (const void *ctx, notmuch_message_t *message,\r
+>      goto DONE;\r
+>      }\r
+>  \r
+> -    mctx->crypto.gpgctx = cryptoctx;\r
+> -    mctx->crypto.decrypt = decrypt;\r
+> +    mctx->crypto = *crypto;\r
+\r
+I think you want to store the notmuch_crypto_t* pointer in the\r
+mime_node_t, rather than copying the value.  This doesn't matter so\r
+much at this point, but when you later start lazily constructing the\r
+cyrpto context, storing it by value will force you to lazily\r
+initialize it separately potentially for every mime_node_t instance.\r
+\r
+>  \r
+>      /* Create the root node */\r
+>      root->part = GMIME_OBJECT (mctx->mime_message);\r
+> diff --git a/notmuch-client.h b/notmuch-client.h\r
+> index 2ad24cf..d86fab3 100644\r
+> --- a/notmuch-client.h\r
+> +++ b/notmuch-client.h\r
+> @@ -345,9 +345,10 @@ struct mime_node {\r
+>  };\r
+>  \r
+>  /* Construct a new MIME node pointing to the root message part of\r
+> - * message.  If cryptoctx is non-NULL, it will be used to verify\r
+> - * signatures on any child parts.  If decrypt is true, then cryptoctx\r
+> - * will additionally be used to decrypt any encrypted child parts.\r
+> + * message.  If crypto.gpgctx is non-NULL, it will be used to verify\r
+> + * signatures on any child parts.  If crypto.decrypt is true, then\r
+> + * crypto.gpgctx will additionally be used to decrypt any encrypted\r
+> + * child parts.\r
+>   *\r
+>   * Return value:\r
+>   *\r
+> @@ -359,12 +360,7 @@ struct mime_node {\r
+>   */\r
+>  notmuch_status_t\r
+>  mime_node_open (const void *ctx, notmuch_message_t *message,\r
+> -#ifdef GMIME_ATLEAST_26\r
+> -            GMimeCryptoContext *cryptoctx,\r
+> -#else\r
+> -            GMimeCipherContext *cryptoctx,\r
+> -#endif\r
+> -            notmuch_bool_t decrypt, mime_node_t **node_out);\r
+> +            notmuch_crypto_t *crypto, mime_node_t **node_out);\r
+>  \r
+>  /* Return a new MIME node for the requested child part of parent.\r
+>   * parent will be used as the talloc context for the returned child\r
+> diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+> index ed87899..6662adb 100644\r
+> --- a/notmuch-reply.c\r
+> +++ b/notmuch-reply.c\r
+> @@ -544,8 +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, crypto->gpgctx, crypto->decrypt,\r
+> -                        &root) == NOTMUCH_STATUS_SUCCESS) {\r
+> +    if (mime_node_open (ctx, message, crypto, &root) == NOTMUCH_STATUS_SUCCESS) {\r
+>          format_part_reply (root);\r
+>          talloc_free (root);\r
+>      }\r
+> @@ -574,8 +573,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, crypto->gpgctx, crypto->decrypt,\r
+> -                    &node) != NOTMUCH_STATUS_SUCCESS)\r
+> +    if (mime_node_open (ctx, message, crypto, &node) != NOTMUCH_STATUS_SUCCESS)\r
+>      return 1;\r
+>  \r
+>      reply = create_reply_message (ctx, config, message, reply_all);\r
+> diff --git a/notmuch-show.c b/notmuch-show.c\r
+> index d254179..8b4d308 100644\r
+> --- a/notmuch-show.c\r
+> +++ b/notmuch-show.c\r
+> @@ -810,8 +810,7 @@ show_message (void *ctx,\r
+>      mime_node_t *root, *part;\r
+>      notmuch_status_t status;\r
+>  \r
+> -    status = mime_node_open (local, message, params->crypto.gpgctx,\r
+> -                         params->crypto.decrypt, &root);\r
+> +    status = mime_node_open (local, message, &(params->crypto), &root);\r
+>      if (status)\r
+>      goto DONE;\r
+>      part = mime_node_seek_dfs (root, (params->part < 0 ? 0 : params->part));\r