From 413284362ffbc5185e72dd2e246ba88f912ffbdb Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Wed, 8 Nov 2000 13:04:59 +0000 Subject: new function, moved from composer 2000-11-08 Radek Doulik * camel-mime-utils.c (mime_guess_type_from_file_name): new function, moved from composer svn path=/trunk/; revision=6506 --- camel/ChangeLog | 5 +++++ camel/camel-mime-utils.c | 21 +++++++++++++++++++++ camel/camel-mime-utils.h | 3 +++ 3 files changed, 29 insertions(+) (limited to 'camel') diff --git a/camel/ChangeLog b/camel/ChangeLog index 0caf7e1aab..e489b8938d 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,8 @@ +2000-11-08 Radek Doulik + + * camel-mime-utils.c (mime_guess_type_from_file_name): new + function, moved from composer + 2000-11-08 Not Zed * camel-mime-message.c (find_best_encoding): Keep track of the diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c index f1dbe6de4c..18c005e3fb 100644 --- a/camel/camel-mime-utils.c +++ b/camel/camel-mime-utils.c @@ -40,6 +40,8 @@ #include #include +#include + #include "camel-mime-utils.h" #include "camel-charset-map.h" @@ -3089,3 +3091,22 @@ header_msgid_generate (void) return g_strdup_printf ("%d.%d.%d.camel@%s.%s", (gint) time (NULL), getpid (), count++, host, domain); } + +gchar * +mime_guess_type_from_file_name (const gchar *file_name) +{ + 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; +} diff --git a/camel/camel-mime-utils.h b/camel/camel-mime-utils.h index e829a17093..33a70cc908 100644 --- a/camel/camel-mime-utils.h +++ b/camel/camel-mime-utils.h @@ -183,4 +183,7 @@ int quoted_decode_step(unsigned char *in, int len, unsigned char *out, int *save int quoted_encode_step(unsigned char *in, int len, unsigned char *out, int *state, int *save); int quoted_encode_close(unsigned char *in, int len, unsigned char *out, int *state, int *save); +gchar * mime_guess_type_from_file_name (const gchar *file_name); + + #endif /* ! _CAMEL_MIME_UTILS_H */ -- cgit v1.2.3