aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/bogo-junk-plugin
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2008-04-25 21:12:22 +0800
committerMilan Crha <mcrha@src.gnome.org>2008-04-25 21:12:22 +0800
commit7ab42c2897e3b1d62bd47550d91ec85a55b651a5 (patch)
tree08d51cbc9948c95988fa47fa6024ad88062a8e75 /plugins/bogo-junk-plugin
parent2999fa6c7b07fa1a53a51cac013b56b2ace3852e (diff)
downloadgsoc2013-evolution-7ab42c2897e3b1d62bd47550d91ec85a55b651a5.tar.gz
gsoc2013-evolution-7ab42c2897e3b1d62bd47550d91ec85a55b651a5.tar.zst
gsoc2013-evolution-7ab42c2897e3b1d62bd47550d91ec85a55b651a5.zip
** Fix for bug #273041
2008-04-25 Milan Crha <mcrha@redhat.com> ** Fix for bug #273041 * mail/mail.error.xml: (junk-check-error), (junk-report-error), (junk-not-report-error): New error messages added. * mail/em-junk-hook.h: (struct _EMJunkHookTarget), (em_junk_error_quark): * mail/em-junk-hook.c: (manage_error), (em_junk_check_junk), (em_junk_report_junk), (em_junk_report_non_junk): Allow propagation of the error from the plugin in the hook target. * plugins/bogo-junk-plugin/bf-junk-filter.c: (pipe_to_bogofilter), (em_junk_bf_check_junk), (em_junk_bf_report_junk), (em_junk_bf_report_non_junk): Propagate possible errors to the UI. * sa-junk-plugin/em-junk-filter.c: (em_junk_sa_commit_reports), (em_junk_sa_validate_binary): Fix function prototype. * sa-junk-plugin/em-junk-filter.c: (pipe_to_sa_full), (em_junk_sa_test_spamd_running), (em_junk_sa_test_spamassassin), (pipe_to_sa), (em_junk_sa_run_spamd), (em_junk_sa_test_spamd), (em_junk_sa_is_available), (em_junk_sa_check_junk), (get_spamassassin_version), (em_junk_sa_report_junk), (em_junk_sa_report_non_junk): Propagate possible errors to the UI. svn path=/trunk/; revision=35415
Diffstat (limited to 'plugins/bogo-junk-plugin')
-rw-r--r--plugins/bogo-junk-plugin/ChangeLog8
-rw-r--r--plugins/bogo-junk-plugin/bf-junk-filter.c26
2 files changed, 26 insertions, 8 deletions
diff --git a/plugins/bogo-junk-plugin/ChangeLog b/plugins/bogo-junk-plugin/ChangeLog
index c40590a97e..4fc625aee7 100644
--- a/plugins/bogo-junk-plugin/ChangeLog
+++ b/plugins/bogo-junk-plugin/ChangeLog
@@ -1,3 +1,11 @@
+2008-04-25 Milan Crha <mcrha@redhat.com>
+
+ ** Fix for bug #273041
+
+ * bf-junk-filter.c: (pipe_to_bogofilter), (em_junk_bf_check_junk),
+ (em_junk_bf_report_junk), (em_junk_bf_report_non_junk):
+ Propagate possible errors to the UI.
+
2008-03-19 Sankar P <psankar@novell.com>
** Fix for bug #519304
diff --git a/plugins/bogo-junk-plugin/bf-junk-filter.c b/plugins/bogo-junk-plugin/bf-junk-filter.c
index 3e0758e14c..4cfbd5deca 100644
--- a/plugins/bogo-junk-plugin/bf-junk-filter.c
+++ b/plugins/bogo-junk-plugin/bf-junk-filter.c
@@ -73,9 +73,8 @@ int e_plugin_lib_enable (EPluginLib *ep, int enable);
static gboolean em_junk_bf_unicode = TRUE;
-
static gint
-pipe_to_bogofilter (CamelMimeMessage *msg, gchar **argv)
+pipe_to_bogofilter (CamelMimeMessage *msg, gchar **argv, GError **error)
{
GPid child_pid;
gint bf_in;
@@ -83,6 +82,7 @@ pipe_to_bogofilter (CamelMimeMessage *msg, gchar **argv)
GError *err = NULL;
gint status;
gint waitres;
+ gint res;
if (camel_debug_start ("junk")) {
int i;
@@ -110,6 +110,9 @@ pipe_to_bogofilter (CamelMimeMessage *msg, gchar **argv)
g_warning ("error occurred while spawning %s: %s",
argv[0],
err->message);
+ /* For Translators: The first %s stands for the executable full path with a file name, the second is the error message itself. */
+ g_set_error (error, EM_JUNK_ERROR, err->code, _("Error occurred while spawning %s: %s."), argv[0], err->message);
+
return BOGOFILTER_ERROR;
}
@@ -132,16 +135,23 @@ pipe_to_bogofilter (CamelMimeMessage *msg, gchar **argv)
kill (child_pid, SIGKILL);
sleep (1);
waitres = waitpid (child_pid, &status, WNOHANG);
- }
+ g_set_error (error, EM_JUNK_ERROR, -2, _("Bogofilter child process does not respond, killing..."));
+ } else
+ g_set_error (error, EM_JUNK_ERROR, -3, _("Wait for Bogofilter child process interrupted, terminating..."));
}
g_spawn_close_pid (child_pid);
if (waitres >= 0 && WIFEXITED (status)) {
- return WEXITSTATUS (status);
+ res = WEXITSTATUS (status);
} else {
- return BOGOFILTER_ERROR;
+ res = BOGOFILTER_ERROR;
}
+
+ if (res != 0)
+ g_set_error (error, EM_JUNK_ERROR, res, _("Pipe to Bogofilter failed, error code: %d."), res);
+
+ return res;
}
static void
@@ -190,7 +200,7 @@ em_junk_bf_check_junk (EPlugin *ep, EMJunkHookTarget *target)
argv[1] = "--unicode=yes";
}
- rv = pipe_to_bogofilter (msg, argv);
+ rv = pipe_to_bogofilter (msg, argv, &target->error);
d(fprintf (stderr, "em_junk_bf_check_junk rv = %d\n", rv));
@@ -215,7 +225,7 @@ em_junk_bf_report_junk (EPlugin *ep, EMJunkHookTarget *target)
argv[2] = "--unicode=yes";
}
- pipe_to_bogofilter (msg, argv);
+ pipe_to_bogofilter (msg, argv, &target->error);
}
void
@@ -236,7 +246,7 @@ em_junk_bf_report_non_junk (EPlugin *ep, EMJunkHookTarget *target)
argv[2] = "--unicode=yes";
}
- pipe_to_bogofilter (msg, argv);
+ pipe_to_bogofilter (msg, argv, &target->error);
}
void