[evolution-patches] fix for bug #65167 [calendar]



Hi,
     Have removed the unnecessary assert statements and used a boolean variable in e-cal-backend-groupwise.c to ensure that the cache is loaded properly.

thanks, chenthill.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.326
diff -u -p -r1.326 ChangeLog
--- ChangeLog	5 Sep 2004 13:04:19 -0000	1.326
+++ ChangeLog	5 Sep 2004 14:43:19 -0000
@@ -1,5 +1,18 @@
 2004-09-05  Chenthill Palanisamy <pchenthill novell com>
 	
+	Fixes #65167
+	* backends/groupwise/e-cal-backend-groupwise-utils.c
+	(set_categories_for_gw_item), e_gw_item_to_cal_component),
+	(set_properties_from_cal_component): replaced the assert
+	statements with If conditions.
+	* backends/groupwise/e-cal-backend-groupwise.c 
+	(ECalBackendGroupwisePrivate): added a boolean variable to
+	indicate the load state of the cache.
+	(connect_to_server): used it to decide whether the cache should
+	be populated or not.
+
+2004-09-05  Chenthill Palanisamy <pchenthill novell com>
+	
 	* libecal/e-cal-utils.h:
        	defined two macros for the handling the static capabilities for 
 	backends which does not support the conversion of a non-recurring
Index: backends/groupwise/e-cal-backend-groupwise.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/groupwise/e-cal-backend-groupwise.c,v
retrieving revision 1.91
diff -u -p -r1.91 e-cal-backend-groupwise.c
--- backends/groupwise/e-cal-backend-groupwise.c	5 Sep 2004 13:04:19 -0000	1.91
+++ backends/groupwise/e-cal-backend-groupwise.c	5 Sep 2004 14:43:19 -0000
@@ -46,6 +46,7 @@ struct _ECalBackendGroupwisePrivate {
 	EGwConnection *cnc;
 	ECalBackendCache *cache;
 	gboolean read_only;
+	gboolean cache_load_state;
 	char *uri;
 	char *username;
 	char *password;
@@ -300,7 +301,8 @@ connect_to_server (ECalBackendGroupwise 
 		/* we need to read actual rights from server when we implement proxy user access */
 		cbgw->priv->read_only = FALSE;
 
-		if (priv->cnc && priv->cache) {
+		/* if cache has been sucessfully loaded return back without loading again */
+		if (priv->cache_load_state) {
 			priv->mode = CAL_MODE_REMOTE;
 			return GNOME_Evolution_Calendar_Success;
 		}
@@ -323,7 +325,8 @@ connect_to_server (ECalBackendGroupwise 
 			} else
 				priv->container_id = NULL;
 
-				priv->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (cbgw)));
+				if (!priv->cache)
+					priv->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (cbgw)));
 				if (!priv->cache) {
 					g_mutex_unlock (priv->mutex);
 					e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Could not create cache file"));
@@ -348,6 +351,7 @@ connect_to_server (ECalBackendGroupwise 
 				g_object_ref (priv->cnc);
 				g_object_ref (priv->cache);
 				g_timeout_add (CACHE_REFRESH_INTERVAL, (GSourceFunc) get_deltas, (gpointer) cbgw);
+				priv->cache_load_state = TRUE;
 				priv->mode = CAL_MODE_REMOTE;
 				return GNOME_Evolution_Calendar_Success;
 			}
@@ -1509,7 +1513,7 @@ e_cal_backend_groupwise_init (ECalBacken
 
 	priv->categories_by_id = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
 	priv->categories_by_name = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-
+	priv->cache_load_state = FALSE;
 	/* create the mutex for thread safety */
 	priv->mutex = g_mutex_new ();
 
Index: backends/groupwise/e-cal-backend-groupwise-utils.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c,v
retrieving revision 1.31
diff -u -p -r1.31 e-cal-backend-groupwise-utils.c
--- backends/groupwise/e-cal-backend-groupwise-utils.c	27 Aug 2004 05:39:52 -0000	1.31
+++ backends/groupwise/e-cal-backend-groupwise-utils.c	5 Sep 2004 14:43:20 -0000
@@ -86,7 +86,7 @@ set_categories_for_gw_item (EGwItem *ite
 	categories_by_id = e_cal_backend_groupwise_get_categories_by_id (cbgw);
 	cnc = e_cal_backend_groupwise_get_connection (cbgw);
 	
-	g_assert (cnc != NULL || categories_by_name != NULL || categories_by_id != NULL);
+	g_return_if_fail (categories_by_id != NULL || categories_by_name != NULL || cnc != NULL);
 	
 	for (; category_names != NULL; category_names = g_list_next (category_names)) {
                      if (!category_names->data || strlen(category_names->data) == 0 )
@@ -132,8 +132,6 @@ set_properties_from_cal_component (EGwIt
 	
 	default_zone = e_cal_backend_groupwise_get_default_zone (cbgw);
 	
-	g_assert (default_zone != NULL);
-	
 	/* first set specific properties */
 	switch (e_cal_component_get_vtype (comp)) {
 	case E_CAL_COMPONENT_EVENT :
@@ -395,7 +393,6 @@ e_gw_item_to_cal_component (EGwItem *ite
 	categories_by_id = e_cal_backend_groupwise_get_categories_by_id (cbgw);
 
 	g_return_val_if_fail (E_IS_GW_ITEM (item), NULL);
-	g_assert (default_zone != NULL || categories_by_id != NULL);
 
 	comp = e_cal_component_new ();
 
@@ -462,7 +459,7 @@ e_gw_item_to_cal_component (EGwItem *ite
 	/* categories */
 	category_ids = e_gw_item_get_categories (item);
 	categories = NULL;
-	if (category_ids) {
+	if (category_ids && categories_by_id) {
 		for (; category_ids != NULL; category_ids = g_list_next (category_ids)) {
 			name = g_hash_table_lookup (categories_by_id, category_ids->data);
 			if (name)


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