diff options
author | Radek Doulik <rodo@ximian.com> | 2004-01-13 01:11:18 +0800 |
---|---|---|
committer | Radek Doulik <rodo@src.gnome.org> | 2004-01-13 01:11:18 +0800 |
commit | 1c4599a82920d2ca4144517a32af9dfd453435be (patch) | |
tree | f7822948182b6906109a3b038e194b06a06522f0 /mail | |
parent | 5c78763efda4c70010f70350533e25b7c9d1c87f (diff) | |
download | gsoc2013-evolution-1c4599a82920d2ca4144517a32af9dfd453435be.tar gsoc2013-evolution-1c4599a82920d2ca4144517a32af9dfd453435be.tar.gz gsoc2013-evolution-1c4599a82920d2ca4144517a32af9dfd453435be.tar.bz2 gsoc2013-evolution-1c4599a82920d2ca4144517a32af9dfd453435be.tar.lz gsoc2013-evolution-1c4599a82920d2ca4144517a32af9dfd453435be.tar.xz gsoc2013-evolution-1c4599a82920d2ca4144517a32af9dfd453435be.tar.zst gsoc2013-evolution-1c4599a82920d2ca4144517a32af9dfd453435be.zip |
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
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 18 | ||||
-rw-r--r-- | mail/em-junk-filter.c | 61 | ||||
-rw-r--r-- | mail/em-mailer-prefs.c | 14 | ||||
-rw-r--r-- | mail/em-mailer-prefs.h | 2 | ||||
-rw-r--r-- | mail/evolution-mail.schemas.in.in | 22 | ||||
-rw-r--r-- | mail/mail-config.glade | 97 | ||||
-rw-r--r-- | mail/mail-session.c | 42 | ||||
-rw-r--r-- | mail/mail-session.h | 5 |
8 files changed, 182 insertions, 79 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index ddb65d5891..9644d88135 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -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 diff --git a/mail/em-junk-filter.c b/mail/em-junk-filter.c index 8c5888e7c5..d81b04feda 100644 --- a/mail/em-junk-filter.c +++ b/mail/em-junk-filter.c @@ -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 * diff --git a/mail/em-mailer-prefs.c b/mail/em-mailer-prefs.c index 8c6cbabec1..d5a80beef3 100644 --- a/mail/em-mailer-prefs.c +++ b/mail/em-mailer-prefs.c @@ -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); } diff --git a/mail/em-mailer-prefs.h b/mail/em-mailer-prefs.h index 60c362607c..3a182476ff 100644 --- a/mail/em-mailer-prefs.h +++ b/mail/em-mailer-prefs.h @@ -116,6 +116,8 @@ struct _EMMailerPrefs { /* Junk prefs */ GtkToggleButton *check_incoming; + GtkToggleButton *sa_local_tests_only; + GtkToggleButton *sa_use_daemon; }; struct _EMMailerPrefsClass { diff --git a/mail/evolution-mail.schemas.in.in b/mail/evolution-mail.schemas.in.in index 7f8d6a25c3..8e2bf3bec8 100644 --- a/mail/evolution-mail.schemas.in.in +++ b/mail/evolution-mail.schemas.in.in @@ -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> diff --git a/mail/mail-config.glade b/mail/mail-config.glade index 62fce2509a..70283e9153 100644 --- a/mail/mail-config.glade +++ b/mail/mail-config.glade @@ -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> diff --git a/mail/mail-session.c b/mail/mail-session.c index 75f95f906b..02294201ea 100644 --- a/mail/mail-session.c +++ b/mail/mail-session.c @@ -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, diff --git a/mail/mail-session.h b/mail/mail-session.h index 2a7559964c..7fe591540c 100644 --- a/mail/mail-session.h +++ b/mail/mail-session.h @@ -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 |