* mu-msg-sexp: expand, more clearly separate 'full' and 'header' messages

This commit is contained in:
Dirk-Jan C. Binnema
2011-09-12 20:43:48 +03:00
parent 9fb2289252
commit 9f6b3b4035

View File

@ -145,8 +145,11 @@ each_contact (MuMsgContact *c, ContactData *cdata)
static void static void
append_sexp_contacts (GString *gstr, MuMsg *msg) append_sexp_contacts (GString *gstr, MuMsg *msg)
{ {
ContactData cdata = { FALSE, FALSE, FALSE, FALSE, gstr, ContactData cdata;
(unsigned)-1};
cdata.from = cdata.to = cdata.cc = cdata.bcc = FALSE;
cdata.gstr = gstr;
cdata.prev_ctype = (unsigned)-1;
mu_msg_contact_foreach (msg, (MuMsgContactForeachFunc)each_contact, mu_msg_contact_foreach (msg, (MuMsgContactForeachFunc)each_contact,
&cdata); &cdata);
@ -238,9 +241,8 @@ append_sexp_message_file_attr (GString *gstr, MuMsg *msg)
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"));
append_sexp_attr (gstr, "body-txt", append_sexp_attr (gstr, "body-txt",
mu_msg_get_body_text(msg)); mu_msg_get_body_text(msg));
append_sexp_attr (gstr, "body-html", append_sexp_attr (gstr, "body-html",
mu_msg_get_body_html(msg)); mu_msg_get_body_html(msg));
} }
@ -260,14 +262,18 @@ append_sexp_thread_info (GString *gstr, const MuMsgIterThreadInfo *ti)
char* char*
mu_msg_to_sexp (MuMsg *msg, const MuMsgIterThreadInfo *ti, gboolean dbonly) mu_msg_to_sexp (MuMsg *msg, unsigned docid, const MuMsgIterThreadInfo *ti,
gboolean headers)
{ {
GString *gstr; GString *gstr;
time_t t; time_t t;
gstr = g_string_sized_new (dbonly ? 1024 : 8192); gstr = g_string_sized_new (headers ? 1024 : 8192);
g_string_append (gstr, "(\n"); g_string_append (gstr, "(\n");
if (docid != 0)
g_string_append_printf (gstr, "\t:docid %u\n", docid);
append_sexp_contacts (gstr, msg); append_sexp_contacts (gstr, msg);
if (ti) if (ti)
@ -292,11 +298,19 @@ mu_msg_to_sexp (MuMsg *msg, const MuMsgIterThreadInfo *ti, gboolean dbonly)
append_sexp_flags (gstr, msg); append_sexp_flags (gstr, msg);
/* file attr things can only be gotten from the file (ie., mu /* headers are retrieved from the database, views from the message file
* view), not from the database (mu find) */ *
if (!dbonly) * file attr things can only be gotten from the file (ie., mu
* view), not from the database (mu find). */
if (!headers)
append_sexp_message_file_attr (gstr, msg); append_sexp_message_file_attr (gstr, msg);
/* we register whether this a db-only msg or not; this is
* useful in the UI to know whether this should be considered
* merely a header or a full message */
g_string_append_printf (gstr, "\t:msgtype %s\n",
headers ? "header" : "view");
g_string_append (gstr, ")\n;;eox\n"); g_string_append (gstr, ")\n;;eox\n");
return g_string_free (gstr, FALSE); return g_string_free (gstr, FALSE);