aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-10-28 05:32:40 +0800
committerMilan Crha <mcrha@redhat.com>2009-10-28 05:32:40 +0800
commit1cdf521ff7d3f3f3134e54727cc3b0a30807ae1e (patch)
treee177d4a43c5e1ff263fb93eca8ad677d03acfa80 /plugins
parent9b4c2438652f02d045c58ec2f41b0592a6d26219 (diff)
downloadgsoc2013-evolution-1cdf521ff7d3f3f3134e54727cc3b0a30807ae1e.tar
gsoc2013-evolution-1cdf521ff7d3f3f3134e54727cc3b0a30807ae1e.tar.gz
gsoc2013-evolution-1cdf521ff7d3f3f3134e54727cc3b0a30807ae1e.tar.bz2
gsoc2013-evolution-1cdf521ff7d3f3f3134e54727cc3b0a30807ae1e.tar.lz
gsoc2013-evolution-1cdf521ff7d3f3f3134e54727cc3b0a30807ae1e.tar.xz
gsoc2013-evolution-1cdf521ff7d3f3f3134e54727cc3b0a30807ae1e.tar.zst
gsoc2013-evolution-1cdf521ff7d3f3f3134e54727cc3b0a30807ae1e.zip
Bug #552727 - Flooded by spam checking errors if bogofilter not installed
Diffstat (limited to 'plugins')
-rw-r--r--plugins/bogo-junk-plugin/bf-junk-filter.c48
-rw-r--r--plugins/sa-junk-plugin/em-junk-filter.c39
2 files changed, 69 insertions, 18 deletions
diff --git a/plugins/bogo-junk-plugin/bf-junk-filter.c b/plugins/bogo-junk-plugin/bf-junk-filter.c
index da384225c8..6d315da575 100644
--- a/plugins/bogo-junk-plugin/bf-junk-filter.c
+++ b/plugins/bogo-junk-plugin/bf-junk-filter.c
@@ -62,7 +62,7 @@
#define d(x) (camel_debug("junk")?(x):0)
-static gboolean enabled = FALSE;
+static gboolean is_installed = FALSE;
static gchar em_junk_bf_binary[] = BOGOFILTER_BINARY;
@@ -85,7 +85,7 @@ gint e_plugin_lib_enable (EPlugin *ep, gint enable);
static gboolean em_junk_bf_unicode = TRUE;
static void
-init_db ()
+init_db (void)
{
CamelStream *stream = camel_stream_fs_new_with_name (WELCOME_MESSAGE, O_RDONLY, 0);
CamelMimeParser *parser = camel_mime_parser_new ();
@@ -151,11 +151,18 @@ retry:
NULL,
&err))
{
- 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);
+ g_warning ("error occurred while spawning %s: %s", argv[0], err->message);
+
+ if (g_error_matches (err, G_SPAWN_ERROR, G_SPAWN_ERROR_NOENT)) {
+ if (is_installed)
+ g_set_error (error, EM_JUNK_ERROR, err->code, _("Bogofilter is not available. Please install it first."));
+ is_installed = FALSE;
+ } else {
+ /* 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);
+ }
+
+ g_error_free (err);
return BOGOFILTER_ERROR;
}
@@ -252,6 +259,9 @@ em_junk_bf_check_junk (EPlugin *ep, EMJunkTarget *target)
NULL
};
+ if (!is_installed)
+ return FALSE;
+
d(fprintf (stderr, "em_junk_bf_check_junk\n"));
if (em_junk_bf_unicode) {
@@ -277,6 +287,9 @@ em_junk_bf_report_junk (EPlugin *ep, EMJunkTarget *target)
NULL
};
+ if (!is_installed)
+ return;
+
d(fprintf (stderr, "em_junk_bf_report_junk\n"));
if (em_junk_bf_unicode) {
@@ -298,6 +311,9 @@ em_junk_bf_report_non_junk (EPlugin *ep, EMJunkTarget *target)
NULL
};
+ if (!is_installed)
+ return;
+
d(fprintf (stderr, "em_junk_bf_report_non_junk\n"));
if (em_junk_bf_unicode) {
@@ -310,23 +326,33 @@ em_junk_bf_report_non_junk (EPlugin *ep, EMJunkTarget *target)
void
em_junk_bf_commit_reports (EPlugin *ep, EMJunkTarget *target)
{
+ if (!is_installed)
+ return;
}
gpointer
em_junk_bf_validate_binary (EPlugin *ep, EMJunkTarget *target)
{
- return g_file_test (em_junk_bf_binary, G_FILE_TEST_EXISTS) ? (gpointer) "1" : NULL;
+ gpointer res = g_file_test (em_junk_bf_binary, G_FILE_TEST_EXISTS) ? (gpointer) "1" : NULL;
+
+ if (res != NULL)
+ is_installed = TRUE;
+
+ return res;
}
gint
e_plugin_lib_enable (EPlugin *ep, gint enable)
{
+ static gboolean first = TRUE;
GConfClient *gconf;
- if (enable != 1 || enabled == TRUE) {
+ is_installed = enable != 0;
+
+ if (!first)
return 0;
- }
- enabled = TRUE;
+
+ first = FALSE;
gconf = gconf_client_get_default();
gconf_client_add_dir (gconf,
diff --git a/plugins/sa-junk-plugin/em-junk-filter.c b/plugins/sa-junk-plugin/em-junk-filter.c
index df5fdecb0a..c0b59891a1 100644
--- a/plugins/sa-junk-plugin/em-junk-filter.c
+++ b/plugins/sa-junk-plugin/em-junk-filter.c
@@ -97,6 +97,7 @@ static gint em_junk_sa_spamd_restarts_count = 0;
/* Variables to indicate whether spamd is running with --allow-tell */
static gint no_allow_tell;
static gboolean em_junk_sa_allow_tell_tested = FALSE;
+static gboolean is_installed = FALSE;
gchar *em_junk_sa_spamc_gconf_binary = NULL;
gchar *em_junk_sa_spamd_gconf_binary = NULL;
@@ -504,8 +505,12 @@ em_junk_sa_is_available (GError **error)
if (em_junk_sa_available && !em_junk_sa_spamd_tested && em_junk_sa_use_daemon)
em_junk_sa_test_spamd ();
- if (!em_junk_sa_available)
- g_set_error (error, EM_JUNK_ERROR, 1, _("SpamAssassin is not available."));
+ if (!em_junk_sa_available && error) {
+ if (is_installed)
+ g_set_error (error, EM_JUNK_ERROR, 1, _("SpamAssassin is not available. Please install it first."));
+
+ is_installed = FALSE;
+ }
/* While we're at it, see if spamd is running with --allow-tell */
if (!em_junk_sa_allow_tell_tested)
@@ -579,10 +584,14 @@ em_junk_sa_check_junk(EPlugin *ep, EMJunkTarget *target)
gboolean rv;
CamelMimeMessage *msg = target->m;
+ if (!is_installed)
+ return FALSE;
+
d(fprintf (stderr, "em_junk_sa_check_junk\n"));
- if (!em_junk_sa_is_available (&target->error))
+ if (!em_junk_sa_is_available (&target->error)) {
return FALSE;
+ }
if (em_junk_sa_use_spamc && em_junk_sa_use_daemon) {
out = g_byte_array_new ();
@@ -697,6 +706,9 @@ em_junk_sa_report_junk (EPlugin *ep, EMJunkTarget *target)
gchar *sub = NULL;
CamelMimeMessage *msg = target->m;
+ if (!is_installed)
+ return;
+
sub = g_strdup (camel_mime_message_get_subject (msg));
g_print ("\nreport junk?? %s\n", sub);
@@ -736,6 +748,9 @@ em_junk_sa_report_non_junk (EPlugin *ep, EMJunkTarget *target)
};
CamelMimeMessage *msg = target->m;
+ if (!is_installed)
+ return;
+
d(fprintf (stderr, "em_junk_sa_report_notjunk\n"));
if (em_junk_sa_is_available (&target->error)) {
@@ -763,7 +778,7 @@ em_junk_sa_commit_reports (EPlugin *ep)
};
/* Only meaningful if we're using sa-learn */
- if (!no_allow_tell)
+ if (!no_allow_tell || !is_installed)
return;
d(fprintf (stderr, "em_junk_sa_commit_reports\n"));
@@ -781,7 +796,12 @@ em_junk_sa_commit_reports (EPlugin *ep)
gpointer
em_junk_sa_validate_binary (EPlugin *ep)
{
- return em_junk_sa_is_available (NULL) ? (gpointer) "1" : NULL;
+ gpointer res = em_junk_sa_is_available (NULL) ? (gpointer) "1" : NULL;
+
+ if (res != NULL)
+ is_installed = TRUE;
+
+ return res;
}
static void
@@ -813,6 +833,11 @@ em_junk_sa_setting_notify(GConfClient *gconf, guint cnxn_id, GConfEntry *entry,
gint
e_plugin_lib_enable (EPlugin *ep, gint enable)
{
+ is_installed = enable != 0;
+
+ if (is_installed)
+ em_junk_sa_tested = FALSE;
+
em_junk_sa_init();
return 0;
@@ -841,11 +866,11 @@ em_junk_sa_init (void)
em_junk_sa_spamc_gconf_binary = gconf_client_get_string (em_junk_sa_gconf, "/apps/evolution/mail/junk/sa/spamc_binary", NULL);
em_junk_sa_spamd_gconf_binary = gconf_client_get_string (em_junk_sa_gconf, "/apps/evolution/mail/junk/sa/spamd_binary", NULL);
+
+ atexit (em_junk_sa_finalize);
}
G_UNLOCK (init);
-
- atexit (em_junk_sa_finalize);
}
static void