[evolution-ews/wip/mcrha/eds-libical-glib] Port to libical-glib



commit b86a436a4bf870230ed36915bca153abb397d3bb
Author: Milan Crha <mcrha redhat com>
Date:   Wed Apr 10 12:28:28 2019 +0200

    Port to libical-glib

 CMakeLists.txt                                     |    7 +-
 src/calendar/e-cal-backend-ews-factory.c           |    6 +-
 src/calendar/e-cal-backend-ews-utils.c             | 1028 +++++++------
 src/calendar/e-cal-backend-ews-utils.h             |   37 +-
 src/calendar/e-cal-backend-ews.c                   | 1559 +++++++++++---------
 src/camel/camel-ews-folder.c                       |   38 +-
 src/configuration/e-ews-subscribe-foreign-folder.c |    2 +-
 src/server/CMakeLists.txt                          |    3 -
 src/server/e-ews-calendar-utils.c                  |  604 ++++----
 src/server/e-ews-calendar-utils.h                  |    8 +-
 src/server/e-ews-connection.c                      |   59 +-
 src/server/e-ews-connection.h                      |    4 +-
 src/server/e-ews-item.c                            |   18 +-
 src/server/e-ews-item.h                            |    3 -
 tests/ews-test-timezones.c                         |   45 +-
 15 files changed, 1906 insertions(+), 1515 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dbc58832..51e98e5b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -123,9 +123,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})
@@ -137,7 +137,6 @@ pkg_check_modules(GNOME_PLATFORM REQUIRED
        gtk+-3.0>=${gdk_minimum_version}
 )
 
-pkg_check_modules(LIBICAL REQUIRED libical)
 pkg_check_modules(SOUP REQUIRED libsoup-2.4>=${soup_minimum_version})
 
 # ******************************
@@ -205,7 +204,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(ewsdatadir evolution-data-server-1.2 privdatadir)
diff --git a/src/calendar/e-cal-backend-ews-factory.c b/src/calendar/e-cal-backend-ews-factory.c
index 7f176fdf..06f01fb7 100644
--- a/src/calendar/e-cal-backend-ews-factory.c
+++ b/src/calendar/e-cal-backend-ews-factory.c
@@ -64,7 +64,7 @@ e_cal_backend_ews_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_EWS;
 }
 
@@ -88,7 +88,7 @@ e_cal_backend_ews_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_EWS;
 }
 
@@ -112,7 +112,7 @@ e_cal_backend_ews_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_EWS;
 }
 
diff --git a/src/calendar/e-cal-backend-ews-utils.c b/src/calendar/e-cal-backend-ews-utils.c
index 7d4f5beb..c6396894 100644
--- a/src/calendar/e-cal-backend-ews-utils.c
+++ b/src/calendar/e-cal-backend-ews-utils.c
@@ -48,7 +48,7 @@
 #include "e-cal-backend-ews-utils.h"
 
 /*
- * A bunch of global variables used to map the icaltimezone to MSDN[0] format.
+ * A bunch of global variables used to map the ICalTimezone to MSDN[0] format.
  * Also, some auxiliar functions to translate from one tz type to another.
  *
  * [0]: http://msdn.microsoft.com/en-us/library/ms912391(v=winembedded.11).aspx
@@ -218,17 +218,17 @@ e_cal_backend_ews_tz_util_get_ical_equivalent (const gchar *msdn_tz_location)
 }
 
 /*
- * Iterate over the icalcomponent properties and collect attendees
+ * Iterate over the ICalComponent properties and collect attendees
  */
 void
-e_ews_collect_attendees (icalcomponent *comp,
+e_ews_collect_attendees (ICalComponent *comp,
                          GSList **required,
                          GSList **optional,
                          GSList **resource,
                         gboolean *out_rsvp_requested)
 {
-       icalproperty *prop;
-       icalparameter *param;
+       ICalProperty *prop;
+       ICalParameter *param;
        const gchar *str = NULL;
        const gchar *org_email_address = NULL;
 
@@ -239,11 +239,11 @@ e_ews_collect_attendees (icalcomponent *comp,
        org_email_address = e_ews_collect_organizer (comp);
 
        /* iterate over every attendee property */
-       for (prop = icalcomponent_get_first_property (comp, ICAL_ATTENDEE_PROPERTY);
-               prop != NULL;
-               prop = icalcomponent_get_next_property (comp, ICAL_ATTENDEE_PROPERTY)) {
+       for (prop = i_cal_component_get_first_property (comp, I_CAL_ATTENDEE_PROPERTY);
+            prop;
+            g_object_unref (prop), prop = i_cal_component_get_next_property (comp, I_CAL_ATTENDEE_PROPERTY)) 
{
 
-               str = icalproperty_get_attendee (prop);
+               str = i_cal_property_get_attendee (prop);
 
                if (!str || !*str)
                        continue;
@@ -257,46 +257,52 @@ e_ews_collect_attendees (icalcomponent *comp,
 
                /* if this attenddee is the orgenizer - dont add him/her
                 in some cases there is no maito for email if meeting orginazer */
-               if (g_ascii_strcasecmp (org_email_address, str) == 0) continue;
+               if (g_ascii_strcasecmp (org_email_address, str) == 0)
+                       continue;
 
                /* figure type of attendee, add to relevant list */
-               param = icalproperty_get_first_parameter (prop, ICAL_ROLE_PARAMETER);
+               param = i_cal_property_get_first_parameter (prop, I_CAL_ROLE_PARAMETER);
 
                /*in case of new time proposal the role parameter is not a part of ical*/
-               if (!param) continue;
+               if (!param)
+                       continue;
 
-               switch (icalparameter_get_role (param)) {
-               case ICAL_ROLE_OPTPARTICIPANT:
+               switch (i_cal_parameter_get_role (param)) {
+               case I_CAL_ROLE_OPTPARTICIPANT:
                        *optional = g_slist_append (*optional, (gpointer)str);
 
                        if (out_rsvp_requested && *out_rsvp_requested) {
-                               icalparameter *rsvp;
+                               ICalParameter *rsvp;
 
-                               rsvp = icalproperty_get_first_parameter (prop, ICAL_RSVP_PARAMETER);
-                               if (rsvp && icalparameter_get_rsvp (rsvp) == ICAL_RSVP_FALSE)
+                               rsvp = i_cal_property_get_first_parameter (prop, I_CAL_RSVP_PARAMETER);
+                               if (rsvp && i_cal_parameter_get_rsvp (rsvp) == I_CAL_RSVP_FALSE)
                                        *out_rsvp_requested = FALSE;
+                               g_clear_object (&rsvp);
                        }
                        break;
-               case ICAL_ROLE_CHAIR:
-               case ICAL_ROLE_REQPARTICIPANT:
+               case I_CAL_ROLE_CHAIR:
+               case I_CAL_ROLE_REQPARTICIPANT:
                        *required = g_slist_append (*required, (gpointer)str);
 
                        if (out_rsvp_requested && *out_rsvp_requested) {
-                               icalparameter *rsvp;
+                               ICalParameter *rsvp;
 
-                               rsvp = icalproperty_get_first_parameter (prop, ICAL_RSVP_PARAMETER);
-                               if (rsvp && icalparameter_get_rsvp (rsvp) == ICAL_RSVP_FALSE)
+                               rsvp = i_cal_property_get_first_parameter (prop, I_CAL_RSVP_PARAMETER);
+                               if (rsvp && i_cal_parameter_get_rsvp (rsvp) == I_CAL_RSVP_FALSE)
                                        *out_rsvp_requested = FALSE;
+                               g_clear_object (&rsvp);
                        }
                        break;
-               case ICAL_ROLE_NONPARTICIPANT:
+               case I_CAL_ROLE_NONPARTICIPANT:
                        *resource = g_slist_append (*resource, (gpointer)str);
                        break;
-               case ICAL_ROLE_X:
-               case ICAL_ROLE_NONE:
+               case I_CAL_ROLE_X:
+               case I_CAL_ROLE_NONE:
                        /* Ignore these for now */
                        break;
                }
+
+               g_object_unref (param);
        }
 
        if (*required == NULL && *optional == NULL && *resource == NULL && org_email_address != NULL)
@@ -306,25 +312,29 @@ e_ews_collect_attendees (icalcomponent *comp,
 gint
 ews_get_alarm (ECalComponent *comp)
 {
-       GList *alarm_uids = e_cal_component_get_alarm_uids (comp);
-       ECalComponentAlarm *alarm = e_cal_component_get_alarm (comp, (const gchar *) (alarm_uids->data));
+       GSList *alarm_uids = e_cal_component_get_alarm_uids (comp);
+       ECalComponentAlarm *alarm;
        ECalComponentAlarmAction action;
-       ECalComponentAlarmTrigger trigger;
        gint dur_int = 0;
 
-       e_cal_component_alarm_get_action (alarm, &action);
+       alarm_uids = e_cal_component_get_alarm_uids (comp);
+       if (!alarm_uids)
+               return dur_int;
+
+       alarm = e_cal_component_get_alarm (comp, (const gchar *) (alarm_uids->data));
+
+       action = e_cal_component_alarm_get_action (alarm);
        if (action == E_CAL_COMPONENT_ALARM_DISPLAY) {
-               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) * -1;
-                       break;
-               default:
-                       break;
+               ECalComponentAlarmTrigger *trigger;
+
+               trigger = e_cal_component_alarm_get_trigger (alarm);
+               if (trigger && e_cal_component_alarm_trigger_get_kind (trigger) == 
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) * -1;
                }
        }
        e_cal_component_alarm_free (alarm);
-       cal_obj_uid_list_free (alarm_uids);
+       g_slist_free_full (alarm_uids, g_free);
+
        return dur_int;
 }
 
@@ -332,56 +342,59 @@ void
 ews_set_alarm (ESoapMessage *msg,
                ECalComponent *comp,
               ETimezoneCache *timezone_cache,
-              icalcomponent *vcalendar,
+              ICalComponent *vcalendar,
               gboolean with_due_by)
 {
        /* We know there would be only a single alarm in EWS calendar item */
-       GList *alarm_uids = e_cal_component_get_alarm_uids (comp);
-       ECalComponentAlarm *alarm = e_cal_component_get_alarm (comp, (const gchar *) (alarm_uids->data));
+       GSList *alarm_uids;
+       ECalComponentAlarm *alarm;
        ECalComponentAlarmAction action;
 
+       alarm_uids = e_cal_component_get_alarm_uids (comp);
+       if (!alarm_uids)
+               return;
+
+       alarm = e_cal_component_get_alarm (comp, (const gchar *) (alarm_uids->data));
+
        e_ews_message_write_string_parameter (msg, "ReminderIsSet", NULL, "true");
-       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) * -1;
+               trigger = e_cal_component_alarm_get_trigger (alarm);
+               if (trigger && e_cal_component_alarm_trigger_get_kind (trigger) == 
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) * -1;
                        e_ews_message_write_int_parameter (msg, "ReminderMinutesBeforeStart", NULL, dur_int);
                        if (with_due_by) {
-                               struct icaltimetype dtstart;
+                               ICalTime *dtstart;
 
                                dtstart = e_cal_backend_ews_get_datetime_with_zone (timezone_cache, 
vcalendar, e_cal_component_get_icalcomponent (comp),
-                                       ICAL_DTSTART_PROPERTY, icalproperty_get_dtstart);
+                                       I_CAL_DTSTART_PROPERTY, i_cal_property_get_dtstart);
 
-                               if (!icaltime_is_null_time (dtstart)) {
+                               if (dtstart && !i_cal_time_is_null_time (dtstart)) {
                                        e_ews_message_write_time_parameter (msg, "ReminderDueBy", NULL,
-                                               icaltime_as_timet_with_zone (dtstart, 
icaltimezone_get_utc_timezone ()));
+                                               i_cal_time_as_timet_with_zone (dtstart, 
i_cal_timezone_get_utc_timezone ()));
                                }
+
+                               g_clear_object (&dtstart);
                        }
-                       break;
-               default:
-                       break;
                }
        }
        e_cal_component_alarm_free (alarm);
-       cal_obj_uid_list_free (alarm_uids);
-
+       g_slist_free_full (alarm_uids, g_free);
 }
 
 static void
 ewscal_set_date (ESoapMessage *msg,
                  const gchar *name,
-                 icaltimetype *t)
+                 ICalTime *itt)
 {
        gchar *str;
 
        str = g_strdup_printf (
                "%04d-%02d-%02d",
-               t->year, t->month, t->day);
+               i_cal_time_get_year (itt), i_cal_time_get_month (itt), i_cal_time_get_day (itt));
 
        e_ews_message_write_string_parameter (msg, name, NULL, str);
        g_free (str);
@@ -422,7 +435,7 @@ static const gchar *weekindex_to_ical (gint index) {
 
        for (i = 0; i < 6; i++) {
                if (index == table[i].index)
-                               return table[i].exch;
+                       return table[i].exch;
        }
 
        return 0;
@@ -430,55 +443,67 @@ static const gchar *weekindex_to_ical (gint index) {
 
 static void
 ewscal_add_rrule (ESoapMessage *msg,
-                  icalproperty *prop)
+                 ICalProperty *prop)
 {
-       struct icalrecurrencetype recur = icalproperty_get_rrule (prop);
+       ICalRecurrence *recur = i_cal_property_get_rrule (prop);
 
        e_soap_message_start_element (msg, "RelativeYearlyRecurrence", NULL, NULL);
 
-       e_ews_message_write_string_parameter (msg, "DaysOfWeek", NULL, number_to_weekday 
(icalrecurrencetype_day_day_of_week (recur.by_day[0])));
-       e_ews_message_write_string_parameter (msg, "DayOfWeekIndex", NULL, weekindex_to_ical 
(icalrecurrencetype_day_position (recur.by_day[0])));
-       e_ews_message_write_string_parameter (msg, "Month", NULL, number_to_month (recur.by_month[0]));
+       e_ews_message_write_string_parameter (msg, "DaysOfWeek", NULL, number_to_weekday 
(i_cal_recurrence_day_day_of_week (i_cal_recurrence_get_by_day (recur, 0))));
+       e_ews_message_write_string_parameter (msg, "DayOfWeekIndex", NULL, weekindex_to_ical 
(i_cal_recurrence_day_position (i_cal_recurrence_get_by_day (recur, 0))));
+       e_ews_message_write_string_parameter (msg, "Month", NULL, number_to_month 
(i_cal_recurrence_get_by_month (recur, 0)));
 
        e_soap_message_end_element (msg); /* "RelativeYearlyRecurrence" */
+       g_clear_object (&recur);
 }
 
 static void
 ewscal_add_timechange (ESoapMessage *msg,
-                       icalcomponent *comp,
-                       gint baseoffs)
+                      ICalComponent *comp,
+                      gint baseoffs)
 {
        gchar buffer[16], *offset;
        const gchar *tzname;
-       icalproperty *prop;
-       struct icaltimetype dtstart;
+       ICalProperty *prop;
+       ICalTime *dtstart;
        gint utcoffs;
 
-       prop = icalcomponent_get_first_property (comp, ICAL_TZNAME_PROPERTY);
+       prop = i_cal_component_get_first_property (comp, I_CAL_TZNAME_PROPERTY);
        if (prop) {
-               tzname = icalproperty_get_tzname (prop);
+               tzname = i_cal_property_get_tzname (prop);
                e_soap_message_add_attribute (msg, "TimeZoneName", tzname, NULL, NULL);
+               g_object_unref (prop);
        }
 
        /* Calculate zone Offset from BaseOffset */
-       prop = icalcomponent_get_first_property (comp, ICAL_TZOFFSETTO_PROPERTY);
+       prop = i_cal_component_get_first_property (comp, I_CAL_TZOFFSETTO_PROPERTY);
        if (prop) {
-               utcoffs = -icalproperty_get_tzoffsetto (prop);
+               ICalDuration *duration;
+
+               utcoffs = -i_cal_property_get_tzoffsetto (prop);
                utcoffs -= baseoffs;
-               offset = icaldurationtype_as_ical_string_r (icaldurationtype_from_int (utcoffs));
+               duration = i_cal_duration_from_int (utcoffs);
+               offset = i_cal_duration_as_ical_string_r (duration);
                e_ews_message_write_string_parameter (msg, "Offset", NULL, offset);
+
+               g_clear_object (&duration);
+               g_object_unref (prop);
                free (offset);
        }
 
-       prop = icalcomponent_get_first_property (comp, ICAL_RRULE_PROPERTY);
-       if (prop)
+       prop = i_cal_component_get_first_property (comp, I_CAL_RRULE_PROPERTY);
+       if (prop) {
                ewscal_add_rrule (msg, prop);
+               g_object_unref (prop);
+       }
 
-       prop = icalcomponent_get_first_property (comp, ICAL_DTSTART_PROPERTY);
+       prop = i_cal_component_get_first_property (comp, I_CAL_DTSTART_PROPERTY);
        if (prop) {
-               dtstart = icalproperty_get_dtstart (prop);
-               snprintf (buffer, 16, "%02d:%02d:%02d", dtstart.hour, dtstart.minute, dtstart.second);
+               dtstart = i_cal_property_get_dtstart (prop);
+               snprintf (buffer, 16, "%02d:%02d:%02d", i_cal_time_get_hour (dtstart), i_cal_time_get_minute 
(dtstart), i_cal_time_get_second (dtstart));
                e_ews_message_write_string_parameter (msg, "Time", NULL, buffer);
+               g_clear_object (&dtstart);
+               g_object_unref (prop);
        }
 }
 
@@ -626,19 +651,21 @@ ewscal_set_timezone (ESoapMessage *msg,
 
 void
 ewscal_set_meeting_timezone (ESoapMessage *msg,
-                            icaltimezone *icaltz)
+                            ICalTimezone *icaltz)
 {
-       icalcomponent *comp;
-       icalproperty *prop;
+       ICalComponent *comp;
+       ICalComponent *xstd, *xdaylight;
+       ICalDuration *duration;
        const gchar *location;
-       icalcomponent *xstd, *xdaylight;
        gint std_utcoffs;
        gchar *offset;
 
        if (!icaltz)
                return;
 
-       comp = icaltimezone_get_component (icaltz);
+       comp = i_cal_timezone_get_component (icaltz);
+       if (!comp)
+               return;
 
        /* Exchange needs a BaseOffset, followed by either *both*
         * Standard and Daylight zones, or neither of them. If there's
@@ -647,9 +674,9 @@ ewscal_set_meeting_timezone (ESoapMessage *msg,
         * historical DST rules cannot be handled by Exchange. */
 
        /* FIXME: Walk through them all to find the *latest* ones, like
-        * icaltimezone_get_tznames_from_vtimezone() does. */
-       xstd = icalcomponent_get_first_component (comp, ICAL_XSTANDARD_COMPONENT);
-       xdaylight = icalcomponent_get_first_component (comp, ICAL_XDAYLIGHT_COMPONENT);
+        * i_cal_timezone_get_tznames_from_vtimezone() does. */
+       xstd = i_cal_component_get_first_component (comp, I_CAL_XSTANDARD_COMPONENT);
+       xdaylight = i_cal_component_get_first_component (comp, I_CAL_XDAYLIGHT_COMPONENT);
 
        /* If there was only a DAYLIGHT component, swap them over and pretend
         * it was the STANDARD component. We're only going to give the server
@@ -660,11 +687,11 @@ ewscal_set_meeting_timezone (ESoapMessage *msg,
        }
 
        /* Find a suitable string to use for the TimeZoneName */
-       location = icaltimezone_get_location (icaltz);
+       location = i_cal_timezone_get_location (icaltz);
        if (!location)
-               location = icaltimezone_get_tzid (icaltz);
+               location = i_cal_timezone_get_tzid (icaltz);
        if (!location)
-               location = icaltimezone_get_tznames (icaltz);
+               location = i_cal_timezone_get_tznames (icaltz);
 
        e_soap_message_start_element (msg, "MeetingTimeZone", NULL, NULL);
        e_soap_message_add_attribute (msg, "TimeZoneName", location, NULL, NULL);
@@ -672,8 +699,11 @@ ewscal_set_meeting_timezone (ESoapMessage *msg,
        /* Fetch the timezone offsets for the standard (or only) zone.
         * Negate it, because Exchange does it backwards */
        if (xstd) {
-               prop = icalcomponent_get_first_property (xstd, ICAL_TZOFFSETTO_PROPERTY);
-               std_utcoffs = -icalproperty_get_tzoffsetto (prop);
+               ICalProperty *prop;
+
+               prop = i_cal_component_get_first_property (xstd, I_CAL_TZOFFSETTO_PROPERTY);
+               std_utcoffs = -i_cal_property_get_tzoffsetto (prop);
+               g_object_unref (prop);
        } else {
                /* UTC has no properties at all, so just set manually */
                std_utcoffs = 0;
@@ -683,8 +713,10 @@ ewscal_set_meeting_timezone (ESoapMessage *msg,
         * zones are offset from. It's redundant, but Exchange always sets it
         * to the offset of the Standard zone, and the Offset in the Standard
         * zone to zero. So try to avoid problems by doing the same. */
-       offset = icaldurationtype_as_ical_string_r (icaldurationtype_from_int (std_utcoffs));
+       duration = i_cal_duration_from_int (std_utcoffs);
+       offset = i_cal_duration_as_ical_string_r (duration);
        e_ews_message_write_string_parameter (msg, "BaseOffset", NULL, offset);
+       g_clear_object (&duration);
        free (offset);
 
        /* Only write the full TimeChangeType information, including the
@@ -702,82 +734,88 @@ ewscal_set_meeting_timezone (ESoapMessage *msg,
                e_soap_message_end_element (msg); /* "Daylight" */
        }
        e_soap_message_end_element (msg); /* "MeetingTimeZone" */
+
+       g_clear_object (&comp);
+       g_clear_object (&xstd);
+       g_clear_object (&xdaylight);
 }
 
 void
 ewscal_set_reccurence (ESoapMessage *msg,
-                       icalproperty *rrule,
-                       icaltimetype *dtstart)
+                      ICalProperty *rrule,
+                      ICalTime *dtstart)
 {
        gchar buffer[256];
        gint i, len;
 
        /* MSDN reference: http://msdn.microsoft.com/en-us/library/aa580471%28v=EXCHG.80%29.aspx
         */
-       struct icalrecurrencetype recur = icalproperty_get_rrule (rrule);
+       ICalRecurrence *recur = i_cal_property_get_rrule (rrule);
+
+       if (!recur)
+               return;
 
        e_soap_message_start_element (msg, "Recurrence", NULL, NULL);
 
-       switch (recur.freq) {
-               case ICAL_DAILY_RECURRENCE:
+       switch (i_cal_recurrence_get_freq (recur)) {
+               case I_CAL_DAILY_RECURRENCE:
                        e_soap_message_start_element (msg, "DailyRecurrence", NULL, NULL);
-                       snprintf (buffer, 32, "%d", recur.interval);
+                       snprintf (buffer, 32, "%d", i_cal_recurrence_get_interval (recur));
                        e_ews_message_write_string_parameter (msg, "Interval", NULL, buffer);
                        e_soap_message_end_element (msg); /* "DailyRecurrence" */
                        break;
 
-               case ICAL_WEEKLY_RECURRENCE:
+               case I_CAL_WEEKLY_RECURRENCE:
                        e_soap_message_start_element (msg, "WeeklyRecurrence", NULL, NULL);
 
-                       snprintf (buffer, 32, "%d", recur.interval);
+                       snprintf (buffer, 32, "%d", i_cal_recurrence_get_interval (recur));
                        e_ews_message_write_string_parameter (msg, "Interval", NULL, buffer);
 
                        len = snprintf (
                                buffer, 256, "%s",
-                               number_to_weekday (icalrecurrencetype_day_day_of_week (recur.by_day[0])));
-                       for (i = 1; recur.by_day[i] != ICAL_RECURRENCE_ARRAY_MAX; i++) {
+                               number_to_weekday (i_cal_recurrence_day_day_of_week 
(i_cal_recurrence_get_by_day (recur, 0))));
+                       for (i = 1; i_cal_recurrence_get_by_day (recur, i) != I_CAL_RECURRENCE_ARRAY_MAX; 
i++) {
                                len += snprintf (
                                        buffer + len, 256 - len, " %s",
-                                       number_to_weekday (icalrecurrencetype_day_day_of_week 
(recur.by_day[i])));
+                                       number_to_weekday (i_cal_recurrence_day_day_of_week 
(i_cal_recurrence_get_by_day (recur, i))));
                        }
                        e_ews_message_write_string_parameter (msg, "DaysOfWeek", NULL, buffer);
 
                        e_soap_message_end_element (msg); /* "WeeklyRecurrence" */
                        break;
 
-               case ICAL_MONTHLY_RECURRENCE:
-                       if (recur.by_month_day[0] == ICAL_RECURRENCE_ARRAY_MAX) {
+               case I_CAL_MONTHLY_RECURRENCE:
+                       if (i_cal_recurrence_get_by_month_day (recur, 0) == I_CAL_RECURRENCE_ARRAY_MAX) {
                                e_soap_message_start_element (msg, "RelativeMonthlyRecurrence", NULL, NULL);
 
                                /* For now this is what got implemented since this is the only
                                 relative monthly recurrence evolution can set.
                                 TODO: extend the code with all possible monthly recurrence settings */
-                               snprintf (buffer, 32, "%d", recur.interval);
+                               snprintf (buffer, 32, "%d", i_cal_recurrence_get_interval (recur));
                                e_ews_message_write_string_parameter (msg, "Interval", NULL, buffer);
 
                                e_ews_message_write_string_parameter (
                                        msg, "DaysOfWeek", NULL,
-                                       number_to_weekday (icalrecurrencetype_day_day_of_week 
(recur.by_day[0])));
+                                       number_to_weekday (i_cal_recurrence_day_day_of_week 
(i_cal_recurrence_get_by_day (recur, 0))));
 
-                               e_ews_message_write_string_parameter (msg, "DayOfWeekIndex", NULL, 
weekindex_to_ical ((recur.by_set_pos[0] == 5 ? -1 : recur.by_set_pos[0])));
+                               e_ews_message_write_string_parameter (msg, "DayOfWeekIndex", NULL, 
weekindex_to_ical (
+                                       i_cal_recurrence_get_by_set_pos (recur, 0) == 5 ? -1 : 
i_cal_recurrence_get_by_set_pos (recur, 0)));
 
                                e_soap_message_end_element (msg); /* "RelativeMonthlyRecurrence" */
-
                        } else {
                                e_soap_message_start_element (msg, "AbsoluteMonthlyRecurrence", NULL, NULL);
 
-                               snprintf (buffer, 256, "%d", recur.interval);
+                               snprintf (buffer, 256, "%d", i_cal_recurrence_get_interval (recur));
                                e_ews_message_write_string_parameter (msg, "Interval", NULL, buffer);
 
-                               snprintf (buffer, 256, "%d", recur.by_month_day[0] == -1 ? 31 : 
recur.by_month_day[0]);
+                               snprintf (buffer, 256, "%d", i_cal_recurrence_get_by_month_day (recur, 0) == 
-1 ? 31 : i_cal_recurrence_get_by_month_day (recur, 0));
                                e_ews_message_write_string_parameter (msg, "DayOfMonth", NULL, buffer);
 
                                e_soap_message_end_element (msg); /* "AbsoluteMonthlyRecurrence" */
-
                        }
                        break;
 
-               case ICAL_YEARLY_RECURRENCE:
+               case I_CAL_YEARLY_RECURRENCE:
                        #if 0 /* FIXME */
                        if (is_relative) {
                                ewscal_add_rrule (msg, rrule);
@@ -790,22 +828,22 @@ ewscal_set_reccurence (ESoapMessage *msg,
                                /* work according to RFC5545 §3.3.10
                                 * dtstart is the default, give preference to by_month & by_month_day if they 
are set
                                 */
-                               if (recur.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) {
-                                       snprintf (buffer, 256, "%d", recur.by_month_day[0] == -1 ? 31 : 
recur.by_month_day[0]);
+                               if (i_cal_recurrence_get_by_month_day (recur, 0) != 
I_CAL_RECURRENCE_ARRAY_MAX) {
+                                       snprintf (buffer, 256, "%d", i_cal_recurrence_get_by_month_day 
(recur, 0) == -1 ? 31 : i_cal_recurrence_get_by_month_day (recur, 0));
                                } else {
-                                       snprintf (buffer, 256, "%d", dtstart->day);
+                                       snprintf (buffer, 256, "%d", i_cal_time_get_day (dtstart));
                                }
                                e_ews_message_write_string_parameter (msg, "DayOfMonth", NULL, buffer);
 
-                               if (recur.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) {
-                                       snprintf (buffer, 256, "%d", recur.by_month_day[0]);
+                               if (i_cal_recurrence_get_by_month (recur, 0) != I_CAL_RECURRENCE_ARRAY_MAX) {
+                                       snprintf (buffer, 256, "%d", i_cal_recurrence_get_by_month_day 
(recur, 0));
                                        e_ews_message_write_string_parameter (
                                                msg, "Month", NULL,
-                                               number_to_month (recur.by_month[0]));
+                                               number_to_month (i_cal_recurrence_get_by_month (recur, 0)));
                                } else {
                                        e_ews_message_write_string_parameter (
                                                msg, "Month", NULL,
-                                               number_to_month (dtstart->month));
+                                               number_to_month (i_cal_time_get_month (dtstart)));
                                }
 
                                e_soap_message_end_element (msg); /* "AbsoluteYearlyRecurrence" */
@@ -813,63 +851,86 @@ ewscal_set_reccurence (ESoapMessage *msg,
                        }
                        break;
 
-               case ICAL_SECONDLY_RECURRENCE:
-               case ICAL_MINUTELY_RECURRENCE:
-               case ICAL_HOURLY_RECURRENCE:
+               case I_CAL_SECONDLY_RECURRENCE:
+               case I_CAL_MINUTELY_RECURRENCE:
+               case I_CAL_HOURLY_RECURRENCE:
                default:
                        /* TODO: remove the "Recurrence" element somehow */
                        g_warning ("EWS cant handle recurrence with frequency higher than DAILY\n");
                        goto exit;
        }
 
-       if (recur.count > 0) {
+       if (i_cal_recurrence_get_count (recur) > 0) {
                e_soap_message_start_element (msg, "NumberedRecurrence", NULL, NULL);
                ewscal_set_date (msg, "StartDate", dtstart);
-               snprintf (buffer, 32, "%d", recur.count);
+               snprintf (buffer, 32, "%d", i_cal_recurrence_get_count (recur));
                e_ews_message_write_string_parameter (msg, "NumberOfOccurrences", NULL, buffer);
                e_soap_message_end_element (msg); /* "NumberedRecurrence" */
+       } else {
+               ICalTime *until;
 
-       } else if (!icaltime_is_null_time (recur.until)) {
-               e_soap_message_start_element (msg, "EndDateRecurrence", NULL, NULL);
-               ewscal_set_date (msg, "StartDate", dtstart);
-               ewscal_set_date (msg, "EndDate", &recur.until);
-               e_soap_message_end_element (msg); /* "EndDateRecurrence" */
+               until = i_cal_recurrence_get_until (recur);
 
-       } else {
-               e_soap_message_start_element (msg, "NoEndRecurrence", NULL, NULL);
-               ewscal_set_date (msg, "StartDate", dtstart);
-               e_soap_message_end_element (msg); /* "NoEndRecurrence" */
+               if (until && !i_cal_time_is_null_time (until)) {
+                       e_soap_message_start_element (msg, "EndDateRecurrence", NULL, NULL);
+                       ewscal_set_date (msg, "StartDate", dtstart);
+                       ewscal_set_date (msg, "EndDate", until);
+                       e_soap_message_end_element (msg); /* "EndDateRecurrence" */
+               } else {
+                       e_soap_message_start_element (msg, "NoEndRecurrence", NULL, NULL);
+                       ewscal_set_date (msg, "StartDate", dtstart);
+                       e_soap_message_end_element (msg); /* "NoEndRecurrence" */
+               }
+
+               g_clear_object (&until);
        }
 
 exit:
        e_soap_message_end_element (msg); /* "Recurrence" */
+       g_object_unref (recur);
 }
 
-static struct icaltimetype
-icalcomponent_get_datetime (icalcomponent *comp,
-                            icalproperty *prop)
+static ICalTime *
+icomponent_get_datetime (ICalComponent *comp,
+                        ICalProperty *prop)
 {
        /* Extract datetime with proper timezone */
-       icalcomponent *c;
-       icalparameter *param;
-       struct icaltimetype ret;
-
-       ret = icalvalue_get_datetime (icalproperty_get_value (prop));
+       ICalParameter *param;
+       ICalValue *value;
+       ICalTime *ret;
+
+       value = i_cal_property_get_value (prop);
+       ret = i_cal_value_get_datetime (value);
+       g_clear_object (&value);
+
+       if ((param = i_cal_property_get_first_parameter (prop, I_CAL_TZID_PARAMETER)) != NULL) {
+               const gchar *tzid = i_cal_parameter_get_tzid (param);
+               ICalTimezone *tz = NULL;
+               ICalComponent *cc, *next_cc;
+
+               for (cc = g_object_ref (comp);
+                    cc;
+                    g_object_unref (cc), cc = next_cc) {
+                       tz = i_cal_component_get_timezone (cc, tzid);
+                       if (tz) {
+                               g_object_unref (cc);
+                               break;
+                       }
 
-       if ((param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER)) != NULL) {
-               const gchar *tzid = icalparameter_get_tzid (param);
-               icaltimezone *tz = NULL;
+                       next_cc = i_cal_component_get_parent (cc);
+               }
 
-               for (c = comp; c != NULL; c = icalcomponent_get_parent (c)) {
-                       tz = icalcomponent_get_timezone (c, tzid);
-                       if (tz != NULL) break;
+               if (!tz) {
+                       tz = i_cal_timezone_get_builtin_timezone_from_tzid (tzid);
+                       if (tz)
+                               g_object_ref (tz);
                }
 
-               if (tz == NULL)
-                       tz = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+               if (tz)
+                       i_cal_time_set_timezone (ret, tz);
 
-               if (tz != NULL)
-                       ret = icaltime_set_timezone (&ret, tz);
+               g_object_unref (param);
+               g_clear_object (&tz);
        }
 
        return ret;
@@ -877,24 +938,27 @@ icalcomponent_get_datetime (icalcomponent *comp,
 
 void
 ewscal_set_reccurence_exceptions (ESoapMessage *msg,
-                                  icalcomponent *comp)
+                                 ICalComponent *comp)
 {
-       icalproperty *exdate;
+       ICalProperty *exdate;
 
        /* Make sure we have at least 1 excluded occurrence */
-       exdate = icalcomponent_get_first_property (comp,ICAL_EXDATE_PROPERTY);
-       if (!exdate) return;
+       exdate = i_cal_component_get_first_property (comp, I_CAL_EXDATE_PROPERTY);
+       if (!exdate)
+               return;
 
        e_soap_message_start_element (msg, "DeletedOccurrences", NULL, NULL);
 
-       for (; exdate; exdate = icalcomponent_get_next_property (comp, ICAL_EXDATE_PROPERTY)) {
-               struct icaltimetype exdatetime = icalcomponent_get_datetime (comp, exdate);
+       for (; exdate; g_object_unref (exdate), exdate = i_cal_component_get_next_property (comp, 
I_CAL_EXDATE_PROPERTY)) {
+               ICalTime *exdatetime = icomponent_get_datetime (comp, exdate);
 
                e_soap_message_start_element (msg, "DeletedOccurrence", NULL, NULL);
 
-               ewscal_set_date (msg, "Start", &exdatetime);
+               ewscal_set_date (msg, "Start", exdatetime);
 
                e_soap_message_end_element (msg); /* "DeletedOccurrence" */
+
+               g_clear_object (&exdatetime);
        }
 
        e_soap_message_end_element (msg); /* "DeletedOccurrences" */
@@ -904,16 +968,21 @@ ewscal_set_reccurence_exceptions (ESoapMessage *msg,
  * get meeting organizer e-mail address
  */
 const gchar *
-e_ews_collect_organizer (icalcomponent *comp)
+e_ews_collect_organizer (ICalComponent *comp)
 {
-       icalproperty *org_prop = NULL;
+       ICalProperty *org_prop = NULL;
        const gchar *org = NULL;
        const gchar *org_email_address = NULL;
 
-       org_prop = icalcomponent_get_first_property (comp, ICAL_ORGANIZER_PROPERTY);
-       org = icalproperty_get_organizer (org_prop);
-       if (!org)
+       org_prop = i_cal_component_get_first_property (comp, I_CAL_ORGANIZER_PROPERTY);
+       if (!org_prop)
+               return NULL;
+
+       org = i_cal_property_get_organizer (org_prop);
+       if (!org) {
+               g_object_unref (org_prop);
                return NULL;
+       }
 
        if (g_ascii_strncasecmp (org, "mailto:";, 7) == 0)
                org = org + 7;
@@ -923,6 +992,8 @@ e_ews_collect_organizer (icalcomponent *comp)
        if (org_email_address && !*org_email_address)
                org_email_address = NULL;
 
+       g_object_unref (org_prop);
+
        return org_email_address;
 }
 
@@ -943,26 +1014,10 @@ e_ews_extract_attachment_id_from_uri (const gchar *uri)
 }
 
 void
-e_ews_clean_icalcomponent (icalcomponent *icalcomp)
+e_ews_clean_icomponent (ICalComponent *icomp)
 {
-       icalproperty *prop, *item_id_prop = NULL, *changekey_prop = NULL;
-
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY);
-       while (prop) {
-               const gchar *x_name = icalproperty_get_x_name (prop);
-               if (!g_ascii_strcasecmp (x_name, "X-EVOLUTION-ITEMID"))
-                       item_id_prop = prop;
-                else if (!g_ascii_strcasecmp (x_name, "X-EVOLUTION-CHANGEKEY"))
-                       changekey_prop = prop;
-
-               prop = icalcomponent_get_next_property (icalcomp, ICAL_X_PROPERTY);
-       }
-
-       if (item_id_prop != NULL)
-               icalcomponent_remove_property (icalcomp, item_id_prop);
-
-       if (changekey_prop != NULL)
-               icalcomponent_remove_property (icalcomp, changekey_prop);
+       e_cal_util_component_remove_x_property (icomp, "X-EVOLUTION-ITEMID");
+       e_cal_util_component_remove_x_property (icomp, "X-EVOLUTION-CHANGEKEY");
 }
 
 static void
@@ -989,51 +1044,48 @@ add_attendees_list_to_message (ESoapMessage *msg,
 
 static void
 convert_sensitivity_calcomp_to_xml (ESoapMessage *msg,
-                                   icalcomponent *icalcomp)
+                                   ICalComponent *icomp)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
        g_return_if_fail (msg != NULL);
-       g_return_if_fail (icalcomp != NULL);
+       g_return_if_fail (icomp != NULL);
 
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_CLASS_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_CLASS_PROPERTY);
        if (prop) {
-               icalproperty_class classify = icalproperty_get_class (prop);
-               if (classify == ICAL_CLASS_PUBLIC) {
+               ICalProperty_Class classify = i_cal_property_get_class (prop);
+               if (classify == I_CAL_CLASS_PUBLIC) {
                        e_ews_message_write_string_parameter (msg, "Sensitivity", NULL, "Normal");
-               } else if (classify == ICAL_CLASS_PRIVATE) {
+               } else if (classify == I_CAL_CLASS_PRIVATE) {
                        e_ews_message_write_string_parameter (msg, "Sensitivity", NULL, "Private");
-               } else if (classify == ICAL_CLASS_CONFIDENTIAL) {
+               } else if (classify == I_CAL_CLASS_CONFIDENTIAL) {
                        e_ews_message_write_string_parameter (msg, "Sensitivity", NULL, "Personal");
                }
+               g_object_unref (prop);
        }
 }
 
 static void
 convert_categories_calcomp_to_xml (ESoapMessage *msg,
                                   ECalComponent *comp,
-                                  icalcomponent *icalcomp)
+                                  ICalComponent *icomp)
 {
        GSList *categ_list, *citer;
 
        g_return_if_fail (msg != NULL);
-       g_return_if_fail (icalcomp != NULL);
+       g_return_if_fail (icomp != NULL);
 
        if (comp) {
                g_object_ref (comp);
        } else {
-               icalcomponent *clone = icalcomponent_new_clone (icalcomp);
-
-               comp = e_cal_component_new ();
-               if (!e_cal_component_set_icalcomponent (comp, clone)) {
-                       icalcomponent_free (clone);
-                       g_object_unref (comp);
+               ICalComponent *clone = i_cal_component_new_clone (icomp);
 
+               comp = e_cal_component_new_from_icalcomponent (clone);
+               if (!comp)
                        return;
-               }
        }
 
-       e_cal_component_get_categories_list (comp, &categ_list);
+       categ_list = e_cal_component_get_categories_list (comp);
 
        g_object_unref (comp);
 
@@ -1063,22 +1115,22 @@ convert_categories_calcomp_to_xml (ESoapMessage *msg,
                e_soap_message_end_element (msg); /* Categories */
        }
 
-       e_cal_component_free_categories_list (categ_list);
+       g_slist_free_full (categ_list, g_free);
 }
 
 static gboolean
-check_is_all_day_event (const struct icaltimetype dtstart,
-                       icaltimezone *zone_start,
-                       const struct icaltimetype dtend,
-                       icaltimezone *zone_end)
+check_is_all_day_event (const ICalTime *dtstart,
+                       ICalTimezone *zone_start,
+                       const ICalTime *dtend,
+                       ICalTimezone *zone_end)
 {
        gint64 secs_start, secs_end;
 
-       if (icaltime_is_date (dtstart) && icaltime_is_date (dtend))
+       if (i_cal_time_is_date (dtstart) && i_cal_time_is_date (dtend))
                return TRUE;
 
-       secs_start = (gint64) (zone_start ? icaltime_as_timet_with_zone (dtstart, zone_start) : 
icaltime_as_timet (dtstart));
-       secs_end = (gint64) (zone_end ? icaltime_as_timet_with_zone (dtend, zone_end) : icaltime_as_timet 
(dtend));
+       secs_start = (gint64) (zone_start ? i_cal_time_as_timet_with_zone (dtstart, zone_start) : 
i_cal_time_as_timet (dtstart));
+       secs_end = (gint64) (zone_end ? i_cal_time_as_timet_with_zone (dtend, zone_end) : i_cal_time_as_timet 
(dtend));
 
        /* takes whole day(s) and starts on midnight in the zone_start */
        return ((secs_end - secs_start) % (24 * 60 * 60)) == 0 && (secs_start % 24 * 60 * 60) == 0;
@@ -1090,17 +1142,19 @@ convert_vevent_calcomp_to_xml (ESoapMessage *msg,
                               GError **error)
 {
        EwsCalendarConvertData *convert_data = user_data;
-       icalcomponent *icalcomp = convert_data->icalcomp;
-       ECalComponent *comp = e_cal_component_new ();
+       ICalComponent *icomp = convert_data->icomp;
+       ECalComponent *comp;
        GSList *required = NULL, *optional = NULL, *resource = NULL;
-       icaltimetype dtstart, dtend;
-       icaltimezone *tzid_start, *tzid_end;
-       icalproperty *prop;
+       ICalTime *dtstart, *dtend;
+       ICalTimezone *tzid_start, *tzid_end;
+       ICalProperty *prop;
        gboolean has_alarms, satisfies, rsvp_requested = TRUE, is_all_day_event;
        const gchar *ical_location_start, *ical_location_end, *value;
        const gchar *msdn_location_start, *msdn_location_end;
 
-       e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp));
+       comp = e_cal_component_new_from_icalcomponent (i_cal_component_new_clone (icomp));
+       if (!comp)
+               return FALSE;
 
        /* FORMAT OF A SAMPLE SOAP MESSAGE: http://msdn.microsoft.com/en-us/library/aa564690.aspx */
 
@@ -1108,18 +1162,18 @@ convert_vevent_calcomp_to_xml (ESoapMessage *msg,
        e_soap_message_start_element (msg, "CalendarItem", NULL, NULL);
 
        /* subject */
-       value = icalcomponent_get_summary (icalcomp);
+       value = i_cal_component_get_summary (icomp);
        if (value)
                e_ews_message_write_string_parameter (msg, "Subject", NULL, value);
 
-       convert_sensitivity_calcomp_to_xml (msg, icalcomp);
+       convert_sensitivity_calcomp_to_xml (msg, icomp);
 
        /* description */
-       value = icalcomponent_get_description (icalcomp);
+       value = i_cal_component_get_description (icomp);
        if (value)
                e_ews_message_write_string_parameter_with_attribute (msg, "Body", NULL, value, "BodyType", 
"Text");
 
-       convert_categories_calcomp_to_xml (msg, comp, icalcomp);
+       convert_categories_calcomp_to_xml (msg, comp, icomp);
 
        /* set alarms */
        has_alarms = e_cal_component_has_alarms (comp);
@@ -1129,13 +1183,17 @@ convert_vevent_calcomp_to_xml (ESoapMessage *msg,
                e_ews_message_write_string_parameter (msg, "ReminderIsSet", NULL, "false");
 
        /* start time, end time and meeting time zone */
-       dtstart = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icalcomp, ICAL_DTSTART_PROPERTY, icalproperty_get_dtstart);
-       tzid_start = (icaltimezone *) (dtstart.zone ? dtstart.zone : convert_data->default_zone);
-       ical_location_start = icaltimezone_get_location (tzid_start);
-
-       dtend = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icalcomp, ICAL_DTEND_PROPERTY, icalproperty_get_dtend);
-       tzid_end = (icaltimezone *) (dtend.zone ? dtend.zone : convert_data->default_zone);
-       ical_location_end = icaltimezone_get_location (tzid_end);
+       dtstart = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icomp, I_CAL_DTSTART_PROPERTY, i_cal_property_get_dtstart);
+       tzid_start = dtstart ? i_cal_time_get_timezone (dtstart) : NULL;
+       if (!tzid_start)
+               tzid_start = convert_data->default_zone;
+       ical_location_start = i_cal_timezone_get_location (tzid_start);
+
+       dtend = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icomp, I_CAL_DTEND_PROPERTY, i_cal_property_get_dtend);
+       tzid_end = dtend ? i_cal_time_get_timezone (dtend) : NULL;
+       if (!tzid_end)
+               tzid_end = convert_data->default_zone;
+       ical_location_end = i_cal_timezone_get_location (tzid_end);
 
        satisfies = e_ews_connection_satisfies_server_version (convert_data->connection, E_EWS_EXCHANGE_2010);
        if (satisfies && ical_location_start != NULL && ical_location_end != NULL) {
@@ -1155,14 +1213,14 @@ convert_vevent_calcomp_to_xml (ESoapMessage *msg,
 
        is_all_day_event = check_is_all_day_event (dtstart, tzid_start, dtend, tzid_end);
 
-       e_ews_cal_utils_set_time (msg, "Start", &dtstart, is_all_day_event && dtstart.is_date);
+       e_ews_cal_utils_set_time (msg, "Start", dtstart, is_all_day_event && i_cal_time_is_date (dtstart));
 
        /* Cover components without DTEND */
-       if (icaltime_is_valid_time (dtend) &&
-           !icaltime_is_null_time (dtend))
-               e_ews_cal_utils_set_time (msg, "End", &dtend, is_all_day_event && dtend.is_date);
+       if (dtend && i_cal_time_is_valid_time (dtend) &&
+           !i_cal_time_is_null_time (dtend))
+               e_ews_cal_utils_set_time (msg, "End", dtend, is_all_day_event && i_cal_time_is_date (dtend));
        else
-               e_ews_cal_utils_set_time (msg, "End", &dtstart, is_all_day_event && dtstart.is_date);
+               e_ews_cal_utils_set_time (msg, "End", dtstart, is_all_day_event && i_cal_time_is_date 
(dtstart));
 
        /* We have to do the time zone(s) later, or the server rejects the request */
 
@@ -1171,19 +1229,20 @@ convert_vevent_calcomp_to_xml (ESoapMessage *msg,
                e_ews_message_write_string_parameter (msg, "IsAllDayEvent", NULL, "true");
 
        /*freebusy*/
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_TRANSP_PROPERTY);
-       if (!g_strcmp0 (icalproperty_get_value_as_string (prop), "TRANSPARENT"))
-               e_ews_message_write_string_parameter (msg, "LegacyFreeBusyStatus",NULL,"Free");
+       prop = i_cal_component_get_first_property (icomp, I_CAL_TRANSP_PROPERTY);
+       if (!prop || i_cal_property_get_transp (prop) == I_CAL_TRANSP_TRANSPARENT)
+               e_ews_message_write_string_parameter (msg, "LegacyFreeBusyStatus", NULL, "Free");
        else
-               e_ews_message_write_string_parameter (msg, "LegacyFreeBusyStatus",NULL,"Busy");
+               e_ews_message_write_string_parameter (msg, "LegacyFreeBusyStatus", NULL, "Busy");
+       g_clear_object (&prop);
 
        /* location */
-       value = icalcomponent_get_location (icalcomp);
+       value = i_cal_component_get_location (icomp);
        if (value)
                e_ews_message_write_string_parameter (msg, "Location", NULL, value);
 
        /* collect attendees */
-       e_ews_collect_attendees (icalcomp, &required, &optional, &resource, &rsvp_requested);
+       e_ews_collect_attendees (icomp, &required, &optional, &resource, &rsvp_requested);
 
        e_ews_message_write_string_parameter (msg, "IsResponseRequested", NULL, rsvp_requested ? "true" : 
"false");
 
@@ -1202,18 +1261,16 @@ convert_vevent_calcomp_to_xml (ESoapMessage *msg,
        /* end of attendees */
 
        /* Recurrence */
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_RRULE_PROPERTY);
-       if (prop != NULL) {
-               ewscal_set_reccurence (msg, prop, &dtstart);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_RRULE_PROPERTY);
+       if (prop) {
+               ewscal_set_reccurence (msg, prop, dtstart);
+               g_object_unref (prop);
        }
 
        msdn_location_start = e_cal_backend_ews_tz_util_get_msdn_equivalent (ical_location_start);
        msdn_location_end = e_cal_backend_ews_tz_util_get_msdn_equivalent (ical_location_end);
        satisfies = e_ews_connection_satisfies_server_version (convert_data->connection, E_EWS_EXCHANGE_2010);
 
-       /* We have to cast these because libical puts a const pointer into the
-        * icaltimetype, but its basic read-only icaltimezone_foo() functions
-        * take a non-const pointer! */
        if (satisfies && msdn_location_start != NULL && msdn_location_end != NULL) {
                GSList *msdn_locations = NULL;
                GSList *tzds = NULL;
@@ -1242,6 +1299,8 @@ convert_vevent_calcomp_to_xml (ESoapMessage *msg,
 
        e_soap_message_end_element (msg); /* "CalendarItem" */
 
+       g_clear_object (&dtstart);
+       g_clear_object (&dtend);
        g_object_unref (comp);
 
        return TRUE;
@@ -1265,9 +1324,9 @@ convert_vtodo_calcomp_to_xml (ESoapMessage *msg,
                              GError **error)
 {
        EwsCalendarConvertData *convert_data = user_data;
-       icalcomponent *icalcomp = convert_data->icalcomp;
-       icalproperty *prop;
-       icaltimetype dt;
+       ICalComponent *icomp = convert_data->icomp;
+       ICalProperty *prop;
+       ICalTime *dt;
        gint value;
        gchar buffer[16];
        gboolean success;
@@ -1275,60 +1334,67 @@ convert_vtodo_calcomp_to_xml (ESoapMessage *msg,
 
        e_soap_message_start_element (msg, "Task", NULL, NULL);
 
-       e_ews_message_write_string_parameter (msg, "Subject", NULL, icalcomponent_get_summary (icalcomp));
+       e_ews_message_write_string_parameter (msg, "Subject", NULL, i_cal_component_get_summary (icomp));
 
-       convert_sensitivity_calcomp_to_xml (msg, icalcomp);
+       convert_sensitivity_calcomp_to_xml (msg, icomp);
 
-       e_ews_message_write_string_parameter_with_attribute (msg, "Body", NULL, icalcomponent_get_description 
(icalcomp), "BodyType", "Text");
+       e_ews_message_write_string_parameter_with_attribute (msg, "Body", NULL, 
i_cal_component_get_description (icomp), "BodyType", "Text");
 
-       convert_categories_calcomp_to_xml (msg, NULL, icalcomp);
+       convert_categories_calcomp_to_xml (msg, NULL, icomp);
 
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_PRIORITY_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_PRIORITY_PROPERTY);
        if (prop) {
                gint priority;
 
-               priority = icalproperty_get_priority (prop);
+               priority = i_cal_property_get_priority (prop);
                e_ews_message_write_string_parameter (msg, "Importance", NULL, ews_priority_to_string 
(priority));
+               g_object_unref (prop);
        }
 
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_DUE_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_DUE_PROPERTY);
        if (prop) {
-               dt = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icalcomp, ICAL_DUE_PROPERTY, icalproperty_get_due);
-               e_ews_cal_utils_set_time (msg, "DueDate", &dt, TRUE);
+               dt = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icomp, I_CAL_DUE_PROPERTY, i_cal_property_get_due);
+               e_ews_cal_utils_set_time (msg, "DueDate", dt, TRUE);
+               g_clear_object (&dt);
+               g_object_unref (prop);
        }
 
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_PERCENTCOMPLETE_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_PERCENTCOMPLETE_PROPERTY);
        if (prop) {
-               value = icalproperty_get_percentcomplete (prop);
+               value = i_cal_property_get_percentcomplete (prop);
                snprintf (buffer, 16, "%d", value);
                e_ews_message_write_string_parameter (msg, "PercentComplete", NULL, buffer);
+               g_object_unref (prop);
        }
 
-       success = e_ews_cal_utils_set_recurrence (msg, icalcomp, FALSE, error);
+       success = e_ews_cal_utils_set_recurrence (msg, icomp, FALSE, error);
 
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_DTSTART_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_DTSTART_PROPERTY);
        if (prop) {
-               dt = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icalcomp, ICAL_DTSTART_PROPERTY, icalproperty_get_dtstart);
-               e_ews_cal_utils_set_time (msg, "StartDate", &dt, TRUE);
+               dt = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icomp, I_CAL_DTSTART_PROPERTY, i_cal_property_get_dtstart);
+               e_ews_cal_utils_set_time (msg, "StartDate", dt, TRUE);
+               g_clear_object (&dt);
+               g_object_unref (prop);
        }
 
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_STATUS_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_STATUS_PROPERTY);
        if (prop) {
-               switch (icalproperty_get_status (prop)) {
-               case ICAL_STATUS_INPROCESS:
+               switch (i_cal_property_get_status (prop)) {
+               case I_CAL_STATUS_INPROCESS:
                        e_ews_message_write_string_parameter (msg, "Status", NULL, "InProgress");
                        break;
-               case ICAL_STATUS_COMPLETED:
+               case I_CAL_STATUS_COMPLETED:
                        e_ews_message_write_string_parameter (msg, "Status", NULL, "Completed");
                        break;
                default:
                        break;
                }
+               g_object_unref (prop);
        }
 
-       /* has_alarms = icalcomponent_get_first_component (icalcomp, ICAL_VALARM_COMPONENT) != NULL;
+       /* has_alarms = e_cal_util_component_has_property (icomp, I_CAL_VALARM_COMPONENT);
        if (has_alarms) {
-               ECalComponent *comp = e_cal_component_new_from_icalcomponent (icalcomponent_new_clone 
(icalcomp));
+               ECalComponent *comp = e_cal_component_new_from_icalcomponent (i_cal_component_new_clone 
(icomp));
 
                if (comp && e_cal_component_has_alarms (comp)) {
                        ews_set_alarm (msg, comp, convert_data->timezone_cache, convert_data->vcalendar, 
TRUE);
@@ -1340,7 +1406,7 @@ convert_vtodo_calcomp_to_xml (ESoapMessage *msg,
        }
 
        if (!has_alarms)
-               e_ews_message_write_string_parameter (msg, "ReminderIsSet", NULL, "false");*/
+               e_ews_message_write_string_parameter (msg, "ReminderIsSet", NULL, "false"); */
 
        e_soap_message_end_element (msg); /* "Task" */
 
@@ -1353,22 +1419,22 @@ convert_vjournal_calcomp_to_xml (ESoapMessage *msg,
                                 GError **error)
 {
        EwsCalendarConvertData *convert_data = user_data;
-       icalcomponent *icalcomp = convert_data->icalcomp;
+       ICalComponent *icomp = convert_data->icomp;
        const gchar *text;
 
        e_soap_message_start_element (msg, "Message", NULL, NULL);
        e_ews_message_write_string_parameter (msg, "ItemClass", NULL, "IPM.StickyNote");
 
-       e_ews_message_write_string_parameter (msg, "Subject", NULL, icalcomponent_get_summary (icalcomp));
+       e_ews_message_write_string_parameter (msg, "Subject", NULL, i_cal_component_get_summary (icomp));
 
-       convert_sensitivity_calcomp_to_xml (msg, icalcomp);
+       convert_sensitivity_calcomp_to_xml (msg, icomp);
 
-       text = icalcomponent_get_description (icalcomp);
+       text = i_cal_component_get_description (icomp);
        if (!text || !*text)
-               text = icalcomponent_get_summary (icalcomp);
+               text = i_cal_component_get_summary (icomp);
        e_ews_message_write_string_parameter_with_attribute (msg, "Body", NULL, text, "BodyType", "Text");
 
-       convert_categories_calcomp_to_xml (msg, NULL, icalcomp);
+       convert_categories_calcomp_to_xml (msg, NULL, icomp);
 
        e_soap_message_end_element (msg); /* Message */
 
@@ -1383,14 +1449,14 @@ e_cal_backend_ews_convert_calcomp_to_xml (ESoapMessage *msg,
        EwsCalendarConvertData *convert_data = user_data;
        gboolean success = FALSE;
 
-       switch (icalcomponent_isa (convert_data->icalcomp)) {
-       case ICAL_VEVENT_COMPONENT:
+       switch (i_cal_component_isa (convert_data->icomp)) {
+       case I_CAL_VEVENT_COMPONENT:
                success = convert_vevent_calcomp_to_xml (msg, convert_data, error);
                break;
-       case ICAL_VTODO_COMPONENT:
+       case I_CAL_VTODO_COMPONENT:
                success = convert_vtodo_calcomp_to_xml (msg, convert_data, error);
                break;
-       case ICAL_VJOURNAL_COMPONENT:
+       case I_CAL_VJOURNAL_COMPONENT:
                success = convert_vjournal_calcomp_to_xml (msg, convert_data, error);
                break;
        default:
@@ -1406,13 +1472,13 @@ convert_component_categories_to_updatexml (ECalComponent *comp,
                                           ESoapMessage *msg,
                                           const gchar *base_elem_name)
 {
-       GSList *categ_list = NULL, *citer;
+       GSList *categ_list, *citer;
 
        g_return_if_fail (comp != NULL);
        g_return_if_fail (msg != NULL);
        g_return_if_fail (base_elem_name != NULL);
 
-       e_cal_component_get_categories_list (comp, &categ_list);
+       categ_list = e_cal_component_get_categories_list (comp);
 
        /* Categories cannot be empty, thus first verify they are not */
 
@@ -1442,7 +1508,7 @@ convert_component_categories_to_updatexml (ECalComponent *comp,
                e_ews_message_add_delete_item_field (msg, "Categories", "item");
        }
 
-       e_cal_component_free_categories_list (categ_list);
+       g_slist_free_full (categ_list, g_free);
 }
 
 static void
@@ -1464,17 +1530,19 @@ convert_vevent_component_to_updatexml (ESoapMessage *msg,
                                       GError **error)
 {
        EwsCalendarConvertData *convert_data = user_data;
-       icalcomponent *icalcomp = e_cal_component_get_icalcomponent (convert_data->comp);
-       icalcomponent *icalcomp_old = e_cal_component_get_icalcomponent (convert_data->old_comp);
+       ICalComponent *icomp = e_cal_component_get_icalcomponent (convert_data->comp);
+       ICalComponent *icomp_old = e_cal_component_get_icalcomponent (convert_data->old_comp);
        GSList *required = NULL, *optional = NULL, *resource = NULL;
-       icaltimetype dtstart, dtend, dtstart_old, dtend_old;
-       icaltimezone *tzid_start = NULL, *tzid_end = NULL;
-       icalproperty *prop, *transp;
+       ICalTime *dtstart, *dtend, *dtstart_old, *dtend_old;
+       ICalTimezone *tzid_start = NULL, *tzid_end = NULL;
+       ICalProperty *prop;
+       ICalPropertyTransp old_transp, new_transp;
        const gchar *org_email_address = NULL, *value = NULL, *old_value = NULL;
        const gchar *ical_location_start = NULL, *ical_location_end = NULL;
        const gchar *old_ical_location_start = NULL, *old_ical_location_end = NULL;
        const gchar *old_msdn_location_start = NULL, *old_msdn_location_end = NULL;
        const gchar *msdn_location_start = NULL, *msdn_location_end = NULL;
+       gchar *rrule_value, *rrule_old_value;
        gboolean has_alarms, has_alarms_old;
        gboolean dt_start_changed = FALSE, dt_end_changed = FALSE, dt_changed;
        gboolean dt_start_changed_timezone_name = FALSE, dt_end_changed_timezone_name = FALSE;
@@ -1483,11 +1551,11 @@ convert_vevent_component_to_updatexml (ESoapMessage *msg,
        gchar *recid;
 
        /* Modifying a recurring meeting ? */
-       if (icalcomponent_get_first_property (icalcomp_old, ICAL_RRULE_PROPERTY) != NULL) {
+       if (e_cal_util_component_has_property (icomp_old, I_CAL_RRULE_PROPERTY)) {
                /* A single occurrence ? */
-               prop = icalcomponent_get_first_property (icalcomp, ICAL_RECURRENCEID_PROPERTY);
+               prop = i_cal_component_get_first_property (icomp, I_CAL_RECURRENCEID_PROPERTY);
                if (prop != NULL) {
-                       recid = icalproperty_get_value_as_string_r (prop);
+                       recid = i_cal_property_get_value_as_string_r (prop);
                        e_ews_message_start_item_change (
                                msg,
                                E_EWS_ITEMCHANGE_TYPE_OCCURRENCEITEM,
@@ -1496,46 +1564,51 @@ convert_vevent_component_to_updatexml (ESoapMessage *msg,
                                e_cal_backend_ews_rid_to_index (
                                        convert_data->default_zone,
                                        recid,
-                                       icalcomp_old,
+                                       icomp_old,
                                        NULL));
+                       g_object_unref (prop);
                        g_free (recid);
                } else {
                        e_ews_message_start_item_change (
                                msg, E_EWS_ITEMCHANGE_TYPE_ITEM,
                                convert_data->item_id, convert_data->change_key, 0);
                }
-       } else e_ews_message_start_item_change (msg, E_EWS_ITEMCHANGE_TYPE_ITEM,
-               convert_data->item_id, convert_data->change_key, 0);
+       } else {
+               e_ews_message_start_item_change (msg, E_EWS_ITEMCHANGE_TYPE_ITEM,
+                       convert_data->item_id, convert_data->change_key, 0);
+       }
 
        /* subject */
-       value = icalcomponent_get_summary (icalcomp);
-       old_value = icalcomponent_get_summary (icalcomp_old);
-       if ((value && old_value && g_ascii_strcasecmp (value, old_value)) ||
-        (value && old_value == NULL)) {
+       value = i_cal_component_get_summary (icomp);
+       old_value = i_cal_component_get_summary (icomp_old);
+       if (g_strcmp0 (value, old_value) != 0 || (value && !old_value)) {
                convert_vevent_property_to_updatexml (msg, "Subject", value, "item", NULL, NULL);
-       } else if (!value && old_value)
+       } else if (!value && old_value) {
                convert_vevent_property_to_updatexml (msg, "Subject", "", "item", NULL, NULL);
+       }
 
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_CLASS_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_CLASS_PROPERTY);
        if (prop) {
-               icalproperty_class classify = icalproperty_get_class (prop);
-               if (classify == ICAL_CLASS_PUBLIC) {
+               ICalProperty_Class classify = i_cal_property_get_class (prop);
+               if (classify == I_CAL_CLASS_PUBLIC) {
                        convert_vevent_property_to_updatexml (msg, "Sensitivity", "Normal", "item", NULL, 
NULL);
-               } else if (classify == ICAL_CLASS_PRIVATE) {
+               } else if (classify == I_CAL_CLASS_PRIVATE) {
                        convert_vevent_property_to_updatexml (msg, "Sensitivity", "Private", "item", NULL, 
NULL);
-               } else if (classify == ICAL_CLASS_CONFIDENTIAL) {
+               } else if (classify == I_CAL_CLASS_CONFIDENTIAL) {
                        convert_vevent_property_to_updatexml (msg, "Sensitivity", "Personal", "item", NULL, 
NULL);
                }
+
+               g_object_unref (prop);
        }
 
        /*description*/
-       value = icalcomponent_get_description (icalcomp);
-       old_value = icalcomponent_get_description (icalcomp_old);
-       if ((value && old_value && g_ascii_strcasecmp (value, old_value)) ||
-        (value && old_value == NULL)) {
+       value = i_cal_component_get_description (icomp);
+       old_value = i_cal_component_get_description (icomp_old);
+       if (g_strcmp0 (value, old_value) != 0 || (value && !old_value)) {
                convert_vevent_property_to_updatexml (msg, "Body", value, "item", "BodyType", "Text");
-       } else if (!value && old_value)
+       } else if (!value && old_value) {
                convert_vevent_property_to_updatexml (msg, "Body", "", "item", "BodyType", "Text");
+       }
 
        /*update alarm items*/
        has_alarms = e_cal_component_has_alarms (convert_data->comp);
@@ -1550,34 +1623,37 @@ convert_vevent_component_to_updatexml (ESoapMessage *msg,
                        convert_vevent_property_to_updatexml (msg, "ReminderIsSet", "true", "item", NULL, 
NULL);
                        convert_vevent_property_to_updatexml (msg, "ReminderMinutesBeforeStart", buf, "item", 
NULL, NULL);
                }
+       } else {
+               convert_vevent_property_to_updatexml (msg, "ReminderIsSet", "false", "item", NULL, NULL);
        }
-       else convert_vevent_property_to_updatexml (msg, "ReminderIsSet", "false", "item", NULL, NULL);
 
        /* Categories */
        convert_component_categories_to_updatexml (convert_data->comp, msg, "CalendarItem");
 
        /*location*/
-       value = icalcomponent_get_location (icalcomp);
-       old_value = icalcomponent_get_location (icalcomp_old);
-       if ((value && old_value && g_ascii_strcasecmp (value, old_value)) ||
-        (value && old_value == NULL)) {
+       value = i_cal_component_get_location (icomp);
+       old_value = i_cal_component_get_location (icomp_old);
+       if (g_strcmp0 (value, old_value) != 0 || (value && !old_value)) {
                convert_vevent_property_to_updatexml (msg, "Location", value, "calendar", NULL, NULL);
-       } else if (!value && old_value)
+       } else if (!value && old_value) {
                convert_vevent_property_to_updatexml (msg, "Location", "", "calendar", NULL, NULL);
+       }
 
        /*freebusy*/
-       transp = icalcomponent_get_first_property (icalcomp, ICAL_TRANSP_PROPERTY);
-       value = icalproperty_get_value_as_string (transp);
-       transp = icalcomponent_get_first_property (icalcomp_old, ICAL_TRANSP_PROPERTY);
-       old_value = icalproperty_get_value_as_string (transp);
-       if (g_strcmp0 (value, old_value)) {
-               if (!g_strcmp0 (value, "TRANSPARENT"))
+       prop = i_cal_component_get_first_property (icomp, I_CAL_TRANSP_PROPERTY);
+       new_transp = prop ? i_cal_property_get_transp (prop) : I_CAL_TRANSP_NONE;
+       g_clear_object (&prop);
+       prop = i_cal_component_get_first_property (icomp_old, I_CAL_TRANSP_PROPERTY);
+       old_transp = prop ? i_cal_property_get_transp (prop) : I_CAL_TRANSP_NONE;
+       g_clear_object (&prop);
+       if (new_transp != old_transp) {
+               if (new_transp == I_CAL_TRANSP_TRANSPARENT)
                        convert_vevent_property_to_updatexml (msg, "LegacyFreeBusyStatus","Free" , 
"calendar", NULL, NULL);
                else
                        convert_vevent_property_to_updatexml (msg, "LegacyFreeBusyStatus","Busy" , 
"calendar", NULL, NULL);
        }
 
-       org_email_address = e_ews_collect_organizer (icalcomp);
+       org_email_address = e_ews_collect_organizer (icomp);
        if (org_email_address && convert_data->user_email && g_ascii_strcasecmp (org_email_address, 
convert_data->user_email)) {
                e_ews_message_end_item_change (msg);
                return TRUE;
@@ -1585,26 +1661,34 @@ convert_vevent_component_to_updatexml (ESoapMessage *msg,
 
        /* Update other properties allowed only for meeting organizers*/
        /*meeting dates*/
-       dtstart = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icalcomp, ICAL_DTSTART_PROPERTY, icalproperty_get_dtstart);
-       dtstart_old = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icalcomp_old, ICAL_DTSTART_PROPERTY, icalproperty_get_dtstart);
-       dt_start_changed = icaltime_compare (dtstart, dtstart_old) != 0;
-       if (dtstart.zone != NULL) {
-               tzid_start = (icaltimezone *) dtstart.zone;
-               ical_location_start = icaltimezone_get_location (tzid_start);
-
-               old_ical_location_start = icaltimezone_get_location ((icaltimezone *)dtstart_old.zone);
+       dtstart = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icomp, I_CAL_DTSTART_PROPERTY, i_cal_property_get_dtstart);
+       dtstart_old = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icomp_old, I_CAL_DTSTART_PROPERTY, i_cal_property_get_dtstart);
+       dt_start_changed = dtstart != dtstart_old || (dtstart && dtstart_old && i_cal_time_compare (dtstart, 
dtstart_old) != 0);
+       tzid_start = dtstart ? i_cal_time_get_timezone (dtstart) : NULL;
+       if (tzid_start) {
+               ICalTimezone *zone;
+
+               zone = dtstart_old ? i_cal_time_get_timezone (dtstart_old) : NULL;
+
+               ical_location_start = i_cal_timezone_get_location (tzid_start);
+               old_ical_location_start = zone ? i_cal_timezone_get_location (zone) : NULL;
+
                if (g_strcmp0 (ical_location_start, old_ical_location_start) != 0)
                        dt_start_changed_timezone_name = TRUE;
        }
 
-       dtend = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icalcomp, ICAL_DTEND_PROPERTY, icalproperty_get_dtend);
-       dtend_old = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icalcomp_old, ICAL_DTEND_PROPERTY, icalproperty_get_dtend);
-       dt_end_changed = icaltime_compare (dtend, dtend_old) != 0;
-       if (dtend.zone != NULL) {
-               tzid_end = (icaltimezone *) dtend.zone;
-               ical_location_end = icaltimezone_get_location (tzid_end);
+       dtend = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icomp, I_CAL_DTEND_PROPERTY, i_cal_property_get_dtend);
+       dtend_old = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icomp_old, I_CAL_DTEND_PROPERTY, i_cal_property_get_dtend);
+       dt_end_changed = dtend != dtend_old || (dtend && dtend_old && i_cal_time_compare (dtend, dtend_old) 
!= 0);
+       tzid_end = dtend ? i_cal_time_get_timezone (dtend) : NULL;
+       if (tzid_end) {
+               ICalTimezone *zone;
+
+               zone = dtend_old ? i_cal_time_get_timezone (dtend_old) : NULL;
+
+               ical_location_end = i_cal_timezone_get_location (tzid_end);
+               old_ical_location_end = zone ? i_cal_timezone_get_location (zone) : NULL;
 
-               old_ical_location_end = icaltimezone_get_location ((icaltimezone *)dtend_old.zone);
                if (g_strcmp0 (ical_location_end, old_ical_location_end) != 0)
                        dt_end_changed_timezone_name = TRUE;
        }
@@ -1654,13 +1738,13 @@ convert_vevent_component_to_updatexml (ESoapMessage *msg,
 
        if (dt_start_changed) {
                e_ews_message_start_set_item_field (msg, "Start", "calendar","CalendarItem");
-               e_ews_cal_utils_set_time (msg, "Start", &dtstart, is_all_day_event && dtstart.is_date);
+               e_ews_cal_utils_set_time (msg, "Start", dtstart, is_all_day_event && i_cal_time_is_date 
(dtstart));
                e_ews_message_end_set_item_field (msg);
        }
 
        if (dt_end_changed) {
                e_ews_message_start_set_item_field (msg, "End", "calendar", "CalendarItem");
-               e_ews_cal_utils_set_time (msg, "End", &dtend, is_all_day_event && dtend.is_date);
+               e_ews_cal_utils_set_time (msg, "End", dtend, is_all_day_event && i_cal_time_is_date (dtend));
                e_ews_message_end_set_item_field (msg);
        }
 
@@ -1672,7 +1756,7 @@ convert_vevent_component_to_updatexml (ESoapMessage *msg,
                        convert_vevent_property_to_updatexml (msg, "IsAllDayEvent", "false", "calendar", 
NULL, NULL);
        }
 
-       e_ews_collect_attendees (icalcomp, &required, &optional, &resource, &rsvp_requested);
+       e_ews_collect_attendees (icomp, &required, &optional, &resource, &rsvp_requested);
 
        convert_vevent_property_to_updatexml (msg, "IsResponseRequested", rsvp_requested ? "true" : "false", 
"calendar", NULL, NULL);
 
@@ -1702,19 +1786,26 @@ convert_vevent_component_to_updatexml (ESoapMessage *msg,
        }
 
        /* Recurrence */
-       value = NULL; old_value = NULL;
-       prop = icalcomponent_get_first_property (icalcomp_old, ICAL_RRULE_PROPERTY);
-       if (prop != NULL)
-               old_value = icalproperty_get_value_as_string (prop);
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_RRULE_PROPERTY);
-       if (prop != NULL)
-               value = icalproperty_get_value_as_string (prop);
-
-       if (prop != NULL && g_strcmp0 (value, old_value)) {
+       rrule_value = NULL;
+       rrule_old_value = NULL;
+       prop = i_cal_component_get_first_property (icomp_old, I_CAL_RRULE_PROPERTY);
+       if (prop) {
+               rrule_old_value = i_cal_property_get_value_as_string_r (prop);
+               g_object_unref (prop);
+       }
+
+       prop = i_cal_component_get_first_property (icomp, I_CAL_RRULE_PROPERTY);
+       if (prop)
+               rrule_value = i_cal_property_get_value_as_string_r (prop);
+
+       if (prop && g_strcmp0 (rrule_value, rrule_old_value)) {
                e_ews_message_start_set_item_field (msg, "Recurrence", "calendar", "CalendarItem");
-               ewscal_set_reccurence (msg, prop, &dtstart);
+               ewscal_set_reccurence (msg, prop, dtstart);
                e_ews_message_end_set_item_field (msg);
        }
+       g_clear_object (&prop);
+       g_free (rrule_value);
+       g_free (rrule_old_value);
 
        if (dt_changed && satisfies) {
                if (msdn_location_start != NULL || msdn_location_end != NULL) {
@@ -1770,6 +1861,11 @@ convert_vevent_component_to_updatexml (ESoapMessage *msg,
 
        e_ews_message_end_item_change (msg);
 
+       g_clear_object (&dtstart);
+       g_clear_object (&dtend);
+       g_clear_object (&dtstart_old);
+       g_clear_object (&dtend_old);
+
        return TRUE;
 }
 
@@ -1792,9 +1888,9 @@ convert_vtodo_component_to_updatexml (ESoapMessage *msg,
                                      GError **error)
 {
        EwsCalendarConvertData *convert_data = user_data;
-       icalcomponent *icalcomp = e_cal_component_get_icalcomponent (convert_data->comp);
-       icalproperty *prop;
-       icaltimetype dt;
+       ICalComponent *icomp = e_cal_component_get_icalcomponent (convert_data->comp);
+       ICalProperty *prop;
+       ICalTime *dt;
        gint value;
        gchar buffer[16];
        gboolean success = TRUE;
@@ -1803,89 +1899,97 @@ convert_vtodo_component_to_updatexml (ESoapMessage *msg,
                msg, E_EWS_ITEMCHANGE_TYPE_ITEM,
                convert_data->item_id, convert_data->change_key, 0);
 
-       convert_vtodo_property_to_updatexml (msg, "Subject", icalcomponent_get_summary (icalcomp), "item", 
NULL, NULL);
+       convert_vtodo_property_to_updatexml (msg, "Subject", i_cal_component_get_summary (icomp), "item", 
NULL, NULL);
 
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_CLASS_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_CLASS_PROPERTY);
        if (prop) {
-               icalproperty_class classify = icalproperty_get_class (prop);
-               if (classify == ICAL_CLASS_PUBLIC) {
+               ICalProperty_Class classify = i_cal_property_get_class (prop);
+               if (classify == I_CAL_CLASS_PUBLIC) {
                        convert_vtodo_property_to_updatexml (msg, "Sensitivity", "Normal", "item", NULL, 
NULL);
-               } else if (classify == ICAL_CLASS_PRIVATE) {
+               } else if (classify == I_CAL_CLASS_PRIVATE) {
                        convert_vtodo_property_to_updatexml (msg, "Sensitivity", "Private", "item", NULL, 
NULL);
-               } else if (classify == ICAL_CLASS_CONFIDENTIAL) {
+               } else if (classify == I_CAL_CLASS_CONFIDENTIAL) {
                        convert_vtodo_property_to_updatexml (msg, "Sensitivity", "Personal", "item", NULL, 
NULL);
                }
+               g_object_unref (prop);
        }
 
-       convert_vtodo_property_to_updatexml (msg, "Body", icalcomponent_get_description (icalcomp), "item", 
"BodyType", "Text");
+       convert_vtodo_property_to_updatexml (msg, "Body", i_cal_component_get_description (icomp), "item", 
"BodyType", "Text");
 
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_DUE_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_DUE_PROPERTY);
        if (prop) {
-               dt = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icalcomp, ICAL_DUE_PROPERTY, icalproperty_get_due);
+               dt = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icomp, I_CAL_DUE_PROPERTY, i_cal_property_get_due);
                e_ews_message_start_set_item_field (msg, "DueDate", "task", "Task");
-               e_ews_cal_utils_set_time (msg, "DueDate", &dt, TRUE);
+               e_ews_cal_utils_set_time (msg, "DueDate", dt, TRUE);
                e_ews_message_end_set_item_field (msg);
+               g_object_unref (prop);
+               g_clear_object (&dt);
        } else {
                e_ews_message_add_delete_item_field (msg, "DueDate", "task");
        }
 
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_PERCENTCOMPLETE_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_PERCENTCOMPLETE_PROPERTY);
        if (prop) {
-               value = icalproperty_get_percentcomplete (prop);
+               value = i_cal_property_get_percentcomplete (prop);
                snprintf (buffer, 16, "%d", value);
                e_ews_message_start_set_item_field (msg, "PercentComplete", "task", "Task");
                e_ews_message_write_string_parameter (msg, "PercentComplete", NULL, buffer);
                e_ews_message_end_set_item_field (msg);
+               g_object_unref (prop);
        }
 
        /* Recurrence */
-       value = icalcomponent_count_properties (e_cal_component_get_icalcomponent (convert_data->old_comp), 
ICAL_RRULE_PROPERTY);
-       if (icalcomponent_count_properties (icalcomp, ICAL_RRULE_PROPERTY) > 0 ||
-           (e_cal_util_find_x_property (icalcomp, X_EWS_TASK_REGENERATION) && value <= 0)) {
+       value = i_cal_component_count_properties (e_cal_component_get_icalcomponent (convert_data->old_comp), 
I_CAL_RRULE_PROPERTY);
+       if (i_cal_component_count_properties (icomp, I_CAL_RRULE_PROPERTY) > 0 ||
+           (e_cal_util_component_has_x_property (icomp, X_EWS_TASK_REGENERATION) && value <= 0)) {
                e_ews_message_start_set_item_field (msg, "Recurrence", "task", "Task");
-               success = success && e_ews_cal_utils_set_recurrence (msg, icalcomp, FALSE, error);
+               success = success && e_ews_cal_utils_set_recurrence (msg, icomp, FALSE, error);
                e_ews_message_end_set_item_field (msg); /* Recurrence */
        } else if (value > 0) {
                e_ews_message_add_delete_item_field (msg, "Recurrence", "task");
        }
 
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_DTSTART_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_DTSTART_PROPERTY);
        if (prop) {
-               dt = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icalcomp, ICAL_DTSTART_PROPERTY, icalproperty_get_dtstart);
+               dt = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache, 
convert_data->vcalendar, icomp, I_CAL_DTSTART_PROPERTY, i_cal_property_get_dtstart);
                e_ews_message_start_set_item_field (msg, "StartDate", "task", "Task");
-               e_ews_cal_utils_set_time (msg, "StartDate", &dt, TRUE);
+               e_ews_cal_utils_set_time (msg, "StartDate", dt, TRUE);
                e_ews_message_end_set_item_field (msg);
+               g_object_unref (prop);
+               g_clear_object (&dt);
        } else {
                e_ews_message_add_delete_item_field (msg, "StartDate", "task");
        }
 
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_STATUS_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_STATUS_PROPERTY);
        if (prop) {
-               switch (icalproperty_get_status (prop)) {
-               case ICAL_STATUS_INPROCESS:
+               switch (i_cal_property_get_status (prop)) {
+               case I_CAL_STATUS_INPROCESS:
                        convert_vtodo_property_to_updatexml (msg, "Status", "InProgress", "task", NULL, NULL);
                        break;
-               case ICAL_STATUS_COMPLETED:
+               case I_CAL_STATUS_COMPLETED:
                        convert_vtodo_property_to_updatexml (msg, "Status", "Completed", "task", NULL, NULL);
                        break;
-               case ICAL_STATUS_NONE:
-               case ICAL_STATUS_NEEDSACTION:
+               case I_CAL_STATUS_NONE:
+               case I_CAL_STATUS_NEEDSACTION:
                        convert_vtodo_property_to_updatexml (msg, "Status", "NotStarted", "task", NULL, NULL);
                        break;
                default:
                        break;
                }
+               g_object_unref (prop);
        }
 
        /* Categories */
        convert_component_categories_to_updatexml (convert_data->comp, msg, "Task");
 
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_PRIORITY_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_PRIORITY_PROPERTY);
        if (prop) {
                gint priority;
 
-               priority = icalproperty_get_priority (prop);
+               priority = i_cal_property_get_priority (prop);
                convert_vtodo_property_to_updatexml (msg, "Importance", ews_priority_to_string (priority), 
"item", NULL, NULL);
+               g_object_unref (prop);
        }
 
        e_ews_message_end_item_change (msg);
@@ -1895,11 +1999,11 @@ convert_vtodo_component_to_updatexml (ESoapMessage *msg,
 
 static void
 convert_vjournal_property_to_updatexml (ESoapMessage *msg,
-                                     const gchar *name,
-                                     const gchar *value,
-                                     const gchar *prefix,
-                                     const gchar *attr_name,
-                                     const gchar *attr_value)
+                                       const gchar *name,
+                                       const gchar *value,
+                                       const gchar *prefix,
+                                       const gchar *attr_name,
+                                       const gchar *attr_value)
 {
        e_ews_message_start_set_item_field (msg, name, prefix, "Message");
        e_ews_message_write_string_parameter_with_attribute (msg, name, NULL, value, attr_name, attr_value);
@@ -1912,8 +2016,8 @@ convert_vjournal_component_to_updatexml (ESoapMessage *msg,
                                         GError **error)
 {
        EwsCalendarConvertData *convert_data = user_data;
-       icalcomponent *icalcomp = e_cal_component_get_icalcomponent (convert_data->comp);
-       icalproperty *prop;
+       ICalComponent *icomp = e_cal_component_get_icalcomponent (convert_data->comp);
+       ICalProperty *prop;
        const gchar *text;
 
        e_ews_message_start_item_change (
@@ -1921,23 +2025,24 @@ convert_vjournal_component_to_updatexml (ESoapMessage *msg,
                convert_data->item_id, convert_data->change_key, 0);
 
        convert_vjournal_property_to_updatexml (msg, "ItemClass", "IPM.StickyNote", "item", NULL, NULL);
-       convert_vjournal_property_to_updatexml (msg, "Subject", icalcomponent_get_summary (icalcomp), "item", 
NULL, NULL);
+       convert_vjournal_property_to_updatexml (msg, "Subject", i_cal_component_get_summary (icomp), "item", 
NULL, NULL);
 
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_CLASS_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_CLASS_PROPERTY);
        if (prop) {
-               icalproperty_class classify = icalproperty_get_class (prop);
-               if (classify == ICAL_CLASS_PUBLIC) {
+               ICalProperty_Class classify = i_cal_property_get_class (prop);
+               if (classify == I_CAL_CLASS_PUBLIC) {
                        convert_vjournal_property_to_updatexml (msg, "Sensitivity", "Normal", "item", NULL, 
NULL);
-               } else if (classify == ICAL_CLASS_PRIVATE) {
+               } else if (classify == I_CAL_CLASS_PRIVATE) {
                        convert_vjournal_property_to_updatexml (msg, "Sensitivity", "Private", "item", NULL, 
NULL);
-               } else if (classify == ICAL_CLASS_CONFIDENTIAL) {
+               } else if (classify == I_CAL_CLASS_CONFIDENTIAL) {
                        convert_vjournal_property_to_updatexml (msg, "Sensitivity", "Personal", "item", NULL, 
NULL);
                }
+               g_object_unref (prop);
        }
 
-       text = icalcomponent_get_description (icalcomp);
+       text = i_cal_component_get_description (icomp);
        if (!text || !*text)
-               text = icalcomponent_get_summary (icalcomp);
+               text = i_cal_component_get_summary (icomp);
 
        convert_vjournal_property_to_updatexml (msg, "Body", text, "item", "BodyType", "Text");
 
@@ -1955,17 +2060,17 @@ e_cal_backend_ews_convert_component_to_updatexml (ESoapMessage *msg,
                                                  GError **error)
 {
        EwsCalendarConvertData *convert_data = user_data;
-       icalcomponent *icalcomp = e_cal_component_get_icalcomponent (convert_data->comp);
+       ICalComponent *icomp = e_cal_component_get_icalcomponent (convert_data->comp);
        gboolean success = FALSE;
 
-       switch (icalcomponent_isa (icalcomp)) {
-       case ICAL_VEVENT_COMPONENT:
+       switch (i_cal_component_isa (icomp)) {
+       case I_CAL_VEVENT_COMPONENT:
                success = convert_vevent_component_to_updatexml (msg, user_data, error);
                break;
-       case ICAL_VTODO_COMPONENT:
+       case I_CAL_VTODO_COMPONENT:
                success = convert_vtodo_component_to_updatexml (msg, user_data, error);
                break;
-       case ICAL_VJOURNAL_COMPONENT:
+       case I_CAL_VJOURNAL_COMPONENT:
                success = convert_vjournal_component_to_updatexml (msg, user_data, error);
                break;
        default:
@@ -1976,41 +2081,67 @@ e_cal_backend_ews_convert_component_to_updatexml (ESoapMessage *msg,
 }
 
 guint
-e_cal_backend_ews_rid_to_index (icaltimezone *timezone,
+e_cal_backend_ews_rid_to_index (ICalTimezone *timezone,
                                const gchar *rid,
-                               icalcomponent *comp,
+                               ICalComponent *comp,
                                GError **error)
 {
        guint index = 1;
-       icalproperty *prop = icalcomponent_get_first_property (comp, ICAL_RRULE_PROPERTY);
-       struct icalrecurrencetype rule = icalproperty_get_rrule (prop);
-       struct icaltimetype dtstart = icalcomponent_get_dtstart (comp);
-       icalrecur_iterator * ritr;
-       icaltimetype next, o_time;
+       ICalProperty *prop = i_cal_component_get_first_property (comp, I_CAL_RRULE_PROPERTY);
+       ICalRecurrence *rrule = i_cal_property_get_rrule (prop);
+       ICalTime *dtstart = i_cal_component_get_dtstart (comp);
+       ICalRecurIterator *ritr;
+       ICalTime *next, *o_time;
+
+       prop = i_cal_component_get_first_property (comp, I_CAL_RRULE_PROPERTY);
+       if (!prop)
+               return index;
+
+       rrule = i_cal_property_get_rrule (prop);
+       if (rrule) {
+               g_object_unref (prop);
+               return index;
+       }
+
+       dtstart = i_cal_component_get_dtstart (comp);
+       if (!dtstart) {
+               g_object_unref (prop);
+               g_object_unref (rrule);
+               return index;
+       }
 
-       /* icalcomponent_get_datetime needs a fix to initialize ret.zone to NULL. If a timezone is not
+       /* icomponent_get_datetime needs a fix to initialize ret.zone to NULL. If a timezone is not
         * found in libical, it remains uninitialized in that function causing invalid read or crash. so
         * we set the timezone as we cannot identify if it has a valid timezone or not */
-       dtstart.zone = timezone;
-       ritr = icalrecur_iterator_new (rule, dtstart);
-       next = icalrecur_iterator_next (ritr);
-       o_time = icaltime_from_string (rid);
-       o_time.zone = dtstart.zone;
-
-       for (; !icaltime_is_null_time (next); next = icalrecur_iterator_next (ritr), index++) {
-               if (icaltime_compare_date_only (o_time, next) == 0)
+       i_cal_time_set_timezone (dtstart, timezone);
+
+       o_time = i_cal_time_from_string (rid);
+       i_cal_time_set_timezone (o_time, timezone);
+
+       ritr = i_cal_recur_iterator_new (rrule, dtstart);
+       next = i_cal_recur_iterator_next (ritr);
+
+       for (next = i_cal_recur_iterator_next (ritr);
+            next && !i_cal_time_is_null_time (next);
+            g_object_unref (next), next = i_cal_recur_iterator_next (ritr), index++) {
+               if (i_cal_time_compare_date_only (o_time, next) == 0) {
                        break;
+               }
        }
 
-       icalrecur_iterator_free (ritr);
-
-       if (icaltime_is_null_time (next)) {
-               g_propagate_error (
-                       error, EDC_ERROR_EX (OtherError,
-                       "Invalid occurrence ID"));
+       if (!next || i_cal_time_is_null_time (next)) {
+               g_propagate_error (error,
+                       e_client_error_create (E_CLIENT_ERROR_OTHER_ERROR, _("Invalid occurrence ID")));
                index = 0;
        }
 
+       g_clear_object (&prop);
+       g_clear_object (&rrule);
+       g_clear_object (&dtstart);
+       g_clear_object (&o_time);
+       g_clear_object (&next);
+       g_clear_object (&ritr);
+
        return index;
 }
 
@@ -2091,41 +2222,50 @@ e_cal_backend_ews_prepare_accept_item_request (ESoapMessage *msg,
        return TRUE;
 }
 
-struct icaltimetype
+ICalTime *
 e_cal_backend_ews_get_datetime_with_zone (ETimezoneCache *timezone_cache,
-                                         icalcomponent *vcalendar,
-                                         icalcomponent *comp,
-                                         icalproperty_kind prop_kind,
-                                         struct icaltimetype (* get_func) (const icalproperty *prop))
+                                         ICalComponent *vcalendar,
+                                         ICalComponent *comp,
+                                         ICalPropertyKind prop_kind,
+                                         ICalTime * (* get_func) (ICalProperty *prop))
 {
-       struct icaltimetype dt = icaltime_null_time ();
-       icalproperty *prop;
-       icalparameter *param;
+       ICalTime *dt = NULL;
+       ICalTimezone *zone;
+       ICalProperty *prop;
+       ICalParameter *param;
        const gchar *tzid, *eqv_tzid;
 
        g_return_val_if_fail (E_IS_TIMEZONE_CACHE (timezone_cache), dt);
        g_return_val_if_fail (comp != NULL, dt);
        g_return_val_if_fail (get_func != NULL, dt);
 
-       prop = icalcomponent_get_first_property (comp, prop_kind);
+       prop = i_cal_component_get_first_property (comp, prop_kind);
        if (!prop)
                return dt;
 
        dt = get_func (prop);
 
-       if (!icaltime_is_valid_time (dt) ||
-           icaltime_is_null_time (dt))
+       if (dt || !i_cal_time_is_valid_time (dt) ||
+           i_cal_time_is_null_time (dt)) {
+               g_clear_object (&dt);
+               g_object_unref (prop);
                return dt;
+       }
 
-       dt.zone = NULL;
+       i_cal_time_set_timezone (dt, NULL);
 
-       param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER);
-       if (!param)
+       param = i_cal_property_get_first_parameter (prop, I_CAL_TZID_PARAMETER);
+       if (!param) {
+               g_object_unref (prop);
                return dt;
+       }
 
-       tzid = icalparameter_get_tzid (param);
-       if (!tzid || !*tzid)
+       tzid = i_cal_parameter_get_tzid (param);
+       if (!tzid || !*tzid) {
+               g_object_unref (param);
+               g_object_unref (prop);
                return dt;
+       }
 
        eqv_tzid = e_cal_backend_ews_tz_util_get_ical_equivalent (tzid);
 
@@ -2136,14 +2276,22 @@ e_cal_backend_ews_get_datetime_with_zone (ETimezoneCache *timezone_cache,
                        eqv_tzid = e_cal_backend_ews_tz_util_get_ical_equivalent (eqv_tzid);
        }
 
+       zone = NULL;
+
        if (eqv_tzid)
-               dt.zone = e_timezone_cache_get_timezone (timezone_cache, eqv_tzid);
+               zone = e_timezone_cache_get_timezone (timezone_cache, eqv_tzid);
+
+       if (!zone)
+               zone = e_timezone_cache_get_timezone (timezone_cache, tzid);
+
+       if (!zone)
+               zone = vcalendar ? i_cal_component_get_timezone (vcalendar, tzid) : NULL;
 
-       if (!dt.zone)
-               dt.zone = e_timezone_cache_get_timezone (timezone_cache, tzid);
+       i_cal_time_set_timezone (dt, zone);
 
-       if (!dt.zone)
-               dt.zone = vcalendar ? icalcomponent_get_timezone (vcalendar, tzid) : NULL;
+       g_clear_object (&zone);
+       g_object_unref (param);
+       g_object_unref (prop);
 
        return dt;
 }
diff --git a/src/calendar/e-cal-backend-ews-utils.h b/src/calendar/e-cal-backend-ews-utils.h
index 6501485f..c8c66ca6 100644
--- a/src/calendar/e-cal-backend-ews-utils.h
+++ b/src/calendar/e-cal-backend-ews-utils.h
@@ -22,8 +22,6 @@
 #define E_CAL_BACKEND_EWS_UTILS_H
 
 #include <libecal/libecal.h>
-#include <libical/icaltime.h>
-#include <libical/icaltimezone.h>
 
 #include "server/e-ews-connection.h"
 #include "server/e-ews-item-change.h"
@@ -31,8 +29,6 @@
 #include "e-cal-backend-ews.h"
 
 G_BEGIN_DECLS
-#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 MINUTES_IN_HOUR 60
 #define SECS_IN_MINUTE 60
@@ -40,14 +36,14 @@ G_BEGIN_DECLS
 typedef struct {
        EEwsConnection *connection;
        ETimezoneCache *timezone_cache;
-       icaltimezone *default_zone;
+       ICalTimezone *default_zone;
        gchar *user_email;
        gchar *response_type; /* Accept */
        GSList *users;
        ECalComponent *comp;
        ECalComponent *old_comp;
-       icalcomponent *icalcomp;
-       icalcomponent *vcalendar; /* can be NULL, parent of icalcomp, where timezones can be eventually found 
*/
+       ICalComponent *icomp;
+       ICalComponent *vcalendar; /* can be NULL, parent of icomp, where timezones can be eventually found */
        gchar *item_id;
        gchar *change_key;
        EEwsItemChangeType change_type;
@@ -56,17 +52,17 @@ typedef struct {
        time_t end;
 } EwsCalendarConvertData;
 
-const gchar *e_ews_collect_organizer (icalcomponent *comp);
-void e_ews_collect_attendees (icalcomponent *comp, GSList **required, GSList **optional, GSList **resource, 
gboolean *out_rsvp_requested);
+const gchar *e_ews_collect_organizer (ICalComponent *comp);
+void e_ews_collect_attendees (ICalComponent *comp, GSList **required, GSList **optional, GSList **resource, 
gboolean *out_rsvp_requested);
 
 void ewscal_set_timezone (ESoapMessage *msg, const gchar *name, EEwsCalendarTimeZoneDefinition *tzd);
-void ewscal_set_meeting_timezone (ESoapMessage *msg, icaltimezone *icaltz);
-void ewscal_set_reccurence (ESoapMessage *msg, icalproperty *rrule, icaltimetype *dtstart);
-void ewscal_set_reccurence_exceptions (ESoapMessage *msg, icalcomponent *comp);
+void ewscal_set_meeting_timezone (ESoapMessage *msg, ICalTimezone *icaltz);
+void ewscal_set_reccurence (ESoapMessage *msg, ICalProperty *rrule, ICalTime *dtstart);
+void ewscal_set_reccurence_exceptions (ESoapMessage *msg, ICalComponent *comp);
 gchar *e_ews_extract_attachment_id_from_uri (const gchar *uri);
-void ews_set_alarm (ESoapMessage *msg, ECalComponent *comp, ETimezoneCache *timezone_cache, icalcomponent 
*vcalendar, gboolean with_due_by);
+void ews_set_alarm (ESoapMessage *msg, ECalComponent *comp, ETimezoneCache *timezone_cache, ICalComponent 
*vcalendar, gboolean with_due_by);
 gint ews_get_alarm (ECalComponent *comp);
-void e_ews_clean_icalcomponent (icalcomponent *icalcomp);
+void e_ews_clean_icomponent (ICalComponent *icomp);
 
 const gchar *e_cal_backend_ews_tz_util_get_msdn_equivalent (const gchar *ical_tz_location);
 const gchar *e_cal_backend_ews_tz_util_get_ical_equivalent (const gchar *msdn_tz_location);
@@ -79,14 +75,13 @@ gboolean e_cal_backend_ews_clear_reminder_is_set (ESoapMessage *msg, gpointer us
 gboolean e_cal_backend_ews_prepare_set_free_busy_status (ESoapMessage *msg,gpointer user_data, GError 
**error);
 gboolean e_cal_backend_ews_prepare_accept_item_request (ESoapMessage *msg, gpointer user_data, GError 
**error);
 
-guint e_cal_backend_ews_rid_to_index (icaltimezone *timezone, const gchar *rid, icalcomponent *comp, GError 
**error);
+guint e_cal_backend_ews_rid_to_index (ICalTimezone *timezone, const gchar *rid, ICalComponent *comp, GError 
**error);
 
-struct icaltimetype
-               e_cal_backend_ews_get_datetime_with_zone        (ETimezoneCache *timezone_cache,
-                                                                icalcomponent *vcalendar,
-                                                                icalcomponent *comp,
-                                                                icalproperty_kind prop_kind,
-                                                                struct icaltimetype (* get_func) (const 
icalproperty *prop));
+ICalTime *     e_cal_backend_ews_get_datetime_with_zone        (ETimezoneCache *timezone_cache,
+                                                                ICalComponent *vcalendar,
+                                                                ICalComponent *comp,
+                                                                ICalPropertyKind prop_kind,
+                                                                ICalTime * (* get_func) (ICalProperty 
*prop));
 
 G_END_DECLS
 
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index 2a574fff..84f93160 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -32,11 +32,7 @@
 #include <camel/camel.h>
 
 #include <libedata-cal/libedata-cal.h>
-
-#include <libical/icaltz-util.h>
-#include <libical/icalcomponent.h>
-#include <libical/icalproperty.h>
-#include <libical/icalparameter.h>
+#include <libecal/libecal.h>
 
 #include <calendar/gui/calendar-config.h>
 #include <calendar/gui/itip-utils.h>
@@ -62,6 +58,11 @@
 #define gmtime_r(tp,tmp) (gmtime(tp)?(*(tmp)=*gmtime(tp),(tmp)):0)
 #endif
 
+#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)
+#define ECC_ERROR_EX(_code, _msg) e_cal_client_error_create (_code, _msg)
+
 /* Private part of the CalBackendEws structure */
 struct _ECalBackendEwsPrivate {
        GRecMutex cnc_lock;
@@ -152,23 +153,25 @@ ecb_ews_convert_error_to_edc_error (GError **perror)
 {
        GError *error = NULL;
 
-       if (!perror || !*perror || (*perror)->domain == E_DATA_CAL_ERROR)
+       if (!perror || !*perror ||
+           (*perror)->domain == E_CLIENT_ERROR ||
+           (*perror)->domain == E_CAL_CLIENT_ERROR)
                return;
 
        if ((*perror)->domain == EWS_CONNECTION_ERROR) {
                switch ((*perror)->code) {
                case EWS_CONNECTION_ERROR_AUTHENTICATION_FAILED:
-                       error = EDC_ERROR_EX (AuthenticationFailed, (*perror)->message);
+                       error = EC_ERROR_EX (E_CLIENT_ERROR_AUTHENTICATION_FAILED, (*perror)->message);
                        break;
                case EWS_CONNECTION_ERROR_FOLDERNOTFOUND:
                case EWS_CONNECTION_ERROR_MANAGEDFOLDERNOTFOUND:
                case EWS_CONNECTION_ERROR_PARENTFOLDERNOTFOUND:
                case EWS_CONNECTION_ERROR_PUBLICFOLDERSERVERNOTFOUND:
-                       error = EDC_ERROR_EX (NoSuchCal, (*perror)->message);
+                       error = ECC_ERROR_EX (E_CAL_CLIENT_ERROR_NO_SUCH_CALENDAR, (*perror)->message);
                        break;
                case EWS_CONNECTION_ERROR_EVENTNOTFOUND:
                case EWS_CONNECTION_ERROR_ITEMNOTFOUND:
-                       error = EDC_ERROR_EX (ObjectNotFound, (*perror)->message);
+                       error = ECC_ERROR_EX (E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND, (*perror)->message);
                        break;
                case EWS_CONNECTION_ERROR_UNAVAILABLE:
                        g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_HOST_NOT_FOUND, 
(*perror)->message);
@@ -176,7 +179,7 @@ ecb_ews_convert_error_to_edc_error (GError **perror)
                }
 
                if (!error)
-                       error = EDC_ERROR_EX (OtherError, (*perror)->message);
+                       error = EC_ERROR_EX (E_CLIENT_ERROR_OTHER_ERROR, (*perror)->message);
        }
 
        if (error) {
@@ -192,7 +195,7 @@ ecb_ews_maybe_disconnect_sync (ECalBackendEws *cbews,
 {
        g_return_if_fail (E_IS_CAL_BACKEND_EWS (cbews));
 
-       if (in_perror && g_error_matches (*in_perror, E_DATA_CAL_ERROR, AuthenticationFailed)) {
+       if (in_perror && g_error_matches (*in_perror, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_FAILED)) {
                e_cal_meta_backend_disconnect_sync (E_CAL_META_BACKEND (cbews), cancellable, NULL);
                e_backend_schedule_credentials_required (E_BACKEND (cbews), 
E_SOURCE_CREDENTIALS_REASON_REJECTED, NULL, 0, NULL, NULL, G_STRFUNC);
        }
@@ -263,18 +266,18 @@ ecb_ews_unset_connection (ECalBackendEws *cbews)
        g_rec_mutex_unlock (&cbews->priv->cnc_lock);
 }
 
-static icaltimezone *
+static ICalTimezone *
 ecb_ews_get_timezone (ETimezoneCache *timezone_cache,
                      const gchar *msdn_tzid,
                      const gchar *tzid,
                      const gchar *evo_ews_tzid)
 {
-       icaltimezone *zone = NULL;
+       ICalTimezone *zone = NULL;
        const gchar *evo_ews_msdn_tzid;
 
        zone = e_timezone_cache_get_timezone (timezone_cache, tzid);
        if (zone == NULL)
-               zone = icaltimezone_get_builtin_timezone (tzid);
+               zone = i_cal_timezone_get_builtin_timezone (tzid);
 
        if (g_strcmp0 (tzid, evo_ews_tzid) == 0)
                return zone;
@@ -285,36 +288,36 @@ ecb_ews_get_timezone (ETimezoneCache *timezone_cache,
                if (g_strcmp0 (msdn_tzid, evo_ews_msdn_tzid) == 0) {
                        zone = e_timezone_cache_get_timezone (timezone_cache, evo_ews_tzid);
                        if (zone == NULL)
-                               zone = icaltimezone_get_builtin_timezone (evo_ews_tzid);
+                               zone = i_cal_timezone_get_builtin_timezone (evo_ews_tzid);
                }
        }
 
        return zone;
 }
 
-static icalparameter *
+static ICalParameter *
 ecb_ews_responsetype_to_partstat (const gchar *responsetype)
 {
-       icalparameter *param = NULL;
+       ICalParameter *param = NULL;
 
        if (!responsetype)
-               return icalparameter_new_partstat (ICAL_PARTSTAT_NONE);
+               return i_cal_parameter_new_partstat (I_CAL_PARTSTAT_NONE);
 
        if (g_ascii_strcasecmp (responsetype, "Organizer") == 0)
-               param = icalparameter_new_partstat (ICAL_PARTSTAT_ACCEPTED);
+               param = i_cal_parameter_new_partstat (I_CAL_PARTSTAT_ACCEPTED);
        else if (g_ascii_strcasecmp (responsetype, "Tentative") == 0)
-               param = icalparameter_new_partstat (ICAL_PARTSTAT_TENTATIVE);
+               param = i_cal_parameter_new_partstat (I_CAL_PARTSTAT_TENTATIVE);
        else if (g_ascii_strcasecmp (responsetype, "Accept") == 0)
-               param = icalparameter_new_partstat (ICAL_PARTSTAT_ACCEPTED);
+               param = i_cal_parameter_new_partstat (I_CAL_PARTSTAT_ACCEPTED);
        else if (g_ascii_strcasecmp (responsetype, "Decline") == 0)
-               param = icalparameter_new_partstat (ICAL_PARTSTAT_DECLINED);
+               param = i_cal_parameter_new_partstat (I_CAL_PARTSTAT_DECLINED);
        else if (g_ascii_strcasecmp (responsetype, "NoResponseReceived") == 0)
-               param = icalparameter_new_partstat (ICAL_PARTSTAT_NEEDSACTION);
+               param = i_cal_parameter_new_partstat (I_CAL_PARTSTAT_NEEDSACTION);
        else if (g_ascii_strcasecmp (responsetype, "Unknown") == 0)
-               param = icalparameter_new_partstat (ICAL_PARTSTAT_NEEDSACTION);
+               param = i_cal_parameter_new_partstat (I_CAL_PARTSTAT_NEEDSACTION);
 
        if (!param)
-               param = icalparameter_new_partstat (ICAL_PARTSTAT_NONE);
+               param = i_cal_parameter_new_partstat (I_CAL_PARTSTAT_NONE);
 
        return param;
 }
@@ -327,10 +330,10 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
 {
        ECalComponent *res_component = NULL;
        ETimezoneCache *timezone_cache;
-       icalcomponent_kind kind;
+       ICalComponentKind kind;
        EEwsItemType item_type;
-       icalcomponent *icalcomp, *vcomp;
-       icaltimezone *utc_zone = icaltimezone_get_utc_timezone ();
+       ICalComponent *icomp, *vcomp;
+       ICalTimezone *utc_zone = i_cal_timezone_get_utc_timezone ();
        CamelEwsSettings *ews_settings;
 
        g_return_val_if_fail (E_IS_CAL_BACKEND_EWS (cbews), NULL);
@@ -343,41 +346,42 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
 
        item_type = e_ews_item_get_item_type (item);
        if (item_type == E_EWS_ITEM_TYPE_TASK || item_type == E_EWS_ITEM_TYPE_MEMO) {
-               icalproperty *icalprop;
-               icaltimetype due_date, start_date, complete_date, created;
-               icalproperty_status status  = ICAL_STATUS_NONE;
-               icalproperty_class class = ICAL_CLASS_NONE;
+               ICalProperty *prop;
+               ICalTime *itt;
+               ICalPropertyStatus status = I_CAL_STATUS_NONE;
+               ICalProperty_Class class = I_CAL_CLASS_NONE;
                const gchar *ews_task_status, *sensitivity;
                EwsImportance item_importance;
                gint priority = 5;
                gboolean has_this_date = FALSE;
 
-               vcomp = icalcomponent_new (ICAL_VCALENDAR_COMPONENT);
+               vcomp = i_cal_component_new (I_CAL_VCALENDAR_COMPONENT);
                /*subject*/
-               icalcomp = icalcomponent_new (item_type == E_EWS_ITEM_TYPE_TASK ? ICAL_VTODO_COMPONENT : 
ICAL_VJOURNAL_COMPONENT);
-               icalprop = icalproperty_new_summary (e_ews_item_get_subject (item));
-               icalcomponent_add_property (icalcomp, icalprop);
+               icomp = i_cal_component_new (item_type == E_EWS_ITEM_TYPE_TASK ? I_CAL_VTODO_COMPONENT : 
I_CAL_VJOURNAL_COMPONENT);
+               prop = i_cal_property_new_summary (e_ews_item_get_subject (item));
+               i_cal_component_take_property (icomp, prop);
 
                /*date time created*/
-               created = icaltime_from_timet_with_zone (e_ews_item_get_date_created (item), 0, utc_zone);
-               icalprop = icalproperty_new_created (created);
-               icalcomponent_add_property (icalcomp, icalprop);
+               itt = i_cal_time_from_timet_with_zone (e_ews_item_get_date_created (item), 0, utc_zone);
+               prop = i_cal_property_new_created (itt);
+               i_cal_component_take_property (icomp, prop);
+               g_clear_object (&itt);
 
                /*sensitivity*/
                sensitivity = e_ews_item_get_sensitivity (item);
                if (g_strcmp0 (sensitivity, "Normal") == 0)
-                       class = ICAL_CLASS_PUBLIC;
+                       class = I_CAL_CLASS_PUBLIC;
                else if (g_strcmp0 (sensitivity, "Private") == 0)
-                       class = ICAL_CLASS_PRIVATE;
+                       class = I_CAL_CLASS_PRIVATE;
                else if ((g_strcmp0 (sensitivity, "Confidential") == 0) ||
                         (g_strcmp0 (sensitivity, "Personal") == 0))
-                       class = ICAL_CLASS_CONFIDENTIAL;
-               icalprop = icalproperty_new_class (class);
-               icalcomponent_add_property (icalcomp, icalprop);
+                       class = I_CAL_CLASS_CONFIDENTIAL;
+               prop = i_cal_property_new_class (class);
+               i_cal_component_take_property (icomp, prop);
 
                /*description*/
-               icalprop = icalproperty_new_description (e_ews_item_get_body (item));
-               icalcomponent_add_property (icalcomp, icalprop);
+               prop = i_cal_property_new_description (e_ews_item_get_body (item));
+               i_cal_component_take_property (icomp, prop);
 
                /*task assaingments*/
                if (e_ews_item_get_delegator (item) != NULL) {
@@ -385,20 +389,20 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
                        GSList *mailboxes = NULL, *l;
                        gboolean includes_last_item;
                        gchar *mailtoname, *user_email;
-                       icalparameter *param;
+                       ICalParameter *param;
 
                        /*The task owner according to Exchange is current user, even that the task was 
assigned by
                         *someone else. I'm making the current user attendee and task delegator will be a 
task organizer */
 
                        user_email = camel_ews_settings_dup_email (ews_settings);
                        mailtoname = g_strdup_printf ("mailto:%s";, user_email);
-                       icalprop = icalproperty_new_attendee (mailtoname);
+                       prop = i_cal_property_new_attendee (mailtoname);
                        g_free (mailtoname);
                        g_free (user_email);
 
-                       param = icalparameter_new_cn (e_ews_item_get_owner (item));
-                       icalproperty_add_parameter (icalprop, param);
-                       icalcomponent_add_property (icalcomp, icalprop);
+                       param = i_cal_parameter_new_cn (e_ews_item_get_owner (item));
+                       i_cal_property_take_parameter (prop, param);
+                       i_cal_component_take_property (icomp, prop);
 
                        /* get delegator mail box*/
                        e_ews_connection_resolve_names_sync (
@@ -410,10 +414,10 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
                                EwsMailbox *mb = l->data;
 
                                mailtoname = g_strdup_printf ("mailto:%s";, mb->email);
-                               icalprop = icalproperty_new_organizer (mailtoname);
-                               param = icalparameter_new_cn (mb->name);
-                               icalproperty_add_parameter (icalprop, param);
-                               icalcomponent_add_property (icalcomp, icalprop);
+                               prop = i_cal_property_new_organizer (mailtoname);
+                               param = i_cal_parameter_new_cn (mb->name);
+                               i_cal_property_take_parameter (prop, param);
+                               i_cal_component_take_property (icomp, prop);
 
                                g_free (mailtoname);
                                e_ews_mailbox_free (mb);
@@ -422,55 +426,58 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
                }
 
                if (item_type == E_EWS_ITEM_TYPE_TASK) {
-                       icaltimezone *user_timezone = calendar_config_get_icaltimezone ();
+                       ICalTimezone *user_timezone = calendar_config_get_icaltimezone ();
                        const gchar *percent_complete;
 
                        /*start date*/
                        has_this_date = FALSE;
                        e_ews_item_task_has_start_date (item, &has_this_date);
                        if (has_this_date) {
-                               start_date = icaltime_from_timet_with_zone (e_ews_item_get_start_date (item), 
0, user_timezone);
-                               start_date.is_date = 1;
-                               icalprop = icalproperty_new_dtstart (start_date);
-                               icalcomponent_add_property (icalcomp, icalprop);
+                               itt = i_cal_time_from_timet_with_zone (e_ews_item_get_start_date (item), 0, 
user_timezone);
+                               i_cal_time_set_is_date (itt, TRUE);
+                               prop = i_cal_property_new_dtstart (itt);
+                               i_cal_component_take_property (icomp, prop);
+                               g_clear_object (&itt);
                        }
 
                        /*status*/
                        ews_task_status = e_ews_item_get_status (item);
                        if (g_strcmp0 (ews_task_status, "NotStarted") != 0) {
                                if (g_strcmp0 (ews_task_status, "Completed") == 0)
-                                       status = ICAL_STATUS_COMPLETED;
+                                       status = I_CAL_STATUS_COMPLETED;
                                else if (g_strcmp0 (ews_task_status, "InProgress") == 0)
-                                       status = ICAL_STATUS_INPROCESS;
+                                       status = I_CAL_STATUS_INPROCESS;
                                else if (g_strcmp0 (ews_task_status, "WaitingOnOthers") == 0)
-                                       status = ICAL_STATUS_NEEDSACTION;
+                                       status = I_CAL_STATUS_NEEDSACTION;
                                else if (g_strcmp0 (ews_task_status, "Deferred") == 0)
-                                       status = ICAL_STATUS_CANCELLED;
-                               icalprop = icalproperty_new_status (status);
-                               icalcomponent_add_property (icalcomp, icalprop);
+                                       status = I_CAL_STATUS_CANCELLED;
+                               prop = i_cal_property_new_status (status);
+                               i_cal_component_take_property (icomp, prop);
                        }
 
                        /*precent complete*/
                        percent_complete = e_ews_item_get_percent_complete (item);
-                       icalprop  = icalproperty_new_percentcomplete (atoi (percent_complete ? 
percent_complete : "0"));
-                       icalcomponent_add_property (icalcomp, icalprop);
+                       prop  = i_cal_property_new_percentcomplete (atoi (percent_complete ? percent_complete 
: "0"));
+                       i_cal_component_take_property (icomp, prop);
 
                        /*due date*/
                        e_ews_item_task_has_due_date (item, &has_this_date);
                        if (has_this_date) {
-                               due_date = icaltime_from_timet_with_zone (e_ews_item_get_due_date (item), 0, 
user_timezone);
-                               due_date.is_date = 1;
-                               icalprop = icalproperty_new_due (due_date);
-                               icalcomponent_add_property (icalcomp, icalprop);
+                               itt = i_cal_time_from_timet_with_zone (e_ews_item_get_due_date (item), 0, 
user_timezone);
+                               i_cal_time_set_is_date (itt, TRUE);
+                               prop = i_cal_property_new_due (itt);
+                               i_cal_component_take_property (icomp, prop);
+                               g_clear_object (&itt);
                        }
 
                        /*complete date*/
                        has_this_date = FALSE;
                        e_ews_item_task_has_complete_date (item, &has_this_date);
                        if (has_this_date) {
-                               complete_date = icaltime_from_timet_with_zone (e_ews_item_get_complete_date 
(item), 0, user_timezone);
-                               icalprop = icalproperty_new_completed (complete_date);
-                               icalcomponent_add_property (icalcomp, icalprop);
+                               itt = i_cal_time_from_timet_with_zone (e_ews_item_get_complete_date (item), 
0, user_timezone);
+                               prop = i_cal_property_new_completed (itt);
+                               i_cal_component_take_property (icomp, prop);
+                               g_clear_object (&itt);
                        }
 
                        /*priority*/
@@ -479,11 +486,11 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
                                priority = 3;
                        else if (item_importance == EWS_ITEM_LOW)
                                priority = 7;
-                       icalprop = icalproperty_new_priority (priority);
-                       icalcomponent_add_property (icalcomp, icalprop);
+                       prop = i_cal_property_new_priority (priority);
+                       i_cal_component_take_property (icomp, prop);
 
                        /* recurrence */
-                       e_ews_cal_utils_recurrence_to_rrule (item, icalcomp);
+                       e_ews_cal_utils_recurrence_to_rrule (item, icomp);
 
                        /* reminders */
                        /* The Exchange server stores start of the Task reminder and Start of the Task
@@ -493,64 +500,64 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
                                gint minutes_before_start = e_ews_item_get_reminder_minutes_before_start 
(item);
 
                                if (minutes_before_start >= 0 && reminder_due_by > (time_t) 0) {
-                                       ECalComponentAlarmTrigger trigger;
-                                       ECalComponentAlarmRepeat repeat;
+                                       ECalComponentAlarmTrigger *trigger;
                                        ECalComponentAlarm *alarm;
-                                       icalcomponent *alarm_icalcomp;
-                                       struct icaltimetype dtstart, due_by;
+                                       ICalTime *dtstart, *due_by;
+                                       ICalDuration *duration;
+                                       ICalComponent *alarm_icomp;
 
-                                       dtstart = e_cal_backend_ews_get_datetime_with_zone (timezone_cache, 
NULL, icalcomp, ICAL_DTSTART_PROPERTY, icalproperty_get_dtstart);
-                                       due_by = icaltime_from_timet_with_zone (reminder_due_by, 0, utc_zone);
+                                       dtstart = e_cal_backend_ews_get_datetime_with_zone (timezone_cache, 
NULL, icomp, I_CAL_DTSTART_PROPERTY, i_cal_property_get_dtstart);
+                                       due_by = i_cal_time_from_timet_with_zone (reminder_due_by, 0, 
utc_zone);
 
-                                       if (icaltime_is_null_time (dtstart)) {
-                                               dtstart = due_by;
-                                               dtstart.is_date = 1;
+                                       if (!dtstart || i_cal_time_is_null_time (dtstart)) {
+                                               g_clear_object (&dtstart);
 
-                                               icalcomponent_set_dtstart (icalcomp, dtstart);
+                                               dtstart = i_cal_time_new_clone (due_by);
+                                               i_cal_time_set_is_date (dtstart, TRUE);
+
+                                               i_cal_component_set_dtstart (icomp, dtstart);
                                        }
 
-                                       dtstart.is_date = 0;
-                                       dtstart.hour = 0;
-                                       dtstart.minute = 0;
-                                       dtstart.second = 0;
-                                       dtstart.zone = utc_zone;
+                                       i_cal_time_set_is_date (dtstart, FALSE);
+                                       i_cal_time_set_time (dtstart, 0, 0, 0);
+                                       i_cal_time_set_timezone (dtstart, utc_zone);
 
                                        minutes_before_start = minutes_before_start + (
-                                               (icaltime_as_timet_with_zone (dtstart, utc_zone) -
-                                                icaltime_as_timet_with_zone (due_by, utc_zone)) / 60);
+                                               (i_cal_time_as_timet_with_zone (dtstart, utc_zone) -
+                                                i_cal_time_as_timet_with_zone (due_by, utc_zone)) / 60);
 
-                                       alarm = e_cal_component_alarm_new ();
-                                       memset (&trigger, 0, sizeof (ECalComponentAlarmTrigger));
+                                       duration = i_cal_duration_null_duration ();
+                                       i_cal_duration_set_is_neg (duration, minutes_before_start < 0 ? 0 : 
1); / * negative 'before start' means 'after start' * /
+                                       i_cal_duration_set_minutes (duration, minutes_before_start < 0 ? 
-minutes_before_start : minutes_before_start);
 
-                                       trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START;
-                                       trigger.u.rel_duration.is_neg = minutes_before_start < 0 ? 0 : 1; / * 
negative 'before start' means 'after start' * /
-                                       trigger.u.rel_duration.minutes = minutes_before_start < 0 ? 
-minutes_before_start : minutes_before_start;
+                                       trigger = e_cal_component_alarm_trigger_new_relative 
(E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START, duration);
+                                       g_clear_object (&duration);
 
-                                       memset (&repeat, 0, sizeof (repeat));
-                                       repeat.repetitions = 0;
+                                       alarm = e_cal_component_alarm_new ();
 
-                                       e_cal_component_alarm_set_trigger (alarm, trigger);
+                                       e_cal_component_alarm_take_trigger (alarm, trigger);
                                        e_cal_component_alarm_set_action (alarm, 
E_CAL_COMPONENT_ALARM_DISPLAY);
-                                       e_cal_component_alarm_set_repeat (alarm, repeat);
 
-                                       alarm_icalcomp = e_cal_component_alarm_get_icalcomponent (alarm);
-                                       if (alarm_icalcomp)
-                                               icalcomponent_add_component (icalcomp, alarm_icalcomp);
+                                       alarm_icomp = e_cal_component_alarm_get_as_component (alarm);
+                                       if (alarm_icomp)
+                                               i_cal_component_take_component (icomp, alarm_icomp);
 
                                        e_cal_component_alarm_free (alarm);
+                                       g_clear_object (&dtstart);
+                                       g_clear_object (&due_by);
                                }
                        } */
                }
 
-               icalcomponent_add_component (vcomp, icalcomp);
+               i_cal_component_take_component (vcomp, icomp);
        } else {
-               struct icaltimetype dt;
+               ICalTime *dt;
                const gchar *mime_content;
                const gchar *tzid;
                gboolean timezone_set = FALSE;
 
                mime_content = e_ews_item_get_mime_content (item);
-               vcomp = mime_content && *mime_content ? icalparser_parse_string (mime_content) : NULL;
+               vcomp = mime_content && *mime_content ? i_cal_parser_parse_string (mime_content) : NULL;
 
                if (!vcomp && mime_content && *mime_content) {
                        const gchar *begin_vcalendar, *end_vcalendar;
@@ -574,7 +581,7 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
                                gchar *str;
 
                                str = g_strconcat (mime_content, "\r\n", "END:VCALENDAR", "\r\n", NULL);
-                               vcomp = icalparser_parse_string (str);
+                               vcomp = i_cal_parser_parse_string (str);
                                g_free (str);
                        }
                }
@@ -605,7 +612,7 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
                         *   newer, we have to care about set it properly here, instead of use the same
                         *   as is used in DTSTART.
                         */
-                       icaltimezone *start_zone, *end_zone;
+                       ICalTimezone *start_zone, *end_zone;
                        const gchar *start_tzid, *end_tzid;
                        const gchar *ical_start_tzid, *ical_end_tzid;
                        const gchar *evo_ews_start_tzid, *evo_ews_end_tzid;
@@ -636,22 +643,26 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
                                evo_ews_end_tzid);
 
                        if (start_zone != NULL) {
-                               icalcomp = icalcomponent_get_first_component (vcomp, kind);
+                               icomp = i_cal_component_get_first_component (vcomp, kind);
 
-                               dt = e_cal_backend_ews_get_datetime_with_zone (timezone_cache, vcomp, 
icalcomp, ICAL_DTSTART_PROPERTY, icalproperty_get_dtstart);
-                               dt = icaltime_convert_to_zone (dt, start_zone);
-                               icalcomponent_set_dtstart (icalcomp, dt);
+                               dt = e_cal_backend_ews_get_datetime_with_zone (timezone_cache, vcomp, icomp, 
I_CAL_DTSTART_PROPERTY, i_cal_property_get_dtstart);
+                               i_cal_time_convert_to_zone_inplace (dt, start_zone);
+                               i_cal_component_set_dtstart (icomp, dt);
+                               g_clear_object (&dt);
 
                                timezone_set = TRUE;
                                e_timezone_cache_add_timezone (timezone_cache, start_zone);
 
                                if (end_zone != NULL) {
-                                       dt = e_cal_backend_ews_get_datetime_with_zone (timezone_cache, vcomp, 
icalcomp, ICAL_DTEND_PROPERTY, icalproperty_get_dtend);
-                                       dt = icaltime_convert_to_zone (dt, end_zone);
-                                       icalcomponent_set_dtend (icalcomp, dt);
+                                       dt = e_cal_backend_ews_get_datetime_with_zone (timezone_cache, vcomp, 
icomp, I_CAL_DTEND_PROPERTY, i_cal_property_get_dtend);
+                                       i_cal_time_convert_to_zone_inplace (dt, end_zone);
+                                       i_cal_component_set_dtend (icomp, dt);
+                                       g_clear_object (&dt);
 
                                        e_timezone_cache_add_timezone (timezone_cache, end_zone);
                                }
+
+                               g_clear_object (&icomp);
                        }
 
                        if (!timezone_set)
@@ -666,42 +677,49 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
                         * So, for older servers, here, we only set the DTSTART and DTEND properties with
                         * the same values.
                         */
-                       icaltimezone *zone;
+                       ICalTimezone *zone;
                        gchar *new_tzid = NULL;
 
-                       icalcomp = icalcomponent_get_first_component (vcomp, kind);
+                       icomp = i_cal_component_get_first_component (vcomp, kind);
 
-                       if (!icaltimezone_get_builtin_timezone (tzid) &&
-                           icalcomponent_get_uid (icalcomp)) {
-                               icalcomponent *vtimezone;
+                       if (!i_cal_timezone_get_builtin_timezone (tzid) &&
+                           i_cal_component_get_uid (icomp)) {
+                               ICalComponent *vtimezone, *clone;
 
                                /* Add the timezone */
-                               vtimezone = icalcomponent_get_first_component (vcomp, 
ICAL_VTIMEZONE_COMPONENT);
+                               vtimezone = i_cal_component_get_first_component (vcomp, 
I_CAL_VTIMEZONE_COMPONENT);
                                if (vtimezone != NULL) {
-                                       icalproperty *prop;
+                                       ICalProperty *prop;
 
-                                       new_tzid = g_strconcat ("/evolution/ews/tzid/", icalcomponent_get_uid 
(icalcomp), NULL);
+                                       new_tzid = g_strconcat ("/evolution/ews/tzid/", 
i_cal_component_get_uid (icomp), NULL);
 
-                                       zone = icaltimezone_new ();
-                                       vtimezone = icalcomponent_new_clone (vtimezone);
-                                       prop = icalcomponent_get_first_property (vtimezone, 
ICAL_TZID_PROPERTY);
+                                       zone = i_cal_timezone_new ();
+                                       clone = i_cal_component_new_clone (vtimezone);
+                                       g_object_unref (vtimezone);
+                                       vtimezone = clone;
+
+                                       prop = i_cal_component_get_first_property (vtimezone, 
I_CAL_TZID_PROPERTY);
                                        if (prop) {
-                                               icalproperty_set_tzid (prop, new_tzid);
+                                               i_cal_property_set_tzid (prop, new_tzid);
+                                               g_object_unref (prop);
 
-                                               prop = icalcomponent_get_first_property (vtimezone, 
ICAL_LOCATION_PROPERTY);
+                                               prop = i_cal_component_get_first_property (vtimezone, 
I_CAL_LOCATION_PROPERTY);
                                                if (!prop) {
                                                        /* Use the original tzid as the timezone Location, to 
not expose
                                                           evolution-ews TZID. */
-                                                       prop = icalproperty_new_location (tzid);
-                                                       icalcomponent_add_property (vtimezone, prop);
+                                                       prop = i_cal_property_new_location (tzid);
+                                                       i_cal_component_take_property (vtimezone, prop);
+                                               } else {
+                                                       g_object_unref (prop);
                                                }
                                        } else {
                                                g_free (new_tzid);
                                                new_tzid = NULL;
                                        }
-                                       icaltimezone_set_component (zone, vtimezone);
+                                       i_cal_timezone_set_component (zone, vtimezone);
                                        e_timezone_cache_add_timezone (timezone_cache, zone);
-                                       icaltimezone_free (zone, TRUE);
+                                       g_object_unref (zone);
+                                       g_object_unref (vtimezone);
                                }
                        }
 
@@ -710,54 +728,53 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
                        if (!zone && new_tzid)
                                zone = e_timezone_cache_get_timezone (timezone_cache, tzid);
 
-                       if (zone == NULL)
-                               zone = icaltimezone_get_builtin_timezone (tzid);
+                       if (!zone)
+                               zone = i_cal_timezone_get_builtin_timezone (tzid);
 
                        if (zone != NULL) {
-                               dt = e_cal_backend_ews_get_datetime_with_zone (timezone_cache, vcomp, 
icalcomp, ICAL_DTSTART_PROPERTY, icalproperty_get_dtstart);
-                               dt = icaltime_convert_to_zone (dt, zone);
-                               icalcomponent_set_dtstart (icalcomp, dt);
-
-                               dt = e_cal_backend_ews_get_datetime_with_zone (timezone_cache, vcomp, 
icalcomp, ICAL_DTEND_PROPERTY, icalproperty_get_dtend);
-                               dt = icaltime_convert_to_zone (dt, zone);
-                               icalcomponent_set_dtend (icalcomp, dt);
+                               dt = e_cal_backend_ews_get_datetime_with_zone (timezone_cache, vcomp, icomp, 
I_CAL_DTSTART_PROPERTY, i_cal_property_get_dtstart);
+                               i_cal_time_convert_to_zone_inplace (dt, zone);
+                               i_cal_component_set_dtstart (icomp, dt);
+                               g_object_unref (dt);
+
+                               dt = e_cal_backend_ews_get_datetime_with_zone (timezone_cache, vcomp, icomp, 
I_CAL_DTEND_PROPERTY, i_cal_property_get_dtend);
+                               i_cal_time_convert_to_zone_inplace (dt, zone);
+                               i_cal_component_set_dtend (icomp, dt);
+                               g_object_unref (dt);
                        }
 
+                       g_clear_object (&icomp);
                        g_free (new_tzid);
                }
        }
 
        /* Vevent or Vtodo */
-       icalcomp = icalcomponent_get_first_component (vcomp, kind);
-       if (icalcomp) {
-               icalproperty *icalprop, *freebusy;
-               struct icaltimetype itt;
+       icomp = i_cal_component_get_first_component (vcomp, kind);
+       if (icomp) {
+               ICalProperty *prop, *freebusy;
+               ICalTime *itt;
+               gchar *xvalue;
                const EwsId *item_id;
-               const GSList *l = NULL;
                const gchar *uid = e_ews_item_get_uid (item);
 
                item_id = e_ews_item_get_id (item);
 
                if (e_ews_item_get_is_meeting (item)) {
+                       const GSList *link;
                        gboolean is_response_requested = e_ews_item_get_is_response_requested (item);
                        gchar *user_email;
 
                        /* Remove any existing attendees first (as Office365.com (and possibly Exchange 2016) 
includes them) */
-                       for (icalprop = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
-                            icalprop;
-                            icalprop = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY)) {
-                               icalcomponent_remove_property (icalcomp, icalprop);
-                               icalproperty_free (icalprop);
-                       }
+                       e_cal_util_component_remove_property_by_kind (icomp, I_CAL_ATTENDEE_PROPERTY, TRUE);
 
                        user_email = camel_ews_settings_dup_email (ews_settings);
 
                        /* Attendees */
-                       for (l = e_ews_item_get_attendees (item); l != NULL; l = g_slist_next (l)) {
-                               icalparameter *param, *cu_type;
+                       for (link = e_ews_item_get_attendees (item); link; link = g_slist_next (link)) {
+                               ICalParameter *param, *cutype;
                                gchar *mailtoname;
                                const gchar *email = NULL;
-                               EwsAttendee *attendee = (EwsAttendee *) l->data;
+                               EwsAttendee *attendee = (EwsAttendee *) link->data;
 
                                if (!attendee->mailbox)
                                        continue;
@@ -766,30 +783,28 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
                                        email = e_ews_item_util_strip_ex_address (attendee->mailbox->email);
 
                                mailtoname = g_strdup_printf ("mailto:%s";, email ? email : 
attendee->mailbox->email);
-                               icalprop = icalproperty_new_attendee (mailtoname);
+                               prop = i_cal_property_new_attendee (mailtoname);
                                g_free (mailtoname);
 
-                               param = icalparameter_new_cn (attendee->mailbox->name);
-                               icalproperty_add_parameter (icalprop, param);
+                               param = i_cal_parameter_new_cn (attendee->mailbox->name);
+                               i_cal_property_take_parameter (prop, param);
 
                                if (g_ascii_strcasecmp (attendee->attendeetype, "Required") == 0) {
-                                       param = icalparameter_new_role (ICAL_ROLE_REQPARTICIPANT);
-                                       cu_type = icalparameter_new_cutype (ICAL_CUTYPE_INDIVIDUAL);
-                               }
-                               else if (g_ascii_strcasecmp (attendee->attendeetype, "Resource") == 0) {
-                                       param = icalparameter_new_role (ICAL_ROLE_NONPARTICIPANT);
-                                       cu_type = icalparameter_new_cutype (ICAL_CUTYPE_RESOURCE);
-                               }
-                               else {
-                                       param = icalparameter_new_role ( ICAL_ROLE_OPTPARTICIPANT);
-                                       cu_type = icalparameter_new_cutype (ICAL_CUTYPE_INDIVIDUAL);
+                                       param = i_cal_parameter_new_role (I_CAL_ROLE_REQPARTICIPANT);
+                                       cutype = i_cal_parameter_new_cutype (I_CAL_CUTYPE_INDIVIDUAL);
+                               } else if (g_ascii_strcasecmp (attendee->attendeetype, "Resource") == 0) {
+                                       param = i_cal_parameter_new_role (I_CAL_ROLE_NONPARTICIPANT);
+                                       cutype = i_cal_parameter_new_cutype (I_CAL_CUTYPE_RESOURCE);
+                               } else {
+                                       param = i_cal_parameter_new_role (I_CAL_ROLE_OPTPARTICIPANT);
+                                       cutype = i_cal_parameter_new_cutype (I_CAL_CUTYPE_INDIVIDUAL);
                                }
-                               icalproperty_add_parameter (icalprop, cu_type);
-                               icalproperty_add_parameter (icalprop, param);
+                               i_cal_property_take_parameter (prop, cutype);
+                               i_cal_property_take_parameter (prop, param);
 
                                if (is_response_requested) {
-                                       param = icalparameter_new_rsvp (ICAL_RSVP_TRUE);
-                                       icalproperty_add_parameter (icalprop, param);
+                                       param = i_cal_parameter_new_rsvp (I_CAL_RSVP_TRUE);
+                                       i_cal_property_take_parameter (prop, param);
                                }
 
                                if (user_email && (email || attendee->mailbox->email) && 
e_ews_item_get_my_response_type (item) &&
@@ -798,78 +813,69 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
                                } else {
                                        param = ecb_ews_responsetype_to_partstat (attendee->responsetype);
                                }
-                               icalproperty_add_parameter (icalprop, param);
+                               i_cal_property_take_parameter (prop, param);
 
-                               icalcomponent_add_property (icalcomp, icalprop);
+                               i_cal_component_take_property (icomp, prop);
                        }
 
                        g_free (user_email);
                }
 
                /* Free/Busy */
-               freebusy = icalcomponent_get_first_property (icalcomp, ICAL_TRANSP_PROPERTY);
+               xvalue = e_cal_util_component_dup_x_property (icomp, "X-MICROSOFT-CDO-BUSYSTATUS");
+               freebusy = i_cal_component_get_first_property (icomp, I_CAL_TRANSP_PROPERTY);
                if (!freebusy && (e_ews_item_get_item_type (item) != E_EWS_ITEM_TYPE_TASK)) {
                        /* Busy by default */
-                       freebusy = icalproperty_new_transp (ICAL_TRANSP_OPAQUE);
-                       icalcomponent_add_property (icalcomp, freebusy);
-               }
-               for (icalprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY);
-                    icalprop != NULL;
-                    icalprop = icalcomponent_get_next_property (icalcomp, ICAL_X_PROPERTY)) {
-                       if (g_strcmp0 (icalproperty_get_x_name (icalprop), "X-MICROSOFT-CDO-BUSYSTATUS") == 
0) {
-                               if (g_strcmp0 (icalproperty_get_value_as_string (icalprop), "BUSY") == 0) {
-                                       icalproperty_set_transp (freebusy, ICAL_TRANSP_OPAQUE);
-                               } else {
-                                       icalproperty_set_transp (freebusy, ICAL_TRANSP_TRANSPARENT);
-                               }
-
-                               break;
+                       freebusy = i_cal_property_new_transp (g_strcmp0 (xvalue, "BUSY") == 0 ? 
I_CAL_TRANSP_OPAQUE : I_CAL_TRANSP_TRANSPARENT);
+                       i_cal_component_add_property (icomp, freebusy);
+               } else if (freebusy) {
+                       if (g_strcmp0 (xvalue, "BUSY") == 0) {
+                               i_cal_property_set_transp (freebusy, I_CAL_TRANSP_OPAQUE);
+                       } else {
+                               i_cal_property_set_transp (freebusy, I_CAL_TRANSP_TRANSPARENT);
                        }
                }
+               g_clear_object (&freebusy);
+               g_free (xvalue);
 
                /* AllDayEvent */
-               for (icalprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY);
-                    icalprop != NULL;
-                    icalprop = icalcomponent_get_next_property (icalcomp, ICAL_X_PROPERTY)) {
-                       if (g_strcmp0 (icalproperty_get_x_name (icalprop), "X-MICROSOFT-CDO-ALLDAYEVENT") == 
0) {
-                               if (g_strcmp0 (icalproperty_get_value_as_string (icalprop), "TRUE") == 0) {
-                                       struct icaltimetype dtend, dtstart;
-                                       dtstart = icalcomponent_get_dtstart (icalcomp);
-                                       dtstart.is_date = 1;
-                                       icalcomponent_set_dtstart (icalcomp, dtstart);
-
-                                       dtend = icalcomponent_get_dtend (icalcomp);
-                                       dtend.is_date = 1;
-                                       icalcomponent_set_dtend (icalcomp, dtend);
-                               }
-                               break;
-                       }
+               xvalue = e_cal_util_component_dup_x_property (icomp, "X-MICROSOFT-CDO-ALLDAYEVENT");
+               if (g_strcmp0 (xvalue, "TRUE") == 0) {
+                       itt = i_cal_component_get_dtstart (icomp);
+                       i_cal_time_set_is_date (itt, TRUE);
+                       i_cal_component_set_dtstart (icomp, itt);
+                       g_object_unref (itt);
+
+                       itt = i_cal_component_get_dtend (icomp);
+                       i_cal_time_set_is_date (itt, TRUE);
+                       i_cal_component_set_dtend (icomp, itt);
+                       g_object_unref (itt);
                }
+               g_free (xvalue);
 
-               if (icalcomponent_get_first_property (icalcomp, ICAL_RECURRENCEID_PROPERTY)) {
+               if (e_cal_util_component_has_property (icomp, I_CAL_RECURRENCEID_PROPERTY)) {
                        /* Exchange sets RRULE even on the children, which is broken */
-                       icalprop = icalcomponent_get_first_property (icalcomp, ICAL_RRULE_PROPERTY);
-                       if (icalprop) {
-                               icalcomponent_remove_property (icalcomp, icalprop);
-                               icalproperty_free (icalprop);
-                       }
+                       e_cal_util_component_remove_property_by_kind (icomp, I_CAL_RRULE_PROPERTY, TRUE);
                }
 
                /* The EXDATE sent by the server can be date-time format with timezone, while
                   the event start time can be date-only. This breaks the rules, thus correct
                   it and make also EXDATE date-only. */
-               itt = icalcomponent_get_dtstart (icalcomp);
-               if (icaltime_is_valid_time (itt) && itt.is_date) {
-                       for (icalprop = icalcomponent_get_first_property (icalcomp, ICAL_EXDATE_PROPERTY);
-                            icalprop;
-                            icalprop = icalcomponent_get_next_property (icalcomp, ICAL_EXDATE_PROPERTY)) {
-                               itt = icalproperty_get_exdate (icalprop);
-                               itt.is_date = 1;
-                               icalproperty_set_exdate (icalprop, itt);
-
-                               icalproperty_remove_parameter_by_kind (icalprop, ICAL_TZID_PARAMETER);
+               itt = i_cal_component_get_dtstart (icomp);
+               if (itt && i_cal_time_is_valid_time (itt) && i_cal_time_is_date (itt)) {
+                       for (prop = i_cal_component_get_first_property (icomp, I_CAL_EXDATE_PROPERTY);
+                            prop;
+                            g_object_unref (prop), prop = i_cal_component_get_next_property (icomp, 
I_CAL_EXDATE_PROPERTY)) {
+                               g_clear_object (&itt);
+
+                               itt = i_cal_property_get_exdate (prop);
+                               i_cal_time_set_is_date (itt, TRUE);
+                               i_cal_property_set_exdate (prop, itt);
+
+                               i_cal_property_remove_parameter_by_kind (prop, I_CAL_TZID_PARAMETER);
                        }
                }
+               g_clear_object (&itt);
 
                /* Exchange sets an ORGANIZER on all events. RFC2445 says:
                 *
@@ -879,19 +885,16 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
                 *   scheduled entities, but are entities only on a single
                 *   user's calendar.
                 */
-               if (!icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY)) {
-                       if ((icalprop = icalcomponent_get_first_property (icalcomp, 
ICAL_ORGANIZER_PROPERTY))) {
-                               icalcomponent_remove_property (icalcomp, icalprop);
-                               icalproperty_free (icalprop);
-                       }
+               if (!e_cal_util_component_has_property (icomp, I_CAL_ATTENDEE_PROPERTY)) {
+                       e_cal_util_component_remove_property_by_kind (icomp, I_CAL_ORGANIZER_PROPERTY, TRUE);
                }
 
-               icalcomponent_set_uid (icalcomp, uid ? uid : item_id->id);
+               i_cal_component_set_uid (icomp, uid ? uid : item_id->id);
 
-               e_cal_util_set_x_property (icalcomp, "X-EVOLUTION-ITEMID", item_id->id);
-               e_cal_util_set_x_property (icalcomp, "X-EVOLUTION-CHANGEKEY", item_id->change_key);
+               e_cal_util_component_set_x_property (icomp, "X-EVOLUTION-ITEMID", item_id->id);
+               e_cal_util_component_set_x_property (icomp, "X-EVOLUTION-CHANGEKEY", item_id->change_key);
 
-               res_component = e_cal_component_new_from_icalcomponent (icalcomponent_new_clone (icalcomp));
+               res_component = e_cal_component_new_from_icalcomponent (i_cal_component_new_clone (icomp));
 
                /* Categories */
                e_cal_component_set_categories_list (res_component, (GSList *) e_ews_item_get_categories 
(item));
@@ -903,36 +906,43 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
                 * set the summary as the alarm description.
                 */
                if (e_cal_component_has_alarms (res_component)) {
-                       GList *alarm_uids, *l;
+                       ECalComponentText *text;
+
+                       text = e_cal_component_get_summary (res_component);
+                       if (text) {
+                               GSList *alarms, *link;
+
+                               alarms = e_cal_component_get_all_alarms (res_component);
+                               e_cal_component_remove_all_alarms (res_component);
 
-                       alarm_uids = e_cal_component_get_alarm_uids (res_component);
-                       for (l = alarm_uids; l != NULL; l = l->next) {
-                               ECalComponentAlarm *alarm;
-                               ECalComponentText text;
+                               for (link = alarms; link; link = g_slist_next (link)) {
+                                       ECalComponentAlarm *alarm = link->data;
 
-                               alarm = e_cal_component_get_alarm (res_component, l->data);
-                               e_cal_component_get_summary (res_component, &text);
-                               e_cal_component_alarm_set_description (alarm, &text);
+                                       e_cal_component_alarm_set_description (alarm, text);
+                                       e_cal_component_add_alarm (res_component, alarm);
+                               }
 
-                               e_cal_component_alarm_free (alarm);
+                               g_slist_free_full (alarms, e_cal_component_alarm_free);
+                               e_cal_component_text_free (text);
                        }
-                       cal_obj_uid_list_free (alarm_uids);
                }
+
+               g_object_unref (icomp);
        }
 
-       icalcomponent_free (vcomp);
+       g_object_unref (vcomp);
 
        if (res_component) {
                const GSList *attachment_ids, *aid, *l;
-               const gchar *uid = NULL;
-               GSList *info_attachments = NULL, *uris = NULL;
+               const gchar *uid;
+               GSList *info_attachments = NULL;
                gboolean has_attachment = FALSE;
 
                e_ews_item_has_attachments (item, &has_attachment);
                if (!has_attachment)
                        return res_component;
 
-               e_cal_component_get_uid (res_component, &uid);
+               uid = e_cal_component_get_uid (res_component);
 
                attachment_ids = e_ews_item_get_attachments_ids (item);
 
@@ -947,9 +957,9 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
                        NULL, NULL,
                        cancellable,
                        NULL)) {
-                       icalcomponent *icalcomp;
-                       icalproperty *icalprop;
-                       icalparameter *icalparam;
+                       ICalProperty *prop;
+                       ICalParameter *param;
+                       GSList *attaches = NULL;
 
                        for (l = info_attachments; l; l = l->next) {
                                EEwsAttachmentInfo *info = l->data;
@@ -958,22 +968,26 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
                                if (e_ews_attachment_info_get_type (info) == E_EWS_ATTACHMENT_INFO_TYPE_URI) {
                                        const gchar *uri = e_ews_attachment_info_get_uri (info);
 
-                                       if (uri)
-                                               uris = g_slist_append (uris, g_strdup (uri));
+                                       if (uri) {
+                                               attaches = g_slist_prepend (attaches,
+                                                       i_cal_attach_new_from_url (uri));
+                                       }
                                }
                        }
 
-                       e_cal_component_set_attachment_list (res_component, uris);
+                       attaches = g_slist_reverse (attaches);
+                       e_cal_component_set_attachments (res_component, attaches);
 
-                       icalcomp = e_cal_component_get_icalcomponent (res_component);
-                       icalprop = icalcomponent_get_first_property (icalcomp, ICAL_ATTACH_PROPERTY);
-                       for (aid = attachment_ids; aid && icalprop; aid = aid->next, icalprop = 
icalcomponent_get_next_property (icalcomp, ICAL_ATTACH_PROPERTY)) {
-                               icalparam = icalparameter_new_x (aid->data);
-                               icalparameter_set_xname (icalparam, "X-EWS-ATTACHMENTID");
-                               icalproperty_add_parameter (icalprop, icalparam);
+                       icomp = e_cal_component_get_icalcomponent (res_component);
+                       for (aid = attachment_ids, prop = i_cal_component_get_first_property (icomp, 
I_CAL_ATTACH_PROPERTY);
+                            aid && prop;
+                            aid = aid->next, g_object_unref (prop), prop = i_cal_component_get_next_property 
(icomp, I_CAL_ATTACH_PROPERTY)) {
+                               param = i_cal_parameter_new_x (aid->data);
+                               i_cal_parameter_set_xname (param, "X-EWS-ATTACHMENTID");
+                               i_cal_property_take_parameter (prop, param);
                        }
 
-                       g_slist_free_full (uris, g_free);
+                       g_slist_free_full (attaches, g_object_unref);
                        g_slist_free_full (info_attachments, (GDestroyNotify) e_ews_attachment_info_free);
                }
        }
@@ -990,7 +1004,7 @@ ecb_ews_store_original_comp (ECalComponent *comp)
        g_return_if_fail (E_IS_CAL_COMPONENT (comp));
 
        /* This makes sure it's not saved also in the original component */
-       e_cal_util_remove_x_property (e_cal_component_get_icalcomponent (comp), X_EWS_ORIGINAL_COMP);
+       e_cal_util_component_remove_x_property (e_cal_component_get_icalcomponent (comp), 
X_EWS_ORIGINAL_COMP);
 
        comp_str = e_cal_component_get_as_string (comp);
        g_return_if_fail (comp_str != NULL);
@@ -998,7 +1012,7 @@ ecb_ews_store_original_comp (ECalComponent *comp)
        /* Include NUL-terminator */
        base64 = g_base64_encode ((const guchar *) comp_str, strlen (comp_str) + 1);
 
-       e_cal_util_set_x_property (e_cal_component_get_icalcomponent (comp),
+       e_cal_util_component_set_x_property (e_cal_component_get_icalcomponent (comp),
                X_EWS_ORIGINAL_COMP, base64);
 
        g_free (base64);
@@ -1009,18 +1023,23 @@ static ECalComponent * /* free with g_object_unref(), if not NULL */
 ecb_ews_restore_original_comp (ECalComponent *from_comp)
 {
        ECalComponent *comp = NULL;
-       const gchar *original_base64;
+       gchar *original_base64;
        guchar *decoded;
        gsize len = -1;
 
        g_return_val_if_fail (E_IS_CAL_COMPONENT (from_comp), NULL);
 
-       original_base64 = e_cal_util_get_x_property (e_cal_component_get_icalcomponent (from_comp), 
X_EWS_ORIGINAL_COMP);
+       original_base64 = e_cal_util_component_dup_x_property (e_cal_component_get_icalcomponent (from_comp), 
X_EWS_ORIGINAL_COMP);
 
-       if (!original_base64 || !*original_base64)
+       if (!original_base64 || !*original_base64) {
+               g_free (original_base64);
                return NULL;
+       }
 
        decoded = g_base64_decode (original_base64, &len);
+
+       g_free (original_base64);
+
        if (!decoded || !*decoded || len <= 0) {
                g_free (decoded);
                return NULL;
@@ -1244,11 +1263,29 @@ ecb_ews_fetch_items_sync (ECalBackendEws *cbews,
        return success;
 }
 
+static gint
+ecb_ews_compare_time_and_free (ICalTime *itt1,
+                              ICalTime *itt2)
+{
+       gint res;
+
+       if (!itt1 || !itt2) {
+               res = itt1 == itt2 ? 0 : itt1 ? 1 : -1;
+       } else {
+               res = i_cal_time_compare (itt1, itt2);
+       }
+
+       g_clear_object (&itt1);
+       g_clear_object (&itt2);
+
+       return res;
+}
+
 static gboolean
 ecb_ews_freebusy_ecomp_changed (ECalComponent *ecomp,
-                               icalcomponent *vevent)
+                               ICalComponent *vevent)
 {
-       icalcomponent *icomp;
+       ICalComponent *icomp;
        gboolean changed = FALSE;
 
        g_return_val_if_fail (vevent != NULL, FALSE);
@@ -1261,20 +1298,34 @@ ecb_ews_freebusy_ecomp_changed (ECalComponent *ecomp,
                return TRUE;
 
        if (!changed)
-               changed = g_strcmp0 (icalcomponent_get_summary (icomp), icalcomponent_get_summary (vevent)) 
!= 0;
+               changed = g_strcmp0 (i_cal_component_get_summary (icomp), i_cal_component_get_summary 
(vevent)) != 0;
        if (!changed)
-               changed = g_strcmp0 (icalcomponent_get_location (icomp), icalcomponent_get_location (vevent)) 
!= 0;
+               changed = g_strcmp0 (i_cal_component_get_location (icomp), i_cal_component_get_location 
(vevent)) != 0;
        if (!changed)
-               changed = icaltime_compare (icalcomponent_get_dtstart (icomp), icalcomponent_get_dtstart 
(vevent)) != 0;
+               changed = ecb_ews_compare_time_and_free (i_cal_component_get_dtstart (icomp), 
i_cal_component_get_dtstart (vevent)) != 0;
        if (!changed)
-               changed = icaltime_compare (icalcomponent_get_dtend (icomp), icalcomponent_get_dtend 
(vevent)) != 0;
+               changed = ecb_ews_compare_time_and_free (i_cal_component_get_dtend (icomp), 
i_cal_component_get_dtend (vevent)) != 0;
 
        return changed;
 }
 
+static gboolean
+ecb_ews_changekey_equal (ICalComponent *icomp,
+                        const gchar *changekey)
+{
+       gchar *stored;
+       gboolean res;
+
+       stored = e_cal_util_component_dup_x_property (icomp, "X-EVOLUTION-CHANGEKEY");
+       res = g_strcmp0 (stored, changekey) == 0;
+       g_free (stored);
+
+       return res;
+}
+
 static GSList * /* the possibly modified 'in_items' */
 ecb_ews_verify_changes (ECalCache *cal_cache,
-                       icalcomponent_kind kind,
+                       ICalComponentKind kind,
                        GSList *in_items, /* EEwsItem * */
                        GCancellable *cancellable)
 {
@@ -1288,14 +1339,13 @@ ecb_ews_verify_changes (ECalCache *cal_cache,
                EEwsItemType type = e_ews_item_get_item_type (item);
 
                if (!g_cancellable_is_cancelled (cancellable) && (
-                   (type == E_EWS_ITEM_TYPE_EVENT && kind == ICAL_VEVENT_COMPONENT) ||
-                   (type == E_EWS_ITEM_TYPE_MEMO && kind == ICAL_VJOURNAL_COMPONENT) ||
-                   (type == E_EWS_ITEM_TYPE_TASK && kind == ICAL_VTODO_COMPONENT) )) {
+                   (type == E_EWS_ITEM_TYPE_EVENT && kind == I_CAL_VEVENT_COMPONENT) ||
+                   (type == E_EWS_ITEM_TYPE_MEMO && kind == I_CAL_VJOURNAL_COMPONENT) ||
+                   (type == E_EWS_ITEM_TYPE_TASK && kind == I_CAL_VTODO_COMPONENT) )) {
                        ECalComponent *existing = NULL;
 
                        if (e_cal_cache_get_component (cal_cache, id->id, NULL, &existing, cancellable, NULL) 
&&
-                           existing && g_strcmp0 (e_cal_util_get_x_property 
(e_cal_component_get_icalcomponent (existing),
-                           "X-EVOLUTION-CHANGEKEY"), id->change_key) == 0) {
+                           existing && ecb_ews_changekey_equal (e_cal_component_get_icalcomponent 
(existing), id->change_key)) {
                                g_object_unref (item);
                        } else {
                                items = g_slist_prepend (items, item);
@@ -1319,7 +1369,7 @@ ecb_ews_verify_changes (ECalCache *cal_cache,
 static GSList * /* ECalMetaBackendInfo */
 ecb_ews_components_to_infos (ECalMetaBackend *meta_backend,
                             const GSList *components, /* ECalComponent * */
-                            icalcomponent_kind kind)
+                            ICalComponentKind kind)
 {
        GSList *nfos = NULL, *link;
        GHashTable *sorted_by_uids; /* gchar * ~> GSList { ECalComponent * } */
@@ -1330,7 +1380,7 @@ ecb_ews_components_to_infos (ECalMetaBackend *meta_backend,
 
        for (link = (GSList *) components; link; link = g_slist_next (link)) {
                ECalComponent *comp = link->data;
-               icalcomponent *icomp;
+               ICalComponent *icomp;
                const gchar *uid;
                GSList *instances;
 
@@ -1338,7 +1388,7 @@ ecb_ews_components_to_infos (ECalMetaBackend *meta_backend,
                        continue;
 
                icomp = e_cal_component_get_icalcomponent (comp);
-               uid = icalcomponent_get_uid (icomp);
+               uid = i_cal_component_get_uid (icomp);
 
                if (!uid)
                        continue;
@@ -1353,10 +1403,10 @@ ecb_ews_components_to_infos (ECalMetaBackend *meta_backend,
        while (g_hash_table_iter_next (&iter, &key, &value)) {
                const gchar *uid = key;
                GSList *instances = value, *link;
-               icalcomponent *icomp, *merged;
+               ICalComponent *icomp, *merged;
                ECalComponent *comp;
                ECalMetaBackendInfo *nfo;
-               const gchar *revision, *itemid;
+               gchar *revision, *itemid;
 
                if (!uid || !instances) {
                        g_slist_free (instances);
@@ -1385,23 +1435,26 @@ ecb_ews_components_to_infos (ECalMetaBackend *meta_backend,
                }
 
                icomp = e_cal_component_get_icalcomponent (comp);
-               itemid = e_cal_util_get_x_property (icomp, "X-EVOLUTION-ITEMID");
-               revision = e_cal_util_get_x_property (icomp, "X-EVOLUTION-CHANGEKEY");
+               itemid = e_cal_util_component_dup_x_property (icomp, "X-EVOLUTION-ITEMID");
+               revision = e_cal_util_component_dup_x_property (icomp, "X-EVOLUTION-CHANGEKEY");
                merged = e_cal_meta_backend_merge_instances (meta_backend, instances, FALSE);
 
                if (!merged) {
-                       g_warn_if_fail (merged != NULL);
                        g_slist_free (instances);
+                       g_free (revision);
+                       g_free (itemid);
                        continue;
                }
 
                nfo = e_cal_meta_backend_info_new (uid, revision, NULL, itemid);
-               nfo->object = icalcomponent_as_ical_string_r (merged);
+               nfo->object = i_cal_component_as_ical_string_r (merged);
 
                nfos = g_slist_prepend (nfos, nfo);
 
-               icalcomponent_free (merged);
                g_slist_free (instances);
+               g_object_unref (merged);
+               g_free (revision);
+               g_free (itemid);
        }
 
        g_hash_table_destroy (sorted_by_uids);
@@ -1414,24 +1467,24 @@ ecb_ews_extract_item_id (ECalComponent *comp,
                         gchar **out_id,
                         gchar **out_change_key)
 {
-       icalcomponent *icalcomp;
+       ICalComponent *icomp;
 
        g_return_if_fail (E_IS_CAL_COMPONENT (comp));
 
-       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);
 
        if (out_id)
-               *out_id = e_cal_util_dup_x_property (icalcomp, "X-EVOLUTION-ITEMID");
+               *out_id = e_cal_util_component_dup_x_property (icomp, "X-EVOLUTION-ITEMID");
        if (out_change_key)
-               *out_change_key = e_cal_util_dup_x_property (icalcomp, "X-EVOLUTION-CHANGEKEY");
+               *out_change_key = e_cal_util_component_dup_x_property (icomp, "X-EVOLUTION-CHANGEKEY");
 }
 
 static gboolean
 ecb_ews_is_organizer (ECalBackendEws *cbews,
                      ECalComponent *comp)
 {
-       ECalComponentOrganizer organizer;
+       ECalComponentOrganizer *organizer;
        gboolean is_organizer = FALSE;
 
        g_return_val_if_fail (E_IS_CAL_BACKEND_EWS (cbews), FALSE);
@@ -1440,26 +1493,25 @@ ecb_ews_is_organizer (ECalBackendEws *cbews,
        if (!e_cal_component_has_organizer (comp))
                return FALSE;
 
-       organizer.value = NULL;
-
-       e_cal_component_get_organizer (comp, &organizer);
-       if (organizer.value) {
+       organizer = e_cal_component_get_organizer (comp);
+       if (organizer && e_cal_component_organizer_get_value (organizer)) {
                CamelEwsSettings *ews_settings;
-               const gchar *email = organizer.value;
+               const gchar *email = e_cal_component_organizer_get_value (organizer);
                gchar *user_email;
 
                ews_settings = ecb_ews_get_collection_settings (cbews);
 
                user_email = camel_ews_settings_dup_email (ews_settings);
 
-               if (!g_ascii_strncasecmp (email, "mailto:";, 7))
-                       email += 7;
+               email = itip_strip_mailto (email);
 
                is_organizer = user_email && g_ascii_strcasecmp (email, user_email) == 0;
 
                g_free (user_email);
        }
 
+       e_cal_component_organizer_free (organizer);
+
        return is_organizer;
 }
 
@@ -1616,7 +1668,7 @@ ecb_ews_get_changes_sync (ECalMetaBackend *meta_backend,
                        &free_busy, cancellable, &local_error);
 
                if (success) {
-                       icaltimezone *utc_zone = icaltimezone_get_utc_timezone ();
+                       ICalTimezone *utc_zone = i_cal_timezone_get_utc_timezone ();
                        GSList *comps = NULL;
                        GHashTable *known;
                        GHashTableIter iter;
@@ -1627,7 +1679,7 @@ ecb_ews_get_changes_sync (ECalMetaBackend *meta_backend,
                        if (e_cal_cache_search_components (cal_cache, NULL, &comps, cancellable, NULL)) {
                                for (link = comps; link; link = g_slist_next (link)) {
                                        ECalComponent *comp = link->data;
-                                       icalcomponent *icomp;
+                                       ICalComponent *icomp;
                                        const gchar *uid;
 
                                        if (!comp)
@@ -1637,7 +1689,7 @@ ecb_ews_get_changes_sync (ECalMetaBackend *meta_backend,
                                        if (!icomp)
                                                continue;
 
-                                       uid = icalcomponent_get_uid (icomp);
+                                       uid = i_cal_component_get_uid (icomp);
 
                                        if (uid && *uid)
                                                g_hash_table_insert (known, g_strdup (uid), g_object_ref 
(comp));
@@ -1647,101 +1699,114 @@ ecb_ews_get_changes_sync (ECalMetaBackend *meta_backend,
                        }
 
                        for (link = free_busy; link; link = g_slist_next (link)) {
-                               icalcomponent *fbcomp = link->data;
-                               icalproperty *fbprop;
-                               icalparameter *param;
-                               struct icalperiodtype fb;
-                               icalparameter_fbtype fbtype;
+                               ICalComponent *fbcomp = link->data;
+                               ICalProperty *fbprop;
+                               ICalParameter *param;
+                               ICalPeriod *fb;
+                               ICalParameterFbtype fbtype;
 
-                               if (!fbcomp || icalcomponent_isa (fbcomp) != ICAL_VFREEBUSY_COMPONENT)
+                               if (!fbcomp || i_cal_component_isa (fbcomp) != I_CAL_VFREEBUSY_COMPONENT)
                                        continue;
 
-                               for (fbprop = icalcomponent_get_first_property (fbcomp, 
ICAL_FREEBUSY_PROPERTY);
+                               for (fbprop = i_cal_component_get_first_property (fbcomp, 
I_CAL_FREEBUSY_PROPERTY);
                                     fbprop;
-                                    fbprop = icalcomponent_get_next_property (fbcomp, 
ICAL_FREEBUSY_PROPERTY)) {
+                                    g_object_unref (fbprop), fbprop = i_cal_component_get_next_property 
(fbcomp, I_CAL_FREEBUSY_PROPERTY)) {
                                        ECalComponent *ecomp;
-                                       icalcomponent *vevent;
-                                       const gchar *id, *summary, *location;
+                                       ICalComponent *vevent;
+                                       ICalTime *itt;
+                                       gchar *id, *summary, *location;
 
-                                       param = icalproperty_get_first_parameter (fbprop, 
ICAL_FBTYPE_PARAMETER);
+                                       param = i_cal_property_get_first_parameter (fbprop, 
I_CAL_FBTYPE_PARAMETER);
                                        if (!param)
                                                continue;
 
-                                       fbtype = icalparameter_get_fbtype (param);
+                                       fbtype = i_cal_parameter_get_fbtype (param);
+                                       g_clear_object (&param);
 
-                                       if (fbtype != ICAL_FBTYPE_FREE &&
-                                           fbtype != ICAL_FBTYPE_BUSY &&
-                                           fbtype != ICAL_FBTYPE_BUSYUNAVAILABLE &&
-                                           fbtype != ICAL_FBTYPE_BUSYTENTATIVE)
+                                       if (fbtype != I_CAL_FBTYPE_FREE &&
+                                           fbtype != I_CAL_FBTYPE_BUSY &&
+                                           fbtype != I_CAL_FBTYPE_BUSYUNAVAILABLE &&
+                                           fbtype != I_CAL_FBTYPE_BUSYTENTATIVE)
                                                continue;
 
-                                       fb = icalproperty_get_freebusy (fbprop);
-                                       id = icalproperty_get_parameter_as_string (fbprop, "X-EWS-ID");
-                                       summary = icalproperty_get_parameter_as_string (fbprop, "X-SUMMARY");
-                                       location = icalproperty_get_parameter_as_string (fbprop, 
"X-LOCATION");
+                                       fb = i_cal_property_get_freebusy (fbprop);
+                                       id = i_cal_property_get_parameter_as_string_r (fbprop, "X-EWS-ID");
+                                       summary = i_cal_property_get_parameter_as_string_r (fbprop, 
"X-SUMMARY");
+                                       location = i_cal_property_get_parameter_as_string_r (fbprop, 
"X-LOCATION");
 
-                                       vevent = icalcomponent_new_vevent ();
+                                       vevent = i_cal_component_new_vevent ();
 
                                        if (id && *id) {
-                                               icalcomponent_set_uid (vevent, id);
+                                               i_cal_component_set_uid (vevent, id);
                                        } else {
-                                               gchar *uid;
-
-                                               uid = g_strdup_printf ("%s-%s-%d",
-                                                       icaltime_as_ical_string (fb.start),
-                                                       icaltime_as_ical_string (fb.end),
-                                                       (gint) fbtype);
+                                               gchar *uid, *start, *end;
 
-                                               icalcomponent_set_uid (vevent, uid);
+                                               itt = i_cal_period_get_start (fb);
+                                               start = i_cal_time_as_ical_string_r (itt);
+                                               g_clear_object (&itt);
 
-                                               g_free (uid);
-                                       }
+                                               itt = i_cal_period_get_end (fb);
+                                               end = i_cal_time_as_ical_string_r (itt);
+                                               g_clear_object (&itt);
 
-                                       fb.start.zone = utc_zone;
-                                       fb.end.zone = utc_zone;
+                                               uid = g_strdup_printf ("%s-%s-%d", start, end, (gint) fbtype);
 
-                                       icalcomponent_set_dtstart (vevent, fb.start);
-                                       icalcomponent_set_dtend (vevent, fb.end);
+                                               i_cal_component_set_uid (vevent, uid);
 
-                                       icalcomponent_add_property (vevent, icalproperty_new_created 
(icaltime_current_time_with_zone (utc_zone)));
+                                               g_free (start);
+                                               g_free (end);
+                                               g_free (uid);
+                                       }
 
-                                       if (fbtype == ICAL_FBTYPE_FREE) {
-                                               icalcomponent_set_summary (vevent, C_("FreeBusyType", 
"Free"));
-                                               icalcomponent_add_property (vevent, icalproperty_new_transp 
(ICAL_TRANSP_TRANSPARENT));
-                                       } else if (fbtype == ICAL_FBTYPE_BUSY) {
-                                               icalcomponent_set_summary (vevent, C_("FreeBusyType", 
"Busy"));
-                                       } else if (fbtype == ICAL_FBTYPE_BUSYUNAVAILABLE) {
-                                               icalcomponent_set_summary (vevent, C_("FreeBusyType", "Out of 
Office"));
-                                       } else if (fbtype == ICAL_FBTYPE_BUSYTENTATIVE) {
-                                               icalcomponent_set_summary (vevent, C_("FreeBusyType", 
"Tentative"));
+                                       itt = i_cal_period_get_start (fb);
+                                       i_cal_time_set_timezone (itt, utc_zone);
+                                       i_cal_component_set_dtstart (vevent, itt);
+                                       g_clear_object (&itt);
+
+                                       itt = i_cal_period_get_end (fb);
+                                       i_cal_time_set_timezone (itt, utc_zone);
+                                       i_cal_component_set_dtend (vevent, itt);
+                                       g_clear_object (&itt);
+
+                                       itt = i_cal_time_current_time_with_zone (utc_zone);
+                                       i_cal_component_take_property (vevent, i_cal_property_new_created 
(itt));
+                                       g_clear_object (&itt);
+
+                                       if (fbtype == I_CAL_FBTYPE_FREE) {
+                                               i_cal_component_set_summary (vevent, C_("FreeBusyType", 
"Free"));
+                                               i_cal_component_take_property (vevent, 
i_cal_property_new_transp (I_CAL_TRANSP_TRANSPARENT));
+                                       } else if (fbtype == I_CAL_FBTYPE_BUSY) {
+                                               i_cal_component_set_summary (vevent, C_("FreeBusyType", 
"Busy"));
+                                       } else if (fbtype == I_CAL_FBTYPE_BUSYUNAVAILABLE) {
+                                               i_cal_component_set_summary (vevent, C_("FreeBusyType", "Out 
of Office"));
+                                       } else if (fbtype == I_CAL_FBTYPE_BUSYTENTATIVE) {
+                                               i_cal_component_set_summary (vevent, C_("FreeBusyType", 
"Tentative"));
                                        }
 
                                        if (summary && *summary)
-                                               icalcomponent_set_summary (vevent, summary);
+                                               i_cal_component_set_summary (vevent, summary);
 
                                        if (location && *location)
-                                               icalcomponent_set_location (vevent, location);
+                                               i_cal_component_set_location (vevent, location);
 
-                                       ecomp = g_hash_table_lookup (known, icalcomponent_get_uid (vevent));
+                                       ecomp = g_hash_table_lookup (known, i_cal_component_get_uid (vevent));
                                        if (ecomp) {
                                                g_object_ref (ecomp);
 
                                                /* This dereferences the ecomp, thus the ref() call above to 
keep it alive */
-                                               g_hash_table_remove (known, icalcomponent_get_uid (vevent));
+                                               g_hash_table_remove (known, i_cal_component_get_uid (vevent));
 
                                                if (ecb_ews_freebusy_ecomp_changed (ecomp, vevent)) {
                                                        ECalMetaBackendInfo *nfo;
                                                        gchar *revision = e_util_generate_uid ();
 
-                                                       e_cal_util_set_x_property (vevent, 
"X-EVOLUTION-CHANGEKEY", revision);
+                                                       e_cal_util_component_set_x_property (vevent, 
"X-EVOLUTION-CHANGEKEY", revision);
 
-                                                       nfo = e_cal_meta_backend_info_new 
(icalcomponent_get_uid (vevent), NULL, NULL, NULL);
+                                                       nfo = e_cal_meta_backend_info_new 
(i_cal_component_get_uid (vevent), NULL, NULL, NULL);
                                                        nfo->revision = revision;
-                                                       nfo->object = icalcomponent_as_ical_string_r (vevent);
+                                                       nfo->object = i_cal_component_as_ical_string_r 
(vevent);
 
                                                        *out_created_objects = g_slist_prepend 
(*out_created_objects, nfo);
-                                               } else {
-                                                       icalcomponent_free (vevent);
                                                }
 
                                                g_clear_object (&ecomp);
@@ -1749,14 +1814,19 @@ ecb_ews_get_changes_sync (ECalMetaBackend *meta_backend,
                                                ECalMetaBackendInfo *nfo;
                                                gchar *revision = e_util_generate_uid ();
 
-                                               e_cal_util_set_x_property (vevent, "X-EVOLUTION-CHANGEKEY", 
revision);
+                                               e_cal_util_component_set_x_property (vevent, 
"X-EVOLUTION-CHANGEKEY", revision);
 
-                                               nfo = e_cal_meta_backend_info_new (icalcomponent_get_uid 
(vevent), NULL, NULL, NULL);
+                                               nfo = e_cal_meta_backend_info_new (i_cal_component_get_uid 
(vevent), NULL, NULL, NULL);
                                                nfo->revision = revision;
-                                               nfo->object = icalcomponent_as_ical_string_r (vevent);
+                                               nfo->object = i_cal_component_as_ical_string_r (vevent);
 
                                                *out_modified_objects = g_slist_prepend 
(*out_modified_objects, nfo);
                                        }
+
+                                       g_free (id);
+                                       g_free (summary);
+                                       g_free (location);
+                                       g_object_unref (vevent);
                                }
                        }
 
@@ -1778,7 +1848,7 @@ ecb_ews_get_changes_sync (ECalMetaBackend *meta_backend,
                        g_propagate_error (error, local_error);
                }
 
-               g_slist_free_full (free_busy, (GDestroyNotify) icalcomponent_free);
+               g_slist_free_full (free_busy, g_object_unref);
                g_slist_free_full (fbdata.user_mails, g_free);
        } else {
                GSList *items_created = NULL, *items_modified = NULL, *items_deleted = NULL, *link;
@@ -1809,7 +1879,7 @@ ecb_ews_get_changes_sync (ECalMetaBackend *meta_backend,
 
                if (success) {
                        GSList *components_created = NULL, *components_modified = NULL;
-                       icalcomponent_kind kind;
+                       ICalComponentKind kind;
 
                        kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbews));
 
@@ -1841,14 +1911,14 @@ ecb_ews_get_changes_sync (ECalMetaBackend *meta_backend,
                                        ECalComponentId *id = ilink->data;
 
                                        /* Use the master object */
-                                       if (id && id->uid && *id->uid && (!id->rid || !*id->rid)) {
+                                       if (id && e_cal_component_id_get_uid (id) && 
e_cal_component_id_get_uid (id)[0] && !e_cal_component_id_get_rid (id)) {
                                                *out_removed_objects = g_slist_prepend (*out_removed_objects,
-                                                       e_cal_meta_backend_info_new (id->uid, NULL, NULL, 
NULL));
+                                                       e_cal_meta_backend_info_new 
(e_cal_component_id_get_uid (id), NULL, NULL, NULL));
                                                break;
                                        }
                                }
 
-                               g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+                               g_slist_free_full (ids, e_cal_component_id_free);
                        }
 
                        g_slist_free_full (components_created, g_object_unref);
@@ -1877,7 +1947,7 @@ static gboolean
 ecb_ews_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)
@@ -1914,7 +1984,7 @@ ecb_ews_load_component_sync (ECalMetaBackend *meta_backend,
                        if (components->next) {
                                GSList *link;
 
-                               *out_component = icalcomponent_new_vcalendar ();
+                               *out_component = i_cal_component_new_vcalendar ();
 
                                for (link = components; link; link = g_slist_next (link)) {
                                        ECalComponent *comp = link->data;
@@ -1922,11 +1992,11 @@ ecb_ews_load_component_sync (ECalMetaBackend *meta_backend,
                                        if (!comp)
                                                continue;
 
-                                       icalcomponent_add_component (*out_component,
-                                               icalcomponent_new_clone (e_cal_component_get_icalcomponent 
(comp)));
+                                       i_cal_component_take_component (*out_component,
+                                               i_cal_component_new_clone (e_cal_component_get_icalcomponent 
(comp)));
                                }
                        } else {
-                               *out_component = icalcomponent_new_clone (e_cal_component_get_icalcomponent 
(components->data));
+                               *out_component = i_cal_component_new_clone (e_cal_component_get_icalcomponent 
(components->data));
                        }
                } else {
                        success = FALSE;
@@ -1967,8 +2037,8 @@ static gboolean
 ecb_ews_components_equal (ECalComponent *comp1,
                          ECalComponent *comp2)
 {
-       icalcomponent *icomp1, *icomp2;
-       icalproperty *prop1;
+       ICalComponent *icomp1, *icomp2;
+       ICalProperty *prop1;
        GHashTable *processed_props;
        gboolean equal = TRUE;
 
@@ -1983,35 +2053,35 @@ ecb_ews_components_equal (ECalComponent *comp1,
        if (!icomp1 || !icomp2)
                return FALSE;
 
-       if (g_strcmp0 (icalcomponent_get_uid (icomp1), icalcomponent_get_uid (icomp2)) != 0)
+       if (g_strcmp0 (i_cal_component_get_uid (icomp1), i_cal_component_get_uid (icomp2)) != 0)
                return FALSE;
 
-       if (icalcomponent_count_properties (icomp1, ICAL_ANY_PROPERTY) !=
-           icalcomponent_count_properties (icomp2, ICAL_ANY_PROPERTY))
+       if (i_cal_component_count_properties (icomp1, I_CAL_ANY_PROPERTY) !=
+           i_cal_component_count_properties (icomp2, I_CAL_ANY_PROPERTY))
                return FALSE;
 
        processed_props = g_hash_table_new (g_direct_hash, g_direct_equal);
 
-       for (prop1 = icalcomponent_get_first_property (icomp1, ICAL_ANY_PROPERTY);
+       for (prop1 = i_cal_component_get_first_property (icomp1, I_CAL_ANY_PROPERTY);
             prop1 && equal;
-            prop1 = icalcomponent_get_next_property (icomp1, ICAL_ANY_PROPERTY)) {
-               icalproperty_kind kind = icalproperty_isa (prop1);
-               icalproperty *prop2;
+            g_object_unref (prop1), prop1 = i_cal_component_get_next_property (icomp1, I_CAL_ANY_PROPERTY)) {
+               ICalPropertyKind kind = i_cal_property_isa (prop1);
+               ICalProperty *prop2;
 
-               for (prop2 = icalcomponent_get_first_property (icomp2, kind);
+               for (prop2 = i_cal_component_get_first_property (icomp2, kind);
                     prop2;
-                    prop2 = icalcomponent_get_next_property (icomp2, kind)) {
+                    g_object_unref (prop2), prop2 = i_cal_component_get_next_property (icomp2, kind)) {
                        gchar *str1, *str2;
                        gboolean same;
 
-                       if (g_hash_table_contains (processed_props, prop2))
+                       if (g_hash_table_contains (processed_props, i_cal_object_get_native (I_CAL_OBJECT 
(prop2))))
                                continue;
 
-                       if (icalproperty_count_parameters (prop1) != icalproperty_count_parameters (prop2))
+                       if (i_cal_property_count_parameters (prop1) != i_cal_property_count_parameters 
(prop2))
                                continue;
 
-                       str1 = icalproperty_as_ical_string_r (prop1);
-                       str2 = icalproperty_as_ical_string_r (prop2);
+                       str1 = i_cal_property_as_ical_string_r (prop1);
+                       str2 = i_cal_property_as_ical_string_r (prop2);
 
                        same = g_strcmp0 (str1, str2) == 0;
 
@@ -2019,15 +2089,19 @@ ecb_ews_components_equal (ECalComponent *comp1,
                        g_free (str2);
 
                        if (same) {
-                               g_hash_table_insert (processed_props, prop2, NULL);
+                               g_hash_table_insert (processed_props, i_cal_object_get_native (I_CAL_OBJECT 
(prop2)), NULL);
                                break;
                        }
                }
 
                if (!prop2)
                        equal = FALSE;
+
+               g_clear_object (&prop2);
        }
 
+       g_clear_object (&prop1);
+
        g_hash_table_destroy (processed_props);
 
        return equal;
@@ -2069,8 +2143,8 @@ ecb_ews_filter_out_unchanged_instances (const GSList *to_save_instances,
        *out_changed_instances = NULL;
        *out_removed_instances = NULL;
 
-       existing_hash = g_hash_table_new_full ((GHashFunc)e_cal_component_id_hash, (GEqualFunc) 
e_cal_component_id_equal,
-               (GDestroyNotify) e_cal_component_free_id, NULL);
+       existing_hash = g_hash_table_new_full ((GHashFunc) e_cal_component_id_hash, (GEqualFunc) 
e_cal_component_id_equal,
+               e_cal_component_id_free, NULL);
 
        for (link = (GSList *) existing_instances; link; link = g_slist_next (link)) {
                ECalComponent *comp = link->data;
@@ -2083,7 +2157,7 @@ ecb_ews_filter_out_unchanged_instances (const GSList *to_save_instances,
 
        for (link = (GSList *) to_save_instances; link; link = g_slist_next (link)) {
                ECalComponent *comp = link->data;
-               ECalComponentId *id = NULL;
+               ECalComponentId *id;
 
                id = e_cal_component_get_id (comp);
                if (id) {
@@ -2102,7 +2176,7 @@ ecb_ews_filter_out_unchanged_instances (const GSList *to_save_instances,
                        }
 
                        g_hash_table_remove (existing_hash, id);
-                       e_cal_component_free_id (id);
+                       e_cal_component_id_free (id);
                }
        }
 
@@ -2115,41 +2189,44 @@ ecb_ews_filter_out_unchanged_instances (const GSList *to_save_instances,
 }
 
 static gboolean
-ecb_ews_extract_attachments (icalcomponent *icalcomp,
+ecb_ews_extract_attachments (ICalComponent *icomp,
                             GSList **out_attachments) /* EEwsAttachmentInfo * */
 {
-       icalproperty *prop;
+       ICalProperty *prop;
        GSList *props = NULL, *link;
 
-       g_return_val_if_fail (icalcomp != NULL, FALSE);
+       g_return_val_if_fail (icomp != NULL, FALSE);
        g_return_val_if_fail (out_attachments != NULL, FALSE);
 
        *out_attachments = NULL;
 
-       for (prop = icalcomponent_get_first_property (icalcomp, ICAL_ATTACH_PROPERTY);
+       for (prop = i_cal_component_get_first_property (icomp, I_CAL_ATTACH_PROPERTY);
             prop;
-            prop = icalcomponent_get_next_property (icalcomp, ICAL_ATTACH_PROPERTY)) {
+            prop = i_cal_component_get_next_property (icomp, I_CAL_ATTACH_PROPERTY)) {
                props = g_slist_prepend (props, prop);
        }
 
        for (link = props; link; link = g_slist_next (link)) {
                EEwsAttachmentInfo *info;
-               icalattach *attach;
-               icalparameter *param;
+               ICalAttach *attach;
+               ICalParameter *param;
                const gchar *stored_filename;
+               gchar *attachid;
 
                prop = link->data;
-               param = icalproperty_get_first_parameter (prop, ICAL_FILENAME_PARAMETER);
-               stored_filename = param ? icalparameter_get_filename (param) : NULL;
+               param = i_cal_property_get_first_parameter (prop, I_CAL_FILENAME_PARAMETER);
+               stored_filename = param ? i_cal_parameter_get_filename (param) : NULL;
 
-               attach = icalproperty_get_attach (prop);
-               if (icalattach_get_is_url (attach)) {
+               attach = i_cal_property_get_attach (prop);
+               if (i_cal_attach_get_is_url (attach)) {
                        const gchar *uri;
 
-                       uri = icalattach_get_url (attach);
+                       uri = i_cal_attach_get_url (attach);
 
-                       if (!uri || !*uri)
+                       if (!uri || !*uri) {
+                               g_clear_object (&param);
                                continue;
+                       }
 
                        info = e_ews_attachment_info_new (E_EWS_ATTACHMENT_INFO_TYPE_URI);
 
@@ -2167,7 +2244,7 @@ ecb_ews_extract_attachments (icalcomponent *icalcomp,
                                        if (basename && *basename && basename[0] != '.' && basename[0] != 
G_DIR_SEPARATOR) {
                                                const gchar *uid;
 
-                                               uid = icalcomponent_get_uid (icalcomp);
+                                               uid = i_cal_component_get_uid (icomp);
 
                                                if (uid && g_str_has_prefix (basename, uid) && 
basename[strlen (uid)] == '-') {
                                                        e_ews_attachment_info_set_prefer_filename (info, 
basename + strlen (uid) + 1);
@@ -2184,7 +2261,7 @@ ecb_ews_extract_attachments (icalcomponent *icalcomp,
                        guchar *decoded = NULL;
                        const gchar *content;
 
-                       content = (const gchar *) icalattach_get_data (attach);
+                       content = (const gchar *) i_cal_attach_get_data (attach);
                        decoded = g_base64_decode (content, &len);
 
                        info = e_ews_attachment_info_new (E_EWS_ATTACHMENT_INFO_TYPE_INLINED);
@@ -2196,39 +2273,48 @@ ecb_ews_extract_attachments (icalcomponent *icalcomp,
                        g_free (decoded);
                }
 
-               e_ews_attachment_info_set_id (info, icalproperty_get_parameter_as_string (prop, 
"X-EWS-ATTACHMENTID"));
+               attachid = i_cal_property_get_parameter_as_string_r (prop, "X-EWS-ATTACHMENTID");
+               e_ews_attachment_info_set_id (info, attachid);
+               g_free (attachid);
+
                *out_attachments = g_slist_prepend (*out_attachments, info);
+
+               g_clear_object (&param);
        }
 
-       g_slist_free (props);
+       g_slist_free_full (props, g_object_unref);
 
        return *out_attachments != NULL;
 }
 
-static icaltimezone *
-ecb_ews_get_timezone_from_ical_component (ECalBackendEws *cbews,
-                                         icalcomponent *icalcomp)
+static ICalTimezone *
+ecb_ews_get_timezone_from_icomponent (ECalBackendEws *cbews,
+                                     ICalComponent *icomp)
 {
        ETimezoneCache *timezone_cache;
-       icalproperty *prop = NULL;
+       ICalProperty *prop = NULL;
        const gchar *tzid = NULL;
 
        timezone_cache = E_TIMEZONE_CACHE (cbews);
 
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_DTSTART_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_DTSTART_PROPERTY);
        if (prop != NULL) {
-               icalparameter *param = NULL;
+               ICalParameter *param = NULL;
 
-               param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER);
+               param = i_cal_property_get_first_parameter (prop, I_CAL_TZID_PARAMETER);
                if (param) {
-                       tzid = icalparameter_get_tzid (param);
+                       tzid = i_cal_parameter_get_tzid (param);
+                       g_object_unref (param);
                } else {
-                       struct icaltimetype dtstart;
+                       ICalTime *dtstart;
 
-                       dtstart = icalproperty_get_dtstart (prop);
-                       if (icaltime_is_utc (dtstart))
+                       dtstart = i_cal_property_get_dtstart (prop);
+                       if (i_cal_time_is_utc (dtstart))
                                tzid = "UTC";
+                       g_clear_object (&dtstart);
                }
+
+               g_object_unref (prop);
        }
 
        if (tzid)
@@ -2261,7 +2347,7 @@ ecb_ews_remove_item_sync (ECalBackendEws *cbews,
        if (!e_cal_cache_get_component (cal_cache, uid, rid, &comp, cancellable, error) ||
            (rid && !e_cal_cache_get_component (cal_cache, uid, NULL, &parent, cancellable, error))) {
                if (!parent && !comp) {
-                       g_propagate_error (error, EDC_ERROR (ObjectNotFound));
+                       g_propagate_error (error, ECC_ERROR (E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND));
                        return FALSE;
                }
        }
@@ -2269,12 +2355,12 @@ ecb_ews_remove_item_sync (ECalBackendEws *cbews,
        ecb_ews_extract_item_id (comp ? comp : parent, &item_id.id, &item_id.change_key);
 
        if (!item_id.id) {
-               g_propagate_error (error, EDC_ERROR_EX (OtherError, "Cannot determine EWS ItemId"));
+               g_propagate_error (error, EC_ERROR_EX (E_CLIENT_ERROR_OTHER_ERROR, _("Cannot determine EWS 
ItemId")));
                success = FALSE;
        } else {
                if (parent) {
                        index = e_cal_backend_ews_rid_to_index (
-                               ecb_ews_get_timezone_from_ical_component (cbews,
+                               ecb_ews_get_timezone_from_icomponent (cbews,
                                        e_cal_component_get_icalcomponent (parent)),
                                rid,
                                e_cal_component_get_icalcomponent (parent),
@@ -2373,20 +2459,20 @@ ecb_ews_get_attach_differences (ECalComponent *oldcomp,
 }
 
 struct TzidCbData {
-       icalcomponent *comp;
+       ICalComponent *comp;
        ECalBackendEws *cbews;
 };
 
 static void
-tzid_cb (icalparameter *param,
+tzid_cb (ICalParameter *param,
         gpointer data)
 {
        struct TzidCbData *cbd = data;
        const gchar *tzid;
-       icaltimezone *zone;
-       icalcomponent *new_comp;
+       ICalTimezone *zone;
+       ICalComponent *new_comp;
 
-       tzid = icalparameter_get_tzid (param);
+       tzid = i_cal_parameter_get_tzid (param);
        if (!tzid)
                return;
 
@@ -2394,16 +2480,18 @@ tzid_cb (icalparameter *param,
        if (!zone)
                return;
 
-       new_comp = icaltimezone_get_component (zone);
+       new_comp = i_cal_timezone_get_component (zone);
        if (!new_comp)
                return;
 
-       icalcomponent_add_component (cbd->comp, icalcomponent_new_clone (new_comp));
+       i_cal_component_take_component (cbd->comp, i_cal_component_new_clone (new_comp));
+
+       g_object_unref (new_comp);
 }
 
 static void
 ecb_ews_pick_all_tzids_out (ECalBackendEws *cbews,
-                           icalcomponent *icalcomp)
+                           ICalComponent *icomp)
 {
 
        /* pick all the tzids out of the component and resolve
@@ -2411,49 +2499,49 @@ ecb_ews_pick_all_tzids_out (ECalBackendEws *cbews,
        struct TzidCbData cbd;
 
        cbd.cbews = cbews;
-       cbd.comp = icalcomp;
+       cbd.comp = icomp;
 
-       icalcomponent_foreach_tzid (icalcomp, tzid_cb, &cbd);
+       i_cal_component_foreach_tzid (icomp, tzid_cb, &cbd);
 }
 
 static gboolean
 ecb_ews_modify_item_sync (ECalBackendEws *cbews,
                          GHashTable *removed_indexes,
-                         icalcomponent *old_icalcomp,
-                         icalcomponent *new_icalcomp,
+                         ICalComponent *old_icomp,
+                         ICalComponent *new_icomp,
                          GCancellable *cancellable,
                          GError **error)
 {
        ECalComponent *comp = NULL, *oldcomp = NULL;
-       icalcomponent *icalcomp;
+       ICalComponent *icomp;
        gchar *itemid = NULL, *changekey = NULL;
        GSList *added_attachments = NULL, *removed_attachment_ids = NULL;
        gboolean success = TRUE;
 
        g_return_val_if_fail (E_IS_CAL_BACKEND_EWS (cbews), FALSE);
-       g_return_val_if_fail (new_icalcomp != NULL, FALSE);
+       g_return_val_if_fail (I_CAL_IS_COMPONENT (new_icomp), FALSE);
 
-       icalcomp = icalcomponent_new_clone (new_icalcomp);
+       icomp = i_cal_component_new_clone (new_icomp);
 
-       ecb_ews_pick_all_tzids_out (cbews, icalcomp);
+       ecb_ews_pick_all_tzids_out (cbews, icomp);
 
-       comp = e_cal_component_new_from_icalcomponent (icalcomp);
+       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;
        }
 
        ecb_ews_extract_item_id (comp, &itemid, &changekey);
        if (!itemid) {
-               g_propagate_error (error, EDC_ERROR_EX (OtherError, "Cannot determine EWS ItemId"));
+               g_propagate_error (error, EC_ERROR_EX (E_CLIENT_ERROR_OTHER_ERROR, _("Cannot determine EWS 
ItemId")));
                g_object_unref (comp);
                return FALSE;
        }
 
-       if (old_icalcomp) {
-               oldcomp = e_cal_component_new_from_icalcomponent (icalcomponent_new_clone (old_icalcomp));
+       if (old_icomp) {
+               oldcomp = e_cal_component_new_from_icalcomponent (i_cal_component_new_clone (old_icomp));
        } else {
-               oldcomp = e_cal_component_new_from_icalcomponent (icalcomponent_new_clone (new_icalcomp));
+               oldcomp = e_cal_component_new_from_icalcomponent (i_cal_component_new_clone (new_icomp));
        }
 
        ecb_ews_pick_all_tzids_out (cbews, e_cal_component_get_icalcomponent (oldcomp));
@@ -2491,10 +2579,10 @@ ecb_ews_modify_item_sync (ECalBackendEws *cbews,
                g_free (item_id.change_key);
        }
 
-       if (success && old_icalcomp &&
-           icalcomponent_get_first_property (new_icalcomp, ICAL_RRULE_PROPERTY) &&
-           !icalcomponent_get_first_property (new_icalcomp, ICAL_RECURRENCEID_PROPERTY)) {
-               icalproperty *prop, *old_prop;
+       if (success && old_icomp &&
+           e_cal_util_component_has_property (new_icomp, I_CAL_RRULE_PROPERTY) &&
+           !e_cal_util_component_has_property (new_icomp, I_CAL_RECURRENCEID_PROPERTY)) {
+               ICalProperty *prop, *old_prop;
                GSList *exceptions = NULL, *link;
                EwsId item_id;
 
@@ -2502,36 +2590,47 @@ ecb_ews_modify_item_sync (ECalBackendEws *cbews,
                item_id.change_key = changekey;
 
                /* Excluded occurrences */
-               for (prop = icalcomponent_get_first_property (new_icalcomp, ICAL_EXDATE_PROPERTY);
+               for (prop = i_cal_component_get_first_property (new_icomp, I_CAL_EXDATE_PROPERTY);
                     prop;
-                    prop = icalcomponent_get_next_property (new_icalcomp, ICAL_EXDATE_PROPERTY)) {
-                       const gchar *new_rid;
+                    g_object_unref (prop), prop = i_cal_component_get_next_property (new_icomp, 
I_CAL_EXDATE_PROPERTY)) {
+                       gchar *new_rid;
 
-                       new_rid = icalproperty_get_value_as_string (prop);
+                       new_rid = i_cal_property_get_value_as_string_r (prop);
 
-                       for (old_prop = icalcomponent_get_first_property (old_icalcomp, ICAL_EXDATE_PROPERTY);
+                       for (old_prop = i_cal_component_get_first_property (old_icomp, I_CAL_EXDATE_PROPERTY);
                             old_prop;
-                            old_prop = icalcomponent_get_next_property (old_icalcomp, ICAL_EXDATE_PROPERTY)) 
{
-                               if (g_strcmp0 (new_rid, icalproperty_get_value_as_string (old_prop)) == 0)
+                            g_object_unref (old_prop), old_prop = i_cal_component_get_next_property 
(old_icomp, I_CAL_EXDATE_PROPERTY)) {
+                               gchar *old_rid = i_cal_property_get_value_as_string_r (old_prop);
+                               if (g_strcmp0 (new_rid, old_rid) == 0) {
+                                       g_object_unref (old_prop);
+                                       g_free (old_rid);
                                        break;
+                               }
+
+                               g_free (old_rid);
                        }
 
                        if (!old_prop)
-                               exceptions = g_slist_prepend (exceptions, prop);
+                               exceptions = g_slist_prepend (exceptions, g_object_ref (prop));
+
+                       g_free (new_rid);
                }
 
                exceptions = g_slist_reverse (exceptions);
 
                for (link = exceptions; link && success; link = g_slist_next (link)) {
+                       gchar *rid;
                        guint index;
 
                        prop = link->data;
 
+                       rid = i_cal_property_get_value_as_string_r (prop);
                        index = e_cal_backend_ews_rid_to_index (
-                               ecb_ews_get_timezone_from_ical_component (cbews, new_icalcomp),
-                               icalproperty_get_value_as_string (prop),
-                               new_icalcomp,
+                               ecb_ews_get_timezone_from_icomponent (cbews, new_icomp),
+                               rid,
+                               new_icomp,
                                error);
+                       g_free (rid);
 
                        if (index == 0) {
                                success = FALSE;
@@ -2544,7 +2643,7 @@ ecb_ews_modify_item_sync (ECalBackendEws *cbews,
                        }
                }
 
-               g_slist_free (exceptions);
+               g_slist_free_full (exceptions, g_object_unref);
        }
 
        if (success) {
@@ -2562,7 +2661,7 @@ ecb_ews_modify_item_sync (ECalBackendEws *cbews,
                convert_data.old_comp = oldcomp;
                convert_data.item_id = itemid;
                convert_data.change_key = changekey;
-               convert_data.default_zone = icaltimezone_get_utc_timezone ();
+               convert_data.default_zone = i_cal_timezone_get_utc_timezone ();
 
                if (e_cal_component_has_attendees (comp)) {
                        send_meeting_invitations = "SendToAllAndSaveCopy";
@@ -2581,17 +2680,19 @@ ecb_ews_modify_item_sync (ECalBackendEws *cbews,
                g_free (convert_data.user_email);
        }
 
-       if (success && icalcomponent_isa (new_icalcomp) == ICAL_VTODO_COMPONENT &&
-           icalcomponent_count_properties (new_icalcomp, ICAL_RRULE_PROPERTY) > 0) {
-               icalproperty *prop;
+       if (success && i_cal_component_isa (new_icomp) == I_CAL_VTODO_COMPONENT &&
+           e_cal_util_component_has_property (new_icomp, I_CAL_RRULE_PROPERTY)) {
+               ICalProperty *prop;
 
-               prop = icalcomponent_get_first_property (new_icalcomp, ICAL_STATUS_PROPERTY);
-               if (prop && icalproperty_get_status (prop) == ICAL_STATUS_COMPLETED) {
+               prop = i_cal_component_get_first_property (new_icomp, I_CAL_STATUS_PROPERTY);
+               if (prop && i_cal_property_get_status (prop) == I_CAL_STATUS_COMPLETED) {
                        /* Setting a recurring task completed will mark the existing task
                           as completed and also add a new task, thus force refresh here,
                           thus the user sees an up-to-date view of the server content. */
                        e_cal_meta_backend_schedule_refresh (E_CAL_META_BACKEND (cbews));
                }
+
+               g_clear_object (&prop);
        }
 
        g_slist_free_full (added_attachments, (GDestroyNotify) e_ews_attachment_info_free);
@@ -2609,6 +2710,7 @@ ecb_ews_save_component_sync (ECalMetaBackend *meta_backend,
                             EConflictResolution conflict_resolution,
                             const GSList *instances,
                             const gchar *extra,
+                            guint32 opflags,
                             gchar **out_new_uid,
                             gchar **out_new_extra,
                             GCancellable *cancellable,
@@ -2619,7 +2721,7 @@ ecb_ews_save_component_sync (ECalMetaBackend *meta_backend,
        ECalComponent *master = NULL;
        EwsFolderId *fid;
        GSList *link;
-       const gchar *uid = NULL;
+       const gchar *uid;
        gboolean success = TRUE;
 
        g_return_val_if_fail (E_IS_CAL_BACKEND_EWS (meta_backend), FALSE);
@@ -2637,7 +2739,7 @@ ecb_ews_save_component_sync (ECalMetaBackend *meta_backend,
        }
 
        if (!master) {
-               g_propagate_error (error, EDC_ERROR (InvalidObject));
+               g_propagate_error (error, ECC_ERROR (E_CAL_CLIENT_ERROR_INVALID_OBJECT));
                return FALSE;
        }
 
@@ -2646,7 +2748,7 @@ ecb_ews_save_component_sync (ECalMetaBackend *meta_backend,
 
        g_rec_mutex_lock (&cbews->priv->cnc_lock);
 
-       e_cal_component_get_uid (master, &uid);
+       uid = e_cal_component_get_uid (master);
        fid = e_ews_folder_id_new (cbews->priv->folder_id, NULL, FALSE);
 
        if (overwrite_existing) {
@@ -2702,8 +2804,9 @@ ecb_ews_save_component_sync (ECalMetaBackend *meta_backend,
                                id = e_cal_component_get_id (comp);
 
                                if (id) {
-                                       success = ecb_ews_remove_item_sync (cbews, cal_cache, 
removed_indexes, id->uid, id->rid, cancellable, error);
-                                       e_cal_component_free_id (id);
+                                       success = ecb_ews_remove_item_sync (cbews, cal_cache, removed_indexes,
+                                               e_cal_component_id_get_uid (id), e_cal_component_id_get_rid 
(id), cancellable, error);
+                                       e_cal_component_id_free (id);
                                }
                        }
 
@@ -2722,16 +2825,16 @@ ecb_ews_save_component_sync (ECalMetaBackend *meta_backend,
                EEwsItem *item = NULL;
                EwsId *ews_id = NULL;
                const gchar *send_meeting_invitations;
-               icalcomponent *icalcomp;
-               icalproperty *prop;
+               ICalComponent *icomp;
+               ICalProperty *prop;
                GSList *items = NULL;
 
-               icalcomp = icalcomponent_new_clone (e_cal_component_get_icalcomponent (master));
+               icomp = i_cal_component_new_clone (e_cal_component_get_icalcomponent (master));
 
-               e_ews_clean_icalcomponent (icalcomp);
+               e_ews_clean_icomponent (icomp);
 
                if (!e_ews_connection_satisfies_server_version (cbews->priv->cnc, E_EWS_EXCHANGE_2010))
-                       ecb_ews_pick_all_tzids_out (cbews, icalcomp);
+                       ecb_ews_pick_all_tzids_out (cbews, icomp);
 
                /*
                 * In case we are creating a meeting with attendees and attachments.
@@ -2752,8 +2855,8 @@ ecb_ews_save_component_sync (ECalMetaBackend *meta_backend,
 
                convert_data.connection = cbews->priv->cnc;
                convert_data.timezone_cache = E_TIMEZONE_CACHE (cbews);
-               convert_data.icalcomp = icalcomp;
-               convert_data.default_zone = icaltimezone_get_utc_timezone ();
+               convert_data.icomp = icomp;
+               convert_data.default_zone = i_cal_timezone_get_utc_timezone ();
 
                success = e_ews_connection_create_items_sync (cbews->priv->cnc, EWS_PRIORITY_MEDIUM, 
"SaveOnly", send_meeting_invitations,
                        fid, e_cal_backend_ews_convert_calcomp_to_xml, &convert_data,
@@ -2812,7 +2915,7 @@ ecb_ews_save_component_sync (ECalMetaBackend *meta_backend,
 
                        g_warn_if_fail (ews_id != NULL);
 
-                       if (ews_id && ecb_ews_extract_attachments (icalcomp, &info_attachments)) {
+                       if (ews_id && ecb_ews_extract_attachments (icomp, &info_attachments)) {
                                gchar *changekey = NULL;
                                GSList *ids = NULL;
 
@@ -2833,14 +2936,14 @@ ecb_ews_save_component_sync (ECalMetaBackend *meta_backend,
 
                removed_indexes = g_hash_table_new (g_direct_hash, g_direct_equal);
 
-               if (success && icalcomponent_get_first_property (icalcomp, ICAL_RRULE_PROPERTY)) {
+               if (success && e_cal_util_component_has_property (icomp, I_CAL_RRULE_PROPERTY)) {
                        GSList *exceptions = NULL;
 
                        /* Excluded occurrences */
-                       for (prop = icalcomponent_get_first_property (icalcomp, ICAL_EXDATE_PROPERTY);
+                       for (prop = i_cal_component_get_first_property (icomp, I_CAL_EXDATE_PROPERTY);
                             prop;
-                            prop = icalcomponent_get_next_property (icalcomp, ICAL_EXDATE_PROPERTY)) {
-                               exceptions = g_slist_prepend (exceptions, g_strdup 
(icalproperty_get_value_as_string (prop)));
+                            g_object_unref (prop), prop = i_cal_component_get_next_property (icomp, 
I_CAL_EXDATE_PROPERTY)) {
+                               exceptions = g_slist_prepend (exceptions, 
i_cal_property_get_value_as_string_r (prop));
                        }
 
                        for (link = exceptions; link && success; link = g_slist_next (link)) {
@@ -2852,16 +2955,16 @@ ecb_ews_save_component_sync (ECalMetaBackend *meta_backend,
 
                if (success && e_cal_component_has_attendees (master) && e_cal_component_has_attachments 
(master)) {
                        if (ews_id) {
-                               e_cal_util_set_x_property (icalcomp, "X-EVOLUTION-ITEMID", ews_id->id);
-                               e_cal_util_set_x_property (icalcomp, "X-EVOLUTION-CHANGEKEY", 
ews_id->change_key);
+                               e_cal_util_component_set_x_property (icomp, "X-EVOLUTION-ITEMID", ews_id->id);
+                               e_cal_util_component_set_x_property (icomp, "X-EVOLUTION-CHANGEKEY", 
ews_id->change_key);
                        }
 
                        /* In case we have attendees and atachemnts we have to fake update items,
                         * this is the only way to pass attachments in meeting invite mail */
-                       success = ecb_ews_modify_item_sync (cbews, removed_indexes, NULL, icalcomp, 
cancellable, error);
+                       success = ecb_ews_modify_item_sync (cbews, removed_indexes, NULL, icomp, cancellable, 
error);
                }
 
-               icalcomponent_free (icalcomp);
+               g_object_unref (icomp);
                e_ews_id_free (ews_id);
                g_clear_object (&item);
 
@@ -2871,9 +2974,9 @@ ecb_ews_save_component_sync (ECalMetaBackend *meta_backend,
                        if (comp == master)
                                continue;
 
-                       icalcomp = e_cal_component_get_icalcomponent (comp);
+                       icomp = e_cal_component_get_icalcomponent (comp);
 
-                       success = ecb_ews_modify_item_sync (cbews, removed_indexes, NULL, icalcomp, 
cancellable, error);
+                       success = ecb_ews_modify_item_sync (cbews, removed_indexes, NULL, icomp, cancellable, 
error);
                }
 
                if (success && items) {
@@ -2905,6 +3008,7 @@ ecb_ews_remove_component_sync (ECalMetaBackend *meta_backend,
                               const gchar *uid,
                               const gchar *extra,
                               const gchar *object,
+                              guint32 opflags,
                               GCancellable *cancellable,
                               GError **error)
 {
@@ -2920,7 +3024,7 @@ ecb_ews_remove_component_sync (ECalMetaBackend *meta_backend,
 
        comp = e_cal_component_new_from_string (object);
        if (!comp) {
-               g_propagate_error (error, EDC_ERROR (InvalidObject));
+               g_propagate_error (error, ECC_ERROR (E_CAL_CLIENT_ERROR_INVALID_OBJECT));
                return FALSE;
        }
 
@@ -2951,6 +3055,7 @@ ecb_ews_discard_alarm_sync (ECalBackendSync *cal_backend_sync,
                            const gchar *uid,
                            const gchar *rid,
                            const gchar *auid,
+                           guint32 opflags,
                            GError **error)
 {
        ECalBackendEws *cbews;
@@ -2967,7 +3072,7 @@ ecb_ews_discard_alarm_sync (ECalBackendSync *cal_backend_sync,
 
        if (!e_cal_cache_get_component (cal_cache, uid, NULL, &comp, cancellable, NULL) || !comp) {
                g_object_unref (cal_cache);
-               g_propagate_error (error, EDC_ERROR (ObjectNotFound));
+               g_propagate_error (error, ECC_ERROR (E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND));
                return;
        }
 
@@ -2981,16 +3086,15 @@ ecb_ews_discard_alarm_sync (ECalBackendSync *cal_backend_sync,
        convert_data.timezone_cache = E_TIMEZONE_CACHE (cbews);
 
        if (e_cal_component_has_recurrences (comp)) {
-               gint *index;
+               gint index;
 
                convert_data.change_type = E_EWS_ITEMCHANGE_TYPE_OCCURRENCEITEM;
-               e_cal_component_get_sequence (comp, &index);
+               index = e_cal_component_get_sequence (comp);
 
-               if (index != NULL) {
+               if (index > 0) {
                        /*Microsoft is counting the occurrences starting from 1
                         where EcalComponent is starting from zerro */
-                       convert_data.index = *index + 1;
-                       e_cal_component_free_sequence (index);
+                       convert_data.index = index + 1;
                } else {
                        convert_data.change_type = E_EWS_ITEMCHANGE_TYPE_ITEM;
                        convert_data.index = -1;
@@ -3011,12 +3115,14 @@ ecb_ews_discard_alarm_sync (ECalBackendSync *cal_backend_sync,
                NULL,
                cancellable,
                error)) {
-               icalcomponent *icomp = e_cal_component_get_icalcomponent (comp);
+               ICalComponent *icomp = e_cal_component_get_icalcomponent (comp);
                GSList *modified_objects;
+               gchar *itemid_str;
 
+               itemid_str = e_cal_util_component_dup_x_property (icomp, "X-EVOLUTION-ITEMID");
                modified_objects = g_slist_prepend (NULL,
-                       e_cal_meta_backend_info_new (icalcomponent_get_uid (icomp), NULL, NULL,
-                               e_cal_util_get_x_property (icomp, "X-EVOLUTION-ITEMID")));
+                       e_cal_meta_backend_info_new (i_cal_component_get_uid (icomp), NULL, NULL, 
itemid_str));
+               g_free (itemid_str);
 
                /* Refresh the local cache, to have up-to-date ChangeKey */
                e_cal_meta_backend_process_changes_sync (E_CAL_META_BACKEND (cbews), NULL, modified_objects, 
NULL, cancellable, error);
@@ -3047,28 +3153,49 @@ ecb_ews_send_cancellation_email_sync (ECalBackendEws *cbews,
        CamelMultipart *multi;
        CamelMimePart *text_part, *vcal_part;
        gchar *ical_str;
-       icalcomponent *vcal, *vevent, *vtz;
-       icalproperty *prop;
-       icaltimezone *icaltz;
-       struct icaltimetype dt;
+       ICalComponent *vcal, *vevent, *vtz;
+       ICalProperty *prop;
+       ICalTimezone *icaltz;
+       ICalTime *dt;
        gboolean success;
 
-       vcal = icalcomponent_new (ICAL_VCALENDAR_COMPONENT);
-       icalcomponent_add_property (vcal, icalproperty_new_version ("2.0"));
-       icalcomponent_add_property (vcal, icalproperty_new_prodid ("-//Evolution EWS backend//EN"));
-       icalcomponent_add_property (vcal, icalproperty_new_method (ICAL_METHOD_CANCEL));
-       vevent = icalcomponent_new_from_string (calobj);
-       prop = icalcomponent_get_first_property (vevent, ICAL_STATUS_PROPERTY);
-       if (prop != NULL) icalcomponent_remove_property (vevent, prop);
-       icalcomponent_add_property (vevent, icalproperty_new_status (ICAL_STATUS_CANCELLED));
-       prop = icalcomponent_get_first_property (vevent, ICAL_METHOD_PROPERTY);
-       if (prop != NULL) icalcomponent_remove_property (vevent, prop);
-       dt = e_cal_backend_ews_get_datetime_with_zone (E_TIMEZONE_CACHE (cbews), NULL, vevent, 
ICAL_DTSTART_PROPERTY, icalproperty_get_dtstart);
-       icaltz = (icaltimezone *)
-               (dt.zone ? dt.zone : ecb_ews_get_timezone_from_ical_component (cbews, vevent));
-       vtz = icaltimezone_get_component (icaltz);
-       icalcomponent_add_component (vcal, icalcomponent_new_clone (vtz));
-       icalcomponent_add_component (vcal, vevent);
+       vcal = i_cal_component_new (I_CAL_VCALENDAR_COMPONENT);
+       i_cal_component_take_property (vcal, i_cal_property_new_version ("2.0"));
+       i_cal_component_take_property (vcal, i_cal_property_new_prodid ("-//Evolution EWS backend//EN"));
+       i_cal_component_take_property (vcal, i_cal_property_new_method (I_CAL_METHOD_CANCEL));
+
+       vevent = i_cal_component_new_from_string (calobj);
+
+       prop = i_cal_component_get_first_property (vevent, I_CAL_STATUS_PROPERTY);
+       if (prop) {
+               i_cal_component_remove_property (vevent, prop);
+               g_object_unref (prop);
+       }
+       i_cal_component_take_property (vevent, i_cal_property_new_status (I_CAL_STATUS_CANCELLED));
+
+       prop = i_cal_component_get_first_property (vevent, I_CAL_METHOD_PROPERTY);
+       if (prop) {
+               i_cal_component_remove_property (vevent, prop);
+               g_object_unref (prop);
+       }
+
+       dt = e_cal_backend_ews_get_datetime_with_zone (E_TIMEZONE_CACHE (cbews), NULL, vevent, 
I_CAL_DTSTART_PROPERTY, i_cal_property_get_dtstart);
+       icaltz = dt ? i_cal_time_get_timezone (dt) : NULL;
+       if (!icaltz) {
+               icaltz = ecb_ews_get_timezone_from_icomponent (cbews, vevent);
+       }
+
+       if (icaltz) {
+               vtz = i_cal_timezone_get_component (icaltz);
+               if (vtz)
+                       i_cal_component_take_component (vcal, i_cal_component_new_clone (vtz));
+               g_clear_object (&vtz);
+       }
+
+       i_cal_component_take_component (vcal, vevent);
+
+       g_clear_object (&dt);
+
        text_part = camel_mime_part_new ();
        camel_mime_part_set_content (text_part, body, strlen (body), "text/plain");
 
@@ -3076,9 +3203,9 @@ ecb_ews_send_cancellation_email_sync (ECalBackendEws *cbews,
        mime_type = camel_data_wrapper_get_mime_type_field (CAMEL_DATA_WRAPPER (vcal_part));
        camel_content_type_set_param (mime_type, "charset", "utf-8");
        camel_content_type_set_param (mime_type, "method", "CANCEL");
-       ical_str = icalcomponent_as_ical_string_r ((icalcomponent *) vcal);
+       ical_str = i_cal_component_as_ical_string_r (vcal);
        camel_mime_part_set_content (vcal_part, ical_str, strlen (ical_str), "text/calendar; method=CANCEL");
-       free (ical_str);
+       g_free (ical_str);
 
        multi = camel_multipart_new ();
        camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (multi), "multipart/alternative");
@@ -3099,15 +3226,15 @@ ecb_ews_send_cancellation_email_sync (ECalBackendEws *cbews,
        success = camel_ews_utils_create_mime_message (cbews->priv->cnc, "SendOnly", NULL, message, NULL, 
from, NULL, NULL, NULL, cancellable, error);
 
        g_object_unref (message);
-       icalcomponent_free (vcal);
+       g_object_unref (vcal);
 
        return success;
 }
 
 static void
 ecb_ews_receive_objects_no_exchange_mail (ECalBackendEws *cbews,
-                                         icalcomponent *vcalendar,
-                                         icalcomponent *subcomp,
+                                         ICalComponent *vcalendar,
+                                         ICalComponent *subcomp,
                                          GSList **ids,
                                          GCancellable *cancellable,
                                          GError **error)
@@ -3117,9 +3244,9 @@ ecb_ews_receive_objects_no_exchange_mail (ECalBackendEws *cbews,
 
        convert_data.connection = cbews->priv->cnc;
        convert_data.timezone_cache = E_TIMEZONE_CACHE (cbews);
-       convert_data.icalcomp = subcomp;
+       convert_data.icomp = subcomp;
        convert_data.vcalendar = vcalendar;
-       convert_data.default_zone = icaltimezone_get_utc_timezone ();
+       convert_data.default_zone = i_cal_timezone_get_utc_timezone ();
 
        fid = e_ews_folder_id_new (cbews->priv->folder_id, NULL, FALSE);
 
@@ -3138,22 +3265,22 @@ ecb_ews_receive_objects_no_exchange_mail (ECalBackendEws *cbews,
        e_ews_folder_id_free (fid);
 }
 
-static icalproperty *
-find_attendee (icalcomponent *ical_comp,
+static ICalProperty *
+find_attendee (ICalComponent *icomp,
                const gchar *address)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
        if (address == NULL)
                return NULL;
 
-       for (prop = icalcomponent_get_first_property (ical_comp, ICAL_ATTENDEE_PROPERTY);
+       for (prop = i_cal_component_get_first_property (icomp, I_CAL_ATTENDEE_PROPERTY);
             prop != NULL;
-            prop = icalcomponent_get_next_property (ical_comp, ICAL_ATTENDEE_PROPERTY)) {
+            g_object_unref (prop), prop = i_cal_component_get_next_property (icomp, 
I_CAL_ATTENDEE_PROPERTY)) {
                gchar *attendee;
                gchar *text;
 
-               attendee = icalproperty_get_value_as_string_r (prop);
+               attendee = i_cal_property_get_value_as_string_r (prop);
 
                 if (!attendee)
                        continue;
@@ -3172,33 +3299,38 @@ find_attendee (icalcomponent *ical_comp,
        return prop;
 }
 
-static icalproperty *
-find_attendee_if_sentby (icalcomponent *ical_comp,
+static ICalProperty *
+find_attendee_if_sentby (ICalComponent *icomp,
                          const gchar *address)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
        if (address == NULL)
                return NULL;
 
-       for (prop = icalcomponent_get_first_property (ical_comp, ICAL_ATTENDEE_PROPERTY);
+       for (prop = i_cal_component_get_first_property (icomp, I_CAL_ATTENDEE_PROPERTY);
             prop != NULL;
-            prop = icalcomponent_get_next_property (ical_comp, ICAL_ATTENDEE_PROPERTY)) {
-               icalparameter *param;
+            g_object_unref (prop), prop = i_cal_component_get_next_property (icomp, 
I_CAL_ATTENDEE_PROPERTY)) {
+               ICalParameter *param;
                const gchar *attendee_sentby;
                gchar *text;
 
-               param = icalproperty_get_first_parameter (prop, ICAL_SENTBY_PARAMETER);
+               param = i_cal_property_get_first_parameter (prop, I_CAL_SENTBY_PARAMETER);
                if (!param)
                        continue;
 
-               attendee_sentby = icalparameter_get_sentby (param);
+               attendee_sentby = i_cal_parameter_get_sentby (param);
 
-               if (!attendee_sentby)
+               if (!attendee_sentby) {
+                       g_object_unref (param);
                        continue;
+               }
 
                text = g_strdup (itip_strip_mailto (attendee_sentby));
                text = g_strstrip (text);
+
+               g_object_unref (param);
+
                if (text && !g_ascii_strcasecmp (address, text)) {
                        g_free (text);
                        break;
@@ -3210,7 +3342,7 @@ find_attendee_if_sentby (icalcomponent *ical_comp,
 }
 
 static void
-ecb_ews_get_rsvp (icalproperty *attendee,
+ecb_ews_get_rsvp (ICalProperty *attendee,
                  gboolean *out_rsvp_requested)
 {
        if (out_rsvp_requested)
@@ -3219,58 +3351,59 @@ ecb_ews_get_rsvp (icalproperty *attendee,
                return;
 
        if (attendee) {
-               icalparameter *rsvp;
+               ICalParameter *rsvp;
 
-               rsvp = icalproperty_get_first_parameter (attendee, ICAL_RSVP_PARAMETER);
+               rsvp = i_cal_property_get_first_parameter (attendee, I_CAL_RSVP_PARAMETER);
                if (rsvp) {
-                       *out_rsvp_requested = icalparameter_get_rsvp (rsvp) == ICAL_RSVP_TRUE;
+                       *out_rsvp_requested = i_cal_parameter_get_rsvp (rsvp) == I_CAL_RSVP_TRUE;
+                       g_object_unref (rsvp);
                }
        }
 }
 
-static const gchar *
+static gchar *
 ecb_ews_get_current_user_meeting_reponse (ECalBackendEws *cbews,
-                                         icalcomponent *icalcomp,
+                                         ICalComponent *icomp,
                                          const gchar *current_user_mail,
                                          gboolean *out_rsvp_requested)
 {
-       icalproperty *attendee;
+       ICalProperty *attendee;
        const gchar *attendee_str = NULL, *attendee_mail = NULL;
        gint attendees_count = 0;
-       const gchar *response = NULL;
+       gchar *response = NULL;
        gboolean found = FALSE;
 
        if (out_rsvp_requested)
                *out_rsvp_requested = FALSE;
 
-       attendee = icalcomponent_get_first_property (icalcomp, ICAL_ORGANIZER_PROPERTY);
+       attendee = i_cal_component_get_first_property (icomp, I_CAL_ORGANIZER_PROPERTY);
        if (attendee) {
-               attendee_str = icalproperty_get_organizer (attendee);
+               attendee_str = i_cal_property_get_organizer (attendee);
 
                if (attendee_str) {
-                       if (!strncasecmp (attendee_str, "mailto:";, 7))
-                               attendee_mail = attendee_str + 7;
-                       else
-                               attendee_mail = attendee_str;
+                       attendee_mail = itip_strip_mailto (attendee_str);
+
                        if (attendee_mail && current_user_mail && g_ascii_strcasecmp (attendee_mail, 
current_user_mail) == 0) {
+                               g_object_unref (attendee);
                                /* Empty string means it's an organizer, NULL is when not found */
-                               return "";
+                               return g_strdup ("");
                        }
                }
+
+               g_object_unref (attendee);
        }
 
-       for (attendee = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
-               attendee != NULL;
-               attendee = icalcomponent_get_next_property (icalcomp, ICAL_ATTENDEE_PROPERTY), 
attendees_count++) {
-               attendee_str = icalproperty_get_attendee (attendee);
+       for (attendee = i_cal_component_get_first_property (icomp, I_CAL_ATTENDEE_PROPERTY);
+            attendee;
+            g_object_unref (attendee), attendee = i_cal_component_get_next_property (icomp, 
I_CAL_ATTENDEE_PROPERTY), attendees_count++) {
+               attendee_str = i_cal_property_get_attendee (attendee);
 
                if (attendee_str != NULL) {
-                       if (!strncasecmp (attendee_str, "mailto:";, 7))
-                               attendee_mail = attendee_str + 7;
-                       else
-                               attendee_mail = attendee_str;
+                       attendee_mail = itip_strip_mailto (attendee_str);
+
                        if (attendee_mail && current_user_mail && g_ascii_strcasecmp (attendee_mail, 
current_user_mail) == 0) {
-                               response = icalproperty_get_parameter_as_string (attendee, "PARTSTAT");
+                               g_free (response);
+                               response = i_cal_property_get_parameter_as_string_r (attendee, "PARTSTAT");
                                ecb_ews_get_rsvp (attendee, out_rsvp_requested);
                                found = TRUE;
                        }
@@ -3280,41 +3413,43 @@ ecb_ews_get_current_user_meeting_reponse (ECalBackendEws *cbews,
        /* this should not happen, but if the user's configured email does not match the one
           used in the invitation, like when the invitation comes to a mailing list... */
        if (!found && attendees_count == 1) {
-               attendee = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
+               attendee = i_cal_component_get_first_property (icomp, I_CAL_ATTENDEE_PROPERTY);
                g_return_val_if_fail (attendee != NULL, NULL);
 
-               response = icalproperty_get_parameter_as_string (attendee, "PARTSTAT");
+               response = i_cal_property_get_parameter_as_string_r (attendee, "PARTSTAT");
                ecb_ews_get_rsvp (attendee, out_rsvp_requested);
                found = TRUE;
+               g_clear_object (&attendee);
        } else if (!found) {
                ESourceRegistry *registry;
                ECalComponent *comp;
 
                registry = e_cal_backend_get_registry (E_CAL_BACKEND (cbews));
-               comp = e_cal_component_new ();
-               if (e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp))) {
+               comp = e_cal_component_new_from_icalcomponent (i_cal_component_new_clone (icomp));
+               if (comp) {
                        gchar *my_address;
 
                        my_address = itip_get_comp_attendee (registry, comp, NULL);
 
-                       attendee = find_attendee (icalcomp, my_address);
+                       attendee = find_attendee (icomp, my_address);
                        if (!attendee)
-                               attendee = find_attendee_if_sentby (icalcomp, my_address);
+                               attendee = find_attendee_if_sentby (icomp, my_address);
 
                        if (attendee) {
-                               response = icalproperty_get_parameter_as_string (attendee, "PARTSTAT");
+                               response = i_cal_property_get_parameter_as_string_r (attendee, "PARTSTAT");
                                ecb_ews_get_rsvp (attendee, out_rsvp_requested);
                                found = TRUE;
+                               g_clear_object (&attendee);
                        }
 
                        g_free (my_address);
                }
 
-               g_object_unref (comp);
+               g_clear_object (&comp);
        }
 
        if (found && !response) {
-               response = "NEEDS-ACTION";
+               response = g_strdup ("NEEDS-ACTION");
        }
 
        return response;
@@ -3327,29 +3462,31 @@ ecb_ews_get_item_accept_id (ECalComponent *comp,
                            gchar **changekey,
                            gchar **mail_id)
 {
-       icalproperty *prop;
+       ICalComponent *icomp;
+       ICalProperty *prop;
        gchar *id_item = NULL;
        gchar *id_accept = NULL;
        gchar *ck = NULL;
 
-       prop = icalcomponent_get_first_property (
-               e_cal_component_get_icalcomponent (comp),
-               ICAL_X_PROPERTY);
-       while (prop) {
+       icomp = e_cal_component_get_icalcomponent (comp);
+
+       for (prop = i_cal_component_get_first_property (icomp, I_CAL_X_PROPERTY);
+            prop;
+            g_object_unref (prop), prop = i_cal_component_get_next_property (icomp, I_CAL_X_PROPERTY)) {
                const gchar *x_name, *x_val;
 
-               x_name = icalproperty_get_x_name (prop);
-               x_val = icalproperty_get_x (prop);
+               x_name = i_cal_property_get_x_name (prop);
+               if (!x_name)
+                       continue;
+
+               x_val = i_cal_property_get_x (prop);
+
                if (!id_item && g_ascii_strcasecmp (x_name, "X-EVOLUTION-ITEMID") == 0)
                        id_item = g_strdup (x_val);
                else if (!id_accept && g_ascii_strcasecmp (x_name, "X-EVOLUTION-ACCEPT-ID") == 0)
                        id_accept = g_strdup (x_val);
                else if (changekey && !ck && !g_ascii_strcasecmp (x_name, "X-EVOLUTION-CHANGEKEY"))
                        ck = g_strdup (x_val);
-
-               prop = icalcomponent_get_next_property (
-                       e_cal_component_get_icalcomponent (comp),
-                       ICAL_X_PROPERTY);
        }
 
        if (!id_item)
@@ -3363,9 +3500,9 @@ ecb_ews_get_item_accept_id (ECalComponent *comp,
 
 static gboolean
 ecb_ews_do_method_request_publish_reply (ECalBackendEws *cbews,
-                                        icalcomponent *vcalendar,
+                                        ICalComponent *vcalendar,
                                         ECalComponent *comp,
-                                        icalcomponent *subcomp,
+                                        ICalComponent *subcomp,
                                         const gchar *response_type,
                                         const gchar *user_email,
                                         gboolean rsvp_requested,
@@ -3382,7 +3519,7 @@ ecb_ews_do_method_request_publish_reply (ECalBackendEws *cbews,
        if (!response_type &&
            e_cal_util_component_has_organizer (subcomp) &&
            e_cal_util_component_has_attendee (subcomp)) {
-               g_set_error (error, E_DATA_CAL_ERROR, UnknownUser, _("Cannot find user “%s” between 
attendees"), user_email ? user_email : "NULL");
+               g_set_error (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_UNKNOWN_USER, _("Cannot find user 
“%s” between attendees"), user_email ? user_email : "NULL");
                return FALSE;
        }
 
@@ -3477,12 +3614,16 @@ ecb_ews_do_method_request_publish_reply (ECalBackendEws *cbews,
        }
 
        if (local_error == NULL) {
-               icalproperty *transp;
+               ICalProperty *prop;
+               ICalPropertyTransp transp = I_CAL_TRANSP_NONE;
 
-               transp = icalcomponent_get_first_property (subcomp, ICAL_TRANSP_PROPERTY);
+               prop = i_cal_component_get_first_property (subcomp, I_CAL_TRANSP_PROPERTY);
+               if (prop) {
+                       transp = i_cal_property_get_transp (prop);
+                       g_object_unref (prop);
+               }
 
-               if (g_strcmp0 (icalproperty_get_value_as_string (transp), "TRANSPARENT") == 0 &&
-                   g_strcmp0 (response_type, "ACCEPTED") == 0) {
+               if (transp == I_CAL_TRANSP_TRANSPARENT && g_strcmp0 (response_type, "ACCEPTED") == 0) {
                        EwsCalendarConvertData convert_data = { 0 };
                        GSList *l;
 
@@ -3536,13 +3677,14 @@ ecb_ews_receive_objects_sync (ECalBackendSync *sync_backend,
                              EDataCal *cal,
                              GCancellable *cancellable,
                              const gchar *calobj,
+                             guint32 opflags,
                              GError **error)
 {
        ECalBackendEws *cbews;
        ECalBackend *cal_backend;
        CamelEwsSettings *ews_settings;
-       icalcomponent *icalcomp, *subcomp;
-       icalcomponent_kind kind;
+       ICalComponent *icomp, *subcomp;
+       ICalComponentKind kind;
        gchar *user_email;
        gboolean success = TRUE, do_refresh = FALSE;
 
@@ -3553,17 +3695,17 @@ ecb_ews_receive_objects_sync (ECalBackendSync *sync_backend,
        if (!e_cal_meta_backend_ensure_connected_sync (E_CAL_META_BACKEND (cbews), cancellable, error))
                return;
 
-       icalcomp = calobj ? icalparser_parse_string (calobj) : NULL;
+       icomp = calobj ? i_cal_parser_parse_string (calobj) : NULL;
 
-       if (!icalcomp) {
-               g_propagate_error (error, EDC_ERROR (InvalidObject));
+       if (!icomp) {
+               g_propagate_error (error, ECC_ERROR (E_CAL_CLIENT_ERROR_INVALID_OBJECT));
                return;
        }
 
        /* make sure ical data we parse is actually a vCalendar component */
-       if (icalcomponent_isa (icalcomp) != ICAL_VCALENDAR_COMPONENT) {
-               icalcomponent_free (icalcomp);
-               g_propagate_error (error, EDC_ERROR (InvalidObject));
+       if (i_cal_component_isa (icomp) != I_CAL_VCALENDAR_COMPONENT) {
+               g_object_unref (icomp);
+               g_propagate_error (error, ECC_ERROR (E_CAL_CLIENT_ERROR_INVALID_OBJECT));
                return;
        }
 
@@ -3573,91 +3715,96 @@ ecb_ews_receive_objects_sync (ECalBackendSync *sync_backend,
        ews_settings = ecb_ews_get_collection_settings (cbews);
        user_email = camel_ews_settings_dup_email (ews_settings);
 
-       switch (icalcomponent_get_method (icalcomp)) {
-       case ICAL_METHOD_REQUEST:
-       case ICAL_METHOD_PUBLISH:
-       case ICAL_METHOD_REPLY:
-               for (subcomp = icalcomponent_get_first_component (icalcomp, kind);
+       switch (i_cal_component_get_method (icomp)) {
+       case I_CAL_METHOD_REQUEST:
+       case I_CAL_METHOD_PUBLISH:
+       case I_CAL_METHOD_REPLY:
+               for (subcomp = i_cal_component_get_first_component (icomp, kind);
                     subcomp && success;
-                    subcomp = icalcomponent_get_next_component (icalcomp, kind)) {
+                    g_object_unref (subcomp), subcomp = i_cal_component_get_next_component (icomp, kind)) {
                        ECalComponent *comp;
-                       const gchar *response_type;
+                       gchar *response_type;
                        gboolean rsvp_requested = FALSE;
 
                        /* getting a data for meeting request response */
                        response_type = ecb_ews_get_current_user_meeting_reponse (cbews, subcomp, user_email, 
&rsvp_requested);
 
-                       comp = e_cal_component_new_from_icalcomponent (icalcomponent_new_clone (subcomp));
+                       comp = e_cal_component_new_from_icalcomponent (i_cal_component_new_clone (subcomp));
 
-                       success = ecb_ews_do_method_request_publish_reply (cbews, icalcomp, comp, subcomp, 
response_type, user_email, rsvp_requested, cancellable, error);
+                       success = ecb_ews_do_method_request_publish_reply (cbews, icomp, comp, subcomp, 
response_type, user_email, rsvp_requested, cancellable, error);
 
                        do_refresh = TRUE;
 
                        g_object_unref (comp);
+                       g_free (response_type);
                }
+               g_clear_object (&subcomp);
                break;
-       case ICAL_METHOD_COUNTER:
+       case I_CAL_METHOD_COUNTER:
                /*
                 * this is a new time proposal mail from one of the attendees
                 * if we decline the proposal, nothing have to be done
                 * if we accept it we will call to modify_object
                 */
-               for (subcomp = icalcomponent_get_first_component (icalcomp, kind);
+               for (subcomp = i_cal_component_get_first_component (icomp, kind);
                     subcomp && success;
-                    subcomp = icalcomponent_get_next_component (icalcomp, kind)) {
-                       const gchar *response_type;
+                    g_object_unref (subcomp), subcomp = i_cal_component_get_next_component (icomp, kind)) {
+                       gchar *response_type;
 
                        /* getting a data for meeting request response */
                        response_type = ecb_ews_get_current_user_meeting_reponse (cbews, subcomp, user_email, 
NULL);
 
                        if (g_strcmp0 (response_type, "ACCEPTED") == 0) {
                                gchar **split_subject;
-                               icalproperty *summary;
+                               ICalProperty *summary;
 
                                /* we have to edit the meeting subject to remove exchange header */
-                               summary = icalcomponent_get_first_property (subcomp, ICAL_SUMMARY_PROPERTY);
-                               split_subject =
-                                       g_strsplit (icalproperty_get_value_as_string (summary), ":", -1);
-                               icalproperty_set_value_from_string (summary, split_subject[1] , "NO");
-                               g_strfreev (split_subject);
+                               summary = i_cal_component_get_first_property (subcomp, 
I_CAL_SUMMARY_PROPERTY);
+                               if (summary) {
+                                       split_subject = g_strsplit (i_cal_property_get_summary (summary), 
":", -1);
+                                       if (split_subject && split_subject[0] && split_subject[1])
+                                               i_cal_property_set_summary (summary, split_subject[1]);
+                                       g_strfreev (split_subject);
+                                       g_object_unref (summary);
+                               }
 
                                success = ecb_ews_modify_item_sync (cbews, NULL, NULL, subcomp, cancellable, 
error);
 
                                do_refresh = TRUE;
                        }
+
+                       g_free (response_type);
                }
+               g_clear_object (&subcomp);
                break;
-       case ICAL_METHOD_CANCEL: {
+       case I_CAL_METHOD_CANCEL: {
                ECalObjModType mod_type = E_CAL_OBJ_MOD_ALL;
                GSList *ids = NULL;
 
-               for (subcomp = icalcomponent_get_first_component (icalcomp, kind);
+               for (subcomp = i_cal_component_get_first_component (icomp, kind);
                     subcomp && success;
-                    subcomp = icalcomponent_get_next_component (icalcomp, kind)) {
-                       const gchar *uid = icalcomponent_get_uid (subcomp);
-                       gchar *rid_str = NULL;
-
-                       if (icalcomponent_get_first_property (subcomp, ICAL_RECURRENCEID_PROPERTY)) {
-                               struct icaltimetype rid = icaltime_null_time ();
+                    g_object_unref (subcomp), subcomp = i_cal_component_get_next_component (icomp, kind)) {
+                       const gchar *uid;
+                       gchar *rid;
 
-                               rid = icalcomponent_get_recurrenceid (subcomp);
-
-                               rid_str = (icaltime_is_valid_time (rid) && !icaltime_is_null_time (rid)) ?
-                                       icaltime_as_ical_string_r (rid) : g_strdup ("0");
+                       uid = i_cal_component_get_uid (subcomp);
+                       rid = e_cal_util_component_get_recurid_as_string (subcomp);
 
+                       if (rid && *rid)
                                mod_type = E_CAL_OBJ_MOD_THIS;
-                       }
 
-                       ids = g_slist_prepend (ids, e_cal_component_id_new (uid, rid_str));
+                       ids = g_slist_prepend (ids, e_cal_component_id_new (uid, rid));
 
-                       g_free (rid_str);
+                       g_free (rid);
                }
 
+               g_clear_object (&subcomp);
+
                if (ids) {
                        GSList *old_comps = NULL, *new_comps = NULL;
                        GError *local_error = NULL;
 
-                       e_cal_backend_sync_remove_objects (sync_backend, cal, cancellable, ids, mod_type, 
&old_comps, &new_comps, &local_error);
+                       e_cal_backend_sync_remove_objects (sync_backend, cal, cancellable, ids, mod_type, 
opflags, &old_comps, &new_comps, &local_error);
 
                        do_refresh = !local_error;
 
@@ -3666,13 +3813,13 @@ ecb_ews_receive_objects_sync (ECalBackendSync *sync_backend,
                        g_clear_error (&local_error);
                }
 
-               g_slist_free_full (ids, (GDestroyNotify) e_cal_component_free_id);
+               g_slist_free_full (ids, e_cal_component_id_free);
                } break;
        default:
                break;
        }
 
-       icalcomponent_free (icalcomp);
+       g_object_unref (icomp);
        g_free (user_email);
 
        if (success && do_refresh)
@@ -3687,13 +3834,14 @@ ecb_ews_send_objects_sync (ECalBackendSync *sync_backend,
                           EDataCal *cal,
                           GCancellable *cancellable,
                           const gchar *calobj,
+                          guint32 opflags,
                           GSList **users,
                           gchar **modified_calobj,
                           GError **error)
 {
        ECalBackendEws *cbews;
-       icalcomponent_kind kind;
-       icalcomponent *icalcomp, *subcomp = NULL;
+       ICalComponentKind kind;
+       ICalComponent *icomp, *subcomp = NULL;
        gchar *subcalobj;
        gboolean success = TRUE;
 
@@ -3704,69 +3852,86 @@ ecb_ews_send_objects_sync (ECalBackendSync *sync_backend,
        if (!e_cal_meta_backend_ensure_connected_sync (E_CAL_META_BACKEND (cbews), cancellable, error))
                return;
 
-       icalcomp = calobj ? icalparser_parse_string (calobj) : NULL;
+       icomp = calobj ? i_cal_parser_parse_string (calobj) : NULL;
 
        /* make sure data was parsed properly */
-       if (!icalcomp) {
-               g_propagate_error (error, EDC_ERROR (InvalidObject));
+       if (!icomp) {
+               g_propagate_error (error, ECC_ERROR (E_CAL_CLIENT_ERROR_INVALID_OBJECT));
                return;
        }
 
        /* make sure ical data we parse is actually an vcal component */
-       if ((icalcomponent_isa (icalcomp) != ICAL_VCALENDAR_COMPONENT) && (icalcomponent_isa (icalcomp) != 
ICAL_VEVENT_COMPONENT)) {
-               icalcomponent_free (icalcomp);
-               g_propagate_error (error, EDC_ERROR (InvalidObject));
+       if (i_cal_component_isa (icomp) != I_CAL_VCALENDAR_COMPONENT &&
+           i_cal_component_isa (icomp) != I_CAL_VEVENT_COMPONENT) {
+               g_object_unref (icomp);
+               g_propagate_error (error, ECC_ERROR (E_CAL_CLIENT_ERROR_INVALID_OBJECT));
                return;
        }
 
        kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbews));
 
-       if (icalcomponent_isa (icalcomp) == ICAL_VCALENDAR_COMPONENT) {
+       if (i_cal_component_isa (icomp) == I_CAL_VCALENDAR_COMPONENT) {
                kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbews));
-               subcomp = icalcomponent_get_first_component (icalcomp, kind);
+               subcomp = i_cal_component_get_first_component (icomp, kind);
+       } else if (i_cal_component_isa (icomp) == I_CAL_VEVENT_COMPONENT) {
+               subcomp = g_object_ref (icomp);
        }
-       if (icalcomponent_isa (icalcomp) == ICAL_VEVENT_COMPONENT)
-               subcomp = icalcomp;
+
        while (subcomp && success) {
-               const gchar *new_body_content = NULL, *subject = NULL, *org_email = NULL;
+               const gchar *subject = NULL, *org_email = NULL;
                const gchar *org = NULL, *attendee = NULL;
-               icalproperty *prop, *org_prop = NULL;
+               gchar *new_body_content, *org_cn;
+               ICalProperty *prop, *org_prop;
                CamelInternetAddress *org_addr = camel_internet_address_new ();
 
-               new_body_content = e_cal_util_get_x_property (subcomp, "X-EVOLUTION-RETRACT-COMMENT");
-               subject = icalproperty_get_value_as_string (icalcomponent_get_first_property (subcomp, 
ICAL_SUMMARY_PROPERTY));
+               new_body_content = e_cal_util_component_dup_x_property (subcomp, 
"X-EVOLUTION-RETRACT-COMMENT");
+               prop = i_cal_component_get_first_property (subcomp, I_CAL_SUMMARY_PROPERTY);
+               if (prop) {
+                       subject = i_cal_property_get_summary (prop);
+                       g_object_unref (prop);
+               }
 
-               org_prop = icalcomponent_get_first_property (subcomp, ICAL_ORGANIZER_PROPERTY);
-               org = icalproperty_get_organizer (org_prop);
-               if (!g_ascii_strncasecmp (org, "mailto:";, 7))
-                       org_email = (org) + 7;
-               else
-                       org_email = org;
+               org_prop = i_cal_component_get_first_property (subcomp, I_CAL_ORGANIZER_PROPERTY);
+               org = i_cal_property_get_organizer (org_prop);
+               org_email = itip_strip_mailto (org);
+               org_cn = i_cal_property_get_parameter_as_string_r (org_prop, "CN");
 
-               camel_internet_address_add (org_addr, icalproperty_get_parameter_as_string (org_prop, "CN"), 
org_email);
+               camel_internet_address_add (org_addr, org_cn, org_email);
 
                /* iterate over every attendee property */
-               for (prop = icalcomponent_get_first_property (subcomp, ICAL_ATTENDEE_PROPERTY);
+               for (prop = i_cal_component_get_first_property (subcomp, I_CAL_ATTENDEE_PROPERTY);
                     prop && success;
-                    prop = icalcomponent_get_next_property (subcomp, ICAL_ATTENDEE_PROPERTY)) {
+                    g_object_unref (prop), prop = i_cal_component_get_next_property (subcomp, 
I_CAL_ATTENDEE_PROPERTY)) {
                        CamelInternetAddress *attendee_addr = camel_internet_address_new ();
-                       attendee = icalproperty_get_attendee (prop);
-                       if (g_ascii_strcasecmp (org_email, attendee) == 0) continue;
-                       if (!g_ascii_strncasecmp (attendee, "mailto:";, 7)) attendee = (attendee) + 7;
+                       gchar *att_cn;
+
+                       attendee = itip_strip_mailto (i_cal_property_get_attendee (prop));
+                       if (!attendee || g_ascii_strcasecmp (org_email, attendee) == 0)
+                               continue;
+
+                       subcalobj = i_cal_component_as_ical_string_r (subcomp);
+                       att_cn = i_cal_property_get_parameter_as_string_r (prop, "CN");
+
+                       camel_internet_address_add (attendee_addr, att_cn, attendee);
 
-                       subcalobj = icalcomponent_as_ical_string_r (subcomp);
-                       camel_internet_address_add (attendee_addr, icalproperty_get_parameter_as_string 
(prop, "CN"), attendee);
                        success = ecb_ews_send_cancellation_email_sync (cbews, CAMEL_ADDRESS (org_addr), 
attendee_addr,
                                subject, new_body_content, subcalobj, cancellable, error);
+
                        g_object_unref (attendee_addr);
-                       free (subcalobj);
+                       g_free (subcalobj);
+                       g_free (att_cn);
                }
 
+               g_free (org_cn);
+               g_free (new_body_content);
+               g_clear_object (&org_prop);
                g_object_unref (org_addr);
-               subcomp = icalcomponent_get_next_component (icalcomp, kind);
+               g_object_unref (subcomp);
+               subcomp = i_cal_component_get_next_component (icomp, kind);
        }
 
-       icalcomponent_free (icalcomp);
+       g_clear_object (&subcomp);
+       g_object_unref (icomp);
 
        ecb_ews_convert_error_to_edc_error (error);
        ecb_ews_maybe_disconnect_sync (cbews, error, cancellable);
@@ -3800,7 +3965,7 @@ ecb_ews_get_free_busy_sync (ECalBackendSync *sync_backend,
        /* EWS can support only 100 identities, which is the maximum number of identities that the Web 
service method can request
         see http://msdn.microsoft.com / en - us / library / aa564001 % 28v = EXCHG.140 % 29.aspx */
        if (g_slist_length ((GSList *) users) > 100) {
-               g_propagate_error (error, EDC_ERROR (SearchSizeLimitExceeded));
+               g_propagate_error (error, EC_ERROR (E_CLIENT_ERROR_SEARCH_SIZE_LIMIT_EXCEEDED));
                return;
        }
 
@@ -3818,21 +3983,21 @@ ecb_ews_get_free_busy_sync (ECalBackendSync *sync_backend,
                for (fblink = freebusy, ulink = (GSList *) users;
                     fblink && ulink;
                     fblink = g_slist_next (fblink), ulink = g_slist_next (ulink)) {
-                       icalcomponent *icalcomp = fblink->data;
+                       ICalComponent *icomp = fblink->data;
                        gchar *mailto;
 
                        /* add attendee property */
                        mailto = g_strconcat ("mailto:";, ulink->data, NULL);
-                       icalcomponent_add_property (icalcomp, icalproperty_new_attendee (mailto));
+                       i_cal_component_take_property (icomp, i_cal_property_new_attendee (mailto));
                        g_free (mailto);
 
-                       *freebusyobjs = g_slist_prepend (*freebusyobjs, icalcomponent_as_ical_string_r 
(icalcomp));
+                       *freebusyobjs = g_slist_prepend (*freebusyobjs, i_cal_component_as_ical_string_r 
(icomp));
                }
 
                *freebusyobjs = g_slist_reverse (*freebusyobjs);
        }
 
-       g_slist_free_full (freebusy, (GDestroyNotify) icalcomponent_free);
+       g_slist_free_full (freebusy, g_object_unref);
 
        ecb_ews_convert_error_to_edc_error (error);
        ecb_ews_maybe_disconnect_sync (cbews, error, cancellable);
@@ -3852,33 +4017,33 @@ ecb_ews_get_backend_property (ECalBackend *cal_backend,
        if (g_str_equal (prop_name, CLIENT_BACKEND_PROPERTY_CAPABILITIES)) {
                return g_strjoin (
                        ",",
-                       CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS,
-                       CAL_STATIC_CAPABILITY_NO_AUDIO_ALARMS,
-                       CAL_STATIC_CAPABILITY_NO_PROCEDURE_ALARMS,
-                       CAL_STATIC_CAPABILITY_ONE_ALARM_ONLY,
-                       CAL_STATIC_CAPABILITY_REMOVE_ALARMS,
-                       CAL_STATIC_CAPABILITY_NO_THISANDPRIOR,
-                       CAL_STATIC_CAPABILITY_NO_THISANDFUTURE,
-                       CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK,
-                       CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT,
-                       CAL_STATIC_CAPABILITY_SAVE_SCHEDULES,
-                       CAL_STATIC_CAPABILITY_NO_ALARM_AFTER_START,
-                       CAL_STATIC_CAPABILITY_NO_MEMO_START_DATE,
-                       CAL_STATIC_CAPABILITY_ALL_DAY_EVENT_AS_TIME,
-                       CAL_STATIC_CAPABILITY_TASK_DATE_ONLY,
-                       CAL_STATIC_CAPABILITY_TASK_NO_ALARM,
-                       CAL_STATIC_CAPABILITY_TASK_CAN_RECUR,
-                       CAL_STATIC_CAPABILITY_TASK_HANDLE_RECUR,
+                       E_CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS,
+                       E_CAL_STATIC_CAPABILITY_NO_AUDIO_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_THISANDPRIOR,
+                       E_CAL_STATIC_CAPABILITY_NO_THISANDFUTURE,
+                       E_CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK,
+                       E_CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT,
+                       E_CAL_STATIC_CAPABILITY_SAVE_SCHEDULES,
+                       E_CAL_STATIC_CAPABILITY_NO_ALARM_AFTER_START,
+                       E_CAL_STATIC_CAPABILITY_NO_MEMO_START_DATE,
+                       E_CAL_STATIC_CAPABILITY_ALL_DAY_EVENT_AS_TIME,
+                       E_CAL_STATIC_CAPABILITY_TASK_DATE_ONLY,
+                       E_CAL_STATIC_CAPABILITY_TASK_NO_ALARM,
+                       E_CAL_STATIC_CAPABILITY_TASK_CAN_RECUR,
+                       E_CAL_STATIC_CAPABILITY_TASK_HANDLE_RECUR,
                        e_cal_meta_backend_get_capabilities (E_CAL_META_BACKEND (cbews)),
                        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 email address of the person who opened the calendar */
                CamelEwsSettings *ews_settings;
 
                ews_settings = ecb_ews_get_collection_settings (cbews);
 
                return camel_ews_settings_dup_email (ews_settings);
-       } 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)) {
                /* ews does not support email based alarms */
                return NULL;
        }
@@ -3964,12 +4129,12 @@ ecb_ews_get_destination_address (EBackend *backend,
 
 static gchar *
 ecb_ews_dup_component_revision (ECalCache *cal_cache,
-                               icalcomponent *icalcomp,
+                               ICalComponent *icomp,
                                gpointer user_data)
 {
-       g_return_val_if_fail (icalcomp != NULL, NULL);
+       g_return_val_if_fail (icomp != NULL, NULL);
 
-       return e_cal_util_dup_x_property (icalcomp, "X-EVOLUTION-CHANGEKEY");
+       return e_cal_util_component_dup_x_property (icomp, "X-EVOLUTION-CHANGEKEY");
 }
 
 static void
diff --git a/src/camel/camel-ews-folder.c b/src/camel/camel-ews-folder.c
index d388bd27..e17b7a9a 100644
--- a/src/camel/camel-ews-folder.c
+++ b/src/camel/camel-ews-folder.c
@@ -39,8 +39,7 @@ which needs to be better organized via functions */
 
 #include <glib/gi18n-lib.h>
 #include <glib/gstdio.h>
-#include <libical/icalcomponent.h>
-#include <libical/icalparser.h>
+#include <libecal/libecal.h>
 
 #include "server/camel-ews-settings.h"
 #include "server/e-ews-camel-common.h"
@@ -398,7 +397,7 @@ ews_update_mgtrequest_mime_calendar_itemid (const gchar *mime_fname,
                CamelDataWrapper *dw;
                CamelStream *tmpstream = NULL, *newstream = NULL;
                GByteArray *ba;
-               icalcomponent *icalcomp = NULL;
+               ICalComponent *icomp = NULL;
                gchar *dir;
                gint fd;
                gboolean success = FALSE;
@@ -413,31 +412,31 @@ ews_update_mgtrequest_mime_calendar_itemid (const gchar *mime_fname,
                ba = camel_stream_mem_get_byte_array (CAMEL_STREAM_MEM (tmpstream));
                if (ba && ba->len) {
                        g_byte_array_append (ba, (guint8 *) "\0", 1);
-                       icalcomp = icalparser_parse_string ((gchar *) ba->data);
+                       icomp = i_cal_parser_parse_string ((gchar *) ba->data);
                }
-               if (icalcomp) {
-                       icalcomponent *subcomp;
-                       icalproperty *icalprop;
+               if (icomp) {
+                       ICalComponent *subcomp;
+                       ICalProperty *prop;
                        gchar *calstring_new;
 
-                       subcomp = icalcomponent_get_first_component (icalcomp, ICAL_VEVENT_COMPONENT);
-                       icalprop = icalproperty_new_x (calendar_item_id->change_key);
-                       icalproperty_set_x_name (icalprop, "X-EVOLUTION-CHANGEKEY");
+                       subcomp = i_cal_component_get_first_component (icomp, I_CAL_VEVENT_COMPONENT);
+                       prop = i_cal_property_new_x (calendar_item_id->change_key);
+                       i_cal_property_set_x_name (prop, "X-EVOLUTION-CHANGEKEY");
+                       i_cal_component_take_property (subcomp, prop);
 
                        /* In order to accept items we have to store AssociatedCalendarItemId 
(X-EVOLUTION-ITEMID)
                         * or mail id (X-EVOLUTION-ACCEPT-ID) when we do not have AssociatedCalendarItemId */
-                       icalcomponent_add_property (subcomp, icalprop);
                        if (is_calendar_UID) {
-                               icalprop = icalproperty_new_x (calendar_item_id->id);
-                               icalproperty_set_x_name (icalprop, "X-EVOLUTION-ITEMID");
-                               icalcomponent_add_property (subcomp, icalprop);
+                               prop = i_cal_property_new_x (calendar_item_id->id);
+                               i_cal_property_set_x_name (prop, "X-EVOLUTION-ITEMID");
+                               i_cal_component_take_property (subcomp, prop);
                        }
 
-                       icalprop = icalproperty_new_x (mail_item_id->id);
-                       icalproperty_set_x_name (icalprop, "X-EVOLUTION-ACCEPT-ID");
-                       icalcomponent_add_property (subcomp, icalprop);
+                       prop = i_cal_property_new_x (mail_item_id->id);
+                       i_cal_property_set_x_name (prop, "X-EVOLUTION-ACCEPT-ID");
+                       i_cal_component_take_property (subcomp, prop);
 
-                       calstring_new = icalcomponent_as_ical_string_r (icalcomp);
+                       calstring_new = i_cal_component_as_ical_string_r (icomp);
                        if (calstring_new) {
                                camel_mime_part_set_content (
                                        mimepart,
@@ -446,7 +445,8 @@ ews_update_mgtrequest_mime_calendar_itemid (const gchar *mime_fname,
                                        "text/calendar");
                                g_free (calstring_new);
                        }
-                       icalcomponent_free (icalcomp);
+                       g_object_unref (subcomp);
+                       g_object_unref (icomp);
                }
                g_object_unref (tmpstream);
 
diff --git a/src/configuration/e-ews-subscribe-foreign-folder.c 
b/src/configuration/e-ews-subscribe-foreign-folder.c
index 33c0b872..44abd807 100644
--- a/src/configuration/e-ews-subscribe-foreign-folder.c
+++ b/src/configuration/e-ews-subscribe-foreign-folder.c
@@ -372,7 +372,7 @@ check_foreign_folder_thread (GObject *with_object,
                        e_ews_cal_utils_prepare_free_busy_request, &fbdata,
                        &free_busy, cancellable, perror);
 
-               g_slist_free_full (free_busy, (GDestroyNotify) icalcomponent_free);
+               g_slist_free_full (free_busy, g_object_unref);
                g_slist_free (fbdata.user_mails);
 
                if (!success) {
diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt
index e33acefb..94dcb0b4 100644
--- a/src/server/CMakeLists.txt
+++ b/src/server/CMakeLists.txt
@@ -59,7 +59,6 @@ target_compile_options(evolution-ews PUBLIC
        ${LIBECAL_CFLAGS}
        ${LIBEDATACAL_CFLAGS}
        ${LIBEDATASERVER_CFLAGS}
-       ${LIBICAL_CFLAGS}
        ${SOUP_CFLAGS}
 )
 
@@ -75,7 +74,6 @@ target_include_directories(evolution-ews PUBLIC
        ${LIBECAL_INCLUDE_DIRS}
        ${LIBEDATACAL_INCLUDE_DIRS}
        ${LIBEDATASERVER_INCLUDE_DIRS}
-       ${LIBICAL_INCLUDE_DIRS}
        ${SOUP_INCLUDE_DIRS}
 )
 
@@ -86,7 +84,6 @@ target_link_libraries(evolution-ews
        ${LIBECAL_LDFLAGS}
        ${LIBEDATACAL_LDFLAGS}
        ${LIBEDATASERVER_LDFLAGS}
-       ${LIBICAL_LDFLAGS}
        ${SOUP_LDFLAGS}
 )
 
diff --git a/src/server/e-ews-calendar-utils.c b/src/server/e-ews-calendar-utils.c
index aac86f9e..2eeb0108 100644
--- a/src/server/e-ews-calendar-utils.c
+++ b/src/server/e-ews-calendar-utils.c
@@ -30,7 +30,7 @@
 
 static void
 e_ews_cal_util_encode_regeneration (EEwsRecurrence *in_recur,
-                                   icalcomponent *out_comp) /* not 'out' as such */
+                                   ICalComponent *out_comp) /* not 'out' as such */
 {
        gchar chr = 0;
 
@@ -88,11 +88,11 @@ e_ews_cal_util_encode_regeneration (EEwsRecurrence *in_recur,
                                end_chr,
                                start_num,
                                end_num);
-                       e_cal_util_set_x_property (out_comp, X_EWS_TASK_REGENERATION, value);
+                       e_cal_util_component_set_x_property (out_comp, X_EWS_TASK_REGENERATION, value);
                        g_free (value);
                }
        } else {
-               e_cal_util_remove_x_property (out_comp, X_EWS_TASK_REGENERATION);
+               e_cal_util_component_remove_x_property (out_comp, X_EWS_TASK_REGENERATION);
        }
 }
 
@@ -137,10 +137,10 @@ e_ews_cal_util_decode_regeneration_info_from_string (const gchar *value,
 }
 
 static void
-e_ews_cal_util_decode_regeneration (icalcomponent *in_comp,
+e_ews_cal_util_decode_regeneration (ICalComponent *in_comp,
                                    EEwsRecurrence *out_recur)
 {
-       const gchar *value;
+       gchar *value;
        gchar recur_type_chr = 0, end_type_chr = 0;
        gint interval = 0;
        gint64 start_num = 0, end_num = 0;
@@ -148,7 +148,7 @@ e_ews_cal_util_decode_regeneration (icalcomponent *in_comp,
        g_return_if_fail (in_comp != NULL);
        g_return_if_fail (out_recur != NULL);
 
-       value = e_cal_util_get_x_property (in_comp, X_EWS_TASK_REGENERATION);
+       value = e_cal_util_component_dup_x_property (in_comp, X_EWS_TASK_REGENERATION);
 
        if (e_ews_cal_util_decode_regeneration_info_from_string (value, &recur_type_chr, &interval, 
&end_type_chr, &start_num, &end_num)) {
                EEwsRecurrenceType recur_type = E_EWS_RECURRENCE_UNKNOWN;
@@ -196,6 +196,8 @@ e_ews_cal_util_decode_regeneration (icalcomponent *in_comp,
        } else if (value && *value) {
                g_warning ("%s: Failed to decode value '%s'", G_STRFUNC, value);
        }
+
+       g_free (value);
 }
 
 static const gchar *
@@ -212,13 +214,13 @@ number_to_weekday (gint num)
 
 static void
 ewscal_add_availability_rrule (ESoapMessage *msg,
-                               icalproperty *prop)
+                               ICalProperty *prop)
 {
-       struct icalrecurrencetype recur = icalproperty_get_rrule (prop);
+       ICalRecurrence *recur = i_cal_property_get_rrule (prop);
        gchar buffer[16];
        gint dayorder;
 
-       dayorder = icalrecurrencetype_day_position (recur.by_day[0]);
+       dayorder = i_cal_recurrence_day_position (i_cal_recurrence_get_by_day (recur, 0));
        dayorder = dayorder % 5;
        if (dayorder < 0)
                dayorder += 5;
@@ -228,10 +230,12 @@ ewscal_add_availability_rrule (ESoapMessage *msg,
        snprintf (buffer, 16, "%d", dayorder);
        e_ews_message_write_string_parameter (msg, "DayOrder", NULL, buffer);
 
-       snprintf (buffer, 16, "%d", recur.by_month[0]);
+       snprintf (buffer, 16, "%d", i_cal_recurrence_get_by_month (recur, 0));
        e_ews_message_write_string_parameter (msg, "Month", NULL, buffer);
 
-       e_ews_message_write_string_parameter (msg, "DayOfWeek", NULL, number_to_weekday 
(icalrecurrencetype_day_day_of_week (recur.by_day[0])));
+       e_ews_message_write_string_parameter (msg, "DayOfWeek", NULL, number_to_weekday 
(i_cal_recurrence_day_day_of_week (i_cal_recurrence_get_by_day (recur, 0))));
+
+       g_clear_object (&recur);
 }
 
 static void
@@ -257,52 +261,56 @@ ewscal_add_availability_default_timechange (ESoapMessage *msg)
 
 static void
 ewscal_add_availability_timechange (ESoapMessage *msg,
-                                    icalcomponent *comp,
+                                    ICalComponent *comp,
                                     gint baseoffs)
 {
        gchar buffer[16];
-       icalproperty *prop;
-       struct icaltimetype dtstart;
+       ICalProperty *prop;
+       ICalTime *dtstart;
        gint utcoffs;
 
        /* Calculate zone Offset from BaseOffset */
-       prop = icalcomponent_get_first_property (comp, ICAL_TZOFFSETTO_PROPERTY);
+       prop = i_cal_component_get_first_property (comp, I_CAL_TZOFFSETTO_PROPERTY);
        if (prop) {
-               utcoffs = -icalproperty_get_tzoffsetto (prop) / 60;
+               utcoffs = -i_cal_property_get_tzoffsetto (prop) / 60;
                utcoffs -= baseoffs;
                snprintf (buffer, 16, "%d", utcoffs);
                e_ews_message_write_string_parameter (msg, "Bias", NULL, buffer);
+               g_object_unref (prop);
        }
 
-       prop = icalcomponent_get_first_property (comp, ICAL_DTSTART_PROPERTY);
+       prop = i_cal_component_get_first_property (comp, I_CAL_DTSTART_PROPERTY);
        if (prop) {
-               dtstart = icalproperty_get_dtstart (prop);
-               snprintf (buffer, 16, "%02d:%02d:%02d", dtstart.hour, dtstart.minute, dtstart.second);
+               dtstart = i_cal_property_get_dtstart (prop);
+               snprintf (buffer, 16, "%02d:%02d:%02d", i_cal_time_get_hour (dtstart), i_cal_time_get_minute 
(dtstart), i_cal_time_get_second (dtstart));
                e_ews_message_write_string_parameter (msg, "Time", NULL, buffer);
+               g_object_unref (dtstart);
+               g_object_unref (prop);
        }
 
-       prop = icalcomponent_get_first_property (comp, ICAL_RRULE_PROPERTY);
-       if (prop)
+       prop = i_cal_component_get_first_property (comp, I_CAL_RRULE_PROPERTY);
+       if (prop) {
                ewscal_add_availability_rrule (msg, prop);
+               g_object_unref (prop);
+       }
 }
 
 static void
 ewscal_set_availability_timezone (ESoapMessage *msg,
-                                  icaltimezone *icaltz)
+                                  ICalTimezone *icaltz)
 {
-       icalcomponent *comp;
-       icalproperty *prop;
-       icalcomponent *xstd, *xdaylight;
+       ICalComponent *comp;
+       ICalComponent *xstd, *xdaylight;
        gint std_utcoffs;
        gchar *offset;
 
        if (!icaltz)
                return;
 
-       comp = icaltimezone_get_component (icaltz);
+       comp = i_cal_timezone_get_component (icaltz);
 
-       xstd = icalcomponent_get_first_component (comp, ICAL_XSTANDARD_COMPONENT);
-       xdaylight = icalcomponent_get_first_component (comp, ICAL_XDAYLIGHT_COMPONENT);
+       xstd = i_cal_component_get_first_component (comp, I_CAL_XSTANDARD_COMPONENT);
+       xdaylight = i_cal_component_get_first_component (comp, I_CAL_XDAYLIGHT_COMPONENT);
 
        /*TimeZone is the root element of GetUserAvailabilityRequest*/
        e_soap_message_start_element (msg, "TimeZone", NULL, NULL);
@@ -310,8 +318,15 @@ ewscal_set_availability_timezone (ESoapMessage *msg,
        /* Fetch the timezone offsets for the standard (or only) zone.
         * Negate it, because Exchange does it backwards */
        if (xstd) {
-               prop = icalcomponent_get_first_property (xstd, ICAL_TZOFFSETTO_PROPERTY);
-               std_utcoffs = -icalproperty_get_tzoffsetto (prop) / 60;
+               ICalProperty *prop;
+
+               prop = i_cal_component_get_first_property (xstd, I_CAL_TZOFFSETTO_PROPERTY);
+               if (prop) {
+                       std_utcoffs = -i_cal_property_get_tzoffsetto (prop) / 60;
+                       g_object_unref (prop);
+               } else {
+                       std_utcoffs = 0;
+               }
        } else
                std_utcoffs = 0;
 
@@ -338,6 +353,10 @@ ewscal_set_availability_timezone (ESoapMessage *msg,
                ewscal_add_availability_default_timechange (msg);
 
        e_soap_message_end_element (msg); /* "TimeZone" */
+
+       g_clear_object (&comp);
+       g_clear_object (&xstd);
+       g_clear_object (&xdaylight);
 }
 
 gboolean
@@ -346,8 +365,8 @@ e_ews_cal_utils_prepare_free_busy_request (ESoapMessage *msg,
                                           GError **error)
 {
        const EEWSFreeBusyData *fbdata = user_data;
-       icaltimetype t_start, t_end;
-       icaltimezone *utc_zone = icaltimezone_get_utc_timezone ();
+       ICalTime *t_start, *t_end;
+       ICalTimezone *utc_zone = i_cal_timezone_get_utc_timezone ();
        GSList *link;
 
        g_return_val_if_fail (fbdata != NULL, FALSE);
@@ -375,13 +394,17 @@ e_ews_cal_utils_prepare_free_busy_request (ESoapMessage *msg,
 
        e_soap_message_start_element (msg, "FreeBusyViewOptions", NULL, NULL);
 
+       t_start = i_cal_time_from_timet_with_zone (fbdata->period_start, 0, utc_zone);
+       t_end = i_cal_time_from_timet_with_zone (fbdata->period_end, 0, utc_zone);
+
        e_soap_message_start_element (msg, "TimeWindow", NULL, NULL);
-       t_start = icaltime_from_timet_with_zone (fbdata->period_start, 0, utc_zone);
-       t_end = icaltime_from_timet_with_zone (fbdata->period_end, 0, utc_zone);
-       e_ews_cal_utils_set_time (msg, "StartTime", &t_start, FALSE);
-       e_ews_cal_utils_set_time (msg, "EndTime", &t_end, FALSE);
+       e_ews_cal_utils_set_time (msg, "StartTime", t_start, FALSE);
+       e_ews_cal_utils_set_time (msg, "EndTime", t_end, FALSE);
        e_soap_message_end_element (msg); /* "TimeWindow" */
 
+       g_clear_object (&t_start);
+       g_clear_object (&t_end);
+
        e_ews_message_write_string_parameter (msg, "MergedFreeBusyIntervalInMinutes", NULL, "60");
        e_ews_message_write_string_parameter (msg, "RequestedView", NULL, "DetailedMerged");
 
@@ -393,23 +416,25 @@ e_ews_cal_utils_prepare_free_busy_request (ESoapMessage *msg,
 void
 e_ews_cal_utils_set_time (ESoapMessage *msg,
                          const gchar *name,
-                         icaltimetype *tt,
+                         ICalTime *tt,
                          gboolean with_timezone)
 {
-       struct icaltimetype local_tt;
+       ICalTime *local_tt = NULL;
        gchar *str;
        gchar *tz_ident = NULL;
 
        g_return_if_fail (tt != NULL);
 
        if (with_timezone) {
-               if (icaltime_is_utc (*tt) || !tt->zone || tt->zone == icaltimezone_get_utc_timezone () || 
tt->is_date) {
+               ICalTimezone *zone = i_cal_time_get_timezone (tt);
+
+               if (i_cal_time_is_utc (tt) || i_cal_time_is_date (tt) || !zone || zone == 
i_cal_timezone_get_utc_timezone ()) {
                        tz_ident = g_strdup ("Z");
                } else {
                        gint offset, is_daylight, hrs, mins;
 
-                       offset = icaltimezone_get_utc_offset (
-                               icaltimezone_get_utc_timezone (), tt, &is_daylight);
+                       offset = i_cal_timezone_get_utc_offset (
+                               i_cal_timezone_get_utc_timezone (), tt, &is_daylight);
 
                        offset = offset * (-1);
                        hrs = offset / 60;
@@ -424,34 +449,45 @@ e_ews_cal_utils_set_time (ESoapMessage *msg,
                }
        }
 
-       if (tt->is_date) {
-               local_tt = *tt;
-               local_tt.zone = calendar_config_get_icaltimezone ();
-               local_tt = icaltime_from_timet_with_zone (icaltime_as_timet_with_zone (local_tt, 
local_tt.zone), FALSE, icaltimezone_get_utc_timezone ());
-               tt = &local_tt;
+       if (i_cal_time_is_date (tt)) {
+               ICalTimezone *cfg_zone;
+
+               cfg_zone = calendar_config_get_icaltimezone ();
+               local_tt = i_cal_time_from_timet_with_zone (i_cal_time_as_timet_with_zone (tt, cfg_zone), 
FALSE, i_cal_timezone_get_utc_timezone ());
+               tt = local_tt;
        }
 
        str = g_strdup_printf (
                "%04d-%02d-%02dT%02d:%02d:%02d%s",
-               tt->year, tt->month, tt->day,
-               tt->hour, tt->minute, tt->second,
+               i_cal_time_get_year (tt),
+               i_cal_time_get_month (tt),
+               i_cal_time_get_day (tt),
+               i_cal_time_get_hour (tt),
+               i_cal_time_get_minute (tt),
+               i_cal_time_get_second (tt),
                tz_ident ? tz_ident : "");
 
        e_ews_message_write_string_parameter (msg, name, NULL, str);
 
+       g_clear_object (&local_tt);
        g_free (tz_ident);
        g_free (str);
 }
 
 static gint
-e_ews_cal_util_recurrence_count_by_xxx (gshort *field,
-                                       gint max_elements)
+e_ews_cal_util_recurrence_count_by_xxx_and_free (GArray *array)
 {
-       gint ii;
+       guint ii;
 
-       for (ii = 0; ii < max_elements; ii++)
-               if (field[ii] == ICAL_RECURRENCE_ARRAY_MAX)
+       if (!array)
+               return 0;
+
+       for (ii = 0; ii < array->len; ii++) {
+               if (g_array_index (array, gshort, ii) == I_CAL_RECURRENCE_ARRAY_MAX)
                        break;
+       }
+
+       g_array_unref (array);
 
        return ii;
 }
@@ -528,76 +564,72 @@ e_ews_cal_util_month_num_to_day_of_week_index (gint month_num)
 }
 
 static gboolean
-e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
+e_ews_cal_utils_convert_recurrence (ICalComponent *icomp,
                                    EEwsRecurrence *out_recur,
                                    GError **error)
 {
-       icalproperty *prop;
-       struct icalrecurrencetype rrule;
+       ICalProperty *prop;
+       ICalRecurrence *rrule = NULL;
        gint n_by_second, n_by_minute, n_by_hour;
        gint n_by_day, n_by_month_day, n_by_year_day;
        gint n_by_week_no, n_by_month, n_by_set_pos;
 
-       g_return_val_if_fail (icalcomp != NULL, FALSE);
+       g_return_val_if_fail (icomp != NULL, FALSE);
        g_return_val_if_fail (out_recur != NULL, FALSE);
 
-       prop = icalcomponent_get_first_property (icalcomp, ICAL_RRULE_PROPERTY);
+       prop = i_cal_component_get_first_property (icomp, I_CAL_RRULE_PROPERTY);
        if (!prop) {
-               e_ews_cal_util_decode_regeneration (icalcomp, out_recur);
+               e_ews_cal_util_decode_regeneration (icomp, out_recur);
                return TRUE;
        }
 
-       switch (icalcomponent_isa (icalcomp)) {
-       case ICAL_VEVENT_COMPONENT:
-       case ICAL_VTODO_COMPONENT:
-       case ICAL_VJOURNAL_COMPONENT:
+       switch (i_cal_component_isa (icomp)) {
+       case I_CAL_VEVENT_COMPONENT:
+       case I_CAL_VTODO_COMPONENT:
+       case I_CAL_VJOURNAL_COMPONENT:
                break;
        default:
+               g_object_unref (prop);
                return TRUE;
        }
 
        out_recur->type = E_EWS_RECURRENCE_UNKNOWN;
        out_recur->end_type = E_EWS_RECURRENCE_END_UNKNOWN;
 
-       if (icalcomponent_count_properties (icalcomp, ICAL_RRULE_PROPERTY) != 1 ||
-           icalcomponent_count_properties (icalcomp, ICAL_RDATE_PROPERTY) != 0 ||
-           icalcomponent_count_properties (icalcomp, ICAL_EXRULE_PROPERTY) != 0)
+       if (i_cal_component_count_properties (icomp, I_CAL_RRULE_PROPERTY) != 1 ||
+           i_cal_component_count_properties (icomp, I_CAL_RDATE_PROPERTY) != 0 ||
+           i_cal_component_count_properties (icomp, I_CAL_EXRULE_PROPERTY) != 0)
                goto custom;
 
-       rrule = icalproperty_get_rrule (prop);
+       rrule = i_cal_property_get_rrule (prop);
 
-       switch (rrule.freq) {
-       case ICAL_DAILY_RECURRENCE:
-       case ICAL_WEEKLY_RECURRENCE:
-       case ICAL_MONTHLY_RECURRENCE:
-       case ICAL_YEARLY_RECURRENCE:
+       switch (i_cal_recurrence_get_freq (rrule)) {
+       case I_CAL_DAILY_RECURRENCE:
+       case I_CAL_WEEKLY_RECURRENCE:
+       case I_CAL_MONTHLY_RECURRENCE:
+       case I_CAL_YEARLY_RECURRENCE:
                break;
        default:
                goto custom;
-
        }
 
-#define N_HAS_BY(field) (e_ews_cal_util_recurrence_count_by_xxx (field, G_N_ELEMENTS (field)))
-
-       n_by_second = N_HAS_BY (rrule.by_second);
-       n_by_minute = N_HAS_BY (rrule.by_minute);
-       n_by_hour = N_HAS_BY (rrule.by_hour);
-       n_by_day = N_HAS_BY (rrule.by_day);
-       n_by_month_day = N_HAS_BY (rrule.by_month_day);
-       n_by_year_day = N_HAS_BY (rrule.by_year_day);
-       n_by_week_no = N_HAS_BY (rrule.by_week_no);
-       n_by_month = N_HAS_BY (rrule.by_month);
-       n_by_set_pos = N_HAS_BY (rrule.by_set_pos);
-
-#undef N_HAS_BY
+       n_by_second = e_ews_cal_util_recurrence_count_by_xxx_and_free (i_cal_recurrence_get_by_second_array 
(rrule));
+       n_by_minute = e_ews_cal_util_recurrence_count_by_xxx_and_free (i_cal_recurrence_get_by_minute_array 
(rrule));
+       n_by_hour = e_ews_cal_util_recurrence_count_by_xxx_and_free (i_cal_recurrence_get_by_hour_array 
(rrule));
+       n_by_day = e_ews_cal_util_recurrence_count_by_xxx_and_free (i_cal_recurrence_get_by_day_array 
(rrule));
+       n_by_month_day = e_ews_cal_util_recurrence_count_by_xxx_and_free 
(i_cal_recurrence_get_by_month_day_array (rrule));
+       n_by_year_day = e_ews_cal_util_recurrence_count_by_xxx_and_free 
(i_cal_recurrence_get_by_year_day_array (rrule));
+       n_by_week_no = e_ews_cal_util_recurrence_count_by_xxx_and_free (i_cal_recurrence_get_by_week_no_array 
(rrule));
+       n_by_month = e_ews_cal_util_recurrence_count_by_xxx_and_free (i_cal_recurrence_get_by_month_array 
(rrule));
+       n_by_set_pos = e_ews_cal_util_recurrence_count_by_xxx_and_free (i_cal_recurrence_get_by_set_pos_array 
(rrule));
 
        if (n_by_second != 0 ||
            n_by_minute != 0 ||
            n_by_hour != 0)
                goto custom;
 
-       switch (rrule.freq) {
-       case ICAL_DAILY_RECURRENCE:
+       switch (i_cal_recurrence_get_freq (rrule)) {
+       case I_CAL_DAILY_RECURRENCE:
                if (n_by_day != 0 ||
                    n_by_month_day != 0 ||
                    n_by_year_day != 0 ||
@@ -606,13 +638,13 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
                    n_by_set_pos != 0)
                        goto custom;
 
-               if (rrule.interval > 0) {
+               if (i_cal_recurrence_get_interval (rrule) > 0) {
                        out_recur->type = E_EWS_RECURRENCE_DAILY;
-                       out_recur->recur.interval = rrule.interval;
+                       out_recur->recur.interval = i_cal_recurrence_get_interval (rrule);
                }
                break;
 
-       case ICAL_WEEKLY_RECURRENCE: {
+       case I_CAL_WEEKLY_RECURRENCE: {
                gint ii, ndays;
                guint8 day_mask;
 
@@ -625,42 +657,42 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
 
                day_mask = 0;
 
-               for (ii = 0; ii < 8 && rrule.by_day[ii] != ICAL_RECURRENCE_ARRAY_MAX; ii++) {
-                       enum icalrecurrencetype_weekday weekday;
+               for (ii = 0; ii < 8 && i_cal_recurrence_get_by_day (rrule, ii) != I_CAL_RECURRENCE_ARRAY_MAX; 
ii++) {
+                       ICalRecurrenceWeekday weekday;
                        gint pos;
 
-                       weekday = icalrecurrencetype_day_day_of_week (rrule.by_day[ii]);
-                       pos = icalrecurrencetype_day_position (rrule.by_day[ii]);
+                       weekday = i_cal_recurrence_day_day_of_week (i_cal_recurrence_get_by_day (rrule, ii));
+                       pos = i_cal_recurrence_day_position (i_cal_recurrence_get_by_day (rrule, ii));
 
                        if (pos != 0)
                                goto custom;
 
                        switch (weekday) {
-                       case ICAL_SUNDAY_WEEKDAY:
+                       case I_CAL_SUNDAY_WEEKDAY:
                                day_mask |= 1 << 0;
                                break;
 
-                       case ICAL_MONDAY_WEEKDAY:
+                       case I_CAL_MONDAY_WEEKDAY:
                                day_mask |= 1 << 1;
                                break;
 
-                       case ICAL_TUESDAY_WEEKDAY:
+                       case I_CAL_TUESDAY_WEEKDAY:
                                day_mask |= 1 << 2;
                                break;
 
-                       case ICAL_WEDNESDAY_WEEKDAY:
+                       case I_CAL_WEDNESDAY_WEEKDAY:
                                day_mask |= 1 << 3;
                                break;
 
-                       case ICAL_THURSDAY_WEEKDAY:
+                       case I_CAL_THURSDAY_WEEKDAY:
                                day_mask |= 1 << 4;
                                break;
 
-                       case ICAL_FRIDAY_WEEKDAY:
+                       case I_CAL_FRIDAY_WEEKDAY:
                                day_mask |= 1 << 5;
                                break;
 
-                       case ICAL_SATURDAY_WEEKDAY:
+                       case I_CAL_SATURDAY_WEEKDAY:
                                day_mask |= 1 << 6;
                                break;
 
@@ -670,13 +702,14 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
                }
 
                if (ii == 0) {
-                       struct icaltimetype dtstart;
+                       ICalTime *dtstart;
 
-                       dtstart = icalcomponent_get_dtstart (icalcomp);
+                       dtstart = i_cal_component_get_dtstart (icomp);
 
-                       ii = icaltime_day_of_week (dtstart);
+                       ii = dtstart ? i_cal_time_day_of_week (dtstart) : 0;
                        if (ii >= 1)
                                day_mask |= 1 << (ii - 1);
+                       g_clear_object (&dtstart);
                }
 
                ndays = 0;
@@ -687,7 +720,7 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
                }
 
                out_recur->type = E_EWS_RECURRENCE_WEEKLY;
-               out_recur->recur.weekly.interval = rrule.interval;
+               out_recur->recur.weekly.interval = i_cal_recurrence_get_interval (rrule);
                out_recur->recur.weekly.days_of_week = 0;
                out_recur->recur.weekly.first_day_of_week = G_DATE_BAD_WEEKDAY;
 
@@ -724,7 +757,7 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
                break;
        }
 
-       case ICAL_MONTHLY_RECURRENCE: {
+       case I_CAL_MONTHLY_RECURRENCE: {
                gint month_index = 1;
                enum month_day_options month_day;
                enum month_num_options month_num;
@@ -741,17 +774,19 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
                        if (n_by_set_pos != 0)
                                goto custom;
 
-                       nth = rrule.by_month_day[0];
+                       nth = i_cal_recurrence_get_by_month_day (rrule, 0);
                        if (nth < 1 && nth != -1)
                                goto custom;
 
                        if (nth == -1) {
-                               struct icaltimetype dtstart;
+                               ICalTime *dtstart;
 
-                               dtstart = icalcomponent_get_dtstart (icalcomp);
+                               dtstart = i_cal_component_get_dtstart (icomp);
 
-                               month_index = dtstart.day;
+                               month_index = dtstart ? i_cal_time_get_day (dtstart) : 0;
                                month_num = MONTH_NUM_LAST;
+
+                               g_clear_object (&dtstart);
                        } else {
                                month_index = nth;
                                month_num = MONTH_NUM_DAY;
@@ -759,46 +794,46 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
                        month_day = MONTH_DAY_NTH;
 
                } else if (n_by_day == 1) {
-                       enum icalrecurrencetype_weekday weekday;
+                       ICalRecurrenceWeekday weekday;
                        gint pos;
 
-                       weekday = icalrecurrencetype_day_day_of_week (rrule.by_day[0]);
-                       pos = icalrecurrencetype_day_position (rrule.by_day[0]);
+                       weekday = i_cal_recurrence_day_day_of_week (i_cal_recurrence_get_by_day (rrule, 0));
+                       pos = i_cal_recurrence_day_position (i_cal_recurrence_get_by_day (rrule, 0));
 
                        if (pos == 0) {
                                if (n_by_set_pos != 1)
                                        goto custom;
-                               pos = rrule.by_set_pos[0];
+                               pos = i_cal_recurrence_get_by_set_pos (rrule, 0);
                        } else if (pos < 0) {
                                goto custom;
                        }
 
                        switch (weekday) {
-                       case ICAL_MONDAY_WEEKDAY:
+                       case I_CAL_MONDAY_WEEKDAY:
                                month_day = MONTH_DAY_MON;
                                break;
 
-                       case ICAL_TUESDAY_WEEKDAY:
+                       case I_CAL_TUESDAY_WEEKDAY:
                                month_day = MONTH_DAY_TUE;
                                break;
 
-                       case ICAL_WEDNESDAY_WEEKDAY:
+                       case I_CAL_WEDNESDAY_WEEKDAY:
                                month_day = MONTH_DAY_WED;
                                break;
 
-                       case ICAL_THURSDAY_WEEKDAY:
+                       case I_CAL_THURSDAY_WEEKDAY:
                                month_day = MONTH_DAY_THU;
                                break;
 
-                       case ICAL_FRIDAY_WEEKDAY:
+                       case I_CAL_FRIDAY_WEEKDAY:
                                month_day = MONTH_DAY_FRI;
                                break;
 
-                       case ICAL_SATURDAY_WEEKDAY:
+                       case I_CAL_SATURDAY_WEEKDAY:
                                month_day = MONTH_DAY_SAT;
                                break;
 
-                       case ICAL_SUNDAY_WEEKDAY:
+                       case I_CAL_SUNDAY_WEEKDAY:
                                month_day = MONTH_DAY_SUN;
                                break;
 
@@ -813,46 +848,46 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
                } else if (n_by_day > 1 && n_by_set_pos == 1 && n_by_month_day == 0) {
                        gint ii, pos;
 
-                       pos = rrule.by_set_pos[0];
+                       pos = i_cal_recurrence_get_by_set_pos (rrule, 0);
                        if (pos == -1)
                                month_num = MONTH_NUM_LAST;
                        else
                                month_num = pos - 1;
 
                        out_recur->type = E_EWS_RECURRENCE_RELATIVE_MONTHLY;
-                       out_recur->recur.relative_monthly.interval = rrule.interval;
+                       out_recur->recur.relative_monthly.interval = i_cal_recurrence_get_interval (rrule);
                        out_recur->recur.relative_monthly.days_of_week = 0;
                        out_recur->recur.relative_monthly.day_of_week_index = 
e_ews_cal_util_month_num_to_day_of_week_index (month_num);
 
-                       for (ii = 0; rrule.by_day[ii] != ICAL_RECURRENCE_ARRAY_MAX; ii++) {
-                               enum icalrecurrencetype_weekday weekday;
+                       for (ii = 0; i_cal_recurrence_get_by_day (rrule, ii) != I_CAL_RECURRENCE_ARRAY_MAX; 
ii++) {
+                               ICalRecurrenceWeekday weekday;
 
-                               weekday = icalrecurrencetype_day_day_of_week (rrule.by_day[ii]);
-                               pos = icalrecurrencetype_day_position (rrule.by_day[ii]);
+                               weekday = i_cal_recurrence_day_day_of_week (i_cal_recurrence_get_by_day 
(rrule, ii));
+                               pos = i_cal_recurrence_day_position (i_cal_recurrence_get_by_day (rrule, ii));
 
                                if (pos != 0)
                                        goto custom;
 
                                switch (weekday) {
-                               case ICAL_SUNDAY_WEEKDAY:
+                               case I_CAL_SUNDAY_WEEKDAY:
                                        out_recur->recur.relative_monthly.days_of_week |= 
E_EWS_RECURRENCE_DAYS_OF_WEEK_SUNDAY;
                                        break;
-                               case ICAL_MONDAY_WEEKDAY:
+                               case I_CAL_MONDAY_WEEKDAY:
                                        out_recur->recur.relative_monthly.days_of_week |= 
E_EWS_RECURRENCE_DAYS_OF_WEEK_MONDAY;
                                        break;
-                               case ICAL_TUESDAY_WEEKDAY:
+                               case I_CAL_TUESDAY_WEEKDAY:
                                        out_recur->recur.relative_monthly.days_of_week |= 
E_EWS_RECURRENCE_DAYS_OF_WEEK_TUESDAY;
                                        break;
-                               case ICAL_WEDNESDAY_WEEKDAY:
+                               case I_CAL_WEDNESDAY_WEEKDAY:
                                        out_recur->recur.relative_monthly.days_of_week |= 
E_EWS_RECURRENCE_DAYS_OF_WEEK_WEDNESDAY;
                                        break;
-                               case ICAL_THURSDAY_WEEKDAY:
+                               case I_CAL_THURSDAY_WEEKDAY:
                                        out_recur->recur.relative_monthly.days_of_week |= 
E_EWS_RECURRENCE_DAYS_OF_WEEK_THURSDAY;
                                        break;
-                               case ICAL_FRIDAY_WEEKDAY:
+                               case I_CAL_FRIDAY_WEEKDAY:
                                        out_recur->recur.relative_monthly.days_of_week |= 
E_EWS_RECURRENCE_DAYS_OF_WEEK_FRIDAY;
                                        break;
-                               case ICAL_SATURDAY_WEEKDAY:
+                               case I_CAL_SATURDAY_WEEKDAY:
                                        out_recur->recur.relative_monthly.days_of_week |= 
E_EWS_RECURRENCE_DAYS_OF_WEEK_SATURDAY;
                                        break;
                                default:
@@ -866,7 +901,7 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
                }
 
                out_recur->type = E_EWS_RECURRENCE_RELATIVE_MONTHLY;
-               out_recur->recur.relative_monthly.interval = rrule.interval;
+               out_recur->recur.relative_monthly.interval = i_cal_recurrence_get_interval (rrule);
                out_recur->recur.relative_monthly.days_of_week = E_EWS_RECURRENCE_DAYS_OF_WEEK_UNKNOWN;
                out_recur->recur.relative_monthly.day_of_week_index = 
E_EWS_RECURRENCE_DAY_OF_WEEK_INDEX_UNKNOWN;
 
@@ -877,7 +912,7 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
                                out_recur->recur.relative_monthly.day_of_week_index = 
E_EWS_RECURRENCE_DAY_OF_WEEK_INDEX_LAST;
                        } else { /* month_num = MONTH_NUM_DAY; */
                                out_recur->type = E_EWS_RECURRENCE_ABSOLUTE_MONTHLY;
-                               out_recur->recur.absolute_monthly.interval = rrule.interval;
+                               out_recur->recur.absolute_monthly.interval = i_cal_recurrence_get_interval 
(rrule);
                                out_recur->recur.absolute_monthly.day_of_month = month_index;
                        }
                        break;
@@ -914,7 +949,7 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
                break;
        }
 
-       case ICAL_YEARLY_RECURRENCE: {
+       case I_CAL_YEARLY_RECURRENCE: {
                gint month_index = 1;
                enum month_day_options month_day = MONTH_DAY_NTH;
                enum month_num_options month_num = MONTH_NUM_DAY;
@@ -922,7 +957,7 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
                if (n_by_year_day != 0 ||
                    n_by_week_no != 0 ||
                    n_by_set_pos > 1 ||
-                   rrule.interval > 1)
+                   i_cal_recurrence_get_interval (rrule) > 1)
                        goto custom;
 
                if (n_by_month_day == 1) {
@@ -931,17 +966,19 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
                        if (n_by_set_pos != 0)
                                goto custom;
 
-                       nth = rrule.by_month_day[0];
+                       nth = i_cal_recurrence_get_by_month_day (rrule, 0);
                        if (nth < 1 && nth != -1)
                                goto custom;
 
                        if (nth == -1) {
-                               struct icaltimetype dtstart;
+                               ICalTime *dtstart;
 
-                               dtstart = icalcomponent_get_dtstart (icalcomp);
+                               dtstart = i_cal_component_get_dtstart (icomp);
 
-                               month_index = dtstart.day;
+                               month_index = dtstart ? i_cal_time_get_day (dtstart) : 0;
                                month_num = MONTH_NUM_LAST;
+
+                               g_clear_object (&dtstart);
                        } else {
                                month_index = nth;
                                month_num = MONTH_NUM_DAY;
@@ -950,46 +987,46 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
                }
 
                if (n_by_day == 1) {
-                       enum icalrecurrencetype_weekday weekday;
+                       ICalRecurrenceWeekday weekday;
                        gint pos;
 
-                       weekday = icalrecurrencetype_day_day_of_week (rrule.by_day[0]);
-                       pos = icalrecurrencetype_day_position (rrule.by_day[0]);
+                       weekday = i_cal_recurrence_day_day_of_week (i_cal_recurrence_get_by_day (rrule, 0));
+                       pos = i_cal_recurrence_day_position (i_cal_recurrence_get_by_day (rrule, 0));
 
                        if (pos == 0) {
                                if (n_by_set_pos != 1)
                                        goto custom;
-                               pos = rrule.by_set_pos[0];
+                               pos = i_cal_recurrence_get_by_set_pos (rrule, 0);
                        } else if (pos < 0) {
                                goto custom;
                        }
 
                        switch (weekday) {
-                       case ICAL_MONDAY_WEEKDAY:
+                       case I_CAL_MONDAY_WEEKDAY:
                                month_day = MONTH_DAY_MON;
                                break;
 
-                       case ICAL_TUESDAY_WEEKDAY:
+                       case I_CAL_TUESDAY_WEEKDAY:
                                month_day = MONTH_DAY_TUE;
                                break;
 
-                       case ICAL_WEDNESDAY_WEEKDAY:
+                       case I_CAL_WEDNESDAY_WEEKDAY:
                                month_day = MONTH_DAY_WED;
                                break;
 
-                       case ICAL_THURSDAY_WEEKDAY:
+                       case I_CAL_THURSDAY_WEEKDAY:
                                month_day = MONTH_DAY_THU;
                                break;
 
-                       case ICAL_FRIDAY_WEEKDAY:
+                       case I_CAL_FRIDAY_WEEKDAY:
                                month_day = MONTH_DAY_FRI;
                                break;
 
-                       case ICAL_SATURDAY_WEEKDAY:
+                       case I_CAL_SATURDAY_WEEKDAY:
                                month_day = MONTH_DAY_SAT;
                                break;
 
-                       case ICAL_SUNDAY_WEEKDAY:
+                       case I_CAL_SUNDAY_WEEKDAY:
                                month_day = MONTH_DAY_SUN;
                                break;
 
@@ -1006,7 +1043,7 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
                out_recur->type = E_EWS_RECURRENCE_RELATIVE_YEARLY;
                out_recur->recur.relative_yearly.days_of_week = E_EWS_RECURRENCE_DAYS_OF_WEEK_UNKNOWN;
                out_recur->recur.relative_yearly.day_of_week_index = 
E_EWS_RECURRENCE_DAY_OF_WEEK_INDEX_UNKNOWN;
-               out_recur->recur.relative_yearly.month = rrule.by_month[0];
+               out_recur->recur.relative_yearly.month = i_cal_recurrence_get_by_month (rrule, 0);
 
                if (n_by_day > 1 &&
                    n_by_month == 1 &&
@@ -1014,7 +1051,7 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
                    n_by_month_day == 0) {
                        gint ii, pos;
 
-                       pos = rrule.by_set_pos[0];
+                       pos = i_cal_recurrence_get_by_set_pos (rrule, 0);
                        if (pos == -1)
                                month_num = MONTH_NUM_LAST;
                        else
@@ -1022,35 +1059,35 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
 
                        out_recur->recur.relative_yearly.day_of_week_index = 
e_ews_cal_util_month_num_to_day_of_week_index (month_num);
 
-                       for (ii = 0; rrule.by_day[ii] != ICAL_RECURRENCE_ARRAY_MAX; ii++) {
-                               enum icalrecurrencetype_weekday weekday;
+                       for (ii = 0; i_cal_recurrence_get_by_day (rrule, ii) != I_CAL_RECURRENCE_ARRAY_MAX; 
ii++) {
+                               ICalRecurrenceWeekday weekday;
 
-                               weekday = icalrecurrencetype_day_day_of_week (rrule.by_day[ii]);
-                               pos = icalrecurrencetype_day_position (rrule.by_day[ii]);
+                               weekday = i_cal_recurrence_day_day_of_week (i_cal_recurrence_get_by_day 
(rrule, ii));
+                               pos = i_cal_recurrence_day_position (i_cal_recurrence_get_by_day (rrule, ii));
 
                                if (pos != 0)
                                        goto custom;
 
                                switch (weekday) {
-                               case ICAL_SUNDAY_WEEKDAY:
+                               case I_CAL_SUNDAY_WEEKDAY:
                                        out_recur->recur.relative_yearly.days_of_week |= 
E_EWS_RECURRENCE_DAYS_OF_WEEK_SUNDAY;
                                        break;
-                               case ICAL_MONDAY_WEEKDAY:
+                               case I_CAL_MONDAY_WEEKDAY:
                                        out_recur->recur.relative_yearly.days_of_week |= 
E_EWS_RECURRENCE_DAYS_OF_WEEK_MONDAY;
                                        break;
-                               case ICAL_TUESDAY_WEEKDAY:
+                               case I_CAL_TUESDAY_WEEKDAY:
                                        out_recur->recur.relative_yearly.days_of_week |= 
E_EWS_RECURRENCE_DAYS_OF_WEEK_TUESDAY;
                                        break;
-                               case ICAL_WEDNESDAY_WEEKDAY:
+                               case I_CAL_WEDNESDAY_WEEKDAY:
                                        out_recur->recur.relative_yearly.days_of_week |= 
E_EWS_RECURRENCE_DAYS_OF_WEEK_WEDNESDAY;
                                        break;
-                               case ICAL_THURSDAY_WEEKDAY:
+                               case I_CAL_THURSDAY_WEEKDAY:
                                        out_recur->recur.relative_yearly.days_of_week |= 
E_EWS_RECURRENCE_DAYS_OF_WEEK_THURSDAY;
                                        break;
-                               case ICAL_FRIDAY_WEEKDAY:
+                               case I_CAL_FRIDAY_WEEKDAY:
                                        out_recur->recur.relative_yearly.days_of_week |= 
E_EWS_RECURRENCE_DAYS_OF_WEEK_FRIDAY;
                                        break;
-                               case ICAL_SATURDAY_WEEKDAY:
+                               case I_CAL_SATURDAY_WEEKDAY:
                                        out_recur->recur.relative_yearly.days_of_week |= 
E_EWS_RECURRENCE_DAYS_OF_WEEK_SATURDAY;
                                        break;
                                default:
@@ -1068,7 +1105,7 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
                                } else { /* month_num = MONTH_NUM_DAY; */
                                        out_recur->type = E_EWS_RECURRENCE_ABSOLUTE_YEARLY;
                                        out_recur->recur.absolute_yearly.day_of_month = month_index;
-                                       out_recur->recur.absolute_yearly.month = rrule.by_month[0];
+                                       out_recur->recur.absolute_yearly.month = 
i_cal_recurrence_get_by_month (rrule, 0);
                                }
                                break;
                        case MONTH_DAY_MON:
@@ -1109,20 +1146,24 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
                        } else { /* month_num = MONTH_NUM_DAY; */
                                out_recur->type = E_EWS_RECURRENCE_ABSOLUTE_YEARLY;
                                out_recur->recur.absolute_yearly.day_of_month = month_index;
-                               out_recur->recur.absolute_yearly.month = rrule.by_month[0];
+                               out_recur->recur.absolute_yearly.month = i_cal_recurrence_get_by_month 
(rrule, 0);
                        }
                } else if (n_by_day == 0 &&
                           n_by_month_day == 0 &&
                           n_by_month == 0) {
-                       struct icaltimetype dtstart;
+                       ICalTime *dtstart;
 
-                       dtstart = icalcomponent_get_dtstart (icalcomp);
-                       if (icaltime_is_null_time (dtstart))
+                       dtstart = i_cal_component_get_dtstart (icomp);
+                       if (!dtstart || i_cal_time_is_null_time (dtstart)) {
+                               g_clear_object (&dtstart);
                                goto custom;
+                       }
 
                        out_recur->type = E_EWS_RECURRENCE_ABSOLUTE_YEARLY;
-                       out_recur->recur.absolute_yearly.day_of_month = dtstart.day;
-                       out_recur->recur.absolute_yearly.month = dtstart.month;
+                       out_recur->recur.absolute_yearly.day_of_month = i_cal_time_get_day (dtstart);
+                       out_recur->recur.absolute_yearly.month = i_cal_time_get_month (dtstart);
+
+                       g_object_unref (dtstart);
                } else {
                        goto custom;
                }
@@ -1133,29 +1174,43 @@ e_ews_cal_utils_convert_recurrence (icalcomponent *icalcomp,
        }
 
        if (out_recur->type != E_EWS_RECURRENCE_UNKNOWN) {
-               struct icaltimetype dtstart;
+               ICalTime *dtstart;
 
-               dtstart = icalcomponent_get_dtstart (icalcomp);
+               dtstart = i_cal_component_get_dtstart (icomp);
 
-               out_recur->utc_start_date = icaltime_as_timet_with_zone (dtstart, 
icaltimezone_get_utc_timezone ());
+               out_recur->utc_start_date = i_cal_time_as_timet_with_zone (dtstart, 
i_cal_timezone_get_utc_timezone ());
+               g_clear_object (&dtstart);
 
-               if (rrule.count) {
+               if (i_cal_recurrence_get_count (rrule)) {
                        out_recur->end_type = E_EWS_RECURRENCE_END_NUMBERED;
-                       out_recur->end.number_of_occurrences = rrule.count;
-               } else if (rrule.until.year) {
-                       rrule.until.is_date = 1;
-
-                       out_recur->end_type = E_EWS_RECURRENCE_END_DATE;
-                       out_recur->end.utc_end_date = icaltime_as_timet_with_zone (rrule.until, 
icaltimezone_get_utc_timezone ());
+                       out_recur->end.number_of_occurrences = i_cal_recurrence_get_count (rrule);
                } else {
-                       out_recur->end_type = E_EWS_RECURRENCE_END_NO_END;
+                       ICalTime *until;
+
+                       until = i_cal_recurrence_get_until (rrule);
+                       if (until && !i_cal_time_is_null_time (until) && i_cal_time_get_year (until)) {
+                               i_cal_time_set_is_date (until, TRUE);
+
+                               out_recur->end_type = E_EWS_RECURRENCE_END_DATE;
+                               out_recur->end.utc_end_date = i_cal_time_as_timet_with_zone (until, 
i_cal_timezone_get_utc_timezone ());
+                       } else {
+                               out_recur->end_type = E_EWS_RECURRENCE_END_NO_END;
+                       }
+
+                       g_clear_object (&until);
                }
        }
 
+       g_clear_object (&rrule);
+       g_clear_object (&prop);
+
        return TRUE;
 
  custom:
 
+       g_clear_object (&rrule);
+       g_clear_object (&prop);
+
        g_set_error (error, EWS_CONNECTION_ERROR, EWS_CONNECTION_ERROR_CALENDARINVALIDRECURRENCE,
                _("Cannot store this recurrence. Change it to simple single daily, weekly, monthly or yearly 
recurrence without exceptions and with start date."));
 
@@ -1328,14 +1383,18 @@ e_ews_cal_util_write_utc_date (ESoapMessage *msg,
                               const gchar *name,
                               time_t utc_date)
 {
-       struct icaltimetype itt;
+       ICalTime *itt;
        gchar *value;
 
        g_return_if_fail (E_IS_SOAP_MESSAGE (msg));
        g_return_if_fail (name != NULL);
 
-       itt = icaltime_from_timet_with_zone (utc_date, 1, icaltimezone_get_utc_timezone ());
-       value = g_strdup_printf ("%04d-%02d-%02dZ", itt.year, itt.month, itt.day);
+       itt = i_cal_time_from_timet_with_zone (utc_date, 1, i_cal_timezone_get_utc_timezone ());
+       value = g_strdup_printf ("%04d-%02d-%02dZ",
+               i_cal_time_get_year (itt),
+               i_cal_time_get_month (itt),
+               i_cal_time_get_day (itt));
+       g_clear_object (&itt);
 
        e_soap_message_start_element (msg, name, NULL, NULL);
        e_soap_message_write_string (msg, value);
@@ -1348,7 +1407,7 @@ e_ews_cal_util_write_utc_date (ESoapMessage *msg,
    cannot be transformed into Recurrence */
 gboolean
 e_ews_cal_utils_set_recurrence (ESoapMessage *msg,
-                               icalcomponent *comp,
+                               ICalComponent *comp,
                                gboolean server_satisfies_2013,
                                GError **error)
 {
@@ -1357,6 +1416,8 @@ e_ews_cal_utils_set_recurrence (ESoapMessage *msg,
        g_return_val_if_fail (E_IS_SOAP_MESSAGE (msg), FALSE);
        g_return_val_if_fail (comp != NULL, FALSE);
 
+       memset (&recur, 0, sizeof (EEwsRecurrence));
+
        recur.type = E_EWS_RECURRENCE_UNKNOWN;
        recur.end_type = E_EWS_RECURRENCE_END_UNKNOWN;
 
@@ -1519,20 +1580,20 @@ e_ews_cal_utils_set_recurrence (ESoapMessage *msg,
 }
 
 static void
-e_ews_cal_utils_days_of_week_to_rrule (struct icalrecurrencetype *rrule,
+e_ews_cal_utils_days_of_week_to_rrule (ICalRecurrence *rrule,
                                       guint32 days_of_week)
 {
        struct _bits {
                EEwsRecurrenceDaysOfWeek bit;
-               icalrecurrencetype_weekday week_day;
+               ICalRecurrenceWeekday week_day;
        } bits[] = {
-               { E_EWS_RECURRENCE_DAYS_OF_WEEK_SUNDAY, ICAL_SUNDAY_WEEKDAY },
-               { E_EWS_RECURRENCE_DAYS_OF_WEEK_MONDAY, ICAL_MONDAY_WEEKDAY },
-               { E_EWS_RECURRENCE_DAYS_OF_WEEK_TUESDAY, ICAL_TUESDAY_WEEKDAY },
-               { E_EWS_RECURRENCE_DAYS_OF_WEEK_WEDNESDAY, ICAL_WEDNESDAY_WEEKDAY },
-               { E_EWS_RECURRENCE_DAYS_OF_WEEK_THURSDAY, ICAL_THURSDAY_WEEKDAY },
-               { E_EWS_RECURRENCE_DAYS_OF_WEEK_FRIDAY, ICAL_FRIDAY_WEEKDAY },
-               { E_EWS_RECURRENCE_DAYS_OF_WEEK_SATURDAY, ICAL_SATURDAY_WEEKDAY }
+               { E_EWS_RECURRENCE_DAYS_OF_WEEK_SUNDAY, I_CAL_SUNDAY_WEEKDAY },
+               { E_EWS_RECURRENCE_DAYS_OF_WEEK_MONDAY, I_CAL_MONDAY_WEEKDAY },
+               { E_EWS_RECURRENCE_DAYS_OF_WEEK_TUESDAY, I_CAL_TUESDAY_WEEKDAY },
+               { E_EWS_RECURRENCE_DAYS_OF_WEEK_WEDNESDAY, I_CAL_WEDNESDAY_WEEKDAY },
+               { E_EWS_RECURRENCE_DAYS_OF_WEEK_THURSDAY, I_CAL_THURSDAY_WEEKDAY },
+               { E_EWS_RECURRENCE_DAYS_OF_WEEK_FRIDAY, I_CAL_FRIDAY_WEEKDAY },
+               { E_EWS_RECURRENCE_DAYS_OF_WEEK_SATURDAY, I_CAL_SATURDAY_WEEKDAY }
        };
        gint ii, idx;
 
@@ -1552,16 +1613,16 @@ e_ews_cal_utils_days_of_week_to_rrule (struct icalrecurrencetype *rrule,
 
        for (ii = 0; ii < G_N_ELEMENTS (bits); ii++) {
                if ((days_of_week & bits[ii].bit) != 0) {
-                       rrule->by_day[idx] = bits[ii].week_day;
+                       i_cal_recurrence_set_by_day (rrule, idx, bits[ii].week_day);
                        idx++;
                }
        }
 
-       rrule->by_day[idx] = ICAL_RECURRENCE_ARRAY_MAX;
+       i_cal_recurrence_set_by_day (rrule, idx, I_CAL_RECURRENCE_ARRAY_MAX);
 }
 
 static void
-e_ews_cal_utils_day_of_week_index_to_rrule (struct icalrecurrencetype *rrule,
+e_ews_cal_utils_day_of_week_index_to_rrule (ICalRecurrence *rrule,
                                            EEwsRecurrenceDayOfWeekIndex day_of_week_index)
 {
        g_return_if_fail (rrule != NULL);
@@ -1570,87 +1631,95 @@ e_ews_cal_utils_day_of_week_index_to_rrule (struct icalrecurrencetype *rrule,
        case E_EWS_RECURRENCE_DAY_OF_WEEK_INDEX_UNKNOWN:
                break;
        case E_EWS_RECURRENCE_DAY_OF_WEEK_INDEX_FIRST:
-               rrule->by_set_pos[0] = 1;
-               rrule->by_set_pos[1] = ICAL_RECURRENCE_ARRAY_MAX;
+               i_cal_recurrence_set_by_set_pos (rrule, 0, 1);
+               i_cal_recurrence_set_by_set_pos (rrule, 1, I_CAL_RECURRENCE_ARRAY_MAX);
                break;
        case E_EWS_RECURRENCE_DAY_OF_WEEK_INDEX_SECOND:
-               rrule->by_set_pos[0] = 2;
-               rrule->by_set_pos[1] = ICAL_RECURRENCE_ARRAY_MAX;
+               i_cal_recurrence_set_by_set_pos (rrule, 0, 2);
+               i_cal_recurrence_set_by_set_pos (rrule, 1, I_CAL_RECURRENCE_ARRAY_MAX);
                break;
        case E_EWS_RECURRENCE_DAY_OF_WEEK_INDEX_THIRD:
-               rrule->by_set_pos[0] = 3;
-               rrule->by_set_pos[1] = ICAL_RECURRENCE_ARRAY_MAX;
+               i_cal_recurrence_set_by_set_pos (rrule, 0, 3);
+               i_cal_recurrence_set_by_set_pos (rrule, 1, I_CAL_RECURRENCE_ARRAY_MAX);
                break;
        case E_EWS_RECURRENCE_DAY_OF_WEEK_INDEX_FOURTH:
-               rrule->by_set_pos[0] = 4;
-               rrule->by_set_pos[1] = ICAL_RECURRENCE_ARRAY_MAX;
+               i_cal_recurrence_set_by_set_pos (rrule, 0, 4);
+               i_cal_recurrence_set_by_set_pos (rrule, 1, I_CAL_RECURRENCE_ARRAY_MAX);
                break;
        case E_EWS_RECURRENCE_DAY_OF_WEEK_INDEX_LAST:
-               rrule->by_set_pos[0] = -1;
-               rrule->by_set_pos[1] = ICAL_RECURRENCE_ARRAY_MAX;
+               i_cal_recurrence_set_by_set_pos (rrule, 0, -1);
+               i_cal_recurrence_set_by_set_pos (rrule, 1, I_CAL_RECURRENCE_ARRAY_MAX);
                break;
        }
 }
 
 static void
-e_ews_cal_utils_month_to_rrule (struct icalrecurrencetype *rrule,
+e_ews_cal_utils_month_to_rrule (ICalRecurrence *rrule,
                                GDateMonth month)
 {
        g_return_if_fail (rrule != NULL);
 
        if (month >= G_DATE_JANUARY && month <= G_DATE_DECEMBER) {
-               rrule->by_month[0] = month;
-               rrule->by_month[1] = ICAL_RECURRENCE_ARRAY_MAX;
+               i_cal_recurrence_set_by_month (rrule, 0, month);
+               i_cal_recurrence_set_by_month (rrule, 1, I_CAL_RECURRENCE_ARRAY_MAX);
        }
 }
 
 /* Does nothing when the 'item' doesn't contain any recurrence */
 void
 e_ews_cal_utils_recurrence_to_rrule (EEwsItem *item,
-                                    icalcomponent *comp)
+                                    ICalComponent *comp)
 {
        EEwsRecurrence recur;
-       struct icalrecurrencetype rrule;
-       struct icaltimetype recur_start;
+       ICalRecurrence *rrule;
+       ICalTime *recur_start, *itt;
        gboolean usable = FALSE;
 
        g_return_if_fail (E_IS_EWS_ITEM (item));
        g_return_if_fail (comp != NULL);
 
-       e_cal_util_remove_property_by_kind (comp, ICAL_RRULE_PROPERTY, TRUE);
-       e_cal_util_remove_property_by_kind (comp, ICAL_RDATE_PROPERTY, TRUE);
-       e_cal_util_remove_property_by_kind (comp, ICAL_EXRULE_PROPERTY, TRUE);
-       e_cal_util_remove_property_by_kind (comp, ICAL_EXDATE_PROPERTY, TRUE);
-       e_cal_util_remove_x_property (comp, X_EWS_TASK_REGENERATION);
+       e_cal_util_component_remove_property_by_kind (comp, I_CAL_RRULE_PROPERTY, TRUE);
+       e_cal_util_component_remove_property_by_kind (comp, I_CAL_RDATE_PROPERTY, TRUE);
+       e_cal_util_component_remove_property_by_kind (comp, I_CAL_EXRULE_PROPERTY, TRUE);
+       e_cal_util_component_remove_property_by_kind (comp, I_CAL_EXDATE_PROPERTY, TRUE);
+       e_cal_util_component_remove_x_property (comp, X_EWS_TASK_REGENERATION);
 
        if (!e_ews_item_get_recurrence (item, &recur))
                return;
 
-       icalrecurrencetype_clear (&rrule);
-       recur_start = icaltime_from_timet_with_zone (recur.utc_start_date, 1, icaltimezone_get_utc_timezone 
());
+       rrule = i_cal_recurrence_new ();
+       recur_start = i_cal_time_from_timet_with_zone (recur.utc_start_date, 1, 
i_cal_timezone_get_utc_timezone ());
 
        switch (recur.end_type) {
        case E_EWS_RECURRENCE_END_UNKNOWN:
                break;
        case E_EWS_RECURRENCE_END_NO_END:
-               rrule.until = icaltime_null_time ();
-               rrule.count = 0;
+               itt = i_cal_time_null_time ();
+               i_cal_recurrence_set_until (rrule, itt);
+               i_cal_recurrence_set_count (rrule, 0);
+               g_clear_object (&itt);
                usable = TRUE;
                break;
        case E_EWS_RECURRENCE_END_DATE:
-               rrule.until = icaltime_from_timet_with_zone (recur.end.utc_end_date, 1, 
icaltimezone_get_utc_timezone ());
-               rrule.count = 0;
-               usable = !icaltime_is_null_time (rrule.until) && icaltime_is_valid_time (rrule.until);
+               itt = i_cal_time_from_timet_with_zone (recur.end.utc_end_date, 1, 
i_cal_timezone_get_utc_timezone ());
+               i_cal_recurrence_set_until (rrule, itt);
+               i_cal_recurrence_set_count (rrule, 0);
+               usable = !i_cal_time_is_null_time (itt) && i_cal_time_is_valid_time (itt);
+               g_clear_object (&itt);
                break;
        case E_EWS_RECURRENCE_END_NUMBERED:
-               rrule.until = icaltime_null_time ();
-               rrule.count = recur.end.number_of_occurrences;
-               usable = rrule.count > 0;
+               itt = i_cal_time_null_time ();
+               i_cal_recurrence_set_until (rrule, itt);
+               i_cal_recurrence_set_count (rrule, recur.end.number_of_occurrences);
+               g_clear_object (&itt);
+               usable = recur.end.number_of_occurrences > 0;
                break;
        }
 
        if (!usable) {
                g_warning ("%s: Cannot decode end condition in received recurrence", G_STRFUNC);
+               g_object_unref (recur_start);
+               g_object_unref (rrule);
                return;
        }
 
@@ -1661,75 +1730,76 @@ e_ews_cal_utils_recurrence_to_rrule (EEwsItem *item,
                break;
        case E_EWS_RECURRENCE_RELATIVE_YEARLY:
                usable = TRUE;
-               rrule.freq = ICAL_YEARLY_RECURRENCE;
-               rrule.interval = 1;
-               e_ews_cal_utils_days_of_week_to_rrule (&rrule, recur.recur.relative_yearly.days_of_week);
-               e_ews_cal_utils_day_of_week_index_to_rrule (&rrule, 
recur.recur.relative_yearly.day_of_week_index);
-               e_ews_cal_utils_month_to_rrule (&rrule, recur.recur.relative_yearly.month);
+               i_cal_recurrence_set_freq (rrule, I_CAL_YEARLY_RECURRENCE);
+               i_cal_recurrence_set_interval (rrule, 1);
+               e_ews_cal_utils_days_of_week_to_rrule (rrule, recur.recur.relative_yearly.days_of_week);
+               e_ews_cal_utils_day_of_week_index_to_rrule (rrule, 
recur.recur.relative_yearly.day_of_week_index);
+               e_ews_cal_utils_month_to_rrule (rrule, recur.recur.relative_yearly.month);
                break;
        case E_EWS_RECURRENCE_ABSOLUTE_YEARLY:
                usable = TRUE;
-               rrule.freq = ICAL_YEARLY_RECURRENCE;
-               rrule.interval = 1;
-               if (icaltime_is_valid_time (recur_start) &&
-                   recur_start.month == recur.recur.absolute_yearly.month &&
-                   recur_start.day == recur.recur.absolute_yearly.day_of_month) {
+               i_cal_recurrence_set_freq (rrule, I_CAL_YEARLY_RECURRENCE);
+               i_cal_recurrence_set_interval (rrule, 1);
+               if (i_cal_time_is_valid_time (recur_start) &&
+                   i_cal_time_get_month (recur_start) == recur.recur.absolute_yearly.month &&
+                   i_cal_time_get_day (recur_start) == recur.recur.absolute_yearly.day_of_month) {
                        /* This is how evolution uses it, derive date from the DTSTART */
                } else {
-                       rrule.by_month_day[0] = recur.recur.absolute_yearly.day_of_month;
-                       rrule.by_month_day[1] = ICAL_RECURRENCE_ARRAY_MAX;
-                       e_ews_cal_utils_month_to_rrule (&rrule, recur.recur.absolute_yearly.month);
+                       i_cal_recurrence_set_by_month_day (rrule, 0, 
recur.recur.absolute_yearly.day_of_month);
+                       i_cal_recurrence_set_by_month_day (rrule, 1, I_CAL_RECURRENCE_ARRAY_MAX);
+                       e_ews_cal_utils_month_to_rrule (rrule, recur.recur.absolute_yearly.month);
                }
                break;
        case E_EWS_RECURRENCE_RELATIVE_MONTHLY:
                usable = TRUE;
-               rrule.freq = ICAL_MONTHLY_RECURRENCE;
-               rrule.interval = recur.recur.relative_monthly.interval;
-               e_ews_cal_utils_days_of_week_to_rrule (&rrule, recur.recur.relative_monthly.days_of_week);
-               e_ews_cal_utils_day_of_week_index_to_rrule (&rrule, 
recur.recur.relative_monthly.day_of_week_index);
+               i_cal_recurrence_set_freq (rrule, I_CAL_MONTHLY_RECURRENCE);
+               i_cal_recurrence_set_interval (rrule, recur.recur.relative_monthly.interval);
+               e_ews_cal_utils_days_of_week_to_rrule (rrule, recur.recur.relative_monthly.days_of_week);
+               e_ews_cal_utils_day_of_week_index_to_rrule (rrule, 
recur.recur.relative_monthly.day_of_week_index);
                break;
        case E_EWS_RECURRENCE_ABSOLUTE_MONTHLY:
                usable = TRUE;
-               rrule.freq = ICAL_MONTHLY_RECURRENCE;
-               rrule.interval = recur.recur.absolute_monthly.interval;
-               rrule.by_month_day[0] = recur.recur.absolute_monthly.day_of_month;
-               rrule.by_month_day[1] = ICAL_RECURRENCE_ARRAY_MAX;
+               i_cal_recurrence_set_freq (rrule, I_CAL_MONTHLY_RECURRENCE);
+               i_cal_recurrence_set_interval (rrule, recur.recur.absolute_monthly.interval);
+               i_cal_recurrence_set_by_month_day (rrule, 0, recur.recur.absolute_monthly.day_of_month);
+               i_cal_recurrence_set_by_month_day (rrule, 1, I_CAL_RECURRENCE_ARRAY_MAX);
                break;
        case E_EWS_RECURRENCE_WEEKLY:
                usable = TRUE;
-               rrule.freq = ICAL_WEEKLY_RECURRENCE;
-               rrule.interval = recur.recur.weekly.interval;
-               e_ews_cal_utils_days_of_week_to_rrule (&rrule, recur.recur.weekly.days_of_week);
+               i_cal_recurrence_set_freq (rrule, I_CAL_WEEKLY_RECURRENCE);
+               i_cal_recurrence_set_interval (rrule, recur.recur.weekly.interval);
+               e_ews_cal_utils_days_of_week_to_rrule (rrule, recur.recur.weekly.days_of_week);
                break;
        case E_EWS_RECURRENCE_DAILY:
                usable = TRUE;
-               rrule.freq = ICAL_DAILY_RECURRENCE;
-               rrule.interval = recur.recur.interval;
+               i_cal_recurrence_set_freq (rrule, I_CAL_DAILY_RECURRENCE);
+               i_cal_recurrence_set_interval (rrule, recur.recur.interval);
                break;
        case E_EWS_RECURRENCE_DAILY_REGENERATION:
        case E_EWS_RECURRENCE_WEEKLY_REGENERATION:
        case E_EWS_RECURRENCE_MONTHLY_REGENERATION:
        case E_EWS_RECURRENCE_YEARLY_REGENERATION:
                e_ews_cal_util_encode_regeneration (&recur, comp);
+               g_object_unref (recur_start);
+               g_object_unref (rrule);
                return;
        }
 
        if (usable) {
-               struct icaltimetype itt;
-
-               itt = icaltime_from_timet_with_zone (recur.utc_start_date, 1, icaltimezone_get_utc_timezone 
());
+               if (recur_start && !i_cal_time_is_null_time (recur_start) && i_cal_time_is_valid_time 
(recur_start)) {
+                       ICalProperty *prop;
 
-               if (!icaltime_is_null_time (itt) && icaltime_is_valid_time (itt)) {
-                       icalproperty *prop;
+                       i_cal_component_set_dtstart (comp, recur_start);
 
-                       icalcomponent_set_dtstart (comp, itt);
-
-                       prop = icalproperty_new_rrule (rrule);
-                       icalcomponent_add_property (comp, prop);
+                       prop = i_cal_property_new_rrule (rrule);
+                       i_cal_component_take_property (comp, prop);
                } else {
                        g_warning ("%s: Cannot decode start date in received recurrence", G_STRFUNC);
                }
        } else {
                g_warning ("%s: Cannot decode received recurrence", G_STRFUNC);
        }
+
+       g_object_unref (recur_start);
+       g_object_unref (rrule);
 }
diff --git a/src/server/e-ews-calendar-utils.h b/src/server/e-ews-calendar-utils.h
index 3cfe5368..82cf83eb 100644
--- a/src/server/e-ews-calendar-utils.h
+++ b/src/server/e-ews-calendar-utils.h
@@ -21,7 +21,7 @@
 #define E_EWS_CALENDAR_UTILS_H
 
 #include <time.h>
-#include <libical/ical.h>
+#include <libecal/libecal.h>
 
 #include "server/e-soap-message.h"
 #include "server/e-ews-item.h"
@@ -44,15 +44,15 @@ gboolean    e_ews_cal_utils_prepare_free_busy_request
                                                 GError **error);
 void           e_ews_cal_utils_set_time        (ESoapMessage *msg,
                                                 const gchar *name,
-                                                icaltimetype *tt,
+                                                ICalTime *tt,
                                                 gboolean with_timezone);
 gboolean       e_ews_cal_utils_set_recurrence  (ESoapMessage *msg,
-                                                icalcomponent *comp,
+                                                ICalComponent *comp,
                                                 gboolean server_satisfies_2013,
                                                 GError **error);
 void           e_ews_cal_utils_recurrence_to_rrule
                                                (EEwsItem *item,
-                                                icalcomponent *comp);
+                                                ICalComponent *comp);
 
 G_END_DECLS
 
diff --git a/src/server/e-ews-connection.c b/src/server/e-ews-connection.c
index 1f561a8e..d80d7dcc 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -28,10 +28,8 @@
 #include <errno.h>
 #include <glib/gi18n-lib.h>
 #include <glib/gstdio.h>
-#include <libical/icalcomponent.h>
-#include <libical/icalproperty.h>
-#include <libical/ical.h>
 #include <libedataserver/libedataserver.h>
+#include <libecal/libecal.h>
 
 #include <libxml/parser.h>
 #include <libxml/xpath.h>
@@ -8031,25 +8029,31 @@ ews_handle_free_busy_view (ESoapParameter *param,
 {
        /*parse the response to create a free_busy data
        http://msdn.microsoft.com / en - us / library / aa564001 % 28v = EXCHG.140 % 29.aspx */
-       icalcomponent *vfb;
-       icalproperty *icalprop = NULL;
-       struct icalperiodtype ipt;
+       ICalComponent *vfb;
+       ICalProperty *prop = NULL;
        ESoapParameter *viewparam, *eventarray, *event_param, *subparam;
        GTimeVal t_val;
        const gchar *name;
        gchar *value, *new_val = NULL, *summary = NULL, *location = NULL, *id = NULL;
 
        viewparam = e_soap_parameter_get_first_child_by_name (param, "FreeBusyView");
-       if (!viewparam) return;
-       vfb = icalcomponent_new_vfreebusy ();
+       if (!viewparam)
+               return;
+       vfb = i_cal_component_new_vfreebusy ();
        eventarray = e_soap_parameter_get_first_child_by_name (viewparam, "CalendarEventArray");
        for (event_param = eventarray ? e_soap_parameter_get_first_child (eventarray) : NULL;
             event_param != NULL;
-            event_param = e_soap_parameter_get_next_child (event_param), icalprop = NULL) {
+            event_param = e_soap_parameter_get_next_child (event_param)) {
+               ICalPeriod *ipt;
+
+               ipt = i_cal_period_null_period ();
+
                for (subparam = e_soap_parameter_get_first_child (event_param); subparam != NULL; subparam = 
e_soap_parameter_get_next_child (subparam)) {
                        name = e_soap_parameter_get_name (subparam);
 
                        if (!g_ascii_strcasecmp (name, "StartTime")) {
+                               ICalTime *itt;
+
                                value = e_soap_parameter_get_string_value (subparam);
                                /*We are sending UTC timezone and expect server to return in same*/
 
@@ -8066,9 +8070,13 @@ ews_handle_free_busy_view (ESoapParameter *param,
                                g_time_val_from_iso8601 (new_val, &t_val);
                                g_free (new_val);
 
-                               ipt.start = icaltime_from_timet_with_zone (t_val.tv_sec, 0, NULL);
+                               itt = i_cal_time_from_timet_with_zone (t_val.tv_sec, 0, NULL);
+                               i_cal_period_set_start (ipt, itt);
+                               g_clear_object (&itt);
 
                        } else if (!g_ascii_strcasecmp (name, "EndTime")) {
+                               ICalTime *itt;
+
                                value = e_soap_parameter_get_string_value (subparam);
                                /*We are sending UTC timezone and expect server to return in same*/
 
@@ -8085,19 +8093,21 @@ ews_handle_free_busy_view (ESoapParameter *param,
                                g_time_val_from_iso8601 (new_val, &t_val);
                                g_free (new_val);
 
-                               ipt.end = icaltime_from_timet_with_zone (t_val.tv_sec, 0, NULL);
+                               itt = i_cal_time_from_timet_with_zone (t_val.tv_sec, 0, NULL);
+                               i_cal_period_set_end (ipt, itt);
+                               g_clear_object (&itt);
 
-                               icalprop = icalproperty_new_freebusy (ipt);
+                               prop = i_cal_property_new_freebusy (ipt);
                        } else if (!g_ascii_strcasecmp (name, "BusyType")) {
                                value = e_soap_parameter_get_string_value (subparam);
                                if (!strcmp (value, "Busy"))
-                                       icalproperty_set_parameter_from_string (icalprop, "FBTYPE", "BUSY");
+                                       i_cal_property_set_parameter_from_string (prop, "FBTYPE", "BUSY");
                                else if (!strcmp (value, "Tentative"))
-                                       icalproperty_set_parameter_from_string (icalprop, "FBTYPE", 
"BUSY-TENTATIVE");
+                                       i_cal_property_set_parameter_from_string (prop, "FBTYPE", 
"BUSY-TENTATIVE");
                                else if (!strcmp (value, "OOF"))
-                                       icalproperty_set_parameter_from_string (icalprop, "FBTYPE", 
"BUSY-UNAVAILABLE");
+                                       i_cal_property_set_parameter_from_string (prop, "FBTYPE", 
"BUSY-UNAVAILABLE");
                                else if (!strcmp (value, "Free"))
-                                       icalproperty_set_parameter_from_string (icalprop, "FBTYPE", "FREE");
+                                       i_cal_property_set_parameter_from_string (prop, "FBTYPE", "FREE");
                                g_free (value);
                        } else if (!g_ascii_strcasecmp (name, "CalendarEventDetails")) {
                                ESoapParameter *dparam;
@@ -8115,19 +8125,22 @@ ews_handle_free_busy_view (ESoapParameter *param,
                                        location = e_soap_parameter_get_string_value (dparam);
                        }
                }
-               if (icalprop != NULL) {
+
+               if (prop) {
                        if (id)
-                               icalproperty_set_parameter_from_string (icalprop, "X-EWS-ID", id);
+                               i_cal_property_set_parameter_from_string (prop, "X-EWS-ID", id);
                        if (summary)
-                               icalproperty_set_parameter_from_string (icalprop, "X-SUMMARY", summary);
+                               i_cal_property_set_parameter_from_string (prop, "X-SUMMARY", summary);
                        if (location)
-                               icalproperty_set_parameter_from_string (icalprop, "X-LOCATION", location);
-                       icalcomponent_add_property (vfb, icalprop);
+                               i_cal_property_set_parameter_from_string (prop, "X-LOCATION", location);
+                       i_cal_component_take_property (vfb, prop);
+                       prop = NULL;
                }
 
                g_clear_pointer (&summary, g_free);
                g_clear_pointer (&location, g_free);
                g_clear_pointer (&id, g_free);
+               g_clear_object (&ipt);
        }
 
        async_data->items = g_slist_append (async_data->items, vfb);
@@ -8236,7 +8249,7 @@ e_ews_connection_get_free_busy (EEwsConnection *cnc,
 gboolean
 e_ews_connection_get_free_busy_finish (EEwsConnection *cnc,
                                        GAsyncResult *result,
-                                       GSList **free_busy,
+                                       GSList **free_busy, /* ICalComponent * */
                                        GError **error)
 {
        GSimpleAsyncResult *simple;
@@ -8263,7 +8276,7 @@ e_ews_connection_get_free_busy_sync (EEwsConnection *cnc,
                                      gint pri,
                                      EEwsRequestCreationCallback free_busy_cb,
                                      gpointer free_busy_user_data,
-                                     GSList **free_busy,
+                                     GSList **free_busy, /* ICalComponent * */
                                      GCancellable *cancellable,
                                      GError **error)
 {
diff --git a/src/server/e-ews-connection.h b/src/server/e-ews-connection.h
index 996ad6ee..37f9592f 100644
--- a/src/server/e-ews-connection.h
+++ b/src/server/e-ews-connection.h
@@ -1115,14 +1115,14 @@ void            e_ews_connection_get_free_busy  (EEwsConnection *cnc,
 gboolean       e_ews_connection_get_free_busy_finish
                                                (EEwsConnection *cnc,
                                                 GAsyncResult *result,
-                                                GSList **free_busy,
+                                                GSList **free_busy, /* ICalComponent * */
                                                 GError **error);
 gboolean       e_ews_connection_get_free_busy_sync
                                                (EEwsConnection *cnc,
                                                 gint pri,
                                                 EEwsRequestCreationCallback free_busy_cb,
                                                 gpointer create_user_data,
-                                                GSList **free_busy,
+                                                GSList **free_busy, /* ICalComponent * */
                                                 GCancellable *cancellable,
                                                 GError **error);
 gboolean       e_ews_connection_download_oal_file_sync
diff --git a/src/server/e-ews-item.c b/src/server/e-ews-item.c
index 4919c664..d702e45d 100644
--- a/src/server/e-ews-item.c
+++ b/src/server/e-ews-item.c
@@ -29,8 +29,8 @@
 #include <glib/gstdio.h>
 #include <glib/gprintf.h>
 #include <libsoup/soup-misc.h>
-#include <libical/ical.h>
 #include <libedataserver/libedataserver.h>
+#include <libecal/libecal.h>
 
 #include "e-ews-item.h"
 #include "e-ews-item-change.h"
@@ -400,16 +400,16 @@ ews_item_parse_date (ESoapParameter *param)
                day = digit_at (dtstring, 6) * 10 + digit_at (dtstring, 7);
 
                if (len == 11) {
-                       struct icaltimetype itt;
+                       ICalTime *itt;
 
-                       itt = icaltime_null_time ();
-                       itt.year = year;
-                       itt.month = month;
-                       itt.day = day;
-                       itt.is_date = 1;
-                       itt.zone = icaltimezone_get_utc_timezone ();
+                       itt = i_cal_time_null_time ();
+                       i_cal_time_set_date (itt, year, month, day);
+                       i_cal_time_set_timezone (itt, i_cal_timezone_get_utc_timezone ());
+                       i_cal_time_set_is_date (itt, TRUE);
 
-                       t = icaltime_as_timet_with_zone (itt, icaltimezone_get_utc_timezone ());
+                       t = i_cal_time_as_timet_with_zone (itt, i_cal_timezone_get_utc_timezone ());
+
+                       g_object_unref (itt);
                } else {
                        GDate date;
                        struct tm tt;
diff --git a/src/server/e-ews-item.h b/src/server/e-ews-item.h
index fa4a066f..f5ce6166 100644
--- a/src/server/e-ews-item.h
+++ b/src/server/e-ews-item.h
@@ -353,9 +353,6 @@ time_t              e_ews_item_get_extended_property_as_time
 EEwsAttachmentInfo *
 e_ews_dump_file_attachment_from_soap_parameter (ESoapParameter *param, const gchar *cache, const gchar 
*comp_uid);
 
-gchar *
-e_ews_item_ical_dump (EEwsItem *item);
-
 EEwsAttachmentInfo *
 e_ews_item_dump_mime_content (EEwsItem *item, const gchar *cache);
 
diff --git a/tests/ews-test-timezones.c b/tests/ews-test-timezones.c
index 7f181730..2207890c 100644
--- a/tests/ews-test-timezones.c
+++ b/tests/ews-test-timezones.c
@@ -40,9 +40,9 @@ const gchar *str_comp =
        "SEQUENCE:2\n"
        "SUMMARY:Test\n"
        "CLASS:PUBLIC\n"
-       "ORGANIZER;CN=Someone:MAILTO:someone provide com\n"
+       "ORGANIZER;CN=Someone:mailto:someone provide com\n"
        "ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;\n"
-       " RSVP=TRUE;CN=Someone;LANGUAGE=en:MAILTO:someone provider com\n"
+       " RSVP=TRUE;CN=Someone;LANGUAGE=en:mailto:someone provider com\n"
        "END:VEVENT";
 
 /*
@@ -75,7 +75,7 @@ static const gchar *unknown_timezones[] = {
        NULL
 };
 
-static icalarray *builtin_timezones = NULL;
+static ICalArray *builtin_timezones = NULL;
 
 static gboolean
 is_a_known_unknown_timezone (const gchar *zone)
@@ -117,14 +117,15 @@ static void
 test_libical_timezones_compatibility (gconstpointer user_data)
 {
        gboolean retval = TRUE;
-       gint i;
+       guint ii, nelems;
 
-       for (i = 0; i < builtin_timezones->num_elements; i++) {
-               icaltimezone *zone;
+       nelems = i_cal_array_size (builtin_timezones);
+       for (ii = 0; ii < nelems; ii++) {
+               ICalTimezone *zone;
                const gchar *zone_location;
 
-               zone = icalarray_element_at (builtin_timezones, i);
-               zone_location = icaltimezone_get_location (zone);
+               zone = i_cal_timezone_array_element_at (builtin_timezones, ii);
+               zone_location = i_cal_timezone_get_location (zone);
 
                if (ical_to_msdn_equivalent (zone_location) == NULL) {
                        if (!is_a_known_unknown_timezone (zone_location)) {
@@ -132,6 +133,7 @@ test_libical_timezones_compatibility (gconstpointer user_data)
                                g_printerr ("\nMissing ical_tz_location: %s\n", zone_location);
                        }
                }
+               g_object_unref (zone);
        }
 
        g_assert (retval == TRUE);
@@ -141,7 +143,7 @@ static void
 test_time_zones_sync (gconstpointer user_data)
 {
        gboolean retval = FALSE;
-       gint i;
+       guint ii, nelems;
        GError *error = NULL;
        UhmServer *local_server;
        EwsTestData *etd = (gpointer) user_data;
@@ -225,29 +227,32 @@ test_time_zones_sync (gconstpointer user_data)
        }
 
        convert_data.connection = etd->connection;
-       convert_data.default_zone = icaltimezone_get_utc_timezone ();
+       convert_data.default_zone = i_cal_timezone_get_utc_timezone ();
 
        tokens = g_strsplit (str_comp, "ICAL_TIMEZONE", 0);
 
-       for (i = 0; i < builtin_timezones->num_elements; i++) {
+       nelems = i_cal_array_size (builtin_timezones);
+       for (ii = 0; ii < nelems; ii++) {
                GSList *ll;
                GSList *ids = NULL;
-               icaltimezone *zone;
+               ICalTimezone *zone;
                ECalComponent *comp;
                const gchar *zone_location;
                gchar *str;
 
-               zone = icalarray_element_at (builtin_timezones, i);
-               zone_location = icaltimezone_get_location (zone);
+               zone = i_cal_timezone_array_element_at (builtin_timezones, ii);
+               zone_location = i_cal_timezone_get_location (zone);
 
-               if (is_a_known_unknown_timezone (zone_location))
+               if (is_a_known_unknown_timezone (zone_location)) {
+                       g_object_unref (zone);
                        continue;
+               }
 
                str = g_strdup_printf ("%s%s%s%s%s", tokens[0], zone_location, tokens[1], zone_location, 
tokens[2]);
                comp = e_cal_component_new_from_string (str);
                g_free (str);
 
-               convert_data.icalcomp = e_cal_component_get_icalcomponent (comp);
+               convert_data.icomp = e_cal_component_get_icalcomponent (comp);
 
                e_ews_connection_create_items_sync (
                        etd->connection,
@@ -268,6 +273,7 @@ test_time_zones_sync (gconstpointer user_data)
                        g_clear_error (&error);
 
                        zone_location_errors = g_slist_append (zone_location_errors, g_strdup 
(zone_location));
+                       g_object_unref (zone);
                        continue;
                }
 
@@ -280,11 +286,13 @@ test_time_zones_sync (gconstpointer user_data)
                                g_clear_error (&error);
 
                                zone_location_errors = g_slist_append (zone_location_errors, g_strdup 
(zone_location));
+                               g_object_unref (zone);
                                continue;
                        }
                }
 
                g_slist_free_full (ids, g_object_unref);
+               g_object_unref (zone);
        }
 
        retval = zone_location_errors == NULL;
@@ -370,7 +378,7 @@ int main (int argc,
 
        /* Set handler of debug information */
        populate_windows_zones ();
-       builtin_timezones = icaltimezone_get_builtin_timezones ();
+       builtin_timezones = i_cal_timezone_get_builtin_timezones ();
 
        for (l = etds; l != NULL; l = l->next) {
                EwsTestData *etd = l->data;
@@ -400,8 +408,7 @@ int main (int argc,
  exit:
        if (module != NULL)
                g_module_close (module);
-       if (builtin_timezones != NULL)
-               icalarray_free (builtin_timezones);
+       i_cal_timezone_free_builtin_timezones ();
        ews_test_cleanup ();
 
        return retval;


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