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 F1A4C6DE091F for ; Fri, 8 Jul 2016 03:15:19 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.018 X-Spam-Level: X-Spam-Status: No, score=0.018 tagged_above=-999 required=5 tests=[AWL=0.018] 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 ZYLJ0ofHjyVj for ; Fri, 8 Jul 2016 03:15:12 -0700 (PDT) Received: from che.mayfirst.org (che.mayfirst.org [162.247.75.118]) by arlo.cworth.org (Postfix) with ESMTP id AC8036DE092E for ; Fri, 8 Jul 2016 03:13:22 -0700 (PDT) Received: from fifthhorseman.net (unknown [88.128.80.54]) by che.mayfirst.org (Postfix) with ESMTPSA id 7E3C1F98B for ; Fri, 8 Jul 2016 06:13:21 -0400 (EDT) Received: by fifthhorseman.net (Postfix, from userid 1000) id A3CD421211; Fri, 8 Jul 2016 11:27:34 +0200 (CEST) From: Daniel Kahn Gillmor To: Notmuch Mail Subject: [PATCH v4 07/16] create a notmuch_indexopts_t index options object Date: Fri, 8 Jul 2016 11:27:18 +0200 Message-Id: <1467970047-8013-8-git-send-email-dkg@fifthhorseman.net> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1467970047-8013-1-git-send-email-dkg@fifthhorseman.net> References: <1467970047-8013-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: Fri, 08 Jul 2016 10:15:20 -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 c012ed1..56a5f5a 100644 --- a/lib/Makefile.local +++ b/lib/Makefile.local @@ -41,6 +41,7 @@ libnotmuch_c_srcs = \ $(dir)/sha1.c \ $(dir)/built-with.c \ $(dir)/string-map.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 65f7ead..8b2aede 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) @@ -594,6 +595,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 aaed516..b92d969 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -229,6 +229,7 @@ typedef struct _notmuch_tags notmuch_tags_t; typedef struct _notmuch_directory notmuch_directory_t; typedef struct _notmuch_filenames notmuch_filenames_t; typedef struct _notmuch_config_list notmuch_config_list_t; +typedef struct _notmuch_indexopts notmuch_indexopts_t; #endif /* __DOXYGEN__ */ /** @@ -2091,6 +2092,68 @@ notmuch_config_list_destroy (notmuch_config_list_t *config_list); */ notmuch_bool_t notmuch_built_with (const char *name); + +/** + * 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.8.1