diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2011-01-20 04:49:28 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2011-01-20 04:49:28 +0000 |
commit | e4c8db7b4c62806e29d8f6aad4180642f7d994d6 (patch) | |
tree | c3cf40dac3babebae8a6ea0dbc1eae610f489b5f /libsylph | |
parent | 890921332f2f03f0aaead00067321f7b5137bcd2 (diff) |
check the return value of junk filter command and show error dialog on failure.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2809 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph')
-rw-r--r-- | libsylph/filter.c | 23 | ||||
-rw-r--r-- | libsylph/filter.h | 1 |
2 files changed, 21 insertions, 3 deletions
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, |