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