[Patch v3 6/8] cli: crypto: S/MIME verification support
[notmuch-archives.git] / a6 / 3c4bac4625821131e7a93d18d3f956b31a66d1
1 Return-Path: <novalazy@gmail.com>\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 529E0429E29\r
6         for <notmuch@notmuchmail.org>; Sat, 19 Jan 2013 16:51:07 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id AunlE-0+pQqC for <notmuch@notmuchmail.org>;\r
17         Sat, 19 Jan 2013 16:51:06 -0800 (PST)\r
18 Received: from mail-pb0-f48.google.com (mail-pb0-f48.google.com\r
19         [209.85.160.48]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 8C7AE431FDE\r
22         for <notmuch@notmuchmail.org>; Sat, 19 Jan 2013 16:50:58 -0800 (PST)\r
23 Received: by mail-pb0-f48.google.com with SMTP id wy12so1317990pbc.7\r
24         for <notmuch@notmuchmail.org>; Sat, 19 Jan 2013 16:50:57 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26         h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
27         :references; bh=Bzx58UkTThN5g0PYx2nrUbbkWjWhx6/7oCLg5+dn2T8=;\r
28         b=dO5F4futU6W1Yot/SOIm2WBgWgx80vld61YLjWhvAE/zMJTfp/y34FJw05uq8pdkzg\r
29         B6c4hJivfgn7eGVK6TauqW7sec6rKzN/FrMkqBgdROd5tToITNM9Kb+DCRfikI54G0aS\r
30         8L7w8C80/u0OqFCFeAlonYpj/s9P+Zy7I1PaUnPmmM83wD+SUWNF3iEs3bGMIstrdqma\r
31         WynF51cT8W1hF3M8Lac7UebEFhHGmJjJAdZDLfPnzwgKaVhtYv1tjXdXoe3ycnJBB3JL\r
32         BVveJ0RJNaAgipsFuhHDt7Z2x9QmV5+EzKqjWoStR0MQUiRJXT97i779l5yPEWyYcejx\r
33         LYxg==\r
34 X-Received: by 10.68.190.227 with SMTP id gt3mr18619897pbc.5.1358643057683;\r
35         Sat, 19 Jan 2013 16:50:57 -0800 (PST)\r
36 Received: from localhost (215.42.233.220.static.exetel.com.au.\r
37         [220.233.42.215])\r
38         by mx.google.com with ESMTPS id oi3sm5811059pbb.1.2013.01.19.16.50.55\r
39         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
40         Sat, 19 Jan 2013 16:50:57 -0800 (PST)\r
41 From: Peter Wang <novalazy@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH v3 05/20] insert: add new message to database\r
44 Date: Sun, 20 Jan 2013 11:49:49 +1100\r
45 Message-Id: <1358643004-14522-6-git-send-email-novalazy@gmail.com>\r
46 X-Mailer: git-send-email 1.7.12.1\r
47 In-Reply-To: <1358643004-14522-1-git-send-email-novalazy@gmail.com>\r
48 References: <1358643004-14522-1-git-send-email-novalazy@gmail.com>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Sun, 20 Jan 2013 00:51:08 -0000\r
62 \r
63 Add the new message to the notmuch database, renaming the file to encode\r
64 notmuch tags as maildir flags.\r
65 ---\r
66  notmuch-insert.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-\r
67  1 file changed, 48 insertions(+), 1 deletion(-)\r
68 \r
69 diff --git a/notmuch-insert.c b/notmuch-insert.c\r
70 index c0289d9..498421d 100644\r
71 --- a/notmuch-insert.c\r
72 +++ b/notmuch-insert.c\r
73 @@ -153,6 +153,44 @@ copy_stdin (int fdin, int fdout)\r
74      return TRUE;\r
75  }\r
76  \r
77 +/* Add the specified message file to the notmuch database.\r
78 + * The file is renamed to encode notmuch tags as maildir flags. */\r
79 +static notmuch_bool_t\r
80 +add_file_to_database (notmuch_database_t *notmuch, const char *path)\r
81 +{\r
82 +    notmuch_message_t *message;\r
83 +    notmuch_status_t status;\r
84 +\r
85 +    status = notmuch_database_add_message (notmuch, path, &message);\r
86 +    switch (status) {\r
87 +    case NOTMUCH_STATUS_SUCCESS:\r
88 +       break;\r
89 +    case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:\r
90 +       fprintf (stderr, "Warning: duplicate message.\n");\r
91 +       break;\r
92 +    default:\r
93 +    case NOTMUCH_STATUS_FILE_NOT_EMAIL:\r
94 +    case NOTMUCH_STATUS_READ_ONLY_DATABASE:\r
95 +    case NOTMUCH_STATUS_XAPIAN_EXCEPTION:\r
96 +    case NOTMUCH_STATUS_OUT_OF_MEMORY:\r
97 +    case NOTMUCH_STATUS_FILE_ERROR:\r
98 +    case NOTMUCH_STATUS_NULL_POINTER:\r
99 +    case NOTMUCH_STATUS_TAG_TOO_LONG:\r
100 +    case NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW:\r
101 +    case NOTMUCH_STATUS_UNBALANCED_ATOMIC:\r
102 +    case NOTMUCH_STATUS_LAST_STATUS:\r
103 +       fprintf (stderr, "Error: failed to add `%s' to notmuch database: %s\n",\r
104 +                path, notmuch_status_to_string (status));\r
105 +       return FALSE;\r
106 +    }\r
107 +\r
108 +    notmuch_message_tags_to_maildir_flags (message);\r
109 +\r
110 +    notmuch_message_destroy (message);\r
111 +\r
112 +    return TRUE;\r
113 +}\r
114 +\r
115  static notmuch_bool_t\r
116  insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,\r
117                 const char *dir)\r
118 @@ -173,8 +211,17 @@ insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,\r
119      }\r
120      if (!ret) {\r
121         unlink (tmppath);\r
122 +       return FALSE;\r
123      }\r
124 -    return ret;\r
125 +\r
126 +    ret = add_file_to_database (notmuch, newpath);\r
127 +    if (!ret) {\r
128 +       /* XXX maybe there should be an option to keep the file in maildir? */\r
129 +       unlink (newpath);\r
130 +       return FALSE;\r
131 +    }\r
132 +\r
133 +    return TRUE;\r
134  }\r
135  \r
136  int\r
137 -- \r
138 1.7.12.1\r
139 \r