[evolution-data-server/wip/mcrha/libical-glib] Changes for e-cal-client.h/e-cal-client.c



commit f41185acfd1212c235df0806289b7a3eb32699a4
Author: Milan Crha <mcrha redhat com>
Date:   Thu Feb 7 17:50:20 2019 +0100

    Changes for e-cal-client.h/e-cal-client.c

 src/calendar/libecal/e-cal-client.c | 1238 ++++++++++++++++-------------------
 src/calendar/libecal/e-cal-client.h |  112 ++--
 src/calendar/libecal/e-cal-util.c   |    3 +-
 3 files changed, 609 insertions(+), 744 deletions(-)
---
diff --git a/src/calendar/libecal/e-cal-client.c b/src/calendar/libecal/e-cal-client.c
index 9cedfef5c..6f5a1e9b8 100644
--- a/src/calendar/libecal/e-cal-client.c
+++ b/src/calendar/libecal/e-cal-client.c
@@ -63,7 +63,7 @@ struct _ECalClientPrivate {
        guint name_watcher_id;
 
        ECalClientSourceType source_type;
-       icaltimezone *default_zone;
+       ICalTimezone *default_zone;
 
        GMutex zone_cache_lock;
        GHashTable *zone_cache;
@@ -75,12 +75,13 @@ struct _ECalClientPrivate {
 
 struct _AsyncContext {
        ECalClientView *client_view;
-       icalcomponent *in_comp;
-       icalcomponent *out_comp;
-       icaltimezone *zone;
+       ICalComponent *in_comp;
+       ICalComponent *out_comp;
+       ICalTimezone *zone;
        GSList *comp_list;
        GSList *object_list;
        GSList *string_list;
+       GSList *ids_list; /* ECalComponentId * */
        gchar *sexp;
        gchar *tzid;
        gchar *uid;
@@ -96,7 +97,7 @@ struct _SignalClosure {
        gchar *property_name;
        gchar *error_message;
        gchar **free_busy_data;
-       icaltimezone *cached_zone;
+       ICalTimezone *cached_zone;
 };
 
 struct _ConnectClosure {
@@ -149,29 +150,15 @@ G_DEFINE_TYPE_WITH_CODE (
 static void
 async_context_free (AsyncContext *async_context)
 {
-       if (async_context->client_view != NULL)
-               g_object_unref (async_context->client_view);
+       g_clear_object (&async_context->client_view);
+       g_clear_object (&async_context->in_comp);
+       g_clear_object (&async_context->out_comp);
+       g_clear_object (&async_context->zone);
 
-       if (async_context->in_comp != NULL)
-               icalcomponent_free (async_context->in_comp);
-
-       if (async_context->out_comp != NULL)
-               icalcomponent_free (async_context->out_comp);
-
-       if (async_context->zone != NULL)
-               icaltimezone_free (async_context->zone, 1);
-
-       g_slist_free_full (
-               async_context->comp_list,
-               (GDestroyNotify) icalcomponent_free);
-
-       g_slist_free_full (
-               async_context->object_list,
-               (GDestroyNotify) g_object_unref);
-
-       g_slist_free_full (
-               async_context->string_list,
-               (GDestroyNotify) g_free);
+       g_slist_free_full (async_context->comp_list, g_object_unref);
+       g_slist_free_full (async_context->object_list, g_object_unref);
+       g_slist_free_full (async_context->string_list, g_free);
+       g_slist_free_full (async_context->ids_list, e_cal_component_id_free);
 
        g_free (async_context->sexp);
        g_free (async_context->tzid);
@@ -191,8 +178,9 @@ signal_closure_free (SignalClosure *signal_closure)
        g_free (signal_closure->error_message);
 
        g_strfreev (signal_closure->free_busy_data);
+       g_clear_object (&signal_closure->cached_zone);
 
-       /* The icaltimezone is cached in ECalClient's internal
+       /* The ICalTimezone is cached in ECalClient's internal
         * "zone_cache" hash table and must not be freed here. */
 
        g_slice_free (SignalClosure, signal_closure);
@@ -222,12 +210,6 @@ run_in_thread_closure_free (RunInThreadClosure *run_in_thread_closure)
        g_slice_free (RunInThreadClosure, run_in_thread_closure);
 }
 
-static void
-free_zone_cb (gpointer zone)
-{
-       icaltimezone_free (zone, 1);
-}
-
 /*
  * Well-known calendar backend properties:
  * @E_CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS: Contains default calendar's email
@@ -235,7 +217,7 @@ free_zone_cb (gpointer zone)
  * @E_CAL_BACKEND_PROPERTY_ALARM_EMAIL_ADDRESS: Contains default alarm email
  *   address suggested by the backend.
  * @E_CAL_BACKEND_PROPERTY_DEFAULT_OBJECT: Contains iCal component string
- *   of an #icalcomponent with the default values for properties needed.
+ *   of an #ICalComponent with the default values for properties needed.
  *   Preferred way of retrieving this property is by
  *   calling e_cal_client_get_default_object().
  *
@@ -461,27 +443,22 @@ cal_client_emit_free_busy_data_idle_cb (gpointer user_data)
 
                for (ii = 0; strv[ii] != NULL; ii++) {
                        ECalComponent *comp;
-                       icalcomponent *icalcomp;
-                       icalcomponent_kind kind;
+                       ICalComponent *icalcomp;
+                       ICalComponentKind kind;
 
-                       icalcomp = icalcomponent_new_from_string (strv[ii]);
+                       icalcomp = i_cal_component_new_from_string (strv[ii]);
                        if (icalcomp == NULL)
                                continue;
 
-                       kind = icalcomponent_isa (icalcomp);
-                       if (kind != ICAL_VFREEBUSY_COMPONENT) {
-                               icalcomponent_free (icalcomp);
+                       kind = i_cal_component_isa (icalcomp);
+                       if (kind != I_CAL_VFREEBUSY_COMPONENT) {
+                               i_cal_component_free (icalcomp);
                                continue;
                        }
 
-                       comp = e_cal_component_new ();
-                       if (!e_cal_component_set_icalcomponent (comp, icalcomp)) {
-                               icalcomponent_free (icalcomp);
-                               g_object_unref (comp);
-                               continue;
-                       }
-
-                       list = g_slist_prepend (list, comp);
+                       comp = e_cal_component_new_from_icalcomponent (icalcomp);
+                       if (comp)
+                               list = g_slist_prepend (list, comp);
                }
 
                list = g_slist_reverse (list);
@@ -874,8 +851,8 @@ cal_client_finalize (GObject *object)
        if (priv->name_watcher_id > 0)
                g_bus_unwatch_name (priv->name_watcher_id);
 
-       if (priv->default_zone && priv->default_zone != icaltimezone_get_utc_timezone ())
-               icaltimezone_free (priv->default_zone, 1);
+       if (priv->default_zone && priv->default_zone != i_cal_timezone_get_utc_timezone ())
+               g_clear_object (&priv->default_zone);
 
        g_mutex_lock (&priv->zone_cache_lock);
        g_hash_table_destroy (priv->zone_cache);
@@ -1360,7 +1337,7 @@ cal_client_initable_init_finish (GAsyncInitable *initable,
 
 static void
 cal_client_add_cached_timezone (ETimezoneCache *cache,
-                                icaltimezone *zone)
+                                ICalTimezone *zone)
 {
        ECalClientPrivate *priv;
        const gchar *tzid;
@@ -1369,39 +1346,34 @@ cal_client_add_cached_timezone (ETimezoneCache *cache,
 
        /* XXX Apparently this function can sometimes return NULL.
         *     I'm not sure when or why that happens, but we can't
-        *     cache the icaltimezone if it has no tzid string. */
-       tzid = icaltimezone_get_tzid (zone);
+        *     cache the ICalTimezone if it has no tzid string. */
+       tzid = i_cal_timezone_get_tzid (zone);
        if (tzid == NULL)
                return;
 
        g_mutex_lock (&priv->zone_cache_lock);
 
        /* Avoid replacing an existing cache entry.  We don't want to
-        * invalidate any icaltimezone pointers that may have already
+        * invalidate any ICalTimezone pointers that may have already
         * been returned through e_timezone_cache_get_timezone(). */
        if (!g_hash_table_contains (priv->zone_cache, tzid)) {
                GSource *idle_source;
                GMainContext *main_context;
                SignalClosure *signal_closure;
+               ICalTimezone *cached_zone;
 
-               icalcomponent *icalcomp;
-               icaltimezone *cached_zone;
-
-               cached_zone = icaltimezone_new ();
-               icalcomp = icaltimezone_get_component (zone);
-               icalcomp = icalcomponent_new_clone (icalcomp);
-               icaltimezone_set_component (cached_zone, icalcomp);
+               cached_zone = e_cal_util_copy_timezone (zone);
 
                g_hash_table_insert (
                        priv->zone_cache,
                        g_strdup (tzid), cached_zone);
 
                /* The closure's client reference will keep the
-                * internally cached icaltimezone alive for the
+                * internally cached ICalTimezone alive for the
                 * duration of the idle callback. */
                signal_closure = g_slice_new0 (SignalClosure);
                g_weak_ref_init (&signal_closure->client, cache);
-               signal_closure->cached_zone = cached_zone;
+               signal_closure->cached_zone = g_object_ref (cached_zone);
 
                main_context = e_client_ref_main_context (E_CLIENT (cache));
 
@@ -1420,21 +1392,21 @@ cal_client_add_cached_timezone (ETimezoneCache *cache,
        g_mutex_unlock (&priv->zone_cache_lock);
 }
 
-static icaltimezone *
+static ICalTimezone *
 cal_client_get_cached_timezone (ETimezoneCache *cache,
                                 const gchar *tzid)
 {
        ECalClientPrivate *priv;
-       icaltimezone *zone = NULL;
-       icaltimezone *builtin_zone = NULL;
-       icalcomponent *icalcomp;
-       icalproperty *prop;
+       ICalTimezone *zone = NULL;
+       ICalTimezone *builtin_zone = NULL;
+       ICalComponent *icalcomp, *clone;
+       ICalProperty *prop;
        const gchar *builtin_tzid;
 
        priv = E_CAL_CLIENT_GET_PRIVATE (cache);
 
        if (g_str_equal (tzid, "UTC"))
-               return icaltimezone_get_utc_timezone ();
+               return i_cal_timezone_get_utc_timezone ();
 
        g_mutex_lock (&priv->zone_cache_lock);
 
@@ -1447,51 +1419,45 @@ cal_client_get_cached_timezone (ETimezoneCache *cache,
        /* Try to replace the original time zone with a more complete
         * and/or potentially updated built-in time zone.  Note this also
         * applies to TZIDs which match built-in time zones exactly: they
-        * are extracted via icaltimezone_get_builtin_timezone_from_tzid()
+        * are extracted via i_cal_timezone_get_builtin_timezone_from_tzid()
         * below without a roundtrip to the backend. */
 
        builtin_tzid = e_cal_match_tzid (tzid);
 
        if (builtin_tzid != NULL)
-               builtin_zone = icaltimezone_get_builtin_timezone_from_tzid (
-                       builtin_tzid);
+               builtin_zone = i_cal_timezone_get_builtin_timezone_from_tzid (builtin_tzid);
 
        if (builtin_zone == NULL)
                goto exit;
 
        /* Use the built-in time zone *and* rename it.  Likely the caller
         * is asking for a specific TZID because it has an event with such
-        * a TZID.  Returning an icaltimezone with a different TZID would
+        * a TZID.  Returning an ICalTimezone with a different TZID would
         * lead to broken VCALENDARs in the caller. */
 
-       icalcomp = icaltimezone_get_component (builtin_zone);
-       icalcomp = icalcomponent_new_clone (icalcomp);
-
-       prop = icalcomponent_get_first_property (
-               icalcomp, ICAL_ANY_PROPERTY);
-
-       while (prop != NULL) {
-               if (icalproperty_isa (prop) == ICAL_TZID_PROPERTY) {
-                       icalproperty_set_value_from_string (prop, tzid, "NO");
+       icalcomp = i_cal_timezone_get_component (builtin_zone);
+       clone = i_cal_component_new_clone (icalcomp);
+       g_object_unref (icalcomp);
+       icalcomp = clone;
+
+       for (prop = i_cal_component_get_first_property (icalcomp, I_CAL_ANY_PROPERTY);
+            prop;
+            g_object_unref (prop), prop = i_cal_component_get_next_property (icalcomp, I_CAL_ANY_PROPERTY)) {
+               if (i_cal_property_isa (prop) == I_CAL_TZID_PROPERTY) {
+                       i_cal_property_set_value_from_string (prop, tzid, "NO");
+                       g_object_unref (prop);
                        break;
                }
-
-               prop = icalcomponent_get_next_property (
-                       icalcomp, ICAL_ANY_PROPERTY);
        }
 
-       if (icalcomp != NULL) {
-               zone = icaltimezone_new ();
-               if (icaltimezone_set_component (zone, icalcomp)) {
-                       tzid = icaltimezone_get_tzid (zone);
-                       g_hash_table_insert (
-                               priv->zone_cache,
-                               g_strdup (tzid), zone);
-               } else {
-                       icalcomponent_free (icalcomp);
-                       icaltimezone_free (zone, 1);
-                       zone = NULL;
-               }
+       zone = i_cal_timezone_new ();
+       if (i_cal_timezone_set_component (zone, icalcomp)) {
+               tzid = i_cal_timezone_get_tzid (zone);
+               g_hash_table_insert (priv->zone_cache, g_strdup (tzid), zone);
+       } else {
+               g_object_unref (icalcomp);
+               g_object_unref (zone);
+               zone = NULL;
        }
 
 exit:
@@ -1600,15 +1566,11 @@ e_cal_client_init (ECalClient *client)
 {
        GHashTable *zone_cache;
 
-       zone_cache = g_hash_table_new_full (
-               (GHashFunc) g_str_hash,
-               (GEqualFunc) g_str_equal,
-               (GDestroyNotify) g_free,
-               (GDestroyNotify) free_zone_cb);
+       zone_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
 
        client->priv = E_CAL_CLIENT_GET_PRIVATE (client);
        client->priv->source_type = E_CAL_CLIENT_SOURCE_TYPE_LAST;
-       client->priv->default_zone = icaltimezone_get_utc_timezone ();
+       client->priv->default_zone = i_cal_timezone_get_utc_timezone ();
        g_mutex_init (&client->priv->zone_cache_lock);
        client->priv->zone_cache = zone_cache;
 }
@@ -1977,35 +1939,6 @@ e_cal_client_get_local_attachment_store (ECalClient *client)
        return e_dbus_calendar_get_cache_dir (client->priv->dbus_proxy);
 }
 
-/* icaltimezone_copy does a shallow copy while icaltimezone_free tries to
- * free the entire the contents inside the structure with libical 0.43.
- * Use this, till eds allows older libical.
- */
-static icaltimezone *
-copy_timezone (icaltimezone *ozone)
-{
-       icaltimezone *zone = NULL;
-       const gchar *tzid;
-
-       tzid = icaltimezone_get_tzid (ozone);
-
-       if (g_strcmp0 (tzid, "UTC") != 0) {
-               icalcomponent *comp;
-
-               comp = icaltimezone_get_component (ozone);
-               if (comp != NULL) {
-                       zone = icaltimezone_new ();
-                       icaltimezone_set_component (
-                               zone, icalcomponent_new_clone (comp));
-               }
-       }
-
-       if (zone == NULL)
-               zone = icaltimezone_get_utc_timezone ();
-
-       return zone;
-}
-
 /**
  * e_cal_client_set_default_timezone:
  * @client: A calendar client.
@@ -2019,7 +1952,7 @@ copy_timezone (icaltimezone *ozone)
  **/
 void
 e_cal_client_set_default_timezone (ECalClient *client,
-                                   icaltimezone *zone)
+                                   ICalTimezone *zone)
 {
        g_return_if_fail (E_IS_CAL_CLIENT (client));
        g_return_if_fail (zone != NULL);
@@ -2027,13 +1960,13 @@ e_cal_client_set_default_timezone (ECalClient *client,
        if (zone == client->priv->default_zone)
                return;
 
-       if (client->priv->default_zone != icaltimezone_get_utc_timezone ())
-               icaltimezone_free (client->priv->default_zone, 1);
+       if (client->priv->default_zone != i_cal_timezone_get_utc_timezone ())
+               g_clear_object (&client->priv->default_zone);
 
-       if (zone == icaltimezone_get_utc_timezone ())
+       if (zone == i_cal_timezone_get_utc_timezone ())
                client->priv->default_zone = zone;
        else
-               client->priv->default_zone = copy_timezone (zone);
+               client->priv->default_zone = e_cal_util_copy_timezone (zone);
 
        g_object_notify (G_OBJECT (client), "default-timezone");
 }
@@ -2046,11 +1979,11 @@ e_cal_client_set_default_timezone (ECalClient *client,
  * e_cal_client_set_default_timezone().  The returned pointer is owned by
  * the @client and should not be freed.
  *
- * Returns: an #icaltimezone
+ * Returns: (transfer none): an #ICalTimezone
  *
  * Since: 3.2
  **/
-icaltimezone *
+ICalTimezone *
 e_cal_client_get_default_timezone (ECalClient *client)
 {
        g_return_val_if_fail (E_IS_CAL_CLIENT (client), NULL);
@@ -2162,103 +2095,6 @@ e_cal_client_check_recurrences_no_master (ECalClient *client)
                E_CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER);
 }
 
-/**
- * e_cal_client_free_icalcomp_slist:
- * @icalcomps: (element-type icalcomponent): list of icalcomponent objects
- *
- * Frees each element of the @icalcomps list and the list itself.
- * Each element is an object of type #icalcomponent.
- *
- * Since: 3.2
- **/
-void
-e_cal_client_free_icalcomp_slist (GSList *icalcomps)
-{
-       g_slist_foreach (icalcomps, (GFunc) icalcomponent_free, NULL);
-       g_slist_free (icalcomps);
-}
-
-/**
- * e_cal_client_free_ecalcomp_slist:
- * @ecalcomps: (element-type ECalComponent): list of #ECalComponent objects
- *
- * Frees each element of the @ecalcomps list and the list itself.
- * Each element is an object of type #ECalComponent.
- *
- * Since: 3.2
- **/
-void
-e_cal_client_free_ecalcomp_slist (GSList *ecalcomps)
-{
-       g_slist_foreach (ecalcomps, (GFunc) g_object_unref, NULL);
-       g_slist_free (ecalcomps);
-}
-
-/**
- * e_cal_client_resolve_tzid_cb:
- * @tzid: ID of the timezone to resolve.
- * @data: Closure data for the callback, in this case #ECalClient.
- *
- * Resolves TZIDs for the recurrence generator.
- *
- * Returns: The timezone identified by the @tzid argument, or %NULL if
- * it could not be found.
- *
- * Since: 3.2
- */
-icaltimezone *
-e_cal_client_resolve_tzid_cb (const gchar *tzid,
-                              gpointer data)
-{
-       ECalClient *client = data;
-       icaltimezone *zone = NULL;
-       GError *local_error = NULL;
-
-       g_return_val_if_fail (E_IS_CAL_CLIENT (client), NULL);
-
-       e_cal_client_get_timezone_sync (
-               client, tzid, &zone, NULL, &local_error);
-
-       if (local_error != NULL) {
-               g_debug (
-                       "%s: Failed to find '%s' timezone: %s",
-                       G_STRFUNC, tzid, local_error->message);
-               g_error_free (local_error);
-       }
-
-       return zone;
-}
-
-/**
- * e_cal_client_resolve_tzid_sync:
- * @tzid: ID of the timezone to resolve.
- * @cal_client: User data for the callback, in this case #ECalClient.
- * @cancellable: optional #GCancellable object, or %NULL
- * @error: return location for a #GError, or %NULL
- *
- * Resolves TZIDs for the recurrence generator.
- *
- * Returns: The timezone identified by the @tzid argument, or %NULL if
- * it could not be found.
- *
- * Since: 3.20
- */
-icaltimezone *
-e_cal_client_resolve_tzid_sync (const gchar *tzid,
-                               gpointer cal_client,
-                               GCancellable *cancellable,
-                               GError **error)
-{
-       icaltimezone *zone = NULL;
-
-       g_return_val_if_fail (E_IS_CAL_CLIENT (cal_client), NULL);
-
-       if (!e_cal_client_get_timezone_sync (cal_client, tzid, &zone, cancellable, error))
-               return NULL;
-
-       return zone;
-}
-
 struct comp_instance {
        ECalComponent *comp;
        time_t start;
@@ -2267,113 +2103,118 @@ struct comp_instance {
 
 struct instances_info {
        GSList **instances;
-       icaltimezone *start_zone;
-       icaltimezone *end_zone;
-       icaltimezone *default_zone;
+       ICalTimezone *start_zone;
+       ICalTimezone *end_zone;
+       ICalTimezone *default_zone;
 };
 
 /* Called from cal_recur_generate_instances(); adds an instance to the list */
 static gboolean
-add_instance (ECalComponent *comp,
-              time_t start,
-              time_t end,
-              gpointer data)
+add_instance_cb (ICalComponent *icomp,
+                ICalTimetype *start,
+                ICalTimetype *end,
+                gpointer user_data,
+                GCancellable *cancellable,
+                GError **error)
 {
        GSList **list;
        struct comp_instance *ci;
-       icalcomponent *icalcomp;
        struct instances_info *instances_hold;
 
-       instances_hold = data;
+       instances_hold = user_data;
        list = instances_hold->instances;
 
        ci = g_new (struct comp_instance, 1);
 
-       icalcomp = icalcomponent_new_clone (
-               e_cal_component_get_icalcomponent (comp));
-
        /* add the instance to the list */
-       ci->comp = e_cal_component_new ();
-       e_cal_component_set_icalcomponent (ci->comp, icalcomp);
+       ci->comp = e_cal_component_new_from_icalcomponent (i_cal_component_new_clone (icomp));
+       if (!ci->comp) {
+               g_free (ci);
+               return FALSE;
+       }
 
        /* make sure we return an instance */
-       if (e_cal_util_component_has_recurrences (icalcomp) &&
-           !(icalcomponent_get_first_property (icalcomp, ICAL_RECURRENCEID_PROPERTY))) {
+       if (e_cal_component_has_recurrences (ci->comp) &&
+           !e_cal_component_is_instance (ci->comp)) {
                ECalComponentRange *range;
-               struct icaltimetype itt;
-               ECalComponentDateTime dtstart, dtend;
+               ICalTimetype *itt;
+               ECalComponentDateTime *dtstart, *dtend;
 
-               /* update DTSTART */
-               dtstart.value = NULL;
-               dtstart.tzid = NULL;
-
-               e_cal_component_get_dtstart (comp, &dtstart);
+               dtstart = e_cal_component_get_dtstart (ci->comp);
 
                if (instances_hold->start_zone) {
-                       itt = icaltime_from_timet_with_zone (
-                               start, dtstart.value && dtstart.value->is_date,
+                       itt = i_cal_time_from_timet_with_zone (i_cal_time_as_timet (start),
+                               dtstart && e_cal_component_datetime_get_value (dtstart) && i_cal_time_is_date 
(e_cal_component_datetime_get_value (dtstart)),
                                instances_hold->start_zone);
-                       g_free ((gchar *) dtstart.tzid);
-                       dtstart.tzid = g_strdup (icaltimezone_get_tzid (
-                               instances_hold->start_zone));
-               } else if (dtstart.value && dtstart.value->is_date && !dtstart.tzid && 
instances_hold->default_zone) {
+                       if (dtstart)
+                               e_cal_component_datetime_set_tzid (dtstart, i_cal_timezone_get_tzid 
(instances_hold->start_zone));
+               } else if (dtstart && instances_hold->default_zone &&
+                          e_cal_component_datetime_get_value (dtstart) &&
+                          i_cal_time_is_date (e_cal_component_datetime_get_value (dtstart)) &&
+                          !e_cal_component_datetime_get_tzid (dtstart)) {
                        /* Floating date, set in the default zone */
-                       itt = icaltime_from_timet_with_zone (start, TRUE, instances_hold->default_zone);
+                       itt = i_cal_time_from_timet_with_zone (i_cal_time_as_timet (start), TRUE, 
instances_hold->default_zone);
                } else {
-                       itt = icaltime_from_timet_with_zone (start, dtstart.value && dtstart.value->is_date, 
NULL);
-                       if (dtstart.tzid) {
-                               g_free ((gchar *) dtstart.tzid);
-                               dtstart.tzid = NULL;
-                       }
+                       itt = i_cal_time_from_timet_with_zone (i_cal_time_as_timet (start),
+                               dtstart && e_cal_component_datetime_get_value (dtstart) && i_cal_time_is_date 
(e_cal_component_datetime_get_value (dtstart)),
+                               NULL);
+                       if (dtstart)
+                               e_cal_component_datetime_set_tzid (dtstart, NULL);
                }
 
-               g_free (dtstart.value);
-               dtstart.value = &itt;
-               e_cal_component_set_dtstart (ci->comp, &dtstart);
+               if (dtstart)
+                       e_cal_component_datetime_set_value (dtstart, itt);
+               else
+                       dtstart = e_cal_component_datetime_new (itt, instances_hold->start_zone ? 
i_cal_timezone_get_tzid (instances_hold->start_zone) : NULL);
+
+               e_cal_component_set_dtstart (ci->comp, dtstart);
 
                /* set the RECUR-ID for the instance */
-               range = g_new0 (ECalComponentRange, 1);
-               range->type = E_CAL_COMPONENT_RANGE_SINGLE;
-               range->datetime = dtstart;
+               range = e_cal_component_range_new (E_CAL_COMPONENT_RANGE_SINGLE, dtstart);
 
                e_cal_component_set_recurid (ci->comp, range);
 
-               g_free (range);
-               g_free ((gchar *) dtstart.tzid);
+               e_cal_component_datetime_free (dtstart);
+               e_cal_component_range_free (range);
+               g_clear_object (&itt);
 
                /* Update DTEND */
-               dtend.value = NULL;
-               dtend.tzid = NULL;
 
-               e_cal_component_get_dtend (comp, &dtend);
+               dtend = e_cal_component_get_dtend (ci->comp);
 
                if (instances_hold->end_zone) {
-                       itt = icaltime_from_timet_with_zone (
-                               end, dtend.value && dtend.value->is_date,
+                       itt = i_cal_time_from_timet_with_zone (i_cal_time_as_timet (end),
+                               dtend && e_cal_component_datetime_get_value (dtend) && i_cal_time_is_date 
(e_cal_component_datetime_get_value (dtend)),
                                instances_hold->end_zone);
-                       g_free ((gchar *) dtend.tzid);
-                       dtend.tzid = g_strdup (icaltimezone_get_tzid (
-                               instances_hold->end_zone));
-               } else if (dtend.value && dtend.value->is_date && !dtend.tzid && 
instances_hold->default_zone) {
+                       if (dtend)
+                               e_cal_component_datetime_set_tzid (dtend, i_cal_timezone_get_tzid 
(instances_hold->end_zone));
+               } else if (dtend && instances_hold->default_zone &&
+                          e_cal_component_datetime_get_value (dtend) &&
+                          i_cal_time_is_date (e_cal_component_datetime_get_value (dtend)) &&
+                          !e_cal_component_datetime_get_tzid (dtend)) {
                        /* Floating date, set in the default zone */
-                       itt = icaltime_from_timet_with_zone (end, TRUE, instances_hold->default_zone);
+                       itt = i_cal_time_from_timet_with_zone (i_cal_time_as_timet (end), TRUE, 
instances_hold->default_zone);
                } else {
-                       itt = icaltime_from_timet_with_zone (end, dtend.value && dtend.value->is_date, NULL);
-                       if (dtend.tzid) {
-                               g_free ((gchar *) dtend.tzid);
-                               dtend.tzid = NULL;
-                       }
+                       itt = i_cal_time_from_timet_with_zone (i_cal_time_as_timet (end),
+                               dtend && e_cal_component_datetime_get_value (dtend) && i_cal_time_is_date 
(e_cal_component_datetime_get_value (dtend)),
+                               NULL);
+                       if (dtend)
+                               e_cal_component_datetime_set_tzid (dtend, NULL);
                }
 
-               g_free (dtend.value);
-               dtend.value = &itt;
-               e_cal_component_set_dtend (ci->comp, &dtend);
+               if (dtend)
+                       e_cal_component_datetime_set_value (dtend, itt);
+               else
+                       dtend = e_cal_component_datetime_new (itt, instances_hold->end_zone ? 
i_cal_timezone_get_tzid (instances_hold->end_zone) : NULL);
 
-               g_free ((gchar *) dtend.tzid);
+               e_cal_component_set_dtend (ci->comp, dtend);
+
+               e_cal_component_datetime_free (dtend);
+               g_clear_object (&itt);
        }
 
-       ci->start = start;
-       ci->end = end;
+       ci->start = i_cal_time_as_timet (start);
+       ci->end = i_cal_time_as_timet (end);
 
        *list = g_slist_prepend (*list, ci);
 
@@ -2397,33 +2238,43 @@ compare_comp_instance (gconstpointer a,
 
 static time_t
 convert_to_tt_with_zone (const ECalComponentDateTime *dt,
-                        ECalRecurResolveTimezoneFn tz_cb,
+                        ECalRecurResolveTimezoneCb tz_cb,
                         gpointer tz_cb_data,
-                        icaltimezone *default_timezone)
+                        ICalTimezone *default_timezone)
 {
-       icaltimezone *zone = default_timezone;
+       ICalTimezone *zone = NULL;
+       ICalTimetype *value;
+       time_t tt;
 
-       if (!dt || !dt->value)
-               return (time_t) 0;
+       value = dt ? e_cal_component_datetime_get_value (dt) : NULL;
 
-       if (icaltime_is_utc (*dt->value)) {
-               zone = icaltimezone_get_utc_timezone ();
-       } else if (tz_cb && !dt->value->is_date && dt->tzid) {
-               zone = (*tz_cb) (dt->tzid, tz_cb_data);
+       if (!dt || !value)
+               return (time_t) 0;
 
-               if (!zone)
-                       zone = default_timezone;
+       if (i_cal_time_is_utc (value)) {
+               zone = i_cal_timezone_get_utc_timezone ();
+               if (zone)
+                       g_object_ref (zone);
+       } else if (tz_cb && !i_cal_time_is_date (value) && e_cal_component_datetime_get_tzid (dt)) {
+               zone = (*tz_cb) (e_cal_component_datetime_get_tzid (dt), tz_cb_data, NULL, NULL);
        }
 
-       return icaltime_as_timet_with_zone (*dt->value, zone);
+       if (!zone)
+               zone = default_timezone ? g_object_ref (default_timezone) : NULL;
+
+       tt = i_cal_time_as_timet_with_zone (value, zone);
+
+       g_clear_object (&zone);
+
+       return tt;
 }
 
 static GSList *
 process_detached_instances (GSList *instances,
                            GSList *detached_instances,
-                           ECalRecurResolveTimezoneFn tz_cb,
+                           ECalRecurResolveTimezoneCb tz_cb,
                            gpointer tz_cb_data,
-                           icaltimezone *default_timezone)
+                           ICalTimezone *default_timezone)
 {
        struct comp_instance *ci, *cid;
        GSList *dl, *unprocessed_instances = NULL;
@@ -2432,21 +2283,23 @@ process_detached_instances (GSList *instances,
                GSList *il;
                const gchar *uid;
                gboolean processed;
-               ECalComponentRange recur_id;
+               ECalComponentRange *recur_id;
                time_t d_rid, i_rid;
 
                processed = FALSE;
-               recur_id.type = E_CAL_COMPONENT_RANGE_SINGLE;
-               recur_id.datetime.value = NULL;
 
                cid = dl->data;
-               e_cal_component_get_uid (cid->comp, &uid);
-               e_cal_component_get_recurid (cid->comp, &recur_id);
+               uid = e_cal_component_get_uid (cid->comp);
+               recur_id = e_cal_component_get_recurid (cid->comp);
 
-               if (!recur_id.datetime.value)
+               if (!recur_id ||
+                   !e_cal_component_range_get_datetime (recur_id) ||
+                   !e_cal_component_datetime_get_value (e_cal_component_range_get_datetime (recur_id))) {
+                       e_cal_component_range_free (recur_id);
                        continue;
+               }
 
-               d_rid = convert_to_tt_with_zone (&recur_id.datetime, tz_cb, tz_cb_data, default_timezone);
+               d_rid = convert_to_tt_with_zone (e_cal_component_range_get_datetime (recur_id), tz_cb, 
tz_cb_data, default_timezone);
 
                /* search for coincident instances already expanded */
                for (il = instances; il != NULL; il = il->next) {
@@ -2454,17 +2307,16 @@ process_detached_instances (GSList *instances,
                        gint cmp;
 
                        ci = il->data;
-                       e_cal_component_get_uid (ci->comp, &instance_uid);
-
-                       if (strcmp (uid, instance_uid) == 0) {
-                               ECalComponentRange instance_recur_id;
+                       instance_uid = e_cal_component_get_uid (ci->comp);
 
-                               instance_recur_id.type = E_CAL_COMPONENT_RANGE_SINGLE;
-                               instance_recur_id.datetime.value = NULL;
+                       if (g_strcmp0 (uid, instance_uid) == 0) {
+                               ECalComponentRange *instance_recur_id;
 
-                               e_cal_component_get_recurid (ci->comp, &instance_recur_id);
+                               instance_recur_id = e_cal_component_get_recurid (ci->comp);
 
-                               if (!instance_recur_id.datetime.value) {
+                               if (!instance_recur_id ||
+                                   !e_cal_component_range_get_datetime (instance_recur_id) ||
+                                   !e_cal_component_datetime_get_value (e_cal_component_range_get_datetime 
(instance_recur_id))) {
                                        /*
                                         * Prevent obvious segfault by ignoring missing
                                         * recurrency ids. Real problem might be elsewhere,
@@ -2472,13 +2324,13 @@ process_detached_instances (GSList *instances,
                                         */
                                        g_warning ("UID %s: instance RECURRENCE-ID and detached instance 
RECURRENCE-ID cannot compare", uid);
 
-                                       e_cal_component_free_range (&instance_recur_id);
+                                       e_cal_component_range_free (instance_recur_id);
                                        continue;
                                }
 
-                               i_rid = convert_to_tt_with_zone (&instance_recur_id.datetime, tz_cb, 
tz_cb_data, default_timezone);
+                               i_rid = convert_to_tt_with_zone (e_cal_component_range_get_datetime 
(instance_recur_id), tz_cb, tz_cb_data, default_timezone);
 
-                               if (recur_id.type == E_CAL_COMPONENT_RANGE_SINGLE && i_rid == d_rid) {
+                               if (e_cal_component_range_get_kind (recur_id) == E_CAL_COMPONENT_RANGE_SINGLE 
&& i_rid == d_rid) {
                                        g_object_unref (ci->comp);
                                        ci->comp = g_object_ref (cid->comp);
                                        ci->start = cid->start;
@@ -2487,15 +2339,12 @@ process_detached_instances (GSList *instances,
                                        processed = TRUE;
                                } else {
                                        cmp = i_rid == d_rid ? 0 : i_rid < d_rid ? -1 : 1;
-                                       if ((recur_id.type == E_CAL_COMPONENT_RANGE_THISPRIOR && cmp <= 0) ||
-                                               (recur_id.type == E_CAL_COMPONENT_RANGE_THISFUTURE && cmp >= 
0)) {
+                                       if ((e_cal_component_range_get_kind (recur_id) == 
E_CAL_COMPONENT_RANGE_THISPRIOR && cmp <= 0) ||
+                                           (e_cal_component_range_get_kind (recur_id) == 
E_CAL_COMPONENT_RANGE_THISFUTURE && cmp >= 0)) {
                                                ECalComponent *comp;
 
-                                               comp = e_cal_component_new ();
-                                               e_cal_component_set_icalcomponent (
-                                                       comp,
-                                                       icalcomponent_new_clone 
(e_cal_component_get_icalcomponent (cid->comp)));
-                                               e_cal_component_set_recurid (comp, &instance_recur_id);
+                                               comp = e_cal_component_clone (cid->comp);
+                                               e_cal_component_set_recurid (comp, instance_recur_id);
 
                                                /* replace the generated instances */
                                                g_object_unref (ci->comp);
@@ -2503,11 +2352,11 @@ process_detached_instances (GSList *instances,
                                        }
                                }
 
-                               e_cal_component_free_range (&instance_recur_id);
+                               e_cal_component_range_free (instance_recur_id);
                        }
                }
 
-               e_cal_component_free_datetime (&recur_id.datetime);
+               e_cal_component_range_free (recur_id);
 
                if (!processed)
                        unprocessed_instances = g_slist_prepend (unprocessed_instances, cid);
@@ -2535,13 +2384,13 @@ generate_instances (ECalClient *client,
                     time_t end,
                     GSList *objects,
                     GCancellable *cancellable,
-                    ECalRecurInstanceFn cb,
+                    ECalRecurInstanceCb cb,
                     gpointer cb_data)
 {
        GSList *instances, *detached_instances = NULL;
        GSList *l;
        ECalClientPrivate *priv;
-       icaltimezone *default_zone;
+       ICalTimezone *default_zone;
 
        priv = client->priv;
 
@@ -2550,7 +2399,7 @@ generate_instances (ECalClient *client,
        if (priv->default_zone)
                default_zone = priv->default_zone;
        else
-               default_zone = icaltimezone_get_utc_timezone ();
+               default_zone = i_cal_timezone_get_utc_timezone ();
 
        for (l = objects; l && !g_cancellable_is_cancelled (cancellable); l = l->next) {
                ECalComponent *comp;
@@ -2558,98 +2407,90 @@ generate_instances (ECalClient *client,
                comp = l->data;
                if (e_cal_component_is_instance (comp)) {
                        struct comp_instance *ci;
-                       ECalComponentDateTime dtstart, dtend;
-                       icaltimezone *start_zone = NULL, *end_zone = NULL;
+                       ECalComponentDateTime *dtstart, *dtend;
+                       ICalTimezone *start_zone = NULL, *end_zone = NULL;
 
                        /* keep the detached instances apart */
                        ci = g_new0 (struct comp_instance, 1);
                        ci->comp = g_object_ref (comp);
 
-                       e_cal_component_get_dtstart (comp, &dtstart);
-                       e_cal_component_get_dtend (comp, &dtend);
+                       dtstart = e_cal_component_get_dtstart (comp);
+                       dtend = e_cal_component_get_dtend (comp);
 
                        /* For DATE-TIME values with a TZID, we use
                         * e_cal_resolve_tzid_cb to resolve the TZID.
                         * For DATE values and DATE-TIME values without a
                         * TZID (i.e. floating times) we use the default
                         * timezone. */
-                       if (dtstart.tzid && dtstart.value && !dtstart.value->is_date) {
-                               start_zone = e_cal_client_resolve_tzid_cb (
-                                       dtstart.tzid, client);
+                       if (dtstart && e_cal_component_datetime_get_tzid (dtstart) && 
e_cal_component_datetime_get_value (dtstart) &&
+                           !i_cal_timetype_get_is_date (e_cal_component_datetime_get_value (dtstart))) {
+                               start_zone = e_cal_client_tzlookup_cb (e_cal_component_datetime_get_tzid 
(dtstart), client, cancellable, NULL);
                                if (!start_zone)
                                        start_zone = default_zone;
                        } else {
                                start_zone = default_zone;
                        }
 
-                       if (dtend.tzid && dtend.value && !dtend.value->is_date) {
-                               end_zone = e_cal_client_resolve_tzid_cb (
-                                       dtend.tzid, client);
+                       if (dtend && e_cal_component_datetime_get_tzid (dtend) && 
e_cal_component_datetime_get_value (dtend) &&
+                           !i_cal_timetype_get_is_date (e_cal_component_datetime_get_value (dtend))) {
+                               end_zone = e_cal_client_tzlookup_cb (e_cal_component_datetime_get_tzid 
(dtend), client, cancellable, NULL);
                                if (!end_zone)
                                        end_zone = default_zone;
                        } else {
                                end_zone = default_zone;
                        }
 
-                       if (!dtstart.value) {
+                       if (!dtstart || !e_cal_component_datetime_get_value (dtstart)) {
                                g_warn_if_reached ();
 
-                               e_cal_component_free_datetime (&dtstart);
-                               e_cal_component_free_datetime (&dtend);
+                               e_cal_component_datetime_free (dtstart);
+                               e_cal_component_datetime_free (dtend);
                                g_object_unref (G_OBJECT (ci->comp));
                                g_free (ci);
 
                                continue;
                        }
 
-                       if (dtstart.value) {
-                               ci->start = icaltime_as_timet_with_zone (
-                                       *dtstart.value, start_zone);
-                       }
+                       ci->start = i_cal_time_as_timet_with_zone (e_cal_component_datetime_get_value 
(dtstart), start_zone);
 
-                       if (dtend.value)
-                               ci->end = icaltime_as_timet_with_zone (
-                                       *dtend.value, end_zone);
-                       else if (dtstart.value && icaltime_is_date (*dtstart.value))
+                       if (dtend && e_cal_component_datetime_get_value (dtend))
+                               ci->end = i_cal_time_as_timet_with_zone (e_cal_component_datetime_get_value 
(dtend), end_zone);
+                       else if (i_cal_time_is_date (e_cal_component_datetime_get_value (dtstart)))
                                ci->end = time_day_end (ci->start);
                        else
                                ci->end = ci->start;
 
-                       e_cal_component_free_datetime (&dtstart);
-                       e_cal_component_free_datetime (&dtend);
+                       e_cal_component_datetime_free (dtstart);
+                       e_cal_component_datetime_free (dtend);
 
                        if (ci->start <= end && ci->end >= start) {
-                               detached_instances = g_slist_prepend (
-                                       detached_instances, ci);
+                               detached_instances = g_slist_prepend (detached_instances, ci);
                        } else {
                                /* it doesn't fit to our time range, thus skip it */
                                g_object_unref (G_OBJECT (ci->comp));
                                g_free (ci);
                        }
                } else {
-                       ECalComponentDateTime datetime;
-                       icaltimezone *start_zone = NULL, *end_zone = NULL;
+                       ECalComponentDateTime *datetime;
+                       ICalTimezone *start_zone = NULL, *end_zone = NULL;
+                       ICalTimetype *starttt, *endtt;
                        struct instances_info *instances_hold;
 
                        /* Get the start timezone */
-                       e_cal_component_get_dtstart (comp, &datetime);
-                       if (datetime.tzid)
-                               e_cal_client_get_timezone_sync (
-                                       client, datetime.tzid,
-                                       &start_zone, cancellable, NULL);
+                       datetime = e_cal_component_get_dtstart (comp);
+                       if (datetime && e_cal_component_datetime_get_tzid (datetime))
+                               e_cal_client_get_timezone_sync (client, e_cal_component_datetime_get_tzid 
(datetime), &start_zone, cancellable, NULL);
                        else
                                start_zone = NULL;
-                       e_cal_component_free_datetime (&datetime);
+                       e_cal_component_datetime_free (datetime);
 
                        /* Get the end timezone */
-                       e_cal_component_get_dtend (comp, &datetime);
-                       if (datetime.tzid)
-                               e_cal_client_get_timezone_sync (
-                                       client, datetime.tzid,
-                                       &end_zone, cancellable, NULL);
+                       datetime = e_cal_component_get_dtend (comp);
+                       if (datetime && e_cal_component_datetime_get_tzid (datetime))
+                               e_cal_client_get_timezone_sync (client, e_cal_component_datetime_get_tzid 
(datetime), &end_zone, cancellable, NULL);
                        else
                                end_zone = NULL;
-                       e_cal_component_free_datetime (&datetime);
+                       e_cal_component_datetime_free (datetime);
 
                        instances_hold = g_new0 (struct instances_info, 1);
                        instances_hold->instances = &instances;
@@ -2657,33 +2498,44 @@ generate_instances (ECalClient *client,
                        instances_hold->end_zone = end_zone;
                        instances_hold->default_zone = default_zone;
 
-                       e_cal_recur_generate_instances (
-                               comp, start, end, add_instance, instances_hold,
-                               e_cal_client_resolve_tzid_cb, client,
-                               default_zone);
+                       starttt = i_cal_time_from_timet_with_zone (start, FALSE, NULL);
+                       endtt = i_cal_time_from_timet_with_zone (end, FALSE, NULL);
+
+                       e_cal_recur_generate_instances_sync (
+                               e_cal_component_get_icalcomponent (comp), starttt, endtt, add_instance_cb, 
instances_hold,
+                               e_cal_client_tzlookup_cb, client,
+                               default_zone, cancellable, NULL);
 
+                       g_clear_object (&starttt);
+                       g_clear_object (&endtt);
                        g_free (instances_hold);
                }
        }
 
-       g_slist_foreach (objects, (GFunc) g_object_unref, NULL);
-       g_slist_free (objects);
+       g_slist_free_full (objects, g_object_unref);
 
        /* Generate instances and spew them out */
 
        if (!g_cancellable_is_cancelled (cancellable)) {
                instances = g_slist_sort (instances, compare_comp_instance);
                instances = process_detached_instances (instances, detached_instances,
-                       e_cal_client_resolve_tzid_cb, client, default_zone);
+                       e_cal_client_tzlookup_cb, client, default_zone);
        }
 
        for (l = instances; l && !g_cancellable_is_cancelled (cancellable); l = l->next) {
                struct comp_instance *ci;
+               ICalTimetype *starttt, *endtt;
                gboolean result;
 
                ci = l->data;
 
-               result = (* cb) (ci->comp, ci->start, ci->end, cb_data);
+               starttt = i_cal_time_from_timet_with_zone (ci->start, FALSE, default_zone);
+               endtt = i_cal_time_from_timet_with_zone (ci->end, FALSE, default_zone);
+
+               result = (* cb) (e_cal_component_get_icalcomponent (ci->comp), starttt, endtt, cb_data, 
cancellable, NULL);
+
+               g_clear_object (&starttt);
+               g_clear_object (&endtt);
 
                if (!result)
                        break;
@@ -2770,15 +2622,15 @@ struct get_objects_async_data {
        ECalClient *client;
        time_t start;
        time_t end;
-       ECalRecurInstanceFn cb;
+       ECalRecurInstanceCb cb;
        gpointer cb_data;
        GDestroyNotify destroy_cb_data;
        gchar *uid;
        gchar *query;
        guint tries;
        void (* ready_cb) (struct get_objects_async_data *goad, GSList *objects);
-       icaltimezone *start_zone;
-       icaltimezone *end_zone;
+       ICalTimezone *start_zone;
+       ICalTimezone *end_zone;
        ECalComponent *comp;
 };
 
@@ -2944,7 +2796,7 @@ generate_instances_got_objects_cb (struct get_objects_async_data *goad,
  *                   @cb_data; can be %NULL.
  *
  * Does a combination of e_cal_client_get_object_list() and
- * e_cal_recur_generate_instances(). Unlike
+ * e_cal_recur_generate_instances_sync(). Unlike
  * e_cal_client_generate_instances_sync(), this returns immediately and the
  * @cb callback is called asynchronously.
  *
@@ -2959,7 +2811,7 @@ e_cal_client_generate_instances (ECalClient *client,
                                  time_t start,
                                  time_t end,
                                  GCancellable *cancellable,
-                                 ECalRecurInstanceFn cb,
+                                 ECalRecurInstanceCb cb,
                                  gpointer cb_data,
                                  GDestroyNotify destroy_cb_data)
 {
@@ -3000,7 +2852,7 @@ e_cal_client_generate_instances (ECalClient *client,
  * @cb_data: (closure): Closure data for the callback
  *
  * Does a combination of e_cal_client_get_object_list() and
- * e_cal_recur_generate_instances().
+ * e_cal_recur_generate_instances_sync().
  *
  * The callback function should do a g_object_ref() of the calendar component
  * it gets passed if it intends to keep it around, since it will be unreffed
@@ -3012,7 +2864,7 @@ void
 e_cal_client_generate_instances_sync (ECalClient *client,
                                       time_t start,
                                       time_t end,
-                                      ECalRecurInstanceFn cb,
+                                      ECalRecurInstanceCb cb,
                                       gpointer cb_data)
 {
        GSList *objects = NULL;
@@ -3033,20 +2885,22 @@ e_cal_client_generate_instances_sync (ECalClient *client,
 
 /* also frees 'instances' GSList */
 static void
-process_instances (ECalComponent *comp,
+process_instances (ECalClient *client,
+                  ECalComponent *comp,
                    GSList *instances,
-                   ECalRecurInstanceFn cb,
+                   ECalRecurInstanceCb cb,
                    gpointer cb_data)
 {
        gchar *rid;
        gboolean result;
 
+       g_return_if_fail (E_IS_CAL_CLIENT (client));
        g_return_if_fail (comp != NULL);
        g_return_if_fail (cb != NULL);
 
        rid = e_cal_component_get_recurid_as_string (comp);
 
-       /* Reverse the instances list because the add_instance() function
+       /* Reverse the instances list because the add_instance_cb() function
         * is prepending. */
        instances = g_slist_reverse (instances);
 
@@ -3059,13 +2913,26 @@ process_instances (ECalComponent *comp,
                ci = instances->data;
 
                if (result) {
+                       ICalTimetype *starttt = NULL, *endtt = NULL;
+
                        instance_rid = e_cal_component_get_recurid_as_string (ci->comp);
 
                        if (rid && *rid) {
-                               if (instance_rid && *instance_rid && strcmp (rid, instance_rid) == 0)
-                                       result = (* cb) (ci->comp, ci->start, ci->end, cb_data);
-                       } else
-                               result = (* cb) (ci->comp, ci->start, ci->end, cb_data);
+                               if (instance_rid && *instance_rid && strcmp (rid, instance_rid) == 0) {
+                                       starttt = i_cal_time_from_timet_with_zone (ci->start, FALSE, 
client->priv->default_zone);
+                                       endtt = i_cal_time_from_timet_with_zone (ci->end, FALSE, 
client->priv->default_zone);
+
+                                       result = (* cb) (e_cal_component_get_icalcomponent (ci->comp), 
starttt, endtt, cb_data, NULL, NULL);
+                               }
+                       } else {
+                               starttt = i_cal_time_from_timet_with_zone (ci->start, FALSE, 
client->priv->default_zone);
+                               endtt = i_cal_time_from_timet_with_zone (ci->end, FALSE, 
client->priv->default_zone);
+
+                               result = (* cb) (e_cal_component_get_icalcomponent (ci->comp), starttt, 
endtt, cb_data, NULL, NULL);
+                       }
+
+                       g_clear_object (&starttt);
+                       g_clear_object (&endtt);
                }
 
                /* remove instance from list */
@@ -3097,11 +2964,11 @@ generate_instances_for_object_got_objects_cb (struct get_objects_async_data *goa
        /* generate all instances in the given time range */
        generate_instances (
                goad->client, goad->start, goad->end, objects,
-               goad->cancellable, add_instance, instances_hold);
+               goad->cancellable, add_instance_cb, instances_hold);
 
        /* it also frees 'instances' GSList */
        process_instances (
-               goad->comp, *(instances_hold->instances),
+               goad->client, goad->comp, *(instances_hold->instances),
                goad->cb, goad->cb_data);
 
        /* clean up */
@@ -3122,7 +2989,7 @@ generate_instances_for_object_got_objects_cb (struct get_objects_async_data *goa
  *                   free @cb_data; can be %NULL.
  *
  * Does a combination of e_cal_client_get_object_list() and
- * e_cal_recur_generate_instances(), like
+ * e_cal_recur_generate_instances_sync(), like
  * e_cal_client_generate_instances(), but for a single object. Unlike
  * e_cal_client_generate_instances_for_object_sync(), this returns immediately
  * and the @cb callback is called asynchronously.
@@ -3135,19 +3002,18 @@ generate_instances_for_object_got_objects_cb (struct get_objects_async_data *goa
  **/
 void
 e_cal_client_generate_instances_for_object (ECalClient *client,
-                                            icalcomponent *icalcomp,
+                                            ICalComponent *icalcomp,
                                             time_t start,
                                             time_t end,
                                             GCancellable *cancellable,
-                                            ECalRecurInstanceFn cb,
+                                            ECalRecurInstanceCb cb,
                                             gpointer cb_data,
                                             GDestroyNotify destroy_cb_data)
 {
        ECalComponent *comp;
        const gchar *uid;
-       ECalComponentDateTime datetime;
-       icaltimezone *start_zone = NULL, *end_zone = NULL;
-       gboolean is_single_instance = FALSE;
+       ECalComponentDateTime *datetime;
+       ICalTimezone *start_zone = NULL, *end_zone = NULL;
        struct get_objects_async_data *goad;
        GCancellable *use_cancellable;
 
@@ -3157,50 +3023,47 @@ e_cal_client_generate_instances_for_object (ECalClient *client,
        g_return_if_fail (end >= 0);
        g_return_if_fail (cb != NULL);
 
-       comp = e_cal_component_new ();
-       e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp));
-
-       if (!e_cal_component_has_recurrences (comp))
-               is_single_instance = TRUE;
-
        /* If the backend stores it as individual instances and does not
         * have a master object - do not expand */
-       if (is_single_instance || e_client_check_capability (E_CLIENT (client), 
E_CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER)) {
+       if (!e_cal_util_component_has_recurrences (icalcomp) || e_client_check_capability (E_CLIENT (client), 
E_CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER)) {
+               ICalTimetype *dtstart, *dtend;
+
+               dtstart = i_cal_component_get_dtstart (icalcomp);
+               dtend = i_cal_component_get_dtend (icalcomp);
+
                /* return the same instance */
-               (* cb)  (comp,
-                       icaltime_as_timet_with_zone (
-                               icalcomponent_get_dtstart (icalcomp),
-                               client->priv->default_zone),
-                       icaltime_as_timet_with_zone (
-                               icalcomponent_get_dtend (icalcomp),
-                               client->priv->default_zone),
-                       cb_data);
-               g_object_unref (comp);
+               (* cb)  (icalcomp, dtstart, dtend, cb_data, NULL, NULL);
+
+               g_clear_object (&dtstart);
+               g_clear_object (&dtend);
 
                if (destroy_cb_data)
                        destroy_cb_data (cb_data);
                return;
        }
 
-       e_cal_component_get_uid (comp, &uid);
+       comp = e_cal_component_new_from_icalcomponent (i_cal_component_new_clone (icalcomp));
+       g_return_if_fail (comp != NULL);
+
+       uid = e_cal_component_get_uid (comp);
 
        /* Get the start timezone */
-       e_cal_component_get_dtstart (comp, &datetime);
-       if (datetime.tzid)
+       datetime = e_cal_component_get_dtstart (comp);
+       if (datetime && e_cal_component_datetime_get_tzid (datetime))
                e_cal_client_get_timezone_sync (
-                       client, datetime.tzid, &start_zone, NULL, NULL);
+                       client, e_cal_component_datetime_get_tzid (datetime), &start_zone, cancellable, NULL);
        else
                start_zone = NULL;
-       e_cal_component_free_datetime (&datetime);
+       e_cal_component_datetime_free (datetime);
 
        /* Get the end timezone */
-       e_cal_component_get_dtend (comp, &datetime);
-       if (datetime.tzid)
+       datetime = e_cal_component_get_dtend (comp);
+       if (datetime && e_cal_component_datetime_get_tzid (datetime))
                e_cal_client_get_timezone_sync (
-                       client, datetime.tzid, &end_zone, NULL, NULL);
+                       client, e_cal_component_datetime_get_tzid (datetime), &end_zone, cancellable, NULL);
        else
                end_zone = NULL;
-       e_cal_component_free_datetime (&datetime);
+       e_cal_component_datetime_free (datetime);
 
        use_cancellable = cancellable;
        if (!use_cancellable)
@@ -3235,7 +3098,7 @@ e_cal_client_generate_instances_for_object (ECalClient *client,
  * @cb_data: (closure): Closure data for the callback
  *
  * Does a combination of e_cal_client_get_object_list() and
- * e_cal_recur_generate_instances(), like
+ * e_cal_recur_generate_instances_sync(), like
  * e_cal_client_generate_instances_sync(), but for a single object.
  *
  * The callback function should do a g_object_ref() of the calendar component
@@ -3246,19 +3109,18 @@ e_cal_client_generate_instances_for_object (ECalClient *client,
  **/
 void
 e_cal_client_generate_instances_for_object_sync (ECalClient *client,
-                                                 icalcomponent *icalcomp,
+                                                 ICalComponent *icalcomp,
                                                  time_t start,
                                                  time_t end,
-                                                 ECalRecurInstanceFn cb,
+                                                 ECalRecurInstanceCb cb,
                                                  gpointer cb_data)
 {
        ECalComponent *comp;
        const gchar *uid;
        GSList *instances = NULL;
-       ECalComponentDateTime datetime;
-       icaltimezone *start_zone = NULL, *end_zone = NULL;
+       ECalComponentDateTime *datetime;
+       ICalTimezone *start_zone = NULL, *end_zone = NULL;
        struct instances_info *instances_hold;
-       gboolean is_single_instance = FALSE;
 
        g_return_if_fail (E_IS_CAL_CLIENT (client));
 
@@ -3266,47 +3128,43 @@ e_cal_client_generate_instances_for_object_sync (ECalClient *client,
        g_return_if_fail (end >= 0);
        g_return_if_fail (cb != NULL);
 
-       comp = e_cal_component_new ();
-       e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp));
-
-       if (!e_cal_component_has_recurrences (comp))
-               is_single_instance = TRUE;
-
        /* If the backend stores it as individual instances and does not
         * have a master object - do not expand */
-       if (is_single_instance || e_client_check_capability (E_CLIENT (client), 
E_CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER)) {
+       if (!e_cal_util_component_has_recurrences (icalcomp) || e_client_check_capability (E_CLIENT (client), 
E_CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER)) {
+               ICalTimetype *dtstart, *dtend;
+
+               dtstart = i_cal_component_get_dtstart (icalcomp);
+               dtend = i_cal_component_get_dtend (icalcomp);
+
                /* return the same instance */
-               (* cb)  (comp,
-                       icaltime_as_timet_with_zone (
-                               icalcomponent_get_dtstart (icalcomp),
-                               client->priv->default_zone),
-                       icaltime_as_timet_with_zone (
-                               icalcomponent_get_dtend (icalcomp),
-                               client->priv->default_zone),
-                       cb_data);
-               g_object_unref (comp);
+               (* cb)  (icalcomp, dtstart, dtend, cb_data, NULL, NULL);
+
+               g_clear_object (&dtstart);
+               g_clear_object (&dtend);
+
                return;
        }
 
-       e_cal_component_get_uid (comp, &uid);
+       comp = e_cal_component_new_from_icalcomponent (i_cal_component_new_clone (icalcomp));
+       g_return_if_fail (comp != NULL);
+
+       uid = e_cal_component_get_uid (comp);
 
        /* Get the start timezone */
-       e_cal_component_get_dtstart (comp, &datetime);
-       if (datetime.tzid)
-               e_cal_client_get_timezone_sync (
-                       client, datetime.tzid, &start_zone, NULL, NULL);
+       datetime = e_cal_component_get_dtstart (comp);
+       if (datetime && e_cal_component_datetime_get_tzid (datetime))
+               e_cal_client_get_timezone_sync (client, e_cal_component_datetime_get_tzid (datetime), 
&start_zone, NULL, NULL);
        else
                start_zone = NULL;
-       e_cal_component_free_datetime (&datetime);
+       e_cal_component_datetime_free (datetime);
 
        /* Get the end timezone */
-       e_cal_component_get_dtend (comp, &datetime);
-       if (datetime.tzid)
-               e_cal_client_get_timezone_sync (
-                       client, datetime.tzid, &end_zone, NULL, NULL);
+       datetime = e_cal_component_get_dtend (comp);
+       if (datetime && e_cal_component_datetime_get_tzid (datetime))
+               e_cal_client_get_timezone_sync (client, e_cal_component_datetime_get_tzid (datetime), 
&end_zone, NULL, NULL);
        else
                end_zone = NULL;
-       e_cal_component_free_datetime (&datetime);
+       e_cal_component_datetime_free (datetime);
 
        instances_hold = g_new0 (struct instances_info, 1);
        instances_hold->instances = &instances;
@@ -3318,10 +3176,10 @@ e_cal_client_generate_instances_for_object_sync (ECalClient *client,
        generate_instances (
                client, start, end,
                get_objects_sync (client, start, end, uid),
-               NULL, add_instance, instances_hold);
+               NULL, add_instance_cb, instances_hold);
 
        /* it also frees 'instances' GSList */
-       process_instances (comp, *(instances_hold->instances), cb, cb_data);
+       process_instances (client, comp, *(instances_hold->instances), cb, cb_data);
 
        /* clean up */
        g_object_unref (comp);
@@ -3338,17 +3196,17 @@ struct _ForeachTZIDCallbackData {
 /* This adds the VTIMEZONE given by the TZID parameter to the GHashTable in
  * data. */
 static void
-foreach_tzid_callback (icalparameter *param,
+foreach_tzid_callback (ICalParameter *param,
                        gpointer cbdata)
 {
        ForeachTZIDCallbackData *data = cbdata;
        const gchar *tzid;
-       icaltimezone *zone = NULL;
-       icalcomponent *vtimezone_comp;
+       ICalTimezone *zone = NULL;
+       ICalComponent *vtimezone_comp;
        gchar *vtimezone_as_string;
 
        /* Get the TZID string from the parameter. */
-       tzid = icalparameter_get_tzid (param);
+       tzid = i_cal_parameter_get_tzid (param);
        if (!tzid)
                return;
 
@@ -3362,11 +3220,11 @@ foreach_tzid_callback (icalparameter *param,
        }
 
        /* Convert it to a string and add it to the hash. */
-       vtimezone_comp = icaltimezone_get_component (zone);
+       vtimezone_comp = i_cal_timezone_get_component (zone);
        if (!vtimezone_comp)
                return;
 
-       vtimezone_as_string = icalcomponent_as_ical_string_r (vtimezone_comp);
+       vtimezone_as_string = i_cal_component_as_ical_string_r (vtimezone_comp);
 
        g_hash_table_insert (data->timezone_hash, (gchar *) tzid, vtimezone_as_string);
 }
@@ -3407,7 +3265,7 @@ free_timezone_string (gpointer key,
  **/
 gchar *
 e_cal_client_get_component_as_string (ECalClient *client,
-                                      icalcomponent *icalcomp)
+                                      ICalComponent *icalcomp)
 {
        GHashTable *timezone_hash;
        GString *vcal_string;
@@ -3424,7 +3282,7 @@ e_cal_client_get_component_as_string (ECalClient *client,
        cbdata.client = client;
        cbdata.timezone_hash = timezone_hash;
        cbdata.success = TRUE;
-       icalcomponent_foreach_tzid (icalcomp, foreach_tzid_callback, &cbdata);
+       i_cal_component_foreach_tzid (icalcomp, foreach_tzid_callback, &cbdata);
        if (!cbdata.success) {
                g_hash_table_foreach (timezone_hash, free_timezone_string, NULL);
                return NULL;
@@ -3445,7 +3303,7 @@ e_cal_client_get_component_as_string (ECalClient *client,
        g_hash_table_foreach (timezone_hash, append_timezone_string, vcal_string);
 
        /* Get the string for the VEVENT/VTODO. */
-       obj_string = icalcomponent_as_ical_string_r (icalcomp);
+       obj_string = i_cal_component_as_ical_string_r (icalcomp);
 
        /* If there were any timezones to send, create a complete VCALENDAR,
         * else just send the VEVENT/VTODO string. */
@@ -3494,7 +3352,7 @@ cal_client_get_default_object_thread (GSimpleAsyncResult *simple,
  * @callback: callback to call when a result is ready
  * @user_data: user data for the @callback
  *
- * Retrives an #icalcomponent from the backend that contains the default
+ * Retrives an #ICalComponent from the backend that contains the default
  * values for properties needed. The call is finished
  * by e_cal_client_get_default_object_finish() from the @callback.
  *
@@ -3533,13 +3391,13 @@ e_cal_client_get_default_object (ECalClient *client,
  * e_cal_client_get_default_object_finish:
  * @client: an #ECalClient
  * @result: a #GAsyncResult
- * @out_icalcomp: (out): Return value for the default calendar object.
+ * @out_icalcomp: (out) (transfer full): Return value for the default calendar object.
  * @error: (out): a #GError to set an error, if any
  *
  * Finishes previous call of e_cal_client_get_default_object() and
- * sets @out_icalcomp to an #icalcomponent from the backend that contains
+ * sets @out_icalcomp to an #ICalComponent from the backend that contains
  * the default values for properties needed. This @out_icalcomp should be
- * freed with icalcomponent_free().
+ * freed with g_object_unref(), when no longer needed.
  *
  * Returns: %TRUE if successful, %FALSE otherwise.
  *
@@ -3548,7 +3406,7 @@ e_cal_client_get_default_object (ECalClient *client,
 gboolean
 e_cal_client_get_default_object_finish (ECalClient *client,
                                         GAsyncResult *result,
-                                        icalcomponent **out_icalcomp,
+                                        ICalComponent **out_icalcomp,
                                         GError **error)
 {
        GSimpleAsyncResult *simple;
@@ -3578,13 +3436,13 @@ e_cal_client_get_default_object_finish (ECalClient *client,
 /**
  * e_cal_client_get_default_object_sync:
  * @client: an #ECalClient
- * @out_icalcomp: (out): Return value for the default calendar object.
+ * @out_icalcomp: (out) (transfer full): Return value for the default calendar object.
  * @cancellable: a #GCancellable; can be %NULL
  * @error: (out): a #GError to set an error, if any
  *
- * Retrives an #icalcomponent from the backend that contains the default
+ * Retrives an #ICalComponent from the backend that contains the default
  * values for properties needed. This @out_icalcomp should be freed with
- * icalcomponent_free().
+ * g_object_unref(), when no longer needed.
  *
  * Returns: %TRUE if successful, %FALSE otherwise.
  *
@@ -3592,11 +3450,11 @@ e_cal_client_get_default_object_finish (ECalClient *client,
  **/
 gboolean
 e_cal_client_get_default_object_sync (ECalClient *client,
-                                      icalcomponent **out_icalcomp,
+                                      ICalComponent **out_icalcomp,
                                       GCancellable *cancellable,
                                       GError **error)
 {
-       icalcomponent *icalcomp = NULL;
+       ICalComponent *icalcomp = NULL;
        gchar *string;
 
        g_return_val_if_fail (E_IS_CAL_CLIENT (client), FALSE);
@@ -3604,7 +3462,7 @@ e_cal_client_get_default_object_sync (ECalClient *client,
 
        string = e_dbus_calendar_dup_default_object (client->priv->dbus_proxy);
        if (string != NULL) {
-               icalcomp = icalparser_parse_string (string);
+               icalcomp = i_cal_parser_parse_string (string);
                g_free (string);
        }
 
@@ -3617,12 +3475,12 @@ e_cal_client_get_default_object_sync (ECalClient *client,
                return FALSE;
        }
 
-       if (icalcomponent_get_uid (icalcomp) != NULL) {
+       if (i_cal_component_get_uid (icalcomp) != NULL) {
                gchar *new_uid;
 
                /* Make sure the UID is always unique. */
                new_uid = e_util_generate_uid ();
-               icalcomponent_set_uid (icalcomp, new_uid);
+               i_cal_component_set_uid (icalcomp, new_uid);
                g_free (new_uid);
        }
 
@@ -3718,13 +3576,13 @@ e_cal_client_get_object (ECalClient *client,
  * e_cal_client_get_object_finish:
  * @client: an #ECalClient
  * @result: a #GAsyncResult
- * @out_icalcomp: (out): Return value for the calendar component object.
+ * @out_icalcomp: (out) (transfer full): Return value for the calendar component object.
  * @error: (out): a #GError to set an error, if any
  *
  * Finishes previous call of e_cal_client_get_object() and
  * sets @out_icalcomp to queried component. This function always returns
  * master object for a case of @rid being NULL or an empty string.
- * This component should be freed with icalcomponent_free().
+ * This component should be freed with g_object_unref(), when no longer needed.
  *
  * Use e_cal_client_get_objects_for_uid() to get list of all
  * objects for the given uid, which includes master object and
@@ -3737,7 +3595,7 @@ e_cal_client_get_object (ECalClient *client,
 gboolean
 e_cal_client_get_object_finish (ECalClient *client,
                                 GAsyncResult *result,
-                                icalcomponent **out_icalcomp,
+                                ICalComponent **out_icalcomp,
                                 GError **error)
 {
        GSimpleAsyncResult *simple;
@@ -3769,14 +3627,15 @@ e_cal_client_get_object_finish (ECalClient *client,
  * @client: an #ECalClient
  * @uid: Unique identifier for a calendar component.
  * @rid: Recurrence identifier.
- * @out_icalcomp: (out): Return value for the calendar component object.
+ * @out_icalcomp: (out) (transfer full): Return value for the calendar component object.
  * @cancellable: a #GCancellable; can be %NULL
  * @error: (out): a #GError to set an error, if any
  *
  * Queries a calendar for a calendar component object based
  * on its unique identifier. This function always returns
  * master object for a case of @rid being NULL or an empty string.
- * This component should be freed with icalcomponent_free().
+ * This component should be freed with g_object_unref(),
+ * when no longer needed.
  *
  * Use e_cal_client_get_objects_for_uid_sync() to get list of all
  * objects for the given uid, which includes master object and
@@ -3790,12 +3649,12 @@ gboolean
 e_cal_client_get_object_sync (ECalClient *client,
                               const gchar *uid,
                               const gchar *rid,
-                              icalcomponent **out_icalcomp,
+                              ICalComponent **out_icalcomp,
                               GCancellable *cancellable,
                               GError **error)
 {
-       icalcomponent *icalcomp = NULL;
-       icalcomponent_kind kind;
+       ICalComponent *icalcomp = NULL;
+       ICalComponentKind kind;
        gchar *utf8_uid;
        gchar *utf8_rid;
        gchar *string = NULL;
@@ -3805,6 +3664,8 @@ e_cal_client_get_object_sync (ECalClient *client,
        g_return_val_if_fail (uid != NULL, FALSE);
        g_return_val_if_fail (out_icalcomp != NULL, FALSE);
 
+       *out_icalcomp = NULL;
+
        if (rid == NULL)
                rid = "";
 
@@ -3829,7 +3690,7 @@ e_cal_client_get_object_sync (ECalClient *client,
                return FALSE;
        }
 
-       icalcomp = icalparser_parse_string (string);
+       icalcomp = i_cal_parser_parse_string (string);
 
        g_free (string);
 
@@ -3844,55 +3705,61 @@ e_cal_client_get_object_sync (ECalClient *client,
 
        switch (e_cal_client_get_source_type (client)) {
                case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
-                       kind = ICAL_VEVENT_COMPONENT;
+                       kind = I_CAL_VEVENT_COMPONENT;
                        break;
                case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
-                       kind = ICAL_VTODO_COMPONENT;
+                       kind = I_CAL_VTODO_COMPONENT;
                        break;
                case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
-                       kind = ICAL_VJOURNAL_COMPONENT;
+                       kind = I_CAL_VJOURNAL_COMPONENT;
                        break;
                default:
                        g_warn_if_reached ();
-                       kind = ICAL_VEVENT_COMPONENT;
+                       kind = I_CAL_VEVENT_COMPONENT;
                        break;
        }
 
-       if (icalcomponent_isa (icalcomp) == kind) {
+       if (i_cal_component_isa (icalcomp) == kind) {
                *out_icalcomp = icalcomp;
+               icalcomp = NULL;
 
-       } else if (icalcomponent_isa (icalcomp) == ICAL_VCALENDAR_COMPONENT) {
-               icalcomponent *subcomponent;
+       } else if (i_cal_component_isa (icalcomp) == I_CAL_VCALENDAR_COMPONENT) {
+               ICalComponent *subcomponent;
 
-               for (subcomponent = icalcomponent_get_first_component (icalcomp, kind);
-                       subcomponent != NULL;
-                       subcomponent = icalcomponent_get_next_component (icalcomp, kind)) {
-                       struct icaltimetype recurrenceid;
+               for (subcomponent = i_cal_component_get_first_component (icalcomp, kind);
+                    subcomponent != NULL;
+                    g_object_unref (subcomponent), subcomponent = i_cal_component_get_next_component 
(icalcomp, kind)) {
+                       ICalTimetype *recurrenceid;
 
-                       if (icalcomponent_get_uid (subcomponent) == NULL)
+                       if (i_cal_component_get_uid (subcomponent) == NULL)
                                continue;
 
-                       recurrenceid =
-                               icalcomponent_get_recurrenceid (subcomponent);
-
-                       if (icaltime_is_null_time (recurrenceid))
-                               break;
+                       recurrenceid = i_cal_component_get_recurrenceid (subcomponent);
 
-                       if (!icaltime_is_valid_time (recurrenceid))
+                       if (!recurrenceid ||
+                           i_cal_time_is_null_time (recurrenceid) ||
+                           !i_cal_time_is_valid_time (recurrenceid)) {
+                               g_clear_object (&recurrenceid);
                                break;
+                       }
                }
 
                if (subcomponent == NULL)
-                       subcomponent = icalcomponent_get_first_component (icalcomp, kind);
-               if (subcomponent != NULL)
-                       subcomponent = icalcomponent_new_clone (subcomponent);
+                       subcomponent = i_cal_component_get_first_component (icalcomp, kind);
+               if (subcomponent != NULL) {
+                       ICalComponent *clone;
 
-               /* XXX Shouldn't we set an error is this is still NULL? */
-               *out_icalcomp = subcomponent;
+                       clone = i_cal_component_new_clone (subcomponent);
+                       g_object_unref (subcomponent);
+                       subcomponent = clone;
+               }
 
-               icalcomponent_free (icalcomp);
+               /* XXX Shouldn't we set an error if this is still NULL? */
+               *out_icalcomp = subcomponent;
        }
 
+       g_clear_object (&icalcomp);
+
        return TRUE;
 }
 
@@ -3984,7 +3851,7 @@ e_cal_client_get_objects_for_uid (ECalClient *client,
  * Finishes previous call of e_cal_client_get_objects_for_uid() and
  * sets @out_ecalcomps to a list of #ECalComponent<!-- -->s corresponding to
  * found components for a given uid of the same type as this client.
- * This list should be freed with e_cal_client_free_ecalcomp_slist().
+ * This list should be freed with e_client_util_free_object_slist().
  *
  * Returns: %TRUE if successful, %FALSE otherwise.
  *
@@ -4031,7 +3898,7 @@ e_cal_client_get_objects_for_uid_finish (ECalClient *client,
  * Queries a calendar for all calendar components with the given unique
  * ID. This will return any recurring event and all its detached recurrences.
  * For non-recurring events, it will just return the object with that ID.
- * This list should be freed with e_cal_client_free_ecalcomp_slist().
+ * This list should be freed with e_client_util_free_object_slist().
  *
  * Returns: %TRUE if successful, %FALSE otherwise.
  *
@@ -4044,8 +3911,8 @@ e_cal_client_get_objects_for_uid_sync (ECalClient *client,
                                        GCancellable *cancellable,
                                        GError **error)
 {
-       icalcomponent *icalcomp;
-       icalcomponent_kind kind;
+       ICalComponent *icalcomp;
+       ICalComponentKind kind;
        gchar *utf8_uid;
        gchar *string = NULL;
        GError *local_error = NULL;
@@ -4054,6 +3921,8 @@ e_cal_client_get_objects_for_uid_sync (ECalClient *client,
        g_return_val_if_fail (uid != NULL, FALSE);
        g_return_val_if_fail (out_ecalcomps != NULL, FALSE);
 
+       *out_ecalcomps = NULL;
+
        utf8_uid = e_util_utf8_make_valid (uid);
 
        e_dbus_calendar_call_get_object_sync (
@@ -4073,7 +3942,7 @@ e_cal_client_get_objects_for_uid_sync (ECalClient *client,
                return FALSE;
        }
 
-       icalcomp = icalparser_parse_string (string);
+       icalcomp = i_cal_parser_parse_string (string);
 
        g_free (string);
 
@@ -4088,52 +3957,47 @@ e_cal_client_get_objects_for_uid_sync (ECalClient *client,
 
        switch (e_cal_client_get_source_type (client)) {
                case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
-                       kind = ICAL_VEVENT_COMPONENT;
+                       kind = I_CAL_VEVENT_COMPONENT;
                        break;
                case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
-                       kind = ICAL_VTODO_COMPONENT;
+                       kind = I_CAL_VTODO_COMPONENT;
                        break;
                case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
-                       kind = ICAL_VJOURNAL_COMPONENT;
+                       kind = I_CAL_VJOURNAL_COMPONENT;
                        break;
                default:
                        g_warn_if_reached ();
-                       kind = ICAL_VEVENT_COMPONENT;
+                       kind = I_CAL_VEVENT_COMPONENT;
                        break;
        }
 
-       if (icalcomponent_isa (icalcomp) == kind) {
+       if (i_cal_component_isa (icalcomp) == kind) {
                ECalComponent *comp;
 
-               comp = e_cal_component_new ();
-               e_cal_component_set_icalcomponent (comp, icalcomp);
+               comp = e_cal_component_new_from_icalcomponent (icalcomp);
+               icalcomp = NULL;
+
                *out_ecalcomps = g_slist_append (NULL, comp);
 
-       } else if (icalcomponent_isa (icalcomp) == ICAL_VCALENDAR_COMPONENT) {
+       } else if (i_cal_component_isa (icalcomp) == I_CAL_VCALENDAR_COMPONENT) {
                GSList *tmp = NULL;
-               icalcomponent *subcomponent;
-
-               subcomponent = icalcomponent_get_first_component (
-                       icalcomp, kind);
+               ICalComponent *subcomponent;
 
-               while (subcomponent != NULL) {
+               for (subcomponent = i_cal_component_get_first_component (icalcomp, kind);
+                    subcomponent;
+                    g_object_unref (subcomponent), subcomponent = i_cal_component_get_next_component 
(icalcomp, kind)) {
                        ECalComponent *comp;
-                       icalcomponent *clone;
 
-                       comp = e_cal_component_new ();
-                       clone = icalcomponent_new_clone (subcomponent);
-                       e_cal_component_set_icalcomponent (comp, clone);
-                       tmp = g_slist_prepend (tmp, comp);
-
-                       subcomponent = icalcomponent_get_next_component (
-                               icalcomp, kind);
+                       comp = e_cal_component_new_from_icalcomponent (i_cal_component_new_clone 
(subcomponent));
+                       if (comp)
+                               tmp = g_slist_prepend (tmp, comp);
                }
 
                *out_ecalcomps = g_slist_reverse (tmp);
-
-               icalcomponent_free (icalcomp);
        }
 
+       g_clear_object (&icalcomp);
+
        return TRUE;
 }
 
@@ -4174,7 +4038,7 @@ cal_client_get_object_list_thread (GSimpleAsyncResult *simple,
  * @user_data: user data for the @callback
  *
  * Gets a list of objects from the calendar that match the query specified
- * by the @sexp argument, returning matching objects as a list of #icalcomponent-s.
+ * by the @sexp argument, returning matching objects as a list of #ICalComponent-s.
  * The call is finished by e_cal_client_get_object_list_finish() from
  * the @callback.
  *
@@ -4216,13 +4080,13 @@ e_cal_client_get_object_list (ECalClient *client,
  * e_cal_client_get_object_list_finish:
  * @client: an #ECalClient
  * @result: a #GAsyncResult
- * @out_icalcomps: (out) (element-type icalcomponent): list of matching
- *                 #icalcomponent<!-- -->s
+ * @out_icalcomps: (out) (element-type ICalComponent): list of matching
+ *                 #ICalComponent<!-- -->s
  * @error: (out): a #GError to set an error, if any
  *
  * Finishes previous call of e_cal_client_get_object_list() and
- * sets @out_icalcomps to a matching list of #icalcomponent-s.
- * This list should be freed with e_cal_client_free_icalcomp_slist().
+ * sets @out_icalcomps to a matching list of #ICalComponent-s.
+ * This list should be freed with e_client_util_free_object_slist().
  *
  * Returns: %TRUE if successful, %FALSE otherwise.
  *
@@ -4260,15 +4124,15 @@ e_cal_client_get_object_list_finish (ECalClient *client,
  * e_cal_client_get_object_list_sync:
  * @client: an #ECalClient
  * @sexp: an S-expression representing the query
- * @out_icalcomps: (out) (element-type icalcomponent): list of matching
- *                 #icalcomponent<!-- -->s
+ * @out_icalcomps: (out) (element-type ICalComponent): list of matching
+ *                 #ICalComponent<!-- -->s
  * @cancellable: (allow-none): a #GCancellable; can be %NULL
  * @error: (out): a #GError to set an error, if any
  *
  * Gets a list of objects from the calendar that match the query specified
  * by the @sexp argument. The objects will be returned in the @out_icalcomps
- * argument, which is a list of #icalcomponent.
- * This list should be freed with e_cal_client_free_icalcomp_slist().
+ * argument, which is a list of #ICalComponent.
+ * This list should be freed with e_client_util_free_object_slist().
  *
  * Returns: %TRUE if successful, %FALSE otherwise.
  *
@@ -4291,6 +4155,8 @@ e_cal_client_get_object_list_sync (ECalClient *client,
        g_return_val_if_fail (sexp != NULL, FALSE);
        g_return_val_if_fail (out_icalcomps != NULL, FALSE);
 
+       *out_icalcomps = NULL;
+
        utf8_sexp = e_util_utf8_make_valid (sexp);
 
        e_dbus_calendar_call_get_object_list_sync (
@@ -4311,9 +4177,9 @@ e_cal_client_get_object_list_sync (ECalClient *client,
        }
 
        for (ii = 0; strv[ii] != NULL; ii++) {
-               icalcomponent *icalcomp;
+               ICalComponent *icalcomp;
 
-               icalcomp = icalcomponent_new_from_string (strv[ii]);
+               icalcomp = i_cal_component_new_from_string (strv[ii]);
                if (icalcomp == NULL)
                        continue;
 
@@ -4412,7 +4278,7 @@ e_cal_client_get_object_list_as_comps (ECalClient *client,
  *
  * Finishes previous call of e_cal_client_get_object_list_as_comps() and
  * sets @out_ecalcomps to a matching list of #ECalComponent-s.
- * This list should be freed with e_cal_client_free_ecalcomp_slist().
+ * This list should be freed with e_client_util_free_object_slist().
  *
  * Returns: %TRUE if successful, %FALSE otherwise.
  *
@@ -4458,7 +4324,7 @@ e_cal_client_get_object_list_as_comps_finish (ECalClient *client,
  * Gets a list of objects from the calendar that match the query specified
  * by the @sexp argument. The objects will be returned in the @out_ecalcomps
  * argument, which is a list of #ECalComponent.
- * This list should be freed with e_cal_client_free_ecalcomp_slist().
+ * This list should be freed with e_client_util_free_object_slist().
  *
  * Returns: %TRUE if successful, %FALSE otherwise.
  *
@@ -4473,13 +4339,14 @@ e_cal_client_get_object_list_as_comps_sync (ECalClient *client,
 {
        GSList *list = NULL;
        GSList *link;
-       GQueue trash = G_QUEUE_INIT;
        gboolean success;
 
        g_return_val_if_fail (E_IS_CAL_CLIENT (client), FALSE);
        g_return_val_if_fail (sexp != NULL, FALSE);
        g_return_val_if_fail (out_ecalcomps != NULL, FALSE);
 
+       *out_ecalcomps = NULL;
+
        success = e_cal_client_get_object_list_sync (
                client, sexp, &list, cancellable, error);
 
@@ -4488,32 +4355,21 @@ e_cal_client_get_object_list_as_comps_sync (ECalClient *client,
                return FALSE;
        }
 
-       /* Convert the icalcomponent list to an ECalComponent list. */
+       /* Convert the ICalComponent list to an ECalComponent list. */
        for (link = list; link != NULL; link = g_slist_next (link)) {
                ECalComponent *comp;
-               icalcomponent *icalcomp = link->data;
-
-               comp = e_cal_component_new ();
+               ICalComponent *icalcomp = link->data;
 
-               /* This takes ownership of the icalcomponent, if it works. */
-               if (e_cal_component_set_icalcomponent (comp, icalcomp)) {
-                       link->data = g_object_ref (comp);
-               } else {
-                       /* On failure, free resources and add
-                        * the GSList link to the trash queue. */
-                       icalcomponent_free (icalcomp);
-                       g_queue_push_tail (&trash, link);
-                       link->data = NULL;
-               }
+               /* This takes ownership of the ICalComponent. */
+               comp = e_cal_component_new_from_icalcomponent (icalcomp);
+               if (comp)
+                       *out_ecalcomps = g_slist_prepend (*out_ecalcomps, comp);
 
-               g_object_unref (comp);
        }
 
-       /* Delete GSList links we failed to convert. */
-       while ((link = g_queue_pop_head (&trash)) != NULL)
-               list = g_slist_delete_link (list, link);
+       g_slist_free (list);
 
-       *out_ecalcomps = list;
+       *out_ecalcomps = g_slist_reverse (*out_ecalcomps);
 
        return TRUE;
 }
@@ -4715,10 +4571,8 @@ e_cal_client_get_free_busy_sync (ECalClient *client,
                        ECalComponent *comp;
 
                        comp = e_cal_component_new_from_string (freebusy_strv[ii]);
-                       if (!comp)
-                               continue;
-
-                       *out_freebusy = g_slist_prepend (*out_freebusy, comp);
+                       if (comp)
+                               *out_freebusy = g_slist_prepend (*out_freebusy, comp);
                }
 
                *out_freebusy = g_slist_reverse (*out_freebusy);
@@ -4775,7 +4629,7 @@ cal_client_create_object_thread (GSimpleAsyncResult *simple,
  **/
 void
 e_cal_client_create_object (ECalClient *client,
-                            icalcomponent *icalcomp,
+                            ICalComponent *icalcomp,
                             GCancellable *cancellable,
                             GAsyncReadyCallback callback,
                             gpointer user_data)
@@ -4787,7 +4641,7 @@ e_cal_client_create_object (ECalClient *client,
        g_return_if_fail (icalcomp != NULL);
 
        async_context = g_slice_new0 (AsyncContext);
-       async_context->in_comp = icalcomponent_new_clone (icalcomp);
+       async_context->in_comp = i_cal_component_new_clone (icalcomp);
 
        simple = g_simple_async_result_new (
                G_OBJECT (client), callback, user_data,
@@ -4807,7 +4661,7 @@ e_cal_client_create_object (ECalClient *client,
  * e_cal_client_create_object_finish:
  * @client: an #ECalClient
  * @result: a #GAsyncResult
- * @out_uid: (out): Return value for the UID assigned to the new component
+ * @out_uid: (out) (nullable): Return value for the UID assigned to the new component
  *           by the calendar backend
  * @error: (out): a #GError to set an error, if any
  *
@@ -4853,7 +4707,7 @@ e_cal_client_create_object_finish (ECalClient *client,
  * e_cal_client_create_object_sync:
  * @client: an #ECalClient
  * @icalcomp: The component to create
- * @out_uid: (out): Return value for the UID assigned to the new component
+ * @out_uid: (out) (nullable): Return value for the UID assigned to the new component
  *           by the calendar backend
  * @cancellable: a #GCancellable; can be %NULL
  * @error: (out): a #GError to set an error, if any
@@ -4870,7 +4724,7 @@ e_cal_client_create_object_finish (ECalClient *client,
  **/
 gboolean
 e_cal_client_create_object_sync (ECalClient *client,
-                                 icalcomponent *icalcomp,
+                                 ICalComponent *icalcomp,
                                  gchar **out_uid,
                                  GCancellable *cancellable,
                                  GError **error)
@@ -4892,6 +4746,8 @@ e_cal_client_create_object_sync (ECalClient *client,
 
        if (out_uid != NULL && string_list != NULL)
                *out_uid = g_strdup (string_list->data);
+       else if (out_uid)
+               *out_uid = NULL;
 
        g_slist_free_full (string_list, (GDestroyNotify) g_free);
 
@@ -4929,7 +4785,7 @@ cal_client_create_objects_thread (GSimpleAsyncResult *simple,
 /**
  * e_cal_client_create_objects:
  * @client: an #ECalClient
- * @icalcomps: (element-type icalcomponent): The components to create
+ * @icalcomps: (element-type ICalComponent): The components to create
  * @cancellable: (allow-none): a #GCancellable; can be %NULL
  * @callback: callback to call when a result is ready
  * @user_data: user data for the @callback
@@ -4957,7 +4813,7 @@ e_cal_client_create_objects (ECalClient *client,
 
        async_context = g_slice_new0 (AsyncContext);
        async_context->comp_list = g_slist_copy_deep (
-               icalcomps, (GCopyFunc) icalcomponent_new_clone, NULL);
+               icalcomps, (GCopyFunc) i_cal_component_new_clone, NULL);
 
        simple = g_simple_async_result_new (
                G_OBJECT (client), callback, user_data,
@@ -4979,7 +4835,7 @@ e_cal_client_create_objects (ECalClient *client,
  * e_cal_client_create_objects_finish:
  * @client: an #ECalClient
  * @result: a #GAsyncResult
- * @out_uids: (out) (element-type utf8): Return value for the UIDs assigned
+ * @out_uids: (out) (nullable) (element-type utf8): Return value for the UIDs assigned
  *            to the new components by the calendar backend
  * @error: (out): a #GError to set an error, if any
  *
@@ -5022,8 +4878,8 @@ e_cal_client_create_objects_finish (ECalClient *client,
 /**
  * e_cal_client_create_objects_sync:
  * @client: an #ECalClient
- * @icalcomps: (element-type icalcomponent): The components to create
- * @out_uids: (out) (element-type utf8): Return value for the UIDs assigned
+ * @icalcomps: (element-type ICalComponent): The components to create
+ * @out_uids: (out) (nullable) (element-type utf8): Return value for the UIDs assigned
  *            to the new components by the calendar backend
  * @cancellable: (allow-none): a #GCancellable; can be %NULL
  * @error: (out): a #GError to set an error, if any
@@ -5059,7 +4915,7 @@ e_cal_client_create_objects_sync (ECalClient *client,
        while (icalcomps != NULL) {
                gchar *ical_string;
 
-               ical_string = icalcomponent_as_ical_string_r (icalcomps->data);
+               ical_string = i_cal_component_as_ical_string_r (icalcomps->data);
                strv[ii++] = e_util_utf8_make_valid (ical_string);
                g_free (ical_string);
 
@@ -5078,7 +4934,7 @@ e_cal_client_create_objects_sync (ECalClient *client,
                ((uids != NULL) && (local_error == NULL)) ||
                ((uids == NULL) && (local_error != NULL)), FALSE);
 
-       if (uids != NULL) {
+       if (uids && out_uids) {
                GSList *tmp = NULL;
 
                /* Steal the string array elements. */
@@ -5088,6 +4944,8 @@ e_cal_client_create_objects_sync (ECalClient *client,
                }
 
                *out_uids = g_slist_reverse (tmp);
+       } else if (out_uids) {
+               *out_uids = NULL;
        }
 
        g_strfreev (uids);
@@ -5153,7 +5011,7 @@ cal_client_modify_object_thread (GSimpleAsyncResult *simple,
  **/
 void
 e_cal_client_modify_object (ECalClient *client,
-                            icalcomponent *icalcomp,
+                            ICalComponent *icalcomp,
                             ECalObjModType mod,
                             GCancellable *cancellable,
                             GAsyncReadyCallback callback,
@@ -5166,7 +5024,7 @@ e_cal_client_modify_object (ECalClient *client,
        g_return_if_fail (icalcomp != NULL);
 
        async_context = g_slice_new0 (AsyncContext);
-       async_context->in_comp = icalcomponent_new_clone (icalcomp);
+       async_context->in_comp = i_cal_component_new_clone (icalcomp);
        async_context->mod = mod;
 
        simple = g_simple_async_result_new (
@@ -5237,7 +5095,7 @@ e_cal_client_modify_object_finish (ECalClient *client,
  **/
 gboolean
 e_cal_client_modify_object_sync (ECalClient *client,
-                                 icalcomponent *icalcomp,
+                                 ICalComponent *icalcomp,
                                  ECalObjModType mod,
                                  GCancellable *cancellable,
                                  GError **error)
@@ -5282,7 +5140,7 @@ cal_client_modify_objects_thread (GSimpleAsyncResult *simple,
 /**
  * e_cal_client_modify_objects:
  * @client: an #ECalClient
- * @comps: (element-type icalcomponent): Components to modify
+ * @icalcomps: (element-type ICalComponent): Components to modify
  * @mod: Type of modification
  * @cancellable: (allow-none): a #GCancellable; can be %NULL
  * @callback: callback to call when a result is ready
@@ -5303,7 +5161,7 @@ cal_client_modify_objects_thread (GSimpleAsyncResult *simple,
  **/
 void
 e_cal_client_modify_objects (ECalClient *client,
-                             GSList *comps,
+                             GSList *icalcomps,
                              ECalObjModType mod,
                              GCancellable *cancellable,
                              GAsyncReadyCallback callback,
@@ -5313,11 +5171,11 @@ e_cal_client_modify_objects (ECalClient *client,
        AsyncContext *async_context;
 
        g_return_if_fail (E_IS_CAL_CLIENT (client));
-       g_return_if_fail (comps != NULL);
+       g_return_if_fail (icalcomps != NULL);
 
        async_context = g_slice_new0 (AsyncContext);
        async_context->comp_list = g_slist_copy_deep (
-               comps, (GCopyFunc) icalcomponent_new_clone, NULL);
+               icalcomps, (GCopyFunc) i_cal_component_new_clone, NULL);
        async_context->mod = mod;
 
        simple = g_simple_async_result_new (
@@ -5369,7 +5227,7 @@ e_cal_client_modify_objects_finish (ECalClient *client,
 /**
  * e_cal_client_modify_objects_sync:
  * @client: an #ECalClient
- * @comps: (element-type icalcomponent): Components to modify
+ * @icalcomps: (element-type ICalComponent): Components to modify
  * @mod: Type of modification
  * @cancellable: (allow-none): a #GCancellable; can be %NULL
  * @error: (out): a #GError to set an error, if any
@@ -5388,7 +5246,7 @@ e_cal_client_modify_objects_finish (ECalClient *client,
  **/
 gboolean
 e_cal_client_modify_objects_sync (ECalClient *client,
-                                  GSList *comps,
+                                  GSList *icalcomps,
                                   ECalObjModType mod,
                                   GCancellable *cancellable,
                                   GError **error)
@@ -5401,7 +5259,7 @@ e_cal_client_modify_objects_sync (ECalClient *client,
        GError *local_error = NULL;
 
        g_return_val_if_fail (E_IS_CAL_CLIENT (client), FALSE);
-       g_return_val_if_fail (comps != NULL, FALSE);
+       g_return_val_if_fail (icalcomps != NULL, FALSE);
 
        flags = g_string_new (NULL);
        flags_class = g_type_class_ref (E_TYPE_CAL_OBJ_MOD_TYPE);
@@ -5414,15 +5272,15 @@ e_cal_client_modify_objects_sync (ECalClient *client,
                flags_value = g_flags_get_first_value (flags_class, mod);
        }
 
-       strv = g_new0 (gchar *, g_slist_length (comps) + 1);
-       while (comps != NULL) {
+       strv = g_new0 (gchar *, g_slist_length (icalcomps) + 1);
+       while (icalcomps != NULL) {
                gchar *ical_string;
 
-               ical_string = icalcomponent_as_ical_string_r (comps->data);
+               ical_string = i_cal_component_as_ical_string_r (icalcomps->data);
                strv[ii++] = e_util_utf8_make_valid (ical_string);
                g_free (ical_string);
 
-               comps = g_slist_next (comps);
+               icalcomps = g_slist_next (icalcomps);
        }
 
        e_dbus_calendar_call_modify_objects_sync (
@@ -5588,14 +5446,21 @@ e_cal_client_remove_object_sync (ECalClient *client,
                                  GCancellable *cancellable,
                                  GError **error)
 {
-       ECalComponentId id = { (gchar *) uid, (gchar *) rid };
-       GSList link = { &id, NULL };
+       ECalComponentId *id;
+       GSList *link;
+       gboolean success;
 
        g_return_val_if_fail (E_IS_CAL_CLIENT (client), FALSE);
        g_return_val_if_fail (uid != NULL, FALSE);
 
-       return e_cal_client_remove_objects_sync (
-               client, &link, mod, cancellable, error);
+       id = e_cal_component_id_new (uid, rid);
+       link = g_slist_prepend (NULL, id);
+
+       success = e_cal_client_remove_objects_sync (client, link, mod, cancellable, error);
+
+       g_slist_free_full (link, e_cal_component_id_free);
+
+       return success;
 }
 
 /* Helper for e_cal_client_remove_objects() */
@@ -5611,7 +5476,7 @@ cal_client_remove_objects_thread (GSimpleAsyncResult *simple,
 
        if (!e_cal_client_remove_objects_sync (
                E_CAL_CLIENT (source_object),
-               async_context->string_list,
+               async_context->ids_list,
                async_context->mod,
                cancellable, &local_error)) {
 
@@ -5661,8 +5526,8 @@ e_cal_client_remove_objects (ECalClient *client,
        g_return_if_fail (ids != NULL);
 
        async_context = g_slice_new0 (AsyncContext);
-       async_context->string_list = g_slist_copy_deep (
-               (GSList *) ids, (GCopyFunc) g_strdup, NULL);
+       async_context->ids_list = g_slist_copy_deep (
+               (GSList *) ids, (GCopyFunc) e_cal_component_id_copy, NULL);
        async_context->mod = mod;
 
        simple = g_simple_async_result_new (
@@ -5760,18 +5625,22 @@ e_cal_client_remove_objects_sync (ECalClient *client,
        g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ss)"));
        while (ids != NULL) {
                ECalComponentId *id = ids->data;
+               const gchar *uid, *rid;
                gchar *utf8_uid;
                gchar *utf8_rid;
 
                ids = g_slist_next (ids);
 
-               if (id->uid == NULL)
+               uid = e_cal_component_id_get_uid (id);
+               rid = e_cal_component_id_get_rid (id);
+
+               if (!uid)
                        continue;
 
                /* Reject empty UIDs with an OBJECT_NOT_FOUND error for
                 * backward-compatibility, even though INVALID_ARG might
                 * be more appropriate. */
-               if (*id->uid == '\0') {
+               if (!*uid) {
                        local_error = g_error_new_literal (
                                E_CAL_CLIENT_ERROR,
                                E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND,
@@ -5781,9 +5650,9 @@ e_cal_client_remove_objects_sync (ECalClient *client,
                        break;
                }
 
-               utf8_uid = e_util_utf8_make_valid (id->uid);
-               if (id->rid != NULL)
-                       utf8_rid = e_util_utf8_make_valid (id->rid);
+               utf8_uid = e_util_utf8_make_valid (uid);
+               if (rid)
+                       utf8_rid = e_util_utf8_make_valid (rid);
                else
                        utf8_rid = g_strdup ("");
 
@@ -5846,7 +5715,7 @@ cal_client_receive_objects_thread (GSimpleAsyncResult *simple,
 /**
  * e_cal_client_receive_objects:
  * @client: an #ECalClient
- * @icalcomp: An #icalcomponent
+ * @icalcomp: An #ICalComponent
  * @cancellable: a #GCancellable; can be %NULL
  * @callback: callback to call when a result is ready
  * @user_data: user data for the @callback
@@ -5862,7 +5731,7 @@ cal_client_receive_objects_thread (GSimpleAsyncResult *simple,
  **/
 void
 e_cal_client_receive_objects (ECalClient *client,
-                              icalcomponent *icalcomp,
+                              ICalComponent *icalcomp,
                               GCancellable *cancellable,
                               GAsyncReadyCallback callback,
                               gpointer user_data)
@@ -5874,7 +5743,7 @@ e_cal_client_receive_objects (ECalClient *client,
        g_return_if_fail (icalcomp != NULL);
 
        async_context = g_slice_new0 (AsyncContext);
-       async_context->in_comp = icalcomponent_new_clone (icalcomp);
+       async_context->in_comp = i_cal_component_new_clone (icalcomp);
 
        simple = g_simple_async_result_new (
                G_OBJECT (client), callback, user_data,
@@ -5925,7 +5794,7 @@ e_cal_client_receive_objects_finish (ECalClient *client,
 /**
  * e_cal_client_receive_objects_sync:
  * @client: an #ECalClient
- * @icalcomp: An #icalcomponent
+ * @icalcomp: An #ICalComponent
  * @cancellable: a #GCancellable; can be %NULL
  * @error: (out): a #GError to set an error, if any
  *
@@ -5939,7 +5808,7 @@ e_cal_client_receive_objects_finish (ECalClient *client,
  **/
 gboolean
 e_cal_client_receive_objects_sync (ECalClient *client,
-                                   icalcomponent *icalcomp,
+                                   ICalComponent *icalcomp,
                                    GCancellable *cancellable,
                                    GError **error)
 {
@@ -5949,7 +5818,7 @@ e_cal_client_receive_objects_sync (ECalClient *client,
 
        g_return_val_if_fail (E_IS_CAL_CLIENT (client), FALSE);
 
-       ical_string = icalcomponent_as_ical_string_r (icalcomp);
+       ical_string = i_cal_component_as_ical_string_r (icalcomp);
        utf8_ical_string = e_util_utf8_make_valid (ical_string);
 
        e_dbus_calendar_call_receive_objects_sync (
@@ -6000,7 +5869,7 @@ cal_client_send_objects_thread (GSimpleAsyncResult *simple,
 /**
  * e_cal_client_send_objects:
  * @client: an #ECalClient
- * @icalcomp: An icalcomponent to be sent
+ * @icalcomp: An #ICalComponent to be sent
  * @cancellable: a #GCancellable; can be %NULL
  * @callback: callback to call when a result is ready
  * @user_data: user data for the @callback
@@ -6014,7 +5883,7 @@ cal_client_send_objects_thread (GSimpleAsyncResult *simple,
  **/
 void
 e_cal_client_send_objects (ECalClient *client,
-                           icalcomponent *icalcomp,
+                           ICalComponent *icalcomp,
                            GCancellable *cancellable,
                            GAsyncReadyCallback callback,
                            gpointer user_data)
@@ -6026,7 +5895,7 @@ e_cal_client_send_objects (ECalClient *client,
        g_return_if_fail (icalcomp != NULL);
 
        async_context = g_slice_new0 (AsyncContext);
-       async_context->in_comp = icalcomponent_new_clone (icalcomp);
+       async_context->in_comp = i_cal_component_new_clone (icalcomp);
 
        simple = g_simple_async_result_new (
                G_OBJECT (client), callback, user_data,
@@ -6048,16 +5917,16 @@ e_cal_client_send_objects (ECalClient *client,
  * e_cal_client_send_objects_finish:
  * @client: an #ECalClient
  * @result: a #GAsyncResult
- * @out_users: (out) (element-type utf8): List of users to send
+ * @out_users: (out) (transfer full) (element-type utf8): List of users to send
  *             the @out_modified_icalcomp to
- * @out_modified_icalcomp: (out): Return value for the icalcomponent to be sent
+ * @out_modified_icalcomp: (out) (transfer full): Return value for the #ICalComponent to be sent
  * @error: (out): a #GError to set an error, if any
  *
  * Finishes previous call of e_cal_client_send_objects() and
  * populates @out_users with a list of users to send @out_modified_icalcomp to.
  *
  * The @out_users list should be freed with e_client_util_free_string_slist()
- * and the @out_modified_icalcomp should be freed with icalcomponent_free().
+ * and the @out_modified_icalcomp should be freed with g_object_unref().
  *
  * Returns: %TRUE if successful, %FALSE otherwise.
  *
@@ -6067,7 +5936,7 @@ gboolean
 e_cal_client_send_objects_finish (ECalClient *client,
                                   GAsyncResult *result,
                                   GSList **out_users,
-                                  icalcomponent **out_modified_icalcomp,
+                                  ICalComponent **out_modified_icalcomp,
                                   GError **error)
 {
        GSimpleAsyncResult *simple;
@@ -6102,10 +5971,10 @@ e_cal_client_send_objects_finish (ECalClient *client,
 /**
  * e_cal_client_send_objects_sync:
  * @client: an #ECalClient
- * @icalcomp: An icalcomponent to be sent
- * @out_users: (out) (element-type utf8): List of users to send the
+ * @icalcomp: An #ICalComponent to be sent
+ * @out_users: (out) (transfer full) (element-type utf8): List of users to send the
  *             @out_modified_icalcomp to
- * @out_modified_icalcomp: (out): Return value for the icalcomponent to be sent
+ * @out_modified_icalcomp: (out) (transfer full): Return value for the #ICalComponent to be sent
  * @cancellable: (allow-none): a #GCancellable; can be %NULL
  * @error: (out): a #GError to set an error, if any
  *
@@ -6114,7 +5983,7 @@ e_cal_client_send_objects_finish (ECalClient *client,
  * @out_users list.
  *
  * The @out_users list should be freed with e_client_util_free_string_slist()
- * and the @out_modified_icalcomp should be freed with icalcomponent_free().
+ * and the @out_modified_icalcomp should be freed with g_object_unref().
  *
  * Returns: %TRUE if successful, %FALSE otherwise.
  *
@@ -6122,9 +5991,9 @@ e_cal_client_send_objects_finish (ECalClient *client,
  **/
 gboolean
 e_cal_client_send_objects_sync (ECalClient *client,
-                                icalcomponent *icalcomp,
+                                ICalComponent *icalcomp,
                                 GSList **out_users,
-                                icalcomponent **out_modified_icalcomp,
+                                ICalComponent **out_modified_icalcomp,
                                 GCancellable *cancellable,
                                 GError **error)
 {
@@ -6139,7 +6008,7 @@ e_cal_client_send_objects_sync (ECalClient *client,
        g_return_val_if_fail (out_users != NULL, FALSE);
        g_return_val_if_fail (out_modified_icalcomp != NULL, FALSE);
 
-       ical_string = icalcomponent_as_ical_string_r (icalcomp);
+       ical_string = i_cal_component_as_ical_string_r (icalcomp);
        utf8_ical_string = e_util_utf8_make_valid (ical_string);
 
        e_dbus_calendar_call_send_objects_sync (
@@ -6161,7 +6030,7 @@ e_cal_client_send_objects_sync (ECalClient *client,
                return FALSE;
        }
 
-       icalcomp = icalparser_parse_string (out_ical_string);
+       icalcomp = i_cal_parser_parse_string (out_ical_string);
 
        g_free (out_ical_string);
 
@@ -6424,12 +6293,12 @@ cal_client_discard_alarm_thread (GSimpleAsyncResult *simple,
  * @client: an #ECalClient
  * @uid: Unique identifier for a calendar component
  * @rid: Recurrence identifier
- * @auid: Alarm identifier to remove
+ * @auid: Alarm identifier to discard
  * @cancellable: a #GCancellable; can be %NULL
  * @callback: callback to call when a result is ready
  * @user_data: user data for the @callback
  *
- * Removes alarm @auid from a given component identified by @uid and @rid.
+ * Discards alarm @auid from a given component identified by @uid and @rid.
  * The call is finished by e_cal_client_discard_alarm_finish() from
  * the @callback.
  *
@@ -6454,7 +6323,7 @@ e_cal_client_discard_alarm (ECalClient *client,
 
        async_context = g_slice_new0 (AsyncContext);
        async_context->uid = g_strdup (uid);
-       async_context->rid = NULL;
+       async_context->rid = g_strdup (rid);
        async_context->auid = g_strdup (auid);
 
        simple = g_simple_async_result_new (
@@ -6508,11 +6377,11 @@ e_cal_client_discard_alarm_finish (ECalClient *client,
  * @client: an #ECalClient
  * @uid: Unique identifier for a calendar component
  * @rid: Recurrence identifier
- * @auid: Alarm identifier to remove
+ * @auid: Alarm identifier to discard
  * @cancellable: a #GCancellable; can be %NULL
  * @error: (out): a #GError to set an error, if any
  *
- * Removes alarm @auid from a given component identified by @uid and @rid.
+ * Discards alarm @auid from a given component identified by @uid and @rid.
  *
  * Returns: %TRUE if successful, %FALSE otherwise.
  *
@@ -6832,7 +6701,7 @@ e_cal_client_get_timezone (ECalClient *client,
  * e_cal_client_get_timezone_finish:
  * @client: an #ECalClient
  * @result: a #GAsyncResult
- * @out_zone: (out): Return value for the timezone
+ * @out_zone: (out) (transfer none): Return value for the timezone
  * @error: (out): a #GError to set an error, if any
  *
  * Finishes previous call of e_cal_client_get_timezone() and
@@ -6846,7 +6715,7 @@ e_cal_client_get_timezone (ECalClient *client,
 gboolean
 e_cal_client_get_timezone_finish (ECalClient *client,
                                   GAsyncResult *result,
-                                  icaltimezone **out_zone,
+                                  ICalTimezone **out_zone,
                                   GError **error)
 {
        GSimpleAsyncResult *simple;
@@ -6877,7 +6746,7 @@ e_cal_client_get_timezone_finish (ECalClient *client,
  * e_cal_client_get_timezone_sync:
  * @client: an #ECalClient
  * @tzid: ID of the timezone to retrieve
- * @out_zone: (out): Return value for the timezone
+ * @out_zone: (out) (transfer none): Return value for the timezone
  * @cancellable: a #GCancellable; can be %NULL
  * @error: (out): a #GError to set an error, if any
  *
@@ -6891,12 +6760,12 @@ e_cal_client_get_timezone_finish (ECalClient *client,
 gboolean
 e_cal_client_get_timezone_sync (ECalClient *client,
                                 const gchar *tzid,
-                                icaltimezone **out_zone,
+                                ICalTimezone **out_zone,
                                 GCancellable *cancellable,
                                 GError **error)
 {
-       icalcomponent *icalcomp;
-       icaltimezone *zone;
+       ICalComponent *icalcomp;
+       ICalTimezone *zone;
        gchar *utf8_tzid;
        gchar *string = NULL;
        GError *local_error = NULL;
@@ -6931,7 +6800,7 @@ e_cal_client_get_timezone_sync (ECalClient *client,
                return FALSE;
        }
 
-       icalcomp = icalparser_parse_string (string);
+       icalcomp = i_cal_parser_parse_string (string);
 
        g_free (string);
 
@@ -6944,15 +6813,15 @@ e_cal_client_get_timezone_sync (ECalClient *client,
                return FALSE;
        }
 
-       zone = icaltimezone_new ();
-       if (!icaltimezone_set_component (zone, icalcomp)) {
+       zone = i_cal_timezone_new ();
+       if (!i_cal_timezone_set_component (zone, icalcomp)) {
                g_set_error_literal (
                        error, E_CAL_CLIENT_ERROR,
                        E_CAL_CLIENT_ERROR_INVALID_OBJECT,
                        e_cal_client_error_to_string (
                        E_CAL_CLIENT_ERROR_INVALID_OBJECT));
-               icalcomponent_free (icalcomp);
-               icaltimezone_free (zone, 1);
+               g_object_unref (icalcomp);
+               g_object_unref (zone);
                return FALSE;
        }
 
@@ -6964,7 +6833,7 @@ e_cal_client_get_timezone_sync (ECalClient *client,
                /* It can be that another thread already filled the zone into the cache,
                   thus deal with it properly, because that other zone can be used by that
                   other thread. */
-               icaltimezone_free (zone, 1);
+               g_object_unref (zone);
                zone = g_hash_table_lookup (client->priv->zone_cache, tzid);
        } else {
                g_hash_table_insert (
@@ -6972,6 +6841,8 @@ e_cal_client_get_timezone_sync (ECalClient *client,
        }
        g_mutex_unlock (&client->priv->zone_cache_lock);
 
+       g_object_unref (icalcomp);
+
        *out_zone = zone;
 
        return TRUE;
@@ -7020,26 +6891,28 @@ cal_client_add_timezone_thread (GSimpleAsyncResult *simple,
  **/
 void
 e_cal_client_add_timezone (ECalClient *client,
-                           icaltimezone *zone,
+                           ICalTimezone *zone,
                            GCancellable *cancellable,
                            GAsyncReadyCallback callback,
                            gpointer user_data)
 {
        GSimpleAsyncResult *simple;
        AsyncContext *async_context;
-       icalcomponent *icalcomp;
+       ICalComponent *icalcomp, *clone;
 
        g_return_if_fail (E_IS_CAL_CLIENT (client));
        g_return_if_fail (zone != NULL);
 
-       icalcomp = icaltimezone_get_component (zone);
+       icalcomp = i_cal_timezone_get_component (zone);
        g_return_if_fail (icalcomp != NULL);
 
        async_context = g_slice_new0 (AsyncContext);
-       async_context->zone = icaltimezone_new ();
+       async_context->zone = i_cal_timezone_new ();
 
-       icalcomp = icalcomponent_new_clone (icalcomp);
-       icaltimezone_set_component (async_context->zone, icalcomp);
+       clone = i_cal_component_new_clone (icalcomp);
+       i_cal_timezone_set_component (async_context->zone, clone);
+       g_object_unref (icalcomp);
+       g_object_unref (clone);
 
        simple = g_simple_async_result_new (
                G_OBJECT (client), callback, user_data,
@@ -7050,7 +6923,7 @@ e_cal_client_add_timezone (ECalClient *client,
        g_simple_async_result_set_op_res_gpointer (
                simple, async_context, (GDestroyNotify) async_context_free);
 
-       if (zone == icaltimezone_get_utc_timezone ())
+       if (zone == i_cal_timezone_get_utc_timezone ())
                g_simple_async_result_complete_in_idle (simple);
        else
                g_simple_async_result_run_in_thread (
@@ -7105,11 +6978,11 @@ e_cal_client_add_timezone_finish (ECalClient *client,
  **/
 gboolean
 e_cal_client_add_timezone_sync (ECalClient *client,
-                                icaltimezone *zone,
+                                ICalTimezone *zone,
                                 GCancellable *cancellable,
                                 GError **error)
 {
-       icalcomponent *icalcomp;
+       ICalComponent *icalcomp;
        gchar *zone_str;
        gchar *utf8_zone_str;
        GError *local_error = NULL;
@@ -7117,10 +6990,10 @@ e_cal_client_add_timezone_sync (ECalClient *client,
        g_return_val_if_fail (E_IS_CAL_CLIENT (client), FALSE);
        g_return_val_if_fail (zone != NULL, FALSE);
 
-       if (zone == icaltimezone_get_utc_timezone ())
+       if (zone == i_cal_timezone_get_utc_timezone ())
                return TRUE;
 
-       icalcomp = icaltimezone_get_component (zone);
+       icalcomp = i_cal_timezone_get_component (zone);
        if (icalcomp == NULL) {
                g_propagate_error (
                        error, e_client_error_create (
@@ -7128,7 +7001,7 @@ e_cal_client_add_timezone_sync (ECalClient *client,
                return FALSE;
        }
 
-       zone_str = icalcomponent_as_ical_string_r (icalcomp);
+       zone_str = i_cal_component_as_ical_string_r (icalcomp);
        utf8_zone_str = e_util_utf8_make_valid (zone_str);
 
        e_dbus_calendar_call_add_timezone_sync (
@@ -7137,6 +7010,7 @@ e_cal_client_add_timezone_sync (ECalClient *client,
 
        g_free (zone_str);
        g_free (utf8_zone_str);
+       g_object_unref (icalcomp);
 
        if (local_error != NULL) {
                g_dbus_error_strip_remote_error (local_error);
diff --git a/src/calendar/libecal/e-cal-client.h b/src/calendar/libecal/e-cal-client.h
index 0913ddd4d..ca7678922 100644
--- a/src/calendar/libecal/e-cal-client.h
+++ b/src/calendar/libecal/e-cal-client.h
@@ -27,8 +27,8 @@
 #include <libedataserver/libedataserver.h>
 
 #include <libecal/e-cal-client-view.h>
-#include <libecal/e-cal-recur.h>
 #include <libecal/e-cal-enums.h>
+#include <libecal/e-cal-recur.h>
 #include <libecal/e-cal-util.h>
 
 /* Standard GObject macros */
@@ -153,7 +153,7 @@ struct _ECalClientClass {
        /*< public >*/
        /* Signals */
        void            (*free_busy_data)       (ECalClient *client,
-                                                const GSList *free_busy_ecalcomps);
+                                                const GSList *free_busy_ecalcomps); /* ECalComponent * */
 };
 
 GQuark         e_cal_client_error_quark        (void) G_GNUC_CONST;
@@ -179,8 +179,8 @@ const gchar *       e_cal_client_get_local_attachment_store
                                                (ECalClient *client);
 void           e_cal_client_set_default_timezone
                                                (ECalClient *client,
-                                                icaltimezone *zone);
-icaltimezone * e_cal_client_get_default_timezone
+                                                ICalTimezone *zone);
+ICalTimezone * e_cal_client_get_default_timezone
                                                (ECalClient *client);
 gboolean       e_cal_client_check_one_alarm_only
                                                (ECalClient *client);
@@ -192,49 +192,39 @@ gboolean  e_cal_client_check_organizer_must_accept
                                                (ECalClient *client);
 gboolean       e_cal_client_check_recurrences_no_master
                                                (ECalClient *client);
-void           e_cal_client_free_icalcomp_slist
-                                               (GSList *icalcomps);
-void           e_cal_client_free_ecalcomp_slist
-                                               (GSList *ecalcomps);
 
-icaltimezone * e_cal_client_resolve_tzid_cb    (const gchar *tzid,
-                                                gpointer data);
-icaltimezone * e_cal_client_resolve_tzid_sync  (const gchar *tzid,
-                                                gpointer cal_client,
-                                                GCancellable *cancellable,
-                                                GError **error);
 void           e_cal_client_generate_instances (ECalClient *client,
                                                 time_t start,
                                                 time_t end,
                                                 GCancellable *cancellable,
-                                                ECalRecurInstanceFn cb,
+                                                ECalRecurInstanceCb cb,
                                                 gpointer cb_data,
                                                 GDestroyNotify destroy_cb_data);
 void           e_cal_client_generate_instances_sync
                                                (ECalClient *client,
                                                 time_t start,
                                                 time_t end,
-                                                ECalRecurInstanceFn cb,
+                                                ECalRecurInstanceCb cb,
                                                 gpointer cb_data);
 void           e_cal_client_generate_instances_for_object
                                                (ECalClient *client,
-                                                icalcomponent *icalcomp,
+                                                ICalComponent *icalcomp,
                                                 time_t start,
                                                 time_t end,
                                                 GCancellable *cancellable,
-                                                ECalRecurInstanceFn cb,
+                                                ECalRecurInstanceCb cb,
                                                 gpointer cb_data,
                                                 GDestroyNotify destroy_cb_data);
 void           e_cal_client_generate_instances_for_object_sync
                                                (ECalClient *client,
-                                                icalcomponent *icalcomp,
+                                                ICalComponent *icalcomp,
                                                 time_t start,
                                                 time_t end,
-                                                ECalRecurInstanceFn cb,
+                                                ECalRecurInstanceCb cb,
                                                 gpointer cb_data);
 gchar *                e_cal_client_get_component_as_string
                                                (ECalClient *client,
-                                                icalcomponent *icalcomp);
+                                                ICalComponent *icalcomp);
 void           e_cal_client_get_default_object (ECalClient *client,
                                                 GCancellable *cancellable,
                                                 GAsyncReadyCallback callback,
@@ -242,11 +232,11 @@ void              e_cal_client_get_default_object (ECalClient *client,
 gboolean       e_cal_client_get_default_object_finish
                                                (ECalClient *client,
                                                 GAsyncResult *result,
-                                                icalcomponent **out_icalcomp,
+                                                ICalComponent **out_icalcomp,
                                                 GError **error);
 gboolean       e_cal_client_get_default_object_sync
                                                (ECalClient *client,
-                                                icalcomponent **out_icalcomp,
+                                                ICalComponent **out_icalcomp,
                                                 GCancellable *cancellable,
                                                 GError **error);
 void           e_cal_client_get_object         (ECalClient *client,
@@ -257,12 +247,12 @@ void              e_cal_client_get_object         (ECalClient *client,
                                                 gpointer user_data);
 gboolean       e_cal_client_get_object_finish  (ECalClient *client,
                                                 GAsyncResult *result,
-                                                icalcomponent **out_icalcomp,
+                                                ICalComponent **out_icalcomp,
                                                 GError **error);
 gboolean       e_cal_client_get_object_sync    (ECalClient *client,
                                                 const gchar *uid,
                                                 const gchar *rid,
-                                                icalcomponent **out_icalcomp,
+                                                ICalComponent **out_icalcomp,
                                                 GCancellable *cancellable,
                                                 GError **error);
 void           e_cal_client_get_objects_for_uid
@@ -274,12 +264,12 @@ void              e_cal_client_get_objects_for_uid
 gboolean       e_cal_client_get_objects_for_uid_finish
                                                (ECalClient *client,
                                                 GAsyncResult *result,
-                                                GSList **out_ecalcomps,
+                                                GSList **out_ecalcomps, /* ECalComponent * */
                                                 GError **error);
 gboolean       e_cal_client_get_objects_for_uid_sync
                                                (ECalClient *client,
                                                 const gchar *uid,
-                                                GSList **out_ecalcomps,
+                                                GSList **out_ecalcomps, /* ECalComponent * */
                                                 GCancellable *cancellable,
                                                 GError **error);
 void           e_cal_client_get_object_list    (ECalClient *client,
@@ -290,12 +280,12 @@ void              e_cal_client_get_object_list    (ECalClient *client,
 gboolean       e_cal_client_get_object_list_finish
                                                (ECalClient *client,
                                                 GAsyncResult *result,
-                                                GSList **out_icalcomps,
+                                                GSList **out_icalcomps, /* ICalComponent * */
                                                 GError **error);
 gboolean       e_cal_client_get_object_list_sync
                                                (ECalClient *client,
                                                 const gchar *sexp,
-                                                GSList **out_icalcomps,
+                                                GSList **out_icalcomps, /* ICalComponent * */
                                                 GCancellable *cancellable,
                                                 GError **error);
 void           e_cal_client_get_object_list_as_comps
@@ -307,35 +297,35 @@ void              e_cal_client_get_object_list_as_comps
 gboolean       e_cal_client_get_object_list_as_comps_finish
                                                (ECalClient *client,
                                                 GAsyncResult *result,
-                                                GSList **out_ecalcomps,
+                                                GSList **out_ecalcomps, /* ECalComponent * */
                                                 GError **error);
 gboolean       e_cal_client_get_object_list_as_comps_sync
                                                (ECalClient *client,
                                                 const gchar *sexp,
-                                                GSList **out_ecalcomps,
+                                                GSList **out_ecalcomps, /* ECalComponent * */
                                                 GCancellable *cancellable,
                                                 GError **error);
 void           e_cal_client_get_free_busy      (ECalClient *client,
                                                 time_t start,
                                                 time_t end,
-                                                const GSList *users,
+                                                const GSList *users, /* gchar * */
                                                 GCancellable *cancellable,
                                                 GAsyncReadyCallback callback,
                                                 gpointer user_data);
 gboolean       e_cal_client_get_free_busy_finish
                                                (ECalClient *client,
                                                 GAsyncResult *result,
-                                                GSList **out_freebusy,
+                                                GSList **out_freebusy, /* ECalComponent * */
                                                 GError **error);
 gboolean       e_cal_client_get_free_busy_sync (ECalClient *client,
                                                 time_t start,
                                                 time_t end,
-                                                const GSList *users,
-                                                GSList **out_freebusy,
+                                                const GSList *users, /* gchar * */
+                                                GSList **out_freebusy, /* ECalComponent * */
                                                 GCancellable *cancellable,
                                                 GError **error);
 void           e_cal_client_create_object      (ECalClient *client,
-                                                icalcomponent *icalcomp,
+                                                ICalComponent *icalcomp,
                                                 GCancellable *cancellable,
                                                 GAsyncReadyCallback callback,
                                                 gpointer user_data);
@@ -345,28 +335,28 @@ gboolean  e_cal_client_create_object_finish
                                                 gchar **out_uid,
                                                 GError **error);
 gboolean       e_cal_client_create_object_sync (ECalClient *client,
-                                                icalcomponent *icalcomp,
+                                                ICalComponent *icalcomp,
                                                 gchar **out_uid,
                                                 GCancellable *cancellable,
                                                 GError **error);
 void           e_cal_client_create_objects     (ECalClient *client,
-                                                GSList *icalcomps,
+                                                GSList *icalcomps, /* ICalComponent * */
                                                 GCancellable *cancellable,
                                                 GAsyncReadyCallback callback,
                                                 gpointer user_data);
 gboolean       e_cal_client_create_objects_finish
                                                (ECalClient *client,
                                                 GAsyncResult *result,
-                                                GSList **out_uids,
+                                                GSList **out_uids, /* gchar * */
                                                 GError **error);
 gboolean       e_cal_client_create_objects_sync
                                                (ECalClient *client,
-                                                GSList *icalcomps,
-                                                GSList **out_uids,
+                                                GSList *icalcomps, /* ICalComponent * */
+                                                GSList **out_uids, /* gchar * */
                                                 GCancellable *cancellable,
                                                 GError **error);
 void           e_cal_client_modify_object      (ECalClient *client,
-                                                icalcomponent *icalcomp,
+                                                ICalComponent *icalcomp,
                                                 ECalObjModType mod,
                                                 GCancellable *cancellable,
                                                 GAsyncReadyCallback callback,
@@ -376,12 +366,12 @@ gboolean  e_cal_client_modify_object_finish
                                                 GAsyncResult *result,
                                                 GError **error);
 gboolean       e_cal_client_modify_object_sync (ECalClient *client,
-                                                icalcomponent *icalcomp,
+                                                ICalComponent *icalcomp,
                                                 ECalObjModType mod,
                                                 GCancellable *cancellable,
                                                 GError **error);
 void           e_cal_client_modify_objects     (ECalClient *client,
-                                                GSList *comps,
+                                                GSList *icalcomps, /* ICalComponent * */
                                                 ECalObjModType mod,
                                                 GCancellable *cancellable,
                                                 GAsyncReadyCallback callback,
@@ -392,7 +382,7 @@ gboolean    e_cal_client_modify_objects_finish
                                                 GError **error);
 gboolean       e_cal_client_modify_objects_sync
                                                (ECalClient *client,
-                                                GSList *comps,
+                                                GSList *icalcomps, /* ICalComponent * */
                                                 ECalObjModType mod,
                                                 GCancellable *cancellable,
                                                 GError **error);
@@ -414,7 +404,7 @@ gboolean    e_cal_client_remove_object_sync (ECalClient *client,
                                                 GCancellable *cancellable,
                                                 GError **error);
 void           e_cal_client_remove_objects     (ECalClient *client,
-                                                const GSList *ids,
+                                                const GSList *ids, /* ECalComponentId * */
                                                 ECalObjModType mod,
                                                 GCancellable *cancellable,
                                                 GAsyncReadyCallback callback,
@@ -425,12 +415,12 @@ gboolean  e_cal_client_remove_objects_finish
                                                 GError **error);
 gboolean       e_cal_client_remove_objects_sync
                                                (ECalClient *client,
-                                                const GSList *ids,
+                                                const GSList *ids, /* ECalComponentId * */
                                                 ECalObjModType mod,
                                                 GCancellable *cancellable,
                                                 GError **error);
 void           e_cal_client_receive_objects    (ECalClient *client,
-                                                icalcomponent *icalcomp,
+                                                ICalComponent *icalcomp,
                                                 GCancellable *cancellable,
                                                 GAsyncReadyCallback callback,
                                                 gpointer user_data);
@@ -440,24 +430,24 @@ gboolean  e_cal_client_receive_objects_finish
                                                 GError **error);
 gboolean       e_cal_client_receive_objects_sync
                                                (ECalClient *client,
-                                                icalcomponent *icalcomp,
+                                                ICalComponent *icalcomp,
                                                 GCancellable *cancellable,
                                                 GError **error);
 void           e_cal_client_send_objects       (ECalClient *client,
-                                                icalcomponent *icalcomp,
+                                                ICalComponent *icalcomp,
                                                 GCancellable *cancellable,
                                                 GAsyncReadyCallback callback,
                                                 gpointer user_data);
 gboolean       e_cal_client_send_objects_finish
                                                (ECalClient *client,
                                                 GAsyncResult *result,
-                                                GSList **out_users,
-                                                icalcomponent **out_modified_icalcomp,
+                                                GSList **out_users, /* gchar * */
+                                                ICalComponent **out_modified_icalcomp,
                                                 GError **error);
 gboolean       e_cal_client_send_objects_sync  (ECalClient *client,
-                                                icalcomponent *icalcomp,
-                                                GSList **out_users,
-                                                icalcomponent **out_modified_icalcomp,
+                                                ICalComponent *icalcomp,
+                                                GSList **out_users, /* gchar * */
+                                                ICalComponent **out_modified_icalcomp,
                                                 GCancellable *cancellable,
                                                 GError **error);
 void           e_cal_client_get_attachment_uris
@@ -470,13 +460,13 @@ void              e_cal_client_get_attachment_uris
 gboolean       e_cal_client_get_attachment_uris_finish
                                                (ECalClient *client,
                                                 GAsyncResult *result,
-                                                GSList **out_attachment_uris,
+                                                GSList **out_attachment_uris, /* gchar * */
                                                 GError **error);
 gboolean       e_cal_client_get_attachment_uris_sync
                                                (ECalClient *client,
                                                 const gchar *uid,
                                                 const gchar *rid,
-                                                GSList **out_attachment_uris,
+                                                GSList **out_attachment_uris, /* gchar * */
                                                 GCancellable *cancellable,
                                                 GError **error);
 void           e_cal_client_discard_alarm      (ECalClient *client,
@@ -518,15 +508,15 @@ void              e_cal_client_get_timezone       (ECalClient *client,
 gboolean       e_cal_client_get_timezone_finish
                                                (ECalClient *client,
                                                 GAsyncResult *result,
-                                                icaltimezone **out_zone,
+                                                ICalTimezone **out_zone,
                                                 GError **error);
 gboolean       e_cal_client_get_timezone_sync  (ECalClient *client,
                                                 const gchar *tzid,
-                                                icaltimezone **out_zone,
+                                                ICalTimezone **out_zone,
                                                 GCancellable *cancellable,
                                                 GError **error);
 void           e_cal_client_add_timezone       (ECalClient *client,
-                                                icaltimezone *zone,
+                                                ICalTimezone *zone,
                                                 GCancellable *cancellable,
                                                 GAsyncReadyCallback callback,
                                                 gpointer user_data);
@@ -535,7 +525,7 @@ gboolean    e_cal_client_add_timezone_finish
                                                 GAsyncResult *result,
                                                 GError **error);
 gboolean       e_cal_client_add_timezone_sync  (ECalClient *client,
-                                                icaltimezone *zone,
+                                                ICalTimezone *zone,
                                                 GCancellable *cancellable,
                                                 GError **error);
 
diff --git a/src/calendar/libecal/e-cal-util.c b/src/calendar/libecal/e-cal-util.c
index 9466b0580..b6f3897ac 100644
--- a/src/calendar/libecal/e-cal-util.c
+++ b/src/calendar/libecal/e-cal-util.c
@@ -26,6 +26,7 @@
 
 #include <libedataserver/libedataserver.h>
 
+#include "e-cal-check-timezones.h"
 #include "e-cal-client.h"
 #include "e-cal-system-timezone.h"
 #include "e-cal-recur.h"
@@ -2235,7 +2236,7 @@ e_cal_util_find_next_occurrence (ICalComponent *vtodo,
 
                success = e_cal_recur_generate_instances_sync (vtodo, interval_start, interval_end,
                        ecu_find_next_occurrence_cb, &nod,
-                       e_cal_client_resolve_tzid_sync, cal_client,
+                       e_cal_client_tzlookup_cb, cal_client,
                        e_cal_client_get_default_timezone (cal_client),
                        cancellable, &local_error) || nod.found_next;
 


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