2012-09-09 [mones] 3.8.1cvs47
[claws.git] / src / plugins / bogofilter / bogofilter.c
index f63ea50fe449f6e9f6500eb56ddd010f89a13519..61001003b3e91849e091702512d3b9ce319ab4af 100644 (file)
@@ -1,10 +1,11 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Claws Mail Team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2012 Colin Leroy <colin@colino.net> and 
+ * the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
+#include "claws-features.h"
 #endif
 
 #include "defs.h"
 #ifdef HAVE_PWD_H
 #include <pwd.h>
 #endif
+#ifdef USE_PTHREAD
+#include <pthread.h>
+#endif
+
+#define PLUGIN_NAME (_("Bogofilter"))
 
 static guint hook_id = -1;
 static MessageCallback message_callback;
@@ -85,13 +92,23 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"save_folder", NULL, &config.save_folder, P_STRING,
         NULL, NULL, NULL},
+       {"save_unsure", "FALSE", &config.save_unsure, P_BOOL,
+        NULL, NULL, NULL},
+       {"save_unsure_folder", NULL, &config.save_unsure_folder, P_STRING,
+        NULL, NULL, NULL},
        {"max_size", "250", &config.max_size, P_INT,
         NULL, NULL, NULL},
        {"bogopath", "bogofilter", &config.bogopath, P_STRING,
         NULL, NULL, NULL},
        {"insert_header", "FALSE", &config.insert_header, P_BOOL,
         NULL, NULL, NULL},
-       {"whitelist_ab", "TRUE", &config.whitelist_ab, P_BOOL,
+       {"whitelist_ab", "FALSE", &config.whitelist_ab, P_BOOL,
+        NULL, NULL, NULL},
+       {"whitelist_ab_folder", N_("Any"), &config.whitelist_ab_folder, P_STRING,
+        NULL, NULL, NULL},
+       {"learn_from_whitelist", "FALSE", &config.learn_from_whitelist, P_BOOL,
+        NULL, NULL, NULL},
+       {"mark_as_read", "TRUE", &config.mark_as_read, P_BOOL,
         NULL, NULL, NULL},
 
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
@@ -129,6 +146,7 @@ typedef struct _BogoFilterData {
        gchar **bogo_args;
        GSList *msglist;
        GSList *new_hams;
+       GSList *new_unsure;
        GSList *new_spams;
        GSList *whitelisted_new_spams;
        gboolean done;
@@ -198,8 +216,20 @@ static void bogofilter_do_filter(BogoFilterData *data)
                status = -1;
        } else {
        
-               if (config.whitelist_ab)
-                       start_address_completion(NULL);
+               if (config.whitelist_ab) {
+                       gchar *ab_folderpath;
+
+                       if (*config.whitelist_ab_folder == '\0' ||
+                               strcasecmp(config.whitelist_ab_folder, "Any") == 0) {
+                               /* match the whole addressbook */
+                               ab_folderpath = NULL;
+                       } else {
+                               /* match the specific book/folder of the addressbook */
+                               ab_folderpath = config.whitelist_ab_folder;
+                       }
+
+                       start_address_completion(ab_folderpath);
+               }
 
                for (cur = data->msglist; cur; cur = cur->next) {
                        gboolean whitelisted = FALSE;
@@ -246,8 +276,8 @@ static void bogofilter_do_filter(BogoFilterData *data)
                                            FOLDER_TYPE(msginfo->folder->folder) == F_MH &&
                                            config.insert_header) {
                                                gchar *tmpfile = get_tmp_file();
-                                               FILE *input = fopen(file, "r");
-                                               FILE *output = fopen(tmpfile, "w");
+                                               FILE *input = g_fopen(file, "r");
+                                               FILE *output = g_fopen(tmpfile, "w");
                                                if (strstr(parts[2], "\n"))
                                                        *(strstr(parts[2], "\n")) = '\0';
                                                if (input && !output) 
@@ -256,18 +286,28 @@ static void bogofilter_do_filter(BogoFilterData *data)
                                                        fclose (output);
                                                else {
                                                        gchar tmpbuf[BUFFSIZE];
+                                                       gboolean err = FALSE;
                                                        const gchar *bogosity = *parts[1] == 'S' ? "Spam":
                                                                                 (*parts[1] == 'H' ? "Ham":"Unsure");
                                                        gchar *tmpstr = g_strdup_printf(
                                                                        "X-Claws-Bogosity: %s, spamicity=%s%s\n",
                                                                        bogosity, parts[2],
                                                                        whitelisted?" [whitelisted]":"");
-                                                       fwrite(tmpstr, 1, strlen(tmpstr), output);
-                                                       while (fgets(tmpbuf, sizeof(buf), input))
-                                                               fputs(tmpbuf, output);
+                                                       if (fwrite(tmpstr, 1, strlen(tmpstr), output) < strlen(tmpstr)) {
+                                                               err = TRUE;
+                                                       } else {
+                                                               while (fgets(tmpbuf, sizeof(buf), input)) {
+                                                                       if (fputs(tmpbuf, output) == EOF) {
+                                                                               err = TRUE;
+                                                                               break;
+                                                                       }
+                                                               }
+                                                       }
                                                        fclose(input);
-                                                       fclose(output);
-                                                       move_file(tmpfile, file, TRUE);
+                                                       if (fclose(output) == EOF)
+                                                               err = TRUE;
+                                                       if (!err)
+                                                               move_file(tmpfile, file, TRUE);
                                                        g_free(tmpstr);
                                                }
                                                g_free(tmpfile);
@@ -282,9 +322,11 @@ static void bogofilter_do_filter(BogoFilterData *data)
                                                        data->mail_filtering_data->filtered, msginfo);
                                                data->new_spams = g_slist_prepend(data->new_spams, msginfo);
 
-                                       } else if (whitelisted && parts && parts[0] && parts[1] && *parts[1] == 'S') {
+                                       } else if (whitelisted && parts && parts[0] && parts[1] && 
+                                                       (*parts[1] == 'S' || *parts[1] == 'U')) {
 
-                                               debug_print("message %d is whitelisted spam\n", msginfo->msgnum);
+                                               debug_print("message %d is whitelisted %s\n", msginfo->msgnum,
+                                                       *parts[1] == 'S' ? "spam":"unsure");
                                                /* Whitelisted spam will *not* be filtered away, but continue
                                                 * their trip through filtering as if it was ham. */
                                                data->mail_filtering_data->unfiltered = g_slist_prepend(
@@ -295,6 +337,14 @@ static void bogofilter_do_filter(BogoFilterData *data)
                                                 * it was not). */
                                                data->whitelisted_new_spams = g_slist_prepend(data->whitelisted_new_spams, msginfo);
 
+                                       } else if (config.save_unsure && parts && parts[0] && parts[1] && *parts[1] == 'U') {
+                                               
+                                               debug_print("message %d is unsure\n", msginfo->msgnum);
+                                               /* Spam will be filtered away */
+                                               data->mail_filtering_data->filtered = g_slist_prepend(
+                                                       data->mail_filtering_data->filtered, msginfo);
+                                               data->new_unsure = g_slist_prepend(data->new_unsure, msginfo);
+
                                        } else {
                                                
                                                debug_print("message %d is ham\n", msginfo->msgnum);
@@ -324,7 +374,7 @@ static void bogofilter_do_filter(BogoFilterData *data)
                else
                        status = WEXITSTATUS(status);
        }
-       
+
        to_filter_data->status = status; 
 }
 
@@ -397,7 +447,8 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
        static gboolean warned_error = FALSE;
        int status = 0;
        int total = 0, curnum = 0;
-       GSList *new_hams = NULL, *new_spams = NULL, *whitelisted_new_spams = NULL;
+       GSList *new_hams = NULL, *new_spams = NULL;
+       GSList *new_unsure, *whitelisted_new_spams = NULL;
        gchar *bogo_exec = (config.bogopath && *config.bogopath) ? config.bogopath:"bogofilter";
        gchar *bogo_args[4];
        gboolean ok_to_thread = TRUE;
@@ -445,6 +496,7 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
        to_filter_data->msglist = msglist;
        to_filter_data->mail_filtering_data = mail_filtering_data;
        to_filter_data->new_hams = NULL;
+       to_filter_data->new_unsure = NULL;
        to_filter_data->new_spams = NULL;
        to_filter_data->whitelisted_new_spams = NULL;
        to_filter_data->done = FALSE;
@@ -483,6 +535,7 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
 #endif
 
        new_hams = to_filter_data->new_hams;
+       new_unsure = to_filter_data->new_unsure;
        new_spams = to_filter_data->new_spams;
        whitelisted_new_spams = to_filter_data->whitelisted_new_spams;
        status = to_filter_data->status;
@@ -497,18 +550,46 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
        for (cur = new_hams; cur; cur = cur->next) {
                MsgInfo *msginfo = (MsgInfo *)cur->data;
                procmsg_msginfo_unset_flags(msginfo, MSG_SPAM, 0);
+               debug_print("unflagging ham: %d\n", msginfo->msgnum);
        }
-       /* flag whitelisted spams */
-       for (cur = whitelisted_new_spams; cur; cur = cur->next) {
+       /* unflag unsure */
+       for (cur = new_unsure; cur; cur = cur->next) {
                MsgInfo *msginfo = (MsgInfo *)cur->data;
-               procmsg_msginfo_set_flags(msginfo, MSG_SPAM, 0);
+               procmsg_msginfo_unset_flags(msginfo, MSG_SPAM, 0);
+               debug_print("unflagging unsure: %d\n", msginfo->msgnum);
+       }
+       if (config.learn_from_whitelist && whitelisted_new_spams) {
+               /* flag whitelisted spams */
+               for (cur = whitelisted_new_spams; cur; cur = cur->next) {
+                       MsgInfo *msginfo = (MsgInfo *)cur->data;
+                       procmsg_msginfo_set_flags(msginfo, MSG_SPAM, 0);
+                       debug_print("flagging whitelisted non-ham: %d\n", msginfo->msgnum);
+               }
+               /* correct bogo */
+               bogofilter_learn(NULL, whitelisted_new_spams, FALSE);
+
+               /* unflag them */
+               for (cur = whitelisted_new_spams; cur; cur = cur->next) {
+                       MsgInfo *msginfo = (MsgInfo *)cur->data;
+                       procmsg_msginfo_unset_flags(msginfo, MSG_SPAM, 0);
+                       debug_print("unflagging whitelisted non-ham: %d\n", msginfo->msgnum);
+               }
+       } else {
+               for (cur = whitelisted_new_spams; cur; cur = cur->next) {
+                       MsgInfo *msginfo = (MsgInfo *)cur->data;
+                       procmsg_msginfo_unset_flags(msginfo, MSG_SPAM, 0);
+                       debug_print("not flagging whitelisted non-ham: %d\n", msginfo->msgnum);
+               }
        }
+
        /* flag spams and delete them if !config.receive_spam 
         * (if config.receive_spam is set, we'll move them later) */
        for (cur = new_spams; cur; cur = cur->next) {
                MsgInfo *msginfo = (MsgInfo *)cur->data;
                if (config.receive_spam) {
-                       procmsg_msginfo_change_flags(msginfo, MSG_SPAM, 0, ~0, 0);
+                       if (config.mark_as_read)
+                               procmsg_msginfo_unset_flags(msginfo, ~0, 0);
+                       procmsg_msginfo_set_flags(msginfo, MSG_SPAM, 0);
                } else {
                        folder_item_remove_msg(msginfo->folder, msginfo->msgnum);
                }
@@ -526,17 +607,15 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
                                           "spam and ham messages."));
                else
                        msg =  g_strdup_printf(_("The Bogofilter plugin couldn't filter "
-                                          "a message. the command `%s %s %s` couldn't be run."), 
+                                          "a message. The command `%s %s %s` couldn't be run."), 
                                           bogo_args[0], bogo_args[1], bogo_args[2]);
                if (!prefs_common.no_recv_err_panel) {
                        if (!warned_error) {
-                               alertpanel_error(msg);
+                               alertpanel_error("%s", msg);
                        }
                        warned_error = TRUE;
                } else {
-                       gchar *tmp = g_strdup_printf("%s\n", msg);
-                       log_error(tmp);
-                       g_free(tmp);
+                       log_error(LOG_PROTOCOL, "%s\n", msg);
                }
                g_free(msg);
        }
@@ -545,22 +624,100 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
                g_slist_free(mail_filtering_data->unfiltered);
                mail_filtering_data->filtered = NULL;
                mail_filtering_data->unfiltered = NULL;
-       } else if (config.receive_spam && new_spams) {
-               FolderItem *save_folder;
-
-               if ((!config.save_folder) ||
-                   (config.save_folder[0] == '\0') ||
-                   ((save_folder = folder_find_item_from_identifier(config.save_folder)) == NULL))
-                       save_folder = folder_get_default_trash();
-               if (save_folder) {
-                       for (cur = new_spams; cur; cur = cur->next) {
-                               msginfo = (MsgInfo *)cur->data;
-                               msginfo->is_move = TRUE;
-                               msginfo->to_filter_folder = save_folder;
+       } else {
+               if (config.receive_spam && new_spams) {
+                       FolderItem *save_folder = NULL;
+
+                       if ((!config.save_folder) ||
+                           (config.save_folder[0] == '\0') ||
+                           ((save_folder = folder_find_item_from_identifier(config.save_folder)) == NULL)) {
+                               if (mail_filtering_data->account && mail_filtering_data->account->set_trash_folder) {
+                                       save_folder = folder_find_item_from_identifier(
+                                               mail_filtering_data->account->trash_folder);
+                                       if (save_folder)
+                                               debug_print("found trash folder from account's advanced settings\n");
+                               }
+                               if (save_folder == NULL && mail_filtering_data->account &&
+                                   mail_filtering_data->account->folder) {
+                                       save_folder = mail_filtering_data->account->folder->trash;
+                                       if (save_folder)
+                                               debug_print("found trash folder from account's trash\n");
+                               }
+                               if (save_folder == NULL && mail_filtering_data->account &&
+                                   !mail_filtering_data->account->folder)  {
+                                       if (mail_filtering_data->account->inbox) {
+                                               FolderItem *item = folder_find_item_from_identifier(
+                                                       mail_filtering_data->account->inbox);
+                                               if (item && item->folder->trash) {
+                                                       save_folder = item->folder->trash;
+                                                       debug_print("found trash folder from account's inbox\n");
+                                               }
+                                       } 
+                                       if (!save_folder && mail_filtering_data->account->local_inbox) {
+                                               FolderItem *item = folder_find_item_from_identifier(
+                                                       mail_filtering_data->account->local_inbox);
+                                               if (item && item->folder->trash) {
+                                                       save_folder = item->folder->trash;
+                                                       debug_print("found trash folder from account's local_inbox\n");
+                                               }
+                                       }
+                               }
+                               if (save_folder == NULL) {
+                                       debug_print("using default trash folder\n");
+                                       save_folder = folder_get_default_trash();
+                               }
+                       }
+                       if (save_folder) {
+                               for (cur = new_spams; cur; cur = cur->next) {
+                                       msginfo = (MsgInfo *)cur->data;
+                                       msginfo->filter_op = IS_MOVE;
+                                       msginfo->to_filter_folder = save_folder;
+                               }
+                       }
+               }
+               if (config.save_unsure && new_unsure) {
+                       FolderItem *save_unsure_folder = NULL;
+
+                       if ((!config.save_unsure_folder) ||
+                           (config.save_unsure_folder[0] == '\0') ||
+                           ((save_unsure_folder = folder_find_item_from_identifier(config.save_unsure_folder)) == NULL)) {
+                               if (mail_filtering_data->account)
+                                       save_unsure_folder = folder_find_item_from_identifier(
+                                               mail_filtering_data->account->inbox);
+                               if (save_unsure_folder == NULL && mail_filtering_data->account &&
+                                   mail_filtering_data->account->folder)
+                                       save_unsure_folder = mail_filtering_data->account->folder->inbox;
+                               if (save_unsure_folder == NULL && mail_filtering_data->account &&
+                                   !mail_filtering_data->account->folder)  {
+                                       if (mail_filtering_data->account->inbox) {
+                                               FolderItem *item = folder_find_item_from_identifier(
+                                                       mail_filtering_data->account->inbox);
+                                               if (item) {
+                                                       save_unsure_folder = item;
+                                               }
+                                       } 
+                                       if (!save_unsure_folder && mail_filtering_data->account->local_inbox) {
+                                               FolderItem *item = folder_find_item_from_identifier(
+                                                       mail_filtering_data->account->local_inbox);
+                                               if (item) {
+                                                       save_unsure_folder = item;
+                                               }
+                                       }
+                               }
+                               if (save_unsure_folder == NULL)
+                                       save_unsure_folder = folder_get_default_inbox();
+                       }
+                       if (save_unsure_folder) {
+                               for (cur = new_unsure; cur; cur = cur->next) {
+                                       msginfo = (MsgInfo *)cur->data;
+                                       msginfo->filter_op = IS_MOVE;
+                                       msginfo->to_filter_folder = save_unsure_folder;
+                               }
                        }
                }
        } 
        g_slist_free(new_hams);
+       g_slist_free(new_unsure);
        g_slist_free(new_spams);
        g_slist_free(whitelisted_new_spams);
 
@@ -605,8 +762,10 @@ int bogofilter_learn(MsgInfo *msginfo, GSList *msglist, gboolean spam)
                        else 
                                /* learn as ham */
                                cmd = g_strdup_printf("%s -n -I '%s'", bogo_exec, file);
+                               
+                       debug_print("%s\n", cmd);
                        if ((status = execute_command_line(cmd, FALSE)) != 0)
-                               log_error(_("Learning failed; `%s` returned with status %d."),
+                               log_error(LOG_PROTOCOL, _("Learning failed; `%s` returned with status %d."),
                                                cmd, status);
                        g_free(cmd);
                        g_free(file);
@@ -652,9 +811,10 @@ int bogofilter_learn(MsgInfo *msginfo, GSList *msglist, gboolean spam)
                                else 
                                        /* learn as ham */
                                        cmd = g_strdup_printf("%s -n -I '%s'", bogo_exec, file);
-
+                               
+                               debug_print("%s\n", cmd);
                                if ((status = execute_command_line(cmd, FALSE)) != 0)
-                                       log_error(_("Learning failed; `%s` returned with status %d."),
+                                       log_error(LOG_PROTOCOL, _("Learning failed; `%s` returned with status %d."),
                                                        cmd, status);
 
                                g_free(cmd);
@@ -679,7 +839,7 @@ int bogofilter_learn(MsgInfo *msginfo, GSList *msglist, gboolean spam)
                                bogo_args[1] = spam ? "-s":"-n";
                        bogo_args[2] = "-b";
                        bogo_args[3] = NULL;
-
+                       debug_print("|%s %s %s ...\n", bogo_args[0], bogo_args[1], bogo_args[2]);
                        bogo_forked = g_spawn_async_with_pipes(
                                        NULL, bogo_args,NULL, G_SPAWN_SEARCH_PATH|G_SPAWN_DO_NOT_REAP_CHILD,
                                        NULL, NULL, &bogo_pid, &bogo_stdin,
@@ -710,7 +870,7 @@ int bogofilter_learn(MsgInfo *msginfo, GSList *msglist, gboolean spam)
                                        status = WEXITSTATUS(status);
                        }
                        if (!bogo_forked || status != 0) {
-                               log_error(_("Learning failed; `%s %s %s` returned with error:\n%s"),
+                               log_error(LOG_PROTOCOL, _("Learning failed; `%s %s %s` returned with error:\n%s"),
                                                bogo_args[0], bogo_args[1], bogo_args[2], 
                                                error ? error->message:_("Unknown error"));
                                if (error)
@@ -744,9 +904,11 @@ void bogofilter_save_config(void)
                prefs_file_close_revert(pfile);
                return;
        }
-       fprintf(pfile->fp, "\n");
-
-       prefs_file_close(pfile);
+        if (fprintf(pfile->fp, "\n") < 0) {
+               FILE_OP_ERROR(rcpath, "fprintf");
+               prefs_file_close_revert(pfile);
+       } else
+               prefs_file_close(pfile);
 }
 
 void bogofilter_set_message_callback(MessageCallback callback)
@@ -760,15 +922,9 @@ gint plugin_init(gchar **error)
 
        hook_id = -1;
 
-       if ((claws_get_version() > VERSION_NUMERIC)) {
-               *error = g_strdup(_("Your version of Claws Mail is newer than the version the Bogofilter plugin was built with"));
-               return -1;
-       }
-
-       if ((claws_get_version() < MAKE_NUMERIC_VERSION(0, 9, 3, 86))) {
-               *error = g_strdup(_("Your version of Claws Mail is too old for the Bogofilter plugin"));
+       if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
+                               VERSION_NUMERIC, PLUGIN_NAME, error))
                return -1;
-       }
 
        prefs_set_default(param);
        rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
@@ -788,13 +944,39 @@ gint plugin_init(gchar **error)
        }
 
        procmsg_register_spam_learner(bogofilter_learn);
-       procmsg_spam_set_folder(config.save_folder);
+       procmsg_spam_set_folder(config.save_folder, bogofilter_get_spam_folder);
 
        return 0;
        
 }
 
-void plugin_done(void)
+FolderItem *bogofilter_get_spam_folder(MsgInfo *msginfo)
+{
+       FolderItem *item = folder_find_item_from_identifier(config.save_folder);
+
+       if (item || msginfo == NULL || msginfo->folder == NULL)
+               return item;
+
+       if (msginfo->folder->folder &&
+           msginfo->folder->folder->account && 
+           msginfo->folder->folder->account->set_trash_folder) {
+               item = folder_find_item_from_identifier(
+                       msginfo->folder->folder->account->trash_folder);
+       }
+
+       if (item == NULL && 
+           msginfo->folder->folder &&
+           msginfo->folder->folder->trash)
+               item = msginfo->folder->folder->trash;
+               
+       if (item == NULL)
+               item = folder_get_default_trash();
+               
+       debug_print("bogo spam dir: %s\n", folder_item_get_path(item));
+       return item;
+}
+
+gboolean plugin_done(void)
 {
        if (hook_id != -1) {
                bogofilter_unregister_hook();
@@ -805,25 +987,26 @@ void plugin_done(void)
        g_free(config.save_folder);
        bogofilter_gtk_done();
        procmsg_unregister_spam_learner(bogofilter_learn);
-       procmsg_spam_set_folder(NULL);
+       procmsg_spam_set_folder(NULL, NULL);
        debug_print("Bogofilter plugin unloaded\n");
+       return TRUE;
 }
 
 const gchar *plugin_name(void)
 {
-       return _("Bogofilter");
+       return PLUGIN_NAME;
 }
 
 const gchar *plugin_desc(void)
 {
        return _("This plugin can check all messages that are received from an "
                 "IMAP, LOCAL or POP account for spam using Bogofilter. "
-                "You will need Bogofilter installed locally.\n "
+                "You will need Bogofilter installed locally.\n"
                 "\n"
                 "Before Bogofilter can recognize spam messages, you have to "
-                "train it by marking a few hundred spam and ham messages. "
-                "Use \"/Mark/Mark as spam\" and \"/Mark/Mark as ham\" to "
-                "train Bogofilter.\n"
+                "train it by marking a few hundred spam and ham messages "
+                "with the use of \"/Mark/Mark as spam\" and \"/Mark/Mark as "
+                "ham\".\n"
                 "\n"
                 "When a message is identified as spam it can be deleted or "
                 "saved in a specially designated folder.\n"
@@ -838,7 +1021,7 @@ const gchar *plugin_type(void)
 
 const gchar *plugin_licence(void)
 {
-       return "GPL";
+       return "GPL3+";
 }
 
 const gchar *plugin_version(void)