diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2007-04-06 05:03:00 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2007-04-06 05:03:00 +0000 |
commit | beedd408b15d15073d135252043fd47d421f4ab4 (patch) | |
tree | e8ee2290f3399ffa09d1efd347b413ca99eac7ed | |
parent | 2dd04f6bc82e5242566c0c829ef50a35f00f4c98 (diff) |
display error dialog if the execution of the junk filter command failed.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1597 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | ChangeLog.ja | 7 | ||||
-rw-r--r-- | libsylph/filter.c | 29 | ||||
-rw-r--r-- | libsylph/filter.h | 9 | ||||
-rw-r--r-- | src/inc.c | 16 | ||||
-rw-r--r-- | src/summaryview.c | 8 |
6 files changed, 71 insertions, 5 deletions
@@ -1,5 +1,12 @@ 2007-04-06 + * libsylph/filter.[ch]: return error code. + * src/inc.c + src/summaryview.c: display error dialog if the execution of the + junk filter command failed. + +2007-04-06 + * src/summaryview.c: added new quick search rule: 'Within 1 day' and 'Recent 5 days'. Fixed a memory leak. diff --git a/ChangeLog.ja b/ChangeLog.ja index 427941c4..ff229c7f 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,5 +1,12 @@ 2007-04-06 + * libsylph/filter.[ch]: エラーコードを返すようにした。 + * src/inc.c + src/summaryview.c: 迷惑メールフィルタコマンドの実行に失敗した + 場合はエラーダイアログを表示するようにした。 + +2007-04-06 + * src/summaryview.c: 新しいクイックサーチルール: 「1日以内」と 「最近5日間」を追加。メモリリークを修正。 diff --git a/libsylph/filter.c b/libsylph/filter.c index 47b60aab..a0ab4ccf 100644 --- a/libsylph/filter.c +++ b/libsylph/filter.c @@ -97,6 +97,8 @@ gint filter_apply_msginfo(GSList *fltlist, MsgInfo *msginfo, g_return_val_if_fail(msginfo != NULL, -1); g_return_val_if_fail(fltinfo != NULL, -1); + fltinfo->error = FLT_ERROR_OK; + if (!fltlist) return 0; file = procmsg_get_message_file(msginfo); @@ -109,12 +111,18 @@ gint filter_apply_msginfo(GSList *fltlist, MsgInfo *msginfo, } for (cur = fltlist; cur != NULL; cur = cur->next) { + gboolean matched; + rule = (FilterRule *)cur->data; if (!rule->enabled) continue; - if (filter_match_rule(rule, msginfo, hlist, fltinfo)) { + matched = filter_match_rule(rule, msginfo, hlist, fltinfo); + if (fltinfo->error != FLT_ERROR_OK) { + g_warning("filter_match_rule() returned error (code: %d)\n", fltinfo->error); + } + if (matched) { ret = filter_action_exec(rule, msginfo, file, fltinfo); if (ret < 0) { - g_warning("filter_action_exec() returned error\n"); + g_warning("filter_action_exec() returned error (code: %d)\n", fltinfo->error); break; } if (fltinfo->drop_done == TRUE || @@ -202,6 +210,7 @@ gint filter_action_exec(FilterRule *rule, MsgInfo *msginfo, const gchar *file, if (!dest_folder) { g_warning("dest folder '%s' not found\n", action->str_value); + fltinfo->error = FLT_ERROR_ERROR; return -1; } debug_print("filter_action_exec(): %s: dest_folder = %s\n", @@ -223,16 +232,20 @@ gint filter_action_exec(FilterRule *rule, MsgInfo *msginfo, const gchar *file, val = folder_item_copy_msg (dest_folder, msginfo); msginfo->flags = save_flags; - if (val == -1) + if (val == -1) { + fltinfo->error = FLT_ERROR_ERROR; return -1; + } } fltinfo->actions[action->type] = TRUE; } } else { if (folder_item_add_msg(dest_folder, file, &fltinfo->flags, - FALSE) < 0) + FALSE) < 0) { + fltinfo->error = FLT_ERROR_ERROR; return -1; + } fltinfo->actions[action->type] = TRUE; } @@ -358,6 +371,7 @@ gboolean filter_match_rule(FilterRule *rule, MsgInfo *msginfo, GSList *hlist, static gboolean filter_match_cond(FilterCond *cond, MsgInfo *msginfo, GSList *hlist, FilterInfo *fltinfo) { + gint ret; gboolean matched = FALSE; gchar *file; gchar *cmdline; @@ -377,7 +391,10 @@ static gboolean filter_match_cond(FilterCond *cond, MsgInfo *msginfo, if (!file) return FALSE; cmdline = g_strconcat(cond->str_value, " \"", file, "\"", NULL); - matched = (execute_command_line(cmdline, FALSE) == 0); + ret = execute_command_line(cmdline, FALSE); + matched = (ret == 0); + if (ret == -1) + fltinfo->error = FLT_ERROR_EXEC_FAILED; g_free(cmdline); g_free(file); break; @@ -407,6 +424,7 @@ static gboolean filter_match_cond(FilterCond *cond, MsgInfo *msginfo, default: g_warning("filter_match_cond(): unknown condition: %d\n", cond->type); + fltinfo->error = FLT_ERROR_ERROR; return FALSE; } @@ -1259,6 +1277,7 @@ FilterInfo *filter_info_new(void) fltinfo->dest_list = NULL; fltinfo->move_dest = NULL; fltinfo->drop_done = FALSE; + fltinfo->error = FLT_ERROR_OK; return fltinfo; } diff --git a/libsylph/filter.h b/libsylph/filter.h index 9f0940be..132810f5 100644 --- a/libsylph/filter.h +++ b/libsylph/filter.h @@ -100,6 +100,13 @@ typedef enum FLT_BY_SUBJECT } FilterCreateType; +typedef enum +{ + FLT_ERROR_OK, + FLT_ERROR_ERROR, + FLT_ERROR_EXEC_FAILED +} FilterErrorValue; + #define FLT_IS_NOT_MATCH(flag) ((flag & FLT_NOT_MATCH) != 0) #define FLT_IS_CASE_SENS(flag) ((flag & FLT_CASE_SENS) != 0) @@ -151,6 +158,8 @@ struct _FilterInfo GSList *dest_list; FolderItem *move_dest; gboolean drop_done; + + FilterErrorValue error; }; gint filter_apply (GSList *fltlist, @@ -1214,6 +1214,14 @@ static gint inc_drop_message(Pop3Session *session, const gchar *file) filter_apply(prefs_common.junk_fltlist, file, fltinfo); if (fltinfo->drop_done) is_junk = TRUE; + else if (fltinfo->error == FLT_ERROR_EXEC_FAILED) { + alertpanel_error + (_("Execution of the junk filter command failed.\n" + "Please check the junk mail control setting.")); + filter_info_free(fltinfo); + inc_session->inc_state = INC_ERROR; + return DROP_ERROR; + } } if (!fltinfo->drop_done && session->ac_prefs->filter_on_recv) @@ -1226,6 +1234,14 @@ static gint inc_drop_message(Pop3Session *session, const gchar *file) filter_apply(prefs_common.junk_fltlist, file, fltinfo); if (fltinfo->drop_done) is_junk = TRUE; + else if (fltinfo->error == FLT_ERROR_EXEC_FAILED) { + alertpanel_error + (_("Execution of the junk filter command failed.\n" + "Please check the junk mail control setting.")); + filter_info_free(fltinfo); + inc_session->inc_state = INC_ERROR; + return DROP_ERROR; + } } } diff --git a/src/summaryview.c b/src/summaryview.c index 368eacac..e74fe4a5 100644 --- a/src/summaryview.c +++ b/src/summaryview.c @@ -4465,6 +4465,14 @@ 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) { + if (summaryview->flt_count == 1) { + alertpanel_error + (_("Execution of the junk filter command failed.\n" + "Please check the junk mail control setting.")); + } + return TRUE; + } if (msginfo->flags.perm_flags != fltinfo->flags.perm_flags) { msginfo->flags = fltinfo->flags; |