Re: [PATCH v4 10/16] Add n_d_add_message_with_indexopts (extension of n_d_add_message)
[notmuch-archives.git] / 57 / 4812f7ffc54b61e6cef287cf76299d574d5402
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 35DC7431FBD\r
6         for <notmuch@notmuchmail.org>; Mon,  9 Mar 2015 13:53:46 -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 xDgkuGY3z0qJ for <notmuch@notmuchmail.org>;\r
16         Mon,  9 Mar 2015 13:53:43 -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 E6BFA431FBC\r
22         for <notmuch@notmuchmail.org>; Mon,  9 Mar 2015 13:53:42 -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 1YV4eL-00063c-Hs; Mon, 09 Mar 2015 20:51:41 +0000\r
26 Received: (nullmailer pid 22313 invoked by uid 1000); Mon, 09 Mar 2015\r
27         20:51:28 -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 1/2] CLI: set up infrastructure to make path to gpg\r
32         configurable.\r
33 Date: Mon,  9 Mar 2015 21:51:22 +0100\r
34 Message-Id: <1425934283-22269-1-git-send-email-david@tethera.net>\r
35 X-Mailer: git-send-email 2.1.4\r
36 In-Reply-To: <87fv9givdr.fsf@nikula.org>\r
37 References: <87fv9givdr.fsf@nikula.org>\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:46 -0000\r
51 \r
52 GMIME takes a path to gpg, but we hardcode that path.  In this commit\r
53 we set up argument passing and option storage to allow this path to\r
54 specified in the top level notmuch command.\r
55 ---\r
56  crypto.c         | 10 +++++-----\r
57  notmuch-client.h |  1 +\r
58  notmuch-reply.c  |  3 ++-\r
59  notmuch-show.c   |  3 ++-\r
60  4 files changed, 10 insertions(+), 7 deletions(-)\r
61 \r
62 diff --git a/crypto.c b/crypto.c\r
63 index 6f4a6db..026640f 100644\r
64 --- a/crypto.c\r
65 +++ b/crypto.c\r
66 @@ -24,12 +24,12 @@\r
67  \r
68  /* Create a GPG context (GMime 2.6) */\r
69  static notmuch_crypto_context_t *\r
70 -create_gpg_context (void)\r
71 +create_gpg_context (const char *gpgpath)\r
72  {\r
73      notmuch_crypto_context_t *gpgctx;\r
74  \r
75      /* TODO: GMimePasswordRequestFunc */\r
76 -    gpgctx = g_mime_gpg_context_new (NULL, "gpg");\r
77 +    gpgctx = g_mime_gpg_context_new (NULL, gpgpath ? gpgpath : "gpg");\r
78      if (! gpgctx)\r
79         return NULL;\r
80  \r
81 @@ -43,13 +43,13 @@ create_gpg_context (void)\r
82  \r
83  /* Create a GPG context (GMime 2.4) */\r
84  static notmuch_crypto_context_t *\r
85 -create_gpg_context (void)\r
86 +create_gpg_context (const char* gpgpath)\r
87  {\r
88      GMimeSession *session;\r
89      notmuch_crypto_context_t *gpgctx;\r
90  \r
91      session = g_object_new (g_mime_session_get_type (), NULL);\r
92 -    gpgctx = g_mime_gpg_context_new (session, "gpg");\r
93 +    gpgctx = g_mime_gpg_context_new (session, gpgpath ? gpgpath : "gpg");\r
94      g_object_unref (session);\r
95  \r
96      if (! gpgctx)\r
97 @@ -83,7 +83,7 @@ notmuch_crypto_get_context (notmuch_crypto_t *crypto, const char *protocol)\r
98      if (strcasecmp (protocol, "application/pgp-signature") == 0 ||\r
99         strcasecmp (protocol, "application/pgp-encrypted") == 0) {\r
100         if (! crypto->gpgctx) {\r
101 -           crypto->gpgctx = create_gpg_context ();\r
102 +           crypto->gpgctx = create_gpg_context (crypto->gpgpath);\r
103             if (! crypto->gpgctx)\r
104                 fprintf (stderr, "Failed to construct gpg context.\n");\r
105         }\r
106 diff --git a/notmuch-client.h b/notmuch-client.h\r
107 index 5e0d475..c25c4ea 100644\r
108 --- a/notmuch-client.h\r
109 +++ b/notmuch-client.h\r
110 @@ -80,6 +80,7 @@ typedef struct notmuch_crypto {\r
111      notmuch_crypto_context_t* gpgctx;\r
112      notmuch_bool_t verify;\r
113      notmuch_bool_t decrypt;\r
114 +    const char *gpgpath;\r
115  } notmuch_crypto_t;\r
116  \r
117  typedef struct notmuch_show_params {\r
118 diff --git a/notmuch-reply.c b/notmuch-reply.c\r
119 index 7c1c809..e18370f 100644\r
120 --- a/notmuch-reply.c\r
121 +++ b/notmuch-reply.c\r
122 @@ -769,7 +769,8 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])\r
123         .part = -1,\r
124         .crypto = {\r
125             .verify = FALSE,\r
126 -           .decrypt = FALSE\r
127 +           .decrypt = FALSE,\r
128 +           .gpgpath = NULL\r
129         }\r
130      };\r
131      int format = FORMAT_DEFAULT;\r
132 diff --git a/notmuch-show.c b/notmuch-show.c\r
133 index d416fbd..d292f29 100644\r
134 --- a/notmuch-show.c\r
135 +++ b/notmuch-show.c\r
136 @@ -1082,7 +1082,8 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])\r
137         .output_body = TRUE,\r
138         .crypto = {\r
139             .verify = FALSE,\r
140 -           .decrypt = FALSE\r
141 +           .decrypt = FALSE,\r
142 +           .gpgpath = NULL\r
143         },\r
144         .include_html = FALSE\r
145      };\r
146 -- \r
147 2.1.4\r
148 \r