aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-identify.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-07-06 03:47:35 +0800
committerDan Winship <danw@src.gnome.org>2000-07-06 03:47:35 +0800
commit53faeaabcc20626b63d0a815f06851aa97152dcd (patch)
tree4c55776503d9b2c6bdd8e68dbc282eff9ba12f3a /mail/mail-identify.c
parent0837fc409943cafbf57dcd51525b9b7f68148639 (diff)
downloadgsoc2013-evolution-53faeaabcc20626b63d0a815f06851aa97152dcd.tar
gsoc2013-evolution-53faeaabcc20626b63d0a815f06851aa97152dcd.tar.gz
gsoc2013-evolution-53faeaabcc20626b63d0a815f06851aa97152dcd.tar.bz2
gsoc2013-evolution-53faeaabcc20626b63d0a815f06851aa97152dcd.tar.lz
gsoc2013-evolution-53faeaabcc20626b63d0a815f06851aa97152dcd.tar.xz
gsoc2013-evolution-53faeaabcc20626b63d0a815f06851aa97152dcd.tar.zst
gsoc2013-evolution-53faeaabcc20626b63d0a815f06851aa97152dcd.zip
Use the gnomevfs sniff buffer interface to try to identify the MIME type
* mail-identify.c (mail_identify_mime_part): Use the gnomevfs sniff buffer interface to try to identify the MIME type when everything else fails. * mail-display.c (on_object_requested): * mail-format.c (lookup_handler, handle_undisplayable, handle_audio): s/gnome_mime/gnome_vfs_mime/ * Makefile.am: Add gnomevfs stuff svn path=/trunk/; revision=3893
Diffstat (limited to 'mail/mail-identify.c')
-rw-r--r--mail/mail-identify.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/mail/mail-identify.c b/mail/mail-identify.c
index 8b8e61487d..8c1e08104a 100644
--- a/mail/mail-identify.c
+++ b/mail/mail-identify.c
@@ -28,7 +28,8 @@
#include <string.h>
#include <glib.h>
-#include <libgnome/libgnome.h>
+#include <libgnomevfs/gnome-vfs-mime.h>
+#include <libgnomevfs/gnome-vfs-mime-sniff-buffer.h>
#include "mail.h"
/**
@@ -43,6 +44,10 @@ mail_identify_mime_part (CamelMimePart *part)
{
GMimeContentField *content_type;
const char *filename, *type;
+ GnomeVFSMimeSniffBuffer *sniffer;
+ CamelStream *memstream;
+ CamelDataWrapper *data;
+ GByteArray *ba;
content_type = camel_mime_part_get_content_type (part);
@@ -52,21 +57,35 @@ mail_identify_mime_part (CamelMimePart *part)
*/
filename = gmime_content_field_get_parameter (content_type, "name");
if (filename) {
- type = gnome_mime_type_or_default (filename, NULL);
+ type = gnome_vfs_mime_type_or_default (filename, NULL);
if (type)
return g_strdup (type);
}
filename = camel_mime_part_get_filename (part);
if (filename) {
- type = gnome_mime_type_or_default (filename, NULL);
+ type = gnome_vfs_mime_type_or_default (filename, NULL);
if (type)
return g_strdup (type);
}
/* Try file magic. */
- /* FIXME */
+ data = camel_medium_get_content_object (CAMEL_MEDIUM (part));
+ 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
+ type = NULL;
+ gtk_object_unref (GTK_OBJECT (memstream));
+
+ if (type)
+ return g_strdup (type);
/* Another possibility to try is the x-mac-type / x-mac-creator