1 Return-Path: <awg@lagos.xvx.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 B52B5431FAE
\r
6 for <notmuch@notmuchmail.org>; Tue, 21 Feb 2012 22:46:46 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_NONE=-0.0001] 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 OpC9sZWhhMbI for <notmuch@notmuchmail.org>;
\r
16 Tue, 21 Feb 2012 22:46:45 -0800 (PST)
\r
17 Received: from idcmail-mo1so.shaw.ca (idcmail-mo1so.shaw.ca [24.71.223.10])
\r
18 by olra.theworths.org (Postfix) with ESMTP id CBB81431FB6
\r
19 for <notmuch@notmuchmail.org>; Tue, 21 Feb 2012 22:46:45 -0800 (PST)
\r
20 Received: from pd2ml3so-ssvc.prod.shaw.ca ([10.0.141.148])
\r
21 by pd4mo1so-svcs.prod.shaw.ca with ESMTP; 21 Feb 2012 23:46:43 -0700
\r
22 X-Cloudmark-SP-Filtered: true
\r
23 X-Cloudmark-SP-Result: v=1.1 cv=W+ZrOcpwHTeQLvZQ9vbIxXRdvbK5p6H2/T6SuQCN924=
\r
25 a=VOVZfvsCZTcA:10 a=BLceEmwcHowA:10 a=yQp6g8lIsgqumF79BAsFDg==:17
\r
26 a=Ip1p9aMYQwLSyBp_cu4A:9 a=kK51L1ATiIlFzoh5DWsA:7
\r
27 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117
\r
28 Received: from unknown (HELO lagos.xvx.ca) ([96.52.216.56])
\r
29 by pd2ml3so-dmz.prod.shaw.ca with ESMTP; 21 Feb 2012 23:46:45 -0700
\r
30 Received: by lagos.xvx.ca (Postfix, from userid 1000)
\r
31 id 8A4818004ED6; Tue, 21 Feb 2012 23:46:44 -0700 (MST)
\r
32 From: Adam Wolfe Gordon <awg+notmuch@xvx.ca>
\r
33 To: notmuch@notmuchmail.org
\r
34 Subject: [PATCH v6 02/10] reply: Factor out reply creation
\r
35 Date: Tue, 21 Feb 2012 23:46:31 -0700
\r
36 Message-Id: <1329893199-21630-3-git-send-email-awg+notmuch@xvx.ca>
\r
37 X-Mailer: git-send-email 1.7.5.4
\r
38 In-Reply-To: <1329893199-21630-1-git-send-email-awg+notmuch@xvx.ca>
\r
39 References: <1329893199-21630-1-git-send-email-awg+notmuch@xvx.ca>
\r
40 X-BeenThere: notmuch@notmuchmail.org
\r
41 X-Mailman-Version: 2.1.13
\r
43 List-Id: "Use and development of the notmuch mail system."
\r
44 <notmuch.notmuchmail.org>
\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
46 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
48 List-Post: <mailto:notmuch@notmuchmail.org>
\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
51 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
52 X-List-Received-Date: Wed, 22 Feb 2012 06:46:47 -0000
\r
54 Factor out the creation of a reply message based on an original
\r
55 message so it can be shared by different reply formats.
\r
57 notmuch-reply.c | 101 +++++++++++++++++++++++++++++++-----------------------
\r
58 1 files changed, 58 insertions(+), 43 deletions(-)
\r
60 diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
61 index 6b244e6..8e56245 100644
\r
62 --- a/notmuch-reply.c
\r
63 +++ b/notmuch-reply.c
\r
64 @@ -505,6 +505,61 @@ guess_from_received_header (notmuch_config_t *config, notmuch_message_t *message
\r
68 +static GMimeMessage *
\r
69 +create_reply_message(void *ctx,
\r
70 + notmuch_config_t *config,
\r
71 + notmuch_message_t *message,
\r
72 + notmuch_bool_t reply_all)
\r
74 + const char *subject, *from_addr = NULL;
\r
75 + const char *in_reply_to, *orig_references, *references;
\r
77 + /* The 1 means we want headers in a "pretty" order. */
\r
78 + GMimeMessage *reply = g_mime_message_new (1);
\r
79 + if (reply == NULL) {
\r
80 + fprintf (stderr, "Out of memory\n");
\r
84 + subject = notmuch_message_get_header (message, "subject");
\r
86 + if (strncasecmp (subject, "Re:", 3))
\r
87 + subject = talloc_asprintf (ctx, "Re: %s", subject);
\r
88 + g_mime_message_set_subject (reply, subject);
\r
91 + from_addr = add_recipients_from_message (reply, config,
\r
92 + message, reply_all);
\r
94 + if (from_addr == NULL)
\r
95 + from_addr = guess_from_received_header (config, message);
\r
97 + if (from_addr == NULL)
\r
98 + from_addr = notmuch_config_get_user_primary_email (config);
\r
100 + from_addr = talloc_asprintf (ctx, "%s <%s>",
\r
101 + notmuch_config_get_user_name (config),
\r
103 + g_mime_object_set_header (GMIME_OBJECT (reply),
\r
104 + "From", from_addr);
\r
106 + in_reply_to = talloc_asprintf (ctx, "<%s>",
\r
107 + notmuch_message_get_message_id (message));
\r
109 + g_mime_object_set_header (GMIME_OBJECT (reply),
\r
110 + "In-Reply-To", in_reply_to);
\r
112 + orig_references = notmuch_message_get_header (message, "references");
\r
113 + references = talloc_asprintf (ctx, "%s%s%s",
\r
114 + orig_references ? orig_references : "",
\r
115 + orig_references ? " " : "",
\r
117 + g_mime_object_set_header (GMIME_OBJECT (reply),
\r
118 + "References", references);
\r
124 notmuch_reply_format_default(void *ctx,
\r
125 notmuch_config_t *config,
\r
126 @@ -515,8 +570,6 @@ notmuch_reply_format_default(void *ctx,
\r
127 GMimeMessage *reply;
\r
128 notmuch_messages_t *messages;
\r
129 notmuch_message_t *message;
\r
130 - const char *subject, *from_addr = NULL;
\r
131 - const char *in_reply_to, *orig_references, *references;
\r
132 const notmuch_show_format_t *format = &format_reply;
\r
134 for (messages = notmuch_query_search_messages (query);
\r
135 @@ -525,48 +578,10 @@ notmuch_reply_format_default(void *ctx,
\r
137 message = notmuch_messages_get (messages);
\r
139 - /* The 1 means we want headers in a "pretty" order. */
\r
140 - reply = g_mime_message_new (1);
\r
141 - if (reply == NULL) {
\r
142 - fprintf (stderr, "Out of memory\n");
\r
146 - subject = notmuch_message_get_header (message, "subject");
\r
148 - if (strncasecmp (subject, "Re:", 3))
\r
149 - subject = talloc_asprintf (ctx, "Re: %s", subject);
\r
150 - g_mime_message_set_subject (reply, subject);
\r
153 - from_addr = add_recipients_from_message (reply, config, message,
\r
155 + reply = create_reply_message (ctx, config, message, reply_all);
\r
157 - if (from_addr == NULL)
\r
158 - from_addr = guess_from_received_header (config, message);
\r
160 - if (from_addr == NULL)
\r
161 - from_addr = notmuch_config_get_user_primary_email (config);
\r
163 - from_addr = talloc_asprintf (ctx, "%s <%s>",
\r
164 - notmuch_config_get_user_name (config),
\r
166 - g_mime_object_set_header (GMIME_OBJECT (reply),
\r
167 - "From", from_addr);
\r
169 - in_reply_to = talloc_asprintf (ctx, "<%s>",
\r
170 - notmuch_message_get_message_id (message));
\r
172 - g_mime_object_set_header (GMIME_OBJECT (reply),
\r
173 - "In-Reply-To", in_reply_to);
\r
175 - orig_references = notmuch_message_get_header (message, "references");
\r
176 - references = talloc_asprintf (ctx, "%s%s%s",
\r
177 - orig_references ? orig_references : "",
\r
178 - orig_references ? " " : "",
\r
180 - g_mime_object_set_header (GMIME_OBJECT (reply),
\r
181 - "References", references);
\r
185 show_reply_headers (reply);
\r