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.
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
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);
* 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");
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");
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");
/*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)
{
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;
}
GHashTable *tracked_contacts; /* UID -> ContactRecord */
GRecMutex tracked_contacts_lock;
- GHashTable *zones;
-
/* properties related to track alarm settings for this backend */
GSettings *settings;
guint notifyid;
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));
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
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)
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);
(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;
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;
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 */
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)
* 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");
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");
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");
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;
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
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,
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
/* The file cache */
ECalBackendStore *store;
- GHashTable *zones;
-
/* Reload */
guint reload_timeout_id;
guint is_loading : 1;
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
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
}
}
-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)
priv->store = NULL;
}
- g_hash_table_destroy (priv->zones);
-
g_free (priv->city);
/* Chain up to parent's finalize() method. */
{
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 (
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;
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);
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,
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;
}
/**
- * 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.
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;
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,
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