[evolution-data-server] [ECalMetaBackend] Doesn't store custom time zones permanently
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] [ECalMetaBackend] Doesn't store custom time zones permanently
- Date: Mon, 12 Mar 2018 12:54:45 +0000 (UTC)
commit d55d0735657d02b156da7664ed40b5f36cb3b5af
Author: Milan Crha <mcrha redhat com>
Date: Mon Mar 12 13:55:56 2018 +0100
[ECalMetaBackend] Doesn't store custom time zones permanently
Reported downstream at:
https://bugzilla.redhat.com/show_bug.cgi?id=1547743
src/calendar/libedata-cal/e-cal-cache.c | 7 ++-
src/calendar/libedata-cal/e-cal-meta-backend.c | 61 +++++++++++++++++++++++-
2 files changed, 66 insertions(+), 2 deletions(-)
---
diff --git a/src/calendar/libedata-cal/e-cal-cache.c b/src/calendar/libedata-cal/e-cal-cache.c
index 324813c..6c2553a 100644
--- a/src/calendar/libedata-cal/e-cal-cache.c
+++ b/src/calendar/libedata-cal/e-cal-cache.c
@@ -3636,12 +3636,17 @@ ecc_add_cached_timezone (ETimezoneCache *cache,
icaltimezone *zone)
{
ECalCache *cal_cache;
+ const gchar *matched_tzid;
const gchar *tzid;
cal_cache = E_CAL_CACHE (cache);
tzid = icaltimezone_get_tzid (zone);
- if (tzid == NULL)
+ if (!tzid || !*tzid || icaltimezone_get_builtin_timezone (tzid))
+ return;
+
+ matched_tzid = e_cal_match_tzid (tzid);
+ if (matched_tzid && icaltimezone_get_builtin_timezone_from_tzid (matched_tzid))
return;
e_cal_cache_put_timezone (cal_cache, zone, NULL, NULL);
diff --git a/src/calendar/libedata-cal/e-cal-meta-backend.c b/src/calendar/libedata-cal/e-cal-meta-backend.c
index 8c9fc6c..937b733 100644
--- a/src/calendar/libedata-cal/e-cal-meta-backend.c
+++ b/src/calendar/libedata-cal/e-cal-meta-backend.c
@@ -102,7 +102,11 @@ enum {
static guint signals[LAST_SIGNAL];
-G_DEFINE_ABSTRACT_TYPE (ECalMetaBackend, e_cal_meta_backend, E_TYPE_CAL_BACKEND_SYNC)
+/* Forward Declarations */
+static void e_cal_meta_backend_timezone_cache_init (ETimezoneCacheInterface *iface);
+
+G_DEFINE_ABSTRACT_TYPE_WITH_CODE (ECalMetaBackend, e_cal_meta_backend, E_TYPE_CAL_BACKEND_SYNC,
+ G_IMPLEMENT_INTERFACE (E_TYPE_TIMEZONE_CACHE, e_cal_meta_backend_timezone_cache_init))
G_DEFINE_BOXED_TYPE (ECalMetaBackendInfo, e_cal_meta_backend_info, e_cal_meta_backend_info_copy,
e_cal_meta_backend_info_free)
@@ -3044,6 +3048,53 @@ ecmb_maybe_wait_for_credentials (ECalMetaBackend *meta_backend,
}
static void
+ecmb_add_cached_timezone (ETimezoneCache *cache,
+ icaltimezone *zone)
+{
+ ECalCache *cal_cache;
+
+ cal_cache = e_cal_meta_backend_ref_cache (E_CAL_META_BACKEND (cache));
+ g_return_if_fail (E_IS_CAL_CACHE (cal_cache));
+
+ e_timezone_cache_add_timezone (E_TIMEZONE_CACHE (cal_cache), zone);
+
+ g_clear_object (&cal_cache);
+}
+
+static icaltimezone *
+ecmb_get_cached_timezone (ETimezoneCache *cache,
+ const gchar *tzid)
+{
+ ECalCache *cal_cache;
+ icaltimezone *zone;
+
+ cal_cache = e_cal_meta_backend_ref_cache (E_CAL_META_BACKEND (cache));
+ g_return_val_if_fail (E_IS_CAL_CACHE (cal_cache), NULL);
+
+ zone = e_timezone_cache_get_timezone (E_TIMEZONE_CACHE (cal_cache), tzid);
+
+ g_clear_object (&cal_cache);
+
+ return zone;
+}
+
+static GList *
+ecmb_list_cached_timezones (ETimezoneCache *cache)
+{
+ ECalCache *cal_cache;
+ GList *zones;
+
+ cal_cache = e_cal_meta_backend_ref_cache (E_CAL_META_BACKEND (cache));
+ g_return_val_if_fail (E_IS_CAL_CACHE (cal_cache), NULL);
+
+ zones = e_timezone_cache_list_timezones (E_TIMEZONE_CACHE (cal_cache));
+
+ g_clear_object (&cal_cache);
+
+ return zones;
+}
+
+static void
e_cal_meta_backend_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -3300,6 +3351,14 @@ e_cal_meta_backend_init (ECalMetaBackend *meta_backend)
meta_backend->priv->connected_writable = -1;
}
+static void
+e_cal_meta_backend_timezone_cache_init (ETimezoneCacheInterface *iface)
+{
+ iface->add_timezone = ecmb_add_cached_timezone;
+ iface->get_timezone = ecmb_get_cached_timezone;
+ iface->list_timezones = ecmb_list_cached_timezones;
+}
+
/**
* e_cal_meta_backend_get_capabilities:
* @meta_backend: an #ECalMetaBackend
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]