1 Return-Path: <felipe.contreras@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 1A14D431FAE
\r
6 for <notmuch@notmuchmail.org>; Wed, 18 Apr 2012 05:39:56 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 iUj6WZ0qMbjg for <notmuch@notmuchmail.org>;
\r
17 Wed, 18 Apr 2012 05:39:51 -0700 (PDT)
\r
18 Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com
\r
19 [209.85.217.181]) (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 1ABAC431FC3
\r
22 for <notmuch@notmuchmail.org>; Wed, 18 Apr 2012 05:39:43 -0700 (PDT)
\r
23 Received: by lbdb5 with SMTP id b5so2794488lbd.26
\r
24 for <notmuch@notmuchmail.org>; Wed, 18 Apr 2012 05:39:42 -0700 (PDT)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
26 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references
\r
27 :mime-version:content-type:content-transfer-encoding;
\r
28 bh=DgLDlP4+izCFtyi+8mjMYjPEp4dtu4IPoIsktFOF0MM=;
\r
29 b=n3b2/Xh3KAIM/rz3iUyRdazdOyFxyEhFlu/xb6biFqefdlMtqMjeBA2v9amr/tPqzU
\r
30 fCucKgD3qHMVF30TYdkrB5naqewT1+qm6v2LYY89tYItbSC+76ILWzP4Ezd96ZN2h1pF
\r
31 6ImhadJK4DtF0Reb8aNhpzDdn4ZB/Q7QwfHteZvCL3anU4kRv06o65lKfeob3gMYBztO
\r
32 n4gUVw7ddprX/0QuLl1HbP+Zjer+F3yGG8MNvhEcX4NhsKChhlGf88y3tSSqGVXvZaun
\r
33 MG/zwsIEo7i3O17HwaS1hLss0T1mOeQCi9J4Vk7KuXlyPhz1bySwSKH4kLah0e/kLqKU
\r
35 Received: by 10.112.26.10 with SMTP id h10mr949974lbg.79.1334752782437;
\r
36 Wed, 18 Apr 2012 05:39:42 -0700 (PDT)
\r
37 Received: from localhost (85-156-70-103.elisa-mobile.fi. [85.156.70.103])
\r
38 by mx.google.com with ESMTPS id o2sm7352895lbd.7.2012.04.18.05.39.40
\r
39 (version=TLSv1/SSLv3 cipher=OTHER);
\r
40 Wed, 18 Apr 2012 05:39:41 -0700 (PDT)
\r
41 From: Felipe Contreras <felipe.contreras@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: =?UTF-8?q?=5BPATCH=20v2=201/3=5D=20Add=20=27compose=27=20command?=
\r
44 Date: Wed, 18 Apr 2012 15:39:11 +0300
\r
45 Message-Id: <1334752753-23970-2-git-send-email-felipe.contreras@gmail.com>
\r
46 X-Mailer: git-send-email 1.7.10
\r
47 In-Reply-To: <1334752753-23970-1-git-send-email-felipe.contreras@gmail.com>
\r
48 References: <1334752753-23970-1-git-send-email-felipe.contreras@gmail.com>
\r
50 Content-Type: text/plain; charset=UTF-8
\r
51 Content-Transfer-Encoding: 8bit
\r
52 Cc: Felipe Contreras <felipe.contreras@ngmail.com>
\r
53 X-BeenThere: notmuch@notmuchmail.org
\r
54 X-Mailman-Version: 2.1.13
\r
56 List-Id: "Use and development of the notmuch mail system."
\r
57 <notmuch.notmuchmail.org>
\r
58 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
59 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
60 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
61 List-Post: <mailto:notmuch@notmuchmail.org>
\r
62 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
63 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
64 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
65 X-List-Received-Date: Wed, 18 Apr 2012 12:39:56 -0000
\r
67 Signed-off-by: Felipe Contreras <felipe.contreras@ngmail.com>
\r
69 Makefile.local | 1 +
\r
70 notmuch-client.h | 3 ++
\r
71 notmuch-compose.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++
\r
73 4 files changed, 120 insertions(+)
\r
74 create mode 100644 notmuch-compose.c
\r
76 diff --git a/Makefile.local b/Makefile.local
\r
77 index 53b4a0d..2c15ec2 100644
\r
78 --- a/Makefile.local
\r
79 +++ b/Makefile.local
\r
80 @@ -279,6 +279,7 @@ notmuch_client_srcs = \
\r
81 gmime-filter-headers.c \
\r
84 + notmuch-compose.c \
\r
88 diff --git a/notmuch-client.h b/notmuch-client.h
\r
89 index 19b7f01..1146cd1 100644
\r
90 --- a/notmuch-client.h
\r
91 +++ b/notmuch-client.h
\r
92 @@ -126,6 +126,9 @@ int
\r
93 notmuch_reply_command (void *ctx, int argc, char *argv[]);
\r
96 +notmuch_compose_command (void *ctx, int argc, char *argv[]);
\r
99 notmuch_restore_command (void *ctx, int argc, char *argv[]);
\r
102 diff --git a/notmuch-compose.c b/notmuch-compose.c
\r
103 new file mode 100644
\r
104 index 0000000..ac5ea95
\r
106 +++ b/notmuch-compose.c
\r
108 +/* notmuch - Not much of an email program, (just index and search)
\r
110 + * Copyright © 2009 Carl Worth
\r
111 + * Copyright © 2009 Keith Packard
\r
113 + * This program is free software: you can redistribute it and/or modify
\r
114 + * it under the terms of the GNU General Public License as published by
\r
115 + * the Free Software Foundation, either version 3 of the License, or
\r
116 + * (at your option) any later version.
\r
118 + * This program is distributed in the hope that it will be useful,
\r
119 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
120 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
121 + * GNU General Public License for more details.
\r
123 + * You should have received a copy of the GNU General Public License
\r
124 + * along with this program. If not, see http://www.gnu.org/licenses/ .
\r
126 + * Authors: Carl Worth <cworth@cworth.org>
\r
127 + * Keith Packard <keithp@keithp.com>
\r
128 + * Felipe Contreras <felipe.contreras@gmail.com>
\r
131 +#include "notmuch-client.h"
\r
132 +#include "gmime-filter-headers.h"
\r
135 +show_message_headers (GMimeMessage *message)
\r
137 + GMimeStream *stream_stdout = NULL, *stream_filter = NULL;
\r
139 + stream_stdout = g_mime_stream_file_new (stdout);
\r
140 + if (stream_stdout) {
\r
141 + g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), FALSE);
\r
142 + stream_filter = g_mime_stream_filter_new(stream_stdout);
\r
143 + if (stream_filter) {
\r
144 + g_mime_stream_filter_add(GMIME_STREAM_FILTER(stream_filter),
\r
145 + g_mime_filter_headers_new());
\r
146 + g_mime_object_write_to_stream(GMIME_OBJECT(message), stream_filter);
\r
147 + g_object_unref(stream_filter);
\r
149 + g_object_unref(stream_stdout);
\r
154 +notmuch_compose (void *ctx, notmuch_config_t *config)
\r
156 + GMimeMessage *msg;
\r
157 + const char *from_addr = NULL;
\r
158 + const char *message_id, *user_agent;
\r
159 + char *simple_from;
\r
161 + /* The 1 means we want headers in a "pretty" order. */
\r
162 + msg = g_mime_message_new (1);
\r
163 + if (msg == NULL) {
\r
164 + fprintf (stderr, "Out of memory\n");
\r
168 + g_mime_message_set_subject (msg, "");
\r
170 + g_mime_object_set_header (GMIME_OBJECT (msg), "To", "");
\r
172 + if (from_addr == NULL)
\r
173 + from_addr = notmuch_config_get_user_primary_email (config);
\r
175 + simple_from = talloc_strdup (ctx, from_addr);
\r
177 + from_addr = talloc_asprintf (ctx, "%s <%s>",
\r
178 + notmuch_config_get_user_name (config),
\r
180 + g_mime_object_set_header (GMIME_OBJECT (msg),
\r
181 + "From", from_addr);
\r
183 + g_mime_object_set_header (GMIME_OBJECT (msg), "Bcc",
\r
184 + notmuch_config_get_user_primary_email (config));
\r
186 + user_agent = talloc_asprintf (ctx, "notmuch %s",
\r
187 + STRINGIFY(NOTMUCH_VERSION));
\r
188 + g_mime_object_set_header (GMIME_OBJECT (msg),
\r
189 + "User-Agent", user_agent);
\r
191 + message_id = talloc_asprintf (ctx, "<%lu-notmuch-%s>",
\r
194 + g_mime_object_set_header (GMIME_OBJECT (msg),
\r
195 + "Message-ID", message_id);
\r
196 + talloc_free (simple_from);
\r
198 + show_message_headers (msg);
\r
200 + g_object_unref (G_OBJECT (msg));
\r
206 +notmuch_compose_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
208 + notmuch_config_t *config;
\r
211 + config = notmuch_config_open (ctx, NULL, NULL);
\r
212 + if (config == NULL)
\r
215 + ret = notmuch_compose (ctx, config);
\r
219 diff --git a/notmuch.c b/notmuch.c
\r
220 index 477a09c..2b500d7 100644
\r
223 @@ -65,6 +65,11 @@ static command_t commands[] = {
\r
224 { "reply", notmuch_reply_command,
\r
225 "[options...] <search-terms> [...]",
\r
226 "Construct a reply template for a set of messages." },
\r
227 + { "compose", notmuch_compose_command,
\r
229 + "Constructs an empty message.",
\r
230 + "\tConstructs a new empty message filling basic headers such as\n"
\r
231 + "\tFrom:, User-Agent: and Message-ID:." },
\r
232 { "tag", notmuch_tag_command,
\r
233 "+<tag>|-<tag> [...] [--] <search-terms> [...]" ,
\r
234 "Add/remove tags for all messages matching the search terms." },
\r