aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--ChangeLog.ja7
-rw-r--r--libsylph/prefs_common.c1
-rw-r--r--libsylph/prefs_common.h1
-rw-r--r--libsylph/procmime.c5
-rw-r--r--libsylph/procmsg.c4
-rw-r--r--libsylph/utils.c34
-rw-r--r--libsylph/utils.h3
-rw-r--r--src/compose.c6
-rw-r--r--src/inc.c5
-rw-r--r--src/messageview.c4
-rw-r--r--src/mimeview.c25
-rw-r--r--src/summaryview.c4
13 files changed, 75 insertions, 31 deletions
diff --git a/ChangeLog b/ChangeLog
index 0177769f..e744d6cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-03-09
+
+ * libsylph/utils.[ch]
+ libsylph/prefs_common.[ch]
+ src/mimeview.c: added a hidden option "mime_command" for backward
+ compatibility.
+
2006-03-08
* libsylph/procmime.c: read mailcap file other than standard location.
diff --git a/ChangeLog.ja b/ChangeLog.ja
index a9edeec9..b4336640 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,3 +1,10 @@
+2006-03-09
+
+ * libsylph/utils.[ch]
+ libsylph/prefs_common.[ch]
+ src/mimeview.c: 後方互換性のために隠しオプション "mime_command"
+ を追加。
+
2006-03-08
* libsylph/procmime.c: 標準の場所以外の mailcap ファイルも読むように
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);
diff --git a/src/compose.c b/src/compose.c
index c6dc645e..7e34a88d 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -5440,7 +5440,6 @@ static void compose_exec_ext_editor(Compose *compose)
GPid pid;
static gchar *def_cmd = "emacs %s";
gchar buf[1024];
- gchar *p;
gchar **cmdline;
tmp = g_strdup_printf("%s%ctmpmsg-%p.txt", get_tmp_dir(),
@@ -5460,10 +5459,9 @@ static void compose_exec_ext_editor(Compose *compose)
#endif
if (prefs_common.ext_editor_cmd &&
- (p = strchr(prefs_common.ext_editor_cmd, '%')) &&
- *(p + 1) == 's' && !strchr(p + 2, '%')) {
+ str_find_format_times(prefs_common.ext_editor_cmd, 's') == 1)
g_snprintf(buf, sizeof(buf), prefs_common.ext_editor_cmd, tmp);
- } else {
+ else {
if (prefs_common.ext_editor_cmd)
g_warning(_("External editor command line is invalid: `%s'\n"),
prefs_common.ext_editor_cmd);
diff --git a/src/inc.c b/src/inc.c
index 87837327..c73985b0 100644
--- a/src/inc.c
+++ b/src/inc.c
@@ -182,10 +182,9 @@ static void inc_finished(MainWindow *mainwin, gint new_messages)
prefs_common.enable_newmsg_notify &&
prefs_common.newmsg_notify_cmd) {
gchar buf[1024];
- gchar *p;
- if ((p = strchr(prefs_common.newmsg_notify_cmd, '%')) &&
- *(p + 1) == 'd' && !strchr(p + 2, '%'))
+ if (str_find_format_times
+ (prefs_common.newmsg_notify_cmd, 'd') == 1)
g_snprintf(buf, sizeof(buf),
prefs_common.newmsg_notify_cmd,
new_messages);
diff --git a/src/messageview.c b/src/messageview.c
index 109801a5..4365778b 100644
--- a/src/messageview.c
+++ b/src/messageview.c
@@ -748,7 +748,6 @@ static void print_cb(gpointer data, guint action, GtkWidget *widget)
MessageView *messageview = (MessageView *)data;
const gchar *cmdline;
gchar *msg;
- gchar *p;
if (!messageview->msginfo) return;
@@ -765,8 +764,7 @@ static void print_cb(gpointer data, guint action, GtkWidget *widget)
}
g_free(msg);
- if (cmdline && (!(p = strchr(cmdline, '%')) || *(p + 1) != 's' ||
- strchr(p + 2, '%'))) {
+ if (cmdline && str_find_format_times(cmdline, 's') != 1) {
alertpanel_error(_("Print command line is invalid:\n`%s'"),
cmdline);
return;
diff --git a/src/mimeview.c b/src/mimeview.c
index 5f4774bd..3a79811a 100644
--- a/src/mimeview.c
+++ b/src/mimeview.c
@@ -1126,8 +1126,7 @@ static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo,
const gchar *cmdline)
{
const gchar *cmd = NULL;
- const gchar *p;
- gchar *cmdbuf;
+ gchar buf[BUFFSIZE];
if (!cmdline) {
#ifdef G_OS_WIN32
@@ -1155,16 +1154,28 @@ static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo,
else if (MIME_TEXT_HTML == partinfo->mime_type)
cmd = prefs_common.uri_cmd;
if (!cmd) {
- procmime_execute_open_file
- (filename, partinfo->content_type);
- return;
+ if (prefs_common.mime_cmd) {
+ if (str_find_format_times
+ (prefs_common.mime_cmd, 's') == 2) {
+ g_snprintf(buf, sizeof(buf),
+ prefs_common.mime_cmd,
+ partinfo->content_type,
+ "%s");
+ cmd = buf;
+ } else
+ cmd = prefs_common.mime_cmd;
+ } else {
+ procmime_execute_open_file
+ (filename, partinfo->content_type);
+ return;
+ }
}
#endif
} else
cmd = cmdline;
- if (cmd && (p = strchr(cmd, '%')) && *(p + 1) == 's' &&
- !strchr(p + 2, '%')) {
+ if (cmd && str_find_format_times(cmd, 's') == 1) {
+ gchar *cmdbuf;
cmdbuf = g_strdup_printf(cmd, filename);
execute_command_line(cmdbuf, TRUE);
g_free(cmdbuf);
diff --git a/src/summaryview.c b/src/summaryview.c
index de3bc835..14cda4ed 100644
--- a/src/summaryview.c
+++ b/src/summaryview.c
@@ -3448,7 +3448,6 @@ void summary_print(SummaryView *summaryview)
GSList *mlist, *cur;
const gchar *cmdline;
gchar *msg;
- gchar *p;
if (gtk_tree_selection_count_selected_rows(summaryview->selection) == 0)
return;
@@ -3466,8 +3465,7 @@ void summary_print(SummaryView *summaryview)
}
g_free(msg);
- if (cmdline && (!(p = strchr(cmdline, '%')) || *(p + 1) != 's' ||
- strchr(p + 2, '%'))) {
+ if (cmdline && str_find_format_times(cmdline, 's') != 1) {
alertpanel_error(_("Print command line is invalid:\n`%s'"),
cmdline);
return;