From a25698c1973869bfd63ea8c71e1cf88b26105cf1 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Mon, 3 Feb 2003 19:31:39 +0000 Subject: Just use gnome_vfs_get_mime_type_from_name() so we can forget all the crap 2003-02-03 Jeffrey Stedfast * mail-identify.c (mail_identify_mime_part): Just use gnome_vfs_get_mime_type_from_name() so we can forget all the crap I implemented before. svn path=/trunk/; revision=19714 --- mail/mail-identify.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/mail/mail-identify.c b/mail/mail-identify.c index c51831fc63..bb05b2f72c 100644 --- a/mail/mail-identify.c +++ b/mail/mail-identify.c @@ -30,6 +30,7 @@ #include #include +#include #include #include #include "mail.h" @@ -50,9 +51,8 @@ static const char *identify_by_magic (CamelDataWrapper *data, MailDisplay *md); char * mail_identify_mime_part (CamelMimePart *part, MailDisplay *md) { - const char *filename, *magic_type = NULL; + const char *filename, *name_type = NULL, *magic_type = NULL; CamelDataWrapper *data; - char *name_type = NULL; filename = camel_mime_part_get_filename (part); if (filename) { @@ -60,7 +60,7 @@ mail_identify_mime_part (CamelMimePart *part, MailDisplay *md) if (!strcmp (filename, "winmail.dat")) return g_strdup ("application/vnd.ms-tnef"); - name_type = gnome_vfs_get_mime_type_from_name (filename); + name_type = gnome_vfs_mime_type_from_name (filename); } data = camel_medium_get_content_object (CAMEL_MEDIUM (part)); @@ -74,26 +74,24 @@ mail_identify_mime_part (CamelMimePart *part, MailDisplay *md) * that instead. */ if (!strcmp (magic_type, "text/plain")) - return name_type; + return g_strdup (name_type); /* If if returns "application/octet-stream" try to * do better with the filename check. */ if (!strcmp (magic_type, "application/octet-stream")) - return name_type; + return g_strdup (name_type); } /* If the MIME part data was online, and the magic check * returned something, use that, since it's more reliable. */ - if (magic_type) { - g_free (name_type); + if (magic_type) return g_strdup (magic_type); - } /* Otherwise try guessing based on the filename */ if (name_type) - return name_type; + return g_strdup (name_type); /* Another possibility to try is the x-mac-type / x-mac-creator * parameter to Content-Type used by some Mac email clients. That -- cgit