From d99f89edc0e85e7b1f9319cd0dd64c5e64e8e37a Mon Sep 17 00:00:00 2001 From: hiro Date: Wed, 8 Mar 2006 06:08:05 +0000 Subject: read mailcap file other than standard location. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1033 ee746299-78ed-0310-b773-934348b2243d --- libsylph/procmime.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'libsylph/procmime.c') diff --git a/libsylph/procmime.c b/libsylph/procmime.c index 31089455..0f9ab39f 100644 --- a/libsylph/procmime.c +++ b/libsylph/procmime.c @@ -1102,10 +1102,9 @@ static GHashTable *procmime_get_mime_type_table(void) #else mime_type_list = procmime_get_mime_type_list(SYSCONFDIR "/mime.types"); - if (!mime_type_list) { - list = procmime_get_mime_type_list("/etc/mime.types"); - mime_type_list = g_list_concat(mime_type_list, list); - } + if (!mime_type_list) + mime_type_list = + procmime_get_mime_type_list("/etc/mime.types"); #endif dir = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "mime.types", NULL); @@ -1253,6 +1252,7 @@ gint procmime_execute_open_file(const gchar *file, const gchar *mime_type) MailCap *mailcap; gchar *cmdline, *p; gint ret = -1; + static gboolean mailcap_list_init = FALSE; g_return_val_if_fail(file != NULL, -1); @@ -1267,8 +1267,28 @@ gint procmime_execute_open_file(const gchar *file, const gchar *mime_type) } else mime_type_ = g_ascii_strdown(mime_type, -1); - if (!mailcap_list) - mailcap_list = procmime_parse_mailcap("/etc/mailcap"); + if (!mailcap_list_init && !mailcap_list) { + GList *list; + gchar *path; + + path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "mailcap", + NULL); + mailcap_list = procmime_parse_mailcap(path); + g_free(path); +#ifdef G_OS_WIN32 + path = g_strconcat(get_startup_dir(), G_DIR_SEPARATOR_S "etc" + G_DIR_SEPARATOR_S "mailcap", NULL); + list = procmime_parse_mailcap(path); + g_free(path); +#else + list = procmime_parse_mailcap(SYSCONFDIR "/mailcap"); + if (!list) + list = procmime_parse_mailcap("/etc/mailcap"); +#endif + mailcap_list = g_list_concat(mailcap_list, list); + + mailcap_list_init = TRUE; + } for (cur = mailcap_list; cur != NULL; cur = cur->next) { mailcap = (MailCap *)cur->data; -- cgit v1.2.3