]> git.notmuchmail.org Git - notmuch/commitdiff
crypto: Avoid explicit handling of GMimeCryptoContext in gmime 3
authorDavid Bremner <david@tethera.net>
Sat, 15 Jul 2017 23:01:45 +0000 (01:01 +0200)
committerDavid Bremner <david@tethera.net>
Sun, 16 Jul 2017 00:43:08 +0000 (21:43 -0300)
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
mime-node.c

index 3e8ce7ca07740b3aea9491dee18c7859b8ac4df5..cc45b88521ec7a19efd38bd8f4a30efbb6056bb7 100644 (file)
--- 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
index bc41b7523c486f72f48b3b132e9241454c568857..bb0870d024ad1f82127e37eeb564578bc9a2695a 100644 (file)
@@ -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) {