diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | libsylph/filter.c | 23 | ||||
-rw-r--r-- | libsylph/filter.h | 1 | ||||
-rw-r--r-- | src/inc.c | 10 | ||||
-rw-r--r-- | src/summaryview.c | 42 |
5 files changed, 67 insertions, 16 deletions
@@ -1,3 +1,10 @@ +2011-01-19 + + * libsylph/filter.[ch] + src/inc.c + src/summaryview.c: check the return value of junk filter command + and show error dialog on failure. + 2011-01-18 * src/inc.c diff --git a/libsylph/filter.c b/libsylph/filter.c index 1a4c1c29..bb6a1c74 100644 --- a/libsylph/filter.c +++ b/libsylph/filter.c @@ -1,6 +1,6 @@ /* * LibSylph -- E-Mail client library - * Copyright (C) 1999-2010 Hiroyuki Yamamoto + * Copyright (C) 1999-2011 Hiroyuki Yamamoto * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -162,6 +162,7 @@ gint filter_action_exec(FilterRule *rule, MsgInfo *msginfo, const gchar *file, GSList *cur; gchar *cmdline; gboolean copy_to_self = FALSE; + gint ret; g_return_val_if_fail(rule != NULL, -1); g_return_val_if_fail(msginfo != NULL, -1); @@ -200,14 +201,28 @@ gint filter_action_exec(FilterRule *rule, MsgInfo *msginfo, const gchar *file, case FLT_ACTION_EXEC: cmdline = g_strconcat(action->str_value, " \"", file, "\"", NULL); - execute_command_line(cmdline, FALSE); + ret = execute_command_line(cmdline, FALSE); + fltinfo->last_exec_exit_status = ret; + if (ret == -1) { + fltinfo->error = FLT_ERROR_EXEC_FAILED; + g_warning("filter_action_exec: cannot execute command: %s", cmdline); + g_free(cmdline); + return -1; + } g_free(cmdline); fltinfo->actions[action->type] = TRUE; break; case FLT_ACTION_EXEC_ASYNC: cmdline = g_strconcat(action->str_value, " \"", file, "\"", NULL); - execute_command_line(cmdline, TRUE); + ret = execute_command_line(cmdline, TRUE); + fltinfo->last_exec_exit_status = ret; + if (ret == -1) { + fltinfo->error = FLT_ERROR_EXEC_FAILED; + g_warning("filter_action_exec: cannot execute command: %s", cmdline); + g_free(cmdline); + return -1; + } g_free(cmdline); fltinfo->actions[action->type] = TRUE; break; @@ -469,6 +484,7 @@ static gboolean filter_match_cond(FilterCond *cond, MsgInfo *msginfo, return FALSE; cmdline = g_strconcat(cond->str_value, " \"", file, "\"", NULL); ret = execute_command_line_async_wait(cmdline); + fltinfo->last_exec_exit_status = ret; matched = (ret == 0); if (ret == -1) fltinfo->error = FLT_ERROR_EXEC_FAILED; @@ -1495,6 +1511,7 @@ FilterInfo *filter_info_new(void) fltinfo->move_dest = NULL; fltinfo->drop_done = FALSE; fltinfo->error = FLT_ERROR_OK; + fltinfo->last_exec_exit_status = 0; return fltinfo; } diff --git a/libsylph/filter.h b/libsylph/filter.h index bb98e570..296c1506 100644 --- a/libsylph/filter.h +++ b/libsylph/filter.h @@ -163,6 +163,7 @@ struct _FilterInfo gboolean drop_done; FilterErrorValue error; + gint last_exec_exit_status; }; gint filter_apply (GSList *fltlist, @@ -1313,7 +1313,10 @@ static gint inc_drop_message(Pop3Session *session, const gchar *file) fltinfo); if (fltinfo->drop_done) is_junk = TRUE; - else if (fltinfo->error == FLT_ERROR_EXEC_FAILED) { + else if (fltinfo->error == FLT_ERROR_EXEC_FAILED || + fltinfo->last_exec_exit_status >= 3) { + g_warning("inc_drop_message: junk filter command returned %d", + fltinfo->last_exec_exit_status); alertpanel_error (_("Execution of the junk filter command failed.\n" "Please check the junk mail control setting.")); @@ -1337,7 +1340,10 @@ static gint inc_drop_message(Pop3Session *session, const gchar *file) msginfo, fltinfo); if (fltinfo->drop_done) is_junk = TRUE; - else if (fltinfo->error == FLT_ERROR_EXEC_FAILED) { + else if (fltinfo->error == FLT_ERROR_EXEC_FAILED || + fltinfo->last_exec_exit_status >= 3) { + g_warning("inc_drop_message: junk filter command returned %d", + fltinfo->last_exec_exit_status); alertpanel_error (_("Execution of the junk filter command failed.\n" "Please check the junk mail control setting.")); diff --git a/src/summaryview.c b/src/summaryview.c index ab01fe5b..8429839d 100644 --- a/src/summaryview.c +++ b/src/summaryview.c @@ -4733,8 +4733,10 @@ static gboolean summary_filter_junk_func(GtkTreeModel *model, GtkTreePath *path, fltinfo->actions[FLT_ACTION_DELETE] || fltinfo->actions[FLT_ACTION_MARK_READ]) summaryview->filtered++; - else if (fltinfo->error == FLT_ERROR_EXEC_FAILED) { + else if (fltinfo->error == FLT_ERROR_EXEC_FAILED || + fltinfo->last_exec_exit_status >= 3) { if (summaryview->flt_count == 1) { + g_warning("summary_filter_junk_func: junk filter command returned %d", fltinfo->last_exec_exit_status); alertpanel_error (_("Execution of the junk filter command failed.\n" "Please check the junk mail control setting.")); @@ -4922,18 +4924,28 @@ static void summary_junk_func(GtkTreeModel *model, GtkTreePath *path, ret = filter_action_exec(&rule, msginfo, file, fltinfo); - if (ret == 0 && - msginfo->flags.perm_flags != fltinfo->flags.perm_flags) { - msginfo->flags = fltinfo->flags; - summary_set_row(summaryview, iter, msginfo); - if (MSG_IS_IMAP(msginfo->flags)) { - if (fltinfo->actions[FLT_ACTION_MARK_READ]) - imap_msg_unset_perm_flags(msginfo, - MSG_NEW | MSG_UNREAD); + if (ret < 0 || fltinfo->last_exec_exit_status != 0) { + g_warning("summary_junk_func: junk filter command returned %d", + fltinfo->last_exec_exit_status); + alertpanel_error + (_("Execution of the junk filter command failed.\n" + "Please check the junk mail control setting.")); + } else { + if (ret == 0 && + msginfo->flags.perm_flags != fltinfo->flags.perm_flags) { + msginfo->flags = fltinfo->flags; + summary_set_row(summaryview, iter, msginfo); + if (MSG_IS_IMAP(msginfo->flags)) { + if (fltinfo->actions[FLT_ACTION_MARK_READ]) + imap_msg_unset_perm_flags + (msginfo, MSG_NEW | MSG_UNREAD); + } } + if (ret == 0 && fltinfo->actions[FLT_ACTION_MOVE] && + fltinfo->move_dest) + summary_move_row_to(summaryview, iter, + fltinfo->move_dest); } - if (ret == 0 && fltinfo->actions[FLT_ACTION_MOVE] && fltinfo->move_dest) - summary_move_row_to(summaryview, iter, fltinfo->move_dest); filter_info_free(fltinfo); g_slist_free(rule.action_list); @@ -4963,6 +4975,14 @@ static void summary_not_junk_func(GtkTreeModel *model, GtkTreePath *path, ret = filter_action_exec(&rule, msginfo, file, fltinfo); + if (ret < 0 || fltinfo->last_exec_exit_status != 0) { + g_warning("summary_not_junk_func: junk filter command returned %d", + fltinfo->last_exec_exit_status); + alertpanel_error + (_("Execution of the junk filter command failed.\n" + "Please check the junk mail control setting.")); + } + filter_info_free(fltinfo); g_slist_free(rule.action_list); g_free(file); |