[evolution-kolab/ek-wip-porting: 8/10] kolab-util-calendar-cache: separated out code for getting timezone into own function
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-porting: 8/10] kolab-util-calendar-cache: separated out code for getting timezone into own function
- Date: Sat, 17 Mar 2012 22:30:16 +0000 (UTC)
commit 09134ddf37f68faa2e333b13af379be4fd95baf9
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Sat Mar 17 23:22:40 2012 +0100
kolab-util-calendar-cache: separated out code for getting timezone into own function
* moved code for getting a timezone information
by its tzid directly from the calendar cache
into an own function (to be used in our
ECalBackendKolab)
src/calendar/kolab-util-calendar-cache.c | 70 +++++++++++++++++------------
src/calendar/kolab-util-calendar-cache.h | 3 +
2 files changed, 44 insertions(+), 29 deletions(-)
---
diff --git a/src/calendar/kolab-util-calendar-cache.c b/src/calendar/kolab-util-calendar-cache.c
index 4015f97..ce54229 100644
--- a/src/calendar/kolab-util-calendar-cache.c
+++ b/src/calendar/kolab-util-calendar-cache.c
@@ -47,6 +47,45 @@ G_DEFINE_TYPE (KolabUtilCalendarCache, kolab_util_calendar_cache, G_TYPE_OBJECT)
/*----------------------------------------------------------------------------*/
+ECalComponent*
+kolab_util_calendar_cache_get_tz_by_id (ECalBackendCache *cache,
+ const gchar *tzid)
+{
+ ECalComponent *ecaltz = NULL;
+ icalcomponent *icalcomp = NULL;
+ const icaltimezone *icaltz = NULL;
+ gboolean ok = FALSE;
+
+ g_assert (E_IS_CAL_BACKEND_CACHE (cache));
+ g_return_val_if_fail (tzid != NULL, NULL);
+
+ icaltz = e_cal_backend_cache_get_timezone (cache,
+ tzid);
+ if (icaltz == NULL) {
+ g_debug ("%s()[%u]: timezone for \"%s\" not found.",
+ __func__, __LINE__, tzid);
+ return NULL;
+ }
+
+ ecaltz = e_cal_component_new();
+ e_cal_component_set_new_vtype (ecaltz, E_CAL_COMPONENT_TIMEZONE);
+ /* Copy the icalcomponent, so that the new created ECalComponent contains
+ * a real copy und doesn't invalidate data on the backend cache on unref.
+ */
+ icalcomp = icalcomponent_new_clone (icaltimezone_get_component ((icaltimezone *) icaltz));
+
+ ok = e_cal_component_set_icalcomponent (ecaltz, icalcomp);
+ if (! ok) {
+ g_object_unref (ecaltz);
+ icalcomponent_free (icalcomp);
+ ecaltz = NULL;
+ g_warning ("%s[%u]: could not set timezone.",
+ __func__, __LINE__);
+ }
+
+ return ecaltz;
+}
+
/**
* kolab_util_calendar_cache_get_tz:
* @cache: A Cache.
@@ -64,8 +103,6 @@ kolab_util_calendar_cache_get_tz (ECalBackendCache *cache,
ECalComponent *comp)
{
ECalComponent *ecaltz = NULL;
- icalcomponent *icalcomp = NULL;
- const icaltimezone *icaltz = NULL;
gchar *tzid = NULL;
gint field_nr;
ECalComponentField tzid_search[3] = {
@@ -73,7 +110,6 @@ kolab_util_calendar_cache_get_tz (ECalBackendCache *cache,
E_CAL_COMPONENT_FIELD_DTSTART,
E_CAL_COMPONENT_FIELD_DUE
};
- gboolean ok = FALSE;
g_assert (E_IS_CAL_BACKEND_CACHE (cache));
g_assert (E_IS_CAL_COMPONENT (comp));
@@ -92,36 +128,12 @@ kolab_util_calendar_cache_get_tz (ECalBackendCache *cache,
}
if (tzid == NULL) {
/* This may happen, e.g.:
- * + All day events don't provide TZIDs. */
- return NULL;
- }
- icaltz = e_cal_backend_cache_get_timezone (cache,
- tzid);
- if (icaltz == NULL) {
- g_debug ("%s()[%u]: timezone for \"%s\" not found.",
- __func__, __LINE__, tzid);
- g_free (tzid);
+ * + All-day-events don't provide TZIDs. */
return NULL;
}
+ ecaltz = kolab_util_calendar_cache_get_tz_by_id (cache, tzid);
g_free (tzid);
-
- ecaltz = e_cal_component_new();
- e_cal_component_set_new_vtype (ecaltz, E_CAL_COMPONENT_TIMEZONE);
- /* Copy the icalcomponent, so that the new created ECalComponent contains
- * a real copy und doesn't invalidate data on the backend cache on unref.
- */
- icalcomp = icalcomponent_new_clone (icaltimezone_get_component ((icaltimezone *) icaltz));
-
- ok = e_cal_component_set_icalcomponent (ecaltz, icalcomp);
- if (! ok) {
- g_object_unref (ecaltz);
- icalcomponent_free (icalcomp);
- ecaltz = NULL;
- g_warning ("%s[%u]: could not set timezone.",
- __func__, __LINE__);
- }
-
return ecaltz;
} /* kolab_util_calendar_cache_get_tz () */
diff --git a/src/calendar/kolab-util-calendar-cache.h b/src/calendar/kolab-util-calendar-cache.h
index 1ff3463..b5760b6 100644
--- a/src/calendar/kolab-util-calendar-cache.h
+++ b/src/calendar/kolab-util-calendar-cache.h
@@ -77,6 +77,9 @@ GType
kolab_util_calendar_cache_get_type (void) G_GNUC_CONST;
ECalComponent*
+kolab_util_calendar_cache_get_tz_by_id (ECalBackendCache *cache,
+ const gchar *tzid);
+ECalComponent*
kolab_util_calendar_cache_get_tz (ECalBackendCache *cache,
ECalComponent *comp);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]