From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 4F0406DE264B for ; Sat, 15 Jul 2017 16:01:55 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[AWL=0.000] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id f52upyQ3mr7N for ; Sat, 15 Jul 2017 16:01:54 -0700 (PDT) Received: from che.mayfirst.org (che.mayfirst.org [162.247.75.118]) by arlo.cworth.org (Postfix) with ESMTP id 3399D6DE261A for ; Sat, 15 Jul 2017 16:01:52 -0700 (PDT) Received: from fifthhorseman.net (38.200.broadband6.iol.cz [88.101.200.38]) by che.mayfirst.org (Postfix) with ESMTPSA id 2B944F99F; Sat, 15 Jul 2017 19:01:51 -0400 (EDT) Received: by fifthhorseman.net (Postfix, from userid 1000) id 03F1520DC1; Sun, 16 Jul 2017 01:01:47 +0200 (CEST) From: Daniel Kahn Gillmor To: Notmuch Mail Subject: [PATCH v2 3/4] crypto: Avoid explicit handling of GMimeCryptoContext in gmime 3 Date: Sun, 16 Jul 2017 01:01:45 +0200 Message-Id: <20170715230146.12695-3-dkg@fifthhorseman.net> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170715230146.12695-1-dkg@fifthhorseman.net> References: <87mv85qpyw.fsf@fifthhorseman.net> <20170715230146.12695-1-dkg@fifthhorseman.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 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: Sat, 15 Jul 2017 23:01:55 -0000 From: David Bremner gmime 3.0 knows how to select the correct GMimeCryptoContext automatically, so a bunch of the code in notmuch can be dropped in that case. The #ifdef removal of the crypto stuff is better than #define aliasing in gmime-extra.h for this stuff. When built against gmime 3.0: * it reduces compiled code, and * it avoids initializing unused gpgme contexts (based on a patch from dkg) --- crypto.c | 8 +++++++- mime-node.c | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/crypto.c b/crypto.c index 3e8ce7ca..cc45b885 100644 --- a/crypto.c +++ b/crypto.c @@ -19,7 +19,7 @@ */ #include "notmuch-client.h" - +#if (GMIME_MAJOR_VERSION < 3) /* Create a GPG context (GMime 2.6) */ static notmuch_crypto_context_t * create_gpg_context (notmuch_crypto_t *crypto) @@ -132,3 +132,9 @@ notmuch_crypto_cleanup (notmuch_crypto_t *crypto) return 0; } +#else +int notmuch_crypto_cleanup (unused(notmuch_crypto_t *crypto)) +{ + return 0; +} +#endif diff --git a/mime-node.c b/mime-node.c index bc41b752..bb0870d0 100644 --- a/mime-node.c +++ b/mime-node.c @@ -240,6 +240,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part) return NULL; } +#if (GMIME_MAJOR_VERSION < 3) if ((GMIME_IS_MULTIPART_ENCRYPTED (part) && node->ctx->crypto->decrypt) || (GMIME_IS_MULTIPART_SIGNED (part) && node->ctx->crypto->verify)) { GMimeContentType *content_type = g_mime_object_get_content_type (part); @@ -248,6 +249,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part) if (!cryptoctx) return NULL; } +#endif /* Handle PGP/MIME parts */ if (GMIME_IS_MULTIPART_ENCRYPTED (part) && node->ctx->crypto->decrypt) { -- 2.13.2