aboutsummaryrefslogtreecommitdiffstats
path: root/composer/e-msg-composer.c
diff options
context:
space:
mode:
authorSrinivasa Ragavan <sragavan@src.gnome.org>2006-02-24 16:15:43 +0800
committerSrinivasa Ragavan <sragavan@src.gnome.org>2006-02-24 16:15:43 +0800
commite58a0e749818ebb5719afd03843d066d1aaa723d (patch)
tree32967e652f28c66bb1d92b877cbf42f5bf90e0ad /composer/e-msg-composer.c
parentca852ba2dea7c1716d22aa919dab07ca0b76d8ee (diff)
downloadgsoc2013-evolution-e58a0e749818ebb5719afd03843d066d1aaa723d.tar.gz
gsoc2013-evolution-e58a0e749818ebb5719afd03843d066d1aaa723d.tar.zst
gsoc2013-evolution-e58a0e749818ebb5719afd03843d066d1aaa723d.zip
Committing Rohini's patch for bug #324742.
svn path=/trunk/; revision=31576
Diffstat (limited to 'composer/e-msg-composer.c')
-rw-r--r--composer/e-msg-composer.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 008c583b00..5d9c6bc4f4 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -2884,10 +2884,30 @@ e_msg_composer_get_remote_download_count (EMsgComposer *composer)
(E_ATTACHMENT_BAR (p->attachment_bar));
}
+static char *
+attachment_guess_mime_type (const char *file_name)
+{
+ GnomeVFSFileInfo *info;
+ GnomeVFSResult result;
+ char *type = NULL;
+
+ info = gnome_vfs_file_info_new ();
+ result = gnome_vfs_get_file_info (file_name, info,
+ GNOME_VFS_FILE_INFO_GET_MIME_TYPE |
+ GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE |
+ GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
+ if (result == GNOME_VFS_OK)
+ type = g_strdup (gnome_vfs_file_info_get_mime_type (info));
+
+ gnome_vfs_file_info_unref (info);
+
+ return type;
+}
+
static void
drop_action(EMsgComposer *composer, GdkDragContext *context, guint32 action, GtkSelectionData *selection, guint info, guint time)
{
- char *tmp, *str, **urls;
+ char *tmp, *str, **urls, *type;
CamelMimePart *mime_part;
CamelStream *stream;
CamelURL *url;
@@ -2939,12 +2959,14 @@ drop_action(EMsgComposer *composer, GdkDragContext *context, guint32 action, Gtk
continue;
}
- if (!g_ascii_strcasecmp (url->protocol, "file"))
- e_attachment_bar_attach
- (E_ATTACHMENT_BAR (p->attachment_bar),
- url->path,
- "attachment");
- else {
+ if (!g_ascii_strcasecmp (url->protocol, "file")) {
+ type=attachment_guess_mime_type (str);
+ if (strncmp (type, "image", 5) || (!p->send_html && !strncmp (type, "image", 5)))
+ e_attachment_bar_attach
+ (E_ATTACHMENT_BAR (p->attachment_bar),
+ url->path,
+ "attachment");
+ } else {
e_attachment_bar_attach_remote_file
(E_ATTACHMENT_BAR (p->attachment_bar),
str);