2006-03-01 [wwp] 2.0.0cvs88
authorTristan Chabredier <wwp@claws-mail.org>
Wed, 1 Mar 2006 10:25:10 +0000 (10:25 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Wed, 1 Mar 2006 10:25:10 +0000 (10:25 +0000)
* src/plugins/spamassassin/spamassassin.c
* src/plugins/spamassassin/spamassassin.h
* src/plugins/spamassassin/spamassassin_gtk.c
made processing of emails w/ sa-plugin an option (default is TRUE),
fixed Engrish some tooltips, capitalization of some debug messages
and warnings. The spamassassin plugin now provides two separate
services: process emails upon incorporation and spamd training.
Both services (un)register independently but use some common
plugin settings (transport settings, spam storage location).

ChangeLog
PATCHSETS
configure.ac
src/plugins/spamassassin/spamassassin.c
src/plugins/spamassassin/spamassassin.h
src/plugins/spamassassin/spamassassin_gtk.c

index 12d2cfe86c94c888083a05a3817777c513a916c3..bac77a013e11a3322943209c65d4bdffe4a8cdbb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2006-03-01 [wwp]       2.0.0cvs88
+
+       * src/plugins/spamassassin/spamassassin.c
+       * src/plugins/spamassassin/spamassassin.h
+       * src/plugins/spamassassin/spamassassin_gtk.c
+               made processing of emails w/ sa-plugin an option (default is TRUE),
+               fixed Engrish some tooltips, capitalization of some debug messages
+               and warnings. The spamassassin plugin now provides two separate
+               services: process emails upon incorporation and spamd training.
+               Both services (un)register independently but use some common
+               plugin settings (transport settings, spam storage location).
+
 2006-02-28 [wwp]       2.0.0cvs87
 
        * src/plugins/spamassassin/spamassassin.c
index 70e4ccb1352d65b014fcdc431fd00ea5c4a550c1..ff40bd0e0fce545b36507f1dd39c72e7c7e8fc65 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.18.2.20 -r 1.18.2.21 src/plugins/spamassassin/spamassassin.c;  ) > 2.0.0cvs85.patchset
 ( cvs diff -u -r 1.18.2.21 -r 1.18.2.22 src/plugins/spamassassin/spamassassin.c;  cvs diff -u -r 1.4.2.7 -r 1.4.2.8 src/plugins/spamassassin/spamassassin.h;  cvs diff -u -r 1.23.2.20 -r 1.23.2.21 src/plugins/spamassassin/spamassassin_gtk.c;  ) > 2.0.0cvs86.patchset
 ( cvs diff -u -r 1.18.2.22 -r 1.18.2.23 src/plugins/spamassassin/spamassassin.c;  ) > 2.0.0cvs87.patchset
+( cvs diff -u -r 1.18.2.23 -r 1.18.2.24 src/plugins/spamassassin/spamassassin.c;  cvs diff -u -r 1.4.2.8 -r 1.4.2.9 src/plugins/spamassassin/spamassassin.h;  cvs diff -u -r 1.23.2.21 -r 1.23.2.22 src/plugins/spamassassin/spamassassin_gtk.c;  ) > 2.0.0cvs88.patchset
index dc5e6acb3eb25b0a3a121baa9ce55b13043386ad..57bea3179b77ce01d1244dc6786796a6a1b15f68 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=0
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=87
+EXTRA_VERSION=88
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index e049b555bc42940028be3e6991f7e1aec2dff58b..da60d966d368e5acc063815886477a3585a75e4f 100644 (file)
@@ -75,7 +75,7 @@ enum {
     TIMEOUT_RUNNING = 1 << 1,
 };
 
-static guint hook_id;
+static guint hook_id = -1;
 static int flags = SPAMC_RAW_MODE | SPAMC_SAFE_FALLBACK | SPAMC_CHECK_ONLY;
 static MessageCallback message_callback;
 
@@ -90,6 +90,8 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"socket", "", &config.socket, P_STRING,
         NULL, NULL, NULL},
+       {"process_emails", "TRUE", &config.process_emails, P_BOOL,
+        NULL, NULL, NULL},
        {"receive_spam", "TRUE", &config.receive_spam, P_BOOL,
         NULL, NULL, NULL},
        {"save_folder", NULL, &config.save_folder, P_STRING,
@@ -277,7 +279,7 @@ void spamassassin_learn(MsgInfo *msginfo, GSList *msglist, gboolean spam)
                } else {
                        cmd = g_strdup_printf("spamc -d %s -p %u -u %s -t %u -s %u -L %s < %s",
                                                        config.hostname, config.port, 
-                                                       config.username, config.timeout,
+                                                       config.username, config.timeout,
                                                        config.max_size * 1024, spam?"spam":"ham", file);
                }
        }
@@ -357,7 +359,7 @@ void spamassassin_save_config(void)
                return;
 
        if (prefs_write_param(param, pfile->fp) < 0) {
-               g_warning("failed to write SpamAssassin configuration to file\n");
+               g_warning("Failed to write SpamAssassin configuration to file\n");
                prefs_file_close_revert(pfile);
                return;
        }
@@ -371,7 +373,9 @@ gboolean spamassassin_check_username(void)
        if (config.username == NULL || config.username[0] == '\0') {
                config.username = (gchar*)g_get_user_name();
                if (config.username == NULL) {
-                       hooks_unregister_hook(MAIL_FILTERING_HOOKLIST, hook_id);
+                       if (hook_id != -1) {
+                               spamassassin_unregister_hook();
+                       }
                        procmsg_unregister_spam_learner(spamassassin_learn);
                        procmsg_spam_set_folder(NULL);
                        return FALSE;
@@ -389,6 +393,8 @@ gint plugin_init(gchar **error)
 {
        gchar *rcpath;
 
+       hook_id = -1;
+
        if ((sylpheed_get_version() > VERSION_NUMERIC)) {
                *error = g_strdup("Your version of Sylpheed-Claws is newer than the version the SpamAssassin plugin was built with");
                return -1;
@@ -399,12 +405,6 @@ gint plugin_init(gchar **error)
                return -1;
        }
 
-       hook_id = hooks_register_hook(MAIL_FILTERING_HOOKLIST, mail_filtering_hook, NULL);
-       if (hook_id == -1) {
-               *error = g_strdup("Failed to register mail filtering hook");
-               return -1;
-       }
-
        prefs_set_default(param);
        rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
        prefs_read_config(param, "SpamAssassin", rcpath, NULL);
@@ -417,13 +417,17 @@ gint plugin_init(gchar **error)
                
        debug_print("Spamassassin plugin loaded\n");
 
+       if (config.process_emails) {
+               spamassassin_register_hook();
+       }
+
        if (config.transport == SPAMASSASSIN_DISABLED) {
                log_error("Spamassassin plugin is loaded but disabled by its preferences.\n");
        }
 
        if (config.transport != SPAMASSASSIN_DISABLED) {
                if (config.transport == SPAMASSASSIN_TRANSPORT_TCP)
-                       debug_print("enabling learner with a remote spamassassin server requires spamc/spamd 3.1.x\n");
+                       debug_print("Enabling learner with a remote spamassassin server requires spamc/spamd 3.1.x\n");
                procmsg_register_spam_learner(spamassassin_learn);
                procmsg_spam_set_folder(config.save_folder);
        }
@@ -434,7 +438,9 @@ gint plugin_init(gchar **error)
 
 void plugin_done(void)
 {
-       hooks_unregister_hook(MAIL_FILTERING_HOOKLIST, hook_id);
+       if (hook_id != -1) {
+               spamassassin_unregister_hook();
+       }
        g_free(config.hostname);
        g_free(config.save_folder);
        spamassassin_gtk_done();
@@ -474,3 +480,19 @@ const gchar *plugin_version(void)
 {
        return VERSION;
 }
+
+void spamassassin_register_hook(void)
+{
+       hook_id = hooks_register_hook(MAIL_FILTERING_HOOKLIST, mail_filtering_hook, NULL);
+       if (hook_id == -1) {
+               g_warning("Failed to register mail filtering hook");
+               config.process_emails = FALSE;
+       }
+}
+
+void spamassassin_unregister_hook(void)
+{
+       if (hook_id != -1) {
+               hooks_unregister_hook(MAIL_FILTERING_HOOKLIST, hook_id);
+       }
+}
index 770a8f2a8d3174b8fc2c3bfe04a8cefdd3c1c890..0440ca2c4f4e89a64be7a5a8beeea8f35567fdbc 100644 (file)
@@ -39,6 +39,7 @@ struct _SpamAssassinConfig
        gchar                   *hostname;
        guint                    port;
        gchar                   *socket;
+       gboolean                 process_emails;
        gboolean                 receive_spam;
        gchar                   *save_folder;
        guint                    max_size;
@@ -53,4 +54,6 @@ void              spamassassin_set_message_callback (MessageCallback callback);
 gint spamassassin_gtk_init(void);
 void spamassassin_gtk_done(void);
 void spamassassin_learn(MsgInfo *msginfo, GSList *msglist, gboolean spam);
+void spamassassin_register_hook(void);
+void spamassassin_unregister_hook(void);
 #endif
index b5c6b00186bdc9df007107bc600dfcc4c2fed634..2921170ce3dd8a70cfa2d24f8056f76a7db4972f 100644 (file)
@@ -51,6 +51,7 @@ struct SpamAssassinPage
        GtkWidget *colon;
        GtkWidget *port;
        GtkWidget *socket;
+       GtkWidget *process_emails;
        GtkWidget *receive_spam;
        GtkWidget *save_folder;
        GtkWidget *save_folder_select;
@@ -116,6 +117,7 @@ static void show_transport(struct SpamAssassinPage *page, struct Transport *tran
                gtk_widget_set_sensitive(page->port, FALSE);
                gtk_widget_set_sensitive(page->max_size, FALSE);
                gtk_widget_set_sensitive(page->timeout, FALSE);
+               gtk_widget_set_sensitive(page->process_emails, FALSE);
                gtk_widget_set_sensitive(page->receive_spam, FALSE);
                gtk_widget_set_sensitive(page->save_folder, FALSE);
                gtk_widget_set_sensitive(page->save_folder_select, FALSE);
@@ -129,6 +131,7 @@ static void show_transport(struct SpamAssassinPage *page, struct Transport *tran
                gtk_widget_set_sensitive(page->socket, TRUE);
                gtk_widget_set_sensitive(page->max_size, TRUE);
                gtk_widget_set_sensitive(page->timeout, TRUE);
+               gtk_widget_set_sensitive(page->process_emails, TRUE);
                gtk_widget_set_sensitive(page->receive_spam, TRUE);
                gtk_widget_set_sensitive(page->save_folder, TRUE);
                gtk_widget_set_sensitive(page->save_folder_select, TRUE);
@@ -141,6 +144,7 @@ static void show_transport(struct SpamAssassinPage *page, struct Transport *tran
                gtk_widget_set_sensitive(page->username, TRUE);
                gtk_widget_set_sensitive(page->max_size, TRUE);
                gtk_widget_set_sensitive(page->timeout, TRUE);
+               gtk_widget_set_sensitive(page->process_emails, TRUE);
                gtk_widget_set_sensitive(page->receive_spam, TRUE);
                gtk_widget_set_sensitive(page->save_folder, TRUE);
                gtk_widget_set_sensitive(page->save_folder_select, TRUE);
@@ -207,11 +211,13 @@ static void spamassassin_create_widget_func(PrefsPage * _page,
        GtkWidget *save_folder;
        GtkWidget *save_folder_select;
        GtkWidget *label6;
+       GtkWidget *hbox5;
+       GtkWidget *process_emails;
        GtkTooltips *tooltips;
 
        tooltips = gtk_tooltips_new();
 
-       table = gtk_table_new(9, 3, FALSE);
+       table = gtk_table_new(10, 3, FALSE);
        gtk_widget_show(table);
        gtk_container_set_border_width(GTK_CONTAINER(table), 8);
        gtk_table_set_row_spacings(GTK_TABLE(table), 4);
@@ -257,6 +263,8 @@ static void spamassassin_create_widget_func(PrefsPage * _page,
        username = gtk_entry_new();
        gtk_widget_show(username);
        gtk_box_pack_end(GTK_BOX(hbox1), username, FALSE, FALSE, 0);
+       gtk_tooltips_set_tip(tooltips, username, _("User to use with spamd server"),
+                            NULL);
 
        spamd_hbox = gtk_hbox_new (FALSE, 8);
        gtk_widget_show (spamd_hbox);
@@ -308,7 +316,7 @@ static void spamassassin_create_widget_func(PrefsPage * _page,
        gtk_widget_show(max_size);
        gtk_box_pack_end(GTK_BOX(hbox3), max_size, FALSE, FALSE, 0);
        gtk_tooltips_set_tip(tooltips, max_size,
-                       _("Maximum size a message is allowed to have to be checked"),
+                       _("Don't check emails bigger than"),
                        NULL);
        gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(max_size), TRUE);
 
@@ -343,18 +351,34 @@ static void spamassassin_create_widget_func(PrefsPage * _page,
                         (GtkAttachOptions) (GTK_FILL),
                         (GtkAttachOptions) (GTK_FILL), 0, 0);
 
+       process_emails = gtk_check_button_new_with_label(_("Process emails"));
+       gtk_widget_show(process_emails);
+       gtk_table_attach(GTK_TABLE(table), process_emails, 0, 1, 5, 6,
+                        (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+       gtk_tooltips_set_tip(tooltips, process_emails,
+                            _("Process emails upon incorporation"),
+                            NULL);
+
+       hbox5 = gtk_hbox_new (FALSE, 8);
+       gtk_widget_show (hbox5);
+       gtk_table_attach (GTK_TABLE (table), hbox5, 0, 1, 6, 7,
+                         (GtkAttachOptions) (GTK_FILL),
+                         (GtkAttachOptions) (GTK_FILL), 0, 0);
+       SET_TOGGLE_SENSITIVITY (process_emails, hbox5);
+
        receive_spam = gtk_check_button_new_with_label(_("Save Spam"));
        gtk_widget_show(receive_spam);
-       gtk_table_attach(GTK_TABLE(table), receive_spam, 0, 1, 5, 6,
+       gtk_table_attach(GTK_TABLE(table), receive_spam, 0, 1, 6, 7,
                         (GtkAttachOptions) (GTK_FILL),
                         (GtkAttachOptions) (0), 0, 0);
        gtk_tooltips_set_tip(tooltips, receive_spam,
-                            _("Save mails that where identified as spam"),
+                            _("Save identified spam"),
                             NULL);
 
        hbox2 = gtk_hbox_new (FALSE, 8);
        gtk_widget_show (hbox2);
-       gtk_table_attach (GTK_TABLE (table), hbox2, 0, 1, 6, 7,
+       gtk_table_attach (GTK_TABLE (table), hbox2, 0, 1, 7, 8,
                          (GtkAttachOptions) (GTK_FILL),
                          (GtkAttachOptions) (GTK_FILL), 0, 0);
        SET_TOGGLE_SENSITIVITY (receive_spam, hbox2);
@@ -368,14 +392,14 @@ static void spamassassin_create_widget_func(PrefsPage * _page,
        gtk_widget_show (save_folder);
        gtk_box_pack_start (GTK_BOX (hbox2), save_folder, TRUE, FALSE, 0);
        gtk_tooltips_set_tip(tooltips, save_folder,
-                            _("Leave empty to use the default trash folder"),
+                            _("Folder to store identified spam. Leave empty to use the default trash folder"),
                             NULL);
 
        save_folder_select = gtkut_get_browse_directory_btn(_("_Browse"));
        gtk_widget_show (save_folder_select);
        gtk_box_pack_end (GTK_BOX (hbox2), save_folder_select, FALSE, FALSE, 0);
        gtk_tooltips_set_tip(tooltips, save_folder_select,
-                            _("Leave empty to use the default trash folder"),
+                            _("Click this button to select a folder to store spam in"),
                             NULL);
 
        config = spamassassin_get_config();
@@ -388,6 +412,7 @@ static void spamassassin_create_widget_func(PrefsPage * _page,
        if (config->hostname != NULL)
                gtk_entry_set_text(GTK_ENTRY(hostname), config->hostname);
        gtk_spin_button_set_value(GTK_SPIN_BUTTON(port), (float) config->port);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(process_emails), config->process_emails);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(receive_spam), config->receive_spam);
        if (config->save_folder != NULL)
                gtk_entry_set_text(GTK_ENTRY(save_folder), config->save_folder);
@@ -401,6 +426,7 @@ static void spamassassin_create_widget_func(PrefsPage * _page,
        page->colon = colon;
        page->port = port;
        page->socket = socket;
+       page->process_emails = process_emails;
        page->receive_spam = receive_spam;
        page->save_folder = save_folder;
        page->save_folder_select = save_folder_select;
@@ -462,6 +488,9 @@ static void spamassassin_save_func(PrefsPage *_page)
        g_free(config->socket);
        config->socket = gtk_editable_get_chars(GTK_EDITABLE(page->socket), 0, -1);
 
+       /* process_emails */
+       config->process_emails = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->process_emails));
+
        /* receive_spam */
        config->receive_spam = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->receive_spam));
 
@@ -475,6 +504,12 @@ static void spamassassin_save_func(PrefsPage *_page)
        /* timeout */
        config->timeout = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(page->timeout));
 
+       if (config->process_emails) {
+               spamassassin_register_hook();
+       } else {
+               spamassassin_unregister_hook();
+       }
+
        if (config->transport == SPAMASSASSIN_DISABLED) {
                procmsg_unregister_spam_learner(spamassassin_learn);
                procmsg_spam_set_folder(NULL);