* mu-msg-gmime: further cleanups

This commit is contained in:
Dirk-Jan C. Binnema
2010-08-19 23:14:13 +03:00
parent 478a2ab3eb
commit 7ea074431c

View File

@ -856,18 +856,18 @@ fill_contact (MuMsgContact *contact, InternetAddress *addr,
} }
static gboolean static void
address_list_foreach (InternetAddressList *addrlist, address_list_foreach (InternetAddressList *addrlist,
MuMsgContactType ctype, MuMsgContactType ctype,
MuMsgContactForeachFunc func, MuMsgContactForeachFunc func,
gpointer user_data) gpointer user_data)
{ {
int i, rv; int i;
if (!addrlist) if (!addrlist)
return FALSE; return;
for (i = 0, rv = FALSE; i != internet_address_list_length(addrlist); ++i) { for (i = 0; i != internet_address_list_length(addrlist); ++i) {
MuMsgContact contact; MuMsgContact contact;
if (!fill_contact(&contact, if (!fill_contact(&contact,
@ -881,32 +881,28 @@ address_list_foreach (InternetAddressList *addrlist,
break; break;
} }
return rv; return;
} }
static gboolean static void
get_contacts_from (MuMsgGMime *msg, MuMsgContactForeachFunc func, get_contacts_from (MuMsgGMime *msg, MuMsgContactForeachFunc func,
gpointer user_data) gpointer user_data)
{ {
InternetAddressList *lst; InternetAddressList *lst;
gboolean rv;
/* we go through this whole excercise of trying to get a *list* /* we go through this whole excercise of trying to get a *list*
* of 'From:' address (usually there is only one...), because * of 'From:' address (usually there is only one...), because
* internet_address_parse_string has the nice side-effect of * internet_address_parse_string has the nice side-effect of
* splitting in names and addresses for us */ * splitting in names and addresses for us */
rv = FALSE;
lst = internet_address_list_parse_string ( lst = internet_address_list_parse_string (
g_mime_message_get_sender (msg->_mime_msg)); g_mime_message_get_sender (msg->_mime_msg));
if (lst) { if (lst) {
rv = address_list_foreach (lst, MU_MSG_CONTACT_TYPE_FROM, address_list_foreach (lst, MU_MSG_CONTACT_TYPE_FROM,
func, user_data); func, user_data);
g_object_unref (G_OBJECT(lst)); g_object_unref (G_OBJECT(lst));
} }
return rv;
} }
@ -914,7 +910,7 @@ void
mu_msg_gmime_contacts_foreach (MuMsgGMime *msg, MuMsgContactForeachFunc func, mu_msg_gmime_contacts_foreach (MuMsgGMime *msg, MuMsgContactForeachFunc func,
gpointer user_data) gpointer user_data)
{ {
int i, rv; int i;
struct { struct {
GMimeRecipientType _gmime_type; GMimeRecipientType _gmime_type;
MuMsgContactType _type; MuMsgContactType _type;
@ -927,17 +923,14 @@ mu_msg_gmime_contacts_foreach (MuMsgGMime *msg, MuMsgContactForeachFunc func,
g_return_if_fail (func && msg); g_return_if_fail (func && msg);
/* first, get the from address(es) */ /* first, get the from address(es) */
rv = get_contacts_from (msg, func, user_data); get_contacts_from (msg, func, user_data);
if (rv != 0)
return; /* callback told us to stop */
for (i = 0, rv = 0; i != G_N_ELEMENTS(ctypes); ++i) { /* get to, cc, bcc */
for (i = 0; i != G_N_ELEMENTS(ctypes); ++i) {
InternetAddressList *addrlist; InternetAddressList *addrlist;
addrlist = g_mime_message_get_recipients (msg->_mime_msg, addrlist = g_mime_message_get_recipients (msg->_mime_msg,
ctypes[i]._gmime_type); ctypes[i]._gmime_type);
rv = address_list_foreach (addrlist, ctypes[i]._type, func, user_data); address_list_foreach (addrlist, ctypes[i]._type, func, user_data);
if (rv != 0)
break;
} }
} }