* include the reply_to address in the list of contact informations:

- mu-msg: add it to the list for for_each
   - mu_msg-sexp: export is as a list in (file-based) msg sexps
   - store-write: for now, don't include it in the database
This commit is contained in:
djcb 2012-04-11 01:15:26 +03:00
parent 7adc7b38b0
commit 1a908b91d6
4 changed files with 36 additions and 17 deletions

View File

@ -62,7 +62,7 @@ append_sexp_attr (GString *gstr, const char* elm, const char *str)
struct _ContactData { struct _ContactData {
gboolean from, to, cc, bcc; gboolean from, to, cc, bcc, reply_to;
GString *gstr; GString *gstr;
MuMsgContactType prev_ctype; MuMsgContactType prev_ctype;
}; };
@ -129,6 +129,10 @@ each_contact (MuMsgContact *c, ContactData *cdata)
add_prefix_maybe (cdata->gstr, &cdata->bcc, "\t:bcc ("); add_prefix_maybe (cdata->gstr, &cdata->bcc, "\t:bcc (");
break; 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); default: g_return_val_if_reached (FALSE);
} }
@ -147,14 +151,15 @@ append_sexp_contacts (GString *gstr, MuMsg *msg)
{ {
ContactData cdata; 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.gstr = gstr;
cdata.prev_ctype = (unsigned)-1; cdata.prev_ctype = (unsigned)-1;
mu_msg_contact_foreach (msg, (MuMsgContactForeachFunc)each_contact, mu_msg_contact_foreach (msg, (MuMsgContactForeachFunc)each_contact,
&cdata); &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"); gstr = g_string_append (gstr, ")\n");
} }
@ -244,13 +249,12 @@ append_sexp_attachments (GString *gstr, MuMsg *msg)
} }
static void static void
append_sexp_message_file_attr (GString *gstr, MuMsg *msg) append_sexp_message_file_attr (GString *gstr, MuMsg *msg)
{ {
append_sexp_attachments (gstr, 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_list (gstr, "references", mu_msg_get_references (msg));
append_sexp_attr (gstr, "in-reply-to", append_sexp_attr (gstr, "in-reply-to",
mu_msg_get_header (msg, "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) if (docid != 0)
g_string_append_printf (gstr, "\t:docid %u\n", docid); 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); append_sexp_contacts (gstr, msg);
if (ti) if (ti)

View File

@ -572,11 +572,14 @@ static void
address_list_foreach (InternetAddressList *addrlist, MuMsgContactType ctype, address_list_foreach (InternetAddressList *addrlist, MuMsgContactType ctype,
MuMsgContactForeachFunc func, gpointer user_data) MuMsgContactForeachFunc func, gpointer user_data)
{ {
int i; int i, len;
for (i = 0; addrlist && i != internet_address_list_length(addrlist); if (!addrlist)
++i) { return;
len = internet_address_list_length(addrlist);
for (i = 0; i != len; ++i) {
MuMsgContact contact; MuMsgContact contact;
if (!fill_contact(&contact, if (!fill_contact(&contact,
internet_address_list_get_address (addrlist, i), 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, msg_contact_foreach_file (MuMsg *msg, MuMsgContactForeachFunc func,
gpointer user_data) gpointer user_data)
{ {
int i; int i;
struct { struct {
@ -624,6 +627,10 @@ msg_contact_foreach_file (MuMsg *msg, MuMsgContactForeachFunc func,
addresses_foreach (g_mime_message_get_sender (msg->_file->_mime_msg), addresses_foreach (g_mime_message_get_sender (msg->_file->_mime_msg),
MU_MSG_CONTACT_TYPE_FROM, func, user_data); 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 */ /* get to, cc, bcc */
for (i = 0; i != G_N_ELEMENTS(ctypes); ++i) { for (i = 0; i != G_N_ELEMENTS(ctypes); ++i) {
InternetAddressList *addrlist; InternetAddressList *addrlist;
@ -656,10 +663,10 @@ mu_msg_contact_foreach (MuMsg *msg, MuMsgContactForeachFunc func,
g_return_if_fail (msg); g_return_if_fail (msg);
g_return_if_fail (func); g_return_if_fail (func);
if (msg->_doc) if (msg->_file)
msg_contact_foreach_doc (msg, func, user_data);
else if (msg->_file)
msg_contact_foreach_file (msg, func, user_data); msg_contact_foreach_file (msg, func, user_data);
else if (msg->_doc)
msg_contact_foreach_doc (msg, func, user_data);
else else
g_return_if_reached (); g_return_if_reached ();
} }

View File

@ -426,6 +426,7 @@ enum _MuMsgContactType { /* Reply-To:? */
MU_MSG_CONTACT_TYPE_FROM, MU_MSG_CONTACT_TYPE_FROM,
MU_MSG_CONTACT_TYPE_CC, MU_MSG_CONTACT_TYPE_CC,
MU_MSG_CONTACT_TYPE_BCC, MU_MSG_CONTACT_TYPE_BCC,
MU_MSG_CONTACT_TYPE_REPLY_TO,
MU_MSG_CONTACT_TYPE_NUM MU_MSG_CONTACT_TYPE_NUM
}; };
@ -441,7 +442,7 @@ struct _MuMsgContact {
const char *name; /* Foo Bar */ const char *name; /* Foo Bar */
const char *address; /* foo@bar.cuux */ const char *address; /* foo@bar.cuux */
MuMsgContactType type; /* MU_MSG_CONTACT_TYPE_{ TO, MuMsgContactType type; /* MU_MSG_CONTACT_TYPE_{ TO,
* CC, BCC, FROM} */ * CC, BCC, FROM, REPLY_TO} */
}; };
typedef struct _MuMsgContact MuMsgContact; 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 * @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 * macro to get the name of a contact

View File

@ -564,7 +564,7 @@ static void
add_terms_values (MuMsgFieldId mfid, MsgDoc* msgdoc) add_terms_values (MuMsgFieldId mfid, MsgDoc* msgdoc)
{ {
/* note: contact-stuff (To/Cc/From) will handled in /* 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) && if (!mu_msg_field_xapian_index(mfid) &&
!mu_msg_field_xapian_term(mfid) && !mu_msg_field_xapian_term(mfid) &&
!mu_msg_field_xapian_value(mfid)) !mu_msg_field_xapian_value(mfid))
@ -622,6 +622,10 @@ xapian_pfx (MuMsgContact *contact)
static void static void
each_contact_info (MuMsgContact *contact, MsgDoc *msgdoc) 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)); const std::string pfx (xapian_pfx(contact));
if (pfx.empty()) if (pfx.empty())
return; /* unsupported contact type */ return; /* unsupported contact type */
@ -638,7 +642,6 @@ each_contact_info (MuMsgContact *contact, MsgDoc *msgdoc)
if (!mu_str_is_empty(contact->address)) { if (!mu_str_is_empty(contact->address)) {
char *escaped; char *escaped;
escaped = mu_str_ascii_xapian_escape (contact->address, escaped = mu_str_ascii_xapian_escape (contact->address,
FALSE /*dont esc space*/); FALSE /*dont esc space*/);
msgdoc->_doc->add_term msgdoc->_doc->add_term