* 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
1 changed files with 55 additions and 41 deletions

View File

@ -145,8 +145,11 @@ each_contact (MuMsgContact *c, ContactData *cdata)
static void
append_sexp_contacts (GString *gstr, MuMsg *msg)
{
ContactData cdata = { FALSE, FALSE, FALSE, FALSE, gstr,
(unsigned)-1};
ContactData cdata;
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,
&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 (gstr, "in-reply-to",
mu_msg_get_header (msg, "In-Reply-To"));
append_sexp_attr (gstr, "body-txt",
mu_msg_get_body_text(msg));
mu_msg_get_body_text(msg));
append_sexp_attr (gstr, "body-html",
mu_msg_get_body_html(msg));
}
@ -260,14 +262,18 @@ append_sexp_thread_info (GString *gstr, const MuMsgIterThreadInfo *ti)
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;
time_t t;
gstr = g_string_sized_new (dbonly ? 1024 : 8192);
gstr = g_string_sized_new (headers ? 1024 : 8192);
g_string_append (gstr, "(\n");
if (docid != 0)
g_string_append_printf (gstr, "\t:docid %u\n", docid);
append_sexp_contacts (gstr, msg);
if (ti)
@ -292,11 +298,19 @@ mu_msg_to_sexp (MuMsg *msg, const MuMsgIterThreadInfo *ti, gboolean dbonly)
append_sexp_flags (gstr, msg);
/* file attr things can only be gotten from the file (ie., mu
* view), not from the database (mu find) */
if (!dbonly)
/* headers are retrieved from the database, views from the message file
*
* 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);
/* 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");
return g_string_free (gstr, FALSE);