From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
To: Notmuch Mail <notmuch@notmuchmail.org>
Subject: [PATCH v2 07/16] create a notmuch_indexopts_t index options object
Date: Tue, 19 Jan 2016 21:52:40 -0500 [thread overview]
Message-ID: <1453258369-7366-8-git-send-email-dkg@fifthhorseman.net> (raw)
In-Reply-To: <1453258369-7366-1-git-send-email-dkg@fifthhorseman.net>
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 <dkg@fifthhorseman.net>
+ */
+
+#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
next prev parent reply other threads:[~2016-01-20 2:53 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-20 2:52 Allow indexing cleartext of encrypted messages (v2) Daniel Kahn Gillmor
2016-01-20 2:52 ` [PATCH v2 01/16] add util/search-path.{c, h} to test for executables in $PATH Daniel Kahn Gillmor
2016-01-20 2:52 ` [PATCH v2 02/16] Move crypto.c into libutil Daniel Kahn Gillmor
2016-01-20 2:52 ` [PATCH v2 03/16] make shared crypto code behave library-like Daniel Kahn Gillmor
2016-01-20 2:52 ` [PATCH v2 04/16] Provide _notmuch_crypto_{set,get}_gpg_path Daniel Kahn Gillmor
2016-01-24 15:23 ` Tomi Ollila
2016-01-24 15:55 ` Daniel Kahn Gillmor
2016-01-20 2:52 ` [PATCH v2 05/16] Use a blank _notmuch_crypto to choose the default gpg_path Daniel Kahn Gillmor
2016-01-20 2:52 ` [PATCH v2 06/16] Prefer gpg2 in the test suite if available Daniel Kahn Gillmor
2016-01-24 15:25 ` Tomi Ollila
2016-01-24 16:03 ` Daniel Kahn Gillmor
2016-01-20 2:52 ` Daniel Kahn Gillmor [this message]
2016-01-20 2:52 ` [PATCH v2 08/16] reorganize indexing of multipart/signed and multipart/encrypted Daniel Kahn Gillmor
2016-01-20 2:52 ` [PATCH v2 09/16] index encrypted parts when asked Daniel Kahn Gillmor
2016-01-20 2:52 ` [PATCH v2 10/16] Add n_d_add_message_with_indexopts (extension of n_d_add_message) Daniel Kahn Gillmor
2016-01-20 2:52 ` [PATCH v2 11/16] add --try-decrypt to notmuch insert Daniel Kahn Gillmor
2016-01-20 2:52 ` [PATCH v2 12/16] add --try-decrypt to notmuch new Daniel Kahn Gillmor
2016-01-20 2:52 ` [PATCH v2 13/16] add indexopts to notmuch python bindings Daniel Kahn Gillmor
2016-01-20 2:52 ` [PATCH v2 14/16] test indexing cleartext version of delivered messages Daniel Kahn Gillmor
2016-01-20 2:52 ` [PATCH v2 15/16] added notmuch_message_reindex Daniel Kahn Gillmor
2016-01-20 2:52 ` [PATCH v2 16/16] add "notmuch reindex" subcommand Daniel Kahn Gillmor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1453258369-7366-8-git-send-email-dkg@fifthhorseman.net \
--to=dkg@fifthhorseman.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).