X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmodest-tny-mime-part.c;h=e567b148947e80dcd848bb77c58e22a8c0288cee;hb=b00d6f58abe989b49873b3b1187cc100bf22b636;hp=67cde71832474082bcde225798acf8c1db8f5656;hpb=91a989d7f47588a1dbea28889484c2850e7f8fa8;p=modest diff --git a/src/modest-tny-mime-part.c b/src/modest-tny-mime-part.c index 67cde71..e567b14 100644 --- a/src/modest-tny-mime-part.c +++ b/src/modest-tny-mime-part.c @@ -142,16 +142,20 @@ gboolean modest_tny_mime_part_is_msg (TnyMimePart *part) { const gchar *content_type; + gchar *down_content_type; if (!TNY_IS_MSG (part)) return FALSE; content_type = tny_mime_part_get_content_type (part); - if ((g_str_has_prefix (content_type, "message/rfc822") || - g_str_has_prefix (content_type, "multipart/") || - g_str_has_prefix (content_type, "text/"))) { + down_content_type = g_ascii_strdown (content_type, -1); + if ((g_str_has_prefix (down_content_type, "message/rfc822") || + g_str_has_prefix (down_content_type, "multipart/") || + g_str_has_prefix (down_content_type, "text/"))) { + g_free (down_content_type); return TRUE; } else { + g_free (down_content_type); return FALSE; } } @@ -207,3 +211,46 @@ modest_tny_mime_part_to_string (TnyMimePart *part, gint indent) g_string_free (indent_prefix, TRUE); } +gchar * +modest_tny_mime_part_get_headers_content_type (TnyMimePart *part) +{ + gchar *header_content_type; + gchar *suffix; + + g_return_val_if_fail (TNY_IS_MIME_PART (part), NULL); + + header_content_type = modest_tny_mime_part_get_header_value (part, "Content-Type"); + + /* See RFC2045 sec 5.2 */ + if (!header_content_type) + return g_strdup ("text/plain; charset=us-ascii"); + + header_content_type = g_strstrip (header_content_type); + + /* remove the ; suffix */ + suffix = index (header_content_type, ';'); + if (suffix) + suffix[0] = '\0'; + + return g_ascii_strdown (header_content_type, -1); +} + +gchar * +modest_tny_mime_part_get_content_type (TnyMimePart *part) +{ + const gchar *content_type; + gchar *retval = NULL; + + g_return_val_if_fail (TNY_IS_MIME_PART (part), NULL); + content_type = tny_mime_part_get_content_type (part); + + if (g_str_has_prefix (content_type, "message/rfc822")) { + retval = modest_tny_mime_part_get_headers_content_type (part); + } + + if (retval == NULL) { + retval = g_ascii_strdown (content_type, -1); + } + + return retval; +}