[evolution-data-server] Bug #602945 - Avoid code duplication with timezone fetching from backends
- From: Milan Crha <mcrha src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug #602945 - Avoid code duplication with timezone fetching from backends
- Date: Mon, 30 Nov 2009 18:33:54 +0000 (UTC)
commit 7e87ac0ff5ee97b9dcb4214447c2fc7512333554
Author: Milan Crha <mcrha redhat com>
Date: Mon Nov 30 19:33:07 2009 +0100
Bug #602945 - Avoid code duplication with timezone fetching from backends
calendar/backends/caldav/e-cal-backend-caldav.c | 61 ++--------------
.../backends/contacts/e-cal-backend-contacts.c | 27 -------
calendar/backends/file/e-cal-backend-file.c | 45 ------------
calendar/backends/google/e-cal-backend-google.c | 49 -------------
.../backends/groupwise/e-cal-backend-groupwise.c | 43 ++----------
calendar/backends/http/e-cal-backend-http.c | 37 +---------
calendar/backends/weather/e-cal-backend-weather.c | 46 ++++---------
calendar/libedata-cal/e-cal-backend-sync.c | 74 ++++++++++++++++----
8 files changed, 93 insertions(+), 289 deletions(-)
---
diff --git a/calendar/backends/caldav/e-cal-backend-caldav.c b/calendar/backends/caldav/e-cal-backend-caldav.c
index e36bad1..fbc3f33 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -2386,7 +2386,6 @@ caldav_refresh (ECalBackendSync *backend, EDataCal *cal)
{
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
- ECalBackendSyncStatus status;
gboolean online;
cbdav = E_CAL_BACKEND_CALDAV (backend);
@@ -3939,43 +3938,6 @@ caldav_get_object (ECalBackendSync *backend,
}
static ECalBackendSyncStatus
-caldav_get_timezone (ECalBackendSync *backend,
- EDataCal *cal,
- const gchar *tzid,
- gchar **object)
-{
- ECalBackendCalDAV *cbdav;
- ECalBackendCalDAVPrivate *priv;
- const icaltimezone *zone;
- icalcomponent *icalcomp;
-
- cbdav = E_CAL_BACKEND_CALDAV (backend);
- priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
-
- g_return_val_if_fail (tzid, GNOME_Evolution_Calendar_ObjectNotFound);
-
- /* first try to get the timezone from the cache */
- zone = e_cal_backend_store_get_timezone (priv->store, tzid);
-
- if (!zone) {
- zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
- if (!zone) {
- return GNOME_Evolution_Calendar_ObjectNotFound;
- }
- }
-
- icalcomp = icaltimezone_get_component ((icaltimezone *) zone);
-
- if (!icalcomp) {
- return GNOME_Evolution_Calendar_InvalidObject;
- }
-
- *object = icalcomponent_as_ical_string_r (icalcomp);
-
- return GNOME_Evolution_Calendar_Success;
-}
-
-static ECalBackendSyncStatus
caldav_add_timezone (ECalBackendSync *backend,
EDataCal *cal,
const gchar *tzobj)
@@ -4419,27 +4381,19 @@ caldav_internal_get_timezone (ECalBackend *backend,
const gchar *tzid)
{
icaltimezone *zone;
+ ECalBackendCalDAV *cbdav;
+ ECalBackendCalDAVPrivate *priv;
- zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
-
- if (!zone) {
- ECalBackendCalDAV *cbdav;
- ECalBackendCalDAVPrivate *priv;
-
- cbdav = E_CAL_BACKEND_CALDAV (backend);
- priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
+ cbdav = E_CAL_BACKEND_CALDAV (backend);
+ priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
+ zone = NULL;
- if (priv->store)
- zone = (icaltimezone *) e_cal_backend_store_get_timezone (priv->store, tzid);
- }
+ if (priv->store)
+ zone = (icaltimezone *) e_cal_backend_store_get_timezone (priv->store, tzid);
if (!zone && E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone)
zone = E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone (backend, tzid);
- if (!zone) {
- zone = icaltimezone_get_utc_timezone ();
- }
-
return zone;
}
@@ -4641,7 +4595,6 @@ e_cal_backend_caldav_class_init (ECalBackendCalDAVClass *class)
sync_class->get_default_object_sync = caldav_get_default_object;
sync_class->get_object_sync = caldav_get_object;
sync_class->get_object_list_sync = caldav_get_object_list;
- sync_class->get_timezone_sync = caldav_get_timezone;
sync_class->add_timezone_sync = caldav_add_timezone;
sync_class->set_default_zone_sync = caldav_set_default_zone;
sync_class->get_freebusy_sync = caldav_get_free_busy;
diff --git a/calendar/backends/contacts/e-cal-backend-contacts.c b/calendar/backends/contacts/e-cal-backend-contacts.c
index 0e82427..0909949 100644
--- a/calendar/backends/contacts/e-cal-backend-contacts.c
+++ b/calendar/backends/contacts/e-cal-backend-contacts.c
@@ -1048,32 +1048,6 @@ e_cal_backend_contacts_is_loaded (ECalBackend *backend)
return priv->addressbook_loaded;
}
-static ECalBackendSyncStatus
-e_cal_backend_contacts_get_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid, gchar **object)
-{
- ECalBackendContacts *cbcontacts;
- ECalBackendContactsPrivate *priv;
- icaltimezone *zone;
- icalcomponent *icalcomp;
-
- cbcontacts = E_CAL_BACKEND_CONTACTS (backend);
- priv = cbcontacts->priv;
-
- g_return_val_if_fail (tzid != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
-
- zone = e_cal_backend_internal_get_timezone (E_CAL_BACKEND (backend), tzid);
- if (!zone)
- return GNOME_Evolution_Calendar_ObjectNotFound;
-
- icalcomp = icaltimezone_get_component (zone);
- if (!icalcomp)
- return GNOME_Evolution_Calendar_InvalidObject;
-
- *object = icalcomponent_as_ical_string_r (icalcomp);
-
- return GNOME_Evolution_Calendar_Success;
-}
-
/* Add_timezone handler for the file backend */
static ECalBackendSyncStatus
e_cal_backend_contacts_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
@@ -1339,7 +1313,6 @@ e_cal_backend_contacts_class_init (ECalBackendContactsClass *class)
sync_class->get_default_object_sync = e_cal_backend_contacts_get_default_object;
sync_class->get_object_sync = e_cal_backend_contacts_get_object;
sync_class->get_object_list_sync = e_cal_backend_contacts_get_object_list;
- sync_class->get_timezone_sync = e_cal_backend_contacts_get_timezone;
sync_class->add_timezone_sync = e_cal_backend_contacts_add_timezone;
sync_class->set_default_zone_sync = e_cal_backend_contacts_set_default_zone;
sync_class->get_freebusy_sync = e_cal_backend_contacts_get_free_busy;
diff --git a/calendar/backends/file/e-cal-backend-file.c b/calendar/backends/file/e-cal-backend-file.c
index 258bb6a..30e5501 100644
--- a/calendar/backends/file/e-cal-backend-file.c
+++ b/calendar/backends/file/e-cal-backend-file.c
@@ -1558,48 +1558,6 @@ e_cal_backend_file_get_object (ECalBackendSync *backend, EDataCal *cal, const gc
return GNOME_Evolution_Calendar_Success;
}
-/* Get_timezone_object handler for the file backend */
-static ECalBackendSyncStatus
-e_cal_backend_file_get_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid, gchar **object)
-{
- ECalBackendFile *cbfile;
- ECalBackendFilePrivate *priv;
- icaltimezone *zone;
- icalcomponent *icalcomp;
-
- cbfile = E_CAL_BACKEND_FILE (backend);
- priv = cbfile->priv;
-
- g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal);
- g_return_val_if_fail (tzid != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
-
- g_static_rec_mutex_lock (&priv->idle_save_rmutex);
-
- if (!strcmp (tzid, "UTC")) {
- zone = icaltimezone_get_utc_timezone ();
- } else {
- zone = icalcomponent_get_timezone (priv->icalcomp, tzid);
- if (!zone) {
- zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
- if (!zone) {
- g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- return GNOME_Evolution_Calendar_ObjectNotFound;
- }
- }
- }
-
- icalcomp = icaltimezone_get_component (zone);
- if (!icalcomp) {
- g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- return GNOME_Evolution_Calendar_InvalidObject;
- }
-
- *object = icalcomponent_as_ical_string_r (icalcomp);
-
- g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- return GNOME_Evolution_Calendar_Success;
-}
-
/* Add_timezone handler for the file backend */
static ECalBackendSyncStatus
e_cal_backend_file_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
@@ -2123,8 +2081,6 @@ e_cal_backend_file_internal_get_timezone (ECalBackend *backend, const gchar *tzi
zone = icaltimezone_get_utc_timezone ();
else {
zone = icalcomponent_get_timezone (priv->icalcomp, tzid);
- if (!zone)
- zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
if (!zone && E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone)
zone = E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone (backend, tzid);
@@ -3150,7 +3106,6 @@ e_cal_backend_file_class_init (ECalBackendFileClass *class)
sync_class->get_object_sync = e_cal_backend_file_get_object;
sync_class->get_object_list_sync = e_cal_backend_file_get_object_list;
sync_class->get_attachment_list_sync = e_cal_backend_file_get_attachment_list;
- sync_class->get_timezone_sync = e_cal_backend_file_get_timezone;
sync_class->add_timezone_sync = e_cal_backend_file_add_timezone;
sync_class->set_default_zone_sync = e_cal_backend_file_set_default_zone;
sync_class->get_freebusy_sync = e_cal_backend_file_get_free_busy;
diff --git a/calendar/backends/google/e-cal-backend-google.c b/calendar/backends/google/e-cal-backend-google.c
index 7c02681..c351607 100644
--- a/calendar/backends/google/e-cal-backend-google.c
+++ b/calendar/backends/google/e-cal-backend-google.c
@@ -107,22 +107,6 @@ e_cal_backend_google_internal_get_default_timezone (ECalBackend *backend)
return cbgo->priv->default_zone;
}
-static icaltimezone *
-e_cal_backend_google_internal_get_timezone (ECalBackend *backend, const gchar *tzid)
-{
- icaltimezone *zone;
-
- zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
-
- if (!zone && E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone)
- zone = E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone (backend, tzid);
-
- if (!zone)
- return icaltimezone_get_utc_timezone ();
-
- return zone;
-}
-
static ECalBackendSyncStatus
e_cal_backend_google_get_free_busy (ECalBackendSync *backend,
EDataCal *cal,
@@ -220,37 +204,6 @@ e_cal_backend_google_get_mode (ECalBackend *backend)
}
static ECalBackendSyncStatus
-e_cal_backend_google_get_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid, gchar **object)
-{
- ECalBackendGoogle *cbgo;
- ECalBackendGooglePrivate *priv;
-
- icaltimezone *zone;
- icalcomponent *icalcomp;
-
- cbgo = E_CAL_BACKEND_GOOGLE (backend);
- priv = cbgo->priv;
-
- g_return_val_if_fail (tzid!=NULL, GNOME_Evolution_Calendar_ObjectNotFound);
-
- if (!strcmp (tzid, "UTC")) {
- zone = icaltimezone_get_utc_timezone ();
- } else {
- zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
- if (!zone)
- return GNOME_Evolution_Calendar_ObjectNotFound;
- }
-
- icalcomp = icaltimezone_get_component (zone);
- if (!icalcomp)
- return GNOME_Evolution_Calendar_InvalidObject;
-
- *object = icalcomponent_as_ical_string_r (icalcomp);
-
- return GNOME_Evolution_Calendar_Success;
-}
-
-static ECalBackendSyncStatus
e_cal_backend_google_get_object (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, gchar **object)
{
ECalComponent *comp;
@@ -1384,7 +1337,6 @@ e_cal_backend_google_class_init (ECalBackendGoogleClass *class)
sync_class->get_object_sync = e_cal_backend_google_get_object;
sync_class->get_object_list_sync = e_cal_backend_google_get_object_list;
sync_class->get_attachment_list_sync = e_cal_backend_google_get_attachment_list;
- sync_class->get_timezone_sync = e_cal_backend_google_get_timezone;
sync_class->add_timezone_sync = e_cal_backend_google_add_timezone;
sync_class->set_default_zone_sync = e_cal_backend_google_set_default_zone;
sync_class->get_freebusy_sync = e_cal_backend_google_get_free_busy;
@@ -1394,7 +1346,6 @@ e_cal_backend_google_class_init (ECalBackendGoogleClass *class)
backend_class->get_mode = e_cal_backend_google_get_mode;
backend_class->set_mode = e_cal_backend_google_set_mode;
backend_class->internal_get_default_timezone = e_cal_backend_google_internal_get_default_timezone;
- backend_class->internal_get_timezone = e_cal_backend_google_internal_get_timezone;
}
/**
diff --git a/calendar/backends/groupwise/e-cal-backend-groupwise.c b/calendar/backends/groupwise/e-cal-backend-groupwise.c
index 5c1d24f..c78060e 100644
--- a/calendar/backends/groupwise/e-cal-backend-groupwise.c
+++ b/calendar/backends/groupwise/e-cal-backend-groupwise.c
@@ -1577,37 +1577,6 @@ e_cal_backend_groupwise_get_object (ECalBackendSync *backend, EDataCal *cal, con
return GNOME_Evolution_Calendar_ObjectNotFound;
}
-/* Get_timezone_object handler for the groupwise backend */
-static ECalBackendSyncStatus
-e_cal_backend_groupwise_get_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid, gchar **object)
-{
- ECalBackendGroupwise *cbgw;
- ECalBackendGroupwisePrivate *priv;
- icaltimezone *zone;
- icalcomponent *icalcomp;
-
- cbgw = E_CAL_BACKEND_GROUPWISE (backend);
- priv = cbgw->priv;
-
- g_return_val_if_fail (tzid != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
-
- if (!strcmp (tzid, "UTC")) {
- zone = icaltimezone_get_utc_timezone ();
- } else {
- zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
- if (!zone)
- return GNOME_Evolution_Calendar_ObjectNotFound;
- }
-
- icalcomp = icaltimezone_get_component (zone);
- if (!icalcomp)
- return GNOME_Evolution_Calendar_InvalidObject;
-
- *object = icalcomponent_as_ical_string_r (icalcomp);
-
- return GNOME_Evolution_Calendar_Success;
-}
-
/* Add_timezone handler for the groupwise backend */
static ECalBackendSyncStatus
e_cal_backend_groupwise_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
@@ -1920,15 +1889,18 @@ static icaltimezone *
e_cal_backend_groupwise_internal_get_timezone (ECalBackend *backend, const gchar *tzid)
{
icaltimezone *zone;
+ ECalBackendGroupwise *cbgw;
+
+ cbgw = E_CAL_BACKEND_GROUPWISE (backend);
+ g_return_val_if_fail (cbgw != NULL, NULL);
+ g_return_val_if_fail (cbgw->priv != NULL, NULL);
- zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+ if (cbgw->priv->store)
+ zone = (icaltimezone *) e_cal_backend_store_get_timezone (cbgw->priv->store, tzid);
if (!zone && E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone)
zone = E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone (backend, tzid);
- if (!zone)
- return icaltimezone_get_utc_timezone();
-
return zone;
}
@@ -2881,7 +2853,6 @@ e_cal_backend_groupwise_class_init (ECalBackendGroupwiseClass *class)
sync_class->get_object_sync = e_cal_backend_groupwise_get_object;
sync_class->get_object_list_sync = e_cal_backend_groupwise_get_object_list;
sync_class->get_attachment_list_sync = e_cal_backend_groupwise_get_attachment_list;
- sync_class->get_timezone_sync = e_cal_backend_groupwise_get_timezone;
sync_class->add_timezone_sync = e_cal_backend_groupwise_add_timezone;
sync_class->set_default_zone_sync = e_cal_backend_groupwise_set_default_zone;
sync_class->get_freebusy_sync = e_cal_backend_groupwise_get_free_busy;
diff --git a/calendar/backends/http/e-cal-backend-http.c b/calendar/backends/http/e-cal-backend-http.c
index 0bb92ab..197e203 100644
--- a/calendar/backends/http/e-cal-backend-http.c
+++ b/calendar/backends/http/e-cal-backend-http.c
@@ -859,37 +859,6 @@ e_cal_backend_http_get_object (ECalBackendSync *backend, EDataCal *cal, const gc
return GNOME_Evolution_Calendar_Success;
}
-/* Get_timezone_object handler for the file backend */
-static ECalBackendSyncStatus
-e_cal_backend_http_get_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid, gchar **object)
-{
- ECalBackendHttp *cbhttp;
- ECalBackendHttpPrivate *priv;
- const icaltimezone *zone;
- icalcomponent *icalcomp;
-
- cbhttp = E_CAL_BACKEND_HTTP (backend);
- priv = cbhttp->priv;
-
- g_return_val_if_fail (tzid != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
-
- /* first try to get the timezone from the cache */
- zone = e_cal_backend_store_get_timezone (priv->store, tzid);
- if (!zone) {
- zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
- if (!zone)
- return GNOME_Evolution_Calendar_ObjectNotFound;
- }
-
- icalcomp = icaltimezone_get_component ((icaltimezone *)zone);
- if (!icalcomp)
- return GNOME_Evolution_Calendar_InvalidObject;
-
- *object = icalcomponent_as_ical_string_r (icalcomp);
-
- return GNOME_Evolution_Calendar_Success;
-}
-
/* Add_timezone handler for the file backend */
static ECalBackendSyncStatus
e_cal_backend_http_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
@@ -1336,10 +1305,13 @@ e_cal_backend_http_internal_get_timezone (ECalBackend *backend, const gchar *tzi
cbhttp = E_CAL_BACKEND_HTTP (backend);
priv = cbhttp->priv;
+ g_return_val_if_fail (tzid != NULL, NULL);
+
if (!strcmp (tzid, "UTC"))
zone = icaltimezone_get_utc_timezone ();
else {
- zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+ /* first try to get the timezone from the cache */
+ zone = (icaltimezone *) e_cal_backend_store_get_timezone (priv->store, tzid);
if (!zone && E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone)
zone = E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone (backend, tzid);
@@ -1398,7 +1370,6 @@ e_cal_backend_http_class_init (ECalBackendHttpClass *class)
sync_class->get_default_object_sync = e_cal_backend_http_get_default_object;
sync_class->get_object_sync = e_cal_backend_http_get_object;
sync_class->get_object_list_sync = e_cal_backend_http_get_object_list;
- sync_class->get_timezone_sync = e_cal_backend_http_get_timezone;
sync_class->add_timezone_sync = e_cal_backend_http_add_timezone;
sync_class->set_default_zone_sync = e_cal_backend_http_set_default_zone;
sync_class->get_freebusy_sync = e_cal_backend_http_get_free_busy;
diff --git a/calendar/backends/weather/e-cal-backend-weather.c b/calendar/backends/weather/e-cal-backend-weather.c
index 7365b99..c8db15c 100644
--- a/calendar/backends/weather/e-cal-backend-weather.c
+++ b/calendar/backends/weather/e-cal-backend-weather.c
@@ -614,32 +614,6 @@ e_cal_backend_weather_get_object_list (ECalBackendSync *backend, EDataCal *cal,
}
static ECalBackendSyncStatus
-e_cal_backend_weather_get_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid, gchar **object)
-{
- ECalBackendWeather *cbw;
- ECalBackendWeatherPrivate *priv;
- icaltimezone *zone;
- icalcomponent *icalcomp;
-
- cbw = E_CAL_BACKEND_WEATHER (backend);
- priv = cbw->priv;
-
- g_return_val_if_fail (tzid != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
-
- zone = e_cal_backend_internal_get_timezone (E_CAL_BACKEND (backend), tzid);
- if (!zone)
- return GNOME_Evolution_Calendar_ObjectNotFound;
-
- icalcomp = icaltimezone_get_component (zone);
- if (!icalcomp)
- return GNOME_Evolution_Calendar_InvalidObject;
-
- *object = icalcomponent_as_ical_string_r (icalcomp);
-
- return GNOME_Evolution_Calendar_Success;
-}
-
-static ECalBackendSyncStatus
e_cal_backend_weather_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
{
ECalBackendWeather *cbw;
@@ -859,13 +833,22 @@ static icaltimezone *
e_cal_backend_weather_internal_get_timezone (ECalBackend *backend, const gchar *tzid)
{
icaltimezone *zone;
- if (!strcmp (tzid, "UTC"))
+
+ g_return_val_if_fail (tzid != NULL, NULL);
+
+ if (!strcmp (tzid, "UTC")) {
zone = icaltimezone_get_utc_timezone ();
- else
- zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+ } else {
+ ECalBackendWeather *cbw = E_CAL_BACKEND_WEATHER (backend);
- if (!zone && E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone)
- zone = E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone (backend, tzid);
+ g_return_val_if_fail (E_IS_CAL_BACKEND_WEATHER (cbw), NULL);
+ g_return_val_if_fail (cbw->priv != NULL, NULL);
+
+ zone = g_hash_table_lookup (cbw->priv->zones, tzid);
+
+ if (!zone && E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone)
+ zone = E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone (backend, tzid);
+ }
return zone;
}
@@ -975,7 +958,6 @@ e_cal_backend_weather_class_init (ECalBackendWeatherClass *class)
sync_class->get_default_object_sync = e_cal_backend_weather_get_default_object;
sync_class->get_object_sync = e_cal_backend_weather_get_object;
sync_class->get_object_list_sync = e_cal_backend_weather_get_object_list;
- sync_class->get_timezone_sync = e_cal_backend_weather_get_timezone;
sync_class->add_timezone_sync = e_cal_backend_weather_add_timezone;
sync_class->set_default_zone_sync = e_cal_backend_weather_set_default_zone;
sync_class->get_freebusy_sync = e_cal_backend_weather_get_free_busy;
diff --git a/calendar/libedata-cal/e-cal-backend-sync.c b/calendar/libedata-cal/e-cal-backend-sync.c
index 57ab76a..3237133 100644
--- a/calendar/libedata-cal/e-cal-backend-sync.c
+++ b/calendar/libedata-cal/e-cal-backend-sync.c
@@ -502,18 +502,51 @@ e_cal_backend_sync_get_attachment_list (ECalBackendSync *backend, EDataCal *cal,
* @tzid: ID of the timezone to retrieve.
* @object: Placeholder for the returned timezone.
*
- * Calls the get_timezone method on the given backend.
+ * Calls the get_timezone_sync method on the given backend.
+ * This method is not mandatory on the backend, because here
+ * is used internal_get_timezone call to fetch timezone from
+ * it and that is transformed to a string. In other words,
+ * any object deriving from ECalBackendSync can implement only
+ * internal_get_timezone and can skip implementation of
+ * get_timezone_sync completely.
*
* Return value: Status code.
*/
ECalBackendSyncStatus
e_cal_backend_sync_get_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid, gchar **object)
{
- ECalBackendSyncStatus status;
+ ECalBackendSyncStatus status = GNOME_Evolution_Calendar_ObjectNotFound;
g_return_val_if_fail (E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
- LOCK_WRAPPER (get_timezone_sync, (backend, cal, tzid, object));
+ if (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->get_timezone_sync) {
+ LOCK_WRAPPER (get_timezone_sync, (backend, cal, tzid, object));
+ }
+
+ if (object && !object) {
+ icaltimezone *zone = NULL;
+
+ if (backend->priv->mutex_lock)
+ g_mutex_lock (backend->priv->sync_mutex);
+ zone = e_cal_backend_internal_get_timezone (E_CAL_BACKEND (backend), tzid);
+ if (backend->priv->mutex_lock)
+ g_mutex_unlock (backend->priv->sync_mutex);
+
+ if (!zone) {
+ status = GNOME_Evolution_Calendar_ObjectNotFound;
+ } else {
+ icalcomponent *icalcomp;
+
+ icalcomp = icaltimezone_get_component (zone);
+
+ if (!icalcomp) {
+ status = GNOME_Evolution_Calendar_InvalidObject;
+ } else {
+ *object = icalcomponent_as_ical_string_r (icalcomp);
+ status = GNOME_Evolution_Calendar_Success;
+ }
+ }
+ }
return status;
}
@@ -977,27 +1010,42 @@ _e_cal_backend_add_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodC
e_data_cal_notify_timezone_added (cal, context, status, tzobj);
}
+/* The default implementation is looking for timezone in the ical's builtin timezones,
+ and if that fails, then it tries to extract the location from the tzid and get the
+ timezone based on it. If even that fails, then it's returning UTC timezone.
+ That means, that any object deriving from ECalBackendSync is supposed to implement
+ this function for checking for a timezone in its own timezone cache, and if that
+ fails, then call parent's object internal_get_timezone, and that's all.
+ */
static icaltimezone *
_e_cal_backend_internal_get_timezone (ECalBackend *backend, const gchar *tzid)
{
icaltimezone *zone = NULL;
- const gchar *s, *slash1 = NULL, *slash2 = NULL;
if (!tzid || !*tzid)
return NULL;
- /* get builtin by a location, if any */
- for (s = tzid; *s; s++) {
- if (*s == '/') {
- slash1 = slash2;
- slash2 = s;
+ zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+
+ if (!zone) {
+ const gchar *s, *slash1 = NULL, *slash2 = NULL;
+
+ /* get builtin by a location, if any */
+ for (s = tzid; *s; s++) {
+ if (*s == '/') {
+ slash1 = slash2;
+ slash2 = s;
+ }
}
+
+ if (slash1)
+ zone = icaltimezone_get_builtin_timezone (slash1 + 1);
+ else if (slash2)
+ zone = icaltimezone_get_builtin_timezone (tzid);
}
- if (slash1)
- zone = icaltimezone_get_builtin_timezone (slash1 + 1);
- else if (slash2)
- zone = icaltimezone_get_builtin_timezone (tzid);
+ if (!zone)
+ zone = icaltimezone_get_utc_timezone ();
return zone;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]