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 CE57E6DE2EA0 for ; Sat, 15 Jul 2017 11:57:57 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.001 X-Spam-Level: X-Spam-Status: No, score=-0.001 tagged_above=-999 required=5 tests=[AWL=0.010, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] 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 QPZ3P5mhEhbu for ; Sat, 15 Jul 2017 11:57:54 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id A24E46DE2B3A for ; Sat, 15 Jul 2017 11:57:54 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1dWSD5-0005xI-5h; Sat, 15 Jul 2017 14:54:35 -0400 Received: (nullmailer pid 17688 invoked by uid 1000); Sat, 15 Jul 2017 18:57:49 -0000 From: David Bremner To: Daniel Kahn Gillmor , Notmuch Mail Subject: [PATCH 3/4] crypto: Avoid explicit handling of GMimeCryptoContext in gmime 3 Date: Sat, 15 Jul 2017 15:57:43 -0300 Message-Id: <20170715185744.17640-3-david@tethera.net> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170715185744.17640-1-david@tethera.net> References: <20170714131202.24966-3-dkg@fifthhorseman.net> <20170715185744.17640-1-david@tethera.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 18:57:57 -0000 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 | 3 ++- mime-node.c | 2 ++ notmuch-reply.c | 2 ++ notmuch-show.c | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/crypto.c b/crypto.c index 3e8ce7ca..05c05a47 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,4 @@ notmuch_crypto_cleanup (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) { diff --git a/notmuch-reply.c b/notmuch-reply.c index 40201b80..4df29b82 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -759,7 +759,9 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[]) if (do_reply (config, query, ¶ms, format, reply_all) != 0) return EXIT_FAILURE; +#if (GMIME_MAJOR_VERSION < 3) notmuch_crypto_cleanup (¶ms.crypto); +#endif notmuch_query_destroy (query); notmuch_database_destroy (notmuch); diff --git a/notmuch-show.c b/notmuch-show.c index 74e77249..4feba07b 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -1241,7 +1241,9 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) g_mime_stream_flush (params.out_stream); g_object_unref (params.out_stream); +#if (GMIME_MAJOR_VERSION < 3) notmuch_crypto_cleanup (¶ms.crypto); +#endif notmuch_query_destroy (query); notmuch_database_destroy (notmuch); -- 2.13.2