[evolution] Hook up GNOME's configured SOCKS4 proxy in the mail session
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Hook up GNOME's configured SOCKS4 proxy in the mail session
- Date: Wed, 2 Jun 2010 23:00:25 +0000 (UTC)
commit 6057792e7d42d490c93f79b57b74baed20b8e4df
Author: Federico Mena Quintero <federico novell com>
Date: Mon May 31 18:12:21 2010 -0500
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>
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 efbe42b..d2ab1d8 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]