From: Matthew Barnes Date: Thu, 3 Jan 2013 16:49:44 +0000 (-0500) Subject: ECalBackend: Remove internal_get_timezone() method. X-Git-Tag: upstream/3.7.4~40 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8550145d22603f65a1d2b1e494d03ba44539aa0f;p=platform%2Fupstream%2Fevolution-data-server.git ECalBackend: Remove internal_get_timezone() method. No longer needed since ECalBackend implements ETimezoneCache. Use e_timezone_cache_get_timezone() instead. Removed functions: e_cal_backend_internal_get_timezone() This is another API break. 3rd party backends will have to be adjusted. --- diff --git a/calendar/backends/caldav/e-cal-backend-caldav.c b/calendar/backends/caldav/e-cal-backend-caldav.c index 9f425b3..8d79618 100644 --- a/calendar/backends/caldav/e-cal-backend-caldav.c +++ b/calendar/backends/caldav/e-cal-backend-caldav.c @@ -269,16 +269,11 @@ static icaltimezone * resolve_tzid (const gchar *tzid, gpointer user_data) { - icaltimezone *zone; - - zone = (!strcmp (tzid, "UTC")) - ? icaltimezone_get_utc_timezone () - : icaltimezone_get_builtin_timezone_from_tzid (tzid); + ETimezoneCache *timezone_cache; - if (!zone) - zone = e_cal_backend_internal_get_timezone (E_CAL_BACKEND (user_data), tzid); + timezone_cache = E_TIMEZONE_CACHE (user_data); - return zone; + return e_timezone_cache_get_timezone (timezone_cache, tzid); } static gboolean @@ -298,7 +293,6 @@ put_component_to_store (ECalBackendCalDAV *cbdav, static ECalBackendSyncClass *parent_class = NULL; -static icaltimezone *caldav_internal_get_timezone (ECalBackend *backend, const gchar *tzid); static void caldav_source_changed_cb (ESource *source, ECalBackendCalDAV *cbdav); static gboolean remove_comp_from_cache (ECalBackendCalDAV *cbdav, const gchar *uid, const gchar *rid); @@ -3474,7 +3468,8 @@ sanitize_component (ECalBackend *cb, * list */ e_cal_component_get_dtstart (comp, &dt); if (dt.value && dt.tzid) { - zone = caldav_internal_get_timezone (cb, dt.tzid); + zone = e_timezone_cache_get_timezone ( + E_TIMEZONE_CACHE (cb), dt.tzid); if (!zone) { g_free ((gchar *) dt.tzid); dt.tzid = g_strdup ("UTC"); @@ -3485,7 +3480,8 @@ sanitize_component (ECalBackend *cb, e_cal_component_get_dtend (comp, &dt); if (dt.value && dt.tzid) { - zone = caldav_internal_get_timezone (cb, dt.tzid); + zone = e_timezone_cache_get_timezone ( + E_TIMEZONE_CACHE (cb), dt.tzid); if (!zone) { g_free ((gchar *) dt.tzid); dt.tzid = g_strdup ("UTC"); @@ -3496,7 +3492,8 @@ sanitize_component (ECalBackend *cb, e_cal_component_get_due (comp, &dt); if (dt.value && dt.tzid) { - zone = caldav_internal_get_timezone (cb, dt.tzid); + zone = e_timezone_cache_get_timezone ( + E_TIMEZONE_CACHE (cb), dt.tzid); if (!zone) { g_free ((gchar *) dt.tzid); dt.tzid = g_strdup ("UTC"); @@ -4819,25 +4816,6 @@ caldav_notify_online_cb (ECalBackend *backend, /*g_mutex_unlock (&cbdav->priv->busy_lock);*/ } -static icaltimezone * -caldav_internal_get_timezone (ECalBackend *backend, - const gchar *tzid) -{ - icaltimezone *zone; - ECalBackendCalDAV *cbdav; - - cbdav = E_CAL_BACKEND_CALDAV (backend); - zone = NULL; - - if (cbdav->priv->store) - zone = (icaltimezone *) e_cal_backend_store_get_timezone (cbdav->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); - - return zone; -} - static gpointer caldav_source_changed_thread (gpointer data) { @@ -5116,6 +5094,4 @@ e_cal_backend_caldav_class_init (ECalBackendCalDAVClass *class) sync_class->get_free_busy_sync = caldav_get_free_busy; backend_class->start_view = caldav_start_view; - - backend_class->internal_get_timezone = caldav_internal_get_timezone; } diff --git a/calendar/backends/contacts/e-cal-backend-contacts.c b/calendar/backends/contacts/e-cal-backend-contacts.c index 1cc8739..8ec35b8 100644 --- a/calendar/backends/contacts/e-cal-backend-contacts.c +++ b/calendar/backends/contacts/e-cal-backend-contacts.c @@ -66,8 +66,6 @@ struct _ECalBackendContactsPrivate { GHashTable *tracked_contacts; /* UID -> ContactRecord */ GRecMutex tracked_contacts_lock; - GHashTable *zones; - /* properties related to track alarm settings for this backend */ GSettings *settings; guint notifyid; @@ -1237,18 +1235,14 @@ e_cal_backend_contacts_add_timezone (ECalBackendSync *backend, GError **error) { ECalBackendContacts *cbcontacts; - ECalBackendContactsPrivate *priv; icalcomponent *tz_comp; icaltimezone *zone; - const gchar *tzid; cbcontacts = (ECalBackendContacts *) backend; e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_CONTACTS (cbcontacts), InvalidArg); e_return_data_cal_error_if_fail (tzobj != NULL, InvalidArg); - priv = cbcontacts->priv; - tz_comp = icalparser_parse_string (tzobj); if (!tz_comp) { g_propagate_error (error, EDC_ERROR (InvalidObject)); @@ -1262,13 +1256,8 @@ e_cal_backend_contacts_add_timezone (ECalBackendSync *backend, zone = icaltimezone_new (); icaltimezone_set_component (zone, tz_comp); - tzid = icaltimezone_get_tzid (zone); - - if (g_hash_table_lookup (priv->zones, tzid)) { - icaltimezone_free (zone, TRUE); - } else { - g_hash_table_insert (priv->zones, g_strdup (tzid), zone); - } + e_timezone_cache_add_timezone (E_TIMEZONE_CACHE (backend), zone); + icaltimezone_free (zone, TRUE); } static void @@ -1329,24 +1318,9 @@ e_cal_backend_contacts_start_view (ECalBackend *backend, e_data_cal_view_notify_complete (query, NULL /* Success */); } -static icaltimezone * -e_cal_backend_contacts_internal_get_timezone (ECalBackend *backend, - const gchar *tzid) -{ - ECalBackendContacts *cbc = E_CAL_BACKEND_CONTACTS (backend); - - return g_hash_table_lookup (cbc->priv->zones, tzid ? tzid : ""); -} - /*********************************************************************************** */ -static void -free_zone (gpointer data) -{ - icaltimezone_free (data, TRUE); -} - /* Finalize handler for the contacts backend */ static void e_cal_backend_contacts_finalize (GObject *object) @@ -1362,7 +1336,6 @@ e_cal_backend_contacts_finalize (GObject *object) g_hash_table_destroy (priv->addressbooks); g_hash_table_destroy (priv->tracked_contacts); - g_hash_table_destroy (priv->zones); if (priv->notifyid) g_signal_handler_disconnect (priv->settings, priv->notifyid); @@ -1423,12 +1396,6 @@ e_cal_backend_contacts_init (ECalBackendContacts *cbc) (GDestroyNotify) g_free, (GDestroyNotify) contact_record_free); - cbc->priv->zones = g_hash_table_new_full ( - (GHashFunc) g_str_hash, - (GEqualFunc) g_str_equal, - (GDestroyNotify) g_free, - (GDestroyNotify) free_zone); - cbc->priv->settings = g_settings_new ("org.gnome.evolution-data-server.calendar"); cbc->priv->notifyid = 0; cbc->priv->update_alarms_id = 0; @@ -1484,7 +1451,6 @@ e_cal_backend_contacts_class_init (ECalBackendContactsClass *class) sync_class->get_free_busy_sync = e_cal_backend_contacts_get_free_busy; backend_class->start_view = e_cal_backend_contacts_start_view; - backend_class->internal_get_timezone = e_cal_backend_contacts_internal_get_timezone; /* Register our ESource extension. */ E_TYPE_SOURCE_CONTACTS; diff --git a/calendar/backends/file/e-cal-backend-file.c b/calendar/backends/file/e-cal-backend-file.c index 0395f92..9d7368a 100644 --- a/calendar/backends/file/e-cal-backend-file.c +++ b/calendar/backends/file/e-cal-backend-file.c @@ -116,9 +116,6 @@ static void e_cal_backend_file_finalize (GObject *object); static void free_refresh_data (ECalBackendFile *cbfile); -static icaltimezone * -e_cal_backend_file_internal_get_timezone (ECalBackend *backend, const gchar *tzid); - static void bump_revision (ECalBackendFile *cbfile); /* g_hash_table_foreach() callback to destroy a ECalBackendFileObject */ @@ -2080,34 +2077,6 @@ e_cal_backend_file_get_free_busy (ECalBackendSync *backend, g_rec_mutex_unlock (&priv->idle_save_rmutex); } -static icaltimezone * -e_cal_backend_file_internal_get_timezone (ECalBackend *backend, - const gchar *tzid) -{ - ECalBackendFile *cbfile; - ECalBackendFilePrivate *priv; - icaltimezone *zone; - - cbfile = E_CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, NULL); - - g_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 && E_CAL_BACKEND_CLASS (e_cal_backend_file_parent_class)->internal_get_timezone) - zone = E_CAL_BACKEND_CLASS (e_cal_backend_file_parent_class)->internal_get_timezone (backend, tzid); - } - - g_rec_mutex_unlock (&priv->idle_save_rmutex); - return zone; -} - static void sanitize_component (ECalBackendFile *cbfile, ECalComponent *comp) @@ -2120,7 +2089,8 @@ sanitize_component (ECalBackendFile *cbfile, * list */ e_cal_component_get_dtstart (comp, &dt); if (dt.value && dt.tzid) { - zone = e_cal_backend_file_internal_get_timezone ((ECalBackend *) cbfile, dt.tzid); + zone = e_timezone_cache_get_timezone ( + E_TIMEZONE_CACHE (cbfile), dt.tzid); if (!zone) { g_free ((gchar *) dt.tzid); dt.tzid = g_strdup ("UTC"); @@ -2131,7 +2101,8 @@ sanitize_component (ECalBackendFile *cbfile, e_cal_component_get_dtend (comp, &dt); if (dt.value && dt.tzid) { - zone = e_cal_backend_file_internal_get_timezone ((ECalBackend *) cbfile, dt.tzid); + zone = e_timezone_cache_get_timezone ( + E_TIMEZONE_CACHE (cbfile), dt.tzid); if (!zone) { g_free ((gchar *) dt.tzid); dt.tzid = g_strdup ("UTC"); @@ -2142,7 +2113,8 @@ sanitize_component (ECalBackendFile *cbfile, e_cal_component_get_due (comp, &dt); if (dt.value && dt.tzid) { - zone = e_cal_backend_file_internal_get_timezone ((ECalBackend *) cbfile, dt.tzid); + zone = e_timezone_cache_get_timezone ( + E_TIMEZONE_CACHE (cbfile), dt.tzid); if (!zone) { g_free ((gchar *) dt.tzid); dt.tzid = g_strdup ("UTC"); @@ -3484,7 +3456,6 @@ e_cal_backend_file_class_init (ECalBackendFileClass *class) sync_class->get_free_busy_sync = e_cal_backend_file_get_free_busy; backend_class->start_view = e_cal_backend_file_start_view; - backend_class->internal_get_timezone = e_cal_backend_file_internal_get_timezone; /* Register our ESource extension. */ E_TYPE_SOURCE_LOCAL; diff --git a/calendar/backends/http/e-cal-backend-http.c b/calendar/backends/http/e-cal-backend-http.c index eacc3a5..a0b837b 100644 --- a/calendar/backends/http/e-cal-backend-http.c +++ b/calendar/backends/http/e-cal-backend-http.c @@ -310,16 +310,11 @@ static icaltimezone * resolve_tzid (const gchar *tzid, gpointer user_data) { - icaltimezone *zone; - - zone = (!strcmp (tzid, "UTC")) - ? icaltimezone_get_utc_timezone () - : icaltimezone_get_builtin_timezone_from_tzid (tzid); + ETimezoneCache *timezone_cache; - if (!zone) - zone = e_cal_backend_internal_get_timezone (E_CAL_BACKEND (user_data), tzid); + timezone_cache = E_TIMEZONE_CACHE (user_data); - return zone; + return e_timezone_cache_get_timezone (timezone_cache, tzid); } static gboolean @@ -1417,32 +1412,6 @@ e_cal_backend_http_send_objects (ECalBackendSync *backend, g_propagate_error (perror, EDC_ERROR (PermissionDenied)); } -static icaltimezone * -e_cal_backend_http_internal_get_timezone (ECalBackend *backend, - const gchar *tzid) -{ - ECalBackendHttp *cbhttp; - ECalBackendHttpPrivate *priv; - icaltimezone *zone; - - 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 { - /* 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 (e_cal_backend_http_parent_class)->internal_get_timezone) - zone = E_CAL_BACKEND_CLASS (e_cal_backend_http_parent_class)->internal_get_timezone (backend, tzid); - } - - return zone; -} - static ESourceAuthenticationResult cal_backend_http_try_password_sync (ESourceAuthenticator *authenticator, const GString *password, @@ -1520,7 +1489,6 @@ e_cal_backend_http_class_init (ECalBackendHttpClass *class) sync_class->get_free_busy_sync = e_cal_backend_http_get_free_busy; backend_class->start_view = e_cal_backend_http_start_view; - backend_class->internal_get_timezone = e_cal_backend_http_internal_get_timezone; } static void diff --git a/calendar/backends/weather/e-cal-backend-weather.c b/calendar/backends/weather/e-cal-backend-weather.c index 13f0d0c..75a47a4 100644 --- a/calendar/backends/weather/e-cal-backend-weather.c +++ b/calendar/backends/weather/e-cal-backend-weather.c @@ -54,8 +54,6 @@ struct _ECalBackendWeatherPrivate { /* The file cache */ ECalBackendStore *store; - GHashTable *zones; - /* Reload */ guint reload_timeout_id; guint is_loading : 1; @@ -129,16 +127,11 @@ static icaltimezone * resolve_tzid (const gchar *tzid, gpointer user_data) { - icaltimezone *zone; - - zone = (!strcmp (tzid, "UTC")) - ? icaltimezone_get_utc_timezone () - : icaltimezone_get_builtin_timezone_from_tzid (tzid); + ETimezoneCache *timezone_cache; - if (!zone) - zone = e_cal_backend_internal_get_timezone (E_CAL_BACKEND (user_data), tzid); + timezone_cache = E_TIMEZONE_CACHE (user_data); - return zone; + return e_timezone_cache_get_timezone (timezone_cache, tzid); } static void @@ -661,13 +654,8 @@ e_cal_backend_weather_add_timezone (ECalBackendSync *backend, zone = icaltimezone_new (); icaltimezone_set_component (zone, tz_comp); - tzid = icaltimezone_get_tzid (zone); - - if (g_hash_table_lookup (priv->zones, tzid)) { - icaltimezone_free (zone, TRUE); - } else { - g_hash_table_insert (priv->zones, g_strdup (tzid), zone); - } + e_timezone_cache_add_timezone (E_TIMEZONE_CACHE (backend), zone); + icaltimezone_free (zone, TRUE); } static void @@ -773,36 +761,6 @@ e_cal_backend_weather_notify_online_cb (ECalBackend *backend, } } -static icaltimezone * -e_cal_backend_weather_internal_get_timezone (ECalBackend *backend, - const gchar *tzid) -{ - icaltimezone *zone; - - g_return_val_if_fail (tzid != NULL, NULL); - - if (!strcmp (tzid, "UTC")) { - zone = icaltimezone_get_utc_timezone (); - } else { - ECalBackendWeather *cbw = E_CAL_BACKEND_WEATHER (backend); - - g_return_val_if_fail (E_IS_CAL_BACKEND_WEATHER (cbw), NULL); - - zone = g_hash_table_lookup (cbw->priv->zones, tzid); - - if (!zone && E_CAL_BACKEND_CLASS (e_cal_backend_weather_parent_class)->internal_get_timezone) - zone = E_CAL_BACKEND_CLASS (e_cal_backend_weather_parent_class)->internal_get_timezone (backend, tzid); - } - - return zone; -} - -static void -free_zone (gpointer data) -{ - icaltimezone_free (data, TRUE); -} - /* Finalize handler for the weather backend */ static void e_cal_backend_weather_finalize (GObject *object) @@ -822,8 +780,6 @@ e_cal_backend_weather_finalize (GObject *object) priv->store = NULL; } - g_hash_table_destroy (priv->zones); - g_free (priv->city); /* Chain up to parent's finalize() method. */ @@ -836,12 +792,6 @@ e_cal_backend_weather_init (ECalBackendWeather *cbw) { cbw->priv = E_CAL_BACKEND_WEATHER_GET_PRIVATE (cbw); - cbw->priv->zones = g_hash_table_new_full ( - (GHashFunc) g_str_hash, - (GEqualFunc) g_str_equal, - (GDestroyNotify) g_free, - (GDestroyNotify) free_zone); - e_cal_backend_sync_set_lock (E_CAL_BACKEND_SYNC (cbw), TRUE); g_signal_connect ( @@ -875,7 +825,6 @@ e_cal_backend_weather_class_init (ECalBackendWeatherClass *class) sync_class->get_free_busy_sync = e_cal_backend_weather_get_free_busy; backend_class->start_view = e_cal_backend_weather_start_view; - backend_class->internal_get_timezone = e_cal_backend_weather_internal_get_timezone; /* Register our ESource extension. */ E_TYPE_SOURCE_WEATHER; diff --git a/calendar/libedata-cal/e-cal-backend-sync.c b/calendar/libedata-cal/e-cal-backend-sync.c index df42717..8066cae 100644 --- a/calendar/libedata-cal/e-cal-backend-sync.c +++ b/calendar/libedata-cal/e-cal-backend-sync.c @@ -504,7 +504,8 @@ e_cal_backend_sync_get_timezone (ECalBackendSync *backend, if (backend->priv->mutex_lock) g_mutex_lock (&backend->priv->sync_mutex); - zone = e_cal_backend_internal_get_timezone (E_CAL_BACKEND (backend), tzid); + zone = e_timezone_cache_get_timezone ( + E_TIMEZONE_CACHE (backend), tzid); if (backend->priv->mutex_lock) g_mutex_unlock (&backend->priv->sync_mutex); @@ -888,47 +889,6 @@ cal_backend_add_timezone (ECalBackend *backend, e_data_cal_respond_add_timezone (cal, opid, error); } -/* 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 * -cal_backend_internal_get_timezone (ECalBackend *backend, - const gchar *tzid) -{ - icaltimezone *zone = NULL; - - if (!tzid || !*tzid) - return NULL; - - 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 (!zone) - zone = icaltimezone_get_utc_timezone (); - - return zone; -} - static gboolean cal_backend_sync_get_backend_property (ECalBackendSync *backend, EDataCal *cal, @@ -994,7 +954,6 @@ e_cal_backend_sync_class_init (ECalBackendSyncClass *class) backend_class->discard_alarm = cal_backend_discard_alarm; backend_class->get_timezone = cal_backend_get_timezone; backend_class->add_timezone = cal_backend_add_timezone; - backend_class->internal_get_timezone = cal_backend_internal_get_timezone; class->get_backend_property_sync = cal_backend_sync_get_backend_property; class->set_backend_property_sync = cal_backend_sync_set_backend_property; diff --git a/calendar/libedata-cal/e-cal-backend.c b/calendar/libedata-cal/e-cal-backend.c index 9c0667c..a1a6dbf 100644 --- a/calendar/libedata-cal/e-cal-backend.c +++ b/calendar/libedata-cal/e-cal-backend.c @@ -1562,24 +1562,6 @@ e_cal_backend_add_timezone (ECalBackend *backend, } /** - * e_cal_backend_internal_get_timezone: - * @backend: an #ECalBackend - * @tzid: ID of the timezone to get. - * - * Calls the internal_get_timezone method on the given backend. - */ -icaltimezone * -e_cal_backend_internal_get_timezone (ECalBackend *backend, - const gchar *tzid) -{ - g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL); - g_return_val_if_fail (tzid != NULL, NULL); - g_return_val_if_fail (E_CAL_BACKEND_GET_CLASS (backend)->internal_get_timezone != NULL, NULL); - - return (* E_CAL_BACKEND_GET_CLASS (backend)->internal_get_timezone) (backend, tzid); -} - -/** * e_cal_backend_start_view: * @backend: an #ECalBackend * @view: The view to be started. diff --git a/calendar/libedata-cal/e-cal-backend.h b/calendar/libedata-cal/e-cal-backend.h index baaeb8d..d53d936 100644 --- a/calendar/libedata-cal/e-cal-backend.h +++ b/calendar/libedata-cal/e-cal-backend.h @@ -255,11 +255,6 @@ struct _ECalBackendClass { EDataCalView *view); void (*stop_view) (ECalBackend *backend, EDataCalView *view); - - /* Internal methods for use only in the pcs */ - icaltimezone * (*internal_get_timezone) - (ECalBackend *backend, - const gchar *tzid); }; GType e_cal_backend_get_type (void) G_GNUC_CONST; @@ -388,9 +383,6 @@ void e_cal_backend_add_timezone (ECalBackend *backend, guint32 opid, GCancellable *cancellable, const gchar *tzobject); -icaltimezone * e_cal_backend_internal_get_timezone - (ECalBackend *backend, - const gchar *tzid); void e_cal_backend_start_view (ECalBackend *backend, EDataCalView *view); void e_cal_backend_stop_view (ECalBackend *backend, diff --git a/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt b/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt index 2049182..6ca17f4 100644 --- a/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt +++ b/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt @@ -43,7 +43,6 @@ e_cal_backend_get_attachment_uris e_cal_backend_discard_alarm e_cal_backend_get_timezone e_cal_backend_add_timezone -e_cal_backend_internal_get_timezone e_cal_backend_start_view e_cal_backend_stop_view e_cal_backend_notify_component_created