[evolution-patches] Exchange connector patch for displaying all the subfolders



Sometimes only a subset of the calendar/tasks/contacts folders of a
exchange account were being displayed (Defect #58320). 
Guess this behavior was due to some sync issue while invoking
e_source_list_sync() several times inside a loop.

So now calling sync function, once for each component after forming the 
e-sources for all the folders in that component, instead of calling it 
for each folder.

This patch also includes some indentation changes.

-Sushma.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-exchange/ChangeLog,v
retrieving revision 1.4
diff -u -r1.4 ChangeLog
--- ChangeLog	12 May 2004 07:43:48 -0000	1.4
+++ ChangeLog	12 May 2004 10:32:51 -0000
@@ -1,6 +1,14 @@
 2004-05-12  Sushma Rai  <rsushma novell com>
 
-	storage/exchange-config-listener.c (add_esource)(remove_esource):
+	* storage/exchange-config-listener.c (add_sources)(remove_sources):
+	Calling e_source_list_sync() after forming the sources for all the 
+	folders for each component, instead of calling it for each folder 
+	in a loop.
+	Fixes bug #58320
+ 
+2004-05-12  Sushma Rai  <rsushma novell com>
+
+	* storage/exchange-config-listener.c (add_esource)(remove_esource):
 	Fixed problem with forming the relative uri for the subfolders.
 	(add_sources)(remove_sources): Finding physical uri of the folder.
 
Index: storage/exchange-config-listener.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/exchange-config-listener.c,v
retrieving revision 1.2
diff -u -r1.2 exchange-config-listener.c
--- storage/exchange-config-listener.c	12 May 2004 07:43:48 -0000	1.2
+++ storage/exchange-config-listener.c	12 May 2004 10:33:21 -0000
@@ -442,27 +442,25 @@
 add_esource (ExchangeAccount *account, 
 	     char *conf_key, 
 	     const char *folder_name, 
-	     const char *physical_uri)
+	     const char *physical_uri,
+	     ESourceList **source_list)
 {
 	ESource *source;
-	ESourceList *source_list;
 	ESourceGroup *source_group;
 	char *relative_uri;
 
 	relative_uri = g_strdup (physical_uri + strlen ("exchange://"));
-	source_list = e_source_list_new_for_gconf (gconf_client_get_default (),
-						 conf_key);
 
-	if ((source_group = e_source_list_peek_group_by_name (source_list, 
+        if ((source_group = e_source_list_peek_group_by_name (*source_list, 
 					account->account_name)) == NULL){
-       		source_group = e_source_group_new (account->account_name, 
+		source_group = e_source_group_new (account->account_name, 
 						   "exchange://");
-        	if (!e_source_list_add_group (source_list, source_group, -1)) {
+		if (!e_source_list_add_group (*source_list, source_group, -1)) {
 			g_object_unref (source_group);
         		g_free(relative_uri);
-                	return;
+			return;
 		}
-        	source = e_source_new (folder_name, relative_uri);
+		source = e_source_new (folder_name, relative_uri);
 		e_source_group_add_source (source_group, source, -1);
 
 		g_object_unref (source);
@@ -479,8 +477,6 @@
 		}
 	}
 
-        e_source_list_sync (source_list, NULL);
-        g_object_unref (source_list);
         g_free(relative_uri);
 }
 
@@ -492,12 +488,23 @@
 	char *conf_key_contacts="/apps/evolution/addressbook/sources";
 	const char *folder_name, *physical_uri;
 	GPtrArray *exchange_folders;
-	EFolder *folder; 
+	EFolder *folder;
+	ESourceList *cal_source_list, *task_source_list, *cont_source_list;
 	int i;
 
 	exchange_folders = exchange_account_get_folders (account);                                                                                 
         if (exchange_folders) {
-                for (i = 0; i < exchange_folders->len; i++) {
+		cal_source_list = e_source_list_new_for_gconf ( 
+					gconf_client_get_default (), 
+					conf_key_cal);
+		task_source_list = e_source_list_new_for_gconf ( 
+					gconf_client_get_default (), 
+					conf_key_tasks);
+		cont_source_list = e_source_list_new_for_gconf (
+					gconf_client_get_default (), 
+					conf_key_contacts);
+
+		for (i = 0; i < exchange_folders->len; i++) {
 			folder = exchange_folders->pdata[i];
 			if (!(strcmp (e_folder_get_type_string (folder), 
 				      "calendar"))){
@@ -506,7 +513,8 @@
         			add_esource (account, 
 					     conf_key_cal, 
 					     folder_name, 
-					     physical_uri);
+					     physical_uri,
+					     &cal_source_list);
 				continue;
 			}
 			if (!(strcmp (e_folder_get_type_string (folder), 
@@ -516,7 +524,8 @@
         			add_esource (account, 
 					     conf_key_tasks, 
 					     folder_name, 
-					     physical_uri);
+					     physical_uri,
+					     &task_source_list);
 				continue;
 			}
 			if (!(strcmp (e_folder_get_type_string (folder), 
@@ -526,55 +535,61 @@
         			add_esource (account, 
 					     conf_key_contacts, 
 					     folder_name, 
-					     physical_uri);
+					     physical_uri,
+					     &cont_source_list);
 				continue;
 			}
 			continue;
 		}
-                g_ptr_array_free (exchange_folders, TRUE);
+		e_source_list_sync (cal_source_list, NULL);
+		g_object_unref (cal_source_list);
+		e_source_list_sync (task_source_list, NULL);
+		g_object_unref (task_source_list);
+		e_source_list_sync (cont_source_list, NULL);
+		g_object_unref (cont_source_list);
+		g_ptr_array_free (exchange_folders, TRUE);
         }
 }
 
 static void 
-remove_esource (ExchangeAccount *account, char *conf_key, const char *physical_uri)
+remove_esource (ExchangeAccount *account, 
+		char *conf_key, 
+		const char *physical_uri,
+		ESourceList **source_list)
 {
-        ESourceList *list;  ESourceGroup *group;
-        ESource *source;
-        GSList *groups;
-        GSList *sources;
-        gboolean found_group;
-        char *relative_uri;
+	ESourceGroup *group;
+	ESource *source;
+	GSList *groups;
+	GSList *sources;
+	gboolean found_group;
+	char *relative_uri;
 
 	relative_uri = g_strdup (physical_uri + strlen ("exchange://"));
-        list = e_source_list_new_for_gconf (gconf_client_get_default (), 
-						conf_key);
-        groups = e_source_list_peek_groups (list);
-        found_group = FALSE;
+	groups = e_source_list_peek_groups (*source_list);
+	found_group = FALSE;
 
-        for ( ; groups != NULL && !found_group; groups = g_slist_next (groups)) {
-                group = E_SOURCE_GROUP (groups->data);
+	for ( ; groups != NULL && !found_group; groups = g_slist_next (groups)) {
+		group = E_SOURCE_GROUP (groups->data);
 
-                if (strcmp (e_source_group_peek_name (group), account->account_name) == 0
+		if (strcmp (e_source_group_peek_name (group), account->account_name) == 0
                     &&
                    strcmp (e_source_group_peek_base_uri (group), "exchange://" ) == 0) {
 
-                        sources = e_source_group_peek_sources (group);
+			sources = e_source_group_peek_sources (group);
 
-                        for( ; sources != NULL; sources = g_slist_next (sources)) {
+			for( ; sources != NULL; sources = g_slist_next (sources)) {
 
-                                source = E_SOURCE (sources->data);
+				source = E_SOURCE (sources->data);
 
-                                if (strcmp (e_source_peek_relative_uri (source), 
+				if (strcmp (e_source_peek_relative_uri (source), 
 					    relative_uri) == 0) {
-                                        e_source_list_remove_group (list, group);
-                                        e_source_list_sync (list, NULL);
+					e_source_list_remove_group (*source_list, group);
                                         found_group = TRUE;
                                         break;
                                 }
                         }
                 }
         }
-        g_object_unref (list);
         g_free(relative_uri);
 }
 
@@ -586,11 +601,22 @@
 	char *conf_key_contacts="/apps/evolution/addressbook/sources";
 	const char *physical_uri;
 	EFolder *folder; 
+	ESourceList *cal_source_list, *task_source_list, *cont_source_list;
 	GPtrArray *exchange_folders;
 	int i;
 
 	exchange_folders = exchange_account_get_folders (account);
 	if (exchange_folders) {
+		cal_source_list = e_source_list_new_for_gconf ( 
+					gconf_client_get_default (), 
+					conf_key_cal);
+		task_source_list = e_source_list_new_for_gconf ( 
+					gconf_client_get_default (), 
+					conf_key_tasks);
+		cont_source_list = e_source_list_new_for_gconf (
+					gconf_client_get_default (), 
+					conf_key_contacts);
+
 		for (i = 0; i < exchange_folders->len; i++) {
 			folder = exchange_folders->pdata[i];
 			if (!(strcmp (e_folder_get_type_string (folder), 
@@ -598,25 +624,34 @@
 				physical_uri = e_folder_get_physical_uri (folder);
         			remove_esource (account, 
 						conf_key_cal, 
-						physical_uri);
+						physical_uri,
+						&cal_source_list);
 				continue;
 			}
 			if (!(strcmp (e_folder_get_type_string (folder), "tasks"))){
 				physical_uri = e_folder_get_physical_uri (folder);
         			remove_esource (account, 
 						conf_key_tasks, 
-						physical_uri);
+						physical_uri,
+						&task_source_list);
 				continue;
 			}
 			if (!(strcmp (e_folder_get_type_string (folder), "contacts"))){
 				physical_uri = e_folder_get_physical_uri (folder);
         			remove_esource (account, 
 						conf_key_contacts, 
-						physical_uri);
+						physical_uri,
+						&cont_source_list);
 				continue;
 			}
 			continue;
 		}
+		e_source_list_sync (cal_source_list, NULL);
+		g_object_unref (cal_source_list);
+		e_source_list_sync (task_source_list, NULL);
+		g_object_unref (task_source_list);
+		e_source_list_sync (cont_source_list, NULL);
+		g_object_unref (cont_source_list);
         	g_ptr_array_free (exchange_folders, TRUE);
         }
 }


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