[evolution-data-server] Migrate caldav, groupwise, http, weather backends to ECalBackendStore.



commit 6ee75ec7e02dd41009c110ebac1ae26e5fc6ac42
Author: Chenthill Palanisamy <pchenthill novell com>
Date:   Fri Jul 24 14:02:16 2009 +0530

    Migrate caldav, groupwise, http, weather backends to ECalBackendStore.

 calendar/backends/caldav/e-cal-backend-caldav.c    |  171 ++++++----------
 .../groupwise/e-cal-backend-groupwise-utils.c      |    4 +-
 .../backends/groupwise/e-cal-backend-groupwise.c   |  213 +++++++++++---------
 calendar/backends/http/e-cal-backend-http.c        |  135 ++++++++-----
 calendar/backends/weather/e-cal-backend-weather.c  |   66 ++++---
 calendar/libedata-cal/e-cal-backend-file-store.c   |    2 +-
 calendar/libedata-cal/e-cal-backend-store.c        |    1 -
 7 files changed, 304 insertions(+), 288 deletions(-)
---
diff --git a/calendar/backends/caldav/e-cal-backend-caldav.c b/calendar/backends/caldav/e-cal-backend-caldav.c
index 052cbf5..08fb02a 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -34,6 +34,7 @@
 #include <libecal/e-cal-util.h>
 #include <libecal/e-cal-time-util.h>
 #include <libedata-cal/e-cal-backend-cache.h>
+#include <libedata-cal/e-cal-backend-file-store.h>
 #include <libedata-cal/e-cal-backend-util.h>
 #include <libedata-cal/e-cal-backend-sexp.h>
 
@@ -72,7 +73,7 @@ struct _ECalBackendCalDAVPrivate {
 	CalMode mode;
 
 	/* The local disk cache */
-	ECalBackendCache *cache;
+	ECalBackendStore *store;
 
 	/* local attachments store */
 	gchar *local_attachments_store;
@@ -85,8 +86,6 @@ struct _ECalBackendCalDAVPrivate {
 
 	/* lock to indicate a busy state */
 	GMutex *busy_lock;
-	/* lock to protect cache */
-	GStaticRecMutex cache_lock;
 
 	/* cond to synch threads */
 	GCond *cond;
@@ -1056,9 +1055,7 @@ check_calendar_changed_on_server (ECalBackendCalDAV *cbdav)
 		if (parse_propfind_response (message, XPATH_GETCTAG_STATUS, XPATH_GETCTAG, &ctag)) {
 			const gchar *my_ctag;
 
-			g_static_rec_mutex_lock (&priv->cache_lock);
-			my_ctag = e_cal_backend_cache_get_key_value (priv->cache, CALDAV_CTAG_KEY);
-			g_static_rec_mutex_unlock (&priv->cache_lock);
+			my_ctag = e_cal_backend_store_get_key_value (priv->store, CALDAV_CTAG_KEY);
 
 			if (ctag && my_ctag && g_str_equal (ctag, my_ctag)) {
 				/* ctag is same, no change in the calendar */
@@ -1612,7 +1609,7 @@ remove_complist_from_cache_and_notify_cb (gpointer key, gpointer value, gpointer
 			continue;
 		}
 
-		if (e_cal_backend_cache_remove_component (priv->cache, id->uid, id->rid)) {
+		if (e_cal_backend_store_remove_component (priv->store, id->uid, id->rid)) {
 			gchar *old_str = e_cal_component_get_as_string (old_comp);
 
 			e_cal_backend_notify_object_removed ((ECalBackend *)cbdav, id, old_str, NULL);
@@ -1653,7 +1650,7 @@ synchronize_cache (ECalBackendCalDAV *cbdav, time_t start_time, time_t end_time)
 	ECalBackendCalDAVPrivate *priv;
 	ECalBackend *bkend;
 	CalDAVObject *sobjs, *object;
-	GList *c_objs, *c_iter; /* list of all items known from our cache */
+	GSList *c_objs, *c_iter; /* list of all items known from our cache */
 	GTree *c_uid2complist;  /* cache components list (with detached instances) sorted by (master's) uid */
 	GHashTable *c_href2uid; /* connection between href and a (master's) uid */
 	GSList *hrefs_to_update, *htu; /* list of href-s to update */
@@ -1673,22 +1670,20 @@ synchronize_cache (ECalBackendCalDAV *cbdav, time_t start_time, time_t end_time)
 	if (!caldav_server_list_objects (cbdav, &sobjs, &len, NULL, start_time, end_time))
 		return;
 
-	g_static_rec_mutex_lock (&priv->cache_lock);
-	c_objs = e_cal_backend_cache_get_components (priv->cache);
-	g_static_rec_mutex_unlock (&priv->cache_lock);
+	c_objs = e_cal_backend_store_get_components (priv->store);
 
 	if (caldav_debug_show (DEBUG_SERVER_ITEMS)) {
-		printf ("CalDAV - found %d objects on the server, locally stored %d objects\n", len, g_list_length (c_objs)); fflush (stdout);
+		printf ("CalDAV - found %d objects on the server, locally stored %d objects\n", len, g_slist_length (c_objs)); fflush (stdout);
 	}
 
 	/* do not store changes in cache immediately - makes things significantly quicker */
-	e_file_cache_freeze_changes (E_FILE_CACHE (priv->cache));
+	e_cal_backend_store_freeze_changes (priv->store);
 
 	c_uid2complist = g_tree_new_full ((GCompareDataFunc)g_strcmp0, NULL, g_free, free_comp_list);
 	c_href2uid = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
 
 	/* fill indexed hash and tree with cached components */
-	for (c_iter = c_objs; c_iter; c_iter = g_list_next (c_iter)) {
+	for (c_iter = c_objs; c_iter; c_iter = g_slist_next (c_iter)) {
 		ECalComponent *ccomp = E_CAL_COMPONENT (c_iter->data);
 		const gchar *uid = NULL;
 		struct cache_comp_list *ccl;
@@ -1731,8 +1726,8 @@ synchronize_cache (ECalBackendCalDAV *cbdav, time_t start_time, time_t end_time)
 	}
 
 	/* clear it now, we do not need it later */
-	g_list_foreach (c_objs, (GFunc) g_object_unref, NULL);
-	g_list_free (c_objs);
+	g_slist_foreach (c_objs, (GFunc) g_object_unref, NULL);
+	g_slist_free (c_objs);
 	c_objs = NULL;
 
 	hrefs_to_update = NULL;
@@ -1821,8 +1816,6 @@ synchronize_cache (ECalBackendCalDAV *cbdav, time_t start_time, time_t end_time)
 			}
 
 			/* we are going to update cache */
-			g_static_rec_mutex_lock (&priv->cache_lock);
-
 			/* they are downloaded, so process them */
 			for (i = 0, object = up_sobjs; i < count /*&& priv->slave_cmd == SLAVE_SHOULD_WORK*/; i++, object++) {
 				if (object->status == 200 && object->href && object->etag && object->cdata && *object->cdata) {
@@ -1881,7 +1874,7 @@ synchronize_cache (ECalBackendCalDAV *cbdav, time_t start_time, time_t end_time)
 										g_free (nc_rid);
 									}
 
-									e_cal_backend_cache_put_component (priv->cache, new_comp);
+									e_cal_backend_store_put_component (priv->store, new_comp);
 
 									if (old_comp == NULL) {
 										gchar *new_str = e_cal_component_get_as_string (new_comp);
@@ -1916,7 +1909,6 @@ synchronize_cache (ECalBackendCalDAV *cbdav, time_t start_time, time_t end_time)
 			}
 
 			/* cache update done for fetched items */
-			g_static_rec_mutex_unlock (&priv->cache_lock);
 		}
 
 		/* do not free 'data' itself, it's part of 'sobjs' */
@@ -1926,17 +1918,13 @@ synchronize_cache (ECalBackendCalDAV *cbdav, time_t start_time, time_t end_time)
 	/* if not interrupted and not using the time range... */
 	if (priv->slave_cmd == SLAVE_SHOULD_WORK && (!start_time || !end_time)) {
 		/* ...remove old (not on server anymore) items from our cache and notify of a removal */
-		g_static_rec_mutex_lock (&priv->cache_lock);
 		g_tree_foreach (c_uid2complist, remove_complist_from_cache_and_notify_cb, cbdav);
-		g_static_rec_mutex_unlock (&priv->cache_lock);
 	}
 
 	if (priv->ctag_to_store) {
 		/* store only when wasn't interrupted */
 		if (priv->slave_cmd == SLAVE_SHOULD_WORK && start_time == 0 && end_time == 0) {
-			g_static_rec_mutex_lock (&priv->cache_lock);
-			e_cal_backend_cache_put_key_value (priv->cache, CALDAV_CTAG_KEY, priv->ctag_to_store);
-			g_static_rec_mutex_unlock (&priv->cache_lock);
+			e_cal_backend_store_put_key_value (priv->store, CALDAV_CTAG_KEY, priv->ctag_to_store);
 		}
 
 		g_free (priv->ctag_to_store);
@@ -1944,7 +1932,7 @@ synchronize_cache (ECalBackendCalDAV *cbdav, time_t start_time, time_t end_time)
 	}
 
 	/* save cache changes to disk finally */
-	e_file_cache_thaw_changes (E_FILE_CACHE (priv->cache));
+	e_cal_backend_store_thaw_changes (priv->store);
 
 	for (i = 0, object = sobjs; i < len; i++, object++) {
 		caldav_object_free (object, FALSE);
@@ -1993,16 +1981,14 @@ caldav_synch_slave_loop (gpointer data)
 		}
 
 		if (caldav_debug_show (DEBUG_SERVER_ITEMS)) {
-			GList *c_objs;
+			GSList *c_objs;
 
-			g_static_rec_mutex_lock (&priv->cache_lock);
-			c_objs = e_cal_backend_cache_get_components (priv->cache);
-			g_static_rec_mutex_unlock (&priv->cache_lock);
+			c_objs = e_cal_backend_store_get_components (priv->store);
 
-			printf ("CalDAV - finished syncing with %d items in a cache\n", g_list_length (c_objs)); fflush (stdout);
+			printf ("CalDAV - finished syncing with %d items in a cache\n", g_slist_length (c_objs)); fflush (stdout);
 
-			g_list_foreach (c_objs, (GFunc) g_object_unref, NULL);
-			g_list_free (c_objs);
+			g_slist_foreach (c_objs, (GFunc) g_object_unref, NULL);
+			g_slist_free (c_objs);
 		}
 
 		priv->slave_busy = FALSE;
@@ -2239,13 +2225,17 @@ initialize_backend (ECalBackendCalDAV *cbdav)
 			break;
 	}
 
-	if (priv->cache == NULL) {
-		priv->cache = e_cal_backend_cache_new (priv->uri, source_type);
+	if (priv->store == NULL) {
+		/* remove the old cache while migrating to ECalBackendStore */
+		e_cal_backend_cache_remove (priv->uri, source_type);
+		priv->store = (ECalBackendStore *) e_cal_backend_file_store_new (priv->uri, source_type);
 
-		if (priv->cache == NULL) {
+		if (priv->store == NULL) {
 			result = GNOME_Evolution_Calendar_OtherError;
 			goto out;
 		}
+
+		e_cal_backend_store_load (priv->store);
 	}
 
 	/* Set the local attachment store */
@@ -2417,8 +2407,8 @@ caldav_remove (ECalBackendSync *backend,
 	if (status != GNOME_Evolution_Calendar_Success)
 		g_print (G_STRLOC ": %s", e_cal_backend_status_to_string (status));
 
-	e_file_cache_remove (E_FILE_CACHE (priv->cache));
-	priv->cache  = NULL;
+	e_cal_backend_store_remove (priv->store);
+	priv->store = NULL;
 	priv->loaded = FALSE;
 
 	if (priv->synch_slave) {
@@ -2433,21 +2423,20 @@ caldav_remove (ECalBackendSync *backend,
 	return GNOME_Evolution_Calendar_Success;
 }
 
-/* has priv->cache_lock locked already */
 static void
 remove_comp_from_cache_cb (gpointer value, gpointer user_data)
 {
 	ECalComponent *comp = value;
-	ECalBackendCache *cache = user_data;
+	ECalBackendStore *store = user_data;
 	ECalComponentId *id;
 
 	g_return_if_fail (comp != NULL);
-	g_return_if_fail (cache != NULL);
+	g_return_if_fail (store != NULL);
 
 	id = e_cal_component_get_id (comp);
 	g_return_if_fail (id != NULL);
 
-	e_cal_backend_cache_remove_component (cache, id->uid, id->rid);
+	e_cal_backend_store_remove_component (store, id->uid, id->rid);
 	e_cal_component_free_id (id);
 }
 
@@ -2459,25 +2448,21 @@ remove_comp_from_cache (ECalBackendCalDAV *cbdav, const gchar *uid, const gchar
 
 	priv  = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
 
-	g_static_rec_mutex_lock (&priv->cache_lock);
-
 	if (!rid || !*rid) {
 		/* get with detached instances */
-		GSList *objects = e_cal_backend_cache_get_components_by_uid (priv->cache, uid);
+		GSList *objects = e_cal_backend_store_get_components_by_uid (priv->store, uid);
 
 		if (objects) {
-			g_slist_foreach (objects, (GFunc)remove_comp_from_cache_cb, priv->cache);
+			g_slist_foreach (objects, (GFunc)remove_comp_from_cache_cb, priv->store);
 			g_slist_foreach (objects, (GFunc)g_object_unref, NULL);
 			g_slist_free (objects);
 
 			res = TRUE;
 		}
 	} else {
-		res = e_cal_backend_cache_remove_component (priv->cache, uid, rid);
+		res = e_cal_backend_store_remove_component (priv->store, uid, rid);
 	}
 
-	g_static_rec_mutex_unlock (&priv->cache_lock);
-
 	return res;
 }
 
@@ -2525,7 +2510,7 @@ get_comp_from_cache (ECalBackendCalDAV *cbdav, const gchar *uid, const gchar *ri
 
 	if (rid == NULL || !*rid) {
 		/* get with detached instances */
-		GSList *objects = e_cal_backend_cache_get_components_by_uid (priv->cache, uid);
+		GSList *objects = e_cal_backend_store_get_components_by_uid (priv->store, uid);
 
 		if (!objects) {
 			return NULL;
@@ -2557,7 +2542,7 @@ get_comp_from_cache (ECalBackendCalDAV *cbdav, const gchar *uid, const gchar *ri
 		g_slist_free (objects);
 	} else {
 		/* get the exact object */
-		ECalComponent *comp = e_cal_backend_cache_get_component (priv->cache, uid, rid);
+		ECalComponent *comp = e_cal_backend_store_get_component (priv->store, uid, rid);
 
 		if (comp) {
 			icalcomp = icalcomponent_new_clone (e_cal_component_get_icalcomponent (comp));
@@ -2612,10 +2597,8 @@ put_comp_to_cache (ECalBackendCalDAV *cbdav, icalcomponent *icalcomp, const gcha
 				if (etag)
 					ecalcomp_set_etag (comp, etag);
 
-				g_static_rec_mutex_lock (&priv->cache_lock);
-				if (e_cal_backend_cache_put_component (priv->cache, comp))
+				if (e_cal_backend_store_put_component (priv->store, comp))
 					res = TRUE;
-				g_static_rec_mutex_unlock (&priv->cache_lock);
 			}
 		}
 	} else if (icalcomponent_isa (icalcomp) == my_kind) {
@@ -2627,9 +2610,7 @@ put_comp_to_cache (ECalBackendCalDAV *cbdav, icalcomponent *icalcomp, const gcha
 			if (etag)
 				ecalcomp_set_etag (comp, etag);
 
-			g_static_rec_mutex_lock (&priv->cache_lock);
-			res = e_cal_backend_cache_put_component (priv->cache, comp);
-			g_static_rec_mutex_unlock (&priv->cache_lock);
+			res = e_cal_backend_store_put_component (priv->store, comp);
 		}
 	}
 
@@ -2877,7 +2858,7 @@ remove_cached_attachment (ECalBackendCalDAV *cbdav, const gchar *uid)
 	g_return_if_fail (uid != NULL);
 
 	priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
-	l = e_cal_backend_cache_get_components_by_uid (priv->cache, uid);
+	l = e_cal_backend_store_get_components_by_uid (priv->store, uid);
 	len = g_slist_length (l);
 	g_slist_free (l);
 	if (len > 0)
@@ -2891,7 +2872,7 @@ remove_cached_attachment (ECalBackendCalDAV *cbdav, const gchar *uid)
 
 /* callback for icalcomponent_foreach_tzid */
 typedef struct {
-	ECalBackendCache *cache;
+	ECalBackendStore *store;
 	icalcomponent *vcal_comp;
 	icalcomponent *icalcomp;
 } ForeachTzidData;
@@ -2916,7 +2897,7 @@ add_timezone_cb (icalparameter *param, gpointer data)
 	if (!tz) {
 		tz = icaltimezone_get_builtin_timezone_from_tzid (tzid);
 		if (!tz)
-			tz = (icaltimezone *) e_cal_backend_cache_get_timezone (f_data->cache, tzid);
+			tz = (icaltimezone *) e_cal_backend_store_get_timezone (f_data->store, tzid);
 		if (!tz)
 			return;
 	}
@@ -2941,13 +2922,11 @@ add_timezones_from_component (ECalBackendCalDAV *cbdav, icalcomponent *vcal_comp
 
 	priv  = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
 
-	f_data.cache = priv->cache;
+	f_data.store = priv->store;
 	f_data.vcal_comp = vcal_comp;
 	f_data.icalcomp = icalcomp;
 
-	g_static_rec_mutex_lock (&priv->cache_lock);
 	icalcomponent_foreach_tzid (icalcomp, add_timezone_cb, &f_data);
-	g_static_rec_mutex_unlock (&priv->cache_lock);
 }
 
 /* also removes X-EVOLUTION-CALDAV from all the components */
@@ -3051,11 +3030,9 @@ cache_contains (ECalBackendCalDAV *cbdav, const gchar *uid, const gchar *rid)
 	g_return_val_if_fail (uid != NULL, FALSE);
 
 	priv  = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
-	g_return_val_if_fail (priv != NULL && priv->cache != NULL, FALSE);
+	g_return_val_if_fail (priv != NULL && priv->store != NULL, FALSE);
 
-	g_static_rec_mutex_lock (&priv->cache_lock);
-	comp = e_cal_backend_cache_get_component (priv->cache, uid, rid);
-	g_static_rec_mutex_unlock (&priv->cache_lock);
+	comp = e_cal_backend_store_get_component (priv->store, uid, rid);
 	res = comp != NULL;
 
 	if (comp)
@@ -3176,7 +3153,7 @@ replace_master (ECalBackendCalDAV *cbdav, icalcomponent *old_comp, icalcomponent
 	return old_comp;
 }
 
-/* a busy_lock and a cache_lock are supposed to be locked already, when calling this function */
+/* a busy_lock is supposed to be locked already, when calling this function */
 static ECalBackendSyncStatus
 do_create_object (ECalBackendCalDAV *cbdav, gchar **calobj, gchar **uid)
 {
@@ -3278,7 +3255,7 @@ do_create_object (ECalBackendCalDAV *cbdav, gchar **calobj, gchar **uid)
 	return status;
 }
 
-/* a busy_lock and a cache_lock are supposed to be locked already, when calling this function */
+/* a busy_lock is supposed to be locked already, when calling this function */
 static ECalBackendSyncStatus
 do_modify_object (ECalBackendCalDAV *cbdav, const gchar *calobj, CalObjModType mod, gchar **old_object, gchar **new_object)
 {
@@ -3344,7 +3321,7 @@ do_modify_object (ECalBackendCalDAV *cbdav, const gchar *calobj, CalObjModType m
 
 		if (e_cal_component_is_instance (comp)) {
 			/* set detached instance as the old object, if any */
-			ECalComponent *old_instance = old_instance = e_cal_backend_cache_get_component (priv->cache, id->uid, id->rid);
+			ECalComponent *old_instance = old_instance = e_cal_backend_store_get_component (priv->store, id->uid, id->rid);
 
 			if (old_instance) {
 				*old_object = e_cal_component_get_as_string (old_instance);
@@ -3435,7 +3412,7 @@ do_modify_object (ECalBackendCalDAV *cbdav, const gchar *calobj, CalObjModType m
 	return status;
 }
 
-/* a busy_lock and a cache_lock are supposed to be locked already, when calling this function */
+/* a busy_lock is supposed to be locked already, when calling this function */
 static ECalBackendSyncStatus
 do_remove_object (ECalBackendCalDAV *cbdav, const gchar *uid, const gchar *rid, CalObjModType mod, gchar **old_object, gchar **object)
 {
@@ -3462,7 +3439,7 @@ do_remove_object (ECalBackendCalDAV *cbdav, const gchar *uid, const gchar *rid,
 	}
 
 	if (old_object) {
-		ECalComponent *old = e_cal_backend_cache_get_component (priv->cache, uid, rid);
+		ECalComponent *old = e_cal_backend_store_get_component (priv->store, uid, rid);
 
 		if (old) {
 			*old_object = e_cal_component_get_as_string (old);
@@ -3590,19 +3567,15 @@ extract_timezones (ECalBackendCalDAV *cbdav, icalcomponent *icomp)
 
 	priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
 
-	g_static_rec_mutex_lock (&priv->cache_lock);
-
 	zone = icaltimezone_new ();
 	for (iter = timezones; iter; iter = iter->next) {
 		if (icaltimezone_set_component (zone, iter->data)) {
-			e_cal_backend_cache_put_timezone (priv->cache, zone);
+			e_cal_backend_store_put_timezone (priv->store, zone);
 		} else {
 			icalcomponent_free (iter->data);
 		}
 	}
 
-	g_static_rec_mutex_unlock (&priv->cache_lock);
-
 	icaltimezone_free (zone, TRUE);
 	g_list_free (timezones);
 
@@ -3809,9 +3782,7 @@ _func_name _params							\
 	}								\
 									\
 	g_mutex_lock (priv->busy_lock);					\
-	g_static_rec_mutex_lock (&priv->cache_lock);			\
 	status = _call_func _call_params;				\
-	g_static_rec_mutex_unlock (&priv->cache_lock);			\
 									\
 	/* this is done before unlocking */				\
 	if (was_slave_busy) {						\
@@ -3906,13 +3877,9 @@ caldav_get_object (ECalBackendSync  *backend,
 	cbdav = E_CAL_BACKEND_CALDAV (backend);
 	priv  = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
 
-	g_static_rec_mutex_lock (&priv->cache_lock);
-
 	*object = NULL;
 	icalcomp = get_comp_from_cache (cbdav, uid, rid, NULL, NULL);
 
-	g_static_rec_mutex_unlock (&priv->cache_lock);
-
 	if (!icalcomp) {
 		return GNOME_Evolution_Calendar_ObjectNotFound;
 	}
@@ -3940,9 +3907,7 @@ caldav_get_timezone (ECalBackendSync  *backend,
 	g_return_val_if_fail (tzid, GNOME_Evolution_Calendar_ObjectNotFound);
 
 	/* first try to get the timezone from the cache */
-	g_static_rec_mutex_lock (&priv->cache_lock);
-	zone = e_cal_backend_cache_get_timezone (priv->cache, tzid);
-	g_static_rec_mutex_unlock (&priv->cache_lock);
+	zone = e_cal_backend_store_get_timezone (priv->store, tzid);
 
 	if (!zone) {
 		zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
@@ -3988,9 +3953,7 @@ caldav_add_timezone (ECalBackendSync *backend,
 		zone = icaltimezone_new ();
 		icaltimezone_set_component (zone, tz_comp);
 
-		g_static_rec_mutex_lock (&priv->cache_lock);
-		e_cal_backend_cache_put_timezone (priv->cache, zone);
-		g_static_rec_mutex_unlock (&priv->cache_lock);
+		e_cal_backend_store_put_timezone (priv->store, zone);
 
 		icaltimezone_free (zone, TRUE);
 	} else {
@@ -4041,10 +4004,9 @@ caldav_get_object_list (ECalBackendSync  *backend,
 	ECalBackendCalDAV        *cbdav;
 	ECalBackendCalDAVPrivate *priv;
 	ECalBackendSExp	 *sexp;
-	ECalBackendCache         *bcache;
-	ECalBackend              *bkend;
+	ECalBackend *bkend;
 	gboolean                  do_search;
-	GList			 *list, *iter;
+	GSList			 *list, *iter;
 
 	cbdav = E_CAL_BACKEND_CALDAV (backend);
 	priv  = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
@@ -4062,15 +4024,12 @@ caldav_get_object_list (ECalBackendSync  *backend,
 	}
 
 	*objects = NULL;
-	bcache = priv->cache;
 
-	g_static_rec_mutex_lock (&priv->cache_lock);
-	list = e_cal_backend_cache_get_components (bcache);
-	g_static_rec_mutex_unlock (&priv->cache_lock);
+	list = e_cal_backend_store_get_components (priv->store);
 
 	bkend = E_CAL_BACKEND (backend);
 
-	for (iter = list; iter; iter = g_list_next (iter)) {
+	for (iter = list; iter; iter = g_slist_next (iter)) {
 		ECalComponent *comp = E_CAL_COMPONENT (iter->data);
 
 		if (!do_search ||
@@ -4083,7 +4042,7 @@ caldav_get_object_list (ECalBackendSync  *backend,
 	}
 
 	g_object_unref (sexp);
-	g_list_free (list);
+	g_slist_free (list);
 
 	return GNOME_Evolution_Calendar_Success;
 }
@@ -4097,7 +4056,7 @@ caldav_start_query (ECalBackend  *backend,
 	ECalBackendSExp	 *sexp;
 	ECalBackend              *bkend;
 	gboolean                  do_search;
-	GList			 *list, *iter;
+	GSList			 *list, *iter;
 	const gchar               *sexp_string;
 
 	cbdav = E_CAL_BACKEND_CALDAV (backend);
@@ -4114,13 +4073,11 @@ caldav_start_query (ECalBackend  *backend,
 		do_search = TRUE;
 	}
 
-	g_static_rec_mutex_lock (&priv->cache_lock);
-	list = e_cal_backend_cache_get_components (priv->cache);
-	g_static_rec_mutex_unlock (&priv->cache_lock);
+	list = e_cal_backend_store_get_components (priv->store);
 
 	bkend = E_CAL_BACKEND (backend);
 
-	for (iter = list; iter; iter = g_list_next (iter)) {
+	for (iter = list; iter; iter = g_slist_next (iter)) {
 		ECalComponent *comp = E_CAL_COMPONENT (iter->data);
 
 		if (!do_search ||
@@ -4134,7 +4091,7 @@ caldav_start_query (ECalBackend  *backend,
 	}
 
 	g_object_unref (sexp);
-	g_list_free (list);
+	g_slist_free (list);
 
 	e_data_cal_view_notify_done (query, GNOME_Evolution_Calendar_Success);
 }
@@ -4510,8 +4467,8 @@ e_cal_backend_caldav_dispose (GObject *object)
 		priv->local_attachments_store = NULL;
 	}
 
-	if (priv->cache != NULL) {
-		g_object_unref (priv->cache);
+	if (priv->store != NULL) {
+		g_object_unref (priv->store);
 	}
 
 	priv->disposed = TRUE;
@@ -4531,7 +4488,6 @@ e_cal_backend_caldav_finalize (GObject *object)
 	priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
 
 	g_mutex_free (priv->busy_lock);
-	g_static_rec_mutex_free (&priv->cache_lock);
 	g_cond_free (priv->cond);
 	g_cond_free (priv->slave_gone_cond);
 
@@ -4573,7 +4529,6 @@ e_cal_backend_caldav_init (ECalBackendCalDAV *cbdav)
 	priv->is_google = FALSE;
 
 	priv->busy_lock = g_mutex_new ();
-	g_static_rec_mutex_init (&priv->cache_lock);
 	priv->cond = g_cond_new ();
 	priv->slave_gone_cond = g_cond_new ();
 
diff --git a/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c b/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
index 405129d..6aaef9f 100644
--- a/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
+++ b/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
@@ -1093,7 +1093,9 @@ e_gw_item_to_cal_component (EGwItem *item, ECalBackendGroupwise *cbgw)
 	/* summary */
 	text.value = e_gw_item_get_subject (item);
 	text.altrep = NULL;
-	e_cal_component_set_summary (comp, &text);
+	
+	if (text.value)
+		e_cal_component_set_summary (comp, &text);
 
 	/* description */
 	description = e_gw_item_get_message (item);
diff --git a/calendar/backends/groupwise/e-cal-backend-groupwise.c b/calendar/backends/groupwise/e-cal-backend-groupwise.c
index d7f45ba..38f136c 100644
--- a/calendar/backends/groupwise/e-cal-backend-groupwise.c
+++ b/calendar/backends/groupwise/e-cal-backend-groupwise.c
@@ -36,6 +36,7 @@
 #include "libedataserver/e-xml-hash-utils.h"
 #include "libedataserver/e-url.h"
 #include <libedata-cal/e-cal-backend-cache.h>
+#include <libedata-cal/e-cal-backend-file-store.h>
 #include <libedata-cal/e-cal-backend-util.h>
 #include <libecal/e-cal-component.h>
 #include <libecal/e-cal-time-util.h>
@@ -57,6 +58,9 @@
 #define gmtime_r(tp,tmp) (gmtime(tp)?(*(tmp)=*gmtime(tp),(tmp)):0)
 #endif
 
+#define SERVER_UTC_TIME "server_utc_time"
+#define CACHE_MARKER "populated"
+
 typedef struct {
 	GCond *cond;
 	GMutex *mutex;
@@ -68,7 +72,7 @@ struct _ECalBackendGroupwisePrivate {
 	/* A mutex to control access to the private structure */
 	GMutex *mutex;
 	EGwConnection *cnc;
-	ECalBackendCache *cache;
+	ECalBackendStore *store;
 	gboolean read_only;
 	gchar *uri;
 	gchar *username;
@@ -284,7 +288,7 @@ populate_cache (ECalBackendGroupwise *cbgw)
 					comp_str = e_cal_component_get_as_string (comp);
 					e_cal_backend_notify_object_created (E_CAL_BACKEND (cbgw), (const gchar *) comp_str);
 					g_free (comp_str);
-					e_cal_backend_cache_put_component (priv->cache, comp);
+					e_cal_backend_store_put_component (priv->store, comp);
 					g_object_unref (comp);
 				}
 				g_free (progress_string);
@@ -305,10 +309,24 @@ populate_cache (ECalBackendGroupwise *cbgw)
 	return E_GW_CONNECTION_STATUS_OK;
 }
 
-static gboolean
-compare_prefix (gconstpointer a, gconstpointer b)
+static gint
+compare_ids (gconstpointer a, gconstpointer b)
 {
-	return !(g_str_has_prefix ((const gchar *)a, (const gchar *)b));
+	ECalComponentId *cache_id = (ECalComponentId *) a;
+	ECalComponentId *server_id = (ECalComponentId *) b;
+
+	if (g_str_equal (cache_id->uid, server_id->uid)) {
+		if (cache_id->rid && server_id->rid) {
+			if (g_str_equal (cache_id->rid, server_id->rid))
+				return 0;
+			else
+				return 1;
+		} else if (!cache_id->rid && !server_id->rid)
+			return 0;
+
+		return 1;
+	} else
+		return 1;
 }
 
 static gboolean
@@ -317,11 +335,11 @@ get_deltas (gpointer handle)
 	ECalBackendGroupwise *cbgw;
 	ECalBackendGroupwisePrivate *priv;
 	EGwConnection *cnc;
-	ECalBackendCache *cache;
+	ECalBackendStore *store;
 	EGwConnectionStatus status;
 	icalcomponent_kind kind;
 	GList *item_list, *total_list = NULL, *l;
-	GSList *cache_keys = NULL, *ls;
+	GSList *cache_ids = NULL, *ls;
 	GPtrArray *uid_array = NULL;
 	gchar *time_string = NULL;
 	gchar t_str [26];
@@ -346,20 +364,20 @@ get_deltas (gpointer handle)
 	priv= cbgw->priv;
 	kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgw));
 	cnc = priv->cnc;
-	cache = priv->cache;
+	store = priv->store;
 	item_list = NULL;
 
 	if (priv->mode == CAL_MODE_LOCAL)
 		return FALSE;
 
-	attempts = e_cal_backend_cache_get_key_value (cache, key);
+	attempts = e_cal_backend_store_get_key_value (store, key);
 
 	g_static_mutex_lock (&connecting);
 
-	serv_time = e_cal_backend_cache_get_server_utc_time (cache);
+	serv_time = e_cal_backend_store_get_key_value (store, SERVER_UTC_TIME);
 	if (serv_time) {
 		icaltimetype tmp;
-		g_strlcpy (t_str, e_cal_backend_cache_get_server_utc_time (cache), 26);
+		g_strlcpy (t_str, e_cal_backend_store_get_key_value (store, SERVER_UTC_TIME), 26);
 		if (!*t_str || !strcmp (t_str, "")) {
 			/* FIXME: When time-stamp is crashed, getting changes from current time */
 			g_warning ("\n\a Could not get the correct time stamp. \n\a");
@@ -395,11 +413,11 @@ get_deltas (gpointer handle)
 		const gchar *msg = NULL;
 
 		if (!attempts) {
-			e_cal_backend_cache_put_key_value (cache, key, "2");
+			e_cal_backend_store_put_key_value (store, key, "2");
 		} else {
 			gint failures;
 			failures = g_ascii_strtod(attempts, NULL) + 1;
-			e_cal_backend_cache_put_key_value (cache, key, GINT_TO_POINTER (failures));
+			e_cal_backend_store_put_key_value (store, key, GINT_TO_POINTER (failures));
 		}
 
 		if (status == E_GW_CONNECTION_STATUS_NO_RESPONSE) {
@@ -413,7 +431,7 @@ get_deltas (gpointer handle)
 		return TRUE;
 	}
 
-	e_file_cache_freeze_changes (E_FILE_CACHE (cache));
+	e_cal_backend_store_freeze_changes (store);
 
 	for (; item_list != NULL; item_list = g_list_next(item_list)) {
 		EGwItem *item = NULL;
@@ -433,7 +451,7 @@ get_deltas (gpointer handle)
 			rid = e_cal_component_get_recurid_as_string (modified_comp);
 
 		e_cal_component_get_uid (modified_comp, &uid);
-		cache_comp = e_cal_backend_cache_get_component (cache, uid, rid);
+		cache_comp = e_cal_backend_store_get_component (store, uid, rid);
 		e_cal_component_commit_sequence (modified_comp);
 
 		e_cal_component_get_last_modified (modified_comp, &tt);
@@ -458,7 +476,7 @@ get_deltas (gpointer handle)
 			g_free (cache_comp_str);
 			g_free (rid);
 			cache_comp_str = NULL;
-			e_cal_backend_cache_put_component (cache, modified_comp);
+			e_cal_backend_store_put_component (store, modified_comp);
 		}
 
 		e_cal_component_free_icaltimetype (tt);
@@ -471,7 +489,7 @@ get_deltas (gpointer handle)
 		if (cache_comp)
 			g_object_unref (cache_comp);
 	}
-	e_file_cache_thaw_changes (E_FILE_CACHE (cache));
+	e_cal_backend_store_thaw_changes (store);
 
 	temp = icaltime_from_string (time_string);
 	current_time = icaltime_as_timet_with_zone (temp, icaltimezone_get_utc_timezone ());
@@ -481,14 +499,14 @@ get_deltas (gpointer handle)
 
 	if (attempts) {
 		tm.tm_min += (time_interval * g_ascii_strtod (attempts, NULL));
-		e_cal_backend_cache_put_key_value (cache, key, NULL);
+		e_cal_backend_store_put_key_value (store, key, NULL);
 	} else {
 		tm.tm_min += time_interval;
 	}
 	strftime (t_str, 26, "%Y-%m-%dT%H:%M:%SZ", &tm);
 	time_string = g_strdup (t_str);
 
-	e_cal_backend_cache_put_server_utc_time (cache, time_string);
+	e_cal_backend_store_put_key_value (store, SERVER_UTC_TIME, time_string);
 
 	g_free (time_string);
 	time_string = NULL;
@@ -519,7 +537,7 @@ get_deltas (gpointer handle)
 		return TRUE;
 	}
 
-	cache_keys = e_cal_backend_cache_get_keys (cache);
+	cache_ids = e_cal_backend_store_get_component_ids (store);
 
 	done = FALSE;
 	while (!done) {
@@ -549,58 +567,51 @@ get_deltas (gpointer handle)
 
 	}
 	e_gw_connection_destroy_cursor (cnc, cbgw->priv->container_id, cursor);
-	e_file_cache_freeze_changes (E_FILE_CACHE (cache));
+	e_cal_backend_store_freeze_changes (store);
 
 	uid_array = g_ptr_array_new ();
-	for (l = total_list; l != NULL; l = l->next) {
+	for (l = total_list; l != NULL; l = g_list_next (l)) {
 		EGwItemCalId *calid = (EGwItemCalId *)	l->data;
-		GCompareFunc func = NULL;
 		GSList *remove = NULL;
-		gchar *real_key = NULL;
-		const gchar *recur_key;
+		ECalComponentId *id = NULL;
 
-		if (calid->recur_key && calid->ical_id) {
-			gchar *rid = NULL;
-			gchar *temp = 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_r (tt);
-				temp = rid;
-			} else
-				rid = calid->ical_id;
-			real_key = g_strconcat (calid->recur_key, "@", rid, NULL);
-			g_free (temp);
-		}
+		id = g_new0 (ECalComponentId, 1);
 
-		if (!calid->recur_key || real_key) {
-			recur_key = real_key;
-			func = (GCompareFunc) strcmp;
-		} else {
-			recur_key = calid->recur_key;
-			func = (GCompareFunc) compare_prefix;
-		}
+		if (calid->recur_key && calid->start_date) {
+			gchar *rid = NULL;
+			
+			icaltimetype tt = icaltime_from_string (calid->start_date);
+			
+			tt = icaltime_convert_to_zone (tt, priv->default_zone);
+			icaltime_set_timezone (&tt, priv->default_zone);
+			rid = icaltime_as_ical_string_r (tt);
+			
+			id->uid = g_strdup (calid->recur_key);
+			id->rid = rid;
+		} else
+			id->uid = g_strdup (calid->ical_id);
 
-		if (!(remove = g_slist_find_custom (cache_keys, calid->recur_key ? recur_key :
-						calid->ical_id,  func))) {
+		if (!(remove = g_slist_find_custom (cache_ids, id,  (GCompareFunc) compare_ids))) {
 			g_ptr_array_add (uid_array, g_strdup (calid->item_id));
 			needs_to_get = TRUE;
 		} else  {
-			cache_keys = g_slist_remove_link (cache_keys, remove);
+			cache_ids = g_slist_remove_link (cache_ids, remove);
+			e_cal_component_free_id (remove->data);
 		}
 
-		g_free (real_key);
+		e_cal_component_free_id (id);
 	}
 
-	for (ls = cache_keys; ls; ls = g_slist_next (ls)) {
+	for (ls = cache_ids; ls; ls = g_slist_next (ls)) {
 		ECalComponent *comp = NULL;
 		icalcomponent *icalcomp = NULL;
+		ECalComponentId *id = ls->data;
 
-		comp = e_cal_backend_cache_get_component (cache, (const gchar *) ls->data, NULL);
+		comp = e_cal_backend_store_get_component (store, id->uid, id->rid);
 
-		if (!comp)
+		if (!comp) 
 			continue;
+
 		icalcomp = e_cal_component_get_icalcomponent (comp);
 		if (kind == icalcomponent_isa (icalcomp)) {
 			gchar *comp_str = NULL;
@@ -609,7 +620,7 @@ get_deltas (gpointer handle)
 			comp_str = e_cal_component_get_as_string (comp);
 			e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbgw),
 					id, comp_str, NULL);
-			e_cal_backend_cache_remove_component (cache, (const gchar *) id->uid, id->rid);
+			e_cal_backend_store_remove_component (store, id->uid, id->rid);
 
 			e_cal_component_free_id (id);
 			g_free (comp_str);
@@ -633,7 +644,7 @@ get_deltas (gpointer handle)
 			if (comp) {
 				e_cal_component_commit_sequence (comp);
 				sanitize_component (E_CAL_BACKEND_SYNC (cbgw), comp, (gchar *) e_gw_item_get_id (item));
-				e_cal_backend_cache_put_component (priv->cache, comp);
+				e_cal_backend_store_put_component (store, comp);
 
 				if (kind == icalcomponent_isa (e_cal_component_get_icalcomponent (comp))) {
 					tmp = e_cal_component_get_as_string (comp);
@@ -647,7 +658,7 @@ get_deltas (gpointer handle)
 		}
 	}
 
-	e_file_cache_thaw_changes (E_FILE_CACHE (cache));
+	e_cal_backend_store_thaw_changes (store);
 
 	g_ptr_array_foreach (uid_array, (GFunc) g_free, NULL);
 	g_ptr_array_free (uid_array, TRUE);
@@ -662,9 +673,9 @@ get_deltas (gpointer handle)
 		g_list_free (total_list);
 	}
 
-	if (cache_keys) {
-		/*FIXME this is a memory leak, but free'ing it causes crash in gslice */
-		/*g_slist_free (cache_keys);*/
+	if (cache_ids) {
+		g_slist_foreach (cache_ids, (GFunc) e_cal_component_free_id, NULL);
+		g_slist_free (cache_ids);
 	}
 
 	g_static_mutex_unlock (&connecting);
@@ -857,7 +868,7 @@ cache_init (ECalBackendGroupwise *cbgw)
 	/* We poke the cache for a default timezone. Its
 	 * absence indicates that the cache file has not been
 	 * populated before. */
-	if (!e_cal_backend_cache_get_marker (priv->cache)) {
+	if (!e_cal_backend_store_get_key_value (priv->store, CACHE_MARKER)) {
 		/* Populate the cache for the first time.*/
 		/* start a timed polling thread set to 1 minute*/
 		cnc_status = populate_cache (cbgw);
@@ -871,8 +882,8 @@ cache_init (ECalBackendGroupwise *cbgw)
 
 			time_interval = get_cache_refresh_interval (cbgw);
 			utc_str = (gchar *) e_gw_connection_get_server_time (priv->cnc);
-			e_cal_backend_cache_set_marker (priv->cache);
-			e_cal_backend_cache_put_server_utc_time (priv->cache, utc_str);
+			e_cal_backend_store_put_key_value (priv->store, CACHE_MARKER, "1");
+			e_cal_backend_store_put_key_value (priv->store, SERVER_UTC_TIME, utc_str);
 
 			priv->timeout_id = g_timeout_add (time_interval, start_fetch_deltas, cbgw);
 
@@ -1017,7 +1028,7 @@ connect_to_server (ECalBackendGroupwise *cbgw)
 	g_free (real_uri);
 
 	if (priv->cnc ) {
-		if (priv->cache && priv->container_id) {
+		if (priv->store && priv->container_id) {
 			priv->mode = CAL_MODE_REMOTE;
 			if (priv->mode_changed && !priv->dthread) {
 				priv->mode_changed = FALSE;
@@ -1052,6 +1063,8 @@ connect_to_server (ECalBackendGroupwise *cbgw)
 
 	if (E_IS_GW_CONNECTION (priv->cnc)) {
 		ECalBackendSyncStatus status;
+		const gchar *uri = e_cal_backend_get_uri (E_CAL_BACKEND (cbgw));
+
 		/* get the ID for the container */
 		if (priv->container_id)
 			g_free (priv->container_id);
@@ -1060,14 +1073,16 @@ connect_to_server (ECalBackendGroupwise *cbgw)
 			return status;
 		}
 
-		priv->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (cbgw)), source_type);
-		if (!priv->cache) {
+		e_cal_backend_cache_remove (uri, source_type);
+		priv->store = (ECalBackendStore *) e_cal_backend_file_store_new (uri, source_type);
+		if (!priv->store) {
 			g_mutex_unlock (priv->mutex);
 			e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Could not create cache file"));
 			return GNOME_Evolution_Calendar_OtherError;
 		}
 
-		e_cal_backend_cache_put_default_timezone (priv->cache, priv->default_zone);
+		e_cal_backend_store_load (priv->store);
+		e_cal_backend_store_set_default_timezone (priv->store, priv->default_zone);
 
 		/* spawn a new thread for opening the calendar */
 		thread = g_thread_create ((GThreadFunc) cache_init, cbgw, FALSE, &error);
@@ -1150,9 +1165,9 @@ e_cal_backend_groupwise_finalize (GObject *object)
 		priv->cnc = NULL;
 	}
 
-	if (priv->cache) {
-		g_object_unref (priv->cache);
-		priv->cache = NULL;
+	if (priv->store) {
+		g_object_unref (priv->store);
+		priv->store = NULL;
 	}
 
 	if (priv->username) {
@@ -1355,9 +1370,13 @@ e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean
 			return GNOME_Evolution_Calendar_RepositoryOffline;
 		}
 
-		if (!priv->cache) {
-			priv->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (cbgw)), source_type);
-			if (!priv->cache) {
+		if (!priv->store) {
+			const gchar *uri = e_cal_backend_get_uri (E_CAL_BACKEND (cbgw));
+			
+			/* remove the old cache while migrating to ECalBackendStore */
+			e_cal_backend_cache_remove (uri, source_type);
+			priv->store = (ECalBackendStore *) e_cal_backend_file_store_new (uri, source_type);
+			if (!priv->store) {
 				g_mutex_unlock (priv->mutex);
 				e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Could not create cache file"));
 
@@ -1365,7 +1384,7 @@ e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean
 			}
 		}
 
-		e_cal_backend_cache_put_default_timezone (priv->cache, priv->default_zone);
+		e_cal_backend_store_set_default_timezone (priv->store, priv->default_zone);
 
 		g_mutex_unlock (priv->mutex);
 		return GNOME_Evolution_Calendar_Success;
@@ -1416,8 +1435,8 @@ e_cal_backend_groupwise_remove (ECalBackendSync *backend, EDataCal *cal)
 	g_mutex_lock (priv->mutex);
 
 	/* remove the cache */
-	if (priv->cache)
-		e_file_cache_remove (E_FILE_CACHE (priv->cache));
+	if (priv->store)
+		e_cal_backend_store_remove (priv->store);
 
 	g_mutex_unlock (priv->mutex);
 
@@ -1434,7 +1453,7 @@ e_cal_backend_groupwise_is_loaded (ECalBackend *backend)
 	cbgw = E_CAL_BACKEND_GROUPWISE (backend);
 	priv = cbgw->priv;
 
-	return priv->cache ? TRUE : FALSE;
+	return priv->store ? TRUE : FALSE;
 }
 
 /* is_remote handler for the file backend */
@@ -1538,7 +1557,7 @@ e_cal_backend_groupwise_get_object (ECalBackendSync *backend, EDataCal *cal, con
 	g_mutex_lock (priv->mutex);
 
 	/* search the object in the cache */
-	comp = e_cal_backend_cache_get_component (priv->cache, uid, rid);
+	comp = e_cal_backend_store_get_component (priv->store, uid, rid);
 	if (comp) {
 		g_mutex_unlock (priv->mutex);
 		if (e_cal_backend_get_kind (E_CAL_BACKEND (backend)) ==
@@ -1613,7 +1632,7 @@ e_cal_backend_groupwise_add_timezone (ECalBackendSync *backend, EDataCal *cal, c
 
 		zone = icaltimezone_new ();
 		icaltimezone_set_component (zone, tz_comp);
-		if (e_cal_backend_cache_put_timezone (priv->cache, zone) == FALSE) {
+		if (e_cal_backend_store_put_timezone (priv->store, zone) == FALSE) {
 			icaltimezone_free (zone, 1);
 			return GNOME_Evolution_Calendar_OtherError;
 		}
@@ -1667,7 +1686,7 @@ e_cal_backend_groupwise_get_object_list (ECalBackendSync *backend, EDataCal *cal
 {
 	ECalBackendGroupwise *cbgw;
 	ECalBackendGroupwisePrivate *priv;
-        GList *components, *l;
+        GSList *components, *l;
 	ECalBackendSExp *cbsexp;
 	gboolean search_needed = TRUE;
 
@@ -1688,7 +1707,7 @@ e_cal_backend_groupwise_get_object_list (ECalBackendSync *backend, EDataCal *cal
 	}
 
 	*objects = NULL;
-	components = e_cal_backend_cache_get_components (priv->cache);
+	components = e_cal_backend_store_get_components (priv->store);
         for (l = components; l != NULL; l = l->next) {
                 ECalComponent *comp = E_CAL_COMPONENT (l->data);
 
@@ -1702,8 +1721,8 @@ e_cal_backend_groupwise_get_object_list (ECalBackendSync *backend, EDataCal *cal
         }
 
 	g_object_unref (cbsexp);
-	g_list_foreach (components, (GFunc) g_object_unref, NULL);
-	g_list_free (components);
+	g_slist_foreach (components, (GFunc) g_object_unref, NULL);
+	g_slist_free (components);
 
 	g_mutex_unlock (priv->mutex);
 
@@ -1782,7 +1801,7 @@ e_cal_backend_groupwise_compute_changes_foreach_key (const gchar *key, const gch
 {
 	ECalBackendGroupwiseComputeChangesData *be_data = data;
 
-	if (!e_cal_backend_cache_get_component (be_data->backend->priv->cache, key, NULL)) {
+	if (!e_cal_backend_store_get_component (be_data->backend->priv->store, key, NULL)) {
 		ECalComponent *comp;
 
 		comp = e_cal_component_new ();
@@ -1804,14 +1823,12 @@ e_cal_backend_groupwise_compute_changes (ECalBackendGroupwise *cbgw, const gchar
 					 GList **adds, GList **modifies, GList **deletes)
 {
         ECalBackendSyncStatus status;
-	ECalBackendCache *cache;
 	gchar    *filename;
 	EXmlHash *ehash;
 	ECalBackendGroupwiseComputeChangesData be_data;
 	GList *i, *list = NULL;
 	gchar *unescaped_uri;
 
-	cache = cbgw->priv->cache;
 
 	/* FIXME Will this always work? */
 	unescaped_uri = g_uri_unescape_string (cbgw->priv->uri, "");
@@ -1985,7 +2002,7 @@ update_from_server (ECalBackendGroupwise *cbgw, GSList *uid_list, gchar **calobj
 		e_cal_comp = e_gw_item_to_cal_component (item, cbgw);
 		e_cal_component_commit_sequence (e_cal_comp);
 		sanitize_component (backend, e_cal_comp, g_ptr_array_index (uid_array, i));
-		e_cal_backend_cache_put_component (priv->cache, e_cal_comp);
+		e_cal_backend_store_put_component (priv->store, e_cal_comp);
 
 		if (i == 0) {
 			*calobj = e_cal_component_get_as_string (e_cal_comp);
@@ -2159,7 +2176,7 @@ e_cal_backend_groupwise_modify_object (ECalBackendSync *backend, EDataCal *cal,
 	case CAL_MODE_ANY :
 	case CAL_MODE_REMOTE :
 		/* when online, send the item to the server */
-		cache_comp = e_cal_backend_cache_get_component (priv->cache, uid, rid);
+		cache_comp = e_cal_backend_store_get_component (priv->store, uid, rid);
 		if (!cache_comp) {
 			g_message ("CRITICAL : Could not find the object in cache");
 			g_free (rid);
@@ -2188,7 +2205,7 @@ e_cal_backend_groupwise_modify_object (ECalBackendSync *backend, EDataCal *cal,
 				return GNOME_Evolution_Calendar_OtherError;
 			}
 
-			e_cal_backend_cache_put_component (priv->cache, comp);
+			e_cal_backend_store_put_component (priv->store, comp);
 			*new_object = e_cal_component_get_as_string (comp);
 			break;
 		}
@@ -2217,7 +2234,7 @@ e_cal_backend_groupwise_modify_object (ECalBackendSync *backend, EDataCal *cal,
 
 					return GNOME_Evolution_Calendar_OtherError;
 				}
-				e_cal_backend_cache_put_component (priv->cache, comp);
+				e_cal_backend_store_put_component (priv->store, comp);
 				break;
 			}
 		}
@@ -2240,7 +2257,7 @@ e_cal_backend_groupwise_modify_object (ECalBackendSync *backend, EDataCal *cal,
 
 	case CAL_MODE_LOCAL :
 		/* in offline mode, we just update the cache */
-		e_cal_backend_cache_put_component (priv->cache, comp);
+		e_cal_backend_store_put_component (priv->store, comp);
 		break;
 	default :
 		break;
@@ -2322,7 +2339,7 @@ e_cal_backend_groupwise_remove_object (ECalBackendSync *backend, EDataCal *cal,
 			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_store_remove_component (priv->store, uid, rid)) {
 					g_free (calobj);
 					return GNOME_Evolution_Calendar_ObjectNotFound;
 				}
@@ -2335,7 +2352,7 @@ e_cal_backend_groupwise_remove_object (ECalBackendSync *backend, EDataCal *cal,
 				return GNOME_Evolution_Calendar_OtherError;
 			}
 		} else if (mod == CALOBJ_MOD_ALL) {
-			GSList *l, *comp_list = e_cal_backend_cache_get_components_by_uid (priv->cache, uid);
+			GSList *l, *comp_list = e_cal_backend_store_get_components_by_uid (priv->store, uid);
 
 			if (e_cal_component_has_attendees (E_CAL_COMPONENT (comp_list->data))) {
 				/* get recurrence key and send it to
@@ -2366,7 +2383,7 @@ e_cal_backend_groupwise_remove_object (ECalBackendSync *backend, EDataCal *cal,
 					ECalComponent *comp = E_CAL_COMPONENT (l->data);
 					ECalComponentId *id = e_cal_component_get_id (comp);
 
-					e_cal_backend_cache_remove_component (priv->cache, id->uid,
+					e_cal_backend_store_remove_component (priv->store, id->uid,
 							id->rid);
 					if (!id->rid || !g_str_equal (id->rid, rid)) {
 						gchar *comp_str = e_cal_component_get_as_string (comp);
@@ -2570,7 +2587,7 @@ receive_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalco
 			const gchar *uid;
 
 			e_cal_component_get_uid (modif_comp, (const gchar **) &uid);
-			comps = e_cal_backend_cache_get_components_by_uid (priv->cache, uid);
+			comps = e_cal_backend_store_get_components_by_uid (priv->store, uid);
 
 			if (!comps)
 				comps = g_slist_append (comps, g_object_ref (modif_comp));
@@ -2580,7 +2597,7 @@ receive_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalco
 			ECalComponentId *id = e_cal_component_get_id (modif_comp);
 			ECalComponent *component = NULL;
 
-			component = e_cal_backend_cache_get_component (priv->cache, id->uid, id->rid);
+			component = e_cal_backend_store_get_component (priv->store, id->uid, id->rid);
 
 			if (!component)
 				comps = g_slist_append (comps, g_object_ref (modif_comp));
@@ -2598,7 +2615,7 @@ receive_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalco
 			if (pstatus == ICAL_PARTSTAT_DECLINED) {
 				ECalComponentId *id = e_cal_component_get_id (component);
 
-				if (e_cal_backend_cache_remove_component (priv->cache, id->uid, id->rid)) {
+				if (e_cal_backend_store_remove_component (priv->store, id->uid, id->rid)) {
 					gchar *comp_str = e_cal_component_get_as_string (component);
 					e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbgw), id, comp_str, NULL);
 					g_free (comp_str);
@@ -2613,7 +2630,7 @@ receive_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalco
 				e_cal_component_get_transparency (comp, &transp);
 				e_cal_component_set_transparency (component, transp);
 
-				e_cal_backend_cache_put_component (priv->cache, component);
+				e_cal_backend_store_put_component (priv->store, component);
 				comp_str = e_cal_component_get_as_string (component);
 
 				if (found)
@@ -2702,7 +2719,7 @@ send_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalcomp,
 	rid = e_cal_component_get_recurid_as_string (comp);
 
 	e_cal_component_get_uid (comp, (const gchar **) &uid);
-	found_comp = e_cal_backend_cache_get_component (priv->cache, uid, rid);
+	found_comp = e_cal_backend_store_get_component (priv->store, uid, rid);
 	g_free (rid);
 	rid = NULL;
 
diff --git a/calendar/backends/http/e-cal-backend-http.c b/calendar/backends/http/e-cal-backend-http.c
index 4d6100e..8d822ac 100644
--- a/calendar/backends/http/e-cal-backend-http.c
+++ b/calendar/backends/http/e-cal-backend-http.c
@@ -32,6 +32,8 @@
 #include <libecal/e-cal-util.h>
 #include <libecal/e-cal-time-util.h>
 #include <libedata-cal/e-cal-backend-cache.h>
+#include <libedata-cal/e-cal-backend-store.h>
+#include <libedata-cal/e-cal-backend-file-store.h>
 #include <libedata-cal/e-cal-backend-util.h>
 #include <libedata-cal/e-cal-backend-sexp.h>
 #include <libsoup/soup.h>
@@ -50,7 +52,7 @@ struct _ECalBackendHttpPrivate {
 	CalMode mode;
 
 	/* The file cache */
-	ECalBackendCache *cache;
+	ECalBackendStore *store;
 
 	/* The calendar's default timezone, used for resolving DATE and
 	   floating DATE-TIME values. */
@@ -126,9 +128,9 @@ e_cal_backend_http_finalize (GObject *object)
 
 	/* Clean up */
 
-	if (priv->cache) {
-		g_object_unref (priv->cache);
-		priv->cache = NULL;
+	if (priv->store) {
+		g_object_unref (priv->store);
+		priv->store = NULL;
 	}
 
 	if (priv->uri) {
@@ -234,7 +236,7 @@ notify_and_remove_from_cache (gpointer key, gpointer value, gpointer user_data)
 	ECalComponent *comp = e_cal_component_new_from_string (calobj);
 	ECalComponentId *id = e_cal_component_get_id (comp);
 
-	e_cal_backend_cache_remove_component (cbhttp->priv->cache, id->uid, id->rid);
+	e_cal_backend_store_remove_component (cbhttp->priv->store, id->uid, id->rid);
 	e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbhttp), id, calobj, NULL);
 
 	e_cal_component_free_id (id);
@@ -244,6 +246,38 @@ notify_and_remove_from_cache (gpointer key, gpointer value, gpointer user_data)
 }
 
 static void
+empty_cache (ECalBackendHttp *cbhttp)
+{
+	ECalBackendHttpPrivate *priv;
+	GSList *comps, *l;
+	
+	priv = cbhttp->priv;
+
+	if (!priv->store)
+		return;
+
+	comps = e_cal_backend_store_get_components (priv->store);
+
+	for (l = comps; l != NULL; l = g_slist_next (l)) {
+		gchar *comp_str;
+		ECalComponentId *id;
+		ECalComponent *comp = l->data;
+
+		id = e_cal_component_get_id (comp);
+		comp_str = e_cal_component_get_as_string (comp);
+
+		e_cal_backend_notify_object_removed ((ECalBackend *) cbhttp, id, comp_str, NULL);
+
+		g_free (comp_str);
+		e_cal_component_free_id (id);
+		g_object_unref (comp);
+	}
+	g_slist_free (comps);
+
+	e_cal_backend_store_clean (priv->store);
+}
+
+static void
 retrieval_done (SoupSession *session, SoupMessage *msg, ECalBackendHttp *cbhttp)
 {
 	ECalBackendHttpPrivate *priv;
@@ -251,7 +285,7 @@ retrieval_done (SoupSession *session, SoupMessage *msg, ECalBackendHttp *cbhttp)
 	icalcomponent_kind kind;
 	const gchar *newuri;
 	GHashTable *old_cache;
-	GList *comps_in_cache;
+	GSList *comps_in_cache;
 
 	priv = cbhttp->priv;
 
@@ -293,7 +327,7 @@ retrieval_done (SoupSession *session, SoupMessage *msg, ECalBackendHttp *cbhttp)
 						    soup_status_get_phrase (msg->status_code));
 		}
 
-		e_cal_backend_empty_cache (E_CAL_BACKEND (cbhttp), priv->cache);
+		empty_cache (cbhttp);
 		return;
 	}
 
@@ -303,7 +337,7 @@ retrieval_done (SoupSession *session, SoupMessage *msg, ECalBackendHttp *cbhttp)
 	if (!icalcomp) {
 		if (!priv->opened)
 			e_cal_backend_notify_error (E_CAL_BACKEND (cbhttp), _("Bad file format."));
-		e_cal_backend_empty_cache (E_CAL_BACKEND (cbhttp), priv->cache);
+		empty_cache (cbhttp);
 		return;
 	}
 
@@ -311,14 +345,14 @@ retrieval_done (SoupSession *session, SoupMessage *msg, ECalBackendHttp *cbhttp)
 		if (!priv->opened)
 			e_cal_backend_notify_error (E_CAL_BACKEND (cbhttp), _("Not a calendar."));
 		icalcomponent_free (icalcomp);
-		e_cal_backend_empty_cache (E_CAL_BACKEND (cbhttp), priv->cache);
+		empty_cache (cbhttp);
 		return;
 	}
 
 	/* Update cache */
 	old_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
 
-	comps_in_cache = e_cal_backend_cache_get_components (priv->cache);
+	comps_in_cache = e_cal_backend_store_get_components (priv->store);
 	while (comps_in_cache != NULL) {
 		const gchar *uid;
 		ECalComponent *comp = comps_in_cache->data;
@@ -326,13 +360,13 @@ retrieval_done (SoupSession *session, SoupMessage *msg, ECalBackendHttp *cbhttp)
 		e_cal_component_get_uid (comp, &uid);
 		g_hash_table_insert (old_cache, g_strdup (uid), e_cal_component_get_as_string (comp));
 
-		comps_in_cache = g_list_remove (comps_in_cache, comps_in_cache->data);
+		comps_in_cache = g_slist_remove (comps_in_cache, comps_in_cache->data);
 		g_object_unref (comp);
 	}
 
 	kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbhttp));
 	subcomp = icalcomponent_get_first_component (icalcomp, ICAL_ANY_COMPONENT);
-	e_file_cache_freeze_changes (E_FILE_CACHE (priv->cache));
+	e_cal_backend_store_freeze_changes (priv->store);
 	while (subcomp) {
 		ECalComponent *comp;
 		icalcomponent_kind subcomp_kind;
@@ -352,7 +386,7 @@ retrieval_done (SoupSession *session, SoupMessage *msg, ECalBackendHttp *cbhttp)
 				const gchar *uid, *orig_key, *orig_value;
 				gchar *obj;
 
-				e_cal_backend_cache_put_component (priv->cache, comp);
+				e_cal_backend_store_put_component (priv->store, comp);
 
 				e_cal_component_get_uid (comp, &uid);
 				/* middle (gpointer) cast only because of 'dereferencing type-punned pointer will break strict-aliasing rules' */
@@ -377,7 +411,7 @@ retrieval_done (SoupSession *session, SoupMessage *msg, ECalBackendHttp *cbhttp)
 
 			zone = icaltimezone_new ();
 			icaltimezone_set_component (zone, icalcomponent_new_clone (subcomp));
-			e_cal_backend_cache_put_timezone (priv->cache, (const icaltimezone *) zone);
+			e_cal_backend_store_put_timezone (priv->store, (const icaltimezone *) zone);
 
 			icaltimezone_free (zone, 1);
 		}
@@ -385,7 +419,7 @@ retrieval_done (SoupSession *session, SoupMessage *msg, ECalBackendHttp *cbhttp)
 		subcomp = icalcomponent_get_next_component (icalcomp, ICAL_ANY_COMPONENT);
 	}
 
-	e_file_cache_thaw_changes (E_FILE_CACHE (priv->cache));
+	e_cal_backend_store_thaw_changes (priv->store);
 
 	/* notify the removals */
 	g_hash_table_foreach_remove (old_cache, (GHRFunc) notify_and_remove_from_cache, cbhttp);
@@ -477,7 +511,7 @@ begin_retrieval_cb (ECalBackendHttp *cbhttp)
 	soup_message = soup_message_new (SOUP_METHOD_GET, priv->uri);
 	if (soup_message == NULL) {
 		priv->is_loading = FALSE;
-		e_cal_backend_empty_cache (E_CAL_BACKEND (cbhttp), priv->cache);
+		empty_cache (cbhttp);
 		return FALSE;
 	}
 
@@ -599,8 +633,9 @@ e_cal_backend_http_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_
 		priv->password = g_strdup (password);
 	}
 
-	if (!priv->cache) {
+	if (!priv->store) {
 		ECalSourceType source_type;
+		const gchar *uri = e_cal_backend_get_uri (E_CAL_BACKEND (backend));
 
 		switch (e_cal_backend_get_kind (E_CAL_BACKEND (backend))) {
 			default:
@@ -614,16 +649,19 @@ e_cal_backend_http_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_
 				source_type = E_CAL_SOURCE_TYPE_JOURNAL;
 				break;
 		}
+		
+		/* remove the old cache while migrating to ECalBackendStore */
+		e_cal_backend_cache_remove (uri, source_type);
+		priv->store = (ECalBackendStore *) e_cal_backend_file_store_new (uri, source_type);
+		e_cal_backend_store_load (priv->store);
 
-		priv->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (backend)), source_type);
-
-		if (!priv->cache) {
+		if (!priv->store) {
 			e_cal_backend_notify_error (E_CAL_BACKEND(cbhttp), _("Could not create cache file"));
 			return GNOME_Evolution_Calendar_OtherError;
 		}
 
 		if (priv->default_zone) {
-			e_cal_backend_cache_put_default_timezone (priv->cache, priv->default_zone);
+			e_cal_backend_store_set_default_timezone (priv->store, priv->default_zone);
 		}
 	}
 
@@ -644,10 +682,10 @@ e_cal_backend_http_remove (ECalBackendSync *backend, EDataCal *cal)
 	cbhttp = E_CAL_BACKEND_HTTP (backend);
 	priv = cbhttp->priv;
 
-	if (!priv->cache)
+	if (!priv->store)
 		return GNOME_Evolution_Calendar_Success;
 
-	e_file_cache_remove (E_FILE_CACHE (priv->cache));
+	e_cal_backend_store_remove (priv->store);
 	return GNOME_Evolution_Calendar_Success;
 }
 
@@ -661,7 +699,7 @@ e_cal_backend_http_is_loaded (ECalBackend *backend)
 	cbhttp = E_CAL_BACKEND_HTTP (backend);
 	priv = cbhttp->priv;
 
-	if (!priv->cache)
+	if (!priv->store)
 		return FALSE;
 
 	return TRUE;
@@ -763,10 +801,10 @@ e_cal_backend_http_get_object (ECalBackendSync *backend, EDataCal *cal, const gc
 
 	g_return_val_if_fail (uid != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
 
-	if (!priv->cache)
+	if (!priv->store)
 		return GNOME_Evolution_Calendar_ObjectNotFound;
 
-	comp = e_cal_backend_cache_get_component (priv->cache, uid, rid);
+	comp = e_cal_backend_store_get_component (priv->store, uid, rid);
 	if (!comp)
 		return GNOME_Evolution_Calendar_ObjectNotFound;
 
@@ -791,7 +829,7 @@ e_cal_backend_http_get_timezone (ECalBackendSync *backend, EDataCal *cal, const
 	g_return_val_if_fail (tzid != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
 
 	/* first try to get the timezone from the cache */
-	zone = e_cal_backend_cache_get_timezone (priv->cache, tzid);
+	zone = e_cal_backend_store_get_timezone (priv->store, tzid);
 	if (!zone) {
 		zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
 		if (!zone)
@@ -834,7 +872,7 @@ e_cal_backend_http_add_timezone (ECalBackendSync *backend, EDataCal *cal, const
 
 	zone = icaltimezone_new ();
 	icaltimezone_set_component (zone, tz_comp);
-	e_cal_backend_cache_put_timezone (priv->cache, zone);
+	e_cal_backend_store_put_timezone (priv->store, zone);
 
 	return GNOME_Evolution_Calendar_Success;
 }
@@ -876,28 +914,28 @@ e_cal_backend_http_get_object_list (ECalBackendSync *backend, EDataCal *cal, con
 {
 	ECalBackendHttp *cbhttp;
 	ECalBackendHttpPrivate *priv;
-	GList *components, *l;
+	GSList *components, *l;
 	ECalBackendSExp *cbsexp;
 
 	cbhttp = E_CAL_BACKEND_HTTP (backend);
 	priv = cbhttp->priv;
 
-	if (!priv->cache)
+	if (!priv->store)
 		return GNOME_Evolution_Calendar_NoSuchCal;
 
 	/* process all components in the cache */
 	cbsexp = e_cal_backend_sexp_new (sexp);
 
 	*objects = NULL;
-	components = e_cal_backend_cache_get_components (priv->cache);
-	for (l = components; l != NULL; l = l->next) {
+	components = e_cal_backend_store_get_components (priv->store);
+	for (l = components; l != NULL; l = g_slist_next (l)) {
 		if (e_cal_backend_sexp_match_comp (cbsexp, E_CAL_COMPONENT (l->data), E_CAL_BACKEND (backend))) {
 			*objects = g_list_append (*objects, e_cal_component_get_as_string (l->data));
 		}
 	}
 
-	g_list_foreach (components, (GFunc) g_object_unref, NULL);
-	g_list_free (components);
+	g_slist_foreach (components, (GFunc) g_object_unref, NULL);
+	g_slist_free (components);
 	g_object_unref (cbsexp);
 
 	return GNOME_Evolution_Calendar_Success;
@@ -909,7 +947,8 @@ e_cal_backend_http_start_query (ECalBackend *backend, EDataCalView *query)
 {
 	ECalBackendHttp *cbhttp;
 	ECalBackendHttpPrivate *priv;
-	GList *components, *l, *objects = NULL;
+	GSList *components, *l;
+	GList *objects = NULL;
 	ECalBackendSExp *cbsexp;
 
 	cbhttp = E_CAL_BACKEND_HTTP (backend);
@@ -917,7 +956,7 @@ e_cal_backend_http_start_query (ECalBackend *backend, EDataCalView *query)
 
 	d(g_message (G_STRLOC ": Starting query (%s)", e_data_cal_view_get_text (query)));
 
-	if (!priv->cache) {
+	if (!priv->store) {
 		e_data_cal_view_notify_done (query, GNOME_Evolution_Calendar_NoSuchCal);
 		return;
 	}
@@ -926,8 +965,8 @@ e_cal_backend_http_start_query (ECalBackend *backend, EDataCalView *query)
 	cbsexp = e_cal_backend_sexp_new (e_data_cal_view_get_text (query));
 
 	objects = NULL;
-	components = e_cal_backend_cache_get_components (priv->cache);
-	for (l = components; l != NULL; l = l->next) {
+	components = e_cal_backend_store_get_components (priv->store);
+	for (l = components; l != NULL; l = g_slist_next (l)) {
 		if (e_cal_backend_sexp_match_comp (cbsexp, E_CAL_COMPONENT (l->data), E_CAL_BACKEND (backend))) {
 			objects = g_list_append (objects, e_cal_component_get_as_string (l->data));
 		}
@@ -935,8 +974,8 @@ e_cal_backend_http_start_query (ECalBackend *backend, EDataCalView *query)
 
 	e_data_cal_view_notify_objects_added (query, (const GList *) objects);
 
-	g_list_foreach (components, (GFunc) g_object_unref, NULL);
-	g_list_free (components);
+	g_slist_foreach (components, (GFunc) g_object_unref, NULL);
+	g_slist_free (components);
 	g_list_foreach (objects, (GFunc) g_free, NULL);
 	g_list_free (objects);
 	g_object_unref (cbsexp);
@@ -991,16 +1030,16 @@ static icalcomponent *
 create_user_free_busy (ECalBackendHttp *cbhttp, const gchar *address, const gchar *cn,
                        time_t start, time_t end)
 {
-        GList *list = NULL, *l;
+        GSList *slist = NULL, *l;
         icalcomponent *vfb;
         icaltimezone *utc_zone;
         ECalBackendSExp *obj_sexp;
         ECalBackendHttpPrivate *priv;
-        ECalBackendCache *cache;
+        ECalBackendStore *store;
         gchar *query, *iso_start, *iso_end;
 
         priv = cbhttp->priv;
-        cache = priv->cache;
+        store = priv->store;
 
         /* create the (unique) VFREEBUSY object that we'll return */
         vfb = icalcomponent_new_vfreebusy ();
@@ -1035,9 +1074,9 @@ create_user_free_busy (ECalBackendHttp *cbhttp, const gchar *address, const gcha
         if (!obj_sexp)
                 return vfb;
 
-        list = e_cal_backend_cache_get_components(cache);
+        slist = e_cal_backend_store_get_components(store);
 
-        for (l = list; l; l = l->next) {
+        for (l = slist; l; l = g_slist_next (l)) {
                 ECalComponent *comp = l->data;
                 icalcomponent *icalcomp, *vcalendar_comp;
                 icalproperty *prop;
@@ -1067,7 +1106,7 @@ create_user_free_busy (ECalBackendHttp *cbhttp, const gchar *address, const gcha
                                                 vfb,
                                                 resolve_tzid,
                                                 vcalendar_comp,
-                                                e_cal_backend_cache_get_default_timezone (cache));
+                                                (icaltimezone *)e_cal_backend_store_get_default_timezone (store));
         }
         g_object_unref (obj_sexp);
 
@@ -1091,7 +1130,7 @@ e_cal_backend_http_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GList
 	g_return_val_if_fail (start != -1 && end != -1, GNOME_Evolution_Calendar_InvalidRange);
 	g_return_val_if_fail (start <= end, GNOME_Evolution_Calendar_InvalidRange);
 
-	if (!priv->cache)
+	if (!priv->store)
 		return GNOME_Evolution_Calendar_NoSuchCal;
 
         if (users == NULL) {
@@ -1238,7 +1277,7 @@ e_cal_backend_http_internal_get_default_timezone (ECalBackend *backend)
 	cbhttp = E_CAL_BACKEND_HTTP (backend);
 	priv = cbhttp->priv;
 
-	if (!priv->cache)
+	if (!priv->store)
 		return NULL;
 
 	return NULL;
diff --git a/calendar/backends/weather/e-cal-backend-weather.c b/calendar/backends/weather/e-cal-backend-weather.c
index 58041b3..6b8aa06 100644
--- a/calendar/backends/weather/e-cal-backend-weather.c
+++ b/calendar/backends/weather/e-cal-backend-weather.c
@@ -20,6 +20,7 @@
 
 #include <config.h>
 #include <libedata-cal/e-cal-backend-cache.h>
+#include <libedata-cal/e-cal-backend-file-store.h>
 #include <libedata-cal/e-cal-backend-util.h>
 #include <libedata-cal/e-cal-backend-sexp.h>
 #include <glib/gi18n-lib.h>
@@ -48,7 +49,7 @@ struct _ECalBackendWeatherPrivate {
 	CalMode mode;
 
 	/* The file cache */
-	ECalBackendCache *cache;
+	ECalBackendStore *store;
 
 	/* The calendar's default timezone, used for resolving DATE and
 	   floating DATE-TIME values. */
@@ -140,7 +141,7 @@ finished_retrieval_cb (WeatherInfo *info, ECalBackendWeather *cbw)
 	ECalBackendWeatherPrivate *priv;
 	ECalComponent *comp;
 	icalcomponent *icomp;
-	GList *l;
+	GSList *l;
 	gchar *obj;
 
 	priv = cbw->priv;
@@ -151,8 +152,8 @@ finished_retrieval_cb (WeatherInfo *info, ECalBackendWeather *cbw)
 	}
 
 	/* update cache */
-	l = e_cal_backend_cache_get_components (priv->cache);
-	for (; l != NULL; l = g_list_next (l)) {
+	l = e_cal_backend_store_get_components (priv->store);
+	for (; l != NULL; l = g_slist_next (l)) {
 		ECalComponentId *id;
 		gchar *obj;
 
@@ -169,14 +170,14 @@ finished_retrieval_cb (WeatherInfo *info, ECalBackendWeather *cbw)
 		g_free (obj);
 		g_object_unref (G_OBJECT (l->data));
 	}
-	g_list_free (l);
-	e_file_cache_clean (E_FILE_CACHE (priv->cache));
+	g_slist_free (l);
+	e_cal_backend_store_clean (priv->store);
 
 	comp = create_weather (cbw, info, FALSE);
 	if (comp) {
 		GSList *forecasts;
 
-		e_cal_backend_cache_put_component (priv->cache, comp);
+		e_cal_backend_store_put_component (priv->store, comp);
 		icomp = e_cal_component_get_icalcomponent (comp);
 		obj = icalcomponent_as_ical_string_r (icomp);
 		e_cal_backend_notify_object_created (E_CAL_BACKEND (cbw), obj);
@@ -193,7 +194,7 @@ finished_retrieval_cb (WeatherInfo *info, ECalBackendWeather *cbw)
 				if (nfo) {
 					comp = create_weather (cbw, nfo, TRUE);
 					if (comp) {
-						e_cal_backend_cache_put_component (priv->cache, comp);
+						e_cal_backend_store_put_component (priv->store, comp);
 						icomp = e_cal_component_get_icalcomponent (comp);
 						obj = icalcomponent_as_ical_string_r (icomp);
 						e_cal_backend_notify_object_created (E_CAL_BACKEND (cbw), obj);
@@ -477,13 +478,15 @@ e_cal_backend_weather_open (ECalBackendSync *backend, EDataCal *cal, gboolean on
 		g_free (priv->city);
 	priv->city = g_strdup (strrchr (uri, '/') + 1);
 
-	if (!priv->cache) {
-		priv->cache = e_cal_backend_cache_new (uri, E_CAL_SOURCE_TYPE_EVENT);
+	if (!priv->store) {
+		e_cal_backend_cache_remove (uri, E_CAL_SOURCE_TYPE_EVENT);
+		priv->store = (ECalBackendStore *) e_cal_backend_file_store_new (uri, E_CAL_SOURCE_TYPE_EVENT);
 
-		if (!priv->cache) {
+		if (!priv->store) {
 			e_cal_backend_notify_error (E_CAL_BACKEND (cbw), _("Could not create cache file"));
 			return GNOME_Evolution_Calendar_OtherError;
 		}
+		e_cal_backend_store_load (priv->store);
 
 		if (priv->default_zone) {
 			icalcomponent *icalcomp = icaltimezone_get_component (priv->default_zone);
@@ -513,13 +516,13 @@ e_cal_backend_weather_remove (ECalBackendSync *backend, EDataCal *cal)
 	cbw = E_CAL_BACKEND_WEATHER (backend);
 	priv = cbw->priv;
 
-	if (!priv->cache) {
+	if (!priv->store) {
 		/* lie here a bit, but otherwise the calendar will not be removed, even it should */
 		g_print (G_STRLOC ": Doesn't have a cache?!?");
 		return GNOME_Evolution_Calendar_Success;
 	}
 
-	e_file_cache_remove (E_FILE_CACHE (priv->cache));
+	e_cal_backend_store_remove (priv->store);
 	return GNOME_Evolution_Calendar_Success;
 }
 
@@ -549,9 +552,9 @@ e_cal_backend_weather_get_object (ECalBackendSync *backend, EDataCal *cal, const
 	ECalComponent *comp;
 
 	g_return_val_if_fail (uid != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
-	g_return_val_if_fail (priv->cache != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
+	g_return_val_if_fail (priv->store != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
 
-	comp = e_cal_backend_cache_get_component (priv->cache, uid, rid);
+	comp = e_cal_backend_store_get_component (priv->store, uid, rid);
 	g_return_val_if_fail (comp != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
 
 	*object = e_cal_component_get_as_string (comp);
@@ -566,20 +569,20 @@ e_cal_backend_weather_get_object_list (ECalBackendSync *backend, EDataCal *cal,
 	ECalBackendWeather *cbw = E_CAL_BACKEND_WEATHER (backend);
 	ECalBackendWeatherPrivate *priv = cbw->priv;
 	ECalBackendSExp *sexp = e_cal_backend_sexp_new (sexp_string);
-	GList *components, *l;
+	GSList *components, *l;
 
 	if (!sexp)
 		return GNOME_Evolution_Calendar_InvalidQuery;
 
 	*objects = NULL;
-	components = e_cal_backend_cache_get_components (priv->cache);
-	for (l = components; l != NULL; l = g_list_next (l)) {
+	components = e_cal_backend_store_get_components (priv->store);
+	for (l = components; l != NULL; l = g_slist_next (l)) {
 		if (e_cal_backend_sexp_match_comp (sexp, E_CAL_COMPONENT (l->data), E_CAL_BACKEND (backend)))
 			*objects = g_list_append (*objects, e_cal_component_get_as_string (l->data));
 	}
 
-	g_list_foreach (components, (GFunc) g_object_unref, NULL);
-	g_list_free (components);
+	g_slist_foreach (components, (GFunc) g_object_unref, NULL);
+	g_slist_free (components);
 	g_object_unref (sexp);
 
 	return GNOME_Evolution_Calendar_Success;
@@ -710,7 +713,7 @@ e_cal_backend_weather_is_loaded (ECalBackend *backend)
 	cbw = E_CAL_BACKEND_WEATHER (backend);
 	priv = cbw->priv;
 
-	if (!priv->cache)
+	if (!priv->store)
 		return FALSE;
 
 	return TRUE;
@@ -721,12 +724,13 @@ static void e_cal_backend_weather_start_query (ECalBackend *backend, EDataCalVie
 	ECalBackendWeather *cbw;
 	ECalBackendWeatherPrivate *priv;
 	ECalBackendSExp *sexp;
-	GList *components, *l, *objects;
+	GSList *components, *l;
+	GList *objects;
 
 	cbw = E_CAL_BACKEND_WEATHER (backend);
 	priv = cbw->priv;
 
-	if (!priv->cache) {
+	if (!priv->store) {
 		e_data_cal_view_notify_done (query, GNOME_Evolution_Calendar_NoSuchCal);
 		return;
 	}
@@ -738,8 +742,8 @@ static void e_cal_backend_weather_start_query (ECalBackend *backend, EDataCalVie
 	}
 
 	objects = NULL;
-	components = e_cal_backend_cache_get_components (priv->cache);
-	for (l = components; l != NULL; l = g_list_next (l)) {
+	components = e_cal_backend_store_get_components (priv->store);
+	for (l = components; l != NULL; l = g_slist_next (l)) {
 		if (e_cal_backend_sexp_match_comp (sexp, E_CAL_COMPONENT (l->data), backend))
 			objects = g_list_append (objects, e_cal_component_get_as_string (l->data));
 	}
@@ -747,8 +751,8 @@ static void e_cal_backend_weather_start_query (ECalBackend *backend, EDataCalVie
 	if (objects)
 		e_data_cal_view_notify_objects_added (query, (const GList *) objects);
 
-	g_list_foreach (components, (GFunc) g_object_unref, NULL);
-	g_list_free (components);
+	g_slist_foreach (components, (GFunc) g_object_unref, NULL);
+	g_slist_free (components);
 	g_list_foreach (objects, (GFunc) g_free, NULL);
 	g_list_free (objects);
 	g_object_unref (sexp);
@@ -866,9 +870,9 @@ e_cal_backend_weather_finalize (GObject *object)
 		priv->begin_retrival_id = 0;
 	}
 
-	if (priv->cache) {
-		g_object_unref (priv->cache);
-		priv->cache = NULL;
+	if (priv->store) {
+		g_object_unref (priv->store);
+		priv->store = NULL;
 	}
 
 	g_hash_table_destroy (priv->zones);
@@ -905,7 +909,7 @@ e_cal_backend_weather_init (ECalBackendWeather *cbw, ECalBackendWeatherClass *cl
 	priv->begin_retrival_id = 0;
 	priv->opened = FALSE;
 	priv->source = NULL;
-	priv->cache = NULL;
+	priv->store = NULL;
 	priv->city = NULL;
 
 	priv->zones = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_zone);
diff --git a/calendar/libedata-cal/e-cal-backend-file-store.c b/calendar/libedata-cal/e-cal-backend-file-store.c
index 0c1df92..b3a28a4 100644
--- a/calendar/libedata-cal/e-cal-backend-file-store.c
+++ b/calendar/libedata-cal/e-cal-backend-file-store.c
@@ -682,7 +682,7 @@ e_cal_backend_file_store_remove (ECalBackendStore *store)
 	ECalBackendFileStore *fstore = E_CAL_BACKEND_FILE_STORE (store);
 	ECalBackendFileStorePrivate *priv;
 
-	priv = GET_PRIVATE (store);
+	priv = GET_PRIVATE (fstore);
 
 	/* This will remove all the contents in the directory */
 	e_file_cache_remove (priv->keys_cache);
diff --git a/calendar/libedata-cal/e-cal-backend-store.c b/calendar/libedata-cal/e-cal-backend-store.c
index 1441314..e062c7f 100644
--- a/calendar/libedata-cal/e-cal-backend-store.c
+++ b/calendar/libedata-cal/e-cal-backend-store.c
@@ -302,7 +302,6 @@ e_cal_backend_store_remove_component (ECalBackendStore *store, const gchar *uid,
 	g_return_val_if_fail (store != NULL, FALSE);
 	g_return_val_if_fail (E_IS_CAL_BACKEND_STORE (store), FALSE);
 	g_return_val_if_fail (uid != NULL, FALSE);
-	g_return_val_if_fail (rid != NULL, FALSE);
 
 	return (E_CAL_BACKEND_STORE_GET_CLASS (store))->remove_component (store, uid, rid);
 }



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