evolution r37236 - trunk/mail



Author: mcrha
Date: Mon Feb  9 10:59:29 2009
New Revision: 37236
URL: http://svn.gnome.org/viewvc/evolution?rev=37236&view=rev

Log:
2009-02-09  Milan Crha  <mcrha redhat com>

	** Part of fix for bug #555888

	* mail-config.glade:
	* em-network-prefs.h: (struct _EMNetworkPrefs):
	* em-network-prefs.c: (emnp_parse_ignore_hosts),
	(emnp_load_sys_settings), (notify_proxy_type_changed),
	(em_network_prefs_construct):
	Do not overwrite user settings with system proxy settings.
	Register signals at the end, when all widgets are read.
	Hide socks settings, it is not used at the moment.

	* em-utils.h: (em_utils_get_proxy_uri):
	* em-utils.c: (em_utils_get_proxy_uri), (emu_proxy_setup):
	* em-format-html.c: (emfh_gethttp):
	Use proxy configurable within Evolution.



Modified:
   trunk/mail/ChangeLog
   trunk/mail/em-format-html.c
   trunk/mail/em-network-prefs.c
   trunk/mail/em-network-prefs.h
   trunk/mail/em-utils.c
   trunk/mail/em-utils.h
   trunk/mail/mail-config.glade

Modified: trunk/mail/em-format-html.c
==============================================================================
--- trunk/mail/em-format-html.c	(original)
+++ trunk/mail/em-format-html.c	Mon Feb  9 10:59:29 2009
@@ -498,9 +498,11 @@
 
 		instream = camel_http_stream_new(CAMEL_HTTP_METHOD_GET, ((EMFormat *)job->format)->session, url);
 		camel_http_stream_set_user_agent((CamelHttpStream *)instream, "CamelHttpStream/1.0 Evolution/" VERSION);
-		proxy = em_utils_get_proxy_uri();
-		camel_http_stream_set_proxy((CamelHttpStream *)instream, proxy);
-		g_free(proxy);
+		proxy = em_utils_get_proxy_uri (job->u.uri);
+		if (proxy) {
+			camel_http_stream_set_proxy ((CamelHttpStream *)instream, proxy);
+			g_free (proxy);
+		}
 		camel_operation_start(NULL, _("Retrieving `%s'"), job->u.uri);
 		tmp_stream = (CamelHttpStream *)instream;
 		content_type = camel_http_stream_get_content_type(tmp_stream);

Modified: trunk/mail/em-network-prefs.c
==============================================================================
--- trunk/mail/em-network-prefs.c	(original)
+++ trunk/mail/em-network-prefs.c	Mon Feb  9 10:59:29 2009
@@ -63,21 +63,6 @@
 #define GCONF_E_USE_PROXY_KEY GCONF_E_SHELL_NETWORK_CONFIG_PATH "use_http_proxy"
 #define GCONF_E_AUTOCONFIG_URL_KEY GCONF_E_SHELL_NETWORK_CONFIG_PATH "autoconfig_url"
 
-#define GCONF_SYS_PROXY_PATH "/system/proxy/"
-#define GCONF_SYS_HTTP_PROXY_PATH "/system/http_proxy"
-#define GCONF_SYS_HTTP_HOST_KEY GCONF_SYS_HTTP_PROXY_PATH "host"
-#define GCONF_SYS_HTTP_PORT_KEY GCONF_SYS_HTTP_PROXY_PATH "port"
-#define GCONF_SYS_HTTPS_HOST_KEY GCONF_SYS_PROXY_PATH "secure_host"
-#define GCONF_SYS_HTTPS_PORT_KEY GCONF_SYS_PROXY_PATH "secure_port"
-#define GCONF_SYS_SOCKS_HOST_KEY GCONF_SYS_PROXY_PATH "socks_host"
-#define GCONF_SYS_SOCKS_PORT_KEY GCONF_SYS_PROXY_PATH "socks_port"
-#define GCONF_SYS_AUTOCONFIG_URL_KEY GCONF_SYS_PROXY_PATH "autoconfig_url"
-#define GCONF_SYS_IGNORE_HOSTS_KEY GCONF_SYS_HTTP_PROXY_PATH "ignore_hosts"
-#define GCONF_SYS_USE_PROXY_KEY GCONF_SYS_HTTP_PROXY_PATH "use_http_proxy"
-#define GCONF_SYS_USE_AUTH_KEY GCONF_SYS_HTTP_PROXY_PATH "use_authentication"
-#define GCONF_SYS_AUTH_USER_KEY GCONF_SYS_HTTP_PROXY_PATH "authentication_user"
-#define GCONF_SYS_AUTH_PWD_KEY GCONF_SYS_HTTP_PROXY_PATH "authentication_password"
-
 static void em_network_prefs_class_init (EMNetworkPrefsClass *class);
 static void em_network_prefs_init       (EMNetworkPrefs *dialog);
 static void em_network_prefs_destroy    (GtkObject *obj);
@@ -197,20 +182,21 @@
 
 		gtk_widget_set_sensitive ((GtkWidget *) prefs->http_host, sensitivity);
 		gtk_widget_set_sensitive ((GtkWidget *) prefs->https_host, sensitivity);
-		gtk_widget_set_sensitive ((GtkWidget *) prefs->socks_host, sensitivity);
 		gtk_widget_set_sensitive ((GtkWidget *) prefs->ignore_hosts, sensitivity);
 		gtk_widget_set_sensitive ((GtkWidget *) prefs->use_auth, sensitivity);
 		gtk_widget_set_sensitive ((GtkWidget *) prefs->http_port, sensitivity);
 		gtk_widget_set_sensitive ((GtkWidget *) prefs->https_port, sensitivity);
-		gtk_widget_set_sensitive ((GtkWidget *) prefs->socks_port, sensitivity);
 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_ignore_hosts, sensitivity);
 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_http_host, sensitivity);
 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_http_port, sensitivity);
 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_https_host, sensitivity);
 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_https_port, sensitivity);
+#if 0
+		gtk_widget_set_sensitive ((GtkWidget *) prefs->socks_host, sensitivity);
+		gtk_widget_set_sensitive ((GtkWidget *) prefs->socks_port, sensitivity);
 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_socks_host, sensitivity);
 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_socks_port, sensitivity);
-
+#endif
 		state = sensitivity && gtk_toggle_button_get_active (prefs->use_auth);
 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_auth_user, state);
 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_auth_pwd, state);
@@ -222,91 +208,6 @@
 }
 
 static void
-emnp_parse_ignore_hosts (gpointer data, gpointer user_data)
-{
-	GString *str = (GString *)user_data;
-
-	if (!str)
-		return;
-
-	/* FIXME: Remove trailing , */
-	if (data) {
-		str = g_string_append (str, data);
-		str = g_string_append_c (str, ',');
-	}
-}
-
-static void 
-emnp_load_sys_settings (GConfClient *gconf)
-{
-	char *buf;
-	int port;
-	GSList *ignore_hosts;
-	gboolean toggle;
-	GString *str = NULL;
-
-	if (!gconf)
-		return;
-	
-	toggle = gconf_client_get_bool (gconf, GCONF_SYS_USE_PROXY_KEY, NULL);
-	if (!toggle) {
-		gconf_client_set_bool (gconf, GCONF_E_USE_PROXY_KEY, toggle, NULL);
-		return;
-	}
-
-	toggle = gconf_client_get_bool (gconf, GCONF_SYS_USE_AUTH_KEY, NULL);
-	gconf_client_set_bool (gconf, GCONF_E_USE_AUTH_KEY, toggle, NULL);
-
-	buf = gconf_client_get_string (gconf, GCONF_SYS_HTTP_HOST_KEY, NULL);
-	gconf_client_set_string (gconf, GCONF_E_HTTP_HOST_KEY, buf, NULL);
-	g_free (buf);
-
-	buf = gconf_client_get_string (gconf, GCONF_SYS_HTTPS_HOST_KEY, NULL);
-	gconf_client_set_string (gconf, GCONF_E_HTTPS_HOST_KEY, buf, NULL);
-	g_free (buf);
-
-	buf = gconf_client_get_string (gconf, GCONF_SYS_SOCKS_HOST_KEY, NULL);
-	gconf_client_set_string (gconf, GCONF_E_SOCKS_HOST_KEY, buf, NULL);
-	g_free (buf);
-
-#if 0
-	buf = gconf_client_get_string (gconf, GCONF_SYS_AUTOCONFIG_URL_KEY, NULL);
-	gconf_client_set_string (gconf, GCONF_E_AUTOCONFIG_URL_KEY, buf, NULL);
-	g_free (buf);
-#endif
-
-	buf = gconf_client_get_string (gconf, GCONF_SYS_AUTH_USER_KEY, NULL);
-	gconf_client_set_string (gconf, GCONF_E_AUTH_USER_KEY, buf, NULL);
-	g_free (buf);
-
-	buf = gconf_client_get_string (gconf, GCONF_SYS_AUTH_PWD_KEY, NULL);
-	gconf_client_set_string (gconf, GCONF_E_AUTH_PWD_KEY, buf, NULL);
-	g_free (buf);
-
-	port = gconf_client_get_int (gconf, GCONF_SYS_HTTP_PORT_KEY, NULL);
-	gconf_client_set_int (gconf, GCONF_E_HTTP_PORT_KEY, port, NULL);
-
-	port = gconf_client_get_int (gconf, GCONF_SYS_HTTPS_PORT_KEY, NULL);
-	gconf_client_set_int (gconf, GCONF_E_HTTPS_PORT_KEY, port, NULL);
-
-	port = gconf_client_get_int (gconf, GCONF_SYS_SOCKS_PORT_KEY, NULL);
-	gconf_client_set_int (gconf, GCONF_E_SOCKS_PORT_KEY, port, NULL);
-
-	ignore_hosts = gconf_client_get_list (gconf, GCONF_SYS_IGNORE_HOSTS_KEY, 
-						GCONF_VALUE_STRING, NULL);
-	if (ignore_hosts) {
-		str = g_string_sized_new (32);
-		g_slist_foreach (ignore_hosts, (GFunc) emnp_parse_ignore_hosts, str);
-		g_slist_foreach (ignore_hosts, (GFunc) g_free, NULL);	
-		g_slist_free (ignore_hosts);
-
-		gconf_client_set_string (gconf, GCONF_E_IGNORE_HOSTS_KEY, 
-					 str->str, NULL);
-		g_string_free (str, TRUE);
-	}
-}
-
-static void
 notify_proxy_type_changed (GtkWidget *widget, EMNetworkPrefs *prefs)
 {
 	int type;
@@ -330,11 +231,6 @@
 	    type == NETWORK_PROXY_SYS_SETTINGS) {
 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_MANUAL, FALSE);
 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_AUTOCONFIG, FALSE);
-		if (type == NETWORK_PROXY_SYS_SETTINGS) {
-			d(g_print ("%s:%s: Loading sys settings... \n", G_STRLOC, G_STRFUNC));
-			emnp_load_sys_settings (prefs->gconf);
-		}
-
 	} else if (type == NETWORK_PROXY_AUTOCONFIG) {
 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_MANUAL, FALSE);
 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_AUTOCONFIG, TRUE);
@@ -448,7 +344,6 @@
 
 	prefs->sys_proxy = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "rdoSysSettings"));
 	gtk_toggle_button_set_active (prefs->sys_proxy, val == NETWORK_PROXY_SYS_SETTINGS);
-	g_signal_connect (prefs->sys_proxy, "toggled", G_CALLBACK (notify_proxy_type_changed), prefs);
 	if (locked)
 		gtk_widget_set_sensitive ((GtkWidget *) prefs->sys_proxy, FALSE);
 
@@ -456,7 +351,6 @@
 
 	prefs->no_proxy = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "rdoNoProxy"));
 	gtk_toggle_button_set_active (prefs->no_proxy, val == NETWORK_PROXY_DIRECT_CONNECTION);
-	g_signal_connect (prefs->no_proxy, "toggled", G_CALLBACK (notify_proxy_type_changed), prefs);
 	if (locked)
 		gtk_widget_set_sensitive ((GtkWidget *) prefs->no_proxy, FALSE);
 
@@ -469,7 +363,6 @@
 
 	gtk_toggle_button_set_active (prefs->auto_proxy, val == NETWORK_PROXY_AUTOCONFIG);
 
-	g_signal_connect (prefs->auto_proxy, "toggled", G_CALLBACK (notify_proxy_type_changed), prefs);
 	g_signal_connect(prefs->auto_proxy_url, "changed", G_CALLBACK(widget_entry_changed_cb), GCONF_E_AUTOCONFIG_URL_KEY);
 	if (locked)
 		gtk_widget_set_sensitive ((GtkWidget *) prefs->auto_proxy, FALSE);
@@ -480,17 +373,13 @@
 	prefs->manual_proxy = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "rdoManualProxy"));
 	prefs->http_host = GTK_ENTRY (glade_xml_get_widget (gui, "txtHttpHost"));
 	prefs->https_host = GTK_ENTRY (glade_xml_get_widget (gui, "txtHttpsHost"));
-	prefs->socks_host = GTK_ENTRY (glade_xml_get_widget (gui, "txtSocksHost"));
 	prefs->ignore_hosts = GTK_ENTRY (glade_xml_get_widget (gui, "txtIgnoreHosts"));
 	prefs->http_port = GTK_SPIN_BUTTON (glade_xml_get_widget (gui, "spnHttpPort"));
 	prefs->https_port = GTK_SPIN_BUTTON (glade_xml_get_widget (gui, "spnHttpsPort"));
-	prefs->socks_port = GTK_SPIN_BUTTON (glade_xml_get_widget (gui, "spnSocksPort"));
 	prefs->lbl_http_host = GTK_LABEL (glade_xml_get_widget (gui, "lblHttpHost"));
 	prefs->lbl_http_port = GTK_LABEL (glade_xml_get_widget (gui, "lblHttpPort"));
 	prefs->lbl_https_host = GTK_LABEL (glade_xml_get_widget (gui, "lblHttpsHost"));
 	prefs->lbl_https_port = GTK_LABEL (glade_xml_get_widget (gui, "lblHttpsPort"));
-	prefs->lbl_socks_host = GTK_LABEL (glade_xml_get_widget (gui, "lblSocksHost"));
-	prefs->lbl_socks_port = GTK_LABEL (glade_xml_get_widget (gui, "lblSocksPort"));
 	prefs->lbl_ignore_hosts = GTK_LABEL (glade_xml_get_widget (gui, "lblIgnoreHosts"));
 	prefs->use_auth = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkUseAuth"));
 	toggle_button_init (prefs, prefs->use_auth, GCONF_E_USE_AUTH_KEY);
@@ -498,28 +387,40 @@
 	prefs->lbl_auth_pwd = GTK_LABEL (glade_xml_get_widget (gui, "lblAuthPwd"));
 	prefs->auth_user = GTK_ENTRY (glade_xml_get_widget (gui, "txtAuthUser"));
 	prefs->auth_pwd = GTK_ENTRY (glade_xml_get_widget (gui, "txtAuthPwd"));
+
+#if 0
+	prefs->socks_host = GTK_ENTRY (glade_xml_get_widget (gui, "txtSocksHost"));
+	prefs->socks_port = GTK_SPIN_BUTTON (glade_xml_get_widget (gui, "spnSocksPort"));
+	prefs->lbl_socks_host = GTK_LABEL (glade_xml_get_widget (gui, "lblSocksHost"));
+	prefs->lbl_socks_port = GTK_LABEL (glade_xml_get_widget (gui, "lblSocksPort"));
+	g_signal_connect (prefs->socks_host, "changed", 
+			  G_CALLBACK(widget_entry_changed_cb), GCONF_E_SOCKS_HOST_KEY);
+	g_signal_connect (prefs->socks_port, "value_changed", 
+			  G_CALLBACK(widget_entry_changed_cb), GCONF_E_SOCKS_PORT_KEY);
+#endif
 	
 	/* Manual proxy options */
 	g_signal_connect (prefs->http_host, "changed", 
 			  G_CALLBACK(widget_entry_changed_cb), GCONF_E_HTTP_HOST_KEY);
 	g_signal_connect (prefs->https_host, "changed", 
 			  G_CALLBACK(widget_entry_changed_cb), GCONF_E_HTTPS_HOST_KEY);
-	g_signal_connect (prefs->socks_host, "changed", 
-			  G_CALLBACK(widget_entry_changed_cb), GCONF_E_SOCKS_HOST_KEY);
 	g_signal_connect (prefs->ignore_hosts, "changed", 
 			  G_CALLBACK(widget_entry_changed_cb), GCONF_E_IGNORE_HOSTS_KEY);
 	g_signal_connect (prefs->http_port, "value_changed", 
 			  G_CALLBACK(widget_entry_changed_cb), GCONF_E_HTTP_PORT_KEY);
 	g_signal_connect (prefs->https_port, "value_changed", 
 			  G_CALLBACK(widget_entry_changed_cb), GCONF_E_HTTPS_PORT_KEY);
-	g_signal_connect (prefs->socks_port, "value_changed", 
-			  G_CALLBACK(widget_entry_changed_cb), GCONF_E_SOCKS_PORT_KEY);
 	g_signal_connect (prefs->auth_user, "changed", 
 			  G_CALLBACK(widget_entry_changed_cb), GCONF_E_AUTH_USER_KEY);
 	g_signal_connect (prefs->auth_pwd, "changed", 
 			  G_CALLBACK(widget_entry_changed_cb), GCONF_E_AUTH_PWD_KEY);
 
 	gtk_toggle_button_set_active (prefs->manual_proxy, val == NETWORK_PROXY_MANUAL);
+	g_signal_connect (prefs->sys_proxy, "toggled", G_CALLBACK (notify_proxy_type_changed), prefs);
+	g_signal_connect (prefs->no_proxy, "toggled", G_CALLBACK (notify_proxy_type_changed), prefs);
+#if 0
+	g_signal_connect (prefs->auto_proxy, "toggled", G_CALLBACK (notify_proxy_type_changed), prefs);
+#endif
 	g_signal_connect (prefs->manual_proxy, "toggled", G_CALLBACK (notify_proxy_type_changed), prefs);
 
 	if (locked)
@@ -534,10 +435,6 @@
 	gtk_entry_set_text (prefs->https_host, buf ? buf : "");
 	g_free (buf);
 
-	buf = gconf_client_get_string (prefs->gconf, GCONF_E_SOCKS_HOST_KEY, NULL);
-	gtk_entry_set_text (prefs->socks_host, buf ? buf : "");
-	g_free (buf);
-
 	buf = gconf_client_get_string (prefs->gconf, GCONF_E_IGNORE_HOSTS_KEY, NULL);
 	gtk_entry_set_text (prefs->ignore_hosts, buf ? buf : "");
 	g_free (buf);
@@ -556,17 +453,20 @@
 	port = gconf_client_get_int (prefs->gconf, GCONF_E_HTTPS_PORT_KEY, NULL);
 	gtk_spin_button_set_value (prefs->https_port, (gdouble)port);
 
+#if 0
+	buf = gconf_client_get_string (prefs->gconf, GCONF_E_SOCKS_HOST_KEY, NULL);
+	gtk_entry_set_text (prefs->socks_host, buf ? buf : "");
+	g_free (buf);
+
 	port = gconf_client_get_int (prefs->gconf, GCONF_E_SOCKS_PORT_KEY, NULL);
 	gtk_spin_button_set_value (prefs->socks_port, (gdouble)port);
-
+#endif
 	emnp_set_markups (prefs);
 
 	if (val == NETWORK_PROXY_DIRECT_CONNECTION ||
 	    val == NETWORK_PROXY_SYS_SETTINGS) {
 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_MANUAL, FALSE);
 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_AUTOCONFIG, FALSE);
-		if (val == NETWORK_PROXY_SYS_SETTINGS)
-			emnp_load_sys_settings (prefs->gconf);
 	} else if (val == NETWORK_PROXY_AUTOCONFIG) {
 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_MANUAL, FALSE);
 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_AUTOCONFIG, TRUE);

Modified: trunk/mail/em-network-prefs.h
==============================================================================
--- trunk/mail/em-network-prefs.h	(original)
+++ trunk/mail/em-network-prefs.h	Mon Feb  9 10:59:29 2009
@@ -70,7 +70,6 @@
 
 	struct _GtkEntry *http_host;
 	struct _GtkEntry *https_host;
-	struct _GtkEntry *socks_host;
 	struct _GtkEntry *ignore_hosts;
 #if 0
 	struct _GtkEntry *auto_proxy_url;
@@ -82,15 +81,18 @@
 	struct _GtkLabel *lbl_http_port;
 	struct _GtkLabel *lbl_https_host;
 	struct _GtkLabel *lbl_https_port;
-	struct _GtkLabel *lbl_socks_host;
-	struct _GtkLabel *lbl_socks_port;	
 	struct _GtkLabel *lbl_ignore_hosts;
 	struct _GtkLabel *lbl_auth_user;
 	struct _GtkLabel *lbl_auth_pwd;
 
 	struct _GtkSpinButton *http_port;
 	struct _GtkSpinButton *https_port;
-	struct _GtkSpinButton *socks_port;	
+#if 0
+	struct _GtkLabel *lbl_socks_host;
+	struct _GtkEntry *socks_host;
+	struct _GtkLabel *lbl_socks_port;
+	struct _GtkSpinButton *socks_port;
+#endif
 };
 
 struct _EMNetworkPrefsClass {

Modified: trunk/mail/em-utils.c
==============================================================================
--- trunk/mail/em-utils.c	(original)
+++ trunk/mail/em-utils.c	Mon Feb  9 10:59:29 2009
@@ -65,6 +65,7 @@
 
 #include <libedataserver/e-data-server-util.h>
 #include <libedataserver/e-flag.h>
+#include <libedataserver/e-proxy.h>
 #include "e-util/e-util.h"
 #include "e-util/e-util-private.h"
 #include "e-util/e-mktemp.h"
@@ -1552,62 +1553,17 @@
 }
 
 /* ********************************************************************** */
-static char *emu_proxy_uri;
-static int emu_proxy_init = 0;
-static pthread_mutex_t emu_proxy_lock = PTHREAD_MUTEX_INITIALIZER;
-
-static void
-emu_set_proxy(GConfClient *client, int needlock)
-{
-	char *server, *uri = NULL;
-	int port;
-
-	if (gconf_client_get_bool(client, "/system/http_proxy/use_http_proxy", NULL)) {
-		server = gconf_client_get_string(client, "/system/http_proxy/host", NULL);
-		port = gconf_client_get_int(client, "/system/http_proxy/port", NULL);
-
-		if (server && server[0]) {
-			if (gconf_client_get_bool(client, "/system/http_proxy/use_authentication", NULL)) {
-				char *user = gconf_client_get_string(client, "/system/http_proxy/authentication_user", NULL);
-				char *pass = gconf_client_get_string(client, "/system/http_proxy/authentication_password", NULL);
-
-				uri = g_strdup_printf("http://%s:%s %s:%d", user, pass, server, port);
-				g_free(user);
-				g_free(pass);
-			} else {
-				uri = g_strdup_printf("http://%s:%d";, server, port);
-			}
-		}
-
-		g_free(server);
-	}
-
-	if (needlock)
-		pthread_mutex_lock(&emu_proxy_lock);
-
-	g_free(emu_proxy_uri);
-	emu_proxy_uri = uri;
-
-	if (needlock)
-		pthread_mutex_unlock(&emu_proxy_lock);
-
-}
-
-static void
-emu_proxy_changed(GConfClient *client, guint32 cnxn_id, GConfEntry *entry, gpointer user_data)
-{
-	emu_set_proxy(client, TRUE);
-}
+static EProxy *emu_proxy = NULL;
+static GStaticMutex emu_proxy_lock = G_STATIC_MUTEX_INIT;
 
 static void *
-emu_proxy_setup(void *data)
+emu_proxy_setup (void *data)
 {
-	GConfClient *client = gconf_client_get_default();
-
-	gconf_client_add_dir(client, "/system/http_proxy", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
-	gconf_client_notify_add(client, "/system/http_proxy", emu_proxy_changed, NULL, NULL, NULL);
-	emu_set_proxy(client, FALSE);
-	g_object_unref(client);
+	if (!emu_proxy) {
+		emu_proxy = e_proxy_new ();
+		e_proxy_setup_proxy (emu_proxy);
+		/* not necessary to listen for changes here */
+	}
 
 	return NULL;
 }
@@ -1615,25 +1571,25 @@
 /**
  * em_utils_get_proxy_uri:
  *
- * Get the system proxy uri.
+ * Get the system proxy uri for 'pUri'.
  *
  * Return value: Must be freed when finished with.
  **/
 char *
-em_utils_get_proxy_uri(void)
+em_utils_get_proxy_uri (const char *pUri)
 {
-	char *uri;
+	char *uri = NULL;
 
-	pthread_mutex_lock(&emu_proxy_lock);
+	g_static_mutex_lock (&emu_proxy_lock);
 
-	if (!emu_proxy_init) {
-		mail_call_main(MAIL_CALL_p_p, (MailMainFunc)emu_proxy_setup, NULL);
-		emu_proxy_init = TRUE;
+	if (!emu_proxy) {
+		mail_call_main (MAIL_CALL_p_p, (MailMainFunc)emu_proxy_setup, NULL);
 	}
 
-	uri = g_strdup(emu_proxy_uri);
+	if (e_proxy_require_proxy_for_uri (emu_proxy, pUri))
+		uri = soup_uri_to_string (e_proxy_peek_uri_for (emu_proxy, pUri), FALSE);
 
-	pthread_mutex_unlock(&emu_proxy_lock);
+	g_static_mutex_unlock (&emu_proxy_lock);
 
 	return uri;
 }

Modified: trunk/mail/em-utils.h
==============================================================================
--- trunk/mail/em-utils.h	(original)
+++ trunk/mail/em-utils.h	Mon Feb  9 10:59:29 2009
@@ -88,7 +88,7 @@
 
 void em_utils_adjustment_page(struct _GtkAdjustment *adj, gboolean down);
 
-char *em_utils_get_proxy_uri(void);
+char *em_utils_get_proxy_uri (const char *uri);
 
 /* FIXME: should this have an override charset? */
 char *em_utils_part_to_html(struct _CamelMimePart *part, ssize_t *len, struct _EMFormat *source);

Modified: trunk/mail/mail-config.glade
==============================================================================
--- trunk/mail/mail-config.glade	(original)
+++ trunk/mail/mail-config.glade	Mon Feb  9 10:59:29 2009
@@ -9329,7 +9329,7 @@
 				</packing>
 			      </child>
 
-			      <child>
+			      <!--<child>
 				<widget class="GtkLabel" id="lblSocksHost">
 				  <property name="visible">True</property>
 				  <property name="label" translatable="yes">S_OCKS Host:</property>
@@ -9356,7 +9356,7 @@
 				  <property name="x_options">fill</property>
 				  <property name="y_options"></property>
 				</packing>
-			      </child>
+			      </child>-->
 
 			      <child>
 				<widget class="GtkLabel" id="lblIgnoreHosts">
@@ -9429,7 +9429,7 @@
 				</packing>
 			      </child>
 
-			      <child>
+			      <!--<child>
 				<widget class="GtkEntry" id="txtSocksHost">
 				  <property name="visible">True</property>
 				  <property name="can_focus">True</property>
@@ -9448,7 +9448,7 @@
 				  <property name="bottom_attach">3</property>
 				  <property name="y_options"></property>
 				</packing>
-			      </child>
+			      </child>-->
 
 			      <child>
 				<widget class="GtkLabel" id="lblHttpPort">
@@ -9506,7 +9506,7 @@
 				</packing>
 			      </child>
 
-			      <child>
+			      <!--<child>
 				<widget class="GtkLabel" id="lblSocksPort">
 				  <property name="visible">True</property>
 				  <property name="label" translatable="yes">Port:</property>
@@ -9532,7 +9532,7 @@
 				  <property name="x_options">fill</property>
 				  <property name="y_options"></property>
 				</packing>
-			      </child>
+			      </child>-->
 
 			      <child>
 				<widget class="GtkSpinButton" id="spnHttpPort">
@@ -9576,7 +9576,7 @@
 				</packing>
 			      </child>
 
-			      <child>
+			      <!--<child>
 				<widget class="GtkSpinButton" id="spnSocksPort">
 				  <property name="visible">True</property>
 				  <property name="can_focus">True</property>
@@ -9595,7 +9595,7 @@
 				  <property name="bottom_attach">3</property>
 				  <property name="y_options"></property>
 				</packing>
-			      </child>
+			      </child>-->
 
 			      <child>
 				<widget class="GtkEntry" id="txtIgnoreHosts">



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]