2006-12-15 [wwp] 2.6.1cvs41
authorTristan Chabredier <wwp@claws-mail.org>
Fri, 15 Dec 2006 16:52:39 +0000 (16:52 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Fri, 15 Dec 2006 16:52:39 +0000 (16:52 +0000)
* src/plugins/bogofilter/bogofilter.c
* src/plugins/bogofilter/bogofilter.h
* src/plugins/bogofilter/bogofilter_gtk.c
bogofilter's whitelist can now use a subset of
the addressbook (either a book, a subfolder of a book,
or the whole addressbook by using "Any"). Re-used there
some pref_matcher widgets and mechanisms to match a subset
of the addressbook.

ChangeLog
PATCHSETS
configure.ac
src/plugins/bogofilter/bogofilter.c
src/plugins/bogofilter/bogofilter.h
src/plugins/bogofilter/bogofilter_gtk.c

index a346c3e..e5e694b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2006-12-15 [wwp]       2.6.1cvs41
+
+       * src/plugins/bogofilter/bogofilter.c
+       * src/plugins/bogofilter/bogofilter.h
+       * src/plugins/bogofilter/bogofilter_gtk.c
+               bogofilter's whitelist can now use a subset of
+               the addressbook (either a book, a subfolder of a book,
+               or the whole addressbook by using "Any"). Re-used there
+               some pref_matcher widgets and mechanisms to match a subset
+               of the addressbook.
+
 2006-12-15 [wwp]       2.6.1cvs40
 
        * src/wizard.c
index 77b633f..18bb098 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.2.16 -r 1.1.2.17 src/plugins/bogofilter/bogofilter.c;  cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/plugins/bogofilter/bogofilter.h;  cvs diff -u -r 1.1.2.9 -r 1.1.2.10 src/plugins/bogofilter/bogofilter_gtk.c;  ) > 2.6.1cvs38.patchset
 ( cvs diff -u -r 1.1.2.17 -r 1.1.2.18 src/plugins/bogofilter/bogofilter.c;  cvs diff -u -r 1.1.2.10 -r 1.1.2.11 src/plugins/bogofilter/bogofilter_gtk.c;  ) > 2.6.1cvs39.patchset
 ( cvs diff -u -r 1.1.2.43 -r 1.1.2.44 src/wizard.c;  cvs diff -u -r 1.13.2.22 -r 1.13.2.23 src/common/plugin.c;  cvs diff -u -r 1.5.2.8 -r 1.5.2.9 src/common/plugin.h;  cvs diff -u -r 1.4.2.43 -r 1.4.2.44 src/gtk/about.c;  cvs diff -u -r 1.1.2.18 -r 1.1.2.19 src/plugins/bogofilter/bogofilter.c;  cvs diff -u -r 1.13.2.27 -r 1.13.2.28 src/plugins/clamav/clamav_plugin.c;  cvs diff -u -r 1.13.2.11 -r 1.13.2.12 src/plugins/demo/demo.c;  cvs diff -u -r 1.12.2.17 -r 1.12.2.18 src/plugins/dillo_viewer/dillo_viewer.c;  cvs diff -u -r 1.1.2.14 -r 1.1.2.15 src/plugins/pgpcore/plugin.c;  cvs diff -u -r 1.1.2.12 -r 1.1.2.13 src/plugins/pgpinline/plugin.c;  cvs diff -u -r 1.1.2.22 -r 1.1.2.23 src/plugins/pgpmime/plugin.c;  cvs diff -u -r 1.18.2.44 -r 1.18.2.45 src/plugins/spamassassin/spamassassin.c;  cvs diff -u -r 1.14.2.45 -r 1.14.2.46 src/plugins/trayicon/trayicon.c;  ) > 2.6.1cvs40.patchset
+( cvs diff -u -r 1.1.2.19 -r 1.1.2.20 src/plugins/bogofilter/bogofilter.c;  cvs diff -u -r 1.1.2.6 -r 1.1.2.7 src/plugins/bogofilter/bogofilter.h;  cvs diff -u -r 1.1.2.11 -r 1.1.2.12 src/plugins/bogofilter/bogofilter_gtk.c;  ) > 2.6.1cvs41.patchset
index bfdcb52..86722a2 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=6
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=40
+EXTRA_VERSION=41
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index f8992ec..cd86341 100644 (file)
@@ -95,6 +95,8 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"whitelist_ab", "TRUE", &config.whitelist_ab, P_BOOL,
         NULL, NULL, NULL},
+       {"whitelist_ab_folder", "Any", &config.whitelist_ab_folder, P_STRING,
+        NULL, NULL, NULL},
 
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
@@ -200,8 +202,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;
index a976721..56f8169 100644 (file)
@@ -35,6 +35,7 @@ struct _BogofilterConfig
        gchar                   *bogopath;
        gboolean                 insert_header;
        gboolean                 whitelist_ab;
+       gchar                   *whitelist_ab_folder;
 };
 
 BogofilterConfig *bogofilter_get_config              (void);
index 0a29090..d986b41 100644 (file)
@@ -40,6 +40,7 @@
 #include "statusbar.h"
 #include "bogofilter.h"
 #include "menu.h"
+#include "addressbook.h"
 
 struct BogofilterPage
 {
@@ -53,6 +54,14 @@ struct BogofilterPage
        GtkWidget *max_size;
        GtkWidget *bogopath;
        GtkWidget *whitelist_ab;
+       GtkWidget *whitelist_ab_folder_combo;
+};
+
+/*!
+ *\brief       Preset addressbook book/folder items
+ */
+static const gchar *whitelist_ab_folder_text [] = {
+       N_("Any")
 };
 
 static void foldersel_cb(GtkWidget *widget, gpointer data)
@@ -70,6 +79,18 @@ static void foldersel_cb(GtkWidget *widget, gpointer data)
        }
 }
 
+static void bogofilter_whitelist_ab_select_cb(GtkWidget *widget, gpointer data)
+{
+       struct BogofilterPage *page = (struct BogofilterPage *) data;
+       gchar *folderpath = NULL;
+       gboolean ret = FALSE;
+
+       folderpath = (gchar *) gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(page->whitelist_ab_folder_combo)->entry));
+       ret = addressbook_folder_selection(&folderpath);
+       if ( ret != FALSE && folderpath != NULL)
+               gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(page->whitelist_ab_folder_combo)->entry), folderpath);
+}
+
 static void bogofilter_create_widget_func(PrefsPage * _page,
                                            GtkWindow * window,
                                            gpointer data)
@@ -79,7 +100,7 @@ static void bogofilter_create_widget_func(PrefsPage * _page,
 
        GtkWidget *vbox1, *vbox2;
        GtkWidget *hbox_max_size;
-       GtkWidget *hbox_process_emails, *hbox_save_spam, *hbox_bogopath;
+       GtkWidget *hbox_process_emails, *hbox_save_spam, *hbox_bogopath, *hbox_whitelist;
 
        GtkWidget *max_size_label;
        GtkObject *max_size_spinbtn_adj;
@@ -99,6 +120,11 @@ static void bogofilter_create_widget_func(PrefsPage * _page,
 
        GtkTooltips *tooltips;
 
+       GtkWidget *whitelist_ab_folder_combo;
+       GtkWidget *whitelist_ab_select_btn;
+       GList *combo_items;
+       gint i;
+
        tooltips = gtk_tooltips_new();
 
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
@@ -167,12 +193,39 @@ static void bogofilter_create_widget_func(PrefsPage * _page,
                        _("Only done for messages in MH folders"),
                        NULL);
 
-       whitelist_ab_chkbtn = gtk_check_button_new_with_label(_("Whitelist senders present in addressbook"));
+       hbox_whitelist = gtk_hbox_new(FALSE, 8);
+       gtk_widget_show(hbox_whitelist);
+       gtk_box_pack_start (GTK_BOX (vbox2), hbox_whitelist, TRUE, TRUE, 0);
+
+       whitelist_ab_chkbtn = gtk_check_button_new_with_label(_("Whitelist senders present in addressbook/folder"));
        gtk_widget_show(whitelist_ab_chkbtn);
-       gtk_box_pack_start(GTK_BOX(vbox2), whitelist_ab_chkbtn, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox_whitelist), whitelist_ab_chkbtn, FALSE, FALSE, 0);
        gtk_tooltips_set_tip(tooltips, whitelist_ab_chkbtn,
                        _("Messages coming from your addressbook contacts will be received in the normal folder even if detected as spam"), NULL);
 
+       whitelist_ab_folder_combo = gtk_combo_new();
+       gtk_widget_show(whitelist_ab_folder_combo);
+       gtk_widget_set_size_request(whitelist_ab_folder_combo, 100, -1);
+       gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(whitelist_ab_folder_combo)->entry),
+                              TRUE);
+
+       combo_items = NULL;
+       for (i = 0; i < (gint) (sizeof(whitelist_ab_folder_text) / sizeof(gchar *)); i++) {
+               combo_items = g_list_append(combo_items,
+                                           (gpointer) _(whitelist_ab_folder_text[i]));
+       }
+       gtk_combo_set_popdown_strings(GTK_COMBO(whitelist_ab_folder_combo), combo_items);
+       g_list_free(combo_items);
+
+       gtk_box_pack_start (GTK_BOX (hbox_whitelist), whitelist_ab_folder_combo, TRUE, TRUE, 0);
+
+       whitelist_ab_select_btn = gtk_button_new_with_label(_(" Select... "));
+       gtk_widget_show (whitelist_ab_select_btn);
+       gtk_box_pack_start (GTK_BOX (hbox_whitelist), whitelist_ab_select_btn, FALSE, FALSE, 0);
+       gtk_tooltips_set_tip(tooltips, whitelist_ab_select_btn,
+                       _("Click this button to select a book or folder in the addressbook"),
+                       NULL);
+
        hbox_bogopath = gtk_hbox_new(FALSE, 8);
        gtk_widget_show(hbox_bogopath);
        gtk_box_pack_start (GTK_BOX (vbox2), hbox_bogopath, FALSE, FALSE, 0);
@@ -196,12 +249,17 @@ static void bogofilter_create_widget_func(PrefsPage * _page,
 
        g_signal_connect(G_OBJECT(save_spam_folder_select), "clicked",
                        G_CALLBACK(foldersel_cb), page);
+       g_signal_connect(G_OBJECT (whitelist_ab_select_btn), "clicked",
+                        G_CALLBACK(bogofilter_whitelist_ab_select_cb), page);
 
        gtk_spin_button_set_value(GTK_SPIN_BUTTON(max_size_spinbtn), (float) config->max_size);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(process_emails_checkbtn), config->process_emails);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(save_spam_checkbtn), config->receive_spam);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(insert_header_chkbtn), config->insert_header);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(whitelist_ab_chkbtn), config->whitelist_ab);
+       if (config->whitelist_ab_folder != NULL)
+               gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(whitelist_ab_folder_combo)->entry),
+                               config->whitelist_ab_folder);
        if (config->save_folder != NULL)
                gtk_entry_set_text(GTK_ENTRY(save_spam_folder_entry), config->save_folder);
        if (config->bogopath != NULL)
@@ -212,6 +270,7 @@ static void bogofilter_create_widget_func(PrefsPage * _page,
        page->receive_spam = save_spam_checkbtn;
        page->insert_header = insert_header_chkbtn;
        page->whitelist_ab = whitelist_ab_chkbtn;
+       page->whitelist_ab_folder_combo = whitelist_ab_folder_combo;
        page->save_folder = save_spam_folder_entry;
        page->save_folder_select = save_spam_folder_select;
        page->bogopath = bogopath_entry;
@@ -248,6 +307,9 @@ static void bogofilter_save_func(PrefsPage *_page)
 
        /* whitelist_ab */
        config->whitelist_ab = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->whitelist_ab));
+       g_free(config->whitelist_ab_folder);
+       config->whitelist_ab_folder = gtk_editable_get_chars(
+                               GTK_EDITABLE(GTK_COMBO(page->whitelist_ab_folder_combo)->entry), 0, -1);
 
        /* bogopath */
        g_free(config->bogopath);