From d9da071ea2c5be0868df24d15a335bee2cb4313b Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Mon, 1 Feb 2016 15:39:52 +1900 Subject: [PATCH] [PATCH v3 07/16] create a notmuch_indexopts_t index options object --- 26/cca4952499f68c947a8f1af097e9c42ea6a60b | 261 ++++++++++++++++++++++ 1 file changed, 261 insertions(+) create mode 100644 26/cca4952499f68c947a8f1af097e9c42ea6a60b diff --git a/26/cca4952499f68c947a8f1af097e9c42ea6a60b b/26/cca4952499f68c947a8f1af097e9c42ea6a60b new file mode 100644 index 000000000..7144ed7f0 --- /dev/null +++ b/26/cca4952499f68c947a8f1af097e9c42ea6a60b @@ -0,0 +1,261 @@ +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 A2A536DE1B43 + for ; Sun, 31 Jan 2016 12:40:17 -0800 (PST) +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=[none] + 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 zc9c-uLr8hqw for ; + Sun, 31 Jan 2016 12:40:15 -0800 (PST) +Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108]) + by arlo.cworth.org (Postfix) with ESMTP id 730CE6DE19DE + for ; Sun, 31 Jan 2016 12:40:09 -0800 (PST) +Received: from fifthhorseman.net (ip-64-134-185-108.public.wayport.net + [64.134.185.108]) + by che.mayfirst.org (Postfix) with ESMTPSA id 57D5DF99B + for ; Sun, 31 Jan 2016 15:40:06 -0500 (EST) +Received: by fifthhorseman.net (Postfix, from userid 1000) + id 4654620E96; Sun, 31 Jan 2016 15:40:06 -0500 (EST) +From: Daniel Kahn Gillmor +To: Notmuch Mail +Subject: [PATCH v3 07/16] create a notmuch_indexopts_t index options object +Date: Sun, 31 Jan 2016 15:39:52 -0500 +Message-Id: <1454272801-23623-8-git-send-email-dkg@fifthhorseman.net> +X-Mailer: git-send-email 2.7.0.rc3 +In-Reply-To: <1454272801-23623-1-git-send-email-dkg@fifthhorseman.net> +References: <1454272801-23623-1-git-send-email-dkg@fifthhorseman.net> +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +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: Sun, 31 Jan 2016 20:40:17 -0000 + +This is currently mostly a wrapper around _notmuch_crypto_t that keeps +its internals private and doesn't expose any of the GMime API. +However, non-crypto indexing options might also be added later to +indexopts (e.g. filters or other transformations). +--- + lib/Makefile.local | 1 + + lib/indexopts.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ + lib/notmuch-private.h | 7 +++++ + lib/notmuch.h | 63 ++++++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 143 insertions(+) + create mode 100644 lib/indexopts.c + +diff --git a/lib/Makefile.local b/lib/Makefile.local +index 3a07090..1652b1b 100644 +--- a/lib/Makefile.local ++++ b/lib/Makefile.local +@@ -39,6 +39,7 @@ libnotmuch_c_srcs = \ + $(dir)/message-file.c \ + $(dir)/messages.c \ + $(dir)/sha1.c \ ++ $(dir)/indexopts.c \ + $(dir)/tags.c + + libnotmuch_cxx_srcs = \ +diff --git a/lib/indexopts.c b/lib/indexopts.c +new file mode 100644 +index 0000000..da36e2b +--- /dev/null ++++ b/lib/indexopts.c +@@ -0,0 +1,72 @@ ++/* indexopts.c - options for indexing messages ++ * ++ * Copyright © 2015 Daniel Kahn Gillmor ++ * ++ * This program is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation, either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program. If not, see http://www.gnu.org/licenses/ . ++ * ++ * Author: Daniel Kahn Gillmor ++ */ ++ ++#include "notmuch-private.h" ++ ++notmuch_indexopts_t * ++notmuch_indexopts_create () ++{ ++ notmuch_indexopts_t *ret; ++ ++ ret = talloc_zero (NULL, notmuch_indexopts_t); ++ ++ return ret; ++} ++ ++notmuch_status_t ++notmuch_indexopts_set_try_decrypt (notmuch_indexopts_t *indexopts, ++ notmuch_bool_t try_decrypt) ++{ ++ if (!indexopts) ++ return NOTMUCH_STATUS_NULL_POINTER; ++ indexopts->crypto.decrypt = try_decrypt; ++ return NOTMUCH_STATUS_SUCCESS; ++} ++ ++notmuch_bool_t ++notmuch_indexopts_get_try_decrypt (const notmuch_indexopts_t *indexopts) ++{ ++ if (!indexopts) ++ return FALSE; ++ return indexopts->crypto.decrypt; ++} ++ ++notmuch_status_t ++notmuch_indexopts_set_gpg_path (notmuch_indexopts_t *indexopts, ++ const char *gpg_path) ++{ ++ if (!indexopts) ++ return NOTMUCH_STATUS_NULL_POINTER; ++ return _notmuch_crypto_set_gpg_path (&(indexopts->crypto), gpg_path); ++} ++ ++const char* ++notmuch_indexopts_get_gpg_path (const notmuch_indexopts_t *indexopts) ++{ ++ if (!indexopts) ++ return NULL; ++ return _notmuch_crypto_get_gpg_path (&(indexopts->crypto)); ++} ++ ++void ++notmuch_indexopts_destroy (notmuch_indexopts_t *indexopts) ++{ ++ talloc_free (indexopts); ++} +diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h +index 5dd4770..e9c1e8a 100644 +--- a/lib/notmuch-private.h ++++ b/lib/notmuch-private.h +@@ -51,6 +51,7 @@ NOTMUCH_BEGIN_DECLS + #include "xutil.h" + #include "error_util.h" + #include "string-util.h" ++#include "crypto.h" + + #pragma GCC visibility push(hidden) + +@@ -544,6 +545,12 @@ _notmuch_thread_create (void *ctx, + notmuch_exclude_t omit_exclude, + notmuch_sort_t sort); + ++/* indexopts.c */ ++ ++typedef struct _notmuch_indexopts { ++ _notmuch_crypto_t crypto; ++} notmuch_indexopts_t; ++ + NOTMUCH_END_DECLS + + #ifdef __cplusplus +diff --git a/lib/notmuch.h b/lib/notmuch.h +index 00002f1..3679c54 100644 +--- a/lib/notmuch.h ++++ b/lib/notmuch.h +@@ -214,6 +214,7 @@ typedef struct _notmuch_message notmuch_message_t; + typedef struct _notmuch_tags notmuch_tags_t; + typedef struct _notmuch_directory notmuch_directory_t; + typedef struct _notmuch_filenames notmuch_filenames_t; ++typedef struct _notmuch_indexopts notmuch_indexopts_t; + #endif /* __DOXYGEN__ */ + + /** +@@ -1846,6 +1847,68 @@ notmuch_filenames_move_to_next (notmuch_filenames_t *filenames); + void + notmuch_filenames_destroy (notmuch_filenames_t *filenames); + ++/** ++ * Create a notmuch_indexopts_t object. ++ * ++ * This object describes options on how indexing can happen when a ++ * message is added to the index. ++ */ ++notmuch_indexopts_t * ++notmuch_indexopts_create (); ++ ++/** ++ * Specify whether to decrypt encrypted parts while indexing. ++ * ++ * Be aware that the index is likely sufficient to reconstruct the ++ * cleartext of the message itself, so please ensure that the notmuch ++ * message index is adequately protected. DO NOT SET THIS FLAG TO TRUE ++ * without considering the security of your index. ++ * ++ */ ++notmuch_status_t ++notmuch_indexopts_set_try_decrypt (notmuch_indexopts_t *indexopts, ++ notmuch_bool_t try_decrypt); ++ ++/** ++ * Return whether to decrypt encrypted parts while indexing. ++ * see notmuch_indexopts_set_try_decrypt. ++ */ ++notmuch_bool_t ++notmuch_indexopts_get_try_decrypt (const notmuch_indexopts_t *indexopts); ++ ++/** ++ * Specify the name (or name and path) of the gpg executable, in case ++ * GnuPG needs to be used during indexing. The default should usually ++ * be fine. ++ * ++ * Passing NULL to this will reset it to the default. ++ * ++ * Return value: ++ * ++ * NOTMUCH_STATUS_SUCCESS: the path was accepted and will be used. ++ * ++ * NOTMUCH_STATUS_FILE_ERROR: the path given either wasn't found or ++ * wasn't executable. ++ */ ++notmuch_status_t ++notmuch_indexopts_set_gpg_path (notmuch_indexopts_t *indexopts, ++ const char *gpg_path); ++ ++/** ++ * Return the name (possibly including path) of the gpg executable to ++ * be used in case GnuPG needs to be used during indexing. ++ * ++ * see notmuch_indexopts_set_gpg_path ++ */ ++const char* ++notmuch_indexopts_get_gpg_path (const notmuch_indexopts_t *indexopts); ++ ++/** ++ * Destroy a notmuch_indexopts_t object. ++ */ ++void ++notmuch_indexopts_destroy (notmuch_indexopts_t *options); ++ + /* @} */ + + NOTMUCH_END_DECLS +-- +2.7.0.rc3 + -- 2.26.2