X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-tny-mime-part.c;h=ff6c1cdf90909adbca32e7e6f6a1a572463e29df;hp=67cde71832474082bcde225798acf8c1db8f5656;hb=50febec782f963624b1ddca59fb3b1c3d7713151;hpb=91a989d7f47588a1dbea28889484c2850e7f8fa8 diff --git a/src/modest-tny-mime-part.c b/src/modest-tny-mime-part.c index 67cde71..ff6c1cd 100644 --- a/src/modest-tny-mime-part.c +++ b/src/modest-tny-mime-part.c @@ -207,3 +207,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; +}