--- /dev/null
+Return-Path: <dkg@fifthhorseman.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id F1A4C6DE091F\r
+ for <notmuch@notmuchmail.org>; Fri, 8 Jul 2016 03:15:19 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.018\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.018 tagged_above=-999 required=5 tests=[AWL=0.018]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id ZYLJ0ofHjyVj for <notmuch@notmuchmail.org>;\r
+ Fri, 8 Jul 2016 03:15:12 -0700 (PDT)\r
+Received: from che.mayfirst.org (che.mayfirst.org [162.247.75.118])\r
+ by arlo.cworth.org (Postfix) with ESMTP id AC8036DE092E\r
+ for <notmuch@notmuchmail.org>; Fri, 8 Jul 2016 03:13:22 -0700 (PDT)\r
+Received: from fifthhorseman.net (unknown [88.128.80.54])\r
+ by che.mayfirst.org (Postfix) with ESMTPSA id 7E3C1F98B\r
+ for <notmuch@notmuchmail.org>; Fri, 8 Jul 2016 06:13:21 -0400 (EDT)\r
+Received: by fifthhorseman.net (Postfix, from userid 1000)\r
+ id A3CD421211; Fri, 8 Jul 2016 11:27:34 +0200 (CEST)\r
+From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH v4 07/16] create a notmuch_indexopts_t index options object\r
+Date: Fri, 8 Jul 2016 11:27:18 +0200\r
+Message-Id: <1467970047-8013-8-git-send-email-dkg@fifthhorseman.net>\r
+X-Mailer: git-send-email 2.8.1\r
+In-Reply-To: <1467970047-8013-1-git-send-email-dkg@fifthhorseman.net>\r
+References: <1467970047-8013-1-git-send-email-dkg@fifthhorseman.net>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 08 Jul 2016 10:15:20 -0000\r
+\r
+This is currently mostly a wrapper around _notmuch_crypto_t that keeps\r
+its internals private and doesn't expose any of the GMime API.\r
+However, non-crypto indexing options might also be added later to\r
+indexopts (e.g. filters or other transformations).\r
+---\r
+ lib/Makefile.local | 1 +\r
+ lib/indexopts.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ lib/notmuch-private.h | 7 +++++\r
+ lib/notmuch.h | 63 ++++++++++++++++++++++++++++++++++++++++++++\r
+ 4 files changed, 143 insertions(+)\r
+ create mode 100644 lib/indexopts.c\r
+\r
+diff --git a/lib/Makefile.local b/lib/Makefile.local\r
+index c012ed1..56a5f5a 100644\r
+--- a/lib/Makefile.local\r
++++ b/lib/Makefile.local\r
+@@ -41,6 +41,7 @@ libnotmuch_c_srcs = \\r
+ $(dir)/sha1.c \\r
+ $(dir)/built-with.c \\r
+ $(dir)/string-map.c \\r
++ $(dir)/indexopts.c \\r
+ $(dir)/tags.c\r
+ \r
+ libnotmuch_cxx_srcs = \\r
+diff --git a/lib/indexopts.c b/lib/indexopts.c\r
+new file mode 100644\r
+index 0000000..da36e2b\r
+--- /dev/null\r
++++ b/lib/indexopts.c\r
+@@ -0,0 +1,72 @@\r
++/* indexopts.c - options for indexing messages\r
++ *\r
++ * Copyright © 2015 Daniel Kahn Gillmor\r
++ *\r
++ * This program is free software: you can redistribute it and/or modify\r
++ * it under the terms of the GNU General Public License as published by\r
++ * the Free Software Foundation, either version 3 of the License, or\r
++ * (at your option) any later version.\r
++ *\r
++ * This program is distributed in the hope that it will be useful,\r
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
++ * GNU General Public License for more details.\r
++ *\r
++ * You should have received a copy of the GNU General Public License\r
++ * along with this program. If not, see http://www.gnu.org/licenses/ .\r
++ *\r
++ * Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
++ */\r
++\r
++#include "notmuch-private.h"\r
++\r
++notmuch_indexopts_t *\r
++notmuch_indexopts_create ()\r
++{\r
++ notmuch_indexopts_t *ret;\r
++ \r
++ ret = talloc_zero (NULL, notmuch_indexopts_t);\r
++\r
++ return ret;\r
++}\r
++\r
++notmuch_status_t\r
++notmuch_indexopts_set_try_decrypt (notmuch_indexopts_t *indexopts,\r
++ notmuch_bool_t try_decrypt)\r
++{\r
++ if (!indexopts)\r
++ return NOTMUCH_STATUS_NULL_POINTER;\r
++ indexopts->crypto.decrypt = try_decrypt;\r
++ return NOTMUCH_STATUS_SUCCESS;\r
++}\r
++\r
++notmuch_bool_t\r
++notmuch_indexopts_get_try_decrypt (const notmuch_indexopts_t *indexopts)\r
++{\r
++ if (!indexopts)\r
++ return FALSE;\r
++ return indexopts->crypto.decrypt;\r
++}\r
++\r
++notmuch_status_t\r
++notmuch_indexopts_set_gpg_path (notmuch_indexopts_t *indexopts,\r
++ const char *gpg_path)\r
++{\r
++ if (!indexopts)\r
++ return NOTMUCH_STATUS_NULL_POINTER;\r
++ return _notmuch_crypto_set_gpg_path (&(indexopts->crypto), gpg_path);\r
++}\r
++\r
++const char*\r
++notmuch_indexopts_get_gpg_path (const notmuch_indexopts_t *indexopts)\r
++{\r
++ if (!indexopts)\r
++ return NULL;\r
++ return _notmuch_crypto_get_gpg_path (&(indexopts->crypto));\r
++}\r
++\r
++void\r
++notmuch_indexopts_destroy (notmuch_indexopts_t *indexopts)\r
++{\r
++ talloc_free (indexopts);\r
++}\r
+diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
+index 65f7ead..8b2aede 100644\r
+--- a/lib/notmuch-private.h\r
++++ b/lib/notmuch-private.h\r
+@@ -51,6 +51,7 @@ NOTMUCH_BEGIN_DECLS\r
+ #include "xutil.h"\r
+ #include "error_util.h"\r
+ #include "string-util.h"\r
++#include "crypto.h"\r
+ \r
+ #pragma GCC visibility push(hidden)\r
+ \r
+@@ -594,6 +595,12 @@ _notmuch_thread_create (void *ctx,\r
+ notmuch_exclude_t omit_exclude,\r
+ notmuch_sort_t sort);\r
+ \r
++/* indexopts.c */\r
++\r
++typedef struct _notmuch_indexopts {\r
++ _notmuch_crypto_t crypto;\r
++} notmuch_indexopts_t;\r
++\r
+ NOTMUCH_END_DECLS\r
+ \r
+ #ifdef __cplusplus\r
+diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+index aaed516..b92d969 100644\r
+--- a/lib/notmuch.h\r
++++ b/lib/notmuch.h\r
+@@ -229,6 +229,7 @@ typedef struct _notmuch_tags notmuch_tags_t;\r
+ typedef struct _notmuch_directory notmuch_directory_t;\r
+ typedef struct _notmuch_filenames notmuch_filenames_t;\r
+ typedef struct _notmuch_config_list notmuch_config_list_t;\r
++typedef struct _notmuch_indexopts notmuch_indexopts_t;\r
+ #endif /* __DOXYGEN__ */\r
+ \r
+ /**\r
+@@ -2091,6 +2092,68 @@ notmuch_config_list_destroy (notmuch_config_list_t *config_list);\r
+ */\r
+ notmuch_bool_t\r
+ notmuch_built_with (const char *name);\r
++\r
++/**\r
++ * Create a notmuch_indexopts_t object.\r
++ *\r
++ * This object describes options on how indexing can happen when a\r
++ * message is added to the index.\r
++ */\r
++notmuch_indexopts_t *\r
++notmuch_indexopts_create ();\r
++\r
++/**\r
++ * Specify whether to decrypt encrypted parts while indexing.\r
++ *\r
++ * Be aware that the index is likely sufficient to reconstruct the\r
++ * cleartext of the message itself, so please ensure that the notmuch\r
++ * message index is adequately protected. DO NOT SET THIS FLAG TO TRUE\r
++ * without considering the security of your index.\r
++ */\r
++notmuch_status_t\r
++notmuch_indexopts_set_try_decrypt (notmuch_indexopts_t *indexopts,\r
++ notmuch_bool_t try_decrypt);\r
++\r
++/**\r
++ * Return whether to decrypt encrypted parts while indexing.\r
++ * see notmuch_indexopts_set_try_decrypt.\r
++ */\r
++notmuch_bool_t\r
++notmuch_indexopts_get_try_decrypt (const notmuch_indexopts_t *indexopts);\r
++\r
++/**\r
++ * Specify the name (or name and path) of the gpg executable, in case\r
++ * GnuPG needs to be used during indexing. The default should usually\r
++ * be fine.\r
++ *\r
++ * Passing NULL to this will reset it to the default.\r
++ *\r
++ * Return value:\r
++ *\r
++ * NOTMUCH_STATUS_SUCCESS: the path was accepted and will be used.\r
++ *\r
++ * NOTMUCH_STATUS_FILE_ERROR: the path given either wasn't found or\r
++ * wasn't executable.\r
++ */\r
++notmuch_status_t\r
++notmuch_indexopts_set_gpg_path (notmuch_indexopts_t *indexopts,\r
++ const char *gpg_path);\r
++\r
++/**\r
++ * Return the name (possibly including path) of the gpg executable to\r
++ * be used in case GnuPG needs to be used during indexing.\r
++ *\r
++ * see notmuch_indexopts_set_gpg_path\r
++ */\r
++const char*\r
++notmuch_indexopts_get_gpg_path (const notmuch_indexopts_t *indexopts);\r
++\r
++/**\r
++ * Destroy a notmuch_indexopts_t object.\r
++ */\r
++void\r
++notmuch_indexopts_destroy (notmuch_indexopts_t *options);\r
++\r
+ /* @} */\r
+ \r
+ NOTMUCH_END_DECLS\r
+-- \r
+2.8.1\r
+\r