1 Return-Path: <jrollins@finestructure.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 olra.theworths.org (Postfix) with ESMTP id 74911429E25
\r
6 for <notmuch@notmuchmail.org>; Sat, 26 May 2012 11:45:56 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_MED=-2.3] 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 gZ81DvvEUvUv for <notmuch@notmuchmail.org>;
\r
16 Sat, 26 May 2012 11:45:55 -0700 (PDT)
\r
17 Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu
\r
19 by olra.theworths.org (Postfix) with ESMTP id 173E7431FC0
\r
20 for <notmuch@notmuchmail.org>; Sat, 26 May 2012 11:45:55 -0700 (PDT)
\r
21 Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1])
\r
22 by fire-doxen-postvirus (Postfix) with ESMTP id B3C88328020
\r
23 for <notmuch@notmuchmail.org>; Sat, 26 May 2012 11:45:54 -0700 (PDT)
\r
24 X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new
\r
25 Received: from finestructure.net (unknown [76.89.192.57])
\r
26 (Authenticated sender: jrollins)
\r
27 by fire-doxen-submit (Postfix) with ESMTP id D1F172E50D08
\r
28 for <notmuch@notmuchmail.org>; Sat, 26 May 2012 11:45:51 -0700 (PDT)
\r
29 Received: by finestructure.net (Postfix, from userid 1000)
\r
30 id 6CAE4B5B; Sat, 26 May 2012 11:45:51 -0700 (PDT)
\r
31 From: Jameson Graef Rollins <jrollins@finestructure.net>
\r
32 To: Notmuch Mail <notmuch@notmuchmail.org>
\r
33 Subject: [PATCH v5 3/7] cli: modify show and reply to use new crypto struct
\r
34 Date: Sat, 26 May 2012 11:45:42 -0700
\r
35 Message-Id: <1338057946-29209-4-git-send-email-jrollins@finestructure.net>
\r
36 X-Mailer: git-send-email 1.7.10
\r
37 In-Reply-To: <1338057946-29209-3-git-send-email-jrollins@finestructure.net>
\r
38 References: <1338057946-29209-1-git-send-email-jrollins@finestructure.net>
\r
39 <1338057946-29209-2-git-send-email-jrollins@finestructure.net>
\r
40 <1338057946-29209-3-git-send-email-jrollins@finestructure.net>
\r
41 X-BeenThere: notmuch@notmuchmail.org
\r
42 X-Mailman-Version: 2.1.13
\r
44 List-Id: "Use and development of the notmuch mail system."
\r
45 <notmuch.notmuchmail.org>
\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
49 List-Post: <mailto:notmuch@notmuchmail.org>
\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
53 X-List-Received-Date: Sat, 26 May 2012 18:45:56 -0000
\r
55 notmuch_show_params_t is modified to use the new notmuch_crypto_t, and
\r
56 notmuch-show and notmuch-reply are modified accordingly.
\r
58 notmuch-client.h | 3 +--
\r
59 notmuch-reply.c | 29 ++++++++++++++++-------------
\r
60 notmuch-show.c | 30 +++++++++++++++++-------------
\r
61 3 files changed, 34 insertions(+), 28 deletions(-)
\r
63 diff --git a/notmuch-client.h b/notmuch-client.h
\r
64 index 6664075..ead7fbd 100644
\r
65 --- a/notmuch-client.h
\r
66 +++ b/notmuch-client.h
\r
67 @@ -87,8 +87,7 @@ typedef struct notmuch_show_params {
\r
68 notmuch_bool_t omit_excluded;
\r
71 - notmuch_crypto_context_t* cryptoctx;
\r
72 - notmuch_bool_t decrypt;
\r
73 + notmuch_crypto_t crypto;
\r
74 } notmuch_show_params_t;
\r
76 /* There's no point in continuing when we've detected that we've done
\r
77 diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
78 index 0f92a2e..11f269f 100644
\r
79 --- a/notmuch-reply.c
\r
80 +++ b/notmuch-reply.c
\r
81 @@ -575,7 +575,7 @@ notmuch_reply_format_default(void *ctx,
\r
82 g_object_unref (G_OBJECT (reply));
\r
85 - if (mime_node_open (ctx, message, params->cryptoctx, params->decrypt,
\r
86 + if (mime_node_open (ctx, message, params->crypto.gpgctx, params->crypto.decrypt,
\r
87 &root) == NOTMUCH_STATUS_SUCCESS) {
\r
88 format_part_reply (root);
\r
90 @@ -605,7 +605,7 @@ notmuch_reply_format_json(void *ctx,
\r
92 messages = notmuch_query_search_messages (query);
\r
93 message = notmuch_messages_get (messages);
\r
94 - if (mime_node_open (ctx, message, params->cryptoctx, params->decrypt,
\r
95 + if (mime_node_open (ctx, message, params->crypto.gpgctx, params->crypto.decrypt,
\r
96 &node) != NOTMUCH_STATUS_SUCCESS)
\r
99 @@ -706,7 +706,12 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
100 char *query_string;
\r
101 int opt_index, ret = 0;
\r
102 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
103 - notmuch_show_params_t params = { .part = -1 };
\r
104 + notmuch_show_params_t params = {
\r
110 int format = FORMAT_DEFAULT;
\r
111 int reply_all = TRUE;
\r
113 @@ -720,7 +725,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
114 (notmuch_keyword_t []){ { "all", TRUE },
\r
115 { "sender", FALSE },
\r
117 - { NOTMUCH_OPT_BOOLEAN, ¶ms.decrypt, "decrypt", 'd', 0 },
\r
118 + { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.decrypt, "decrypt", 'd', 0 },
\r
122 @@ -737,18 +742,18 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
124 reply_format_func = notmuch_reply_format_default;
\r
126 - if (params.decrypt) {
\r
127 + if (params.crypto.decrypt) {
\r
128 #ifdef GMIME_ATLEAST_26
\r
129 /* TODO: GMimePasswordRequestFunc */
\r
130 - params.cryptoctx = g_mime_gpg_context_new (NULL, "gpg");
\r
131 + params.crypto.gpgctx = g_mime_gpg_context_new (NULL, "gpg");
\r
133 GMimeSession* session = g_object_new (g_mime_session_get_type(), NULL);
\r
134 - params.cryptoctx = g_mime_gpg_context_new (session, "gpg");
\r
135 + params.crypto.gpgctx = g_mime_gpg_context_new (session, "gpg");
\r
137 - if (params.cryptoctx) {
\r
138 - g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.cryptoctx, FALSE);
\r
139 + if (params.crypto.gpgctx) {
\r
140 + g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.crypto.gpgctx, FALSE);
\r
142 - params.decrypt = FALSE;
\r
143 + params.crypto.decrypt = FALSE;
\r
144 fprintf (stderr, "Failed to construct gpg context.\n");
\r
146 #ifndef GMIME_ATLEAST_26
\r
147 @@ -784,11 +789,9 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
148 if (reply_format_func (ctx, config, query, ¶ms, reply_all) != 0)
\r
151 + notmuch_crypto_cleanup (¶ms.crypto);
\r
152 notmuch_query_destroy (query);
\r
153 notmuch_database_destroy (notmuch);
\r
155 - if (params.cryptoctx)
\r
156 - g_object_unref(params.cryptoctx);
\r
160 diff --git a/notmuch-show.c b/notmuch-show.c
\r
161 index 95427d4..cc509a6 100644
\r
162 --- a/notmuch-show.c
\r
163 +++ b/notmuch-show.c
\r
164 @@ -810,8 +810,8 @@ show_message (void *ctx,
\r
165 mime_node_t *root, *part;
\r
166 notmuch_status_t status;
\r
168 - status = mime_node_open (local, message, params->cryptoctx,
\r
169 - params->decrypt, &root);
\r
170 + status = mime_node_open (local, message, params->crypto.gpgctx,
\r
171 + params->crypto.decrypt, &root);
\r
174 part = mime_node_seek_dfs (root, (params->part < 0 ? 0 : params->part));
\r
175 @@ -984,7 +984,13 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
176 char *query_string;
\r
177 int opt_index, ret;
\r
178 const notmuch_show_format_t *format = &format_text;
\r
179 - notmuch_show_params_t params = { .part = -1, .omit_excluded = TRUE };
\r
180 + notmuch_show_params_t params = {
\r
182 + .omit_excluded = TRUE,
\r
187 int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
\r
188 notmuch_bool_t verify = FALSE;
\r
189 int exclude = EXCLUDE_TRUE;
\r
190 @@ -1002,7 +1008,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
192 { NOTMUCH_OPT_INT, ¶ms.part, "part", 'p', 0 },
\r
193 { NOTMUCH_OPT_BOOLEAN, ¶ms.entire_thread, "entire-thread", 't', 0 },
\r
194 - { NOTMUCH_OPT_BOOLEAN, ¶ms.decrypt, "decrypt", 'd', 0 },
\r
195 + { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.decrypt, "decrypt", 'd', 0 },
\r
196 { NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 },
\r
199 @@ -1047,18 +1053,18 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
203 - if (params.decrypt || verify) {
\r
204 + if (params.crypto.decrypt || verify) {
\r
205 #ifdef GMIME_ATLEAST_26
\r
206 /* TODO: GMimePasswordRequestFunc */
\r
207 - params.cryptoctx = g_mime_gpg_context_new (NULL, "gpg");
\r
208 + params.crypto.gpgctx = g_mime_gpg_context_new (NULL, "gpg");
\r
210 GMimeSession* session = g_object_new (g_mime_session_get_type(), NULL);
\r
211 - params.cryptoctx = g_mime_gpg_context_new (session, "gpg");
\r
212 + params.crypto.gpgctx = g_mime_gpg_context_new (session, "gpg");
\r
214 - if (params.cryptoctx) {
\r
215 - g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.cryptoctx, FALSE);
\r
216 + if (params.crypto.gpgctx) {
\r
217 + g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.crypto.gpgctx, FALSE);
\r
219 - params.decrypt = FALSE;
\r
220 + params.crypto.decrypt = FALSE;
\r
221 fprintf (stderr, "Failed to construct gpg context.\n");
\r
223 #ifndef GMIME_ATLEAST_26
\r
224 @@ -1115,11 +1121,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
225 ret = do_show (ctx, query, format, ¶ms);
\r
228 + notmuch_crypto_cleanup (¶ms.crypto);
\r
229 notmuch_query_destroy (query);
\r
230 notmuch_database_destroy (notmuch);
\r
232 - if (params.cryptoctx)
\r
233 - g_object_unref(params.cryptoctx);
\r