[evolution-data-server/wip/mcrha/libical-glib] Changes related to e_cal_component_get_... functions (incomplete)



commit b4409f3199362461d8de47036344397dc2d099ae
Author: Milan Crha <mcrha redhat com>
Date:   Tue Feb 12 13:36:58 2019 +0100

    Changes related to e_cal_component_get_... functions (incomplete)

 .../backends/caldav/e-cal-backend-caldav.c         |  70 +++--
 .../backends/contacts/e-cal-backend-contacts.c     |  32 +-
 src/calendar/backends/file/e-cal-backend-file.c    | 169 ++++++-----
 .../backends/gtasks/e-cal-backend-gtasks.c         |  14 +-
 .../backends/weather/e-cal-backend-weather.c       |   2 +-
 src/calendar/libecal/CMakeLists.txt                |   7 +-
 src/calendar/libecal/e-cal-check-timezones.h       |   2 +-
 src/calendar/libecal/e-cal-component-datetime.c    |  62 +++-
 src/calendar/libecal/e-cal-component-datetime.h    |   6 +
 src/calendar/libecal/e-cal-component-id.c          |  12 +-
 src/calendar/libecal/e-cal-component.c             |   3 +-
 src/calendar/libecal/e-reminder-watcher.c          |   8 +-
 src/calendar/libecal/libecal.h                     |   5 +-
 .../libedata-cal/e-cal-backend-intervaltree.c      |   2 +-
 src/calendar/libedata-cal/e-cal-backend-sexp.c     | 200 +++++++------
 src/calendar/libedata-cal/e-cal-backend.c          |   7 +-
 src/calendar/libedata-cal/e-cal-cache.c            | 332 ++++++++++-----------
 src/calendar/libedata-cal/e-cal-cache.h            |  19 +-
 src/calendar/libedata-cal/e-cal-meta-backend.c     | 220 ++++++++------
 src/calendar/libedata-cal/e-data-cal-view.c        |  33 +-
 src/calendar/libedata-cal/e-data-cal.c             |  26 +-
 src/calendar/libedata-cal/libedata-cal.h           |   5 +-
 src/libedataserverui/e-reminders-widget.c          |  21 +-
 .../evolution-alarm-notify/e-alarm-notify.c        |  52 ++--
 tests/libecal/test-cal-client-bulk-methods.c       |   6 +-
 tests/libecal/test-cal-client-get-view.c           |  34 ++-
 tests/libecal/test-cal-client-revision-view.c      |  99 +++---
 tests/libecal/test-cal-client-send-objects.c       |  12 +-
 tests/libecal/test-cal-component.c                 |  10 +-
 tests/libedata-cal/test-cal-cache-getters.c        |  24 +-
 tests/libedata-cal/test-cal-cache-intervals.c      |   9 +-
 tests/libedata-cal/test-cal-cache-offline.c        |  18 +-
 tests/libedata-cal/test-cal-cache-search.c         |  21 +-
 tests/libedata-cal/test-cal-meta-backend.c         |  42 +--
 tests/libedata-cal/test-intervaltree.c             | 111 +++----
 35 files changed, 899 insertions(+), 796 deletions(-)
---
diff --git a/src/calendar/backends/caldav/e-cal-backend-caldav.c 
b/src/calendar/backends/caldav/e-cal-backend-caldav.c
index c3520e3aa..b44203e50 100644
--- a/src/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/src/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -1679,20 +1679,20 @@ ecb_caldav_get_free_busy_from_schedule_outbox_sync (ECalBackendCalDAV *cbdav,
                                                    GCancellable *cancellable,
                                                    GError **error)
 {
-       icalcomponent *icalcomp;
+       ICalComponent *icomp;
        ECalComponent *comp;
-       ECalComponentDateTime dt;
-       ECalComponentOrganizer organizer = { NULL };
+       ECalComponentDateTime *dt;
+       ECalComponentOrganizer *organizer;
        ESourceAuthentication *auth_extension;
        ESource *source;
        EWebDAVSession *webdav;
-       struct icaltimetype dtvalue;
-       icaltimezone *utc;
+       ICalTimetype *dtvalue;
+       ICalTimezone *utc;
        gchar *str;
        GSList *link;
-       GSList *attendees = NULL, *to_free = NULL;
+       GSList *attendees = NULL;
        const gchar *extension_name;
-       gchar *usermail;
+       gchar *usermail, *organizer_value;
        GByteArray *response = NULL;
        GError *local_error = NULL;
 
@@ -1716,18 +1716,18 @@ ecb_caldav_get_free_busy_from_schedule_outbox_sync (ECalBackendCalDAV *cbdav,
        e_cal_component_set_uid (comp, str);
        g_free (str);
 
-       utc = icaltimezone_get_utc_timezone ();
-       dt.value = &dtvalue;
-       dt.tzid = icaltimezone_get_tzid (utc);
+       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));
+
+       e_cal_component_set_dtstamp (comp, e_cal_component_datetime_get_value (dt));
 
-       dtvalue = icaltime_current_time_with_zone (utc);
-       e_cal_component_set_dtstamp (comp, &dtvalue);
+       e_cal_component_datetime_take_value (dt, i_cal_time_from_timet_with_zone (start, FALSE, utc));
+       e_cal_component_set_dtstart (comp, dt);
 
-       dtvalue = icaltime_from_timet_with_zone (start, FALSE, utc);
-       e_cal_component_set_dtstart (comp, &dt);
+       e_cal_component_datetime_take_value (dt, i_cal_time_from_timet_with_zone (end, FALSE, utc));
+       e_cal_component_set_dtend (comp, dt);
 
-       dtvalue = icaltime_from_timet_with_zone (end, FALSE, utc);
-       e_cal_component_set_dtend (comp, &dt);
+       e_cal_component_datetime_free (dt);
 
        usermail = ecb_caldav_get_usermail (cbdav);
        if (usermail != NULL && *usermail == '\0') {
@@ -1742,9 +1742,13 @@ ecb_caldav_get_free_busy_from_schedule_outbox_sync (ECalBackendCalDAV *cbdav,
        if (!usermail)
                usermail = e_source_authentication_dup_user (auth_extension);
 
-       organizer.value = g_strconcat ("mailto:";, usermail, NULL);
-       e_cal_component_set_organizer (comp, &organizer);
-       g_free ((gchar *) organizer.value);
+       organizer_value = g_strconcat ("mailto:";, usermail, NULL);
+       organizer = e_cal_component_organizer_new ();
+       e_cal_component_organizer_set_value (organizer, organizer_value);
+       g_free (organizer_value);
+
+       e_cal_component_set_organizer (comp, organizer);
+       e_cal_component_organizer_free (organizer);
 
        g_free (usermail);
 
@@ -1752,32 +1756,32 @@ ecb_caldav_get_free_busy_from_schedule_outbox_sync (ECalBackendCalDAV *cbdav,
                ECalComponentAttendee *ca;
                gchar *temp = g_strconcat ("mailto:";, (const gchar *) link->data, NULL);
 
-               ca = g_new0 (ECalComponentAttendee, 1);
+               ca = e_cal_component_attendee_new ();
+
+               e_cal_component_attendee_set_value (ca, temp);
+               e_cal_component_attendee_set_cutype (ca, I_CAL_CUTYPE_INDIVIDUAL);
+               e_cal_component_attendee_set_partstat (ca, I_CAL_PARTSTAT_NEEDSACTION);
+               e_cal_component_attendee_set_role (ca, I_CAL_ROLE_CHAIR);
 
-               ca->value = temp;
-               ca->cutype = ICAL_CUTYPE_INDIVIDUAL;
-               ca->status = ICAL_PARTSTAT_NEEDSACTION;
-               ca->role = ICAL_ROLE_CHAIR;
+               g_free (temp);
 
-               to_free = g_slist_prepend (to_free, temp);
                attendees = g_slist_append (attendees, ca);
        }
 
-       e_cal_component_set_attendee_list (comp, attendees);
+       e_cal_component_set_attendees (comp, attendees);
 
-       g_slist_free_full (attendees, g_free);
-       g_slist_free_full (to_free, g_free);
+       g_slist_free_full (attendees, e_cal_component_attendee_free);
 
        e_cal_component_abort_sequence (comp);
 
        /* put the free/busy request to a VCALENDAR */
-       icalcomp = e_cal_util_new_top_level ();
-       icalcomponent_set_method (icalcomp, ICAL_METHOD_REQUEST);
-       icalcomponent_add_component (icalcomp, icalcomponent_new_clone (e_cal_component_get_icalcomponent 
(comp)));
+       icomp = e_cal_util_new_top_level ();
+       i_cal_component_set_method (icomp, ICAL_METHOD_REQUEST);
+       i_cal_component_take_component (icomp, i_cal_component_new_clone (e_cal_component_get_icalcomponent 
(comp)));
 
-       str = icalcomponent_as_ical_string_r (icalcomp);
+       str = i_cal_component_as_ical_string_r (icomp);
 
-       icalcomponent_free (icalcomp);
+       g_object_unref (icomp);
        g_object_unref (comp);
 
        webdav = ecb_caldav_ref_session (cbdav);
diff --git a/src/calendar/backends/contacts/e-cal-backend-contacts.c 
b/src/calendar/backends/contacts/e-cal-backend-contacts.c
index 26ae9febc..25f8a3073 100644
--- a/src/calendar/backends/contacts/e-cal-backend-contacts.c
+++ b/src/calendar/backends/contacts/e-cal-backend-contacts.c
@@ -461,7 +461,7 @@ contact_record_free (ContactRecord *cr)
                id = e_cal_component_get_id (cr->comp_birthday);
                e_cal_backend_notify_component_removed (E_CAL_BACKEND (cr->cbc), id, cr->comp_birthday, NULL);
 
-               e_cal_component_free_id (id);
+               e_cal_component_id_free (id);
                g_object_unref (G_OBJECT (cr->comp_birthday));
        }
 
@@ -471,7 +471,7 @@ contact_record_free (ContactRecord *cr)
 
                e_cal_backend_notify_component_removed (E_CAL_BACKEND (cr->cbc), id, cr->comp_anniversary, 
NULL);
 
-               e_cal_component_free_id (id);
+               e_cal_component_id_free (id);
                g_object_unref (G_OBJECT (cr->comp_anniversary));
        }
 
@@ -805,8 +805,9 @@ setup_alarm (ECalBackendContacts *cbc,
              ECalComponent *comp)
 {
        ECalComponentAlarm *alarm;
-       ECalComponentAlarmTrigger trigger;
-       ECalComponentText summary;
+       ECalComponentAlarmTrigger *trigger;
+       ECalComponentText *summary;
+       ICalDurationType *duration;
 
        g_return_if_fail (cbc != NULL);
 
@@ -847,27 +848,24 @@ setup_alarm (ECalBackendContacts *cbc,
                return;
 
        alarm = e_cal_component_alarm_new ();
-       e_cal_component_get_summary (comp, &summary);
-       e_cal_component_alarm_set_description (alarm, &summary);
+       summary = e_cal_component_get_summary (comp);
+       e_cal_component_alarm_take_description (alarm, summary);
        e_cal_component_alarm_set_action (alarm, E_CAL_COMPONENT_ALARM_DISPLAY);
 
-       trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START;
-
-       memset (&trigger.u.rel_duration, 0, sizeof (trigger.u.rel_duration));
-
-       trigger.u.rel_duration.is_neg = TRUE;
+       duration = i_cal_duration_type_null_duration ();
+       i_cal_duration_type_set_is_neg (duration, TRUE);
 
        switch (cbc->priv->alarm_units) {
        case CAL_MINUTES:
-               trigger.u.rel_duration.minutes = cbc->priv->alarm_interval;
+               i_cal_duration_type_set_minutes (duration, cbc->priv->alarm_interval);
                break;
 
        case CAL_HOURS:
-               trigger.u.rel_duration.hours = cbc->priv->alarm_interval;
+               i_cal_duration_type_set_hours (duration, cbc->priv->alarm_interval);
                break;
 
        case CAL_DAYS:
-               trigger.u.rel_duration.days = cbc->priv->alarm_interval;
+               i_cal_duration_type_set_days (duration, cbc->priv->alarm_interval);
                break;
 
        default:
@@ -876,7 +874,11 @@ setup_alarm (ECalBackendContacts *cbc,
                return;
        }
 
-       e_cal_component_alarm_set_trigger (alarm, trigger);
+       trigger = e_cal_component_alarm_trigger_new_relative (E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START, 
duration);
+
+       g_object_unref (duration);
+
+       e_cal_component_alarm_take_trigger (alarm, trigger);
        e_cal_component_add_alarm (comp, alarm);
        e_cal_component_alarm_free (alarm);
 }
diff --git a/src/calendar/backends/file/e-cal-backend-file.c b/src/calendar/backends/file/e-cal-backend-file.c
index 86fd3bf9d..ce305e731 100644
--- a/src/calendar/backends/file/e-cal-backend-file.c
+++ b/src/calendar/backends/file/e-cal-backend-file.c
@@ -569,13 +569,13 @@ check_dup_uid (ECalBackendFile *cbfile,
 {
        ECalBackendFilePrivate *priv;
        ECalBackendFileObject *obj_data;
-       const gchar *uid = NULL;
+       const gchar *uid;
        gchar *new_uid = NULL;
        gchar *rid = NULL;
 
        priv = cbfile->priv;
 
-       e_cal_component_get_uid (comp, &uid);
+       uid = e_cal_component_get_uid (comp);
 
        if (!uid) {
                g_warning ("Checking for duplicate uid, the component does not have a valid UID skipping 
it\n");
@@ -616,19 +616,28 @@ check_dup_uid (ECalBackendFile *cbfile,
        g_free (new_uid);
 }
 
-static struct icaltimetype
-get_rid_icaltime (ECalComponent *comp)
+static time_t
+get_rid_as_time_t (ECalComponent *comp)
 {
-       ECalComponentRange range;
-       struct icaltimetype tt;
+       ECalComponentRange *range;
+       ECalComponentDatetime *dt;
+       time_t tmt = (time_t) -1;
+
+       range = e_cal_component_get_recurid (comp);
+       if (!range)
+               return tmt;
+
+       dt = e_cal_component_range_get_datetime (range);
+       if (!dt) {
+               e_cal_component_free_range (range);
+               return tmt;
+       }
 
-       e_cal_component_get_recurid (comp, &range);
-       if (!range.datetime.value)
-               return icaltime_null_time ();
-       tt = *range.datetime.value;
-       e_cal_component_free_range (&range);
+       tmt = i_cal_time_as_timet (e_cal_component_datetime_get_value (dt));
 
-       return tt;
+       e_cal_component_range_free (range);
+
+       return tmt;
 }
 
 /* Adds component to the interval tree
@@ -665,7 +674,7 @@ static gboolean
 remove_component_from_intervaltree (ECalBackendFile *cbfile,
                                     ECalComponent *comp)
 {
-       const gchar *uid = NULL;
+       const gchar *uid;
        gchar *rid;
        gboolean res;
        ECalBackendFilePrivate *priv;
@@ -675,8 +684,8 @@ remove_component_from_intervaltree (ECalBackendFile *cbfile,
 
        priv = cbfile->priv;
 
+       uid = e_cal_component_get_uid (comp);
        rid = e_cal_component_get_recurid_as_string (comp);
-       e_cal_component_get_uid (comp, &uid);
 
        g_rec_mutex_lock (&priv->idle_save_rmutex);
        res = e_intervaltree_remove (priv->interval_tree, uid, rid);
@@ -701,11 +710,11 @@ add_component (ECalBackendFile *cbfile,
 {
        ECalBackendFilePrivate *priv;
        ECalBackendFileObject *obj_data;
-       const gchar *uid = NULL;
+       const gchar *uid;
 
        priv = cbfile->priv;
 
-       e_cal_component_get_uid (comp, &uid);
+       uid = e_cal_component_get_uid (comp);
 
        if (!uid) {
                g_warning ("The component does not have a valid UID skipping it\n");
@@ -1179,7 +1188,7 @@ notify_removals_cb (gpointer key,
 
                e_cal_backend_notify_component_removed (context->backend, id, old_obj_data->full_object, 
NULL);
 
-               e_cal_component_free_id (id);
+               e_cal_component_id_free (id);
        }
 }
 
@@ -1611,15 +1620,11 @@ static void
 match_object_sexp_to_component (gpointer value,
                                 gpointer data)
 {
-       ECalComponent * comp = value;
+       ECalComponent *comp = value;
        MatchObjectData *match_data = data;
        ETimezoneCache *timezone_cache;
-       const gchar *uid;
-
-       e_cal_component_get_uid (comp, &uid);
 
        g_return_if_fail (comp != NULL);
-
        g_return_if_fail (match_data->backend != NULL);
 
        timezone_cache = E_TIMEZONE_CACHE (match_data->backend);
@@ -2151,49 +2156,43 @@ static void
 sanitize_component (ECalBackendFile *cbfile,
                     ECalComponent *comp)
 {
-       ECalComponentDateTime dt;
-       icaltimezone *zone;
+       ECalComponentDateTime *dt;
+       ICalTimezone *zone;
 
        /* Check dtstart, dtend and due's timezone, and convert it to local
         * default timezone if the timezone is not in our builtin timezone
         * list */
-       e_cal_component_get_dtstart (comp, &dt);
-       if (dt.value && dt.tzid) {
-               zone = e_timezone_cache_get_timezone (
-                       E_TIMEZONE_CACHE (cbfile), dt.tzid);
+       dt = e_cal_component_get_dtstart (comp);
+       if (dt && e_cal_component_datetime_get_value (dt) && e_cal_component_datetime_get_tzid (dt)) {
+               zone = e_timezone_cache_get_timezone (E_TIMEZONE_CACHE (cbfile), 
e_cal_component_datetime_get_tzid (dt));
                if (!zone) {
-                       g_free ((gchar *) dt.tzid);
-                       dt.tzid = g_strdup ("UTC");
-                       e_cal_component_set_dtstart (comp, &dt);
+                       e_cal_component_datetime_set_tzid (dt, "UTC");
+                       e_cal_component_set_dtstart (comp, dt);
                }
        }
-       e_cal_component_free_datetime (&dt);
+       e_cal_component_datetime_free (dt);
 
-       e_cal_component_get_dtend (comp, &dt);
-       if (dt.value && dt.tzid) {
-               zone = e_timezone_cache_get_timezone (
-                       E_TIMEZONE_CACHE (cbfile), dt.tzid);
+       dt = e_cal_component_get_dtend (comp);
+       if (dt && e_cal_component_datetime_get_value (dt) && e_cal_component_datetime_get_tzid (dt)) {
+               zone = e_timezone_cache_get_timezone (E_TIMEZONE_CACHE (cbfile), 
e_cal_component_datetime_get_tzid (dt));
                if (!zone) {
-                       g_free ((gchar *) dt.tzid);
-                       dt.tzid = g_strdup ("UTC");
-                       e_cal_component_set_dtend (comp, &dt);
+                       e_cal_component_datetime_set_tzid (dt, "UTC");
+                       e_cal_component_set_dtend (comp, dt);
                }
        }
-       e_cal_component_free_datetime (&dt);
+       e_cal_component_datetime_free (dt);
 
-       e_cal_component_get_due (comp, &dt);
-       if (dt.value && dt.tzid) {
-               zone = e_timezone_cache_get_timezone (
-                       E_TIMEZONE_CACHE (cbfile), dt.tzid);
+       dt = e_cal_component_get_due (comp);
+       if (dt && e_cal_component_datetime_get_value (dt) && e_cal_component_datetime_get_tzid (dt)) {
+               zone = e_timezone_cache_get_timezone (E_TIMEZONE_CACHE (cbfile), 
e_cal_component_datetime_get_tzid (dt));
                if (!zone) {
-                       g_free ((gchar *) dt.tzid);
-                       dt.tzid = g_strdup ("UTC");
-                       e_cal_component_set_due (comp, &dt);
+                       e_cal_component_datetime_set_tzid (dt, "UTC");
+                       e_cal_component_set_due (comp, dt);
                }
        }
-       e_cal_component_free_datetime (&dt);
-       e_cal_component_abort_sequence (comp);
+       e_cal_component_datetime_free (dt);
 
+       e_cal_component_abort_sequence (comp);
 }
 
 static void
@@ -2347,7 +2346,7 @@ remove_object_instance_cb (gpointer key,
        RemoveRecurrenceData *rrdata = user_data;
 
        fromtt = icaltime_as_timet (icaltime_from_string (rrdata->rid));
-       instancett = icaltime_as_timet (get_rid_icaltime (instance));
+       instancett = get_rid_as_time_t (instance);
 
        if (fromtt > 0 && instancett > 0) {
                if ((rrdata->mod == E_CAL_OBJ_MOD_THIS_AND_PRIOR && instancett <= fromtt) ||
@@ -2918,7 +2917,7 @@ notify_comp_removed_cb (gpointer pecalcomp,
 
        e_cal_backend_notify_component_removed (backend, id, comp, NULL);
 
-       e_cal_component_free_id (id);
+       e_cal_component_id_free (id);
 }
 
 /* Remove_object handler for the file backend */
@@ -2967,8 +2966,8 @@ e_cal_backend_file_remove_objects (ECalBackendSync *backend,
        /* First step, validate the input */
        for (l = ids; l; l = l->next) {
                ECalComponentId *id = l->data;
-                               /* Make the ID contains a uid */
-               if (!id || !id->uid) {
+               /* Make the ID contains a uid */
+               if (!id || !e_cal_component_id_get_uid (id)) {
                        g_rec_mutex_unlock (&priv->idle_save_rmutex);
                        g_propagate_error (error, EDC_ERROR (ObjectNotFound));
                        return;
@@ -2976,13 +2975,13 @@ e_cal_backend_file_remove_objects (ECalBackendSync *backend,
                                /* Check that it has a recurrence id if mod is E_CAL_OBJ_MOD_THIS_AND_PRIOR
                                         or E_CAL_OBJ_MOD_THIS_AND_FUTURE */
                if ((mod == E_CAL_OBJ_MOD_THIS_AND_PRIOR || mod == E_CAL_OBJ_MOD_THIS_AND_FUTURE) &&
-                       (!id->rid || !*(id->rid))) {
+                   !e_cal_component_id_get_rid (id)) {
                        g_rec_mutex_unlock (&priv->idle_save_rmutex);
                        g_propagate_error (error, EDC_ERROR (ObjectNotFound));
                        return;
                }
                                /* Make sure the uid exists in the local hash table */
-               if (!g_hash_table_lookup (priv->comp_uid_hash, id->uid)) {
+               if (!g_hash_table_lookup (priv->comp_uid_hash, e_cal_component_id_get_uid (id))) {
                        g_rec_mutex_unlock (&priv->idle_save_rmutex);
                        g_propagate_error (error, EDC_ERROR (ObjectNotFound));
                        return;
@@ -2997,10 +2996,8 @@ e_cal_backend_file_remove_objects (ECalBackendSync *backend,
                ECalBackendFileObject *obj_data;
                ECalComponentId *id = l->data;
 
-               obj_data = g_hash_table_lookup (priv->comp_uid_hash, id->uid);
-
-               if (id->rid && *(id->rid))
-                       recur_id = id->rid;
+               obj_data = g_hash_table_lookup (priv->comp_uid_hash, e_cal_component_id_get_uid (id));
+               recur_id = e_cal_component_id_get_rid (id);
 
                switch (mod) {
                case E_CAL_OBJ_MOD_ALL :
@@ -3009,7 +3006,7 @@ e_cal_backend_file_remove_objects (ECalBackendSync *backend,
 
                        if (obj_data->recurrences_list)
                                g_list_foreach (obj_data->recurrences_list, notify_comp_removed_cb, cbfile);
-                       remove_component (cbfile, id->uid, obj_data);
+                       remove_component (cbfile, e_cal_component_id_get_uid (id), obj_data);
                        break;
                case E_CAL_OBJ_MOD_ONLY_THIS:
                case E_CAL_OBJ_MOD_THIS: {
@@ -3017,7 +3014,7 @@ e_cal_backend_file_remove_objects (ECalBackendSync *backend,
                        ECalComponent *new_component = NULL;
 
                        remove_instance (
-                               cbfile, obj_data, id->uid, recur_id, mod,
+                               cbfile, obj_data, e_cal_component_id_get_uid (id), recur_id, mod,
                                &old_component, &new_component, error);
 
                        *old_components = g_slist_prepend (*old_components, old_component);
@@ -3092,17 +3089,17 @@ cancel_received_object (ECalBackendFile *cbfile,
        ECalBackendFileObject *obj_data;
        ECalBackendFilePrivate *priv;
        gchar *rid;
-       const gchar *uid = NULL;
+       const gchar *uid;
 
        priv = cbfile->priv;
 
        *old_comp = NULL;
        *new_comp = NULL;
 
-       e_cal_component_get_uid (comp, &uid);
+       uid = e_cal_component_get_uid (comp);
 
        /* Find the old version of the component. */
-       obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid);
+       obj_data = uid ? g_hash_table_lookup (priv->comp_uid_hash, uid) : NULL;
        if (!obj_data)
                return FALSE;
 
@@ -3153,21 +3150,26 @@ static void
 fetch_attachments (ECalBackendSync *backend,
                    ECalComponent *comp)
 {
-       GSList *attach_list = NULL, *new_attach_list = NULL;
+       GSList *attach_list;
        GSList *l;
        gchar *dest_url, *dest_file;
        gint fd, fileindex;
        const gchar *uid;
 
-       e_cal_component_get_attachment_list (comp, &attach_list);
-       e_cal_component_get_uid (comp, &uid);
+       attach_list = e_cal_component_get_attachments (comp);
+       uid = e_cal_component_get_uid (comp);
 
        for (l = attach_list, fileindex = 0; l; l = l->next, fileindex++) {
-               gchar *sfname = g_filename_from_uri ((const gchar *) l->data, NULL, NULL);
+               ICalAttach *attach = l->data;
+               gchar *sfname;
                gchar *filename;
                GMappedFile *mapped_file;
                GError *error = NULL;
 
+               if (!attach || !i_cal_attach_get_is_url (attach))
+                       continue;
+
+               sfname = g_filename_from_uri (i_cal_attach_get_url (attach), NULL, NULL)
                if (!sfname)
                        continue;
 
@@ -3201,11 +3203,14 @@ fetch_attachments (ECalBackendSync *backend,
                        close (fd);
                dest_url = g_filename_to_uri (dest_file, NULL, NULL);
                g_free (dest_file);
-               new_attach_list = g_slist_append (new_attach_list, dest_url);
+
+               i_cal_attach_set_uri (attach, dest_url);
+
+               g_free (dest_url);
                g_free (sfname);
        }
 
-       e_cal_component_set_attachment_list (comp, new_attach_list);
+       g_slist_free_full (attach_list, g_object_unref);
 }
 
 static gint
@@ -3246,7 +3251,6 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend,
        icalcomponent *subcomp;
        GList *comps, *del_comps, *l;
        ECalComponent *comp;
-       struct icaltimetype current;
        ECalBackendFileTzidData tzdata;
        GError *err = NULL;
 
@@ -3387,6 +3391,7 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend,
        for (l = comps; l; l = l->next) {
                ECalComponent *old_component = NULL;
                ECalComponent *new_component = NULL;
+               ICalTimetype *current;
                const gchar *uid;
                gchar *rid;
                ECalBackendFileObject *obj_data;
@@ -3399,18 +3404,20 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend,
                e_cal_component_set_icalcomponent (comp, subcomp);
 
                /* 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)) {
                        /* 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);
+                       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_last_modified (comp, current);
                }
 
-               e_cal_component_get_uid (comp, &uid);
+               g_clear_object (&current);
+
+               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))
@@ -3459,7 +3466,7 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend,
                                                                                id, old_component,
                                                                                rid ? comp : NULL);
 
-                                       e_cal_component_free_id (id);
+                                       e_cal_component_id_free (id);
                                        g_object_unref (comp);
                                }
 
@@ -3505,7 +3512,7 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend,
 
                                /* remove the component from the toplevel VCALENDAR */
                                icalcomponent_remove_component (priv->icalcomp, subcomp);
-                               e_cal_component_free_id (id);
+                               e_cal_component_id_free (id);
 
                                if (new_component)
                                        g_object_unref (new_component);
@@ -3867,7 +3874,7 @@ write_list (GSList *list)
                const gchar *str = l->data;
                ECalComponent *comp = e_cal_component_new_from_string (str);
                const gchar *uid;
-               e_cal_component_get_uid (comp, &uid);
+               uid = e_cal_component_get_uid (comp);
                g_print ("%s\n", uid);
        }
 }
@@ -3884,14 +3891,14 @@ get_difference_of_lists (ECalBackendFile *cbfile,
                const gchar *uid;
                ECalComponent *comp = e_cal_component_new_from_string (str);
                gboolean found = FALSE;
-               e_cal_component_get_uid (comp, &uid);
+               uid = e_cal_component_get_uid (comp);
 
                for (lsmaller = smaller; lsmaller && !found; lsmaller = lsmaller->next)
                {
                        gchar *strsmaller = lsmaller->data;
                        const gchar *uidsmaller;
                        ECalComponent *compsmaller = e_cal_component_new_from_string (strsmaller);
-                       e_cal_component_get_uid (compsmaller, &uidsmaller);
+                       uidsmaller = e_cal_component_get_uid (compsmaller);
 
                        found = strcmp (uid, uidsmaller) == 0;
 
diff --git a/src/calendar/backends/gtasks/e-cal-backend-gtasks.c 
b/src/calendar/backends/gtasks/e-cal-backend-gtasks.c
index cc519a8da..afa3ef4d4 100644
--- a/src/calendar/backends/gtasks/e-cal-backend-gtasks.c
+++ b/src/calendar/backends/gtasks/e-cal-backend-gtasks.c
@@ -723,13 +723,13 @@ ecb_gtasks_get_changes_sync (ECalMetaBackend *meta_backend,
                                        object = e_cal_component_get_as_string (new_comp);
 
                                        if (cached_comp) {
-                                               struct icaltimetype *cached_tt = NULL, *new_tt = NULL;
+                                               ICalTimetype *cached_tt, *new_tt;
 
-                                               e_cal_component_get_last_modified (cached_comp, &cached_tt);
-                                               e_cal_component_get_last_modified (new_comp, &new_tt);
+                                               cached_tt = e_cal_component_get_last_modified (cached_comp);
+                                               new_tt = e_cal_component_get_last_modified (new_comp);
 
                                                if (!cached_tt || !new_tt ||
-                                                   icaltime_compare (*cached_tt, *new_tt) != 0) {
+                                                   i_cal_time_compare (cached_tt, new_tt) != 0) {
                                                        /* Google doesn't store/provide 'created', thus use 
'created,
                                                           as first seen by the backend' */
                                                        if (cached_tt)
@@ -739,10 +739,8 @@ ecb_gtasks_get_changes_sync (ECalMetaBackend *meta_backend,
                                                                e_cal_meta_backend_info_new (uid, revision, 
object, NULL));
                                                }
 
-                                               if (cached_tt)
-                                                       e_cal_component_free_icaltimetype (cached_tt);
-                                               if (new_tt)
-                                                       e_cal_component_free_icaltimetype (new_tt);
+                                               g_clear_object (&cached_tt);
+                                               g_clear_object (&new_tt);
                                        } else {
                                                *out_created_objects = g_slist_prepend (*out_created_objects,
                                                        e_cal_meta_backend_info_new (uid, revision, object, 
NULL));
diff --git a/src/calendar/backends/weather/e-cal-backend-weather.c 
b/src/calendar/backends/weather/e-cal-backend-weather.c
index 48e614bad..39158d0b0 100644
--- a/src/calendar/backends/weather/e-cal-backend-weather.c
+++ b/src/calendar/backends/weather/e-cal-backend-weather.c
@@ -204,7 +204,7 @@ finished_retrieval_cb (GWeatherInfo *info,
 
                e_cal_backend_notify_component_removed (E_CAL_BACKEND (cbw), id, NULL, NULL);
        }
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_id_free);
        e_cache_remove_all (E_CACHE (priv->cache), NULL, NULL);
 
        comp = create_weather (cbw, info, unit, FALSE, NULL);
diff --git a/src/calendar/libecal/CMakeLists.txt b/src/calendar/libecal/CMakeLists.txt
index d0d5ab3cf..83ad92bb5 100644
--- a/src/calendar/libecal/CMakeLists.txt
+++ b/src/calendar/libecal/CMakeLists.txt
@@ -112,7 +112,7 @@ install(FILES ${HEADERS}
 )
 
 set(gir_sources ${SOURCES} ${HEADERS})
-set(gir_identifies_prefixes ECal)
+set(gir_identifies_prefixes ECal E)
 set(gir_includes GObject-2.0 Gio-2.0 Soup-2.4 libxml2-2.0 ICalGLib-3.0)
 set(gir_cflags
        -DLIBECAL_COMPILATION
@@ -121,7 +121,10 @@ set(gir_cflags
 )
 set(gir_libdirs)
 set(gir_libs ecal)
-set(gir_deps)
+set(gir_deps
+       ${CMAKE_BINARY_DIR}/src/camel/Camel-${API_VERSION}.gir
+       ${CMAKE_BINARY_DIR}/src/libedataserver/EDataServer-${API_VERSION}.gir
+)
 
 gir_add_introspection_simple(
        ECal
diff --git a/src/calendar/libecal/e-cal-check-timezones.h b/src/calendar/libecal/e-cal-check-timezones.h
index ba4b3c987..ec20f90f1 100644
--- a/src/calendar/libecal/e-cal-check-timezones.h
+++ b/src/calendar/libecal/e-cal-check-timezones.h
@@ -33,7 +33,7 @@ G_BEGIN_DECLS
 
 gboolean       e_cal_client_check_timezones_sync
                                                (ICalComponent *vcalendar,
-                                                GSList *comps, /* ICalComponent * */
+                                                GSList *icalcomps, /* ICalComponent * */
                                                 ECalRecurResolveTimezoneCb tzlookup,
                                                 gpointer tzlookup_data,
                                                 GCancellable *cancellable,
diff --git a/src/calendar/libecal/e-cal-component-datetime.c b/src/calendar/libecal/e-cal-component-datetime.c
index 708471397..9b49e3a56 100644
--- a/src/calendar/libecal/e-cal-component-datetime.c
+++ b/src/calendar/libecal/e-cal-component-datetime.c
@@ -196,8 +196,33 @@ e_cal_component_datetime_set_value (ECalComponentDateTime *dt,
        g_return_if_fail (dt != NULL);
        g_return_if_fail (I_CAL_IS_TIMETYPE (value));
 
-       g_clear_object (&dt->value);
-       dt->value = i_cal_timetype_new_clone (value);
+       if (dt->value != value) {
+               g_clear_object (&dt->value);
+               dt->value = i_cal_timetype_new_clone (value);
+       }
+}
+
+/**
+ * e_cal_component_datetime_take_value:
+ * @dt: an #ECalComponentDateTime
+ * @value: (not nullable) (transfer full): the value to take, as an #ICalTimetype
+ *
+ * Sets the @value of the @dt and assumes ownership of the @value.
+ * Any previously set value is freed.
+ *
+ * Since: 3.36
+ **/
+void
+e_cal_component_datetime_take_value (ECalComponentDateTime *dt,
+                                    ICalTimetype *value)
+{
+       g_return_if_fail (dt != NULL);
+       g_return_if_fail (I_CAL_IS_TIMETYPE (value));
+
+       if (dt->value != value) {
+               g_clear_object (&dt->value);
+               dt->value = value;
+       }
 }
 
 /**
@@ -205,9 +230,11 @@ e_cal_component_datetime_set_value (ECalComponentDateTime *dt,
  * @dt: an #ECalComponentDateTime
  *
  * Returns the TZID stored with the @dt. The string is owned by @dt and
- * it's valid until the @dt is freed or its TZID overwritten.
+ * it's valid until the @dt is freed or its TZID overwritten. It never
+ * returns an empty string, it returns either set TZID parameter value
+ * or %NULL, when none is set.
  *
- * Returns: (transfer none): a TZID of @dt
+ * Returns: (transfer none) (nullable): a TZID of @dt, or %NULL
  *
  * Since: 3.36
  **/
@@ -243,3 +270,30 @@ e_cal_component_datetime_set_tzid (ECalComponentDateTime *dt,
                dt->tzid = g_strdup (tzid);
        }
 }
+
+/**
+ * e_cal_component_datetime_take_tzid:
+ * @dt: an #ECalComponentDateTime
+ * @tzid: (nullable) (transfer full): the TZID to take, or %NULL
+ *
+ * Sets the @tzid of the @dt and assumes ownership of @tzid. Any previously
+ * set TZID is freed. An empty string or a %NULL as @tzid is treated as none TZID.
+ *
+ * Since: 3.36
+ **/
+void
+e_cal_component_datetime_take_tzid (ECalComponentDateTime *dt,
+                                   gchar *tzid)
+{
+       g_return_if_fail (dt != NULL);
+
+       if (tzid && !*tzid) {
+               g_free (tzid);
+               tzid = NULL;
+       }
+
+       if (tzid != dt->tzid) {
+               g_free (dt->tzid);
+               dt->tzid = tzid;
+       }
+}
diff --git a/src/calendar/libecal/e-cal-component-datetime.h b/src/calendar/libecal/e-cal-component-datetime.h
index 946248771..93b287ea1 100644
--- a/src/calendar/libecal/e-cal-component-datetime.h
+++ b/src/calendar/libecal/e-cal-component-datetime.h
@@ -57,11 +57,17 @@ ICalTimetype *      e_cal_component_datetime_get_value
 void           e_cal_component_datetime_set_value
                                                (ECalComponentDateTime *dt,
                                                 const ICalTimetype *value);
+void           e_cal_component_datetime_take_value
+                                               (ECalComponentDateTime *dt,
+                                                ICalTimetype *value);
 const gchar *  e_cal_component_datetime_get_tzid
                                                (const ECalComponentDateTime *dt);
 void           e_cal_component_datetime_set_tzid
                                                (ECalComponentDateTime *dt,
                                                 const gchar *tzid);
+void           e_cal_component_datetime_take_tzid
+                                               (ECalComponentDateTime *dt,
+                                                gchar *tzid);
 
 G_END_DECLS
 
diff --git a/src/calendar/libecal/e-cal-component-id.c b/src/calendar/libecal/e-cal-component-id.c
index 79e785bfb..86ee33f44 100644
--- a/src/calendar/libecal/e-cal-component-id.c
+++ b/src/calendar/libecal/e-cal-component-id.c
@@ -223,8 +223,10 @@ e_cal_component_id_set_uid (ECalComponentId *id,
        g_return_if_fail (id != NULL);
        g_return_if_fail (uid != NULL);
 
-       g_free (id->uid);
-       id->uid = g_strdup (uid);
+       if (g_strcmp0 (id->uid, uid) != 0) {
+               g_free (id->uid);
+               id->uid = g_strdup (uid);
+       }
 }
 
 /**
@@ -262,6 +264,8 @@ e_cal_component_id_set_rid (ECalComponentId *id,
 {
        g_return_if_fail (id != NULL);
 
-       g_free (id->rid);
-       id->rid = (rid && *rid) ? g_strdup (rid) : NULL;
+       if (g_strcmp0 (id->rid, rid) != 0) {
+               g_free (id->rid);
+               id->rid = (rid && *rid) ? g_strdup (rid) : NULL;
+       }
 }
diff --git a/src/calendar/libecal/e-cal-component.c b/src/calendar/libecal/e-cal-component.c
index 9a77c9492..2d2f129e8 100644
--- a/src/calendar/libecal/e-cal-component.c
+++ b/src/calendar/libecal/e-cal-component.c
@@ -865,7 +865,8 @@ get_attachments_cb (ICalComponent *icalcomp,
  * e_cal_component_get_attachments:
  * @comp: A calendar component object
  *
- * Queries the attachment properties of the calendar component object.
+ * Queries the attachment properties as #ICalAttach objects of the calendar
+ * component object. Changes on these objects are directly affecting the component.
  * Free the returned #GSList with g_slist_free_full (slist, g_object_unref);,
  * when no longer needed.
  *
diff --git a/src/calendar/libecal/e-reminder-watcher.c b/src/calendar/libecal/e-reminder-watcher.c
index 158a10a4d..eb4b107f1 100644
--- a/src/calendar/libecal/e-reminder-watcher.c
+++ b/src/calendar/libecal/e-reminder-watcher.c
@@ -2189,7 +2189,7 @@ e_reminder_watcher_class_init (EReminderWatcherClass *klass)
        g_object_class_install_property (
                object_class,
                PROP_DEFAULT_ZONE,
-               g_param_spec_boxed (
+               g_param_spec_object (
                        "default-zone",
                        "Default Zone",
                        "The default time zone",
@@ -2252,7 +2252,7 @@ e_reminder_watcher_class_init (EReminderWatcherClass *klass)
        /**
         * EReminderWatcher::triggered:
         * @watcher: an #EReminderWatcher
-        * @reminders: (element-type EReminderData): a #GSList of #EReminderData
+        * @reminders: (type GSList) (element-type EReminderData): a #GSList of #EReminderData
         * @snoozed: %TRUE, when the @reminders had been snoozed, %FALSE otherwise
         *
         * Signal is emitted when any reminder is either overdue or triggered.
@@ -2356,11 +2356,11 @@ e_reminder_watcher_get_registry (EReminderWatcher *watcher)
 }
 
 /**
- * e_reminders_widget_ref_opened_client:
+ * e_reminder_watcher_ref_opened_client:
  * @watcher: an #EReminderWatcher
  * @source_uid: an #ESource UID of the calendar to return
  *
- * Returns: (nullable) (transfer full): a referenced #ECalClient for the @source_uid,
+ * Returns: (transfer full) (nullable): a referenced #ECalClient for the @source_uid,
  *    if any such is opened; %NULL otherwise.
  *
  * Since: 3.30
diff --git a/src/calendar/libecal/libecal.h b/src/calendar/libecal/libecal.h
index 7bc156486..f3abf2bb8 100644
--- a/src/calendar/libecal/libecal.h
+++ b/src/calendar/libecal/libecal.h
@@ -20,6 +20,8 @@
 
 #define __LIBECAL_H_INSIDE__
 
+#define LIBICAL_GLIB_UNSTABLE_API 1
+
 #include <libical-glib/libical-glib.h>
 #include <libedataserver/libedataserver.h>
 
@@ -48,7 +50,8 @@
 #include <libecal/e-reminder-watcher.h>
 #include <libecal/e-timezone-cache.h>
 
+#undef LIBICAL_GLIB_UNSTABLE_API
+
 #undef __LIBECAL_H_INSIDE__
 
 #endif /* LIBECAL_H */
-
diff --git a/src/calendar/libedata-cal/e-cal-backend-intervaltree.c 
b/src/calendar/libedata-cal/e-cal-backend-intervaltree.c
index b94cea02b..0615d44f2 100644
--- a/src/calendar/libedata-cal/e-cal-backend-intervaltree.c
+++ b/src/calendar/libedata-cal/e-cal-backend-intervaltree.c
@@ -508,7 +508,7 @@ e_intervaltree_insert (EIntervalTree *tree,
 
        g_rec_mutex_lock (&tree->priv->mutex);
 
-       e_cal_component_get_uid (comp, &uid);
+       uid = e_cal_component_get_uid (comp);
        rid = e_cal_component_get_recurid_as_string (comp);
        e_intervaltree_remove (tree, uid, rid);
 
diff --git a/src/calendar/libedata-cal/e-cal-backend-sexp.c b/src/calendar/libedata-cal/e-cal-backend-sexp.c
index b7b1f0b7f..ca08cbbd1 100644
--- a/src/calendar/libedata-cal/e-cal-backend-sexp.c
+++ b/src/calendar/libedata-cal/e-cal-backend-sexp.c
@@ -72,7 +72,7 @@ func_uid (ESExp *esexp,
           gpointer data)
 {
        SearchContext *ctx = data;
-       const gchar *uid = NULL, *arg_uid;
+       const gchar *uid, *arg_uid;
        gboolean equal;
        ESExpResult *result;
 
@@ -94,7 +94,7 @@ func_uid (ESExp *esexp,
        }
 
        arg_uid = argv[0]->value.string;
-       e_cal_component_get_uid (ctx->comp, &uid);
+       uid = e_cal_component_get_uid (ctx->comp);
 
        if (!arg_uid && !uid)
                equal = TRUE;
@@ -125,7 +125,7 @@ check_instance_time_range_cb (ECalComponent *comp,
        return FALSE;
 }
 
-static icaltimezone *
+static ICalTimezone *
 resolve_tzid (const gchar *tzid,
               gpointer user_data)
 {
@@ -304,8 +304,8 @@ func_due_in_time_range (ESExp *esexp,
        SearchContext *ctx = data;
        time_t start, end;
        ESExpResult *result;
-       icaltimezone *zone;
-       ECalComponentDateTime dt;
+       ICalTimezone *zone;
+       ECalComponentDateTime *dt;
        time_t due_t;
        gboolean retval;
 
@@ -337,17 +337,17 @@ func_due_in_time_range (ESExp *esexp,
        }
 
        end = argv[1]->value.time;
-       e_cal_component_get_due (ctx->comp, &dt);
+       dt = e_cal_component_get_due (ctx->comp);
 
-       if (dt.value != NULL) {
-               zone = resolve_tzid (dt.tzid, ctx);
+       if (dt && e_cal_component_datetime_get_value (dt)) {
+               zone = resolve_tzid (e_cal_component_datetime_get_tzid (dt), ctx);
                if (zone)
-                       due_t = icaltime_as_timet_with_zone (*dt.value,zone);
+                       due_t = i_cal_time_as_timet_with_zone (e_cal_component_datetime_get_value (dt), zone);
                else
-                       due_t = icaltime_as_timet (*dt.value);
+                       due_t = i_cal_time_as_timet (e_cal_component_datetime_get_value (dt));
        }
 
-       if (dt.value != NULL && (due_t <= end && due_t >= start))
+       if (dt && e_cal_component_datetime_get_value (dt) && (due_t <= end && due_t >= start))
                retval = TRUE;
        else
                retval = FALSE;
@@ -355,7 +355,7 @@ func_due_in_time_range (ESExp *esexp,
        result = e_sexp_result_new (esexp, ESEXP_RES_BOOL);
        result->value.boolean = retval;
 
-       e_cal_component_free_datetime (&dt);
+       e_cal_component_datetime_free (dt);
 
        return result;
 }
@@ -366,16 +366,13 @@ matches_text_list (GSList *text_list,
                    const gchar *str)
 {
        GSList *l;
-       gboolean matches;
-
-       matches = FALSE;
+       gboolean matches = FALSE;
 
        for (l = text_list; l; l = l->next) {
-               ECalComponentText *text;
-
-               text = l->data;
+               ECalComponentText *text = l->data;
 
-               if (text && e_util_utf8_strstrcasedecomp (text->value, str) != NULL) {
+               if (text && e_cal_component_text_get_value (text) &&
+                   e_util_utf8_strstrcasedecomp (e_cal_component_tet_get_value (text), str) != NULL) {
                        matches = TRUE;
                        break;
                }
@@ -392,9 +389,9 @@ matches_comment (ECalComponent *comp,
        GSList *list;
        gboolean matches;
 
-       e_cal_component_get_comment_list (comp, &list);
+       list = e_cal_component_get_comments (comp);
        matches = matches_text_list (list, str);
-       e_cal_component_free_text_list (list);
+       g_slist_free_full (list, e_cal_component_text_free);
 
        return matches;
 }
@@ -407,9 +404,9 @@ matches_description (ECalComponent *comp,
        GSList *list;
        gboolean matches;
 
-       e_cal_component_get_description_list (comp, &list);
+       list = e_cal_component_get_descriptions (comp);
        matches = matches_text_list (list, str);
-       e_cal_component_free_text_list (list);
+       g_slist_free_full (list, e_cal_component_text_free);
 
        return matches;
 }
@@ -421,22 +418,24 @@ matches_attendee (ECalComponent *comp,
        GSList *a_list = NULL, *l;
        gboolean matches = FALSE;
 
-       e_cal_component_get_attendee_list (comp, &a_list);
+       a_list = e_cal_component_get_attendees (comp);
 
        for (l = a_list; l; l = l->next) {
                ECalComponentAttendee *att = l->data;
 
-               if ((att->value && e_util_utf8_strstrcasedecomp (att->value, str)) ||
-                   (att->cn != NULL && e_util_utf8_strstrcasedecomp (att->cn, str))) {
+               if (!att)
+                       continue;
+
+               if ((e_cal_component_attendee_get_value (att) && e_util_utf8_strstrcasedecomp 
(e_cal_component_attendee_get_value (att), str)) ||
+                   (e_cal_component_attendee_get_cn (att) && e_util_utf8_strstrcasedecomp 
(e_cal_component_attendee_get_cn (att), str))) {
                        matches = TRUE;
                        break;
                }
        }
 
-       e_cal_component_free_attendee_list (a_list);
+       g_slist_free_full (a_list, e_cal_component_attendee_free);
 
        return matches;
-
 }
 
 static gboolean
@@ -444,17 +443,22 @@ matches_organizer (ECalComponent *comp,
                    const gchar *str)
 {
 
-       ECalComponentOrganizer org;
+       ECalComponentOrganizer *org;
+       gboolean matches;
 
-       e_cal_component_get_organizer (comp, &org);
        if (str && !*str)
                return TRUE;
 
-       if ((org.value && e_util_utf8_strstrcasedecomp (org.value, str)) ||
-           (org.cn && e_util_utf8_strstrcasedecomp (org.cn, str)))
-               return TRUE;
+       org = e_cal_component_get_organizer (comp);
+       if (!org)
+               return FALSE;
 
-       return FALSE;
+       matches = (e_cal_component_organizer_get_value (org) && e_util_utf8_strstrcasedecomp 
(e_cal_component_organizer_get_value (org), str)) ||
+                 (e_cal_component_organizer_get_cn (org) && e_util_utf8_strstrcasedecomp 
(e_cal_component_organizer_get_cn (org), str));
+
+       e_cal_component_organizer_free (org);
+
+       return matches;
 }
 
 static gboolean
@@ -476,7 +480,7 @@ matches_classification (ECalComponent *comp,
        else
                classification1 = E_CAL_COMPONENT_CLASS_UNKNOWN;
 
-       e_cal_component_get_classification (comp, &classification);
+       classification = e_cal_component_get_classification (comp);
 
        return (classification == classification1 ? TRUE : FALSE);
 }
@@ -486,17 +490,20 @@ static gboolean
 matches_summary (ECalComponent *comp,
                  const gchar *str)
 {
-       ECalComponentText text;
-
-       e_cal_component_get_summary (comp, &text);
+       ECalComponentText *text;
+       gboolean matches;
 
        if (!*str)
                return TRUE;
 
-       if (!text.value)
-               return FALSE;
+       text = e_cal_component_get_summary (comp);
+
+       matches = text && e_cal_component_text_get_value (text) &&
+                 e_util_utf8_strstrcasedecomp (e_cal_component_text_get_value (text), str) != NULL;
 
-       return e_util_utf8_strstrcasedecomp (text.value, str) != NULL;
+       e_cal_component_text_free (text);
+
+       return matches;
 }
 
 /* Returns whether the location in a component matches the specified string */
@@ -504,14 +511,16 @@ static gboolean
 matches_location (ECalComponent *comp,
                   const gchar *str)
 {
-       const gchar *location = NULL;
+       gchar *location;
+       gboolean matches;
 
-       e_cal_component_get_location (comp, &location);
+       location = e_cal_component_get_location (comp);
 
-       if (!location)
-               return FALSE;
+       matches = location && e_util_utf8_strstrcasedecomp (location, str) != NULL;
+
+       g_free (location);
 
-       return e_util_utf8_strstrcasedecomp (location, str) != NULL;
+       return matches;
 }
 
 /* Returns whether any text field in a component matches the specified string */
@@ -538,61 +547,59 @@ matches_priority (ECalComponent *comp ,const gchar *pr)
        gboolean res = FALSE;
        gint *priority = NULL;
 
-       e_cal_component_get_priority (comp, &priority);
+       priority = e_cal_component_get_priority (comp);
 
-       if (!priority)
+       if (priority == -1)
                return g_str_equal (pr, "UNDEFINED");
 
-       if (g_str_equal (pr, "HIGH") && *priority <= 4)
+       if (g_str_equal (pr, "HIGH") && priority <= 4)
                res = TRUE;
-       else if (g_str_equal (pr, "NORMAL") && *priority == 5)
+       else if (g_str_equal (pr, "NORMAL") && priority == 5)
                res = TRUE;
-       else if (g_str_equal (pr, "LOW") && *priority > 5)
+       else if (g_str_equal (pr, "LOW") && priority > 5)
                res = TRUE;
 
-       e_cal_component_free_priority (priority);
-
        return res;
 }
 
 static gboolean
 matches_status (ECalComponent *comp ,const gchar *str)
 {
-       icalproperty_status status;
+       ICalPropertyStatus status;
 
        if (!*str)
                return FALSE;
 
-       e_cal_component_get_status (comp, &status);
+       status = e_cal_component_get_status (comp);
 
        switch (status) {
-       case ICAL_STATUS_NONE:
+       case I_CAL_STATUS_NONE:
                return g_str_equal (str, "NOT STARTED");
-       case ICAL_STATUS_COMPLETED:
+       case I_CAL_STATUS_COMPLETED:
                return g_str_equal (str, "COMPLETED");
-       case ICAL_STATUS_CANCELLED:
+       case I_CAL_STATUS_CANCELLED:
                return g_str_equal (str, "CANCELLED");
-       case ICAL_STATUS_INPROCESS:
+       case I_CAL_STATUS_INPROCESS:
                return g_str_equal (str, "IN PROGRESS");
-       case ICAL_STATUS_NEEDSACTION:
+       case I_CAL_STATUS_NEEDSACTION:
                return g_str_equal (str, "NEEDS ACTION");
-       case ICAL_STATUS_TENTATIVE:
+       case I_CAL_STATUS_TENTATIVE:
                return g_str_equal (str, "TENTATIVE");
-       case ICAL_STATUS_CONFIRMED:
+       case I_CAL_STATUS_CONFIRMED:
                return g_str_equal (str, "CONFIRMED");
-       case ICAL_STATUS_DRAFT:
+       case I_CAL_STATUS_DRAFT:
                return g_str_equal (str, "DRAFT");
-       case ICAL_STATUS_FINAL:
+       case I_CAL_STATUS_FINAL:
                return g_str_equal (str, "FINAL");
-       case ICAL_STATUS_SUBMITTED:
+       case I_CAL_STATUS_SUBMITTED:
                return g_str_equal (str, "SUBMITTED");
-       case ICAL_STATUS_PENDING:
+       case I_CAL_STATUS_PENDING:
                return g_str_equal (str, "PENDING");
-       case ICAL_STATUS_FAILED:
+       case I_CAL_STATUS_FAILED:
                return g_str_equal (str, "FAILED");
-       case ICAL_STATUS_DELETED:
+       case I_CAL_STATUS_DELETED:
                return g_str_equal (str, "DELETED");
-       case ICAL_STATUS_X:
+       case I_CAL_STATUS_X:
                break;
        }
 
@@ -629,7 +636,7 @@ func_percent_complete (ESExp *esexp,
 {
        SearchContext *ctx = data;
        ESExpResult *result = NULL;
-       gint *percent;
+       gint percent;
 
        if (argc != 0) {
                e_sexp_fatal_error (
@@ -638,16 +645,10 @@ func_percent_complete (ESExp *esexp,
                return NULL;
        }
 
-       e_cal_component_get_percent (ctx->comp, &percent);
+       percent = e_cal_component_get_percent (ctx->comp);
 
        result = e_sexp_result_new (esexp, ESEXP_RES_INT);
-
-       if (percent) {
-               result->value.number = *percent;
-               e_cal_component_free_percent (percent);
-       } else {
-               result->value.number = -1;
-       }
+       result->value.number = percent;
 
        return result;
 }
@@ -753,7 +754,7 @@ func_has_start (ESExp *esexp,
 {
        SearchContext *ctx = data;
        ESExpResult *result;
-       ECalComponentDateTime dt;
+       ECalComponentDateTime *dt;
 
        /* Check argument types */
 
@@ -764,10 +765,10 @@ func_has_start (ESExp *esexp,
                return NULL;
        }
 
-       e_cal_component_get_dtstart (ctx->comp, &dt);
+       dt = e_cal_component_get_dtstart (ctx->comp);
        result = e_sexp_result_new (esexp, ESEXP_RES_BOOL);
-       result->value.boolean = dt.value != NULL;
-       e_cal_component_free_datetime (&dt);
+       result->value.boolean = dt && e_cal_component_datetime_get_value (dt);
+       e_cal_component_datetime_free (dt);
 
        return result;
 }
@@ -925,7 +926,7 @@ func_has_categories (ESExp *esexp,
         * whether unfiled components are supposed to match.
         */
 
-       e_cal_component_get_categories_list (ctx->comp, &categories);
+       categories = e_cal_component_get_categories_list (ctx->comp);
        if (!categories) {
                result = e_sexp_result_new (esexp, ESEXP_RES_BOOL);
                result->value.boolean = unfiled;
@@ -940,7 +941,7 @@ func_has_categories (ESExp *esexp,
                result = e_sexp_result_new (esexp, ESEXP_RES_BOOL);
                result->value.boolean = FALSE;
 
-               e_cal_component_free_categories_list (categories);
+               g_slist_free_full (categories, g_free);
 
                return result;
        }
@@ -973,7 +974,7 @@ func_has_categories (ESExp *esexp,
                }
        }
 
-       e_cal_component_free_categories_list (categories);
+       g_slist_free_full (categories, g_free);
 
        result = e_sexp_result_new (esexp, ESEXP_RES_BOOL);
        result->value.boolean = matches;
@@ -1026,7 +1027,7 @@ func_is_completed (ESExp *esexp,
 {
        SearchContext *ctx = data;
        ESExpResult *result;
-       struct icaltimetype *t;
+       ICalTimetype *itt;
        gboolean complete = FALSE;
 
        /* Check argument types */
@@ -1038,16 +1039,16 @@ func_is_completed (ESExp *esexp,
                return NULL;
        }
 
-       e_cal_component_get_completed (ctx->comp, &t);
-       if (t) {
+       itt = e_cal_component_get_completed (ctx->comp);
+       if (itt) {
                complete = TRUE;
-               e_cal_component_free_icaltimetype (t);
+               g_obejct_unref (itt);
        } else {
-               icalproperty_status status = ICAL_STATUS_NONE;
+               ICalPropertyStatus status;
 
-               e_cal_component_get_status (ctx->comp, &status);
+               status = e_cal_component_get_status (ctx->comp);
 
-               complete = status == ICAL_STATUS_COMPLETED;
+               complete = status == I_CAL_STATUS_COMPLETED;
        }
 
        result = e_sexp_result_new (esexp, ESEXP_RES_BOOL);
@@ -1072,8 +1073,8 @@ func_completed_before (ESExp *esexp,
 {
        SearchContext *ctx = data;
        ESExpResult *result;
-       struct icaltimetype *tt;
-       icaltimezone *zone;
+       ICalTimetype *itt;
+       ICalTimezone *zone;
        gboolean retval = FALSE;
        time_t before_time, completed_time;
 
@@ -1093,13 +1094,14 @@ func_completed_before (ESExp *esexp,
                        "completed-before");
                return NULL;
        }
+
        before_time = argv[0]->value.time;
 
-       e_cal_component_get_completed (ctx->comp, &tt);
-       if (tt) {
+       itt = e_cal_component_get_completed (ctx->comp);
+       if (itt) {
                /* COMPLETED must be in UTC. */
-               zone = icaltimezone_get_utc_timezone ();
-               completed_time = icaltime_as_timet_with_zone (*tt, zone);
+               zone = i_cal_timezone_get_utc_timezone ();
+               completed_time = i_cal_time_as_timet_with_zone (itt, zone);
 
                /* We want to return TRUE if before_time is after
                 * completed_time. */
@@ -1107,7 +1109,7 @@ func_completed_before (ESExp *esexp,
                        retval = TRUE;
                }
 
-               e_cal_component_free_icaltimetype (tt);
+               g_object_unref (itt);
        }
 
        result = e_sexp_result_new (esexp, ESEXP_RES_BOOL);
diff --git a/src/calendar/libedata-cal/e-cal-backend.c b/src/calendar/libedata-cal/e-cal-backend.c
index b380d1076..1f41cd7d2 100644
--- a/src/calendar/libedata-cal/e-cal-backend.c
+++ b/src/calendar/libedata-cal/e-cal-backend.c
@@ -158,7 +158,7 @@ async_context_free (AsyncContext *async_context)
 
        g_slist_free_full (
                async_context->compid_list,
-               (GDestroyNotify) e_cal_component_free_id);
+               (GDestroyNotify) e_cal_component_id_free);
 
        g_slist_free_full (
                async_context->string_list,
@@ -3164,7 +3164,7 @@ e_cal_backend_remove_objects_finish (ECalBackend *backend,
                e_cal_backend_notify_component_removed (
                        backend, component_id, old_component, new_component);
 
-               e_cal_component_free_id (component_id);
+               e_cal_component_id_free (component_id);
                g_clear_object (&old_component);
                g_clear_object (&new_component);
        }
@@ -4408,12 +4408,11 @@ match_view_and_notify_component (EDataCalView *view,
        else if (new_match)
                e_data_cal_view_notify_components_added_1 (view, new_component);
        else if (old_match) {
-
                ECalComponentId *id = e_cal_component_get_id (old_component);
 
                e_data_cal_view_notify_objects_removed_1 (view, id);
 
-               e_cal_component_free_id (id);
+               e_cal_component_id_free (id);
        }
 }
 
diff --git a/src/calendar/libedata-cal/e-cal-cache.c b/src/calendar/libedata-cal/e-cal-cache.c
index 5802eb4aa..f5695ba13 100644
--- a/src/calendar/libedata-cal/e-cal-cache.c
+++ b/src/calendar/libedata-cal/e-cal-cache.c
@@ -507,56 +507,60 @@ e_cal_cache_get_ids (ECache *cache,
        return TRUE;
 }
 
-static icaltimezone *
+static ICalTimezone *
 ecc_resolve_tzid_cb (const gchar *tzid,
                     gpointer user_data)
 {
        ECalCache *cal_cache = user_data;
-       icaltimezone *zone = NULL;
+       ICalTimezone *zone = NULL;
 
        g_return_val_if_fail (E_IS_CAL_CACHE (cal_cache), NULL);
 
        if (e_cal_cache_get_timezone (cal_cache, tzid, &zone, NULL, NULL) && zone)
                return zone;
 
-       zone = icaltimezone_get_builtin_timezone (tzid);
+       zone = i_cal_timezone_get_builtin_timezone (tzid);
        if (!zone)
-               zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+               zone = i_cal_timezone_get_builtin_timezone_from_tzid (tzid);
        if (!zone) {
                tzid = e_cal_match_tzid (tzid);
-               zone = icaltimezone_get_builtin_timezone (tzid);
+               zone = i_cal_timezone_get_builtin_timezone (tzid);
        }
 
        if (!zone)
-               zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+               zone = i_cal_timezone_get_builtin_timezone_from_tzid (tzid);
 
        return zone;
 }
 
 static gchar *
-ecc_encode_itt_to_sql (struct icaltimetype itt)
+ecc_encode_itt_to_sql (ICalTimetype *itt)
 {
+       if (!itt)
+               return g_strdup ("00000000000000");
+
        return g_strdup_printf ("%04d%02d%02d%02d%02d%02d",
-               itt.year, itt.month, itt.day,
-               itt.hour, itt.minute, itt.second);
+               i_cal_timetype_get_year (itt), i_cal_timetype_get_month (itt), i_cal_timetype_get_day (itt),
+               i_cal_timetype_get_hour (itt), i_cal_timetype_get_minute (itt), i_cal_timetype_get_second 
(itt));
 }
 
 static gchar *
 ecc_encode_time_to_sql (ECalCache *cal_cache,
                        const ECalComponentDateTime *dt)
 {
-       struct icaltimetype itt;
-       icaltimezone *zone = NULL;
+       ICalTimetype *itt;
+       ICalTimezone *zone = NULL;
 
-       if (!dt || !dt->value)
+       if (!dt || !e_cal_component_datetime_get_value (dt))
                return NULL;
 
-       itt = *dt->value;
+       itt = e_cal_component_datetime_get_value (dt);
 
-       if (!itt.is_date && !icaltime_is_utc (itt) && dt->tzid && *dt->tzid)
-               zone = ecc_resolve_tzid_cb (dt->tzid, cal_cache);
+       if (i_cal_time_is_date (itt) && !i_cal_time_is_utc (itt) &&
+           e_cal_component_datetime_get_tzid (dt))
+               zone = ecc_resolve_tzid_cb (e_cal_component_datetime_get_tzid (dt), cal_cache);
 
-       icaltimezone_convert_time (&itt, zone, icaltimezone_get_utc_timezone ());
+       i_cal_timezone_convert_time (itt, zone, i_cal_timezone_get_utc_timezone ());
 
        return ecc_encode_itt_to_sql (itt);
 }
@@ -565,14 +569,19 @@ static gchar *
 ecc_encode_timet_to_sql (ECalCache *cal_cache,
                         time_t tt)
 {
-       struct icaltimetype itt;
+       ICalTimetype *itt;
+       gchar *res;
 
        if (tt <= 0)
                return NULL;
 
-       itt = icaltime_from_timet_with_zone (tt, FALSE, icaltimezone_get_utc_timezone ());
+       itt = i_cal_time_from_timet_with_zone (tt, FALSE, i_cal_timezone_get_utc_timezone ());
 
-       return ecc_encode_itt_to_sql (itt);
+       res = ecc_encode_itt_to_sql (itt);
+
+       g_clear_object (&itt);
+
+       return res;
 }
 
 static gchar *
@@ -589,10 +598,10 @@ ecc_extract_text_list (const GSList *list)
        for (link = list; link; link = g_slist_next (link)) {
                ECalComponentText *text = link->data;
 
-               if (text && text->value) {
+               if (text && e_cal_component_text_get_value (text)) {
                        gchar *str;
 
-                       str = e_util_utf8_decompose (text->value);
+                       str = e_util_utf8_decompose (e_cal_component_text_get_value (text));
                        if (str)
                                g_string_append (value, str);
                        g_free (str);
@@ -605,14 +614,14 @@ ecc_extract_text_list (const GSList *list)
 static gchar *
 ecc_extract_comment (ECalComponent *comp)
 {
-       GSList *list = NULL;
+       GSList *list;
        gchar *value;
 
        g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), NULL);
 
-       e_cal_component_get_comment_list (comp, &list);
+       list = e_cal_component_get_comments (comp);
        value = ecc_extract_text_list (list);
-       e_cal_component_free_text_list (list);
+       g_slist_free_full (list, e_cal_component_text_free);
 
        return value;
 }
@@ -620,14 +629,14 @@ ecc_extract_comment (ECalComponent *comp)
 static gchar *
 ecc_extract_description (ECalComponent *comp)
 {
-       GSList *list = NULL;
+       GSList *list;
        gchar *value;
 
        g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), NULL);
 
-       e_cal_component_get_description_list (comp, &list);
+       list = e_cal_component_get_descriptions (comp);
        value = ecc_extract_text_list (list);
-       e_cal_component_free_text_list (list);
+       g_slist_free_full (list, e_cal_component_text_free);
 
        return value;
 }
@@ -674,12 +683,12 @@ ecc_encode_mail (GString *out_value,
 static gchar *
 ecc_extract_attendees (ECalComponent *comp)
 {
-       GSList *attendees = NULL, *link;
+       GSList *attendees, *link;
        GString *value;
 
        g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), NULL);
 
-       e_cal_component_get_attendee_list (comp, &attendees);
+       attendees = e_cal_component_get_attendees (comp);
        if (!attendees)
                return NULL;
 
@@ -691,10 +700,10 @@ ecc_extract_attendees (ECalComponent *comp)
                if (!att)
                        continue;
 
-               ecc_encode_mail (value, att->cn, att->value);
+               ecc_encode_mail (value, e_cal_component_attendee_get_cn (att), 
e_cal_component_attendee_get_value (att));
        }
 
-       e_cal_component_free_attendee_list (attendees);
+       g_slist_free_full (attendees, e_cal_component_attendee_free);
 
        if (value->len) {
                /* This way it is encoded as:
@@ -709,19 +718,23 @@ ecc_extract_attendees (ECalComponent *comp)
 static gchar *
 ecc_extract_organizer (ECalComponent *comp)
 {
-       ECalComponentOrganizer org;
+       ECalComponentOrganizer *org;
        GString *value;
 
        g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), NULL);
 
-       e_cal_component_get_organizer (comp, &org);
+       org = e_cal_component_get_organizer (comp);
 
-       if (!org.value)
+       if (!org || !e_cal_component_organizer_get_value (org)) {
+               e_cal_component_organizer_free (org);
                return NULL;
+       }
 
        value = g_string_new ("");
 
-       ecc_encode_mail (value, org.cn, org.value);
+       ecc_encode_mail (value, e_cal_component_organizer_get_cn (org), e_cal_component_organizer_get_value 
(org));
+
+       e_cal_component_organizer_free (org);
 
        return g_string_free (value, !value->len);
 }
@@ -734,7 +747,7 @@ ecc_extract_categories (ECalComponent *comp)
 
        g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), NULL);
 
-       e_cal_component_get_categories_list (comp, &categories);
+       categories = e_cal_component_get_categories_list (comp);
 
        if (!categories)
                return NULL;
@@ -751,7 +764,7 @@ ecc_extract_categories (ECalComponent *comp)
                }
        }
 
-       e_cal_component_free_categories_list (categories);
+       g_slist_free_full (categories, g_free);
 
        if (value->len) {
                /* This way it is encoded as:
@@ -789,36 +802,36 @@ ecc_get_classification_as_string (ECalComponentClassification classification)
 }
 
 static const gchar *
-ecc_get_status_as_string (icalproperty_status status)
+ecc_get_status_as_string (ICalPropertyStatus status)
 {
        switch (status) {
-       case ICAL_STATUS_NONE:
+       case I_CAL_STATUS_NONE:
                return "not started";
-       case ICAL_STATUS_COMPLETED:
+       case I_CAL_STATUS_COMPLETED:
                return "completed";
-       case ICAL_STATUS_CANCELLED:
+       case I_CAL_STATUS_CANCELLED:
                return "cancelled";
-       case ICAL_STATUS_INPROCESS:
+       case I_CAL_STATUS_INPROCESS:
                return "in progress";
-       case ICAL_STATUS_NEEDSACTION:
+       case I_CAL_STATUS_NEEDSACTION:
                return "needs action";
-       case ICAL_STATUS_TENTATIVE:
+       case I_CAL_STATUS_TENTATIVE:
                return "tentative";
-       case ICAL_STATUS_CONFIRMED:
+       case I_CAL_STATUS_CONFIRMED:
                return "confirmed";
-       case ICAL_STATUS_DRAFT:
+       case I_CAL_STATUS_DRAFT:
                return "draft";
-       case ICAL_STATUS_FINAL:
+       case I_CAL_STATUS_FINAL:
                return "final";
-       case ICAL_STATUS_SUBMITTED:
+       case I_CAL_STATUS_SUBMITTED:
                return "submitted";
-       case ICAL_STATUS_PENDING:
+       case I_CAL_STATUS_PENDING:
                return "pending";
-       case ICAL_STATUS_FAILED:
+       case I_CAL_STATUS_FAILED:
                return "failed";
-       case ICAL_STATUS_DELETED:
+       case I_CAL_STATUS_DELETED:
                return "deleted";
-       case ICAL_STATUS_X:
+       case I_CAL_STATUS_X:
                break;
        }
 
@@ -831,14 +844,14 @@ ecc_fill_other_columns (ECalCache *cal_cache,
                        ECalComponent *comp)
 {
        time_t occur_start = -1, occur_end = -1;
-       ECalComponentDateTime dt;
-       ECalComponentText text;
+       ECalComponentDateTime *dt;
+       ECalComponentText *text;
        ECalComponentClassification classification = E_CAL_COMPONENT_CLASS_PUBLIC;
-       icalcomponent *icalcomp;
-       icalproperty_status status = ICAL_STATUS_NONE;
-       struct icaltimetype *itt;
-       const gchar *str = NULL;
-       gint *pint = NULL;
+       ICalComponent *icomp;
+       ICalPropertyStatus status = I_CAL_STATUS_NONE;
+       ICalTimetype *itt;
+       gchar *str = NULL;
+       gint nint;
        gboolean has;
 
        g_return_if_fail (E_IS_CAL_CACHE (cal_cache));
@@ -847,60 +860,55 @@ ecc_fill_other_columns (ECalCache *cal_cache,
 
        #define add_value(_col, _val) e_cache_column_values_take_value (other_columns, _col, _val)
 
-       icalcomp = e_cal_component_get_icalcomponent (comp);
+       icomp = e_cal_component_get_icalcomponent (comp);
 
        e_cal_util_get_component_occur_times (
                comp, &occur_start, &occur_end,
-               ecc_resolve_tzid_cb, cal_cache, icaltimezone_get_utc_timezone (),
-               icalcomponent_isa (icalcomp));
+               ecc_resolve_tzid_cb, cal_cache, i_cal_timezone_get_utc_timezone (),
+               i_cal_component_isa (icomp));
 
-       e_cal_component_get_dtstart (comp, &dt);
-       add_value (ECC_COLUMN_OCCUR_START, dt.value && ((dt.tzid && *dt.tzid) || icaltime_is_utc (*dt.value)) 
? ecc_encode_timet_to_sql (cal_cache, occur_start) : NULL);
+       dt = e_cal_component_get_dtstart (comp);
+       add_value (ECC_COLUMN_OCCUR_START, dt && e_cal_component_datetime_get_value (dt) &&
+               (e_cal_component_datetime_get_tzid (dt) || i_cal_time_is_utc 
(e_cal_component_datetime_get_value (dt)))
+               ? ecc_encode_timet_to_sql (cal_cache, occur_start) : NULL);
 
-       has = dt.value != NULL;
+       has = dt && e_cal_component_datetime_get_value (dt);
        add_value (ECC_COLUMN_HAS_START, g_strdup (has ? "1" : "0"));
-       e_cal_component_free_datetime (&dt);
+       e_cal_component_datetime_free (dt);
 
-       e_cal_component_get_dtend (comp, &dt);
-       add_value (ECC_COLUMN_OCCUR_END, dt.value && ((dt.tzid && *dt.tzid) || icaltime_is_utc (*dt.value)) ? 
ecc_encode_timet_to_sql (cal_cache, occur_end) : NULL);
-       e_cal_component_free_datetime (&dt);
+       dt = e_cal_component_get_dtend (comp);
+       add_value (ECC_COLUMN_OCCUR_END, dt && e_cal_component_datetime_get_value (dt) &&
+               (e_cal_component_datetime_get_tzid (dt) || i_cal_time_is_utc 
(e_cal_component_datetime_get_value (dt)))
+               ? ecc_encode_timet_to_sql (cal_cache, occur_end) : NULL);
+       e_cal_component_datetime_free (dt);
 
-       e_cal_component_get_due (comp, &dt);
-       add_value (ECC_COLUMN_DUE, ecc_encode_time_to_sql (cal_cache, &dt));
-       e_cal_component_free_datetime (&dt);
+       dt = e_cal_component_get_due (comp);
+       add_value (ECC_COLUMN_DUE, ecc_encode_time_to_sql (cal_cache, dt));
+       e_cal_component_datetime_free (dt);
 
-       itt = NULL;
-       e_cal_component_get_completed (comp, &itt);
-       add_value (ECC_COLUMN_COMPLETED, itt ? ecc_encode_itt_to_sql (*itt) : NULL);
-       if (itt)
-               e_cal_component_free_icaltimetype (itt);
+       itt = e_cal_component_get_completed (comp);
+       add_value (ECC_COLUMN_COMPLETED, itt ? ecc_encode_itt_to_sql (itt) : NULL);
+       g_clear_object (&itt);
 
-       text.value = NULL;
-       e_cal_component_get_summary (comp, &text);
-       add_value (ECC_COLUMN_SUMMARY, text.value ? e_util_utf8_decompose (text.value) : NULL);
+       text = e_cal_component_get_summary (comp);
+       add_value (ECC_COLUMN_SUMMARY, text && e_cal_component_text_get_value (text) ? e_util_utf8_decompose 
(e_cal_component_text_get_value (text)) : NULL);
+       e_cal_component_text_free (text);
 
-       e_cal_component_get_location (comp, &str);
+       str = e_cal_component_get_location (comp);
        add_value (ECC_COLUMN_LOCATION, str ? e_util_utf8_decompose (str) : NULL);
+       g_free (str);
 
-       e_cal_component_get_classification (comp, &classification);
+       classification = e_cal_component_get_classification (comp);
        add_value (ECC_COLUMN_CLASSIFICATION, g_strdup (ecc_get_classification_as_string (classification)));
 
-       e_cal_component_get_status (comp, &status);
+       status = e_cal_component_get_status (comp);
        add_value (ECC_COLUMN_STATUS, g_strdup (ecc_get_status_as_string (status)));
 
-       e_cal_component_get_priority (comp, &pint);
-       add_value (ECC_COLUMN_PRIORITY, pint && *pint ? g_strdup_printf ("%d", *pint) : NULL);
-       if (pint) {
-               e_cal_component_free_priority (pint);
-               pint = NULL;
-       }
+       nint = e_cal_component_get_priority (comp);
+       add_value (ECC_COLUMN_PRIORITY, nint != -1 ? g_strdup_printf ("%d", nint) : NULL);
 
-       e_cal_component_get_percent (comp, &pint);
-       add_value (ECC_COLUMN_PERCENT_COMPLETE, pint && *pint ? g_strdup_printf ("%d", *pint) : NULL);
-       if (pint) {
-               e_cal_component_free_percent (pint);
-               pint = NULL;
-       }
+       nint = e_cal_component_get_percent (comp);
+       add_value (ECC_COLUMN_PERCENT_COMPLETE, nint != -1 ? g_strdup_printf ("%d", nint) : NULL);
 
        has = e_cal_component_has_alarms (comp);
        add_value (ECC_COLUMN_HAS_ALARM, g_strdup (has ? "1" : "0"));
@@ -1790,7 +1798,7 @@ cal_cache_gather_v1_affected_cb (ECalCache *cal_cache,
 {
        ComponentInfo *ci = user_data;
        ECalComponent *comp;
-       ECalComponentDateTime dt;
+       ECalComponentDateTime *dt;
 
        g_return_val_if_fail (object != NULL, FALSE);
        g_return_val_if_fail (ci != NULL, FALSE);
@@ -1802,9 +1810,11 @@ cal_cache_gather_v1_affected_cb (ECalCache *cal_cache,
        if (!comp)
                return TRUE;
 
-       e_cal_component_get_due (comp, &dt);
+       dt = e_cal_component_get_due (comp);
 
-       if (dt.value && !icaltime_is_utc (*dt.value) && (!dt.tzid || !*dt.tzid)) {
+       if (dt && e_cal_component_datetime_get_value (dt) &&
+           !i_cal_time_is_utc (e_cal_component_datetime_get_value (dt)) &&
+           !e_cal_component_datetime_get_tzid (dt)) {
                GSList **pcomps, **pextras;
 
                if (offline_state == E_OFFLINE_STATE_SYNCED) {
@@ -1819,27 +1829,27 @@ cal_cache_gather_v1_affected_cb (ECalCache *cal_cache,
                *pextras = g_slist_prepend (*pextras, g_strdup (extra));
        }
 
-       e_cal_component_free_datetime (&dt);
+       e_cal_component_datetime_free (dt);
        g_object_unref (comp);
 
        return TRUE;
 }
 
-static icaltimezone *
+static ICalTimezone *
 ecc_timezone_from_string (const gchar *icalstring)
 {
-       icalcomponent *component;
+       ICalComponent *component;
 
        g_return_val_if_fail (icalstring != NULL, NULL);
 
-       component = icalcomponent_new_from_string (icalstring);
+       component = i_cal_component_new_from_string (icalstring);
        if (component) {
-               icaltimezone *zone;
+               i_cal_timezone *zone;
 
-               zone = icaltimezone_new ();
-               if (!icaltimezone_set_component (zone, component)) {
-                       icalcomponent_free (component);
-                       icaltimezone_free (zone, 1);
+               zone = i_cal_timezone_new ();
+               if (!i_cal_timezone_set_component (zone, component)) {
+                       g_object_unref (component);
+                       g_object_unref (zone);
                } else {
                        return zone;
                }
@@ -1853,15 +1863,15 @@ ecc_tzid_is_libical_builtin (const gchar *tzid)
 {
        const gchar *matched_tzid;
 
-       if (!tzid || !*tzid || icaltimezone_get_builtin_timezone (tzid))
+       if (!tzid || !*tzid || i_cal_timezone_get_builtin_timezone (tzid))
                return TRUE;
 
        matched_tzid = e_cal_match_tzid (tzid);
-       return matched_tzid && icaltimezone_get_builtin_timezone_from_tzid (matched_tzid);
+       return matched_tzid && i_cal_timezone_get_builtin_timezone_from_tzid (matched_tzid);
 }
 
 typedef struct _TimezoneMigrationData {
-       icaltimezone *zone;
+       ICalTimezone *zone;
        guint refs;
        gboolean is_deref; /* TRUE when should dereference, instead of reference, the timezone with refs 
references */
 } TimezoneMigrationData;
@@ -1872,8 +1882,7 @@ timezone_migration_data_free (gpointer ptr)
        TimezoneMigrationData *tmd = ptr;
 
        if (tmd) {
-               if (tmd->zone)
-                       icaltimezone_free (tmd->zone, 1);
+               g_clear_object (&tmd->zone);
                g_free (tmd);
        }
 }
@@ -1886,7 +1895,7 @@ typedef struct _CountTimezonesData {
 } CountTimezonesData;
 
 static void
-ecc_count_timezones_in_icalcomp_cb (icalparameter *param,
+ecc_count_timezones_in_icalcomp_cb (ICalParameter *param,
                                    gpointer user_data)
 {
        CountTimezonesData *ctd = user_data;
@@ -1895,7 +1904,7 @@ ecc_count_timezones_in_icalcomp_cb (icalparameter *param,
 
        g_return_if_fail (ctd != NULL);
 
-       tzid = icalparameter_get_tzid (param);
+       tzid = i_cal_parameter_get_tzid (param);
        if (!tzid)
                return;
 
@@ -1925,7 +1934,7 @@ ecc_count_timezones_in_icalcomp_cb (icalparameter *param,
                        }
                }
        } else if (!ecc_tzid_is_libical_builtin (tzid)) {
-               icaltimezone *zone = NULL;
+               ICalTimezone *zone = NULL;
 
                g_signal_emit (ctd->cal_cache, signals[GET_TIMEZONE], 0, tzid, &zone);
 
@@ -1933,25 +1942,8 @@ ecc_count_timezones_in_icalcomp_cb (icalparameter *param,
                        zone = NULL;
 
                /* Make a copy of it, it's not owned by the caller, but by the originator */
-               if (zone) {
-                       icalcomponent *zonecomp;
-
-                       zonecomp = icaltimezone_get_component (zone);
-                       if (zonecomp) {
-                               icalcomponent *clone;
-
-                               clone = icalcomponent_new_clone (zonecomp);
-                               /* icaltimezone_copy() doesn't carry over the component, thus do it this way 
*/
-                               zone = icaltimezone_new ();
-                               if (!icaltimezone_set_component (zone, clone)) {
-                                       icalcomponent_free (clone);
-                                       icaltimezone_free (zone, 1);
-                                       zone = NULL;
-                               }
-                       } else {
-                               zone = NULL;
-                       }
-               }
+               if (zone)
+                       zone = e_cal_util_copy_timezone (zone);
 
                if (zone) {
                        tmd = g_new0 (TimezoneMigrationData, 1);
@@ -1967,7 +1959,7 @@ ecc_count_timezones_in_icalcomp_cb (icalparameter *param,
 static void
 ecc_count_timezones_for_component (ECalCache *cal_cache,
                                   GHashTable *timezones,
-                                  icalcomponent *icalcomp,
+                                  ICalComponent *icomp,
                                   gboolean is_inc,
                                   GCancellable *cancellable)
 {
@@ -1982,7 +1974,7 @@ ecc_count_timezones_for_component (ECalCache *cal_cache,
                ctd.is_inc = is_inc;
                ctd.cancellable = cancellable;
 
-               icalcomponent_foreach_tzid (icalcomp, ecc_count_timezones_in_icalcomp_cb, &ctd);
+               i_cal_component_foreach_tzid (icomp, ecc_count_timezones_in_icalcomp_cb, &ctd);
        }
 }
 
@@ -2000,12 +1992,12 @@ ecc_count_timezones_for_old_component (ECalCache *cal_cache,
 
        objstr = e_cache_get_object_include_deleted (E_CACHE (cal_cache), uid_in_table, NULL, NULL, 
cancellable, NULL);
        if (objstr) {
-               icalcomponent *icalcomp;
+               ICalComponent *icomp;
 
-               icalcomp = icalcomponent_new_from_string (objstr);
-               if (icalcomp) {
-                       ecc_count_timezones_for_component (cal_cache, timezones, icalcomp, FALSE, 
cancellable);
-                       icalcomponent_free (icalcomp);
+               icomp = i_cal_component_new_from_string (objstr);
+               if (icomp) {
+                       ecc_count_timezones_for_component (cal_cache, timezones, icomp, FALSE, cancellable);
+                       g_object_unref (icomp);
                }
 
                g_free (objstr);
@@ -2058,7 +2050,7 @@ e_cal_cache_fill_tmd_cb (ECache *cache,
 
        /* Verify the timezone is not provided twice */
        if (!g_hash_table_lookup (timezones, column_values[0])) {
-               icaltimezone *zone;
+               ICalTimezone *zone;
 
                zone = ecc_timezone_from_string (column_values[1]);
                if (zone) {
@@ -2076,14 +2068,14 @@ e_cal_cache_fill_tmd_cb (ECache *cache,
 }
 
 static void
-ecc_count_tmd_refs_cb (icalparameter *param,
+ecc_count_tmd_refs_cb (ICalParameter *param,
                       gpointer user_data)
 {
        GHashTable *timezones = user_data;
        const gchar *tzid;
        TimezoneMigrationData *tmd;
 
-       tzid = icalparameter_get_tzid (param);
+       tzid = i_cal_parameter_get_tzid (param);
        if (!tzid || !timezones)
                return;
 
@@ -2103,15 +2095,15 @@ cal_cache_count_tmd_refs (ECalCache *cal_cache,
                          gpointer user_data)
 {
        GHashTable *timezones = user_data;
-       icalcomponent *icalcomp;
+       ICalComponent *icomp;
 
        g_return_val_if_fail (timezones != NULL, FALSE);
        g_return_val_if_fail (object != NULL, FALSE);
 
-       icalcomp = icalcomponent_new_from_string (object);
-       if (icalcomp) {
-               icalcomponent_foreach_tzid (icalcomp, ecc_count_tmd_refs_cb, timezones);
-               icalcomponent_free (icalcomp);
+       icomp = i_cal_component_new_from_string (object);
+       if (icomp) {
+               i_cal_component_foreach_tzid (icomp, ecc_count_tmd_refs_cb, timezones);
+               g_object_unref (icomp);
        }
 
        return TRUE;
@@ -2480,12 +2472,12 @@ e_cal_cache_put_components (ECalCache *cal_cache,
 
                id = e_cal_component_get_id (component);
                if (id) {
-                       uid = ecc_encode_id_sql (id->uid, id->rid);
+                       uid = ecc_encode_id_sql (e_cal_component_id_get_uid (id), e_cal_component_id_get_rid 
(id));
                } else {
                        g_warn_if_reached ();
                        uid = g_strdup ("");
                }
-               e_cal_component_free_id (id);
+               e_cal_component_id_free (id);
 
                rev = e_cal_cache_dup_component_revision (cal_cache, e_cal_component_get_icalcomponent 
(component));
 
@@ -2593,7 +2585,7 @@ e_cal_cache_remove_components (ECalCache *cal_cache,
                if (!id)
                        continue;
 
-               uid = ecc_encode_id_sql (id->uid, id->rid);
+               uid = ecc_encode_id_sql (e_cal_component_id_get_uid (id), e_cal_component_id_get_rid (id));
 
                success = e_cache_remove (cache, uid, offline_flag, cancellable, error);
 
@@ -2817,7 +2809,7 @@ e_cal_cache_get_component_extra (ECalCache *cal_cache,
  * Gets all the ID-s the @extra data is set for.
  *
  * The @out_ids should be freed with
- * g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+ * g_slist_free_full (ids, (GDestroyNotify) e_cal_component_id_free);
  * when no longer needed.
  *
  * Returns: Whether succeeded.
@@ -3240,7 +3232,7 @@ e_cal_cache_search_components (ECalCache *cal_cache,
  * Searches the @cal_cache with the given @sexp and returns ECalComponentId
  * for those components which satisfy the search expression.
  * The @out_ids should be freed with
- * g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+ * g_slist_free_full (ids, (GDestroyNotify) e_cal_component_id_free);
  * when no longer needed.
  *
  * Returns: Whether succeeded.
@@ -3267,7 +3259,7 @@ e_cal_cache_search_ids (ECalCache *cal_cache,
        if (success) {
                *out_ids = g_slist_reverse (*out_ids);
        } else {
-               g_slist_free_full (*out_ids, (GDestroyNotify) e_cal_component_free_id);
+               g_slist_free_full (*out_ids, (GDestroyNotify) e_cal_component_id_free);
                *out_ids = NULL;
        }
 
@@ -3912,14 +3904,13 @@ _e_cal_cache_remove_loaded_timezones (ECalCache *cal_cache)
  *
  * An #ECalRecurResolveTimezoneCb callback, which can be used
  * with e_cal_recur_generate_instances_sync(). The @cal_cache
- * is supposed to be an #ECalCache instance. See also
- * e_cal_cache_resolve_timezone_simple_cb().
+ * is supposed to be an #ECalCache instance.
  *
- * Returns: (transfer none) (nullable): the resolved icaltimezone, or %NULL, if not found
+ * Returns: (transfer none) (nullable): the resolved #ICalTimezone, or %NULL, if not found
  *
  * Since: 3.26
  **/
-icaltimezone *
+ICalTimezone *
 e_cal_cache_resolve_timezone_cb (const gchar *tzid,
                                 gpointer cal_cache,
                                 GCancellable *cancellable,
@@ -3927,29 +3918,6 @@ e_cal_cache_resolve_timezone_cb (const gchar *tzid,
 {
        g_return_val_if_fail (E_IS_CAL_CACHE (cal_cache), NULL);
 
-       return e_cal_cache_resolve_timezone_simple_cb (tzid, cal_cache);
-}
-
-/**
- * e_cal_cache_resolve_timezone_simple_cb:
- * @tzid: a timezone ID
- * @cal_cache: an #ECalCache
- *
- * An #ECalRecurResolveTimezoneFn callback, which can be used
- * with e_cal_recur_ensure_end_dates() and simialr functions.
- * The @cal_cache is supposed to be an #ECalCache instance. See
- * also e_cal_cache_resolve_timezone_cb().
- *
- * Returns: (transfer none) (nullable): the resolved icaltimezone, or %NULL, if not found
- *
- * Since: 3.26
- **/
-icaltimezone *
-e_cal_cache_resolve_timezone_simple_cb (const gchar *tzid,
-                                       gpointer cal_cache)
-{
-       g_return_val_if_fail (E_IS_CAL_CACHE (cal_cache), NULL);
-
        return e_timezone_cache_get_timezone (E_TIMEZONE_CACHE (cal_cache), tzid);
 }
 
diff --git a/src/calendar/libedata-cal/e-cal-cache.h b/src/calendar/libedata-cal/e-cal-cache.h
index 3cef7517b..995537eb5 100644
--- a/src/calendar/libedata-cal/e-cal-cache.h
+++ b/src/calendar/libedata-cal/e-cal-cache.h
@@ -55,7 +55,7 @@ typedef struct _ECalCachePrivate ECalCachePrivate;
  * @uid: UID of the component
  * @rid: Recurrence-ID of the component
  * @revision: stored revision of the component
- * @object: the component itself, as iCalalendar string
+ * @object: the component itself, as an iCalendar string
  * @state: an #EOfflineState of the component
  *
  * Holds the information about offline change for one component.
@@ -178,8 +178,8 @@ struct _ECalCacheClass {
        /* Signals */
        gchar *         (* dup_component_revision)
                                                (ECalCache *cal_cache,
-                                                icalcomponent *icalcomp);
-       icaltimezone *  (* get_timezone)        (ECalCache *cal_cache,
+                                                ICalComponent *icomp);
+       ICalTimezone *  (* get_timezone)        (ECalCache *cal_cache,
                                                 const gchar *tzid);
 
        /* Padding for future expansion */
@@ -193,7 +193,7 @@ ECalCache * e_cal_cache_new                 (const gchar *filename,
                                                 GError **error);
 gchar *                e_cal_cache_dup_component_revision
                                                (ECalCache *cal_cache,
-                                                icalcomponent *icalcomp);
+                                                ICalComponent *icomp);
 gboolean       e_cal_cache_contains            (ECalCache *cal_cache,
                                                 const gchar *uid,
                                                 const gchar *rid,
@@ -303,18 +303,18 @@ GSList *  e_cal_cache_get_offline_changes (ECalCache *cal_cache,
                                                 GCancellable *cancellable,
                                                 GError **error);
 gboolean       e_cal_cache_delete_attachments  (ECalCache *cal_cache,
-                                                icalcomponent *component,
+                                                ICalComponent *component,
                                                 GCancellable *cancellable,
                                                 GError **error);
 
 gboolean       e_cal_cache_put_timezone        (ECalCache *cal_cache,
-                                                const icaltimezone *zone,
+                                                const ICalTimezone *zone,
                                                 guint inc_ref_counts,
                                                 GCancellable *cancellable,
                                                 GError **error);
 gboolean       e_cal_cache_get_timezone        (ECalCache *cal_cache,
                                                 const gchar *tzid,
-                                                icaltimezone **out_zone,
+                                                ICalTimezone **out_zone,
                                                 GCancellable *cancellable,
                                                 GError **error);
 gboolean       e_cal_cache_dup_timezone_as_string
@@ -335,13 +335,10 @@ gboolean  e_cal_cache_remove_timezone     (ECalCache *cal_cache,
 gboolean       e_cal_cache_remove_timezones    (ECalCache *cal_cache,
                                                 GCancellable *cancellable,
                                                 GError **error);
-icaltimezone * e_cal_cache_resolve_timezone_cb (const gchar *tzid,
+ICalTimezone * e_cal_cache_resolve_timezone_cb (const gchar *tzid,
                                                 gpointer cal_cache,
                                                 GCancellable *cancellable,
                                                 GError **error);
-icaltimezone * e_cal_cache_resolve_timezone_simple_cb
-                                               (const gchar *tzid,
-                                                gpointer cal_cache);
 
 G_END_DECLS
 
diff --git a/src/calendar/libedata-cal/e-cal-meta-backend.c b/src/calendar/libedata-cal/e-cal-meta-backend.c
index 7f0796415..bc23b4a0e 100644
--- a/src/calendar/libedata-cal/e-cal-meta-backend.c
+++ b/src/calendar/libedata-cal/e-cal-meta-backend.c
@@ -640,15 +640,15 @@ ecmb_maybe_remove_from_cache (ECalMetaBackend *meta_backend,
                id = e_cal_component_get_id (comp);
                if (id) {
                        if (!e_cal_cache_delete_attachments (cal_cache, e_cal_component_get_icalcomponent 
(comp), cancellable, error) ||
-                           !e_cal_cache_remove_component (cal_cache, id->uid, id->rid, offline_flag, 
cancellable, error)) {
-                               e_cal_component_free_id (id);
+                           !e_cal_cache_remove_component (cal_cache, e_cal_component_id_get_uid (id), 
e_cal_component_id_get_rid (id), offline_flag, cancellable, error)) {
+                               e_cal_component_id_free (id);
                                g_slist_free_full (comps, g_object_unref);
 
                                return FALSE;
                        }
 
                        e_cal_backend_notify_component_removed (cal_backend, id, comp, NULL);
-                       e_cal_component_free_id (id);
+                       e_cal_component_id_free (id);
                }
        }
 
@@ -888,13 +888,13 @@ ecmb_find_in_instances (const GSList *instances, /* ECalComponent * */
                if (!id)
                        continue;
 
-               if (g_strcmp0 (id->uid, uid) == 0 &&
-                   g_strcmp0 (id->rid, rid) == 0) {
-                       e_cal_component_free_id (id);
+               if (g_strcmp0 (e_cal_component_id_get_uid (id), uid) == 0 &&
+                   g_strcmp0 (e_cal_component_id_get_rid (id), rid) == 0) {
+                       e_cal_component_id_free (id);
                        return comp;
                }
 
-               e_cal_component_free_id (id);
+               e_cal_component_id_free (id);
        }
 
        return NULL;
@@ -929,9 +929,9 @@ ecmb_put_one_component (ECalMetaBackend *meta_backend,
 
                id = e_cal_component_get_id (comp);
                if (id) {
-                       existing = ecmb_find_in_instances (*inout_cache_instances, id->uid, id->rid);
+                       existing = ecmb_find_in_instances (*inout_cache_instances, e_cal_component_id_get_uid 
(id), e_cal_component_id_get_rid (id));
 
-                       e_cal_component_free_id (id);
+                       e_cal_component_id_free (id);
                }
 
                if (existing) {
@@ -994,11 +994,11 @@ ecmb_put_instances (ECalMetaBackend *meta_backend,
                        if (!success)
                                break;
 
-                       success = e_cal_cache_remove_component (cal_cache, id->uid, id->rid, offline_flag, 
cancellable, error);
+                       success = e_cal_cache_remove_component (cal_cache, e_cal_component_id_get_uid (id), 
e_cal_component_id_get_rid (id), offline_flag, cancellable, error);
 
                        e_cal_backend_notify_component_removed (cal_backend, id, comp, NULL);
 
-                       e_cal_component_free_id (id);
+                       e_cal_component_id_free (id);
                }
        }
 
@@ -1750,28 +1750,28 @@ ecmb_modify_object_sync (ECalMetaBackend *meta_backend,
                return FALSE;
        }
 
-       if (!e_cal_cache_get_components_by_uid (cal_cache, id->uid, &instances, cancellable, &local_error)) {
+       if (!e_cal_cache_get_components_by_uid (cal_cache, e_cal_component_id_get_uid (id), &instances, 
cancellable, &local_error)) {
                if (g_error_matches (local_error, E_CACHE_ERROR, E_CACHE_ERROR_NOT_FOUND)) {
                        g_clear_error (&local_error);
                        local_error = e_data_cal_create_error (ObjectNotFound, NULL);
                }
 
                g_propagate_error (error, local_error);
-               e_cal_component_free_id (id);
+               e_cal_component_id_free (id);
 
                return FALSE;
        }
 
-       master_comp = ecmb_find_in_instances (instances, id->uid, NULL);
+       master_comp = ecmb_find_in_instances (instances, e_cal_component_id_get_uid (id), NULL);
        if (e_cal_component_is_instance (comp)) {
                /* Set detached instance as the old object */
-               existing_comp = ecmb_find_in_instances (instances, id->uid, id->rid);
+               existing_comp = ecmb_find_in_instances (instances, e_cal_component_id_get_uid (id), 
e_cal_component_id_get_rid (id));
 
                if (!existing_comp && mod == E_CAL_OBJ_MOD_ONLY_THIS) {
                        g_propagate_error (error, e_data_cal_create_error (ObjectNotFound, NULL));
 
                        g_slist_free_full (instances, g_object_unref);
-                       e_cal_component_free_id (id);
+                       e_cal_component_id_free (id);
 
                        return FALSE;
                }
@@ -1780,8 +1780,8 @@ ecmb_modify_object_sync (ECalMetaBackend *meta_backend,
        if (!existing_comp)
                existing_comp = master_comp;
 
-       if (!e_cal_cache_get_component_extra (cal_cache, id->uid, id->rid, &extra, cancellable, NULL) && 
id->rid) {
-               if (!e_cal_cache_get_component_extra (cal_cache, id->uid, NULL, &extra, cancellable, NULL))
+       if (!e_cal_cache_get_component_extra (cal_cache, e_cal_component_id_get_uid (id), 
e_cal_component_id_get_rid (id), &extra, cancellable, NULL) && id->rid) {
+               if (!e_cal_cache_get_component_extra (cal_cache, e_cal_component_id_get_uid (id), NULL, 
&extra, cancellable, NULL))
                        extra = NULL;
        }
 
@@ -1813,7 +1813,7 @@ ecmb_modify_object_sync (ECalMetaBackend *meta_backend,
                instances = g_slist_append (instances, e_cal_component_clone (comp));
                break;
        case E_CAL_OBJ_MOD_ALL:
-               e_cal_recur_ensure_end_dates (comp, TRUE, e_cal_cache_resolve_timezone_simple_cb, cal_cache);
+               e_cal_recur_ensure_end_dates (comp, TRUE, e_cal_cache_resolve_timezone_cb, cal_cache);
 
                /* Replace master object */
                instances = g_slist_remove (instances, master_comp);
@@ -1834,7 +1834,7 @@ ecmb_modify_object_sync (ECalMetaBackend *meta_backend,
 
                        if (mod == E_CAL_OBJ_MOD_THIS_AND_FUTURE &&
                            e_cal_util_is_first_instance (master_comp, icalcomponent_get_recurrenceid 
(icalcomp),
-                               e_cal_cache_resolve_timezone_simple_cb, cal_cache)) {
+                               e_cal_cache_resolve_timezone_cb, cal_cache)) {
                                icalproperty *prop = icalcomponent_get_first_property (icalcomp, 
ICAL_RECURRENCEID_PROPERTY);
 
                                if (prop)
@@ -1843,7 +1843,7 @@ ecmb_modify_object_sync (ECalMetaBackend *meta_backend,
                                e_cal_component_rescan (comp);
 
                                /* Then do it like for "mod_all" */
-                               e_cal_recur_ensure_end_dates (comp, TRUE, 
e_cal_cache_resolve_timezone_simple_cb, cal_cache);
+                               e_cal_recur_ensure_end_dates (comp, TRUE, e_cal_cache_resolve_timezone_cb, 
cal_cache);
 
                                /* Replace master */
                                instances = g_slist_remove (instances, master_comp);
@@ -1870,7 +1870,7 @@ ecmb_modify_object_sync (ECalMetaBackend *meta_backend,
                                rid = icaltime_convert_to_zone (rid, icaltimezone_get_utc_timezone ());
                                e_cal_util_remove_instances (e_cal_component_get_icalcomponent (master_comp), 
rid, mod);
                                e_cal_component_rescan (master_comp);
-                               e_cal_recur_ensure_end_dates (master_comp, TRUE, 
e_cal_cache_resolve_timezone_simple_cb, cal_cache);
+                               e_cal_recur_ensure_end_dates (master_comp, TRUE, 
e_cal_cache_resolve_timezone_cb, cal_cache);
 
                                if (out_new_comp) {
                                        g_clear_object (&new_comp);
@@ -1887,7 +1887,7 @@ ecmb_modify_object_sync (ECalMetaBackend *meta_backend,
 
                                g_warn_if_fail (e_cal_component_set_icalcomponent (comp, split_icalcomp));
 
-                               e_cal_recur_ensure_end_dates (comp, TRUE, 
e_cal_cache_resolve_timezone_simple_cb, cal_cache);
+                               e_cal_recur_ensure_end_dates (comp, TRUE, e_cal_cache_resolve_timezone_cb, 
cal_cache);
 
                                success = ecmb_create_object_sync (meta_backend, cal_cache, offline_flag, 
E_CONFLICT_RESOLUTION_FAIL,
                                        comp, NULL, NULL, cancellable, error);
@@ -1914,11 +1914,11 @@ ecmb_modify_object_sync (ECalMetaBackend *meta_backend,
 
        if (success && *offline_flag == E_CACHE_IS_ONLINE) {
                success = ecmb_save_component_wrapper_sync (meta_backend, cal_cache, TRUE, 
conflict_resolution,
-                       instances, extra, id->uid, &requires_put, &new_uid, &new_extra, cancellable, error);
+                       instances, extra, e_cal_component_id_get_uid (id), &requires_put, &new_uid, 
&new_extra, cancellable, error);
        }
 
        if (success && requires_put)
-               success = ecmb_put_instances (meta_backend, cal_cache, id->uid, *offline_flag, instances, 
new_extra ? new_extra : extra, cancellable, error);
+               success = ecmb_put_instances (meta_backend, cal_cache, e_cal_component_id_get_uid (id), 
*offline_flag, instances, new_extra ? new_extra : extra, cancellable, error);
 
        if (!success) {
                g_clear_object (&old_comp);
@@ -1929,7 +1929,7 @@ ecmb_modify_object_sync (ECalMetaBackend *meta_backend,
                *out_old_comp = old_comp;
        if (out_new_comp) {
                if (new_uid) {
-                       if (!e_cal_cache_get_component (cal_cache, new_uid, id->rid, out_new_comp, 
cancellable, NULL))
+                       if (!e_cal_cache_get_component (cal_cache, new_uid, e_cal_component_id_get_rid (id), 
out_new_comp, cancellable, NULL))
                                *out_new_comp = NULL;
                } else {
                        *out_new_comp = new_comp ? g_object_ref (new_comp) : NULL;
@@ -1937,7 +1937,7 @@ ecmb_modify_object_sync (ECalMetaBackend *meta_backend,
        }
 
        g_slist_free_full (instances, g_object_unref);
-       e_cal_component_free_id (id);
+       e_cal_component_id_free (id);
        g_clear_object (&new_comp);
        g_free (new_extra);
        g_free (new_uid);
@@ -2024,7 +2024,7 @@ ecmb_remove_object_sync (ECalMetaBackend *meta_backend,
                         GCancellable *cancellable,
                         GError **error)
 {
-       struct icaltimetype itt;
+       ICalTimetype *itt;
        ECalComponent *old_comp = NULL, *new_comp = NULL, *master_comp, *existing_comp = NULL;
        GSList *instances = NULL;
        gboolean success = TRUE;
@@ -2101,24 +2101,32 @@ ecmb_remove_object_sync (ECalMetaBackend *meta_backend,
                                success = FALSE;
                                g_propagate_error (error, e_data_cal_create_error (ObjectNotFound, NULL));
                        } else {
-                               itt = icaltime_from_string (rid);
-                               if (!itt.zone) {
-                                       ECalComponentDateTime dt;
-
-                                       e_cal_component_get_dtstart (master_comp, &dt);
-                                       if (dt.value && dt.tzid) {
-                                               icaltimezone *zone = e_cal_cache_resolve_timezone_simple_cb 
(dt.tzid, cal_cache);
-
-                                               if (zone)
-                                                       itt = icaltime_convert_to_zone (itt, zone);
+                               itt = i_cal_time_from_string (rid);
+                               if (itt && !i_cal_timetype_get_zone (itt)) {
+                                       ECalComponentDateTime *dt;
+                                       ICalTimetype *tmp_itt;
+
+                                       dt = e_cal_component_get_dtstart (master_comp);
+                                       if (dt && e_cal_component_datetime_get_value (dt) && 
e_cal_component_datetime_get_tzid (dt)) {
+                                               ICalTimezone *zone = e_cal_cache_resolve_timezone_cb 
(e_cal_component_datetime_get_tzid (dt), cal_cache);
+
+                                               if (zone) {
+                                                       tmp_itt = i_cal_time_convert_to_zone (itt, zone);
+                                                       g_object_unref (itt);
+                                                       itt = tmp_itt;
+                                               }
                                        }
-                                       e_cal_component_free_datetime (&dt);
+                                       e_cal_component_datetime_free (dt);
 
-                                       itt = icaltime_convert_to_zone (itt, icaltimezone_get_utc_timezone 
());
+                                       tmp_itt = i_cal_time_convert_to_zone (itt, 
i_cal_timezone_get_utc_timezone ());
+                                       g_object_unref (itt);
+                                       itt = tmp_itt;
                                }
 
                                if (master_comp)
-                                       e_cal_util_remove_instances (e_cal_component_get_icalcomponent 
(master_comp), itt, mod);
+                                       e_cal_util_component_remove_instances 
(e_cal_component_get_icalcomponent (master_comp), itt, mod);
+
+                               g_clear_object (&itt);
                        }
 
                        if (success && out_new_comp && (master_comp || existing_comp))
@@ -2133,30 +2141,37 @@ ecmb_remove_object_sync (ECalMetaBackend *meta_backend,
                        time_t fromtt, instancett;
                        GSList *link, *previous = instances;
 
-                       itt = icaltime_from_string (rid);
-                       if (!itt.zone) {
-                               ECalComponentDateTime dt;
+                       itt = i_cal_time_from_string (rid);
+                       if (itt && !i_cal_timetype_get_zone (itt)) {
+                               ECalComponentDateTime *dt;
+                               ICalTimetype *tmp_itt;
 
-                               e_cal_component_get_dtstart (master_comp, &dt);
-                               if (dt.value && dt.tzid) {
-                                       icaltimezone *zone = e_cal_cache_resolve_timezone_simple_cb (dt.tzid, 
cal_cache);
+                               dt = e_cal_component_get_dtstart (master_comp);
+                               if (dt && e_cal_component_datetime_get_value (dt) && 
e_cal_component_datetime_get_tzid (dt)) {
+                                       icaltimezone *zone = e_cal_cache_resolve_timezone_cb 
(e_cal_component_datetime_get_tzid (dt), cal_cache);
 
-                                       if (zone)
-                                               itt = icaltime_convert_to_zone (itt, zone);
+                                       if (zone) {
+                                               tmp_itt = i_cal_time_convert_to_zone (itt, zone);
+                                               g_object_unref (itt);
+                                               itt = tmp_itt;
+                                       }
                                }
-                               e_cal_component_free_datetime (&dt);
+                               e_cal_component_datetime_free (dt);
 
-                               itt = icaltime_convert_to_zone (itt, icaltimezone_get_utc_timezone ());
+                               tmp_itt = i_cal_time_convert_to_zone (itt, i_cal_timezone_get_utc_timezone 
());
+                               g_obejct_unref (itt);
+                               itt = tmp_itt;
                        }
 
                        e_cal_util_remove_instances (e_cal_component_get_icalcomponent (master_comp), itt, 
mod);
 
-                       fromtt = icaltime_as_timet (itt);
+                       fromtt = i_cal_time_as_timet (itt);
 
                        /* Remove detached instances */
                        for (link = instances; link && fromtt > 0;) {
                                ECalComponent *comp = link->data;
-                               ECalComponentRange range;
+                               ECalComponentRange *range;
+                               ECalComponentDatetime *rangedt;
 
                                if (!e_cal_component_is_instance (comp)) {
                                        previous = link;
@@ -2164,12 +2179,13 @@ ecmb_remove_object_sync (ECalMetaBackend *meta_backend,
                                        continue;
                                }
 
-                               e_cal_component_get_recurid (comp, &range);
-                               if (range.datetime.value)
-                                       instancett = icaltime_as_timet (*range.datetime.value);
+                               range = e_cal_component_get_recurid (comp);
+                               rangedt = range ? e_cal_component_range_get_datetime (range) : NULL;
+                               if (rangedt && e_cal_component_datetime_get_value (rangedt))
+                                       instancett = i_cal_time_as_timet (e_cal_component_datetime_get_value 
(rangedt));
                                else
                                        instancett = 0;
-                               e_cal_component_free_range (&range);
+                               e_cal_component_range_free (range);
 
                                if (instancett > 0 && (
                                    (mod == E_CAL_OBJ_MOD_THIS_AND_PRIOR && instancett <= fromtt) ||
@@ -2189,6 +2205,8 @@ ecmb_remove_object_sync (ECalMetaBackend *meta_backend,
                                        link = g_slist_next (link);
                                }
                        }
+
+                       g_clear_object (&itt);
                } else {
                        mod = E_CAL_OBJ_MOD_ALL;
                }
@@ -2226,11 +2244,11 @@ ecmb_remove_object_sync (ECalMetaBackend *meta_backend,
                                                if (!id)
                                                        continue;
 
-                                               if (!e_cal_cache_get_component_extra (cal_cache, id->uid, 
id->rid, &comp_extra, cancellable, NULL)) {
+                                               if (!e_cal_cache_get_component_extra (cal_cache, 
e_cal_component_id_get_uid (id), e_cal_component_id_get_rid (id), &comp_extra, cancellable, NULL)) {
                                                        comp_extra = NULL;
                                                        if (g_cancellable_set_error_if_cancelled 
(cancellable, &local_error)) {
                                                                success = FALSE;
-                                                               e_cal_component_free_id (id);
+                                                               e_cal_component_id_free (id);
                                                                break;
                                                        }
 
@@ -2240,9 +2258,10 @@ ecmb_remove_object_sync (ECalMetaBackend *meta_backend,
                                                ical_string = e_cal_component_get_as_string (comp);
 
                                                /* This pretends the first instance is the master object and 
the implementations should count with it */
-                                               success = e_cal_meta_backend_remove_component_sync 
(meta_backend, conflict_resolution, id->uid, comp_extra, ical_string, cancellable, &local_error);
+                                               success = e_cal_meta_backend_remove_component_sync 
(meta_backend, conflict_resolution,
+                                                       e_cal_component_id_get_uid (id), comp_extra, 
ical_string, cancellable, &local_error);
 
-                                               e_cal_component_free_id (id);
+                                               e_cal_component_id_free (id);
                                                g_clear_pointer (&ical_string, g_free);
                                                g_free (comp_extra);
 
@@ -2266,15 +2285,17 @@ ecmb_remove_object_sync (ECalMetaBackend *meta_backend,
                        gchar *new_uid = NULL, *new_extra = NULL;
 
                        if (master_comp) {
-                               icalcomponent *icalcomp = e_cal_component_get_icalcomponent (master_comp);
+                               gint sequence = e_cal_component_get_sequence (master_comp);
 
-                               icalcomponent_set_sequence (icalcomp, icalcomponent_get_sequence (icalcomp) + 
1);
+                               if (sequence < 0)
+                                       sequence = 0;
 
-                               e_cal_component_rescan (master_comp);
+                               e_cal_component_set_sequence (master_comp, sequence + 1);
 
                                /* Set the last modified time on the component */
-                               itt = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
-                               e_cal_component_set_last_modified (master_comp, &itt);
+                               itt = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
+                               e_cal_component_set_last_modified (master_comp, itt);
+                               g_clear_object (&itt);
                        }
 
                        if (*offline_flag == E_CACHE_IS_ONLINE) {
@@ -2358,7 +2379,7 @@ ecmb_remove_objects_sync (ECalBackendSync *sync_backend,
                }
 
                success = ecmb_remove_object_sync (meta_backend, cal_cache, &offline_flag, 
conflict_resolution,
-                       mod, id->uid, id->rid, &old_comp, &new_comp, cancellable, error);
+                       mod, e_cal_component_id_get_uid (id), e_cal_component_id_get_rid (id), &old_comp, 
&new_comp, cancellable, error);
 
                if (success) {
                        *out_old_components = g_slist_prepend (*out_old_components, old_comp);
@@ -2412,14 +2433,14 @@ ecmb_receive_object_sync (ECalMetaBackend *meta_backend,
        registry = e_cal_backend_get_registry (cal_backend);
 
        /* Just to check whether component exists in the cache */
-       is_in_cache = e_cal_cache_contains (cal_cache, id->uid, NULL, E_CACHE_EXCLUDE_DELETED) ||
-               (id->rid && *id->rid && e_cal_cache_contains (cal_cache, id->uid, id->rid, 
E_CACHE_EXCLUDE_DELETED));
+       is_in_cache = e_cal_cache_contains (cal_cache, e_cal_component_id_get_uid (id), NULL, 
E_CACHE_EXCLUDE_DELETED) ||
+               (e_cal_component_id_get_rid (id) && e_cal_cache_contains (cal_cache, 
e_cal_component_id_get_uid (id), e_cal_component_id_get_rid (id), E_CACHE_EXCLUDE_DELETED));
 
        /* For cases when there's no master object in the cache */
        if (!is_in_cache) {
                GSList *icalstrings = NULL;
 
-               if (e_cal_cache_get_components_by_uid_as_string (cal_cache, id->uid, &icalstrings, 
cancellable, NULL)) {
+               if (e_cal_cache_get_components_by_uid_as_string (cal_cache, e_cal_component_id_get_uid (id), 
&icalstrings, cancellable, NULL)) {
                        is_in_cache = icalstrings && icalstrings->data;
                        g_slist_free_full (icalstrings, g_free);
                }
@@ -2438,7 +2459,7 @@ ecmb_receive_object_sync (ECalMetaBackend *meta_backend,
                                        mod, comp, NULL, NULL, cancellable, error);
                        } else {
                                success = ecmb_remove_object_sync (meta_backend, cal_cache, offline_flag, 
conflict_resolution,
-                                       mod, id->uid, id->rid, NULL, NULL, cancellable, error);
+                                       mod, e_cal_component_id_get_uid (id), e_cal_component_id_get_rid 
(id), NULL, NULL, cancellable, error);
                        }
                } else if (!is_declined) {
                        success = ecmb_create_object_sync (meta_backend, cal_cache, offline_flag, 
conflict_resolution,
@@ -2448,7 +2469,7 @@ ecmb_receive_object_sync (ECalMetaBackend *meta_backend,
        case ICAL_METHOD_CANCEL:
                if (is_in_cache) {
                        success = ecmb_remove_object_sync (meta_backend, cal_cache, offline_flag, 
conflict_resolution,
-                               E_CAL_OBJ_MOD_THIS, id->uid, id->rid, NULL, NULL, cancellable, error);
+                               E_CAL_OBJ_MOD_THIS, e_cal_component_id_get_uid (id), 
e_cal_component_id_get_rid (id), NULL, NULL, cancellable, error);
                } else {
                        g_propagate_error (error, e_data_cal_create_error (ObjectNotFound, NULL));
                }
@@ -2459,7 +2480,7 @@ ecmb_receive_object_sync (ECalMetaBackend *meta_backend,
                break;
        }
 
-       e_cal_component_free_id (id);
+       e_cal_component_id_free (id);
 
        return success;
 }
@@ -3738,7 +3759,9 @@ static gint
 sort_master_first_cb (gconstpointer a,
                      gconstpointer b)
 {
-       icalcomponent *ca, *cb;
+       ICalComponent *ca, *cb;
+       ICalTimetype *rida, *ridb;
+       gint res;
 
        ca = e_cal_component_get_icalcomponent ((ECalComponent *) a);
        cb = e_cal_component_get_icalcomponent ((ECalComponent *) b);
@@ -3752,7 +3775,22 @@ sort_master_first_cb (gconstpointer a,
                return 1;
        }
 
-       return icaltime_compare (icalcomponent_get_recurrenceid (ca), icalcomponent_get_recurrenceid (cb));
+       rida = icalcomponent_get_recurrenceid (ca);
+       ridb = icalcomponent_get_recurrenceid (cb);
+
+       if (!rida || !ridb) {
+               if (rida == ridb)
+                       res = 0;
+               else
+                       res = rida ? -1 : 1;
+       } else {
+               res = i_cal_time_compare (rida, ridb);
+       }
+
+       g_clear_object (&rida);
+       g_clear_object (&ridb);
+
+       return res;
 }
 
 typedef struct {
@@ -4188,7 +4226,7 @@ e_cal_meta_backend_empty_cache_sync (ECalMetaBackend *meta_backend,
                }
        }
 
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_id_free);
 
        return success;
 }
@@ -4418,7 +4456,7 @@ e_cal_meta_backend_split_changes_sync (ECalMetaBackend *meta_backend,
        locally_cached = g_hash_table_new_full (
                (GHashFunc) e_cal_component_id_hash,
                (GEqualFunc) e_cal_component_id_equal,
-               (GDestroyNotify) e_cal_component_free_id,
+               (GDestroyNotify) e_cal_component_id_free,
                g_free);
 
        if (!e_cal_cache_search_with_callback (cal_cache, NULL,
@@ -4430,20 +4468,19 @@ e_cal_meta_backend_split_changes_sync (ECalMetaBackend *meta_backend,
 
        for (link = objects; link; link = g_slist_next (link)) {
                ECalMetaBackendInfo *nfo = link->data;
-               ECalComponentId id;
+               ECalComponentId *id;
 
                if (!nfo)
                        continue;
 
-               id.uid = nfo->uid;
-               id.rid = NULL;
+               id = e_cal_component_id_new (nfo->uid, NULL);
 
-               if (!g_hash_table_contains (locally_cached, &id)) {
+               if (!g_hash_table_contains (locally_cached, id)) {
                        link->data = NULL;
 
                        *out_created_objects = g_slist_prepend (*out_created_objects, nfo);
                } else {
-                       const gchar *local_revision = g_hash_table_lookup (locally_cached, &id);
+                       const gchar *local_revision = g_hash_table_lookup (locally_cached, id);
 
                        if (g_strcmp0 (local_revision, nfo->revision) != 0) {
                                link->data = NULL;
@@ -4451,8 +4488,10 @@ e_cal_meta_backend_split_changes_sync (ECalMetaBackend *meta_backend,
                                *out_modified_objects = g_slist_prepend (*out_modified_objects, nfo);
                        }
 
-                       g_hash_table_remove (locally_cached, &id);
+                       g_hash_table_remove (locally_cached, id);
                }
+
+               e_cal_component_id_free (id);
        }
 
        if (out_removed_objects) {
@@ -4469,17 +4508,20 @@ e_cal_meta_backend_split_changes_sync (ECalMetaBackend *meta_backend,
                        }
 
                        /* Skit detached instances, if the master object is still in the cache */
-                       if (id->rid && *id->rid) {
-                               ECalComponentId master_id;
+                       if (e_cal_component_id_get_rid (id)) {
+                               ECalComponentId *master_id;
 
-                               master_id.uid = id->uid;
-                               master_id.rid = NULL;
+                               master_id = e_cal_component_id_new (e_cal_component_id_get_uid (id), NULL);
 
-                               if (!g_hash_table_contains (locally_cached, &master_id))
+                               if (!g_hash_table_contains (locally_cached, master_id)) {
+                                       e_cal_component_id_free (master_id);
                                        continue;
+                               }
+
+                               e_cal_component_id_free (master_id);
                        }
 
-                       nfo = e_cal_meta_backend_info_new (id->uid, revision, NULL, NULL);
+                       nfo = e_cal_meta_backend_info_new (e_cal_component_id_get_uid (id), revision, NULL, 
NULL);
                        *out_removed_objects = g_slist_prepend (*out_removed_objects, nfo);
                }
 
diff --git a/src/calendar/libedata-cal/e-data-cal-view.c b/src/calendar/libedata-cal/e-data-cal-view.c
index 416d74c58..d5fbec71c 100644
--- a/src/calendar/libedata-cal/e-data-cal-view.c
+++ b/src/calendar/libedata-cal/e-data-cal-view.c
@@ -139,25 +139,6 @@ str_ic_equal (gconstpointer a,
        return stra[ii] == strb[ii];
 }
 
-static guint
-id_hash (gconstpointer key)
-{
-       const ECalComponentId *id = key;
-
-       return g_str_hash (id->uid) ^ (id->rid ? g_str_hash (id->rid) : 0);
-}
-
-static gboolean
-id_equal (gconstpointer a,
-          gconstpointer b)
-{
-       const ECalComponentId *id_a = a;
-       const ECalComponentId *id_b = b;
-
-       return (g_strcmp0 (id_a->uid, id_b->uid) == 0) &&
-               (g_strcmp0 (id_a->rid, id_b->rid) == 0);
-}
-
 static void
 reset_array (GArray *array)
 {
@@ -598,9 +579,9 @@ e_data_cal_view_init (EDataCalView *view)
                TRUE, TRUE, sizeof (gchar *), THRESHOLD_ITEMS);
 
        view->priv->ids = g_hash_table_new_full (
-               (GHashFunc) id_hash,
-               (GEqualFunc) id_equal,
-               (GDestroyNotify) e_cal_component_free_id,
+               (GHashFunc) e_cal_component_id_hash,
+               (GEqualFunc) e_cal_component_id_equal,
+               (GDestroyNotify) e_cal_component_id_free,
                (GDestroyNotify) NULL);
 
        g_mutex_init (&view->priv->pending_mutex);
@@ -784,15 +765,15 @@ notify_remove (EDataCalView *view,
                send_pending_removes (view);
 
        /* store ECalComponentId as <uid>[\n<rid>] (matches D-Bus API) */
-       if (id->uid) {
-               uid = e_util_utf8_make_valid (id->uid);
+       if (e_cal_component_id_get_uid (id)) {
+               uid = e_util_utf8_make_valid (e_cal_component_id_get_uid (id));
                uid_len = strlen (uid);
        } else {
                uid = NULL;
                uid_len = 0;
        }
-       if (id->rid) {
-               rid = e_util_utf8_make_valid (id->rid);
+       if (e_cal_component_id_get_rid (id)) {
+               rid = e_util_utf8_make_valid (e_cal_component_id_get_rid (id));
                rid_len = strlen (rid);
        } else {
                rid = NULL;
diff --git a/src/calendar/libedata-cal/e-data-cal.c b/src/calendar/libedata-cal/e-data-cal.c
index 93fdc193c..957bf03b8 100644
--- a/src/calendar/libedata-cal/e-data-cal.c
+++ b/src/calendar/libedata-cal/e-data-cal.c
@@ -1109,29 +1109,17 @@ data_cal_handle_remove_objects_cb (EDBusCalendar *dbus_interface,
 
        n_children = g_variant_n_children (in_uid_rid_array);
        for (ii = 0; ii < n_children; ii++) {
-               ECalComponentId *id;
+               gchar *uid = NULL, *rid = NULL;
 
-               /* e_cal_component_free_id() uses g_free(),
-                * not g_slice_free().  Therefore allocate
-                * with g_malloc(), not g_slice_new(). */
-               id = g_malloc0 (sizeof (ECalComponentId));
+               g_variant_get_child (in_uid_rid_array, ii, "(ss)", &uid, &rid);
 
-               g_variant_get_child (
-                       in_uid_rid_array, ii, "(ss)", &id->uid, &id->rid);
-
-               if (id->uid != NULL && *id->uid == '\0') {
-                       e_cal_component_free_id (id);
+               if (!uid || !*uid) {
+                       g_free (uid);
+                       g_free (rid);
                        continue;
                }
 
-               /* Recurrence ID is optional.  Its omission is denoted
-                * via D-Bus by an empty string.  Convert it to NULL. */
-               if (id->rid != NULL && *id->rid == '\0') {
-                       g_free (id->rid);
-                       id->rid = NULL;
-               }
-
-               g_queue_push_tail (&component_ids, id);
+               g_queue_push_tail (&component_ids, e_cal_component_id_new_take (uid, rid));
        }
 
        async_context = async_context_new (data_cal, invocation);
@@ -1144,7 +1132,7 @@ data_cal_handle_remove_objects_cb (EDBusCalendar *dbus_interface,
                async_context);
 
        while (!g_queue_is_empty (&component_ids))
-               e_cal_component_free_id (g_queue_pop_head (&component_ids));
+               e_cal_component_id_free (g_queue_pop_head (&component_ids));
 
        g_object_unref (backend);
 
diff --git a/src/calendar/libedata-cal/libedata-cal.h b/src/calendar/libedata-cal/libedata-cal.h
index 0e1c45db1..4fd49a2f2 100644
--- a/src/calendar/libedata-cal/libedata-cal.h
+++ b/src/calendar/libedata-cal/libedata-cal.h
@@ -23,6 +23,8 @@
 #include <libecal/libecal.h>
 #include <libebackend/libebackend.h>
 
+#define LIBICAL_GLIB_UNSTABLE_API 1
+
 #include <libedata-cal/e-cal-backend-factory.h>
 #include <libedata-cal/e-cal-backend.h>
 #include <libedata-cal/e-cal-backend-intervaltree.h>
@@ -36,7 +38,8 @@
 #include <libedata-cal/e-data-cal-view.h>
 #include <libedata-cal/e-subprocess-cal-factory.h>
 
+#undef LIBICAL_GLIB_UNSTABLE_API
+
 #undef __LIBEDATA_CAL_H_INSIDE__
 
 #endif /* LIBEDATA_CAL_H */
-
diff --git a/src/libedataserverui/e-reminders-widget.c b/src/libedataserverui/e-reminders-widget.c
index 3703e1c39..f50c1925f 100644
--- a/src/libedataserverui/e-reminders-widget.c
+++ b/src/libedataserverui/e-reminders-widget.c
@@ -479,20 +479,27 @@ reminders_sort_by_occur (gconstpointer ptr1,
                         gconstpointer ptr2)
 {
        const EReminderData *rd1 = ptr1, *rd2 = ptr2;
+       const ECalComponentAlarmInstance *inst1, *inst2;
        gint cmp;
 
        if (!rd1 || !rd2)
                return rd1 == rd2 ? 0 : rd1 ? 1 : -1;
 
-       if (rd1->instance.occur_start != rd2->instance.occur_start)
-               return rd1->instance.occur_start < rd2->instance.occur_start ? -1 : 1;
+       inst1 = e_reminder_data_get_instance (rd1);
+       inst2 = e_reminder_data_get_instance (rd2);
 
-       if (rd1->instance.trigger != rd2->instance.trigger)
-               return rd1->instance.trigger < rd2->instance.trigger ? -1 : 1;
+       if (!inst1 || !inst2)
+               return inst1 == inst2 ? 0 : inst1 ? 1 : -1;
 
-       cmp = g_strcmp0 (rd1->source_uid, rd2->source_uid);
+       if (e_cal_component_alarm_instance_get_occur_start (inst1) != 
e_cal_component_alarm_instance_get_occur_start (inst2))
+               return e_cal_component_alarm_instance_get_occur_start (inst1) < 
e_cal_component_alarm_instance_get_occur_start (inst2) ? -1 : 1;
+
+       if (e_cal_component_alarm_instance_get_time (inst1) != e_cal_component_alarm_instance_get_time 
(inst2))
+               return e_cal_component_alarm_instance_get_time (inst1) < 
e_cal_component_alarm_instance_get_time (inst2) ? -1 : 1;
+
+       cmp = g_strcmp0 (e_reminder_data_get_source_uid (rd1), e_reminder_data_get_source_uid (rd2));
        if (!cmp)
-               cmp = g_strcmp0 (rd1->instance.auid, rd2->instance.auid);
+               cmp = g_strcmp0 (e_cal_component_alarm_instance_get_uid (inst1), 
e_cal_component_alarm_instance_get_uid (inst2));
 
        return cmp;
 }
@@ -612,7 +619,7 @@ reminders_widget_refresh_content_cb (gpointer user_data)
                        const EReminderData *rd = link->data;
                        gchar *overdue = NULL, *description = NULL;
 
-                       if (!rd || !rd->component)
+                       if (!rd || !e_reminder_data_get_component (rd))
                                continue;
 
                        reminders_get_reminder_markups (reminders, rd, &overdue, &description);
diff --git a/src/services/evolution-alarm-notify/e-alarm-notify.c 
b/src/services/evolution-alarm-notify/e-alarm-notify.c
index c071725ea..8ea0be46d 100644
--- a/src/services/evolution-alarm-notify/e-alarm-notify.c
+++ b/src/services/evolution-alarm-notify/e-alarm-notify.c
@@ -174,32 +174,35 @@ e_alarm_notify_build_notif_id (const EReminderData *rd)
 {
        GString *string;
        ECalComponentId *id;
+       ECalComponentAlarmInstance *instance;
 
        g_return_val_if_fail (rd != NULL, NULL);
 
        string = g_string_sized_new (32);
 
-       if (rd->source_uid) {
-               g_string_append (string, rd->source_uid);
+       if (e_reminder_data_get_source_uid (rd)) {
+               g_string_append (string, e_reminder_data_get_source_uid (rd));
                g_string_append (string, "\n");
        }
 
-       id = e_cal_component_get_id (rd->component);
+       id = e_cal_component_get_id (e_reminder_data_get_source_uid (component));
        if (id) {
-               if (id->uid) {
-                       g_string_append (string, id->uid);
+               if (e_cal_component_id_get_uid (id)) {
+                       g_string_append (string, e_cal_component_id_get_uid (id));
                        g_string_append (string, "\n");
                }
 
-               if (id->rid) {
-                       g_string_append (string, id->rid);
+               if (e_cal_component_id_get_rid (id)) {
+                       g_string_append (string, e_cal_component_id_get_rid (id));
                        g_string_append (string, "\n");
                }
 
-               e_cal_component_free_id (id);
+               e_cal_component_id_free (id);
        }
 
-       g_string_append_printf (string, "%" G_GINT64_FORMAT, (gint64) rd->instance.trigger);
+       instance = e_reminder_data_get_instance (rd);
+
+       g_string_append_printf (string, "%" G_GINT64_FORMAT, (gint64) (instance ? 
e_cal_component_alarm_instance_get_time (instance) : -1));
 
        return g_string_free (string, FALSE);
 }
@@ -282,7 +285,7 @@ e_alarm_notify_email (EAlarmNotify *an,
        g_return_val_if_fail (rd != NULL, FALSE);
        g_return_val_if_fail (alarm != NULL, FALSE);
 
-       client = e_reminder_watcher_ref_opened_client (an->priv->watcher, rd->source_uid);
+       client = e_reminder_watcher_ref_opened_client (an->priv->watcher, e_reminder_data_get_source_uid 
(rd));
        if (client && !e_client_check_capability (E_CLIENT (client), 
E_CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS)) {
                g_object_unref (client);
                return FALSE;
@@ -461,43 +464,44 @@ e_alarm_notify_process (EAlarmNotify *an,
                        gboolean snoozed)
 {
        ECalComponentAlarm *alarm;
+       ECalComponentAlarmInstance *instance;
        ECalComponentAlarmAction action;
        gboolean keep_in_reminders = FALSE;
 
        g_return_val_if_fail (an != NULL, FALSE);
        g_return_val_if_fail (rd != NULL, FALSE);
 
-       if (e_cal_component_get_vtype (rd->component) == E_CAL_COMPONENT_TODO) {
-               icalproperty_status status = ICAL_STATUS_NONE;
+       if (e_cal_component_get_vtype (e_reminder_data_get_component (rd)) == E_CAL_COMPONENT_TODO) {
+               ICalPropertyStatus status;
 
-               e_cal_component_get_status (rd->component, &status);
+               status = e_cal_component_get_status (e_reminder_data_get_component (rd));
 
-               if (status == ICAL_STATUS_COMPLETED &&
+               if (status == I_CAL_STATUS_COMPLETED &&
                    !g_settings_get_boolean (an->priv->settings, "notify-completed-tasks")) {
                        return FALSE;
                }
        }
 
-       alarm = e_cal_component_get_alarm (rd->component, rd->instance.auid);
+       instance = e_reminder_data_get_instance (rd);
+
+       alarm = instance ? e_cal_component_get_alarm (e_reminder_data_get_component (rd), 
e_cal_component_alarm_instance_get_uid (instance)) : NULL;
        if (!alarm)
                return FALSE;
 
        if (!snoozed && !g_settings_get_boolean (an->priv->settings, "notify-past-events")) {
-               ECalComponentAlarmTrigger trigger;
-               ECalComponentAlarmRepeat repeat;
+               ECalComponentAlarmTrigger *trigger;
                time_t offset = 0, event_relative, orig_trigger_day, today;
 
-               e_cal_component_alarm_get_trigger (alarm, &trigger);
-               e_cal_component_alarm_get_repeat (alarm, &repeat);
+               trigger = e_cal_component_alarm_get_trigger (alarm);
 
-               switch (trigger.type) {
+               switch (trigger ? e_cal_component_alarm_trigger_get_kind (trigger) : 
E_CAL_COMPONENT_ALARM_TRIGGER_NONE) {
                case E_CAL_COMPONENT_ALARM_TRIGGER_NONE:
                case E_CAL_COMPONENT_ALARM_TRIGGER_ABSOLUTE:
                        break;
 
                case E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START:
                case E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_END:
-                       offset = icaldurationtype_as_int (trigger.u.rel_duration);
+                       offset = i_cal_duration_type_as_int (e_cal_component_alarm_trigger_get_duration 
(trigger));
                        break;
 
                default:
@@ -505,12 +509,12 @@ e_alarm_notify_process (EAlarmNotify *an,
                }
 
                today = time (NULL);
-               event_relative = rd->instance.occur_start - offset;
+               event_relative = e_cal_component_alarm_instance_get_occur_start (instance) - offset;
 
                #define CLAMP_TO_DAY(x) ((x) - ((x) % (60 * 60 * 24)))
 
                event_relative = CLAMP_TO_DAY (event_relative);
-               orig_trigger_day = CLAMP_TO_DAY (rd->instance.trigger);
+               orig_trigger_day = CLAMP_TO_DAY (e_cal_component_alarm_instance_get_time (instance));
                today = CLAMP_TO_DAY (today);
 
                #undef CLAMP_TO_DAY
@@ -521,7 +525,7 @@ e_alarm_notify_process (EAlarmNotify *an,
                }
        }
 
-       e_cal_component_alarm_get_action (alarm, &action);
+       action = e_cal_component_alarm_get_action (alarm);
 
        switch (action) {
        case E_CAL_COMPONENT_ALARM_AUDIO:
diff --git a/tests/libecal/test-cal-client-bulk-methods.c b/tests/libecal/test-cal-client-bulk-methods.c
index 5e960bf3e..c481f8ab2 100644
--- a/tests/libecal/test-cal-client-bulk-methods.c
+++ b/tests/libecal/test-cal-client-bulk-methods.c
@@ -81,9 +81,7 @@ uid_slist_to_ecalcomponentid_slist (GSList *uids)
        const GSList *l;
 
        for (l = uids; l; l = l->next) {
-               ECalComponentId *id = g_new0 (ECalComponentId, 1);
-               id->uid = g_strdup (l->data);
-               ids = g_slist_append (ids, id);
+               ids = g_slist_append (ids, e_cal_component_id_new (l->data, NULL));
        }
 
        return ids;
@@ -166,7 +164,7 @@ test_bulk_methods (ECalClient *cal_client,
        if (!e_cal_client_remove_objects_sync (cal_client, ids, E_CAL_OBJ_MOD_ALL, NULL, &error))
                g_error ("remove objects sync: %s", error->message);
 
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
 
        /* Check that the objects don't exist anymore */
        check_removed (cal_client, uids);
diff --git a/tests/libecal/test-cal-client-get-view.c b/tests/libecal/test-cal-client-get-view.c
index c141c8f59..220dcd32b 100644
--- a/tests/libecal/test-cal-client-get-view.c
+++ b/tests/libecal/test-cal-client-get-view.c
@@ -59,7 +59,7 @@ objects_added_cb (GObject *object,
        const GSList *l;
 
        for (l = objects; l; l = l->next)
-               g_print ("Object added %s (%s)\n", icalcomponent_get_uid (l->data), icalcomponent_get_summary 
(l->data));
+               g_print ("Object added %s (%s)\n", i_cal_component_get_uid (l->data), 
i_cal_component_get_summary (l->data));
 
        subtest_passed (SUBTEST_OBJECTS_ADDED, loop);
 }
@@ -73,7 +73,7 @@ objects_modified_cb (GObject *object,
        const GSList *l;
 
        for (l = objects; l; l = l->next)
-               g_print ("Object modified %s (%s)\n", icalcomponent_get_uid (l->data), 
icalcomponent_get_summary (l->data));
+               g_print ("Object modified %s (%s)\n", i_cal_component_get_uid (l->data), 
i_cal_component_get_summary (l->data));
 
        subtest_passed (SUBTEST_OBJECTS_MODIFIED, loop);
 }
@@ -89,7 +89,7 @@ objects_removed_cb (GObject *object,
        for (l = objects; l; l = l->next) {
                ECalComponentId *id = l->data;
 
-               g_print ("Object removed: uid: %s, rid: %s\n", id->uid, id->rid);
+               g_print ("Object removed: uid: %s, rid: %s\n", e_cal_component_id_get_uid (id), 
e_cal_component_id_get_rid (id));
        }
 
        subtest_passed (SUBTEST_OBJECTS_REMOVED, loop);
@@ -112,32 +112,36 @@ alter_cal_client (gpointer user_data)
 {
        ECalClient *cal_client = user_data;
        GError *error = NULL;
-       icalcomponent *icalcomp;
-       struct icaltimetype now;
+       ICalComponent *comp;
+       ICalTimetype *now, *itt;
        gchar *uid = NULL;
 
        g_return_val_if_fail (cal_client != NULL, NULL);
 
-       now = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
-       icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
-       icalcomponent_set_summary (icalcomp, "Initial event summary");
-       icalcomponent_set_dtstart (icalcomp, now);
-       icalcomponent_set_dtend   (icalcomp, icaltime_from_timet_with_zone (icaltime_as_timet (now) + 60 * 60 
* 60, 0, NULL));
+       now = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
+       itt = i_cal_time_from_timet_with_zone (i_cal_time_as_timet (now) + 60 * 60 * 60, 0, NULL);
 
-       if (!e_cal_client_create_object_sync (cal_client, icalcomp, &uid, NULL, &error))
+       comp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
+       i_cal_component_set_summary (comp, "Initial event summary");
+       i_cal_component_set_dtstart (comp, now);
+       i_cal_component_set_dtend (comp, itt);
+
+       if (!e_cal_client_create_object_sync (cal_client, comp, &uid, NULL, &error))
                g_error ("create object sync: %s", error->message);
 
-       icalcomponent_set_uid (icalcomp, uid);
-       icalcomponent_set_summary (icalcomp, "Modified event summary");
+       i_cal_component_set_uid (comp, uid);
+       i_cal_component_set_summary (comp, "Modified event summary");
 
-       if (!e_cal_client_modify_object_sync (cal_client, icalcomp, E_CAL_OBJ_MOD_ALL, NULL, &error))
+       if (!e_cal_client_modify_object_sync (cal_client, comp, E_CAL_OBJ_MOD_ALL, NULL, &error))
                g_error ("modify object sync: %s", error->message);
 
        if (!e_cal_client_remove_object_sync (cal_client, uid, NULL, E_CAL_OBJ_MOD_ALL, NULL, &error))
                g_error ("remove object sync: %s", error->message);
 
+       g_object_unref (comp);
+       g_object_unref (itt);
+       g_object_unref (now);
        g_free (uid);
-       icalcomponent_free (icalcomp);
 
        return FALSE;
 }
diff --git a/tests/libecal/test-cal-client-revision-view.c b/tests/libecal/test-cal-client-revision-view.c
index c1b57fa4d..a108d3221 100644
--- a/tests/libecal/test-cal-client-revision-view.c
+++ b/tests/libecal/test-cal-client-revision-view.c
@@ -50,19 +50,28 @@ subtest_passed (SubTestId id,
                g_main_loop_quit (loop);
 }
 
-static struct icaltimetype
-get_last_modified (icalcomponent *component)
+static ICalTimetype *
+get_last_modified (ICalComponent *component)
 {
-       icalcomponent *inner = icalcomponent_get_inner (component);
-       icalproperty  *prop;
+       ICalComponent *inner = i_cal_component_get_inner (component);
+       ICalProperty *prop;
+       ICalTimetype *res;
 
-       prop = icalcomponent_get_first_property (inner, ICAL_LASTMODIFIED_PROPERTY);
+       if (!inner)
+               return i_cal_time_null_time ();
 
-       if (prop == 0) {
-               return icaltime_null_time ();
+       prop = i_cal_component_get_first_property (inner, I_CAL_LASTMODIFIED_PROPERTY);
+
+       if (prop) {
+               res = i_cal_property_get_lastmodified (prop);
+               g_object_unref (prop);
+       } else {
+               res = i_cal_time_null_time ();
        }
 
-       return icalproperty_get_lastmodified (prop);
+       g_clear_object (&innter);
+
+       return res;
 }
 
 static void
@@ -74,17 +83,26 @@ objects_added_cb (GObject *object,
        GMainLoop *loop = (GMainLoop *) data;
 
        for (l = objects; l; l = l->next) {
-               icalcomponent      *component = l->data;
-               struct icaltimetype recurrence = icalcomponent_get_recurrenceid (component);
-               struct icaltimetype last_modified = get_last_modified (component);
+               ICalComponent *component = l->data;
+               ICalTimetype *recurrence = i_cal_component_get_recurrenceid (component);
+               ICalTimetype *last_modified = get_last_modified (component);
+               gchar *str_recurrence, *str_last_modified;
+
+               str_recurrence = i_cal_time_as_ical_string (recurrence);
+               str_last_modified = i_cal_time_as_ical_string_r (last_modified);
 
                g_print (
                        "Object added %s (recurrence id:%s, last-modified:%s)\n",
-                       icalcomponent_get_uid (component),
-                       icaltime_as_ical_string (recurrence),
-                       icaltime_as_ical_string (last_modified));
+                       i_cal_component_get_uid (component),
+                       str_recurrence,
+                       str_last_modified);
 
-               g_assert (icalcomponent_get_summary (component) == NULL);
+               g_clear_object (&recurrence);
+               g_clear_object (&last_modified);
+               g_free (str_recurrence);
+               g_free (str_last_modified);
+
+               g_assert (i_cal_component_get_summary (component) == NULL);
        }
 
        subtest_passed (SUBTEST_OBJECTS_ADDED, loop);
@@ -99,15 +117,24 @@ objects_modified_cb (GObject *object,
        GMainLoop *loop = (GMainLoop *) data;
 
        for (l = objects; l; l = l->next) {
-               icalcomponent      *component = l->data;
-               struct icaltimetype recurrence = icalcomponent_get_recurrenceid (component);
-               struct icaltimetype last_modified = get_last_modified (component);
+               ICalComponent *component = l->data;
+               ICalTimetype *recurrence = i_cal_component_get_recurrenceid (component);
+               ICalTimetype *last_modified = get_last_modified (component);
+               gchar *str_recurrence, *str_last_modified;
+
+               str_recurrence = i_cal_time_as_ical_string (recurrence);
+               str_last_modified = i_cal_time_as_ical_string_r (last_modified);
 
                g_print (
                        "Object modified %s (recurrence id:%s, last-modified:%s)\n",
-                       icalcomponent_get_uid (component),
-                       icaltime_as_ical_string (recurrence),
-                       icaltime_as_ical_string (last_modified));
+                       i_cal_component_get_uid (component),
+                       str_recurrence,
+                       str_last_modified);
+
+               g_clear_object (&recurrence);
+               g_clear_object (&last_modified);
+               g_free (str_recurrence);
+               g_free (str_last_modified);
 
                g_assert (icalcomponent_get_summary (component) == NULL);
        }
@@ -126,7 +153,7 @@ objects_removed_cb (GObject *object,
        for (l = objects; l; l = l->next) {
                ECalComponentId *id = l->data;
 
-               g_print ("Object removed: uid: %s, rid: %s\n", id->uid, id->rid);
+               g_print ("Object removed: uid: %s, rid: %s\n", e_cal_component_id_get_uid (id), 
e_cal_component_id_get_rid (id));
        }
 
        subtest_passed (SUBTEST_OBJECTS_REMOVED, loop);
@@ -149,32 +176,36 @@ alter_cal_client (gpointer user_data)
 {
        ECalClient *cal_client = user_data;
        GError *error = NULL;
-       icalcomponent *icalcomp;
-       struct icaltimetype now;
+       ICalComponent *comp;
+       ICalTimetype *now, *itt;
        gchar *uid = NULL;
 
        g_return_val_if_fail (cal_client != NULL, NULL);
 
-       now = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
-       icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
-       icalcomponent_set_summary (icalcomp, "Initial event summary");
-       icalcomponent_set_dtstart (icalcomp, now);
-       icalcomponent_set_dtend   (icalcomp, icaltime_from_timet_with_zone (icaltime_as_timet (now) + 60 * 60 
* 60, 0, NULL));
+       now = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
+       itt = i_cal_time_from_timet_with_zone (i_cal_time_as_timet (now) + 60 * 60 * 60, 0, NULL);
+
+       comp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
+       i_cal_component_set_summary (comp, "Initial event summary");
+       i_cal_component_set_dtstart (comp, now);
+       i_cal_component_set_dtend   (comp, itt);
 
-       if (!e_cal_client_create_object_sync (cal_client, icalcomp, &uid, NULL, &error))
+       if (!e_cal_client_create_object_sync (cal_client, comp, &uid, NULL, &error))
                g_error ("create object sync: %s", error->message);
 
-       icalcomponent_set_uid (icalcomp, uid);
-       icalcomponent_set_summary (icalcomp, "Modified event summary");
+       i_cal_component_set_uid (comp, uid);
+       i_cal_component_set_summary (comp, "Modified event summary");
 
-       if (!e_cal_client_modify_object_sync (cal_client, icalcomp, E_CAL_OBJ_MOD_ALL, NULL, &error))
+       if (!e_cal_client_modify_object_sync (cal_client, comp, E_CAL_OBJ_MOD_ALL, NULL, &error))
                g_error ("modify object sync: %s", error->message);
 
        if (!e_cal_client_remove_object_sync (cal_client, uid, NULL, E_CAL_OBJ_MOD_ALL, NULL, &error))
                g_error ("remove object sync: %s", error->message);
 
+       g_object_urnef (comp);
+       g_object_unref (now);
+       g_object_unref (itt);
        g_free (uid);
-       icalcomponent_free (icalcomp);
 
        return FALSE;
 }
diff --git a/tests/libecal/test-cal-client-send-objects.c b/tests/libecal/test-cal-client-send-objects.c
index 20e9ed0f1..b7bd98d83 100644
--- a/tests/libecal/test-cal-client-send-objects.c
+++ b/tests/libecal/test-cal-client-send-objects.c
@@ -27,17 +27,19 @@ static ETestServerClosure cal_closure_async =
 static void
 print_ecomp (ECalComponent *ecalcomp)
 {
-       const gchar *uid = NULL;
-       ECalComponentText summary = { 0 };
+       const gchar *uid;
+       ECalComponentText *summary;
 
        g_return_if_fail (ecalcomp != NULL);
 
-       e_cal_component_get_uid (ecalcomp, &uid);
-       e_cal_component_get_summary (ecalcomp, &summary);
+       uid = e_cal_component_get_uid (ecalcomp);
+       summary = e_cal_component_get_summary (ecalcomp);
 
        g_print ("   Component: %s\n", uid ? uid : "no-uid");
-       g_print ("   Summary: %s\n", summary.value ? summary.value : "NULL");
+       g_print ("   Summary: %s\n", summary && e_cal_component_text_get_value (summary) ? 
e_cal_component_text_get_value (summary) : "NULL");
        g_print ("\n");
+
+       e_cal_component_text_free (summary);
 }
 
 static void
diff --git a/tests/libecal/test-cal-component.c b/tests/libecal/test-cal-component.c
index eeb5385a3..143d78db1 100644
--- a/tests/libecal/test-cal-component.c
+++ b/tests/libecal/test-cal-component.c
@@ -1083,8 +1083,16 @@ test_component_struct_datetime (void)
                        g_assert_nonnull (tt);
 
                        if (expected) {
-                               if (((set_kind + ii) & 1) != 0) {
+                               if (((set_kind + ii) % 3) == 0) {
                                        e_cal_component_datetime_set (expected, tt, values[ii].tzid);
+                               } else if (((set_kind + ii) % 3) == 1) {
+                                       ICalTimetype *ttcopy;
+
+                                       ttcopy = i_cal_timetype_new_clone (tt);
+                                       g_assert_nonnull (ttcopy);
+
+                                       e_cal_component_datetime_take_value (expected, ttcopy);
+                                       e_cal_component_datetime_take_tzid (expected, g_strdup 
(values[ii].tzid));
                                } else {
                                        e_cal_component_datetime_set_value (expected, tt);
                                        e_cal_component_datetime_set_tzid (expected, values[ii].tzid);
diff --git a/tests/libedata-cal/test-cal-cache-getters.c b/tests/libedata-cal/test-cal-cache-getters.c
index b42a9fd8b..8c0a795e1 100644
--- a/tests/libedata-cal/test-cal-cache-getters.c
+++ b/tests/libedata-cal/test-cal-cache-getters.c
@@ -31,7 +31,7 @@ extract_id_from_component (ECalComponent *component)
 
        id = e_cal_component_get_id (component);
        g_assert (id != NULL);
-       g_assert (id->uid != NULL);
+       g_assert (e_cal_component_id_get_uid (id) != NULL);
 
        return id;
 }
@@ -80,10 +80,10 @@ test_get_one (ECalCache *cal_cache,
 
                id = extract_id_from_component (component);
 
-               g_assert_cmpstr (id->uid, ==, uid);
-               g_assert_cmpstr (id->rid, ==, rid && *rid ? rid : NULL);
+               g_assert_cmpstr (e_cal_component_id_get_uid (id), ==, uid);
+               g_assert_cmpstr (e_cal_component_id_get_rid (id), ==, rid && *rid ? rid : NULL);
 
-               e_cal_component_free_id (id);
+               e_cal_component_id_free (id);
                g_object_unref (component);
        }
 
@@ -101,10 +101,10 @@ test_get_one (ECalCache *cal_cache,
 
                id = extract_id_from_string (icalstring);
 
-               g_assert_cmpstr (id->uid, ==, uid);
-               g_assert_cmpstr (id->rid, ==, rid && *rid ? rid : NULL);
+               g_assert_cmpstr (e_cal_component_id_get_uid (id), ==, uid);
+               g_assert_cmpstr (e_cal_component_id_get_rid (id), ==, rid && *rid ? rid : NULL);
 
-               e_cal_component_free_id (id);
+               e_cal_component_id_free (id);
                g_free (icalstring);
        }
 }
@@ -140,7 +140,7 @@ test_get_all (ECalCache *cal_cache,
        GError *error = NULL;
 
        expects = g_hash_table_new_full ((GHashFunc) e_cal_component_id_hash, (GEqualFunc) 
e_cal_component_id_equal,
-               (GDestroyNotify) e_cal_component_free_id, NULL);
+               (GDestroyNotify) e_cal_component_id_free, NULL);
 
        va_start (va, uid);
        tmp = va_arg (va, const gchar *);
@@ -173,10 +173,10 @@ test_get_all (ECalCache *cal_cache,
                for (link = items; link; link = g_slist_next (link)) {
                        id = extract_id_from_component (link->data);
 
-                       g_assert_cmpstr (id->uid, ==, uid);
+                       g_assert_cmpstr (e_cal_component_id_get_uid (id), ==, uid);
                        g_assert (g_hash_table_contains (expects, id));
 
-                       e_cal_component_free_id (id);
+                       e_cal_component_id_free (id);
                }
 
                g_slist_free_full (items, g_object_unref);
@@ -201,10 +201,10 @@ test_get_all (ECalCache *cal_cache,
                for (link = items; link; link = g_slist_next (link)) {
                        id = extract_id_from_string (link->data);
 
-                       g_assert_cmpstr (id->uid, ==, uid);
+                       g_assert_cmpstr (e_cal_component_id_get_uid (id), ==, uid);
                        g_assert (g_hash_table_contains (expects, id));
 
-                       e_cal_component_free_id (id);
+                       e_cal_component_id_free (id);
                }
 
                g_slist_free_full (items, g_free);
diff --git a/tests/libedata-cal/test-cal-cache-intervals.c b/tests/libedata-cal/test-cal-cache-intervals.c
index ecf7ce850..ba1962c73 100644
--- a/tests/libedata-cal/test-cal-cache-intervals.c
+++ b/tests/libedata-cal/test-cal-cache-intervals.c
@@ -92,7 +92,7 @@ search_in_intervals (ETimezoneCache *zone_cache,
        g_assert_nonnull (sexp);
 
        res = g_hash_table_new_full ((GHashFunc) e_cal_component_id_hash, (GEqualFunc) 
e_cal_component_id_equal,
-               (GDestroyNotify) e_cal_component_free_id, g_object_unref);
+               (GDestroyNotify) e_cal_component_id_free, g_object_unref);
 
        for (link = intervals; link; link = g_slist_next (link)) {
                IntervalData *data = link->data;
@@ -130,7 +130,7 @@ check_search_results (GSList *ecalcomps,
 
                g_assert (g_hash_table_contains (from_intervals, id));
 
-               e_cal_component_free_id (id);
+               e_cal_component_id_free (id);
        }
 }
 
@@ -288,11 +288,12 @@ test_intervals (TCUFixture *fixture,
                        id = e_cal_component_get_id (comp);
                        g_assert (id != NULL);
 
-                       success = e_cal_cache_remove_component (fixture->cal_cache, id->uid, id->rid, 
E_CACHE_IS_ONLINE, NULL, &error);
+                       success = e_cal_cache_remove_component (fixture->cal_cache, 
e_cal_component_id_get_uid (id),
+                               e_cal_component_id_get_rid (id), E_CACHE_IS_ONLINE, NULL, &error);
                        g_assert_no_error (error);
                        g_assert (success);
 
-                       e_cal_component_free_id (id);
+                       e_cal_component_id_free (id);
 
                        interval_data_free (interval);
                        intervals = g_slist_delete_link (intervals, l1);
diff --git a/tests/libedata-cal/test-cal-cache-offline.c b/tests/libedata-cal/test-cal-cache-offline.c
index 1fd837841..e6aed5f92 100644
--- a/tests/libedata-cal/test-cal-cache-offline.c
+++ b/tests/libedata-cal/test-cal-cache-offline.c
@@ -79,9 +79,9 @@ test_check_search_result (const GSList *list,
                        const ECalComponentId *id = link->data;
 
                        g_assert (id != NULL);
-                       g_assert (id->uid != NULL);
+                       g_assert (e_cal_component_id_get_uid (id) != NULL);
 
-                       uid = id->uid;
+                       uid = e_cal_component_id_get_uid (id);
                }
 
                g_assert_nonnull (uid);
@@ -143,7 +143,7 @@ test_basic_search (TCUFixture *fixture,
        g_assert_no_error (error);
        g_assert_cmpint (g_slist_length (list), ==, expect_total);
        test_check_search_result (list, flags | EXPECT_EVENT_2);
-       g_slist_free_full (list, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (list, e_cal_component_id_free);
        list = NULL;
 
        /* Only Party, aka event-5, as an in-summary query */
@@ -160,7 +160,7 @@ test_basic_search (TCUFixture *fixture,
        g_assert_no_error (error);
        g_assert_cmpint (g_slist_length (list), ==, 1);
        test_check_search_result (list, EXPECT_DEFAULT);
-       g_slist_free_full (list, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (list, e_cal_component_id_free);
        list = NULL;
 
        /* Only Party, aka event-5, as a non-summarised query */
@@ -177,7 +177,7 @@ test_basic_search (TCUFixture *fixture,
        g_assert_no_error (error);
        g_assert_cmpint (g_slist_length (list), ==, 1);
        test_check_search_result (list, EXPECT_DEFAULT);
-       g_slist_free_full (list, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (list, e_cal_component_id_free);
        list = NULL;
 
        /* Invalid expression */
@@ -392,9 +392,9 @@ test_offline_basics (TCUFixture *fixture,
        g_assert_no_error (error);
        g_assert_cmpint (g_slist_length (ids), ==, 1);
        g_assert_nonnull (ids->data);
-       g_assert_cmpstr (((ECalComponentId *) ids->data)->uid, ==, uid);
+       g_assert_cmpstr (e_cal_component_id_get_uid (ids->data), ==, uid);
 
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
        ids = NULL;
 
        icalcomponent_set_summary (e_cal_component_get_icalcomponent (component), "summ-0");
@@ -470,9 +470,9 @@ test_offline_basics (TCUFixture *fixture,
        g_assert_no_error (error);
        g_assert_cmpint (g_slist_length (ids), ==, 1);
        g_assert_nonnull (ids->data);
-       g_assert_cmpstr (((ECalComponentId *) ids->data)->uid, ==, uid);
+       g_assert_cmpstr (e_cal_component_id_get_uid (ids->data), ==, uid);
 
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
        ids = NULL;
 
        g_assert_cmpint (e_cache_get_count (E_CACHE (fixture->cal_cache), E_CACHE_EXCLUDE_DELETED, NULL, 
&error), ==, 3);
diff --git a/tests/libedata-cal/test-cal-cache-search.c b/tests/libedata-cal/test-cal-cache-search.c
index 973966513..43e644128 100644
--- a/tests/libedata-cal/test-cal-cache-search.c
+++ b/tests/libedata-cal/test-cal-cache-search.c
@@ -36,7 +36,7 @@ test_search_manual (ECalCache *cal_cache,
        GError *error = NULL;
 
        res = g_hash_table_new_full ((GHashFunc) e_cal_component_id_hash, (GEqualFunc) 
e_cal_component_id_equal,
-               (GDestroyNotify) e_cal_component_free_id, g_object_unref);
+               e_cal_component_id_free, g_object_unref);
 
        zone_cache = E_TIMEZONE_CACHE (cal_cache);
 
@@ -92,8 +92,9 @@ test_search_dump_results (GSList *search_data,
        g_hash_table_iter_init (&iter, should_be);
        while (g_hash_table_iter_next (&iter, &key, NULL)) {
                ECalComponentId *id = key;
+               const gchar *rid = e_cal_component_id_get_rid (id);
 
-               printf ("      [%d]: %s%s%s\n", ii, id->uid, id->rid ? ", " : "", id->rid ? id->rid : "");
+               printf ("      [%d]: %s%s%s\n", ii, e_cal_component_id_get_uid (id), rid ? ", " : "", rid ? 
rid : "");
                ii++;
        }
 
@@ -139,16 +140,16 @@ component_check_cb (GHashTable *should_be,
        ECalComponentId *id;
        gboolean contains;
 
-       g_assert (comp != NULL);
+       g_assert_nonnull (comp);
 
        id = e_cal_component_get_id (comp);
 
-       g_assert (id != NULL);
-       g_assert (id->uid != NULL);
+       g_assert_nonnull (id);
+       g_assert_nonnull (e_cal_component_id_get_uid (id));
 
        contains = g_hash_table_contains (should_be, id);
 
-       e_cal_component_free_id (id);
+       e_cal_component_id_free (id);
 
        return contains;
 }
@@ -159,8 +160,8 @@ id_check_cb (GHashTable *should_be,
 {
        ECalComponentId *id = item_data;
 
-       g_assert (id != NULL);
-       g_assert (id->uid != NULL);
+       g_assert_nonnull (id);
+       g_assert_nonnull (e_cal_component_id_get_uid (id));
 
        return g_hash_table_contains (should_be, id);
 }
@@ -212,7 +213,7 @@ test_search_expr (TCUFixture *fixture,
                for (link = items; link; link = g_slist_next (link)) {
                        ECalComponentId *id = link->data;
 
-                       if (g_strcmp0 (id->uid, expects) == 0)
+                       if (g_strcmp0 (e_cal_component_id_get_uid (id), expects) == 0)
                                break;
                }
 
@@ -224,7 +225,7 @@ test_search_expr (TCUFixture *fixture,
 
        test_search_result_equal (items, should_be, id_check_cb);
 
-       g_slist_free_full (items, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (items, e_cal_component_id_free);
 
        g_hash_table_destroy (should_be);
 }
diff --git a/tests/libedata-cal/test-cal-meta-backend.c b/tests/libedata-cal/test-cal-meta-backend.c
index 8065b6b9d..a4fe11359 100644
--- a/tests/libedata-cal/test-cal-meta-backend.c
+++ b/tests/libedata-cal/test-cal-meta-backend.c
@@ -125,7 +125,7 @@ ecmb_test_gather_ids (va_list args)
        const gchar *uid, *rid;
 
        expects = g_hash_table_new_full ((GHashFunc) e_cal_component_id_hash, (GEqualFunc) 
e_cal_component_id_equal,
-               (GDestroyNotify) e_cal_component_free_id, NULL);
+               e_cal_component_id_free, NULL);
 
        uid = va_arg (args, const gchar *);
        while (uid) {
@@ -211,7 +211,7 @@ ecmb_test_cache_contains (ECalCache *cal_cache,
 
                g_assert_nonnull (id);
 
-               if (e_cal_cache_contains (cal_cache, id->uid, id->rid, E_CACHE_EXCLUDE_DELETED))
+               if (e_cal_cache_contains (cal_cache, e_cal_component_id_get_uid (id), 
e_cal_component_id_get_rid (id), E_CACHE_EXCLUDE_DELETED))
                        found++;
        }
 
@@ -2196,7 +2196,7 @@ test_remove_objects (ECalMetaBackend *meta_backend)
        g_assert_null (old_components);
        g_assert_null (new_components);
        g_clear_error (&error);
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
 
        /* Remove existing event */
        ids = g_slist_prepend (NULL, e_cal_component_id_new ("event-1", NULL));
@@ -2217,7 +2217,7 @@ test_remove_objects (ECalMetaBackend *meta_backend)
 
        g_slist_free_full (old_components, g_object_unref);
        g_slist_free (new_components);
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
        old_components = NULL;
        new_components = NULL;
 
@@ -2248,7 +2248,7 @@ test_remove_objects (ECalMetaBackend *meta_backend)
 
        g_slist_free_full (old_components, g_object_unref);
        g_slist_free_full (new_components, g_object_unref);
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
        old_components = NULL;
        new_components = NULL;
 
@@ -2265,7 +2265,7 @@ test_remove_objects (ECalMetaBackend *meta_backend)
        g_assert_null (old_components);
        g_assert_null (new_components);
        g_clear_error (&error);
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
 
        /* Remove non-existing detached instance with THIS - changes master object */
        ids = g_slist_prepend (NULL, e_cal_component_id_new ("event-6", "20170227T134900"));
@@ -2290,7 +2290,7 @@ test_remove_objects (ECalMetaBackend *meta_backend)
 
        g_slist_free_full (old_components, g_object_unref);
        g_slist_free_full (new_components, g_object_unref);
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
        old_components = NULL;
        new_components = NULL;
 
@@ -2321,7 +2321,7 @@ test_remove_objects (ECalMetaBackend *meta_backend)
 
        g_slist_free_full (old_components, g_object_unref);
        g_slist_free (new_components);
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
        old_components = NULL;
        new_components = NULL;
 
@@ -2440,7 +2440,7 @@ test_receive_objects (ECalMetaBackend *meta_backend)
 
        g_slist_free_full (old_components, g_object_unref);
        g_slist_free (new_components);
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
        old_components = NULL;
        new_components = NULL;
 
@@ -2604,7 +2604,7 @@ test_receive_and_remove (ECalMetaBackend *meta_backend)
 
        g_slist_free_full (old_components, g_object_unref);
        g_slist_free (new_components);
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
        old_components = NULL;
        new_components = NULL;
 
@@ -2686,7 +2686,7 @@ test_receive_and_remove (ECalMetaBackend *meta_backend)
 
        g_slist_free_full (old_components, g_object_unref);
        g_slist_free_full (new_components, g_object_unref);
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
        old_components = NULL;
        new_components = NULL;
 
@@ -2759,7 +2759,7 @@ test_receive_and_remove (ECalMetaBackend *meta_backend)
 
        g_slist_free_full (old_components, g_object_unref);
        g_slist_free (new_components);
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
        old_components = NULL;
        new_components = NULL;
 
@@ -2819,7 +2819,7 @@ test_receive_and_remove (ECalMetaBackend *meta_backend)
 
        g_slist_free_full (old_components, g_object_unref);
        g_slist_free (new_components);
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
        old_components = NULL;
        new_components = NULL;
 
@@ -2854,7 +2854,7 @@ test_receive_and_remove (ECalMetaBackend *meta_backend)
 
        g_slist_free_full (old_components, g_object_unref);
        g_slist_free (new_components);
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
        old_components = NULL;
        new_components = NULL;
 
@@ -2903,7 +2903,7 @@ test_receive_and_remove (ECalMetaBackend *meta_backend)
 
        g_slist_free_full (old_components, g_object_unref);
        g_slist_free (new_components);
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
        old_components = NULL;
        new_components = NULL;
 
@@ -2950,7 +2950,7 @@ test_receive_and_remove (ECalMetaBackend *meta_backend)
 
        g_slist_free_full (old_components, g_object_unref);
        g_slist_free (new_components);
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
        old_components = NULL;
        new_components = NULL;
 
@@ -2999,7 +2999,7 @@ test_receive_and_remove (ECalMetaBackend *meta_backend)
 
        g_slist_free_full (old_components, g_object_unref);
        g_slist_free (new_components);
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
        old_components = NULL;
        new_components = NULL;
 
@@ -3043,7 +3043,7 @@ test_receive_and_remove (ECalMetaBackend *meta_backend)
 
        g_slist_free_full (old_components, g_object_unref);
        g_slist_free (new_components);
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
        old_components = NULL;
        new_components = NULL;
 
@@ -3094,7 +3094,7 @@ test_receive_and_remove (ECalMetaBackend *meta_backend)
 
        g_slist_free_full (old_components, g_object_unref);
        g_slist_free (new_components);
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
        old_components = NULL;
        new_components = NULL;
 
@@ -3178,7 +3178,7 @@ test_receive_and_remove (ECalMetaBackend *meta_backend)
 
        g_slist_free_full (old_components, g_object_unref);
        g_slist_free_full (new_components, g_object_unref);
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
        old_components = NULL;
        new_components = NULL;
 
@@ -3214,7 +3214,7 @@ test_receive_and_remove (ECalMetaBackend *meta_backend)
 
        g_slist_free_full (old_components, g_object_unref);
        g_slist_free (new_components);
-       g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+       g_slist_free_full (ids, e_cal_component_id_free);
        old_components = NULL;
        new_components = NULL;
 
diff --git a/tests/libedata-cal/test-intervaltree.c b/tests/libedata-cal/test-intervaltree.c
index 9740ba246..e0c102557 100644
--- a/tests/libedata-cal/test-intervaltree.c
+++ b/tests/libedata-cal/test-intervaltree.c
@@ -70,12 +70,10 @@ search_in_list (GList *l,
        GList * result = NULL;
        EInterval *i, *i_new;
 
-       while (l)
-       {
+       while (l) {
                i = (EInterval *) l->data;
 
-               if (compare_intervals (start, end, i->start, i->end) == 0)
-               {
+               if (compare_intervals (start, end, i->start, i->end) == 0) {
                        i_new = g_new (EInterval, 1);
 
                        i_new->start = i->start;
@@ -107,8 +105,7 @@ compare_interval_lists (GList *list1,
 
        found = TRUE;
 
-       while (list1 != NULL && found)
-       {
+       while (list1 != NULL && found) {
                found = FALSE;
 
                l2 = list2;
@@ -116,8 +113,7 @@ compare_interval_lists (GList *list1,
                i1 = (EInterval *) list1->data;
                c1 = i1->comp;
 
-               while (!found && l2 != NULL)
-               {
+               while (!found && l2 != NULL) {
                        c2 = (ECalComponent *) l2->data;
 
                        found = (c1 == c2);
@@ -129,8 +125,7 @@ compare_interval_lists (GList *list1,
                        list1 = list1->next;
        }
 
-       if (!found)
-       {
+       if (!found) {
                i1 = (EInterval *) list1->data;
 
                g_message (G_STRLOC ": Not found %d - %d\n", i1->start, i1->end);
@@ -144,34 +139,35 @@ create_test_component (time_t start,
                        time_t end)
 {
        ECalComponent *comp = e_cal_component_new ();
-       ECalComponentText summary;
-       struct icaltimetype current;
+       ECalComponentText *summary;
+       ICalTimetype *current;
+       gchar *txt;
+       /* ECalComponentDateTime *dt; */
+
        e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT);
 
        /*
-       ECalComponentDateTime dtstart, dtend;
-       struct icaltimetype time_start, time_end;
- *
-       time_start = icaltime_from_timet_with_zone (start, 0, NULL);
-       dtstart.value = icaltime_from_timet_with_zone (start, 0, NULL);
-       dtstart.zone = icaltimezone_get_utc_timezone ();
- *
-       dtend.value = icaltime_from_timet_with_zone (end, 0, NULL);
-       dtend.value = icaltimezone_get_utc_timezone ();
-       e_cal_component_set_dtstart (comp, &dtstart);
-       e_cal_component_set_dtend (comp, &dtend);
+       dt = e_cal_component_datetime_new_take (i_cal_time_from_timet_with_zone (start, 0, NULL), NULL);
+       e_cal_component_set_dtstart (comp, dt);
+       e_cal_component_datetime_free (dt);
+
+       dt = e_cal_component_datetime_new_take (i_cal_time_from_timet_with_zone (end, 0, NULL), NULL);
+       e_cal_component_set_dtend (comp, dt);
+       e_cal_component_datetime_free (dt);
        */
 
-       summary.value = g_strdup_printf ("%" G_GINT64_FORMAT "- %" G_GINT64_FORMAT, (gint64) start, (gint64) 
end);
-       summary.altrep = NULL;
+       txt = g_strdup_printf ("%" G_GINT64_FORMAT "- %" G_GINT64_FORMAT, (gint64) start, (gint64) end);
 
-       e_cal_component_set_summary (comp, &summary);
+       summary = e_cal_component_new (txt, NULL);
+       e_cal_component_set_summary (comp, summary);
+       e_cal_component_text_free (summary);
 
-       g_free ((gchar *) summary.value);
+       g_free (txt);
 
-       current = icaltime_from_timet_with_zone (time (NULL), 0, NULL);
-       e_cal_component_set_created (comp, &current);
-       e_cal_component_set_last_modified (comp, &current);
+       current = i_cal_time_from_timet_with_zone (time (NULL), 0, NULL);
+       e_cal_component_set_created (comp, current);
+       e_cal_component_set_last_modified (comp, current);
+       g_clear_object (&current);
 
        return comp;
 }
@@ -189,24 +185,23 @@ unref_comp (gpointer data,
 static void
 print_nodes_list (GList *l1)
 {
-       while (l1)
-       {
+       while (l1) {
                ECalComponent *comp = l1->data;
-               ECalComponentText summary;
- *
-               e_cal_component_get_summary (comp, &summary);
-               g_print ("%s\n", summary.value);
+               ECalComponentText *summary;
+
+               summary = e_cal_component_get_summary (comp);
+               g_print ("%s\n", summary ? e_cal_component_text_get_value (summary) : NULL);
+               e_cal_component_text_free (summary);
                l1 = l1->next;
        }
 }
- *
+
 static void
 print_list (GList *l2)
 {
-       while (l2)
-       {
-               EInterval * i = l2->data;
- *
+       while (l2) {
+               EInterval *i = l2->data;
+
                g_print ("%d - %d\n", i->start, i->end);
                l2 = l2->next;
        }
@@ -233,14 +228,12 @@ random_test (void)
 
        tree = e_intervaltree_new ();
 
-       for (i = 0; i < NUM_INTERVALS_CLOSED; i++)
-       {
+       for (i = 0; i < NUM_INTERVALS_CLOSED; i++) {
                ECalComponent *comp;
                start = g_rand_int_range (myrand, 0, 1000);
                end = g_rand_int_range (myrand, start, 2000);
                comp = create_test_component (start, end);
-               if (!comp)
-               {
+               if (!comp) {
                        g_message (G_STRLOC ": error");
                        exit (-1);
                }
@@ -256,8 +249,7 @@ random_test (void)
        }
 
        /* insert open ended intervals */
-       for (i = 0; i < NUM_INTERVALS_OPEN; i++)
-       {
+       for (i = 0; i < NUM_INTERVALS_OPEN; i++) {
                ECalComponent *comp;
                start = g_rand_int_range (myrand, 0, 1000);
                comp = create_test_component (start, end);
@@ -279,8 +271,7 @@ random_test (void)
 
        g_print ("Number of intervals inserted: %d\n", NUM_INTERVALS_CLOSED + NUM_INTERVALS_OPEN);
 
-       for (i = 0; i < NUM_SEARCHES; i++)
-       {
+       for (i = 0; i < NUM_SEARCHES; i++) {
                start = g_rand_int_range (myrand, 0, 1000);
                end = g_rand_int_range (myrand, 2000, _TIME_MAX);
 
@@ -292,8 +283,7 @@ random_test (void)
 
                l2 = search_in_list (list, start, end);
 
-               if (!compare_interval_lists (l2, l1))
-               {
+               if (!compare_interval_lists (l2, l1)) {
                        e_intervaltree_dump (tree);
                        g_message (G_STRLOC "Error");
                        exit (-1);
@@ -307,8 +297,7 @@ random_test (void)
        }
 
        /* open-ended intervals */
-       for (i = 0; i < 20; i++)
-       {
+       for (i = 0; i < 20; i++) {
                start = g_rand_int_range (myrand, 0, 1000);
                end = _TIME_MAX;
 
@@ -320,8 +309,7 @@ random_test (void)
 
                l2 = search_in_list (list, start, end);
 
-               if (!compare_interval_lists (l2, l1))
-               {
+               if (!compare_interval_lists (l2, l1)) {
                        e_intervaltree_dump (tree);
                        g_message (G_STRLOC "Error");
                        exit (-1);
@@ -336,15 +324,13 @@ random_test (void)
 
        l1 = list;
 
-       while (l1)
-       {
+       while (l1) {
                /* perhaps we will delete l1 */
                next = l1->next;
 
-               if (g_rand_double (myrand) < pbality_delete)
-               {
+               if (g_rand_double (myrand) < pbality_delete) {
                        ECalComponent *comp;
-                       const gchar *uid = NULL;
+                       const gchar *uid;
                        gchar *rid;
                        interval = (EInterval *) l1->data;
                        comp = interval->comp;
@@ -356,9 +342,8 @@ random_test (void)
                         * */
 
                        rid = e_cal_component_get_recurid_as_string (comp);
-                       e_cal_component_get_uid (comp, &uid);
-                       if (!e_intervaltree_remove (tree, uid, rid))
-                       {
+                       uid = e_cal_component_get_uid (comp);
+                       if (!e_intervaltree_remove (tree, uid, rid)) {
                                g_free (rid);
                                e_intervaltree_dump (tree);
                                g_print (



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