[evolution-patches] fix for the bug #305656 [calendar]



Hi,
  Have attached the fix for the bug. This removes the deleted events in
the server from the cache.

thanks, Chenthill.
Index: calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.553
diff -u -p -u -p -r1.553 ChangeLog
--- calendar/ChangeLog	19 Jan 2006 08:41:57 -0000	1.553
+++ calendar/ChangeLog	20 Jan 2006 13:08:57 -0000
@@ -1,3 +1,9 @@
+2006-01-20  Chenthill Palanisamy  <pchenthill novell com>
+
+	Fixes #305656
+	* backends/groupwise/e-cal-backend-groupwise.c: (get_deltas):
+	Remove the deleted items from the server.
+
 2006-01-19  Chenthill Palanisamy  <pchenthill novell com>
 
 	Fixes #322951
Index: calendar/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.172
diff -u -p -u -p -r1.172 e-cal-backend-groupwise.c
--- calendar/backends/groupwise/e-cal-backend-groupwise.c	8 Dec 2005 06:26:40 -0000	1.172
+++ calendar/backends/groupwise/e-cal-backend-groupwise.c	20 Jan 2006 13:08:58 -0000
@@ -389,13 +389,11 @@ get_deltas (gpointer handle)
 		item_list = NULL;
 	}
 	
-	/* TODO currently the read cursors response does not give us the recurrencKey, uncomment
-	   this once the  response gives the recurrenceKey */
 	/* handle deleted items here by going over the entire cache and
 	 * checking for deleted items.*/
 	position = E_GW_CURSOR_POSITION_END;
 	cursor = 0;
-	status = e_gw_connection_create_cursor (cnc, cbgw->priv->container_id, "id iCalId recurrenceKey", NULL, &cursor);
+	status = e_gw_connection_create_cursor (cnc, cbgw->priv->container_id, "id iCalId recurrenceKey startDate", NULL, &cursor);
 
 	if (status != E_GW_CONNECTION_STATUS_OK) {
 		if (status == E_GW_CONNECTION_STATUS_NO_RESPONSE) {
@@ -423,18 +421,6 @@ get_deltas (gpointer handle)
 			return TRUE;
 		}
 		
-		/* FIXME handle deleted items here by going over the entire cache and
-		 * checking for deleted items.*/
-#if 0
-		for (l1 = item_list; l1; l1 = g_list_next (l1)) {
-			char *icalid;
-			icalid = (char *)(l1->data);
-			cache_keys = g_slist_delete_link (cache_keys, 
-					g_slist_find_custom (cache_keys, icalid, (GCompareFunc) strcmp));
-			if (l1->data)
-				g_free (l1->data);
-		}	
-#endif
 		if (!item_list  || g_list_length (item_list) == 0)
 			done = TRUE;
 		else {
@@ -452,7 +438,42 @@ get_deltas (gpointer handle)
 	e_gw_connection_destroy_cursor (cnc, cbgw->priv->container_id, cursor);
 	e_file_cache_freeze_changes (E_FILE_CACHE (cache));
 
-#if 0
+	g_message ("************* total in cache and server are %d %d \n", g_slist_length (cache_keys),g_list_length (total_list));
+	for (l = total_list; l != NULL; l = l->next) {
+		EGwItemCalId *calid = (EGwItemCalId *)	l->data;
+		GCompareFunc func = NULL;
+		GSList *remove = NULL;
+		char *real_key = NULL;
+
+		if (calid->recur_key && calid->ical_id) {
+			const char *rid = NULL;
+			icaltimetype tt = icaltime_from_string (calid->ical_id);
+			if (!tt.is_date) {
+				tt = icaltime_convert_to_zone (tt, priv->default_zone); 
+				icaltime_set_timezone (&tt, priv->default_zone);
+				rid = icaltime_as_ical_string (tt);
+			} else
+				rid = calid->ical_id;
+			real_key = g_strconcat (calid->recur_key, "@", rid, NULL);
+		}
+		
+		if (!calid->recur_key || real_key) 
+			func = (GCompareFunc) strcmp;
+		else
+			func = (GCompareFunc) compare_prefix;
+
+		if (!(remove = g_slist_find_custom (cache_keys, calid->recur_key ? real_key :
+						calid->ical_id,  func))) {
+			g_ptr_array_add (uid_array, g_strdup (calid->item_id));
+			needs_to_get = TRUE;
+		} else  {
+			cache_keys = g_slist_delete_link (cache_keys, remove);
+			g_message ("******** found \n");
+		}
+	
+		g_free (real_key);
+	}
+
 	for (l = cache_keys; l ; l = g_slist_next (l)) {
 		/* assumes rid is null - which works for now */
 		ECalComponent *comp = NULL;
@@ -467,36 +488,20 @@ get_deltas (gpointer handle)
 		vtype = e_cal_component_get_vtype (comp);
 		if ((vtype == E_CAL_COMPONENT_EVENT) ||
 				(vtype == E_CAL_COMPONENT_TODO)) {
+			char *comp_str = NULL;
+			ECalComponentId *id = e_cal_component_get_id (comp);
+			
 			comp_str = e_cal_component_get_as_string (comp);
+			g_message ("**** item %s \n", comp_str);
 			e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbgw), 
-					(char *) l->data, comp_str, NULL);
-			e_cal_backend_cache_remove_component (cache, (const char *) l->data, NULL);
+					id, comp_str, NULL);
+			e_cal_backend_cache_remove_component (cache, (const char *) id->uid, id->rid);
+
+			e_cal_component_free_id (id);
 			g_free (comp_str);
 		}
 		g_object_unref (comp);
 	}
-#endif
-
-	for (l = total_list; l != NULL; l = l->next) {
-		EGwItemCalId *calid = (EGwItemCalId *)	l->data;
-		GCompareFunc func = NULL;
-		GSList *remove = NULL;
-
-		if (calid->ical_id) 
-			func = (GCompareFunc) strcmp;
-		else
-			func = (GCompareFunc) compare_prefix;
-
-		if (!(remove = g_slist_find_custom (cache_keys, calid->ical_id ? calid->ical_id :
-						calid->recur_key,  func))) {
-			g_ptr_array_add (uid_array, g_strdup (calid->item_id));
-			needs_to_get = TRUE;
-		} else  {
-			cache_keys = g_slist_delete_link (cache_keys, remove);
-			continue;
-		}
-
-	}
 
 	if (needs_to_get) {
 		e_gw_connection_get_items_from_ids (priv->cnc,
@@ -527,7 +532,7 @@ get_deltas (gpointer handle)
 
 			g_object_unref (item);
 		}
-	}
+	} 
 
 	e_file_cache_thaw_changes (E_FILE_CACHE (cache));
 
Index: servers/groupwise/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/ChangeLog,v
retrieving revision 1.173
diff -u -p -u -p -r1.173 ChangeLog
--- servers/groupwise/ChangeLog	5 Jan 2006 18:38:59 -0000	1.173
+++ servers/groupwise/ChangeLog	20 Jan 2006 13:08:58 -0000
@@ -1,3 +1,9 @@
+2006-01-20  Chenthill Palanisamy  <pchenthill novell com>
+
+	Fixes #305656
+	* e-gw-connection.c: (e_gw_connection_read_cal_ids):
+	Get the start date of the appointment if its recurring.
+
 2006-01-05  Kjartan Maraas,,23491770  <kmaraas gnome org>
 
 	* e-gw-connection.c: (e_gw_connection_add_members),
Index: servers/groupwise/e-gw-connection.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-connection.c,v
retrieving revision 1.137
diff -u -p -u -p -r1.137 e-gw-connection.c
--- servers/groupwise/e-gw-connection.c	5 Jan 2006 18:38:59 -0000	1.137
+++ servers/groupwise/e-gw-connection.c	20 Jan 2006 13:09:02 -0000
@@ -3429,39 +3429,33 @@ e_gw_connection_read_cal_ids (EGwConnect
 			subparam = soup_soap_parameter_get_next_child_by_name (subparam, "item")) {
 		SoupSoapParameter *param_id;
 		EGwItemCalId *calid = g_new0 (EGwItemCalId, 1);
+		EGwItemType type;
 		char *id = NULL, *item_type = NULL;
 		
 		item_type = soup_soap_parameter_get_property (subparam, "type");
 		
-		if (!(g_str_equal (item_type, "Appointment") || g_str_equal (item_type, "Task"))) {
+		if (g_str_equal (item_type, "Appointment"))
+				type  = E_GW_ITEM_TYPE_APPOINTMENT;
+		else if  (g_str_equal (item_type, "Task"))
+			type = E_GW_ITEM_TYPE_TASK;
+		else {
 			g_free (item_type);
 			continue;	
 		}
-			 
 		g_free (item_type);
-
+		
 		param_id = soup_soap_parameter_get_first_child_by_name (subparam, "id");
-		if (!param_id) {
-			if (*list) {
-				g_list_foreach (*list, (GFunc) e_gw_item_free_cal_id, NULL);
-				g_list_free (*list);
-				*list = NULL;
+		if (param_id) {
+			id = soup_soap_parameter_get_string_value (param_id);
+			if (!id) {
+				e_gw_item_free_cal_id (calid);
+				g_object_unref (response);
+				g_object_unref (msg);
+				return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
 			}
-			e_gw_item_free_cal_id (calid);
-			g_object_unref (response);
-			g_object_unref (msg);
-			return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
-		}
-		
-		id = soup_soap_parameter_get_string_value (param_id);
-		if (id)
+
 			calid->item_id = id;
-		else {
-			if (*list) {
-				g_list_foreach (*list, (GFunc) e_gw_item_free_cal_id, NULL);
-				g_list_free (*list);
-				*list = NULL;
-			}
+		} else {
 			e_gw_item_free_cal_id (calid);
 			g_object_unref (response);
 			g_object_unref (msg);
@@ -3469,15 +3463,40 @@ e_gw_connection_read_cal_ids (EGwConnect
 		}
 		
 		id = NULL;
-	
+		
 		param_id = soup_soap_parameter_get_first_child_by_name (subparam, "recurrenceKey");
 		if (param_id) {
 			id = soup_soap_parameter_get_string_value (param_id);
 		}
 		
-		if (id && !g_str_equal (id, "0"))
+		if (id && !g_str_equal (id, "0")) {
+			guint allday = 0;
+
 			calid->recur_key = id;
-		else {
+		
+			if (type == E_GW_ITEM_TYPE_APPOINTMENT) {
+				param_id = soup_soap_parameter_get_first_child_by_name (subparam, "allDayEvent");
+				if (param_id) {
+					allday = soup_soap_parameter_get_int_value (param_id);
+				}
+
+			}
+
+			if (allday) 
+				param_id = soup_soap_parameter_get_first_child_by_name (subparam, "startDay");
+			else
+				param_id = soup_soap_parameter_get_first_child_by_name (subparam, "startDate");
+
+			if (param_id) {
+				char *formatted_date;
+				id = soup_soap_parameter_get_string_value (param_id);
+				formatted_date = e_gw_connection_format_date_string (id);
+				 /* store the date in calid for recurring events */
+				calid->ical_id = formatted_date; 
+				g_free (id);
+			}
+
+		} else {
 			g_free (id);
 			id = NULL;
 


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