CVS: sylpheedclaws/sylpheed-claws/src/plugins/bogofilter bogofilter.c,1.1.2.15,1.1.2.16 bogofilter.h,1.1.2.4,1.1.2.5 bogofilter_gtk.c,1.1.2.8,1.1.2.9
[email protected] Fri, 15 Dec 2006 09:13:00 +0000
| Newsgroups | gmane.mail.sylpheed.claws.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /pack/anoncvs/sylpheedclaws/sylpheed-claws/src/plugins/bogofilter
In directory sunsite.dk:/tmp/cvs-serv23553/src/plugins/bogofilter
Modified Files:
Tag: gtk2
bogofilter.c bogofilter.h bogofilter_gtk.c
Log Message:
2006-12-15 [paul] 2.6.1cvs36
* src/plugins/bogofilter/bogofilter.c
* src/plugins/bogofilter/bogofilter.h
* src/plugins/bogofilter/bogofilter_gtk.c
Add an option to allow inserting an
X-Claws-Bogosity header (on MH folders
only). Patch by Colin
Index: bogofilter.c
===================================================================
RCS file: /pack/anoncvs/sylpheedclaws/sylpheed-claws/src/plugins/bogofilter/Attic/bogofilter.c,v
retrieving revision 1.1.2.15
retrieving revision 1.1.2.16
diff -u -d -r1.1.2.15 -r1.1.2.16
--- bogofilter.c 2006/11/27 08:06:58 1.1.2.15
+++ bogofilter.c 2006/12/15 09:12:56 1.1.2.16
@@ -88,6 +88,8 @@
NULL, NULL, NULL},
{"bogopath", "bogofilter", &config.bogopath, P_STRING,
NULL, NULL, NULL},
+ {"insert_header", "FALSE", &config.insert_header, P_BOOL,
+ NULL, NULL, NULL},
{NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
};
@@ -175,7 +177,6 @@
/* can set flags (SCANNED, ATTACHMENT) but that's ok
* as GUI updates are hooked not direct */
file = procmsg_get_message_file(msginfo);
-
if (file) {
gchar *tmp = g_strdup_printf("%s\n",file);
write_all(bogo_stdin, tmp, strlen(tmp));
@@ -196,6 +197,35 @@
}
parts = g_strsplit(tmp, " ", 0);
debug_print("read %s\n", buf);
+ if (parts && parts[0] && parts[1] && parts[2] &&
+ 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");
+ if (strstr(parts[2], "\n"))
+ *(strstr(parts[2], "\n")) = '\0';
+ if (input && !output)
+ fclose (input);
+ else if (!input && output)
+ fclose (output);
+ else {
+ gchar tmpbuf[BUFFSIZE];
+ const gchar *bogosity = *parts[1] == 'S' ? "Spam":
+ (*parts[1] == 'H' ? "Ham":"Unsure");
+ gchar *tmpstr = g_strdup_printf(
+ "X-Claws-Bogosity: %s, spamicity=%s\n",
+ bogosity, parts[2]);
+ fwrite(tmpstr, 1, strlen(tmpstr), output);
+ while (fgets(tmpbuf, sizeof(buf), input))
+ fputs(tmpbuf, output);
+ fclose(input);
+ fclose(output);
+ move_file(tmpfile, file, TRUE);
+ g_free(tmpstr);
+ }
+ g_free(tmpfile);
+ }
if (parts && parts[0] && parts[1] && *parts[1] == 'S') {
debug_print("message %d is spam\n", msginfo->msgnum);
if (config.receive_spam) {
Index: bogofilter.h
===================================================================
RCS file: /pack/anoncvs/sylpheedclaws/sylpheed-claws/src/plugins/bogofilter/Attic/bogofilter.h,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -d -r1.1.2.4 -r1.1.2.5
--- bogofilter.h 2006/11/10 17:31:44 1.1.2.4
+++ bogofilter.h 2006/12/15 09:12:56 1.1.2.5
@@ -33,6 +33,7 @@
gchar *save_folder;
guint max_size;
gchar *bogopath;
+ gboolean insert_header;
};
BogofilterConfig *bogofilter_get_config (void);
Index: bogofilter_gtk.c
===================================================================
RCS file: /pack/anoncvs/sylpheedclaws/sylpheed-claws/src/plugins/bogofilter/Attic/bogofilter_gtk.c,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -d -r1.1.2.8 -r1.1.2.9
--- bogofilter_gtk.c 2006/11/27 08:06:59 1.1.2.8
+++ bogofilter_gtk.c 2006/12/15 09:12:56 1.1.2.9
@@ -49,6 +49,7 @@
GtkWidget *receive_spam;
GtkWidget *save_folder;
GtkWidget *save_folder_select;
+ GtkWidget *insert_header;
GtkWidget *max_size;
GtkWidget *bogopath;
};
@@ -90,6 +91,7 @@
GtkWidget *save_spam_folder_entry;
GtkWidget *save_spam_folder_select;
+ GtkWidget *insert_header_chkbtn;
GtkWidget *bogopath_label;
GtkWidget *bogopath_entry;
@@ -156,6 +158,13 @@
_("Click this button to select a folder for storing spam"),
NULL);
+ insert_header_chkbtn = gtk_check_button_new_with_label(_("Insert X-Bogosity header"));
+ gtk_widget_show(insert_header_chkbtn);
+ gtk_box_pack_start(GTK_BOX(vbox2), insert_header_chkbtn, FALSE, FALSE, 0);
+ gtk_tooltips_set_tip(tooltips, insert_header_chkbtn,
+ _("Only done for mails in MH folders"),
+ 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);
@@ -173,6 +182,7 @@
SET_TOGGLE_SENSITIVITY(save_spam_checkbtn, save_spam_folder_entry);
SET_TOGGLE_SENSITIVITY(save_spam_checkbtn, save_spam_folder_select);
+ SET_TOGGLE_SENSITIVITY(save_spam_checkbtn, insert_header_chkbtn);
config = bogofilter_get_config();
@@ -182,6 +192,7 @@
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);
if (config->save_folder != NULL)
gtk_entry_set_text(GTK_ENTRY(save_spam_folder_entry), config->save_folder);
if (config->bogopath != NULL)
@@ -190,6 +201,7 @@
page->max_size = max_size_spinbtn;
page->process_emails = process_emails_checkbtn;
page->receive_spam = save_spam_checkbtn;
+ page->insert_header = insert_header_chkbtn;
page->save_folder = save_spam_folder_entry;
page->save_folder_select = save_spam_folder_select;
page->bogopath = bogopath_entry;
@@ -220,6 +232,9 @@
/* save_folder */
g_free(config->save_folder);
config->save_folder = gtk_editable_get_chars(GTK_EDITABLE(page->save_folder), 0, -1);
+
+ /* insert_header */
+ config->insert_header = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->insert_header));
/* bogopath */
g_free(config->bogopath);