diff options
author | Milan Crha <mcrha@src.gnome.org> | 2007-10-01 15:40:48 +0800 |
---|---|---|
committer | Milan Crha <mcrha@src.gnome.org> | 2007-10-01 15:40:48 +0800 |
commit | 203034b3f4c0869197c2195c87e14675e6db5f69 (patch) | |
tree | 799787548716fd91cdc601c4d6f0597c864c2c8d /widgets/misc | |
parent | ecd38612b666a4f6f0edb2c21d1cd9769ce1d89e (diff) | |
download | gsoc2013-evolution-203034b3f4c0869197c2195c87e14675e6db5f69.tar.gz gsoc2013-evolution-203034b3f4c0869197c2195c87e14675e6db5f69.tar.zst gsoc2013-evolution-203034b3f4c0869197c2195c87e14675e6db5f69.zip |
2007-10-01 mcrha Fix for bug #413420
svn path=/trunk/; revision=34340
Diffstat (limited to 'widgets/misc')
-rw-r--r-- | widgets/misc/ChangeLog | 8 | ||||
-rw-r--r-- | widgets/misc/e-attachment.c | 51 |
2 files changed, 58 insertions, 1 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog index 4bc064f4f8..2899ec0fa4 100644 --- a/widgets/misc/ChangeLog +++ b/widgets/misc/ChangeLog @@ -1,3 +1,11 @@ +2007-10-01 Milan Crha <mcrha@redhat.com> + + ** Fix for bug #413420 + + * e-attachment.c: (file_ext_is): New helper function. + * e-attachment.c: (attachment_guess_mime_type): Change mimetype + if knows the extension and if the content of file is valid. + 2007-09-26 Milan Crha <mcrha@redhat.com> ** Fix for bug #423401 diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c index 14dad294f9..d9ec749ebc 100644 --- a/widgets/misc/e-attachment.c +++ b/widgets/misc/e-attachment.c @@ -54,6 +54,8 @@ #include <glib/gi18n.h> #include <glib/gstdio.h> +#include <libebook/e-vcard.h> + #include "e-util/e-error.h" #include "e-util/e-mktemp.h" #include "e-util/e-util-private.h" @@ -194,6 +196,33 @@ e_attachment_get_type (void) return type; } +/** + * file_ext_is: + * @param file_name: path for file + * @param ext: desired extension, with a dot + * @return if file_name has extension ext or not + **/ + +static gboolean +file_ext_is (const char *file_name, const char *ext) +{ + int i, dot = -1; + + if (!file_name || !ext) + return FALSE; + + for (i = 0; file_name[i]; i++) { + if (file_name [i] == '.') + dot = i; + } + + if (dot > 0) { + return 0 == g_ascii_strcasecmp (file_name + dot, ext); + } + + return FALSE; +} + static char * attachment_guess_mime_type (const char *file_name) { @@ -206,9 +235,29 @@ attachment_guess_mime_type (const char *file_name) 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) + if (result == GNOME_VFS_OK) { + gchar *content = NULL; + type = g_strdup (gnome_vfs_file_info_get_mime_type (info)); + if (type && strcmp (type, "text/directory") == 0 && + file_ext_is (file_name, ".vcf") && + g_file_get_contents (file_name, &content, NULL, NULL) && + content) { + EVCard *vc = e_vcard_new_from_string (content); + + if (vc) { + g_free (type); + g_object_unref (G_OBJECT (vc)); + + type = g_strdup ("text/x-vcard"); + } + + } + + g_free (content); + } + gnome_vfs_file_info_unref (info); return type; |