[evolution-data-server/wip/mcrha/libical-glib] Calendar backends changes



commit 7972bacd6a7161ebe0fa551d4932ea3f8b466d91
Author: Milan Crha <mcrha redhat com>
Date:   Wed Mar 13 14:47:41 2019 +0100

    Calendar backends changes

 .../backends/caldav/e-cal-backend-caldav.c         |  222 ++--
 .../backends/contacts/e-cal-backend-contacts.c     |  140 ++-
 src/calendar/backends/file/e-cal-backend-file.c    | 1082 +++++++++++---------
 .../backends/gtasks/e-cal-backend-gtasks.c         |  202 ++--
 src/calendar/backends/http/e-cal-backend-http.c    |  101 +-
 .../backends/weather/e-cal-backend-weather.c       |  135 +--
 6 files changed, 1024 insertions(+), 858 deletions(-)
---
diff --git a/src/calendar/backends/caldav/e-cal-backend-caldav.c 
b/src/calendar/backends/caldav/e-cal-backend-caldav.c
index b44203e50..11cfe184e 100644
--- a/src/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/src/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -325,37 +325,39 @@ ecb_caldav_disconnect_sync (ECalMetaBackend *meta_backend,
 }
 
 static const gchar *
-ecb_caldav_get_vcalendar_uid (icalcomponent *vcalendar)
+ecb_caldav_get_vcalendar_uid (ICalComponent *vcalendar)
 {
        const gchar *uid = NULL;
-       icalcomponent *subcomp;
+       ICalComponent *subcomp;
 
        g_return_val_if_fail (vcalendar != NULL, NULL);
-       g_return_val_if_fail (icalcomponent_isa (vcalendar) == ICAL_VCALENDAR_COMPONENT, NULL);
+       g_return_val_if_fail (i_cal_component_isa (vcalendar) == I_CAL_VCALENDAR_COMPONENT, NULL);
 
-       for (subcomp = icalcomponent_get_first_component (vcalendar, ICAL_ANY_COMPONENT);
+       for (subcomp = i_cal_component_get_first_component (vcalendar, I_CAL_ANY_COMPONENT);
             subcomp && !uid;
-            subcomp = icalcomponent_get_next_component (vcalendar, ICAL_ANY_COMPONENT)) {
-               icalcomponent_kind kind = icalcomponent_isa (subcomp);
+            g_object_unref (subcomp), subcomp = i_cal_component_get_next_component (vcalendar, 
I_CAL_ANY_COMPONENT)) {
+               ICalComponentKind kind = i_cal_component_isa (subcomp);
 
-               if (kind == ICAL_VEVENT_COMPONENT ||
-                   kind == ICAL_VJOURNAL_COMPONENT ||
-                   kind == ICAL_VTODO_COMPONENT) {
-                       uid = icalcomponent_get_uid (subcomp);
+               if (kind == I_CAL_VEVENT_COMPONENT ||
+                   kind == I_CAL_VJOURNAL_COMPONENT ||
+                   kind == I_CAL_VTODO_COMPONENT) {
+                       uid = i_cal_component_get_uid (subcomp);
                        if (uid && !*uid)
                                uid = NULL;
                }
        }
 
+       g_clear_object (&subcomp);
+
        return uid;
 }
 
 static void
 ecb_caldav_update_nfo_with_vcalendar (ECalMetaBackendInfo *nfo,
-                                     icalcomponent *vcalendar,
+                                     ICalComponent *vcalendar,
                                      const gchar *etag)
 {
-       icalcomponent *subcomp;
+       ICalComponent *subcomp;
        const gchar *uid;
 
        g_return_if_fail (nfo != NULL);
@@ -366,20 +368,20 @@ ecb_caldav_update_nfo_with_vcalendar (ECalMetaBackendInfo *nfo,
        if (!etag || !*etag)
                etag = nfo->revision;
 
-       for (subcomp = icalcomponent_get_first_component (vcalendar, ICAL_ANY_COMPONENT);
+       for (subcomp = i_cal_component_get_first_component (vcalendar, I_CAL_ANY_COMPONENT);
             subcomp;
-            subcomp = icalcomponent_get_next_component (vcalendar, ICAL_ANY_COMPONENT)) {
-               icalcomponent_kind kind = icalcomponent_isa (subcomp);
+            g_object_unref (subcomp), subcomp = i_cal_component_get_next_component (vcalendar, 
I_CAL_ANY_COMPONENT)) {
+               ICalComponentKind kind = i_cal_component_isa (subcomp);
 
-               if (kind == ICAL_VEVENT_COMPONENT ||
-                   kind == ICAL_VJOURNAL_COMPONENT ||
-                   kind == ICAL_VTODO_COMPONENT) {
-                       e_cal_util_set_x_property (subcomp, E_CALDAV_X_ETAG, etag);
+               if (kind == I_CAL_VEVENT_COMPONENT ||
+                   kind == I_CAL_VJOURNAL_COMPONENT ||
+                   kind == I_CAL_VTODO_COMPONENT) {
+                       e_cal_util_component_set_x_property (subcomp, E_CALDAV_X_ETAG, etag);
                }
        }
 
        g_warn_if_fail (nfo->object == NULL);
-       nfo->object = icalcomponent_as_ical_string_r (vcalendar);
+       nfo->object = i_cal_component_as_ical_string_r (vcalendar);
 
        if (!nfo->uid || !*(nfo->uid)) {
                g_free (nfo->uid);
@@ -418,9 +420,9 @@ ecb_caldav_multiget_response_cb (EWebDAVSession *webdav,
                etag = e_webdav_session_util_maybe_dequote (e_xml_xpath_eval_as_string (xpath_ctx, 
"%s/D:getetag", xpath_prop_prefix));
 
                if (calendar_data) {
-                       icalcomponent *vcalendar;
+                       ICalComponent *vcalendar;
 
-                       vcalendar = icalcomponent_new_from_string (calendar_data);
+                       vcalendar = i_cal_component_new_from_string (calendar_data);
                        if (vcalendar) {
                                const gchar *uid;
 
@@ -447,7 +449,7 @@ ecb_caldav_multiget_response_cb (EWebDAVSession *webdav,
                                        }
                                }
 
-                               icalcomponent_free (vcalendar);
+                               g_object_unref (vcalendar);
                        }
                }
 
@@ -511,12 +513,12 @@ ecb_caldav_multiget_from_sets_sync (ECalBackendCalDAV *cbdav,
                                nfo->extra, NULL, &etag, &calendar_data, NULL, cancellable, error);
 
                        if (success && calendar_data) {
-                               icalcomponent *vcalendar;
+                               ICalComponent *vcalendar;
 
-                               vcalendar = icalcomponent_new_from_string (calendar_data);
+                               vcalendar = i_cal_component_new_from_string (calendar_data);
                                if (vcalendar) {
                                        ecb_caldav_update_nfo_with_vcalendar (nfo, vcalendar, etag);
-                                       icalcomponent_free (vcalendar);
+                                       g_object_unref (vcalendar);
                                }
                        }
 
@@ -766,7 +768,7 @@ ecb_caldav_get_changes_sync (ECalMetaBackend *meta_backend,
        }
 
        if (!is_repeat) {
-               icaltimezone *utc = icaltimezone_get_utc_timezone ();
+               ICalTimezone *utc = i_cal_timezone_get_utc_timezone ();
                time_t now;
                gchar *tmp;
 
@@ -875,9 +877,9 @@ ecb_caldav_extract_existing_cb (EWebDAVSession *webdav,
                calendar_data = e_xml_xpath_eval_as_string (xpath_ctx, "%s/C:calendar-data", 
xpath_prop_prefix);
 
                if (calendar_data) {
-                       icalcomponent *vcalendar;
+                       ICalComponent *vcalendar;
 
-                       vcalendar = icalcomponent_new_from_string (calendar_data);
+                       vcalendar = i_cal_component_new_from_string (calendar_data);
                        if (vcalendar) {
                                const gchar *uid;
 
@@ -889,7 +891,7 @@ ecb_caldav_extract_existing_cb (EWebDAVSession *webdav,
                                                e_cal_meta_backend_info_new (uid, etag, NULL, href));
                                }
 
-                               icalcomponent_free (vcalendar);
+                               g_object_unref (vcalendar);
                        }
                }
 
@@ -909,7 +911,7 @@ ecb_caldav_list_existing_sync (ECalMetaBackend *meta_backend,
 {
        ECalBackendCalDAV *cbdav;
        EWebDAVSession *webdav;
-       icalcomponent_kind kind;
+       ICalComponentKind kind;
        EXmlDocument *xml;
        GError *local_error = NULL;
        gboolean success;
@@ -920,7 +922,6 @@ ecb_caldav_list_existing_sync (ECalMetaBackend *meta_backend,
        *out_existing_objects = NULL;
 
        cbdav = E_CAL_BACKEND_CALDAV (meta_backend);
-
        kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbdav));
 
        xml = e_xml_document_new (E_WEBDAV_NS_CALDAV, "calendar-query");
@@ -934,11 +935,11 @@ ecb_caldav_list_existing_sync (ECalMetaBackend *meta_backend,
        e_xml_document_start_element (xml, E_WEBDAV_NS_CALDAV, "comp");
        e_xml_document_add_attribute (xml, NULL, "name", "VCALENDAR");
        e_xml_document_start_element (xml, E_WEBDAV_NS_CALDAV, "comp");
-       if (kind == ICAL_VEVENT_COMPONENT)
+       if (kind == I_CAL_VEVENT_COMPONENT)
                e_xml_document_add_attribute (xml, NULL, "name", "VEVENT");
-       else if (kind == ICAL_VJOURNAL_COMPONENT)
+       else if (kind == I_CAL_VJOURNAL_COMPONENT)
                e_xml_document_add_attribute (xml, NULL, "name", "VJOURNAL");
-       else if (kind == ICAL_VTODO_COMPONENT)
+       else if (kind == I_CAL_VTODO_COMPONENT)
                e_xml_document_add_attribute (xml, NULL, "name", "VTODO");
        else
                g_warn_if_reached ();
@@ -954,11 +955,11 @@ ecb_caldav_list_existing_sync (ECalMetaBackend *meta_backend,
        e_xml_document_start_element (xml, E_WEBDAV_NS_CALDAV, "comp-filter");
        e_xml_document_add_attribute (xml, NULL, "name", "VCALENDAR");
        e_xml_document_start_element (xml, E_WEBDAV_NS_CALDAV, "comp-filter");
-       if (kind == ICAL_VEVENT_COMPONENT)
+       if (kind == I_CAL_VEVENT_COMPONENT)
                e_xml_document_add_attribute (xml, NULL, "name", "VEVENT");
-       else if (kind == ICAL_VJOURNAL_COMPONENT)
+       else if (kind == I_CAL_VJOURNAL_COMPONENT)
                e_xml_document_add_attribute (xml, NULL, "name", "VJOURNAL");
-       else if (kind == ICAL_VTODO_COMPONENT)
+       else if (kind == I_CAL_VTODO_COMPONENT)
                e_xml_document_add_attribute (xml, NULL, "name", "VTODO");
        e_xml_document_end_element (xml); /* comp-filter / VEVENT|VJOURNAL|VTODO */
        e_xml_document_end_element (xml); /* comp-filter / VCALENDAR */
@@ -1042,25 +1043,25 @@ ecb_caldav_uid_to_uri (ECalBackendCalDAV *cbdav,
 }
 
 static void
-ecb_caldav_store_component_etag (icalcomponent *icalcomp,
+ecb_caldav_store_component_etag (ICalComponent *icomp,
                                 const gchar *etag)
 {
-       icalcomponent *subcomp;
+       ICalComponent *subcomp;
 
-       g_return_if_fail (icalcomp != NULL);
+       g_return_if_fail (icomp != NULL);
        g_return_if_fail (etag != NULL);
 
-       e_cal_util_set_x_property (icalcomp, E_CALDAV_X_ETAG, etag);
+       e_cal_util_component_set_x_property (icomp, E_CALDAV_X_ETAG, etag);
 
-       for (subcomp = icalcomponent_get_first_component (icalcomp, ICAL_ANY_COMPONENT);
+       for (subcomp = i_cal_component_get_first_component (icomp, I_CAL_ANY_COMPONENT);
             subcomp;
-            subcomp = icalcomponent_get_next_component (icalcomp, ICAL_ANY_COMPONENT)) {
-               icalcomponent_kind kind = icalcomponent_isa (subcomp);
+            g_object_unref (subcomp), subcomp = i_cal_component_get_next_component (icomp, 
I_CAL_ANY_COMPONENT)) {
+               ICalComponentKind kind = i_cal_component_isa (subcomp);
 
-               if (kind == ICAL_VEVENT_COMPONENT ||
-                   kind == ICAL_VJOURNAL_COMPONENT ||
-                   kind == ICAL_VTODO_COMPONENT) {
-                       e_cal_util_set_x_property (subcomp, E_CALDAV_X_ETAG, etag);
+               if (kind == I_CAL_VEVENT_COMPONENT ||
+                   kind == I_CAL_VJOURNAL_COMPONENT ||
+                   kind == I_CAL_VTODO_COMPONENT) {
+                       e_cal_util_component_set_x_property (subcomp, E_CALDAV_X_ETAG, etag);
                }
        }
 }
@@ -1069,7 +1070,7 @@ static gboolean
 ecb_caldav_load_component_sync (ECalMetaBackend *meta_backend,
                                const gchar *uid,
                                const gchar *extra,
-                               icalcomponent **out_component,
+                               ICalComponent **out_component,
                                gchar **out_extra,
                                GCancellable *cancellable,
                                GError **error)
@@ -1096,9 +1097,9 @@ ecb_caldav_load_component_sync (ECalMetaBackend *meta_backend,
 
                newline = strchr (extra, '\n');
                if (newline && newline[1] && newline != extra) {
-                       icalcomponent *vcalendar;
+                       ICalComponent *vcalendar;
 
-                       vcalendar = icalcomponent_new_from_string (newline + 1);
+                       vcalendar = i_cal_component_new_from_string (newline + 1);
                        if (vcalendar) {
                                *out_extra = g_strndup (extra, newline - extra);
                                *out_component = vcalendar;
@@ -1174,14 +1175,14 @@ ecb_caldav_load_component_sync (ECalMetaBackend *meta_backend,
                *out_component = NULL;
 
                if (href && etag && bytes && length != ((gsize) -1)) {
-                       icalcomponent *icalcomp;
+                       ICalComponent *icomp;
 
-                       icalcomp = icalcomponent_new_from_string (bytes);
+                       icomp = i_cal_component_new_from_string (bytes);
 
-                       if (icalcomp) {
-                               ecb_caldav_store_component_etag (icalcomp, etag);
+                       if (icomp) {
+                               ecb_caldav_store_component_etag (icomp, etag);
 
-                               *out_component = icalcomp;
+                               *out_component = icomp;
                        }
                }
 
@@ -1227,7 +1228,7 @@ ecb_caldav_save_component_sync (ECalMetaBackend *meta_backend,
 {
        ECalBackendCalDAV *cbdav;
        EWebDAVSession *webdav;
-       icalcomponent *vcalendar, *subcomp;
+       ICalComponent *vcalendar, *subcomp;
        gchar *href = NULL, *etag = NULL, *uid = NULL;
        gchar *ical_string = NULL;
        gboolean success;
@@ -1243,24 +1244,24 @@ ecb_caldav_save_component_sync (ECalMetaBackend *meta_backend,
        vcalendar = e_cal_meta_backend_merge_instances (meta_backend, instances, TRUE);
        g_return_val_if_fail (vcalendar != NULL, FALSE);
 
-       for (subcomp = icalcomponent_get_first_component (vcalendar, ICAL_ANY_COMPONENT);
+       for (subcomp = i_cal_component_get_first_component (vcalendar, I_CAL_ANY_COMPONENT);
             subcomp;
-            subcomp = icalcomponent_get_next_component (vcalendar, ICAL_ANY_COMPONENT)) {
-               icalcomponent_kind kind = icalcomponent_isa (subcomp);
+            g_object_unref (subcomp), subcomp = i_cal_component_get_next_component (vcalendar, 
I_CAL_ANY_COMPONENT)) {
+               ICalComponentKind kind = i_cal_component_isa (subcomp);
 
-               if (kind == ICAL_VEVENT_COMPONENT ||
-                   kind == ICAL_VJOURNAL_COMPONENT ||
-                   kind == ICAL_VTODO_COMPONENT) {
+               if (kind == I_CAL_VEVENT_COMPONENT ||
+                   kind == I_CAL_VJOURNAL_COMPONENT ||
+                   kind == I_CAL_VTODO_COMPONENT) {
                        if (!etag)
-                               etag = e_cal_util_dup_x_property (subcomp, E_CALDAV_X_ETAG);
+                               etag = e_cal_util_component_dup_x_property (subcomp, E_CALDAV_X_ETAG);
                        if (!uid)
-                               uid = g_strdup (icalcomponent_get_uid (subcomp));
+                               uid = g_strdup (i_cal_component_get_uid (subcomp));
 
-                       e_cal_util_remove_x_property (subcomp, E_CALDAV_X_ETAG);
+                       e_cal_util_component_remove_x_property (subcomp, E_CALDAV_X_ETAG);
                }
        }
 
-       ical_string = icalcomponent_as_ical_string_r (vcalendar);
+       ical_string = i_cal_component_as_ical_string_r (vcalendar);
 
        webdav = ecb_caldav_ref_session (cbdav);
 
@@ -1297,7 +1298,7 @@ ecb_caldav_save_component_sync (ECalMetaBackend *meta_backend,
                                ecb_caldav_store_component_etag (vcalendar, new_etag);
 
                                g_free (ical_string);
-                               ical_string = icalcomponent_as_ical_string_r (vcalendar);
+                               ical_string = i_cal_component_as_ical_string_r (vcalendar);
 
                                /* Encodes the href and the component into one string, which
                                   will be decoded in the load function */
@@ -1325,7 +1326,7 @@ ecb_caldav_save_component_sync (ECalMetaBackend *meta_backend,
                g_propagate_error (error, EDC_ERROR (InvalidObject));
        }
 
-       icalcomponent_free (vcalendar);
+       g_object_unref (vcalendar);
        g_free (ical_string);
        g_free (href);
        g_free (etag);
@@ -1352,7 +1353,7 @@ ecb_caldav_remove_component_sync (ECalMetaBackend *meta_backend,
 {
        ECalBackendCalDAV *cbdav;
        EWebDAVSession *webdav;
-       icalcomponent *icalcomp;
+       ICalComponent *icomp;
        gchar *etag = NULL;
        gboolean success;
        GError *local_error = NULL;
@@ -1368,14 +1369,14 @@ ecb_caldav_remove_component_sync (ECalMetaBackend *meta_backend,
                return FALSE;
        }
 
-       icalcomp = icalcomponent_new_from_string (object);
-       if (!icalcomp) {
+       icomp = i_cal_component_new_from_string (object);
+       if (!icomp) {
                g_propagate_error (error, EDC_ERROR (InvalidObject));
                return FALSE;
        }
 
        if (conflict_resolution == E_CONFLICT_RESOLUTION_FAIL)
-               etag = e_cal_util_dup_x_property (icalcomp, E_CALDAV_X_ETAG);
+               etag = e_cal_util_component_dup_x_property (icomp, E_CALDAV_X_ETAG);
 
        webdav = ecb_caldav_ref_session (cbdav);
 
@@ -1406,7 +1407,7 @@ ecb_caldav_remove_component_sync (ECalMetaBackend *meta_backend,
                }
        }
 
-       icalcomponent_free (icalcomp);
+       g_object_unref (icomp);
        g_free (etag);
 
        /* Ignore not found errors, this was a delete and the resource is gone.
@@ -1576,42 +1577,40 @@ ecb_caldav_receive_schedule_outbox_url_sync (ECalBackendCalDAV *cbdav,
 }
 
 static void
-ecb_caldav_extract_objects (icalcomponent *icomp,
-                           icalcomponent_kind ekind,
+ecb_caldav_extract_objects (ICalComponent *icomp,
+                           ICalComponentKind ekind,
                            GSList **out_objects,
                            GError **error)
 {
-       icalcomponent *scomp;
-       icalcomponent_kind kind;
+       ICalComponent *scomp;
+       ICalComponentKind kind;
        GSList *link;
 
        g_return_if_fail (icomp != NULL);
        g_return_if_fail (out_objects != NULL);
 
-       kind = icalcomponent_isa (icomp);
+       kind = i_cal_component_isa (icomp);
 
        if (kind == ekind) {
-               *out_objects = g_slist_prepend (NULL, icalcomponent_new_clone (icomp));
+               *out_objects = g_slist_prepend (NULL, i_cal_component_new_clone (icomp));
                return;
        }
 
-       if (kind != ICAL_VCALENDAR_COMPONENT) {
+       if (kind != I_CAL_VCALENDAR_COMPONENT) {
                g_propagate_error (error, EDC_ERROR (InvalidObject));
                return;
        }
 
        *out_objects = NULL;
-       scomp = icalcomponent_get_first_component (icomp, ekind);
-
-       while (scomp) {
-               *out_objects = g_slist_prepend (*out_objects, scomp);
-
-               scomp = icalcomponent_get_next_component (icomp, ekind);
+       for (scomp = i_cal_component_get_first_component (icomp, ekind);
+            scomp;
+            g_object_unref (scomp), scomp = i_cal_component_get_next_component (icomp, ekind)) {
+               *out_objects = g_slist_prepend (*out_objects, g_object_ref (scomp));
        }
 
        for (link = *out_objects; link; link = g_slist_next (link)) {
                /* Remove components from toplevel here */
-               icalcomponent_remove_component (icomp, link->data);
+               i_cal_component_remove_component (icomp, link->data);
        }
 
        *out_objects = g_slist_reverse (*out_objects);
@@ -1686,7 +1685,6 @@ ecb_caldav_get_free_busy_from_schedule_outbox_sync (ECalBackendCalDAV *cbdav,
        ESourceAuthentication *auth_extension;
        ESource *source;
        EWebDAVSession *webdav;
-       ICalTimetype *dtvalue;
        ICalTimezone *utc;
        gchar *str;
        GSList *link;
@@ -1717,7 +1715,7 @@ ecb_caldav_get_free_busy_from_schedule_outbox_sync (ECalBackendCalDAV *cbdav,
        g_free (str);
 
        utc = i_cal_timezone_get_utc_timezone ();
-       dt = e_cal_component_datetime_new_take (i_cal_time_current_time_with_zone (utc), 
i_cal_timezone_get_tzid (utc));
+       dt = e_cal_component_datetime_new_take (i_cal_time_current_time_with_zone (utc), g_strdup 
(i_cal_timezone_get_tzid (utc)));
 
        e_cal_component_set_dtstamp (comp, e_cal_component_datetime_get_value (dt));
 
@@ -1822,12 +1820,12 @@ ecb_caldav_get_free_busy_from_schedule_outbox_sync (ECalBackendCalDAV *cbdav,
                                        if (tmp && *tmp) {
                                                GSList *objects = NULL;
 
-                                               icalcomp = icalparser_parse_string (tmp);
-                                               if (icalcomp)
-                                                       ecb_caldav_extract_objects (icalcomp, 
ICAL_VFREEBUSY_COMPONENT, &objects, &local_error);
-                                               if (icalcomp && !local_error) {
+                                               icomp = i_cal_parser_parse_string (tmp);
+                                               if (icomp)
+                                                       ecb_caldav_extract_objects (icomp, 
I_CAL_VFREEBUSY_COMPONENT, &objects, &local_error);
+                                               if (icomp && !local_error) {
                                                        for (link = objects; link; link = g_slist_next 
(link)) {
-                                                               gchar *obj_str = 
icalcomponent_as_ical_string_r (link->data);
+                                                               gchar *obj_str = 
i_cal_component_as_ical_string_r (link->data);
 
                                                                if (obj_str && *obj_str)
                                                                        *out_freebusy = g_slist_prepend 
(*out_freebusy, obj_str);
@@ -1836,10 +1834,9 @@ ecb_caldav_get_free_busy_from_schedule_outbox_sync (ECalBackendCalDAV *cbdav,
                                                        }
                                                }
 
-                                               g_slist_free_full (objects, (GDestroyNotify) 
icalcomponent_free);
+                                               g_slist_free_full (objects, g_object_unref);
 
-                                               if (icalcomp)
-                                                       icalcomponent_free (icalcomp);
+                                               g_clear_object (&icomp);
                                                g_clear_error (&local_error);
                                        }
 
@@ -1928,30 +1925,30 @@ ecb_caldav_get_free_busy_from_principal_sync (ECalBackendCalDAV *cbdav,
 
        if (success && content_type && content && content->data && content->len &&
            g_ascii_strcasecmp (content_type, "text/calendar") == 0) {
-               icalcomponent *vcalendar;
+               ICalComponent *vcalendar;
 
-               vcalendar = icalcomponent_new_from_string ((const gchar *) content->data);
+               vcalendar = i_cal_component_new_from_string ((const gchar *) content->data);
                if (vcalendar) {
                        GSList *comps = NULL, *link;
 
-                       ecb_caldav_extract_objects (vcalendar, ICAL_VFREEBUSY_COMPONENT, &comps, NULL);
+                       ecb_caldav_extract_objects (vcalendar, I_CAL_VFREEBUSY_COMPONENT, &comps, NULL);
 
                        for (link = comps; link; link = g_slist_next (link)) {
-                               icalcomponent *subcomp = link->data;
+                               ICalComponent *subcomp = link->data;
                                gchar *obj_str;
 
-                               if (!icalcomponent_get_first_property (subcomp, ICAL_ATTENDEE_PROPERTY)) {
-                                       icalproperty *prop;
+                               if (!e_cal_util_component_has_property (subcomp, I_CAL_ATTENDEE_PROPERTY)) {
+                                       ICalProperty *prop;
                                        gchar *mailto;
 
                                        mailto = g_strconcat ("mailto:";, usermail, NULL);
-                                       prop = icalproperty_new_attendee (mailto);
+                                       prop = i_cal_property_new_attendee (mailto);
                                        g_free (mailto);
 
-                                       icalcomponent_add_property (subcomp, prop);
+                                       i_cal_component_take_property (subcomp, prop);
                                }
 
-                               obj_str = icalcomponent_as_ical_string_r (subcomp);
+                               obj_str = i_cal_component_as_ical_string_r (subcomp);
 
                                if (obj_str && *obj_str)
                                        *out_freebusy = g_slist_prepend (*out_freebusy, obj_str);
@@ -1961,7 +1958,8 @@ ecb_caldav_get_free_busy_from_principal_sync (ECalBackendCalDAV *cbdav,
 
                        success = comps != NULL;
 
-                       g_slist_free_full (comps, (GDestroyNotify) icalcomponent_free);
+                       g_slist_free_full (comps, g_object_unref);
+                       g_object_unref (vcalendar);
                } else {
                        success = FALSE;
                }
@@ -2112,11 +2110,11 @@ ecb_caldav_notify_property_changed_cb (GObject *object,
 
 static gchar *
 ecb_caldav_dup_component_revision_cb (ECalCache *cal_cache,
-                                     icalcomponent *icalcomp)
+                                     ICalComponent *icomp)
 {
-       g_return_val_if_fail (icalcomp != NULL, NULL);
+       g_return_val_if_fail (icomp != NULL, NULL);
 
-       return e_cal_util_dup_x_property (icalcomp, E_CALDAV_X_ETAG);
+       return e_cal_util_component_dup_x_property (icomp, E_CALDAV_X_ETAG);
 }
 
 static void
diff --git a/src/calendar/backends/contacts/e-cal-backend-contacts.c 
b/src/calendar/backends/contacts/e-cal-backend-contacts.c
index 25f8a3073..7a5e3995f 100644
--- a/src/calendar/backends/contacts/e-cal-backend-contacts.c
+++ b/src/calendar/backends/contacts/e-cal-backend-contacts.c
@@ -699,19 +699,20 @@ contacts_removed_cb (EBookClientView *book_view,
 }
 
 /************************************************************************************/
-static struct icaltimetype
+static ICalTimetype *
 cdate_to_icaltime (EContactDate *cdate)
 {
-       struct icaltimetype ret = icaltime_null_time ();
-
-       ret.year = cdate->year;
-       ret.month = cdate->month;
-       ret.day = cdate->day;
-       ret.is_date = TRUE;
-       ret.zone = NULL;
-       ret.is_daylight = FALSE;
-
-       ret.hour = ret.minute = ret.second = 0;
+       ICalTimetype *ret = i_cal_time_null_time ();
+
+       i_cal_timetype_set_year (ret, cdate->year);
+       i_cal_timetype_set_month (ret, cdate->month);
+       i_cal_timetype_set_day (ret, cdate->day);
+       i_cal_timetype_set_hour (ret, 0);
+       i_cal_timetype_set_minute (ret, 0);
+       i_cal_timetype_set_second (ret, 0);
+       i_cal_timetype_set_zone (ret, NULL);
+       i_cal_timetype_set_is_daylight (ret, FALSE);
+       i_cal_timetype_set_is_date (ret, TRUE);
 
        return ret;
 }
@@ -894,15 +895,14 @@ create_component (ECalBackendContacts *cbc,
                   EContactDate *cdate,
                   const gchar *summary)
 {
-       ECalComponent             *cal_comp;
-       ECalComponentText          comp_summary;
-       icalcomponent             *ical_comp;
-       icalproperty              *prop;
-       struct icaltimetype        itt;
-       ECalComponentDateTime      dt;
-       struct icalrecurrencetype  r;
-       gchar                     *since_year;
-       GSList recur_list;
+       ECalComponent *cal_comp;
+       ECalComponentText *comp_summary;
+       ECalComponentDateTime *dt;
+       ICalComponent *icomp;
+       ICalTimetype *itt, *itt_norm;
+       ICalRecurrenceType *rt;
+       gchar *since_year;
+       GSList *recur_list;
        gboolean is_leap_day;
 
        g_return_val_if_fail (E_IS_CAL_BACKEND_CONTACTS (cbc), NULL);
@@ -910,17 +910,14 @@ create_component (ECalBackendContacts *cbc,
        if (!cdate)
                return NULL;
 
-       ical_comp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
+       icomp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
 
        since_year = g_strdup_printf ("%04d", cdate->year);
-       prop = icalproperty_new_x (since_year);
-       icalproperty_set_x_name (prop, "X-EVOLUTION-SINCE-YEAR");
-       icalcomponent_add_property (ical_comp, prop);
+       e_cal_util_component_set_x_property (icomp, "X-EVOLUTION-SINCE-YEAR", since_year);
        g_free (since_year);
 
        /* Create the event object */
-       cal_comp = e_cal_component_new ();
-       e_cal_component_set_icalcomponent (cal_comp, ical_comp);
+       cal_comp = e_cal_component_new_from_icalcomponent (icomp);
 
        /* Set uid */
        d (g_message ("Creating UID: %s", uid));
@@ -928,34 +925,36 @@ create_component (ECalBackendContacts *cbc,
 
        /* Set all-day event's date from contact data */
        itt = cdate_to_icaltime (cdate);
-       dt.value = &itt;
-       dt.tzid = NULL;
-       e_cal_component_set_dtstart (cal_comp, &dt);
 
-       itt = icaltime_normalize (itt);
-       is_leap_day = itt.day == 29 && itt.month == 2;
+       itt_norm = i_cal_time_normalize (itt);
+       is_leap_day = i_cal_timetype_get_day (itt_norm) == 29 && i_cal_timetype_get_month (itt_norm) == 2;
+       g_clear_object (&itt_norm);
+
+       dt = e_cal_component_datetime_new_take (itt, NULL);
+       e_cal_component_set_dtstart (cal_comp, dt);
+       e_cal_component_datetime_free (dt);
 
        itt = cdate_to_icaltime (cdate);
-       icaltime_adjust (&itt, 1, 0, 0, 0);
-       dt.value = &itt;
-       dt.tzid = NULL;
        /* We have to add 1 day to DTEND, as it is not inclusive. */
-       e_cal_component_set_dtend (cal_comp, &dt);
+       i_cal_time_adjust (itt, 1, 0, 0, 0);
+       dt = e_cal_component_datetime_new_take (itt, NULL);
+       e_cal_component_set_dtend (cal_comp, dt);
+       e_cal_component_datetime_free (dt);
 
        /* Create yearly recurrence */
-       icalrecurrencetype_clear (&r);
-       r.freq = ICAL_YEARLY_RECURRENCE;
-       r.interval = 1;
+       rt = i_cal_recurrence_type_new ();
+       i_cal_recurrence_type_set_freq (rt, I_CAL_YEARLY_RECURRENCE);
+       i_cal_recurrence_type_set_interval (rt, 1);
        if (is_leap_day)
-               r.by_month_day[0] = -1;
-       recur_list.data = &r;
-       recur_list.next = NULL;
-       e_cal_component_set_rrule_list (cal_comp, &recur_list);
+               i_cal_recurrence_type_set_by_month_day (rt, 0, -1);
+       recur_list = g_slist_prepend (NULL, rt);
+       e_cal_component_set_rrules (cal_comp, recur_list);
+       g_slist_free_full (recur_list, g_object_unref);
 
        /* Create summary */
-       comp_summary.value = summary;
-       comp_summary.altrep = NULL;
-       e_cal_component_set_summary (cal_comp, &comp_summary);
+       comp_summary = e_cal_component_text_new (summary, NULL);
+       e_cal_component_set_summary (cal_comp, comp_summary);
+       e_cal_component_text_free (comp_summary);
 
        /* Set category and visibility */
        if (g_str_has_suffix (uid, ANNIVERSARY_UID_EXT))
@@ -1140,32 +1139,22 @@ e_cal_backend_contacts_get_free_busy (ECalBackendSync *backend,
 {
        /* Birthdays/anniversaries don't count as busy time */
 
-       icalcomponent *vfb = icalcomponent_new_vfreebusy ();
-       icaltimezone *utc_zone = icaltimezone_get_utc_timezone ();
+       ICalComponent *vfb = i_cal_component_new_vfreebusy ();
+       ICalTimezone *utc_zone = i_cal_timezone_get_utc_timezone ();
+       ICalTimetype *itt;
        gchar *calobj;
 
-#if 0
-       icalproperty *prop;
-       icalparameter *param;
+       itt = i_cal_time_from_timet_with_zone (start, FALSE, utc_zone);
+       i_cal_component_set_dtstart (vfb, itt);
+       g_object_unref (itt);
 
-       prop = icalproperty_new_organizer (address);
-       if (prop != NULL && cn != NULL) {
-               param = icalparameter_new_cn (cn);
-               icalproperty_add_parameter (prop, param);
-       }
-       if (prop != NULL)
-               icalcomponent_add_property (vfb, prop);
-#endif
-
-       icalcomponent_set_dtstart (vfb, icaltime_from_timet_with_zone (start, FALSE, utc_zone));
-       icalcomponent_set_dtend (vfb, icaltime_from_timet_with_zone (end, FALSE, utc_zone));
+       itt = i_cal_time_from_timet_with_zone (end, FALSE, utc_zone);
+       i_cal_component_set_dtend (vfb, itt);
+       g_object_unref (itt);
 
-       calobj = icalcomponent_as_ical_string_r (vfb);
+       calobj = i_cal_component_as_ical_string_r (vfb);
        *freebusy = g_slist_append (NULL, calobj);
-       icalcomponent_free (vfb);
-
-       /* WRITE ME */
-       /* Success */
+       g_object_unref (vfb);
 }
 
 static void
@@ -1232,24 +1221,27 @@ e_cal_backend_contacts_add_timezone (ECalBackendSync *backend,
                                      const gchar *tzobj,
                                      GError **error)
 {
-       icalcomponent *tz_comp;
-       icaltimezone *zone;
+       ICalComponent *tz_comp;
+       ICalTimezone *zone;
 
-       tz_comp = icalparser_parse_string (tzobj);
+       tz_comp = i_cal_parser_parse_string (tzobj);
        if (!tz_comp) {
                g_propagate_error (error, EDC_ERROR (InvalidObject));
                return;
        }
 
-       if (icalcomponent_isa (tz_comp) != ICAL_VTIMEZONE_COMPONENT) {
+       if (i_cal_component_isa (tz_comp) != I_CAL_VTIMEZONE_COMPONENT) {
+               g_object_unref (tz_comp);
                g_propagate_error (error, EDC_ERROR (InvalidObject));
                return;
        }
 
-       zone = icaltimezone_new ();
-       icaltimezone_set_component (zone, tz_comp);
-       e_timezone_cache_add_timezone (E_TIMEZONE_CACHE (backend), zone);
-       icaltimezone_free (zone, TRUE);
+       zone = i_cal_timezone_new ();
+       if (i_cal_timezone_set_component (zone, tz_comp))
+               e_timezone_cache_add_timezone (E_TIMEZONE_CACHE (backend), zone);
+
+       g_object_unref (zone);
+       g_object_unref (tz_comp);
 }
 
 static void
diff --git a/src/calendar/backends/file/e-cal-backend-file.c b/src/calendar/backends/file/e-cal-backend-file.c
index ce305e731..3f3a0aa69 100644
--- a/src/calendar/backends/file/e-cal-backend-file.c
+++ b/src/calendar/backends/file/e-cal-backend-file.c
@@ -72,7 +72,7 @@ struct _ECalBackendFilePrivate {
        GRecMutex idle_save_rmutex;
 
        /* Toplevel VCALENDAR component */
-       icalcomponent *icalcomp;
+       ICalComponent *vcalendar;
 
        /* All the objects in the calendar, hashed by UID.  The
         * hash key *is* the uid returned by cal_component_get_uid(); it is not
@@ -100,15 +100,13 @@ struct _ECalBackendFilePrivate {
 
        /* Just an incremental number to ensure uniqueness across revisions */
        guint revision_counter;
-};
 
-
+       /* Only for ETimezoneCache::get_timezone() call */
+       GHashTable *cached_timezones; /* gchar *tzid ~> ICalTimezone * */
+};
 
 #define d(x)
 
-static void e_cal_backend_file_dispose (GObject *object);
-static void e_cal_backend_file_finalize (GObject *object);
-
 static void free_refresh_data (ECalBackendFile *cbfile);
 
 static void bump_revision (ECalBackendFile *cbfile);
@@ -156,7 +154,7 @@ save_file_when_idle (gpointer user_data)
 
        priv = cbfile->priv;
        g_return_val_if_fail (priv->path != NULL, FALSE);
-       g_return_val_if_fail (priv->icalcomp != NULL, FALSE);
+       g_return_val_if_fail (priv->vcalendar != NULL, FALSE);
 
        writable = e_cal_backend_get_writable (E_CAL_BACKEND (cbfile));
 
@@ -202,7 +200,7 @@ save_file_when_idle (gpointer user_data)
                goto error;
        }
 
-       buf = icalcomponent_as_ical_string_r (priv->icalcomp);
+       buf = i_cal_component_as_ical_string_r (priv->vcalendar);
        succeeded = g_output_stream_write_all (G_OUTPUT_STREAM (stream), buf, strlen (buf) * sizeof (gchar), 
NULL, NULL, &e);
        g_free (buf);
 
@@ -280,13 +278,13 @@ save (ECalBackendFile *cbfile,
 
 static void
 free_calendar_components (GHashTable *comp_uid_hash,
-                          icalcomponent *top_icomp)
+                         ICalComponent *top_icomp)
 {
        if (comp_uid_hash)
                g_hash_table_destroy (comp_uid_hash);
 
        if (top_icomp)
-               icalcomponent_free (top_icomp);
+               g_object_unref (top_icomp);
 }
 
 static void
@@ -301,9 +299,9 @@ free_calendar_data (ECalBackendFile *cbfile)
        e_intervaltree_destroy (priv->interval_tree);
        priv->interval_tree = NULL;
 
-       free_calendar_components (priv->comp_uid_hash, priv->icalcomp);
+       free_calendar_components (priv->comp_uid_hash, priv->vcalendar);
        priv->comp_uid_hash = NULL;
-       priv->icalcomp = NULL;
+       priv->vcalendar = NULL;
 
        g_list_free (priv->comp);
        priv->comp = NULL;
@@ -354,6 +352,7 @@ e_cal_backend_file_finalize (GObject *object)
        g_mutex_clear (&priv->refresh_lock);
 
        g_rec_mutex_clear (&priv->idle_save_rmutex);
+       g_hash_table_destroy (priv->cached_timezones);
 
        g_free (priv->path);
        g_free (priv->file_name);
@@ -362,8 +361,6 @@ e_cal_backend_file_finalize (GObject *object)
        G_OBJECT_CLASS (e_cal_backend_file_parent_class)->finalize (object);
 }
 
-
-
 /* Looks up an component by its UID on the backend's component hash table
  * and returns TRUE if any event (regardless whether it is the master or a child)
  * with that UID exists */
@@ -380,28 +377,13 @@ uid_in_use (ECalBackendFile *cbfile,
        return obj_data != NULL;
 }
 
-
-
-static icalproperty *
+static ICalProperty *
 get_revision_property (ECalBackendFile *cbfile)
 {
-       icalproperty *prop = NULL;
-
-       if (cbfile->priv->icalcomp != NULL)
-               prop = icalcomponent_get_first_property (
-                       cbfile->priv->icalcomp, ICAL_X_PROPERTY);
-
-       while (prop != NULL) {
-               const gchar *name = icalproperty_get_x_name (prop);
-
-               if (name && strcmp (name, ECAL_REVISION_X_PROP) == 0)
-                       return prop;
-
-               prop = icalcomponent_get_next_property (
-                       cbfile->priv->icalcomp, ICAL_X_PROPERTY);
-       }
+       if (!cbfile->priv->vcalendar)
+               return NULL;
 
-       return NULL;
+       return e_cal_util_component_find_x_property (cbfile->priv->vcalendar, ECAL_REVISION_X_PROP);
 }
 
 static gchar *
@@ -420,27 +402,25 @@ make_revision_string (ECalBackendFile *cbfile)
        return revision;
 }
 
-static icalproperty *
+static ICalProperty *
 ensure_revision (ECalBackendFile *cbfile)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
-       if (cbfile->priv->icalcomp == NULL)
+       if (cbfile->priv->vcalendar == NULL)
                return NULL;
 
        prop = get_revision_property (cbfile);
 
-       if (prop == NULL) {
+       if (!prop) {
                gchar *revision = make_revision_string (cbfile);
 
-               prop = icalproperty_new (ICAL_X_PROPERTY);
-
-               icalproperty_set_x_name (prop, ECAL_REVISION_X_PROP);
-               icalproperty_set_x (prop, revision);
-
-               icalcomponent_add_property (cbfile->priv->icalcomp, prop);
+               e_cal_util_component_set_x_property (cbfile->priv->vcalendar, ECAL_REVISION_X_PROP, revision);
 
                g_free (revision);
+
+               prop = get_revision_property (cbfile);
+               g_warn_if_fail (prop != NULL);
        }
 
        return prop;
@@ -450,15 +430,16 @@ static void
 bump_revision (ECalBackendFile *cbfile)
 {
        /* Update the revision string */
-       icalproperty *prop = ensure_revision (cbfile);
-       gchar        *revision = make_revision_string (cbfile);
+       ICalProperty *prop = ensure_revision (cbfile);
+       gchar *revision = make_revision_string (cbfile);
 
-       icalproperty_set_x (prop, revision);
+       i_cal_property_set_x (prop, revision);
 
        e_cal_backend_notify_property_changed (E_CAL_BACKEND (cbfile),
                                              E_CAL_BACKEND_PROPERTY_REVISION,
                                              revision);
 
+       g_object_unref (prop);
        g_free (revision);
 }
 
@@ -521,15 +502,17 @@ e_cal_backend_file_get_backend_property (ECalBackend *backend,
                return prop_value;
 
        } else if (g_str_equal (prop_name, E_CAL_BACKEND_PROPERTY_REVISION)) {
-               icalproperty *prop;
-               const gchar *revision = NULL;
+               ICalProperty *prop;
+               gchar *revision = NULL;
 
-               /* This returns NULL if backend lacks an icalcomp. */
+               /* This returns NULL if backend lacks a vcalendar. */
                prop = ensure_revision (E_CAL_BACKEND_FILE (backend));
-               if (prop != NULL)
-                       revision = icalproperty_get_x (prop);
+               if (prop) {
+                       revision = g_strdup (i_cal_property_get_x (prop));
+                       g_object_unref (prop);
+               }
 
-               return g_strdup (revision);
+               return revision;
        }
 
        /* Chain up to parent's get_backend_property() method. */
@@ -537,23 +520,62 @@ e_cal_backend_file_get_backend_property (ECalBackend *backend,
                get_backend_property (backend, prop_name);
 }
 
+typedef struct _ResolveTzidData {
+       ICalComponent *vcalendar;
+       GHashTable *zones; /* gchar *tzid ~> ICalTimezone * */
+} ResolveTzidData;
+
+static void
+resolve_tzid_data_init (ResolveTzidData *rtd,
+                       ICalComponent *vcalendar)
+{
+       if (rtd) {
+               rtd->vcalendar = vcalendar;
+               rtd->zones = NULL;
+       }
+}
+
+/* Clears the content, not the structure */
+static void
+resolve_tzid_data_clear (ResolveTzidData *rtd)
+{
+       if (rtd && rtd->zones)
+               g_hash_table_destroy (rtd->zones);
+}
+
 /* function to resolve timezones */
-static icaltimezone *
-resolve_tzid (const gchar *tzid,
-              gpointer user_data)
+static ICalTimezone *
+resolve_tzid_cb (const gchar *tzid,
+                gpointer user_data,
+                GCancellable *cancellable,
+                GError **error)
 {
-       icalcomponent *vcalendar_comp = user_data;
-       icaltimezone * zone;
+       ResolveTzidData *rtd = user_data;
+       ICalTimezone *zone;
 
        if (!tzid || !tzid[0])
                return NULL;
        else if (!strcmp (tzid, "UTC"))
-               return icaltimezone_get_utc_timezone ();
+               return i_cal_timezone_get_utc_timezone ();
+
+       if (rtd->zones) {
+               zone = g_hash_table_lookup (rtd->zones, tzid);
+               if (zone)
+                       return zone;
+       }
+
+       zone = i_cal_timezone_get_builtin_timezone_from_tzid (tzid);
+       if (zone)
+               g_object_ref (zone);
+       else if (rtd->vcalendar)
+               zone = i_cal_component_get_timezone (rtd->vcalendar, tzid);
 
-       zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+       if (zone) {
+               if (!rtd->zones)
+                       rtd->zones = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
 
-       if (!zone)
-               zone = icalcomponent_get_timezone (vcalendar_comp, tzid);
+               g_hash_table_insert (rtd->zones, g_strdup (tzid), zone);
+       }
 
        return zone;
 }
@@ -620,7 +642,7 @@ static time_t
 get_rid_as_time_t (ECalComponent *comp)
 {
        ECalComponentRange *range;
-       ECalComponentDatetime *dt;
+       ECalComponentDateTime *dt;
        time_t tmt = (time_t) -1;
 
        range = e_cal_component_get_recurid (comp);
@@ -629,7 +651,7 @@ get_rid_as_time_t (ECalComponent *comp)
 
        dt = e_cal_component_range_get_datetime (range);
        if (!dt) {
-               e_cal_component_free_range (range);
+               e_cal_component_range_free (range);
                return tmt;
        }
 
@@ -648,17 +670,22 @@ add_component_to_intervaltree (ECalBackendFile *cbfile,
 {
        time_t time_start = -1, time_end = -1;
        ECalBackendFilePrivate *priv;
+       ResolveTzidData rtd;
 
        g_return_if_fail (cbfile != NULL);
        g_return_if_fail (comp != NULL);
 
        priv = cbfile->priv;
 
+       resolve_tzid_data_init (&rtd, cbfile->priv->vcalendar);
+
        e_cal_util_get_component_occur_times (
                comp, &time_start, &time_end,
-               resolve_tzid, priv->icalcomp, icaltimezone_get_utc_timezone (),
+               resolve_tzid_cb, &rtd, i_cal_timezone_get_utc_timezone (),
                e_cal_backend_get_kind (E_CAL_BACKEND (cbfile)));
 
+       resolve_tzid_data_clear (&rtd);
+
        if (time_end != -1 && time_start > time_end) {
                gchar *str = e_cal_component_get_as_string (comp);
                g_print ("Bogus component %s\n", str);
@@ -696,7 +723,7 @@ remove_component_from_intervaltree (ECalBackendFile *cbfile,
        return res;
 }
 
-/* Tries to add an icalcomponent to the file backend.  We only store the objects
+/* Tries to add an ICalComponent to the file backend.  We only store the objects
  * of the types we support; all others just remain in the toplevel component so
  * that we don't lose them.
  *
@@ -765,12 +792,12 @@ add_component (ECalBackendFile *cbfile,
        /* Put the object in the toplevel component if required */
 
        if (add_to_toplevel) {
-               icalcomponent *icalcomp;
+               ICalComponent *icomp;
 
-               icalcomp = e_cal_component_get_icalcomponent (comp);
-               g_return_if_fail (icalcomp != NULL);
+               icomp = e_cal_component_get_icalcomponent (comp);
+               g_return_if_fail (icomp != NULL);
 
-               icalcomponent_add_component (priv->icalcomp, icalcomp);
+               i_cal_component_add_component (priv->vcalendar, icomp);
        }
 }
 
@@ -780,8 +807,7 @@ remove_recurrence_cb (gpointer key,
                       gpointer value,
                       gpointer data)
 {
-       GList *l;
-       icalcomponent *icalcomp;
+       ICalComponent *icomp;
        ECalBackendFilePrivate *priv;
        ECalComponent *comp = value;
        ECalBackendFile *cbfile = data;
@@ -789,24 +815,27 @@ remove_recurrence_cb (gpointer key,
        priv = cbfile->priv;
 
        /* remove the recurrence from the top-level calendar */
-       icalcomp = e_cal_component_get_icalcomponent (comp);
-       g_return_val_if_fail (icalcomp != NULL, FALSE);
+       icomp = e_cal_component_get_icalcomponent (comp);
+       g_return_val_if_fail (icomp != NULL, FALSE);
+
+       icomp = g_object_ref (icomp);
 
        if (!remove_component_from_intervaltree (cbfile, comp)) {
                g_message (G_STRLOC " Could not remove component from interval tree!");
        }
-       icalcomponent_remove_component (priv->icalcomp, icalcomp);
+       i_cal_component_remove_component (priv->vcalendar, icomp);
+
+       g_object_unref (icomp);
 
        /* remove it from our mapping */
-       l = g_list_find (priv->comp, comp);
-       priv->comp = g_list_delete_link (priv->comp, l);
+       priv->comp = g_list_remove (priv->comp, comp);
 
        return TRUE;
 }
 
 /* Removes a component from the backend's hash and lists.  Does not perform
  * notification on the clients.  Also removes the component from the toplevel
- * icalcomponent.
+ * ICalComponent.
  */
 static void
 remove_component (ECalBackendFile *cbfile,
@@ -814,17 +843,17 @@ remove_component (ECalBackendFile *cbfile,
                   ECalBackendFileObject *obj_data)
 {
        ECalBackendFilePrivate *priv;
-       icalcomponent *icalcomp;
+       ICalComponent *icomp;
        GList *l;
 
        priv = cbfile->priv;
 
-       /* Remove the icalcomp from the toplevel */
+       /* Remove the ICalComponent from the toplevel */
        if (obj_data->full_object) {
-               icalcomp = e_cal_component_get_icalcomponent (obj_data->full_object);
-               g_return_if_fail (icalcomp != NULL);
+               icomp = e_cal_component_get_icalcomponent (obj_data->full_object);
+               g_return_if_fail (icomp != NULL);
 
-               icalcomponent_remove_component (priv->icalcomp, icalcomp);
+               i_cal_component_remove_component (priv->vcalendar, icomp);
 
                /* Remove it from our mapping */
                l = g_list_find (priv->comp, obj_data->full_object);
@@ -849,37 +878,43 @@ static void
 scan_vcalendar (ECalBackendFile *cbfile)
 {
        ECalBackendFilePrivate *priv;
-       icalcompiter iter;
+       ICalCompIter *iter;
+       ICalComponent *icomp;
 
        priv = cbfile->priv;
-       g_return_if_fail (priv->icalcomp != NULL);
+       g_return_if_fail (priv->vcalendar != NULL);
        g_return_if_fail (priv->comp_uid_hash != NULL);
 
-       for (iter = icalcomponent_begin_component (priv->icalcomp, ICAL_ANY_COMPONENT);
-            icalcompiter_deref (&iter) != NULL;
-            icalcompiter_next (&iter)) {
-               icalcomponent *icalcomp;
-               icalcomponent_kind kind;
+       iter = i_cal_component_begin_component (priv->vcalendar, I_CAL_ANY_COMPONENT);
+       icomp = iter ? i_cal_comp_iter_deref (iter) : NULL;
+       while (icomp) {
+               ICalComponentKind kind;
                ECalComponent *comp;
 
-               icalcomp = icalcompiter_deref (&iter);
+               kind = i_cal_component_isa (icomp);
 
-               kind = icalcomponent_isa (icalcomp);
+               if (kind == I_CAL_VEVENT_COMPONENT ||
+                   kind == I_CAL_VTODO_COMPONENT ||
+                   kind == I_CAL_VJOURNAL_COMPONENT) {
+                       comp = e_cal_component_new ();
 
-               if (!(kind == ICAL_VEVENT_COMPONENT
-                     || kind == ICAL_VTODO_COMPONENT
-                     || kind == ICAL_VJOURNAL_COMPONENT))
-                       continue;
-
-               comp = e_cal_component_new ();
+                       if (e_cal_component_set_icalcomponent (comp, icomp)) {
+                               /* Thus it's not freed while being used in the 'comp' */
+                               g_object_ref (icomp);
 
-               if (!e_cal_component_set_icalcomponent (comp, icalcomp))
-                       continue;
+                               check_dup_uid (cbfile, comp);
 
-               check_dup_uid (cbfile, comp);
+                               add_component (cbfile, comp, FALSE);
+                       } else {
+                               g_object_unref (comp);
+                       }
+               }
 
-               add_component (cbfile, comp, FALSE);
+               g_object_unref (icomp);
+               icomp = i_cal_comp_iter_next (iter);
        }
+
+       g_clear_object (&iter);
 }
 
 static gchar *
@@ -1099,20 +1134,22 @@ free_refresh_data (ECalBackendFile *cbfile)
 }
 
 static void
-cal_backend_file_take_icalcomp (ECalBackendFile *cbfile,
-                                icalcomponent *icalcomp)
+cal_backend_file_take_icomp (ECalBackendFile *cbfile,
+                            ICalComponent *icomp)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
-       g_warn_if_fail (cbfile->priv->icalcomp == NULL);
-       cbfile->priv->icalcomp = icalcomp;
+       g_warn_if_fail (cbfile->priv->vcalendar == NULL);
+       cbfile->priv->vcalendar = icomp;
 
        prop = ensure_revision (cbfile);
 
        e_cal_backend_notify_property_changed (
                E_CAL_BACKEND (cbfile),
                E_CAL_BACKEND_PROPERTY_REVISION,
-               icalproperty_get_x (prop));
+               i_cal_property_get_x (prop));
+
+       g_clear_object (&prop);
 }
 
 /* Parses an open iCalendar file and loads it into the backend */
@@ -1122,14 +1159,14 @@ open_cal (ECalBackendFile *cbfile,
           GError **perror)
 {
        ECalBackendFilePrivate *priv;
-       icalcomponent *icalcomp;
+       ICalComponent *icomp;
 
        priv = cbfile->priv;
 
        free_refresh_data (cbfile);
 
-       icalcomp = e_cal_util_parse_ics_file (uristr);
-       if (!icalcomp) {
+       icomp = e_cal_util_parse_ics_file (uristr);
+       if (!icomp) {
                g_propagate_error (perror, e_data_cal_create_error_fmt (OtherError, "Cannot parse ISC file 
'%s'", uristr));
                return;
        }
@@ -1138,8 +1175,8 @@ open_cal (ECalBackendFile *cbfile,
         * individual components as well?
         */
 
-       if (icalcomponent_isa (icalcomp) != ICAL_VCALENDAR_COMPONENT) {
-               icalcomponent_free (icalcomp);
+       if (i_cal_component_isa (icomp) != I_CAL_VCALENDAR_COMPONENT) {
+               g_object_unref (icomp);
 
                g_propagate_error (perror, e_data_cal_create_error_fmt (OtherError, "File '%s' is not v 
VCALENDAR component", uristr));
                return;
@@ -1147,7 +1184,7 @@ open_cal (ECalBackendFile *cbfile,
 
        g_rec_mutex_lock (&priv->idle_save_rmutex);
 
-       cal_backend_file_take_icalcomp (cbfile, icalcomp);
+       cal_backend_file_take_icomp (cbfile, icomp);
        priv->path = uri_to_path (E_CAL_BACKEND (cbfile));
 
        priv->comp_uid_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_object_data);
@@ -1216,7 +1253,7 @@ notify_adds_modifies_cb (gpointer key,
                if (!old_obj_data->full_object || !new_obj_data->full_object)
                        return;
 
-               /* There should be better ways to compare an icalcomponent
+               /* There should be better ways to compare an ICalComponent
                 * than serializing and comparing the strings...
                 */
                old_obj_str = e_cal_component_get_as_string (old_obj_data->full_object);
@@ -1252,13 +1289,13 @@ reload_cal (ECalBackendFile *cbfile,
             GError **perror)
 {
        ECalBackendFilePrivate *priv;
-       icalcomponent *icalcomp, *icalcomp_old;
+       ICalComponent *icomp, *icomp_old;
        GHashTable *comp_uid_hash_old;
 
        priv = cbfile->priv;
 
-       icalcomp = e_cal_util_parse_ics_file (uristr);
-       if (!icalcomp) {
+       icomp = e_cal_util_parse_ics_file (uristr);
+       if (!icomp) {
                g_propagate_error (perror, e_data_cal_create_error_fmt (OtherError, "Cannot parse ISC file 
'%s'", uristr));
                return;
        }
@@ -1267,8 +1304,8 @@ reload_cal (ECalBackendFile *cbfile,
         * individual components as well?
         */
 
-       if (icalcomponent_isa (icalcomp) != ICAL_VCALENDAR_COMPONENT) {
-               icalcomponent_free (icalcomp);
+       if (i_cal_component_isa (icomp) != I_CAL_VCALENDAR_COMPONENT) {
+               g_object_unref (icomp);
 
                g_propagate_error (perror, e_data_cal_create_error_fmt (OtherError, "File '%s' is not v 
VCALENDAR component", uristr));
                return;
@@ -1278,8 +1315,8 @@ reload_cal (ECalBackendFile *cbfile,
 
        g_rec_mutex_lock (&priv->idle_save_rmutex);
 
-       icalcomp_old = priv->icalcomp;
-       priv->icalcomp = NULL;
+       icomp_old = priv->vcalendar;
+       priv->vcalendar = NULL;
 
        comp_uid_hash_old = priv->comp_uid_hash;
        priv->comp_uid_hash = NULL;
@@ -1288,7 +1325,7 @@ reload_cal (ECalBackendFile *cbfile,
 
        free_calendar_data (cbfile);
 
-       cal_backend_file_take_icalcomp (cbfile, icalcomp);
+       cal_backend_file_take_icomp (cbfile, icomp);
 
        priv->comp_uid_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_object_data);
        priv->interval_tree = e_intervaltree_new ();
@@ -1304,7 +1341,7 @@ reload_cal (ECalBackendFile *cbfile,
 
        /* Free old data */
 
-       free_calendar_components (comp_uid_hash_old, icalcomp_old);
+       free_calendar_components (comp_uid_hash_old, icomp_old);
 }
 
 static void
@@ -1314,7 +1351,7 @@ create_cal (ECalBackendFile *cbfile,
 {
        gchar *dirname;
        ECalBackendFilePrivate *priv;
-       icalcomponent *icalcomp;
+       ICalComponent *icomp;
 
        free_refresh_data (cbfile);
 
@@ -1333,8 +1370,8 @@ create_cal (ECalBackendFile *cbfile,
        g_rec_mutex_lock (&priv->idle_save_rmutex);
 
        /* Create the new calendar information */
-       icalcomp = e_cal_util_new_top_level ();
-       cal_backend_file_take_icalcomp (cbfile, icalcomp);
+       icomp = e_cal_util_new_top_level ();
+       cal_backend_file_take_icomp (cbfile, icomp);
 
        /* Create our internal data */
        priv->comp_uid_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_object_data);
@@ -1476,11 +1513,11 @@ add_detached_recur_to_vcalendar (gpointer key,
                                  gpointer user_data)
 {
        ECalComponent *recurrence = value;
-       icalcomponent *vcalendar = user_data;
+       ICalComponent *vcalendar = user_data;
 
-       icalcomponent_add_component (
+       i_cal_component_take_component (
                vcalendar,
-               icalcomponent_new_clone (e_cal_component_get_icalcomponent (recurrence)));
+               i_cal_component_new_clone (e_cal_component_get_icalcomponent (recurrence)));
 }
 
 /* Get_object_component handler for the file backend */
@@ -1500,7 +1537,7 @@ e_cal_backend_file_get_object (ECalBackendSync *backend,
        cbfile = E_CAL_BACKEND_FILE (backend);
        priv = cbfile->priv;
 
-       if (priv->icalcomp == NULL) {
+       if (priv->vcalendar == NULL) {
                g_set_error_literal (
                        error, E_CAL_CLIENT_ERROR,
                        E_CAL_CLIENT_ERROR_INVALID_OBJECT,
@@ -1528,8 +1565,8 @@ e_cal_backend_file_get_object (ECalBackendSync *backend,
                if (comp) {
                        *object = e_cal_component_get_as_string (comp);
                } else {
-                       icalcomponent *icalcomp;
-                       struct icaltimetype itt;
+                       ICalComponent *icomp;
+                       ICalTimetype *itt;
 
                        if (!obj_data->full_object) {
                                g_rec_mutex_unlock (&priv->idle_save_rmutex);
@@ -1537,39 +1574,41 @@ e_cal_backend_file_get_object (ECalBackendSync *backend,
                                return;
                        }
 
-                       itt = icaltime_from_string (rid);
-                       icalcomp = e_cal_util_construct_instance (
+                       itt = i_cal_time_from_string (rid);
+                       icomp = e_cal_util_construct_instance (
                                e_cal_component_get_icalcomponent (obj_data->full_object),
                                itt);
-                       if (!icalcomp) {
+                       g_object_unref (itt);
+
+                       if (!icomp) {
                                g_rec_mutex_unlock (&priv->idle_save_rmutex);
                                g_propagate_error (error, EDC_ERROR (ObjectNotFound));
                                return;
                        }
 
-                       *object = icalcomponent_as_ical_string_r (icalcomp);
+                       *object = i_cal_component_as_ical_string_r (icomp);
 
-                       icalcomponent_free (icalcomp);
+                       g_object_unref (icomp);
                }
        } else {
                if (g_hash_table_size (obj_data->recurrences) > 0) {
-                       icalcomponent *icalcomp;
+                       ICalComponent *icomp;
 
                        /* if we have detached recurrences, return a VCALENDAR */
-                       icalcomp = e_cal_util_new_top_level ();
+                       icomp = e_cal_util_new_top_level ();
 
                        /* detached recurrences don't have full_object */
                        if (obj_data->full_object)
-                               icalcomponent_add_component (
-                                       icalcomp,
-                                       icalcomponent_new_clone (e_cal_component_get_icalcomponent 
(obj_data->full_object)));
+                               i_cal_component_take_component (
+                                       icomp,
+                                       i_cal_component_new_clone (e_cal_component_get_icalcomponent 
(obj_data->full_object)));
 
                        /* add all detached recurrences */
-                       g_hash_table_foreach (obj_data->recurrences, (GHFunc) 
add_detached_recur_to_vcalendar, icalcomp);
+                       g_hash_table_foreach (obj_data->recurrences, (GHFunc) 
add_detached_recur_to_vcalendar, icomp);
 
-                       *object = icalcomponent_as_ical_string_r (icalcomp);
+                       *object = i_cal_component_as_ical_string_r (icomp);
 
-                       icalcomponent_free (icalcomp);
+                       g_object_unref (icomp);
                } else if (obj_data->full_object)
                        *object = e_cal_component_get_as_string (obj_data->full_object);
        }
@@ -1586,24 +1625,26 @@ e_cal_backend_file_add_timezone (ECalBackendSync *backend,
                                  GError **error)
 {
        ETimezoneCache *timezone_cache;
-       icalcomponent *tz_comp;
+       ICalComponent *tz_comp;
 
        timezone_cache = E_TIMEZONE_CACHE (backend);
 
-       tz_comp = icalparser_parse_string (tzobj);
+       tz_comp = i_cal_parser_parse_string (tzobj);
        if (!tz_comp) {
                g_propagate_error (error, EDC_ERROR (InvalidObject));
                return;
        }
 
-       if (icalcomponent_isa (tz_comp) == ICAL_VTIMEZONE_COMPONENT) {
-               icaltimezone *zone;
+       if (i_cal_component_isa (tz_comp) == I_CAL_VTIMEZONE_COMPONENT) {
+               ICalTimezone *zone;
 
-               zone = icaltimezone_new ();
-               icaltimezone_set_component (zone, tz_comp);
-               e_timezone_cache_add_timezone (timezone_cache, zone);
-               icaltimezone_free (zone, 1);
+               zone = i_cal_timezone_new ();
+               if (i_cal_timezone_set_component (zone, tz_comp))
+                       e_timezone_cache_add_timezone (timezone_cache, zone);
+               g_object_unref (zone);
        }
+
+       g_object_unref (tz_comp);
 }
 
 typedef struct {
@@ -1757,36 +1798,34 @@ e_cal_backend_file_get_object_list (ECalBackendSync *backend,
 
 static void
 add_attach_uris (GSList **attachment_uris,
-                 icalcomponent *icalcomp)
+                ICalComponent *icomp)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
        g_return_if_fail (attachment_uris != NULL);
-       g_return_if_fail (icalcomp != NULL);
+       g_return_if_fail (icomp != NULL);
 
-       for (prop = icalcomponent_get_first_property (icalcomp, ICAL_ATTACH_PROPERTY);
+       for (prop = i_cal_component_get_first_property (icomp, I_CAL_ATTACH_PROPERTY);
             prop;
-            prop = icalcomponent_get_next_property (icalcomp, ICAL_ATTACH_PROPERTY)) {
-               icalattach *attach = icalproperty_get_attach (prop);
+            g_object_unref (prop), prop = i_cal_component_get_next_property (icomp, I_CAL_ATTACH_PROPERTY)) {
+               ICalAttach *attach = i_cal_property_get_attach (prop);
 
-               if (attach && icalattach_get_is_url (attach)) {
+               if (attach && i_cal_attach_get_is_url (attach)) {
                        const gchar *url;
 
-                       url = icalattach_get_url (attach);
+                       url = i_cal_attach_get_url (attach);
                        if (url) {
-                               gsize buf_size;
                                gchar *buf;
 
-                               buf_size = strlen (url);
-                               buf = g_malloc0 (buf_size + 1);
-
-                               icalvalue_decode_ical_string (url, buf, buf_size);
+                               buf = i_cal_value_decode_ical_string (url);
 
                                *attachment_uris = g_slist_prepend (*attachment_uris, g_strdup (buf));
 
                                g_free (buf);
                        }
                }
+
+               g_clear_object (&attach);
        }
 }
 
@@ -1836,8 +1875,8 @@ e_cal_backend_file_get_attachment_uris (ECalBackendSync *backend,
                if (comp) {
                        add_attach_uris (attachment_uris, e_cal_component_get_icalcomponent (comp));
                } else {
-                       icalcomponent *icalcomp;
-                       struct icaltimetype itt;
+                       ICalComponent *icomp;
+                       ICalTimetype *itt;
 
                        if (!obj_data->full_object) {
                                g_rec_mutex_unlock (&priv->idle_save_rmutex);
@@ -1845,19 +1884,20 @@ e_cal_backend_file_get_attachment_uris (ECalBackendSync *backend,
                                return;
                        }
 
-                       itt = icaltime_from_string (rid);
-                       icalcomp = e_cal_util_construct_instance (
+                       itt = i_cal_time_from_string (rid);
+                       icomp = e_cal_util_construct_instance (
                                e_cal_component_get_icalcomponent (obj_data->full_object),
                                itt);
-                       if (!icalcomp) {
+                       g_object_unref (itt);
+                       if (!icomp) {
                                g_rec_mutex_unlock (&priv->idle_save_rmutex);
                                g_propagate_error (error, EDC_ERROR (ObjectNotFound));
                                return;
                        }
 
-                       add_attach_uris (attachment_uris, icalcomp);
+                       add_attach_uris (attachment_uris, icomp);
 
-                       icalcomponent_free (icalcomp);
+                       g_object_unref (icomp);
                }
        } else {
                if (g_hash_table_size (obj_data->recurrences) > 0) {
@@ -1966,76 +2006,82 @@ e_cal_backend_file_start_view (ECalBackend *backend,
 }
 
 static gboolean
-free_busy_instance (ECalComponent *comp,
-                    time_t instance_start,
-                    time_t instance_end,
-                    gpointer data)
+free_busy_instance (ICalComponent *icomp,
+                   ICalTimetype *instance_start,
+                   ICalTimetype *instance_end,
+                   gpointer user_data,
+                   GCancellable *cancellable,
+                   GError **error)
 {
-       icalcomponent *vfb = data;
-       icalproperty *prop;
-       icalparameter *param;
-       struct icalperiodtype ipt;
-       icaltimezone *utc_zone;
+       ICalComponent *vfb = user_data;
+       ICalProperty *prop;
+       ICalParameter *param;
+       ICalPeriodType *ipt;
        const gchar *summary, *location;
 
-       utc_zone = icaltimezone_get_utc_timezone ();
-
-       ipt.start = icaltime_from_timet_with_zone (instance_start, FALSE, utc_zone);
-       ipt.end = icaltime_from_timet_with_zone (instance_end, FALSE, utc_zone);
-       ipt.duration = icaldurationtype_null_duration ();
+       ipt = i_cal_period_type_null_period ();
+       i_cal_period_type_set_start (ipt, instance_start);
+       i_cal_period_type_set_end (ipt, instance_end);
 
         /* add busy information to the vfb component */
-       prop = icalproperty_new (ICAL_FREEBUSY_PROPERTY);
-       icalproperty_set_freebusy (prop, ipt);
+       prop = i_cal_property_new (I_CAL_FREEBUSY_PROPERTY);
+       i_cal_property_set_freebusy (prop, ipt);
+       g_object_unref (ipt);
 
-       param = icalparameter_new_fbtype (ICAL_FBTYPE_BUSY);
-       icalproperty_add_parameter (prop, param);
+       param = i_cal_parameter_new_fbtype (I_CAL_FBTYPE_BUSY);
+       i_cal_property_take_parameter (prop, param);
 
-       summary = icalcomponent_get_summary (e_cal_component_get_icalcomponent (comp));
+       summary = i_cal_component_get_summary (icomp);
        if (summary && *summary)
-               icalproperty_set_parameter_from_string (prop, "X-SUMMARY", summary);
-       location = icalcomponent_get_location (e_cal_component_get_icalcomponent (comp));
+               i_cal_property_set_parameter_from_string (prop, "X-SUMMARY", summary);
+       location = i_cal_component_get_location (icomp);
        if (location && *location)
-               icalproperty_set_parameter_from_string (prop, "X-LOCATION", location);
+               i_cal_property_set_parameter_from_string (prop, "X-LOCATION", location);
 
-       icalcomponent_add_property (vfb, prop);
+       i_cal_component_take_property (vfb, prop);
 
        return TRUE;
 }
 
-static icalcomponent *
+static ICalComponent *
 create_user_free_busy (ECalBackendFile *cbfile,
                        const gchar *address,
                        const gchar *cn,
                        time_t start,
-                       time_t end)
+                       time_t end,
+                      GCancellable *cancellable)
 {
        ECalBackendFilePrivate *priv;
        GList *l;
-       icalcomponent *vfb;
-       icaltimezone *utc_zone;
+       ICalComponent *vfb;
+       ICalTimezone *utc_zone;
+       ICalTimetype *starttt, *endtt;
        ECalBackendSExp *obj_sexp;
        gchar *query, *iso_start, *iso_end;
 
        priv = cbfile->priv;
 
        /* create the (unique) VFREEBUSY object that we'll return */
-       vfb = icalcomponent_new_vfreebusy ();
+       vfb = i_cal_component_new_vfreebusy ();
        if (address != NULL) {
-               icalproperty *prop;
-               icalparameter *param;
+               ICalProperty *prop;
+               ICalParameter *param;
 
-               prop = icalproperty_new_organizer (address);
+               prop = i_cal_property_new_organizer (address);
                if (prop != NULL && cn != NULL) {
-                       param = icalparameter_new_cn (cn);
-                       icalproperty_add_parameter (prop, param);
+                       param = i_cal_parameter_new_cn (cn);
+                       i_cal_property_take_parameter (prop, param);
                }
                if (prop != NULL)
-                       icalcomponent_add_property (vfb, prop);
+                       i_cal_component_take_property (vfb, prop);
        }
-       utc_zone = icaltimezone_get_utc_timezone ();
-       icalcomponent_set_dtstart (vfb, icaltime_from_timet_with_zone (start, FALSE, utc_zone));
-       icalcomponent_set_dtend (vfb, icaltime_from_timet_with_zone (end, FALSE, utc_zone));
+       utc_zone = i_cal_timezone_get_utc_timezone ();
+
+       starttt = i_cal_time_from_timet_with_zone (start, FALSE, utc_zone);
+       i_cal_component_set_dtstart (vfb, starttt);
+
+       endtt = i_cal_time_from_timet_with_zone (end, FALSE, utc_zone);
+       i_cal_component_set_dtend (vfb, endtt);
 
        /* add all objects in the given interval */
        iso_start = isodate_from_time_t (start);
@@ -2048,43 +2094,56 @@ create_user_free_busy (ECalBackendFile *cbfile,
        g_free (iso_start);
        g_free (iso_end);
 
-       if (!obj_sexp)
+       if (!obj_sexp) {
+               g_clear_object (&starttt);
+               g_clear_object (&endtt);
                return vfb;
+       }
 
        for (l = priv->comp; l; l = l->next) {
                ECalComponent *comp = l->data;
-               icalcomponent *icalcomp, *vcalendar_comp;
-               icalproperty *prop;
+               ICalComponent *icomp, *vcalendar_comp;
+               ICalProperty *prop;
+               ResolveTzidData rtd;
 
-               icalcomp = e_cal_component_get_icalcomponent (comp);
-               if (!icalcomp)
+               icomp = e_cal_component_get_icalcomponent (comp);
+               if (!icomp)
                        continue;
 
                /* If the event is TRANSPARENT, skip it. */
-               prop = icalcomponent_get_first_property (
-                       icalcomp,
-                       ICAL_TRANSP_PROPERTY);
+               prop = i_cal_component_get_first_property (icomp, I_CAL_TRANSP_PROPERTY);
                if (prop) {
-                       icalproperty_transp transp_val = icalproperty_get_transp (prop);
-                       if (transp_val == ICAL_TRANSP_TRANSPARENT ||
-                           transp_val == ICAL_TRANSP_TRANSPARENTNOCONFLICT)
+                       ICalPropertyTransp transp_val = i_cal_property_get_transp (prop);
+
+                       g_object_unref (prop);
+
+                       if (transp_val == I_CAL_TRANSP_TRANSPARENT ||
+                           transp_val == I_CAL_TRANSP_TRANSPARENTNOCONFLICT)
                                continue;
                }
 
-               if (!e_cal_backend_sexp_match_comp (
-                       obj_sexp, l->data,
-                       E_TIMEZONE_CACHE (cbfile)))
+               if (!e_cal_backend_sexp_match_comp (obj_sexp, comp, E_TIMEZONE_CACHE (cbfile)))
                        continue;
 
-               vcalendar_comp = icalcomponent_get_parent (icalcomp);
-               e_cal_recur_generate_instances (
-                       comp, start, end,
+               vcalendar_comp = i_cal_component_get_parent (icomp);
+
+               resolve_tzid_data_init (&rtd, vcalendar_comp);
+
+               e_cal_recur_generate_instances_sync (
+                       e_cal_component_get_icalcomponent (comp), starttt, endtt,
                        free_busy_instance,
                        vfb,
-                       resolve_tzid,
-                       vcalendar_comp,
-                       icaltimezone_get_utc_timezone ());
+                       resolve_tzid_cb,
+                       &rtd,
+                       i_cal_timezone_get_utc_timezone (),
+                       cancellable, NULL);
+
+               resolve_tzid_data_clear (&rtd);
+               g_clear_object (&vcalendar_comp);
        }
+
+       g_clear_object (&starttt);
+       g_clear_object (&endtt);
        g_object_unref (obj_sexp);
 
        return vfb;
@@ -2105,14 +2164,14 @@ e_cal_backend_file_get_free_busy (ECalBackendSync *backend,
        ECalBackendFile *cbfile;
        ECalBackendFilePrivate *priv;
        gchar *address, *name;
-       icalcomponent *vfb;
+       ICalComponent *vfb;
        gchar *calobj;
        const GSList *l;
 
        cbfile = E_CAL_BACKEND_FILE (backend);
        priv = cbfile->priv;
 
-       if (priv->icalcomp == NULL) {
+       if (priv->vcalendar == NULL) {
                g_set_error_literal (
                        error, E_CAL_CLIENT_ERROR,
                        E_CAL_CLIENT_ERROR_NO_SUCH_CALENDAR,
@@ -2129,10 +2188,10 @@ e_cal_backend_file_get_free_busy (ECalBackendSync *backend,
 
        if (users == NULL) {
                if (e_cal_backend_mail_account_get_default (registry, &address, &name)) {
-                       vfb = create_user_free_busy (cbfile, address, name, start, end);
-                       calobj = icalcomponent_as_ical_string_r (vfb);
+                       vfb = create_user_free_busy (cbfile, address, name, start, end, cancellable);
+                       calobj = i_cal_component_as_ical_string_r (vfb);
                        *freebusy = g_slist_append (*freebusy, calobj);
-                       icalcomponent_free (vfb);
+                       g_object_unref (vfb);
                        g_free (address);
                        g_free (name);
                }
@@ -2140,10 +2199,10 @@ e_cal_backend_file_get_free_busy (ECalBackendSync *backend,
                for (l = users; l != NULL; l = l->next ) {
                        address = l->data;
                        if (e_cal_backend_mail_account_is_valid (registry, address, &name)) {
-                               vfb = create_user_free_busy (cbfile, address, name, start, end);
-                               calobj = icalcomponent_as_ical_string_r (vfb);
+                               vfb = create_user_free_busy (cbfile, address, name, start, end, cancellable);
+                               calobj = i_cal_component_as_ical_string_r (vfb);
                                *freebusy = g_slist_append (*freebusy, calobj);
-                               icalcomponent_free (vfb);
+                               g_object_unref (vfb);
                                g_free (name);
                        }
                }
@@ -2206,13 +2265,13 @@ e_cal_backend_file_create_objects (ECalBackendSync *backend,
 {
        ECalBackendFile *cbfile;
        ECalBackendFilePrivate *priv;
-       GSList *icalcomps = NULL;
+       GSList *icomps = NULL;
        const GSList *l;
 
        cbfile = E_CAL_BACKEND_FILE (backend);
        priv = cbfile->priv;
 
-       if (priv->icalcomp == NULL) {
+       if (priv->vcalendar == NULL) {
                g_set_error_literal (
                        error, E_CAL_CLIENT_ERROR,
                        E_CAL_CLIENT_ERROR_NO_SUCH_CALENDAR,
@@ -2228,81 +2287,84 @@ e_cal_backend_file_create_objects (ECalBackendSync *backend,
 
        /* First step, parse input strings and do uid verification: may fail */
        for (l = in_calobjs; l; l = l->next) {
-               icalcomponent *icalcomp;
+               ICalComponent *icomp;
                const gchar *comp_uid;
 
                /* Parse the icalendar text */
-               icalcomp = icalparser_parse_string ((gchar *) l->data);
-               if (!icalcomp) {
-                       g_slist_free_full (icalcomps, (GDestroyNotify) icalcomponent_free);
+               icomp = i_cal_parser_parse_string ((gchar *) l->data);
+               if (!icomp) {
+                       g_slist_free_full (icomps, g_object_unref);
                        g_rec_mutex_unlock (&priv->idle_save_rmutex);
                        g_propagate_error (error, EDC_ERROR (InvalidObject));
                        return;
                }
 
                /* Append icalcomponent to icalcomps */
-               icalcomps = g_slist_prepend (icalcomps, icalcomp);
+               icomps = g_slist_prepend (icomps, icomp);
 
                /* Check kind with the parent */
-               if (icalcomponent_isa (icalcomp) != e_cal_backend_get_kind (E_CAL_BACKEND (backend))) {
-                       g_slist_free_full (icalcomps, (GDestroyNotify) icalcomponent_free);
+               if (i_cal_component_isa (icomp) != e_cal_backend_get_kind (E_CAL_BACKEND (backend))) {
+                       g_slist_free_full (icomps, g_object_unref);
                        g_rec_mutex_unlock (&priv->idle_save_rmutex);
                        g_propagate_error (error, EDC_ERROR (InvalidObject));
                        return;
                }
 
                /* Get the UID */
-               comp_uid = icalcomponent_get_uid (icalcomp);
+               comp_uid = i_cal_component_get_uid (icomp);
                if (!comp_uid) {
                        gchar *new_uid;
 
                        new_uid = e_util_generate_uid ();
                        if (!new_uid) {
-                               g_slist_free_full (icalcomps, (GDestroyNotify) icalcomponent_free);
+                               g_slist_free_full (icomps, g_object_unref);
                                g_rec_mutex_unlock (&priv->idle_save_rmutex);
                                g_propagate_error (error, EDC_ERROR (InvalidObject));
                                return;
                        }
 
-                       icalcomponent_set_uid (icalcomp, new_uid);
-                       comp_uid = icalcomponent_get_uid (icalcomp);
+                       i_cal_component_set_uid (icomp, new_uid);
+                       comp_uid = i_cal_component_get_uid (icomp);
 
                        g_free (new_uid);
                }
 
                /* check that the object is not in our cache */
                if (uid_in_use (cbfile, comp_uid)) {
-                       g_slist_free_full (icalcomps, (GDestroyNotify) icalcomponent_free);
+                       g_slist_free_full (icomps, g_object_unref);
                        g_rec_mutex_unlock (&priv->idle_save_rmutex);
                        g_propagate_error (error, EDC_ERROR (ObjectIdAlreadyExists));
                        return;
                }
        }
 
-       icalcomps = g_slist_reverse (icalcomps);
+       icomps = g_slist_reverse (icomps);
 
        /* Second step, add the objects */
-       for (l = icalcomps; l; l = l->next) {
+       for (l = icomps; l; l = l->next) {
                ECalComponent *comp;
-               struct icaltimetype current;
-               icalcomponent *icalcomp = l->data;
+               ICalTimetype *current;
+               ICalComponent *icomp = l->data;
 
                /* Create the cal component */
-               comp = e_cal_component_new ();
-               e_cal_component_set_icalcomponent (comp, icalcomp);
+               comp = e_cal_component_new_from_icalcomponent (icomp);
+               if (!comp)
+                       continue;
 
                /* Set the created and last modified times on the component, if not there already */
-               current = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
+               current = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
 
-               if (!icalcomponent_get_first_property (icalcomp, ICAL_CREATED_PROPERTY)) {
+               if (!e_cal_util_component_has_property (icomp, I_CAL_CREATED_PROPERTY)) {
                        /* Update both when CREATED is missing, to make sure the LAST-MODIFIED
                           is not before CREATED */
-                       e_cal_component_set_created (comp, &current);
-                       e_cal_component_set_last_modified (comp, &current);
-               } else if (!icalcomponent_get_first_property (icalcomp, ICAL_LASTMODIFIED_PROPERTY)) {
-                       e_cal_component_set_last_modified (comp, &current);
+                       e_cal_component_set_created (comp, current);
+                       e_cal_component_set_last_modified (comp, current);
+               } else if (!e_cal_util_component_has_property (icomp, I_CAL_LASTMODIFIED_PROPERTY)) {
+                       e_cal_component_set_last_modified (comp, current);
                }
 
+               g_object_unref (current);
+
                /* sanitize the component*/
                sanitize_component (cbfile, comp);
 
@@ -2311,12 +2373,12 @@ e_cal_backend_file_create_objects (ECalBackendSync *backend,
 
                /* Keep the UID and the modified component to return them later */
                if (uids)
-                       *uids = g_slist_prepend (*uids, g_strdup (icalcomponent_get_uid (icalcomp)));
+                       *uids = g_slist_prepend (*uids, g_strdup (i_cal_component_get_uid (icomp)));
 
                *new_components = g_slist_prepend (*new_components, e_cal_component_clone (comp));
        }
 
-       g_slist_free (icalcomps);
+       g_slist_free (icomps);
 
        /* Save the file */
        save (cbfile, TRUE);
@@ -2342,18 +2404,22 @@ remove_object_instance_cb (gpointer key,
                            gpointer user_data)
 {
        time_t fromtt, instancett;
+       ICalTimetype *itt;
        ECalComponent *instance = value;
        RemoveRecurrenceData *rrdata = user_data;
 
-       fromtt = icaltime_as_timet (icaltime_from_string (rrdata->rid));
+       itt = i_cal_time_from_string (rrdata->rid);
+       fromtt = i_cal_time_as_timet (itt);
+       g_object_unref (itt);
+
        instancett = get_rid_as_time_t (instance);
 
        if (fromtt > 0 && instancett > 0) {
                if ((rrdata->mod == E_CAL_OBJ_MOD_THIS_AND_PRIOR && instancett <= fromtt) ||
                    (rrdata->mod == E_CAL_OBJ_MOD_THIS_AND_FUTURE && instancett >= fromtt)) {
                        /* remove the component from our data */
-                       icalcomponent_remove_component (
-                               rrdata->cbfile->priv->icalcomp,
+                       i_cal_component_remove_component (
+                               rrdata->cbfile->priv->vcalendar,
                                e_cal_component_get_icalcomponent (instance));
                        rrdata->cbfile->priv->comp = g_list_remove (rrdata->cbfile->priv->comp, instance);
 
@@ -2378,13 +2444,14 @@ e_cal_backend_file_modify_objects (ECalBackendSync *backend,
 {
        ECalBackendFile *cbfile;
        ECalBackendFilePrivate *priv;
-       GSList *icalcomps = NULL;
+       GSList *icomps = NULL;
        const GSList *l;
+       ResolveTzidData rtd;
 
        cbfile = E_CAL_BACKEND_FILE (backend);
        priv = cbfile->priv;
 
-       if (priv->icalcomp == NULL) {
+       if (priv->vcalendar == NULL) {
                g_set_error_literal (
                        error, E_CAL_CLIENT_ERROR,
                        E_CAL_CLIENT_ERROR_NO_SUCH_CALENDAR,
@@ -2393,6 +2460,8 @@ e_cal_backend_file_modify_objects (ECalBackendSync *backend,
                return;
        }
 
+       resolve_tzid_data_init (&rtd, priv->vcalendar);
+
        switch (mod) {
        case E_CAL_OBJ_MOD_THIS:
        case E_CAL_OBJ_MOD_THIS_AND_PRIOR:
@@ -2414,63 +2483,65 @@ e_cal_backend_file_modify_objects (ECalBackendSync *backend,
        /* First step, parse input strings and do uid verification: may fail */
        for (l = calobjs; l; l = l->next) {
                const gchar *comp_uid;
-               icalcomponent *icalcomp;
+               ICalComponent *icomp;
 
-               /* Parse the icalendar text */
-               icalcomp = icalparser_parse_string (l->data);
-               if (!icalcomp) {
-                       g_slist_free_full (icalcomps, (GDestroyNotify) icalcomponent_free);
+               /* Parse the iCalendar text */
+               icomp = i_cal_parser_parse_string (l->data);
+               if (!icomp) {
+                       g_slist_free_full (icomps, g_object_unref);
                        g_rec_mutex_unlock (&priv->idle_save_rmutex);
                        g_propagate_error (error, EDC_ERROR (InvalidObject));
                        return;
                }
 
-               icalcomps = g_slist_prepend (icalcomps, icalcomp);
+               icomps = g_slist_prepend (icomps, icomp);
 
                /* Check kind with the parent */
-               if (icalcomponent_isa (icalcomp) != e_cal_backend_get_kind (E_CAL_BACKEND (backend))) {
-                       g_slist_free_full (icalcomps, (GDestroyNotify) icalcomponent_free);
+               if (i_cal_component_isa (icomp) != e_cal_backend_get_kind (E_CAL_BACKEND (backend))) {
+                       g_slist_free_full (icomps, g_object_unref);
                        g_rec_mutex_unlock (&priv->idle_save_rmutex);
                        g_propagate_error (error, EDC_ERROR (InvalidObject));
                        return;
                }
 
                /* Get the uid */
-               comp_uid = icalcomponent_get_uid (icalcomp);
+               comp_uid = i_cal_component_get_uid (icomp);
 
                /* Get the object from our cache */
                if (!g_hash_table_lookup (priv->comp_uid_hash, comp_uid)) {
-                       g_slist_free_full (icalcomps, (GDestroyNotify) icalcomponent_free);
+                       g_slist_free_full (icomps, g_object_unref);
                        g_rec_mutex_unlock (&priv->idle_save_rmutex);
                        g_propagate_error (error, EDC_ERROR (ObjectNotFound));
                        return;
                }
        }
 
-       icalcomps = g_slist_reverse (icalcomps);
+       icomps = g_slist_reverse (icomps);
 
        /* Second step, update the objects */
-       for (l = icalcomps; l; l = l->next) {
-               struct icaltimetype current;
+       for (l = icomps; l; l = l->next) {
+               ICalTimetype *current;
                RemoveRecurrenceData rrdata;
                GList *detached = NULL;
                gchar *rid = NULL;
-               gchar *real_rid;
                const gchar *comp_uid;
-               icalcomponent * icalcomp = l->data, *split_icalcomp = NULL;
+               ICalComponent * icomp = l->data, *split_icomp = NULL;
                ECalComponent *comp, *recurrence;
                ECalBackendFileObject *obj_data;
-
-               comp_uid = icalcomponent_get_uid (icalcomp);
-               obj_data = g_hash_table_lookup (priv->comp_uid_hash, comp_uid);
+               gpointer value;
 
                /* Create the cal component */
-               comp = e_cal_component_new ();
-               e_cal_component_set_icalcomponent (comp, icalcomp);
+               comp = e_cal_component_new_from_icalcomponent (icomp);
+               if (!comp)
+                       continue;
+
+               comp_uid = i_cal_component_get_uid (icomp);
+               obj_data = g_hash_table_lookup (priv->comp_uid_hash, comp_uid);
 
                /* Set the last modified time on the component */
-               current = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
-               e_cal_component_set_last_modified (comp, &current);
+               current = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
+               e_cal_component_set_last_modified (comp, current);
+               g_object_unref (current);
 
                /* sanitize the component*/
                sanitize_component (cbfile, comp);
@@ -2485,8 +2556,8 @@ e_cal_backend_file_modify_objects (ECalBackendSync *backend,
 
                                /* replace only the full object */
                                if (obj_data->full_object) {
-                                       icalcomponent_remove_component (
-                                               priv->icalcomp,
+                                       i_cal_component_remove_component (
+                                               priv->vcalendar,
                                                e_cal_component_get_icalcomponent (obj_data->full_object));
                                        priv->comp = g_list_remove (priv->comp, obj_data->full_object);
 
@@ -2496,7 +2567,7 @@ e_cal_backend_file_modify_objects (ECalBackendSync *backend,
                                /* add the new object */
                                obj_data->full_object = comp;
 
-                               e_cal_recur_ensure_end_dates (comp, TRUE, resolve_tzid, priv->icalcomp);
+                               e_cal_recur_ensure_end_dates (comp, TRUE, resolve_tzid_cb, &rtd, cancellable, 
NULL);
 
                                if (!remove_component_from_intervaltree (cbfile, comp)) {
                                        g_message (G_STRLOC " Could not remove component from interval 
tree!");
@@ -2504,20 +2575,22 @@ e_cal_backend_file_modify_objects (ECalBackendSync *backend,
 
                                add_component_to_intervaltree (cbfile, comp);
 
-                               icalcomponent_add_component (
-                                       priv->icalcomp,
+                               i_cal_component_add_component (
+                                       priv->vcalendar,
                                        e_cal_component_get_icalcomponent (obj_data->full_object));
                                priv->comp = g_list_prepend (priv->comp, obj_data->full_object);
                                break;
                        }
 
-                       if (g_hash_table_lookup_extended (obj_data->recurrences, rid, (gpointer *) &real_rid, 
(gpointer *) &recurrence)) {
+                       if (g_hash_table_lookup_extended (obj_data->recurrences, rid, NULL, &value)) {
+                               recurrence = value;
+
                                if (old_components)
                                        *old_components = g_slist_prepend (*old_components, 
e_cal_component_clone (recurrence));
 
                                /* remove the component from our data */
-                               icalcomponent_remove_component (
-                                       priv->icalcomp,
+                               i_cal_component_remove_component (
+                                       priv->vcalendar,
                                        e_cal_component_get_icalcomponent (recurrence));
                                priv->comp = g_list_remove (priv->comp, recurrence);
                                obj_data->recurrences_list = g_list_remove (obj_data->recurrences_list, 
recurrence);
@@ -2532,8 +2605,8 @@ e_cal_backend_file_modify_objects (ECalBackendSync *backend,
                                obj_data->recurrences,
                                g_strdup (rid),
                                comp);
-                       icalcomponent_add_component (
-                               priv->icalcomp,
+                       i_cal_component_add_component (
+                               priv->vcalendar,
                                e_cal_component_get_icalcomponent (comp));
                        priv->comp = g_list_append (priv->comp, comp);
                        obj_data->recurrences_list = g_list_append (obj_data->recurrences_list, comp);
@@ -2545,33 +2618,41 @@ e_cal_backend_file_modify_objects (ECalBackendSync *backend,
 
                        /* remove the component from our data, temporarily */
                        if (obj_data->full_object) {
-                               if (mod == E_CAL_OBJ_MOD_THIS_AND_FUTURE &&
-                                   e_cal_util_is_first_instance (obj_data->full_object, 
icalcomponent_get_recurrenceid (icalcomp), resolve_tzid, priv->icalcomp)) {
-                                       icalproperty *prop = icalcomponent_get_first_property (icalcomp, 
ICAL_RECURRENCEID_PROPERTY);
+                               if (mod == E_CAL_OBJ_MOD_THIS_AND_FUTURE) {
+                                       ICalTimetype *itt = i_cal_component_get_recurrenceid (icomp);
+
+                                       if (e_cal_util_is_first_instance (obj_data->full_object, itt, 
resolve_tzid_cb, &rtd)) {
+                                               ICalProperty *prop = i_cal_component_get_first_property 
(icomp, I_CAL_RECURRENCEID_PROPERTY);
 
-                                       if (prop)
-                                               icalcomponent_remove_property (icalcomp, prop);
+                                               g_clear_object (&itt);
 
-                                       e_cal_component_rescan (comp);
+                                               if (prop) {
+                                                       i_cal_component_remove_property (icomp, prop);
+                                                       g_object_unref (prop);
+                                               }
+
+                                               goto like_mod_all;
+                                       }
 
-                                       goto like_mod_all;
+                                       g_clear_object (&itt);
                                }
 
-                               icalcomponent_remove_component (
-                                       priv->icalcomp,
+                               i_cal_component_remove_component (
+                                       priv->vcalendar,
                                        e_cal_component_get_icalcomponent (obj_data->full_object));
                                priv->comp = g_list_remove (priv->comp, obj_data->full_object);
                        }
 
                        /* now deal with the detached recurrence */
-                       if (g_hash_table_lookup_extended (obj_data->recurrences, rid,
-                                                         (gpointer *) &real_rid, (gpointer *) &recurrence)) {
+                       if (g_hash_table_lookup_extended (obj_data->recurrences, rid, NULL, &value)) {
+                               recurrence = value;
+
                                if (old_components)
                                        *old_components = g_slist_prepend (*old_components, 
e_cal_component_clone (recurrence));
 
                                /* remove the component from our data */
-                               icalcomponent_remove_component (
-                                       priv->icalcomp,
+                               i_cal_component_remove_component (
+                                       priv->vcalendar,
                                        e_cal_component_get_icalcomponent (recurrence));
                                priv->comp = g_list_remove (priv->comp, recurrence);
                                obj_data->recurrences_list = g_list_remove (obj_data->recurrences_list, 
recurrence);
@@ -2591,50 +2672,68 @@ e_cal_backend_file_modify_objects (ECalBackendSync *backend,
                         * so that it's always before any detached instance we
                         * might have */
                        if (obj_data->full_object) {
-                               struct icaltimetype rid_struct = icalcomponent_get_recurrenceid (icalcomp), 
master_dtstart;
-                               icalcomponent *master_icalcomp = e_cal_component_get_icalcomponent 
(obj_data->full_object);
-                               icalproperty *prop = icalcomponent_get_first_property (icalcomp, 
ICAL_RECURRENCEID_PROPERTY);
-
-                               if (prop)
-                                       icalcomponent_remove_property (icalcomp, prop);
-
-                               master_dtstart = icalcomponent_get_dtstart (master_icalcomp);
-                               if (master_dtstart.zone && master_dtstart.zone != rid_struct.zone)
-                                       rid_struct = icaltime_convert_to_zone (rid_struct, (icaltimezone *) 
master_dtstart.zone);
-                               split_icalcomp = e_cal_util_split_at_instance (icalcomp, rid_struct, 
master_dtstart);
-                               if (split_icalcomp) {
+                               ICalTimetype *rid_struct = i_cal_component_get_recurrenceid (icomp), 
*master_dtstart;
+                               ICalComponent *master_icomp = e_cal_component_get_icalcomponent 
(obj_data->full_object);
+                               ICalProperty *prop = i_cal_component_get_first_property (icomp, 
I_CAL_RECURRENCEID_PROPERTY);
+
+                               if (prop) {
+                                       i_cal_component_remove_property (icomp, prop);
+                                       g_object_unref (prop);
+                               }
+
+                               master_dtstart = i_cal_component_get_dtstart (master_icomp);
+                               if (master_dtstart && i_cal_timetype_get_zone (master_dtstart) &&
+                                   i_cal_timetype_get_zone (master_dtstart) != i_cal_timetype_get_zone 
(rid_struct)) {
+                                       ICalTimetype *itt;
+
+                                       itt = i_cal_time_convert_to_zone (rid_struct, i_cal_timetype_get_zone 
(master_dtstart));
+                                       g_clear_object (&rid_struct);
+                                       rid_struct = itt;
+                               }
+
+                               split_icomp = e_cal_util_split_at_instance (icomp, rid_struct, 
master_dtstart);
+                               if (split_icomp) {
                                        ECalComponent *prev_comp;
+                                       ICalTimetype *itt;
+
                                        prev_comp = e_cal_component_clone (obj_data->full_object);
 
-                                       rid_struct = icaltime_convert_to_zone (rid_struct, 
icaltimezone_get_utc_timezone ());
+                                       itt = i_cal_time_convert_to_zone (rid_struct, 
i_cal_timezone_get_utc_timezone ());
+                                       g_clear_object (&rid_struct);
+                                       rid_struct = itt;
+
                                        e_cal_util_remove_instances (e_cal_component_get_icalcomponent 
(obj_data->full_object), rid_struct, mod);
-                                       e_cal_component_rescan (obj_data->full_object);
-                                       e_cal_recur_ensure_end_dates (obj_data->full_object, TRUE, 
resolve_tzid, priv->icalcomp);
+                                       e_cal_recur_ensure_end_dates (obj_data->full_object, TRUE, 
resolve_tzid_cb, &rtd, cancellable, NULL);
 
                                        e_cal_backend_notify_component_modified (E_CAL_BACKEND (backend), 
prev_comp, obj_data->full_object);
 
                                        g_clear_object (&prev_comp);
                                }
 
-                               icalcomponent_add_component (
-                                       priv->icalcomp,
+                               i_cal_component_add_component (
+                                       priv->vcalendar,
                                        e_cal_component_get_icalcomponent (obj_data->full_object));
                                priv->comp = g_list_prepend (priv->comp, obj_data->full_object);
+
+                               g_clear_object (&rid_struct);
+                               g_clear_object (&master_dtstart);
                        } else {
-                               struct icaltimetype rid_struct = icalcomponent_get_recurrenceid (icalcomp);
+                               ICalTimetype *rid_struct = i_cal_component_get_recurrenceid (icomp);
 
-                               split_icalcomp = e_cal_util_split_at_instance (icalcomp, rid_struct, 
icaltime_null_time ());
+                               split_icomp = e_cal_util_split_at_instance (icomp, rid_struct, NULL);
+
+                               g_object_unref (rid_struct);
                        }
 
-                       if (split_icalcomp) {
+                       if (split_icomp) {
                                gchar *new_uid;
 
                                new_uid = e_util_generate_uid ();
-                               icalcomponent_set_uid (split_icalcomp, new_uid);
+                               i_cal_component_set_uid (split_icomp, new_uid);
                                g_free (new_uid);
 
-                               g_warn_if_fail (e_cal_component_set_icalcomponent (comp, split_icalcomp));
-                               e_cal_recur_ensure_end_dates (comp, TRUE, resolve_tzid, priv->icalcomp);
+                               g_warn_if_fail (e_cal_component_set_icalcomponent (comp, split_icomp));
+                               e_cal_recur_ensure_end_dates (comp, TRUE, resolve_tzid_cb, &rtd, cancellable, 
NULL);
 
                                /* sanitize the component */
                                sanitize_component (cbfile, comp);
@@ -2660,14 +2759,14 @@ e_cal_backend_file_modify_objects (ECalBackendSync *backend,
 
                        remove_component (cbfile, comp_uid, obj_data);
 
-                       e_cal_recur_ensure_end_dates (comp, TRUE, resolve_tzid, priv->icalcomp);
+                       e_cal_recur_ensure_end_dates (comp, TRUE, resolve_tzid_cb, &rtd, cancellable, NULL);
 
                        /* Add the new object */
                        add_component (cbfile, comp, TRUE);
 
                        if (detached) {
                                /* it had some detached components, place them back */
-                               comp_uid = icalcomponent_get_uid (e_cal_component_get_icalcomponent (comp));
+                               comp_uid = i_cal_component_get_uid (e_cal_component_get_icalcomponent (comp));
 
                                if ((obj_data = g_hash_table_lookup (priv->comp_uid_hash, comp_uid)) != NULL) 
{
                                        GList *ll;
@@ -2676,7 +2775,7 @@ e_cal_backend_file_modify_objects (ECalBackendSync *backend,
                                                ECalComponent *c = ll->data;
 
                                                g_hash_table_insert (obj_data->recurrences, 
e_cal_component_get_recurid_as_string (c), c);
-                                               icalcomponent_add_component (priv->icalcomp, 
e_cal_component_get_icalcomponent (c));
+                                               i_cal_component_add_component (priv->vcalendar, 
e_cal_component_get_icalcomponent (c));
                                                priv->comp = g_list_append (priv->comp, c);
                                                obj_data->recurrences_list = g_list_append 
(obj_data->recurrences_list, c);
                                        }
@@ -2699,7 +2798,9 @@ e_cal_backend_file_modify_objects (ECalBackendSync *backend,
                }
        }
 
-       g_slist_free (icalcomps);
+       resolve_tzid_data_clear (&rtd);
+
+       g_slist_free (icomps);
 
        /* All the components were updated, now we save the file */
        save (cbfile, TRUE);
@@ -2737,20 +2838,21 @@ remove_instance (ECalBackendFile *cbfile,
                  ECalComponent **new_comp,
                  GError **error)
 {
-       gchar *hash_rid;
        ECalComponent *comp;
-       struct icaltimetype current;
+       ICalTimetype *current;
 
        /* only check for non-NULL below, empty string is detected here */
        if (rid && !*rid)
                rid = NULL;
 
        if (rid) {
-               struct icaltimetype rid_struct;
+               ICalTimetype *rid_struct;
+               gpointer value;
 
                /* remove recurrence */
-               if (g_hash_table_lookup_extended (obj_data->recurrences, rid,
-                                                 (gpointer *) &hash_rid, (gpointer *) &comp)) {
+               if (g_hash_table_lookup_extended (obj_data->recurrences, rid, NULL, &value)) {
+                       comp = value;
+
                        /* Removing without parent or not modifying parent?
                         * Report removal to caller. */
                        if (old_comp &&
@@ -2765,15 +2867,16 @@ remove_instance (ECalBackendFile *cbfile,
                                /* old object string not provided,
                                 * instead rely on the view detecting
                                 * whether it contains the id */
-                               ECalComponentId id;
-                               id.uid = (gchar *) uid;
-                               id.rid = (gchar *) rid;
-                               e_cal_backend_notify_component_removed (E_CAL_BACKEND (cbfile), &id, NULL, 
NULL);
+                               ECalComponentId *id;
+
+                               id = e_cal_component_id_new (uid, rid);
+                               e_cal_backend_notify_component_removed (E_CAL_BACKEND (cbfile), id, NULL, 
NULL);
+                               e_cal_component_id_free (id);
                        }
 
                        /* remove the component from our data */
-                       icalcomponent_remove_component (
-                               cbfile->priv->icalcomp,
+                       i_cal_component_remove_component (
+                               cbfile->priv->vcalendar,
                                e_cal_component_get_icalcomponent (comp));
                        cbfile->priv->comp = g_list_remove (cbfile->priv->comp, comp);
                        obj_data->recurrences_list = g_list_remove (obj_data->recurrences_list, comp);
@@ -2801,8 +2904,8 @@ remove_instance (ECalBackendFile *cbfile,
                        return obj_data;
 
                /* remove the main component from our data before modifying it */
-               icalcomponent_remove_component (
-                       cbfile->priv->icalcomp,
+               i_cal_component_remove_component (
+                       cbfile->priv->vcalendar,
                        e_cal_component_get_icalcomponent (obj_data->full_object));
                cbfile->priv->comp = g_list_remove (cbfile->priv->comp, obj_data->full_object);
 
@@ -2811,22 +2914,32 @@ remove_instance (ECalBackendFile *cbfile,
                        *old_comp = e_cal_component_clone (obj_data->full_object);
                }
 
-               rid_struct = icaltime_from_string (rid);
-               if (!rid_struct.zone) {
-                       struct icaltimetype master_dtstart = icalcomponent_get_dtstart 
(e_cal_component_get_icalcomponent (obj_data->full_object));
-                       if (master_dtstart.zone && master_dtstart.zone != rid_struct.zone)
-                               rid_struct = icaltime_convert_to_zone (rid_struct, (icaltimezone *) 
master_dtstart.zone);
-                       rid_struct = icaltime_convert_to_zone (rid_struct, icaltimezone_get_utc_timezone ());
+               rid_struct = i_cal_time_from_string (rid);
+               if (!i_cal_timetype_get_zone (rid_struct)) {
+                       ICalTimetype *master_dtstart = i_cal_component_get_dtstart 
(e_cal_component_get_icalcomponent (obj_data->full_object)), *itt;
+
+                       if (master_dtstart && i_cal_timetype_get_zone (master_dtstart)) {
+                               itt = i_cal_time_convert_to_zone (rid_struct, i_cal_timetype_get_zone 
(master_dtstart));
+                               g_object_unref (rid_struct);
+                               rid_struct = itt;
+                       }
+
+                       itt = i_cal_time_convert_to_zone (rid_struct, i_cal_timezone_get_utc_timezone ());
+                       g_object_unref (rid_struct);
+                       rid_struct = itt;
                }
 
                e_cal_util_remove_instances (
                        e_cal_component_get_icalcomponent (obj_data->full_object),
                        rid_struct, E_CAL_OBJ_MOD_THIS);
 
+               g_clear_object (&rid_struct);
+
                /* Since we are only removing one instance of recurrence
                 * event, update the last modified time on the component */
-               current = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
-               e_cal_component_set_last_modified (obj_data->full_object, &current);
+               current = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
+               e_cal_component_set_last_modified (obj_data->full_object, current);
+               g_object_unref (current);
 
                /* report update */
                if (new_comp) {
@@ -2836,8 +2949,8 @@ remove_instance (ECalBackendFile *cbfile,
                /* add the modified object to the beginning of the list,
                 * so that it's always before any detached instance we
                 * might have */
-               icalcomponent_add_component (
-                       cbfile->priv->icalcomp,
+               i_cal_component_add_component (
+                       cbfile->priv->vcalendar,
                        e_cal_component_get_icalcomponent (obj_data->full_object));
                cbfile->priv->comp = g_list_prepend (cbfile->priv->comp, obj_data->full_object);
        } else {
@@ -2856,8 +2969,8 @@ remove_instance (ECalBackendFile *cbfile,
                        g_message (G_STRLOC " Could not remove component from interval tree!");
                        return obj_data;
                }
-               icalcomponent_remove_component (
-                       cbfile->priv->icalcomp,
+               i_cal_component_remove_component (
+                       cbfile->priv->vcalendar,
                        e_cal_component_get_icalcomponent (obj_data->full_object));
                cbfile->priv->comp = g_list_remove (cbfile->priv->comp, obj_data->full_object);
 
@@ -2884,14 +2997,16 @@ clone_ecalcomp_from_fileobject (ECalBackendFileObject *obj_data,
                                 const gchar *rid)
 {
        ECalComponent *comp = obj_data->full_object;
-       gchar         *real_rid;
 
        if (!comp)
                return NULL;
 
        if (rid) {
-               if (!g_hash_table_lookup_extended (obj_data->recurrences, rid,
-                                                 (gpointer *) &real_rid, (gpointer *) &comp)) {
+               gpointer value;
+
+               if (g_hash_table_lookup_extended (obj_data->recurrences, rid, NULL, &value)) {
+                       comp = value;
+               } else {
                        /* FIXME remove this once we delete an instance from master object through
                         * modify request by setting exception */
                        comp = obj_data->full_object;
@@ -2938,7 +3053,7 @@ e_cal_backend_file_remove_objects (ECalBackendSync *backend,
        cbfile = E_CAL_BACKEND_FILE (backend);
        priv = cbfile->priv;
 
-       if (priv->icalcomp == NULL) {
+       if (priv->vcalendar == NULL) {
                g_set_error_literal (
                        error, E_CAL_CLIENT_ERROR,
                        E_CAL_CLIENT_ERROR_NO_SUCH_CALENDAR,
@@ -3026,26 +3141,35 @@ e_cal_backend_file_remove_objects (ECalBackendSync *backend,
                        comp = obj_data->full_object;
 
                        if (comp) {
-                               struct icaltimetype rid_struct;
+                               ICalTimetype *rid_struct;
 
                                *old_components = g_slist_prepend (*old_components, e_cal_component_clone 
(comp));
 
                                /* remove the component from our data, temporarily */
-                               icalcomponent_remove_component (
-                                       priv->icalcomp,
+                               i_cal_component_remove_component (
+                                       priv->vcalendar,
                                        e_cal_component_get_icalcomponent (comp));
                                priv->comp = g_list_remove (priv->comp, comp);
 
-                               rid_struct = icaltime_from_string (recur_id);
-                               if (!rid_struct.zone) {
-                                       struct icaltimetype master_dtstart = icalcomponent_get_dtstart 
(e_cal_component_get_icalcomponent (comp));
-                                       if (master_dtstart.zone && master_dtstart.zone != rid_struct.zone)
-                                               rid_struct = icaltime_convert_to_zone (rid_struct, 
(icaltimezone *) master_dtstart.zone);
-                                       rid_struct = icaltime_convert_to_zone (rid_struct, 
icaltimezone_get_utc_timezone ());
+                               rid_struct = i_cal_time_from_string (recur_id);
+                               if (!i_cal_timetype_get_zone (rid_struct)) {
+                                       ICalTimetype *master_dtstart = i_cal_component_get_dtstart 
(e_cal_component_get_icalcomponent (comp)), *itt;
+
+                                       if (master_dtstart && i_cal_timetype_get_zone (master_dtstart)) {
+                                               itt = i_cal_time_convert_to_zone (rid_struct, 
i_cal_timetype_get_zone (master_dtstart));
+                                               g_object_unref (rid_struct);
+                                               rid_struct = itt;
+                                       }
+
+                                       itt = i_cal_time_convert_to_zone (rid_struct, 
i_cal_timezone_get_utc_timezone ());
+                                       g_object_unref (rid_struct);
+                                       rid_struct = itt;
                                }
                                e_cal_util_remove_instances (
                                        e_cal_component_get_icalcomponent (comp),
                                        rid_struct, mod);
+
+                               g_object_unref (rid_struct);
                        } else {
                                *old_components = g_slist_prepend (*old_components, NULL);
                        }
@@ -3132,13 +3256,13 @@ typedef struct {
 } ECalBackendFileTzidData;
 
 static void
-check_tzids (icalparameter *param,
+check_tzids (ICalParameter *param,
              gpointer data)
 {
        ECalBackendFileTzidData *tzdata = data;
        const gchar *tzid;
 
-       tzid = icalparameter_get_tzid (param);
+       tzid = i_cal_parameter_get_tzid (param);
        if (!tzid || g_hash_table_lookup (tzdata->zones, tzid))
                tzdata->found = FALSE;
 }
@@ -3169,7 +3293,7 @@ fetch_attachments (ECalBackendSync *backend,
                if (!attach || !i_cal_attach_get_is_url (attach))
                        continue;
 
-               sfname = g_filename_from_uri (i_cal_attach_get_url (attach), NULL, NULL)
+               sfname = g_filename_from_uri (i_cal_attach_get_url (attach), NULL, NULL);
                if (!sfname)
                        continue;
 
@@ -3204,12 +3328,15 @@ fetch_attachments (ECalBackendSync *backend,
                dest_url = g_filename_to_uri (dest_file, NULL, NULL);
                g_free (dest_file);
 
-               i_cal_attach_set_uri (attach, dest_url);
+               g_object_unref (attach);
+               l->data = i_cal_attach_new_from_url (dest_url);
 
                g_free (dest_url);
                g_free (sfname);
        }
 
+       e_cal_component_set_attachments (comp, attach_list);
+
        g_slist_free_full (attach_list, g_object_unref);
 }
 
@@ -3217,16 +3344,16 @@ static gint
 masters_first_cmp (gconstpointer ptr1,
                   gconstpointer ptr2)
 {
-       icalcomponent *icomp1 = (icalcomponent *) ptr1;
-       icalcomponent *icomp2 = (icalcomponent *) ptr2;
+       ICalComponent *icomp1 = (ICalComponent *) ptr1;
+       ICalComponent *icomp2 = (ICalComponent *) ptr2;
        gboolean has_rid1, has_rid2;
 
-       has_rid1 = (icomp1 && icalcomponent_get_first_property (icomp1, ICAL_RECURRENCEID_PROPERTY)) ? 1 : 0;
-       has_rid2 = (icomp2 && icalcomponent_get_first_property (icomp2, ICAL_RECURRENCEID_PROPERTY)) ? 1 : 0;
+       has_rid1 = (icomp1 && e_cal_util_component_has_property (icomp1, I_CAL_RECURRENCEID_PROPERTY)) ? 1 : 
0;
+       has_rid2 = (icomp2 && e_cal_util_component_has_property (icomp2, I_CAL_RECURRENCEID_PROPERTY)) ? 1 : 
0;
 
        if (has_rid1 == has_rid2)
-               return g_strcmp0 (icomp1 ? icalcomponent_get_uid (icomp1) : NULL,
-                                 icomp2 ? icalcomponent_get_uid (icomp2) : NULL);
+               return g_strcmp0 (icomp1 ? i_cal_component_get_uid (icomp1) : NULL,
+                                 icomp2 ? i_cal_component_get_uid (icomp2) : NULL);
 
        if (has_rid1)
                return 1;
@@ -3245,11 +3372,11 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend,
        ESourceRegistry *registry;
        ECalBackendFile *cbfile;
        ECalBackendFilePrivate *priv;
-       icalcomponent *toplevel_comp, *icalcomp = NULL;
-       icalcomponent_kind kind;
-       icalproperty_method toplevel_method, method;
-       icalcomponent *subcomp;
-       GList *comps, *del_comps, *l;
+       ICalComponent *toplevel_comp, *icomp = NULL;
+       ICalComponentKind kind;
+       ICalPropertyMethod toplevel_method, method;
+       ICalComponent *subcomp;
+       GSList *comps = NULL, *del_comps = NULL, *link;
        ECalComponent *comp;
        ECalBackendFileTzidData tzdata;
        GError *err = NULL;
@@ -3257,7 +3384,7 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend,
        cbfile = E_CAL_BACKEND_FILE (backend);
        priv = cbfile->priv;
 
-       if (priv->icalcomp == NULL) {
+       if (priv->vcalendar == NULL) {
                g_set_error_literal (
                        error, E_CAL_CLIENT_ERROR,
                        E_CAL_CLIENT_ERROR_NO_SUCH_CALENDAR,
@@ -3267,7 +3394,7 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend,
        }
 
        /* Pull the component from the string and ensure that it is sane */
-       toplevel_comp = icalparser_parse_string ((gchar *) calobj);
+       toplevel_comp = i_cal_parser_parse_string (calobj);
        if (!toplevel_comp) {
                g_propagate_error (error, EDC_ERROR (InvalidObject));
                return;
@@ -3277,97 +3404,94 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend,
 
        registry = e_cal_backend_get_registry (E_CAL_BACKEND (backend));
 
-       kind = icalcomponent_isa (toplevel_comp);
-       if (kind != ICAL_VCALENDAR_COMPONENT) {
+       kind = i_cal_component_isa (toplevel_comp);
+       if (kind != I_CAL_VCALENDAR_COMPONENT) {
                /* If its not a VCALENDAR, make it one to simplify below */
-               icalcomp = toplevel_comp;
+               icomp = toplevel_comp;
                toplevel_comp = e_cal_util_new_top_level ();
-               if (icalcomponent_get_method (icalcomp) == ICAL_METHOD_CANCEL)
-                       icalcomponent_set_method (toplevel_comp, ICAL_METHOD_CANCEL);
+               if (i_cal_component_get_method (icomp) == I_CAL_METHOD_CANCEL)
+                       i_cal_component_set_method (toplevel_comp, I_CAL_METHOD_CANCEL);
                else
-                       icalcomponent_set_method (toplevel_comp, ICAL_METHOD_PUBLISH);
-               icalcomponent_add_component (toplevel_comp, icalcomp);
+                       i_cal_component_set_method (toplevel_comp, I_CAL_METHOD_PUBLISH);
+               i_cal_component_take_component (toplevel_comp, icomp);
        } else {
-               if (!icalcomponent_get_first_property (toplevel_comp, ICAL_METHOD_PROPERTY))
-                       icalcomponent_set_method (toplevel_comp, ICAL_METHOD_PUBLISH);
+               if (!e_cal_util_component_has_property (toplevel_comp, I_CAL_METHOD_PROPERTY))
+                       i_cal_component_set_method (toplevel_comp, I_CAL_METHOD_PUBLISH);
        }
 
-       toplevel_method = icalcomponent_get_method (toplevel_comp);
+       toplevel_method = i_cal_component_get_method (toplevel_comp);
 
        /* Build a list of timezones so we can make sure all the objects have valid info */
        tzdata.zones = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
 
-       subcomp = icalcomponent_get_first_component (toplevel_comp, ICAL_VTIMEZONE_COMPONENT);
-       while (subcomp) {
-               icaltimezone *zone;
-
-               zone = icaltimezone_new ();
-               if (icaltimezone_set_component (zone, subcomp))
-                       g_hash_table_insert (tzdata.zones, g_strdup (icaltimezone_get_tzid (zone)), NULL);
-               icaltimezone_free (zone, 1);
+       for (subcomp = i_cal_component_get_first_component (toplevel_comp, I_CAL_VTIMEZONE_COMPONENT);
+            subcomp;
+            g_object_unref (subcomp), subcomp = i_cal_component_get_next_component (toplevel_comp, 
I_CAL_VTIMEZONE_COMPONENT)) {
+               ICalTimezone *zone;
 
-               subcomp = icalcomponent_get_next_component (toplevel_comp, ICAL_VTIMEZONE_COMPONENT);
+               zone = i_cal_timezone_new ();
+               if (i_cal_timezone_set_component (zone, subcomp))
+                       g_hash_table_insert (tzdata.zones, g_strdup (i_cal_timezone_get_tzid (zone)), NULL);
+               g_object_unref (zone);
        }
 
        /* First we make sure all the components are usuable */
-       comps = del_comps = NULL;
        kind = e_cal_backend_get_kind (E_CAL_BACKEND (backend));
 
-       subcomp = icalcomponent_get_first_component (toplevel_comp, ICAL_ANY_COMPONENT);
-       while (subcomp) {
-               icalcomponent_kind child_kind = icalcomponent_isa (subcomp);
+       for (subcomp = i_cal_component_get_first_component (toplevel_comp, I_CAL_ANY_COMPONENT);
+            subcomp;
+            g_object_unref (subcomp), subcomp = i_cal_component_get_next_component (toplevel_comp, 
I_CAL_ANY_COMPONENT)) {
+               ICalComponentKind child_kind = i_cal_component_isa (subcomp);
 
                if (child_kind != kind) {
                        /* remove the component from the toplevel VCALENDAR */
-                       if (child_kind != ICAL_VTIMEZONE_COMPONENT)
-                               del_comps = g_list_prepend (del_comps, subcomp);
-
-                       subcomp = icalcomponent_get_next_component (toplevel_comp, ICAL_ANY_COMPONENT);
+                       if (child_kind != I_CAL_VTIMEZONE_COMPONENT)
+                               del_comps = g_slist_prepend (del_comps, g_object_ref (subcomp));
                        continue;
                }
 
                tzdata.found = TRUE;
-               icalcomponent_foreach_tzid (subcomp, check_tzids, &tzdata);
+               i_cal_component_foreach_tzid (subcomp, check_tzids, &tzdata);
 
                if (!tzdata.found) {
                        err = EDC_ERROR (InvalidObject);
+                       g_object_unref (subcomp);
                        goto error;
                }
 
-               if (!icalcomponent_get_uid (subcomp)) {
-                       if (toplevel_method == ICAL_METHOD_PUBLISH) {
-
+               if (!i_cal_component_get_uid (subcomp)) {
+                       if (toplevel_method == I_CAL_METHOD_PUBLISH) {
                                gchar *new_uid = NULL;
 
                                new_uid = e_util_generate_uid ();
-                               icalcomponent_set_uid (subcomp, new_uid);
+                               i_cal_component_set_uid (subcomp, new_uid);
                                g_free (new_uid);
                        } else {
                                err = EDC_ERROR (InvalidObject);
+                               g_object_unref (subcomp);
                                goto error;
                        }
 
                }
 
-               comps = g_list_prepend (comps, subcomp);
-               subcomp = icalcomponent_get_next_component (toplevel_comp, ICAL_ANY_COMPONENT);
+               comps = g_slist_prepend (comps, g_object_ref (subcomp));
        }
 
        /* Now we remove the components we don't care about */
-       for (l = del_comps; l; l = l->next) {
-               subcomp = l->data;
+       for (link = del_comps; link; link = g_slist_next (link)) {
+               subcomp = link->data;
 
-               icalcomponent_remove_component (toplevel_comp, subcomp);
-               icalcomponent_free (subcomp);
+               i_cal_component_remove_component (toplevel_comp, subcomp);
        }
 
-       g_list_free (del_comps);
+       g_slist_free_full (del_comps, g_object_unref);
+       del_comps = NULL;
 
         /* check and patch timezones */
-       if (!e_cal_client_check_timezones (toplevel_comp,
+       if (!e_cal_client_check_timezones_sync (toplevel_comp,
                               NULL,
-                              e_cal_client_tzlookup_icomp,
-                              priv->icalcomp,
+                              e_cal_client_tzlookup_icalcomp_cb,
+                              priv->vcalendar,
                               NULL,
                               &err)) {
                /*
@@ -3382,13 +3506,13 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend,
 
        /* Merge the iCalendar components with our existing VCALENDAR,
         * resolving any conflicting TZIDs. It also frees the toplevel_comp. */
-       icalcomponent_merge_component (priv->icalcomp, toplevel_comp);
-       toplevel_comp = NULL;
+       i_cal_component_merge_component (priv->vcalendar, toplevel_comp);
+       g_clear_object (&toplevel_comp);
 
        /* Now we manipulate the components we care about */
-       comps = g_list_sort (comps, masters_first_cmp);
+       comps = g_slist_sort (comps, masters_first_cmp);
 
-       for (l = comps; l; l = l->next) {
+       for (link = comps; link; link = g_slist_next (link)) {
                ECalComponent *old_component = NULL;
                ECalComponent *new_component = NULL;
                ICalTimetype *current;
@@ -3397,21 +3521,22 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend,
                ECalBackendFileObject *obj_data;
                gboolean is_declined;
 
-               subcomp = l->data;
+               subcomp = link->data;
 
                /* Create the cal component */
-               comp = e_cal_component_new ();
-               e_cal_component_set_icalcomponent (comp, subcomp);
+               comp = e_cal_component_new_from_icalcomponent (g_object_ref (subcomp));
+               if (!comp)
+                       continue;
 
                /* Set the created and last modified times on the component, if not there already */
                current = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
 
-               if (!icalcomponent_get_first_property (icalcomp, ICAL_CREATED_PROPERTY)) {
+               if (!e_cal_util_component_has_property (subcomp, ICAL_CREATED_PROPERTY)) {
                        /* Update both when CREATED is missing, to make sure the LAST-MODIFIED
                           is not before CREATED */
                        e_cal_component_set_created (comp, current);
                        e_cal_component_set_last_modified (comp, current);
-               } else if (!icalcomponent_get_first_property (icalcomp, ICAL_LASTMODIFIED_PROPERTY)) {
+               } else if (!e_cal_util_component_has_property (subcomp, ICAL_LASTMODIFIED_PROPERTY)) {
                        e_cal_component_set_last_modified (comp, current);
                }
 
@@ -3420,8 +3545,8 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend,
                uid = e_cal_component_get_uid (comp);
                rid = e_cal_component_get_recurid_as_string (comp);
 
-               if (icalcomponent_get_first_property (subcomp, ICAL_METHOD_PROPERTY))
-                       method = icalcomponent_get_method (subcomp);
+               if (e_cal_util_component_has_property (subcomp, I_CAL_METHOD_PROPERTY))
+                       method = i_cal_component_get_method (subcomp);
                else
                        method = toplevel_method;
 
@@ -3511,7 +3636,7 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend,
                                                                        id, old_component, new_component);
 
                                /* remove the component from the toplevel VCALENDAR */
-                               icalcomponent_remove_component (priv->icalcomp, subcomp);
+                               i_cal_component_remove_component (priv->vcalendar, subcomp);
                                e_cal_component_id_free (id);
 
                                if (new_component)
@@ -3530,11 +3655,12 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend,
                }
        }
 
-       g_list_free (comps);
-
        save (cbfile, TRUE);
 
  error:
+       g_slist_free_full (del_comps, g_object_unref);
+       g_slist_free_full (comps, g_object_unref);
+
        g_hash_table_destroy (tzdata.zones);
        g_rec_mutex_unlock (&priv->idle_save_rmutex);
 
@@ -3562,7 +3688,7 @@ cal_backend_file_constructed (GObject *object)
        ESourceRegistry *registry;
        ESource *builtin_source;
        ESource *source;
-       icalcomponent_kind kind;
+       ICalComponentKind kind;
        const gchar *user_data_dir;
        const gchar *component_type;
        const gchar *uid;
@@ -3584,15 +3710,15 @@ cal_backend_file_constructed (GObject *object)
        g_return_if_fail (uid != NULL);
 
        switch (kind) {
-               case ICAL_VEVENT_COMPONENT:
+               case I_CAL_VEVENT_COMPONENT:
                        component_type = "calendar";
                        builtin_source = e_source_registry_ref_builtin_calendar (registry);
                        break;
-               case ICAL_VTODO_COMPONENT:
+               case I_CAL_VTODO_COMPONENT:
                        component_type = "tasks";
                        builtin_source = e_source_registry_ref_builtin_task_list (registry);
                        break;
-               case ICAL_VJOURNAL_COMPONENT:
+               case I_CAL_VJOURNAL_COMPONENT:
                        component_type = "memos";
                        builtin_source = e_source_registry_ref_builtin_memo_list (registry);
                        break;
@@ -3621,7 +3747,7 @@ cal_backend_file_constructed (GObject *object)
 
 static void
 cal_backend_file_add_cached_timezone (ETimezoneCache *cache,
-                                      icaltimezone *zone)
+                                      ICalTimezone *zone)
 {
        ECalBackendFilePrivate *priv;
        const gchar *tzid;
@@ -3631,13 +3757,15 @@ cal_backend_file_add_cached_timezone (ETimezoneCache *cache,
 
        g_rec_mutex_lock (&priv->idle_save_rmutex);
 
-       tzid = icaltimezone_get_tzid (zone);
-       if (icalcomponent_get_timezone (priv->icalcomp, tzid) == NULL) {
-               icalcomponent *tz_comp;
+       tzid = i_cal_timezone_get_tzid (zone);
+       if (!i_cal_component_get_timezone (priv->vcalendar, tzid)) {
+               ICalComponent *tz_comp;
+
+               tz_comp = i_cal_timezone_get_component (zone);
 
-               tz_comp = icaltimezone_get_component (zone);
-               tz_comp = icalcomponent_new_clone (tz_comp);
-               icalcomponent_add_component (priv->icalcomp, tz_comp);
+               i_cal_component_take_component (priv->vcalendar, i_cal_component_new_clone (tz_comp));
+
+               g_clear_object (&tz_comp);
 
                timezone_added = TRUE;
                save (E_CAL_BACKEND_FILE (cache), TRUE);
@@ -3650,24 +3778,29 @@ cal_backend_file_add_cached_timezone (ETimezoneCache *cache,
                g_signal_emit_by_name (cache, "timezone-added", zone);
 }
 
-static icaltimezone *
+static ICalTimezone *
 cal_backend_file_get_cached_timezone (ETimezoneCache *cache,
                                       const gchar *tzid)
 {
        ECalBackendFilePrivate *priv;
-       icaltimezone *zone;
+       ICalTimezone *zone;
 
        priv = E_CAL_BACKEND_FILE_GET_PRIVATE (cache);
 
        g_rec_mutex_lock (&priv->idle_save_rmutex);
-       zone = icalcomponent_get_timezone (priv->icalcomp, tzid);
+       zone = g_hash_table_lookup (priv->cached_timezones, tzid);
+       if (!zone) {
+               zone = i_cal_component_get_timezone (priv->vcalendar, tzid);
+               if (zone)
+                       g_hash_table_insert (priv->cached_timezones, g_strdup (tzid), zone);
+       }
        g_rec_mutex_unlock (&priv->idle_save_rmutex);
 
        if (zone != NULL)
                return zone;
 
        /* Chain up and let ECalBackend try to match
-        * the TZID against a built-in icaltimezone. */
+        * the TZID against a built-in ICalTimezone. */
        return parent_timezone_cache_interface->get_timezone (cache, tzid);
 }
 
@@ -3739,6 +3872,8 @@ e_cal_backend_file_init (ECalBackendFile *cbfile)
        g_rec_mutex_init (&cbfile->priv->idle_save_rmutex);
 
        g_mutex_init (&cbfile->priv->refresh_lock);
+
+       cbfile->priv->cached_timezones = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, 
g_object_unref);
 }
 
 void
@@ -3908,14 +4043,19 @@ get_difference_of_lists (ECalBackendFile *cbfile,
                if (!found)
                {
                        time_t time_start, time_end;
+                       ResolveTzidData rtd;
                        printf ("%s IS MISSING\n", uid);
 
+                       resolve_tzid_data_init (&rtd, cbfile->priv->vcalendar);
+
                        e_cal_util_get_component_occur_times (
                                comp, &time_start, &time_end,
-                               resolve_tzid, cbfile->priv->icalcomp,
-                               icaltimezone_get_utc_timezone (),
+                               resolve_tzid_cb, &rtd,
+                               i_cal_timezone_get_utc_timezone (),
                                e_cal_backend_get_kind (E_CAL_BACKEND (cbfile)));
 
+                       resolve_tzid_data_clear (&rtd);
+
                        d (printf ("start %s\n", asctime (gmtime (&time_start))));
                        d (printf ("end %s\n", asctime (gmtime (&time_end))));
                }
diff --git a/src/calendar/backends/gtasks/e-cal-backend-gtasks.c 
b/src/calendar/backends/gtasks/e-cal-backend-gtasks.c
index afa3ef4d4..26b22edbf 100644
--- a/src/calendar/backends/gtasks/e-cal-backend-gtasks.c
+++ b/src/calendar/backends/gtasks/e-cal-backend-gtasks.c
@@ -77,20 +77,21 @@ ecb_gtasks_store_data_version (ECalCache *cal_cache)
 }
 
 static void
-ecb_gtasks_update_ical_time_property (icalcomponent *icomp,
-                                     icalproperty_kind kind,
-                                     icalproperty * (* prop_new_func) (struct icaltimetype v),
-                                     void (* prop_set_func) (icalproperty *prop, struct icaltimetype v),
-                                     struct icaltimetype t)
+ecb_gtasks_update_ical_time_property (ICalComponent *icomp,
+                                     ICalPropertyKind kind,
+                                     ICalProperty * (* prop_new_func) (ICalTimetype *v),
+                                     void (* prop_set_func) (ICalProperty *prop, ICalTimetype *v),
+                                     ICalTimetype *tt)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
-       prop = icalcomponent_get_first_property (icomp, kind);
+       prop = i_cal_component_get_first_property (icomp, kind);
        if (prop) {
-               prop_set_func (prop, t);
+               prop_set_func (prop, tt);
+               g_object_unref (prop);
        } else {
-               prop = prop_new_func (t);
-               icalcomponent_add_property (icomp, prop);
+               prop = prop_new_func (tt);
+               i_cal_component_take_property (icomp, prop);
        }
 }
 
@@ -100,81 +101,97 @@ ecb_gtasks_gdata_to_comp (GDataTasksTask *task)
        GDataEntry *entry;
        GDataLink *data_link;
        ECalComponent *comp;
-       icalcomponent *icomp;
+       ICalComponent *icomp;
+       ICalTimetype *tt;
+       ICalTimezone *utc_zone;
        const gchar *position;
        const gchar *parent;
        const gchar *text;
-       struct icaltimetype tt;
 
        g_return_val_if_fail (GDATA_IS_TASKS_TASK (task), NULL);
 
        entry = GDATA_ENTRY (task);
-       icomp = icalcomponent_new (ICAL_VTODO_COMPONENT);
+       icomp = i_cal_component_new (I_CAL_VTODO_COMPONENT);
 
-       icalcomponent_set_uid (icomp, gdata_entry_get_id (entry));
+       i_cal_component_set_uid (icomp, gdata_entry_get_id (entry));
 
-       tt = icaltime_from_timet_with_zone (gdata_entry_get_published (entry), 0, 
icaltimezone_get_utc_timezone ());
-       if (!icaltime_is_valid_time (tt) || icaltime_is_null_time (tt))
-               tt = icaltime_from_timet_with_zone (gdata_entry_get_updated (entry), 0, 
icaltimezone_get_utc_timezone ());
-       if (!icaltime_is_valid_time (tt) || icaltime_is_null_time (tt))
-               tt = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
+       utc_zone = i_cal_timezone_get_utc_timezone ();
 
-       ecb_gtasks_update_ical_time_property (icomp, ICAL_CREATED_PROPERTY,
-               icalproperty_new_created,
-               icalproperty_set_created,
+       tt = i_cal_time_from_timet_with_zone (gdata_entry_get_published (entry), 0, utc_zone);
+       if (!tt || !i_cal_time_is_valid_time (tt) || i_cal_time_is_null_time (tt)) {
+               g_clear_object (&tt);
+               tt = i_cal_time_from_timet_with_zone (gdata_entry_get_updated (entry), 0, utc_zone);
+       }
+       if (!tt || !i_cal_time_is_valid_time (tt) || i_cal_time_is_null_time (tt)) {
+               g_clear_object (&tt);
+               tt = i_cal_time_current_time_with_zone (utc_zone);
+       }
+
+       ecb_gtasks_update_ical_time_property (icomp, I_CAL_CREATED_PROPERTY,
+               i_cal_property_new_created,
+               i_cal_property_set_created,
                tt);
 
-       tt = icaltime_from_timet_with_zone (gdata_entry_get_updated (entry), 0, icaltimezone_get_utc_timezone 
());
-       if (!icaltime_is_valid_time (tt) || icaltime_is_null_time (tt))
-               tt = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
-       icalcomponent_set_dtstamp (icomp, tt);
+       g_clear_object (&tt);
 
-       ecb_gtasks_update_ical_time_property (icomp, ICAL_LASTMODIFIED_PROPERTY,
-               icalproperty_new_lastmodified,
-               icalproperty_set_lastmodified,
+       tt = i_cal_time_from_timet_with_zone (gdata_entry_get_updated (entry), 0, utc_zone);
+       if (!tt || !i_cal_time_is_valid_time (tt) || i_cal_time_is_null_time (tt)) {
+               g_clear_object (&tt);
+               tt = i_cal_time_current_time_with_zone (utc_zone);
+       }
+       i_cal_component_set_dtstamp (icomp, tt);
+
+       ecb_gtasks_update_ical_time_property (icomp, I_CAL_LASTMODIFIED_PROPERTY,
+               i_cal_property_new_lastmodified,
+               i_cal_property_set_lastmodified,
                tt);
 
+       g_clear_object (&tt);
+
        if (gdata_tasks_task_get_due (task) > 0) {
-               tt = icaltime_from_timet_with_zone (gdata_tasks_task_get_due (task), 1, NULL);
-               if (icaltime_is_valid_time (tt) && !icaltime_is_null_time (tt))
-                       icalcomponent_set_due (icomp, tt);
+               tt = i_cal_time_from_timet_with_zone (gdata_tasks_task_get_due (task), 1, NULL);
+               if (tt && i_cal_time_is_valid_time (tt) && !i_cal_time_is_null_time (tt))
+                       i_cal_component_set_due (icomp, tt);
+               g_clear_object (&tt);
        }
 
        if (gdata_tasks_task_get_completed (task) > 0) {
-               tt = icaltime_from_timet_with_zone (gdata_tasks_task_get_completed (task), 0, 
icaltimezone_get_utc_timezone ());
-               if (icaltime_is_valid_time (tt) && !icaltime_is_null_time (tt))
-                       ecb_gtasks_update_ical_time_property (icomp, ICAL_COMPLETED_PROPERTY,
-                               icalproperty_new_completed,
-                               icalproperty_set_completed,
+               tt = i_cal_time_from_timet_with_zone (gdata_tasks_task_get_completed (task), 0, utc_zone);
+               if (tt && i_cal_time_is_valid_time (tt) && !i_cal_time_is_null_time (tt)) {
+                       ecb_gtasks_update_ical_time_property (icomp, I_CAL_COMPLETED_PROPERTY,
+                               i_cal_property_new_completed,
+                               i_cal_property_set_completed,
                                tt);
+               }
+               g_clear_object (&tt);
        }
 
        text = gdata_entry_get_title (entry);
        if (text && *text)
-               icalcomponent_set_summary (icomp, text);
+               i_cal_component_set_summary (icomp, text);
 
        text = gdata_tasks_task_get_notes (task);
        if (text && *text)
-               icalcomponent_set_description (icomp, text);
+               i_cal_component_set_description (icomp, text);
 
        /* "needsAction" or "completed" */
        text = gdata_tasks_task_get_status (task);
        if (g_strcmp0 (text, "completed") == 0)
-               icalcomponent_set_status (icomp, ICAL_STATUS_COMPLETED);
+               i_cal_component_set_status (icomp, I_CAL_STATUS_COMPLETED);
        else if (g_strcmp0 (text, "needsAction") == 0)
-               icalcomponent_set_status (icomp, ICAL_STATUS_NEEDSACTION);
+               i_cal_component_set_status (icomp, I_CAL_STATUS_NEEDSACTION);
 
        data_link = gdata_entry_look_up_link (entry, GDATA_LINK_SELF);
        if (data_link)
-               e_cal_util_set_x_property (icomp, X_EVO_GTASKS_SELF_LINK, gdata_link_get_uri (data_link));
+               e_cal_util_component_set_x_property (icomp, X_EVO_GTASKS_SELF_LINK, gdata_link_get_uri 
(data_link));
 
        position = gdata_tasks_task_get_position (task);
        if (position)
-               e_cal_util_set_x_property (icomp, X_EVO_GTASKS_POSITION, position);
+               e_cal_util_component_set_x_property (icomp, X_EVO_GTASKS_POSITION, position);
 
        parent = gdata_tasks_task_get_parent (task);
        if (parent)
-               icalcomponent_add_property (icomp, icalproperty_new_relatedto (parent));
+               i_cal_component_take_property (icomp, i_cal_property_new_relatedto (parent));
 
        comp = e_cal_component_new_from_icalcomponent (icomp);
        g_warn_if_fail (comp != NULL);
@@ -189,60 +206,66 @@ ecb_gtasks_comp_to_gdata (ECalComponent *comp,
 {
        GDataEntry *entry;
        GDataTasksTask *task;
-       icalcomponent *icomp;
-       icalproperty *prop;
+       ICalComponent *icomp;
+       ICalProperty *prop;
+       ICalTimetype *tt;
+       ICalTimezone *utc_zone;
        const gchar *text;
+       gchar *tmp;
 #if GDATA_CHECK_VERSION(0, 17, 10)
        gchar *position;
 #endif
-       gchar *tmp;
-       struct icaltimetype tt;
 
        g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), NULL);
 
        icomp = e_cal_component_get_icalcomponent (comp);
        g_return_val_if_fail (icomp != NULL, NULL);
 
-       text = icalcomponent_get_uid (icomp);
+       text = i_cal_component_get_uid (icomp);
        task = gdata_tasks_task_new ((!ignore_uid && text && *text) ? text : NULL);
        entry = GDATA_ENTRY (task);
 
-       tt = icalcomponent_get_due (icomp);
-       if (icaltime_is_valid_time (tt) && !icaltime_is_null_time (tt)) {
+       utc_zone = i_cal_timezone_get_utc_timezone ();
+
+       tt = i_cal_component_get_due (icomp);
+       if (tt && i_cal_time_is_valid_time (tt) && !i_cal_time_is_null_time (tt)) {
                gint64 due;
 
-               due = (gint64) icaltime_as_timet_with_zone (tt, icaltimezone_get_utc_timezone ());
+               due = (gint64) i_cal_time_as_timet_with_zone (tt, utc_zone);
                gdata_tasks_task_set_due (task, due);
        }
+       g_clear_object (&tt);
 
-       prop = icalcomponent_get_first_property (icomp, ICAL_COMPLETED_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_COMPLETED_PROPERTY);
        if (prop) {
-               tt = icalproperty_get_completed (prop);
+               tt = i_cal_property_get_completed (prop);
 
-               if (icaltime_is_valid_time (tt) && !icaltime_is_null_time (tt)) {
+               if (tt && i_cal_time_is_valid_time (tt) && !i_cal_time_is_null_time (tt)) {
                        gint64 completed;
 
-                       completed = (gint64) icaltime_as_timet_with_zone (tt, icaltimezone_get_utc_timezone 
());
+                       completed = (gint64) i_cal_time_as_timet_with_zone (tt, utc_zone);
                        gdata_tasks_task_set_completed (task, completed);
                        gdata_tasks_task_set_status (task, "completed");
                }
+               g_clear_object (&tt);
+               g_object_unref (prop);
        }
 
-       text = icalcomponent_get_summary (icomp);
+       text = i_cal_component_get_summary (icomp);
        if (text && *text)
                gdata_entry_set_title (entry, text);
 
-       text = icalcomponent_get_description (icomp);
+       text = i_cal_component_get_description (icomp);
        if (text && *text)
                gdata_tasks_task_set_notes (task, text);
 
        /* "needsAction" or "completed" */
-       if (icalcomponent_get_status (icomp) == ICAL_STATUS_COMPLETED)
+       if (i_cal_component_get_status (icomp) == I_CAL_STATUS_COMPLETED)
                gdata_tasks_task_set_status (task, "completed");
-       else if (icalcomponent_get_status (icomp) == ICAL_STATUS_NEEDSACTION)
+       else if (i_cal_component_get_status (icomp) == I_CAL_STATUS_NEEDSACTION)
                gdata_tasks_task_set_status (task, "needsAction");
 
-       tmp = e_cal_util_dup_x_property (icomp, X_EVO_GTASKS_SELF_LINK);
+       tmp = e_cal_util_component_dup_x_property (icomp, X_EVO_GTASKS_SELF_LINK);
        if (!tmp || !*tmp) {
                g_free (tmp);
                tmp = NULL;
@@ -250,7 +273,7 @@ ecb_gtasks_comp_to_gdata (ECalComponent *comp,
                /* If the passed-in component doesn't contain the libgdata self link,
                   then get it from the cached comp */
                if (cached_comp) {
-                       tmp = e_cal_util_dup_x_property (
+                       tmp = e_cal_util_component_dup_x_property (
                                e_cal_component_get_icalcomponent (cached_comp),
                                X_EVO_GTASKS_SELF_LINK);
                }
@@ -268,7 +291,7 @@ ecb_gtasks_comp_to_gdata (ECalComponent *comp,
 
 #if GDATA_CHECK_VERSION(0, 17, 10)
        /* Position */
-       position = e_cal_util_dup_x_property (icomp, X_EVO_GTASKS_POSITION);
+       position = e_cal_util_component_dup_x_property (icomp, X_EVO_GTASKS_POSITION);
        if (!position || !*position) {
                g_free (position);
                position = NULL;
@@ -276,7 +299,7 @@ ecb_gtasks_comp_to_gdata (ECalComponent *comp,
                /* If the passed-in component doesn't contain the libgdata position,
                   then get it from the cached comp */
                if (cached_comp) {
-                       position = e_cal_util_dup_x_property (
+                       position = e_cal_util_component_dup_x_property (
                                e_cal_component_get_icalcomponent (cached_comp),
                                X_EVO_GTASKS_POSITION);
                }
@@ -288,15 +311,17 @@ ecb_gtasks_comp_to_gdata (ECalComponent *comp,
        g_free (position);
 
        /* Parent */
-       prop = icalcomponent_get_first_property (icomp, ICAL_RELATEDTO_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_RELATEDTO_PROPERTY);
        if (!prop && cached_comp) {
-               prop = icalcomponent_get_first_property (
+               prop = i_cal_component_get_first_property (
                        e_cal_component_get_icalcomponent (cached_comp),
-                       ICAL_RELATEDTO_PROPERTY);
+                       I_CAL_RELATEDTO_PROPERTY);
        }
 
-       if (prop)
-               gdata_tasks_task_set_parent (task, icalproperty_get_relatedto (prop));
+       if (prop) {
+               gdata_tasks_task_set_parent (task, i_cal_property_get_relatedto (prop));
+               g_object_unref (prop);
+       }
 #endif
 
        return task;
@@ -797,7 +822,7 @@ static gboolean
 ecb_gtasks_load_component_sync (ECalMetaBackend *meta_backend,
                                const gchar *uid,
                                const gchar *extra,
-                               icalcomponent **out_instances,
+                               ICalComponent **out_instances,
                                gchar **out_extra,
                                GCancellable *cancellable,
                                GError **error)
@@ -818,15 +843,15 @@ ecb_gtasks_load_component_sync (ECalMetaBackend *meta_backend,
 
                comp = g_hash_table_lookup (cbgtasks->priv->preloaded, uid);
                if (comp) {
-                       icalcomponent *icalcomp;
+                       ICalComponent *icomp;
 
-                       icalcomp = e_cal_component_get_icalcomponent (comp);
-                       if (icalcomp)
-                               *out_instances = icalcomponent_new_clone (icalcomp);
+                       icomp = e_cal_component_get_icalcomponent (comp);
+                       if (icomp)
+                               *out_instances = i_cal_component_new_clone (icomp);
 
                        g_hash_table_remove (cbgtasks->priv->preloaded, uid);
 
-                       if (icalcomp)
+                       if (icomp)
                                return TRUE;
                }
        }
@@ -851,7 +876,6 @@ ecb_gtasks_save_component_sync (ECalMetaBackend *meta_backend,
        ECalCache *cal_cache;
        GDataTasksTask *new_task, *comp_task;
        ECalComponent *comp, *cached_comp = NULL;
-       icalcomponent *icalcomp;
        const gchar *uid;
 
        g_return_val_if_fail (E_IS_CAL_BACKEND_GTASKS (meta_backend), FALSE);
@@ -876,9 +900,8 @@ ecb_gtasks_save_component_sync (ECalMetaBackend *meta_backend,
                return FALSE;
        }
 
-       if (!overwrite_existing || !e_cal_cache_get_component (cal_cache,
-               icalcomponent_get_uid (e_cal_component_get_icalcomponent (comp)),
-               NULL, &cached_comp, cancellable, NULL)) {
+       if (!overwrite_existing ||
+           !e_cal_cache_get_component (cal_cache, e_cal_component_get_uid (comp), NULL, &cached_comp, 
cancellable, NULL)) {
                cached_comp = NULL;
        }
 
@@ -914,10 +937,9 @@ ecb_gtasks_save_component_sync (ECalMetaBackend *meta_backend,
                return FALSE;
        }
 
-       icalcomp = e_cal_component_get_icalcomponent (comp);
-       uid = icalcomp ? icalcomponent_get_uid (icalcomp) : NULL;
+       uid = e_cal_component_get_uid (comp);
 
-       if (!icalcomp || !uid) {
+       if (!uid) {
                g_object_unref (comp);
                g_propagate_error (error, EDC_ERROR (InvalidObject));
                return FALSE;
@@ -1025,20 +1047,22 @@ ecb_gtasks_requires_reconnect (ECalMetaBackend *meta_backend)
 
 static gchar *
 ecb_gtasks_dup_component_revision (ECalCache *cal_cache,
-                                  icalcomponent *icalcomp,
+                                  ICalComponent *icomp,
                                   gpointer user_data)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
        gchar *revision = NULL;
 
-       g_return_val_if_fail (icalcomp != NULL, NULL);
+       g_return_val_if_fail (icomp != NULL, NULL);
 
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_LASTMODIFIED_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_LASTMODIFIED_PROPERTY);
        if (prop) {
-               struct icaltimetype itt;
+               ICalTimetype *itt;
 
-               itt = icalproperty_get_lastmodified (prop);
-               revision = icaltime_as_ical_string_r (itt);
+               itt = i_cal_property_get_lastmodified (prop);
+               revision = i_cal_time_as_ical_string_r (itt);
+               g_clear_object (&itt);
+               g_object_unref (prop);
        }
 
        return revision;
diff --git a/src/calendar/backends/http/e-cal-backend-http.c b/src/calendar/backends/http/e-cal-backend-http.c
index b000195ba..4491a2626 100644
--- a/src/calendar/backends/http/e-cal-backend-http.c
+++ b/src/calendar/backends/http/e-cal-backend-http.c
@@ -40,7 +40,7 @@ struct _ECalBackendHttpPrivate {
        SoupRequestHTTP *request;
        GInputStream *input_stream;
        GRecMutex conn_lock;
-       GHashTable *components; /* gchar *uid ~> icalcomponent * */
+       GHashTable *components; /* gchar *uid ~> ICalComponent * */
 };
 
 static gchar *
@@ -313,9 +313,9 @@ ecb_http_get_changes_sync (ECalMetaBackend *meta_backend,
        ECalBackendHttp *cbhttp;
        SoupMessage *message;
        gchar *icalstring;
-       icalcompiter iter;
-       icalcomponent *maincomp, *subcomp;
-       icalcomponent_kind backend_kind = e_cal_backend_get_kind (E_CAL_BACKEND (meta_backend));
+       ICalCompIter *iter = NULL;
+       ICalComponent *maincomp, *subcomp;
+       ICalComponentKind backend_kind;
        GHashTable *components = NULL;
        gboolean success = TRUE;
 
@@ -326,6 +326,7 @@ ecb_http_get_changes_sync (ECalMetaBackend *meta_backend,
        g_return_val_if_fail (out_removed_objects != NULL, FALSE);
 
        cbhttp = E_CAL_BACKEND_HTTP (meta_backend);
+       backend_kind = e_cal_backend_get_kind (E_CAL_BACKEND (meta_backend));
 
        g_rec_mutex_lock (&cbhttp->priv->conn_lock);
 
@@ -378,9 +379,9 @@ ecb_http_get_changes_sync (ECalMetaBackend *meta_backend,
        if (((guchar) icalstring[0]) == 0xEF &&
            ((guchar) icalstring[1]) == 0xBB &&
            ((guchar) icalstring[2]) == 0xBF)
-               maincomp = icalparser_parse_string (icalstring + 3);
+               maincomp = i_cal_parser_parse_string (icalstring + 3);
        else
-               maincomp = icalparser_parse_string (icalstring);
+               maincomp = i_cal_parser_parse_string (icalstring);
 
        g_free (icalstring);
 
@@ -391,96 +392,99 @@ ecb_http_get_changes_sync (ECalMetaBackend *meta_backend,
                return FALSE;
        }
 
-       if (icalcomponent_isa (maincomp) != ICAL_VCALENDAR_COMPONENT &&
-           icalcomponent_isa (maincomp) != ICAL_XROOT_COMPONENT) {
-               icalcomponent_free (maincomp);
+       if (i_cal_component_isa (maincomp) != I_CAL_VCALENDAR_COMPONENT &&
+           i_cal_component_isa (maincomp) != I_CAL_XROOT_COMPONENT) {
+               g_object_unref (maincomp);
                g_set_error (error, SOUP_HTTP_ERROR, SOUP_STATUS_MALFORMED, _("Not a calendar."));
                e_cal_meta_backend_empty_cache_sync (meta_backend, cancellable, NULL);
                ecb_http_disconnect_sync (meta_backend, cancellable, NULL);
                return FALSE;
        }
 
-       if (icalcomponent_isa (maincomp) == ICAL_VCALENDAR_COMPONENT) {
-               subcomp = maincomp;
+       if (i_cal_component_isa (maincomp) == I_CAL_VCALENDAR_COMPONENT) {
+               subcomp = g_object_ref (maincomp);
        } else {
-               iter = icalcomponent_begin_component (maincomp, ICAL_VCALENDAR_COMPONENT);
-               subcomp = icalcompiter_deref (&iter);
+               iter = i_cal_component_begin_component (maincomp, I_CAL_VCALENDAR_COMPONENT);
+               subcomp = i_cal_comp_iter_deref (iter);
        }
 
        while (subcomp && success) {
-               if (subcomp != maincomp)
-                       icalcompiter_next (&iter);
+               ICalComponent *next_subcomp = NULL;
 
-               if (icalcomponent_isa (subcomp) == ICAL_VCALENDAR_COMPONENT) {
+               if (iter)
+                       next_subcomp = i_cal_comp_iter_next (iter);
+
+               if (i_cal_component_isa (subcomp) == I_CAL_VCALENDAR_COMPONENT) {
                        success = e_cal_meta_backend_gather_timezones_sync (meta_backend, subcomp, TRUE, 
cancellable, error);
                        if (success) {
-                               icalcomponent *icalcomp;
+                               ICalComponent *icomp;
 
-                               while (icalcomp = icalcomponent_get_first_component (subcomp, backend_kind), 
icalcomp) {
-                                       icalcomponent *existing_icalcomp;
+                               while (icomp = i_cal_component_get_first_component (subcomp, backend_kind), 
icomp) {
+                                       ICalComponent *existing_icomp;
                                        gpointer orig_key, orig_value;
                                        const gchar *uid;
 
-                                       icalcomponent_remove_component (subcomp, icalcomp);
+                                       i_cal_component_remove_component (subcomp, icomp);
 
                                        if (!components)
-                                               components = g_hash_table_new_full (g_str_hash, g_str_equal, 
g_free, (GDestroyNotify) icalcomponent_free);
+                                               components = g_hash_table_new_full (g_str_hash, g_str_equal, 
g_free, g_object_unref);
 
-                                       if (!icalcomponent_get_first_property (icalcomp, ICAL_UID_PROPERTY)) {
+                                       if (!e_cal_util_component_has_property (icomp, I_CAL_UID_PROPERTY)) {
                                                gchar *new_uid = e_util_generate_uid ();
-                                               icalcomponent_set_uid (icalcomp, new_uid);
+                                               i_cal_component_set_uid (icomp, new_uid);
                                                g_free (new_uid);
                                        }
 
-                                       uid = icalcomponent_get_uid (icalcomp);
+                                       uid = i_cal_component_get_uid (icomp);
 
                                        if (!g_hash_table_lookup_extended (components, uid, &orig_key, 
&orig_value)) {
                                                orig_key = NULL;
                                                orig_value = NULL;
                                        }
 
-                                       existing_icalcomp = orig_value;
-                                       if (existing_icalcomp) {
-                                               if (icalcomponent_isa (existing_icalcomp) != 
ICAL_VCALENDAR_COMPONENT) {
-                                                       icalcomponent *vcal;
+                                       existing_icomp = orig_value;
+                                       if (existing_icomp) {
+                                               if (i_cal_component_isa (existing_icomp) != 
I_CAL_VCALENDAR_COMPONENT) {
+                                                       ICalComponent *vcal;
 
                                                        vcal = e_cal_util_new_top_level ();
 
                                                        g_warn_if_fail (g_hash_table_steal (components, uid));
 
-                                                       icalcomponent_add_component (vcal, existing_icalcomp);
+                                                       i_cal_component_take_component (vcal, existing_icomp);
                                                        g_hash_table_insert (components, g_strdup (uid), 
vcal);
 
                                                        g_free (orig_key);
 
-                                                       existing_icalcomp = vcal;
+                                                       existing_icomp = vcal;
                                                }
 
-                                               icalcomponent_add_component (existing_icalcomp, icalcomp);
+                                               i_cal_component_take_component (existing_icomp, icomp);
                                        } else {
-                                               g_hash_table_insert (components, g_strdup (uid), icalcomp);
+                                               g_hash_table_insert (components, g_strdup (uid), icomp);
                                        }
                                }
                        }
                }
 
-               if (subcomp == maincomp)
-                       subcomp = NULL;
-               else
-                       subcomp = icalcompiter_deref (&iter);
+               g_object_unref (subcomp);
+               subcomp = next_subcomp;
        }
 
+       g_clear_object (&subcomp);
+       g_clear_object (&iter);
+
        if (components) {
                g_warn_if_fail (cbhttp->priv->components == NULL);
                cbhttp->priv->components = components;
 
-               icalcomponent_free (maincomp);
+               g_object_unref (maincomp);
 
                success = E_CAL_META_BACKEND_CLASS (e_cal_backend_http_parent_class)->get_changes_sync 
(meta_backend,
                        last_sync_tag, is_repeat, out_new_sync_tag, out_repeat, out_created_objects,
                        out_modified_objects, out_removed_objects, cancellable, error);
        } else {
-               icalcomponent_free (maincomp);
+               g_object_unref (maincomp);
        }
 
        if (!success)
@@ -498,7 +502,7 @@ ecb_http_list_existing_sync (ECalMetaBackend *meta_backend,
 {
        ECalBackendHttp *cbhttp;
        ECalCache *cal_cache;
-       icalcomponent_kind kind;
+       ICalComponentKind kind;
        GHashTableIter iter;
        gpointer key, value;
 
@@ -518,25 +522,28 @@ ecb_http_list_existing_sync (ECalMetaBackend *meta_backend,
 
        g_hash_table_iter_init (&iter, cbhttp->priv->components);
        while (g_hash_table_iter_next (&iter, &key, &value)) {
-               icalcomponent *icalcomp = value;
+               ICalComponent *icomp = value;
                ECalMetaBackendInfo *nfo;
                const gchar *uid;
                gchar *revision, *object;
 
-               if (icalcomp && icalcomponent_isa (icalcomp) == ICAL_VCALENDAR_COMPONENT)
-                       icalcomp = icalcomponent_get_first_component (icalcomp, kind);
+               if (icomp && i_cal_component_isa (icomp) == I_CAL_VCALENDAR_COMPONENT)
+                       icomp = i_cal_component_get_first_component (icomp, kind);
+               else if (icomp)
+                       icomp = g_object_ref (icomp);
 
-               if (!icalcomp)
+               if (!icomp)
                        continue;
 
-               uid = icalcomponent_get_uid (icalcomp);
-               revision = e_cal_cache_dup_component_revision (cal_cache, icalcomp);
-               object = icalcomponent_as_ical_string_r (value);
+               uid = i_cal_component_get_uid (icomp);
+               revision = e_cal_cache_dup_component_revision (cal_cache, icomp);
+               object = i_cal_component_as_ical_string_r (value);
 
                nfo = e_cal_meta_backend_info_new (uid, revision, object, NULL);
 
                *out_existing_objects = g_slist_prepend (*out_existing_objects, nfo);
 
+               g_object_unref (icomp);
                g_free (revision);
                g_free (object);
        }
@@ -552,7 +559,7 @@ static gboolean
 ecb_http_load_component_sync (ECalMetaBackend *meta_backend,
                              const gchar *uid,
                              const gchar *extra,
-                             icalcomponent **out_component,
+                             ICalComponent **out_component,
                              gchar **out_extra,
                              GCancellable *cancellable,
                              GError **error)
diff --git a/src/calendar/backends/weather/e-cal-backend-weather.c 
b/src/calendar/backends/weather/e-cal-backend-weather.c
index 39158d0b0..4bd7532aa 100644
--- a/src/calendar/backends/weather/e-cal-backend-weather.c
+++ b/src/calendar/backends/weather/e-cal-backend-weather.c
@@ -343,7 +343,7 @@ begin_retrieval_cb (ECalBackendWeather *cbw)
 }
 
 static const gchar *
-getCategory (GWeatherInfo *report)
+get_category (GWeatherInfo *report)
 {
        struct {
                const gchar *description;
@@ -447,16 +447,16 @@ create_weather (ECalBackendWeather *cbw,
                GSList *same_day_forecasts)
 {
        ECalComponent             *cal_comp;
-       ECalComponentText          comp_summary;
-       icalcomponent             *ical_comp;
-       struct icaltimetype        itt;
-       ECalComponentDateTime      dt;
+       ECalComponentText         *comp_summary;
+       ICalComponent             *icomp;
+       ICalTimetype              *itt;
+       ECalComponentDateTime     *dt;
        gchar                     *uid;
-       GSList                    *text_list = NULL, *link;
+       GSList                    *text_list, *link;
        ECalComponentText         *description;
-       gchar                     *tmp, *city_name;
+       gchar                     *tmp, *city_name, *summary_text;
        time_t                     update_time;
-       icaltimezone              *update_zone = NULL;
+       ICalTimezone              *update_zone = NULL;
        const GWeatherLocation    *location;
        const GWeatherTimezone    *w_timezone;
        gdouble tmin = 0.0, tmax = 0.0, temp = 0.0;
@@ -467,9 +467,8 @@ create_weather (ECalBackendWeather *cbw,
                return NULL;
 
        /* create the component and event object */
-       ical_comp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
-       cal_comp = e_cal_component_new ();
-       e_cal_component_set_icalcomponent (cal_comp, ical_comp);
+       icomp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
+       cal_comp = e_cal_component_new_from_icalcomponent (icomp);
 
        /* set uid */
        uid = e_util_generate_uid ();
@@ -479,30 +478,30 @@ create_weather (ECalBackendWeather *cbw,
        /* use timezone of the location to determine date for which this is set */
        location = gweather_info_get_location (report);
        if (location && (w_timezone = gweather_location_get_timezone ((GWeatherLocation *) location)))
-               update_zone = icaltimezone_get_builtin_timezone (gweather_timezone_get_tzid 
((GWeatherTimezone *) w_timezone));
+               update_zone = i_cal_timezone_get_builtin_timezone (gweather_timezone_get_tzid 
((GWeatherTimezone *) w_timezone));
 
        if (!update_zone)
-               update_zone = icaltimezone_get_utc_timezone ();
+               update_zone = i_cal_timezone_get_utc_timezone ();
 
        /* Set all-day event's date from forecast data - cannot set is_date,
         * because in that case no timezone conversion is done */
-       itt = icaltime_from_timet_with_zone (update_time, 0, update_zone);
-       itt.hour = 0;
-       itt.minute = 0;
-       itt.second = 0;
-       itt.is_date = 1;
+       itt = i_cal_time_from_timet_with_zone (update_time, 0, update_zone);
+       i_cal_timetype_set_hour (itt, 0);
+       i_cal_timetype_set_minute (itt, 0);
+       i_cal_timetype_set_second (itt, 0);
+       i_cal_timetype_set_is_date (itt, TRUE);
 
-       dt.value = &itt;
-       if (update_zone)
-               dt.tzid = icaltimezone_get_tzid (update_zone);
-       else
-               dt.tzid = NULL;
+       dt = e_cal_component_datetime_new (itt, update_zone ? i_cal_timezone_get_tzid (update_zone) : NULL);
+       e_cal_component_set_dtstart (cal_comp, dt);
+       e_cal_component_datetime_free (dt);
 
-       e_cal_component_set_dtstart (cal_comp, &dt);
-
-       icaltime_adjust (&itt, 1, 0, 0, 0);
        /* We have to add 1 day to DTEND, as it is not inclusive. */
-       e_cal_component_set_dtend (cal_comp, &dt);
+       i_cal_time_adjust (itt, 1, 0, 0, 0);
+
+       dt = e_cal_component_datetime_new (itt, update_zone ? i_cal_timezone_get_tzid (update_zone) : NULL);
+       e_cal_component_set_dtend (cal_comp, dt);
+       e_cal_component_datetime_free (dt);
+       g_object_unref (itt);
 
        city_name = gweather_info_get_location_name (report);
        if (gweather_info_get_value_temp_min (report, unit, &tmin) &&
@@ -512,31 +511,30 @@ create_weather (ECalBackendWeather *cbw,
 
                min = cal_backend_weather_get_temp (tmin, unit);
                max = cal_backend_weather_get_temp (tmax, unit);
-               comp_summary.value = g_strdup_printf ("%s : %s / %s", city_name, min, max);
+               summary_text = g_strdup_printf ("%s : %s / %s", city_name, min, max);
 
-               g_free (min); g_free (max);
+               g_free (min);
+               g_free (max);
        } else if (gweather_info_get_value_temp (report, unit, &temp)) {
                tmp = cal_backend_weather_get_temp (temp, unit);
-               comp_summary.value = g_strdup_printf ("%s : %s", city_name, tmp);
+               summary_text = g_strdup_printf ("%s : %s", city_name, tmp);
 
                g_free (tmp);
        } else {
-               gchar *temp;
-
-               temp = gweather_info_get_temp (report);
-               comp_summary.value = g_strdup_printf ("%s : %s", city_name, temp);
-
-               g_free (temp);
+               tmp = gweather_info_get_temp (report);
+               summary_text = g_strdup_printf ("%s : %s", city_name, tmp);
+               g_free (tmp);
        }
        g_free (city_name);
 
-       comp_summary.altrep = NULL;
-       e_cal_component_set_summary (cal_comp, &comp_summary);
-       g_free ((gchar *) comp_summary.value);
+       comp_summary = e_cal_component_text_new (summary_text, NULL);
+       e_cal_component_set_summary (cal_comp, comp_summary);
+       e_cal_component_text_free (comp_summary);
+       g_free (summary_text);
 
-       comp_summary.value = gweather_info_get_weather_summary (report);
+       summary_text = gweather_info_get_weather_summary (report);
 
-       description = g_new0 (ECalComponentText, 1);
+       description = e_cal_component_text_new ("", NULL);
        {
                GString *builder;
                gboolean has_forecast_word = FALSE;
@@ -544,7 +542,7 @@ create_weather (ECalBackendWeather *cbw,
                builder = g_string_new (NULL);
 
                if (!is_forecast) {
-                       g_string_append (builder, comp_summary.value);
+                       g_string_append (builder, summary_text);
                        g_string_append_c (builder, '\n');
                }
 
@@ -603,19 +601,18 @@ create_weather (ECalBackendWeather *cbw,
                        }
                }
 
-               description->value = g_string_free (builder, FALSE);
+               e_cal_component_text_set_value (description, builder->str);
+               g_string_free (builder, TRUE);
                g_free (tmp);
        }
-       description->altrep = "";
-       text_list = g_slist_append (text_list, description);
-       e_cal_component_set_description_list (cal_comp, text_list);
-       g_slist_free (text_list);
-       g_free ((gchar *) (description->value));
-       g_free (description);
-       g_free ((gchar *) comp_summary.value);
+
+       text_list = g_slist_prepend (NULL, description);
+       e_cal_component_set_descriptions (cal_comp, text_list);
+       g_slist_free_full (text_list, e_cal_component_text_free);
+       g_free (summary_text);
 
        /* Set category and visibility */
-       e_cal_component_set_categories (cal_comp, getCategory (report));
+       e_cal_component_set_categories (cal_comp, get_category (report));
        e_cal_component_set_classification (cal_comp, E_CAL_COMPONENT_CLASS_PUBLIC);
 
        /* Weather is shown as free time */
@@ -820,10 +817,10 @@ e_cal_backend_weather_add_timezone (ECalBackendSync *backend,
                                     const gchar *tzobj,
                                     GError **error)
 {
-       icalcomponent *tz_comp;
-       icaltimezone *zone;
+       ICalComponent *tz_comp;
+       ICalTimezone *zone;
 
-       tz_comp = icalparser_parse_string (tzobj);
+       tz_comp = i_cal_parser_parse_string (tzobj);
        if (tz_comp == NULL) {
                g_set_error_literal (
                        error, E_CAL_CLIENT_ERROR,
@@ -833,15 +830,17 @@ e_cal_backend_weather_add_timezone (ECalBackendSync *backend,
                return;
        }
 
-       if (icalcomponent_isa (tz_comp) != ICAL_VTIMEZONE_COMPONENT) {
+       if (i_cal_component_isa (tz_comp) != I_CAL_VTIMEZONE_COMPONENT) {
+               g_object_unref (tz_comp);
                g_propagate_error (error, EDC_ERROR (InvalidObject));
                return;
        }
 
-       zone = icaltimezone_new ();
-       icaltimezone_set_component (zone, tz_comp);
-       e_timezone_cache_add_timezone (E_TIMEZONE_CACHE (backend), zone);
-       icaltimezone_free (zone, TRUE);
+       zone = i_cal_timezone_new ();
+       if (i_cal_timezone_set_component (zone, tz_comp))
+               e_timezone_cache_add_timezone (E_TIMEZONE_CACHE (backend), zone);
+       g_object_unref (zone);
+       g_object_unref (tz_comp);
 }
 
 static void
@@ -855,16 +854,22 @@ e_cal_backend_weather_get_free_busy (ECalBackendSync *backend,
                                      GError **perror)
 {
        /* Weather doesn't count as busy time */
-       icalcomponent *vfb = icalcomponent_new_vfreebusy ();
-       icaltimezone *utc_zone = icaltimezone_get_utc_timezone ();
+       ICalComponent *vfb = i_cal_component_new_vfreebusy ();
+       ICalTimezone *utc_zone = i_cal_timezone_get_utc_timezone ();
+       ICalTimetype *itt;
        gchar *calobj;
 
-       icalcomponent_set_dtstart (vfb, icaltime_from_timet_with_zone (start, FALSE, utc_zone));
-       icalcomponent_set_dtend (vfb, icaltime_from_timet_with_zone (end, FALSE, utc_zone));
+       itt = i_cal_time_from_timet_with_zone (start, FALSE, utc_zone);
+       i_cal_component_set_dtstart (vfb, itt);
+       g_object_unref (itt);
+
+       itt = i_cal_time_from_timet_with_zone (end, FALSE, utc_zone);
+       i_cal_component_set_dtend (vfb, itt);
+       g_object_unref (itt);
 
-       calobj = icalcomponent_as_ical_string_r (vfb);
+       calobj = i_cal_component_as_ical_string_r (vfb);
        *freebusy = g_slist_append (NULL, calobj);
-       icalcomponent_free (vfb);
+       g_object_unref (vfb);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]