Index: ChangeLog
===================================================================
--- ChangeLog	(revision 10036)
+++ ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2009-02-06  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #555888
+
+	* libedataserver/e-proxy.h:
+	* libedataserver/e-proxy.c:
+	Read system proxy setting directly and listen to their changes.
+	EProxy API changed, use e_proxy_peek_uri_for now.
+
 2009-02-05  Suman Manjunath  <msuman@novell.com>
 
 	* configure.in: Expose the right CFLAGS for libical headers. We want
Index: servers/exchange/lib/e2k-context.c
===================================================================
--- servers/exchange/lib/e2k-context.c	(revision 10036)
+++ servers/exchange/lib/e2k-context.c	(working copy)
@@ -145,7 +145,7 @@ proxy_settings_changed (EProxy *proxy, g
 	if (!e_proxy_require_proxy_for_uri (proxy, ctx->priv->owa_uri))
 		proxy_uri = NULL;
 	else
-		proxy_uri = e_proxy_peek_uri (proxy);
+		proxy_uri = e_proxy_peek_uri_for (proxy, ctx->priv->owa_uri);
 
 	if (ctx->priv->session)
 		g_object_set (ctx->priv->session, SOUP_SESSION_PROXY_URI,
@@ -436,7 +436,7 @@ e2k_context_set_auth (E2kContext *ctx, c
 
 	/* Check do we need a proxy to contact the server? */
         if (e_proxy_require_proxy_for_uri (ctx->priv->proxy, ctx->priv->owa_uri))
-                uri = e_proxy_peek_uri (ctx->priv->proxy);
+                uri = e_proxy_peek_uri_for (ctx->priv->proxy, ctx->priv->owa_uri);
 
 	ctx->priv->session = soup_session_sync_new_with_options (
 		SOUP_SESSION_USE_NTLM, !authmech || !strcmp (authmech, "NTLM"),
Index: servers/exchange/ChangeLog
===================================================================
--- servers/exchange/ChangeLog	(revision 10036)
+++ servers/exchange/ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2009-02-06  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #555888
+
+	* lib/e2k-context.c: (proxy_settings_changed), (e2k_context_set_auth):
+	EProxy API changed, use e_proxy_peek_uri_for now.
+
 2009-01-14  Matthew Barnes  <mbarnes@redhat.com>
 
 	** Fixes part of bug #564543
Index: servers/groupwise/ChangeLog
===================================================================
--- servers/groupwise/ChangeLog	(revision 10036)
+++ servers/groupwise/ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2009-02-06  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #555888
+
+	* e-gw-connection.c: (update_soup_session_proxy_settings):
+	EProxy API changed, use e_proxy_peek_uri_for now.
+
 2009-02-04  Sankar P  <psankar@novell.com>
 
 	* servers/groupwise/e-gw-connection.c:
Index: servers/groupwise/e-gw-connection.c
===================================================================
--- servers/groupwise/e-gw-connection.c	(revision 10036)
+++ servers/groupwise/e-gw-connection.c	(working copy)
@@ -75,7 +75,7 @@ update_soup_session_proxy_settings (EPro
 		return;
 	
 	if (e_proxy_require_proxy_for_uri (proxy, uri))
-		proxy_uri = e_proxy_peek_uri (proxy);
+		proxy_uri = e_proxy_peek_uri_for (proxy, uri);
 
 	g_object_set (session, SOUP_SESSION_PROXY_URI,
 		      proxy_uri, NULL);	
Index: libedataserver/e-proxy.c
===================================================================
--- libedataserver/e-proxy.c	(revision 10036)
+++ libedataserver/e-proxy.c	(working copy)
@@ -48,27 +48,55 @@
 /* Debug */
 #define d(x)
 
+enum ProxyType {
+	PROXY_TYPE_SYSTEM = 0,
+	PROXY_TYPE_NO_PROXY,
+	PROXY_TYPE_MANUAL,
+	PROXY_TYPE_AUTO_URL /* no auto-proxy at the moment */
+};
+
 /* GConf paths and keys */
-#define PATH_GCONF_NETWORK_CONFIG "/apps/evolution/shell/network_config"
-#define KEY_GCONF_HTTP_PROXY_PORT (PATH_GCONF_NETWORK_CONFIG "/" "http_port")
-#define KEY_GCONF_HTTP_PROXY_HOST (PATH_GCONF_NETWORK_CONFIG "/" "http_host")
-#define KEY_GCONF_HTTPS_PROXY_PORT (PATH_GCONF_NETWORK_CONFIG "/" "secure_port")
-#define KEY_GCONF_HTTPS_PROXY_HOST (PATH_GCONF_NETWORK_CONFIG "/" "secure_host")
-#define KEY_GCONF_SOCKS_PROXY_PORT (PATH_GCONF_NETWORK_CONFIG "/" "socks_port")
-#define KEY_GCONF_SOCKS_PROXY_HOST (PATH_GCONF_NETWORK_CONFIG "/" "socks_host")
-#define KEY_GCONF_USE_HTTP_PROXY (PATH_GCONF_NETWORK_CONFIG "/" "use_http_proxy")
-#define KEY_GCONF_HTTP_AUTH_USER (PATH_GCONF_NETWORK_CONFIG "/" "authentication_user")
-#define KEY_GCONF_HTTP_AUTH_PW   (PATH_GCONF_NETWORK_CONFIG "/" "authentication_password")
-#define KEY_GCONF_HTTP_USE_AUTH (PATH_GCONF_NETWORK_CONFIG "/" "use_authentication")
+#define PATH_GCONF_EVO_NETWORK_CONFIG "/apps/evolution/shell/network_config"
+#define KEY_GCONF_EVO_PROXY_TYPE       PATH_GCONF_EVO_NETWORK_CONFIG "/proxy_type"
+
+#define KEY_GCONF_EVO_USE_HTTP_PROXY    PATH_GCONF_EVO_NETWORK_CONFIG "/use_http_proxy"
+#define KEY_GCONF_EVO_HTTP_HOST         PATH_GCONF_EVO_NETWORK_CONFIG "/http_host"
+#define KEY_GCONF_EVO_HTTP_PORT         PATH_GCONF_EVO_NETWORK_CONFIG "/http_port"
+#define KEY_GCONF_EVO_HTTP_USE_AUTH     PATH_GCONF_EVO_NETWORK_CONFIG "/use_authentication"
+#define KEY_GCONF_EVO_HTTP_AUTH_USER    PATH_GCONF_EVO_NETWORK_CONFIG "/authentication_user"
+#define KEY_GCONF_EVO_HTTP_AUTH_PWD     PATH_GCONF_EVO_NETWORK_CONFIG "/authentication_password"
+#define KEY_GCONF_EVO_HTTP_IGNORE_HOSTS PATH_GCONF_EVO_NETWORK_CONFIG "/ignore_hosts"
+#define KEY_GCONF_EVO_HTTPS_HOST        PATH_GCONF_EVO_NETWORK_CONFIG "/secure_host"
+#define KEY_GCONF_EVO_HTTPS_PORT        PATH_GCONF_EVO_NETWORK_CONFIG "/secure_port"
+#define KEY_GCONF_EVO_SOCKS_HOST        PATH_GCONF_EVO_NETWORK_CONFIG "/socks_host"
+#define KEY_GCONF_EVO_SOCKS_PORT        PATH_GCONF_EVO_NETWORK_CONFIG "/socks_port"
+#define KEY_GCONF_EVO_AUTOCONFIG_URL    PATH_GCONF_EVO_NETWORK_CONFIG "/autoconfig_url"
+
+#define PATH_GCONF_SYS_PROXY "/system/proxy"
+#define PATH_GCONF_SYS_HTTP_PROXY "/system/http_proxy"
+
+#define KEY_GCONF_SYS_USE_HTTP_PROXY    PATH_GCONF_SYS_HTTP_PROXY "/use_http_proxy"
+#define KEY_GCONF_SYS_HTTP_HOST         PATH_GCONF_SYS_HTTP_PROXY "/host"
+#define KEY_GCONF_SYS_HTTP_PORT         PATH_GCONF_SYS_HTTP_PROXY "/port"
+#define KEY_GCONF_SYS_HTTP_USE_AUTH     PATH_GCONF_SYS_HTTP_PROXY "/use_authentication"
+#define KEY_GCONF_SYS_HTTP_AUTH_USER    PATH_GCONF_SYS_HTTP_PROXY "/authentication_user"
+#define KEY_GCONF_SYS_HTTP_AUTH_PWD     PATH_GCONF_SYS_HTTP_PROXY "/authentication_password"
+#define KEY_GCONF_SYS_HTTP_IGNORE_HOSTS PATH_GCONF_SYS_HTTP_PROXY "/ignore_hosts"
+#define KEY_GCONF_SYS_HTTPS_HOST        PATH_GCONF_SYS_PROXY "/secure_host"
+#define KEY_GCONF_SYS_HTTPS_PORT        PATH_GCONF_SYS_PROXY "/secure_port"
+#define KEY_GCONF_SYS_SOCKS_HOST        PATH_GCONF_SYS_PROXY "/socks_host"
+#define KEY_GCONF_SYS_SOCKS_PORT        PATH_GCONF_SYS_PROXY "/socks_port"
+#define KEY_GCONF_SYS_AUTOCONFIG_URL    PATH_GCONF_SYS_PROXY "/autoconfig_url"
 
-#define KEY_GCONF_HTTP_PROXY_IGNORE_HOSTS (PATH_GCONF_NETWORK_CONFIG "/" "ignore_hosts")
+#define RIGHT_KEY(sufix) (priv->type == PROXY_TYPE_SYSTEM ? KEY_GCONF_SYS_ ## sufix : KEY_GCONF_EVO_ ## sufix)
 
 struct _EProxyPrivate {
-	SoupURI* uri;
-	guint notify_id; 	/* conxn id of gconf_client_notify_add  */
+	SoupURI *uri_http, *uri_https;
+	guint notify_id_evo, notify_id_sys, notify_id_sys_http; /* conxn id of gconf_client_notify_add  */
 	GSList* ign_hosts;	/* List of hostnames. (Strings)		*/
 	GSList* ign_addrs;	/* List of hostaddrs. (ProxyHostAddrs)	*/
-	gboolean use_proxy;	/* Is system-proxy enabled? */
+	gboolean use_proxy;	/* Is our-proxy enabled? */
+	enum ProxyType type;
 };
 
 /* Enum definition is copied from gnome-vfs/modules/http-proxy.c */
@@ -158,9 +186,13 @@ e_proxy_init (EProxy *pxy, EProxyClass *
 	pxy->priv = priv;
 	priv->ign_hosts = NULL;
 	priv->ign_addrs = NULL;
-	priv->uri = NULL;
-	priv->notify_id = 0;
+	priv->uri_http = NULL;
+	priv->uri_https = NULL;
+	priv->notify_id_evo = 0;
+	priv->notify_id_sys = 0;
+	priv->notify_id_sys_http = 0;
 	priv->use_proxy = FALSE;
+	priv->type = PROXY_TYPE_SYSTEM;
 }
 
 static void
@@ -178,13 +210,19 @@ e_proxy_dispose (GObject *object)
 		GConfClient* client = NULL;
 
 		if ((client = gconf_client_get_default ())) {
-			if (priv->notify_id > 0)
-				gconf_client_notify_remove (client, priv->notify_id);
+			if (priv->notify_id_evo > 0)
+				gconf_client_notify_remove (client, priv->notify_id_evo);
+			if (priv->notify_id_sys > 0)
+				gconf_client_notify_remove (client, priv->notify_id_sys);
+			if (priv->notify_id_sys_http > 0)
+				gconf_client_notify_remove (client, priv->notify_id_sys_http);
 			g_object_unref (client);
 		}
 
-		if (priv->uri)
-			soup_uri_free (priv->uri);
+		if (priv->uri_http)
+			soup_uri_free (priv->uri_http);
+		if (priv->uri_https)
+			soup_uri_free (priv->uri_https);
 
 		if (priv->ign_hosts) {
 			g_slist_foreach (priv->ign_hosts, (GFunc) ep_free_proxy_host_addr, NULL);
@@ -196,7 +234,9 @@ e_proxy_dispose (GObject *object)
 			g_slist_free (priv->ign_addrs);
 		}
 		
-		priv->notify_id = 0;
+		priv->notify_id_evo = 0;
+		priv->notify_id_sys = 0;
+		priv->notify_id_sys_http = 0;
 		
 		g_free (priv);
 		priv = NULL;
@@ -226,7 +266,39 @@ e_proxy_get_type (void)
 }
 
 static gboolean
-ep_need_proxy (EProxy* proxy, const char* host)
+ep_is_in_ignored (EProxy *proxy, const char *host)
+{
+	EProxyPrivate *priv;
+	GSList* l;
+	gchar *hn;
+
+	g_return_val_if_fail (proxy != NULL, FALSE);
+	g_return_val_if_fail (host != NULL, FALSE);
+
+	priv = proxy->priv;
+	if (!priv->ign_hosts)
+		return FALSE;
+
+	hn = g_ascii_strdown (host, -1);
+		
+	for (l = priv->ign_hosts; l; l = l->next) {
+		if (*((gchar *)l->data) == '*') {
+			if (g_str_has_suffix (hn, ((gchar *)l->data)+1)) {
+				g_free (hn);
+				return TRUE;
+			}
+		} else if (strcmp (hn, l->data) == 0) {
+				g_free (hn);
+				return TRUE;
+		}
+	}
+	g_free (hn);
+
+	return FALSE;
+}
+
+static gboolean
+ep_need_proxy_http (EProxy* proxy, const char* host)
 {
 	SoupAddress *addr = NULL;
 	EProxyPrivate *priv = proxy->priv;
@@ -234,6 +306,10 @@ ep_need_proxy (EProxy* proxy, const char
 	GSList *l;
 	guint status;
 
+	/* check for ignored first */
+	if (ep_is_in_ignored (proxy, host))
+		return FALSE;
+
 	addr = soup_address_new (host, 0);
 	status = soup_address_resolve_sync (addr, NULL);
 	if (status == SOUP_STATUS_OK) {
@@ -296,29 +372,20 @@ ep_need_proxy (EProxy* proxy, const char
 				}
 			}
 		}
-	} else {
-		GSList* l;
-		gchar* hn = g_ascii_strdown (host, -1);
-		
-		for (l = priv->ign_hosts; l; l = l->next) {
-			if (*((gchar *)l->data) == '*') {
-				if (g_str_has_suffix (hn, ((gchar *)l->data)+1)) {
-					g_free (hn);
-					return FALSE;
-				}
-			} else if (strcmp (hn, l->data) == 0) {
-					g_free (hn);
-					return FALSE;
-			}
-		}
-		g_free (hn);
 	}
-
+	
 	d(g_print ("%s needs a proxy to connect to internet\n", host));
 	return TRUE;
 }
 
 static gboolean
+ep_need_proxy_https (EProxy* proxy, const char* host)
+{
+	/* Can we share ignore list from HTTP at all? */
+	return !ep_is_in_ignored (proxy, host);
+}
+
+static gboolean
 ep_manipulate_ipv4 (ProxyHostAddr *host_addr, 
 		    struct in_addr *addr_in, 
 		    gchar* netmask)
@@ -475,112 +542,169 @@ ep_parse_ignore_host (gpointer data, gpo
 	g_object_unref (addr);
 }
 
+static gboolean
+ep_change_uri (SoupURI **soup_uri, const char *uri)
+{
+	gboolean changed = FALSE;
+
+	g_return_val_if_fail (soup_uri != NULL, FALSE);
+
+	if (!uri || !*uri) {
+		if (*soup_uri) {
+			soup_uri_free (*soup_uri);
+			*soup_uri = NULL;
+			changed = TRUE;
+		}			
+	} else if (*soup_uri) {
+		char *old = soup_uri_to_string (*soup_uri, FALSE);
+
+		changed = old && uri && g_ascii_strcasecmp (old, uri) != 0;
+		if (changed) {
+			soup_uri_free (*soup_uri);
+			*soup_uri = soup_uri_new (uri);
+		}
+
+		g_free (old);
+	} else {
+		*soup_uri = soup_uri_new (uri);
+		changed = TRUE;
+	}
+
+	return changed;
+}
+
 static void
 ep_set_proxy (GConfClient *client, 
 	      gpointer user_data, 
-	      gboolean regen_ign_host_list,
-	      gboolean set_auth)
+	      gboolean regen_ign_host_list)
 {
-	char *proxy_server = NULL, *proxy_user = NULL, *proxy_pw = NULL, *uri = NULL;
-	gboolean use_auth;
-	int proxy_port;
+	char *proxy_server, *uri_http = NULL, *uri_https = NULL;
+	int proxy_port, old_type;
 	EProxy* proxy = (EProxy *)user_data;
 	EProxyPrivate* priv = proxy->priv;
 	GSList *ignore;
+	gboolean changed = FALSE;
 
-	priv->use_proxy = gconf_client_get_bool (client, KEY_GCONF_USE_HTTP_PROXY, NULL);
-	if (priv->use_proxy == FALSE) {
-		if (priv->uri) {
-			soup_uri_free (priv->uri);
-			priv->uri = NULL;
-		}
+	old_type = priv->type;
+	priv->type = gconf_client_get_int (client, KEY_GCONF_EVO_PROXY_TYPE, NULL);
+	if (priv->type < PROXY_TYPE_SYSTEM || priv->type > PROXY_TYPE_AUTO_URL)
+		priv->type = PROXY_TYPE_SYSTEM;
+	changed = priv->type != old_type;
+
+	priv->use_proxy = gconf_client_get_bool (client, RIGHT_KEY (USE_HTTP_PROXY), NULL);
+	if (!priv->use_proxy || priv->type == PROXY_TYPE_NO_PROXY) {
+		changed = ep_change_uri (&priv->uri_http, NULL) || changed;
+		changed = ep_change_uri (&priv->uri_https, NULL) || changed;
 		goto emit_signal;
 	}
-	
-	proxy_server = gconf_client_get_string (client, KEY_GCONF_HTTP_PROXY_HOST, NULL);
-	proxy_port = gconf_client_get_int (client, KEY_GCONF_HTTP_PROXY_PORT, NULL);
-	uri = g_strdup_printf ("http://%s:%d", proxy_server, proxy_port);
-	d(g_print ("ep_set_proxy: uri: %s\n", uri));
 
-	if (regen_ign_host_list) {		
+	proxy_server = gconf_client_get_string (client, RIGHT_KEY (HTTP_HOST), NULL);
+	proxy_port = gconf_client_get_int (client, RIGHT_KEY (HTTP_PORT), NULL);
+	uri_http = g_strdup_printf ("http://%s:%d", proxy_server, proxy_port);
+	g_free (proxy_server);
+	d(g_print ("ep_set_proxy: uri_http: %s\n", uri_http));
+
+	proxy_server = gconf_client_get_string (client, RIGHT_KEY (HTTPS_HOST), NULL);
+	proxy_port = gconf_client_get_int (client, RIGHT_KEY (HTTPS_PORT), NULL);
+	uri_https = g_strdup_printf ("https://%s:%d", proxy_server, proxy_port);
+	g_free (proxy_server);
+	d(g_print ("ep_set_proxy: uri_http: %s\n", uri_http));
+
+	if (regen_ign_host_list) {
 		if (priv->ign_hosts) {
 			g_slist_foreach (priv->ign_hosts, (GFunc) g_free, NULL);
 			g_slist_free (priv->ign_hosts);
 			priv->ign_hosts = NULL;
 		}
-		
+
 		if (priv->ign_addrs) {
 			g_slist_foreach (priv->ign_addrs, (GFunc) g_free, NULL);
 			g_slist_free (priv->ign_addrs);
 			priv->ign_addrs = NULL;
 		}
 
-		ignore = gconf_client_get_list (client, KEY_GCONF_HTTP_PROXY_IGNORE_HOSTS, 
-						GCONF_VALUE_STRING, NULL);
+		ignore = gconf_client_get_list (client, RIGHT_KEY (HTTP_IGNORE_HOSTS), GCONF_VALUE_STRING, NULL);
 		if (ignore) {
 			g_slist_foreach (ignore, (GFunc) ep_parse_ignore_host, proxy);
-			g_slist_foreach (ignore, (GFunc) g_free, NULL);	
+			g_slist_foreach (ignore, (GFunc) g_free, NULL);
 			g_slist_free (ignore);
 		}
-	} else if (set_auth) {
-	
-		use_auth = gconf_client_get_bool (client, KEY_GCONF_HTTP_USE_AUTH, NULL);
-		if (use_auth == TRUE) {
-			proxy_user = gconf_client_get_string (client, KEY_GCONF_HTTP_AUTH_USER, NULL);
-			proxy_pw = gconf_client_get_string (client, KEY_GCONF_HTTP_AUTH_PW, NULL);
-		
-			if (uri)
-				g_free (uri);
-
-			uri = g_strdup_printf ("http://%s:%s@%s:%d", proxy_user, proxy_pw, proxy_server, proxy_port);
-		} 
 	}
 
-	if (priv->uri) {
-		soup_uri_free (priv->uri);
-		priv->uri = NULL;
+	if (gconf_client_get_bool (client, RIGHT_KEY (HTTP_USE_AUTH), NULL)) {
+		char *proxy_user, *proxy_pw, *tmp;
+
+		proxy_user = gconf_client_get_string (client, RIGHT_KEY (HTTP_AUTH_USER), NULL);
+		proxy_pw = gconf_client_get_string (client, RIGHT_KEY (HTTP_AUTH_PWD), NULL);
+
+		tmp = uri_http;
+
+		uri_http = g_strdup_printf ("http://%s:%s@%s", proxy_user, proxy_pw, tmp + strlen ("http://"));
+
+		g_free (proxy_user);
+		g_free (proxy_pw);
+		g_free (tmp);
 	}
-	
-	if (uri)
-		priv->uri = soup_uri_new (uri);
-	d(g_print ("system-proxy: uri: %s\n", uri));
 
- emit_signal:	
-	g_signal_emit (proxy, signals[CHANGED], 0);
+	changed = ep_change_uri (&priv->uri_http, uri_http) || changed;
+	changed = ep_change_uri (&priv->uri_https, uri_https) || changed;
+	d(g_print ("system-proxy: uri_http: %s; uri_https: %s\n", uri_http ? uri_http : "[null]", uri_https ? uri_https : "[null]"));
 
-	g_free (uri);
+ emit_signal:
+	if (changed)
+		g_signal_emit (proxy, signals[CHANGED], 0);
+
+	g_free (uri_http);
+	g_free (uri_https);
 
 	return;
 }
 
 static void
-ep_setting_changed (GConfClient *client, guint32 cnxn_id,
-		       GConfEntry *entry, gpointer user_data)
+ep_setting_changed (GConfClient *client, guint32 cnxn_id, GConfEntry *entry, gpointer user_data)
 {
-    const char *key;
-    EProxy* proxy = (EProxy *)user_data;
+	const char *key;
+	EProxy* proxy = (EProxy *)user_data;
+	EProxyPrivate *priv;
 
-    if (!proxy || !proxy->priv)
-	    return;
+	if (!proxy || !proxy->priv)
+		return;
 
-    key = gconf_entry_get_key(entry);
-
-    if (strcmp(key, KEY_GCONF_USE_HTTP_PROXY) == 0
-        || strcmp(key, KEY_GCONF_HTTP_PROXY_IGNORE_HOSTS) == 0
-        || strcmp(key, KEY_GCONF_HTTP_PROXY_HOST) == 0
-        || strcmp(key, KEY_GCONF_HTTP_PROXY_PORT) == 0) {
-	    gboolean regen_ign_host_list = FALSE;
-
-	    if (strcmp(key, KEY_GCONF_HTTP_PROXY_IGNORE_HOSTS) == 0)
-		    regen_ign_host_list = TRUE;
-	    ep_set_proxy (client, user_data, regen_ign_host_list, FALSE);
-	    d(g_print ("e-proxy.c:ep_settings_changed: proxy settings changed\n"));
-    } else if (strcmp(key, KEY_GCONF_HTTP_AUTH_USER) == 0
-               || strcmp(key, KEY_GCONF_HTTP_AUTH_PW) == 0
-               || strcmp(key, KEY_GCONF_HTTP_USE_AUTH) == 0) {
-	    ep_set_proxy (client, user_data, FALSE, TRUE);
-	    d(g_print ("e-proxy.c:ep_settings_changed: auth settings changed\n"));	    
-    }
+	priv = proxy->priv;
+	key = gconf_entry_get_key (entry);
+
+	if (g_str_equal (key, KEY_GCONF_EVO_PROXY_TYPE)) {
+		ep_set_proxy (client, user_data, FALSE);
+		d(g_print ("e-proxy.c:ep_settings_changed: proxy type changed\n"));
+	} else if (g_str_equal (key, RIGHT_KEY (USE_HTTP_PROXY)) ||
+		   g_str_equal (key, RIGHT_KEY (HTTP_IGNORE_HOSTS)) ||
+		   g_str_equal (key, RIGHT_KEY (HTTP_HOST)) ||
+		   g_str_equal (key, RIGHT_KEY (HTTP_PORT))) {
+		gboolean regen_ign_host_list = FALSE;
+
+		if (g_str_equal (key, RIGHT_KEY (HTTP_IGNORE_HOSTS)))
+			regen_ign_host_list = TRUE;
+
+		ep_set_proxy (client, user_data, regen_ign_host_list);
+		d(g_print ("e-proxy.c:ep_settings_changed: proxy settings changed\n"));
+	} else if (g_str_equal (key, RIGHT_KEY (HTTP_AUTH_USER)) ||
+		   g_str_equal (key, RIGHT_KEY (HTTP_AUTH_PWD)) ||
+		   g_str_equal (key, RIGHT_KEY (HTTP_USE_AUTH))) {
+
+		ep_set_proxy (client, user_data, FALSE);
+		d(g_print ("e-proxy.c:ep_settings_changed: auth settings changed\n"));
+	} else if (g_str_equal (key, RIGHT_KEY (HTTPS_HOST)) ||
+		   g_str_equal (key, RIGHT_KEY (HTTPS_PORT))) {
+
+		ep_set_proxy (client, user_data, FALSE);
+		d(g_print ("e-proxy.c:ep_settings_changed: https\n"));
+	} else if (g_str_equal (key, RIGHT_KEY (SOCKS_HOST)) ||
+		   g_str_equal (key, RIGHT_KEY (SOCKS_PORT)) ||
+		   g_str_equal (key, RIGHT_KEY (AUTOCONFIG_URL))) {
+
+		/* ep_set_proxy (client, user_data, FALSE); */
+		d(g_print ("e-proxy.c:ep_settings_changed: socks/autoconf-url changed\n"));
+	}
 }
 
 EProxy* 
@@ -608,27 +732,45 @@ e_proxy_setup_proxy (EProxy* proxy)
 	if (!proxy || !proxy->priv)
 		return;
 
-	/* Listen to the changes in the evolution-shell path */
-	gconf_client_add_dir (client, PATH_GCONF_NETWORK_CONFIG,
-			      GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
-
-	if (proxy->priv->notify_id == 0)
-		proxy->priv->notify_id = gconf_client_notify_add (client, PATH_GCONF_NETWORK_CONFIG,
-								  ep_setting_changed, (gpointer)proxy, 
-								  NULL, NULL);
-	
-	ep_set_proxy (client, proxy, TRUE, TRUE);
+	if (proxy->priv->notify_id_evo == 0) {
+		/* Listen to the changes in the evolution-shell path */
+		gconf_client_add_dir (client, PATH_GCONF_EVO_NETWORK_CONFIG, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+		/* and system proxy setup changes */
+		gconf_client_add_dir (client, PATH_GCONF_SYS_PROXY, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+		gconf_client_add_dir (client, PATH_GCONF_SYS_HTTP_PROXY, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+
+		proxy->priv->notify_id_evo = gconf_client_notify_add (client, PATH_GCONF_EVO_NETWORK_CONFIG,
+								      ep_setting_changed, (gpointer)proxy, 
+								      NULL, NULL);
+		proxy->priv->notify_id_sys = gconf_client_notify_add (client, PATH_GCONF_SYS_PROXY,
+								      ep_setting_changed, (gpointer)proxy, 
+								      NULL, NULL);
+		proxy->priv->notify_id_sys_http = gconf_client_notify_add (client, PATH_GCONF_SYS_HTTP_PROXY,
+								      ep_setting_changed, (gpointer)proxy, 
+								      NULL, NULL);
+	}
+
+	ep_set_proxy (client, proxy, TRUE);
 
 	g_object_unref (client);
 }
 
 SoupURI*
-e_proxy_peek_uri (EProxy* proxy)
+e_proxy_peek_uri_for (EProxy* proxy, const char *uri)
 {
-	if (!proxy || !proxy->priv)
+	SoupURI *suri;
+
+	if (!proxy || !proxy->priv || !uri || !*uri)
 		return NULL;
-	
-	return proxy->priv->uri;
+
+	suri = soup_uri_new (uri);
+	g_return_val_if_fail (suri != NULL, NULL);
+
+	if (suri->scheme == SOUP_URI_SCHEME_HTTPS) {
+		return proxy->priv->uri_https;
+	}
+
+	return proxy->priv->uri_http;
 }
 
 gboolean
@@ -640,16 +782,22 @@ e_proxy_require_proxy_for_uri (EProxy* p
 	if (!uri || !proxy || !proxy->priv)
 		return ret;
 
-	if (!proxy->priv->use_proxy) {
+	if (!proxy->priv->use_proxy || proxy->priv->type == PROXY_TYPE_NO_PROXY) {
 		d(g_print ("[%s] don't need a proxy to connect to internet\n", uri));
 		return ret;
 	}
 
 	srv_uri = soup_uri_new (uri);
-	
-	ret = ep_need_proxy (proxy, srv_uri->host);
 
-	soup_uri_free (srv_uri);
+	if (srv_uri) {
+		if (srv_uri->scheme == SOUP_URI_SCHEME_HTTPS) {
+			ret = ep_need_proxy_https (proxy, srv_uri->host);
+		} else {
+			ret = ep_need_proxy_http (proxy, srv_uri->host);
+		}
+
+		soup_uri_free (srv_uri);
+	}
 
 	return ret;
 }
Index: libedataserver/e-proxy.h
===================================================================
--- libedataserver/e-proxy.h	(revision 10036)
+++ libedataserver/e-proxy.h	(working copy)
@@ -51,7 +51,7 @@ struct _EProxyClass {
 };
 
 EProxy* e_proxy_new (void);
-SoupURI* e_proxy_peek_uri (EProxy* proxy);
+SoupURI* e_proxy_peek_uri_for (EProxy* proxy, const char *uri);
 void e_proxy_setup_proxy (EProxy* proxy);
 GType e_proxy_get_type (void);
 gboolean e_proxy_require_proxy_for_uri (EProxy *proxy, 
Index: addressbook/ChangeLog
===================================================================
--- addressbook/ChangeLog	(revision 10036)
+++ addressbook/ChangeLog	(working copy)
@@ -1,3 +1,15 @@
+2009-02-06  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #555888
+
+	* backends/webdav/e-book-backend-webdav.c:
+	(struct _EBookBackendWebdavPrivate), (proxy_settings_changed),
+	(e_book_backend_webdav_load_source), (e_book_backend_webdav_dispose):
+	* backends/google/google-book.c (struct _GoogleBookPrivate),
+	(google_book_dispose), (proxy_settings_changed),
+	(google_book_connect_to_google), (google_book_set_offline_mode):
+	Use proxy configurable within Evolution.
+
 2009-01-11  Matthew Barnes  <mbarnes@redhat.com>
 
 	** Fixes part of bug #567384
Index: addressbook/backends/webdav/e-book-backend-webdav.c
===================================================================
--- addressbook/backends/webdav/e-book-backend-webdav.c	(revision 10036)
+++ addressbook/backends/webdav/e-book-backend-webdav.c	(working copy)
@@ -34,6 +34,7 @@
 
 #include <libedataserver/e-url.h> 
 #include <libedataserver/e-flag.h>
+#include <libedataserver/e-proxy.h>
 #include <libebook/e-contact.h>
 #include <libebook/e-address-western.h>
 
@@ -60,6 +61,7 @@ struct _EBookBackendWebdavPrivate {
 	int                mode;
 	gboolean           marked_for_offline;
 	SoupSession       *session;
+	EProxy		  *proxy;
 	gchar             *uri;
 	char              *username;
 	char              *password;
@@ -960,6 +962,23 @@ static void soup_authenticate(SoupSessio
 	}
 }
 
+static void
+proxy_settings_changed (EProxy *proxy, gpointer user_data)
+{
+	SoupURI *proxy_uri = NULL;
+	EBookBackendWebdavPrivate *priv = (EBookBackendWebdavPrivate *) user_data;
+
+	if (!priv || !priv->uri || !priv->session)
+		return;
+
+	/* use proxy if necessary */
+	if (e_proxy_require_proxy_for_uri (proxy, priv->uri)) {
+		proxy_uri = e_proxy_peek_uri_for (proxy, priv->uri);
+	}
+
+	g_object_set (priv->session, SOUP_SESSION_PROXY_URI, proxy_uri, NULL);
+}
+
 static GNOME_Evolution_Addressbook_CallStatus
 e_book_backend_webdav_load_source(EBookBackend *backend,
                                   ESource *source, gboolean only_if_exists)
@@ -1017,6 +1036,10 @@ e_book_backend_webdav_load_source(EBookB
 	                 webdav);
 
 	priv->session = session;
+	priv->proxy = e_proxy_new ();
+	e_proxy_setup_proxy (priv->proxy);
+	g_signal_connect (priv->proxy, "changed", G_CALLBACK (proxy_settings_changed), priv);
+	proxy_settings_changed (priv->proxy, priv);
 
 	e_book_backend_notify_auth_required(backend);
 	e_book_backend_set_is_loaded(backend, TRUE);
@@ -1092,6 +1115,7 @@ e_book_backend_webdav_dispose(GObject *o
 	EBookBackendWebdavPrivate *priv   = webdav->priv;
 
 	g_object_unref(priv->session);
+	g_object_unref (priv->proxy);
 	g_object_unref(priv->cache);
 	g_free(priv->uri);
 	g_free(priv->username);
Index: addressbook/backends/google/google-book.c
===================================================================
--- addressbook/backends/google/google-book.c	(revision 10036)
+++ addressbook/backends/google/google-book.c	(working copy)
@@ -21,6 +21,7 @@
 
 #include <string.h>
 #include <libedata-book/e-book-backend-cache.h>
+#include <libedataserver/e-proxy.h>
 #include <gdata-service-iface.h>
 #include <gdata-google-service.h>
 
@@ -79,6 +80,7 @@ struct _GoogleBookPrivate
 
     gboolean offline;
     GDataService *service;
+    EProxy *proxy;
     guint refresh_interval;
     char *base_uri;
     /* FIXME - this one should not be needed */
@@ -533,6 +535,10 @@ google_book_dispose (GObject *object)
         g_object_unref (priv->service);
         priv->service = NULL;
     }
+    if (priv->proxy) {
+	g_object_unref (priv->proxy);
+	priv->proxy = NULL;
+    }
     google_book_cache_destroy (GOOGLE_BOOK (object));
 
     if (G_OBJECT_CLASS (google_book_parent_class)->dispose)
@@ -726,6 +732,22 @@ google_book_new (const char *username, g
                          NULL);
 }
 
+static void
+proxy_settings_changed (EProxy *proxy, gpointer user_data)
+{
+	SoupURI *proxy_uri = NULL;
+
+	GoogleBookPrivate *priv = (GoogleBookPrivate*) user_data;
+	if (!priv || !priv->base_uri)
+		return;
+
+	/* use proxy if necessary */
+	if (e_proxy_require_proxy_for_uri (proxy, priv->base_uri)) {
+		proxy_uri = e_proxy_peek_uri_for (proxy, priv->base_uri);
+	}
+	gdata_service_set_proxy (GDATA_SERVICE (priv->service), proxy_uri);
+}
+
 gboolean
 google_book_connect_to_google (GoogleBook *book, const char *password, GError **error)
 {
@@ -745,6 +767,12 @@ google_book_connect_to_google (GoogleBoo
     }
 
     service = (GDataService*)gdata_google_service_new ("cp", "evolution-client-0.0.1");
+    priv->proxy = e_proxy_new ();
+    e_proxy_setup_proxy (priv->proxy);
+    priv->service = service;
+    proxy_settings_changed (priv->proxy, priv);
+    priv->service = NULL;
+
     gdata_service_set_credentials (GDATA_SERVICE (service), priv->username, password);
     gdata_google_service_authenticate (GDATA_GOOGLE_SERVICE (service), &soup_error);
 
@@ -752,8 +780,13 @@ google_book_connect_to_google (GoogleBoo
         google_book_error_from_soup_error (soup_error, error,
                                            "Connecting to google failed");
         priv->service = NULL;
+	g_object_unref (service);
+	g_object_unref (priv->proxy);
+	priv->proxy = NULL;
         return FALSE;
     }
+
+    g_signal_connect (priv->proxy, "changed", G_CALLBACK (proxy_settings_changed), priv);
     priv->service = service;
 
     return google_book_cache_refresh_if_needed (book, error);
@@ -770,9 +803,15 @@ google_book_set_offline_mode (GoogleBook
     priv = GET_PRIVATE (book);
 
     priv->offline = offline;
-    if (offline && priv->service) {
-        g_object_unref (priv->service);
-        priv->service = NULL;
+    if (offline) {
+	if (priv->service) {
+		g_object_unref (priv->service);
+		priv->service = NULL;
+	}
+	if (priv->proxy) {
+		g_object_unref (priv->proxy);
+		priv->proxy = NULL;
+	}
     }
     if (offline == FALSE) {
         if (priv->service) {
Index: calendar/ChangeLog
===================================================================
--- calendar/ChangeLog	(revision 10036)
+++ calendar/ChangeLog	(working copy)
@@ -1,3 +1,17 @@
+2009-02-06  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #555888
+
+	* backends/http/e-cal-backend-http.c: (begin_retrieval_cb):
+	* backends/caldav/e-cal-backend-caldav.c: (proxy_settings_changed),
+	(caldav_do_open), (e_cal_backend_caldav_dispose),
+	(e_cal_backend_caldav_init):
+	Use proxy configurable within Evolution.
+
+	* backends/google/e-cal-backend-google.c: (proxy_settings_changed),
+	(e_cal_backend_google_set_uri):
+	EProxy API changed, use e_proxy_peek_uri_for now.
+
 2009-02-05  Suman Manjunath  <msuman@novell.com>
 
 	** Fix for bug #569459
Index: calendar/backends/http/e-cal-backend-http.c
===================================================================
--- calendar/backends/http/e-cal-backend-http.c	(revision 10036)
+++ calendar/backends/http/e-cal-backend-http.c	(working copy)
@@ -27,6 +27,7 @@
 #include <gconf/gconf-client.h>
 #include <glib/gi18n-lib.h>
 #include "libedataserver/e-xml-hash-utils.h"
+#include "libedataserver/e-proxy.h"
 #include <libecal/e-cal-recur.h>
 #include <libecal/e-cal-util.h>
 #include <libecal/e-cal-time-util.h>
@@ -424,9 +425,18 @@ begin_retrieval_cb (ECalBackendHttp *cbh
 
 	priv->is_loading = TRUE;
 
+	if (priv->uri == NULL) {
+		ESource *source = e_cal_backend_get_source (E_CAL_BACKEND (cbhttp));
+		const char *secure_prop = e_source_get_property (source, "use_ssl");
+
+		priv->uri = webcal_to_http_method (e_cal_backend_get_uri (E_CAL_BACKEND (cbhttp)),
+		                                   (secure_prop && g_str_equal(secure_prop, "1")));
+	}
+
 	/* create the Soup session if not already created */
 	if (!priv->soup_session) {
-		GConfClient *conf_client;
+		EProxy *proxy;
+		SoupURI *proxy_uri = NULL;
 
 		priv->soup_session = soup_session_async_new ();
 
@@ -434,51 +444,15 @@ begin_retrieval_cb (ECalBackendHttp *cbh
 				  G_CALLBACK (soup_authenticate), cbhttp);
 
 		/* set the HTTP proxy, if configuration is set to do so */
-		conf_client = gconf_client_get_default ();
-		if (gconf_client_get_bool (conf_client, "/system/http_proxy/use_http_proxy", NULL)) {
-			char *server, *proxy_uri;
-			int port;
-
-			server = gconf_client_get_string (conf_client, "/system/http_proxy/host", NULL);
-			port = gconf_client_get_int (conf_client, "/system/http_proxy/port", NULL);
-
-			if (server && server[0]) {
-				SoupURI *suri;
-				if (gconf_client_get_bool (conf_client, "/system/http_proxy/use_authentication", NULL)) {
-					char *user, *password;
-
-					user = gconf_client_get_string (conf_client,
-									"/system/http_proxy/authentication_user",
-									NULL);
-					password = gconf_client_get_string (conf_client,
-									    "/system/http_proxy/authentication_password",
-									    NULL);
-
-					proxy_uri = g_strdup_printf("http://%s:%s@%s:%d", user, password, server, port);
-
-					g_free (user);
-					g_free (password);
-				} else
-					proxy_uri = g_strdup_printf ("http://%s:%d", server, port);
-
-				suri = soup_uri_new (proxy_uri);
-				g_object_set (G_OBJECT (priv->soup_session), SOUP_SESSION_PROXY_URI, suri, NULL);
-
-				soup_uri_free (suri);
-				g_free (server);
-				g_free (proxy_uri);
-			}
+		proxy = e_proxy_new ();
+		e_proxy_setup_proxy (proxy);
+		if (e_proxy_require_proxy_for_uri (proxy, priv->uri)) {
+			proxy_uri = e_proxy_peek_uri_for (proxy, priv->uri);
 		}
 
-		g_object_unref (conf_client);
-	}
-
-	if (priv->uri == NULL) {
-		ESource *source = e_cal_backend_get_source (E_CAL_BACKEND (cbhttp));
-		const char *secure_prop = e_source_get_property (source, "use_ssl");
+		g_object_set (G_OBJECT (priv->soup_session), SOUP_SESSION_PROXY_URI, proxy_uri, NULL);
 
-		priv->uri = webcal_to_http_method (e_cal_backend_get_uri (E_CAL_BACKEND (cbhttp)),
-		                                   (secure_prop && g_str_equal(secure_prop, "1")));
+		g_object_unref (proxy);
 	}
 
 	/* create message to be sent to server */
Index: calendar/backends/caldav/e-cal-backend-caldav.c
===================================================================
--- calendar/backends/caldav/e-cal-backend-caldav.c	(revision 10036)
+++ calendar/backends/caldav/e-cal-backend-caldav.c	(working copy)
@@ -28,6 +28,7 @@
 #include <gconf/gconf-client.h>
 #include <glib/gi18n-lib.h>
 #include "libedataserver/e-xml-hash-utils.h"
+#include "libedataserver/e-proxy.h"
 #include <libecal/e-cal-recur.h>
 #include <libecal/e-cal-util.h>
 #include <libecal/e-cal-time-util.h>
@@ -91,6 +92,7 @@ struct _ECalBackendCalDAVPrivate {
 
 	/* The main soup session  */
 	SoupSession *session;
+	EProxy *proxy;
 
 	/* well, guess what */
 	gboolean read_only;
@@ -790,75 +792,6 @@ soup_authenticate (SoupSession  *session
 		soup_auth_authenticate (auth, priv->username, priv->password);
 }
 
-static gint
-caldav_ignore_host(gconstpointer a, gconstpointer b)
-{
-	gchar *hostname = (gchar*)a,
-	      *ignore = (gchar*)b;
-
-	if (hostname && ignore)
-	  return strcmp(hostname, ignore);
-        return -1;
-}
-
-static void
-caldav_set_session_proxy(ECalBackendCalDAVPrivate *priv)
-{
-	GConfClient *conf_client;
-	SoupURI *uri_base;
-
- 	if (priv->session == NULL)
- 		return;
-
-	uri_base = soup_uri_new (priv->uri);
-	if (uri_base == NULL)
-		return;
-
-	/* set the outbound HTTP proxy, if configuration is set to do so */
-	conf_client = gconf_client_get_default ();
-	if (gconf_client_get_bool (conf_client, "/system/http_proxy/use_http_proxy", NULL)) {
-		char *server, *proxy_uri;
-		int port;
- 		GSList *ignore = gconf_client_get_list (conf_client,
-  							"/system/http_proxy/ignore_hosts",
-  		                                	GCONF_VALUE_STRING, NULL);
-  		if (ignore == NULL ||
-  		    g_slist_find_custom(ignore, uri_base->host, caldav_ignore_host) == NULL) {
-  			server = gconf_client_get_string (conf_client, "/system/http_proxy/host", NULL);
-			port = gconf_client_get_int (conf_client, "/system/http_proxy/port", NULL);
-
-			if (server && server[0]) {
-				SoupURI *suri;
-				if (gconf_client_get_bool (conf_client, "/system/http_proxy/use_authentication", NULL)) {
-					char *user, *password;
-					user = gconf_client_get_string (conf_client,
-									"/system/http_proxy/authentication_user",
-									NULL);
-					password = gconf_client_get_string (conf_client,
-									    "/system/http_proxy/authentication_password",
-									    NULL);
-
-					proxy_uri = g_strdup_printf("http://%s:%s@%s:%d", user, password, server, port);
-					g_free (user);
-					g_free (password);
-				} else
-					proxy_uri = g_strdup_printf ("http://%s:%d", server, port);
-
-				suri = soup_uri_new (proxy_uri);
-				g_object_set (G_OBJECT (priv->session), SOUP_SESSION_PROXY_URI, suri, NULL);
-
-				soup_uri_free (suri);
-				g_free (server);
-				g_free (proxy_uri);
-			}
-		}
- 		g_slist_foreach(ignore, (GFunc) g_free, NULL);
-		g_slist_free(ignore);
-	}
-	soup_uri_free (uri_base);
-}
-
-
 /* ************************************************************************* */
 /* direct CalDAV server access functions */
 
@@ -1833,6 +1766,23 @@ out:
 	return result;
 }
 
+static void
+proxy_settings_changed (EProxy *proxy, gpointer user_data)
+{
+	SoupURI *proxy_uri = NULL;
+	ECalBackendCalDAVPrivate *priv = (ECalBackendCalDAVPrivate *) user_data;
+
+	if (!priv || !priv->uri || !priv->session)
+		return;
+
+	/* use proxy if necessary */
+	if (e_proxy_require_proxy_for_uri (proxy, priv->uri)) {
+		proxy_uri = e_proxy_peek_uri_for (proxy, priv->uri);
+	}
+
+	g_object_set (priv->session, SOUP_SESSION_PROXY_URI, proxy_uri, NULL);
+}
+
 static ECalBackendSyncStatus
 caldav_do_open (ECalBackendSync *backend,
 		EDataCal        *cal,
@@ -1886,7 +1836,7 @@ caldav_do_open (ECalBackendSync *backend
 
 	if (priv->mode == CAL_MODE_REMOTE) {
 		/* set forward proxy */
-		caldav_set_session_proxy (priv);
+		proxy_settings_changed (priv->proxy, priv);
 
 		status = caldav_server_open_calendar (cbdav);
 
@@ -3057,6 +3007,7 @@ e_cal_backend_caldav_dispose (GObject *o
 	}
 
 	g_object_unref (priv->session);
+	g_object_unref (priv->proxy);
 
 	g_free (priv->username);
 	g_free (priv->password);
@@ -3098,7 +3049,6 @@ e_cal_backend_caldav_finalize (GObject *
 		(* G_OBJECT_CLASS (parent_class)->finalize) (object);
 }
 
-
 static void
 e_cal_backend_caldav_init (ECalBackendCalDAV *cbdav)
 {
@@ -3106,6 +3056,9 @@ e_cal_backend_caldav_init (ECalBackendCa
 	priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
 
 	priv->session = soup_session_sync_new ();
+	priv->proxy = e_proxy_new ();
+	e_proxy_setup_proxy (priv->proxy);
+	g_signal_connect (priv->proxy, "changed", G_CALLBACK (proxy_settings_changed), priv);
 
 	if (G_UNLIKELY (caldav_debug_show (DEBUG_MESSAGE)))
 		caldav_debug_setup (priv->session);
Index: calendar/backends/google/e-cal-backend-google.c
===================================================================
--- calendar/backends/google/e-cal-backend-google.c	(revision 10036)
+++ calendar/backends/google/e-cal-backend-google.c	(working copy)
@@ -1318,7 +1318,7 @@ proxy_settings_changed (EProxy *proxy, g
 
 	/* use proxy if necessary */
 	if (e_proxy_require_proxy_for_uri (proxy, priv->uri)) {
-		proxy_uri = e_proxy_peek_uri (proxy);
+		proxy_uri = e_proxy_peek_uri_for (proxy, priv->uri);
 	}
 	gdata_service_set_proxy (GDATA_SERVICE (priv->service), proxy_uri);
 }
@@ -1500,6 +1500,7 @@ void
 e_cal_backend_google_set_uri (ECalBackendGoogle *cbgo, gchar *uri)
 {
 	ECalBackendGooglePrivate *priv;
+	SoupURI *proxy_uri = NULL;
 
 	g_return_if_fail (cbgo != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo));
@@ -1509,10 +1510,10 @@ e_cal_backend_google_set_uri (ECalBacken
 
 	/* use proxy if necessary */
 	if (e_proxy_require_proxy_for_uri (priv->proxy, priv->uri)) {
-		SoupURI *proxy_uri = e_proxy_peek_uri (priv->proxy);
-
-		gdata_service_set_proxy (GDATA_SERVICE (priv->service), proxy_uri);
+		proxy_uri = e_proxy_peek_uri_for (priv->proxy, priv->uri);
 	}
+
+	gdata_service_set_proxy (GDATA_SERVICE (priv->service), proxy_uri);
 }
 
 /**
