[evolution-mapi/wip/mcrha/eds-libical-glib] Port to libecal-2.0 and libedata-cal-2.0



commit 6d6c2fc5103dea2bfabd93975c259d0e67cbdc72
Author: Milan Crha <mcrha redhat com>
Date:   Thu Apr 25 15:37:13 2019 +0200

    Port to libecal-2.0 and libedata-cal-2.0

 CMakeLists.txt                               |    7 +-
 src/calendar/e-cal-backend-mapi-factory.c    |    6 +-
 src/calendar/e-cal-backend-mapi.c            |  359 +++++----
 src/libexchangemapi/e-mapi-cal-recur-utils.c |  530 +++++++------
 src/libexchangemapi/e-mapi-cal-recur-utils.h |    2 +-
 src/libexchangemapi/e-mapi-cal-tz-utils.c    |  194 ++---
 src/libexchangemapi/e-mapi-cal-tz-utils.h    |    2 +-
 src/libexchangemapi/e-mapi-cal-utils.c       | 1067 +++++++++++++++-----------
 src/libexchangemapi/e-mapi-cal-utils.h       |    9 +-
 src/libexchangemapi/e-mapi-mail-utils.c      |   78 +-
 src/libexchangemapi/e-mapi-utils.h           |    4 +-
 11 files changed, 1280 insertions(+), 978 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7488344..e695b69 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -113,9 +113,9 @@ pkg_check_modules(CAMEL REQUIRED camel-1.2>=${eds_minimum_version})
 pkg_check_modules(EVOLUTION_DATA_SERVER REQUIRED evolution-data-server-1.2>=${eds_minimum_version})
 pkg_check_modules(LIBEBACKEND REQUIRED libebackend-1.2>=${eds_minimum_version})
 pkg_check_modules(LIBEBOOK REQUIRED libebook-1.2>=${eds_minimum_version})
-pkg_check_modules(LIBECAL REQUIRED libecal-1.2>=${eds_minimum_version})
+pkg_check_modules(LIBECAL REQUIRED libecal-2.0>=${eds_minimum_version})
 pkg_check_modules(LIBEDATABOOK REQUIRED libedata-book-1.2>=${eds_minimum_version})
-pkg_check_modules(LIBEDATACAL REQUIRED libedata-cal-1.2>=${eds_minimum_version})
+pkg_check_modules(LIBEDATACAL REQUIRED libedata-cal-2.0>=${eds_minimum_version})
 pkg_check_modules(LIBEDATASERVER REQUIRED libedataserver-1.2>=${eds_minimum_version})
 
 pkg_check_modules(EVOLUTION_SHELL REQUIRED evolution-shell-3.0>=${evo_minimum_version})
@@ -126,7 +126,6 @@ pkg_check_modules(GNOME_PLATFORM REQUIRED
        gtk+-3.0>=${gdk_minimum_version}
 )
 
-pkg_check_modules(LIBICAL REQUIRED libical)
 pkg_check_modules(LIBMAPI REQUIRED libmapi>=${libmapi_minimum_version})
 
 set(CMAKE_REQUIRED_DEFINITIONS ${LIBMAPI_CFLAGS_OTHER})
@@ -177,7 +176,7 @@ pkg_check_variable(errordir evolution-shell-3.0 errordir)
 pkg_check_variable(evo_privlibdir evolution-shell-3.0 privlibdir)
 pkg_check_variable(camel_providerdir camel-1.2 camel_providerdir)
 pkg_check_variable(ebook_backenddir libedata-book-1.2 backenddir)
-pkg_check_variable(ecal_backenddir libedata-cal-1.2 backenddir)
+pkg_check_variable(ecal_backenddir libedata-cal-2.0 backenddir)
 pkg_check_variable(eds_moduledir libebackend-1.2 moduledir)
 pkg_check_variable(evo_moduledir evolution-shell-3.0 moduledir)
 pkg_check_variable(mapidatadir evolution-data-server-1.2 privdatadir)
diff --git a/src/calendar/e-cal-backend-mapi-factory.c b/src/calendar/e-cal-backend-mapi-factory.c
index 20f676a..0f35901 100644
--- a/src/calendar/e-cal-backend-mapi-factory.c
+++ b/src/calendar/e-cal-backend-mapi-factory.c
@@ -77,7 +77,7 @@ e_cal_backend_mapi_events_factory_class_init (ECalBackendFactoryClass *class)
        backend_factory_class->share_subprocess = TRUE;
 
        class->factory_name = FACTORY_NAME;
-       class->component_kind = ICAL_VEVENT_COMPONENT;
+       class->component_kind = I_CAL_VEVENT_COMPONENT;
        class->backend_type = E_TYPE_CAL_BACKEND_MAPI;
 }
 
@@ -101,7 +101,7 @@ e_cal_backend_mapi_journal_factory_class_init (ECalBackendFactoryClass *class)
        backend_factory_class->share_subprocess = TRUE;
 
        class->factory_name = FACTORY_NAME;
-       class->component_kind = ICAL_VJOURNAL_COMPONENT;
+       class->component_kind = I_CAL_VJOURNAL_COMPONENT;
        class->backend_type = E_TYPE_CAL_BACKEND_MAPI;
 }
 
@@ -125,7 +125,7 @@ e_cal_backend_mapi_todos_factory_class_init (ECalBackendFactoryClass *class)
        backend_factory_class->share_subprocess = TRUE;
 
        class->factory_name = FACTORY_NAME;
-       class->component_kind = ICAL_VTODO_COMPONENT;
+       class->component_kind = I_CAL_VTODO_COMPONENT;
        class->backend_type = E_TYPE_CAL_BACKEND_MAPI;
 }
 
diff --git a/src/calendar/e-cal-backend-mapi.c b/src/calendar/e-cal-backend-mapi.c
index a2d8b56..97f998f 100644
--- a/src/calendar/e-cal-backend-mapi.c
+++ b/src/calendar/e-cal-backend-mapi.c
@@ -26,8 +26,6 @@
 #include <glib/gi18n-lib.h>
 #include <gio/gio.h>
 
-#include <libical/icaltz-util.h>
-
 #include <libedata-cal/libedata-cal.h>
 #include <libedataserver/libedataserver.h>
 
@@ -50,8 +48,9 @@
 #define gmtime_r(tp,tmp) (gmtime(tp)?(*(tmp)=*gmtime(tp),(tmp)):0)
 #endif
 
-#define EDC_ERROR(_code) e_data_cal_create_error (_code, NULL)
-#define EDC_ERROR_EX(_code, _msg) e_data_cal_create_error (_code, _msg)
+#define EC_ERROR(_code) e_client_error_create (_code, NULL)
+#define EC_ERROR_EX(_code, _msg) e_client_error_create (_code, _msg)
+#define ECC_ERROR(_code) e_cal_client_error_create (_code, NULL)
 
 /* Current data version */
 #define EMA_DATA_VERSION       1
@@ -65,13 +64,14 @@ struct _ECalBackendMAPIPrivate {
 };
 
 static gchar * ecb_mapi_dup_component_revision_cb      (ECalCache *cal_cache,
-                                                        icalcomponent *icalcomp);
+                                                        ICalComponent *icomp);
 
 static void
-ecb_mapi_error_to_edc_error (GError **perror,
-                            const GError *mapi_error,
-                            EDataCalCallStatus code,
-                            const gchar *context)
+ecb_mapi_error_to_client_error (GError **perror,
+                               const GError *mapi_error,
+                               GQuark domain,
+                               gint code,
+                               const gchar *context)
 {
        gchar *err_msg = NULL;
 
@@ -83,15 +83,16 @@ ecb_mapi_error_to_edc_error (GError **perror,
                return;
        }
 
-       if (code == OtherError && mapi_error && mapi_error->domain == E_MAPI_ERROR) {
+       if (domain == E_CLIENT_ERROR && code == E_CLIENT_ERROR_OTHER_ERROR &&
+           mapi_error && mapi_error->domain == E_MAPI_ERROR) {
                /* Change error to more accurate only with OtherError */
                switch (mapi_error->code) {
                case MAPI_E_PASSWORD_CHANGE_REQUIRED:
                case MAPI_E_PASSWORD_EXPIRED:
-                       code = AuthenticationRequired;
+                       code = E_CLIENT_ERROR_AUTHENTICATION_REQUIRED;
                        break;
                case ecRpcFailed:
-                       code = RepositoryOffline;
+                       code = E_CLIENT_ERROR_REPOSITORY_OFFLINE;
                        break;
                default:
                        break;
@@ -101,7 +102,7 @@ ecb_mapi_error_to_edc_error (GError **perror,
        if (context)
                err_msg = g_strconcat (context, mapi_error ? ": " : NULL, mapi_error ? mapi_error->message : 
NULL, NULL);
 
-       g_propagate_error (perror, EDC_ERROR_EX (code, err_msg ? err_msg : mapi_error ? mapi_error->message : 
_("Unknown error")));
+       g_set_error_literal (perror, domain, code, err_msg ? err_msg : mapi_error ? mapi_error->message : 
_("Unknown error"));
 
        g_free (err_msg);
 }
@@ -204,20 +205,20 @@ ecb_mapi_maybe_disconnect (ECalBackendMAPI *cbmapi,
 }
 
 static void
-ecb_mapi_get_comp_mid (icalcomponent *icalcomp,
+ecb_mapi_get_comp_mid (ICalComponent *icomp,
                       mapi_id_t *mid)
 {
        gchar *x_mid;
 
-       g_return_if_fail (icalcomp != NULL);
+       g_return_if_fail (icomp != NULL);
        g_return_if_fail (mid != NULL);
 
-       x_mid = e_mapi_cal_utils_get_icomp_x_prop (icalcomp, "X-EVOLUTION-MAPI-MID");
+       x_mid = e_cal_util_component_dup_x_property (icomp, "X-EVOLUTION-MAPI-MID");
        if (x_mid) {
                e_mapi_util_mapi_id_from_string (x_mid, mid);
                g_free (x_mid);
        } else {
-               e_mapi_util_mapi_id_from_string (icalcomponent_get_uid (icalcomp), mid);
+               e_mapi_util_mapi_id_from_string (i_cal_component_get_uid (icomp), mid);
        }
 }
 
@@ -302,23 +303,27 @@ ecb_mapi_build_global_id_restriction (EMapiConnection *conn,
        restriction->res.resProperty.relop = RELOP_EQ;
        restriction->res.resProperty.ulPropTag = PidLidGlobalObjectId;
 
-       propval = e_mapi_cal_utils_get_icomp_x_prop (e_cal_component_get_icalcomponent (comp), 
"X-EVOLUTION-MAPI-GLOBALID");
+       propval = e_cal_util_component_dup_x_property (e_cal_component_get_icalcomponent (comp), 
"X-EVOLUTION-MAPI-GLOBALID");
        if (propval && *propval) {
                gsize len = 0;
 
                sb.lpb = g_base64_decode (propval, &len);
                sb.cb = len;
        } else {
-               struct icaltimetype ical_creation_time = { 0 };
+               ICalTime *dtstamp;
                struct FILETIME creation_time = { 0 };
                const gchar *uid;
 
-               uid = icalcomponent_get_uid (e_cal_component_get_icalcomponent (comp));
+               uid = e_cal_component_get_uid (comp);
+
+               dtstamp = e_cal_component_get_dtstamp (comp);
+               if (!dtstamp)
+                       dtstamp = i_cal_time_null_time ();
 
-               e_cal_component_get_dtstamp (comp, &ical_creation_time);
+               e_mapi_util_time_t_to_filetime (i_cal_time_as_timet (dtstamp), &creation_time);
+               e_mapi_cal_util_generate_globalobjectid (FALSE, uid, NULL, (dtstamp && i_cal_time_get_year 
(dtstamp)) ? &creation_time : NULL, &sb);
 
-               e_mapi_util_time_t_to_filetime (icaltime_as_timet (ical_creation_time), &creation_time);
-               e_mapi_cal_util_generate_globalobjectid (FALSE, uid, NULL, ical_creation_time.year ? 
&creation_time : NULL, &sb);
+               g_clear_object (&dtstamp);
        }
        g_free (propval);
 
@@ -383,13 +388,13 @@ ecb_mapi_get_server_data (ECalBackendMAPI *cbmapi,
                          GCancellable *cancellable)
 {
        EMapiConnection *conn;
-       icalcomponent *icalcomp;
+       ICalComponent *icomp;
        mapi_id_t mid;
        mapi_object_t obj_folder;
        GError *mapi_error = NULL;
 
-       icalcomp = e_cal_component_get_icalcomponent (comp);
-       ecb_mapi_get_comp_mid (icalcomp, &mid);
+       icomp = e_cal_component_get_icalcomponent (comp);
+       ecb_mapi_get_comp_mid (icomp, &mid);
 
        conn = cbmapi->priv->conn;
        if (!conn)
@@ -529,49 +534,64 @@ static gboolean
 ecb_mapi_modifier_is_organizer (ECalBackendMAPI *cbmapi,
                                ECalComponent *comp)
 {
-       ECalComponentOrganizer org;
+       ECalComponentOrganizer *org;
        const gchar *ownerid, *orgid;
+       gboolean res;
 
        if (!e_cal_component_has_organizer (comp))
                return TRUE;
 
-       e_cal_component_get_organizer (comp, &org);
-       if (!g_ascii_strncasecmp (org.value, "mailto:";, 7))
-               orgid = (org.value) + 7;
-       else
-               orgid = org.value;
+       org = e_cal_component_get_organizer (comp);
+       if (!org)
+               return TRUE;
+
+       orgid = e_cal_component_organizer_get_value (org);
+
+       if (orgid && !g_ascii_strncasecmp (orgid, "mailto:";, 7))
+               orgid = orgid + 7;
 
        ownerid = ecb_mapi_get_owner_email (cbmapi);
 
-       return g_ascii_strcasecmp (orgid, ownerid) == 0;
+       res = g_ascii_strcasecmp (orgid, ownerid) == 0;
+
+       e_cal_component_organizer_free (org);
+
+       return res;
 }
 
 static OlResponseStatus
 ecb_mapi_find_my_response (ECalBackendMAPI *cbmapi,
                           ECalComponent *comp)
 {
-       icalcomponent *icalcomp = e_cal_component_get_icalcomponent (comp);
-       icalproperty *attendee;
+       ICalComponent *icomp = e_cal_component_get_icalcomponent (comp);
+       ICalProperty *attendee;
        gchar *att = NULL;
        OlResponseStatus val = olResponseTentative;
 
        att = g_strdup_printf ("mailto:%s";, ecb_mapi_get_owner_email (cbmapi));
 
-       for (attendee = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
+       for (attendee = i_cal_component_get_first_property (icomp, I_CAL_ATTENDEE_PROPERTY);
             attendee;
-            attendee = icalcomponent_get_next_property (icalcomp, ICAL_ATTENDEE_PROPERTY)) {
-               const gchar *value = icalproperty_get_attendee (attendee);
+            g_object_unref (attendee), attendee = i_cal_component_get_next_property (icomp, 
I_CAL_ATTENDEE_PROPERTY)) {
+               const gchar *value = i_cal_property_get_attendee (attendee);
                if (!g_ascii_strcasecmp (value, att)) {
-                       icalparameter *param = icalproperty_get_first_parameter (attendee, 
ICAL_PARTSTAT_PARAMETER);
+                       ICalParameterPartstat partstat = I_CAL_PARTSTAT_NONE;
+                       ICalParameter *param;
 
-                       switch (icalparameter_get_partstat (param)) {
-                       case ICAL_PARTSTAT_ACCEPTED:
+                       param = i_cal_property_get_first_parameter (attendee, I_CAL_PARTSTAT_PARAMETER);
+                       if (param) {
+                               partstat = i_cal_parameter_get_partstat (param);
+                               g_object_unref (param);
+                       }
+
+                       switch (partstat) {
+                       case I_CAL_PARTSTAT_ACCEPTED:
                                val = olResponseAccepted;
                                break;
-                       case ICAL_PARTSTAT_TENTATIVE:
+                       case I_CAL_PARTSTAT_TENTATIVE:
                                val = olResponseTentative;
                                break;
-                       case ICAL_PARTSTAT_DECLINED:
+                       case I_CAL_PARTSTAT_DECLINED:
                                val = olResponseDeclined;
                                break;
                        default:
@@ -579,6 +599,7 @@ ecb_mapi_find_my_response (ECalBackendMAPI *cbmapi,
                                break;
                        }
 
+                       g_object_unref (attendee);
                        break;
                }
        }
@@ -722,7 +743,7 @@ ecb_mapi_connect_sync (ECalMetaBackend *meta_backend,
                ecb_mapi_unlock_connection (cbmapi);
 
                if (is_network_error)
-                       ecb_mapi_error_to_edc_error (error, mapi_error, OtherError, NULL);
+                       ecb_mapi_error_to_client_error (error, mapi_error, E_CLIENT_ERROR, 
E_CLIENT_ERROR_OTHER_ERROR, NULL);
 
                g_clear_error (&mapi_error);
 
@@ -792,8 +813,8 @@ ecb_mapi_disconnect_sync (ECalMetaBackend *meta_backend,
 
 typedef struct _LoadMultipleData {
        ECalMetaBackend *meta_backend;
-       icalcomponent_kind kind;
-       GSList **out_components; /* icalcomponent * */
+       ICalComponentKind kind;
+       GSList **out_components; /* ICalComponent * */
 } LoadMultipleData;
 
 static gboolean
@@ -831,7 +852,7 @@ transfer_calendar_objects_cb (EMapiConnection *conn,
                instances = g_slist_prepend (instances, comp);
 
        if (instances) {
-               icalcomponent *icomp;
+               ICalComponent *icomp;
 
                icomp = e_cal_meta_backend_merge_instances (lmd->meta_backend, instances, FALSE);
                if (icomp)
@@ -846,7 +867,7 @@ transfer_calendar_objects_cb (EMapiConnection *conn,
 static gboolean
 ecb_mapi_load_multiple_sync (ECalBackendMAPI *cbmapi,
                             const GSList *uids, /* gchar * */
-                            GSList **out_components, /* icalcomponent * */
+                            GSList **out_components, /* ICalComponent * */
                             GCancellable *cancellable,
                             GError **error)
 {
@@ -888,7 +909,7 @@ ecb_mapi_load_multiple_sync (ECalBackendMAPI *cbmapi,
 
        if (mapi_error) {
                ecb_mapi_maybe_disconnect (cbmapi, mapi_error);
-               ecb_mapi_error_to_edc_error (error, mapi_error, OtherError, _("Failed to transfer objects 
from a server"));
+               ecb_mapi_error_to_client_error (error, mapi_error, E_CLIENT_ERROR, 
E_CLIENT_ERROR_OTHER_ERROR, _("Failed to transfer objects from a server"));
                g_error_free (mapi_error);
 
                success = FALSE;
@@ -947,28 +968,30 @@ ecb_mapi_preload_infos_sync (ECalBackendMAPI *cbmapi,
                success = ecb_mapi_load_multiple_sync (cbmapi, uids, &components, cancellable, error);
                if (success) {
                        for (link = components; link; link = g_slist_next (link)) {
-                               icalcomponent *icomp = link->data;
+                               ICalComponent *icomp = link->data;
 
                                if (icomp) {
                                        ECalMetaBackendInfo *nfo;
                                        const gchar *uid = NULL;
                                        gchar *xmid = NULL;
 
-                                       if (icalcomponent_isa (icomp) == ICAL_VCALENDAR_COMPONENT) {
-                                               icalcomponent *subcomp;
-                                               icalcomponent_kind kind;
+                                       if (i_cal_component_isa (icomp) == I_CAL_VCALENDAR_COMPONENT) {
+                                               ICalComponent *subcomp;
+                                               ICalComponentKind kind;
 
                                                kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbmapi));
 
-                                               for (subcomp = icalcomponent_get_first_component (icomp, 
kind);
+                                               for (subcomp = i_cal_component_get_first_component (icomp, 
kind);
                                                     subcomp && !uid;
-                                                    subcomp = icalcomponent_get_next_component (icomp, 
kind)) {
-                                                       uid = icalcomponent_get_uid (subcomp);
-                                                       xmid = e_mapi_cal_utils_get_icomp_x_prop (subcomp, 
"X-EVOLUTION-MAPI-MID");
+                                                    g_object_unref (subcomp), subcomp = 
i_cal_component_get_next_component (icomp, kind)) {
+                                                       uid = i_cal_component_get_uid (subcomp);
+                                                       xmid = e_cal_util_component_dup_x_property (subcomp, 
"X-EVOLUTION-MAPI-MID");
                                                }
+
+                                               g_clear_object (&subcomp);
                                        } else {
-                                               uid = icalcomponent_get_uid (icomp);
-                                               xmid = e_mapi_cal_utils_get_icomp_x_prop (icomp, 
"X-EVOLUTION-MAPI-MID");
+                                               uid = i_cal_component_get_uid (icomp);
+                                               xmid = e_cal_util_component_dup_x_property (icomp, 
"X-EVOLUTION-MAPI-MID");
                                        }
 
                                        nfo = uid ? g_hash_table_lookup (infos, uid) : NULL;
@@ -976,14 +999,14 @@ ecb_mapi_preload_infos_sync (ECalBackendMAPI *cbmapi,
                                                nfo = g_hash_table_lookup (infos, xmid);
 
                                        if (nfo && !nfo->object)
-                                               nfo->object = icalcomponent_as_ical_string_r (icomp);
+                                               nfo->object = i_cal_component_as_ical_string_r (icomp);
 
                                        g_free (xmid);
                                }
                        }
                }
 
-               g_slist_free_full (components, (GDestroyNotify) icalcomponent_free);
+               g_slist_free_full (components, g_object_unref);
        }
 
        g_hash_table_destroy (infos);
@@ -1045,11 +1068,12 @@ ecb_mapi_list_existing_uids_cb (EMapiConnection *conn,
 
        uid = e_mapi_util_mapi_id_to_string (object_data->mid);
        if (uid) {
-               struct icaltimetype itt;
+               ICalTime *itt;
                gchar *rev;
 
-               itt = icaltime_from_timet_with_zone (object_data->last_modified, 0, 
icaltimezone_get_utc_timezone ());
-               rev = icaltime_as_ical_string_r (itt);
+               itt = i_cal_time_from_timet_with_zone (object_data->last_modified, 0, 
i_cal_timezone_get_utc_timezone ());
+               rev = i_cal_time_as_ical_string_r (itt);
+               g_clear_object (&itt);
 
                *out_existing_objects = g_slist_prepend (*out_existing_objects,
                        e_cal_meta_backend_info_new (uid, rev, NULL, uid));
@@ -1068,6 +1092,7 @@ ecb_mapi_populate_mid_to_gid_cb (ECalCache *cal_cache,
                                 const gchar *revision,
                                 const gchar *object,
                                 const gchar *extra,
+                                guint32 custom_flags,
                                 EOfflineState offline_state,
                                 gpointer user_data)
 {
@@ -1112,7 +1137,7 @@ ecb_mapi_list_existing_sync (ECalMetaBackend *meta_backend,
 
        if (mapi_error) {
                ecb_mapi_maybe_disconnect (cbmapi, mapi_error);
-               ecb_mapi_error_to_edc_error (error, mapi_error, OtherError, _("Failed to list items from a 
server"));
+               ecb_mapi_error_to_client_error (error, mapi_error, E_CLIENT_ERROR, 
E_CLIENT_ERROR_OTHER_ERROR, _("Failed to list items from a server"));
                g_error_free (mapi_error);
 
                success = FALSE;
@@ -1161,7 +1186,7 @@ static gboolean
 ecb_mapi_load_component_sync (ECalMetaBackend *meta_backend,
                              const gchar *uid,
                              const gchar *extra,
-                             icalcomponent **out_component,
+                             ICalComponent **out_component,
                              gchar **out_extra,
                              GCancellable *cancellable,
                              GError **error)
@@ -1216,7 +1241,7 @@ ecb_mapi_load_component_sync (ECalMetaBackend *meta_backend,
                *out_component = components->data;
                g_slist_free (components);
        } else {
-               g_slist_free_full (components, (GDestroyNotify) icalcomponent_free);
+               g_slist_free_full (components, g_object_unref);
        }
 
        if (local_error)
@@ -1233,6 +1258,7 @@ ecb_mapi_save_component_sync (ECalMetaBackend *meta_backend,
                              EConflictResolution conflict_resolution,
                              const GSList *instances,
                              const gchar *extra,
+                             guint32 opflags, /* bit-or of ECalOperationFlags */
                              gchar **out_new_uid,
                              gchar **out_new_extra,
                              GCancellable *cancellable,
@@ -1240,7 +1266,7 @@ ecb_mapi_save_component_sync (ECalMetaBackend *meta_backend,
 {
        ECalBackendMAPI *cbmapi;
        ECalComponent *comp;
-       icalcomponent *icomp;
+       ICalComponent *icomp;
        gboolean no_increment;
        mapi_object_t obj_folder;
        mapi_id_t mid = 0;
@@ -1255,19 +1281,19 @@ ecb_mapi_save_component_sync (ECalMetaBackend *meta_backend,
 
        if (instances->next ||
            e_cal_component_is_instance (instances->data)) {
-               g_propagate_error (error, EDC_ERROR_EX (OtherError,
+               g_propagate_error (error, EC_ERROR_EX (E_CLIENT_ERROR_OTHER_ERROR,
                        _("Support for modifying single instances of a recurring appointment is not yet 
implemented. No change was made to the appointment on the server.")));
                return FALSE;
        }
 
        cbmapi = E_CAL_BACKEND_MAPI (meta_backend);
 
-       icomp = icalcomponent_new_clone (e_cal_component_get_icalcomponent (instances->data));
-       no_increment = e_cal_util_remove_x_property (icomp, "X-EVOLUTION-IS-REPLY");
+       icomp = i_cal_component_new_clone (e_cal_component_get_icalcomponent (instances->data));
+       no_increment = e_cal_util_component_remove_x_property (icomp, "X-EVOLUTION-IS-REPLY");
 
        comp = e_cal_component_new_from_icalcomponent (icomp);
        if (!comp) {
-               g_propagate_error (error, EDC_ERROR (InvalidObject));
+               g_propagate_error (error, ECC_ERROR (E_CAL_CLIENT_ERROR_INVALID_OBJECT));
                return FALSE;
        }
 
@@ -1282,7 +1308,7 @@ ecb_mapi_save_component_sync (ECalMetaBackend *meta_backend,
                cbdata.comp = comp;
                cbdata.is_modify = overwrite_existing;
                cbdata.msgflags = MSGFLAG_READ;
-               cbdata.get_timezone = (icaltimezone * (*)(gpointer data, const gchar *tzid)) 
e_timezone_cache_get_timezone;
+               cbdata.get_timezone = e_timezone_cache_get_timezone;
                cbdata.get_tz_data = cbmapi;
 
                if (overwrite_existing) {
@@ -1338,7 +1364,7 @@ ecb_mapi_save_component_sync (ECalMetaBackend *meta_backend,
 
        if (mapi_error || !mid) {
                ecb_mapi_maybe_disconnect (cbmapi, mapi_error);
-               ecb_mapi_error_to_edc_error (error, mapi_error, OtherError,
+               ecb_mapi_error_to_client_error (error, mapi_error, E_CLIENT_ERROR, E_CLIENT_ERROR_OTHER_ERROR,
                        overwrite_existing ? _("Failed to modify item on a server") : _("Failed to create 
item on a server"));
                g_clear_error (&mapi_error);
 
@@ -1361,6 +1387,7 @@ ecb_mapi_remove_component_sync (ECalMetaBackend *meta_backend,
                                const gchar *uid,
                                const gchar *extra,
                                const gchar *object,
+                               guint32 opflags, /* bit-or of ECalOperationFlags */
                                GCancellable *cancellable,
                                GError **error)
 {
@@ -1375,12 +1402,12 @@ ecb_mapi_remove_component_sync (ECalMetaBackend *meta_backend,
        cbmapi = E_CAL_BACKEND_MAPI (meta_backend);
 
        if (object) {
-               icalcomponent *icomp;
+               ICalComponent *icomp;
 
-               icomp = icalcomponent_new_from_string (object);
+               icomp = i_cal_component_new_from_string (object);
                if (icomp) {
                        ecb_mapi_get_comp_mid (icomp, &mid);
-                       icalcomponent_free (icomp);
+                       g_object_unref (icomp);
                }
        }
 
@@ -1407,7 +1434,7 @@ ecb_mapi_remove_component_sync (ECalMetaBackend *meta_backend,
 
        if (mapi_error || !mid) {
                ecb_mapi_maybe_disconnect (cbmapi, mapi_error);
-               ecb_mapi_error_to_edc_error (error, mapi_error, OtherError, _("Failed to remove item from a 
server"));
+               ecb_mapi_error_to_client_error (error, mapi_error, E_CLIENT_ERROR, 
E_CLIENT_ERROR_OTHER_ERROR, _("Failed to remove item from a server"));
                g_clear_error (&mapi_error);
 
                success = FALSE;
@@ -1429,27 +1456,27 @@ ecb_mapi_get_backend_property (ECalBackend *backend,
        if (g_str_equal (prop_name, CLIENT_BACKEND_PROPERTY_CAPABILITIES)) {
                return g_strjoin (
                        ",",
-                       CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT,
-                       CAL_STATIC_CAPABILITY_NO_AUDIO_ALARMS,
-                       CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS,
-                       CAL_STATIC_CAPABILITY_NO_PROCEDURE_ALARMS,
-                       CAL_STATIC_CAPABILITY_ONE_ALARM_ONLY,
-                       CAL_STATIC_CAPABILITY_REMOVE_ALARMS,
-                       CAL_STATIC_CAPABILITY_NO_THISANDFUTURE,
-                       CAL_STATIC_CAPABILITY_NO_THISANDPRIOR,
-                       CAL_STATIC_CAPABILITY_CREATE_MESSAGES,
-                       CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK,
-                       CAL_STATIC_CAPABILITY_NO_CONV_TO_RECUR,
-                       CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING,
-                       CAL_STATIC_CAPABILITY_REFRESH_SUPPORTED,
-                       CAL_STATIC_CAPABILITY_NO_MEMO_START_DATE,
-                       CAL_STATIC_CAPABILITY_TASK_DATE_ONLY,
-                       CAL_STATIC_CAPABILITY_TASK_NO_ALARM,
+                       E_CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT,
+                       E_CAL_STATIC_CAPABILITY_NO_AUDIO_ALARMS,
+                       E_CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS,
+                       E_CAL_STATIC_CAPABILITY_NO_PROCEDURE_ALARMS,
+                       E_CAL_STATIC_CAPABILITY_ONE_ALARM_ONLY,
+                       E_CAL_STATIC_CAPABILITY_REMOVE_ALARMS,
+                       E_CAL_STATIC_CAPABILITY_NO_THISANDFUTURE,
+                       E_CAL_STATIC_CAPABILITY_NO_THISANDPRIOR,
+                       E_CAL_STATIC_CAPABILITY_CREATE_MESSAGES,
+                       E_CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK,
+                       E_CAL_STATIC_CAPABILITY_NO_CONV_TO_RECUR,
+                       E_CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING,
+                       E_CAL_STATIC_CAPABILITY_REFRESH_SUPPORTED,
+                       E_CAL_STATIC_CAPABILITY_NO_MEMO_START_DATE,
+                       E_CAL_STATIC_CAPABILITY_TASK_DATE_ONLY,
+                       E_CAL_STATIC_CAPABILITY_TASK_NO_ALARM,
                        e_cal_meta_backend_get_capabilities (E_CAL_META_BACKEND (backend)),
                        NULL);
-       } else if (g_str_equal (prop_name, CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS)) {
+       } else if (g_str_equal (prop_name, E_CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS)) {
                return g_strdup (ecb_mapi_get_owner_email (cbmapi));
-       } else if (g_str_equal (prop_name, CAL_BACKEND_PROPERTY_ALARM_EMAIL_ADDRESS)) {
+       } else if (g_str_equal (prop_name, E_CAL_BACKEND_PROPERTY_ALARM_EMAIL_ADDRESS)) {
                /* We don't support email alarms. This should not have been called. */
                return NULL;
        }
@@ -1463,18 +1490,19 @@ ecb_mapi_send_objects_sync (ECalBackendSync *sync_backend,
                            EDataCal *cal,
                            GCancellable *cancellable,
                            const gchar *calobj,
+                           guint32 opflags, /* bit-or of ECalOperationFlags */
                            GSList **users,
                            gchar **modified_calobj,
                            GError **error)
 {
        ECalBackendMAPI *cbmapi;
        EMapiConnection *conn;
-       icalcomponent_kind kind;
-       icalcomponent *icalcomp;
+       ICalComponentKind kind;
+       ICalComponent *icomp;
        GError *mapi_error = NULL;
 
-       e_mapi_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_MAPI (sync_backend), InvalidArg);
-       e_mapi_return_data_cal_error_if_fail (calobj != NULL, InvalidArg);
+       e_mapi_return_client_error_if_fail (E_IS_CAL_BACKEND_MAPI (sync_backend), E_CLIENT_ERROR_INVALID_ARG);
+       e_mapi_return_client_error_if_fail (calobj != NULL, E_CLIENT_ERROR_INVALID_ARG);
 
        cbmapi = E_CAL_BACKEND_MAPI (sync_backend);
        kind = e_cal_backend_get_kind (E_CAL_BACKEND (sync_backend));
@@ -1486,9 +1514,9 @@ ecb_mapi_send_objects_sync (ECalBackendSync *sync_backend,
                ecb_mapi_unlock_connection (cbmapi);
 
                if (!mapi_error)
-                       g_propagate_error (error, EDC_ERROR (RepositoryOffline));
+                       g_propagate_error (error, EC_ERROR (E_CLIENT_ERROR_REPOSITORY_OFFLINE));
                else
-                       ecb_mapi_error_to_edc_error (error, mapi_error, RepositoryOffline, NULL);
+                       ecb_mapi_error_to_client_error (error, mapi_error, E_CLIENT_ERROR, 
E_CLIENT_ERROR_REPOSITORY_OFFLINE, NULL);
                g_clear_error (&mapi_error);
                return;
        }
@@ -1496,24 +1524,24 @@ ecb_mapi_send_objects_sync (ECalBackendSync *sync_backend,
        conn = cbmapi->priv->conn;
 
        /* check the component for validity */
-       icalcomp = icalparser_parse_string (calobj);
-       if (!icalcomp) {
+       icomp = i_cal_parser_parse_string (calobj);
+       if (!icomp) {
                ecb_mapi_unlock_connection (cbmapi);
-               g_propagate_error (error, EDC_ERROR (InvalidObject));
+               g_propagate_error (error, ECC_ERROR (E_CAL_CLIENT_ERROR_INVALID_OBJECT));
                return;
        }
 
        *modified_calobj = NULL;
        *users = NULL;
 
-       if (icalcomponent_isa (icalcomp) == ICAL_VCALENDAR_COMPONENT) {
-               icalproperty_method method = icalcomponent_get_method (icalcomp);
-               icalcomponent *subcomp;
+       if (i_cal_component_isa (icomp) == I_CAL_VCALENDAR_COMPONENT) {
+               ICalPropertyMethod method = i_cal_component_get_method (icomp);
+               ICalComponent *subcomp;
 
-               for (subcomp = icalcomponent_get_first_component (icalcomp, kind);
+               for (subcomp = i_cal_component_get_first_component (icomp, kind);
                     subcomp;
-                    subcomp = icalcomponent_get_next_component (icalcomp, kind)) {
-                       ECalComponent *comp = e_cal_component_new ();
+                    g_object_unref (subcomp), subcomp = i_cal_component_get_next_component (icomp, kind)) {
+                       ECalComponent *comp;
                        struct cal_cbdata cbdata = { 0 };
                        mapi_id_t mid = 0;
                        const gchar *compuid;
@@ -1521,10 +1549,12 @@ ecb_mapi_send_objects_sync (ECalBackendSync *sync_backend,
                        struct SBinary_short globalid = { 0 }, cleanglobalid = { 0 };
                        struct timeval *exception_repleace_time = NULL, ex_rep_time = { 0 };
                        struct FILETIME creation_time = { 0 };
-                       struct icaltimetype ical_creation_time = { 0 };
+                       ICalTime *dtstamp;
                        mapi_object_t obj_folder;
 
-                       e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (subcomp));
+                       comp = e_cal_component_new_from_icalcomponent (i_cal_component_new_clone (subcomp));
+                       if (!comp)
+                               continue;
 
                        cbdata.kind = kind;
                        cbdata.comp = comp;
@@ -1532,16 +1562,16 @@ ecb_mapi_send_objects_sync (ECalBackendSync *sync_backend,
                        cbdata.msgflags = MSGFLAG_READ | MSGFLAG_SUBMIT | MSGFLAG_UNSENT;
 
                        switch (method) {
-                       case ICAL_METHOD_REQUEST:
+                       case I_CAL_METHOD_REQUEST:
                                cbdata.meeting_type = MEETING_REQUEST;
                                cbdata.resp = olResponseNotResponded;
                                break;
-                       case ICAL_METHOD_CANCEL:
+                       case I_CAL_METHOD_CANCEL:
                                cbdata.meeting_type = MEETING_CANCEL;
                                cbdata.resp = olResponseNotResponded;
                                break;
-                       case ICAL_METHOD_REPLY:
-                       case ICAL_METHOD_RESPONSE:
+                       case I_CAL_METHOD_REPLY:
+                       case I_CAL_METHOD_RESPONSE:
                                cbdata.meeting_type = MEETING_RESPONSE;
                                cbdata.resp = ecb_mapi_find_my_response (cbmapi, comp);
                                break;
@@ -1558,15 +1588,17 @@ ecb_mapi_send_objects_sync (ECalBackendSync *sync_backend,
                        free_and_dupe_str (cbdata.ownername, ecb_mapi_get_owner_name (cbmapi));
                        free_and_dupe_str (cbdata.owneridtype, "SMTP");
                        free_and_dupe_str (cbdata.ownerid, ecb_mapi_get_owner_email (cbmapi));
-                       cbdata.get_timezone = (icaltimezone * (*)(gpointer data, const gchar *tzid)) 
e_timezone_cache_get_timezone;
+                       cbdata.get_timezone = e_timezone_cache_get_timezone;
                        cbdata.get_tz_data = cbmapi;
 
-                       e_cal_component_get_uid (comp, &compuid);
+                       compuid = e_cal_component_get_uid (comp);
 
-                       e_cal_component_get_dtstamp (comp, &ical_creation_time);
-                       e_mapi_util_time_t_to_filetime (icaltime_as_timet (ical_creation_time), 
&creation_time);
+                       dtstamp = e_cal_component_get_dtstamp (comp);
+                       if (!dtstamp)
+                               dtstamp = i_cal_time_null_time ();
+                       e_mapi_util_time_t_to_filetime (i_cal_time_as_timet (dtstamp), &creation_time);
 
-                       propval = e_mapi_cal_utils_get_icomp_x_prop (e_cal_component_get_icalcomponent 
(comp), "X-EVOLUTION-MAPI-EXREPTIME");
+                       propval = e_cal_util_component_dup_x_property (e_cal_component_get_icalcomponent 
(comp), "X-EVOLUTION-MAPI-EXREPTIME");
                        if (propval && *propval) {
                                mapi_id_t val64 = 0;
 
@@ -1579,7 +1611,7 @@ ecb_mapi_send_objects_sync (ECalBackendSync *sync_backend,
 
                        /* inherit GlobalID from the source object, if available */
                        if (e_cal_component_get_icalcomponent (comp)) {
-                               propval = e_mapi_cal_utils_get_icomp_x_prop 
(e_cal_component_get_icalcomponent (comp), "X-EVOLUTION-MAPI-GLOBALID");
+                               propval = e_cal_util_component_dup_x_property 
(e_cal_component_get_icalcomponent (comp), "X-EVOLUTION-MAPI-GLOBALID");
                                if (propval && *propval) {
                                        gsize len = 0;
 
@@ -1604,10 +1636,14 @@ ecb_mapi_send_objects_sync (ECalBackendSync *sync_backend,
                        }
 
                        if (compuid) {
-                               e_mapi_cal_util_generate_globalobjectid (FALSE, compuid, 
exception_repleace_time, ical_creation_time.year ? &creation_time : NULL, &globalid);
-                               e_mapi_cal_util_generate_globalobjectid (TRUE,  compuid, 
exception_repleace_time, ical_creation_time.year ? &creation_time : NULL, &cleanglobalid);
+                               e_mapi_cal_util_generate_globalobjectid (FALSE, compuid, 
exception_repleace_time,
+                                       (dtstamp && i_cal_time_get_year (dtstamp)) ? &creation_time : NULL, 
&globalid);
+                               e_mapi_cal_util_generate_globalobjectid (TRUE,  compuid, 
exception_repleace_time,
+                                       (dtstamp && i_cal_time_get_year (dtstamp)) ? &creation_time : NULL, 
&cleanglobalid);
                        }
 
+                       g_clear_object (&dtstamp);
+
                        if (cbdata.globalid)
                                e_mapi_util_free_sbinary_short (cbdata.globalid);
                        if (cbdata.cleanglobalid)
@@ -1633,7 +1669,7 @@ ecb_mapi_send_objects_sync (ECalBackendSync *sync_backend,
                        if (!mid) {
                                ecb_mapi_unlock_connection (cbmapi);
                                g_object_unref (comp);
-                               ecb_mapi_error_to_edc_error (error, mapi_error, OtherError, _("Failed to 
create item on a server"));
+                               ecb_mapi_error_to_client_error (error, mapi_error, E_CLIENT_ERROR, 
E_CLIENT_ERROR_OTHER_ERROR, _("Failed to create item on a server"));
                                ecb_mapi_maybe_disconnect (cbmapi, mapi_error);
                                if (mapi_error)
                                        g_error_free (mapi_error);
@@ -1648,7 +1684,7 @@ ecb_mapi_send_objects_sync (ECalBackendSync *sync_backend,
 
        *modified_calobj = g_strdup (calobj);
 
-       icalcomponent_free (icalcomp);
+       g_object_unref (icomp);
 }
 
 static void
@@ -1675,15 +1711,15 @@ ecb_mapi_get_free_busy_sync (ECalBackendSync *sync_backend,
                ecb_mapi_unlock_connection (cbmapi);
 
                if (!mapi_error)
-                       g_propagate_error (error, EDC_ERROR (RepositoryOffline));
+                       g_propagate_error (error, EC_ERROR (E_CLIENT_ERROR_REPOSITORY_OFFLINE));
                else
-                       ecb_mapi_error_to_edc_error (error, mapi_error, RepositoryOffline, NULL);
+                       ecb_mapi_error_to_client_error (error, mapi_error, E_CLIENT_ERROR, 
E_CLIENT_ERROR_REPOSITORY_OFFLINE, NULL);
                g_clear_error (&mapi_error);
                return;
        }
 
        if (!e_mapi_cal_utils_get_free_busy_data (cbmapi->priv->conn, users, start, end, freebusyobjs, 
cancellable, &mapi_error)) {
-               ecb_mapi_error_to_edc_error (error, mapi_error, OtherError, _("Failed to get Free/Busy 
data"));
+               ecb_mapi_error_to_client_error (error, mapi_error, E_CLIENT_ERROR, 
E_CLIENT_ERROR_OTHER_ERROR, _("Failed to get Free/Busy data"));
                ecb_mapi_maybe_disconnect (cbmapi, mapi_error);
 
                if (mapi_error)
@@ -1752,45 +1788,51 @@ ecb_mapi_update_tzid_cb (ECache *cache,
                         ECacheColumnValues **out_other_columns,
                         gpointer user_data)
 {
-       icalcomponent *icomp;
-       icalproperty *prop;
+       ICalComponent *icomp;
+       ICalProperty *prop;
        gboolean changed = FALSE;
 
        g_return_val_if_fail (object != NULL, FALSE);
        g_return_val_if_fail (out_object != NULL, FALSE);
 
-       icomp = icalcomponent_new_from_string (object);
+       icomp = i_cal_component_new_from_string (object);
        if (!icomp)
                return TRUE;
 
-       prop = icalcomponent_get_first_property (icomp, ICAL_DTSTART_PROPERTY);
-       if (prop && icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER)) {
-               struct icaltimetype itt;
+       prop = i_cal_component_get_first_property (icomp, I_CAL_DTSTART_PROPERTY);
+       if (prop && e_cal_util_property_has_parameter (prop, I_CAL_TZID_PARAMETER)) {
+               ICalTime *itt;
 
-               itt = icalproperty_get_dtstart (prop);
-               if (icaltime_is_valid_time (itt) && icaltime_is_utc (itt)) {
-                       itt.zone = NULL;
-                       icalproperty_set_dtstart (prop, itt);
+               itt = i_cal_property_get_dtstart (prop);
+               if (itt && i_cal_time_is_valid_time (itt) && i_cal_time_is_utc (itt)) {
+                       i_cal_time_set_timezone (itt, NULL);
+                       i_cal_property_set_dtstart (prop, itt);
                        changed = TRUE;
                }
+
+               g_clear_object (&itt);
        }
+       g_clear_object (&prop);
 
-       prop = icalcomponent_get_first_property (icomp, ICAL_DTEND_PROPERTY);
-       if (prop && icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER)) {
-               struct icaltimetype itt;
+       prop = i_cal_component_get_first_property (icomp, I_CAL_DTEND_PROPERTY);
+       if (prop && e_cal_util_property_has_parameter (prop, I_CAL_TZID_PARAMETER)) {
+               ICalTime *itt;
 
-               itt = icalproperty_get_dtend (prop);
-               if (icaltime_is_valid_time (itt) && icaltime_is_utc (itt)) {
-                       itt.zone = NULL;
-                       icalproperty_set_dtend (prop, itt);
+               itt = i_cal_property_get_dtend (prop);
+               if (itt && i_cal_time_is_valid_time (itt) && i_cal_time_is_utc (itt)) {
+                       i_cal_time_set_timezone (itt, NULL);
+                       i_cal_property_set_dtend (prop, itt);
                        changed = TRUE;
                }
+
+               g_clear_object (&itt);
        }
+       g_clear_object (&prop);
 
        if (changed)
-               *out_object = icalcomponent_as_ical_string_r (icomp);
+               *out_object = i_cal_component_as_ical_string_r (icomp);
 
-       icalcomponent_free (icomp);
+       g_object_unref (icomp);
 
        return TRUE;
 }
@@ -1809,20 +1851,25 @@ ecb_mapi_migrate (ECalBackendMAPI *cbmapi,
 
 static gchar *
 ecb_mapi_dup_component_revision_cb (ECalCache *cal_cache,
-                                   icalcomponent *icalcomp)
+                                   ICalComponent *icomp)
 {
-       icalproperty *prop;
-       struct icaltimetype itt;
+       ICalProperty *prop;
+       ICalTime *itt;
+       gchar *res;
 
-       g_return_val_if_fail (icalcomp != NULL, NULL);
+       g_return_val_if_fail (I_CAL_IS_COMPONENT (icomp), NULL);
 
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_LASTMODIFIED_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_LASTMODIFIED_PROPERTY);
        if (!prop)
                return NULL;
 
-       itt = icalproperty_get_lastmodified (prop);
+       itt = i_cal_property_get_lastmodified (prop);
+       res = i_cal_time_as_ical_string_r (itt);
 
-       return icaltime_as_ical_string_r (itt);
+       g_clear_object (&prop);
+       g_clear_object (&itt);
+
+       return res;
 }
 
 static void
diff --git a/src/libexchangemapi/e-mapi-cal-recur-utils.c b/src/libexchangemapi/e-mapi-cal-recur-utils.c
index 0b8288b..e62dba7 100644
--- a/src/libexchangemapi/e-mapi-cal-recur-utils.c
+++ b/src/libexchangemapi/e-mapi-cal-recur-utils.c
@@ -557,48 +557,72 @@ free_arp_contents(struct ema_AppointmentRecurrencePattern *arp)
        }
 }
 
-static icalrecurrencetype_weekday
+static ICalRecurrenceWeekday
 get_ical_weekstart (uint32_t fdow)
 {
        switch (fdow) {
-               case FirstDOW_Sunday    : return ICAL_SUNDAY_WEEKDAY;
-               case FirstDOW_Monday    : return ICAL_MONDAY_WEEKDAY;
-               case FirstDOW_Tuesday   : return ICAL_TUESDAY_WEEKDAY;
-               case FirstDOW_Wednesday : return ICAL_WEDNESDAY_WEEKDAY;
-               case FirstDOW_Thursday  : return ICAL_THURSDAY_WEEKDAY;
-               case FirstDOW_Friday    : return ICAL_FRIDAY_WEEKDAY;
-               case FirstDOW_Saturday  : return ICAL_SATURDAY_WEEKDAY;
-               default                 : return ICAL_SUNDAY_WEEKDAY;
+       case FirstDOW_Sunday:
+               return I_CAL_SUNDAY_WEEKDAY;
+       case FirstDOW_Monday:
+               return I_CAL_MONDAY_WEEKDAY;
+       case FirstDOW_Tuesday:
+               return I_CAL_TUESDAY_WEEKDAY;
+       case FirstDOW_Wednesday:
+               return I_CAL_WEDNESDAY_WEEKDAY;
+       case FirstDOW_Thursday:
+               return I_CAL_THURSDAY_WEEKDAY;
+       case FirstDOW_Friday:
+               return I_CAL_FRIDAY_WEEKDAY;
+       case FirstDOW_Saturday:
+               return I_CAL_SATURDAY_WEEKDAY;
+       default:
+               return I_CAL_SUNDAY_WEEKDAY;
        }
 }
 
 static uint32_t
-get_mapi_weekstart (icalrecurrencetype_weekday weekstart)
+get_mapi_weekstart (ICalRecurrenceWeekday weekstart)
 {
        switch (weekstart) {
-               case ICAL_SUNDAY_WEEKDAY   : return FirstDOW_Sunday;
-               case ICAL_MONDAY_WEEKDAY   : return FirstDOW_Monday;
-               case ICAL_TUESDAY_WEEKDAY  : return FirstDOW_Tuesday;
-               case ICAL_WEDNESDAY_WEEKDAY: return FirstDOW_Wednesday;
-               case ICAL_THURSDAY_WEEKDAY : return FirstDOW_Thursday;
-               case ICAL_FRIDAY_WEEKDAY   : return FirstDOW_Friday;
-               case ICAL_SATURDAY_WEEKDAY : return FirstDOW_Saturday;
-               default                    : return FirstDOW_Sunday;
+       case I_CAL_SUNDAY_WEEKDAY:
+               return FirstDOW_Sunday;
+       case I_CAL_MONDAY_WEEKDAY:
+               return FirstDOW_Monday;
+       case I_CAL_TUESDAY_WEEKDAY:
+               return FirstDOW_Tuesday;
+       case I_CAL_WEDNESDAY_WEEKDAY:
+               return FirstDOW_Wednesday;
+       case I_CAL_THURSDAY_WEEKDAY:
+               return FirstDOW_Thursday;
+       case I_CAL_FRIDAY_WEEKDAY:
+               return FirstDOW_Friday;
+       case I_CAL_SATURDAY_WEEKDAY:
+               return FirstDOW_Saturday;
+       default:
+               return FirstDOW_Sunday;
        }
 }
 
 static uint32_t
-get_mapi_day (icalrecurrencetype_weekday someday)
+get_mapi_day (ICalRecurrenceWeekday someday)
 {
        switch (someday) {
-               case ICAL_SUNDAY_WEEKDAY   : return olSunday;
-               case ICAL_MONDAY_WEEKDAY   : return olMonday;
-               case ICAL_TUESDAY_WEEKDAY  : return olTuesday;
-               case ICAL_WEDNESDAY_WEEKDAY: return olWednesday;
-               case ICAL_THURSDAY_WEEKDAY : return olThursday;
-               case ICAL_FRIDAY_WEEKDAY   : return olFriday;
-               case ICAL_SATURDAY_WEEKDAY : return olSaturday;
-               default                    : return 0;
+       case I_CAL_SUNDAY_WEEKDAY:
+               return olSunday;
+       case I_CAL_MONDAY_WEEKDAY:
+               return olMonday;
+       case I_CAL_TUESDAY_WEEKDAY:
+               return olTuesday;
+       case I_CAL_WEDNESDAY_WEEKDAY:
+               return olWednesday;
+       case I_CAL_THURSDAY_WEEKDAY:
+               return olThursday;
+       case I_CAL_FRIDAY_WEEKDAY:
+               return olFriday;
+       case I_CAL_SATURDAY_WEEKDAY:
+               return olSaturday;
+       default:
+               return 0;
        }
 }
 
@@ -715,9 +739,13 @@ check_calendar_type (guint16 type)
 }
 
 gboolean
-e_mapi_cal_util_bin_to_rrule (const guint8 *lpb, guint32 cb, ECalComponent *comp, GSList **extra_detached, 
icaltimezone *recur_zone)
+e_mapi_cal_util_bin_to_rrule (const guint8 *lpb,
+                             guint32 cb,
+                             ECalComponent *comp,
+                             GSList **extra_detached,
+                             ICalTimezone *recur_zone)
 {
-       struct icalrecurrencetype rt;
+       ICalRecurrence *rt;
        struct ema_AppointmentRecurrencePattern arp;
        struct ema_RecurrencePattern *rp; /* Convenience pointer */
        gboolean success = FALSE, check_calendar = FALSE;
@@ -735,7 +763,7 @@ e_mapi_cal_util_bin_to_rrule (const guint8 *lpb, guint32 cb, ECalComponent *comp
        fake_ba.data = (guint8 *) lpb;
        fake_ba.len = cb;
 
-       icalrecurrencetype_clear (&rt);
+       rt = i_cal_recurrence_new ();
 
        memset(&arp, 0, sizeof (struct ema_AppointmentRecurrencePattern));
        if (! gba_to_arp (&fake_ba, &off, &arp))
@@ -746,7 +774,7 @@ e_mapi_cal_util_bin_to_rrule (const guint8 *lpb, guint32 cb, ECalComponent *comp
        /* FREQUENCY */
 
        if (rp->RecurFrequency == RecurFrequency_Daily) {
-               rt.freq = ICAL_DAILY_RECURRENCE;
+               i_cal_recurrence_set_freq (rt, I_CAL_DAILY_RECURRENCE);
 
                if (rp->PatternType == PatternType_Day) {
                        /* Daily every N days */
@@ -754,7 +782,7 @@ e_mapi_cal_util_bin_to_rrule (const guint8 *lpb, guint32 cb, ECalComponent *comp
                        check_calendar = TRUE;
 
                        /* INTERVAL */
-                       rt.interval = (short) (rp->Period / (24 * 60));
+                       i_cal_recurrence_set_interval (rt, (short) (rp->Period / (24 * 60)));
                } else if (rp->PatternType == PatternType_Week) {
                        /* Daily every weekday */
 
@@ -762,13 +790,13 @@ e_mapi_cal_util_bin_to_rrule (const guint8 *lpb, guint32 cb, ECalComponent *comp
 
                        /* NOTE: Evolution does not handle daily-every-weekday
                         * any different from a weekly recurrence.  */
-                       rt.freq = ICAL_WEEKLY_RECURRENCE;
+                       i_cal_recurrence_set_freq (rt, I_CAL_WEEKLY_RECURRENCE);
 
                        /* INTERVAL */
-                       rt.interval = (short) (rp->Period);
+                       i_cal_recurrence_set_interval (rt, (short) (rp->Period));
                }
        } else if (rp->RecurFrequency == RecurFrequency_Weekly) {
-               rt.freq = ICAL_WEEKLY_RECURRENCE;
+               i_cal_recurrence_set_freq (rt, I_CAL_WEEKLY_RECURRENCE);
 
                if (rp->PatternType == PatternType_Week) {
                        /* weekly every N weeks (for all events and non-regenerating tasks) */
@@ -776,7 +804,7 @@ e_mapi_cal_util_bin_to_rrule (const guint8 *lpb, guint32 cb, ECalComponent *comp
                        check_calendar = TRUE;
 
                        /* INTERVAL */
-                       rt.interval = (short) (rp->Period);
+                       i_cal_recurrence_set_interval (rt, (short) (rp->Period));
                } else if (rp->PatternType == 0x0) {
                        /* weekly every N weeks (for all regenerating tasks) */
 
@@ -788,7 +816,7 @@ e_mapi_cal_util_bin_to_rrule (const guint8 *lpb, guint32 cb, ECalComponent *comp
                }
 
        } else if (rp->RecurFrequency == RecurFrequency_Monthly) {
-               rt.freq = ICAL_MONTHLY_RECURRENCE;
+               i_cal_recurrence_set_freq (rt, I_CAL_MONTHLY_RECURRENCE);
 
                if (rp->PatternType == PatternType_Month ||
                    rp->PatternType == PatternType_MonthEnd) {
@@ -797,13 +825,13 @@ e_mapi_cal_util_bin_to_rrule (const guint8 *lpb, guint32 cb, ECalComponent *comp
                        check_calendar = TRUE;
 
                        /* INTERVAL */
-                       rt.interval = (short) (rp->Period);
+                       i_cal_recurrence_set_interval (rt, (short) (rp->Period));
 
                        /* MONTH_DAY */
                        if (rp->PatternType == PatternType_Month)
-                               rt.by_month_day[0] = (short) (rp->PatternTypeSpecific);
+                               i_cal_recurrence_set_by_month_day (rt, 0, (short) (rp->PatternTypeSpecific));
                        else if (rp->PatternType == PatternType_MonthEnd)
-                               rt.by_month_day[0] = (short) (-1);
+                               i_cal_recurrence_set_by_month_day (rt, 0, (short) (-1));
 
                } else if (rp->PatternType == PatternType_MonthNth) {
                        gboolean post_process = FALSE;
@@ -812,36 +840,36 @@ e_mapi_cal_util_bin_to_rrule (const guint8 *lpb, guint32 cb, ECalComponent *comp
                        check_calendar = TRUE;
 
                        /* INTERVAL */
-                       rt.interval = (short) (rp->Period);
+                       i_cal_recurrence_set_interval (rt, (short) (rp->Period));
 
                        /* BITMASK */
                        if (rp->PatternTypeSpecific == olSunday)
-                               rt.by_day[0] = ICAL_SUNDAY_WEEKDAY;
+                               i_cal_recurrence_set_by_day (rt, 0, I_CAL_SUNDAY_WEEKDAY);
                        else if (rp->PatternTypeSpecific == olMonday)
-                               rt.by_day[0] = ICAL_MONDAY_WEEKDAY;
+                               i_cal_recurrence_set_by_day (rt, 0, I_CAL_MONDAY_WEEKDAY);
                        else if (rp->PatternTypeSpecific == olTuesday)
-                               rt.by_day[0] = ICAL_TUESDAY_WEEKDAY;
+                               i_cal_recurrence_set_by_day (rt, 0, I_CAL_TUESDAY_WEEKDAY);
                        else if (rp->PatternTypeSpecific == olWednesday)
-                               rt.by_day[0] = ICAL_WEDNESDAY_WEEKDAY;
+                               i_cal_recurrence_set_by_day (rt, 0, I_CAL_WEDNESDAY_WEEKDAY);
                        else if (rp->PatternTypeSpecific == olThursday)
-                               rt.by_day[0] = ICAL_THURSDAY_WEEKDAY;
+                               i_cal_recurrence_set_by_day (rt, 0, I_CAL_THURSDAY_WEEKDAY);
                        else if (rp->PatternTypeSpecific == olFriday)
-                               rt.by_day[0] = ICAL_FRIDAY_WEEKDAY;
+                               i_cal_recurrence_set_by_day (rt, 0, I_CAL_FRIDAY_WEEKDAY);
                        else if (rp->PatternTypeSpecific == olSaturday)
-                               rt.by_day[0] = ICAL_SATURDAY_WEEKDAY;
+                               i_cal_recurrence_set_by_day (rt, 0, I_CAL_SATURDAY_WEEKDAY);
                        else {
                                post_process = TRUE;
                        }
 
                        /* RecurrenceN */
                        if (!post_process) {
-                               rt.by_set_pos[0] = get_ical_pos (rp->N);
-                               if (rt.by_set_pos[0] == 0)
+                               i_cal_recurrence_set_by_set_pos (rt, 0, get_ical_pos (rp->N));
+                               if (i_cal_recurrence_get_by_set_pos (rt, 0) == 0)
                                        goto cleanup;
                        } else {
                                if (rp->PatternTypeSpecific == (olSunday | olMonday | olTuesday | olWednesday 
| olThursday | olFriday | olSaturday)) {
-                                       rt.by_month_day[0] = get_ical_pos (rp->N);
-                                       if (rt.by_month_day[0] == 0)
+                                       i_cal_recurrence_set_by_month_day (rt, 0, get_ical_pos (rp->N));
+                                       if (i_cal_recurrence_get_by_month_day (rt, 0) == 0)
                                                goto cleanup;
                                } else {
                                /* FIXME: Can we/LibICAL support any other types here? Namely, weekday and 
weekend-day */
@@ -852,7 +880,7 @@ e_mapi_cal_util_bin_to_rrule (const guint8 *lpb, guint32 cb, ECalComponent *comp
                }
 
        } else if (rp->RecurFrequency == RecurFrequency_Yearly) {
-               rt.freq = ICAL_YEARLY_RECURRENCE;
+               i_cal_recurrence_set_freq (rt, I_CAL_YEARLY_RECURRENCE);
 
                if (rp->PatternType == PatternType_Month) {
                        /* Yearly on day D of month M */
@@ -860,7 +888,7 @@ e_mapi_cal_util_bin_to_rrule (const guint8 *lpb, guint32 cb, ECalComponent *comp
                        check_calendar = TRUE;
 
                        /* INTERVAL */
-                       rt.interval = (short) (rp->Period / 12);
+                       i_cal_recurrence_set_interval (rt, (short) (rp->Period / 12));
 
                } else if (rp->PatternType == PatternType_MonthNth) {
                        /* Yearly on the Xth Y of month M */
@@ -881,19 +909,19 @@ e_mapi_cal_util_bin_to_rrule (const guint8 *lpb, guint32 cb, ECalComponent *comp
              rp->PatternType == PatternType_Week) ) {
                i = 0;
                if (rp->PatternTypeSpecific & olSunday)
-                       rt.by_day[i++] = ICAL_SUNDAY_WEEKDAY;
+                       i_cal_recurrence_set_by_day (rt, i++, I_CAL_SUNDAY_WEEKDAY);
                if (rp->PatternTypeSpecific & olMonday)
-                       rt.by_day[i++] = ICAL_MONDAY_WEEKDAY;
+                       i_cal_recurrence_set_by_day (rt, i++, I_CAL_MONDAY_WEEKDAY);
                if (rp->PatternTypeSpecific & olTuesday)
-                       rt.by_day[i++] = ICAL_TUESDAY_WEEKDAY;
+                       i_cal_recurrence_set_by_day (rt, i++, I_CAL_TUESDAY_WEEKDAY);
                if (rp->PatternTypeSpecific & olWednesday)
-                       rt.by_day[i++] = ICAL_WEDNESDAY_WEEKDAY;
+                       i_cal_recurrence_set_by_day (rt, i++, I_CAL_WEDNESDAY_WEEKDAY);
                if (rp->PatternTypeSpecific & olThursday)
-                       rt.by_day[i++] = ICAL_THURSDAY_WEEKDAY;
+                       i_cal_recurrence_set_by_day (rt, i++, I_CAL_THURSDAY_WEEKDAY);
                if (rp->PatternTypeSpecific & olFriday)
-                       rt.by_day[i++] = ICAL_FRIDAY_WEEKDAY;
+                       i_cal_recurrence_set_by_day (rt, i++, I_CAL_FRIDAY_WEEKDAY);
                if (rp->PatternTypeSpecific & olSaturday)
-                       rt.by_day[i++] = ICAL_SATURDAY_WEEKDAY;
+                       i_cal_recurrence_set_by_day (rt, i++, I_CAL_SATURDAY_WEEKDAY);
        }
 
        /* Only some calendar types supported */
@@ -902,55 +930,56 @@ e_mapi_cal_util_bin_to_rrule (const guint8 *lpb, guint32 cb, ECalComponent *comp
 
        /* End Type - followed by Occurence count */
        if (rp->EndType == END_AFTER_N_OCCURRENCES) {
-               rt.count = rp->OccurrenceCount;
+               i_cal_recurrence_set_count (rt, rp->OccurrenceCount);
        }
 
        /* week_start */
-       rt.week_start = get_ical_weekstart (rp->FirstDOW);
+       i_cal_recurrence_set_week_start (rt, get_ical_weekstart (rp->FirstDOW));
 
        /* number of exceptions */
        if (rp->DeletedInstanceCount) {
                for (i = 0; i < rp->DeletedInstanceCount; ++i) {
-                       struct icaltimetype tt, *val;
-                       ECalComponentDateTime *dt = g_new0 (ECalComponentDateTime, 1);
+                       ICalTime *tt;
                        time_t ictime = convert_recurrence_minutes_to_timet (rp->DeletedInstanceDates[i]);
 
-                       tt = icaltime_from_timet_with_zone (ictime, 1, NULL);
+                       tt = i_cal_time_from_timet_with_zone (ictime, 1, NULL);
 
-                       val = g_new0(struct icaltimetype, 1);
-                       memcpy (val, &tt, sizeof(struct icaltimetype));
-
-                       dt->value = val;
-                       dt->tzid = g_strdup ("UTC");
-
-                       exdate_list = g_slist_append (exdate_list, dt);
+                       exdate_list = g_slist_append (exdate_list, e_cal_component_datetime_new_take (tt, 
g_strdup ("UTC")));
                }
        }
 
        /* end date */
        if (rp->EndType == END_AFTER_DATE) {
+               ICalTime *itt;
+
                time_t ict = convert_recurrence_minutes_to_timet (rp->EndDate);
-               rt.until = icaltime_from_timet_with_zone (ict, 1, NULL);
+
+               itt = i_cal_time_from_timet_with_zone (ict, 1, NULL);
+               i_cal_recurrence_set_until (rt, itt);
+               g_clear_object (&itt);
        }
 
        /* Set the recurrence */
        {
                GSList l;
 
-               l.data = &rt;
+               l.data = rt;
                l.next = NULL;
 
-               e_cal_component_set_rrule_list (comp, &l);
-               e_cal_component_set_exdate_list (comp, exdate_list);
+               e_cal_component_set_rrules (comp, &l);
+               e_cal_component_set_exdates (comp, exdate_list);
        }
 
+       g_slist_free_full (exdate_list, e_cal_component_datetime_free);
+       g_clear_object (&rt);
+
        /* Modified exceptions */
        if (arp.ExceptionCount && extra_detached) {
                ECalComponent **detached = g_new0 (ECalComponent *,
                                                   arp.ExceptionCount);
-               struct icaltimetype tt;
-               ECalComponentDateTime edt;
-               ECalComponentRange rid;
+               ICalTime *tt;
+               ECalComponentDateTime *edt;
+               ECalComponentRange *rid;
 
                e_cal_component_commit_sequence (comp);
 
@@ -960,43 +989,45 @@ e_mapi_cal_util_bin_to_rrule (const guint8 *lpb, guint32 cb, ECalComponent *comp
                        /* make a shallow clone of comp */
                        detached[i] = e_cal_component_clone (comp);
 
-                       tt = icaltime_from_timet_with_zone (convert_recurrence_minutes_to_timet 
(ei->OriginalStartDate), 0, NULL);
-                       rid.type = E_CAL_COMPONENT_RANGE_SINGLE;
-                       rid.datetime.value = &tt;
-                       rid.datetime.tzid = recur_zone ? icaltimezone_get_tzid (recur_zone) : "UTC";
-                       e_cal_component_set_recurid (detached[i], &rid);
+                       tt = i_cal_time_from_timet_with_zone (convert_recurrence_minutes_to_timet 
(ei->OriginalStartDate), 0, NULL);
+                       rid = e_cal_component_range_new_take (E_CAL_COMPONENT_RANGE_SINGLE,
+                               e_cal_component_datetime_new_take (tt, g_strdup (recur_zone ? 
i_cal_timezone_get_tzid (recur_zone) : "UTC")));
+                       e_cal_component_set_recurid (detached[i], rid);
+                       e_cal_component_range_free (rid);
 
-                       tt = icaltime_from_timet_with_zone (convert_recurrence_minutes_to_timet 
(ei->StartDateTime), 0, NULL);
-                       edt.value = &tt;
-                       edt.tzid = recur_zone ? icaltimezone_get_tzid (recur_zone) : "UTC";
-                       e_cal_component_set_dtstart (detached[i], &edt);
+                       tt = i_cal_time_from_timet_with_zone (convert_recurrence_minutes_to_timet 
(ei->StartDateTime), 0, NULL);
+                       edt = e_cal_component_datetime_new_take (tt, g_strdup (recur_zone ? 
i_cal_timezone_get_tzid (recur_zone) : "UTC"));
+                       e_cal_component_set_dtstart (detached[i], edt);
+                       e_cal_component_datetime_free (edt);
 
-                       tt = icaltime_from_timet_with_zone (convert_recurrence_minutes_to_timet 
(ei->EndDateTime), 0, NULL);
-                       edt.value = &tt;
-                       edt.tzid = recur_zone ? icaltimezone_get_tzid (recur_zone) : "UTC";
-                       e_cal_component_set_dtend (detached[i], &edt);
+                       tt = i_cal_time_from_timet_with_zone (convert_recurrence_minutes_to_timet 
(ei->EndDateTime), 0, NULL);
+                       edt = e_cal_component_datetime_new_take (tt, g_strdup (recur_zone ? 
i_cal_timezone_get_tzid (recur_zone) : "UTC"));
+                       e_cal_component_set_dtend (detached[i], edt);
+                       e_cal_component_datetime_free (edt);
 
-                       e_cal_component_set_rdate_list (detached[i], NULL);
-                       e_cal_component_set_rrule_list (detached[i], NULL);
-                       e_cal_component_set_exdate_list (detached[i], NULL);
-                       e_cal_component_set_exrule_list (detached[i], NULL);
+                       e_cal_component_set_rdates (detached[i], NULL);
+                       e_cal_component_set_rrules (detached[i], NULL);
+                       e_cal_component_set_exdates (detached[i], NULL);
+                       e_cal_component_set_exrules (detached[i], NULL);
 
                        if (ee->WideCharSubject) {
-                               ECalComponentText txt = { 0 };
+                               ECalComponentText *txt;
                                gchar *str;
 
                                str = g_convert (ee->WideCharSubject,
                                                 2 * ee->WideCharSubjectLength,
                                                 "UTF-8", "UTF-16", NULL, NULL,
                                                 NULL);
-                               txt.value = str;
-                               e_cal_component_set_summary (detached[i], &txt);
+                               txt = e_cal_component_text_new (str ? str : "", NULL);
+                               e_cal_component_set_summary (detached[i], txt);
+                               e_cal_component_text_free (txt);
                                g_free (str);
                        } else if (ei->Subject) {
-                               ECalComponentText txt = { 0 };
+                               ECalComponentText *txt;
 
-                               txt.value = ei->Subject;
-                               e_cal_component_set_summary (detached[i], &txt);
+                               txt = e_cal_component_text_new (ei->Subject, NULL);
+                               e_cal_component_set_summary (detached[i], txt);
+                               e_cal_component_text_free (txt);
                        }
 
                        /* FIXME: Handle MeetingType */
@@ -1031,54 +1062,76 @@ e_mapi_cal_util_bin_to_rrule (const guint8 *lpb, guint32 cb, ECalComponent *comp
 
        success = TRUE;
 cleanup:
-       free_arp_contents(&arp);
+       free_arp_contents (&arp);
        return success;
 }
 
 static guint32
 compute_startdate (ECalComponent *comp)
 {
-       ECalComponentDateTime dtstart;
+       ECalComponentDateTime *dtstart;
+       ICalTime *itt;
        guint32 flag32;
 
-       e_cal_component_get_dtstart (comp, &dtstart);
-       dtstart.value->hour = dtstart.value->minute = dtstart.value->second = 0;
-       flag32 = convert_timet_to_recurrence_minutes (icaltime_as_timet_with_zone (*(dtstart.value), 0));
+       dtstart = e_cal_component_get_dtstart (comp);
+       if (!dtstart)
+               return 0;
+
+       itt = e_cal_component_datetime_get_value (dtstart);
+       i_cal_time_set_time (itt, 0, 0, 0);
 
-       e_cal_component_free_datetime (&dtstart);
+       flag32 = convert_timet_to_recurrence_minutes (i_cal_time_as_timet_with_zone (itt, NULL));
+
+       e_cal_component_datetime_free (dtstart);
 
        return flag32;
 }
 
 static guint32
-compute_rdaily_firstdatetime (ECalComponent *comp, guint32 period)
+compute_rdaily_firstdatetime (ECalComponent *comp,
+                             guint32 period)
 {
        return (compute_startdate (comp) % period);
 }
 
 static guint32
-compute_rweekly_firstdatetime (ECalComponent *comp, icalrecurrencetype_weekday week_start, guint32 period)
+compute_rweekly_firstdatetime (ECalComponent *comp,
+                              ICalRecurrenceWeekday week_start,
+                              guint32 period)
 {
-       ECalComponentDateTime dtstart;
+       ECalComponentDateTime *dtstart;
+       ICalTime *itt;
        guint32 flag32;
        gint cur_weekday = 0, weekstart_weekday = 0, diff = 0;
        time_t t;
 
-       e_cal_component_get_dtstart (comp, &dtstart);
-       dtstart.value->hour = dtstart.value->minute = dtstart.value->second = 0;
-       cur_weekday = icaltime_day_of_week (*(dtstart.value));
-       t = icaltime_as_timet_with_zone (*(dtstart.value), 0);
-       e_cal_component_free_datetime (&dtstart);
+       dtstart = e_cal_component_get_dtstart (comp);
+       if (!dtstart)
+               return 0;
+
+       itt = e_cal_component_datetime_get_value (dtstart);
+       i_cal_time_set_time (itt, 0, 0, 0);
+       cur_weekday = i_cal_time_day_of_week (itt);
+       t = i_cal_time_as_timet_with_zone (itt, NULL);
+       e_cal_component_datetime_free (dtstart);
 
        switch (week_start) {
-               case ICAL_SUNDAY_WEEKDAY        : weekstart_weekday = 1; break;
-               case ICAL_MONDAY_WEEKDAY        : weekstart_weekday = 2; break;
-               case ICAL_TUESDAY_WEEKDAY       : weekstart_weekday = 3; break;
-               case ICAL_WEDNESDAY_WEEKDAY     : weekstart_weekday = 4; break;
-               case ICAL_THURSDAY_WEEKDAY      : weekstart_weekday = 5; break;
-               case ICAL_FRIDAY_WEEKDAY        : weekstart_weekday = 6; break;
-               case ICAL_SATURDAY_WEEKDAY      : weekstart_weekday = 7; break;
-               default                         : weekstart_weekday = 1; break;
+       case I_CAL_SUNDAY_WEEKDAY:
+               weekstart_weekday = 1; break;
+       case I_CAL_MONDAY_WEEKDAY:
+               weekstart_weekday = 2; break;
+       case I_CAL_TUESDAY_WEEKDAY:
+               weekstart_weekday = 3; break;
+       case I_CAL_WEDNESDAY_WEEKDAY:
+               weekstart_weekday = 4; break;
+       case I_CAL_THURSDAY_WEEKDAY:
+               weekstart_weekday = 5; break;
+       case I_CAL_FRIDAY_WEEKDAY:
+               weekstart_weekday = 6; break;
+       case I_CAL_SATURDAY_WEEKDAY:
+               weekstart_weekday = 7; break;
+       default:
+               weekstart_weekday = 1; break;
        };
 
        diff = cur_weekday - weekstart_weekday;
@@ -1096,15 +1149,20 @@ compute_rweekly_firstdatetime (ECalComponent *comp, icalrecurrencetype_weekday w
 
 /* The most fucked up algorithm ever conceived by (..you know who..) */
 static guint32
-compute_rmonthly_firstdatetime (ECalComponent *comp, guint32 period)
+compute_rmonthly_firstdatetime (ECalComponent *comp,
+                               guint32 period)
 {
        const guint8 dinm[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
-       ECalComponentDateTime dtstart;
+       ECalComponentDateTime *dtstart;
+       ICalTime *itt;
        guint32 flag32, monthindex, i;
 
-       e_cal_component_get_dtstart (comp, &dtstart);
-       monthindex = (guint32)((((guint64)(12) * (dtstart.value->year - 1601)) + (dtstart.value->month - 1)) 
% period);
-       e_cal_component_free_datetime (&dtstart);
+       dtstart = e_cal_component_get_dtstart (comp);
+       if (!dtstart)
+               return 0;
+       itt = e_cal_component_datetime_get_value (dtstart);
+       monthindex = (guint32)((((guint64)(12) * (i_cal_time_get_year (itt)- 1601)) + (i_cal_time_get_month 
(itt) - 1)) % period);
+       e_cal_component_datetime_free (dtstart);
 
        for (flag32 = 0, i = 0; i < monthindex; ++i)
                flag32 += dinm[(i % 12) + 1] * 24 * 60;
@@ -1113,29 +1171,47 @@ compute_rmonthly_firstdatetime (ECalComponent *comp, guint32 period)
 }
 
 static guint32
-calculate_no_of_occurrences (ECalComponent *comp, const struct icalrecurrencetype *rt)
+calculate_no_of_occurrences (ECalComponent *comp,
+                            ICalRecurrence *rt)
 {
-       ECalComponentDateTime dtstart;
-       icalrecur_iterator *iter;
-       struct icaltimetype next;
+       ECalComponentDateTime *dtstart;
+       ICalRecurIterator *iter;
+       ICalTime *next, *prev = NULL;
        guint32 count = 1;
 
-       e_cal_component_get_dtstart (comp, &dtstart);
+       dtstart = e_cal_component_get_dtstart (comp);
+       if (!dtstart)
+               return 1;
+
+       iter = i_cal_recur_iterator_new (rt, e_cal_component_datetime_get_value (dtstart));
+       if (iter) {
+               for (next = i_cal_recur_iterator_next (iter);
+                    next && !i_cal_time_is_null_time (next);
+                    g_object_unref (next), next = i_cal_recur_iterator_next (iter)) {
+                       if (prev && !i_cal_time_is_null_time (prev) &&
+                           i_cal_time_compare (next, prev) == 0)
+                               break;
+
+                       g_clear_object (&prev);
+                       prev = i_cal_time_new_clone (next);
 
-       for (iter = icalrecur_iterator_new (*rt, *(dtstart.value)),
-            next = icalrecur_iterator_next(iter);
-            !icaltime_is_null_time(next);
-            next = icalrecur_iterator_next(iter))
-               ++count;
+                       count++;
+               }
 
-       icalrecur_iterator_free (iter);
-       e_cal_component_free_datetime (&dtstart);
+               g_clear_object (&iter);
+               g_clear_object (&prev);
+               g_clear_object (&next);
+       }
+
+       e_cal_component_datetime_free (dtstart);
 
        return count;
 }
 
 static gint
-compare_guint32 (gconstpointer a, gconstpointer b, gpointer user_data)
+compare_guint32 (gconstpointer a,
+                gconstpointer b,
+                gpointer user_data)
 {
        return (*((guint32 *) a) - *((guint32 *) b));
 }
@@ -1145,9 +1221,10 @@ e_mapi_cal_util_rrule_to_bin (ECalComponent *comp,
                              struct SBinary_short *bin,
                              TALLOC_CTX *mem_ctx)
 {
-       struct icalrecurrencetype *rt;
+       ICalRecurrence *rt;
+       ICalTime *until;
        gint i;
-       GSList *rrule_list = NULL, *exdate_list = NULL;
+       GSList *rrule_list, *exdate_list;
        GByteArray *ba = NULL;
        struct ema_AppointmentRecurrencePattern arp;
        struct ema_RecurrencePattern *rp; /* Convenience ptr */
@@ -1159,18 +1236,18 @@ e_mapi_cal_util_rrule_to_bin (ECalComponent *comp,
        if (!e_cal_component_has_recurrences (comp))
                return FALSE;
 
-       e_cal_component_get_rrule_list (comp, &rrule_list);
+       rrule_list = e_cal_component_get_rrules (comp);
        if (g_slist_length (rrule_list) != 1) {
-               e_cal_component_free_recur_list (rrule_list);
+               g_slist_free_full (rrule_list, g_object_unref);
                return FALSE;
        }
 
-       e_cal_component_get_exdate_list (comp, &exdate_list);
+       exdate_list = e_cal_component_get_exdates (comp);
 
-       rt = (struct icalrecurrencetype *)(rrule_list->data);
+       rt = rrule_list->data;
 
        ba = g_byte_array_new ();
-       memset(&arp, 0, sizeof (struct ema_AppointmentRecurrencePattern));
+       memset (&arp, 0, sizeof (struct ema_AppointmentRecurrencePattern));
        rp = &arp.RecurrencePattern;
 
        /* Reader Version */
@@ -1180,7 +1257,7 @@ e_mapi_cal_util_rrule_to_bin (ECalComponent *comp,
        /* Calendar Type */
        rp->CalendarType = CAL_DEFAULT;
 
-       if (rt->freq == ICAL_DAILY_RECURRENCE) {
+       if (i_cal_recurrence_get_freq (rt) == I_CAL_DAILY_RECURRENCE) {
                rp->RecurFrequency = RecurFrequency_Daily;
 
                /* Pattern Type - it would be PatternType_Day since we have
@@ -1189,14 +1266,14 @@ e_mapi_cal_util_rrule_to_bin (ECalComponent *comp,
                rp->PatternType = PatternType_Day;
 
                /* FirstDateTime */
-               rp->FirstDateTime = compute_rdaily_firstdatetime (comp, (rt->interval * (60 * 24)));
+               rp->FirstDateTime = compute_rdaily_firstdatetime (comp, (i_cal_recurrence_get_interval (rt) * 
(60 * 24)));
 
                /* INTERVAL */
-               rp->Period = (rt->interval * (60 * 24));
+               rp->Period = (i_cal_recurrence_get_interval (rt) * (60 * 24));
 
                /* No PatternTypeSpecific for PatternType_Day */
 
-       } else if (rt->freq == ICAL_WEEKLY_RECURRENCE) {
+       } else if (i_cal_recurrence_get_freq (rt) == I_CAL_WEEKLY_RECURRENCE) {
                rp->RecurFrequency = RecurFrequency_Weekly;
 
                /* Pattern Type - it would be PatternType_Week since we don't
@@ -1204,56 +1281,56 @@ e_mapi_cal_util_rrule_to_bin (ECalComponent *comp,
                rp->PatternType = PatternType_Week;
 
                /* FirstDateTime */
-               rp->FirstDateTime = compute_rweekly_firstdatetime (comp, rt->week_start, (rt->interval * (60 
* 24 * 7)));
+               rp->FirstDateTime = compute_rweekly_firstdatetime (comp, i_cal_recurrence_get_week_start 
(rt), (i_cal_recurrence_get_interval (rt) * (60 * 24 * 7)));
 
                /* INTERVAL */
-               rp->Period = rt->interval;
+               rp->Period = i_cal_recurrence_get_interval (rt);
 
                /* BITMASK */
-               for (i = 0; i < ICAL_BY_DAY_SIZE; ++i) {
-                       if (rt->by_day[i] == ICAL_SUNDAY_WEEKDAY)
+               for (i = 0; i < I_CAL_BY_DAY_SIZE; ++i) {
+                       if (i_cal_recurrence_get_by_day (rt, i) == I_CAL_SUNDAY_WEEKDAY)
                                rp->PatternTypeSpecific |= olSunday;
-                       else if (rt->by_day[i] == ICAL_MONDAY_WEEKDAY)
+                       else if (i_cal_recurrence_get_by_day (rt, i) == I_CAL_MONDAY_WEEKDAY)
                                rp->PatternTypeSpecific |= olMonday;
-                       else if (rt->by_day[i] == ICAL_TUESDAY_WEEKDAY)
+                       else if (i_cal_recurrence_get_by_day (rt, i) == I_CAL_TUESDAY_WEEKDAY)
                                rp->PatternTypeSpecific |= olTuesday;
-                       else if (rt->by_day[i] == ICAL_WEDNESDAY_WEEKDAY)
+                       else if (i_cal_recurrence_get_by_day (rt, i) == I_CAL_WEDNESDAY_WEEKDAY)
                                rp->PatternTypeSpecific |= olWednesday;
-                       else if (rt->by_day[i] == ICAL_THURSDAY_WEEKDAY)
+                       else if (i_cal_recurrence_get_by_day (rt, i) == I_CAL_THURSDAY_WEEKDAY)
                                rp->PatternTypeSpecific |= olThursday;
-                       else if (rt->by_day[i] == ICAL_FRIDAY_WEEKDAY)
+                       else if (i_cal_recurrence_get_by_day (rt, i) == I_CAL_FRIDAY_WEEKDAY)
                                rp->PatternTypeSpecific |= olFriday;
-                       else if (rt->by_day[i] == ICAL_SATURDAY_WEEKDAY)
+                       else if (i_cal_recurrence_get_by_day (rt, i) == I_CAL_SATURDAY_WEEKDAY)
                                rp->PatternTypeSpecific |= olSaturday;
                        else
                                break;
                }
 
-       } else if (rt->freq == ICAL_MONTHLY_RECURRENCE) {
+       } else if (i_cal_recurrence_get_freq (rt) == I_CAL_MONTHLY_RECURRENCE) {
                guint16 pattern = 0x0; guint32 mask = 0x0, flag = 0x0;
 
                rp->RecurFrequency = RecurFrequency_Monthly;
 
-               if (rt->by_month_day[0] >= 1 && rt->by_month_day[0] <= 31) {
+               if (i_cal_recurrence_get_by_month_day (rt, 0) >= 1 && i_cal_recurrence_get_by_month_day (rt, 
0) <= 31) {
                        pattern = PatternType_Month;
-                       flag = rt->by_month_day[0];
-               } else if (rt->by_month_day[0] == -1) {
+                       flag = i_cal_recurrence_get_by_month_day (rt, 0);
+               } else if (i_cal_recurrence_get_by_month_day (rt, 0) == -1) {
                        pattern = PatternType_MonthNth;
                        mask = (olSunday | olMonday | olTuesday | olWednesday | olThursday | olFriday | 
olSaturday);
                        flag = RecurrenceN_Last;
-               } else if (rt->by_day[0] >= ICAL_SUNDAY_WEEKDAY && rt->by_day[0] <= ICAL_SATURDAY_WEEKDAY) {
+               } else if (i_cal_recurrence_get_by_day (rt, 0) >= I_CAL_SUNDAY_WEEKDAY && 
i_cal_recurrence_get_by_day (rt, 0) <= I_CAL_SATURDAY_WEEKDAY) {
                        pattern = PatternType_MonthNth;
-                       mask = get_mapi_day (rt->by_day[0]);
-                       flag = get_mapi_pos (rt->by_set_pos[0]);
+                       mask = get_mapi_day (i_cal_recurrence_get_by_day (rt, 0));
+                       flag = get_mapi_pos (i_cal_recurrence_get_by_set_pos (rt, 0));
                }
 
                rp->PatternType = pattern;
 
                /* FirstDateTime */
-               rp->FirstDateTime = compute_rmonthly_firstdatetime (comp, rt->interval);
+               rp->FirstDateTime = compute_rmonthly_firstdatetime (comp, i_cal_recurrence_get_interval (rt));
 
                /* INTERVAL */
-               rp->Period = rt->interval;
+               rp->Period = i_cal_recurrence_get_interval (rt);
 
                if (pattern == PatternType_Month) {
                        rp->N = flag;
@@ -1270,7 +1347,7 @@ e_mapi_cal_util_rrule_to_bin (ECalComponent *comp,
                        g_warning ("Possibly setting incorrect values in the stream. ");
                }
 
-       } else if (rt->freq == ICAL_YEARLY_RECURRENCE) {
+       } else if (i_cal_recurrence_get_freq (rt) == I_CAL_YEARLY_RECURRENCE) {
                rp->RecurFrequency = RecurFrequency_Yearly;
 
                /* Pattern Type - it would be PatternType_Month since we don't
@@ -1286,26 +1363,31 @@ e_mapi_cal_util_rrule_to_bin (ECalComponent *comp,
 
                /* MONTH_DAY */
                {
-                       ECalComponentDateTime dtstart;
-                       e_cal_component_get_dtstart (comp, &dtstart);
-                       rp->PatternTypeSpecific = dtstart.value->day;
-                       e_cal_component_free_datetime (&dtstart);
+                       ECalComponentDateTime *dtstart;
+                       dtstart = e_cal_component_get_dtstart (comp);
+                       rp->PatternTypeSpecific = (dtstart && e_cal_component_datetime_get_value (dtstart)) ?
+                               i_cal_time_get_day (e_cal_component_datetime_get_value (dtstart)) : 0;
+                       e_cal_component_datetime_free (dtstart);
                }
        }
 
+       until = i_cal_recurrence_get_until (rt);
+
        /* End Type followed by Occurence count */
-       if (!icaltime_is_null_time (rt->until)) {
+       if (until && !i_cal_time_is_null_time (until)) {
                rp->EndType = END_AFTER_DATE;
                rp->OccurrenceCount = calculate_no_of_occurrences (comp, rt);
-       } else if (rt->count) {
+       } else if (i_cal_recurrence_get_count (rt)) {
                rp->EndType = END_AFTER_N_OCCURRENCES;
-               rp->OccurrenceCount = rt->count;
+               rp->OccurrenceCount = i_cal_recurrence_get_count (rt);
        } else {
                rp->EndType = END_NEVER_END;
        }
 
+       g_clear_object (&until);
+
        /* FirstDOW */
-       rp->FirstDOW = get_mapi_weekstart (rt->week_start);
+       rp->FirstDOW = get_mapi_weekstart (i_cal_recurrence_get_week_start (rt));
 
        /* DeletedInstanceDates */
        rp->DeletedInstanceCount = g_slist_length (exdate_list);
@@ -1316,9 +1398,17 @@ e_mapi_cal_util_rrule_to_bin (ECalComponent *comp,
                                              rp->DeletedInstanceCount);
                /* FIXME: This should include modified dates */
                for (i = 0, l = exdate_list; l; ++i, l = l->next) {
-                       dt = (ECalComponentDateTime *)(l->data);
-                       dt->value->hour = dt->value->minute = dt->value->second = 0;
-                       rp->DeletedInstanceDates[i] = convert_timet_to_recurrence_minutes 
(icaltime_as_timet_with_zone (*(dt->value), 0));
+                       ICalTime *itt;
+
+                       dt = l->data;
+
+                       itt = e_cal_component_datetime_get_value (dt);
+                       if (!itt)
+                               continue;
+
+                       i_cal_time_set_time (itt, 0, 0, 0);
+
+                       rp->DeletedInstanceDates[i] = convert_timet_to_recurrence_minutes 
(i_cal_time_as_timet_with_zone (itt, NULL));
                }
 
                g_qsort_with_data (rp->DeletedInstanceDates,
@@ -1338,25 +1428,31 @@ e_mapi_cal_util_rrule_to_bin (ECalComponent *comp,
                        /* FIXME: named prop here? */
                        rp->EndDate = 0x5AE980DF;
                else if (rp->EndType == END_AFTER_N_OCCURRENCES) {
-                       ECalComponentDateTime dtstart;
-                       gchar *rrule_str = icalrecurrencetype_as_string_r (rt);
-                       time_t *array = g_new0 (time_t, rt->count);
-
-                       e_cal_component_get_dtstart (comp, &dtstart);
-                       dtstart.value->hour = dtstart.value->minute = dtstart.value->second = 0;
-
-                       icalrecur_expand_recurrence (rrule_str, icaltime_as_timet_with_zone 
(*(dtstart.value), 0), rt->count, array);
-
-                       rp->EndDate = convert_timet_to_recurrence_minutes (array[(rt->count) - 1]);
+                       ECalComponentDateTime *dtstart;
+                       ICalTime *itt;
+                       gchar *rrule_str = i_cal_recurrence_as_string_r (rt);
+                       GArray *array;
+
+                       dtstart = e_cal_component_get_dtstart (comp);
+                       itt = e_cal_component_datetime_get_value (dtstart);
+                       i_cal_time_set_time (itt, 0, 0, 0);
+
+                       array = i_cal_recur_expand_recurrence (rrule_str, i_cal_time_as_timet_with_zone (itt, 
NULL), i_cal_recurrence_get_count (rt));
+                       if (array) {
+                               rp->EndDate = convert_timet_to_recurrence_minutes (g_array_index (array, 
time_t, i_cal_recurrence_get_count (rt) - 1));
+                               g_array_unref (array);
+                       } else {
+                               g_warn_if_reached ();
+                       }
 
-                       g_free (array);
                        g_free (rrule_str);
-                       e_cal_component_free_datetime (&dtstart);
+                       e_cal_component_datetime_free (dtstart);
                } else if (rp->EndType == END_AFTER_DATE) {
-                       struct icaltimetype until;
-                       memcpy (&until, &(rt->until), sizeof(struct icaltimetype));
-                       until.hour = until.minute = until.second = 0;
-                       rp->EndDate = convert_timet_to_recurrence_minutes (icaltime_as_timet_with_zone 
(until, 0));
+                       until = i_cal_recurrence_get_until (rt);
+                       i_cal_time_set_time (until, 0, 0, 0);
+
+                       rp->EndDate = convert_timet_to_recurrence_minutes (i_cal_time_as_timet_with_zone 
(until, NULL));
+                       g_clear_object (&until);
                }
        }
 
@@ -1367,29 +1463,36 @@ e_mapi_cal_util_rrule_to_bin (ECalComponent *comp,
 
        /* StartTimeOffset */
        {
-               ECalComponentDateTime dtstart;
-               e_cal_component_get_dtstart (comp, &dtstart);
-               arp.StartTimeOffset = (dtstart.value->hour * 60) + dtstart.value->minute;
-               e_cal_component_free_datetime (&dtstart);
+               ECalComponentDateTime *dtstart;
+               ICalTime *itt;
+
+               dtstart = e_cal_component_get_dtstart (comp);
+               itt = e_cal_component_datetime_get_value (dtstart);
+
+               arp.StartTimeOffset = (i_cal_time_get_hour (itt) * 60) + i_cal_time_get_minute (itt);
+               e_cal_component_datetime_free (dtstart);
        }
 
        /* EndTimeOffset */
        {
-               ECalComponentDateTime dtend;
-               e_cal_component_get_dtend (comp, &dtend);
-               arp.EndTimeOffset = (dtend.value->hour * 60) + dtend.value->minute;
-               e_cal_component_free_datetime (&dtend);
+               ECalComponentDateTime *dtend;
+               ICalTime *itt;
+
+               dtend = e_cal_component_get_dtend (comp);
+               itt = e_cal_component_datetime_get_value (dtend);
+               arp.EndTimeOffset = (i_cal_time_get_hour (itt) * 60) + i_cal_time_get_minute (itt);
+               e_cal_component_datetime_free (dtend);
        }
 
        /* FIXME: Add ExceptionInfo here */
        /* FIXME: Add the ExtendedExceptionInfo here */
 
        /* Reserved Block 2 Size */
-       arp_to_gba(&arp, ba);
+       arp_to_gba (&arp, ba);
 
-       free_arp_contents(&arp);
-       e_cal_component_free_exdate_list (exdate_list);
-       e_cal_component_free_recur_list (rrule_list);
+       free_arp_contents (&arp);
+       g_slist_free_full (exdate_list, e_cal_component_datetime_free);
+       g_slist_free_full (rrule_list, g_object_unref);
 
        /*g_print ("\n== ICAL to MAPI == The recurrence blob data is as follows:\n");
        for (i = 0; i < ba->len; ++i)
@@ -1403,4 +1506,3 @@ e_mapi_cal_util_rrule_to_bin (ECalComponent *comp,
 
        return TRUE;
 }
-
diff --git a/src/libexchangemapi/e-mapi-cal-recur-utils.h b/src/libexchangemapi/e-mapi-cal-recur-utils.h
index 54f9058..17bfb01 100644
--- a/src/libexchangemapi/e-mapi-cal-recur-utils.h
+++ b/src/libexchangemapi/e-mapi-cal-recur-utils.h
@@ -35,7 +35,7 @@ gboolean      e_mapi_cal_util_bin_to_rrule    (const guint8 *lpb,
                                                 guint32 cb,
                                                 ECalComponent *comp,
                                                 GSList **extra_detached,
-                                                icaltimezone *recur_zone);
+                                                ICalTimezone *recur_zone);
 
 gboolean       e_mapi_cal_util_rrule_to_bin    (ECalComponent *comp,
                                                 struct SBinary_short *bin,
diff --git a/src/libexchangemapi/e-mapi-cal-tz-utils.c b/src/libexchangemapi/e-mapi-cal-tz-utils.c
index 32dba1d..25fb0da 100644
--- a/src/libexchangemapi/e-mapi-cal-tz-utils.c
+++ b/src/libexchangemapi/e-mapi-cal-tz-utils.c
@@ -79,40 +79,34 @@ e_mapi_cal_tz_util_get_ical_equivalent (const gchar *mapi_tz_location)
        return retval;
 }
 
-static struct icaltimetype
-e_mapi_tm_to_icaltimetype (struct tm *tm,
-                          gboolean dst)
+static ICalTime *
+e_mapi_tm_to_icaltime (struct tm *tm,
+                      gboolean dst)
 {
-       struct icaltimetype itt;
+       ICalTime *itt;
 
-       memset (&itt, 0, sizeof (struct icaltimetype));
-
-       itt.second = 0;
-       itt.minute = 0;
-       itt.hour = 0;
-
-       itt.day = 1;
-       itt.month = dst ? 6 : 1;
-       itt.year = tm->tm_year + 1900;
-
-       itt.zone = NULL;
-       itt.is_date = 0;
+       itt = i_cal_time_null_time ();
+       i_cal_time_set_time (itt, 0, 0, 0);
+       i_cal_time_set_date (itt, tm->tm_year + 1900, dst ? 6 : 1, 1);
+       i_cal_time_set_timezone (itt, NULL);
+       i_cal_time_set_is_date (itt, FALSE);
 
        return itt;
 }
 
 static gint
-get_offset (icaltimezone *zone,
+get_offset (ICalTimezone *zone,
            gboolean dst)
 {
        struct tm local;
-       struct icaltimetype tt;
+       ICalTime *itt;
        gint offset;
        time_t now = time (NULL);
 
        gmtime_r (&now, &local);
-       tt = e_mapi_tm_to_icaltimetype (&local, dst);
-       offset = icaltimezone_get_utc_offset (zone, &tt, NULL);
+       itt = e_mapi_tm_to_icaltime (&local, dst);
+       offset = i_cal_timezone_get_utc_offset (zone, itt, NULL);
+       g_clear_object (&itt);
 
        return offset / -60;
 }
@@ -145,10 +139,10 @@ e_mapi_cal_tz_util_ical_from_zone_struct (const guint8 *lpb,
        g_hash_table_iter_init (&iter, mapi_to_ical);
        while (g_hash_table_iter_next (&iter, &key, &value)) {
                const gchar *location = value;
-               icaltimezone *zone;
+               ICalTimezone *zone;
                gint offset;
 
-               zone = icaltimezone_get_builtin_timezone (location);
+               zone = i_cal_timezone_get_builtin_timezone (location);
                if (!zone)
                        continue;
 
@@ -295,36 +289,43 @@ e_mapi_cal_tz_util_populate (void)
 static void
 e_mapi_cal_tz_util_dump_ical_tzs (void)
 {
-       guint i;
-       icalarray *zones;
+       gint ii, nelems;
+       ICalArray *zones;
        GList *l, *list_items = NULL;
 
        /* Get the array of builtin timezones. */
-       zones = icaltimezone_get_builtin_timezones ();
+       zones = i_cal_timezone_get_builtin_timezones ();
+       nelems = i_cal_array_size (zones);
 
        g_message("%s: %s: ", G_STRLOC, G_STRFUNC);
-       for (i = 0; i < zones->num_elements; i++) {
-               icaltimezone *zone;
+
+       for (ii = 0; ii < nelems; ii++) {
+               ICalTimezone *zone;
                const gchar *tzid = NULL;
 
-               zone = icalarray_element_at (zones, i);
+               zone = i_cal_timezone_array_element_at (zones, ii);
+               if (!zone)
+                       continue;
 
-               tzid = icaltimezone_get_tzid (zone);
+               tzid = i_cal_timezone_get_tzid (zone);
+               if (tzid)
+                       list_items = g_list_prepend (list_items, g_strdup (tzid));
 
-               list_items = g_list_prepend (list_items, (gpointer)tzid);
+               g_object_unref (zone);
        }
 
        list_items = g_list_sort (list_items, (GCompareFunc) g_ascii_strcasecmp);
 
        /* Put the "UTC" entry at the top of the combo's list. */
-       list_items = g_list_prepend (list_items, (gpointer)"UTC");
+       list_items = g_list_prepend (list_items, g_strdup ("UTC"));
 
-       for (l = list_items, i = 0; l != NULL; l = l->next, ++i)
-               g_print ("[%3d]\t%s\n", (i+1), (gchar *)(l->data));
+       for (l = list_items, ii = 0; l != NULL; l = l->next, ++ii) {
+               g_print ("[%3d]\t%s\n", (ii + 1), (gchar *)(l->data));
+       }
 
-//     icaltimezone_free_builtin_timezones ();
+       /* i_cal_timezone_free_builtin_timezones (); */
 
-       g_list_free (list_items);
+       g_list_free_full (list_items, g_free);
 }
 
 void
@@ -375,36 +376,36 @@ e_mapi_cal_tz_util_dump (void)
 
 static void
 write_icaltime_as_systemtime (GByteArray *ba,
-                             struct icaltimetype icaltime)
+                             ICalTime *itt)
 {
        guint16 flag16;
 
        /* wYear */
-       flag16 = icaltime.year;
+       flag16 = i_cal_time_get_year (itt);
        g_byte_array_append (ba, (const guint8 *) &flag16, sizeof (guint16));
 
        /* wMonth */
-       flag16 = icaltime.month;
+       flag16 = i_cal_time_get_month (itt);
        g_byte_array_append (ba, (const guint8 *) &flag16, sizeof (guint16));
 
        /* wDayOfWeek */
-       flag16 = icaltime.year == 0 ? 0 : icaltime_day_of_week (icaltime);
+       flag16 = i_cal_time_get_year (itt) == 0 ? 0 : i_cal_time_day_of_week (itt);
        g_byte_array_append (ba, (const guint8 *) &flag16, sizeof (guint16));
 
        /* wDay */
-       flag16 = icaltime.day;
+       flag16 = i_cal_time_get_day (itt);
        g_byte_array_append (ba, (const guint8 *) &flag16, sizeof (guint16));
 
        /* wHour */
-       flag16 = icaltime.hour;
+       flag16 = i_cal_time_get_hour (itt);
        g_byte_array_append (ba, (const guint8 *) &flag16, sizeof (guint16));
 
        /* wMinute */
-       flag16 = icaltime.minute;
+       flag16 = i_cal_time_get_minute (itt);
        g_byte_array_append (ba, (const guint8 *) &flag16, sizeof (guint16));
 
        /* wSecond */
-       flag16 = icaltime.second;
+       flag16 = i_cal_time_get_second (itt);
        g_byte_array_append (ba, (const guint8 *) &flag16, sizeof (guint16));
 
        /* wMilliseconds */
@@ -418,8 +419,8 @@ write_tz_rule (GByteArray *ba,
               guint32 bias,
               guint32 standard_bias,
               guint32 daylight_bias,
-              struct icaltimetype standard_date,
-              struct icaltimetype daylight_date)
+              ICalTime *standard_date,
+              ICalTime *daylight_date)
 {
        guint8 flag8;
        guint16 flag16;
@@ -445,7 +446,7 @@ write_tz_rule (GByteArray *ba,
        g_byte_array_append (ba, (const guint8 *) &flag16, sizeof (guint16));
 
        /* wYear */
-       flag16 = standard_date.year;
+       flag16 = i_cal_time_get_year (standard_date);
        g_byte_array_append (ba, (const guint8 *) &flag16, sizeof (guint16));
 
        /* X - 14 times 0x00 */
@@ -471,35 +472,37 @@ write_tz_rule (GByteArray *ba,
 }
 
 static void
-extract_bias_and_date (icalcomponent *comp,
+extract_bias_and_date (ICalComponent *icomp,
                       guint32 *bias,
-                      struct icaltimetype *start)
+                      ICalTime **start)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
        gint tzoffset;
 
-       g_return_if_fail (comp != NULL);
+       g_return_if_fail (icomp != NULL);
        g_return_if_fail (bias != NULL);
        g_return_if_fail (start != NULL);
 
-       prop = icalcomponent_get_first_property (comp, ICAL_TZOFFSETTO_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_TZOFFSETTO_PROPERTY);
        if (prop)
-               tzoffset = icalproperty_get_tzoffsetto (prop);
+               tzoffset = i_cal_property_get_tzoffsetto (prop);
        else
                tzoffset = 0;
 
        *bias = tzoffset / 60;
-       *start = icalcomponent_get_dtstart (comp);
+       *start = i_cal_component_get_dtstart (icomp);
+
+       g_clear_object (&prop);
 }
 
 static void
 write_tz_rule_comps (GByteArray *ba,
                     gboolean is_recur,
-                    icalcomponent *standardcomp,
-                    icalcomponent *daylightcomp,
-                    icaltimezone *zone)
+                    ICalComponent *standardcomp,
+                    ICalComponent *daylightcomp,
+                    ICalTimezone *zone)
 {
-       struct icaltimetype standard_date, daylight_date, current_time;
+       ICalTime *standard_date, *daylight_date, *current_time;
        guint32 bias, standard_bias, daylight_bias;
 
        g_return_if_fail (ba != NULL);
@@ -509,56 +512,65 @@ write_tz_rule_comps (GByteArray *ba,
        extract_bias_and_date (standardcomp, &standard_bias, &standard_date);
        extract_bias_and_date (daylightcomp, &daylight_bias, &daylight_date);
 
-       current_time = icaltime_current_time_with_zone (zone);
-       bias = current_time.is_daylight ? daylight_bias : standard_bias;
+       current_time = i_cal_time_current_time_with_zone (zone);
+       bias = i_cal_time_is_daylight (current_time) ? daylight_bias : standard_bias;
 
        write_tz_rule (ba, is_recur, bias, standard_bias, daylight_bias, standard_date, daylight_date);
+
+       g_clear_object (&standard_date);
+       g_clear_object (&daylight_date);
+       g_clear_object (&current_time);
 }
 
 static void
 add_timezone_rules (GByteArray *ba,
                    gboolean is_recur,
-                   icalcomponent *vtimezone,
-                   icaltimezone *zone)
+                   ICalComponent *vtimezone,
+                   ICalTimezone *zone)
 {
        gboolean any_added = FALSE;
 
        g_return_if_fail (ba != NULL);
 
        if (vtimezone) {
-               icalcomponent *subcomp, *standardcomp = NULL, *daylightcomp = NULL;
+               ICalComponent *subcomp, *standardcomp = NULL, *daylightcomp = NULL;
 
-               for (subcomp = icalcomponent_get_first_component (vtimezone, ICAL_ANY_COMPONENT);
+               for (subcomp = i_cal_component_get_first_component (vtimezone, I_CAL_ANY_COMPONENT);
                     subcomp;
-                    subcomp = icalcomponent_get_next_component (vtimezone, ICAL_ANY_COMPONENT)) {
-                       if (icalcomponent_isa (subcomp) == ICAL_XSTANDARD_COMPONENT)
-                               standardcomp = subcomp;
-                       if (icalcomponent_isa (subcomp) == ICAL_XDAYLIGHT_COMPONENT)
-                               daylightcomp = subcomp;
+                    g_object_unref (subcomp), subcomp = i_cal_component_get_next_component (vtimezone, 
I_CAL_ANY_COMPONENT)) {
+                       if (i_cal_component_isa (subcomp) == I_CAL_XSTANDARD_COMPONENT)
+                               standardcomp = g_object_ref (subcomp);
+                       if (i_cal_component_isa (subcomp) == I_CAL_XDAYLIGHT_COMPONENT)
+                               daylightcomp = g_object_ref (subcomp);
                        if (standardcomp && daylightcomp) {
                                write_tz_rule_comps (ba, is_recur, standardcomp, daylightcomp, zone);
 
                                any_added = TRUE;
-                               standardcomp = NULL;
-                               daylightcomp = NULL;
+                               g_clear_object (&standardcomp);
+                               g_clear_object (&daylightcomp);
                        }
                }
 
                if (standardcomp || daylightcomp) {
                        if (!standardcomp)
-                               standardcomp = daylightcomp;
+                               standardcomp = g_object_ref (daylightcomp);
                        write_tz_rule_comps (ba, is_recur, standardcomp, daylightcomp, zone);
                        any_added = TRUE;
                }
+
+               g_clear_object (&standardcomp);
+               g_clear_object (&daylightcomp);
        }
 
        /* at least one should be always added, make it UTC */
        if (!any_added) {
-               struct icaltimetype fake_utc;
+               ICalTime *fake_utc;
 
-               memset (&fake_utc, 0, sizeof (struct icaltimetype));
+               fake_utc = i_cal_time_null_time ();
 
                write_tz_rule (ba, is_recur, 0, 0, 0, fake_utc, fake_utc);
+
+               g_object_unref (fake_utc);
        }
 }
 
@@ -579,19 +591,19 @@ e_mapi_cal_util_mapi_tz_to_bin (const gchar *mapi_tzid,
        guint16 flag16;
        gunichar2 *buf;
        glong items_written;
-       icaltimezone *zone = NULL;
-       icalcomponent *vtimezone;
+       ICalTimezone *zone = NULL;
+       ICalComponent *vtimezone;
        gint rules = 0;
        const gchar *ical_location = e_mapi_cal_tz_util_get_ical_equivalent (mapi_tzid);
 
        if (ical_location && *ical_location)
-               zone = icaltimezone_get_builtin_timezone (ical_location);
+               zone = i_cal_timezone_get_builtin_timezone (ical_location);
        if (!zone)
-               zone = icaltimezone_get_utc_timezone ();
-       vtimezone = icaltimezone_get_component (zone);
+               zone = i_cal_timezone_get_utc_timezone ();
+       vtimezone = i_cal_timezone_get_component (zone);
        if (vtimezone)
-               rules = (icalcomponent_count_components (vtimezone, ICAL_XSTANDARD_COMPONENT) + 
-                        icalcomponent_count_components (vtimezone, ICAL_XDAYLIGHT_COMPONENT)) / 2;
+               rules = (i_cal_component_count_components (vtimezone, I_CAL_XSTANDARD_COMPONENT) +
+                        i_cal_component_count_components (vtimezone, I_CAL_XDAYLIGHT_COMPONENT)) / 2;
        if (!rules)
                rules = 1;
 
@@ -636,10 +648,12 @@ e_mapi_cal_util_mapi_tz_to_bin (const gchar *mapi_tzid,
                g_print("0x%.2X ", ba->data[i]));
 
        g_byte_array_free (ba, TRUE);
+       g_clear_object (&vtimezone);
 }
 
 gchar *
-e_mapi_cal_util_bin_to_mapi_tz (const guint8 *lpb, guint32 cb)
+e_mapi_cal_util_bin_to_mapi_tz (const guint8 *lpb,
+                               guint32 cb)
 {
        guint8 flag8;
        guint16 flag16, cbHeader = 0;
@@ -815,24 +829,24 @@ nth_day_of_month (int year, int month, int wday, int ordinal)
 
 /* return the most-correct PidLidTimeZone value w.r.t. OXOCAL 2.2.5.6. */
 int
-e_mapi_cal_util_mapi_tz_pidlidtimezone (icaltimezone *ictz)
+e_mapi_cal_util_mapi_tz_pidlidtimezone (ICalTimezone *ictz)
 {
        gboolean tz_dst_now = FALSE, tz_has_dst = FALSE;
        int i, utc_offset = 0, best_index = 0, best_score = -1;
-       const char *tznames;
-       icaltimetype tt;
+       const gchar *tznames;
+       ICalTime *tt;
 
        if (ictz == NULL)
                return 0;
 
        /* Simple hack to determine if our TZ has DST */
-       tznames = icaltimezone_get_tznames (ictz);
+       tznames = i_cal_timezone_get_tznames (ictz);
        if (tznames && strchr (tznames, '/'))
                tz_has_dst = TRUE;
 
        /* Calculate minutes east of UTC, what MS uses in this spec */
-       tt = icaltime_current_time_with_zone (ictz);
-       utc_offset = icaltimezone_get_utc_offset (ictz, &tt, &tz_dst_now) / 60;
+       tt = i_cal_time_current_time_with_zone (ictz);
+       utc_offset = i_cal_timezone_get_utc_offset (ictz, tt, &tz_dst_now) / 60;
        if (tz_dst_now)
                utc_offset -= 60;
 
@@ -848,7 +862,7 @@ e_mapi_cal_util_mapi_tz_pidlidtimezone (icaltimezone *ictz)
                        score = 1;
 
                if (score && tz_has_dst) {
-                       sdt = nth_day_of_month (tt.year, pme->standard_wMonth,
+                       sdt = nth_day_of_month (i_cal_time_get_year (tt), pme->standard_wMonth,
                                                pme->standard_wDayOfWeek,
                                                pme->standard_wDay);
                        /* add the transition hour and a second */
@@ -856,7 +870,7 @@ e_mapi_cal_util_mapi_tz_pidlidtimezone (icaltimezone *ictz)
                        pre_sdt = sdt - 2 * 60 * 60;
                        post_sdt = sdt + 2 * 60 * 60;
 
-                       dst = nth_day_of_month (tt.year, pme->daylight_wMonth,
+                       dst = nth_day_of_month (i_cal_time_get_year (tt), pme->daylight_wMonth,
                                                pme->daylight_wDayOfWeek,
                                                pme->daylight_wDay);
                        dst += (pme->daylight_wHour * 60 * 60) + 1;
@@ -892,5 +906,7 @@ e_mapi_cal_util_mapi_tz_pidlidtimezone (icaltimezone *ictz)
                }
        }
 
+       g_clear_object (&tt);
+
        return best_index;
 }
diff --git a/src/libexchangemapi/e-mapi-cal-tz-utils.h b/src/libexchangemapi/e-mapi-cal-tz-utils.h
index b4d792b..07877fe 100644
--- a/src/libexchangemapi/e-mapi-cal-tz-utils.h
+++ b/src/libexchangemapi/e-mapi-cal-tz-utils.h
@@ -42,7 +42,7 @@ void          e_mapi_cal_util_mapi_tz_to_bin          (const gchar *mapi_tzid,
                                                         struct SBinary_short *bin,
                                                         TALLOC_CTX *mem_ctx,
                                                         gboolean is_recur);
-int            e_mapi_cal_util_mapi_tz_pidlidtimezone  (icaltimezone *ictz);
+int            e_mapi_cal_util_mapi_tz_pidlidtimezone  (ICalTimezone *ictz);
 gchar *                e_mapi_cal_util_bin_to_mapi_tz          (const guint8 *lpb, guint32 cb);
 
 G_END_DECLS
diff --git a/src/libexchangemapi/e-mapi-cal-utils.c b/src/libexchangemapi/e-mapi-cal-utils.c
index 105f406..5f82cc7 100644
--- a/src/libexchangemapi/e-mapi-cal-utils.c
+++ b/src/libexchangemapi/e-mapi-cal-utils.c
@@ -46,126 +46,156 @@
 #define DEFAULT_TASK_REMINDER_MINS 1080
 
 
-static icalparameter_role
+static ICalParameterRole
 get_role_from_type (OlMailRecipientType type)
 {
        switch (type) {
-               case olCC   : return ICAL_ROLE_OPTPARTICIPANT;
-               case olOriginator :
-               case olTo   :
-               case olBCC  :
-               default     : return ICAL_ROLE_REQPARTICIPANT;
+       case olCC:
+               return I_CAL_ROLE_OPTPARTICIPANT;
+       case olOriginator:
+       case olTo:
+       case olBCC:
+       default:
+               return I_CAL_ROLE_REQPARTICIPANT;
        }
 }
 
 static OlMailRecipientType
-get_type_from_role (icalparameter_role role)
+get_type_from_role (ICalParameterRole role)
 {
        switch (role) {
-               case ICAL_ROLE_OPTPARTICIPANT   : return olCC;
-               case ICAL_ROLE_CHAIR            :
-               case ICAL_ROLE_REQPARTICIPANT   :
-               case ICAL_ROLE_NONPARTICIPANT   :
-               default                         : return olTo;
+       case I_CAL_ROLE_OPTPARTICIPANT:
+               return olCC;
+       case I_CAL_ROLE_CHAIR:
+       case I_CAL_ROLE_REQPARTICIPANT:
+       case I_CAL_ROLE_NONPARTICIPANT:
+       default:
+               return olTo;
        }
 }
 
-static icalparameter_partstat
+static ICalParameterPartstat
 get_partstat_from_trackstatus (uint32_t trackstatus)
 {
        switch (trackstatus) {
-               case olResponseOrganized :
-               case olResponseAccepted  : return ICAL_PARTSTAT_ACCEPTED;
-               case olResponseTentative : return ICAL_PARTSTAT_TENTATIVE;
-               case olResponseDeclined  : return ICAL_PARTSTAT_DECLINED;
-               default                 : return ICAL_PARTSTAT_NEEDSACTION;
+       case olResponseOrganized:
+       case olResponseAccepted:
+               return I_CAL_PARTSTAT_ACCEPTED;
+       case olResponseTentative:
+               return I_CAL_PARTSTAT_TENTATIVE;
+       case olResponseDeclined:
+               return I_CAL_PARTSTAT_DECLINED;
+       default:
+               return I_CAL_PARTSTAT_NEEDSACTION;
        }
 }
 
 static uint32_t
-get_trackstatus_from_partstat (icalparameter_partstat partstat)
+get_trackstatus_from_partstat (ICalParameterPartstat partstat)
 {
        switch (partstat) {
-               case ICAL_PARTSTAT_ACCEPTED     : return olResponseAccepted;
-               case ICAL_PARTSTAT_TENTATIVE    : return olResponseTentative;
-               case ICAL_PARTSTAT_DECLINED     : return olResponseDeclined;
-               default                         : return olResponseNone;
+       case I_CAL_PARTSTAT_ACCEPTED:
+               return olResponseAccepted;
+       case I_CAL_PARTSTAT_TENTATIVE:
+               return olResponseTentative;
+       case I_CAL_PARTSTAT_DECLINED:
+               return olResponseDeclined;
+       default:
+               return olResponseNone;
        }
 }
 
-static icalproperty_transp
+static ICalPropertyTransp
 get_transp_from_prop (uint32_t prop)
 {
        /* FIXME: is this mapping correct ? */
        switch (prop) {
-               case olFree             :
-               case olTentative        : return ICAL_TRANSP_TRANSPARENT;
-               case olBusy             :
-               case olOutOfOffice      :
-               default                 : return ICAL_TRANSP_OPAQUE;
+       case olFree:
+       case olTentative:
+               return I_CAL_TRANSP_TRANSPARENT;
+       case olBusy:
+       case olOutOfOffice:
+       default:
+               return I_CAL_TRANSP_OPAQUE;
        }
 }
 
 static uint32_t
-get_prop_from_transp (icalproperty_transp transp)
+get_prop_from_transp (ICalPropertyTransp transp)
 {
        /* FIXME: is this mapping correct ? */
        switch (transp) {
-               case ICAL_TRANSP_TRANSPARENT            :
-               case ICAL_TRANSP_TRANSPARENTNOCONFLICT  : return olFree;
-               case ICAL_TRANSP_OPAQUE                 :
-               case ICAL_TRANSP_OPAQUENOCONFLICT       :
-               default                                 : return olBusy;
+       case I_CAL_TRANSP_TRANSPARENT:
+       case I_CAL_TRANSP_TRANSPARENTNOCONFLICT:
+               return olFree;
+       case I_CAL_TRANSP_OPAQUE:
+       case I_CAL_TRANSP_OPAQUENOCONFLICT:
+       default:
+               return olBusy;
        }
 }
 
-static icalproperty_status
+static ICalPropertyStatus
 get_taskstatus_from_prop (uint32_t prop)
 {
        /* FIXME: is this mapping correct ? */
        switch (prop) {
-               case olTaskComplete     : return ICAL_STATUS_COMPLETED;
-               case olTaskWaiting      :
-               case olTaskInProgress   : return ICAL_STATUS_INPROCESS;
-               case olTaskDeferred     : return ICAL_STATUS_CANCELLED;
-               case olTaskNotStarted   :
-               default                 : return ICAL_STATUS_NEEDSACTION;
+       case olTaskComplete:
+               return I_CAL_STATUS_COMPLETED;
+       case olTaskWaiting:
+       case olTaskInProgress:
+               return I_CAL_STATUS_INPROCESS;
+       case olTaskDeferred:
+               return I_CAL_STATUS_CANCELLED;
+       case olTaskNotStarted:
+       default:
+               return I_CAL_STATUS_NEEDSACTION;
        }
 }
 
 static uint32_t
-get_prop_from_taskstatus (icalproperty_status status)
+get_prop_from_taskstatus (ICalPropertyStatus status)
 {
        /* FIXME: is this mapping correct ? */
        switch (status) {
-               case ICAL_STATUS_INPROCESS      : return olTaskInProgress;
-               case ICAL_STATUS_COMPLETED      : return olTaskComplete;
-               case ICAL_STATUS_CANCELLED      : return olTaskDeferred;
-               default                         : return olTaskNotStarted;
+       case I_CAL_STATUS_INPROCESS:
+               return olTaskInProgress;
+       case I_CAL_STATUS_COMPLETED:
+               return olTaskComplete;
+       case I_CAL_STATUS_CANCELLED:
+               return olTaskDeferred;
+       default:
+               return olTaskNotStarted;
        }
 }
 
-static icalproperty_class
+static ICalProperty_Class
 get_class_from_prop (uint32_t prop)
 {
        /* FIXME: is this mapping correct ? */
        switch (prop) {
-               case olPersonal         :
-               case olPrivate          : return ICAL_CLASS_PRIVATE;
-               case olConfidential     : return ICAL_CLASS_CONFIDENTIAL;
-               case olNormal           :
-               default                 : return ICAL_CLASS_PUBLIC;
+       case olPersonal:
+       case olPrivate:
+               return I_CAL_CLASS_PRIVATE;
+       case olConfidential:
+               return I_CAL_CLASS_CONFIDENTIAL;
+       case olNormal:
+       default:
+               return I_CAL_CLASS_PUBLIC;
        }
 }
 
 static uint32_t
-get_prop_from_class (icalproperty_class class)
+get_prop_from_class (ICalProperty_Class classif)
 {
        /* FIXME: is this mapping correct ? */
-       switch (class) {
-               case ICAL_CLASS_PRIVATE         : return olPrivate;
-               case ICAL_CLASS_CONFIDENTIAL    : return olConfidential;
-               default                         : return olNormal;
+       switch (classif) {
+       case I_CAL_CLASS_PRIVATE:
+               return olPrivate;
+       case I_CAL_CLASS_CONFIDENTIAL:
+               return olConfidential;
+       default:
+               return olNormal;
        }
 }
 
@@ -214,7 +244,11 @@ static const uint8_t GID_START_SEQ[] = {
    creation_time is a value of PR_CREATION_TIME
 */
 void
-e_mapi_cal_util_generate_globalobjectid (gboolean is_clean, const gchar *uid, const struct timeval 
*exception_replace_time, const struct FILETIME *creation_time, struct SBinary_short *sb)
+e_mapi_cal_util_generate_globalobjectid (gboolean is_clean,
+                                        const gchar *uid,
+                                        const struct timeval *exception_replace_time,
+                                        const struct FILETIME *creation_time,
+                                        struct SBinary_short *sb)
 {
        GByteArray *ba;
        guint32 val32;
@@ -228,12 +262,14 @@ e_mapi_cal_util_generate_globalobjectid (gboolean is_clean, const gchar *uid, co
 
        val32 = 0;
        if (!is_clean && exception_replace_time) {
-               struct icaltimetype icaltm = icaltime_from_timet_with_zone (exception_replace_time->tv_sec, 
0, icaltimezone_get_utc_timezone ());
+               ICalTime *itt = i_cal_time_from_timet_with_zone (exception_replace_time->tv_sec, 0, 
i_cal_timezone_get_utc_timezone ());
 
-               val32 |= (icaltm.year & 0xFF00) << 16;
-               val32 |= (icaltm.year & 0xFF) << 16;
-               val32 |= (icaltm.month & 0xFF) << 8;
-               val32 |= (icaltm.day & 0xFF);
+               val32 |= (i_cal_time_get_year (itt) & 0xFF00) << 16;
+               val32 |= (i_cal_time_get_year (itt) & 0xFF) << 16;
+               val32 |= (i_cal_time_get_month (itt) & 0xFF) << 8;
+               val32 |= (i_cal_time_get_day (itt) & 0xFF);
+
+               g_clear_object (&itt);
        }
 
        ba = g_byte_array_append (ba, (const guint8 *) &val32, sizeof (guint32));
@@ -274,7 +310,8 @@ e_mapi_cal_util_generate_globalobjectid (gboolean is_clean, const gchar *uid, co
 
 /* returns complete globalid as base64 encoded string */
 static gchar *
-globalid_to_string (const guint8 *lpb, guint32 cb)
+globalid_to_string (const guint8 *lpb,
+                   guint32 cb)
 {
        const guint8 *ptr;
        guint32 i, j;
@@ -299,9 +336,10 @@ globalid_to_string (const guint8 *lpb, guint32 cb)
 
 /* retrieves timezone location from a timezone ID */
 static const gchar *
-get_tzid_location (const gchar *tzid, struct cal_cbdata *cbdata)
+get_tzid_location (const gchar *tzid,
+                  struct cal_cbdata *cbdata)
 {
-       icaltimezone *zone = NULL;
+       ICalTimezone *zone = NULL;
 
        if (!tzid || !*tzid || g_str_equal (tzid, "UTC"))
                return NULL;
@@ -311,20 +349,20 @@ get_tzid_location (const gchar *tzid, struct cal_cbdata *cbdata)
                zone = cbdata->get_timezone (cbdata->get_tz_data, tzid);
 
        if (!zone)
-               zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+               zone = i_cal_timezone_get_builtin_timezone_from_tzid (tzid);
 
        /* the old TZID prefix used in previous versions of evolution-mapi */
        #define OLD_TZID_PREFIX "/softwarestudio.org/Tzfile/"
 
        if (!zone && g_str_has_prefix (tzid, OLD_TZID_PREFIX))
-               zone = icaltimezone_get_builtin_timezone (tzid + strlen (OLD_TZID_PREFIX));
+               zone = i_cal_timezone_get_builtin_timezone (tzid + strlen (OLD_TZID_PREFIX));
 
        #undef OLD_TZID_PREFIX
 
        if (!zone)
                return NULL;
 
-       return icaltimezone_get_location (zone);
+       return i_cal_timezone_get_location (zone);
 }
 
 #define MINUTES_IN_HOUR 60
@@ -446,7 +484,12 @@ mapi_get_date_from_string (const gchar *dtstring)
 }
 
 static void
-populate_freebusy_data (struct Binary_r *bin, uint32_t month, uint32_t year, GSList **freebusy, const gchar 
*accept_type, ECalComponent *comp)
+populate_freebusy_data (struct Binary_r *bin,
+                       uint32_t month,
+                       uint32_t year,
+                       GSList **freebusy,
+                       const gchar *accept_type,
+                       ECalComponent *comp)
 {
        uint16_t        event_start;
        uint16_t        event_end;
@@ -458,7 +501,7 @@ populate_freebusy_data (struct Binary_r *bin, uint32_t month, uint32_t year, GSL
        gchar *date_string = NULL;
        gchar *start = NULL, *end = NULL;
        time_t start_date, end_date;
-       icalcomponent *icalcomp = NULL;
+       ICalComponent *icomp = NULL;
 
        if (!bin)
                return;
@@ -476,9 +519,9 @@ populate_freebusy_data (struct Binary_r *bin, uint32_t month, uint32_t year, GSL
                event_end = (bin->lpb[i + 3] << 8) | bin->lpb[i + 2];
 
                if (event_start <= event_end) {
-                       struct icalperiodtype ipt;
-                       icalproperty *icalprop;
-                       icaltimetype itt;
+                       ICalPeriod *period;
+                       ICalProperty *prop;
+                       ICalTime *itt;
 
                        day = 1;
                        minutes = 0;
@@ -495,25 +538,29 @@ populate_freebusy_data (struct Binary_r *bin, uint32_t month, uint32_t year, GSL
                        start_date = mapi_get_date_from_string (start) + (60 * event_start);
                        end_date = mapi_get_date_from_string (end) + (60 * event_end);
 
-                       memset (&ipt, 0, sizeof (struct icalperiodtype));
+                       period = i_cal_period_null_period ();
 
-                       itt = icaltime_from_timet_with_zone (start_date, 0, icaltimezone_get_utc_timezone ());
-                       ipt.start = itt;
+                       itt = i_cal_time_from_timet_with_zone (start_date, 0, i_cal_timezone_get_utc_timezone 
());
+                       i_cal_period_set_start (period, itt);
+                       g_clear_object (&itt);
 
-                       itt = icaltime_from_timet_with_zone (end_date, 0, icaltimezone_get_utc_timezone ());
-                       ipt.end = itt;
+                       itt = i_cal_time_from_timet_with_zone (end_date, 0, i_cal_timezone_get_utc_timezone 
());
+                       i_cal_period_set_end (period, itt);
+                       g_clear_object (&itt);
 
-                       icalcomp = e_cal_component_get_icalcomponent (comp);
-                       icalprop = icalproperty_new_freebusy (ipt);
+                       icomp = e_cal_component_get_icalcomponent (comp);
+                       prop = i_cal_property_new_freebusy (period);
 
                        if (!strcmp (accept_type, "Busy"))
-                               icalproperty_set_parameter_from_string (icalprop, "FBTYPE", "BUSY");
+                               i_cal_property_set_parameter_from_string (prop, "FBTYPE", "BUSY");
                        else if (!strcmp (accept_type, "Tentative"))
-                               icalproperty_set_parameter_from_string (icalprop, "FBTYPE", "BUSY-TENTATIVE");
+                               i_cal_property_set_parameter_from_string (prop, "FBTYPE", "BUSY-TENTATIVE");
                        else if (!strcmp (accept_type, "OutOfOffice"))
-                               icalproperty_set_parameter_from_string (icalprop, "FBTYPE", 
"BUSY-UNAVAILABLE");
+                               i_cal_property_set_parameter_from_string (prop, "FBTYPE", "BUSY-UNAVAILABLE");
+
+                       i_cal_component_take_property (icomp, prop);
 
-                       icalcomponent_add_property(icalcomp, icalprop);
+                       g_clear_object (&period);
                        g_free (start);
                        g_free (end);
                }
@@ -521,13 +568,19 @@ populate_freebusy_data (struct Binary_r *bin, uint32_t month, uint32_t year, GSL
 }
 
 gboolean
-e_mapi_cal_utils_get_free_busy_data (EMapiConnection *conn, const GSList *users, time_t start, time_t end, 
GSList **freebusy, GCancellable *cancellable, GError **mapi_error)
+e_mapi_cal_utils_get_free_busy_data (EMapiConnection *conn,
+                                    const GSList *users,
+                                    time_t start,
+                                    time_t end,
+                                    GSList **freebusy,
+                                    GCancellable *cancellable,
+                                    GError **mapi_error)
 {
        struct SRow             aRow;
        enum MAPISTATUS         ms;
        uint32_t                i;
        mapi_object_t           obj_folder;
-       const GSList *l;
+       const GSList *link;
 
        const uint32_t                  *publish_start;
        const struct LongArray_r        *busy_months;
@@ -540,10 +593,10 @@ e_mapi_cal_utils_get_free_busy_data (EMapiConnection *conn, const GSList *users,
        uint32_t                        event_year;
 
        ECalComponent *comp;
-       ECalComponentAttendee attendee;
-       GSList *attendee_list = NULL;
-       icalcomponent *icalcomp = NULL;
-       icaltimetype start_time, end_time;
+       ECalComponentAttendee *attendee;
+       GSList *attendees;
+       ICalComponent *icomp = NULL;
+       ICalTime *starttt, *endtt;
 
        *freebusy = NULL;
 
@@ -554,11 +607,11 @@ e_mapi_cal_utils_get_free_busy_data (EMapiConnection *conn, const GSList *users,
                return FALSE;
        }
 
-       for ( l = users; l != NULL; l = g_slist_next (l)) {
-               ms = GetUserFreeBusyData (&obj_folder, (const gchar *)l->data, &aRow);
+       for (link = users; link; link = g_slist_next (link)) {
+               ms = GetUserFreeBusyData (&obj_folder, (const gchar *) link->data, &aRow);
 
                if (ms != MAPI_E_SUCCESS) {
-                       gchar *context = g_strconcat ("GetUserFreeBusyData for ", l->data, NULL);
+                       gchar *context = g_strconcat ("GetUserFreeBusyData for ", link->data, NULL);
 
                        make_mapi_error (mapi_error, context, ms);
 
@@ -583,25 +636,36 @@ e_mapi_cal_utils_get_free_busy_data (EMapiConnection *conn, const GSList *users,
                comp = e_cal_component_new ();
                e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_FREEBUSY);
                e_cal_component_commit_sequence (comp);
-               icalcomp = e_cal_component_get_icalcomponent (comp);
-
-               start_time = icaltime_from_timet_with_zone (start, 0, NULL);
-               end_time = icaltime_from_timet_with_zone (end, 0, NULL);
-               icalcomponent_set_dtstart (icalcomp, start_time);
-               icalcomponent_set_dtend (icalcomp, end_time);
-
-               memset (&attendee, 0, sizeof (ECalComponentAttendee));
-               if (l->data)
-                       attendee.value = l->data;
+               icomp = e_cal_component_get_icalcomponent (comp);
+
+               starttt = i_cal_time_from_timet_with_zone (start, 0, NULL);
+               endtt = i_cal_time_from_timet_with_zone (end, 0, NULL);
+               i_cal_component_set_dtstart (icomp, starttt);
+               i_cal_component_set_dtend (icomp, endtt);
+               g_clear_object (&starttt);
+               g_clear_object (&endtt);
+
+               attendee = e_cal_component_attendee_new ();
+               if (link->data) {
+                       if (g_ascii_strncasecmp (link->data, "mailto:";, 7) != 0) {
+                               gchar *mailto;
+
+                               mailto = g_strconcat ("mailto:";, link->data, NULL);
+                               e_cal_component_attendee_set_value (attendee, mailto);
+                               g_free (mailto);
+                       } else {
+                               e_cal_component_attendee_set_value (attendee, link->data);
+                       }
+               }
 
-               attendee.cutype = ICAL_CUTYPE_INDIVIDUAL;
-               attendee.role = ICAL_ROLE_REQPARTICIPANT;
-               attendee.status = ICAL_PARTSTAT_NEEDSACTION;
+               e_cal_component_attendee_set_cutype (attendee, I_CAL_CUTYPE_INDIVIDUAL);
+               e_cal_component_attendee_set_role (attendee, I_CAL_ROLE_REQPARTICIPANT);
+               e_cal_component_attendee_set_partstat (attendee, I_CAL_PARTSTAT_NEEDSACTION);
 
-               attendee_list = g_slist_append (attendee_list, &attendee);
+               attendees = g_slist_append (NULL, attendee);
 
-               e_cal_component_set_attendee_list (comp, attendee_list);
-               g_slist_free (attendee_list);
+               e_cal_component_set_attendees (comp, attendees);
+               g_slist_free_full (attendees, e_cal_component_attendee_free);
 
                if (busy_months && ((*(const uint32_t *) busy_months) != MAPI_E_NOT_FOUND) &&
                    busy_events && ((*(const uint32_t *) busy_events) != MAPI_E_NOT_FOUND)) {
@@ -638,34 +702,10 @@ e_mapi_cal_utils_get_free_busy_data (EMapiConnection *conn, const GSList *users,
        return TRUE;
 }
 
-gchar *
-e_mapi_cal_utils_get_icomp_x_prop (icalcomponent *comp, const gchar *key)
-{
-       icalproperty *xprop;
-
-       /* Find the old one first */
-       xprop = icalcomponent_get_first_property (comp, ICAL_X_PROPERTY);
-
-       while (xprop) {
-               const gchar *str = icalproperty_get_x_name (xprop);
-
-               if (str && !strcmp (str, key)) {
-                       break;
-               }
-
-               xprop = icalcomponent_get_next_property (comp, ICAL_X_PROPERTY);
-       }
-
-       if (xprop)
-               return icalproperty_get_value_as_string_r (xprop);
-
-       return NULL;
-}
-
 static void
 populate_ical_attendees (EMapiConnection *conn,
                         EMapiRecipient *recipients,
-                        icalcomponent *icalcomp,
+                        ICalComponent *icomp,
                         gboolean rsvp)
 {
        const uint32_t name_proptags[] = {
@@ -683,12 +723,12 @@ populate_ical_attendees (EMapiConnection *conn,
        EMapiRecipient *recipient;
 
        g_return_if_fail (conn != NULL);
-       g_return_if_fail (icalcomp != NULL);
+       g_return_if_fail (icomp != NULL);
 
        for (recipient = recipients; recipient; recipient = recipient->next) {
                gchar *name = NULL, *email = NULL, *icalemail;
-               icalproperty *prop;
-               icalparameter *param;
+               ICalProperty *prop;
+               ICalParameter *param;
                const uint32_t *ui32;
                const uint32_t *flags;
 
@@ -704,52 +744,52 @@ populate_ical_attendees (EMapiConnection *conn,
                        continue;
                }
 
-               icalemail = g_strdup_printf ("mailto:%s";, email);
+               icalemail = g_strconcat ("mailto:";, email, NULL);
 
                flags = e_mapi_util_find_array_propval (&recipient->properties, PidTagRecipientFlags);
 
                if (flags && (*flags & RECIP_ORGANIZER)) {
-                       prop = icalproperty_new_organizer (icalemail);
+                       prop = i_cal_property_new_organizer (icalemail);
 
                        /* CN */
                        if (name && *name) {
-                               param = icalparameter_new_cn (name);
-                               icalproperty_add_parameter (prop, param);
+                               param = i_cal_parameter_new_cn (name);
+                               i_cal_property_take_parameter (prop, param);
                        }
                } else {
-                       prop = icalproperty_new_attendee (icalemail);
+                       prop = i_cal_property_new_attendee (icalemail);
 
                        /* CN */
                        if (name && *name) {
-                               param = icalparameter_new_cn (name);
-                               icalproperty_add_parameter (prop, param);
+                               param = i_cal_parameter_new_cn (name);
+                               i_cal_property_take_parameter (prop, param);
                        }
 
                        /* RSVP */
-                       param = icalparameter_new_rsvp (rsvp ? ICAL_RSVP_TRUE : ICAL_RSVP_FALSE);
-                       icalproperty_add_parameter (prop, param);
+                       param = i_cal_parameter_new_rsvp (rsvp ? I_CAL_RSVP_TRUE : I_CAL_RSVP_FALSE);
+                       i_cal_property_take_parameter (prop, param);
 
                        /* PARTSTAT */
                        ui32 = e_mapi_util_find_array_propval (&recipient->properties, 
PidTagRecipientTrackStatus);
-                       param = icalparameter_new_partstat (get_partstat_from_trackstatus (ui32 ? *ui32 : 
olResponseNone));
-                       icalproperty_add_parameter (prop, param);
+                       param = i_cal_parameter_new_partstat (get_partstat_from_trackstatus (ui32 ? *ui32 : 
olResponseNone));
+                       i_cal_property_take_parameter (prop, param);
 
                        /* ROLE */
                        ui32 = e_mapi_util_find_array_propval (&recipient->properties, PidTagRecipientType);
-                       param = icalparameter_new_role (get_role_from_type (ui32 ? *ui32 : olTo));
-                       icalproperty_add_parameter (prop, param);
+                       param = i_cal_parameter_new_role (get_role_from_type (ui32 ? *ui32 : olTo));
+                       i_cal_property_take_parameter (prop, param);
 
                        /* CALENDAR USER TYPE */
                        param = NULL;
                        if (ui32 && *ui32 == 0x03)
-                               param = icalparameter_new_cutype (ICAL_CUTYPE_RESOURCE);
+                               param = i_cal_parameter_new_cutype (I_CAL_CUTYPE_RESOURCE);
                        if (!param)
-                               param = icalparameter_new_cutype (ICAL_CUTYPE_INDIVIDUAL);
+                               param = i_cal_parameter_new_cutype (I_CAL_CUTYPE_INDIVIDUAL);
 
-                       icalproperty_add_parameter (prop, param);
+                       i_cal_property_take_parameter (prop, param);
                }
 
-               icalcomponent_add_property (icalcomp, prop);
+               i_cal_component_take_property (icomp, prop);
 
                g_free (icalemail);
                g_free (email);
@@ -763,24 +803,24 @@ set_attachments_to_comp (EMapiConnection *conn,
                         ECalComponent *comp)
 {
        EMapiAttachment *attach;
-       icalcomponent *icalcomp;
+       ICalComponent *icomp;
 
        g_return_if_fail (comp != NULL);
 
        if (!attachments)
                return;
 
-       icalcomp = e_cal_component_get_icalcomponent (comp);
-       g_return_if_fail (icalcomp != NULL);
+       icomp = e_cal_component_get_icalcomponent (comp);
+       g_return_if_fail (icomp != NULL);
 
        for (attach = attachments; attach; attach = attach->next) {
                uint64_t data_cb = 0;
                const uint8_t *data_lpb = NULL;
                const gchar *filename;
-               icalattach *new_attach;
-               icalparameter *param;
+               ICalAttach *new_attach;
+               ICalParameter *param;
                gchar *base64;
-               icalproperty *prop;
+               ICalProperty *prop;
 
                if (!e_mapi_attachment_get_bin_prop (attach, PidTagAttachDataBinary, &data_cb, &data_lpb)) {
                        g_debug ("%s: Skipping calendar attachment without data", G_STRFUNC);
@@ -792,33 +832,31 @@ set_attachments_to_comp (EMapiConnection *conn,
                        filename = e_mapi_util_find_array_propval (&attach->properties, PidTagAttachFilename);
 
                base64 = g_base64_encode ((const guchar *) data_lpb, data_cb);
-               new_attach = icalattach_new_from_data (base64, NULL, NULL);
+               new_attach = i_cal_attach_new_from_data (base64, NULL, NULL);
                g_free (base64);
 
-               prop = icalproperty_new_attach (new_attach);
-               icalattach_unref (new_attach);
+               prop = i_cal_property_new_attach (new_attach);
+               g_object_unref (new_attach);
 
-               param = icalparameter_new_value (ICAL_VALUE_BINARY);
-               icalproperty_add_parameter (prop, param);
+               param = i_cal_parameter_new_value (I_CAL_VALUE_BINARY);
+               i_cal_property_take_parameter (prop, param);
 
-               param = icalparameter_new_encoding (ICAL_ENCODING_BASE64);
-               icalproperty_add_parameter (prop, param);
+               param = i_cal_parameter_new_encoding (I_CAL_ENCODING_BASE64);
+               i_cal_property_take_parameter (prop, param);
 
                if (filename && *filename) {
-                       param = icalparameter_new_filename (filename);
-                       icalproperty_add_parameter (prop, param);
+                       param = i_cal_parameter_new_filename (filename);
+                       i_cal_property_take_parameter (prop, param);
                }
 
-               icalcomponent_add_property (icalcomp, prop);
+               i_cal_component_take_property (icomp, prop);
        }
-
-       e_cal_component_rescan (comp);
 }
 
 ECalComponent *
 e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
                                EMapiObject *object,
-                               icalcomponent_kind kind,
+                               ICalComponentKind kind,
                                gboolean is_reply,
                                const gchar *use_uid,
                                GSList **detached_components)
@@ -830,10 +868,11 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
        const struct SBinary_short *bin;
        const uint32_t *ui32;
        const uint8_t *b;
-       icalcomponent *ical_comp;
-       icalproperty *prop = NULL;
-       icalparameter *param = NULL;
-       icaltimezone *utc_zone;
+       ICalComponent *icomp;
+       ICalProperty *prop = NULL;
+       ICalParameter *param = NULL;
+       ICalTimezone *utc_zone;
+       ICalTime *itt;
 
        g_return_val_if_fail (conn != NULL, NULL);
        g_return_val_if_fail (object != NULL, NULL);
@@ -845,14 +884,12 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
        }
 
        switch (kind) {
-               case ICAL_VEVENT_COMPONENT:
-               case ICAL_VTODO_COMPONENT:
-               case ICAL_VJOURNAL_COMPONENT:
-                       comp = e_cal_component_new ();
-                       ical_comp = icalcomponent_new (kind);
-                       if (!e_cal_component_set_icalcomponent (comp, ical_comp)) {
-                               icalcomponent_free (ical_comp);
-                               g_object_unref (comp);
+               case I_CAL_VEVENT_COMPONENT:
+               case I_CAL_VTODO_COMPONENT:
+               case I_CAL_VJOURNAL_COMPONENT:
+                       icomp = i_cal_component_new (kind);
+                       comp = e_cal_component_new_from_icalcomponent (icomp);
+                       if (!comp) {
                                return NULL;
                        }
                        e_cal_component_set_uid (comp, use_uid);
@@ -861,13 +898,13 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
                        return NULL;
        }
 
-       utc_zone = icaltimezone_get_utc_timezone ();
+       utc_zone = i_cal_timezone_get_utc_timezone ();
 
        str = e_mapi_util_find_array_propval (&object->properties, PidTagSubject);
        str = str ? str : e_mapi_util_find_array_propval (&object->properties, PidTagNormalizedSubject);
        str = str ? str : e_mapi_util_find_array_propval (&object->properties, PidTagConversationTopic);
        str = str ? str : "";
-       icalcomponent_set_summary (ical_comp, str);
+       i_cal_component_set_summary (icomp, str);
 
        ui32 = e_mapi_util_find_array_propval (&object->properties, PidTagInternetCodepage);
        if (e_mapi_object_contains_prop (object, PidTagBody)) {
@@ -896,7 +933,7 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
                        str = "";
                }
 
-               icalcomponent_set_description (ical_comp, str);
+               i_cal_component_set_description (icomp, str);
 
                g_free (utf8_str);
        } else {
@@ -907,7 +944,7 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
                        gchar *utf8_str = NULL;
 
                        if (e_mapi_utils_ensure_utf8_string (PidTagHtml, ui32, html_lpb, html_cb, &utf8_str))
-                               icalcomponent_set_description (ical_comp, utf8_str);
+                               i_cal_component_set_description (icomp, utf8_str);
 
                        g_free (utf8_str);
                }
@@ -915,20 +952,27 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
 
        /* set dtstamp - in UTC */
        if (e_mapi_util_find_array_datetime_propval (&t, &object->properties, PidTagCreationTime) == 
MAPI_E_SUCCESS) {
-               icalcomponent_set_dtstamp (ical_comp, icaltime_from_timet_with_zone (t.tv_sec, 0, utc_zone));
+               itt = i_cal_time_from_timet_with_zone (t.tv_sec, 0, utc_zone);
+               i_cal_component_set_dtstamp (icomp, itt);
+
+               prop = i_cal_property_new_created (itt);
+               i_cal_component_take_property (icomp, prop);
 
-               prop = icalproperty_new_created (icaltime_from_timet_with_zone (t.tv_sec, 0, utc_zone));
-               icalcomponent_add_property (ical_comp, prop);
+               g_clear_object (&itt);
        } else {
                /* created - in UTC */
-               prop = icalproperty_new_created (icaltime_current_time_with_zone (utc_zone));
-               icalcomponent_add_property (ical_comp, prop);
+               itt = i_cal_time_current_time_with_zone (utc_zone);
+               prop = i_cal_property_new_created (itt);
+               i_cal_component_take_property (icomp, prop);
+               g_clear_object (&itt);
        }
 
        /* last modified - in UTC */
        if (get_mapi_SPropValue_array_date_timeval (&t, &object->properties, PidTagLastModificationTime) == 
MAPI_E_SUCCESS) {
-               prop = icalproperty_new_lastmodified (icaltime_from_timet_with_zone (t.tv_sec, 0, utc_zone));
-               icalcomponent_add_property (ical_comp, prop);
+               itt = i_cal_time_from_timet_with_zone (t.tv_sec, 0, utc_zone);
+               prop = i_cal_property_new_lastmodified (itt);
+               i_cal_component_take_property (icomp, prop);
+               g_clear_object (&itt);
        }
 
        categories_array = e_mapi_util_find_array_propval (&object->properties, PidNameKeywords);
@@ -942,15 +986,17 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
                        if (!category || !*category)
                                continue;
 
-                       categories = g_slist_append (categories, (gpointer) category);
+                       categories = g_slist_prepend (categories, (gpointer) category);
                }
 
+               categories = g_slist_reverse (categories);
+
                e_cal_component_set_categories_list (comp, categories);
 
                g_slist_free (categories);
        }
 
-       if (icalcomponent_isa (ical_comp) == ICAL_VEVENT_COMPONENT) {
+       if (i_cal_component_isa (icomp) == I_CAL_VEVENT_COMPONENT) {
                const gchar *location = NULL;
                const gchar *dtstart_tz_location = NULL, *dtend_tz_location = NULL;
                gboolean all_day;
@@ -959,17 +1005,12 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
                bin = e_mapi_util_find_array_propval (&object->properties, PidLidGlobalObjectId);
                if (bin) {
                        gchar *value = globalid_to_string (bin->lpb, bin->cb);
-                       prop = icalproperty_new_x (value);
-                       icalproperty_set_x_name (prop, "X-EVOLUTION-MAPI-GLOBALID");
-                       icalcomponent_add_property (ical_comp, prop);
+                       e_cal_util_component_set_x_property (icomp, "X-EVOLUTION-MAPI-GLOBALID", value);
                        if (value && *value) {
                                e_cal_component_set_uid (comp, value);
 
-                               if (!g_str_equal (value, use_uid)) {
-                                       prop = icalproperty_new_x (use_uid);
-                                       icalproperty_set_x_name (prop, "X-EVOLUTION-MAPI-MID");
-                                       icalcomponent_add_property (ical_comp, prop);
-                               }
+                               if (!g_str_equal (value, use_uid))
+                                       e_cal_util_component_set_x_property (icomp, "X-EVOLUTION-MAPI-MID", 
use_uid);
                        }
 
                        g_free (value);
@@ -979,9 +1020,8 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
                if (ui32) {
                        gchar *value = e_mapi_util_mapi_id_to_string ((mapi_id_t) (*ui32));
 
-                       prop = icalproperty_new_x (value);
-                       icalproperty_set_x_name (prop, "X-EVOLUTION-MAPI-OWNER-APPT-ID");
-                       icalcomponent_add_property (ical_comp, prop);
+                       e_cal_util_component_set_x_property (icomp, "X-EVOLUTION-MAPI-OWNER-APPT-ID", value);
+
                        g_free (value);
                }
 
@@ -989,15 +1029,15 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
                ui32 = e_mapi_util_find_array_propval (&object->properties, PidLidAppointmentSequence);
                if (ui32) {
                        gchar *value = g_strdup_printf ("%d", *ui32);
-                       prop = icalproperty_new_x (value);
-                       icalproperty_set_x_name (prop, "X-EVOLUTION-MAPI-APPTSEQ");
-                       icalcomponent_add_property (ical_comp, prop);
+
+                       e_cal_util_component_set_x_property (icomp, "X-EVOLUTION-MAPI-APPTSEQ", value);
+
                        g_free (value);
                }
 
                location = e_mapi_util_find_array_propval (&object->properties, PidLidLocation);
                if (location && *location)
-                       icalcomponent_set_location (ical_comp, location);
+                       i_cal_component_set_location (icomp, location);
 
                b = e_mapi_util_find_array_propval (&object->properties, PidLidAppointmentSubType);
                all_day = b && *b;
@@ -1016,15 +1056,18 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
                }
 
                if (e_mapi_util_find_array_datetime_propval (&t, &object->properties, 
PidLidAppointmentStartWhole) == MAPI_E_SUCCESS) {
-                       icaltimezone *zone = dtstart_tz_location ? icaltimezone_get_builtin_timezone 
(dtstart_tz_location) : utc_zone;
-                       struct icaltimetype itt = icaltime_from_timet_with_zone (t.tv_sec, all_day, zone);
-                       itt.zone = zone;
-                       prop = icalproperty_new_dtstart (itt);
-                       if (!all_day && zone && icaltimezone_get_tzid (zone)) {
-                               icalproperty_add_parameter (prop, icalparameter_new_tzid 
(icaltimezone_get_tzid (zone)));
+                       ICalTimezone *zone = dtstart_tz_location ? i_cal_timezone_get_builtin_timezone 
(dtstart_tz_location) : utc_zone;
+
+                       itt = i_cal_time_from_timet_with_zone (t.tv_sec, all_day, zone);
+                       i_cal_time_set_timezone (itt, zone);
+                       prop = i_cal_property_new_dtstart (itt);
+                       if (!all_day && zone && i_cal_timezone_get_tzid (zone)) {
+                               i_cal_property_take_parameter (prop, i_cal_parameter_new_tzid 
(i_cal_timezone_get_tzid (zone)));
                        }
 
-                       icalcomponent_add_property (ical_comp, prop);
+                       i_cal_component_take_property (icomp, prop);
+
+                       g_clear_object (&itt);
                }
 
                bin = e_mapi_util_find_array_propval (&object->properties, 
PidLidAppointmentTimeZoneDefinitionEndDisplay);
@@ -1041,27 +1084,26 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
                }
 
                if (e_mapi_util_find_array_datetime_propval (&t, &object->properties, 
PidLidAppointmentEndWhole) == MAPI_E_SUCCESS) {
-                       icaltimezone *zone;
-                       struct icaltimetype itt;
+                       ICalTimezone *zone;
 
                        if (!dtend_tz_location)
                                dtend_tz_location = dtstart_tz_location;
 
-                       zone = dtend_tz_location ? icaltimezone_get_builtin_timezone (dtend_tz_location) : 
utc_zone;
-                       itt = icaltime_from_timet_with_zone (t.tv_sec, all_day, zone);
-                       itt.zone = zone;
-                       prop = icalproperty_new_dtend (itt);
-                       if (!all_day && zone && icaltimezone_get_tzid (zone)) {
-                               icalproperty_add_parameter (prop, icalparameter_new_tzid 
(icaltimezone_get_tzid (zone)));
+                       zone = dtend_tz_location ? i_cal_timezone_get_builtin_timezone (dtend_tz_location) : 
utc_zone;
+                       itt = i_cal_time_from_timet_with_zone (t.tv_sec, all_day, zone);
+                       i_cal_time_set_timezone (itt, zone);
+                       prop = i_cal_property_new_dtend (itt);
+                       if (!all_day && zone && i_cal_timezone_get_tzid (zone)) {
+                               i_cal_property_take_parameter (prop, i_cal_parameter_new_tzid 
(i_cal_timezone_get_tzid (zone)));
                        }
 
-                       icalcomponent_add_property (ical_comp, prop);
+                       i_cal_component_take_property (icomp, prop);
                }
 
                ui32 = e_mapi_util_find_array_propval (&object->properties, PidLidBusyStatus);
                if (ui32) {
-                       prop = icalproperty_new_transp (get_transp_from_prop (*ui32));
-                       icalcomponent_add_property (ical_comp, prop);
+                       prop = i_cal_property_new_transp (get_transp_from_prop (*ui32));
+                       i_cal_component_take_property (icomp, prop);
                }
 
                if (object->recipients) {
@@ -1069,9 +1111,9 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
                        gchar *val;
 
                        b = e_mapi_util_find_array_propval (&object->properties, PidTagResponseRequested);
-                       populate_ical_attendees (conn, object->recipients, ical_comp, (b && *b));
+                       populate_ical_attendees (conn, object->recipients, icomp, (b && *b));
                        if (is_reply) {
-                               if (icalcomponent_get_first_property (ical_comp, ICAL_ORGANIZER_PROPERTY) == 
NULL) {
+                               if (!e_cal_util_component_has_property (icomp, I_CAL_ORGANIZER_PROPERTY)) {
                                        name = NULL;
                                        email = NULL;
 
@@ -1083,23 +1125,23 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
 
                                        if (email) {
                                                val = g_strdup_printf ("mailto:%s";, email);
-                                               prop = icalproperty_new_organizer (val);
+                                               prop = i_cal_property_new_organizer (val);
                                                g_free (val);
 
                                                if (name && g_strcmp0 (name, email) != 0) {
                                                        /* CN */
-                                                       param = icalparameter_new_cn (name);
-                                                       icalproperty_add_parameter (prop, param);
+                                                       param = i_cal_parameter_new_cn (name);
+                                                       i_cal_property_take_parameter (prop, param);
                                                }
 
-                                               icalcomponent_add_property (ical_comp, prop);
+                                               i_cal_component_take_property (icomp, prop);
                                        }
 
                                        g_free (name);
                                        g_free (email);
                                }
 
-                               if (icalcomponent_get_first_property (ical_comp, ICAL_ATTENDEE_PROPERTY) == 
NULL) {
+                               if (!e_cal_util_component_has_property (icomp, I_CAL_ATTENDEE_PROPERTY)) {
                                        name = NULL;
                                        email = NULL;
 
@@ -1111,26 +1153,26 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
 
                                        if (email) {
                                                val = g_strdup_printf ("mailto:%s";, email);
-                                               prop = icalproperty_new_attendee (val);
+                                               prop = i_cal_property_new_attendee (val);
                                                g_free (val);
 
                                                if (name && g_strcmp0 (name, email) != 0) {
                                                        /* CN */
-                                                       param = icalparameter_new_cn (name);
-                                                       icalproperty_add_parameter (prop, param);
+                                                       param = i_cal_parameter_new_cn (name);
+                                                       i_cal_property_take_parameter (prop, param);
                                                }
 
                                                ui32 = e_mapi_util_find_array_propval (&object->properties, 
PidLidResponseStatus);
-                                               param = icalparameter_new_partstat 
(get_partstat_from_trackstatus (ui32 ? *ui32 : olResponseNone));
-                                               icalproperty_add_parameter (prop, param);
+                                               param = i_cal_parameter_new_partstat 
(get_partstat_from_trackstatus (ui32 ? *ui32 : olResponseNone));
+                                               i_cal_property_take_parameter (prop, param);
 
-                                               icalcomponent_add_property (ical_comp, prop);
+                                               i_cal_component_take_property (icomp, prop);
                                        }
 
                                        g_free (name);
                                        g_free (email);
                                }
-                       } else if (icalcomponent_get_first_property (ical_comp, ICAL_ORGANIZER_PROPERTY) == 
NULL) {
+                       } else if (!e_cal_util_component_has_property (icomp, I_CAL_ORGANIZER_PROPERTY)) {
                                gchar *sent_name = NULL, *sent_email = NULL;
 
                                name = NULL;
@@ -1150,24 +1192,24 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
 
                                if (sent_email) {
                                        val = g_strdup_printf ("mailto:%s";, sent_email);
-                                       prop = icalproperty_new_organizer (val);
+                                       prop = i_cal_property_new_organizer (val);
                                        g_free (val);
 
                                        if (sent_name && g_strcmp0 (sent_name, sent_email) != 0) {
                                                /* CN */
-                                               param = icalparameter_new_cn (sent_name);
-                                               icalproperty_add_parameter (prop, param);
+                                               param = i_cal_parameter_new_cn (sent_name);
+                                               i_cal_property_take_parameter (prop, param);
                                        }
 
                                        /* SENTBY */
                                        if (email && g_utf8_collate (sent_email, email)) {
                                                val = g_strdup_printf ("mailto:%s";, email);
-                                               param = icalparameter_new_sentby (val);
-                                               icalproperty_add_parameter (prop, param);
+                                               param = i_cal_parameter_new_sentby (val);
+                                               i_cal_property_take_parameter (prop, param);
                                                g_free (val);
                                        }
 
-                                       icalcomponent_add_property (ical_comp, prop);
+                                       i_cal_component_take_property (icomp, prop);
                                }
 
 
@@ -1182,13 +1224,13 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
                if (b && *b) {
                        bin = e_mapi_util_find_array_propval (&object->properties, PidLidAppointmentRecur);
                        if (bin) {
-                               icaltimezone *recur_zone;
+                               ICalTimezone *recur_zone;
                                const gchar *recur_tz_location;
 
                                recur_tz_location = e_mapi_util_find_array_propval (&object->properties, 
PidLidTimeZoneDescription);
                                if (recur_tz_location)
                                        recur_tz_location = e_mapi_cal_tz_util_get_ical_equivalent 
(recur_tz_location);
-                               recur_zone = recur_tz_location ? icaltimezone_get_builtin_timezone 
(recur_tz_location) : utc_zone;
+                               recur_zone = recur_tz_location ? i_cal_timezone_get_builtin_timezone 
(recur_tz_location) : utc_zone;
 
                                e_mapi_cal_util_bin_to_rrule (bin->lpb, bin->cb, comp, detached_components, 
recur_zone);
                        }
@@ -1201,45 +1243,61 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
                        if ((e_mapi_util_find_array_datetime_propval (&start, &object->properties, 
PidLidReminderTime) == MAPI_E_SUCCESS)
                         && (e_mapi_util_find_array_datetime_propval (&displaytime, &object->properties, 
PidLidReminderSignalTime) == MAPI_E_SUCCESS)) {
                                ECalComponentAlarm *e_alarm = e_cal_component_alarm_new ();
-                               ECalComponentAlarmTrigger trigger;
+                               ECalComponentAlarmTrigger *trigger;
+                               ICalDuration *duration;
+                               ICalTime *itt1, *itt2;
+
+                               itt1 = i_cal_time_from_timet_with_zone (displaytime.tv_sec, 0, NULL);
+                               itt2 = i_cal_time_from_timet_with_zone (start.tv_sec, 0, NULL);
+                               duration = i_cal_time_subtract (itt1, itt2);
+                               g_clear_object (&itt1);
+                               g_clear_object (&itt2);
 
-                               trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START;
-                               trigger.u.rel_duration = icaltime_subtract (icaltime_from_timet_with_zone 
(displaytime.tv_sec, 0, NULL),
-                                                                           icaltime_from_timet_with_zone 
(start.tv_sec, 0, NULL));
+                               trigger = e_cal_component_alarm_trigger_new_relative 
(E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START, duration);
 
                                e_cal_component_alarm_set_action (e_alarm, E_CAL_COMPONENT_ALARM_DISPLAY);
-                               e_cal_component_alarm_set_trigger (e_alarm, trigger);
+                               e_cal_component_alarm_take_trigger (e_alarm, trigger);
 
                                e_cal_component_add_alarm (comp, e_alarm);
                                e_cal_component_alarm_free (e_alarm);
+                               g_clear_object (&duration);
                        }
                } else
                        e_cal_component_remove_all_alarms (comp);
 
-       } else if (icalcomponent_isa (ical_comp) == ICAL_VTODO_COMPONENT) {
+       } else if (i_cal_component_isa (icomp) == I_CAL_VTODO_COMPONENT) {
                const double *complete = NULL;
                const uint64_t *status = NULL;
 
                /* NOTE: Exchange tasks are DATE values, not DATE-TIME values, but maybe someday, we could 
expect Exchange to support it;) */
-               if (e_mapi_util_find_array_datetime_propval (&t, &object->properties, PidLidTaskStartDate) == 
MAPI_E_SUCCESS)
-                       icalcomponent_set_dtstart (ical_comp, icaltime_from_timet_with_zone (t.tv_sec, 1, 
utc_zone));
-               if (e_mapi_util_find_array_datetime_propval (&t, &object->properties, PidLidTaskDueDate) == 
MAPI_E_SUCCESS)
-                       icalcomponent_set_due (ical_comp, icaltime_from_timet_with_zone (t.tv_sec, 1, 
utc_zone));
+               if (e_mapi_util_find_array_datetime_propval (&t, &object->properties, PidLidTaskStartDate) == 
MAPI_E_SUCCESS) {
+                       itt = i_cal_time_from_timet_with_zone (t.tv_sec, 1, utc_zone);
+                       i_cal_component_set_dtstart (icomp, itt);
+                       g_clear_object (&itt);
+               }
+
+               if (e_mapi_util_find_array_datetime_propval (&t, &object->properties, PidLidTaskDueDate) == 
MAPI_E_SUCCESS) {
+                       itt = i_cal_time_from_timet_with_zone (t.tv_sec, 1, utc_zone);
+                       i_cal_component_set_due (icomp, itt);
+                       g_clear_object (&itt);
+               }
 
                status = e_mapi_util_find_array_propval (&object->properties, PidLidTaskStatus);
                if (status) {
-                       icalcomponent_set_status (ical_comp, get_taskstatus_from_prop (*status));
+                       i_cal_component_set_status (icomp, get_taskstatus_from_prop (*status));
                        if (*status == olTaskComplete
                            && e_mapi_util_find_array_datetime_propval (&t, &object->properties, 
PidLidTaskDateCompleted) == MAPI_E_SUCCESS) {
-                               prop = icalproperty_new_completed (icaltime_from_timet_with_zone (t.tv_sec, 
0, utc_zone));
-                               icalcomponent_add_property (ical_comp, prop);
+                               itt = i_cal_time_from_timet_with_zone (t.tv_sec, 0, utc_zone);
+                               prop = i_cal_property_new_completed (itt);
+                               i_cal_component_take_property (icomp, prop);
+                               g_clear_object (&itt);
                        }
                }
 
                complete = e_mapi_util_find_array_propval (&object->properties, PidLidPercentComplete);
                if (complete) {
-                       prop = icalproperty_new_percentcomplete ((gint) ((*complete) * 100 + 1e-9));
-                       icalcomponent_add_property (ical_comp, prop);
+                       prop = i_cal_property_new_percentcomplete ((gint) ((*complete) * 100 + 1e-9));
+                       i_cal_component_take_property (icomp, prop);
                }
 
                b = e_mapi_util_find_array_propval (&object->properties, PidLidTaskFRecurring);
@@ -1253,13 +1311,15 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
 
                        if (e_mapi_util_find_array_datetime_propval (&abs, &object->properties, 
PidLidReminderTime) == MAPI_E_SUCCESS) {
                                ECalComponentAlarm *e_alarm = e_cal_component_alarm_new ();
-                               ECalComponentAlarmTrigger trigger;
+                               ECalComponentAlarmTrigger *trigger;
+                               ICalTime *abs_time;
 
-                               trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_ABSOLUTE;
-                               trigger.u.abs_time = icaltime_from_timet_with_zone (abs.tv_sec, 0, utc_zone);
+                               abs_time = i_cal_time_from_timet_with_zone (abs.tv_sec, 0, utc_zone);
+                               trigger = e_cal_component_alarm_trigger_new_absolute (abs_time);
+                               g_clear_object (&abs_time);
 
                                e_cal_component_alarm_set_action (e_alarm, E_CAL_COMPONENT_ALARM_DISPLAY);
-                               e_cal_component_alarm_set_trigger (e_alarm, trigger);
+                               e_cal_component_alarm_take_trigger (e_alarm, trigger);
 
                                e_cal_component_add_alarm (comp, e_alarm);
                                e_cal_component_alarm_free (e_alarm);
@@ -1267,32 +1327,33 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
                } else
                        e_cal_component_remove_all_alarms (comp);
 
-       } else if (icalcomponent_isa (ical_comp) == ICAL_VJOURNAL_COMPONENT) {
-               if (e_mapi_util_find_array_datetime_propval (&t, &object->properties, 
PidTagLastModificationTime) == MAPI_E_SUCCESS)
-                       icalcomponent_set_dtstart (ical_comp, icaltime_from_timet_with_zone (t.tv_sec, 1, 
utc_zone));
+       } else if (i_cal_component_isa (icomp) == I_CAL_VJOURNAL_COMPONENT) {
+               if (e_mapi_util_find_array_datetime_propval (&t, &object->properties, 
PidTagLastModificationTime) == MAPI_E_SUCCESS) {
+                       itt = i_cal_time_from_timet_with_zone (t.tv_sec, 1, utc_zone);
+                       i_cal_component_set_dtstart (icomp, itt);
+                       g_clear_object (&itt);
+               }
        }
 
-       if (icalcomponent_isa (ical_comp) == ICAL_VEVENT_COMPONENT ||
-           icalcomponent_isa (ical_comp) == ICAL_VTODO_COMPONENT) {
+       if (i_cal_component_isa (icomp) == I_CAL_VEVENT_COMPONENT ||
+           i_cal_component_isa (icomp) == I_CAL_VTODO_COMPONENT) {
                /* priority */
                ui32 = e_mapi_util_find_array_propval (&object->properties, PidTagPriority);
                if (ui32) {
-                       prop = icalproperty_new_priority (get_priority_from_prop (*ui32));
-                       icalcomponent_add_property (ical_comp, prop);
+                       prop = i_cal_property_new_priority (get_priority_from_prop (*ui32));
+                       i_cal_component_take_property (icomp, prop);
                }
        }
 
        /* classification */
        ui32 = e_mapi_util_find_array_propval (&object->properties, PidTagSensitivity);
        if (ui32) {
-               prop = icalproperty_new_class (get_class_from_prop (*ui32));
-               icalcomponent_add_property (ical_comp, prop);
+               prop = i_cal_property_new_class (get_class_from_prop (*ui32));
+               i_cal_component_take_property (icomp, prop);
        }
 
        set_attachments_to_comp (conn, object->attachments, comp);
 
-       e_cal_component_rescan (comp);
-
        return comp;
 }
 
@@ -1300,21 +1361,21 @@ static void
 e_mapi_cal_utils_add_organizer (EMapiObject *object,
                                ECalComponent *comp)
 {
-       icalcomponent *icalcomp;
-       icalproperty *org_prop = NULL;
+       ICalComponent *icomp;
+       ICalProperty *org_prop = NULL;
        const gchar *org = NULL;
 
        g_return_if_fail (object != NULL);
        g_return_if_fail (comp != NULL);
 
-       icalcomp = e_cal_component_get_icalcomponent (comp);
-       org_prop = icalcomponent_get_first_property (icalcomp, ICAL_ORGANIZER_PROPERTY);
-       org = icalproperty_get_organizer (org_prop);
+       icomp = e_cal_component_get_icalcomponent (comp);
+       org_prop = i_cal_component_get_first_property (icomp, I_CAL_ORGANIZER_PROPERTY);
+       org = i_cal_property_get_organizer (org_prop);
        if (org && *org) {
                EMapiRecipient *recipient;
                uint32_t ui32 = 0;
                const gchar *str = NULL, *email;
-               icalparameter *param;
+               ICalParameter *param;
 
                recipient = e_mapi_recipient_new (object);
                e_mapi_object_add_recipient (object, recipient);
@@ -1349,11 +1410,12 @@ e_mapi_cal_utils_add_organizer (EMapiObject *object,
                ui32 = olTo;
                set_value (PidTagRecipientType, &ui32);
 
-               param = icalproperty_get_first_parameter (org_prop, ICAL_CN_PARAMETER);
-               str = icalparameter_get_cn (param);
+               param = i_cal_property_get_first_parameter (org_prop, I_CAL_CN_PARAMETER);
+               str = param ? i_cal_parameter_get_cn (param) : NULL;
                str = (str && *str) ? str : email;
                set_value (PidTagRecipientDisplayName, str);
                set_value (PidTagDisplayName, str);
+               g_clear_object (&param);
 
                ui32 = DT_MAILUSER;
                set_value (PidTagDisplayType, &ui32);
@@ -1363,14 +1425,16 @@ e_mapi_cal_utils_add_organizer (EMapiObject *object,
 
                #undef set_value
        }
+
+       g_clear_object (&org_prop);
 }
 
 static void
 e_mapi_cal_utils_add_recipients (EMapiObject *object,
                                 ECalComponent *comp)
 {
-       icalcomponent *icalcomp;
-       icalproperty *org_prop = NULL, *att_prop = NULL;
+       ICalComponent *icomp;
+       ICalProperty *org_prop = NULL, *att_prop = NULL;
        const gchar *org = NULL;
 
        g_return_if_fail (object != NULL);
@@ -1379,24 +1443,23 @@ e_mapi_cal_utils_add_recipients (EMapiObject *object,
        if (!e_cal_component_has_attendees (comp))
                return;
 
-       icalcomp = e_cal_component_get_icalcomponent (comp);
-       org_prop = icalcomponent_get_first_property (icalcomp, ICAL_ORGANIZER_PROPERTY);
-       org = icalproperty_get_organizer (org_prop);
+       icomp = e_cal_component_get_icalcomponent (comp);
+       org_prop = i_cal_component_get_first_property (icomp, I_CAL_ORGANIZER_PROPERTY);
+       org = org_prop ? i_cal_property_get_organizer (org_prop) : NULL;
        if (!org)
                org = "";
 
-       att_prop = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
-       while (att_prop) {
+       for (att_prop = i_cal_component_get_first_property (icomp, I_CAL_ATTENDEE_PROPERTY);
+            att_prop;
+            g_object_unref (att_prop), att_prop = i_cal_component_get_next_property (icomp, 
I_CAL_ATTENDEE_PROPERTY)) {
                EMapiRecipient *recipient;
                uint32_t ui32 = 0;
                const gchar *str = NULL, *email;
-               icalparameter *param;
+               ICalParameter *param;
 
-               str = icalproperty_get_attendee (att_prop);
-               if (!str || g_ascii_strcasecmp (str, org) == 0) {
-                       att_prop = icalcomponent_get_next_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
+               str = i_cal_property_get_attendee (att_prop);
+               if (!str || g_ascii_strcasecmp (str, org) == 0)
                        continue;
-               }
 
                recipient = e_mapi_recipient_new (object);
                e_mapi_object_add_recipient (object, recipient);
@@ -1424,19 +1487,22 @@ e_mapi_cal_utils_add_recipients (EMapiObject *object,
                ui32 = RECIP_SENDABLE | (g_ascii_strcasecmp (str, org) == 0 ? RECIP_ORGANIZER : 0);
                set_value (PidTagRecipientFlags, &ui32);
 
-               param = icalproperty_get_first_parameter (att_prop, ICAL_PARTSTAT_PARAMETER);
-               ui32 = get_trackstatus_from_partstat (icalparameter_get_partstat (param));
+               param = i_cal_property_get_first_parameter (att_prop, I_CAL_PARTSTAT_PARAMETER);
+               ui32 = get_trackstatus_from_partstat (param ? i_cal_parameter_get_partstat (param) : 
I_CAL_PARTSTAT_ACCEPTED);
                set_value (PidTagRecipientTrackStatus, &ui32);
+               g_clear_object (&param);
 
-               param = icalproperty_get_first_parameter (att_prop, ICAL_ROLE_PARAMETER);
-               ui32 = get_type_from_role (icalparameter_get_role (param));
+               param = i_cal_property_get_first_parameter (att_prop, I_CAL_ROLE_PARAMETER);
+               ui32 = get_type_from_role (param ? i_cal_parameter_get_role (param) : I_CAL_ROLE_NONE);
                set_value (PidTagRecipientType, &ui32);
+               g_clear_object (&param);
 
-               param = icalproperty_get_first_parameter (att_prop, ICAL_CN_PARAMETER);
-               str = icalparameter_get_cn (param);
+               param = i_cal_property_get_first_parameter (att_prop, I_CAL_CN_PARAMETER);
+               str = param ? i_cal_parameter_get_cn (param) : NULL;
                str = (str && *str) ? str : email;
                set_value (PidTagRecipientDisplayName, str);
                set_value (PidTagDisplayName, str);
+               g_clear_object (&param);
 
                ui32 = DT_MAILUSER;
                set_value (PidTagDisplayType, &ui32);
@@ -1445,17 +1511,17 @@ e_mapi_cal_utils_add_recipients (EMapiObject *object,
                set_value (PidTagObjectType, &ui32);
 
                #undef set_value
-
-               att_prop = icalcomponent_get_next_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
        }
+
+       g_clear_object (&org_prop);
 }
 
 static void
 e_mapi_cal_utils_add_attachments (EMapiObject *object,
                                  ECalComponent *comp)
 {
-       GSList *comp_attach_list = NULL;
-       GSList *l;
+       ICalComponent *icomp;
+       ICalProperty *prop;
        const gchar *uid;
        gchar *safeuid;
 
@@ -1465,49 +1531,108 @@ e_mapi_cal_utils_add_attachments (EMapiObject *object,
        if (!e_cal_component_has_attachments (comp))
                return;
 
-       e_cal_component_get_attachment_list (comp, &comp_attach_list);
-       e_cal_component_get_uid (comp, &uid);
+       uid = e_cal_component_get_uid (comp);
+       icomp = e_cal_component_get_icalcomponent (comp);
 
        safeuid = g_strdup (uid);
        e_filename_make_safe (safeuid);
        g_return_if_fail (safeuid != NULL);
 
-       for (l = comp_attach_list; l; l = l->next) {
-               gchar *sfname_uri = (gchar *) l->data;
+       for (prop = i_cal_component_get_first_property (icomp, I_CAL_ATTACH_PROPERTY);
+            prop;
+            g_object_unref (prop), prop = i_cal_component_get_next_property (icomp, I_CAL_ATTACH_PROPERTY)) {
+               ICalAttach *attach = i_cal_property_get_attach (prop);
+               ICalParameter *param;
+               const gchar *sfname_uri, *stored_filename;
                gchar *sfname = NULL, *filename = NULL;
                GMappedFile *mapped_file;
                GError *error = NULL;
 
-               sfname = g_filename_from_uri (sfname_uri, NULL, NULL);
-               mapped_file = g_mapped_file_new (sfname, FALSE, &error);
-               filename = g_path_get_basename (sfname);
+               if (!I_CAL_IS_ATTACH (attach))
+                       continue;
+
+               #define set_value(pt,vl) {                                                              \
+                       if (!e_mapi_utils_add_property (&attachment->properties, pt, vl, attachment)) { \
+                               g_warning ("%s: Failed to set property 0x%x", G_STRFUNC, pt);           \
+                                                                                                       \
+                               return;                                                                 \
+                       }                                                                               \
+               }
+
+               param = i_cal_property_get_first_parameter (prop, I_CAL_FILENAME_PARAMETER);
+               stored_filename = param ? i_cal_parameter_get_filename (param) : NULL;
+               if (stored_filename && !*stored_filename)
+                       stored_filename = NULL;
+
+               if (i_cal_attach_get_is_url (attach)) {
+                       sfname_uri = i_cal_attach_get_url (attach);
+
+                       sfname = g_filename_from_uri (sfname_uri, NULL, NULL);
+                       mapped_file = g_mapped_file_new (sfname, FALSE, &error);
+                       filename = g_path_get_basename (sfname);
+
+                       if (mapped_file) {
+                               EMapiAttachment *attachment;
+                               guint8 *attach = (guint8 *) g_mapped_file_get_contents (mapped_file);
+                               guint filelength = g_mapped_file_get_length (mapped_file);
+                               const gchar *split_name;
+                               uint32_t ui32;
+                               uint64_t data_cb;
+                               uint8_t *data_lpb;
+
+                               if (g_str_has_prefix (filename, safeuid)) {
+                                       split_name = (filename + strlen (safeuid) + strlen ("-"));
+                               } else {
+                                       split_name = filename;
+                               }
 
-               if (mapped_file) {
+                               attachment = e_mapi_attachment_new (object);
+                               e_mapi_object_add_attachment (object, attachment);
+
+                               ui32 = ATTACH_BY_VALUE;
+                               set_value (PidTagAttachMethod, &ui32);
+
+                               /* MSDN Documentation: When the supplied offset is -1 (0xFFFFFFFF), the
+                                * attachment is not rendered using the PR_RENDERING_POSITION property.
+                                * All values other than -1 indicate the position within PR_BODY at which
+                                * the attachment is to be rendered.
+                                */
+                               ui32 = -1;
+                               set_value (PidTagRenderingPosition, &ui32);
+
+                               set_value (PidTagAttachFilename, stored_filename ? stored_filename : 
split_name);
+                               set_value (PidTagAttachLongFilename, stored_filename ? stored_filename : 
split_name);
+
+                               data_cb = filelength;
+                               data_lpb = talloc_memdup (attachment, attach, data_cb);
+                               e_mapi_attachment_add_streamed (attachment, PidTagAttachDataBinary, data_cb, 
data_lpb);
+
+#if GLIB_CHECK_VERSION(2,21,3)
+                               g_mapped_file_unref (mapped_file);
+#else
+                               g_mapped_file_free (mapped_file);
+#endif
+                       } else if (error) {
+                               e_mapi_debug_print ("Could not map %s: %s \n", sfname_uri, error->message);
+                               g_error_free (error);
+                       }
+
+                       g_free (filename);
+               } else {
                        EMapiAttachment *attachment;
-                       guint8 *attach = (guint8 *) g_mapped_file_get_contents (mapped_file);
-                       guint filelength = g_mapped_file_get_length (mapped_file);
-                       const gchar *split_name;
+                       gsize len = -1;
+                       guchar *decoded = NULL;
+                       const gchar *content;
                        uint32_t ui32;
                        uint64_t data_cb;
                        uint8_t *data_lpb;
 
-                       if (g_str_has_prefix (filename, safeuid)) {
-                               split_name = (filename + strlen (safeuid) + strlen ("-"));
-                       } else {
-                               split_name = filename;
-                       }
+                       content = (const gchar *) i_cal_attach_get_data (attach);
+                       decoded = g_base64_decode (content, &len);
 
                        attachment = e_mapi_attachment_new (object);
                        e_mapi_object_add_attachment (object, attachment);
 
-                       #define set_value(pt,vl) {                                                            
  \
-                               if (!e_mapi_utils_add_property (&attachment->properties, pt, vl, attachment)) 
{ \
-                                       g_warning ("%s: Failed to set property 0x%x", G_STRFUNC, pt);         
  \
-                                                                                                             
  \
-                                       return;                                                               
  \
-                               }                                                                             
  \
-                       }
-
                        ui32 = ATTACH_BY_VALUE;
                        set_value (PidTagAttachMethod, &ui32);
 
@@ -1519,26 +1644,21 @@ e_mapi_cal_utils_add_attachments (EMapiObject *object,
                        ui32 = -1;
                        set_value (PidTagRenderingPosition, &ui32);
 
-                       set_value (PidTagAttachFilename, split_name);
-                       set_value (PidTagAttachLongFilename, split_name);
+                       if (stored_filename) {
+                               set_value (PidTagAttachFilename, stored_filename);
+                               set_value (PidTagAttachLongFilename, stored_filename);
+                       }
 
-                       data_cb = filelength;
-                       data_lpb = talloc_memdup (attachment, attach, data_cb);
+                       data_cb = len;
+                       data_lpb = talloc_memdup (attachment, decoded, data_cb);
                        e_mapi_attachment_add_streamed (attachment, PidTagAttachDataBinary, data_cb, 
data_lpb);
 
-                       #undef set_value
-
-#if GLIB_CHECK_VERSION(2,21,3)
-                       g_mapped_file_unref (mapped_file);
-#else
-                       g_mapped_file_free (mapped_file);
-#endif
-               } else if (error) {
-                       e_mapi_debug_print ("Could not map %s: %s \n", sfname_uri, error->message);
-                       g_error_free (error);
+                       g_free (decoded);
                }
 
-               g_free (filename);
+               #undef set_value
+
+               g_clear_object (&param);
        }
 
        g_free (safeuid);
@@ -1554,13 +1674,13 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
 {
        struct cal_cbdata *cbdata = (struct cal_cbdata *) user_data;
        ECalComponent *comp;
-       icalcomponent *ical_comp;
-       icalcomponent_kind kind;
+       ICalComponent *icomp;
+       ICalComponentKind kind;
        uint32_t flag32;
        uint8_t b;
-       icalproperty *prop;
-       struct icaltimetype dtstart, dtend, utc_dtstart, utc_dtend, all_day_dtstart = {0}, all_day_dtend = 
{0};
-       const icaltimezone *utc_zone;
+       ICalProperty *prop;
+       ICalTime *dtstart, *dtend, *utc_dtstart, *utc_dtend, *all_day_dtstart = NULL, *all_day_dtend = NULL;
+       ICalTimezone *utc_zone;
        const gchar *dtstart_tz_location, *dtend_tz_location, *text = NULL;
        time_t tt;
        gboolean is_all_day;
@@ -1573,17 +1693,17 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
        g_return_val_if_fail (pobject != NULL, FALSE);
 
        switch (cbdata->kind) {
-               case ICAL_VEVENT_COMPONENT:
-               case ICAL_VTODO_COMPONENT:
-               case ICAL_VJOURNAL_COMPONENT:
+               case I_CAL_VEVENT_COMPONENT:
+               case I_CAL_VTODO_COMPONENT:
+               case I_CAL_VJOURNAL_COMPONENT:
                        break;
                default:
                        return FALSE;
        }
 
        comp = cbdata->comp;
-       ical_comp = e_cal_component_get_icalcomponent (comp);
-       kind = icalcomponent_isa (ical_comp);
+       icomp = e_cal_component_get_icalcomponent (comp);
+       kind = i_cal_component_isa (icomp);
        g_return_val_if_fail (kind == cbdata->kind, FALSE);
 
        object = e_mapi_object_new (mem_ctx);
@@ -1601,58 +1721,54 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
                set_value (hex, &filetime);                             \
                } G_STMT_END
 
-       utc_zone = icaltimezone_get_utc_timezone ();
+       utc_zone = i_cal_timezone_get_utc_timezone ();
 
-       dtstart = icalcomponent_get_dtstart (ical_comp);
+       dtstart = i_cal_component_get_dtstart (icomp);
 
        /* For VEVENTs */
-       if (icalcomponent_get_first_property (ical_comp, ICAL_DTEND_PROPERTY) != 0)
-               dtend = icalcomponent_get_dtend (ical_comp);
+       if (e_cal_util_component_has_property (icomp, I_CAL_DTEND_PROPERTY))
+               dtend = i_cal_component_get_dtend (icomp);
        /* For VTODOs */
-       else if (icalcomponent_get_first_property (ical_comp, ICAL_DUE_PROPERTY) != 0)
-               dtend = icalcomponent_get_due (ical_comp);
+       else if (e_cal_util_component_has_property (icomp, I_CAL_DUE_PROPERTY) != 0)
+               dtend = i_cal_component_get_due (icomp);
        else
-               dtend = icalcomponent_get_dtstart (ical_comp);
+               dtend = i_cal_component_get_dtstart (icomp);
 
-       dtstart_tz_location = get_tzid_location (icaltime_get_tzid (dtstart), cbdata);
-       dtend_tz_location = get_tzid_location (icaltime_get_tzid (dtend), cbdata);
+       dtstart_tz_location = get_tzid_location (i_cal_time_get_tzid (dtstart), cbdata);
+       dtend_tz_location = get_tzid_location (i_cal_time_get_tzid (dtend), cbdata);
 
-       is_all_day = kind == ICAL_VEVENT_COMPONENT && icaltime_is_date (dtstart) && icaltime_is_date (dtend);
+       is_all_day = kind == I_CAL_VEVENT_COMPONENT && i_cal_time_is_date (dtstart) && i_cal_time_is_date 
(dtend);
        if (is_all_day) {
                const gchar *def_location;
-               icaltimezone *use_zone = NULL;
+               ICalTimezone *use_zone = NULL;
 
                /* all-day events expect times not in UTC but in local time;
                   if this differs from the server timezone, then the event
                   is shown spread among (two) days */
                def_location = get_tzid_location ("*default-zone*", cbdata);
                if (def_location && *def_location)
-                       use_zone = icaltimezone_get_builtin_timezone (def_location);
+                       use_zone = i_cal_timezone_get_builtin_timezone (def_location);
 
                if (!use_zone)
-                       use_zone = (icaltimezone *) utc_zone;
-
-               dtstart.is_date = 0;
-               dtstart.hour = 0;
-               dtstart.minute = 0;
-               dtstart.second = 0;
-               all_day_dtstart = icaltime_convert_to_zone (dtstart, use_zone);
-               dtstart.is_date = 1;
-               all_day_dtstart = icaltime_convert_to_zone (all_day_dtstart, (icaltimezone *) utc_zone);
-
-               dtend.is_date = 0;
-               dtend.hour = 0;
-               dtend.minute = 0;
-               dtend.second = 0;
-               all_day_dtend = icaltime_convert_to_zone (dtend, use_zone);
-               dtend.is_date = 1;
-               all_day_dtend = icaltime_convert_to_zone (all_day_dtend, (icaltimezone *) utc_zone);
+                       use_zone = utc_zone;
+
+               i_cal_time_set_is_date (dtstart, FALSE);
+               i_cal_time_set_time (dtstart, 0, 0, 0);
+               all_day_dtstart = i_cal_time_convert_to_zone (dtstart, use_zone);
+               i_cal_time_set_is_date (dtstart, TRUE);
+               all_day_dtstart = i_cal_time_convert_to_zone (all_day_dtstart, utc_zone);
+
+               i_cal_time_set_is_date (dtend, FALSE);
+               i_cal_time_set_time (dtend, 0, 0, 0);
+               all_day_dtend = i_cal_time_convert_to_zone (dtend, use_zone);
+               i_cal_time_set_is_date (dtend, TRUE);
+               all_day_dtend = i_cal_time_convert_to_zone (all_day_dtend, utc_zone);
        }
 
-       utc_dtstart = icaltime_convert_to_zone (dtstart, (icaltimezone *)utc_zone);
-       utc_dtend = icaltime_convert_to_zone (dtend, (icaltimezone *)utc_zone);
+       utc_dtstart = i_cal_time_convert_to_zone (dtstart, utc_zone);
+       utc_dtend = i_cal_time_convert_to_zone (dtend, utc_zone);
 
-       text = icalcomponent_get_summary (ical_comp);
+       text = i_cal_component_get_summary (icomp);
        if (!(text && *text))
                text = "";
        set_value (PidTagSubject, text);
@@ -1666,13 +1782,13 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
        set_value (PidTagMessageEditorFormat, &flag32);
 
        /* it'd be better to convert, then set it in unicode */
-       text = icalcomponent_get_description (ical_comp);
+       text = i_cal_component_get_description (icomp);
        if (!(text && *text) || !g_utf8_validate (text, -1, NULL))
                text = "";
        set_value (PidTagBody, text);
        text = NULL;
 
-       e_cal_component_get_categories_list (comp, &categories);
+       categories = e_cal_component_get_categories_list (comp);
        if (categories) {
                gint ii;
                GSList *c;
@@ -1695,15 +1811,16 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
 
                set_value (PidNameKeywords, &categories_array);
 
-               e_cal_component_free_categories_list (categories);
+               g_slist_free_full (categories, g_free);
        }
 
        /* Priority and Importance */
-       prop = icalcomponent_get_first_property (ical_comp, ICAL_PRIORITY_PROPERTY);
-       flag32 = prop ? get_prio_prop_from_priority (icalproperty_get_priority (prop)) : PRIORITY_NORMAL;
+       prop = i_cal_component_get_first_property (icomp, I_CAL_PRIORITY_PROPERTY);
+       flag32 = prop ? get_prio_prop_from_priority (i_cal_property_get_priority (prop)) : PRIORITY_NORMAL;
        set_value (PidTagPriority, &flag32);
-       flag32 = prop ? get_imp_prop_from_priority (icalproperty_get_priority (prop)) : IMPORTANCE_NORMAL;
+       flag32 = prop ? get_imp_prop_from_priority (i_cal_property_get_priority (prop)) : IMPORTANCE_NORMAL;
        set_value (PidTagImportance, &flag32);
+       g_clear_object (&prop);
 
        if (cbdata->ownername && cbdata->owneridtype && cbdata->ownerid) {
                set_value (PidTagSentRepresentingName, cbdata->ownername);
@@ -1724,18 +1841,20 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
        b = e_cal_component_has_alarms (comp);
        if (b) {
                /* We know there would be only a single alarm of type:DISPLAY [static properties of the 
backend] */
-               GList *alarm_uids = e_cal_component_get_alarm_uids (comp);
+               GSList *alarm_uids = e_cal_component_get_alarm_uids (comp);
                ECalComponentAlarm *alarm = e_cal_component_get_alarm (comp, (const gchar 
*)(alarm_uids->data));
                ECalComponentAlarmAction action;
-               e_cal_component_alarm_get_action (alarm, &action);
+
+               action = e_cal_component_alarm_get_action (alarm);
                if (action == E_CAL_COMPONENT_ALARM_DISPLAY) {
-                       ECalComponentAlarmTrigger trigger;
+                       ECalComponentAlarmTrigger *trigger;
                        gint dur_int = 0;
-                       e_cal_component_alarm_get_trigger (alarm, &trigger);
-                       switch (trigger.type) {
-                       case E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START :
-                               dur_int = (icaldurationtype_as_int (trigger.u.rel_duration)) / SECS_IN_MINUTE;
-                       /* we cannot set an alarm to popup after the start of an appointment on Exchange */
+
+                       trigger = e_cal_component_alarm_get_trigger (alarm);
+                       switch (e_cal_component_alarm_trigger_get_kind (trigger)) {
+                       case E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START:
+                               dur_int = (i_cal_duration_as_int (e_cal_component_alarm_trigger_get_duration 
(trigger))) / SECS_IN_MINUTE;
+                               /* we cannot set an alarm to popup after the start of an appointment on 
Exchange */
                                flag32 = (dur_int < 0) ? -(dur_int) : 0;
                                break;
                        default :
@@ -1743,14 +1862,14 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
                        }
                }
                e_cal_component_alarm_free (alarm);
-               cal_obj_uid_list_free (alarm_uids);
+               g_slist_free_full (alarm_uids, g_free);
        }
        if (!flag32)
                switch (kind) {
-                       case ICAL_VEVENT_COMPONENT:
+                       case I_CAL_VEVENT_COMPONENT:
                                flag32 = DEFAULT_APPT_REMINDER_MINS;
                                break;
-                       case ICAL_VTODO_COMPONENT:
+                       case I_CAL_VTODO_COMPONENT:
                                flag32 = DEFAULT_TASK_REMINDER_MINS;
                                break;
                        default:
@@ -1758,28 +1877,29 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
                }
        set_value (PidLidReminderSet, &b);
        set_value (PidLidReminderDelta, &flag32);
-       tt = icaltime_as_timet (utc_dtstart);
+       tt = i_cal_time_as_timet (utc_dtstart);
        set_timet_value (PidLidReminderTime, tt);
-       tt = icaltime_as_timet (utc_dtstart) - (flag32 * SECS_IN_MINUTE);
+       tt = i_cal_time_as_timet (utc_dtstart) - (flag32 * SECS_IN_MINUTE);
        /* ReminderNextTime: FIXME for recurrence */
        set_timet_value (PidLidReminderSignalTime, tt);
 
        /* Sensitivity, Private */
        flag32 = olNormal;      /* default */
        b = 0;                  /* default */
-       prop = icalcomponent_get_first_property (ical_comp, ICAL_CLASS_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_CLASS_PROPERTY);
        if (prop)
-               flag32 = get_prop_from_class (icalproperty_get_class (prop));
+               flag32 = get_prop_from_class (i_cal_property_get_class (prop));
        if (flag32 == olPrivate || flag32 == olConfidential)
                b = 1;
        set_value (PidTagSensitivity, &flag32);
        set_value (PidLidPrivate, &b);
+       g_clear_object (&prop);
 
-       tt = icaltime_as_timet (is_all_day ? all_day_dtstart : utc_dtstart);
+       tt = i_cal_time_as_timet (is_all_day ? all_day_dtstart : utc_dtstart);
        set_timet_value (PidLidCommonStart, tt);
        set_timet_value (PidTagStartDate, tt);
 
-       tt = icaltime_as_timet (is_all_day ? all_day_dtend : utc_dtend);
+       tt = i_cal_time_as_timet (is_all_day ? all_day_dtend : utc_dtend);
        set_timet_value (PidLidCommonEnd, tt);
        set_timet_value (PidTagEndDate, tt);
 
@@ -1792,17 +1912,19 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
        b = 0;
        set_value (PidTagRtfInSync, &b);
 
-       if (kind == ICAL_VEVENT_COMPONENT) {
+       if (kind == I_CAL_VEVENT_COMPONENT) {
                const gchar *mapi_tzid;
                struct SBinary_short start_tz, end_tz;
+               ICalDuration *duration;
+               ICalTime *itt;
 
                set_value (PidLidAppointmentMessageClass, IPM_APPOINTMENT);
 
                /* Busy Status */
                flag32 = olBusy;
-               prop = icalcomponent_get_first_property (ical_comp, ICAL_TRANSP_PROPERTY);
+               prop = i_cal_component_get_first_property (icomp, I_CAL_TRANSP_PROPERTY);
                if (prop)
-                       flag32 = get_prop_from_transp (icalproperty_get_transp (prop));
+                       flag32 = get_prop_from_transp (i_cal_property_get_transp (prop));
                if (cbdata->meeting_type == MEETING_CANCEL)
                        flag32 = olFree;
                set_value (PidLidIntendedBusyStatus, &flag32);
@@ -1815,9 +1937,10 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
                        set_value (PidLidBusyStatus, &flag32);
                } else
                        set_value (PidLidBusyStatus, &flag32);
+               g_clear_object (&prop);
 
                /* Location */
-               text = icalcomponent_get_location (ical_comp);
+               text = i_cal_component_get_location (icomp);
                if (!(text && *text))
                        text = "";
                set_value (PidLidLocation, text);
@@ -1832,7 +1955,7 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
                set_value (PidLidAppointmentSubType, &b);
 
                /* Start */
-               tt = icaltime_as_timet (is_all_day ? all_day_dtstart : utc_dtstart);
+               tt = i_cal_time_as_timet (is_all_day ? all_day_dtstart : utc_dtstart);
                set_timet_value (PidLidAppointmentStartWhole, tt);
                /* FIXME: for recurrence */
                set_timet_value (PidLidClipStart, tt);
@@ -1853,7 +1976,7 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
                set_value (PidLidTimeZoneDescription, mapi_tzid ? mapi_tzid : "");
 
                /* End */
-               tt = icaltime_as_timet (is_all_day ? all_day_dtend : utc_dtend);
+               tt = i_cal_time_as_timet (is_all_day ? all_day_dtend : utc_dtend);
                set_timet_value (PidLidAppointmentEndWhole, tt);
                /* FIXME: for recurrence */
                set_timet_value (PidLidClipEnd, tt);
@@ -1869,41 +1992,43 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
                   to properly determine SDT/DST and appear in OWA (Bug #629057). */
                if (e_cal_component_has_recurrences (comp)) {
                        uint64_t pltz;
-                       icaltimezone *ictz;
+                       ICalTimezone *ictz;
                        const gchar *zone_location = dtstart_tz_location;
 
                        if (!zone_location)
                                zone_location = get_tzid_location ("*default-zone*", cbdata);
 
-                       ictz = icaltimezone_get_builtin_timezone (zone_location);
+                       ictz = i_cal_timezone_get_builtin_timezone (zone_location);
                        pltz = e_mapi_cal_util_mapi_tz_pidlidtimezone (ictz);
                        set_value (PidLidTimeZone, &pltz);
                }
 
                /* Duration */
-               flag32 = icaldurationtype_as_int (icaltime_subtract (dtend, dtstart));
+               duration = i_cal_time_subtract (dtend, dtstart);
+               flag32 = i_cal_duration_as_int (duration);
                flag32 /= MINUTES_IN_HOUR;
                set_value (PidLidAppointmentDuration, &flag32);
+               g_clear_object (&duration);
 
                if (e_cal_component_has_recurrences (comp)) {
                        GSList *rrule_list = NULL;
-                       struct icalrecurrencetype *rt = NULL;
+                       ICalRecurrence *rt = NULL;
 
-                       e_cal_component_get_rrule_list (comp, &rrule_list);
-                       rt = (struct icalrecurrencetype *)(rrule_list->data);
+                       rrule_list = e_cal_component_get_rrules (comp);
+                       rt = rrule_list->data;
 
-                       if (rt->freq == ICAL_DAILY_RECURRENCE)
+                       if (i_cal_recurrence_get_freq (rt) == I_CAL_DAILY_RECURRENCE)
                                flag32 = rectypeDaily;
-                       else if (rt->freq == ICAL_WEEKLY_RECURRENCE)
+                       else if (i_cal_recurrence_get_freq (rt) == I_CAL_WEEKLY_RECURRENCE)
                                flag32 = rectypeWeekly;
-                       else if (rt->freq == ICAL_MONTHLY_RECURRENCE)
+                       else if (i_cal_recurrence_get_freq (rt) == I_CAL_MONTHLY_RECURRENCE)
                                flag32 = rectypeMonthly;
-                       else if (rt->freq == ICAL_YEARLY_RECURRENCE)
+                       else if (i_cal_recurrence_get_freq (rt) == I_CAL_YEARLY_RECURRENCE)
                                flag32 = rectypeYearly;
                        else
                                flag32 = rectypeNone;
 
-                       e_cal_component_free_recur_list (rrule_list);
+                       g_slist_free_full (rrule_list, g_object_unref);
                } else
                        flag32 = rectypeNone;
                set_value (PidLidRecurrenceType, &flag32);
@@ -1912,7 +2037,7 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
                if (!flag32) {
                        gchar *propval;
 
-                       propval = e_mapi_cal_utils_get_icomp_x_prop (e_cal_component_get_icalcomponent 
(comp), "X-EVOLUTION-MAPI-OWNER-APPT-ID");
+                       propval = e_cal_util_component_dup_x_property (e_cal_component_get_icalcomponent 
(comp), "X-EVOLUTION-MAPI-OWNER-APPT-ID");
                        if (propval && *propval) {
                                mapi_id_t as_id = 0;
 
@@ -2003,8 +2128,10 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
                        b = 1;
                        set_value (PidLidFInvited, &b);
 
-                       tt = icaltime_as_timet (icaltime_current_time_with_zone (utc_zone));
+                       itt = i_cal_time_current_time_with_zone (utc_zone);
+                       tt = i_cal_time_as_timet (itt);
                        set_timet_value (PidLidAttendeeCriticalChange, tt);
+                       g_clear_object (&itt);
 
                        break;
                case MEETING_REQUEST_RCVD :
@@ -2049,7 +2176,7 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
                        #define prefix_subject(prefix) {                                        \
                                const gchar *summary;                                           \
                                                                                                \
-                               summary = icalcomponent_get_summary (ical_comp);                \
+                               summary = i_cal_component_get_summary (icomp);                  \
                                if (!(summary && *summary))                                     \
                                        summary = "";                                           \
                                                                                                \
@@ -2097,8 +2224,10 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
                        flag32 = mtgEmpty;
                        set_value (PidLidMeetingType, &flag32);
 
-                       tt = icaltime_as_timet (icaltime_current_time_with_zone (utc_zone));
+                       itt = i_cal_time_current_time_with_zone (utc_zone);
+                       tt = i_cal_time_as_timet (itt);
                        set_timet_value (PidLidAppointmentReplyTime, tt);
+                       g_clear_object (&itt);
 
                        break;
                case NOT_A_MEETING :
@@ -2142,7 +2271,7 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
                b = 0;
                set_value (PidLidAppointmentCounterProposal, &b);
 
-       } else if (kind == ICAL_VTODO_COMPONENT) {
+       } else if (kind == I_CAL_VTODO_COMPONENT) {
                gdouble d;
 
                set_value (PidTagMessageClass, IPM_TASK);
@@ -2155,11 +2284,12 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
                flag32 = olTaskNotStarted;      /* default */
                b = 0;                          /* default */
                d = 0.0;
-               prop = icalcomponent_get_first_property (ical_comp, ICAL_PERCENTCOMPLETE_PROPERTY);
+               prop = i_cal_component_get_first_property (icomp, I_CAL_PERCENTCOMPLETE_PROPERTY);
                if (prop)
-                       d = 0.01 * icalproperty_get_percentcomplete (prop);
+                       d = 0.01 * i_cal_property_get_percentcomplete (prop);
+               g_clear_object (&prop);
 
-               flag32 = get_prop_from_taskstatus (icalcomponent_get_status (ical_comp));
+               flag32 = get_prop_from_taskstatus (i_cal_component_get_status (icomp));
                if (flag32 == olTaskComplete) {
                        b = 1;
                        d = 1.0;
@@ -2171,35 +2301,39 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
 
                /* Date completed */
                if (b) {
-                       struct icaltimetype completed;
-                       prop = icalcomponent_get_first_property (ical_comp, ICAL_COMPLETED_PROPERTY);
-                       completed = icalproperty_get_completed (prop);
+                       ICalTime *completed;
+
+                       prop = i_cal_component_get_first_property (icomp, I_CAL_COMPLETED_PROPERTY);
+                       if (prop) {
+                               completed = i_cal_property_get_completed (prop);
 
-                       completed.hour = completed.minute = completed.second = 0;
-                       completed.is_date = 1;
-                       completed.zone = utc_zone;
+                               i_cal_time_set_time (completed, 0, 0, 0);
+                               i_cal_time_set_is_date (completed, TRUE);
+                               i_cal_time_set_timezone (completed, utc_zone);
 
-                       tt = icaltime_as_timet (completed);
-                       set_timet_value (PidLidTaskDateCompleted, tt);
+                               tt = i_cal_time_as_timet (completed);
+                               set_timet_value (PidLidTaskDateCompleted, tt);
+                               g_clear_object (&completed);
+                       }
                }
 
                /* Start */
-               dtstart.hour = dtstart.minute = dtstart.second = 0;
-               dtstart.is_date = 1;
-               dtstart.zone = utc_zone;
+               i_cal_time_set_time (dtstart, 0, 0, 0);
+               i_cal_time_set_is_date (dtstart, TRUE);
+               i_cal_time_set_timezone (dtstart, utc_zone);
 
-               tt = icaltime_as_timet (dtstart);
-               if (!icaltime_is_null_time (dtstart)) {
+               tt = i_cal_time_as_timet (dtstart);
+               if (!i_cal_time_is_null_time (dtstart)) {
                        set_timet_value (PidLidTaskStartDate, tt);
                }
 
                /* Due */
-               dtend.hour = dtend.minute = dtend.second = 0;
-               dtend.is_date = 1;
-               dtend.zone = utc_zone;
+               i_cal_time_set_time (dtend, 0, 0, 0);
+               i_cal_time_set_is_date (dtend, TRUE);
+               i_cal_time_set_timezone (dtend, utc_zone);
 
-               tt = icaltime_as_timet (dtend);
-               if (!icaltime_is_null_time (dtend)) {
+               tt = i_cal_time_as_timet (dtend);
+               if (!i_cal_time_is_null_time (dtend)) {
                        set_timet_value (PidLidTaskDueDate, tt);
                }
 
@@ -2207,7 +2341,7 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
                b = 0;
                set_value (PidLidTaskFRecurring, &b);
 
-       } else if (kind == ICAL_VJOURNAL_COMPONENT) {
+       } else if (kind == I_CAL_VJOURNAL_COMPONENT) {
                uint32_t color = olYellow;
 
                set_value (PidTagMessageClass, IPM_STICKYNOTE);
@@ -2246,5 +2380,12 @@ e_mapi_cal_utils_comp_to_object (EMapiConnection *conn,
                e_mapi_debug_dump_object (object, TRUE, 3);
        }
 
+       g_clear_object (&dtstart);
+       g_clear_object (&dtend);
+       g_clear_object (&utc_dtstart);
+       g_clear_object (&utc_dtend);
+       g_clear_object (&all_day_dtstart);
+       g_clear_object (&all_day_dtend);
+
        return TRUE;
 }
diff --git a/src/libexchangemapi/e-mapi-cal-utils.h b/src/libexchangemapi/e-mapi-cal-utils.h
index 1af3db6..b10cea8 100644
--- a/src/libexchangemapi/e-mapi-cal-utils.h
+++ b/src/libexchangemapi/e-mapi-cal-utils.h
@@ -49,7 +49,7 @@ typedef enum {
 } MAPIMeetingOptions;
 
 struct cal_cbdata {
-       gint kind;
+       ICalComponentKind kind;
        ECalComponent *comp;
        gboolean is_modify;
 
@@ -71,7 +71,7 @@ struct cal_cbdata {
 
        /* custom callback to get timezone from a backend */
        gpointer get_tz_data;
-       icaltimezone * (*get_timezone)(gpointer get_tz_data, const gchar *tzid);
+       ICalTimezone * (*get_timezone)(ETimezoneCache *get_tz_data, const gchar *tzid);
 };
 
 void           e_mapi_cal_util_generate_globalobjectid         (gboolean is_clean,
@@ -93,7 +93,7 @@ gboolean      e_mapi_cal_utils_get_free_busy_data             (EMapiConnection *conn,
 
 ECalComponent *        e_mapi_cal_util_object_to_comp                  (EMapiConnection *conn,
                                                                 EMapiObject *object,
-                                                                icalcomponent_kind kind,
+                                                                ICalComponentKind kind,
                                                                 gboolean is_reply,
                                                                 const gchar *use_uid,
                                                                 GSList **detached_components);
@@ -105,9 +105,6 @@ gboolean    e_mapi_cal_utils_comp_to_object                 (EMapiConnection *conn,
                                                                 GCancellable *cancellable,
                                                                 GError **perror);
 
-gchar *                e_mapi_cal_utils_get_icomp_x_prop               (icalcomponent *comp,
-                                                                const gchar *key);
-
 G_END_DECLS
 
 #endif
diff --git a/src/libexchangemapi/e-mapi-mail-utils.c b/src/libexchangemapi/e-mapi-mail-utils.c
index 96ae902..2f9153e 100644
--- a/src/libexchangemapi/e-mapi-mail-utils.c
+++ b/src/libexchangemapi/e-mapi-mail-utils.c
@@ -281,36 +281,36 @@ is_apple_attach (EMapiAttachment *attach, guint32 *data_len, guint32 *resource_l
 
 typedef struct {
        GHashTable *tzids;
-       icalcomponent *icalcomp;
+       ICalComponent *icomp;
 } ForeachTZIDData;
 
 static void
-add_timezones_cb (icalparameter *param,
+add_timezones_cb (ICalParameter *param,
                  gpointer data)
 {
        ForeachTZIDData *tz_data = data;
        const gchar *tzid;
-       icaltimezone *zone = NULL;
-       icalcomponent *vtimezone_comp;
+       ICalTimezone *zone = NULL;
+       ICalComponent *vtimezone_comp;
 
        /* Get the TZID string from the parameter. */
-       tzid = icalparameter_get_tzid (param);
+       tzid = i_cal_parameter_get_tzid (param);
        if (!tzid || g_hash_table_lookup (tz_data->tzids, tzid))
                return;
 
        /* Look for the timezone */
-       zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+       zone = i_cal_timezone_get_builtin_timezone_from_tzid (tzid);
        if (!zone)
                return;
 
        /* 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;
 
-       icalcomponent_add_component (tz_data->icalcomp, icalcomponent_new_clone (vtimezone_comp));
+       i_cal_component_take_component (tz_data->icomp, i_cal_component_new_clone (vtimezone_comp));
 
-       g_hash_table_insert (tz_data->tzids, (gchar *) tzid, (gchar *) tzid);
+       g_hash_table_insert (tz_data->tzids, g_strdup (tzid), GINT_TO_POINTER (1));
 }
 
 static gchar *
@@ -319,11 +319,11 @@ build_ical_string (EMapiConnection *conn,
                   const gchar *msg_class)
 {
        gchar *ical_string = NULL, *use_uid;
-       icalcomponent_kind ical_kind = ICAL_NO_COMPONENT;
-       icalproperty_method ical_method = ICAL_METHOD_NONE;
+       ICalComponentKind kind = I_CAL_NO_COMPONENT;
+       ICalPropertyMethod method = I_CAL_METHOD_NONE;
        const uint64_t *pmid;
        ECalComponent *comp;
-       icalcomponent *icalcomp;
+       ICalComponent *icomp;
        GSList *detached_components = NULL, *iter;
 
        g_return_val_if_fail (conn != NULL, NULL);
@@ -331,23 +331,23 @@ build_ical_string (EMapiConnection *conn,
        g_return_val_if_fail (msg_class != NULL, NULL);
 
        if (g_ascii_strcasecmp (msg_class, IPM_SCHEDULE_MEETING_REQUEST) == 0) {
-               ical_method = ICAL_METHOD_REQUEST;
-               ical_kind = ICAL_VEVENT_COMPONENT;
+               method = I_CAL_METHOD_REQUEST;
+               kind = I_CAL_VEVENT_COMPONENT;
        } else if (g_ascii_strcasecmp (msg_class, IPM_SCHEDULE_MEETING_CANCELED) == 0) {
-               ical_method = ICAL_METHOD_CANCEL;
-               ical_kind = ICAL_VEVENT_COMPONENT;
+               method = I_CAL_METHOD_CANCEL;
+               kind = I_CAL_VEVENT_COMPONENT;
        } else if (g_str_has_prefix (msg_class, IPM_SCHEDULE_MEETING_RESP_PREFIX)) {
-               ical_method = ICAL_METHOD_REPLY;
-               ical_kind = ICAL_VEVENT_COMPONENT;
+               method = I_CAL_METHOD_REPLY;
+               kind = I_CAL_VEVENT_COMPONENT;
        } else if (g_ascii_strcasecmp (msg_class, IPM_APPOINTMENT) == 0) {
-               ical_method = ICAL_METHOD_NONE;
-               ical_kind = ICAL_VEVENT_COMPONENT;
+               method = I_CAL_METHOD_NONE;
+               kind = I_CAL_VEVENT_COMPONENT;
        } else if (g_ascii_strcasecmp (msg_class, IPM_TASK) == 0) {
-               ical_method = ICAL_METHOD_NONE;
-               ical_kind = ICAL_VTODO_COMPONENT;
+               method = I_CAL_METHOD_NONE;
+               kind = I_CAL_VTODO_COMPONENT;
        } else if (g_ascii_strcasecmp (msg_class, IPM_STICKYNOTE) == 0) {
-               ical_method = ICAL_METHOD_NONE;
-               ical_kind = ICAL_VJOURNAL_COMPONENT;
+               method = I_CAL_METHOD_NONE;
+               kind = I_CAL_VJOURNAL_COMPONENT;
        } else {
                return NULL;
        }
@@ -358,41 +358,41 @@ build_ical_string (EMapiConnection *conn,
        else
                use_uid = e_util_generate_uid ();
 
-       comp = e_mapi_cal_util_object_to_comp (conn, object, ical_kind, ical_method == ICAL_METHOD_REPLY, 
use_uid, &detached_components);
+       comp = e_mapi_cal_util_object_to_comp (conn, object, kind, method == I_CAL_METHOD_REPLY, use_uid, 
&detached_components);
 
        g_free (use_uid);
 
        if (!comp)
                return NULL;
 
-       if (ical_method != ICAL_METHOD_NONE || detached_components) {
+       if (method != I_CAL_METHOD_NONE || detached_components) {
                ForeachTZIDData tz_data;
-               icalcomponent *clone;
+               ICalComponent *clone;
 
-               clone = icalcomponent_new_clone (e_cal_component_get_icalcomponent (comp));
+               clone = i_cal_component_new_clone (e_cal_component_get_icalcomponent (comp));
 
-               icalcomp = e_cal_util_new_top_level ();
-               if (ical_method != ICAL_METHOD_NONE)
-                       icalcomponent_set_method (icalcomp, ical_method);
+               icomp = e_cal_util_new_top_level ();
+               if (method != I_CAL_METHOD_NONE)
+                       i_cal_component_set_method (icomp, method);
 
-               tz_data.tzids = g_hash_table_new (g_str_hash, g_str_equal);
-               tz_data.icalcomp = icalcomp;
+               tz_data.tzids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+               tz_data.icomp = icomp;
 
                /* Add timezones first */
-               icalcomponent_foreach_tzid (clone, add_timezones_cb, &tz_data);
+               i_cal_component_foreach_tzid (clone, add_timezones_cb, &tz_data);
 
                g_hash_table_destroy (tz_data.tzids);
 
                /* Then the components */
-               icalcomponent_add_component (icalcomp, clone);
+               i_cal_component_take_component (icomp, clone);
                for (iter = detached_components; iter; iter = g_slist_next (iter)) {
-                       icalcomponent_add_component (icalcomp,
-                               icalcomponent_new_clone (e_cal_component_get_icalcomponent (iter->data)));
+                       i_cal_component_take_component (icomp,
+                               i_cal_component_new_clone (e_cal_component_get_icalcomponent (iter->data)));
                }
 
-               ical_string = icalcomponent_as_ical_string_r (icalcomp);
+               ical_string = i_cal_component_as_ical_string_r (icomp);
 
-               icalcomponent_free (icalcomp);
+               g_object_unref (icomp);
        } else {
                ical_string = e_cal_component_get_as_string (comp);
        }
diff --git a/src/libexchangemapi/e-mapi-utils.h b/src/libexchangemapi/e-mapi-utils.h
index 4fc9baf..800a421 100644
--- a/src/libexchangemapi/e-mapi-utils.h
+++ b/src/libexchangemapi/e-mapi-utils.h
@@ -30,7 +30,7 @@
 #include "e-mapi-debug.h"
 #include "e-mapi-connection.h"
 
-#define e_mapi_return_data_cal_error_if_fail(expr, _code)                      \
+#define e_mapi_return_client_error_if_fail(expr, _code)                                \
        G_STMT_START {                                                          \
                if (G_LIKELY (expr)) {                                          \
                } else {                                                        \
@@ -38,7 +38,7 @@
                                G_LOG_LEVEL_CRITICAL,                           \
                                "file %s: line %d (%s): assertion `%s' failed", \
                                __FILE__, __LINE__, G_STRFUNC, #expr);          \
-                       g_set_error (error, E_DATA_CAL_ERROR, (_code),          \
+                       g_set_error (error, E_CLIENT_ERROR, (_code),            \
                                "file %s: line %d (%s): assertion `%s' failed", \
                                __FILE__, __LINE__, G_STRFUNC, #expr);          \
                        return;                                                 \


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