diff --git a/src/mu-msg-sexp.c b/src/mu-msg-sexp.c index 12436818..d1a581c4 100644 --- a/src/mu-msg-sexp.c +++ b/src/mu-msg-sexp.c @@ -62,7 +62,7 @@ append_sexp_attr (GString *gstr, const char* elm, const char *str) struct _ContactData { - gboolean from, to, cc, bcc; + gboolean from, to, cc, bcc, reply_to; GString *gstr; MuMsgContactType prev_ctype; }; @@ -129,6 +129,10 @@ each_contact (MuMsgContact *c, ContactData *cdata) add_prefix_maybe (cdata->gstr, &cdata->bcc, "\t:bcc ("); break; + case MU_MSG_CONTACT_TYPE_REPLY_TO: + add_prefix_maybe (cdata->gstr, &cdata->reply_to, "\t:reply-to ("); + break; + default: g_return_val_if_reached (FALSE); } @@ -147,14 +151,15 @@ append_sexp_contacts (GString *gstr, MuMsg *msg) { ContactData cdata; - cdata.from = cdata.to = cdata.cc = cdata.bcc = FALSE; + cdata.from = cdata.to = cdata.cc = cdata.bcc + = cdata.reply_to = FALSE; cdata.gstr = gstr; cdata.prev_ctype = (unsigned)-1; mu_msg_contact_foreach (msg, (MuMsgContactForeachFunc)each_contact, &cdata); - if (cdata.from || cdata.to || cdata.cc || cdata.bcc) + if (cdata.from || cdata.to || cdata.cc || cdata.bcc || cdata.reply_to) gstr = g_string_append (gstr, ")\n"); } @@ -244,13 +249,12 @@ append_sexp_attachments (GString *gstr, MuMsg *msg) } + static void append_sexp_message_file_attr (GString *gstr, MuMsg *msg) { append_sexp_attachments (gstr, msg); - append_sexp_attr (gstr, "reply-to", - mu_msg_get_header (msg, "Reply-To")); append_sexp_attr_list (gstr, "references", mu_msg_get_references (msg)); append_sexp_attr (gstr, "in-reply-to", mu_msg_get_header (msg, "In-Reply-To")); @@ -291,6 +295,10 @@ mu_msg_to_sexp (MuMsg *msg, unsigned docid, const MuMsgIterThreadInfo *ti, if (docid != 0) g_string_append_printf (gstr, "\t:docid %u\n", docid); + if (!header) /* force loading of file... should do this a bit + * more elegantly */ + mu_msg_get_header (msg, "Reply-To"); + append_sexp_contacts (gstr, msg); if (ti) diff --git a/src/mu-msg.c b/src/mu-msg.c index 59cdc88e..8c9b908e 100644 --- a/src/mu-msg.c +++ b/src/mu-msg.c @@ -572,11 +572,14 @@ static void address_list_foreach (InternetAddressList *addrlist, MuMsgContactType ctype, MuMsgContactForeachFunc func, gpointer user_data) { - int i; + int i, len; - for (i = 0; addrlist && i != internet_address_list_length(addrlist); - ++i) { + if (!addrlist) + return; + len = internet_address_list_length(addrlist); + + for (i = 0; i != len; ++i) { MuMsgContact contact; if (!fill_contact(&contact, internet_address_list_get_address (addrlist, i), @@ -606,9 +609,9 @@ addresses_foreach (const char* addrs, MuMsgContactType ctype, } -void +static void msg_contact_foreach_file (MuMsg *msg, MuMsgContactForeachFunc func, - gpointer user_data) + gpointer user_data) { int i; struct { @@ -624,6 +627,10 @@ msg_contact_foreach_file (MuMsg *msg, MuMsgContactForeachFunc func, addresses_foreach (g_mime_message_get_sender (msg->_file->_mime_msg), MU_MSG_CONTACT_TYPE_FROM, func, user_data); + /* reply_to */ + addresses_foreach (g_mime_message_get_reply_to (msg->_file->_mime_msg), + MU_MSG_CONTACT_TYPE_REPLY_TO, func, user_data); + /* get to, cc, bcc */ for (i = 0; i != G_N_ELEMENTS(ctypes); ++i) { InternetAddressList *addrlist; @@ -656,10 +663,10 @@ mu_msg_contact_foreach (MuMsg *msg, MuMsgContactForeachFunc func, g_return_if_fail (msg); g_return_if_fail (func); - if (msg->_doc) - msg_contact_foreach_doc (msg, func, user_data); - else if (msg->_file) + if (msg->_file) msg_contact_foreach_file (msg, func, user_data); + else if (msg->_doc) + msg_contact_foreach_doc (msg, func, user_data); else g_return_if_reached (); } diff --git a/src/mu-msg.h b/src/mu-msg.h index f8edebb6..0a538c47 100644 --- a/src/mu-msg.h +++ b/src/mu-msg.h @@ -426,6 +426,7 @@ enum _MuMsgContactType { /* Reply-To:? */ MU_MSG_CONTACT_TYPE_FROM, MU_MSG_CONTACT_TYPE_CC, MU_MSG_CONTACT_TYPE_BCC, + MU_MSG_CONTACT_TYPE_REPLY_TO, MU_MSG_CONTACT_TYPE_NUM }; @@ -441,7 +442,7 @@ struct _MuMsgContact { const char *name; /* Foo Bar */ const char *address; /* foo@bar.cuux */ MuMsgContactType type; /* MU_MSG_CONTACT_TYPE_{ TO, - * CC, BCC, FROM} */ + * CC, BCC, FROM, REPLY_TO} */ }; typedef struct _MuMsgContact MuMsgContact; @@ -466,7 +467,7 @@ MuMsgContact *mu_msg_contact_new (const char *name, const char *address, * * @param contact a contact object, or NULL */ -void mu_msg_contact_destroy (MuMsgContact *contact); +void mu_msg_contact_destroy (MuMsgContact *contact); /** * macro to get the name of a contact diff --git a/src/mu-store-write.cc b/src/mu-store-write.cc index db0a89a6..6e0e2ffc 100644 --- a/src/mu-store-write.cc +++ b/src/mu-store-write.cc @@ -564,7 +564,7 @@ static void add_terms_values (MuMsgFieldId mfid, MsgDoc* msgdoc) { /* note: contact-stuff (To/Cc/From) will handled in - * add_contact_info, not here */ + * each_contact_info, not here */ if (!mu_msg_field_xapian_index(mfid) && !mu_msg_field_xapian_term(mfid) && !mu_msg_field_xapian_value(mfid)) @@ -622,6 +622,10 @@ xapian_pfx (MuMsgContact *contact) static void each_contact_info (MuMsgContact *contact, MsgDoc *msgdoc) { + /* for now, don't store reply-to addresses */ + if (mu_msg_contact_type (contact) == MU_MSG_CONTACT_TYPE_REPLY_TO) + return; + const std::string pfx (xapian_pfx(contact)); if (pfx.empty()) return; /* unsupported contact type */ @@ -638,7 +642,6 @@ each_contact_info (MuMsgContact *contact, MsgDoc *msgdoc) if (!mu_str_is_empty(contact->address)) { char *escaped; - escaped = mu_str_ascii_xapian_escape (contact->address, FALSE /*dont esc space*/); msgdoc->_doc->add_term