mirror of https://github.com/djcb/mu.git
* mu-msg-sexp.c: fix each_contact for cc10, line33 checks
This commit is contained in:
parent
250aa91f5c
commit
8f7ef5d748
|
@ -63,6 +63,7 @@ append_sexp_attr (GString *gstr, const char* elm, const char *str)
|
|||
struct _ContactData {
|
||||
gboolean from, to, cc, bcc;
|
||||
GString *gstr;
|
||||
MuMsgContactType prev_ctype;
|
||||
};
|
||||
typedef struct _ContactData ContactData;
|
||||
|
||||
|
@ -87,37 +88,49 @@ get_name_addr_pair (MuMsgContact *c)
|
|||
}
|
||||
|
||||
|
||||
|
||||
static gboolean
|
||||
each_contact (MuMsgContact *c, ContactData *cdata)
|
||||
{
|
||||
char *pair;
|
||||
MuMsgContactType ctype;
|
||||
|
||||
if (mu_msg_contact_type (c) == MU_MSG_CONTACT_TYPE_FROM) {
|
||||
ctype = mu_msg_contact_type (c);
|
||||
|
||||
if (cdata->prev_ctype != ctype && cdata->prev_ctype != (unsigned)-1)
|
||||
g_string_append (cdata->gstr, ")\n");
|
||||
|
||||
switch (ctype) {
|
||||
|
||||
case MU_MSG_CONTACT_TYPE_FROM:
|
||||
if (!cdata->from)
|
||||
g_string_append (cdata->gstr, "\t:from (");
|
||||
cdata->from = TRUE;
|
||||
break;
|
||||
|
||||
} else if (mu_msg_contact_type (c) == MU_MSG_CONTACT_TYPE_TO) {
|
||||
case MU_MSG_CONTACT_TYPE_TO:
|
||||
if (!cdata->to)
|
||||
g_string_append_printf (cdata->gstr,"%s\t:to (",
|
||||
cdata->from ? ")\n" : "");
|
||||
g_string_append_printf (cdata->gstr,"\t:to (");
|
||||
cdata->to = TRUE;
|
||||
break;
|
||||
|
||||
} else if (mu_msg_contact_type (c) == MU_MSG_CONTACT_TYPE_CC) {
|
||||
case MU_MSG_CONTACT_TYPE_CC:
|
||||
if (!cdata->cc)
|
||||
g_string_append_printf (cdata->gstr,"%s\t:cc (",
|
||||
cdata->from||cdata->to ?
|
||||
")\n" : "");
|
||||
g_string_append_printf (cdata->gstr,"\t:cc (");
|
||||
cdata->cc = TRUE;
|
||||
break;
|
||||
|
||||
} else if (mu_msg_contact_type (c) == MU_MSG_CONTACT_TYPE_BCC) {
|
||||
case MU_MSG_CONTACT_TYPE_BCC:
|
||||
if (!cdata->bcc)
|
||||
g_string_append_printf
|
||||
(cdata->gstr, "%s\t:bcc (",
|
||||
cdata->from||cdata->to||cdata->cc ? ")\n":"");
|
||||
g_string_append_printf (cdata->gstr, "\t:bcc (");
|
||||
cdata->bcc = TRUE;
|
||||
} else
|
||||
g_return_val_if_reached (FALSE);
|
||||
break;
|
||||
|
||||
default: g_return_val_if_reached (FALSE);
|
||||
}
|
||||
|
||||
|
||||
cdata->prev_ctype = ctype;
|
||||
|
||||
pair = get_name_addr_pair (c);
|
||||
g_string_append (cdata->gstr, pair);
|
||||
|
@ -130,7 +143,8 @@ each_contact (MuMsgContact *c, ContactData *cdata)
|
|||
static void
|
||||
append_sexp_contacts (GString *gstr, MuMsg *msg)
|
||||
{
|
||||
ContactData cdata = { FALSE, FALSE, FALSE, FALSE, gstr};
|
||||
ContactData cdata = { FALSE, FALSE, FALSE, FALSE, gstr,
|
||||
(unsigned)-1};
|
||||
|
||||
mu_msg_contact_foreach (msg, (MuMsgContactForeachFunc)each_contact,
|
||||
&cdata);
|
||||
|
|
Loading…
Reference in New Issue