[evolution-patches] Exchange: Fix for bugs 272784 and 220168



Hello -

Attached patch fixes the bugs 272784 and 220168 which are related to the
reflection of changes made to the Exchange account configuration. Please
review.

Thanks -
Praveen.

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-exchange/ChangeLog,v
retrieving revision 1.369
diff -u -p -r1.369 ChangeLog
--- ChangeLog	9 Aug 2005 08:15:40 -0000	1.369
+++ ChangeLog	11 Aug 2005 15:53:22 -0000
@@ -1,3 +1,14 @@
+2005-08-11  Praveen Kumar  <kpraveen novell com>
+
+	* storage/exchange-config-listener.c
+	(exchange_camel_urls_is_equal): Added new
+	(account_added): Removed the default folder settings as it will be 
+	handled by the plugin.
+	(account_changed): Removed the dialog popups as all dialogs are now
+	from the plugin
+	(account_removed): Removed the ESource deletion and the dialog popup
+	as it will be handled by the plugin
+	
 2005-08-08  Sarfraaz Ahmed <asarfraaz novell com>
 
 	* configure.in : Bumped the version to 2.3.7
Index: storage/exchange-config-listener.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/exchange-config-listener.c,v
retrieving revision 1.27
diff -u -p -r1.27 exchange-config-listener.c
--- storage/exchange-config-listener.c	25 Jul 2005 11:03:18 -0000	1.27
+++ storage/exchange-config-listener.c	11 Aug 2005 15:53:24 -0000
@@ -40,6 +40,8 @@
 #include <libedataserver/e-source-list.h>
 #include <libedataserver/e-source-group.h>
 
+#include <camel/camel-url.h>
+
 #include <stdlib.h>
 #include <string.h>
 
@@ -84,6 +86,10 @@ static void account_changed (EAccountLis
 static void account_removed (EAccountList *account_listener,
 			     EAccount     *account);
 
+static gboolean exchange_camel_urls_is_equal (const gchar *url1, 
+					      const gchar *url2);
+
+
 static void
 class_init (GObjectClass *object_class)
 {
@@ -345,8 +351,6 @@ account_added (EAccountList *account_lis
 	config_listener = EXCHANGE_CONFIG_LISTENER (account_list);
 	if (config_listener->priv->configured_account) {
 		/* Multiple accounts configured. */
-		e_notice (NULL, GTK_MESSAGE_ERROR,
-			  _("You may only configure a single Exchange account"));
 		return;
 	}
 
@@ -366,12 +370,6 @@ account_added (EAccountList *account_lis
 	g_free (config_listener->priv->configured_name);
 	config_listener->priv->configured_name = g_strdup (account->name);
 
-	if (account == e_account_list_get_default (account_list)) {
-		g_signal_connect_swapped (config_listener->priv->exchange_account,
-					  "connected",
-					  G_CALLBACK (add_defaults_for_account),
-					  config_listener);
-	}
 
 	g_signal_emit (config_listener, signals[EXCHANGE_ACCOUNT_CREATED], 0,
 		       exchange_account);
@@ -479,7 +477,12 @@ account_changed (EAccountList *account_l
 		return;
 	}
 
-	if (!strcmp (config_listener->priv->configured_uri, account->source->url) &&
+	/* FIXME: The order of the parameters in the Camel URL string is not in 
+	 * order for the two given strings. So, we will not be able to use
+	 * plain string comparison. Instead compare the parameters one by one.
+	 */
+	if (exchange_camel_urls_is_equal (config_listener->priv->configured_uri, 
+					  account->source->url) &&
 	    !strcmp (config_listener->priv->configured_name, account->name)) {
 		/* The user changed something we don't care about. */
 		return;
@@ -513,42 +516,24 @@ account_changed (EAccountList *account_l
 	 * could be due to change in hostname or some parameter value, 
 	 * remove old e-sources 
 	 */
-	if (strcmp (config_listener->priv->configured_uri, account->source->url)) {
-		/* This condition will be true always as order of parameters in 
-		 * configured_uri and source->url will not match
-		 */
-		remove_account_esources (priv->exchange_account);
-
-		/* Ask user to authenticate at next login if username, hostname,
-		 * OWA URL or GC server values are changed. 
-		 */
-		if (requires_relogin (config_listener->priv->configured_uri, 
-				      account->source->url)) {
-			exchange_account_forget_password (priv->exchange_account);
-		}
-		else {
-			/* FIXME: modify esources and don't ask for re-login */
-			/* modify_esource (priv->exchange_account, 
-			 * account->source->url); 
-			 * return;
-			 */
-		}
+	if (requires_relogin (config_listener->priv->configured_uri, 
+			      account->source->url)) {
+		exchange_account_forget_password (priv->exchange_account);
+	} else if (strcmp (config_listener->priv->configured_name, account->name)) {
+/* 		remove_account_esources (priv->exchange_account); */
+		g_free (config_listener->priv->configured_name);
+		config_listener->priv->configured_name = g_strdup (account->name);
+		return;
+	} else {
+		/* FIXME: Do ESources need to be modified? */
+		return;
 	}
-	else if (strcmp (config_listener->priv->configured_name, account->name))
-		remove_account_esources (priv->exchange_account);
-
-	/* Nope. Let the user know we're ignoring him. */
-	e_notice (NULL, GTK_MESSAGE_WARNING,
-		  _("Changes to Exchange account configuration will "
-		    "take\nplace after you quit and restart Evolution."));
 
 	/* But note the new URI so if he changes something else, we
 	 * only warn again if he changes again.
 	 */
 	g_free (config_listener->priv->configured_uri);
 	config_listener->priv->configured_uri = g_strdup (account->source->url);
-	g_free (config_listener->priv->configured_name);
-	config_listener->priv->configured_name = g_strdup (account->name);
 }
 
 static void
@@ -561,9 +546,6 @@ account_removed (EAccountList *account_l
 	if (account != priv->configured_account)
 		return;
 
-	/* Remove all ESources */
-	remove_account_esources (priv->exchange_account);
-
 	exchange_account_forget_password (priv->exchange_account);
 
 	if (!exchange_account_get_context (priv->exchange_account)) {
@@ -582,17 +564,7 @@ account_removed (EAccountList *account_l
 		priv->configured_uri = NULL;
 		g_free (priv->configured_name);
 		priv->configured_name = NULL;
-	} else {
-		if (account->enabled) {
-			e_notice (NULL, GTK_MESSAGE_INFO,
-				_("The Exchange account will be removed when you quit Evolution"));
-		}
-		else {
-			/* The account is in use. We can't remove it. */
-			e_notice (NULL, GTK_MESSAGE_INFO,
-			  	_("The Exchange account will be disabled when you quit Evolution"));
-		}
-	}
+	} 
 }
 
 static gboolean
@@ -645,4 +617,53 @@ exchange_config_listener_get_accounts (E
 		return g_slist_append (NULL, config_listener->priv->exchange_account);
 	else
 		return NULL;
+}
+
+/**
+ * exchange_camel_urls_is_equal 
+ * 
+ * @url1: CAMEL URL string 1
+ * @url2: CAMEL URL string 2
+ *
+ * This function checks if the parameters present in two given CAMEL URLS are
+ * identical and returns the result.
+ *
+ * Return Value: Boolean result of the comparision.
+ *
+ **/ 
+static gboolean
+exchange_camel_urls_is_equal (const gchar *url1, const gchar *url2)
+{
+	CamelURL *curl1, *curl2;
+	gchar *param1, *param2;
+	const char *params[] = {
+		"auth",
+		"owa_url",
+		"owa_path",
+		"mailbox",
+		"ad_server",
+	};
+	const int n_params = 5;
+	int i;
+	
+	curl1 = camel_url_new (url1, NULL);
+	curl2 = camel_url_new (url2, NULL);
+
+	for (i = 0; i < n_params; ++i) {
+		param1 = (gchar*) camel_url_get_param (curl1, params[i]);
+		param2 = (gchar*) camel_url_get_param (curl2, params[i]);
+		if ((param1 && !param2) || (!param1 && param2) || /* Missing */
+		    (param1 && param2 && strcmp (param1, param2))) { /* Differing */
+			g_free (param1);
+			g_free (param2);
+			g_free (curl1);
+			g_free (curl2);
+			return FALSE;
+		}		
+		g_free (param1);
+		g_free (param2);
+	}
+	g_free (curl1);
+	g_free (curl2);
+	return TRUE;
 }
Index: plugins/exchange-operations/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/ChangeLog,v
retrieving revision 1.43
diff -u -p -r1.43 ChangeLog
--- plugins/exchange-operations/ChangeLog	8 Aug 2005 05:54:26 -0000	1.43
+++ plugins/exchange-operations/ChangeLog	11 Aug 2005 15:55:33 -0000
@@ -1,3 +1,14 @@
+2005-08-11  Praveen Kumar  <kpraveen novell com>
+
+	* exchange-config-listener.c
+	(exchange_camel_urls_is_equal): Added new
+	(exchange_modify_esource_group_name): Added new
+	(account_changed): Handle most of the account parameter changes
+	without restart. This fixes bug 272784 and partially bug 220168
+	(account_removed): Removed the message dialog that says that the
+	changes will be reflected after restart. This partially fixes the
+	bug 220168
+	
 2005-08-08  Arunprakash <arunp novell com>
 
 	* exchange-folder-size-display.c: Included glib/gi18n.h file for
Index: plugins/exchange-operations/exchange-config-listener.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-config-listener.c,v
retrieving revision 1.10
diff -u -p -r1.10 exchange-config-listener.c
--- plugins/exchange-operations/exchange-config-listener.c	3 Aug 2005 09:58:28 -0000	1.10
+++ plugins/exchange-operations/exchange-config-listener.c	11 Aug 2005 15:55:33 -0000
@@ -35,6 +35,7 @@
 #include <e-folder-exchange.h>
 #include <e2k-marshal.h>
 #include <e2k-uri.h>
+#include <camel/camel-url.h>
 
 #include <e-util/e-error.h>
 
@@ -85,9 +86,12 @@ static void account_changed (EAccountLis
 			     EAccount     *account);
 static void account_removed (EAccountList *account_listener,
 			     EAccount     *account);
-
 static void exchange_add_autocompletion_folders (GConfClient *gc_client, 
 						 ExchangeAccount *account);
+static gboolean exchange_camel_urls_is_equal (const gchar *url1, 
+					      const gchar *url2);
+static void exchange_modify_esource_group_name (const char *old_name, 
+						const char *new_name);
 
 static void
 class_init (GObjectClass *object_class)
@@ -716,7 +720,12 @@ account_changed (EAccountList *account_l
 		return;
 	}
 
-	if (!strcmp (config_listener->priv->configured_uri, account->source->url) &&
+	/* FIXME: The order of the parameters in the Camel URL string is not in 
+	 * order for the two given strings. So, we will not be able to use
+	 * plain string comparison. Instead compare the parameters one by one.
+	 */
+	if (exchange_camel_urls_is_equal (config_listener->priv->configured_uri, 
+					  account->source->url) &&
 	    !strcmp (config_listener->priv->configured_name, account->name)) {
 		/* The user changed something we don't care about. */
 		return;
@@ -750,30 +759,22 @@ account_changed (EAccountList *account_l
 	 * could be due to change in hostname or some parameter value, 
 	 * remove old e-sources 
 	 */
-	if (strcmp (config_listener->priv->configured_uri, account->source->url)) {
-		/* This condition will be true always as order of parameters in 
-		 * configured_uri and source->url will not match
-		 */
+	if (requires_relogin (config_listener->priv->configured_uri, 
+			      account->source->url)) {
 		remove_account_esources (priv->exchange_account);
-
-		/* Ask user to authenticate at next login if username, hostname,
-		 * OWA URL or GC server values are changed. 
-		 */
-		if (requires_relogin (config_listener->priv->configured_uri, 
-				      account->source->url)) {
-			exchange_account_forget_password (priv->exchange_account);
-		}
-		else {
-			/* FIXME: modify esources and don't ask for re-login */
-			/* modify_esource (priv->exchange_account, 
-			 * account->source->url); 
-			 * return;
-			 */
-		}
+		exchange_account_forget_password (priv->exchange_account);
+	} else if (strcmp (config_listener->priv->configured_name, account->name)) {
+/* 		remove_account_esources (priv->exchange_account); */
+		exchange_modify_esource_group_name (config_listener->priv->configured_name, 
+						    account->name);
+		g_free (config_listener->priv->configured_name);
+		config_listener->priv->configured_name = g_strdup (account->name);
+		return;
+	} else {
+		/* FIXME: Do ESources need to be modified? */
+		return;
 	}
-	else if (strcmp (config_listener->priv->configured_name, account->name))
-		remove_account_esources (priv->exchange_account);
-
+	
 	/* Nope. Let the user know we're ignoring him. */
 	e_error_run (NULL, "org-gnome-exchange-operations:apply-restart", NULL);
 
@@ -782,8 +783,6 @@ account_changed (EAccountList *account_l
 	 */
 	g_free (config_listener->priv->configured_uri);
 	config_listener->priv->configured_uri = g_strdup (account->source->url);
-	g_free (config_listener->priv->configured_name);
-	config_listener->priv->configured_name = g_strdup (account->name);
 }
 
 static void
@@ -817,15 +816,7 @@ account_removed (EAccountList *account_l
 		priv->configured_uri = NULL;
 		g_free (priv->configured_name);
 		priv->configured_name = NULL;
-	} else {
-		if (account->enabled) {
-			e_error_run (NULL, "org-gnome-exchange-operations:remove-quit", NULL);
-		}
-		else {
-			/* The account is in use. We can't remove it. */
-			e_error_run (NULL, "org-gnome-exchange-operations:disable-quit", NULL);
-		}
-	}
+	} 
 }
 
 static gboolean
@@ -947,4 +938,114 @@ exchange_add_autocompletion_folders (GCo
 			found_group = TRUE;
 		}
 	}
+}
+
+
+/**
+ * exchange_camel_urls_is_equal 
+ * 
+ * @url1: CAMEL URL string 1
+ * @url2: CAMEL URL string 2
+ *
+ * This function checks if the parameters present in two given CAMEL URLS are
+ * identical and returns the result.
+ *
+ * Return Value: Boolean result of the comparision.
+ *
+ **/ 
+static gboolean
+exchange_camel_urls_is_equal (const gchar *url1, const gchar *url2)
+{
+	CamelURL *curl1, *curl2;
+	gchar *param1, *param2;
+	const char *params[] = {
+		"auth",
+		"owa_url",
+		"owa_path",
+		"mailbox",
+		"ad_server",
+	};
+	const int n_params = 5;
+	int i;
+	g_print ("URL 1:%s URL 2: %s\n", url1, url2);
+	
+	curl1 = camel_url_new (url1, NULL);
+	curl2 = camel_url_new (url2, NULL);
+
+	for (i = 0; i < n_params; ++i) {
+		param1 = (gchar*) camel_url_get_param (curl1, params[i]);
+		param2 = (gchar*) camel_url_get_param (curl2, params[i]);
+		if ((param1 && !param2) || (!param1 && param2) || /* Missing */
+		    (param1 && param2 && strcmp (param1, param2))) { /* Differing */
+			g_free (param1);
+			g_free (param2);
+			g_free (curl1);
+			g_free (curl2);
+			return FALSE;
+		}		
+		g_free (param1);
+		g_free (param2);
+	}
+	g_free (curl1);
+	g_free (curl2);
+	return TRUE;
+}
+
+/**
+ * exchange_modify_esource_group_name
+ * 
+ * @old_name: Old name of the ESourceGroup
+ * @new_name: New name of the ESourceGroup
+ *
+ * This function modifies the old source group name to the specified new
+ * source group name
+ **/ 
+static void
+exchange_modify_esource_group_name (const char *old_name, const char *new_name)
+{
+	GConfClient *client;
+	ESourceGroup *group;
+	GSList *groups;
+	ESourceList *c_source_list = NULL, *t_source_list = NULL, 
+		*a_source_list = NULL;
+
+	client = gconf_client_get_default ();
+
+	c_source_list = e_source_list_new_for_gconf ( client, CONF_KEY_CAL);
+	t_source_list = e_source_list_new_for_gconf ( client, CONF_KEY_TASKS);
+	a_source_list = e_source_list_new_for_gconf ( client, CONF_KEY_CONTACTS);
+
+	groups = e_source_list_peek_groups (c_source_list);
+
+	for ( ; groups != NULL; groups = g_slist_next (groups)) {
+		group = E_SOURCE_GROUP (groups->data);
+		if (!strcmp (e_source_group_peek_name (group), old_name)) {
+			e_source_group_set_name (group, new_name);
+			break;
+		}
+	}
+
+	groups = e_source_list_peek_groups (t_source_list);
+
+	for ( ; groups != NULL; groups = g_slist_next (groups)) {
+		group = E_SOURCE_GROUP (groups->data);
+		if (!strcmp (e_source_group_peek_name (group), old_name)) {
+			e_source_group_set_name (group, new_name);
+			break;
+		}
+	}
+
+	groups = e_source_list_peek_groups (a_source_list);
+
+	for ( ; groups != NULL; groups = g_slist_next (groups)) {
+		group = E_SOURCE_GROUP (groups->data);
+		if (!strcmp (e_source_group_peek_name (group), old_name)) {
+			e_source_group_set_name (group, new_name);
+			break;
+		}
+	}
+
+	e_source_list_sync (c_source_list, NULL);
+	e_source_list_sync (t_source_list, NULL);
+	e_source_list_sync (a_source_list, NULL);
 }


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