Re: [evolution-patches] patch from the recurrences-work branch



On Tue, 2004-05-18 at 12:35 +0000, Rodrigo Moya wrote:
> The attached patch is coming from the recurrences-work-branch, and makes
> the file calendar backend deal correctly with any detached instance
> there might be in the .ics file.
> 
> This is useful even if we don't support fully detached instances, since
> users might get that sort of instances from meetings, from webcal
> calendars, etc.
> 
updated patch, that removes a g_warning that was being issued for each
detached recurrence, and makes sure all detached recurrences are
returned.

cheers
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.269
diff -u -p -r1.269 ChangeLog
--- ChangeLog	18 May 2004 14:51:51 -0000	1.269
+++ ChangeLog	18 May 2004 17:39:45 -0000
@@ -1,5 +1,12 @@
 2004-05-18  Rodrigo Moya <rodrigo ximian com>
 
+	* backends/file/e-cal-backend-file.c (add_component): make sure we
+	process correctly the detached instances.
+	(match_object_sexp): deal with hash table entries not containing
+	a full_object (ie, detached recurrences).
+
+2004-05-18  Rodrigo Moya <rodrigo ximian com>
+
 	* libedata-cal/e-cal-backend-sexp.c (func_occur_in_time_range): always
 	use a valid timezone.
 
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.30
diff -u -p -r1.30 e-cal-backend-file.c
--- backends/file/e-cal-backend-file.c	17 May 2004 15:01:17 -0000	1.30
+++ backends/file/e-cal-backend-file.c	18 May 2004 17:39:46 -0000
@@ -403,38 +403,46 @@ add_component (ECalBackendFile *cbfile, 
 
 	priv = cbfile->priv;
 
-	if (e_cal_component_is_instance (comp)) { /* FIXME: more checks needed, to detect detached instances */
+	e_cal_component_get_uid (comp, &uid);
+	obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid);
+	if (e_cal_component_is_instance (comp)) {
 		const char *rid;
-
-		e_cal_component_get_uid (comp, &uid);
-
-		obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid);
-		if (!obj_data) {
-			g_warning (G_STRLOC ": Got an instance of a non-existing component");
-			return;
-		}
-
+	
 		rid = e_cal_component_get_recurid_as_string (comp);
-		if (g_hash_table_lookup (obj_data->recurrences, rid)) {
-			g_warning (G_STRLOC ": Tried to adding an already existing recurrence");
-			return;
+		if (obj_data) {
+			if (g_hash_table_lookup (obj_data->recurrences, rid)) {
+				g_warning (G_STRLOC ": Tried to add an already existing recurrence");
+				return;
+			}
+		} else {
+			obj_data = g_new0 (ECalBackendFileObject, 1);
+			obj_data->full_object = NULL;
+			obj_data->recurrences = g_hash_table_new (g_str_hash, g_str_equal);
+			g_hash_table_insert (priv->comp_uid_hash, (gpointer) uid, obj_data);
 		}
 
 		g_hash_table_insert (obj_data->recurrences, g_strdup (rid), comp);
-		/* FIXME: sort the recurrences */
 		obj_data->recurrences_list = g_list_append (obj_data->recurrences_list, comp);
 	} else {
 		/* Ensure that the UID is unique; some broken implementations spit
 		 * components with duplicated UIDs.
 		 */
 		check_dup_uid (cbfile, comp);
-		e_cal_component_get_uid (comp, &uid);
 
-		obj_data = g_new0 (ECalBackendFileObject, 1);
-		obj_data->full_object = comp;
-		obj_data->recurrences = g_hash_table_new (g_str_hash, g_str_equal);
+		if (obj_data) {
+			if (obj_data->full_object) {
+				g_warning (G_STRLOC ": Tried to add an already existing object");
+				return;
+			}
+
+			obj_data->full_object = comp;
+		} else {
+			obj_data = g_new0 (ECalBackendFileObject, 1);
+			obj_data->full_object = comp;
+			obj_data->recurrences = g_hash_table_new (g_str_hash, g_str_equal);
 
-		g_hash_table_insert (priv->comp_uid_hash, (gpointer) uid, obj_data);
+			g_hash_table_insert (priv->comp_uid_hash, (gpointer) uid, obj_data);
+		}
 	}
 
 	priv->comp = g_list_prepend (priv->comp, comp);
@@ -1164,16 +1172,18 @@ match_object_sexp (gpointer key, gpointe
 	ECalBackendFileObject *obj_data = value;
 	MatchObjectData *match_data = data;
 
-	if ((!match_data->search_needed) ||
-	    (e_cal_backend_sexp_match_comp (match_data->obj_sexp, obj_data->full_object, match_data->backend))) {
-		match_data->obj_list = g_list_append (match_data->obj_list,
-						      e_cal_component_get_as_string (obj_data->full_object));
-
-		/* match also recurrences */
-		g_hash_table_foreach (obj_data->recurrences,
-				      (GHFunc) match_recurrence_sexp,
-				      match_data);
+	if (obj_data->full_object) {
+		if ((!match_data->search_needed) ||
+		    (e_cal_backend_sexp_match_comp (match_data->obj_sexp, obj_data->full_object, match_data->backend))) {
+			match_data->obj_list = g_list_append (match_data->obj_list,
+							      e_cal_component_get_as_string (obj_data->full_object));
+		}
 	}
+
+	/* match also recurrences */
+	g_hash_table_foreach (obj_data->recurrences,
+			      (GHFunc) match_recurrence_sexp,
+			      match_data);
 }
 
 /* Get_objects_in_range handler for the file backend */


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