Re: [PATCH v4 13/16] add indexopts to notmuch python bindings.
[notmuch-archives.git] / d1 / d792f20c4d56b410e6af58df3df2e9e7a9837c
1 Return-Path: <dkg@fifthhorseman.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id 166646DE1B85\r
6  for <notmuch@notmuchmail.org>; Tue, 19 Jan 2016 18:53:28 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.023\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.023 tagged_above=-999 required=5\r
12  tests=[AWL=-0.023] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id Cfh9usCn4Lx1 for <notmuch@notmuchmail.org>;\r
16  Tue, 19 Jan 2016 18:53:25 -0800 (PST)\r
17 Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
18  by arlo.cworth.org (Postfix) with ESMTP id 6E68C6DE163B\r
19  for <notmuch@notmuchmail.org>; Tue, 19 Jan 2016 18:53:16 -0800 (PST)\r
20 Received: from fifthhorseman.net (unknown [38.109.115.130])\r
21  by che.mayfirst.org (Postfix) with ESMTPSA id CE3F6F993\r
22  for <notmuch@notmuchmail.org>; Tue, 19 Jan 2016 21:53:13 -0500 (EST)\r
23 Received: by fifthhorseman.net (Postfix, from userid 1000)\r
24  id E46D420257; Tue, 19 Jan 2016 18:53:10 -0800 (PST)\r
25 From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
26 To: Notmuch Mail <notmuch@notmuchmail.org>\r
27 Subject: [PATCH v2 07/16] create a notmuch_indexopts_t index options object\r
28 Date: Tue, 19 Jan 2016 21:52:40 -0500\r
29 Message-Id: <1453258369-7366-8-git-send-email-dkg@fifthhorseman.net>\r
30 X-Mailer: git-send-email 2.7.0.rc3\r
31 In-Reply-To: <1453258369-7366-1-git-send-email-dkg@fifthhorseman.net>\r
32 References: <1453258369-7366-1-git-send-email-dkg@fifthhorseman.net>\r
33 MIME-Version: 1.0\r
34 Content-Type: text/plain; charset=UTF-8\r
35 Content-Transfer-Encoding: 8bit\r
36 X-BeenThere: notmuch@notmuchmail.org\r
37 X-Mailman-Version: 2.1.20\r
38 Precedence: list\r
39 List-Id: "Use and development of the notmuch mail system."\r
40  <notmuch.notmuchmail.org>\r
41 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
42  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
44 List-Post: <mailto:notmuch@notmuchmail.org>\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
46 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
47  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
48 X-List-Received-Date: Wed, 20 Jan 2016 02:53:28 -0000\r
49 \r
50 This is currently mostly a wrapper around _notmuch_crypto_t that keeps\r
51 its internals private and doesn't expose any of the GMime API.\r
52 However, non-crypto indexing options might also be added later to\r
53 indexopts (e.g. filters or other transformations).\r
54 ---\r
55  lib/Makefile.local    |  1 +\r
56  lib/indexopts.c       | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++\r
57  lib/notmuch-private.h |  7 +++++\r
58  lib/notmuch.h         | 63 ++++++++++++++++++++++++++++++++++++++++++++\r
59  4 files changed, 143 insertions(+)\r
60  create mode 100644 lib/indexopts.c\r
61 \r
62 diff --git a/lib/Makefile.local b/lib/Makefile.local\r
63 index 3a07090..1652b1b 100644\r
64 --- a/lib/Makefile.local\r
65 +++ b/lib/Makefile.local\r
66 @@ -39,6 +39,7 @@ libnotmuch_c_srcs =           \\r
67         $(dir)/message-file.c   \\r
68         $(dir)/messages.c       \\r
69         $(dir)/sha1.c           \\r
70 +       $(dir)/indexopts.c      \\r
71         $(dir)/tags.c\r
72  \r
73  libnotmuch_cxx_srcs =          \\r
74 diff --git a/lib/indexopts.c b/lib/indexopts.c\r
75 new file mode 100644\r
76 index 0000000..da36e2b\r
77 --- /dev/null\r
78 +++ b/lib/indexopts.c\r
79 @@ -0,0 +1,72 @@\r
80 +/* indexopts.c - options for indexing messages\r
81 + *\r
82 + * Copyright © 2015 Daniel Kahn Gillmor\r
83 + *\r
84 + * This program is free software: you can redistribute it and/or modify\r
85 + * it under the terms of the GNU General Public License as published by\r
86 + * the Free Software Foundation, either version 3 of the License, or\r
87 + * (at your option) any later version.\r
88 + *\r
89 + * This program is distributed in the hope that it will be useful,\r
90 + * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
91 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
92 + * GNU General Public License for more details.\r
93 + *\r
94 + * You should have received a copy of the GNU General Public License\r
95 + * along with this program.  If not, see http://www.gnu.org/licenses/ .\r
96 + *\r
97 + * Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
98 + */\r
99 +\r
100 +#include "notmuch-private.h"\r
101 +\r
102 +notmuch_indexopts_t *\r
103 +notmuch_indexopts_create ()\r
104 +{\r
105 +    notmuch_indexopts_t *ret;\r
106 +    \r
107 +    ret = talloc_zero (NULL, notmuch_indexopts_t);\r
108 +\r
109 +    return ret;\r
110 +}\r
111 +\r
112 +notmuch_status_t\r
113 +notmuch_indexopts_set_try_decrypt (notmuch_indexopts_t *indexopts,\r
114 +                                  notmuch_bool_t try_decrypt)\r
115 +{\r
116 +    if (!indexopts)\r
117 +       return NOTMUCH_STATUS_NULL_POINTER;\r
118 +    indexopts->crypto.decrypt = try_decrypt;\r
119 +    return NOTMUCH_STATUS_SUCCESS;\r
120 +}\r
121 +\r
122 +notmuch_bool_t\r
123 +notmuch_indexopts_get_try_decrypt (const notmuch_indexopts_t *indexopts)\r
124 +{\r
125 +    if (!indexopts)\r
126 +       return FALSE;\r
127 +    return indexopts->crypto.decrypt;\r
128 +}\r
129 +\r
130 +notmuch_status_t\r
131 +notmuch_indexopts_set_gpg_path (notmuch_indexopts_t *indexopts,\r
132 +                               const char *gpg_path)\r
133 +{\r
134 +    if (!indexopts)\r
135 +       return NOTMUCH_STATUS_NULL_POINTER;\r
136 +    return _notmuch_crypto_set_gpg_path (&(indexopts->crypto), gpg_path);\r
137 +}\r
138 +\r
139 +const char*\r
140 +notmuch_indexopts_get_gpg_path (const notmuch_indexopts_t *indexopts)\r
141 +{\r
142 +    if (!indexopts)\r
143 +       return NULL;\r
144 +    return _notmuch_crypto_get_gpg_path (&(indexopts->crypto));\r
145 +}\r
146 +\r
147 +void\r
148 +notmuch_indexopts_destroy (notmuch_indexopts_t *indexopts)\r
149 +{\r
150 +    talloc_free (indexopts);\r
151 +}\r
152 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
153 index 5dd4770..e9c1e8a 100644\r
154 --- a/lib/notmuch-private.h\r
155 +++ b/lib/notmuch-private.h\r
156 @@ -51,6 +51,7 @@ NOTMUCH_BEGIN_DECLS\r
157  #include "xutil.h"\r
158  #include "error_util.h"\r
159  #include "string-util.h"\r
160 +#include "crypto.h"\r
161  \r
162  #pragma GCC visibility push(hidden)\r
163  \r
164 @@ -544,6 +545,12 @@ _notmuch_thread_create (void *ctx,\r
165                         notmuch_exclude_t omit_exclude,\r
166                         notmuch_sort_t sort);\r
167  \r
168 +/* indexopts.c */\r
169 +\r
170 +typedef struct _notmuch_indexopts {\r
171 +    _notmuch_crypto_t crypto;\r
172 +} notmuch_indexopts_t;\r
173 +\r
174  NOTMUCH_END_DECLS\r
175  \r
176  #ifdef __cplusplus\r
177 diff --git a/lib/notmuch.h b/lib/notmuch.h\r
178 index 00002f1..3679c54 100644\r
179 --- a/lib/notmuch.h\r
180 +++ b/lib/notmuch.h\r
181 @@ -214,6 +214,7 @@ typedef struct _notmuch_message notmuch_message_t;\r
182  typedef struct _notmuch_tags notmuch_tags_t;\r
183  typedef struct _notmuch_directory notmuch_directory_t;\r
184  typedef struct _notmuch_filenames notmuch_filenames_t;\r
185 +typedef struct _notmuch_indexopts notmuch_indexopts_t;\r
186  #endif /* __DOXYGEN__ */\r
187  \r
188  /**\r
189 @@ -1846,6 +1847,68 @@ notmuch_filenames_move_to_next (notmuch_filenames_t *filenames);\r
190  void\r
191  notmuch_filenames_destroy (notmuch_filenames_t *filenames);\r
192  \r
193 +/**\r
194 + * Create a notmuch_indexopts_t object.\r
195 + *\r
196 + * This object describes options on how indexing can happen when a\r
197 + * message is added to the index.\r
198 + */\r
199 +notmuch_indexopts_t *\r
200 +notmuch_indexopts_create ();\r
201 +\r
202 +/**\r
203 + * Specify whether to decrypt encrypted parts while indexing.\r
204 + * \r
205 + * Be aware that the index is likely sufficient to reconstruct the\r
206 + * cleartext of the message itself, so please ensure that the notmuch\r
207 + * message index is adequately protected. DO NOT SET THIS FLAG TO TRUE\r
208 + * without considering the security of your index.\r
209 + *\r
210 + */\r
211 +notmuch_status_t\r
212 +notmuch_indexopts_set_try_decrypt (notmuch_indexopts_t *indexopts,\r
213 +                                  notmuch_bool_t try_decrypt);\r
214 +\r
215 +/**\r
216 + * Return whether to decrypt encrypted parts while indexing.\r
217 + * see notmuch_indexopts_set_try_decrypt.\r
218 + */\r
219 +notmuch_bool_t\r
220 +notmuch_indexopts_get_try_decrypt (const notmuch_indexopts_t *indexopts);\r
221 +\r
222 +/**\r
223 + * Specify the name (or name and path) of the gpg executable, in case\r
224 + * GnuPG needs to be used during indexing.  The default should usually\r
225 + * be fine.\r
226 + * \r
227 + * Passing NULL to this will reset it to the default.\r
228 + * \r
229 + * Return value:\r
230 + *\r
231 + * NOTMUCH_STATUS_SUCCESS: the path was accepted and will be used.\r
232 + * \r
233 + * NOTMUCH_STATUS_FILE_ERROR: the path given either wasn't found or\r
234 + *      wasn't executable.\r
235 + */\r
236 +notmuch_status_t\r
237 +notmuch_indexopts_set_gpg_path (notmuch_indexopts_t *indexopts,\r
238 +                               const char *gpg_path);\r
239 +\r
240 +/**\r
241 + * Return the name (possibly including path) of the gpg executable to\r
242 + * be used in case GnuPG needs to be used during indexing.\r
243 + * \r
244 + * see notmuch_indexopts_set_gpg_path\r
245 + */\r
246 +const char*\r
247 +notmuch_indexopts_get_gpg_path (const notmuch_indexopts_t *indexopts);\r
248 +\r
249 +/**\r
250 + * Destroy a notmuch_indexopts_t object.\r
251 + */\r
252 +void\r
253 +notmuch_indexopts_destroy (notmuch_indexopts_t *options);\r
254 +\r
255  /* @} */\r
256  \r
257  NOTMUCH_END_DECLS\r
258 -- \r
259 2.7.0.rc3\r
260 \r