added SA prefs (mail_session_get_sa_local_only): new helper method
2004-01-12 Radek Doulik <rodo@ximian.com> * mail-session.c: added SA prefs (mail_session_get_sa_local_only): new helper method (mail_session_set_sa_local_only): ditto (mail_session_get_sa_use_daemon): ditto (mail_session_set_sa_use_daemon): ditto (mail_session_check_junk_notify): fix the key comparison (mail_session_init): add gconf dir so that we get notified * mail-config.glade: added SA preferences * em-mailer-prefs.c (em_mailer_prefs_construct): added more junk prefs (em_mailer_prefs_apply): ditto * em-junk-filter.c: use preferences svn path=/trunk/; revision=24174
This commit is contained in:
committed by
Radek Doulik
parent
5c78763efd
commit
1c4599a829
@ -1,3 +1,21 @@
|
||||
2004-01-12 Radek Doulik <rodo@ximian.com>
|
||||
|
||||
* mail-session.c: added SA prefs
|
||||
(mail_session_get_sa_local_only): new helper method
|
||||
(mail_session_set_sa_local_only): ditto
|
||||
(mail_session_get_sa_use_daemon): ditto
|
||||
(mail_session_set_sa_use_daemon): ditto
|
||||
(mail_session_check_junk_notify): fix the key comparison
|
||||
(mail_session_init): add gconf dir so that we get notified
|
||||
|
||||
* mail-config.glade: added SA preferences
|
||||
|
||||
* em-mailer-prefs.c (em_mailer_prefs_construct): added more junk
|
||||
prefs
|
||||
(em_mailer_prefs_apply): ditto
|
||||
|
||||
* em-junk-filter.c: use preferences
|
||||
|
||||
2004-01-12 Larry Ewing <lewing@ximian.com>
|
||||
|
||||
* GNOME_Evolution_Mail.server.in.in: fix up the controls factory
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
#include <camel/camel-data-wrapper.h>
|
||||
#include <camel/camel-stream-fs.h>
|
||||
|
||||
#include "mail-session.h"
|
||||
#include "em-junk-filter.h"
|
||||
|
||||
#define LOCK(x) pthread_mutex_lock(&x)
|
||||
@ -228,7 +229,7 @@ em_junk_sa_test_spamd ()
|
||||
for (i = 0; i < NPORTS; i ++) {
|
||||
d(fprintf (stderr, "trying to run spamd at port %d\n", port));
|
||||
|
||||
sad_args [2] = g_strdup_printf ("spamd --port %d --local --daemonize", port);
|
||||
sad_args [2] = g_strdup_printf ("spamd --port %d %s--daemonize", port, mail_session_get_sa_local_only () ? "--local " : "");
|
||||
if (!pipe_to_sa (NULL, NULL, 3, sad_args)) {
|
||||
g_free (sad_args [2]);
|
||||
em_junk_sa_use_spamc = TRUE;
|
||||
@ -282,10 +283,11 @@ em_junk_sa_check_junk (CamelMimeMessage *msg)
|
||||
" -c" /* Exit with a non-zero exit code if the
|
||||
tested message was junk */
|
||||
" -p %d", em_junk_sa_spamd_port))
|
||||
: g_strdup ("spamassassin"
|
||||
" --exit-code" /* Exit with a non-zero exit code if the
|
||||
tested message was junk */
|
||||
" --local"); /* Local tests only (no online tests) */
|
||||
: g_strdup_printf ("spamassassin"
|
||||
" --exit-code%s", /* Exit with a non-zero exit code if the
|
||||
tested message was junk */
|
||||
mail_session_get_sa_local_only ()
|
||||
? " --local" : ""); /* Local tests only (no online tests) */
|
||||
|
||||
retval = pipe_to_sa (msg, NULL, 3, args);
|
||||
|
||||
@ -300,18 +302,23 @@ em_junk_sa_report_junk (CamelMimeMessage *msg)
|
||||
static gchar *args [4] = {
|
||||
"/bin/sh",
|
||||
"-c",
|
||||
"sa-learn"
|
||||
" --no-rebuild" /* do not rebuild db */
|
||||
" --spam" /* report junk */
|
||||
" --single" /* single message */
|
||||
" --local", /* local only */
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
d(fprintf (stderr, "em_junk_sa_report_junk\n"));
|
||||
|
||||
if (em_junk_sa_is_available ())
|
||||
if (em_junk_sa_is_available ()) {
|
||||
args [2] = g_strdup_printf
|
||||
("sa-learn"
|
||||
" --no-rebuild" /* do not rebuild db */
|
||||
" --spam" /* report junk */
|
||||
" --single%s", /* single message */
|
||||
mail_session_get_sa_local_only ()
|
||||
? " --local" : ""); /* local only */
|
||||
pipe_to_sa (msg, NULL, 3, args);
|
||||
g_free (args [2]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -320,18 +327,23 @@ em_junk_sa_report_notjunk (CamelMimeMessage *msg)
|
||||
static gchar *args [4] = {
|
||||
"/bin/sh",
|
||||
"-c",
|
||||
"sa-learn"
|
||||
" --no-rebuild" /* do not rebuild db */
|
||||
" --ham" /* report notjunk */
|
||||
" --single" /* single message */
|
||||
" --local", /* local only */
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
d(fprintf (stderr, "em_junk_sa_report_notjunk\n"));
|
||||
|
||||
if (em_junk_sa_is_available ())
|
||||
if (em_junk_sa_is_available ()) {
|
||||
args [2] = g_strdup_printf
|
||||
("sa-learn"
|
||||
" --no-rebuild" /* do not rebuild db */
|
||||
" --ham" /* report notjunk */
|
||||
" --single%s", /* single message */
|
||||
mail_session_get_sa_local_only ()
|
||||
? " --local" : ""); /* local only */
|
||||
pipe_to_sa (msg, NULL, 3, args);
|
||||
g_free (args [2]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -340,16 +352,21 @@ em_junk_sa_commit_reports (void)
|
||||
static gchar *args [4] = {
|
||||
"/bin/sh",
|
||||
"-c",
|
||||
"sa-learn"
|
||||
" --rebuild" /* do not rebuild db */
|
||||
" --local", /* local only */
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
d(fprintf (stderr, "em_junk_sa_commit_reports\n");)
|
||||
d(fprintf (stderr, "em_junk_sa_commit_reports\n"));
|
||||
|
||||
if (em_junk_sa_is_available ())
|
||||
if (em_junk_sa_is_available ()) {
|
||||
args [2] = g_strdup_printf
|
||||
("sa-learn"
|
||||
" --rebuild%s", /* do not rebuild db */
|
||||
mail_session_get_sa_local_only ()
|
||||
? " --local" : ""); /* local only */
|
||||
pipe_to_sa (NULL, NULL, 3, args);
|
||||
g_free (args [2]);
|
||||
}
|
||||
}
|
||||
|
||||
const EMJunkPlugin *
|
||||
|
||||
@ -652,6 +652,16 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs)
|
||||
bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/junk/check_incoming", NULL);
|
||||
gtk_toggle_button_set_active (prefs->check_incoming, bool);
|
||||
g_signal_connect (prefs->check_incoming, "toggled", G_CALLBACK (settings_changed), prefs);
|
||||
|
||||
prefs->sa_local_tests_only = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkSALocalTestsOnly"));
|
||||
bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/junk/sa/local_only", NULL);
|
||||
gtk_toggle_button_set_active (prefs->sa_local_tests_only, bool);
|
||||
g_signal_connect (prefs->sa_local_tests_only, "toggled", G_CALLBACK (settings_changed), prefs);
|
||||
|
||||
prefs->sa_use_daemon = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkSAUseDaemon"));
|
||||
bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/junk/sa/use_daemon", NULL);
|
||||
gtk_toggle_button_set_active (prefs->sa_use_daemon, bool);
|
||||
g_signal_connect (prefs->sa_use_daemon, "toggled", G_CALLBACK (settings_changed), prefs);
|
||||
}
|
||||
|
||||
|
||||
@ -792,6 +802,10 @@ em_mailer_prefs_apply (EMMailerPrefs *prefs)
|
||||
/* junk prefs */
|
||||
gconf_client_set_bool (prefs->gconf, "/apps/evolution/mail/junk/check_incoming",
|
||||
gtk_toggle_button_get_active (prefs->check_incoming), NULL);
|
||||
gconf_client_set_bool (prefs->gconf, "/apps/evolution/mail/junk/sa/local_only",
|
||||
gtk_toggle_button_get_active (prefs->sa_local_tests_only), NULL);
|
||||
gconf_client_set_bool (prefs->gconf, "/apps/evolution/mail/junk/sa/use_daemon",
|
||||
gtk_toggle_button_get_active (prefs->sa_use_daemon), NULL);
|
||||
|
||||
gconf_client_suggest_sync (prefs->gconf, NULL);
|
||||
}
|
||||
|
||||
@ -116,6 +116,8 @@ struct _EMMailerPrefs {
|
||||
|
||||
/* Junk prefs */
|
||||
GtkToggleButton *check_incoming;
|
||||
GtkToggleButton *sa_local_tests_only;
|
||||
GtkToggleButton *sa_use_daemon;
|
||||
};
|
||||
|
||||
struct _EMMailerPrefsClass {
|
||||
|
||||
@ -637,6 +637,28 @@
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/evolution/mail/junk/sa/local_only</key>
|
||||
<applyto>/apps/evolution/mail/junk/sa/local_only</applyto>
|
||||
<owner>evolution-mail</owner>
|
||||
<type>bool</type>
|
||||
<default>true</default>
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/evolution/mail/junk/sa/use_daemon</key>
|
||||
<applyto>/apps/evolution/mail/junk/sa/use_daemon</applyto>
|
||||
<owner>evolution-mail</owner>
|
||||
<type>bool</type>
|
||||
<default>true</default>
|
||||
<locale name="C">
|
||||
<short>Use Spamasssassin daemon and client</short>
|
||||
<long>
|
||||
Use Spamasssassin daemon and client (spamc/spamd)
|
||||
</long>
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
<!-- Account settings -->
|
||||
|
||||
<schema>
|
||||
|
||||
@ -4694,7 +4694,48 @@ For example: "Work" or "Personal"</property>
|
||||
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
<widget class="GtkVBox" id="vbox163">
|
||||
<property name="border_width">6</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">3</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="chkSALocalTestsOnly">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">_Local Tests Only</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="chkSAUseDaemon">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Use _Daemon</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
@ -6134,58 +6175,4 @@ for display purposes only. </property>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget class="GtkWindow" id="sa_options">
|
||||
<property name="title" translatable="yes">window1</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox163">
|
||||
<property name="border_width">6</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">3</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="chkLocalTestsOnly">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">_Local Tests Only</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="chkUseDaemon">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Use _Daemon</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
||||
|
||||
@ -72,6 +72,10 @@ typedef struct _MailSession {
|
||||
EMutex *lock;
|
||||
|
||||
MailAsyncEvent *async;
|
||||
|
||||
/* spamassassin filter options */
|
||||
gboolean sa_local_only;
|
||||
gboolean sa_use_daemon;
|
||||
} MailSession;
|
||||
|
||||
typedef struct _MailSessionClass {
|
||||
@ -95,6 +99,8 @@ init (MailSession *session)
|
||||
{
|
||||
session->lock = e_mutex_new(E_MUTEX_REC);
|
||||
session->async = mail_async_event_new();
|
||||
session->sa_local_only = gconf_client_get_bool (mail_config_get_gconf_client (), "/apps/evolution/mail/junk/sa/local_only", NULL);
|
||||
session->sa_use_daemon = gconf_client_get_bool (mail_config_get_gconf_client (), "/apps/evolution/mail/junk/sa/use_daemon", NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -754,6 +760,30 @@ mail_session_forget_password (const char *key)
|
||||
e_passwords_forget_password ("Mail", key);
|
||||
}
|
||||
|
||||
gboolean
|
||||
mail_session_get_sa_local_only ()
|
||||
{
|
||||
return MAIL_SESSION (session)->sa_local_only;
|
||||
}
|
||||
|
||||
void
|
||||
mail_session_set_sa_local_only (gboolean value)
|
||||
{
|
||||
MAIL_SESSION (session)->sa_local_only = value;
|
||||
}
|
||||
|
||||
gboolean
|
||||
mail_session_get_sa_use_daemon ()
|
||||
{
|
||||
return MAIL_SESSION (session)->sa_use_daemon;
|
||||
}
|
||||
|
||||
void
|
||||
mail_session_set_sa_use_daemon (gboolean value)
|
||||
{
|
||||
MAIL_SESSION (session)->sa_use_daemon = value;
|
||||
}
|
||||
|
||||
static void
|
||||
mail_session_check_junk_notify (GConfClient *gconf, guint id, GConfEntry *entry, CamelSession *session)
|
||||
{
|
||||
@ -763,8 +793,15 @@ mail_session_check_junk_notify (GConfClient *gconf, guint id, GConfEntry *entry,
|
||||
g_return_if_fail (gconf_entry_get_value (entry) != NULL);
|
||||
|
||||
key = strrchr (gconf_entry_get_key (entry), '/');
|
||||
if (!strcmp (key, "check_incoming"))
|
||||
camel_session_set_check_junk (session, gconf_value_get_bool (gconf_entry_get_value (entry)));
|
||||
if (key) {
|
||||
key ++;
|
||||
if (!strcmp (key, "check_incoming"))
|
||||
camel_session_set_check_junk (session, gconf_value_get_bool (gconf_entry_get_value (entry)));
|
||||
else if (!strcmp (key, "local_only"))
|
||||
mail_session_set_sa_local_only (gconf_value_get_bool (gconf_entry_get_value (entry)));
|
||||
else if (!strcmp (key, "use_daemon"))
|
||||
mail_session_set_sa_use_daemon (gconf_value_get_bool (gconf_entry_get_value (entry)));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -782,6 +819,7 @@ mail_session_init (const char *base_directory)
|
||||
camel_session_construct (session, camel_dir);
|
||||
|
||||
gconf = mail_config_get_gconf_client ();
|
||||
gconf_client_add_dir (gconf, "/apps/evolution/mail/junk", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
|
||||
camel_session_set_check_junk (session, gconf_client_get_bool (gconf, "/apps/evolution/mail/junk/check_incoming", NULL));
|
||||
session_check_junk_notify_id = gconf_client_notify_add (gconf, "/apps/evolution/mail/junk",
|
||||
(GConfClientNotifyFunc) mail_session_check_junk_notify,
|
||||
|
||||
@ -49,6 +49,11 @@ void mail_session_forget_password (const char *key);
|
||||
|
||||
void mail_session_flush_filter_log (void);
|
||||
|
||||
gboolean mail_session_get_sa_local_only (void);
|
||||
void mail_session_set_sa_local_only (gboolean value);
|
||||
gboolean mail_session_get_sa_use_daemon (void);
|
||||
void mail_session_set_sa_use_daemon (gboolean value);
|
||||
|
||||
extern CamelSession *session;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user