Index: calendar/backends/http/e-cal-backend-http.c
===================================================================
--- calendar/backends/http/e-cal-backend-http.c	(revision 8197)
+++ calendar/backends/http/e-cal-backend-http.c	(working copy)
@@ -337,15 +337,15 @@
 		if (subcomp_kind == kind) {
 			comp = e_cal_component_new ();
 			if (e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (subcomp))) {
-				const char *uid, *orig_key, *orig_value;
+				const char *uid;
+				void *orig_key, *orig_value;
 
 				e_cal_backend_cache_put_component (priv->cache, comp);
 
 				e_cal_component_get_uid (comp, &uid);
-				/* middle (void*) cast only because of 'dereferencing type-punned pointer will break strict-aliasing rules' */
-				if (g_hash_table_lookup_extended (old_cache, uid, (void **)(void*)&orig_key, (void **)(void*)&orig_value)) {
+				if (g_hash_table_lookup_extended (old_cache, uid, &orig_key, &orig_value)) {
 					e_cal_backend_notify_object_modified (E_CAL_BACKEND (cbhttp),
-									      orig_value,
+									      (const char *) orig_value,
 									      icalcomponent_as_ical_string (subcomp));
 					g_hash_table_remove (old_cache, uid);
 				} else {
Index: calendar/backends/caldav/e-cal-backend-caldav.c
===================================================================
--- calendar/backends/caldav/e-cal-backend-caldav.c	(revision 8197)
+++ calendar/backends/caldav/e-cal-backend-caldav.c	(working copy)
@@ -1367,7 +1367,6 @@
 	bkend = E_CAL_BACKEND (cbdav);
 	
 	if (kind == ICAL_VCALENDAR_COMPONENT) {
-	
 		kind = e_cal_backend_get_kind (bkend);
 		subcomp = icalcomponent_get_first_component (icomp, kind);
 
@@ -2073,6 +2072,35 @@
 	return GNOME_Evolution_Calendar_Success;
 }
 
+static void
+remove_subcomps (icalcomponent *icomp, icalcomponent_kind ekind)
+{
+	GList *del_comps, *p;
+	icalcomponent *subcomp;
+	icalcomponent_kind kind;
+
+	g_return_if_fail (icomp != NULL);
+
+	del_comps = NULL;
+	for (subcomp = icalcomponent_get_first_component (icomp, ICAL_ANY_COMPONENT);
+	     subcomp;
+	     subcomp = icalcomponent_get_next_component (icomp, ICAL_ANY_COMPONENT)) {
+		kind = icalcomponent_isa (subcomp);
+
+		if (kind != ekind && kind != ICAL_VTIMEZONE_COMPONENT)
+			del_comps = g_list_prepend (del_comps, subcomp);
+	}
+
+	for (p = del_comps; p; p = p->next) {
+		subcomp = p->data;
+
+		icalcomponent_remove_component (icomp, subcomp);
+		icalcomponent_free (subcomp);		
+	}
+
+	g_list_free (del_comps);
+}
+
 /* FIXME: use list here? */
 static ECalBackendSyncStatus
 extract_objects (icalcomponent       *icomp,
@@ -2085,10 +2113,11 @@
 	g_return_val_if_fail (icomp, GNOME_Evolution_Calendar_OtherError);
 	g_return_val_if_fail (objects, GNOME_Evolution_Calendar_OtherError);
 	
+	*objects = NULL;
 	kind = icalcomponent_isa (icomp);
-	
 	if (kind == ekind) {
-		*objects = g_list_prepend (NULL, icomp);
+		remove_subcomps (icomp, ekind);
+		*objects = g_list_prepend (*objects, icomp);
 		return GNOME_Evolution_Calendar_Success;
 	}
 
@@ -2307,8 +2336,7 @@
 		return GNOME_Evolution_Calendar_InvalidObject;
 	}
 
-	/* FIXME: use the e_cal_backend_xxx_kind call here */
-	kind = ICAL_VEVENT_COMPONENT;
+	kind = e_cal_backend_get_kind (E_CAL_BACKEND (backend));
 	status = extract_objects (icomp, kind, &objects);
 
 	if (status != GNOME_Evolution_Calendar_Success) {
Index: calendar/backends/caldav/e-cal-backend-caldav-factory.c
===================================================================
--- calendar/backends/caldav/e-cal-backend-caldav-factory.c	(revision 8197)
+++ calendar/backends/caldav/e-cal-backend-caldav-factory.c	(working copy)
@@ -28,11 +28,11 @@
 #include "e-cal-backend-caldav.h"
 
 typedef struct {
-	   ECalBackendFactory parent_object;
+	ECalBackendFactory parent_object;
 } ECalBackendCalDAVFactory;
 
 typedef struct {
-	   ECalBackendFactoryClass parent_class;
+	ECalBackendFactoryClass parent_class;
 } ECalBackendCalDAVFactoryClass;
 
 static void
@@ -46,71 +46,81 @@
 	   return "caldav";
 }
 
-static ECalBackend*
-_events_new_backend (ECalBackendFactory *factory, ESource *source)
-{
-	   return g_object_new (E_TYPE_CAL_BACKEND_CALDAV,
-					    "source", source,
-					    "kind", ICAL_VEVENT_COMPONENT,
-					    NULL);
-}
+#define def_type_functions(factory_name, comp_kind, new_backend_func, get_kind_func, class_init_func, get_type_func) \
+										\
+static ECalBackend *								\
+new_backend_func (ECalBackendFactory *factory, ESource *source)			\
+{										\
+	return g_object_new (E_TYPE_CAL_BACKEND_CALDAV,				\
+			     "source", source,					\
+			     "kind", comp_kind,					\
+			     NULL);						\
+}										\
+										\
+static icalcomponent_kind							\
+get_kind_func (ECalBackendFactory *factory)					\
+{										\
+	return comp_kind;							\
+}										\
+										\
+static void									\
+class_init_func (ECalBackendCalDAVFactoryClass *klass)				\
+{										\
+	E_CAL_BACKEND_FACTORY_CLASS (klass)->get_protocol = _get_protocol;	\
+	E_CAL_BACKEND_FACTORY_CLASS (klass)->get_kind     = get_kind_func;	\
+	E_CAL_BACKEND_FACTORY_CLASS (klass)->new_backend  = new_backend_func;	\
+}										\
+										\
+static GType									\
+get_type_func (GTypeModule *module)						\
+{										\
+	GType type;								\
+										\
+	GTypeInfo info = {							\
+		sizeof (ECalBackendCalDAVFactoryClass),				\
+		NULL,								\
+		NULL, 								\
+		(GClassInitFunc)  class_init_func,				\
+		NULL, 								\
+		NULL,								\
+		sizeof (ECalBackend),						\
+		0,    								\
+		(GInstanceInitFunc) e_cal_backend_caldav_factory_instance_init	\
+	};									\
+										\
+	type = g_type_module_register_type (module,				\
+					    E_TYPE_CAL_BACKEND_FACTORY,		\
+					    factory_name,			\
+					    &info, 0);				\
+										\
+	return type;								\
+}										\
 
-static icalcomponent_kind
-_events_get_kind (ECalBackendFactory *factory)
-{
-	   return ICAL_VEVENT_COMPONENT;
-}
 
-static void
-events_backend_factory_class_init (ECalBackendCalDAVFactoryClass *klass)
-{
-	   E_CAL_BACKEND_FACTORY_CLASS (klass)->get_protocol = _get_protocol;
-	   E_CAL_BACKEND_FACTORY_CLASS (klass)->get_kind     = _events_get_kind;
-	   E_CAL_BACKEND_FACTORY_CLASS (klass)->new_backend  = _events_new_backend;
-}
+def_type_functions ("ECalBackendCalDAVEventsFactory", ICAL_VEVENT_COMPONENT,   _events_new_backend, _events_get_kind, _events_class_init, events_backend_factory_get_type)
+def_type_functions ("ECalBackendCalDAVTasksFactory",  ICAL_VTODO_COMPONENT,    _tasks_new_backend,  _tasks_get_kind,  _tasks_class_init,  tasks_backend_factory_get_type)
+def_type_functions ("ECalBackendCalDAVMemosFactory",  ICAL_VJOURNAL_COMPONENT, _memos_new_backend,  _memos_get_kind,  _memos_class_init,  memos_backend_factory_get_type)
 
-static GType
-events_backend_factory_get_type (GTypeModule *module)
-{
-	   GType type;
+/* ------------------------------------------------------------------------ */
 
-	   GTypeInfo info = {
-			 sizeof (ECalBackendCalDAVFactoryClass),
-			 NULL, /* base_class_init */
-			 NULL, /* base_class_finalize */
-			 (GClassInitFunc)  events_backend_factory_class_init,
-			 NULL, /* class_finalize */
-			 NULL, /* class_data */
-			 sizeof (ECalBackend),
-			 0,    /* n_preallocs */
-			 (GInstanceInitFunc) e_cal_backend_caldav_factory_instance_init
-	   };
+static GType caldav_types[3];
 
-	   type = g_type_module_register_type (module,
-								    E_TYPE_CAL_BACKEND_FACTORY,
-								    "ECalBackendCalDAVEventsFactory",
-								    &info, 0);
-
-	   return type;
-}
-
-
-static GType caldav_types[1];
-
 void
 eds_module_initialize (GTypeModule *module)
 {
-	   caldav_types[0] = events_backend_factory_get_type (module);
+	caldav_types[0] = events_backend_factory_get_type (module);
+	caldav_types[1] = tasks_backend_factory_get_type (module);
+	caldav_types[2] = memos_backend_factory_get_type (module);
 }
 
 void
-eds_module_shutdown   (void)
+eds_module_shutdown (void)
 {
 }
 
 void
 eds_module_list_types (const GType **types, int *num_types)
 {
-	   *types = caldav_types;
-	   *num_types = 1;
+	*types = caldav_types;
+	*num_types = 3;
 }
