[PATCH 2/9] Add a lazily-initialized crypto context to notmuch_database_t

Tomi Ollila tomi.ollila at iki.fi
Fri Dec 11 13:55:16 PST 2015


On Thu, Dec 10 2015, Daniel Kahn Gillmor <dkg at fifthhorseman.net> wrote:

> This is in large part a duplicate of parts of crypto.c, but that code
> is in the client (outside the library), and we don't want to entangle
> the libgmime API with the libnotmuch API.
>
> I welcome better proposals for how to share this code explicitly
> between the library and the client.
> ---
>  lib/database-private.h |  1 +
>  lib/database.cc        | 42 ++++++++++++++++++++++++++++++++++++++++++
>  lib/notmuch-private.h  |  8 ++++++++
>  3 files changed, 51 insertions(+)
>
> diff --git a/lib/database-private.h b/lib/database-private.h
> index 3fb10f7..1bf76c5 100644
> --- a/lib/database-private.h
> +++ b/lib/database-private.h
> @@ -171,6 +171,7 @@ struct _notmuch_database {
>       * notmuch_database_new_revision. */
>      unsigned long revision;
>      const char *uuid;
> +    GMimeCryptoContext *gpg_crypto_ctx;
>  
>      Xapian::QueryParser *query_parser;
>      Xapian::TermGenerator *term_gen;
> diff --git a/lib/database.cc b/lib/database.cc
> index 3b342f1..13b0bad 100644
> --- a/lib/database.cc
> +++ b/lib/database.cc
> @@ -995,6 +995,8 @@ notmuch_database_open_verbose (const char *path,
>  	notmuch->uuid = talloc_strdup (
>  	    notmuch, notmuch->xapian_db->get_uuid ().c_str ());
>  
> +	notmuch->gpg_crypto_ctx = NULL;
> +	
>  	notmuch->query_parser = new Xapian::QueryParser;
>  	notmuch->term_gen = new Xapian::TermGenerator;
>  	notmuch->term_gen->set_stemmer (Xapian::Stem ("english"));
> @@ -1090,6 +1092,11 @@ notmuch_database_close (notmuch_database_t *notmuch)
>      delete notmuch->last_mod_range_processor;
>      notmuch->last_mod_range_processor = NULL;
>  
> +    if (notmuch->gpg_crypto_ctx) {
> +	g_object_unref (notmuch->gpg_crypto_ctx);
> +	notmuch->gpg_crypto_ctx = NULL;
> +    }
> +    
>      return status;
>  }
>  
> @@ -2386,6 +2393,41 @@ _notmuch_database_link_message (notmuch_database_t *notmuch,
>      return status;
>  }
>  
> +notmuch_private_status_t
> +_notmuch_database_get_crypto_for_protocol (notmuch_database_t *notmuch,
> +					   const char *protocol,
> +					   GMimeCryptoContext **crypto_ctx)

^^^^ static function ^^^



More information about the notmuch mailing list