1 Return-Path: <jani@nikula.org>
\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 olra.theworths.org (Postfix) with ESMTP id 76FFA431FAF
\r
6 for <notmuch@notmuchmail.org>; Thu, 17 May 2012 00:36:16 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id cnfEI171w897 for <notmuch@notmuchmail.org>;
\r
16 Thu, 17 May 2012 00:36:15 -0700 (PDT)
\r
17 Received: from mail-lpp01m010-f53.google.com (mail-lpp01m010-f53.google.com
\r
18 [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 09847431FAE
\r
21 for <notmuch@notmuchmail.org>; Thu, 17 May 2012 00:36:14 -0700 (PDT)
\r
22 Received: by lagu2 with SMTP id u2so1266293lag.26
\r
23 for <notmuch@notmuchmail.org>; Thu, 17 May 2012 00:36:12 -0700 (PDT)
\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
25 d=google.com; s=20120113;
\r
26 h=from:to:subject:in-reply-to:references:user-agent:date:message-id
\r
27 :mime-version:content-type:x-gm-message-state;
\r
28 bh=Ve+d0ggxO1BwdZf1iDi1ZMOqwj8MsIgXOObjp4NBo6k=;
\r
29 b=kt07yKDse0CqkPRyprQAJBGXXEfSob/3EaxOMb2UE1KfAEoGj5NBA2v07Jtaokwrrn
\r
30 7Q2vgxKA8WEYtmCeDBa9Kqdgq4pSnWnCUVjFrgiVOlYtF7Vg4iPiTdmVOP9zhZIPrJKV
\r
31 /5wzL7NE61shXamR0ikYVF+o60O26qNpOw2jS7PuQUoCIdj+E/i5/F+rV0PAuofRJ9ua
\r
32 Oog0Lm+HKF889kmhgPaVe0kKEVN2EPsdaYGQDXEegQeGB6JM0Y1ozjik10lqFhpXEv9k
\r
33 tNYZ9YSrhVah+/LaRk5G9RjKqQcrgrMoK7J35buJaVV8aFLY5HKvTzJr/bR9JNLz7onZ
\r
35 Received: by 10.112.44.163 with SMTP id f3mr2555757lbm.59.1337240171964;
\r
36 Thu, 17 May 2012 00:36:11 -0700 (PDT)
\r
37 Received: from localhost (dsl-hkibrasgw4-fe50dc00-68.dhcp.inet.fi.
\r
39 by mx.google.com with ESMTPS id u4sm6702346lad.5.2012.05.17.00.36.09
\r
40 (version=SSLv3 cipher=OTHER); Thu, 17 May 2012 00:36:11 -0700 (PDT)
\r
41 From: Jani Nikula <jani@nikula.org>
\r
42 To: Jameson Graef Rollins <jrollins@finestructure.net>,
\r
43 Notmuch Mail <notmuch@notmuchmail.org>
\r
44 Subject: Re: [PATCH 1/6] cli: new crypto structure to store crypto contexts
\r
46 In-Reply-To: <1337205359-2444-2-git-send-email-jrollins@finestructure.net>
\r
47 References: <1337205359-2444-1-git-send-email-jrollins@finestructure.net>
\r
48 <1337205359-2444-2-git-send-email-jrollins@finestructure.net>
\r
49 User-Agent: Notmuch/0.13+13~gc259b9a (http://notmuchmail.org) Emacs/23.3.1
\r
51 Date: Thu, 17 May 2012 10:36:08 +0300
\r
52 Message-ID: <87ehqji7iv.fsf@nikula.org>
\r
54 Content-Type: text/plain; charset=us-ascii
\r
56 ALoCoQk0LQR9yVcQdVFEszhY4ElvDlaotsnLpzzLxbXpgUGJ8HeWXAI3pognWz1KDgTHKzEOd29H
\r
57 X-BeenThere: notmuch@notmuchmail.org
\r
58 X-Mailman-Version: 2.1.13
\r
60 List-Id: "Use and development of the notmuch mail system."
\r
61 <notmuch.notmuchmail.org>
\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
63 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
65 List-Post: <mailto:notmuch@notmuchmail.org>
\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
69 X-List-Received-Date: Thu, 17 May 2012 07:36:16 -0000
\r
71 On Thu, 17 May 2012, Jameson Graef Rollins <jrollins@finestructure.net> wrote:
\r
72 > The main point here is to keep track of the crypto stuff together in
\r
73 > one place. In notmuch-show the crypto struct is a sub structure of
\r
74 > the parameters struct. In notmuch-reply, which had been using a
\r
75 > notmuch_show_params_t to store the crypto parameters, we can now just
\r
76 > use the general crypto struct.
\r
78 Looks good. My only (potentially unwarranted) worry is dropping the use
\r
79 of notmuch_show_params_t in reply. This diverges the show/reply code,
\r
80 making any future unification of them slightly harder. And if reply ever
\r
81 needs params, we'll need to bring it back. But perhaps I worry too
\r
89 > I slip in a name change of the crypto context itself to better reflect
\r
90 > what the context is specifically for: it's actually a GPG context,
\r
91 > which is a sub type of Crypto context. There are other types of
\r
92 > Crypto contexts (Pkcs7 in particular) so we want to be clear.
\r
94 > The following patches will use this to simplify some function
\r
97 > notmuch-client.h | 16 ++++++++++------
\r
98 > notmuch-reply.c | 34 +++++++++++++++++-----------------
\r
99 > notmuch-show.c | 22 +++++++++++-----------
\r
100 > 3 files changed, 38 insertions(+), 34 deletions(-)
\r
102 > diff --git a/notmuch-client.h b/notmuch-client.h
\r
103 > index 19b7f01..2ad24cf 100644
\r
104 > --- a/notmuch-client.h
\r
105 > +++ b/notmuch-client.h
\r
106 > @@ -74,17 +74,21 @@ typedef struct notmuch_show_format {
\r
107 > const char *message_set_end;
\r
108 > } notmuch_show_format_t;
\r
110 > +typedef struct notmuch_crypto {
\r
111 > +#ifdef GMIME_ATLEAST_26
\r
112 > + GMimeCryptoContext* gpgctx;
\r
114 > + GMimeCipherContext* gpgctx;
\r
116 > + notmuch_bool_t decrypt;
\r
117 > +} notmuch_crypto_t;
\r
119 > typedef struct notmuch_show_params {
\r
120 > notmuch_bool_t entire_thread;
\r
121 > notmuch_bool_t omit_excluded;
\r
122 > notmuch_bool_t raw;
\r
124 > -#ifdef GMIME_ATLEAST_26
\r
125 > - GMimeCryptoContext* cryptoctx;
\r
127 > - GMimeCipherContext* cryptoctx;
\r
129 > - notmuch_bool_t decrypt;
\r
130 > + notmuch_crypto_t crypto;
\r
131 > } notmuch_show_params_t;
\r
133 > /* There's no point in continuing when we've detected that we've done
\r
134 > diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
135 > index 7184a5d..ed87899 100644
\r
136 > --- a/notmuch-reply.c
\r
137 > +++ b/notmuch-reply.c
\r
138 > @@ -515,7 +515,7 @@ static int
\r
139 > notmuch_reply_format_default(void *ctx,
\r
140 > notmuch_config_t *config,
\r
141 > notmuch_query_t *query,
\r
142 > - notmuch_show_params_t *params,
\r
143 > + notmuch_crypto_t *crypto,
\r
144 > notmuch_bool_t reply_all)
\r
146 > GMimeMessage *reply;
\r
147 > @@ -544,7 +544,7 @@ notmuch_reply_format_default(void *ctx,
\r
148 > g_object_unref (G_OBJECT (reply));
\r
151 > - if (mime_node_open (ctx, message, params->cryptoctx, params->decrypt,
\r
152 > + if (mime_node_open (ctx, message, crypto->gpgctx, crypto->decrypt,
\r
153 > &root) == NOTMUCH_STATUS_SUCCESS) {
\r
154 > format_part_reply (root);
\r
155 > talloc_free (root);
\r
156 > @@ -559,7 +559,7 @@ static int
\r
157 > notmuch_reply_format_json(void *ctx,
\r
158 > notmuch_config_t *config,
\r
159 > notmuch_query_t *query,
\r
160 > - notmuch_show_params_t *params,
\r
161 > + notmuch_crypto_t *crypto,
\r
162 > notmuch_bool_t reply_all)
\r
164 > GMimeMessage *reply;
\r
165 > @@ -574,7 +574,7 @@ notmuch_reply_format_json(void *ctx,
\r
167 > messages = notmuch_query_search_messages (query);
\r
168 > message = notmuch_messages_get (messages);
\r
169 > - if (mime_node_open (ctx, message, params->cryptoctx, params->decrypt,
\r
170 > + if (mime_node_open (ctx, message, crypto->gpgctx, crypto->decrypt,
\r
171 > &node) != NOTMUCH_STATUS_SUCCESS)
\r
174 > @@ -605,7 +605,7 @@ static int
\r
175 > notmuch_reply_format_headers_only(void *ctx,
\r
176 > notmuch_config_t *config,
\r
177 > notmuch_query_t *query,
\r
178 > - unused (notmuch_show_params_t *params),
\r
179 > + unused (notmuch_crypto_t *crypto),
\r
180 > notmuch_bool_t reply_all)
\r
182 > GMimeMessage *reply;
\r
183 > @@ -674,8 +674,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
184 > notmuch_query_t *query;
\r
185 > char *query_string;
\r
186 > int opt_index, ret = 0;
\r
187 > - int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t reply_all);
\r
188 > - notmuch_show_params_t params = { .part = -1 };
\r
189 > + int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, notmuch_crypto_t *crypto, notmuch_bool_t reply_all);
\r
190 > + notmuch_crypto_t crypto = { .decrypt = FALSE };
\r
191 > int format = FORMAT_DEFAULT;
\r
192 > int reply_all = TRUE;
\r
194 > @@ -689,7 +689,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
195 > (notmuch_keyword_t []){ { "all", TRUE },
\r
196 > { "sender", FALSE },
\r
198 > - { NOTMUCH_OPT_BOOLEAN, ¶ms.decrypt, "decrypt", 'd', 0 },
\r
199 > + { NOTMUCH_OPT_BOOLEAN, &crypto.decrypt, "decrypt", 'd', 0 },
\r
200 > { 0, 0, 0, 0, 0 }
\r
203 > @@ -706,18 +706,18 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
205 > reply_format_func = notmuch_reply_format_default;
\r
207 > - if (params.decrypt) {
\r
208 > + if (crypto.decrypt) {
\r
209 > #ifdef GMIME_ATLEAST_26
\r
210 > /* TODO: GMimePasswordRequestFunc */
\r
211 > - params.cryptoctx = g_mime_gpg_context_new (NULL, "gpg");
\r
212 > + crypto.gpgctx = g_mime_gpg_context_new (NULL, "gpg");
\r
214 > GMimeSession* session = g_object_new (g_mime_session_get_type(), NULL);
\r
215 > - params.cryptoctx = g_mime_gpg_context_new (session, "gpg");
\r
216 > + crypto.gpgctx = g_mime_gpg_context_new (session, "gpg");
\r
218 > - if (params.cryptoctx) {
\r
219 > - g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.cryptoctx, FALSE);
\r
220 > + if (crypto.gpgctx) {
\r
221 > + g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) crypto.gpgctx, FALSE);
\r
223 > - params.decrypt = FALSE;
\r
224 > + crypto.decrypt = FALSE;
\r
225 > fprintf (stderr, "Failed to construct gpg context.\n");
\r
227 > #ifndef GMIME_ATLEAST_26
\r
228 > @@ -750,14 +750,14 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
232 > - if (reply_format_func (ctx, config, query, ¶ms, reply_all) != 0)
\r
233 > + if (reply_format_func (ctx, config, query, &crypto, reply_all) != 0)
\r
236 > notmuch_query_destroy (query);
\r
237 > notmuch_database_destroy (notmuch);
\r
239 > - if (params.cryptoctx)
\r
240 > - g_object_unref(params.cryptoctx);
\r
241 > + if (crypto.gpgctx)
\r
242 > + g_object_unref(crypto.gpgctx);
\r
246 > diff --git a/notmuch-show.c b/notmuch-show.c
\r
247 > index 95427d4..d254179 100644
\r
248 > --- a/notmuch-show.c
\r
249 > +++ b/notmuch-show.c
\r
250 > @@ -810,8 +810,8 @@ show_message (void *ctx,
\r
251 > mime_node_t *root, *part;
\r
252 > notmuch_status_t status;
\r
254 > - status = mime_node_open (local, message, params->cryptoctx,
\r
255 > - params->decrypt, &root);
\r
256 > + status = mime_node_open (local, message, params->crypto.gpgctx,
\r
257 > + params->crypto.decrypt, &root);
\r
260 > part = mime_node_seek_dfs (root, (params->part < 0 ? 0 : params->part));
\r
261 > @@ -1002,7 +1002,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
263 > { NOTMUCH_OPT_INT, ¶ms.part, "part", 'p', 0 },
\r
264 > { NOTMUCH_OPT_BOOLEAN, ¶ms.entire_thread, "entire-thread", 't', 0 },
\r
265 > - { NOTMUCH_OPT_BOOLEAN, ¶ms.decrypt, "decrypt", 'd', 0 },
\r
266 > + { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.decrypt, "decrypt", 'd', 0 },
\r
267 > { NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 },
\r
268 > { 0, 0, 0, 0, 0 }
\r
270 > @@ -1047,18 +1047,18 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
274 > - if (params.decrypt || verify) {
\r
275 > + if (params.crypto.decrypt || verify) {
\r
276 > #ifdef GMIME_ATLEAST_26
\r
277 > /* TODO: GMimePasswordRequestFunc */
\r
278 > - params.cryptoctx = g_mime_gpg_context_new (NULL, "gpg");
\r
279 > + params.crypto.gpgctx = g_mime_gpg_context_new (NULL, "gpg");
\r
281 > GMimeSession* session = g_object_new (g_mime_session_get_type(), NULL);
\r
282 > - params.cryptoctx = g_mime_gpg_context_new (session, "gpg");
\r
283 > + params.crypto.gpgctx = g_mime_gpg_context_new (session, "gpg");
\r
285 > - if (params.cryptoctx) {
\r
286 > - g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.cryptoctx, FALSE);
\r
287 > + if (params.crypto.gpgctx) {
\r
288 > + g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.crypto.gpgctx, FALSE);
\r
290 > - params.decrypt = FALSE;
\r
291 > + params.crypto.decrypt = FALSE;
\r
292 > fprintf (stderr, "Failed to construct gpg context.\n");
\r
294 > #ifndef GMIME_ATLEAST_26
\r
295 > @@ -1118,8 +1118,8 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
296 > notmuch_query_destroy (query);
\r
297 > notmuch_database_destroy (notmuch);
\r
299 > - if (params.cryptoctx)
\r
300 > - g_object_unref(params.cryptoctx);
\r
301 > + if (params.crypto.gpgctx)
\r
302 > + g_object_unref(params.crypto.gpgctx);
\r
309 > _______________________________________________
\r
310 > notmuch mailing list
\r
311 > notmuch@notmuchmail.org
\r
312 > http://notmuchmail.org/mailman/listinfo/notmuch
\r