Index: plugins/google-account-setup/ChangeLog
===================================================================
--- plugins/google-account-setup/ChangeLog	(revision 35743)
+++ plugins/google-account-setup/ChangeLog	(working copy)
@@ -1,3 +1,11 @@
+2008-07-18  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #525555
+
+	* google-source.c: (print_uri_noproto): Removed.
+	* google-source.c: (user_changed): Do not leak.
+	* google-source.c: (plugin_google): Get username from source, not URL.
+
 2008-03-31  Suman Manjunath  <msuman@novell.com>
 
 	** Fix for bug #346555
Index: plugins/google-account-setup/google-source.c
===================================================================
--- plugins/google-account-setup/google-source.c	(revision 35743)
+++ plugins/google-account-setup/google-source.c	(working copy)
@@ -103,43 +103,6 @@ e_plugin_lib_enable (EPluginLib *ep, int
 
 
 /********************************************************************************************************************/
-/* the location field for google sources */
-/* stolen from calendar-weather eplugin */
-static gchar *
-print_uri_noproto (EUri *uri)
-{
-	gchar *uri_noproto;
-
-	if (uri->port != 0)
-		uri_noproto = g_strdup_printf (
-			"%s%s%s%s%s%s%s:%d%s%s%s",
-			uri->user ? uri->user : "",
-			uri->authmech ? ";auth=" : "",
-			uri->authmech ? uri->authmech : "",
-			uri->passwd ? ":" : "",
-			uri->passwd ? uri->passwd : "",
-			uri->user ? "@" : "",
-			uri->host ? uri->host : "",
-			uri->port,
-			uri->path ? uri->path : "",
-			uri->query ? "?" : "",
-			uri->query ? uri->query : "");
-	else
-		uri_noproto = g_strdup_printf (
-			"%s%s%s%s%s%s%s%s%s%s",
-			uri->user ? uri->user : "",
-			uri->authmech ? ";auth=" : "",
-			uri->authmech ? uri->authmech : "",
-			uri->passwd ? ":" : "",
-			uri->passwd ? uri->passwd : "",
-			uri->user ? "@" : "",
-			uri->host ? uri->host : "",
-			uri->path ? uri->path : "",
-			uri->query ? "?" : "",
-			uri->query ? uri->query : "");
-	return uri_noproto;
-}
-
 #if 0
 
 FIXME: Not sure why this function is declared but called no where. This needs fixing.
@@ -174,41 +137,41 @@ user_changed (GtkEntry *editable, ESourc
 {
 	EUri       *euri;
 	char       *uri;
-	char       *ruri;
+	char       *tmp = NULL;
 	const char *user;
-	char *projection;
+	const char *projection;
 
 	uri = e_source_get_uri (source);
 	user = gtk_entry_get_text (GTK_ENTRY (editable));
 
-	if (uri == NULL) {
-		g_free (uri);
+	if (uri == NULL)
 		return;
-	}
 
 	euri = e_uri_new (uri);
+	g_free (uri);
 	g_free (euri->user);
 
-	if (user != NULL) {
+	if (user != NULL && *user) {
 		euri->user = g_strdup (user);
 		e_source_set_property (source, "auth", "1");
 	} else {
+		euri->user = NULL;
 		e_source_set_property (source, "auth", NULL);
 	}
 
-	projection = g_strdup ("/private/full");
+	projection = "/private/full";
 
 	if (!is_email (user)) {
-		user = g_strconcat (user, "@gmail.com", NULL);
+		tmp = g_strconcat (user, "@gmail.com", NULL);
+		user = tmp;
 	}
 
-	e_source_set_relative_uri (source, g_strconcat (CALENDAR_LOCATION, g_strdup(user), g_strdup (projection), NULL));
+	e_source_set_relative_uri (source, g_strconcat (CALENDAR_LOCATION, user, projection, NULL));
 	e_source_set_property (source, "username", euri->user);
 	e_source_set_property (source, "protocol", "google");
 	e_source_set_property (source, "auth-domain", "google");
 
-	ruri = print_uri_noproto (euri);
-	g_free (ruri);
+	g_free (tmp);
 	e_uri_free (euri);
 }
 
@@ -306,7 +269,7 @@ plugin_google  (EPlugin                 
 	GtkWidget    *user;
 	GtkWidget    *label;
 	char         *uri;
-	char         *username;
+	const char   *username;
 	const char   *ssl_prop;
 	gboolean      ssl_enabled;
 	int           row;
@@ -332,7 +295,8 @@ plugin_google  (EPlugin                 
 		return NULL;
 	}
 
-	username = euri->user;
+	username = e_source_get_property (source, "username");
+	g_free (euri->user);
 	euri->user = NULL;
 	uri = e_uri_to_string (euri, FALSE);
 
@@ -423,7 +387,6 @@ plugin_google  (EPlugin                 
 			  source);
 
         g_free (uri);
-	g_free (username);
 
 	return widget;
 }
