Re: [PATCH v4 13/16] add indexopts to notmuch python bindings.
[notmuch-archives.git] / 93 / 9056dc738a514a2860d847cbfb539e98cbac2e
1 Return-Path: <bremner@tesseract.cs.unb.ca>\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 8F466431FDB\r
6         for <notmuch@notmuchmail.org>; Mon,  9 Mar 2015 13:53:57 -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.438\r
10 X-Spam-Level: **\r
11 X-Spam-Status: No, score=2.438 tagged_above=-999 required=5\r
12         tests=[DNS_FROM_AHBL_RHSBL=2.438] 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 QdS02rtIEFXh for <notmuch@notmuchmail.org>;\r
16         Mon,  9 Mar 2015 13:53:55 -0700 (PDT)\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
18         [87.98.215.224])\r
19         (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id D004D431FBC\r
22         for <notmuch@notmuchmail.org>; Mon,  9 Mar 2015 13:53:51 -0700 (PDT)\r
23 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
24         4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
25         id 1YV4eY-00063o-So; Mon, 09 Mar 2015 20:51:54 +0000\r
26 Received: (nullmailer pid 22322 invoked by uid 1000); Mon, 09 Mar 2015\r
27         20:51:32 -0000\r
28 From: David Bremner <david@tethera.net>\r
29 To: Jani Nikula <jani@nikula.org>, David Bremner <david@tethera.net>,\r
30         notmuch@notmuchmail.org\r
31 Subject: [Patch v2 2/2] CLI: make gpg binary used by libgmime configurable.\r
32 Date: Mon,  9 Mar 2015 21:51:23 +0100\r
33 Message-Id: <1425934283-22269-2-git-send-email-david@tethera.net>\r
34 X-Mailer: git-send-email 2.1.4\r
35 In-Reply-To: <1425934283-22269-1-git-send-email-david@tethera.net>\r
36 References: <87fv9givdr.fsf@nikula.org>\r
37         <1425934283-22269-1-git-send-email-david@tethera.net>\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.13\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Mon, 09 Mar 2015 20:53:58 -0000\r
51 \r
52 Previously we set up a way for the top level notmuch command to choose\r
53 which gpg binary was invoked by libgmime. In this commit we add the\r
54 (mostly boilerplate) code to allow the notmuch-config command to read\r
55 and write this path, and use it in the appropriate struct.\r
56 ---\r
57  doc/man1/notmuch-config.rst |  8 ++++++++\r
58  notmuch-client.h            |  7 +++++++\r
59  notmuch-config.c            | 35 ++++++++++++++++++++++++++++++++++-\r
60  notmuch-reply.c             |  2 ++\r
61  notmuch-show.c              |  2 ++\r
62  5 files changed, 53 insertions(+), 1 deletion(-)\r
63 \r
64 diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst\r
65 index 2676a86..40c1272 100644\r
66 --- a/doc/man1/notmuch-config.rst\r
67 +++ b/doc/man1/notmuch-config.rst\r
68 @@ -125,6 +125,14 @@ The available configuration items are described below.\r
69  \r
70          Default: ``true``.\r
71  \r
72 +    **crypto.gpg_path**\r
73 +\r
74 +        Name (or full path) of gpg binary to use in verification and\r
75 +        decryption of PGP/MIME messages.\r
76 +    \r
77 +        Default: ``gpg``.\r
78 +\r
79 +\r
80  ENVIRONMENT\r
81  ===========\r
82  \r
83 diff --git a/notmuch-client.h b/notmuch-client.h\r
84 index c25c4ea..fb3021c 100644\r
85 --- a/notmuch-client.h\r
86 +++ b/notmuch-client.h\r
87 @@ -279,6 +279,13 @@ notmuch_config_set_database_path (notmuch_config_t *config,\r
88                                   const char *database_path);\r
89  \r
90  const char *\r
91 +notmuch_config_get_crypto_gpg_path (notmuch_config_t *config);\r
92 +\r
93 +void\r
94 +notmuch_config_set_crypto_gpg_path (notmuch_config_t *config,\r
95 +                                 const char *gpg_path);\r
96 +\r
97 +const char *\r
98  notmuch_config_get_user_name (notmuch_config_t *config);\r
99  \r
100  void\r
101 diff --git a/notmuch-config.c b/notmuch-config.c\r
102 index a564bca..2d5c297 100644\r
103 --- a/notmuch-config.c\r
104 +++ b/notmuch-config.c\r
105 @@ -101,12 +101,21 @@ static const char search_config_comment[] =\r
106      "\t\tsearch results by default.  Using an excluded tag in a\n"\r
107      "\t\tquery will override that exclusion.\n";\r
108  \r
109 +static const char crypto_config_comment[] =\r
110 +    " Cryptography related configuration\n"\r
111 +    "\n"\r
112 +    " The following option is supported here:\n"\r
113 +    "\n"\r
114 +    "\tgpg_path\n"\r
115 +    "\t\tbinary name or full path to invoke gpg.\n";\r
116 +\r
117  struct _notmuch_config {\r
118      char *filename;\r
119      GKeyFile *key_file;\r
120      notmuch_bool_t is_new;\r
121  \r
122      char *database_path;\r
123 +    char *crypto_gpg_path;\r
124      char *user_name;\r
125      char *user_primary_email;\r
126      const char **user_other_email;\r
127 @@ -244,6 +253,7 @@ notmuch_config_open (void *ctx,\r
128      int file_had_user_group;\r
129      int file_had_maildir_group;\r
130      int file_had_search_group;\r
131 +    int file_had_crypto_group;\r
132  \r
133      notmuch_config_t *config = talloc (ctx, notmuch_config_t);\r
134      if (config == NULL) {\r
135 @@ -277,6 +287,7 @@ notmuch_config_open (void *ctx,\r
136      config->maildir_synchronize_flags = TRUE;\r
137      config->search_exclude_tags = NULL;\r
138      config->search_exclude_tags_length = 0;\r
139 +    config->crypto_gpg_path = NULL;\r
140  \r
141      if (! g_key_file_load_from_file (config->key_file,\r
142                                      config->filename,\r
143 @@ -326,7 +337,7 @@ notmuch_config_open (void *ctx,\r
144      file_had_user_group = g_key_file_has_group (config->key_file, "user");\r
145      file_had_maildir_group = g_key_file_has_group (config->key_file, "maildir");\r
146      file_had_search_group = g_key_file_has_group (config->key_file, "search");\r
147 -\r
148 +    file_had_crypto_group = g_key_file_has_group (config->key_file, "crypto");\r
149  \r
150      if (notmuch_config_get_database_path (config) == NULL) {\r
151         char *path = getenv ("MAILDIR");\r
152 @@ -406,6 +417,10 @@ notmuch_config_open (void *ctx,\r
153         g_error_free (error);\r
154      }\r
155  \r
156 +    if (notmuch_config_get_crypto_gpg_path (config) == NULL) {\r
157 +       notmuch_config_set_crypto_gpg_path (config, "gpg");\r
158 +    }\r
159 +    \r
160      /* Whenever we know of configuration sections that don't appear in\r
161       * the configuration file, we add some comments to help the user\r
162       * understand what can be done. */\r
163 @@ -433,6 +448,10 @@ notmuch_config_open (void *ctx,\r
164         g_key_file_set_comment (config->key_file, "search", NULL,\r
165                                 search_config_comment, NULL);\r
166  \r
167 +    if (! file_had_crypto_group)\r
168 +       g_key_file_set_comment (config->key_file, "crypto", NULL,\r
169 +                               crypto_config_comment, NULL);\r
170 +\r
171      return config;\r
172  }\r
173  \r
174 @@ -690,6 +709,20 @@ notmuch_config_set_search_exclude_tags (notmuch_config_t *config,\r
175                       &(config->search_exclude_tags));\r
176  }\r
177  \r
178 +const char *\r
179 +notmuch_config_get_crypto_gpg_path (notmuch_config_t *config)\r
180 +{\r
181 +    return _config_get (config, &config->crypto_gpg_path, "crypto", "gpg_path");\r
182 +}\r
183 +\r
184 +void\r
185 +notmuch_config_set_crypto_gpg_path (notmuch_config_t *config,\r
186 +                             const char *gpg_path)\r
187 +{\r
188 +    _config_set (config, &config->crypto_gpg_path, "crypto", "gpg_path", gpg_path);\r
189 +}\r
190 +\r
191 +\r
192  /* Given a configuration item of the form <group>.<key> return the\r
193   * component group and key. If any error occurs, print a message on\r
194   * stderr and return 1. Otherwise, return 0.\r
195 diff --git a/notmuch-reply.c b/notmuch-reply.c\r
196 index e18370f..d51fdfc 100644\r
197 --- a/notmuch-reply.c\r
198 +++ b/notmuch-reply.c\r
199 @@ -822,6 +822,8 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])\r
200         return EXIT_FAILURE;\r
201      }\r
202  \r
203 +    params.crypto.gpgpath = notmuch_config_get_crypto_gpg_path (config);\r
204 +\r
205      if (notmuch_database_open (notmuch_config_get_database_path (config),\r
206                                NOTMUCH_DATABASE_MODE_READ_ONLY, &notmuch))\r
207         return EXIT_FAILURE;\r
208 diff --git a/notmuch-show.c b/notmuch-show.c\r
209 index d292f29..43bf71c 100644\r
210 --- a/notmuch-show.c\r
211 +++ b/notmuch-show.c\r
212 @@ -1204,6 +1204,8 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])\r
213         return EXIT_FAILURE;\r
214      }\r
215  \r
216 +    params.crypto.gpgpath = notmuch_config_get_crypto_gpg_path (config);\r
217 +\r
218      if (notmuch_database_open (notmuch_config_get_database_path (config),\r
219                                NOTMUCH_DATABASE_MODE_READ_ONLY, &notmuch))\r
220         return EXIT_FAILURE;\r
221 -- \r
222 2.1.4\r
223 \r