[evolution-patches] patch from recurrences branch



Hi

The attached patch is from the recurrences-work-branch. All work is done
for the backend API and the file backend. The Groupwise backend needs
much more work that can be done in HEAD, which will also make it easier
for me to follow HEAD fixes.

cheers
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.241
retrieving revision 1.237.2.7
diff -u -p -r1.241 -r1.237.2.7
--- ChangeLog	12 Apr 2004 06:53:50 -0000	1.241
+++ ChangeLog	12 Apr 2004 10:45:35 -0000	1.237.2.7
@@ -1,10 +1,22 @@
+2004-04-12  Rodrigo Moya <rodrigo ximian com>
+
+	* backends/file/e-cal-backend-file.c (e_cal_backend_file_modify_object):
+	added support for CALOBJ_MOD_THISANDPRIOR/THISANDFUTURE.
+	(e_cal_backend_file_remove_object): fixed warning.
+
+2004-04-12  Rodrigo Moya <rodrigo ximian com>
+
+	* backends/file/e-cal-backend-file.c (e_cal_backend_file_modify_object):
+	when CALOBJ_MOD_THIS is used on the full object, just replace that one.
+	Added missing code to add detached instances.
+
 2004-04-12  Sarfraaz Ahmed <asarfraaz novell com>
 
 	Fixes #56517
-                                                                                
-        * libecal/e-cal.c (e_cal_add_timezone): Added a check for icalcomponent
-        structure. Return FALSE if icalcomponent is NULL.
-
+	
+	* libecal/e-cal.c (e_cal_add_timezone): Added a check for icalcomponent
+	structure. Return FALSE if icalcomponent is NULL.
+                                                                        
 2004-04-12  Harish K <kharish novell com>
 
 	Fixes #53926
@@ -12,22 +24,52 @@
 	* backends/groupwise/e-cal-backend-groupwise-utils.c
 	(e_gw_item_to_cal_component) : set the tzid to "UTC"
 	while setting the dueDate.
-		
-	
+
 2004-04-08  Rodrigo Moya <rodrigo ximian com>
 
 	* backends/groupwise/e-cal-backend-groupwise.c
-	(e_cal_backend_groupwise_get_static_capabilities): add the 
+	(e_cal_backend_groupwise_get_static_capabilities): add the
 	ONE_ALARM_ONLY static capability.
 
+2004-04-07  Rodrigo Moya <rodrigo ximian com>
+
+	* libedata-cal/e-cal-backend-sync.[ch]: added "old_object" argument to
+	"remove_object_sync" virtual method.
+	(e_cal_backend_sync_remove_object): added new argument.
+	(_e_cal_backend_remove_object): pass correct number of arguments to
+	e_cal_backend_sync_remove_object.
+
+	* backends/file/e-cal-backend-file.c (e_cal_backend_file_remove_object):
+	* backends/groupwise/e-cal-backend-groupwise.c
+	(e_cal_backend_groupwise_remove_object):
+	* backends/http/e-cal-backend-http.c (e_cal_backend_http_remove_object):
+	adapted to changes in ECalBackendSync's "remove_object_sync" method.
+
 2004-04-06  Harish K <kharish novell com>
-	
-	Fixes #55169
 
+	Fixes #55169
+	
 	* backends/groupwise/e-cal-backend-groupwise-utils.c
 	(e_gw_connection_get_freebusy_info) : Use icalproperty
 	to add free/busy data to ECalComponent.
-	
+
+2004-04-05  Rodrigo Moya <rodrigo ximian com>
+
+	* libedata-cal/e-cal-backend.[ch] (e_cal_backend_notify_object_removed):
+	changed to contain also the new object, since we might have removed only
+	an instance, in which case, notify a modification, not a removal.
+	(e_cal_backend_notify_object_modified): splitted notification logic...
+	(match_query_and_notify): ...to here.
+
+	* libedata-cal/e-data-cal.[ch] (e_data_cal_notify_object_removed): added
+	'old_object' argument.
+
+	* libedata-cal/e-cal-backend-sync.c (_e_cal_backend_remove_object):
+	* backends/file/e-cal-backend-file.c (notify_removals_cb,
+	e_cal_backend_file_receive_objects):
+	* backends/contacts/e-cal-backend-contacts.c (contact_record_free):
+	adapted to changes in e_cal_backend_notify_object_removed.
+
 2004-04-05  Rodrigo Moya <rodrigo ximian com>
 
 	* backends/groupwise/e-cal-backend-groupwise.c
Index: backends/contacts/e-cal-backend-contacts.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/contacts/e-cal-backend-contacts.c,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -u -p -r1.9 -r1.9.2.1
--- backends/contacts/e-cal-backend-contacts.c	5 Apr 2004 00:43:11 -0000	1.9
+++ backends/contacts/e-cal-backend-contacts.c	6 Apr 2004 12:13:21 -0000	1.9.2.1
@@ -175,7 +175,7 @@ contact_record_free (ContactRecord *cr)
 	if (cr->comp_birthday) {
 		comp_str = e_cal_component_get_as_string (cr->comp_birthday);
 		e_cal_component_get_uid (cr->comp_birthday, &uid);
-		e_cal_backend_notify_object_removed (E_CAL_BACKEND (cr->cbc), uid, comp_str);
+		e_cal_backend_notify_object_removed (E_CAL_BACKEND (cr->cbc), uid, comp_str, NULL);
 		g_free (comp_str);
 		g_object_unref (G_OBJECT (cr->comp_birthday));
 	}
@@ -184,7 +184,7 @@ contact_record_free (ContactRecord *cr)
 	if (cr->comp_anniversary) {
 		comp_str = e_cal_component_get_as_string (cr->comp_anniversary);
 		e_cal_component_get_uid (cr->comp_anniversary, &uid);
-		e_cal_backend_notify_object_removed (E_CAL_BACKEND (cr->cbc), uid, comp_str);
+		e_cal_backend_notify_object_removed (E_CAL_BACKEND (cr->cbc), uid, comp_str, NULL);
 		g_free (comp_str);
 		g_object_unref (G_OBJECT (cr->comp_anniversary));
 	}
Index: backends/file/e-cal-backend-file.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/file/e-cal-backend-file.c,v
retrieving revision 1.27
retrieving revision 1.27.2.4
diff -u -p -r1.27 -r1.27.2.4
--- backends/file/e-cal-backend-file.c	31 Mar 2004 19:56:02 -0000	1.27
+++ backends/file/e-cal-backend-file.c	12 Apr 2004 10:45:35 -0000	1.27.2.4
@@ -674,7 +674,7 @@ notify_removals_cb (gpointer key, gpoint
 		if (!old_obj_str)
 			return;
 
-		e_cal_backend_notify_object_removed (context->backend, uid, old_obj_str);
+		e_cal_backend_notify_object_removed (context->backend, uid, old_obj_str, NULL);
 	}
 }
 
@@ -1670,10 +1670,56 @@ e_cal_backend_file_create_object (ECalBa
 	return GNOME_Evolution_Calendar_Success;
 }
 
+typedef struct {
+	ECalBackendFile *cbfile;
+	ECalBackendFileObject *obj_data;
+	const char *rid;
+	CalObjModType mod;
+} RemoveRecurrenceData;
+
+static gboolean
+remove_object_instance_cb (gpointer key, gpointer value, gpointer user_data)
+{
+	time_t fromtt, instancett;
+	GSList *categories;
+	char *rid = key;
+	ECalComponent *instance = value;
+	RemoveRecurrenceData *rrdata = user_data;
+
+	fromtt = icaltime_as_timet (icaltime_from_string (rrdata->rid));
+	instancett = icaltime_as_timet (get_rid_icaltime (instance));
+
+	if (fromtt > 0 && instancett > 0) {
+		if ((rrdata->mod == CALOBJ_MOD_THISANDPRIOR && instancett <= fromtt) ||
+		    (rrdata->mod == CALOBJ_MOD_THISANDFUTURE && instancett >= fromtt)) {
+			/* remove the component from our data */
+			icalcomponent_remove_component (rrdata->cbfile->priv->icalcomp,
+							e_cal_component_get_icalcomponent (instance));
+			rrdata->cbfile->priv->comp = g_list_remove (rrdata->cbfile->priv->comp, instance);
+
+			rrdata->obj_data->recurrences_list = g_list_remove (rrdata->obj_data->recurrences_list, instance);
+
+			/* update the set of categories */
+			e_cal_component_get_categories_list (instance, &categories);
+			e_cal_backend_unref_categories (E_CAL_BACKEND (rrdata->cbfile), categories);
+			e_cal_component_free_categories_list (categories);
+
+			/* free memory */
+			g_free (rid);
+			g_object_unref (instance);
+
+			return TRUE;
+		}
+	}
+
+	return FALSE;
+}
+
 static ECalBackendSyncStatus
 e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, const char *calobj, 
 				  CalObjModType mod, char **old_object)
 {
+	RemoveRecurrenceData rrdata;
 	ECalBackendFile *cbfile;
 	ECalBackendFilePrivate *priv;
 	icalcomponent *icalcomp;
@@ -1725,8 +1771,22 @@ e_cal_backend_file_modify_object (ECalBa
 	case CALOBJ_MOD_THIS :
 		rid = e_cal_component_get_recurid_as_string (comp);
 		if (!rid || !*rid) {
-			g_object_unref (comp);
-			return GNOME_Evolution_Calendar_ObjectNotFound;
+			if (old_object)
+				*old_object = e_cal_component_get_as_string (obj_data->full_object);
+
+			/* replace only the full object */
+			icalcomponent_remove_component (priv->icalcomp,
+							e_cal_component_get_icalcomponent (obj_data->full_object));
+			priv->comp = g_list_remove (priv->comp, obj_data->full_object);
+
+			/* Add the new object */
+			g_object_unref (obj_data->full_object);
+			obj_data->full_object = comp;
+
+			icalcomponent_add_component (priv->icalcomp,
+						     e_cal_component_get_icalcomponent (obj_data->full_object));
+			priv->comp = g_list_prepend (priv->comp, obj_data->full_object);
+			break;
 		}
 
 		if (g_hash_table_lookup_extended (obj_data->recurrences, rid,
@@ -1768,11 +1828,69 @@ e_cal_backend_file_modify_object (ECalBa
 		g_hash_table_insert (obj_data->recurrences, 
 				     g_strdup (e_cal_component_get_recurid_as_string (comp)),
 				     comp);
+		icalcomponent_add_component (priv->icalcomp,
+					     e_cal_component_get_icalcomponent (comp));
+		priv->comp = g_list_append (priv->comp, comp);
 		obj_data->recurrences_list = g_list_append (obj_data->recurrences_list, comp);
 		break;
 	case CALOBJ_MOD_THISANDPRIOR :
-		break;
 	case CALOBJ_MOD_THISANDFUTURE :
+		rid = e_cal_component_get_recurid_as_string (comp);
+		if (!rid || !*rid) {
+			g_object_unref (comp);
+			return GNOME_Evolution_Calendar_ObjectNotFound;
+		}
+
+		/* remove the component from our data, temporarily */
+		icalcomponent_remove_component (priv->icalcomp,
+						e_cal_component_get_icalcomponent (obj_data->full_object));
+		priv->comp = g_list_remove (priv->comp, obj_data->full_object);
+
+		/* now deal with the detached recurrence */
+		if (g_hash_table_lookup_extended (obj_data->recurrences, rid,
+						  &real_rid, &recurrence)) {
+			if (old_object)
+				*old_object = e_cal_component_get_as_string (recurrence);
+
+			/* remove the component from our data */
+			icalcomponent_remove_component (priv->icalcomp,
+							e_cal_component_get_icalcomponent (recurrence));
+			priv->comp = g_list_remove (priv->comp, recurrence);
+			g_hash_table_remove (obj_data->recurrences, rid);
+			obj_data->recurrences_list = g_list_remove (obj_data->recurrences_list, recurrence);
+
+			/* free memory */
+			g_free (real_rid);
+		} else {
+			if (old_object)
+				*old_object = e_cal_component_get_as_string (obj_data->full_object);
+		}
+
+		/* remove all affected recurrences */
+		e_cal_util_remove_instances (e_cal_component_get_icalcomponent (obj_data->full_object),
+					     icaltime_from_string (rid), mod);
+
+		rrdata.cbfile = cbfile;
+		rrdata.obj_data = obj_data;
+		rrdata.rid = rid;
+		rrdata.mod = mod;
+		g_hash_table_foreach_remove (obj_data->recurrences, (GHRFunc) remove_object_instance_cb, &rrdata);
+
+		/* add the modified object to the beginning of the list,
+		   so that it's always before any detached instance we
+		   might have */
+		icalcomponent_add_component (priv->icalcomp,
+					     e_cal_component_get_icalcomponent (obj_data->full_object));
+		priv->comp = g_list_prepend (priv->comp, obj_data->full_object);
+
+		/* add the new detached recurrence */
+		g_hash_table_insert (obj_data->recurrences, 
+				     g_strdup (e_cal_component_get_recurid_as_string (comp)),
+				     comp);
+		icalcomponent_add_component (priv->icalcomp,
+					     e_cal_component_get_icalcomponent (comp));
+		priv->comp = g_list_append (priv->comp, comp);
+		obj_data->recurrences_list = g_list_append (obj_data->recurrences_list, comp);
 		break;
 	case CALOBJ_MOD_ALL :
 		/* in this case, we blow away all recurrences, and start over
@@ -1837,62 +1955,17 @@ remove_instance (ECalBackendFile *cbfile
 	cbfile->priv->comp = g_list_prepend (cbfile->priv->comp, obj_data->full_object);
 }
 
-typedef struct {
-	ECalBackendFile *cbfile;
-	ECalBackendFileObject *obj_data;
-	const char *rid;
-	CalObjModType mod;
-} RemoveRecurrenceData;
-
-static gboolean
-remove_object_instance_cb (gpointer key, gpointer value, gpointer user_data)
-{
-	time_t fromtt, instancett;
-	GSList *categories;
-	char *rid = key;
-	ECalComponent *instance = value;
-	RemoveRecurrenceData *rrdata = user_data;
-
-	fromtt = icaltime_as_timet (icaltime_from_string (rrdata->rid));
-	instancett = icaltime_as_timet (get_rid_icaltime (instance));
-
-	if (fromtt > 0 && instancett > 0) {
-		if ((rrdata->mod == CALOBJ_MOD_THISANDPRIOR && instancett <= fromtt) ||
-		    (rrdata->mod == CALOBJ_MOD_THISANDFUTURE && instancett >= fromtt)) {
-			/* remove the component from our data */
-			icalcomponent_remove_component (rrdata->cbfile->priv->icalcomp,
-							e_cal_component_get_icalcomponent (instance));
-			rrdata->cbfile->priv->comp = g_list_remove (rrdata->cbfile->priv->comp, instance);
-
-			rrdata->obj_data->recurrences_list = g_list_remove (rrdata->obj_data->recurrences_list, instance);
-
-			/* update the set of categories */
-			e_cal_component_get_categories_list (instance, &categories);
-			e_cal_backend_unref_categories (E_CAL_BACKEND (rrdata->cbfile), categories);
-			e_cal_component_free_categories_list (categories);
-
-			/* free memory */
-			g_free (rid);
-			g_object_unref (instance);
-
-			return TRUE;
-		}
-	}
-
-	return FALSE;
-}
-
 /* Remove_object handler for the file backend */
 static ECalBackendSyncStatus
 e_cal_backend_file_remove_object (ECalBackendSync *backend, EDataCal *cal,
-				const char *uid, const char *rid,
-				CalObjModType mod, char **object)
+				  const char *uid, const char *rid,
+				  CalObjModType mod, char **old_object,
+				  char **object)
 {
 	ECalBackendFile *cbfile;
 	ECalBackendFilePrivate *priv;
 	ECalBackendFileObject *obj_data;
 	ECalComponent *comp;
-	GSList *categories;
 	RemoveRecurrenceData rrdata;
 
 	cbfile = E_CAL_BACKEND_FILE (backend);
@@ -1901,6 +1974,8 @@ e_cal_backend_file_remove_object (ECalBa
 	g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal);
 	g_return_val_if_fail (uid != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
 
+	*old_object = *object = NULL;
+
 	obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid);
 	if (!obj_data)
 		return GNOME_Evolution_Calendar_ObjectNotFound;
@@ -1909,14 +1984,19 @@ e_cal_backend_file_remove_object (ECalBa
 
 	switch (mod) {
 	case CALOBJ_MOD_ALL :
-		*object = e_cal_component_get_as_string (comp);
+		*old_object = e_cal_component_get_as_string (comp);
 		remove_component (cbfile, comp);
+		*object = NULL;
 		break;
 	case CALOBJ_MOD_THIS :
-		if (!rid || !*rid)
-			return GNOME_Evolution_Calendar_ObjectNotFound;
-
-		remove_instance (cbfile, obj_data, rid);
+		if (!rid || !*rid) {
+			*old_object = e_cal_component_get_as_string (comp);
+			remove_component (cbfile, comp);
+			*object = NULL;
+		} else {
+			remove_instance (cbfile, obj_data, rid);
+			*object = e_cal_component_get_as_string (obj_data->full_object);
+		}
 		break;
 	case CALOBJ_MOD_THISANDPRIOR :
 	case CALOBJ_MOD_THISANDFUTURE :
@@ -1942,6 +2022,8 @@ e_cal_backend_file_remove_object (ECalBa
 		   so that it's always before any detached instance we
 		   might have */
 		priv->comp = g_list_prepend (priv->comp, comp);
+
+		*object = e_cal_component_get_as_string (obj_data->full_object);
 		break;
 	}
 
@@ -2132,7 +2214,7 @@ e_cal_backend_file_receive_objects (ECal
 		case ICAL_METHOD_CANCEL:
 			if (cancel_received_object (cbfile, subcomp)) {
 				calobj = (char *) icalcomponent_as_ical_string (subcomp);
-				e_cal_backend_notify_object_removed (E_CAL_BACKEND (backend), icalcomponent_get_uid (subcomp), calobj);
+				e_cal_backend_notify_object_removed (E_CAL_BACKEND (backend), icalcomponent_get_uid (subcomp), calobj, NULL);
 
 				/* remove the component from the toplevel VCALENDAR */
 				icalcomponent_remove_component (toplevel_comp, subcomp);
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.14
retrieving revision 1.12.2.2
diff -u -p -r1.14 -r1.12.2.2
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.65
retrieving revision 1.64.2.2
diff -u -p -r1.65 -r1.64.2.2
--- backends/groupwise/e-cal-backend-groupwise.c	8 Apr 2004 14:18:32 -0000	1.65
+++ backends/groupwise/e-cal-backend-groupwise.c	8 Apr 2004 14:21:12 -0000	1.64.2.2
@@ -995,7 +995,8 @@ e_cal_backend_groupwise_modify_object (E
 static ECalBackendSyncStatus
 e_cal_backend_groupwise_remove_object (ECalBackendSync *backend, EDataCal *cal,
 				       const char *uid, const char *rid,
-				       CalObjModType mod, char **object)
+				       CalObjModType mod, char **old_object,
+				       char **object)
 {
 	ECalBackendGroupwise *cbgw;
         ECalBackendGroupwisePrivate *priv;
@@ -1003,6 +1004,8 @@ e_cal_backend_groupwise_remove_object (E
 	cbgw = E_CAL_BACKEND_GROUPWISE (backend);
 	priv = cbgw->priv;
 
+	*old_object = *object = NULL;
+
 	/* if online, remove the item from the server */
 	if (priv->mode == CAL_MODE_REMOTE) {
 		ECalBackendSyncStatus status;
@@ -1014,10 +1017,13 @@ e_cal_backend_groupwise_remove_object (E
 		if (status != GNOME_Evolution_Calendar_Success)
 			return status;
 
+		*old_object = calobj;
+
 		icalcomp = icalparser_parse_string (calobj);
-		g_free (calobj);
-		if (!icalcomp)
+		if (!icalcomp) {
+			g_free (calobj);
 			return GNOME_Evolution_Calendar_InvalidObject;
+		}
 
 		/* search the component for the X-EVOLUTION-GROUPWISE-ID property */
 		icalprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY);
@@ -1045,13 +1051,18 @@ e_cal_backend_groupwise_remove_object (E
 		icalcomponent_free (icalcomp);
 		if (status == E_GW_CONNECTION_STATUS_OK) {
 			/* remove the component from the cache */
-			if (!e_cal_backend_cache_remove_component (priv->cache, uid, rid))
+			if (!e_cal_backend_cache_remove_component (priv->cache, uid, rid)) {
+				g_free (calobj);
 				return GNOME_Evolution_Calendar_ObjectNotFound;
+			}
 			return GNOME_Evolution_Calendar_Success;
-		} else
+		} else {
+			g_free (calobj);
 			return GNOME_Evolution_Calendar_OtherError;
+		}
 
 		/* if there was no X-EVOLUTION-GROUPWISE-ID property, return NOT_FOUND */
+		g_free (calobj);
 		return GNOME_Evolution_Calendar_ObjectNotFound;
 	}
 
Index: backends/http/e-cal-backend-http.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/http/e-cal-backend-http.c,v
retrieving revision 1.17
retrieving revision 1.17.2.1
diff -u -p -r1.17 -r1.17.2.1
--- backends/http/e-cal-backend-http.c	31 Mar 2004 19:56:02 -0000	1.17
+++ backends/http/e-cal-backend-http.c	7 Apr 2004 10:58:35 -0000	1.17.2.1
@@ -720,7 +720,8 @@ e_cal_backend_http_modify_object (ECalBa
 static ECalBackendSyncStatus
 e_cal_backend_http_remove_object (ECalBackendSync *backend, EDataCal *cal,
 				const char *uid, const char *rid,
-				CalObjModType mod, char **object)
+				CalObjModType mod, char **old_object,
+				char **object)
 {
 	ECalBackendHttp *cbhttp;
 	ECalBackendHttpPrivate *priv;
@@ -729,6 +730,8 @@ e_cal_backend_http_remove_object (ECalBa
 	priv = cbhttp->priv;
 
 	g_return_val_if_fail (uid != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
+
+	*old_object = *object = NULL;
 
 	return GNOME_Evolution_Calendar_PermissionDenied;
 }
Index: idl/Evolution-DataServer-Calendar.idl
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/idl/Evolution-DataServer-Calendar.idl,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -p -r1.5 -r1.5.2.1
--- idl/Evolution-DataServer-Calendar.idl	1 Mar 2004 15:45:57 -0000	1.5
+++ idl/Evolution-DataServer-Calendar.idl	8 Apr 2004 14:21:12 -0000	1.5.2.1
@@ -140,7 +140,7 @@ module Calendar {
 	/* Listener for changes in a query of a calendar */
 	interface CalViewListener : Bonobo::Unknown {
 		oneway void notifyObjectsAdded (in stringlist objects);		
-		oneway void notifyObjectsModified (in stringlist objects);		
+		oneway void notifyObjectsModified (in stringlist objects);
 		oneway void notifyObjectsRemoved (in CalObjUIDSeq uids);
 		oneway void notifyQueryProgress (in string message, in short percent);
 		oneway void notifyQueryDone (in CallStatus status);
Index: libecal/e-cal.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libecal/e-cal.c,v
retrieving revision 1.54
retrieving revision 1.53.2.1
diff -u -p -r1.54 -r1.53.2.1
Index: libedata-cal/e-cal-backend-sync.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libedata-cal/e-cal-backend-sync.c,v
retrieving revision 1.8
retrieving revision 1.8.2.2
diff -u -p -r1.8 -r1.8.2.2
--- libedata-cal/e-cal-backend-sync.c	25 Mar 2004 13:30:31 -0000	1.8
+++ libedata-cal/e-cal-backend-sync.c	7 Apr 2004 10:58:35 -0000	1.8.2.2
@@ -128,13 +128,14 @@ e_cal_backend_sync_modify_object (ECalBa
 
 ECalBackendSyncStatus
 e_cal_backend_sync_remove_object (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *rid,
-				CalObjModType mod, char **object)
+				CalObjModType mod, char **old_object, char **object)
 {
 	g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
 
 	g_assert (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->remove_object_sync);
 
-	return (* E_CAL_BACKEND_SYNC_GET_CLASS (backend)->remove_object_sync) (backend, cal, uid, rid, mod, object);
+	return (* E_CAL_BACKEND_SYNC_GET_CLASS (backend)->remove_object_sync) (backend, cal, uid, rid, mod,
+									       old_object, object);
 }
 
 ECalBackendSyncStatus
@@ -375,11 +376,11 @@ static void
 _e_cal_backend_remove_object (ECalBackend *backend, EDataCal *cal, const char *uid, const char *rid, CalObjModType mod)
 {
 	ECalBackendSyncStatus status;
-	char *object = NULL;
+	char *object = NULL, *old_object = NULL;
 	
-	status = e_cal_backend_sync_remove_object (E_CAL_BACKEND_SYNC (backend), cal, uid, rid, mod, &object);
+	status = e_cal_backend_sync_remove_object (E_CAL_BACKEND_SYNC (backend), cal, uid, rid, mod, &old_object, &object);
 
-	e_data_cal_notify_object_removed (cal, status, uid, object);
+	e_data_cal_notify_object_removed (cal, status, uid, old_object, object);
 }
 
 static void
Index: libedata-cal/e-cal-backend-sync.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libedata-cal/e-cal-backend-sync.h,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -p -r1.6 -r1.6.2.1
--- libedata-cal/e-cal-backend-sync.h	25 Mar 2004 13:30:31 -0000	1.6
+++ libedata-cal/e-cal-backend-sync.h	7 Apr 2004 10:58:35 -0000	1.6.2.1
@@ -44,7 +44,7 @@ struct _ECalBackendSyncClass {
 
 	ECalBackendSyncStatus (*create_object_sync)  (ECalBackendSync *backend, EDataCal *cal, char **calobj, char **uid);
 	ECalBackendSyncStatus (*modify_object_sync)  (ECalBackendSync *backend, EDataCal *cal, const char *calobj, CalObjModType mod, char **old_object);
-	ECalBackendSyncStatus (*remove_object_sync)  (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *rid, CalObjModType mod, char **object);
+	ECalBackendSyncStatus (*remove_object_sync)  (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *rid, CalObjModType mod, char **old_object, char **object);
 
 	ECalBackendSyncStatus (*discard_alarm_sync)  (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *auid);
 
@@ -110,6 +110,7 @@ ECalBackendSyncStatus e_cal_backend_sync
 							       const char      *uid,
 							       const char      *rid,
 							       CalObjModType    mod,
+							       char **old_object,
 							       char **object);
 ECalBackendSyncStatus e_cal_backend_sync_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *auid);
 
Index: libedata-cal/e-cal-backend.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libedata-cal/e-cal-backend.c,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -p -r1.5 -r1.5.2.1
--- libedata-cal/e-cal-backend.c	1 Mar 2004 15:46:01 -0000	1.5
+++ libedata-cal/e-cal-backend.c	6 Apr 2004 12:13:21 -0000	1.5.2.1
@@ -1003,6 +1003,26 @@ e_cal_backend_notify_object_created (ECa
 	g_object_unref (queries);
 }
 
+static void
+match_query_and_notify (EDataCalView *query, const char *old_object, const char *object)
+{
+	gboolean old_match, new_match;
+
+	old_match = e_data_cal_view_object_matches (query, old_object);
+	new_match = e_data_cal_view_object_matches (query, object);
+	if (old_match && new_match)
+		e_data_cal_view_notify_objects_modified_1 (query, object);
+	else if (new_match)
+		e_data_cal_view_notify_objects_added_1 (query, object);
+	else /* if (old_match) */ {
+		icalcomponent *icalcomp;
+		
+		icalcomp = icalcomponent_new_from_string ((char *) old_object);
+		e_data_cal_view_notify_objects_removed_1 (query, icalcomponent_get_uid (icalcomp));
+		icalcomponent_free (icalcomp);
+	}
+}
+
 /**
  * e_cal_backend_notify_object_modified:
  * @backend: A calendar backend.
@@ -1017,13 +1037,12 @@ e_cal_backend_notify_object_created (ECa
  **/
 void
 e_cal_backend_notify_object_modified (ECalBackend *backend, 
-				    const char *old_object, const char *object)
+				      const char *old_object, const char *object)
 {
 	ECalBackendPrivate *priv;
 	EList *queries;
 	EIterator *iter;
 	EDataCalView *query;
-	gboolean old_match, new_match;
 
 	priv = backend->priv;
 
@@ -1037,23 +1056,9 @@ e_cal_backend_notify_object_modified (EC
 
 	while (e_iterator_is_valid (iter)) {
 		query = QUERY (e_iterator_get (iter));
-		
-		bonobo_object_ref (query);
-
-		old_match = e_data_cal_view_object_matches (query, old_object);
-		new_match = e_data_cal_view_object_matches (query, object);
-		if (old_match && new_match)
-			e_data_cal_view_notify_objects_modified_1 (query, object);
-		else if (new_match)
-			e_data_cal_view_notify_objects_added_1 (query, object);
-		else /* if (old_match) */ {
-			icalcomponent *comp;
-
-			comp = icalcomponent_new_from_string ((char *)old_object);
-			e_data_cal_view_notify_objects_removed_1 (query, icalcomponent_get_uid (comp));
-			icalcomponent_free (comp);
-		}
 
+		bonobo_object_ref (query);
+		match_query_and_notify (query, old_object, object);
 		bonobo_object_unref (query);
 
 		e_iterator_next (iter);
@@ -1067,6 +1072,9 @@ e_cal_backend_notify_object_modified (EC
  * @backend: A calendar backend.
  * @uid: the UID of the removed object
  * @old_object: iCalendar representation of the removed object
+ * @new_object: iCalendar representation of the object after the removal. This
+ * only applies to recurrent appointments that had an instance removed. In that
+ * case, this function notifies a modification instead of a removal.
  *
  * Notifies each of the backend's listeners about a removed object.
  *
@@ -1076,7 +1084,7 @@ e_cal_backend_notify_object_modified (EC
  **/
 void
 e_cal_backend_notify_object_removed (ECalBackend *backend, const char *uid,
-				   const char *old_object)
+				     const char *old_object, const char *object)
 {
 	ECalBackendPrivate *priv;
 	EList *queries;
@@ -1086,7 +1094,7 @@ e_cal_backend_notify_object_removed (ECa
 	priv = backend->priv;
 
 	if (priv->notification_proxy) {
-		e_cal_backend_notify_object_removed (priv->notification_proxy, uid, old_object);
+		e_cal_backend_notify_object_removed (priv->notification_proxy, uid, old_object, NULL);
 		return;
 	}
 
@@ -1097,8 +1105,15 @@ e_cal_backend_notify_object_removed (ECa
 		query = QUERY (e_iterator_get (iter));
 
 		bonobo_object_ref (query);
-		if (e_data_cal_view_object_matches (query, old_object))
-			e_data_cal_view_notify_objects_removed_1 (query, uid);
+
+		if (object == NULL) {
+			/* if object == NULL, it means the object has been completely
+			   removed from the backend */
+			if (e_data_cal_view_object_matches (query, old_object))
+				e_data_cal_view_notify_objects_removed_1 (query, uid);
+		} else
+			match_query_and_notify (query, old_object, object);
+
 		bonobo_object_unref (query);
 
 		e_iterator_next (iter);
Index: libedata-cal/e-cal-backend.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libedata-cal/e-cal-backend.h,v
retrieving revision 1.6
retrieving revision 1.6.4.1
diff -u -p -r1.6 -r1.6.4.1
--- libedata-cal/e-cal-backend.h	19 Dec 2003 16:29:33 -0000	1.6
+++ libedata-cal/e-cal-backend.h	6 Apr 2004 12:13:21 -0000	1.6.4.1
@@ -165,7 +165,7 @@ void e_cal_backend_last_client_gone (ECa
 void e_cal_backend_set_notification_proxy (ECalBackend *backend, ECalBackend *proxy);
 void e_cal_backend_notify_object_created  (ECalBackend *backend, const char *calobj);
 void e_cal_backend_notify_object_modified (ECalBackend *backend, const char *old_object, const char *object);
-void e_cal_backend_notify_object_removed  (ECalBackend *backend, const char *uid, const char *old_object);
+void e_cal_backend_notify_object_removed  (ECalBackend *backend, const char *uid, const char *old_object, const char *object);
 
 void e_cal_backend_notify_mode      (ECalBackend *backend,
 				   GNOME_Evolution_Calendar_CalListener_SetModeStatus status, 
Index: libedata-cal/e-data-cal.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libedata-cal/e-data-cal.c,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -p -r1.7 -r1.7.2.1
--- libedata-cal/e-data-cal.c	11 Mar 2004 15:15:13 -0000	1.7
+++ libedata-cal/e-data-cal.c	6 Apr 2004 12:13:21 -0000	1.7.2.1
@@ -822,7 +822,7 @@ e_data_cal_notify_object_modified (EData
 
 void
 e_data_cal_notify_object_removed (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, 
-				  const char *uid, const char *object)
+				  const char *uid, const char *old_object, const char *object)
 {
 	EDataCalPrivate *priv;
 	CORBA_Environment ev;
@@ -834,7 +834,7 @@ e_data_cal_notify_object_removed (EDataC
 	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
 
 	if (status == GNOME_Evolution_Calendar_Success)
-		e_cal_backend_notify_object_removed (priv->backend, uid, object);
+		e_cal_backend_notify_object_removed (priv->backend, uid, old_object, object);
 
 	CORBA_exception_init (&ev);
 	GNOME_Evolution_Calendar_CalListener_notifyObjectRemoved (priv->listener, status, &ev);
Index: libedata-cal/e-data-cal.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libedata-cal/e-data-cal.h,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -p -r1.5 -r1.5.2.1
--- libedata-cal/e-data-cal.h	1 Mar 2004 15:46:01 -0000	1.5
+++ libedata-cal/e-data-cal.h	6 Apr 2004 12:13:21 -0000	1.5.2.1
@@ -83,7 +83,7 @@ void e_data_cal_notify_object_created  (
 void e_data_cal_notify_object_modified (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, 
 					const char *old_object, const char *object);
 void e_data_cal_notify_object_removed  (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, 
-					const char *uid, const char *object);
+					const char *uid, const char *old_object, const char *object);
 void e_data_cal_notify_alarm_discarded (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status);
 
 void e_data_cal_notify_objects_received (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status);


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