aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRadek Doulik <rodo@ximian.com>2004-02-03 21:11:41 +0800
committerRadek Doulik <rodo@src.gnome.org>2004-02-03 21:11:41 +0800
commit9c080b3f3a2664f8336557ea9ed16cd72cf93a0b (patch)
treea3e5ff1d2059ca8237463823be014d095d53e5ce
parent4d0eb82b047273f3f6a05bc29be26160258639f4 (diff)
downloadgsoc2013-evolution-9c080b3f3a2664f8336557ea9ed16cd72cf93a0b.tar
gsoc2013-evolution-9c080b3f3a2664f8336557ea9ed16cd72cf93a0b.tar.gz
gsoc2013-evolution-9c080b3f3a2664f8336557ea9ed16cd72cf93a0b.tar.bz2
gsoc2013-evolution-9c080b3f3a2664f8336557ea9ed16cd72cf93a0b.tar.lz
gsoc2013-evolution-9c080b3f3a2664f8336557ea9ed16cd72cf93a0b.tar.xz
gsoc2013-evolution-9c080b3f3a2664f8336557ea9ed16cd72cf93a0b.tar.zst
gsoc2013-evolution-9c080b3f3a2664f8336557ea9ed16cd72cf93a0b.zip
handle the sa prefs here, have own gconf client with sa dir added
2004-02-03 Radek Doulik <rodo@ximian.com> * em-junk-filter.c: handle the sa prefs here, have own gconf client with sa dir added * mail-session.c: removed sa prefs svn path=/trunk/; revision=24578
-rw-r--r--mail/ChangeLog7
-rw-r--r--mail/em-junk-filter.c50
-rw-r--r--mail/mail-session.c51
-rw-r--r--mail/mail-session.h7
4 files changed, 46 insertions, 69 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 6b14bf7821..f95ec64f09 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,10 @@
+2004-02-03 Radek Doulik <rodo@ximian.com>
+
+ * em-junk-filter.c: handle the sa prefs here, have own gconf
+ client with sa dir added
+
+ * mail-session.c: removed sa prefs
+
2004-02-02 Jeffrey Stedfast <fejj@ximian.com>
Fix for bug #52941
diff --git a/mail/em-junk-filter.c b/mail/em-junk-filter.c
index bdd7213c05..ddb18c245e 100644
--- a/mail/em-junk-filter.c
+++ b/mail/em-junk-filter.c
@@ -36,9 +36,12 @@
#include "mail-session.h"
#include "em-junk-filter.h"
+#include <gconf/gconf.h>
+#include <gconf/gconf-client.h>
+
#define d(x) x
-static pthread_mutex_t em_junk_sa_test_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t em_junk_sa_init_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t em_junk_sa_report_lock = PTHREAD_MUTEX_INITIALIZER;
static const char *em_junk_sa_get_name (void);
@@ -64,7 +67,7 @@ static gboolean em_junk_sa_tested = FALSE;
static gboolean em_junk_sa_use_spamc = FALSE;
static gboolean em_junk_sa_available = FALSE;
static int em_junk_sa_spamd_port = -1;
-
+static GConfClient *em_junk_sa_gconf = NULL;
static const char *
em_junk_sa_get_name (void)
@@ -72,6 +75,24 @@ em_junk_sa_get_name (void)
return _("Spamassassin (built-in)");
}
+static gboolean
+em_junk_sa_get_local_only ()
+{
+ return gconf_client_get_bool (em_junk_sa_gconf, "/apps/evolution/mail/junk/sa/local_only", NULL);
+}
+
+static gboolean
+em_junk_sa_get_use_daemon ()
+{
+ return gconf_client_get_bool (em_junk_sa_gconf, "/apps/evolution/mail/junk/sa/use_daemon", NULL);
+}
+
+static int
+em_junk_sa_get_daemon_port ()
+{
+ return gconf_client_get_int (em_junk_sa_gconf, "/apps/evolution/mail/junk/sa/daemon_port", NULL);
+}
+
static int
pipe_to_sa (CamelMimeMessage *msg, const char *in, char **argv)
{
@@ -187,7 +208,7 @@ em_junk_sa_test_spamd_running (int port)
static void
em_junk_sa_test_spamd (void)
{
- int port = mail_session_get_sa_daemon_port ();
+ int port = em_junk_sa_get_daemon_port ();
int i;
char *argv[6] = {
"/bin/sh",
@@ -228,7 +249,7 @@ em_junk_sa_test_spamd (void)
argv[i++] = "--port";
argv[i++] = port_buf;
- if (mail_session_get_sa_local_only ())
+ if (em_junk_sa_get_local_only ())
argv[i++] = "--local";
argv[i++] = "--daemonize";
@@ -255,10 +276,17 @@ em_junk_sa_test_spamd (void)
static gboolean
em_junk_sa_is_available (void)
{
- pthread_mutex_lock (&em_junk_sa_test_lock);
+ pthread_mutex_lock (&em_junk_sa_init_lock);
+
+ if (!em_junk_sa_gconf) {
+ em_junk_sa_gconf = gconf_client_get_default();
+ gconf_client_add_dir (em_junk_sa_gconf, "/apps/evolution/mail/junk/sa", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+ }
+
if (!em_junk_sa_tested)
em_junk_sa_test_spamd ();
- pthread_mutex_unlock (&em_junk_sa_test_lock);
+
+ pthread_mutex_unlock (&em_junk_sa_init_lock);
return em_junk_sa_available;
}
@@ -274,7 +302,7 @@ em_junk_sa_check_junk (CamelMimeMessage *msg)
if (!em_junk_sa_is_available ())
return FALSE;
- if (em_junk_sa_use_spamc && mail_session_get_sa_use_daemon ()) {
+ if (em_junk_sa_use_spamc && em_junk_sa_get_use_daemon ()) {
argv[i++] = "spamc";
argv[i++] = "-c";
if (em_junk_sa_spamd_port != -1) {
@@ -286,7 +314,7 @@ em_junk_sa_check_junk (CamelMimeMessage *msg)
argv[i++] = "/bin/sh";
argv[i++] = "-c";
- if (mail_session_get_sa_local_only ())
+ if (em_junk_sa_get_local_only ())
argv[i++] = "spamassassin --exit-code --local";
else
argv[i++] = "spamassassin --exit-code";
@@ -312,7 +340,7 @@ em_junk_sa_report_junk (CamelMimeMessage *msg)
d(fprintf (stderr, "em_junk_sa_report_junk\n"));
if (em_junk_sa_is_available ()) {
- if (mail_session_get_sa_local_only ())
+ if (em_junk_sa_get_local_only ())
argv[4] = "--local";
pthread_mutex_lock (&em_junk_sa_report_lock);
@@ -336,7 +364,7 @@ em_junk_sa_report_notjunk (CamelMimeMessage *msg)
d(fprintf (stderr, "em_junk_sa_report_notjunk\n"));
if (em_junk_sa_is_available ()) {
- if (mail_session_get_sa_local_only ())
+ if (em_junk_sa_get_local_only ())
argv[4] = "--local";
pthread_mutex_lock (&em_junk_sa_report_lock);
@@ -358,7 +386,7 @@ em_junk_sa_commit_reports (void)
d(fprintf (stderr, "em_junk_sa_commit_reports\n"));
if (em_junk_sa_is_available ()) {
- if (mail_session_get_sa_local_only ())
+ if (em_junk_sa_get_local_only ())
argv[2] = "--local";
pthread_mutex_lock (&em_junk_sa_report_lock);
diff --git a/mail/mail-session.c b/mail/mail-session.c
index 5a93eab803..e6979061e7 100644
--- a/mail/mail-session.c
+++ b/mail/mail-session.c
@@ -72,11 +72,6 @@ typedef struct _MailSession {
EMutex *lock;
MailAsyncEvent *async;
-
- /* spamassassin filter options */
- gboolean sa_local_only;
- gboolean sa_use_daemon;
- int sa_daemon_port;
} MailSession;
typedef struct _MailSessionClass {
@@ -100,8 +95,6 @@ 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
@@ -765,42 +758,6 @@ 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;
-}
-
-int
-mail_session_get_sa_daemon_port ()
-{
- return MAIL_SESSION (session)->sa_daemon_port;
-}
-
-void
-mail_session_set_sa_daemon_port (int value)
-{
- MAIL_SESSION (session)->sa_daemon_port = value;
-}
-
static void
mail_session_check_junk_notify (GConfClient *gconf, guint id, GConfEntry *entry, CamelSession *session)
{
@@ -816,13 +773,6 @@ mail_session_check_junk_notify (GConfClient *gconf, guint id, GConfEntry *entry,
camel_session_set_check_junk (session, gconf_value_get_bool (gconf_entry_get_value (entry)));
else if (!strcmp (key, "check_incoming_imap"))
camel_session_set_check_junk_for_imap (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)));
- else if (!strcmp (key, "daemon_port"))
- mail_session_set_sa_daemon_port (gconf_value_get_int (gconf_entry_get_value (entry)));
-
}
}
@@ -844,7 +794,6 @@ mail_session_init (const char *base_directory)
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));
camel_session_set_check_junk_for_imap (session, gconf_client_get_bool (gconf, "/apps/evolution/mail/junk/check_incoming_imap", NULL));
- mail_session_set_sa_daemon_port (gconf_client_get_int (gconf, "/apps/evolution/mail/junk/sa/daemon_port", NULL));
session_check_junk_notify_id = gconf_client_notify_add (gconf, "/apps/evolution/mail/junk",
(GConfClientNotifyFunc) mail_session_check_junk_notify,
session, NULL, NULL);
diff --git a/mail/mail-session.h b/mail/mail-session.h
index 9eb0dd446e..2a7559964c 100644
--- a/mail/mail-session.h
+++ b/mail/mail-session.h
@@ -49,13 +49,6 @@ 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);
-void mail_session_set_sa_daemon_port (int value);
-int mail_session_get_sa_daemon_port (void);
-
extern CamelSession *session;
#ifdef __cplusplus