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 A3902431FDD
\r
6 for <notmuch@notmuchmail.org>; Sun, 18 Jan 2015 02:45:48 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"
\r
12 X-Spam-Status: No, score=1.738 tagged_above=-999 required=5
\r
13 tests=[DNS_FROM_AHBL_RHSBL=2.438, RCVD_IN_DNSWL_LOW=-0.7]
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id VVjYkxWf2gXE for <notmuch@notmuchmail.org>;
\r
18 Sun, 18 Jan 2015 02:45:45 -0800 (PST)
\r
19 Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com
\r
20 [209.85.212.180]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
21 (No client certificate requested)
\r
22 by olra.theworths.org (Postfix) with ESMTPS id E2A6F431FB6
\r
23 for <notmuch@notmuchmail.org>; Sun, 18 Jan 2015 02:45:44 -0800 (PST)
\r
24 Received: by mail-wi0-f180.google.com with SMTP id bs8so11170668wib.1
\r
25 for <notmuch@notmuchmail.org>; Sun, 18 Jan 2015 02:45:43 -0800 (PST)
\r
26 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
27 d=1e100.net; s=20130820;
\r
28 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
\r
29 :references:in-reply-to:references;
\r
30 bh=uBZu6WMShVr+8R9ONNtyHu8Edtyja5mRtLal+cUwoDA=;
\r
31 b=i+E3QpXBK1xKvlp2JfDJ/Uyv2vksHOr7hp/7cpfU2SVsNs/qNP3PUiSuM03VNF3dmD
\r
32 +8DlsxzYQuocdPC4zaT1bS1gpahcusDnyR/XP7fsoxFLBI/2WerRmE0Ty58PTBlRHLKd
\r
33 m5stb1ISE9M+BwDRvkdCT93rPXHNwY0wUol0B/FI7lnz43f4M4bdcDTjremBjJbVK8+c
\r
34 Ri0O6l5VTFODYzg1Gg6uJVw1R+EU/+Dh82QAbw7b1zEi/nHp5x4PwxC4kmrv3C7bjFYH
\r
35 34GNnVWiOUO04OMRXX+ezHaLvsP0VT8pNNw8MauXqN4QaB0X6hd1KdKddY62LBD2ddY3
\r
38 ALoCoQkt1wtb0YEhZ/k7iy6NWzFeHiIxoyxxB6S/cd7YVMLXKSTqJs9hAIs7HOcxAJ0YAYQRGoPj
\r
39 X-Received: by 10.194.88.131 with SMTP id bg3mr45711384wjb.99.1421577943654;
\r
40 Sun, 18 Jan 2015 02:45:43 -0800 (PST)
\r
41 Received: from localhost (mobile-internet-bcee14-89.dhcp.inet.fi.
\r
42 [188.238.20.89]) by mx.google.com with ESMTPSA id
\r
43 ww4sm12903629wjc.47.2015.01.18.02.45.42
\r
44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
\r
45 Sun, 18 Jan 2015 02:45:43 -0800 (PST)
\r
46 From: Jani Nikula <jani@nikula.org>
\r
47 To: david@tethera.net,
\r
48 notmuch@notmuchmail.org
\r
49 Subject: [PATCH 1/3] crypto: refactor context creation to facilitate further
\r
51 Date: Sun, 18 Jan 2015 12:45:51 +0200
\r
53 <760fe8048f9f3a641297a40ed129abc6695b6b94.1421577605.git.jani@nikula.org>
\r
54 X-Mailer: git-send-email 2.1.4
\r
55 In-Reply-To: <cover.1421577605.git.jani@nikula.org>
\r
56 References: <1421568167-18683-3-git-send-email-david@tethera.net>
\r
57 <cover.1421577605.git.jani@nikula.org>
\r
58 In-Reply-To: <cover.1421577605.git.jani@nikula.org>
\r
59 References: <cover.1421577605.git.jani@nikula.org>
\r
60 X-BeenThere: notmuch@notmuchmail.org
\r
61 X-Mailman-Version: 2.1.13
\r
63 List-Id: "Use and development of the notmuch mail system."
\r
64 <notmuch.notmuchmail.org>
\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
66 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
68 List-Post: <mailto:notmuch@notmuchmail.org>
\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
71 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
72 X-List-Received-Date: Sun, 18 Jan 2015 10:45:48 -0000
\r
75 crypto.c | 27 +++++++++++++++++----------
\r
76 1 file changed, 17 insertions(+), 10 deletions(-)
\r
78 diff --git a/crypto.c b/crypto.c
\r
79 index 6f4a6db9d0f1..7cd7b69d1221 100644
\r
84 /* Create a GPG context (GMime 2.6) */
\r
85 static notmuch_crypto_context_t *
\r
86 -create_gpg_context (void)
\r
87 +create_gpg_context (notmuch_crypto_t *crypto)
\r
89 notmuch_crypto_context_t *gpgctx;
\r
91 + if (crypto->gpgctx)
\r
92 + return crypto->gpgctx;
\r
94 /* TODO: GMimePasswordRequestFunc */
\r
95 gpgctx = g_mime_gpg_context_new (NULL, "gpg");
\r
98 + fprintf (stderr, "Failed to construct gpg context.\n");
\r
101 + crypto->gpgctx = gpgctx;
\r
103 g_mime_gpg_context_set_use_agent ((GMimeGpgContext *) gpgctx, TRUE);
\r
104 g_mime_gpg_context_set_always_trust ((GMimeGpgContext *) gpgctx, FALSE);
\r
105 @@ -43,17 +49,23 @@ create_gpg_context (void)
\r
107 /* Create a GPG context (GMime 2.4) */
\r
108 static notmuch_crypto_context_t *
\r
109 -create_gpg_context (void)
\r
110 +create_gpg_context (notmuch_crypto_t *crypto)
\r
112 GMimeSession *session;
\r
113 notmuch_crypto_context_t *gpgctx;
\r
115 + if (crypto->gpgctx)
\r
116 + return crypto->gpgctx;
\r
118 session = g_object_new (g_mime_session_get_type (), NULL);
\r
119 gpgctx = g_mime_gpg_context_new (session, "gpg");
\r
120 g_object_unref (session);
\r
124 + fprintf (stderr, "Failed to construct gpg context.\n");
\r
127 + crypto->gpgctx = gpgctx;
\r
129 g_mime_gpg_context_set_always_trust ((GMimeGpgContext *) gpgctx, FALSE);
\r
131 @@ -82,12 +94,7 @@ notmuch_crypto_get_context (notmuch_crypto_t *crypto, const char *protocol)
\r
133 if (strcasecmp (protocol, "application/pgp-signature") == 0 ||
\r
134 strcasecmp (protocol, "application/pgp-encrypted") == 0) {
\r
135 - if (! crypto->gpgctx) {
\r
136 - crypto->gpgctx = create_gpg_context ();
\r
137 - if (! crypto->gpgctx)
\r
138 - fprintf (stderr, "Failed to construct gpg context.\n");
\r
140 - cryptoctx = crypto->gpgctx;
\r
141 + cryptoctx = create_gpg_context (crypto);
\r
143 fprintf (stderr, "Unknown or unsupported cryptographic protocol.\n");
\r