diff options
author | Federico Mena Quintero <federico@novell.com> | 2010-06-01 07:12:21 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@novell.com> | 2010-06-03 07:05:40 +0800 |
commit | 6057792e7d42d490c93f79b57b74baed20b8e4df (patch) | |
tree | 830f9bbc4a40cdf9c69a0cd17eafc291a6a35624 /mail | |
parent | 7959b11113a399f649c28b86fb57daf8c6c542b9 (diff) | |
download | gsoc2013-evolution-6057792e7d42d490c93f79b57b74baed20b8e4df.tar.gz gsoc2013-evolution-6057792e7d42d490c93f79b57b74baed20b8e4df.tar.zst gsoc2013-evolution-6057792e7d42d490c93f79b57b74baed20b8e4df.zip |
Hook up GNOME's configured SOCKS4 proxy in the mail session
This requires the version of libcamel which has
camel_session_set_socks_proxy().
Signed-off-by: Federico Mena Quintero <federico@novell.com>
Diffstat (limited to 'mail')
-rw-r--r-- | mail/mail-session.c | 69 |
1 files changed, 66 insertions, 3 deletions
diff --git a/mail/mail-session.c b/mail/mail-session.c index efbe42b03c..d2ab1d8930 100644 --- a/mail/mail-session.c +++ b/mail/mail-session.c @@ -62,7 +62,8 @@ #define d(x) CamelSession *session; -static gint session_check_junk_notify_id = -1; +static guint session_check_junk_notify_id; +static guint session_gconf_proxy_id; #define MAIL_TYPE_SESSION \ (mail_session_get_type ()) @@ -106,9 +107,19 @@ static void mail_session_finalize (GObject *object) { MailSession *session = (MailSession *) object; + GConfClient *client; - if (session_check_junk_notify_id != -1) - gconf_client_notify_remove (mail_config_get_gconf_client (), session_check_junk_notify_id); + client = mail_config_get_gconf_client (); + + if (session_check_junk_notify_id != 0) { + gconf_client_notify_remove (client, session_check_junk_notify_id); + session_check_junk_notify_id = 0; + } + + if (session_gconf_proxy_id != 0) { + gconf_client_notify_remove (client, session_gconf_proxy_id); + session_gconf_proxy_id = 0; + } mail_async_event_destroy(session->async); @@ -797,6 +808,56 @@ mail_session_check_junk_notify (GConfClient *gconf, guint id, GConfEntry *entry, } } +#define DIR_PROXY "/system/proxy" +#define KEY_SOCKS_HOST "/system/proxy/socks_host" +#define KEY_SOCKS_PORT "/system/proxy/socks_port" + +static void +set_socks_proxy_from_gconf (void) +{ + GConfClient *client; + gchar *host; + gint port; + + client = mail_config_get_gconf_client (); + + host = gconf_client_get_string (client, KEY_SOCKS_HOST, NULL); /* NULL-GError */ + port = gconf_client_get_int (client, KEY_SOCKS_PORT, NULL); /* NULL-GError */ + camel_session_set_socks_proxy (session, host, port); + + g_free (host); +} + +static void +proxy_gconf_notify_cb (GConfClient* client, guint cnxn_id, GConfEntry *entry, gpointer user_data) +{ + const gchar *key; + + key = gconf_entry_get_key (entry); + + if (strcmp (entry->key, KEY_SOCKS_HOST) == 0 + || strcmp (entry->key, KEY_SOCKS_PORT) == 0) + set_socks_proxy_from_gconf (); +} + +static void +set_socks_proxy_gconf_watch (void) +{ + GConfClient *client; + + client = mail_config_get_gconf_client (); + + gconf_client_add_dir (client, DIR_PROXY, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); /* NULL-GError */ + session_gconf_proxy_id = gconf_client_notify_add (client, DIR_PROXY, proxy_gconf_notify_cb, NULL, NULL, NULL); /* NULL-GError */ +} + +static void +init_socks_proxy (void) +{ + set_socks_proxy_gconf_watch (); + set_socks_proxy_from_gconf (); +} + void mail_session_start (void) { @@ -821,6 +882,8 @@ mail_session_start (void) session->junk_plugin = NULL; mail_config_reload_junk_headers (); + + init_socks_proxy (); } void |