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 166646DE1B85 for ; Tue, 19 Jan 2016 18:53:28 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.023 X-Spam-Level: X-Spam-Status: No, score=-0.023 tagged_above=-999 required=5 tests=[AWL=-0.023] 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 Cfh9usCn4Lx1 for ; Tue, 19 Jan 2016 18:53:25 -0800 (PST) Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108]) by arlo.cworth.org (Postfix) with ESMTP id 6E68C6DE163B for ; Tue, 19 Jan 2016 18:53:16 -0800 (PST) Received: from fifthhorseman.net (unknown [38.109.115.130]) by che.mayfirst.org (Postfix) with ESMTPSA id CE3F6F993 for ; Tue, 19 Jan 2016 21:53:13 -0500 (EST) Received: by fifthhorseman.net (Postfix, from userid 1000) id E46D420257; Tue, 19 Jan 2016 18:53:10 -0800 (PST) From: Daniel Kahn Gillmor To: Notmuch Mail Subject: [PATCH v2 07/16] create a notmuch_indexopts_t index options object Date: Tue, 19 Jan 2016 21:52:40 -0500 Message-Id: <1453258369-7366-8-git-send-email-dkg@fifthhorseman.net> X-Mailer: git-send-email 2.7.0.rc3 In-Reply-To: <1453258369-7366-1-git-send-email-dkg@fifthhorseman.net> References: <1453258369-7366-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: Wed, 20 Jan 2016 02:53:28 -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