[evolution-patches] Addressbook, calendar and exchange patch



Hi,

These patches take care of synchronising the passwords across
components. This fixes #309420 in part.

Addressbook : [ evo-add-auth.patch ] The strip uri code was neglecting
the auth mech in the uri. This patch takes care of escaping the authmech
in the uri.

Calendar : [ eds-libecal-key.patch ] Similar to addressbook and cleans
up the ugly uri re-creation that was being done earlier.

Exchange : [eds-ex-auth-sanitize.patch and ex-camel-uri.patch ] 
Redefine the uri for exchange folders, so that the folder path is
delimited as a parameter.

Please let me know if this is fine to commit.

Thanks
-- Sarfraaz
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.1990
diff -u -p -u -p -r1.1990 ChangeLog
--- ChangeLog	26 Aug 2005 05:39:33 -0000	1.1990
+++ ChangeLog	26 Aug 2005 10:32:10 -0000
@@ -1,3 +1,8 @@
+2005-08-26  Sarfraaz Ahmed <asarfraaz novell com>
+
+	* gui/component/addressbook.c (remove_parameters_from_uri) : This now
+	takes care to escape any auth mechanism in the uri.
+
 2005-08-26  Devashish Sharma <sdevashish novell com>
 
 	* gui/widgets/e-addressbook-view.etspec: In ETableSpecification source
Index: gui/component/addressbook.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/component/addressbook.c,v
retrieving revision 1.252
diff -u -p -u -p -r1.252 addressbook.c
--- gui/component/addressbook.c	24 Aug 2005 03:06:49 -0000	1.252
+++ gui/component/addressbook.c	26 Aug 2005 10:32:10 -0000
@@ -62,6 +62,23 @@ remove_parameters_from_uri (const gchar 
   gchar **components;
   gchar *new_uri = NULL;
                                                                                                                              
+  if (strchr (uri, '@')) {
+	/* This matches foo://user host/ */
+    components = g_strsplit (uri, "@", 2);
+      if (strchr (components[0], ';')) {
+	/* This matches foo://user;prop host/ */
+	g_strfreev (components);
+	components = g_strsplit (uri, ";", 3);
+	  if (components[0] && components[1]) {
+		/* Concatinate the first 2 parts */
+	    new_uri = g_strdup_printf ("%s;%s", components[0], components[1]);
+	    g_strfreev (components);
+            return new_uri;
+          }
+      }
+    g_strfreev (components);
+  }
+
   components = g_strsplit (uri, ";", 2);
   if (components[0])
         new_uri = g_strdup (components[0]);
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.510
diff -u -p -u -p -r1.510 ChangeLog
--- ChangeLog	25 Aug 2005 12:20:43 -0000	1.510
+++ ChangeLog	26 Aug 2005 09:54:30 -0000
@@ -1,3 +1,9 @@
+2005-08-26  Sarfraaz Ahmed <asarfraaz novell com>
+
+	* libecal/e-cal.c (build_pass_key) : Do not recreate the uri. Instead
+	strip the uri part after a ';'. The backend can now set its uri
+	accordingly to have a consistent password key across multiple calendars
+
 2005-08-25  Chenthill Palanisamy  <pchenthill novell com>
 
 	Fixes #312853
Index: libecal/e-cal.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libecal/e-cal.c,v
retrieving revision 1.112
diff -u -p -u -p -r1.112 e-cal.c
--- libecal/e-cal.c	24 Aug 2005 02:32:56 -0000	1.112
+++ libecal/e-cal.c	26 Aug 2005 09:54:31 -0000
@@ -1605,26 +1605,37 @@ get_host_from_uri (const char *uri)
 static char *
 build_pass_key (ESource *source)
 {
-	const char *base_uri, *user_name, *auth_type, *rel_uri;
-	char *uri, *new_uri, *host_name;
-	ESourceGroup *es_grp;
-
-	es_grp = e_source_peek_group (source);
-	base_uri = e_source_group_peek_base_uri (es_grp);
-	if (base_uri) {
-		user_name = e_source_get_property (source, "username");
-		auth_type = e_source_get_property (source, "auth-type");
-		rel_uri = e_source_peek_relative_uri (source);
-		host_name = get_host_from_uri (rel_uri);
-		if (host_name) {
-			new_uri = g_strdup_printf ("%s%s;%s %s/", base_uri, user_name, auth_type, host_name);
-			g_free (host_name);
+	gchar **components;
+	gchar *new_uri = NULL, *uri;
+	
+	uri = e_source_get_uri (source);
+	if (strchr (uri, '@')) {
+		/* This matches foo://user host/ */
+		components = g_strsplit (uri, "@", 2);
+		if (strchr (components[0], ';')) {
+			/* This matches foo://user;prop host/ */
+			g_strfreev (components);
+			components = g_strsplit (uri, ";", 3);
+			if (components[0] && components[1]) {
+				/* Concatinate the first 2 parts */
+				new_uri = g_strdup_printf ("%s;%s", components[0], components[1]);
 
-			return new_uri;
+				g_strfreev (components);
+				g_free (uri);
+				return new_uri;
+			}
 		}
+		g_strfreev (components);
 	}
 
-	uri = e_source_get_uri (source);
+	components = g_strsplit (uri, ";", 2);
+	if (components[0]) {
+		new_uri = g_strdup (components[0]);
+		g_strfreev (components);
+		g_free (uri);
+		return new_uri;
+	}
+	g_strfreev (components);
 
 	return uri;
 }
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/exchange/ChangeLog,v
retrieving revision 1.29
diff -u -p -u -p -r1.29 ChangeLog
--- ChangeLog	25 Aug 2005 14:29:59 -0000	1.29
+++ ChangeLog	26 Aug 2005 09:20:52 -0000
@@ -1,3 +1,16 @@
+2005-08-26  Sarfraaz Ahmed <asarfraaz novell com>
+
+	* lib/e2k-autoconfig.c (e2k_validate_user) : Fix the password key to
+	be consistent with the camel key.
+	* storage/e-folder-exchange.c (sanitize_path) : Strips the ';' in the
+	path.
+	* storage/exchange-account.c (get_hierarchy_for)
+	(setup_account_hierarchies) : Fix the physical uri to delimit the 
+	folder path from the uri with a ';'
+	(exchange_account_new) : Fix the uri authority to be same as the camel
+	uri which would be later used in all components for creating the 
+	password key.
+
 2005-08-25  Arunprakash  <arunp novell com>
 
 	* storage/exchange-account.c (init) : set the default linestatus
Index: lib/e2k-autoconfig.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/exchange/lib/e2k-autoconfig.c,v
retrieving revision 1.3
diff -u -p -u -p -r1.3 e2k-autoconfig.c
--- lib/e2k-autoconfig.c	1 Jul 2005 05:43:21 -0000	1.3
+++ lib/e2k-autoconfig.c	26 Aug 2005 09:20:53 -0000
@@ -1568,6 +1568,7 @@ e2k_validate_user (const char *owa_url, 
 	char *key, *password, *prompt;
 
 	key = g_strdup_printf ("%s//%s %s", "exchange:", user, owa_url); /* FIXME */
+		
 	password = e_passwords_get_password ("Exchange", key);
 	if (!password) {
 		prompt = g_strdup_printf (_("Enter password for %s"), user);
@@ -1587,8 +1588,11 @@ e2k_validate_user (const char *owa_url, 
 
 				*remember_password = remember;
 				g_free (key);
-				key = g_strdup_printf ("%s//%s %s", 
-						       "exchange:", user, exchange_params->host);
+				if (exchange_params->is_ntlm)
+					key = g_strdup_printf ("exchange://%s;auth=NTLM %s/", 
+								       user, exchange_params->host);
+				else
+					key = g_strdup_printf ("exchange://%s %s/", user, exchange_params->host);
 				e_passwords_add_password (key, password);
 				e_passwords_remember_password ("Exchange", key);
 			}
Index: storage/e-folder-exchange.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/exchange/storage/e-folder-exchange.c,v
retrieving revision 1.5
diff -u -p -u -p -r1.5 e-folder-exchange.c
--- storage/e-folder-exchange.c	21 Jul 2005 14:45:57 -0000	1.5
+++ storage/e-folder-exchange.c	26 Aug 2005 09:20:53 -0000
@@ -45,7 +45,7 @@ struct _EFolderExchangePrivate {
 	ExchangeHierarchy *hier;
 	char *internal_uri, *permanent_uri;
 	char *outlook_class, *storage_dir;
-	const char *path;
+	char *path;
 	long long int folder_size;
 	gboolean has_subfolders;
 };
@@ -98,6 +98,7 @@ finalize (GObject *object)
 	g_free (folder->priv->permanent_uri);
 	g_free (folder->priv->outlook_class);
 	g_free (folder->priv->storage_dir);
+	g_free (folder->priv->path);
 	g_free (folder->priv);
 
 	G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -147,6 +148,26 @@ e_mkdir_hier(const char *path, mode_t mo
 	return 0;
 }
 
+static char *
+sanitize_path (char *path)
+{
+	gchar **comps;
+	char *new_path = NULL;
+
+	if (!path)
+		return;
+
+	comps = g_strsplit (path, ";", 2);
+	if (comps[1])
+		new_path = g_strdup_printf ("%s%s", comps[0], comps[1]);
+	else if (comps[0])
+		new_path = g_strdup (comps[0]);
+
+	g_strfreev (comps);
+	return new_path;	
+}
+
+
 /**
  * e_folder_exchange_new:
  * @hier: the #ExchangeHierarchy containing the new folder
@@ -181,7 +202,7 @@ e_folder_exchange_new (ExchangeHierarchy
 	efe->priv->hier = hier;
 	g_object_ref (hier);
 	efe->priv->internal_uri = g_strdup (internal_uri);
-	efe->priv->path = e2k_uri_path (e_folder_get_physical_uri (ef));
+	efe->priv->path = sanitize_path (e2k_uri_path (e_folder_get_physical_uri (ef)));
 	efe->priv->outlook_class = g_strdup (outlook_class);
 
 	/* Add ESources */
Index: storage/exchange-account.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/exchange/storage/exchange-account.c,v
retrieving revision 1.15
diff -u -p -u -p -r1.15 exchange-account.c
--- storage/exchange-account.c	25 Aug 2005 14:29:59 -0000	1.15
+++ storage/exchange-account.c	26 Aug 2005 09:20:53 -0000
@@ -624,7 +624,7 @@ get_hierarchy_for (ExchangeAccount *acco
 					  entry->display_name);
 	source = g_strdup_printf ("exchange://%s %s/", entry->mailbox,
 				  account->exchange_server);
-	physical_uri_prefix = g_strdup_printf ("exchange://%s/%s",
+	physical_uri_prefix = g_strdup_printf ("exchange://%s/;%s",
 					       account->priv->uri_authority,
 					       entry->email);
 	internal_uri_prefix = exchange_account_get_foreign_uri (account, entry,
@@ -1261,7 +1261,7 @@ setup_account_hierarchies (ExchangeAccou
 		return FALSE;
 
 	/* Set up Personal Folders hierarchy */
-	phys_uri_prefix = g_strdup_printf ("exchange://%s/personal",
+	phys_uri_prefix = g_strdup_printf ("exchange://%s/;personal",
 					   account->priv->uri_authority);
 	hier = exchange_hierarchy_webdav_new (account,
 					      EXCHANGE_HIERARCHY_PERSONAL,
@@ -1277,7 +1277,7 @@ setup_account_hierarchies (ExchangeAccou
 	personal_hier = hier;
 
 	/* Favorite Public Folders */
-	phys_uri_prefix = g_strdup_printf ("exchange://%s/favorites",
+	phys_uri_prefix = g_strdup_printf ("exchange://%s/;favorites",
 					   account->priv->uri_authority);
 	hier = exchange_hierarchy_favorites_new (account,
 						 _("Favorite Public Folders"),
@@ -1292,7 +1292,7 @@ setup_account_hierarchies (ExchangeAccou
 	account->priv->favorites_hierarchy = hier;
 
 	/* Public Folders */
-	phys_uri_prefix = g_strdup_printf ("exchange://%s/public",
+	phys_uri_prefix = g_strdup_printf ("exchange://%s/;public",
 					   account->priv->uri_authority);
 	hier = exchange_hierarchy_webdav_new (account,
 					      EXCHANGE_HIERARCHY_PUBLIC,
@@ -1308,7 +1308,7 @@ setup_account_hierarchies (ExchangeAccou
 	g_free (phys_uri_prefix);
 
 	/* Global Address List */
-	phys_uri_prefix = g_strdup_printf ("gal://%s/gal",
+	phys_uri_prefix = g_strdup_printf ("gal://%s/;gal",
 					   account->priv->uri_authority);
 						     /* i18n: Outlookism */
 	hier = exchange_hierarchy_gal_new (account, _("Global Address List"),
@@ -2024,7 +2024,7 @@ ExchangeAccount *
 exchange_account_new (EAccountList *account_list, EAccount *adata)
 {
 	ExchangeAccount *account;
-	char *enc_user, *mailbox;
+	char *enc_user, *mailbox, *old_uri_authority;
 	const char *param, *proto="http", *owa_path, *pf_server, *owa_url; 
 	const char *passwd_exp_warn_period, *offline_sync;
 	E2kUri *uri;
@@ -2056,8 +2056,14 @@ exchange_account_new (EAccountList *acco
 
 	/* URI, etc, info */
 	enc_user = e2k_uri_encode (uri->user, FALSE, "@/;:");
-	account->priv->uri_authority = g_strdup_printf ("%s %s", enc_user,
+	old_uri_authority = g_strdup_printf ("%s %s", enc_user,
 							uri->host);
+	if (uri->authmech)
+		account->priv->uri_authority = g_strdup_printf ("%s;auth=%s %s", enc_user,
+								uri->authmech, uri->host);
+	else
+		account->priv->uri_authority = g_strdup_printf ("%s %s", enc_user,
+								uri->host);
 	g_free (enc_user);
 
 	account->priv->source_uri = g_strdup_printf ("exchange://%s/", account->priv->uri_authority);
@@ -2065,7 +2071,7 @@ exchange_account_new (EAccountList *acco
 	/* Backword compatibility; FIXME, we should just migrate the
 	 * password from this to source_uri.
 	 */
-	account->priv->password_key = g_strdup_printf ("exchange://%s", account->priv->uri_authority);
+	account->priv->password_key = g_strdup_printf ("exchange://%s", old_uri_authority);
 
 	account->priv->username = g_strdup (uri->user);
 	if (uri->domain)
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-exchange/ChangeLog,v
retrieving revision 1.390
diff -u -p -u -p -r1.390 ChangeLog
--- ChangeLog	26 Aug 2005 07:54:02 -0000	1.390
+++ ChangeLog	26 Aug 2005 10:40:49 -0000
@@ -1,3 +1,8 @@
+2005-08-26  Sarfraaz Ahmed <asarfraaz novell com>
+
+	* camel/camel-exchange-store.c (make_folder_info) : Strip the ';' in 
+	the folder uri.
+
 2005-08-26  Dan Damian  <dand gnome ro>
 
 	* configure.in: Added "ro" to ALL_LINGUAS.
Index: camel/camel-exchange-store.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/camel/camel-exchange-store.c,v
retrieving revision 1.23
diff -u -p -u -p -r1.23 camel-exchange-store.c
--- camel/camel-exchange-store.c	22 Aug 2005 14:22:01 -0000	1.23
+++ camel/camel-exchange-store.c	26 Aug 2005 10:40:50 -0000
@@ -375,9 +375,9 @@ exchange_connect (CamelService *service,
 	
 	exch->stub = camel_stub_new (socket_path, _("Evolution Exchange backend process"), ex);
 	g_free (socket_path);
-	if (!exch->stub)
+	if (!exch->stub) 
 		return FALSE;
-	
+
 	camel_exchange_get_password (service, ex);
 	/* Initialize the stub connection */
 	if (!camel_stub_send (exch->stub, NULL, CAMEL_STUB_CMD_CONNECT,
@@ -392,7 +392,7 @@ exchange_connect (CamelService *service,
 		exch->stub = NULL;
 		return FALSE;
 	}
-	
+
 	camel_object_hook_event (CAMEL_OBJECT (exch->stub), "notification",
 				 stub_notification, exch);
 	return TRUE;
@@ -549,18 +549,27 @@ make_folder_info (CamelExchangeStore *ex
 	d(printf ("make folder info : %s flags : %d\n", name, flags));
 	CamelFolderInfo *info;
 	const char *path;
+	gchar **components;
+	char *new_uri;
 
 	path = strstr (uri, "://");
 	if (!path)
 		return NULL;
-	path = strchr (path + 3, '/');
+	path = strstr (path + 3, "/;");
 	if (!path)
 		return NULL;
 
+	components = g_strsplit (uri, ";", 3);
+	if (components[0] && components[1])
+		new_uri = g_strdup_printf ("%s;%s%s", components[0], components[1], components[2]);
+	else
+		new_uri = g_strdup (uri);
+
+	printf ("new_uri is : %s\n", new_uri);
 	info = g_new0 (CamelFolderInfo, 1);
 	info->name = name;
-	info->uri = uri;
-	info->full_name = g_strdup (path + 1);
+	info->uri = new_uri;
+	info->full_name = g_strdup (path + 2);
 	info->unread = unread_count;
 
 	if (flags & CAMEL_STUB_FOLDER_NOSELECT)


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