X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=imap%2Fmessage.c;h=1f634afb3fe009b99c401ccee39af62a7d0afdb3;hp=8412c61d2fdd2e4d3c9b916ecdc60400eeb2be97;hb=f288d1771c814e6104da83e6f0f1761a40de1224;hpb=98cf5779d8184a74541be1bc61d15c5f35efd310 diff --git a/imap/message.c b/imap/message.c index 8412c61..1f634af 100644 --- a/imap/message.c +++ b/imap/message.c @@ -291,6 +291,50 @@ int imap_read_headers (IMAP_DATA * idata, int msgbegin, int msgend) return msgend; } +/* move all the headers from extra not present in base into base */ +static void mutt_merge_envelopes(ENVELOPE* base, ENVELOPE** extra) +{ + /* copies each existing element if necessary, and sets the element + * to NULL in the source so that envelope_delete doesn't leave us + * with dangling pointers. */ +#define MOVE_ELEM(h) if (!base->h) { base->h = (*extra)->h; (*extra)->h = NULL; } + MOVE_ELEM(return_path); + MOVE_ELEM(from); + MOVE_ELEM(to); + MOVE_ELEM(cc); + MOVE_ELEM(bcc); + MOVE_ELEM(sender); + MOVE_ELEM(reply_to); + MOVE_ELEM(mail_followup_to); + MOVE_ELEM(list_post); + MOVE_ELEM(message_id); + MOVE_ELEM(supersedes); + MOVE_ELEM(date); + MOVE_ELEM(x_label); + if (!base->refs_changed) { + MOVE_ELEM(references); + } + if (!base->irt_changed) { + MOVE_ELEM(in_reply_to); + } + /* real_subj is subordinate to subject */ + if (!base->subject) { + base->subject = (*extra)->subject; + base->real_subj = (*extra)->real_subj; + (*extra)->subject = NULL; + (*extra)->real_subj = NULL; + } + /* spam and user headers should never be hashed, and the new envelope may + * have better values. Use new versions regardless. */ + mutt_buffer_free (&base->spam); + string_list_wipe(&base->userhdrs); + MOVE_ELEM(spam); + MOVE_ELEM(userhdrs); +#undef MOVE_ELEM + + envelope_delete(extra); +} + int imap_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) { IMAP_DATA *idata;