Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / 27 / 2ed8015b81e6d180848be83d4987013efbb7fa
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 1A338431FB6\r
6         for <notmuch@notmuchmail.org>; Tue, 22 May 2012 18:44:01 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.3\r
10 X-Spam-Level: \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 hHqCh14u+q9e for <notmuch@notmuchmail.org>;\r
16         Tue, 22 May 2012 18:43:57 -0700 (PDT)\r
17 Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu\r
18         [131.215.239.19])\r
19         by olra.theworths.org (Postfix) with ESMTP id CAED7431FBC\r
20         for <notmuch@notmuchmail.org>; Tue, 22 May 2012 18:43:56 -0700 (PDT)\r
21 Received: from earth-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
22         by earth-doxen-postvirus (Postfix) with ESMTP id 7E49F66E0178\r
23         for <notmuch@notmuchmail.org>; Tue, 22 May 2012 18:43:56 -0700 (PDT)\r
24 X-Spam-Scanned: at Caltech-IMSS on earth-doxen by amavisd-new\r
25 Received: from finestructure.net (gwave-125.ligo.caltech.edu\r
26  [131.215.114.125])     (Authenticated sender: jrollins)        by earth-doxen-submit\r
27  (Postfix) with ESMTP id 541F266E0169   for <notmuch@notmuchmail.org>; Tue, 22\r
28  May 2012 18:43:54 -0700 (PDT)\r
29 Received: by finestructure.net (Postfix, from userid 1000)\r
30         id 35CCF1DF; Tue, 22 May 2012 18:43:54 -0700 (PDT)\r
31 From: Jameson Graef Rollins <jrollins@finestructure.net>\r
32 To: Notmuch Mail <notmuch@notmuchmail.org>\r
33 Subject: [PATCH v3 2/6] cli: modify show and reply to use new crypto struct\r
34 Date: Tue, 22 May 2012 18:43:46 -0700\r
35 Message-Id: <1337737430-21160-3-git-send-email-jrollins@finestructure.net>\r
36 X-Mailer: git-send-email 1.7.10\r
37 In-Reply-To: <1337737430-21160-2-git-send-email-jrollins@finestructure.net>\r
38 References: <1337737430-21160-1-git-send-email-jrollins@finestructure.net>\r
39         <1337737430-21160-2-git-send-email-jrollins@finestructure.net>\r
40 X-BeenThere: notmuch@notmuchmail.org\r
41 X-Mailman-Version: 2.1.13\r
42 Precedence: list\r
43 List-Id: "Use and development of the notmuch mail system."\r
44         <notmuch.notmuchmail.org>\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
48 List-Post: <mailto:notmuch@notmuchmail.org>\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
51         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
52 X-List-Received-Date: Wed, 23 May 2012 01:44:01 -0000\r
53 \r
54 notmuch_show_params_t is modified to use the new notmuch_crypto_t, and\r
55 notmuch-show and notmuch-reply are modified accordingly.\r
56 ---\r
57  notmuch-client.h |    7 +------\r
58  notmuch-reply.c  |   29 ++++++++++++++++-------------\r
59  notmuch-show.c   |   30 +++++++++++++++++-------------\r
60  3 files changed, 34 insertions(+), 32 deletions(-)\r
61 \r
62 diff --git a/notmuch-client.h b/notmuch-client.h\r
63 index 14d1e2f..86c9697 100644\r
64 --- a/notmuch-client.h\r
65 +++ b/notmuch-client.h\r
66 @@ -88,12 +88,7 @@ typedef struct notmuch_show_params {\r
67      notmuch_bool_t omit_excluded;\r
68      notmuch_bool_t raw;\r
69      int part;\r
70 -#ifdef GMIME_ATLEAST_26\r
71 -    GMimeCryptoContext* cryptoctx;\r
72 -#else\r
73 -    GMimeCipherContext* cryptoctx;\r
74 -#endif\r
75 -    notmuch_bool_t decrypt;\r
76 +    notmuch_crypto_t crypto;\r
77  } notmuch_show_params_t;\r
78  \r
79  /* There's no point in continuing when we've detected that we've done\r
80 diff --git a/notmuch-reply.c b/notmuch-reply.c\r
81 index 7184a5d..41b18e4 100644\r
82 --- a/notmuch-reply.c\r
83 +++ b/notmuch-reply.c\r
84 @@ -544,7 +544,7 @@ notmuch_reply_format_default(void *ctx,\r
85         g_object_unref (G_OBJECT (reply));\r
86         reply = NULL;\r
87  \r
88 -       if (mime_node_open (ctx, message, params->cryptoctx, params->decrypt,\r
89 +       if (mime_node_open (ctx, message, params->crypto.gpgctx, params->crypto.decrypt,\r
90                             &root) == NOTMUCH_STATUS_SUCCESS) {\r
91             format_part_reply (root);\r
92             talloc_free (root);\r
93 @@ -574,7 +574,7 @@ notmuch_reply_format_json(void *ctx,\r
94  \r
95      messages = notmuch_query_search_messages (query);\r
96      message = notmuch_messages_get (messages);\r
97 -    if (mime_node_open (ctx, message, params->cryptoctx, params->decrypt,\r
98 +    if (mime_node_open (ctx, message, params->crypto.gpgctx, params->crypto.decrypt,\r
99                         &node) != NOTMUCH_STATUS_SUCCESS)\r
100         return 1;\r
101  \r
102 @@ -675,7 +675,12 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
103      char *query_string;\r
104      int opt_index, ret = 0;\r
105      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
106 -    notmuch_show_params_t params = { .part = -1 };\r
107 +    notmuch_show_params_t params = {\r
108 +       .part = -1,\r
109 +       .crypto = {\r
110 +           .decrypt = FALSE\r
111 +       }\r
112 +    };\r
113      int format = FORMAT_DEFAULT;\r
114      int reply_all = TRUE;\r
115  \r
116 @@ -689,7 +694,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
117           (notmuch_keyword_t []){ { "all", TRUE },\r
118                                   { "sender", FALSE },\r
119                                   { 0, 0 } } },\r
120 -       { NOTMUCH_OPT_BOOLEAN, &params.decrypt, "decrypt", 'd', 0 },\r
121 +       { NOTMUCH_OPT_BOOLEAN, &params.crypto.decrypt, "decrypt", 'd', 0 },\r
122         { 0, 0, 0, 0, 0 }\r
123      };\r
124  \r
125 @@ -706,18 +711,18 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
126      else\r
127         reply_format_func = notmuch_reply_format_default;\r
128  \r
129 -    if (params.decrypt) {\r
130 +    if (params.crypto.decrypt) {\r
131  #ifdef GMIME_ATLEAST_26\r
132         /* TODO: GMimePasswordRequestFunc */\r
133 -       params.cryptoctx = g_mime_gpg_context_new (NULL, "gpg");\r
134 +       params.crypto.gpgctx = g_mime_gpg_context_new (NULL, "gpg");\r
135  #else\r
136         GMimeSession* session = g_object_new (g_mime_session_get_type(), NULL);\r
137 -       params.cryptoctx = g_mime_gpg_context_new (session, "gpg");\r
138 +       params.crypto.gpgctx = g_mime_gpg_context_new (session, "gpg");\r
139  #endif\r
140 -       if (params.cryptoctx) {\r
141 -           g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.cryptoctx, FALSE);\r
142 +       if (params.crypto.gpgctx) {\r
143 +           g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.crypto.gpgctx, FALSE);\r
144         } else {\r
145 -           params.decrypt = FALSE;\r
146 +           params.crypto.decrypt = FALSE;\r
147             fprintf (stderr, "Failed to construct gpg context.\n");\r
148         }\r
149  #ifndef GMIME_ATLEAST_26\r
150 @@ -753,11 +758,9 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
151      if (reply_format_func (ctx, config, query, &params, reply_all) != 0)\r
152         return 1;\r
153  \r
154 +    notmuch_crypto_cleanup (&params.crypto);\r
155      notmuch_query_destroy (query);\r
156      notmuch_database_destroy (notmuch);\r
157  \r
158 -    if (params.cryptoctx)\r
159 -       g_object_unref(params.cryptoctx);\r
160 -\r
161      return ret;\r
162  }\r
163 diff --git a/notmuch-show.c b/notmuch-show.c\r
164 index 95427d4..cc509a6 100644\r
165 --- a/notmuch-show.c\r
166 +++ b/notmuch-show.c\r
167 @@ -810,8 +810,8 @@ show_message (void *ctx,\r
168      mime_node_t *root, *part;\r
169      notmuch_status_t status;\r
170  \r
171 -    status = mime_node_open (local, message, params->cryptoctx,\r
172 -                            params->decrypt, &root);\r
173 +    status = mime_node_open (local, message, params->crypto.gpgctx,\r
174 +                            params->crypto.decrypt, &root);\r
175      if (status)\r
176         goto DONE;\r
177      part = mime_node_seek_dfs (root, (params->part < 0 ? 0 : params->part));\r
178 @@ -984,7 +984,13 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
179      char *query_string;\r
180      int opt_index, ret;\r
181      const notmuch_show_format_t *format = &format_text;\r
182 -    notmuch_show_params_t params = { .part = -1, .omit_excluded = TRUE };\r
183 +    notmuch_show_params_t params = {\r
184 +       .part = -1,\r
185 +       .omit_excluded = TRUE,\r
186 +       .crypto = {\r
187 +           .decrypt = FALSE\r
188 +       }\r
189 +    };\r
190      int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;\r
191      notmuch_bool_t verify = FALSE;\r
192      int exclude = EXCLUDE_TRUE;\r
193 @@ -1002,7 +1008,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
194                                    { 0, 0 } } },\r
195         { NOTMUCH_OPT_INT, &params.part, "part", 'p', 0 },\r
196         { NOTMUCH_OPT_BOOLEAN, &params.entire_thread, "entire-thread", 't', 0 },\r
197 -       { NOTMUCH_OPT_BOOLEAN, &params.decrypt, "decrypt", 'd', 0 },\r
198 +       { NOTMUCH_OPT_BOOLEAN, &params.crypto.decrypt, "decrypt", 'd', 0 },\r
199         { NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 },\r
200         { 0, 0, 0, 0, 0 }\r
201      };\r
202 @@ -1047,18 +1053,18 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
203         break;\r
204      }\r
205  \r
206 -    if (params.decrypt || verify) {\r
207 +    if (params.crypto.decrypt || verify) {\r
208  #ifdef GMIME_ATLEAST_26\r
209         /* TODO: GMimePasswordRequestFunc */\r
210 -       params.cryptoctx = g_mime_gpg_context_new (NULL, "gpg");\r
211 +       params.crypto.gpgctx = g_mime_gpg_context_new (NULL, "gpg");\r
212  #else\r
213         GMimeSession* session = g_object_new (g_mime_session_get_type(), NULL);\r
214 -       params.cryptoctx = g_mime_gpg_context_new (session, "gpg");\r
215 +       params.crypto.gpgctx = g_mime_gpg_context_new (session, "gpg");\r
216  #endif\r
217 -       if (params.cryptoctx) {\r
218 -           g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.cryptoctx, FALSE);\r
219 +       if (params.crypto.gpgctx) {\r
220 +           g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.crypto.gpgctx, FALSE);\r
221         } else {\r
222 -           params.decrypt = FALSE;\r
223 +           params.crypto.decrypt = FALSE;\r
224             fprintf (stderr, "Failed to construct gpg context.\n");\r
225         }\r
226  #ifndef GMIME_ATLEAST_26\r
227 @@ -1115,11 +1121,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
228         ret = do_show (ctx, query, format, &params);\r
229      }\r
230  \r
231 +    notmuch_crypto_cleanup (&params.crypto);\r
232      notmuch_query_destroy (query);\r
233      notmuch_database_destroy (notmuch);\r
234  \r
235 -    if (params.cryptoctx)\r
236 -       g_object_unref(params.cryptoctx);\r
237 -\r
238      return ret;\r
239  }\r
240 -- \r
241 1.7.10\r
242 \r