[Commits] [SCM] claws branch, master, updated. 3.16.0-129-g567a186

wwp at claws-mail.org wwp at claws-mail.org
Thu Apr 12 21:38:12 CEST 2018


The branch, master has been updated
       via  567a186d197384a5d6f7794b963d4a98f21933a1 (commit)
      from  32426d892c92cfb61dfb5f7ba9811232c9400ab9 (commit)

Summary of changes:
 configure.ac                                |   22 ++++++++++++++++++++++
 src/plugins/spamassassin/Makefile.am        |    6 ++++--
 src/plugins/spamassassin/spamassassin.c     |   17 +++++++++++++++--
 src/plugins/spamassassin/spamassassin.h     |    1 +
 src/plugins/spamassassin/spamassassin_gtk.c |   24 ++++++++++++++++++++++--
 5 files changed, 64 insertions(+), 6 deletions(-)


- Log -----------------------------------------------------------------
commit 567a186d197384a5d6f7794b963d4a98f21933a1
Author: wwp <wwp at free.fr>
Date:   Thu Apr 12 21:37:21 2018 +0200

    Spamassassin plug-in: add support for compression (server must have
    compression enabled, local spamc too).

diff --git a/configure.ac b/configure.ac
index 791a2dd..50d6866 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1853,6 +1853,28 @@ if test x"$enable_spamassassin_plugin" != xno; then
 	PLUGINS="$PLUGINS spamassassin"
 	AC_MSG_RESULT(yes)
 	AC_SPAMASSASSIN
+
+	dnl check for zlib (optional)
+	spamassassin_zlib=0
+	SPAMASSASSIN_CFLAGS=""
+	SPAMASSASSIN_LIBS=""
+	AC_CHECK_HEADER([zlib.h],
+			[AC_DEFINE(HAVE_ZLIB_H,1,[optional zlib support for spamassassin plugin])]
+			[spamassassin_zlib=1],
+			[spamassassin_zlib=0])
+	if test $spamassassin_zlib -eq 1; then
+		AC_CHECK_LIB(z, deflate, [spamassassin_zlib=1], [spamassassin_zlib=0])
+		AC_MSG_CHECKING([whether to build spamassassin plugin with zlib support])
+		if test $spamassassin_zlib -eq 1; then
+			AC_MSG_RESULT(yes)
+			SPAMASSASSIN_CFLAGS="-DHAVE_LIBZ"
+			SPAMASSASSIN_LIBS="-lz"
+		else
+			AC_MSG_RESULT(no)
+		fi
+	fi
+	AC_SUBST(SPAMASSASSIN_CFLAGS)
+	AC_SUBST(SPAMASSASSIN_LIBS)
 else
 	DISABLED_PLUGINS="$DISABLED_PLUGINS spamassassin"
 	AC_MSG_RESULT(no)
diff --git a/src/plugins/spamassassin/Makefile.am b/src/plugins/spamassassin/Makefile.am
index 92712f0..71e6c06 100644
--- a/src/plugins/spamassassin/Makefile.am
+++ b/src/plugins/spamassassin/Makefile.am
@@ -16,7 +16,8 @@ spamassassin_la_SOURCES = \
 	utils.c utils.h
 
 spamassassin_la_LDFLAGS = \
-	-avoid-version -module
+	-avoid-version -module \
+	$(SPAMASSASSIN_LIBS)
 
 if CYGWIN
 cygwin_export_lib = -L$(top_builddir)/src -lclaws-mail
@@ -33,6 +34,7 @@ spamassassin_la_CPPFLAGS = \
 	-I$(top_srcdir)/src/gtk \
 	$(ENCHANT_CFLAGS) \
 	$(GLIB_CFLAGS) \
-	$(GTK_CFLAGS)
+	$(GTK_CFLAGS) \
+	$(SPAMASSASSIN_CFLAGS)
 
 EXTRA_DIST = README NOTICE
diff --git a/src/plugins/spamassassin/spamassassin.c b/src/plugins/spamassassin/spamassassin.c
index f01bd92..c33307b 100644
--- a/src/plugins/spamassassin/spamassassin.c
+++ b/src/plugins/spamassassin/spamassassin.c
@@ -116,6 +116,8 @@ static PrefParam param[] = {
 	 NULL, NULL, NULL},
 	{"whitelist_ab_folder", N_("Any"), &config.whitelist_ab_folder, P_STRING,
 	 NULL, NULL, NULL},
+	{"compress", "FALSE", &config.compress, P_BOOL,
+	 NULL, NULL, NULL},
 
 	{NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
@@ -137,6 +139,15 @@ typedef enum {
 	MSG_FILTERING_ERROR = 2
 } MsgStatus;
 
+static void update_flags(void)
+{
+	/* set the SPAMC_USE_ZLIB flag according to config */
+	if (config.compress)
+		flags |= SPAMC_USE_ZLIB;
+	else
+		flags &= ~SPAMC_USE_ZLIB;
+}
+
 static MsgStatus msg_is_spam(FILE *fp)
 {
 	struct transport trans;
@@ -146,6 +157,7 @@ static MsgStatus msg_is_spam(FILE *fp)
 	if (!config.enable)
 		return MSG_IS_HAM;
 
+	update_flags();
 	transport_init(&trans);
 	switch (config.transport) {
 	case SPAMASSASSIN_TRANSPORT_LOCALHOST:
@@ -371,10 +383,11 @@ gchar* spamassassin_create_tmp_spamc_wrapper(gboolean spam)
 
 	if (fname != NULL) {
 		contents = g_strdup_printf(
-						"spamc -d %s -p %u -u %s -t %u -s %u -L %s<\"$*\";exit $?",
+						"spamc -d %s -p %u -u %s -t %u -s %u %s -L %s<\"$*\";exit $?",
 						config.hostname, config.port, 
 						config.username, config.timeout,
-						config.max_size * 1024, spam?"spam":"ham");
+						config.max_size * 1024, config.compress?"-z":"",
+						spam?"spam":"ham");
 		if (str_write_to_file(contents, fname) < 0) {
 			g_free(fname);
 			fname = NULL;
diff --git a/src/plugins/spamassassin/spamassassin.h b/src/plugins/spamassassin/spamassassin.h
index d786da9..c13d4bc 100644
--- a/src/plugins/spamassassin/spamassassin.h
+++ b/src/plugins/spamassassin/spamassassin.h
@@ -50,6 +50,7 @@ struct _SpamAssassinConfig
 	gboolean		 mark_as_read;
 	gboolean		 whitelist_ab;
 	gchar			*whitelist_ab_folder;
+	gboolean		 compress;
 };
 
 SpamAssassinConfig *spamassassin_get_config	      (void);
diff --git a/src/plugins/spamassassin/spamassassin_gtk.c b/src/plugins/spamassassin/spamassassin_gtk.c
index 1c92544..3cc56d6 100644
--- a/src/plugins/spamassassin/spamassassin_gtk.c
+++ b/src/plugins/spamassassin/spamassassin_gtk.c
@@ -60,6 +60,7 @@ struct SpamAssassinPage
 	GtkWidget *save_folder_select;
 	GtkWidget *max_size;
 	GtkWidget *timeout;
+	GtkWidget *compress;
 	GtkWidget *mark_as_read;
 	GtkWidget *whitelist_ab;
 	GtkWidget *whitelist_ab_folder_combo;
@@ -216,8 +217,8 @@ static void spamassassin_create_widget_func(PrefsPage * _page,
 
 	GtkWidget *vbox1, *vbox2;
 	GtkWidget *frame_transport, *table_transport, *vbox_transport;
-	GtkWidget *hbox_spamd, *hbox_max_size, *hbox_timeout;
-	GtkWidget *hbox_process_emails, *hbox_save_spam;
+	GtkWidget *hbox_spamd, *hbox_compress, *hbox_max_size;
+	GtkWidget *hbox_timeout, *hbox_process_emails, *hbox_save_spam;
 	GtkWidget *hbox_mark_as_read, *hbox_whitelist;
 	GtkWidget *whitelist_ab_checkbtn;
 	GtkWidget *whitelist_ab_folder_combo;
@@ -238,6 +239,8 @@ static void spamassassin_create_widget_func(PrefsPage * _page,
 	GtkWidget *spamd_port_spinbtn;
 	GtkWidget *spamd_socket_entry;
 
+	GtkWidget *compress_checkbtn;
+
 	GtkWidget *max_size_label;
 	GtkAdjustment *max_size_spinbtn_adj;
 	GtkWidget *max_size_spinbtn;
@@ -353,6 +356,17 @@ static void spamassassin_create_widget_func(PrefsPage * _page,
 	gtk_box_pack_start(GTK_BOX(hbox_spamd), spamd_socket_entry, TRUE, TRUE, 0);
 	CLAWS_SET_TIP(spamd_socket_entry, _("Path of Unix socket"));
 
+	hbox_compress = gtk_hbox_new(FALSE, 8);
+	gtk_widget_show(hbox_compress);
+	gtk_box_pack_start (GTK_BOX (vbox2), hbox_compress, TRUE, TRUE, 0);
+
+	compress_checkbtn = gtk_check_button_new_with_label(
+			_("Use compression"));
+	gtk_widget_show(compress_checkbtn);
+	gtk_box_pack_start(GTK_BOX(hbox_compress), compress_checkbtn, TRUE, TRUE, 0);
+	CLAWS_SET_TIP(compress_checkbtn,
+			_("Enable compression if spamd uses it, otherwise disable it."));
+
 	hbox_max_size = gtk_hbox_new(FALSE, 8);
 	gtk_widget_show(hbox_max_size);
 	gtk_box_pack_start (GTK_BOX (vbox2), hbox_max_size, TRUE, TRUE, 0);
@@ -453,6 +467,7 @@ static void spamassassin_create_widget_func(PrefsPage * _page,
 			_("Click this button to select a book or folder in the address book"));
 
 	SET_TOGGLE_SENSITIVITY(enable_sa_checkbtn, frame_transport);
+	SET_TOGGLE_SENSITIVITY(enable_sa_checkbtn, hbox_compress);
 	SET_TOGGLE_SENSITIVITY(enable_sa_checkbtn, hbox_max_size);
 	SET_TOGGLE_SENSITIVITY(enable_sa_checkbtn, hbox_timeout);
 	SET_TOGGLE_SENSITIVITY(enable_sa_checkbtn, hbox_save_spam);
@@ -498,6 +513,7 @@ static void spamassassin_create_widget_func(PrefsPage * _page,
 					config->whitelist_ab_folder);
 	}
 	gtk_spin_button_set_value(GTK_SPIN_BUTTON(spamd_port_spinbtn), (float) config->port);
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(compress_checkbtn), config->compress);
 	gtk_spin_button_set_value(GTK_SPIN_BUTTON(max_size_spinbtn), (float) config->max_size);
 	gtk_spin_button_set_value(GTK_SPIN_BUTTON(timeout_spinbtn), (float) config->timeout);
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(process_emails_checkbtn), config->process_emails);
@@ -515,6 +531,7 @@ static void spamassassin_create_widget_func(PrefsPage * _page,
 	page->colon = spamd_colon_label;
 	page->port = spamd_port_spinbtn;
 	page->socket = spamd_socket_entry;
+	page->compress = compress_checkbtn;
 	page->max_size = max_size_spinbtn;
 	page->timeout = timeout_spinbtn;
 	page->process_emails = process_emails_checkbtn;
@@ -603,6 +620,9 @@ static void spamassassin_save_func(PrefsPage *_page)
 	/* timeout */
 	config->timeout = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(page->timeout));
 
+	/* compress */
+	config->compress = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->compress));
+
 	/* mark_as_read */
 	config->mark_as_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->mark_as_read));
 

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list