mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-23 19:38:07 +01:00
reply: Factor out reply creation
Factor out the creation of a reply message based on an original message so it can be shared by different reply formats.
This commit is contained in:
parent
30172649e8
commit
766aebc02c
1 changed files with 62 additions and 42 deletions
|
@ -505,31 +505,20 @@ guess_from_received_header (notmuch_config_t *config, notmuch_message_t *message
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
notmuch_reply_format_default(void *ctx,
|
||||
static GMimeMessage *
|
||||
create_reply_message(void *ctx,
|
||||
notmuch_config_t *config,
|
||||
notmuch_query_t *query,
|
||||
notmuch_show_params_t *params,
|
||||
notmuch_message_t *message,
|
||||
notmuch_bool_t reply_all)
|
||||
{
|
||||
GMimeMessage *reply;
|
||||
notmuch_messages_t *messages;
|
||||
notmuch_message_t *message;
|
||||
const char *subject, *from_addr = NULL;
|
||||
const char *in_reply_to, *orig_references, *references;
|
||||
const notmuch_show_format_t *format = &format_reply;
|
||||
|
||||
for (messages = notmuch_query_search_messages (query);
|
||||
notmuch_messages_valid (messages);
|
||||
notmuch_messages_move_to_next (messages))
|
||||
{
|
||||
message = notmuch_messages_get (messages);
|
||||
|
||||
/* The 1 means we want headers in a "pretty" order. */
|
||||
reply = g_mime_message_new (1);
|
||||
GMimeMessage *reply = g_mime_message_new (1);
|
||||
if (reply == NULL) {
|
||||
fprintf (stderr, "Out of memory\n");
|
||||
return 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
subject = notmuch_message_get_header (message, "subject");
|
||||
|
@ -539,8 +528,8 @@ notmuch_reply_format_default(void *ctx,
|
|||
g_mime_message_set_subject (reply, subject);
|
||||
}
|
||||
|
||||
from_addr = add_recipients_from_message (reply, config, message,
|
||||
reply_all);
|
||||
from_addr = add_recipients_from_message (reply, config,
|
||||
message, reply_all);
|
||||
|
||||
if (from_addr == NULL)
|
||||
from_addr = guess_from_received_header (config, message);
|
||||
|
@ -568,6 +557,37 @@ notmuch_reply_format_default(void *ctx,
|
|||
g_mime_object_set_header (GMIME_OBJECT (reply),
|
||||
"References", references);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
static int
|
||||
notmuch_reply_format_default(void *ctx,
|
||||
notmuch_config_t *config,
|
||||
notmuch_query_t *query,
|
||||
notmuch_show_params_t *params,
|
||||
notmuch_bool_t reply_all)
|
||||
{
|
||||
GMimeMessage *reply;
|
||||
notmuch_messages_t *messages;
|
||||
notmuch_message_t *message;
|
||||
const notmuch_show_format_t *format = &format_reply;
|
||||
|
||||
for (messages = notmuch_query_search_messages (query);
|
||||
notmuch_messages_valid (messages);
|
||||
notmuch_messages_move_to_next (messages))
|
||||
{
|
||||
message = notmuch_messages_get (messages);
|
||||
|
||||
reply = create_reply_message (ctx, config, message, reply_all);
|
||||
|
||||
/* If reply creation failed, we're out of memory, so don't
|
||||
* bother trying any more messages.
|
||||
*/
|
||||
if (!reply) {
|
||||
notmuch_message_destroy (message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
show_reply_headers (reply);
|
||||
|
||||
g_object_unref (G_OBJECT (reply));
|
||||
|
|
Loading…
Reference in a new issue