Index: plugins/exchange-operations/exchange-calendar.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-calendar.c,v
retrieving revision 1.13
diff -u -p -r1.13 exchange-calendar.c
--- plugins/exchange-operations/exchange-calendar.c	6 Jan 2006 06:49:25 -0000	1.13
+++ plugins/exchange-operations/exchange-calendar.c	25 Jan 2006 13:45:11 -0000
@@ -337,8 +337,10 @@ e_exchange_calendar_commit (EPlugin *epl
 	}	
 
 	status = exchange_is_offline (&offline_status);
-	if (offline_status == OFFLINE_MODE || status != CONFIG_LISTENER_STATUS_OK)
+	if (offline_status == OFFLINE_MODE || status != CONFIG_LISTENER_STATUS_OK) {
+		g_free (uri_text);
 		return;
+	}
 
 	account = exchange_operations_get_exchange_account ();
 	username = exchange_account_get_username (account);
@@ -359,19 +361,36 @@ e_exchange_calendar_commit (EPlugin *epl
 		/* FIXME: This one would ever occur? */
 		ftype = g_strdup ("mail");
 	}
+	
 
 	gname = (gchar*) e_source_peek_name (source);
 	gruri = (gchar*) e_source_peek_relative_uri (source);
+	
 	if (calendar_src_exists) {
-		gchar *tmpruri, *tmpdelimit;
-		tmpruri = g_strdup (gruri);
-		tmpdelimit = g_strrstr (tmpruri, "/");
-		tmpdelimit[0] = '\0';
-		ruri = g_strconcat (tmpruri, "/", gname, NULL);
+		gchar *tmpruri, *uri_string;
+		EUri *euri;
+
+		/* sample uri_string: exchange://user;auth=NTLM@host/ */
+		/* sample uri_text: exchange://user;auth=NTLM@host/;personal/Calendar */
+
+		euri = e_uri_new (uri_text);
+		uri_string = e_uri_to_string (euri, FALSE);
+		e_uri_free (euri);
+
+		/* sample gruri: user;auth=NTLM@host/;personal/Calendar */
+		/* sample ruri: user;auth=NTLM@host/personal/Calendar */
+		/* sample path: /personal/Calendar */
+
+		tmpruri = g_strdup (uri_string + strlen ("exchange://"));
+		ruri = g_strconcat (tmpruri, uri_text + (strlen(uri_string)+1), NULL);
+		path = g_build_filename ("/", uri_text + (strlen(uri_string)+1), NULL);
+		oldpath = g_build_filename ("/", calendar_old_source_uri+prefix_len, NULL);
+		g_free (uri_string);
 		g_free (tmpruri);
 	}
 	else {
 		ruri = g_strconcat (gruri, "/", gname, NULL);
+		path = g_build_filename ("/", ruri+prefix_len, NULL);
 	}
 	e_source_set_relative_uri (source, ruri);
 	e_source_set_property (source, "username", username);
@@ -379,16 +398,13 @@ e_exchange_calendar_commit (EPlugin *epl
 	if (authtype)
 		 e_source_set_property (source, "auth-type", authtype);
 	e_source_set_property (source, "auth", "1");
-
-	path = g_build_filename ("/", ruri+prefix_len, NULL);
 	
 	if (!calendar_src_exists) {
 		/* Create the new folder */
 		result = exchange_account_create_folder (account, path, ftype);
 	}
-	else if (gruri && strcmp (gruri, calendar_old_source_uri)) {
+	else if (gruri && strcmp (gruri, calendar_old_source_uri) && strcmp (path, oldpath)) {
 		/* Rename the folder */
-		oldpath = g_build_filename ("/", calendar_old_source_uri+prefix_len, NULL);
 		result = exchange_account_xfer_folder (account, oldpath, path, TRUE);
 		exchange_operations_update_child_esources (source, 
 							   calendar_old_source_uri, 
Index: plugins/exchange-operations/exchange-contacts.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-contacts.c,v
retrieving revision 1.13
diff -u -p -r1.13 exchange-contacts.c
--- plugins/exchange-operations/exchange-contacts.c	18 Jan 2006 12:55:50 -0000	1.13
+++ plugins/exchange-operations/exchange-contacts.c	25 Jan 2006 13:46:24 -0000
@@ -321,12 +321,13 @@ e_exchange_contacts_commit (EPlugin *epl
 		g_free (uri_text);
 		return ;
 	}	
-	g_free (uri_text);
 
 	exchange_config_listener_get_offline_status (exchange_global_config_listener, 
 								    &offline_status);
-	if (offline_status == OFFLINE_MODE)
+	if (offline_status == OFFLINE_MODE) {
+		g_free (uri_text);
 		return;
+	}
 
 	account = exchange_operations_get_exchange_account ();
 	username = exchange_account_get_username (account);
@@ -338,17 +339,27 @@ e_exchange_contacts_commit (EPlugin *epl
 
 	gname = (gchar*) e_source_peek_name (source);
 	gruri = (gchar*) e_source_peek_relative_uri (source);
+
 	if (contacts_src_exists) {
-		gchar *tmpruri, *tmpdelimit;
-		tmpruri = g_strdup (gruri);
-		tmpdelimit = g_strrstr (tmpruri, "/");
-		tmpdelimit[0] = '\0';
-		ruri = g_strconcat (tmpruri, "/", gname, NULL);
+		gchar *tmpruri, *uri_string;
+		EUri *euri;
+
+		euri = e_uri_new (uri_text);
+		uri_string = e_uri_to_string (euri, FALSE);
+		e_uri_free (euri);
+		
+		tmpruri = g_strdup (uri_string + strlen ("exchange://"));
+		ruri = g_strconcat (tmpruri, uri_text + (strlen(uri_string)+1), NULL);
+		path = g_build_filename ("/", uri_text + (strlen(uri_string)+1), NULL);
+		oldpath = g_strdup_printf ("/%s", contacts_old_src_uri+prefix_len);
+		g_free (uri_string);
 		g_free (tmpruri);
 	}
 	else {
 		ruri = g_strconcat (gruri, "/", gname, NULL);
+		path = g_build_filename ("/", ruri+prefix_len, NULL);
 	}
+
 	e_source_set_relative_uri (source, ruri);
 	e_source_set_property (source, "username", username);
 	e_source_set_property (source, "auth-domain", "Exchange");
@@ -356,15 +367,12 @@ e_exchange_contacts_commit (EPlugin *epl
 		e_source_set_property (source, "auth-type", authtype);
 	e_source_set_property (source, "auth", "plain/password");
 
-	path = g_strdup_printf ("/%s", ruri+prefix_len);
-
 	if (!contacts_src_exists) {
 		/* Create the new folder */
 		result = exchange_account_create_folder (account, path, "contacts");
 	}
-	else if (strcmp (gruri, contacts_old_src_uri)) {
+	else if (gruri && strcmp (gruri, contacts_old_src_uri) && strcmp (path, oldpath)) {
 		/* Rename the folder */
-		oldpath = g_strdup_printf ("/%s", contacts_old_src_uri+prefix_len);
 		result = exchange_account_xfer_folder (account, oldpath, path, TRUE);
 		exchange_operations_update_child_esources (source, 
 							   contacts_old_src_uri, 
