2006-04-06 [mones] 2.1.0cvs7
[claws.git] / src / plugins / spamassassin / spamassassin.c
index f7762b47ae9944286e5536a5c6b4e01210564b20..9ac5dcf1d675de169afe3688aef6865921769d05 100644 (file)
@@ -83,6 +83,8 @@ static MessageCallback message_callback;
 static SpamAssassinConfig config;
 
 static PrefParam param[] = {
+       {"enable", "FALSE", &config.enable, P_BOOL,
+       NULL, NULL, NULL},
        {"transport", "0", &config.transport, P_INT,
         NULL, NULL, NULL},
        {"hostname", "localhost", &config.hostname, P_STRING,
@@ -124,6 +126,9 @@ static gboolean msg_is_spam(FILE *fp)
        struct message m;
        gboolean is_spam = FALSE;
 
+       if (!config.enable)
+               return FALSE;
+
        transport_init(&trans);
        switch (config.transport) {
        case SPAMASSASSIN_TRANSPORT_LOCALHOST:
@@ -182,7 +187,8 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
        int pid = 0;
        int status;
 
-       if (config.transport == SPAMASSASSIN_DISABLED) {
+       /* SPAMASSASSIN_DISABLED : keep test for compatibility purpose */
+       if (!config.enable || config.transport == SPAMASSASSIN_DISABLED) {
                log_error("Spamassassin plugin is disabled by its preferences.\n");
                return FALSE;
        }
@@ -340,13 +346,9 @@ int spamassassin_learn(MsgInfo *msginfo, GSList *msglist, gboolean spam)
                                        execute_command_line(tmpcmd, FALSE);
                                        g_free(tmpcmd);
                                }
-                               if (tmpfile != NULL) {
-                                       g_free(tmpfile);
-                               }
-                       }
-                       if (spamc_wrapper != NULL) {
-                               g_free(spamc_wrapper);
+                               g_free(tmpfile);
                        }
+                       g_free(spamc_wrapper);
                        return 0;
                } else {
                        cmd = g_strdup_printf("sa-learn -u %s %s %s",
@@ -366,9 +368,7 @@ int spamassassin_learn(MsgInfo *msginfo, GSList *msglist, gboolean spam)
                                        g_free(cmd);
                                        cmd = tmpcmd;
                                }
-                               if (tmpfile != NULL) {
-                                       g_free(tmpfile);
-                               }
+                               g_free(tmpfile);
                        }
                }
        }
@@ -379,9 +379,8 @@ int spamassassin_learn(MsgInfo *msginfo, GSList *msglist, gboolean spam)
        /* only run sync calls to sa-learn/spamc to prevent system lockdown */
        execute_command_line(cmd, FALSE);
        g_free(cmd);
-       if (spamc_wrapper != NULL) {
-               g_free(spamc_wrapper);
-       }
+       g_free(spamc_wrapper);
+
        return 0;
 }
 
@@ -461,11 +460,10 @@ gint plugin_init(gchar **error)
                spamassassin_register_hook();
        }
 
-       if (config.transport == SPAMASSASSIN_DISABLED) {
+       if (!config.enable || config.transport == SPAMASSASSIN_DISABLED) {
                log_error("Spamassassin plugin is loaded but disabled by its preferences.\n");
        }
-
-       if (config.transport != SPAMASSASSIN_DISABLED) {
+       else {
                if (config.transport == SPAMASSASSIN_TRANSPORT_TCP)
                        debug_print("Enabling learner with a remote spamassassin server requires spamc/spamd 3.1.x\n");
                procmsg_register_spam_learner(spamassassin_learn);
@@ -496,14 +494,17 @@ const gchar *plugin_name(void)
 
 const gchar *plugin_desc(void)
 {
-       return _("This plugin checks all messages that are received from an "
+       return _("This plugin can check all messages that are received from an "
                 "IMAP, LOCAL or POP account for spam using a SpamAssassin "
                 "server. You will need a SpamAssassin Server (spamd) running "
                 "somewhere.\n"
                 "\n"
+                "It can also be used for marking messages as Ham or Spam.\n"
+                "\n"
                 "When a message is identified as spam it can be deleted or "
-                "saved into a special folder.\n"
-                "\n");
+                "saved in a specially designated folder.\n"
+                "\n"
+                "Options can be found in /Configuration/Preferences/Plugins/SpamAssassin");
 }
 
 const gchar *plugin_type(void)