From 1ce13acf9d8da12e0bf5e9fc601ec38ff5b865f4 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Fri, 11 Dec 2015 23:55:16 +0200 Subject: [PATCH] Re: [PATCH 2/9] Add a lazily-initialized crypto context to notmuch_database_t --- 7a/38af445ab2aa07d1afd4e98a23601d7be62b79 | 115 ++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 7a/38af445ab2aa07d1afd4e98a23601d7be62b79 diff --git a/7a/38af445ab2aa07d1afd4e98a23601d7be62b79 b/7a/38af445ab2aa07d1afd4e98a23601d7be62b79 new file mode 100644 index 000000000..03f0217b7 --- /dev/null +++ b/7a/38af445ab2aa07d1afd4e98a23601d7be62b79 @@ -0,0 +1,115 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id A4CF76DE0B4B + for ; Fri, 11 Dec 2015 13:55:07 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.702 +X-Spam-Level: +X-Spam-Status: No, score=0.702 tagged_above=-999 required=5 tests=[AWL=0.050, + SPF_NEUTRAL=0.652] 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 uvIqJFasg67v for ; + Fri, 11 Dec 2015 13:55:05 -0800 (PST) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by arlo.cworth.org (Postfix) with ESMTP id 824E96DE005F + for ; Fri, 11 Dec 2015 13:55:05 -0800 (PST) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 2A0F6100090; + Fri, 11 Dec 2015 23:55:16 +0200 (EET) +From: Tomi Ollila +To: Daniel Kahn Gillmor , + Notmuch Mail +Subject: Re: [PATCH 2/9] Add a lazily-initialized crypto context to + notmuch_database_t +In-Reply-To: <1449718786-28000-3-git-send-email-dkg@fifthhorseman.net> +References: <1449718786-28000-1-git-send-email-dkg@fifthhorseman.net> + <1449718786-28000-3-git-send-email-dkg@fifthhorseman.net> +User-Agent: Notmuch/0.21+32~g73439f8 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +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: Fri, 11 Dec 2015 21:55:07 -0000 + +On Thu, Dec 10 2015, Daniel Kahn Gillmor 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 ^^^ + -- 2.26.2