[evolution-kolab] kolab-util-calendar-cache.c: Replace uri params with EBookBackendSync.



commit 3eb513028c2597c97c75da7168cfde94d9fed0eb
Author: Matthew Barnes <mbarnes redhat com>
Date:   Fri Jun 29 07:48:40 2012 -0400

    kolab-util-calendar-cache.c: Replace uri params with EBookBackendSync.
    
    The "backend" parameter really only has to be an EBackend.  I made it
    ECalBackendSync just for calling convenience from ECalBackendKolab.
    
    Functions can then call kolab_util_backend_get_foldername() to obtain
    the Kolab IMAP foldername for the backend, instead of parsing URIs.

 src/calendar/e-cal-backend-kolab.c       |   36 +++++++++++-----------
 src/calendar/kolab-util-calendar-cache.c |   50 ++++++++++++++---------------
 src/calendar/kolab-util-calendar-cache.h |   16 +++++-----
 3 files changed, 50 insertions(+), 52 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-kolab.c b/src/calendar/e-cal-backend-kolab.c
index 8bc5206..f028cd4 100644
--- a/src/calendar/e-cal-backend-kolab.c
+++ b/src/calendar/e-cal-backend-kolab.c
@@ -690,9 +690,9 @@ e_cal_backend_kolab_get_object (ECalBackendSync *backend,
 	self = E_CAL_BACKEND_KOLAB (backend);
 	priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
 
-	ecalcomp = kolab_util_calendar_cache_get_object (priv->cal_cache,
+	ecalcomp = kolab_util_calendar_cache_get_object (backend,
+	                                                 priv->cal_cache,
 	                                                 priv->cal_koma,
-	                                                 priv->cal_uri,
 	                                                 uid,
 	                                                 FALSE,
 	                                                 cancellable,
@@ -734,10 +734,10 @@ e_cal_backend_kolab_get_object_list (ECalBackendSync *backend,
 	self = E_CAL_BACKEND_KOLAB (backend);
 	priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
 
-	ok = kolab_util_calendar_cache_update_on_query (priv->cal_cache,
+	ok = kolab_util_calendar_cache_update_on_query (backend,
+	                                                priv->cal_cache,
 	                                                priv->cal_koma,
 	                                                sexp,
-	                                                priv->cal_uri,
 	                                                cancellable,
 	                                                &tmp_err);
 	if (! ok) {
@@ -761,9 +761,9 @@ e_cal_backend_kolab_get_object_list (ECalBackendSync *backend,
 	for (it = uid_list; it != NULL; it = g_list_next (it)) {
 		gchar *uid = it->data;
 		ECalComponent *ecalcomp = NULL;
-		ecalcomp = kolab_util_calendar_cache_get_object (priv->cal_cache,
+		ecalcomp = kolab_util_calendar_cache_get_object (backend,
+		                                                 priv->cal_cache,
 		                                                 priv->cal_koma,
-		                                                 priv->cal_uri,
 		                                                 uid,
 		                                                 TRUE,
 		                                                 cancellable,
@@ -969,10 +969,10 @@ e_cal_backend_kolab_create_objects (ECalBackendSync *backend,
 		}
 	}
 
-	ok = kolab_util_calendar_cache_assure_uid_on_ecalcomponent (priv->cal_cache,
+	ok = kolab_util_calendar_cache_assure_uid_on_ecalcomponent (backend,
+	                                                            priv->cal_cache,
 	                                                            priv->cal_koma,
 	                                                            ecalcomp,
-	                                                            priv->cal_uri,
 	                                                            FALSE,
 	                                                            cancellable,
 	                                                            &tmp_err);
@@ -1096,9 +1096,9 @@ e_cal_backend_kolab_modify_objects (ECalBackendSync *backend,
 
 	e_cal_component_get_uid (ecalcomp, &uid);
 
-	oldcomp = kolab_util_calendar_cache_get_object (priv->cal_cache,
+	oldcomp = kolab_util_calendar_cache_get_object (backend,
+	                                                priv->cal_cache,
 	                                                priv->cal_koma,
-	                                                priv->cal_uri,
 	                                                uid,
 	                                                FALSE,
 	                                                cancellable,
@@ -1139,10 +1139,10 @@ e_cal_backend_kolab_modify_objects (ECalBackendSync *backend,
 		                                                     oldcomp,
 		                                                     uid,
 		                                                     rid);
-		ok = kolab_util_calendar_cache_assure_uid_on_ecalcomponent (priv->cal_cache,
+		ok = kolab_util_calendar_cache_assure_uid_on_ecalcomponent (backend,
+		                                                            priv->cal_cache,
 		                                                            priv->cal_koma,
 		                                                            ecalcomp,
-		                                                            priv->cal_uri,
 		                                                            TRUE,
 		                                                            cancellable,
 		                                                            &tmp_err);
@@ -1278,9 +1278,9 @@ e_cal_backend_kolab_remove_objects (ECalBackendSync *backend,
 	if (rid == NULL)
 		mod = CALOBJ_MOD_ALL;
 
-	oldcomp = kolab_util_calendar_cache_get_object (priv->cal_cache,
+	oldcomp = kolab_util_calendar_cache_get_object (backend,
+	                                                priv->cal_cache,
 	                                                priv->cal_koma,
-	                                                priv->cal_uri,
 	                                                uid,
 	                                                FALSE,
 	                                                cancellable,
@@ -1808,10 +1808,10 @@ e_cal_backend_kolab_start_view (ECalBackend *backend,
 
 	sourcename = kolab_util_backend_get_relative_path_from_uri (priv->cal_uri);
 
-	ok = kolab_util_calendar_cache_update_on_query (priv->cal_cache,
+	ok = kolab_util_calendar_cache_update_on_query (backend,
+	                                                priv->cal_cache,
 	                                                priv->cal_koma,
 	                                                query,
-	                                                priv->cal_uri,
 	                                                NULL, /* FIXME: GCancellable */
 	                                                &tmp_err);
 	if (! ok)
@@ -1827,9 +1827,9 @@ e_cal_backend_kolab_start_view (ECalBackend *backend,
 	for (it = uid_list; it != NULL; it = g_list_next (it)) {
 		gchar *uid = it->data;
 		ECalComponent *ecalcomp = NULL;
-		ecalcomp = kolab_util_calendar_cache_get_object (priv->cal_cache,
+		ecalcomp = kolab_util_calendar_cache_get_object (backend,
+		                                                 priv->cal_cache,
 		                                                 priv->cal_koma,
-		                                                 priv->cal_uri,
 		                                                 uid,
 		                                                 TRUE,
 		                                                 NULL, /* FIXME GCancellable */
diff --git a/src/calendar/kolab-util-calendar-cache.c b/src/calendar/kolab-util-calendar-cache.c
index ce54229..d2c3aec 100644
--- a/src/calendar/kolab-util-calendar-cache.c
+++ b/src/calendar/kolab-util-calendar-cache.c
@@ -139,9 +139,9 @@ kolab_util_calendar_cache_get_tz (ECalBackendCache *cache,
 
 /**
  * kolab_util_calendar_cache_get_object:
+ * @backend: an #ECalBackendSync
  * @cal_cache: A Cache.
  * @koma: A KolabMailAccess object.
- * @uri: An ECalComponent uri string.
  * @uid: The uid to search for.
  * @bulk: Whether or not this is a mass operation.
  * @cancellable: A cancellation stack.
@@ -154,9 +154,9 @@ kolab_util_calendar_cache_get_tz (ECalBackendCache *cache,
  *          Unref if no longer needed.
  **/
 ECalComponent*
-kolab_util_calendar_cache_get_object (ECalBackendCache *cal_cache,
+kolab_util_calendar_cache_get_object (ECalBackendSync *backend,
+                                      ECalBackendCache *cal_cache,
                                       KolabMailAccess *koma,
-                                      const gchar *uri,
                                       const gchar *uid,
                                       gboolean bulk,
                                       GCancellable *cancellable,
@@ -166,25 +166,24 @@ kolab_util_calendar_cache_get_object (ECalBackendCache *cal_cache,
 	ECalComponent *comp = NULL;
 	ECalComponent *tz = NULL;
 	GError *tmp_error = NULL;
-	gchar *sourcename = NULL;
+	const gchar *foldername;
 	gchar *tzid = NULL;
 	gboolean ok = FALSE;
 
+	g_assert (E_IS_CAL_BACKEND_SYNC (backend));
 	g_assert (E_IS_CAL_BACKEND_CACHE (cal_cache));
 	g_assert (KOLAB_IS_MAIL_ACCESS (koma));
-	g_assert (uri != NULL);
 	g_assert (uid != NULL);
 	/* cancellable may be NULL */
 	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
-	sourcename = kolab_util_backend_get_relative_path_from_uri (uri);
+	foldername = kolab_util_backend_get_foldername (E_BACKEND (backend));
 
 	kmh = kolab_mail_access_get_handle (koma,
 	                                    uid,
-	                                    sourcename,
+	                                    foldername,
 	                                    cancellable,
 	                                    &tmp_error);
-	g_free (sourcename);
 	if (kmh == NULL) {
 		/* empty object, could be "nothing found" */
 		if (tmp_error != NULL) {
@@ -227,9 +226,9 @@ kolab_util_calendar_cache_get_object (ECalBackendCache *cal_cache,
 } /* kolab_util_calendar_cache_get_object () */
 
 gboolean
-kolab_util_calendar_cache_update_object (ECalBackendCache *cache,
+kolab_util_calendar_cache_update_object (ECalBackendSync *backend,
+                                         ECalBackendCache *cache,
                                          KolabMailAccess *koma,
-                                         const gchar *uri,
                                          const gchar *uid,
                                          gboolean bulk,
                                          GCancellable *cancellable,
@@ -237,16 +236,16 @@ kolab_util_calendar_cache_update_object (ECalBackendCache *cache,
 {
 	ECalComponent *ecalcomp = NULL;
 
+	g_assert (E_IS_CAL_BACKEND_SYNC (backend));
 	g_assert (E_IS_CAL_BACKEND_CACHE (cache));
 	g_assert (KOLAB_IS_MAIL_ACCESS (koma));
-	g_assert (uri != NULL);
 	g_assert (uid != NULL);
 	/* cancellable may be NULL */
 	g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
-	ecalcomp = kolab_util_calendar_cache_get_object (cache,
+	ecalcomp = kolab_util_calendar_cache_get_object (backend,
+	                                                 cache,
 	                                                 koma,
-	                                                 uri,
 	                                                 uid,
 	                                                 bulk,
 	                                                 cancellable,
@@ -312,40 +311,39 @@ kolab_util_calendar_cache_remove_instance (ECalBackendCache *cal_cache,
 } /* kolab_util_calendar_cache_remove_instance () */
 
 gboolean
-kolab_util_calendar_cache_update_on_query (ECalBackendCache *cache,
+kolab_util_calendar_cache_update_on_query (ECalBackendSync *backend,
+                                           ECalBackendCache *cache,
                                            KolabMailAccess *koma,
                                            const gchar *query,
-                                           const gchar *uri,
                                            GCancellable *cancellable,
                                            GError **error)
 {
 	GList *changed_uids = NULL;
-	gchar *sourcename = NULL;
+	const gchar *foldername;
 	GError *tmp_error = NULL;
 
 	g_debug ("%s()[%u] called.", __func__, __LINE__);
 
+	g_assert (E_IS_CAL_BACKEND_SYNC (backend));
 	g_assert (E_IS_CAL_BACKEND_CACHE (cache));
 	g_assert (KOLAB_IS_MAIL_ACCESS (koma));
 	/* query may be NULL */
-	g_assert (uri != NULL);
 	/* cancellable may be NULL */
 	g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
-	sourcename = kolab_util_backend_get_relative_path_from_uri (uri);
+	foldername = kolab_util_backend_get_foldername (E_BACKEND (backend));
 
 	/* Backend cache no longer in use for PIM objects -
 	 * we can just free() the result (but must fetch
 	 * it nonetheless)
 	 */
 	changed_uids = kolab_mail_access_query_changed_uids (koma,
-	                                                     sourcename,
+	                                                     foldername,
 	                                                     query,
 	                                                     cancellable,
 	                                                     &tmp_error);
 	if (tmp_error != NULL) {
 		g_propagate_error (error, tmp_error);
-		g_free (sourcename);
 		return FALSE;
 	}
 	if (changed_uids != NULL)
@@ -360,9 +358,9 @@ kolab_util_calendar_cache_update_on_query (ECalBackendCache *cache,
 
 /**
  * kolab_util_calendar_cache_assure_uid_on_ecalcomponent:
+ * @backend: an #ECalBackendSync
  * @cache: An ECalBackendCache.
  * @koma: A KolabMailAccess instance.
- * @uri: An ECalComponent uri string.
  * @ecalcomp: An ECalComponent.
  * @bulk: Whether or not this is a mass operation.
  * @cancellable: A cancellation stack.
@@ -373,10 +371,10 @@ kolab_util_calendar_cache_update_on_query (ECalBackendCache *cache,
  * Returns: On Success TRUE is returned.
  */
 gboolean
-kolab_util_calendar_cache_assure_uid_on_ecalcomponent (ECalBackendCache *cache,
+kolab_util_calendar_cache_assure_uid_on_ecalcomponent (ECalBackendSync *backend,
+                                                       ECalBackendCache *cache,
                                                        KolabMailAccess *koma,
                                                        ECalComponent *ecalcomp,
-                                                       const gchar *uri,
                                                        gboolean bulk,
                                                        GCancellable *cancellable,
                                                        GError **error)
@@ -387,10 +385,10 @@ kolab_util_calendar_cache_assure_uid_on_ecalcomponent (ECalBackendCache *cache,
 	gchar *uid = NULL;
 	KolabSettingsHandler *ksettings = NULL;
 
+	g_assert (E_IS_CAL_BACKEND_SYNC (backend));
 	g_assert (E_IS_CAL_BACKEND_CACHE (cache));
 	g_assert (KOLAB_IS_MAIL_ACCESS (koma));
 	g_assert (E_IS_CAL_COMPONENT (ecalcomp));
-	g_assert (uri != NULL);
 	/* cancellable may be NULL */
 	g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
@@ -406,9 +404,9 @@ kolab_util_calendar_cache_assure_uid_on_ecalcomponent (ECalBackendCache *cache,
 		uid = e_cal_component_gen_uid();
 	for (;;) {
 		/* remember, this has to be called with a non-empty uid */
-		tmp_comp = kolab_util_calendar_cache_get_object (cache,
+		tmp_comp = kolab_util_calendar_cache_get_object (backend,
+		                                                 cache,
 		                                                 koma,
-		                                                 uri,
 		                                                 uid,
 		                                                 bulk,
 		                                                 cancellable,
diff --git a/src/calendar/kolab-util-calendar-cache.h b/src/calendar/kolab-util-calendar-cache.h
index 64a5a9b..25593b0 100644
--- a/src/calendar/kolab-util-calendar-cache.h
+++ b/src/calendar/kolab-util-calendar-cache.h
@@ -84,9 +84,9 @@ kolab_util_calendar_cache_get_tz (ECalBackendCache *cache,
                                   ECalComponent *comp);
 
 ECalComponent*
-kolab_util_calendar_cache_get_object (ECalBackendCache *cal_cache,
+kolab_util_calendar_cache_get_object (ECalBackendSync *backend,
+                                      ECalBackendCache *cal_cache,
                                       KolabMailAccess *koma,
-                                      const gchar *uri,
                                       const gchar *uid,
                                       gboolean bulk,
                                       GCancellable *cancellable,
@@ -100,26 +100,26 @@ kolab_util_calendar_cache_remove_instance (ECalBackendCache *cal_cache,
                                            const gchar *rid);
 
 gboolean
-kolab_util_calendar_cache_assure_uid_on_ecalcomponent (ECalBackendCache *cache,
+kolab_util_calendar_cache_assure_uid_on_ecalcomponent (ECalBackendSync *backend,
+                                                       ECalBackendCache *cache,
                                                        KolabMailAccess *koma,
                                                        ECalComponent *ecalcomp,
-                                                       const gchar *uri,
                                                        gboolean bulk,
                                                        GCancellable *cancellable,
                                                        GError **error);
 
 gboolean
-kolab_util_calendar_cache_update_on_query (ECalBackendCache *cache,
+kolab_util_calendar_cache_update_on_query (ECalBackendSync *backend,
+                                           ECalBackendCache *cache,
                                            KolabMailAccess *koma,
                                            const gchar *query,
-                                           const gchar *uri,
                                            GCancellable *cancellable,
                                            GError **error);
 
 gboolean
-kolab_util_calendar_cache_update_object (ECalBackendCache *cache,
+kolab_util_calendar_cache_update_object (ECalBackendSync *backend,
+                                         ECalBackendCache *cache,
                                          KolabMailAccess *koma,
-                                         const gchar *uri,
                                          const gchar *uid,
                                          gboolean bulk,
                                          GCancellable *cancellable,



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