Re: [feature request] emacs: use `notmuch insert` for FCC
[notmuch-archives.git] / 3c / 1e830a0126746f0075cba9549af4999d661315
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 9DAD2431FD6\r
6         for <notmuch@notmuchmail.org>; Fri, 29 Jun 2012 11:38:30 -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 4szEgKtnTe2V for <notmuch@notmuchmail.org>;\r
16         Fri, 29 Jun 2012 11:38:30 -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 0DFAE431FCF\r
20         for <notmuch@notmuchmail.org>; Fri, 29 Jun 2012 11:38:30 -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 C1FB866E030A\r
23         for <notmuch@notmuchmail.org>; Fri, 29 Jun 2012 11:38:27 -0700 (PDT)\r
24 X-Spam-Scanned: at Caltech-IMSS on earth-doxen by amavisd-new\r
25 Received: from finestructure.net (gwave-70.ligo.caltech.edu [131.215.114.70])\r
26         (Authenticated sender: jrollins)\r
27         by earth-doxen-submit (Postfix) with ESMTP id F1E4466E0306\r
28         for <notmuch@notmuchmail.org>; Fri, 29 Jun 2012 11:38:25 -0700 (PDT)\r
29 Received: by finestructure.net (Postfix, from userid 1000)\r
30         id D50D62E97; Fri, 29 Jun 2012 11:38:25 -0700 (PDT)\r
31 From: Jameson Graef Rollins <jrollins@finestructure.net>\r
32 To: Notmuch Mail <notmuch@notmuchmail.org>\r
33 Subject: [PATCH 1/2] cli: S/MIME verification/decryption support\r
34 Date: Fri, 29 Jun 2012 11:38:20 -0700\r
35 Message-Id: <1340995101-9616-2-git-send-email-jrollins@finestructure.net>\r
36 X-Mailer: git-send-email 1.7.10\r
37 In-Reply-To: <1340995101-9616-1-git-send-email-jrollins@finestructure.net>\r
38 References: <1340995101-9616-1-git-send-email-jrollins@finestructure.net>\r
39 X-BeenThere: notmuch@notmuchmail.org\r
40 X-Mailman-Version: 2.1.13\r
41 Precedence: list\r
42 List-Id: "Use and development of the notmuch mail system."\r
43         <notmuch.notmuchmail.org>\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
45         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
47 List-Post: <mailto:notmuch@notmuchmail.org>\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
51 X-List-Received-Date: Fri, 29 Jun 2012 18:38:31 -0000\r
52 \r
53 The notmuch-show flags --decrypt and --verify will now also process\r
54 S/MIME multiparts if encountered.  Requires gmime-2.6 and gpgsm.\r
55 ---\r
56  crypto.c         |   21 +++++++++++++++++++++\r
57  notmuch-client.h |    5 +++--\r
58  2 files changed, 24 insertions(+), 2 deletions(-)\r
59 \r
60 diff --git a/crypto.c b/crypto.c\r
61 index fbe5aeb..551ffc5 100644\r
62 --- a/crypto.c\r
63 +++ b/crypto.c\r
64 @@ -52,6 +52,22 @@ notmuch_crypto_get_context (notmuch_crypto_t *crypto, const char *protocol)\r
65         }\r
66         cryptoctx = crypto->gpgctx;\r
67  \r
68 +#ifdef GMIME_ATLEAST_26\r
69 +    } else if ((strcasecmp (protocol, "application/pkcs7-signature") == 0)\r
70 +              || (strcasecmp (protocol, "application/x-pkcs7-signature") == 0)\r
71 +              || (strcasecmp (protocol, "application/pkcs7-encrypted") == 0)) {\r
72 +       if (!crypto->pkcs7ctx) {\r
73 +           /* TODO: GMimePasswordRequestFunc */\r
74 +           crypto->pkcs7ctx = g_mime_pkcs7_context_new (NULL);\r
75 +           if (crypto->pkcs7ctx) {\r
76 +               g_mime_pkcs7_context_set_always_trust ((GMimePkcs7Context*) crypto->pkcs7ctx, FALSE);\r
77 +           } else {\r
78 +               fprintf (stderr, "Failed to construct pkcs7 context.\n");\r
79 +           }\r
80 +       }\r
81 +       cryptoctx = crypto->pkcs7ctx;\r
82 +\r
83 +#endif\r
84      } else {\r
85         fprintf (stderr, "Unknown or unsupported cryptographic protocol.\n");\r
86      }\r
87 @@ -67,5 +83,10 @@ notmuch_crypto_cleanup (notmuch_crypto_t *crypto)\r
88         crypto->gpgctx = NULL;\r
89      }\r
90  \r
91 +    if (crypto->pkcs7ctx) {\r
92 +       g_object_unref (crypto->pkcs7ctx);\r
93 +       crypto->pkcs7ctx = NULL;\r
94 +    }\r
95 +\r
96      return 0;\r
97  }\r
98 diff --git a/notmuch-client.h b/notmuch-client.h\r
99 index 9b63eae..72edd50 100644\r
100 --- a/notmuch-client.h\r
101 +++ b/notmuch-client.h\r
102 @@ -79,6 +79,7 @@ typedef struct notmuch_show_format {\r
103  \r
104  typedef struct notmuch_crypto {\r
105      notmuch_crypto_context_t* gpgctx;\r
106 +    notmuch_crypto_context_t* pkcs7ctx;\r
107      notmuch_bool_t verify;\r
108      notmuch_bool_t decrypt;\r
109  } notmuch_crypto_t;\r
110 @@ -353,8 +354,8 @@ struct mime_node {\r
111  /* Construct a new MIME node pointing to the root message part of\r
112   * message. If crypto->verify is true, signed child parts will be\r
113   * verified. If crypto->decrypt is true, encrypted child parts will be\r
114 - * decrypted.  If crypto->gpgctx is NULL, it will be lazily\r
115 - * initialized.\r
116 + * decrypted.  If the crypto contexts (crypto->gpgctx or\r
117 + * crypto->pkcs7) are NULL, they will be lazily initialized.\r
118   *\r
119   * Return value:\r
120   *\r
121 -- \r
122 1.7.10\r
123 \r