diff options
author | Shi Pu <shi.pu@sun.com> | 2006-01-04 17:06:01 +0800 |
---|---|---|
committer | Harry Lu <haip@src.gnome.org> | 2006-01-04 17:06:01 +0800 |
commit | ce328275aa0fb64f5791cfce6ea9cbc0937eb3ab (patch) | |
tree | 53edf6827acd7748058e059d79131eb0f98549fa /plugins/sa-junk-plugin | |
parent | b278fdd58784c5f47d7ebff440a25a614413d4ad (diff) | |
download | gsoc2013-evolution-ce328275aa0fb64f5791cfce6ea9cbc0937eb3ab.tar.gz gsoc2013-evolution-ce328275aa0fb64f5791cfce6ea9cbc0937eb3ab.tar.zst gsoc2013-evolution-ce328275aa0fb64f5791cfce6ea9cbc0937eb3ab.zip |
See bug ** 325210
2005-01-04 Shi Pu <shi.pu@sun.com>
See bug ** 325210
* em-junk-filter.c:
(get_spamassassin_version): gets the spamassassin version which evolution used (em_junk_sa_report_junk),
(em_junk_sa_report_non_junk),
(em_junk_sa_commit_reports): judge spamassassin version to decide
which sync option should be used
svn path=/trunk/; revision=31050
Diffstat (limited to 'plugins/sa-junk-plugin')
-rw-r--r-- | plugins/sa-junk-plugin/ChangeLog | 11 | ||||
-rw-r--r-- | plugins/sa-junk-plugin/em-junk-filter.c | 50 |
2 files changed, 58 insertions, 3 deletions
diff --git a/plugins/sa-junk-plugin/ChangeLog b/plugins/sa-junk-plugin/ChangeLog index f1d8bfb1f9..34d88bb950 100644 --- a/plugins/sa-junk-plugin/ChangeLog +++ b/plugins/sa-junk-plugin/ChangeLog @@ -1,3 +1,14 @@ +2005-01-04 Shi Pu <shi.pu@sun.com> + + See bug ** 325210 + + * em-junk-filter.c: + (get_spamassassin_version): gets the spamassassin version which evolution used + (em_junk_sa_report_junk), + (em_junk_sa_report_non_junk), + (em_junk_sa_commit_reports): judge spamassassin version to decide + which sync option should be used + 2005-10-06 Vivek Jain <jvivek@novell.com> ** See Bug #268852 diff --git a/plugins/sa-junk-plugin/em-junk-filter.c b/plugins/sa-junk-plugin/em-junk-filter.c index 431b0b3a12..8fbe471fc0 100644 --- a/plugins/sa-junk-plugin/em-junk-filter.c +++ b/plugins/sa-junk-plugin/em-junk-filter.c @@ -73,6 +73,8 @@ static gboolean em_junk_sa_use_spamc = FALSE; static gboolean em_junk_sa_available = FALSE; static gboolean em_junk_sa_system_spamd_available = FALSE; static gboolean em_junk_sa_new_daemon_started = FALSE; +static gboolean em_junk_sa_checked_spamassassin_version = FALSE; +static guint em_junk_sa_spamassassin_version = 0; static char *em_junk_sa_socket_path = NULL; static char *em_junk_sa_spamd_pidfile = NULL; static char *em_junk_sa_spamc_binary = NULL; @@ -588,12 +590,52 @@ em_junk_sa_check_junk(EPlugin *ep, EMJunkHookTarget *target) return rv; } +static guint +get_spamassassin_version () +{ + GByteArray *out = NULL; + int i; + + char * argv[3] = { + "sa-learn", + "--version", + NULL + }; + + if (!em_junk_sa_checked_spamassassin_version){ + out = g_byte_array_new (); + + if (pipe_to_sa_full (NULL, NULL, argv, -1, 1, out) != 0){ + if(out) + g_byte_array_free (out, TRUE); + return em_junk_sa_spamassassin_version; + } + + if(out->len > 0){ + for(i = 0; i < out->len; i++){ + if(g_ascii_isdigit (out->data[i])){ + em_junk_sa_spamassassin_version = (out->data[i] - '0'); + em_junk_sa_checked_spamassassin_version = TRUE; + break; + } + } + } + + + if(out) + g_byte_array_free (out, TRUE); + } + + return em_junk_sa_spamassassin_version; +} + void em_junk_sa_report_junk (EPlugin *ep, EMJunkHookTarget *target) { + char *sync_op = ((get_spamassassin_version () >= 3) ? "--no-sync": "--no-rebuild"); char *argv[6] = { "sa-learn", - "--no-rebuild", + sync_op, "--spam", "--single", NULL, @@ -620,9 +662,10 @@ em_junk_sa_report_junk (EPlugin *ep, EMJunkHookTarget *target) void em_junk_sa_report_non_junk (EPlugin *ep, EMJunkHookTarget *target) { + char *sync_op = ((get_spamassassin_version () >= 3) ? "--no-sync": "--no-rebuild"); char *argv[6] = { "sa-learn", - "--no-rebuild", + sync_op, "--ham", "--single", NULL, @@ -645,9 +688,10 @@ em_junk_sa_report_non_junk (EPlugin *ep, EMJunkHookTarget *target) void em_junk_sa_commit_reports (EPlugin *ep, EMJunkHookTarget *target) { + char *sync_op = ((get_spamassassin_version () >= 3) ? "--sync": "--rebuild"); char *argv[4] = { "sa-learn", - "--rebuild", + sync_op, NULL, NULL }; |