aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-identify.c
diff options
context:
space:
mode:
Diffstat (limited to 'mail/mail-identify.c')
-rw-r--r--mail/mail-identify.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/mail/mail-identify.c b/mail/mail-identify.c
index 21e3b6a0fd..e2f614f059 100644
--- a/mail/mail-identify.c
+++ b/mail/mail-identify.c
@@ -30,8 +30,7 @@
#include <string.h>
#include <glib.h>
-#include <libgnomevfs/gnome-vfs-mime.h>
-#include <libgnomevfs/gnome-vfs-mime-sniff-buffer.h>
+#include <libgnomevfs/gnome-vfs-mime-utils.h>
#include "mail.h"
static const char *identify_by_magic (CamelDataWrapper *data, MailDisplay *md);
@@ -50,8 +49,9 @@ static const char *identify_by_magic (CamelDataWrapper *data, MailDisplay *md);
char *
mail_identify_mime_part (CamelMimePart *part, MailDisplay *md)
{
- const char *filename, *name_type = NULL, *magic_type = NULL;
+ const char *filename, *magic_type = NULL;
CamelDataWrapper *data;
+ char *name_type = NULL;
filename = camel_mime_part_get_filename (part);
if (filename) {
@@ -59,7 +59,8 @@ mail_identify_mime_part (CamelMimePart *part, MailDisplay *md)
if (!strcmp (filename, "winmail.dat"))
return g_strdup ("application/vnd.ms-tnef");
- name_type = gnome_vfs_mime_type_from_name_or_default (filename, NULL);
+#warning "does gnome_vfs_get_mime_type handle a plain filename as the 'text_uri'?"
+ name_type = gnome_vfs_get_mime_type(filename);
}
data = camel_medium_get_content_object (CAMEL_MEDIUM (part));
@@ -73,24 +74,26 @@ mail_identify_mime_part (CamelMimePart *part, MailDisplay *md)
* that instead.
*/
if (!strcmp (magic_type, "text/plain"))
- return g_strdup (name_type);
+ return name_type;
/* If if returns "application/octet-stream" try to
* do better with the filename check.
*/
if (!strcmp (magic_type, "application/octet-stream"))
- return g_strdup (name_type);
+ return 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)
+ if (magic_type) {
+ g_free(name_type);
return g_strdup (magic_type);
+ }
/* Otherwise try guessing based on the filename */
if (name_type)
- return g_strdup (name_type);
+ return 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
@@ -115,21 +118,15 @@ mail_identify_mime_part (CamelMimePart *part, MailDisplay *md)
static const char *
identify_by_magic (CamelDataWrapper *data, MailDisplay *md)
{
- GnomeVFSMimeSniffBuffer *sniffer;
- CamelStream *memstream;
+ CamelStreamMem *memstream;
const char *type;
- GByteArray *ba;
-
- ba = g_byte_array_new ();
- memstream = camel_stream_mem_new_with_byte_array (ba);
- camel_data_wrapper_write_to_stream (data, memstream);
- if (ba->len) {
- sniffer = gnome_vfs_mime_sniff_buffer_new_from_memory (ba->data, ba->len);
- type = gnome_vfs_get_mime_type_for_buffer (sniffer);
- gnome_vfs_mime_sniff_buffer_free (sniffer);
- } else
+
+ memstream = (CamelStreamMem *)camel_stream_mem_new();
+ if (camel_data_wrapper_write_to_stream (data, (CamelStream *)memstream) > 0)
+ type = gnome_vfs_get_mime_type_for_data(memstream->buffer->data, memstream->buffer->len);
+ else
type = NULL;
- camel_object_unref (CAMEL_OBJECT (memstream));
+ camel_object_unref(memstream);
return type;
}