aboutsummaryrefslogtreecommitdiffstats
path: root/composer/e-msg-composer-attachment.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-09-19 08:07:47 +0800
committerDan Winship <danw@src.gnome.org>2000-09-19 08:07:47 +0800
commita4264abf3b15a74c2c4e68a547eddc395251b957 (patch)
tree4caa035ed37dfbb3c84a2b9fd29828e5239d8de8 /composer/e-msg-composer-attachment.c
parent267e69cf010fa5ab7381a30740a264a66a9493a2 (diff)
downloadgsoc2013-evolution-a4264abf3b15a74c2c4e68a547eddc395251b957.tar
gsoc2013-evolution-a4264abf3b15a74c2c4e68a547eddc395251b957.tar.gz
gsoc2013-evolution-a4264abf3b15a74c2c4e68a547eddc395251b957.tar.bz2
gsoc2013-evolution-a4264abf3b15a74c2c4e68a547eddc395251b957.tar.lz
gsoc2013-evolution-a4264abf3b15a74c2c4e68a547eddc395251b957.tar.xz
gsoc2013-evolution-a4264abf3b15a74c2c4e68a547eddc395251b957.tar.zst
gsoc2013-evolution-a4264abf3b15a74c2c4e68a547eddc395251b957.zip
Use gnome_vfs_get_file_info.
* e-msg-composer-attachment.c (get_mime_type): Use gnome_vfs_get_file_info. * e-msg-composer-attachment-bar.c (update): Use gnome_vfs_mime functions, not old gnome_mime. svn path=/trunk/; revision=5496
Diffstat (limited to 'composer/e-msg-composer-attachment.c')
-rw-r--r--composer/e-msg-composer-attachment.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/composer/e-msg-composer-attachment.c b/composer/e-msg-composer-attachment.c
index 141ad7c9ab..c607b59068 100644
--- a/composer/e-msg-composer-attachment.c
+++ b/composer/e-msg-composer-attachment.c
@@ -32,6 +32,7 @@
#include <gnome.h>
#include <camel/camel.h>
#include <gal/widgets/e-unicode.h>
+#include <libgnomevfs/gnome-vfs.h>
#include "e-msg-composer-attachment.h"
@@ -47,16 +48,23 @@ static GtkObjectClass *parent_class = NULL;
/* Utility functions. */
-static const gchar *
+static gchar *
get_mime_type (const gchar *file_name)
{
- const gchar *mime_type;
-
- mime_type = gnome_mime_type_of_file (file_name);
- if (mime_type == NULL)
- mime_type = "application/octet-stream";
-
- return mime_type;
+ GnomeVFSFileInfo info;
+ GnomeVFSResult result;
+
+ result = gnome_vfs_get_file_info (file_name, &info,
+ GNOME_VFS_FILE_INFO_GET_MIME_TYPE |
+ GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
+ if (result == GNOME_VFS_OK) {
+ gchar *type;
+
+ type = g_strdup (gnome_vfs_file_info_get_mime_type (&info));
+ gnome_vfs_file_info_unref (&info);
+ return type;
+ } else
+ return NULL;
}
static void
@@ -161,6 +169,7 @@ e_msg_composer_attachment_new (const gchar *file_name)
CamelDataWrapper *wrapper;
CamelStream *data;
struct stat statbuf;
+ gchar *mime_type;
g_return_val_if_fail (file_name != NULL, NULL);
@@ -170,7 +179,12 @@ e_msg_composer_attachment_new (const gchar *file_name)
wrapper = camel_data_wrapper_new ();
camel_data_wrapper_construct_from_stream (wrapper, data);
camel_object_unref (CAMEL_OBJECT (data));
- camel_data_wrapper_set_mime_type (wrapper, get_mime_type (file_name));
+ mime_type = get_mime_type (file_name);
+ if (mime_type) {
+ camel_data_wrapper_set_mime_type (wrapper, mime_type);
+ g_free (mime_type);
+ } else
+ camel_data_wrapper_set_mime_type (wrapper, "application/octet-stream");
part = camel_mime_part_new ();
camel_medium_set_content_object (CAMEL_MEDIUM (part), wrapper);