[evolution-data-server] Find the timezone in libical first and then the backend or cache while resolving tzids



commit fcf9801eef6632aad812db7499d8c2ac57e4ec8c
Author: Chenthill Palanisamy <pchenthill novell com>
Date:   Tue Sep 7 16:52:18 2010 +0530

    Find the timezone in libical first and then the backend or cache while resolving tzids

 calendar/backends/caldav/e-cal-backend-caldav.c    |   14 +++++++++--
 calendar/backends/file/e-cal-backend-file.c        |   10 ++++----
 .../backends/groupwise/e-cal-backend-groupwise.c   |   14 +++++++++--
 calendar/backends/http/e-cal-backend-http.c        |   23 +++++++++++--------
 calendar/backends/weather/e-cal-backend-weather.c  |   14 +++++++++--
 calendar/libecal/e-cal-util.c                      |    2 +-
 calendar/libecal/e-cal-util.h                      |    2 +-
 calendar/libedata-cal/e-cal-backend-file-store.c   |   15 ++++++++++--
 8 files changed, 65 insertions(+), 29 deletions(-)
---
diff --git a/calendar/backends/caldav/e-cal-backend-caldav.c b/calendar/backends/caldav/e-cal-backend-caldav.c
index 595f6fb..a2f6ae9 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -266,12 +266,20 @@ caldav_debug_setup (SoupSession *session)
 	g_object_unref (logger);
 }
 
+/* TODO Do not replicate this in every backend */
 static icaltimezone *
 resolve_tzid (const char *tzid, gpointer user_data)
 {
-	return (!strcmp (tzid, "UTC"))
+	icaltimezone *zone;
+		
+	zone = (!strcmp (tzid, "UTC"))
 		? icaltimezone_get_utc_timezone ()
 		: icaltimezone_get_builtin_timezone_from_tzid (tzid);
+	
+	if (!zone)
+		e_cal_backend_internal_get_timezone (E_CAL_BACKEND (user_data), tzid);
+
+	return zone;
 }
 
 static gboolean 
@@ -283,8 +291,8 @@ put_component_to_store (ECalBackendCalDAV *cbdav,
 
 	priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
 
-	get_component_occur_times (comp, &time_start, &time_end,
-				   resolve_tzid, NULL,  icaltimezone_get_utc_timezone (),
+	e_cal_util_get_component_occur_times (comp, &time_start, &time_end,
+				   resolve_tzid, cbdav,  icaltimezone_get_utc_timezone (),
 				   e_cal_backend_get_kind (E_CAL_BACKEND (cbdav)));
 
 	return e_cal_backend_store_put_component_with_time_range (priv->store, comp, time_start, time_end);
diff --git a/calendar/backends/file/e-cal-backend-file.c b/calendar/backends/file/e-cal-backend-file.c
index dc106b4..0ea7955 100644
--- a/calendar/backends/file/e-cal-backend-file.c
+++ b/calendar/backends/file/e-cal-backend-file.c
@@ -459,10 +459,10 @@ resolve_tzid (const gchar *tzid, gpointer user_data)
         else if (!strcmp (tzid, "UTC"))
                 return icaltimezone_get_utc_timezone ();
 
-	zone = icalcomponent_get_timezone (vcalendar_comp, tzid);
+	zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
 
 	if (!zone)
-		zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+		zone = icalcomponent_get_timezone (vcalendar_comp, tzid);
 
 	return zone;
 }
@@ -531,7 +531,7 @@ add_component_to_intervaltree (ECalBackendFile *cbfile, ECalComponent *comp)
 
 	priv = cbfile->priv;
 
-	get_component_occur_times (comp, &time_start, &time_end,
+	e_cal_util_get_component_occur_times (comp, &time_start, &time_end,
 				   resolve_tzid, priv->icalcomp, priv->default_zone,
 				   e_cal_backend_get_kind (E_CAL_BACKEND (cbfile)));
 
@@ -556,7 +556,7 @@ remove_component_from_intervaltree (ECalBackendFile *cbfile, ECalComponent *comp
 
 	priv = cbfile->priv;
 
-	get_component_occur_times (comp, &time_start, &time_end,
+	e_cal_util_get_component_occur_times (comp, &time_start, &time_end,
 				   resolve_tzid, priv->icalcomp, priv->default_zone,
 				   e_cal_backend_get_kind (E_CAL_BACKEND (cbfile)));
 
@@ -3497,7 +3497,7 @@ get_difference_of_lists (ECalBackendFile* cbfile, GList* smaller, GList* bigger)
 			time_t time_start, time_end;
 			printf ("%s IS MISSING\n", uid);
 
-			get_component_occur_times (comp, &time_start, &time_end,
+			e_cal_util_get_component_occur_times (comp, &time_start, &time_end,
 						   resolve_tzid, cbfile->priv->icalcomp,
 						   cbfile->priv->default_zone,
 						   e_cal_backend_get_kind (E_CAL_BACKEND (cbfile)));
diff --git a/calendar/backends/groupwise/e-cal-backend-groupwise.c b/calendar/backends/groupwise/e-cal-backend-groupwise.c
index 4719598..6d16213 100644
--- a/calendar/backends/groupwise/e-cal-backend-groupwise.c
+++ b/calendar/backends/groupwise/e-cal-backend-groupwise.c
@@ -191,12 +191,20 @@ get_element_type (icalcomponent_kind kind)
 
 }
 
+/* TODO Do not replicate this in every backend */
 static icaltimezone *
 resolve_tzid (const char *tzid, gpointer user_data)
 {
-	return (!strcmp (tzid, "UTC"))
+	icaltimezone *zone;
+		
+	zone = (!strcmp (tzid, "UTC"))
 		? icaltimezone_get_utc_timezone ()
 		: icaltimezone_get_builtin_timezone_from_tzid (tzid);
+	
+	if (!zone)
+		e_cal_backend_internal_get_timezone (E_CAL_BACKEND (user_data), tzid);
+
+	return zone;
 }
 
 static void
@@ -208,8 +216,8 @@ put_component_to_store (ECalBackendGroupwise *cbgw,
 
 	priv = cbgw->priv;
 
-	get_component_occur_times (comp, &time_start, &time_end,
-				   resolve_tzid, NULL, priv->default_zone,
+	e_cal_util_get_component_occur_times (comp, &time_start, &time_end,
+				   resolve_tzid, cbgw, priv->default_zone,
 				   e_cal_backend_get_kind (E_CAL_BACKEND (cbgw)));
 
 	e_cal_backend_store_put_component_with_time_range (priv->store, comp, time_start, time_end);
diff --git a/calendar/backends/http/e-cal-backend-http.c b/calendar/backends/http/e-cal-backend-http.c
index 46c7937..520f5b2 100644
--- a/calendar/backends/http/e-cal-backend-http.c
+++ b/calendar/backends/http/e-cal-backend-http.c
@@ -274,17 +274,20 @@ empty_cache (ECalBackendHttp *cbhttp)
 	e_cal_backend_store_clean (priv->store);
 }
 
+/* TODO Do not replicate this in every backend */
 static icaltimezone *
 resolve_tzid (const char *tzid, gpointer user_data)
 {
-        icalcomponent *vcalendar_comp = user_data;
-
-        if (!tzid || !tzid[0])
-                return NULL;
-        else if (!strcmp (tzid, "UTC"))
-                return icaltimezone_get_utc_timezone ();
+	icaltimezone *zone;
+		
+	zone = (!strcmp (tzid, "UTC"))
+		? icaltimezone_get_utc_timezone ()
+		: icaltimezone_get_builtin_timezone_from_tzid (tzid);
+	
+	if (!zone)
+		e_cal_backend_internal_get_timezone (E_CAL_BACKEND (user_data), tzid);
 
-        return icalcomponent_get_timezone (vcalendar_comp, tzid);
+	return zone;
 }
 
 static void
@@ -296,8 +299,8 @@ put_component_to_store (ECalBackendHttp *cb,
 
 	priv = cb->priv;
 
-	get_component_occur_times (comp, &time_start, &time_end,
-				   resolve_tzid, NULL, priv->default_zone,
+	e_cal_util_get_component_occur_times (comp, &time_start, &time_end,
+				   resolve_tzid, cb, priv->default_zone,
 				   e_cal_backend_get_kind (E_CAL_BACKEND (cb)));
 
 	e_cal_backend_store_put_component_with_time_range (priv->store, comp, time_start, time_end);
diff --git a/calendar/backends/weather/e-cal-backend-weather.c b/calendar/backends/weather/e-cal-backend-weather.c
index 7b703af..d1bc5dc 100644
--- a/calendar/backends/weather/e-cal-backend-weather.c
+++ b/calendar/backends/weather/e-cal-backend-weather.c
@@ -139,12 +139,20 @@ maybe_start_reload_timeout (ECalBackendWeather *cbw)
 
 }
 
+/* TODO Do not replicate this in every backend */
 static icaltimezone *
 resolve_tzid (const char *tzid, gpointer user_data)
 {
-	return (!strcmp (tzid, "UTC"))
+	icaltimezone *zone;
+		
+	zone = (!strcmp (tzid, "UTC"))
 		? icaltimezone_get_utc_timezone ()
 		: icaltimezone_get_builtin_timezone_from_tzid (tzid);
+	
+	if (!zone)
+		e_cal_backend_internal_get_timezone (E_CAL_BACKEND (user_data), tzid);
+
+	return zone;
 }
 
 static void
@@ -156,8 +164,8 @@ put_component_to_store (ECalBackendWeather *cb,
 
 	priv = cb->priv;
 
-	get_component_occur_times (comp, &time_start, &time_end,
-				   resolve_tzid, NULL, priv->default_zone,
+	e_cal_util_get_component_occur_times (comp, &time_start, &time_end,
+				   resolve_tzid, cb, priv->default_zone,
 				   e_cal_backend_get_kind (E_CAL_BACKEND (cb)));
 
 	e_cal_backend_store_put_component_with_time_range (priv->store, comp, time_start, time_end);
diff --git a/calendar/libecal/e-cal-util.c b/calendar/libecal/e-cal-util.c
index e7a8720..1a67f02 100644
--- a/calendar/libecal/e-cal-util.c
+++ b/calendar/libecal/e-cal-util.c
@@ -1196,7 +1196,7 @@ componenttime_to_utc_timet (const ECalComponentDateTime* dt_time,
  * Find out, when the component starts and stops. Be careful about recurrences.
  */
 void
-get_component_occur_times (ECalComponent *comp,
+e_cal_util_get_component_occur_times (ECalComponent *comp,
 			   time_t* start,
 			   time_t* end,
 			   ECalRecurResolveTimezoneFn tz_cb,
diff --git a/calendar/libecal/e-cal-util.h b/calendar/libecal/e-cal-util.h
index 5de7400..02e0660 100644
--- a/calendar/libecal/e-cal-util.h
+++ b/calendar/libecal/e-cal-util.h
@@ -151,7 +151,7 @@ void           e_cal_util_remove_instances (icalcomponent *icalcomp,
 
 gchar *e_cal_util_get_system_timezone_location (void);
 icaltimezone *e_cal_util_get_system_timezone (void);
-void get_component_occur_times (ECalComponent *comp,
+void e_cal_util_get_component_occur_times (ECalComponent *comp,
 				   time_t* start,
 				   time_t* end,
 				   ECalRecurResolveTimezoneFn tz_cb,
diff --git a/calendar/libedata-cal/e-cal-backend-file-store.c b/calendar/libedata-cal/e-cal-backend-file-store.c
index 902db18..b8a5f09 100644
--- a/calendar/libedata-cal/e-cal-backend-file-store.c
+++ b/calendar/libedata-cal/e-cal-backend-file-store.c
@@ -611,9 +611,16 @@ add_timezone (ECalBackendFileStore *fstore, icalcomponent *vtzcomp)
 static icaltimezone *
 resolve_tzid (const char *tzid, gpointer user_data)
 {
-	return (!strcmp (tzid, "UTC"))
+	icaltimezone *zone;
+		
+	zone = (!strcmp (tzid, "UTC"))
 		? icaltimezone_get_utc_timezone ()
 		: icaltimezone_get_builtin_timezone_from_tzid (tzid);
+	
+	if (!zone)
+		e_cal_backend_store_get_timezone (E_CAL_BACKEND_STORE (user_data), tzid);
+
+	return zone;
 }
 
 /*static icaltimezone * 
@@ -644,6 +651,7 @@ scan_vcalendar (ECalBackendStore *store, icalcomponent *top_icalcomp)
 	for (iter = icalcomponent_begin_component (top_icalcomp, ICAL_ANY_COMPONENT);
 	     icalcompiter_deref (&iter) != NULL;
 	     icalcompiter_next (&iter)) {
+		const icaltimezone *dzone = NULL;
 		icalcomponent *icalcomp;
 		icalcomponent_kind kind;
 		ECalComponent *comp;
@@ -669,8 +677,9 @@ scan_vcalendar (ECalBackendStore *store, icalcomponent *top_icalcomp)
 			continue;
 		}
 		
-		get_component_occur_times (comp, &time_start, &time_end,
-						resolve_tzid, NULL, NULL, kind);
+		dzone = e_cal_backend_store_get_default_timezone (store);
+		e_cal_util_get_component_occur_times (comp, &time_start, &time_end,
+						resolve_tzid, store, dzone, kind);
 
 		e_cal_backend_store_put_component_with_time_range (store, comp, time_start, time_end);
 



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