From 0ee556d346fe8976b63d9eb1c929b41a101037e1 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 18 May 2013 13:17:33 -0400 Subject: Add e_mail_part_get_mime_type(). --- mail/e-mail-request.c | 2 +- mail/em-utils.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'mail') diff --git a/mail/e-mail-request.c b/mail/e-mail-request.c index 1c88b74e33..b4ecfce501 100644 --- a/mail/e-mail-request.c +++ b/mail/e-mail-request.c @@ -161,7 +161,7 @@ handle_mail_request (GSimpleAsyncResult *res, g_object_unref (mime_part); } else { if (mime_type == NULL) - mime_type = part->mime_type; + mime_type = e_mail_part_get_mime_type (part); e_mail_formatter_format_as ( formatter, &context, part, diff --git a/mail/em-utils.c b/mail/em-utils.c index 3e3f9f022b..fa6e704369 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1215,6 +1215,7 @@ is_only_text_part_in_this_level (GList *parts, level_len = dot - text_html_part_id; for (iter = parts; iter; iter = iter->next) { EMailPart *part = E_MAIL_PART (iter->data); + const gchar *mime_type; const gchar *part_id; if (part == NULL) @@ -1229,7 +1230,8 @@ is_only_text_part_in_this_level (GList *parts, if (part->is_attachment) continue; - if (part->mime_type == NULL) + mime_type = e_mail_part_get_mime_type (part); + if (mime_type == NULL) continue; part_id = e_mail_part_get_id (part); @@ -1238,7 +1240,7 @@ is_only_text_part_in_this_level (GList *parts, strncmp (text_html_part_id, part_id, level_len) != 0) continue; - if (g_ascii_strncasecmp (part->mime_type, "text/", 5) == 0) + if (g_ascii_strncasecmp (mime_type, "text/", 5) == 0) return FALSE; } @@ -1321,12 +1323,16 @@ em_utils_message_to_html (CamelSession *session, for (link = head; link != NULL; link = g_list_next (link)) { EMailPart *part = link->data; GList *vhead, *vlink; + const gchar *mime_type; + + mime_type = e_mail_part_get_mime_type (part); /* prefer-plain can hide HTML parts, even when it's the only * text part in the email, thus show it (and hide again later) */ if (part->is_hidden && !hidden_text_html_part && - part->mime_type && !part->is_attachment && - g_ascii_strcasecmp (part->mime_type, "text/html") == 0 && + mime_type != NULL && + !part->is_attachment && + g_ascii_strcasecmp (mime_type, "text/html") == 0 && is_only_text_part_in_this_level (head, part)) { part->is_hidden = FALSE; hidden_text_html_part = part; -- cgit