diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2006-03-09 06:37:55 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2006-03-09 06:37:55 +0000 |
commit | 39683eb5ab1e51c69ddf12a9da1ce0402f78380f (patch) | |
tree | d7f296191bfad70c9edf0c6fe10c42b2fe8ccb49 /libsylph | |
parent | 57da061f6ef7b0b005066dcf7fd5bd317f394339 (diff) |
added a hidden option "mime_command" for backward compatibility.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1035 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph')
-rw-r--r-- | libsylph/prefs_common.c | 1 | ||||
-rw-r--r-- | libsylph/prefs_common.h | 1 | ||||
-rw-r--r-- | libsylph/procmime.c | 5 | ||||
-rw-r--r-- | libsylph/procmsg.c | 4 | ||||
-rw-r--r-- | libsylph/utils.c | 34 | ||||
-rw-r--r-- | libsylph/utils.h | 3 |
6 files changed, 37 insertions, 11 deletions
diff --git a/libsylph/prefs_common.c b/libsylph/prefs_common.c index 292b40ba..8360d0ce 100644 --- a/libsylph/prefs_common.c +++ b/libsylph/prefs_common.c @@ -267,6 +267,7 @@ static PrefParam param[] = { {"mime_open_command", "gedit '%s'", &prefs_common.mime_open_cmd, #endif P_STRING}, + {"mime_command", NULL, &prefs_common.mime_cmd, P_STRING}, /* Junk mail */ {"enable_junk", "FALSE", &prefs_common.enable_junk, P_BOOL}, diff --git a/libsylph/prefs_common.h b/libsylph/prefs_common.h index 233604b3..de3a53c8 100644 --- a/libsylph/prefs_common.h +++ b/libsylph/prefs_common.h @@ -195,6 +195,7 @@ struct _PrefsCommon gchar *mime_image_viewer; gchar *mime_audio_player; gchar *mime_open_cmd; + gchar *mime_cmd; GList *mime_open_cmd_history; diff --git a/libsylph/procmime.c b/libsylph/procmime.c index 0f9ab39f..349bd84f 100644 --- a/libsylph/procmime.c +++ b/libsylph/procmime.c @@ -1250,7 +1250,7 @@ gint procmime_execute_open_file(const gchar *file, const gchar *mime_type) gchar *mime_type_ = NULL; GList *cur; MailCap *mailcap; - gchar *cmdline, *p; + gchar *cmdline; gint ret = -1; static gboolean mailcap_list_init = FALSE; @@ -1298,8 +1298,7 @@ gint procmime_execute_open_file(const gchar *file, const gchar *mime_type) if (mailcap->needs_terminal) continue; - if ((p = strchr(mailcap->cmdline_fmt, '%')) && - *(p + 1) == 's' && !strchr(p + 2, '%')) + if (str_find_format_times(mailcap->cmdline_fmt, 's') == 1) cmdline = g_strdup_printf(mailcap->cmdline_fmt, file); else cmdline = g_strconcat(mailcap->cmdline_fmt, " \"", file, diff --git a/libsylph/procmsg.c b/libsylph/procmsg.c index 3487bdf0..00a3b9c9 100644 --- a/libsylph/procmsg.c +++ b/libsylph/procmsg.c @@ -1289,7 +1289,6 @@ void procmsg_print_message(MsgInfo *msginfo, const gchar *cmdline) GPtrArray *headers; gint i; gchar buf[1024]; - gchar *p; g_return_if_fail(msginfo != NULL); @@ -1367,8 +1366,7 @@ void procmsg_print_message(MsgInfo *msginfo, const gchar *cmdline) } #endif - if (cmdline && (p = strchr(cmdline, '%')) && *(p + 1) == 's' && - !strchr(p + 2, '%')) + if (cmdline && str_find_format_times(cmdline, 's') == 1) g_snprintf(buf, sizeof(buf) - 1, cmdline, prtmp); else { if (cmdline) { diff --git a/libsylph/utils.c b/libsylph/utils.c index c9bdd83c..a2c3bd3e 100644 --- a/libsylph/utils.c +++ b/libsylph/utils.c @@ -444,6 +444,25 @@ gboolean str_has_suffix_case(const gchar *str, const gchar *suffix) return (g_ascii_strcasecmp(str + (len - s_len), suffix) == 0); } +gint str_find_format_times(const gchar *haystack, gchar ch) +{ + gint n = 0; + const gchar *p = haystack; + + while ((p = strchr(p, '%')) != NULL) { + ++p; + if (*p == '%') { + ++p; + } else if (*p == ch) { + ++p; + ++n; + } else + return -1; + } + + return n; +} + /* Examine if next block is non-ASCII string */ gboolean is_next_nonascii(const gchar *s) { @@ -3382,7 +3401,15 @@ gint execute_command_line(const gchar *cmdline, gboolean async) gchar **argv; gint ret; - debug_print("execute_command_line(): executing: %s\n", cmdline); + if (debug_mode) { + gchar *utf8_cmdline; + + utf8_cmdline = g_filename_to_utf8 + (cmdline, -1, NULL, NULL, NULL); + debug_print("execute_command_line(): executing: %s\n", + utf8_cmdline ? utf8_cmdline : cmdline); + g_free(utf8_cmdline); + } argv = strsplit_with_quote(cmdline, " ", 0); @@ -3490,7 +3517,6 @@ gchar *get_command_output(const gchar *cmdline) gint open_uri(const gchar *uri, const gchar *cmdline) { gchar buf[BUFFSIZE]; - gchar *p; g_return_val_if_fail(uri != NULL, -1); @@ -3499,9 +3525,7 @@ gint open_uri(const gchar *uri, const gchar *cmdline) return execute_open_file(uri, NULL); #endif - if (cmdline && - (p = strchr(cmdline, '%')) && *(p + 1) == 's' && - !strchr(p + 2, '%')) + if (cmdline && str_find_format_times(cmdline, 's') == 1) g_snprintf(buf, sizeof(buf), cmdline, uri); else { if (cmdline) diff --git a/libsylph/utils.h b/libsylph/utils.h index e5251991..43372bb0 100644 --- a/libsylph/utils.h +++ b/libsylph/utils.h @@ -237,6 +237,9 @@ gchar *strncpy2 (gchar *dest, gboolean str_has_suffix_case (const gchar *str, const gchar *suffix); +gint str_find_format_times (const gchar *haystack, + gchar ch); + gboolean is_next_nonascii (const gchar *s); gint get_next_word_len (const gchar *s); |