[evolution/wip/mcrha/eds-libical-glib] Initial changes with 'ical' modifications around e-cal-model



commit e038731de376945bf61f5ab93d8c30d6704817b9
Author: Milan Crha <mcrha redhat com>
Date:   Tue Mar 19 17:19:36 2019 +0100

    Initial changes with 'ical' modifications around e-cal-model

 CMakeLists.txt                                    |  45 +-
 config.h.in                                       |  12 -
 src/calendar/gui/calendar-config.c                |   8 +-
 src/calendar/gui/e-cal-model-calendar.c           | 169 +++---
 src/calendar/gui/e-cal-model-memos.c              |  13 +-
 src/calendar/gui/e-cal-model-tasks.c              | 491 ++++++++++--------
 src/calendar/gui/e-cal-model.c                    | 594 ++++++++++------------
 src/calendar/gui/e-cal-model.h                    |  30 +-
 src/calendar/gui/e-cell-date-edit-text.c          | 203 ++++++--
 src/calendar/gui/e-cell-date-edit-text.h          |  30 +-
 src/calendar/gui/e-comp-editor-page-attachments.c |   6 -
 src/calendar/gui/e-comp-editor-page-general.c     |  34 +-
 src/calendar/gui/e-comp-editor-property-parts.c   |   8 -
 src/calendar/gui/e-timezone-entry.c               |  56 +-
 src/calendar/gui/e-timezone-entry.h               |  11 +-
 src/calendar/gui/e-to-do-pane.c                   |   4 -
 src/calendar/gui/itip-utils.c                     |   6 +-
 src/calendar/gui/itip-utils.h                     |   1 -
 src/e-util/e-timezone-dialog.c                    | 142 +++---
 src/e-util/e-timezone-dialog.h                    |   9 +-
 src/e-util/test-source-selector.c                 |   6 +-
 src/modules/calendar/e-cal-attachment-handler.c   |   1 -
 src/shell/main.c                                  |   8 +-
 23 files changed, 1013 insertions(+), 874 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c5e24687b5..65b7f4175a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -286,7 +286,7 @@ pkg_check_modules(GNOME_PLATFORM REQUIRED
 pkg_check_modules(EVOLUTION_DATA_SERVER REQUIRED
        camel-1.2>=${eds_minimum_version}
        libebook-1.2>=${eds_minimum_version}
-       libecal-1.2>=${eds_minimum_version}
+       libecal-2.0>=${eds_minimum_version}
        libedataserver-1.2>=${eds_minimum_version}
        libedataserverui-1.2>=${eds_minimum_version}
        libebackend-1.2>=${eds_minimum_version}
@@ -589,49 +589,6 @@ set(HAVE_LIBNOTIFY ${LIBNOTIFY_FOUND})
 pkg_check_modules(LIBUNITY unity>=${libunity_minimum_version})
 set(HAVE_LIBUNITY ${LIBUNITY_FOUND})
 
-# ******************************
-# libical tweaks
-# ******************************
-
-set(CMAKE_REQUIRED_DEFINITIONS ${EVOLUTION_DATA_SERVER_CFLAGS_OTHER})
-set(CMAKE_REQUIRED_INCLUDES ${EVOLUTION_DATA_SERVER_INCLUDE_DIRS})
-set(CMAKE_REQUIRED_LIBRARIES ${EVOLUTION_DATA_SERVER_LDFLAGS})
-
-CHECK_C_SOURCE_COMPILES("#include <libical/ical.h>
-                       int main(void) {
-                               ical_set_unknown_token_handling_setting (ICAL_DISCARD_TOKEN);
-                               return 0;
-                       }" HAVE_ICAL_UNKNOWN_TOKEN_HANDLING)
-
-CHECK_C_SOURCE_COMPILES("#include <libical/ical.h>
-                       int main(void) {
-                               icaltzutil_set_exact_vtimezones_support (0);
-                               return 0;
-                       }" HAVE_ICALTZUTIL_SET_EXACT_VTIMEZONES_SUPPORT)
-
-CHECK_C_SOURCE_COMPILES("#include <libical/ical.h>
-                       int main(void) {
-                               icalparameter *param;
-                               param = icalproperty_get_first_parameter (NULL, ICAL_FILENAME_PARAMETER);
-                               icalparameter_get_filename (param);
-                               icalparameter_new_filename (NULL);
-                               return 0;
-                       }" HAVE_ICAL_FILENAME_PARAMETER)
-
-CHECK_C_SOURCE_COMPILES("#include <libical/ical.h>
-                       int main(void) {
-                               icalproperty *prop;
-                               prop = icalcomponent_get_first_property (NULL, ICAL_COLOR_PROPERTY);
-                               icalproperty_get_color (prop);
-                               icalproperty_set_color (prop, \"white\");
-                               prop = icalproperty_new_color (NULL);
-                               return 0;
-                       }" HAVE_ICAL_COLOR_PROPERTY)
-
-unset(CMAKE_REQUIRED_DEFINITIONS)
-unset(CMAKE_REQUIRED_INCLUDES)
-unset(CMAKE_REQUIRED_LIBRARIES)
-
 # ******************************
 # gspell
 # ******************************
diff --git a/config.h.in b/config.h.in
index 4a134f6b66..19bfc49cc9 100644
--- a/config.h.in
+++ b/config.h.in
@@ -99,18 +99,6 @@
 /* Define if you have libunity */
 #cmakedefine HAVE_LIBUNITY 1
 
-/* libical provides ical_set_unknown_token_handling_setting function */
-#cmakedefine HAVE_ICAL_UNKNOWN_TOKEN_HANDLING 1
-
-/* libical provides icaltzutil_set_exact_vtimezones_support function */
-#cmakedefine HAVE_ICALTZUTIL_SET_EXACT_VTIMEZONES_SUPPORT 1
-
-/* libical provides ICAL_FILENAME_PARAMETER */
-#cmakedefine HAVE_ICAL_FILENAME_PARAMETER 1
-
-/* libical provides ICAL_COLOR_PROPERTY */
-#cmakedefine HAVE_ICAL_COLOR_PROPERTY 1
-
 /* When defined GSpell usage is enabled */
 #cmakedefine HAVE_GSPELL 1
 
diff --git a/src/calendar/gui/calendar-config.c b/src/calendar/gui/calendar-config.c
index 4be9405875..84811a25bf 100644
--- a/src/calendar/gui/calendar-config.c
+++ b/src/calendar/gui/calendar-config.c
@@ -399,14 +399,14 @@ calendar_config_get_day_second_zone (void)
 void
 calendar_config_select_day_second_zone (GtkWidget *parent)
 {
-       icaltimezone *zone = NULL;
+       ICalTimezone *zone = NULL;
        ETimezoneDialog *tzdlg;
        GtkWidget *dialog;
        gchar *second_location;
 
        second_location = calendar_config_get_day_second_zone ();
        if (second_location && *second_location)
-               zone = icaltimezone_get_builtin_timezone (second_location);
+               zone = i_cal_timezone_get_builtin_timezone (second_location);
        g_free (second_location);
 
        if (!zone)
@@ -424,10 +424,10 @@ calendar_config_select_day_second_zone (GtkWidget *parent)
                const gchar *location = NULL;
 
                zone = e_timezone_dialog_get_timezone (tzdlg);
-               if (zone == icaltimezone_get_utc_timezone ()) {
+               if (zone == i_cal_timezone_get_utc_timezone ()) {
                        location = "UTC";
                } else if (zone) {
-                       location = icaltimezone_get_location (zone);
+                       location = i_cal_timezone_get_location (zone);
                }
 
                calendar_config_set_day_second_zone (location);
diff --git a/src/calendar/gui/e-cal-model-calendar.c b/src/calendar/gui/e-cal-model-calendar.c
index 8ce31daf9f..2fef77526a 100644
--- a/src/calendar/gui/e-cal-model-calendar.c
+++ b/src/calendar/gui/e-cal-model-calendar.c
@@ -49,102 +49,119 @@ static ECellDateEditValue *
 get_dtend (ECalModelCalendar *model,
            ECalModelComponent *comp_data)
 {
-       struct icaltimetype tt_end;
+       ICalTimetype *tt_end;
 
        if (!comp_data->dtend) {
-               icalproperty *prop;
-               icaltimezone *zone = NULL, *model_zone = NULL;
-               gboolean got_zone = FALSE;
+               ICalProperty *prop;
+               ICalTimezone *zone = NULL, *model_zone = NULL;
+               gboolean got_zone = FALSE, is_date;
 
-               prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DTEND_PROPERTY);
+               prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_DTEND_PROPERTY);
                if (!prop)
                        return NULL;
 
-               tt_end = icalproperty_get_dtend (prop);
+               tt_end = i_cal_property_get_dtend (prop);
 
-               if (icaltime_get_tzid (tt_end)
-                   && e_cal_client_get_timezone_sync (comp_data->client, icaltime_get_tzid (tt_end), &zone, 
NULL, NULL))
+               if (i_cal_time_get_tzid (tt_end) &&
+                   e_cal_client_get_timezone_sync (comp_data->client, i_cal_time_get_tzid (tt_end), &zone, 
NULL, NULL))
                        got_zone = TRUE;
 
                model_zone = e_cal_model_get_timezone (E_CAL_MODEL (model));
 
+               is_date = i_cal_time_is_date (tt_end);
+
+               g_clear_object (&tt_end);
+               g_clear_object (&prop);
+
                if (got_zone) {
-                       tt_end = icaltime_from_timet_with_zone (comp_data->instance_end, tt_end.is_date, 
zone);
+                       tt_end = i_cal_time_from_timet_with_zone (comp_data->instance_end, is_date, zone);
                } else {
-                       tt_end = icaltime_from_timet_with_zone (
-                               comp_data->instance_end,
-                               tt_end.is_date, model_zone);
+                       tt_end = i_cal_time_from_timet_with_zone (comp_data->instance_end, is_date, 
model_zone);
                }
 
-               if (!icaltime_is_valid_time (tt_end) || icaltime_is_null_time (tt_end))
+               if (!i_cal_time_is_valid_time (tt_end) || i_cal_time_is_null_time (tt_end)) {
+                       g_clear_object (&tt_end);
                        return NULL;
+               }
 
-               if (tt_end.is_date && icalcomponent_get_first_property (comp_data->icalcomp, 
ICAL_DTSTART_PROPERTY)) {
-                       struct icaltimetype tt_start;
-                       icaltimezone *start_zone = NULL;
+               if (i_cal_time_is_date (tt_end) &&
+                   (prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_DTSTART_PROPERTY)) 
!= NULL) {
+                       ICalTimetype *tt_start;
+                       ICalTimezone *start_zone = NULL;
                        gboolean got_start_zone = FALSE;
 
-                       tt_start = icalproperty_get_dtstart (prop);
+                       tt_start = i_cal_property_get_dtstart (prop);
 
-                       if (icaltime_get_tzid (tt_start)
-                           && e_cal_client_get_timezone_sync (comp_data->client, icaltime_get_tzid 
(tt_start), &start_zone, NULL, NULL))
+                       if (i_cal_time_get_tzid (tt_start) &&
+                           e_cal_client_get_timezone_sync (comp_data->client, i_cal_time_get_tzid 
(tt_start), &start_zone, NULL, NULL))
                                got_start_zone = TRUE;
 
+                       is_date = i_cal_time_is_date (tt_end);
+
+                       g_clear_object (&tt_start);
+
                        if (got_start_zone) {
-                               tt_start = icaltime_from_timet_with_zone (comp_data->instance_start, 
tt_start.is_date, start_zone);
+                               tt_start = i_cal_time_from_timet_with_zone (comp_data->instance_start, 
is_date, start_zone);
                        } else {
-                               tt_start = icaltime_from_timet_with_zone (
-                                       comp_data->instance_start,
-                                       tt_start.is_date, model_zone);
+                               tt_start = i_cal_time_from_timet_with_zone (comp_data->instance_start, 
is_date, model_zone);
                        }
 
-                       icaltime_adjust (&tt_start, 1, 0, 0, 0);
+                       i_cal_time_adjust (tt_start, 1, 0, 0, 0);
 
                        /* Decrease by a day only if the DTSTART will still be before, or the same as, DTEND 
*/
-                       if (icaltime_compare (tt_start, tt_end) <= 0)
-                               icaltime_adjust (&tt_end, -1, 0, 0, 0);
+                       if (i_cal_time_compare (tt_start, tt_end) <= 0)
+                               i_cal_time_adjust (tt_end, -1, 0, 0, 0);
+
+                       g_clear_object (&tt_start);
                }
 
-               comp_data->dtend = g_new0 (ECellDateEditValue, 1);
-               comp_data->dtend->tt = tt_end;
+               g_clear_object (&prop);
 
-               if (got_zone)
-                       comp_data->dtend->zone = zone;
-               else
-                       comp_data->dtend->zone = NULL;
+               comp_data->dtend = e_cell_date_edit_value_new_take (tt_end, (got_zone && zone) ? 
e_cal_util_copy_timezone (zone) : NULL);
        }
 
-       return e_cal_model_copy_cell_date_value (comp_data->dtend);
+       return e_cell_date_edit_value_copy (comp_data->dtend);
 }
 
 static gpointer
 get_location (ECalModelComponent *comp_data)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
+       const gchar *res = NULL;
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_LOCATION_PROPERTY);
-       if (prop)
-               return (gpointer) icalproperty_get_location (prop);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_LOCATION_PROPERTY);
+       if (prop) {
+               res = i_cal_property_get_location (prop);
+               g_clear_object (&prop);
+       }
 
-       return (gpointer) "";
+       if (!res)
+               res = "";
+
+       return (gpointer) res;
 }
 
 static gpointer
 get_transparency (ECalModelComponent *comp_data)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_TRANSP_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_TRANSP_PROPERTY);
        if (prop) {
-               icalproperty_transp transp;
-
-               transp = icalproperty_get_transp (prop);
-               if (transp == ICAL_TRANSP_TRANSPARENT ||
-                   transp == ICAL_TRANSP_TRANSPARENTNOCONFLICT)
-                       return _("Free");
-               else if (transp == ICAL_TRANSP_OPAQUE ||
-                        transp == ICAL_TRANSP_OPAQUENOCONFLICT)
-                       return _("Busy");
+               ICalPropertyTransp transp;
+               const gchar *res = NULL;
+
+               transp = i_cal_property_get_transp (prop);
+               if (transp == I_CAL_TRANSP_TRANSPARENT ||
+                   transp == I_CAL_TRANSP_TRANSPARENTNOCONFLICT)
+                       res = _("Free");
+               else if (transp == I_CAL_TRANSP_OPAQUE ||
+                        transp == I_CAL_TRANSP_OPAQUENOCONFLICT)
+                       res = _("Busy");
+
+               g_clear_object (&prop);
+
+               return res;
        }
 
        return NULL;
@@ -155,28 +172,29 @@ set_dtend (ECalModel *model,
            ECalModelComponent *comp_data,
            gconstpointer value)
 {
-       e_cal_model_update_comp_time (model, comp_data, value, ICAL_DTEND_PROPERTY, icalproperty_set_dtend, 
icalproperty_new_dtend);
+       e_cal_model_update_comp_time (model, comp_data, value, I_CAL_DTEND_PROPERTY, 
i_cal_property_set_dtend, i_cal_property_new_dtend);
 }
 
 static void
 set_location (ECalModelComponent *comp_data,
               gconstpointer value)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_LOCATION_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_LOCATION_PROPERTY);
 
        if (string_is_empty (value)) {
                if (prop) {
-                       icalcomponent_remove_property (comp_data->icalcomp, prop);
-                       icalproperty_free (prop);
+                       i_cal_component_remove_property (comp_data->icalcomp, prop);
+                       g_object_unref (prop);
                }
        } else {
-               if (prop)
-                       icalproperty_set_location (prop, (const gchar *) value);
-               else {
-                       prop = icalproperty_new_location ((const gchar *) value);
-                       icalcomponent_add_property (comp_data->icalcomp, prop);
+               if (prop) {
+                       i_cal_property_set_location (prop, (const gchar *) value);
+                       g_object_unref (prop);
+               } else {
+                       prop = i_cal_property_new_location ((const gchar *) value);
+                       i_cal_component_take_property (comp_data->icalcomp, prop);
                }
        }
 }
@@ -185,36 +203,37 @@ static void
 set_transparency (ECalModelComponent *comp_data,
                   gconstpointer value)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_TRANSP_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_TRANSP_PROPERTY);
 
        if (string_is_empty (value)) {
                if (prop) {
-                       icalcomponent_remove_property (comp_data->icalcomp, prop);
-                       icalproperty_free (prop);
+                       i_cal_component_remove_property (comp_data->icalcomp, prop);
+                       g_object_unref (prop);
                }
        } else {
-               icalproperty_transp transp;
+               ICalPropertyTransp transp;
 
                if (!g_ascii_strcasecmp (value, "FREE"))
-                       transp = ICAL_TRANSP_TRANSPARENT;
+                       transp = I_CAL_TRANSP_TRANSPARENT;
                else if (!g_ascii_strcasecmp (value, "OPAQUE"))
-                       transp = ICAL_TRANSP_OPAQUE;
+                       transp = I_CAL_TRANSP_OPAQUE;
                else {
                        if (prop) {
-                               icalcomponent_remove_property (comp_data->icalcomp, prop);
-                               icalproperty_free (prop);
+                               i_cal_component_remove_property (comp_data->icalcomp, prop);
+                               g_object_unref (prop);
                        }
 
                        return;
                }
 
-               if (prop)
-                       icalproperty_set_transp (prop, transp);
-               else {
-                       prop = icalproperty_new_transp (transp);
-                       icalcomponent_add_property (comp_data->icalcomp, prop);
+               if (prop) {
+                       i_cal_property_set_transp (prop, transp);
+                       g_object_unref (prop);
+               } else {
+                       prop = i_cal_property_new_transp (transp);
+                       i_cal_component_take_property (comp_data->icalcomp, prop);
                }
        }
 }
@@ -310,7 +329,7 @@ cal_model_calendar_set_value_at (ETableModel *etm,
        if (!comp_data)
                return;
 
-       comp = e_cal_component_new_from_icalcomponent (icalcomponent_new_clone (comp_data->icalcomp));
+       comp = e_cal_component_new_from_icalcomponent (i_cal_component_new_clone (comp_data->icalcomp));
        if (!comp) {
                return;
        }
@@ -379,7 +398,7 @@ cal_model_calendar_duplicate_value (ETableModel *etm,
 
        switch (col) {
        case E_CAL_MODEL_CALENDAR_FIELD_DTEND :
-               return e_cal_model_copy_cell_date_value (value);
+               return e_cell_date_edit_value_copy (value);
        case E_CAL_MODEL_CALENDAR_FIELD_LOCATION :
        case E_CAL_MODEL_CALENDAR_FIELD_TRANSPARENCY :
                return g_strdup (value);
diff --git a/src/calendar/gui/e-cal-model-memos.c b/src/calendar/gui/e-cal-model-memos.c
index f7ee2b03d6..bfa6ec3ecd 100644
--- a/src/calendar/gui/e-cal-model-memos.c
+++ b/src/calendar/gui/e-cal-model-memos.c
@@ -64,16 +64,19 @@ cal_model_memos_fill_component_from_values (ECalModel *model,
                                            ECalModelComponent *comp_data,
                                            GHashTable *values)
 {
-       icaltimetype start;
+       ICalTimetype *dtstart;
 
        g_return_if_fail (E_IS_CAL_MODEL_MEMOS (model));
        g_return_if_fail (comp_data != NULL);
        g_return_if_fail (values != NULL);
 
-       start = icalcomponent_get_dtstart (comp_data->icalcomp);
-       if (icaltime_compare_date_only (start, icaltime_null_time ()) == 0) {
-               start = icaltime_today ();
-               icalcomponent_set_dtstart (comp_data->icalcomp, start);
+       dtstart = i_cal_component_get_dtstart (comp_data->icalcomp);
+       if (i_cal_time_is_null_time (dtstart) || !i_cal_time_is_valid_time (dtstart)) {
+               g_clear_object (&dtstart);
+
+               dtstart = i_cal_time_today ();
+               i_cal_component_set_dtstart (comp_data->icalcomp, dtstart);
+               g_clear_object (&dtstart);
        }
 }
 
diff --git a/src/calendar/gui/e-cal-model-tasks.c b/src/calendar/gui/e-cal-model-tasks.c
index 71bb3ae069..ec468e5662 100644
--- a/src/calendar/gui/e-cal-model-tasks.c
+++ b/src/calendar/gui/e-cal-model-tasks.c
@@ -83,28 +83,26 @@ ensure_task_complete (ECalModelComponent *comp_data,
 static void
 ensure_task_partially_complete (ECalModelComponent *comp_data)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
        /* Date Completed. */
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_COMPLETED_PROPERTY);
-       if (prop) {
-               icalcomponent_remove_property (comp_data->icalcomp, prop);
-               icalproperty_free (prop);
-       }
+       e_cal_util_component_remove_property_by_kind (comp_data->icalcomp, I_CAL_COMPLETED_PROPERTY, TRUE);
 
        /* Percent. */
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_PERCENTCOMPLETE_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_PERCENTCOMPLETE_PROPERTY);
        if (!prop)
-               icalcomponent_add_property (comp_data->icalcomp, icalproperty_new_percentcomplete (50));
-       else if (icalproperty_get_percentcomplete (prop) == 0 || icalproperty_get_percentcomplete (prop) == 
100)
-               icalproperty_set_percentcomplete (prop, 50);
+               i_cal_component_take_property (comp_data->icalcomp, i_cal_property_new_percentcomplete (50));
+       else if (i_cal_property_get_percentcomplete (prop) == 0 || i_cal_property_get_percentcomplete (prop) 
== 100)
+               i_cal_property_set_percentcomplete (prop, 50);
+       g_clear_object (&prop);
 
        /* Status. */
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_STATUS_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_STATUS_PROPERTY);
        if (prop)
-               icalproperty_set_status (prop, ICAL_STATUS_INPROCESS);
+               i_cal_property_set_status (prop, I_CAL_STATUS_INPROCESS);
        else
-               icalcomponent_add_property (comp_data->icalcomp, icalproperty_new_status 
(ICAL_STATUS_INPROCESS));
+               i_cal_component_take_property (comp_data->icalcomp, i_cal_property_new_status 
(I_CAL_STATUS_INPROCESS));
+       g_clear_object (&prop);
 }
 
 /* This makes sure a task is marked as incomplete. It clears the
@@ -112,154 +110,177 @@ ensure_task_partially_complete (ECalModelComponent *comp_data)
  * and if the status is "Completed" it sets it to "Needs Action".
  * Note that this doesn't update the component on the client. */
 static void
-ensure_task_not_complete (ECalModelComponent *comp_data)
+ensure_task_not_complete (ECalModelComponent *comp_data,
+                         gboolean with_status)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
        /* Date Completed. */
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_COMPLETED_PROPERTY);
-       if (prop) {
-               icalcomponent_remove_property (comp_data->icalcomp, prop);
-               icalproperty_free (prop);
-       }
+       e_cal_util_component_remove_property_by_kind (comp_data->icalcomp, I_CAL_COMPLETED_PROPERTY, TRUE);
 
        /* Percent. */
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_PERCENTCOMPLETE_PROPERTY);
-       if (prop) {
-               icalcomponent_remove_property (comp_data->icalcomp, prop);
-               icalproperty_free (prop);
-       }
+       e_cal_util_component_remove_property_by_kind (comp_data->icalcomp, I_CAL_PERCENTCOMPLETE_PROPERTY, 
TRUE);
 
        /* Status. */
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_STATUS_PROPERTY);
-       if (prop)
-               icalproperty_set_status (prop, ICAL_STATUS_NEEDSACTION);
+       if (with_status) {
+               prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_STATUS_PROPERTY);
+               if (prop) {
+                       i_cal_property_set_status (prop, I_CAL_STATUS_NEEDSACTION);
+                       g_object_unref (prop);
+               }
+       }
 }
 
 static ECellDateEditValue *
 get_completed (ECalModelComponent *comp_data)
 {
-       struct icaltimetype tt_completed;
-
        if (!comp_data->completed) {
-               icaltimezone *zone;
-               icalproperty *prop;
+               ICalTimetype *tt_completed;
+               ICalTimezone *zone = NULL;
+               ICalProperty *prop;
 
-               prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_COMPLETED_PROPERTY);
+               prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_COMPLETED_PROPERTY);
                if (!prop)
                        return NULL;
 
-               tt_completed = icalproperty_get_completed (prop);
-               if (!icaltime_is_valid_time (tt_completed) || icaltime_is_null_time (tt_completed))
+               tt_completed = i_cal_property_get_completed (prop);
+               g_clear_object (&prop);
+
+               if (!i_cal_time_is_valid_time (tt_completed) || i_cal_time_is_null_time (tt_completed)) {
+                       g_clear_object (&tt_completed);
                        return NULL;
+               }
 
-               comp_data->completed = g_new0 (ECellDateEditValue, 1);
-               comp_data->completed->tt = tt_completed;
+               if (!i_cal_time_get_tzid (tt_completed) ||
+                   !e_cal_client_get_timezone_sync (comp_data->client, i_cal_time_get_tzid (tt_completed), 
&zone, NULL, NULL))
+                       zone = NULL;
 
-               if (icaltime_get_tzid (tt_completed)
-                   && e_cal_client_get_timezone_sync (comp_data->client, icaltime_get_tzid (tt_completed), 
&zone, NULL, NULL))
-                       comp_data->completed->zone = zone;
-               else
-                       comp_data->completed->zone = NULL;
+               comp_data->completed = e_cell_date_edit_value_new_take (tt_completed, zone ? 
e_cal_util_copy_timezone (zone) : NULL);
        }
 
-       return e_cal_model_copy_cell_date_value (comp_data->completed);
+       return e_cell_date_edit_value_copy (comp_data->completed);
 }
 
 static ECellDateEditValue *
 get_due (ECalModelComponent *comp_data)
 {
-       struct icaltimetype tt_due;
-
        if (!comp_data->due) {
-               icaltimezone *zone;
-               icalproperty *prop;
+               ICalTimetype *tt_due;
+               ICalTimezone *zone = NULL;
+               ICalProperty *prop;
 
-               prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DUE_PROPERTY);
+               prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_DUE_PROPERTY);
                if (!prop)
                        return NULL;
 
-               tt_due = icalproperty_get_due (prop);
-               if (!icaltime_is_valid_time (tt_due) || icaltime_is_null_time (tt_due))
+               tt_due = i_cal_property_get_due (prop);
+
+               g_clear_object (&prop);
+
+               if (!i_cal_time_is_valid_time (tt_due) || i_cal_time_is_null_time (tt_due)) {
+                       g_clear_object (&tt_due);
                        return NULL;
+               }
 
-               comp_data->due = g_new0 (ECellDateEditValue, 1);
-               comp_data->due->tt = tt_due;
+               if (!i_cal_time_get_tzid (tt_due) ||
+                   !e_cal_client_get_timezone_sync (comp_data->client, i_cal_time_get_tzid (tt_due), &zone, 
NULL, NULL))
+                       zone = NULL;
 
-               if (icaltime_get_tzid (tt_due)
-                   && e_cal_client_get_timezone_sync (comp_data->client, icaltime_get_tzid (tt_due), &zone, 
NULL, NULL))
-                       comp_data->due->zone = zone;
-               else
-                       comp_data->due->zone = NULL;
+               comp_data->due = e_cell_date_edit_value_new_take (tt_due, zone ? e_cal_util_copy_timezone 
(zone) : NULL);
        }
 
-       return e_cal_model_copy_cell_date_value (comp_data->due);
+       return e_cell_date_edit_value_copy (comp_data->due);
 }
 
 static gpointer
 get_geo (ECalModelComponent *comp_data)
 {
-       icalproperty *prop;
-       struct icalgeotype geo;
+       ICalProperty *prop;
+       ICalGeoType *geo = NULL;
        static gchar buf[32];
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_GEO_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_GEO_PROPERTY);
        if (prop) {
-               geo = icalproperty_get_geo (prop);
-               g_snprintf (
-                       buf, sizeof (buf), "%g %s, %g %s",
-                       fabs (geo.lat),
-                       geo.lat >= 0.0 ? "N" : "S",
-                       fabs (geo.lon),
-                       geo.lon >= 0.0 ? "E" : "W");
-               return buf;
+               geo = i_cal_property_get_geo (prop);
+               if (geo) {
+                       g_snprintf (
+                               buf, sizeof (buf), "%g %s, %g %s",
+                               fabs (i_cal_geo_type_get_lat (geo)),
+                               i_cal_geo_type_get_lat (geo) >= 0.0 ? "N" : "S",
+                               fabs (i_cal_geo_type_get_lon (geo)),
+                               i_cal_geo_type_get_lon (geo) >= 0.0 ? "E" : "W");
+                       g_object_unref (prop);
+                       g_object_unref (geo);
+                       return buf;
+               }
        }
 
+       g_clear_object (&prop);
+       g_clear_object (&geo);
+
        return (gpointer) "";
 }
 
 static gint
 get_percent (ECalModelComponent *comp_data)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
+       gint percent = 0;
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_PERCENTCOMPLETE_PROPERTY);
-       if (prop)
-               return icalproperty_get_percentcomplete (prop);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_PERCENTCOMPLETE_PROPERTY);
+       if (prop) {
+               percent = i_cal_property_get_percentcomplete (prop);
+               g_object_unref (prop);
+       }
 
-       return 0;
+       return percent;
 }
 
 static gpointer
 get_priority (ECalModelComponent *comp_data)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
+       const gchar *value = NULL;
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_PRIORITY_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_PRIORITY_PROPERTY);
        if (prop)
-               return (gpointer) e_cal_util_priority_to_string (icalproperty_get_priority (prop));
+               value = e_cal_util_priority_to_string (i_cal_property_get_priority (prop));
 
-       return (gpointer) "";
+       if (!value)
+               value = "";
+
+       return (gpointer) value;
 }
 
 static gboolean
 is_status_canceled (ECalModelComponent *comp_data)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
+       gboolean res;
+
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_STATUS_PROPERTY);
+
+       res = prop && i_cal_property_get_status (prop) == I_CAL_STATUS_CANCELLED;
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_STATUS_PROPERTY);
+       g_clear_object (&prop);
 
-       return prop && icalproperty_get_status (prop) == ICAL_STATUS_CANCELLED;
+       return res;
 }
 
 static gpointer
 get_status (ECalModelComponent *comp_data)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_STATUS_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_STATUS_PROPERTY);
        if (prop) {
-               switch (icalproperty_get_status (prop)) {
+               ICalPropertyStatus status;
+
+               status = i_cal_property_get_status (prop);
+
+               g_object_unref (prop);
+
+               switch (status) {
                case ICAL_STATUS_NONE:
                        return (gpointer) "";
                case ICAL_STATUS_NEEDSACTION:
@@ -281,43 +302,59 @@ get_status (ECalModelComponent *comp_data)
 static gpointer
 get_url (ECalModelComponent *comp_data)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
+       const gchar *url;
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_URL_PROPERTY);
-       if (prop)
-               return (gpointer) icalproperty_get_url (prop);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_URL_PROPERTY);
+       if (prop) {
+               url = i_cal_property_get_url (prop);
+               g_object_unref (prop);
+       }
 
-       return (gpointer) "";
+       return (gpointer) (url ? url : "");
 }
 
 static gpointer
 get_location (ECalModelComponent *comp_data)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
+       const gchar *localtion;
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_LOCATION_PROPERTY);
-       if (prop)
-               return (gpointer) icalproperty_get_location (prop);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_LOCATION_PROPERTY);
+       if (prop) {
+               location = i_cal_property_get_location (prop);
+               g_object_unref (prop);
+       }
 
-       return (gpointer) "";
+       return (gpointer) (location ? location : "");
 }
 
 static gboolean
 is_complete (ECalModelComponent *comp_data)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_COMPLETED_PROPERTY);
-       if (prop)
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_COMPLETED_PROPERTY);
+       if (prop) {
+               g_object_unref (prop);
                return TRUE;
+       }
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_PERCENTCOMPLETE_PROPERTY);
-       if (prop && icalproperty_get_percentcomplete (prop) == 100)
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_PERCENTCOMPLETE_PROPERTY);
+       if (prop && i_cal_property_get_percentcomplete (prop) == 100) {
+               g_object_unref (prop);
                return TRUE;
+       }
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_STATUS_PROPERTY);
-       if (prop && icalproperty_get_status (prop) == ICAL_STATUS_COMPLETED)
+       g_clear_object (&prop);
+
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_STATUS_PROPERTY);
+       if (prop && i_cal_property_get_status (prop) == I_CAL_STATUS_COMPLETED) {
+               g_object_unref (prop);
                return TRUE;
+       }
+
+       g_clear_object (&prop);
 
        return FALSE;
 }
@@ -334,27 +371,33 @@ static ECalModelTasksDueStatus
 get_due_status (ECalModelTasks *model,
                 ECalModelComponent *comp_data)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
        /* First, do we have a due date? */
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DUE_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_DUE_PROPERTY);
        if (!prop)
                return E_CAL_MODEL_TASKS_DUE_NEVER;
        else {
-               struct icaltimetype now_tt, due_tt;
-               icaltimezone *zone = NULL;
+               ICalTimetype *now_tt, *due_tt;
+               ICalTimezone *zone = NULL;
 
                /* Second, is it already completed? */
-               if (is_complete (comp_data))
+               if (is_complete (comp_data)) {
+                       g_object_unref (prop);
                        return E_CAL_MODEL_TASKS_DUE_COMPLETE;
+               }
 
                /* Third, are we overdue as of right now? */
-               due_tt = icalproperty_get_due (prop);
-               if (due_tt.is_date) {
+               due_tt = i_cal_property_get_due (prop);
+               if (i_cal_time_is_date (due_tt)) {
                        gint cmp;
 
-                       now_tt = icaltime_current_time_with_zone (e_cal_model_get_timezone (E_CAL_MODEL 
(model)));
-                       cmp = icaltime_compare_date_only (due_tt, now_tt);
+                       now_tt = i_cal_time_current_time_with_zone (e_cal_model_get_timezone (E_CAL_MODEL 
(model)));
+                       cmp = i_cal_time_compare_date_only (due_tt, now_tt);
+
+                       g_object_unref (now_tt);
+                       g_object_unref (due_tt);
+                       g_object_unref (prop);
 
                        if (cmp < 0)
                                return E_CAL_MODEL_TASKS_DUE_OVERDUE;
@@ -363,28 +406,42 @@ get_due_status (ECalModelTasks *model,
                        else
                                return E_CAL_MODEL_TASKS_DUE_FUTURE;
                } else {
-                       icalparameter *param;
+                       ECalModelTasksDueStatus res;
+                       ICalParameter *param;
                        const gchar *tzid;
 
-                       if (!(param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER)))
+                       if (!(param = i_cal_property_get_first_parameter (prop, I_CAL_TZID_PARAMETER))) {
+                               g_object_unref (due_tt);
+                               g_object_unref (prop);
                                return E_CAL_MODEL_TASKS_DUE_FUTURE;
+                       }
 
                        /* Get the current time in the same timezone as the DUE date.*/
-                       tzid = icalparameter_get_tzid (param);
-                       e_cal_client_get_timezone_sync (
-                               comp_data->client, tzid, &zone, NULL, NULL);
-                       if (zone == NULL)
+                       tzid = i_cal_parameter_get_tzid (param);
+                       if (!e_cal_client_get_timezone_sync (comp_data->client, tzid, &zone, NULL, NULL))
+                               zone = NULL;
+
+                       g_object_unref (param);
+                       g_object_unref (prop);
+
+                       if (zone == NULL) {
+                               g_object_unref (due_tt);
                                return E_CAL_MODEL_TASKS_DUE_FUTURE;
+                       }
 
-                       now_tt = icaltime_current_time_with_zone (zone);
+                       now_tt = i_cal_time_current_time_with_zone (zone);
 
-                       if (icaltime_compare (due_tt, now_tt) <= 0)
-                               return E_CAL_MODEL_TASKS_DUE_OVERDUE;
+                       if (i_cal_time_compare (due_tt, now_tt) <= 0)
+                               res = E_CAL_MODEL_TASKS_DUE_OVERDUE;
+                       else if (i_cal_time_compare_date_only (due_tt, now_tt) == 0)
+                               res = E_CAL_MODEL_TASKS_DUE_TODAY;
                        else
-                               if (icaltime_compare_date_only (due_tt, now_tt) == 0)
-                                       return E_CAL_MODEL_TASKS_DUE_TODAY;
-                               else
-                                       return E_CAL_MODEL_TASKS_DUE_FUTURE;
+                               res = E_CAL_MODEL_TASKS_DUE_FUTURE;
+
+                       g_clear_object (&due_tt);
+                       g_clear_object (&now_tt);
+
+                       return res;
                }
        }
 }
@@ -414,19 +471,21 @@ set_completed (ECalModelTasks *model,
        ECellDateEditValue *dv = (ECellDateEditValue *) value;
 
        if (!dv)
-               ensure_task_not_complete (comp_data);
+               ensure_task_not_complete (comp_data, TRUE);
        else {
+               ICalTimetype *tt;
                time_t t;
 
-               if (dv->tt.is_date) {
+               tt = e_cell_date_edit_value_get_time (dv);
+               if (i_cal_time_is_date (tt)) {
                        /* if it's a date, it will be floating,
                         * but completed needs a date time value */
-                       dv->tt.is_date = FALSE;
-                       t = icaltime_as_timet_with_zone (dv->tt, e_cal_model_get_timezone (E_CAL_MODEL 
(model)));
+                       i_cal_timetype_set_is_date (tt, FALSE);
+                       t = i_cal_time_as_timet_with_zone (tt, e_cal_model_get_timezone (E_CAL_MODEL 
(model)));
                } else {
                        /* we assume that COMPLETED is entered in the current timezone,
                         * even though it gets stored in UTC */
-                       t = icaltime_as_timet_with_zone (dv->tt, dv->zone);
+                       t = i_cal_time_as_timet_with_zone (tt, dv->zone);
                }
 
                ensure_task_complete (comp_data, t);
@@ -442,7 +501,7 @@ set_complete (ECalModelComponent *comp_data,
        if (state)
                ensure_task_complete (comp_data, -1);
        else
-               ensure_task_not_complete (comp_data);
+               ensure_task_not_complete (comp_data, TRUE);
 }
 
 static void
@@ -450,7 +509,7 @@ set_due (ECalModel *model,
          ECalModelComponent *comp_data,
          gconstpointer value)
 {
-       e_cal_model_update_comp_time (model, comp_data, value, ICAL_DUE_PROPERTY, icalproperty_set_due, 
icalproperty_new_due);
+       e_cal_model_update_comp_time (model, comp_data, value, I_CAL_DUE_PROPERTY, i_cal_property_set_due, 
i_cal_property_new_due);
 }
 
 /* FIXME: We need to set the "transient_for" property for the dialog, but the
@@ -472,32 +531,32 @@ static void
 set_geo (ECalModelComponent *comp_data,
          const gchar *value)
 {
-       gdouble latitude, longitude;
+       gdouble latitude = 0.0, longitude = 0.0;
        gint matched;
-       struct icalgeotype geo;
-       icalproperty *prop;
+       ICalGeoType *geo;
+       ICalProperty *prop;
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_GEO_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_GEO_PROPERTY);
 
        if (string_is_empty (value)) {
                if (prop) {
-                       icalcomponent_remove_property (comp_data->icalcomp, prop);
-                       icalproperty_free (prop);
+                       i_cal_component_remove_property (comp_data->icalcomp, prop);
+                       g_object_unref (prop);
                }
        } else {
                matched = sscanf (value, "%lg , %lg", &latitude, &longitude);
                if (matched != 2)
                        show_geo_warning ();
 
-               geo.lat = latitude;
-               geo.lon = longitude;
-               if (prop)
-                       icalproperty_set_geo (prop, geo);
-               else {
-                       prop = icalproperty_new_geo (geo);
-                       icalcomponent_add_property (comp_data->icalcomp, prop);
-               }
+               geo = i_cal_geo_type_new (latitude, longitude);
 
+               if (prop) {
+                       i_cal_property_set_geo (prop, geo);
+                       g_object_unref (prop);
+               } else {
+                       prop = i_cal_property_new_geo (geo);
+                       i_cal_component_take_property (comp_data->icalcomp, prop);
+               }
        }
 }
 
@@ -505,41 +564,46 @@ static void
 set_status (ECalModelComponent *comp_data,
             const gchar *value)
 {
-       icalproperty_status status;
-       icalproperty *prop;
+       ICalPropertyStatus status;
+       ICalProperty *prop;
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_STATUS_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_STATUS_PROPERTY);
 
        /* an empty string is the same as 'None' */
-       if (!value[0])
+       if (!value[0]) {
+               g_clear_object (&prop);
                return;
+       }
 
        /* Translators: "None" for task's status */
-       if (!e_util_utf8_strcasecmp (value, C_("cal-task-status", "None")))
+       if (!e_util_utf8_strcasecmp (value, C_("cal-task-status", "None"))) {
+               g_clear_object (&prop);
                return;
-       else if (!e_util_utf8_strcasecmp (value, _("Not Started")))
-               status = ICAL_STATUS_NEEDSACTION;
+       } else if (!e_util_utf8_strcasecmp (value, _("Not Started")))
+               status = I_CAL_STATUS_NEEDSACTION;
        else if (!e_util_utf8_strcasecmp (value, _("In Progress")))
-               status = ICAL_STATUS_INPROCESS;
+               status = I_CAL_STATUS_INPROCESS;
        else if (!e_util_utf8_strcasecmp (value, _("Completed")))
-               status = ICAL_STATUS_COMPLETED;
+               status = I_CAL_STATUS_COMPLETED;
        else if (!e_util_utf8_strcasecmp (value, _("Cancelled")))
-               status = ICAL_STATUS_CANCELLED;
+               status = I_CAL_STATUS_CANCELLED;
        else {
+               g_clear_object (&prop);
                g_warning ("Invalid status: %s\n", value);
                return;
        }
 
-       if (prop)
-               icalproperty_set_status (prop, status);
-       else {
-               prop = icalproperty_new_status (status);
-               icalcomponent_add_property (comp_data->icalcomp, prop);
+       if (prop) {
+               i_cal_property_set_status (prop, status);
+               g_object_unref (prop);
+       } else {
+               prop = i_cal_property_new_status (status);
+               i_cal_component_take_property (comp_data->icalcomp, prop);
        }
 
        switch (status) {
        case ICAL_STATUS_NEEDSACTION:
-               ensure_task_not_complete (comp_data);
+               ensure_task_not_complete (comp_data, TRUE);
                break;
 
        case ICAL_STATUS_INPROCESS:
@@ -547,9 +611,7 @@ set_status (ECalModelComponent *comp_data,
                break;
 
        case ICAL_STATUS_CANCELLED:
-               ensure_task_not_complete (comp_data);
-               /* do this again, because the previous function changed status to NEEDSACTION */
-               icalproperty_set_status (prop, status);
+               ensure_task_not_complete (comp_data, FALSE);
                break;
 
        case ICAL_STATUS_COMPLETED:
@@ -567,36 +629,37 @@ static void
 set_percent (ECalModelComponent *comp_data,
              gconstpointer value)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
        gint percent = GPOINTER_TO_INT (value);
 
        g_return_if_fail (percent >= -1);
        g_return_if_fail (percent <= 100);
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_PERCENTCOMPLETE_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_PERCENTCOMPLETE_PROPERTY);
 
        /* A value of -1 means it isn't set */
        if (percent == -1) {
                if (prop) {
-                       icalcomponent_remove_property (comp_data->icalcomp, prop);
-                       icalproperty_free (prop);
+                       i_cal_component_remove_property (comp_data->icalcomp, prop);
+                       g_object_unref (prop);
                }
-               ensure_task_not_complete (comp_data);
+               ensure_task_not_complete (comp_data, TRUE);
        } else {
-               if (prop)
-                       icalproperty_set_percentcomplete (prop, percent);
-               else {
-                       prop = icalproperty_new_percentcomplete (percent);
-                       icalcomponent_add_property (comp_data->icalcomp, prop);
+               if (prop) {
+                       i_cal_property_set_percentcomplete (prop, percent);
+                       g_object_urnef (prop);
+               } else {
+                       prop = i_cal_property_new_percentcomplete (percent);
+                       i_cal_component_take_property (comp_data->icalcomp, prop);
                }
 
                if (percent == 100)
                        ensure_task_complete (comp_data, -1);
                else {
-                       prop = icalcomponent_get_first_property (comp_data->icalcomp, 
ICAL_COMPLETED_PROPERTY);
+                       prop = i_cal_component_get_first_property (comp_data->icalcomp, 
I_CAL_COMPLETED_PROPERTY);
                        if (prop) {
-                               icalcomponent_remove_property (comp_data->icalcomp, prop);
-                               icalproperty_free (prop);
+                               i_cal_component_remove_property (comp_data->icalcomp, prop);
+                               g_object_unref (prop);
                        }
 
                        if (percent > 0)
@@ -610,10 +673,10 @@ static void
 set_priority (ECalModelComponent *comp_data,
               const gchar *value)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
        gint priority;
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_PRIORITY_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_PRIORITY_PROPERTY);
 
        priority = e_cal_util_priority_from_string (value);
        if (priority == -1) {
@@ -621,11 +684,12 @@ set_priority (ECalModelComponent *comp_data,
                priority = 0;
        }
 
-       if (prop)
-               icalproperty_set_priority (prop, priority);
-       else {
-               prop = icalproperty_new_priority (priority);
-               icalcomponent_add_property (comp_data->icalcomp, prop);
+       if (prop) {
+               i_cal_property_set_priority (prop, priority);
+               g_object_unref (prop);
+       } else {
+               prop = i_cal_property_new_priority (priority);
+               i_cal_component_take_property (comp_data->icalcomp, prop);
        }
 }
 
@@ -633,21 +697,22 @@ static void
 set_url (ECalModelComponent *comp_data,
          const gchar *value)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_URL_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_URL_PROPERTY);
 
        if (string_is_empty (value)) {
                if (prop) {
-                       icalcomponent_remove_property (comp_data->icalcomp, prop);
-                       icalproperty_free (prop);
+                       i_cal_component_remove_property (comp_data->icalcomp, prop);
+                       g_object_unref (prop);
                }
        } else {
-               if (prop)
-                       icalproperty_set_url (prop, value);
-               else {
-                       prop = icalproperty_new_url (value);
-                       icalcomponent_add_property (comp_data->icalcomp, prop);
+               if (prop) {
+                       i_cal_property_set_url (prop, value);
+                       g_object_unref (prop);
+               } else {
+                       prop = i_cal_property_new_url (value);
+                       i_cal_component_take_property (comp_data->icalcomp, prop);
                }
        }
 }
@@ -656,21 +721,22 @@ static void
 set_location (ECalModelComponent *comp_data,
               gconstpointer value)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_LOCATION_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_LOCATION_PROPERTY);
 
        if (string_is_empty (value)) {
                if (prop) {
-                       icalcomponent_remove_property (comp_data->icalcomp, prop);
-                       icalproperty_free (prop);
+                       i_cal_component_remove_property (comp_data->icalcomp, prop);
+                       g_object_unref (prop);
                }
        } else {
-               if (prop)
-                       icalproperty_set_location (prop, (const gchar *) value);
-               else {
-                       prop = icalproperty_new_location ((const gchar *) value);
-                       icalcomponent_add_property (comp_data->icalcomp, prop);
+               if (prop) {
+                       i_cal_property_set_location (prop, (const gchar *) value);
+                       g_object_unref (prop);
+               } else {
+                       prop = i_cal_property_new_location ((const gchar *) value);
+                       i_cal_component_take_property (comp_data->icalcomp, prop);
                }
        }
 }
@@ -1003,7 +1069,7 @@ cal_model_tasks_duplicate_value (ETableModel *etm,
        switch (col) {
        case E_CAL_MODEL_TASKS_FIELD_COMPLETED :
        case E_CAL_MODEL_TASKS_FIELD_DUE :
-               return e_cal_model_copy_cell_date_value (value);
+               return e_cell_date_edit_value_copy (value);
 
        case E_CAL_MODEL_TASKS_FIELD_GEO :
        case E_CAL_MODEL_TASKS_FIELD_PRIORITY :
@@ -1386,7 +1452,7 @@ void
 e_cal_model_tasks_mark_comp_incomplete (ECalModelTasks *model,
                                         ECalModelComponent *comp_data)
 {
-       icalproperty *prop,*prop1;
+       ICalProperty *prop;
 
        g_return_if_fail (model != NULL);
        g_return_if_fail (comp_data != NULL);
@@ -1395,25 +1461,18 @@ e_cal_model_tasks_mark_comp_incomplete (ECalModelTasks *model,
        /*e_table_model_pre_change (E_TABLE_MODEL (model));*/
 
        /* Status */
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_STATUS_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_STATUS_PROPERTY);
        if (prop)
-               icalproperty_set_status (prop, ICAL_STATUS_NEEDSACTION);
+               i_cal_property_set_status (prop, ICAL_STATUS_NEEDSACTION);
        else
-               icalcomponent_add_property (comp_data->icalcomp, icalproperty_new_status 
(ICAL_STATUS_NEEDSACTION));
+               i_cal_component_take_property (comp_data->icalcomp, i_cal_property_new_status 
(I_CAL_STATUS_NEEDSACTION));
+       g_clear_object (&prop);
 
        /*complete property*/
-       prop1 = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_COMPLETED_PROPERTY);
-       if (prop1) {
-               icalcomponent_remove_property (comp_data->icalcomp, prop1);
-               icalproperty_free (prop1);
-       }
+       e_cal_util_component_remove_property_by_kind (comp_data->icalcomp, I_CAL_COMPLETED_PROPERTY, TRUE);
 
        /* Percent. */
-       prop1 = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_PERCENTCOMPLETE_PROPERTY);
-       if (prop1) {
-               icalcomponent_remove_property (comp_data->icalcomp, prop1);
-               icalproperty_free (prop1);
-       }
+       e_cal_util_component_remove_property_by_kind (comp_data->icalcomp, I_CAL_PERCENTCOMPLETE_PROPERTY, 
TRUE);
 
        /*e_table_model_row_changed (E_TABLE_MODEL (model), model_row);*/
 
diff --git a/src/calendar/gui/e-cal-model.c b/src/calendar/gui/e-cal-model.c
index 78bf368f18..8bdee39d93 100644
--- a/src/calendar/gui/e-cal-model.c
+++ b/src/calendar/gui/e-cal-model.c
@@ -64,8 +64,8 @@ struct _ECalModelPrivate {
        /* Array for storing the objects. Each element is of type ECalModelComponent */
        GPtrArray *objects;
 
-       icalcomponent_kind kind;
-       icaltimezone *zone;
+       ICalComponentKind kind;
+       ICalTimezone *zone;
 
        /* The time range to display */
        time_t start;
@@ -197,36 +197,26 @@ G_DEFINE_TYPE (ECalModelComponent, e_cal_model_component, G_TYPE_OBJECT)
 static void
 e_cal_model_component_set_icalcomponent (ECalModelComponent *comp_data,
                                         ECalModel *model,
-                                        icalcomponent *icalcomp)
+                                        ICalComponent *icomp)
 {
        if (model != NULL)
                g_return_if_fail (E_IS_CAL_MODEL (model));
        g_return_if_fail (comp_data != NULL);
 
-       #define free_ptr(x) { \
-               if (x) { \
-                       g_free (x); \
-                       x = NULL; \
-               } \
-       }
-
-       if (comp_data->icalcomp)
-               icalcomponent_free (comp_data->icalcomp);
-       comp_data->icalcomp = icalcomp;
+       g_clear_object (&comp_data->icalcomp);
+       comp_data->icalcomp = icomp;
 
        if (comp_data->priv->categories_str)
                g_string_free (comp_data->priv->categories_str, TRUE);
        comp_data->priv->categories_str = NULL;
 
-       free_ptr (comp_data->dtstart);
-       free_ptr (comp_data->dtend);
-       free_ptr (comp_data->due);
-       free_ptr (comp_data->completed);
-       free_ptr (comp_data->created);
-       free_ptr (comp_data->lastmodified);
-       free_ptr (comp_data->color);
-
-       #undef free_ptr
+       g_clear_pointer (&comp_data->dtstart, e_cell_date_edit_value_free);
+       g_clear_pointer (&comp_data->dtend, e_cell_date_edit_value_free);
+       g_clear_pointer (&comp_data->due, e_cell_date_edit_value_free);
+       g_clear_pointer (&comp_data->completed, e_cell_date_edit_value_free);
+       g_clear_pointer (&comp_data->created, e_cell_date_edit_value_free);
+       g_clear_pointer (&comp_data->lastmodified, e_cell_date_edit_value_free);
+       g_clear_pointer (&comp_data->color, g_free);
 
        if (comp_data->icalcomp && model)
                e_cal_model_set_instance_times (comp_data, model->priv->zone);
@@ -271,14 +261,14 @@ static gpointer
 get_categories (ECalModelComponent *comp_data)
 {
        if (!comp_data->priv->categories_str) {
-               icalproperty *prop;
+               ICalProperty *prop;
 
                comp_data->priv->categories_str = g_string_new ("");
 
-               for (prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_CATEGORIES_PROPERTY);
+               for (prop = i_cal_component_get_first_property (comp_data->icalcomp, 
I_CAL_CATEGORIES_PROPERTY);
                     prop;
-                    prop = icalcomponent_get_next_property (comp_data->icalcomp, ICAL_CATEGORIES_PROPERTY)) {
-                       const gchar *categories = icalproperty_get_categories (prop);
+                    g_object_urnef (prop), prop = i_cal_component_get_next_property (comp_data->icalcomp, 
I_CAL_CATEGORIES_PROPERTY)) {
+                       const gchar *categories = i_cal_property_get_categories (prop);
                        if (!categories)
                                continue;
 
@@ -294,23 +284,24 @@ get_categories (ECalModelComponent *comp_data)
 static gchar *
 get_classification (ECalModelComponent *comp_data)
 {
-       icalproperty *prop;
-       icalproperty_class class;
+       ICalProperty *prop;
+       ICalPropertyClass class_prop;
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_CLASS_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_CLASS_PROPERTY);
 
        if (!prop)
                return _("Public");
 
-       class = icalproperty_get_class (prop);
+       class_prop = i_cal_property_get_class (prop);
 
-       switch (class)
-       {
-       case ICAL_CLASS_PUBLIC:
+       g_clear_object (&prop);
+
+       switch (class) {
+       case I_CAL_CLASS_PUBLIC:
                return _("Public");
-       case ICAL_CLASS_PRIVATE:
+       case I_CAL_CLASS_PRIVATE:
                return _("Private");
-       case ICAL_CLASS_CONFIDENTIAL:
+       case I_CAL_CLASS_CONFIDENTIAL:
                return _("Confidential");
        default:
                return _("Unknown");
@@ -329,19 +320,18 @@ get_color (ECalModel *model,
 static gpointer
 get_description (ECalModelComponent *comp_data)
 {
-       icalproperty *prop;
-
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DESCRIPTION_PROPERTY);
-       if (prop) {
-               GString *str = g_string_new (NULL);
-               do {
-                       str = g_string_append (str, icalproperty_get_description (prop));
-               } while ((prop = icalcomponent_get_next_property (comp_data->icalcomp, 
ICAL_DESCRIPTION_PROPERTY)));
+       ICalProperty *prop;
+       GString *str = NULL;
 
-               return g_string_free (str, FALSE);
+       for (prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_DESCRIPTION_PROPERTY);
+            prop;
+            g_object_unref (prop), prop = i_cal_component_get_next_property (comp_data->icalcomp, 
I_CAL_DESCRIPTION_PROPERTY)) {
+               if (!str)
+                       str = g_string_new (NULL);
+               g_string_append (str, i_cal_property_get_description (prop));
        }
 
-       return g_strdup ("");
+       return str ? g_string_free (str, FALSE) : g_strdup ("");
 }
 
 static ECellDateEditValue *
@@ -349,103 +339,111 @@ get_dtstart (ECalModel *model,
              ECalModelComponent *comp_data)
 {
        ECalModelPrivate *priv;
-       struct icaltimetype tt_start;
+       ICalTimetype *tt_start;
 
        priv = model->priv;
 
        if (!comp_data->dtstart) {
-               icalproperty *prop;
-               icaltimezone *zone;
+               ICalProperty *prop;
+               ICalTimezone *zone;
                gboolean got_zone = FALSE;
 
-               prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DTSTART_PROPERTY);
+               prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_DTSTART_PROPERTY);
                if (!prop)
                        return NULL;
 
-               tt_start = icalproperty_get_dtstart (prop);
+               tt_start = i_cal_property_get_dtstart (prop);
 
-               if (icaltime_get_tzid (tt_start)
-                   && e_cal_client_get_timezone_sync (comp_data->client, icaltime_get_tzid (tt_start), 
&zone, NULL, NULL))
+               if (i_cal_time_get_tzid (tt_start)
+                   && e_cal_client_get_timezone_sync (comp_data->client, i_cal_time_get_tzid (tt_start), 
&zone, NULL, NULL))
                        got_zone = TRUE;
 
                if (e_cal_data_model_get_expand_recurrences (priv->data_model)) {
-                       if (got_zone)
-                               tt_start = icaltime_from_timet_with_zone (comp_data->instance_start, 
tt_start.is_date, zone);
-                       else if (priv->zone)
-                               tt_start = icaltime_from_timet_with_zone (comp_data->instance_start, 
tt_start.is_date, priv->zone);
+                       gboolean is_date = i_cal_time_is_date (tt_start);
+
+                       if (got_zone) {
+                               g_clear_obejct (&tt_start);
+                               tt_start = i_cal_time_from_timet_with_zone (comp_data->instance_start, 
is_date, zone);
+                       } else if (priv->zone) {
+                               g_clear_obejct (&tt_start);
+                               tt_start = i_cal_time_from_timet_with_zone (comp_data->instance_start, 
is_date, priv->zone);
+                       }
                }
 
-               if (!icaltime_is_valid_time (tt_start) || icaltime_is_null_time (tt_start))
-                       return NULL;
+               g_object_unref (prop);
 
-               comp_data->dtstart = g_new0 (ECellDateEditValue, 1);
-               comp_data->dtstart->tt = tt_start;
+               if (!i_cal_time_is_valid_time (tt_start) || i_cal_time_is_null_time (tt_start)) {
+                       g_clear_object (&tt_start);
+                       return NULL;
+               }
 
-               if (got_zone)
-                       comp_data->dtstart->zone = zone;
-               else
-                       comp_data->dtstart->zone = NULL;
+               comp_data->dtstart = e_cell_date_edit_value_new_take (tt_start, (got_zone && zone) ? 
e_cal_util_copy_timezone (zone) : NULL);
        }
 
-       return e_cal_model_copy_cell_date_value (comp_data->dtstart);
+       return e_cell_date_edit_value_copy (comp_data->dtstart);
 }
 
 static ECellDateEditValue *
 get_datetime_from_utc (ECalModel *model,
                        ECalModelComponent *comp_data,
-                       icalproperty_kind propkind,
-                       struct icaltimetype (*get_value) (const icalproperty *prop),
+                       ICalPropertyKind propkind,
+                       ICalTimetype (*get_value) (const ICalProperty *prop),
                       ECellDateEditValue **buffer)
 {
        g_return_val_if_fail (buffer != NULL, NULL);
 
        if (!*buffer) {
                ECalModelPrivate *priv;
-               struct icaltimetype tt_value;
-               icalproperty *prop;
-               ECellDateEditValue *res;
+               ICalTimetype *tt_value;
+               ICalProperty *prop;
 
                priv = model->priv;
 
-               prop = icalcomponent_get_first_property (comp_data->icalcomp, propkind);
+               prop = i_cal_component_get_first_property (comp_data->icalcomp, propkind);
                if (!prop)
                        return NULL;
 
                tt_value = get_value (prop);
 
                /* these are always in UTC, thus convert to default zone, if any and done */
-               if (priv->zone)
-                       icaltimezone_convert_time (&tt_value, icaltimezone_get_utc_timezone (), priv->zone);
+               if (priv->zone) {
+                       i_cal_timezone_convert_time (tt_value, i_cal_timezone_get_utc_timezone (), 
priv->zone);
 
-               if (!icaltime_is_valid_time (tt_value) || icaltime_is_null_time (tt_value))
-                       return NULL;
+               g_object_unref (prop);
 
-               res = g_new0 (ECellDateEditValue, 1);
-               res->tt = tt_value;
-               res->zone = NULL;
+               if (!i_cal_time_is_valid_time (tt_value) || i_cal_time_is_null_time (tt_value)) {
+                       g_clear_object (&tt_value);
+                       return NULL;
+               }
 
-               *buffer = res;
+               *buffer = e_cell_date_edit_value_new_take (tt_value, NULL);
        }
 
-       return e_cal_model_copy_cell_date_value (*buffer);
+       return e_cell_date_edit_value_copy (*buffer);
 }
 
 static gpointer
 get_summary (ECalModelComponent *comp_data)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
+       gchar *res = NULL;
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_SUMMARY_PROPERTY);
-       if (prop && icalproperty_get_summary (prop))
-               return g_strdup (icalproperty_get_summary (prop));
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_SUMMARY_PROPERTY);
+       if (prop)
+               res = g_strdup (i_cal_property_get_summary (prop));
 
-       return g_strdup ("");
+       g_clear_object (&prop);
+
+       if (!res)
+               res = g_strdup ("");
+
+       return res;
 }
 
 static gchar *
 get_uid (ECalModelComponent *comp_data)
 {
-       return (gchar *) icalcomponent_get_uid (comp_data->icalcomp);
+       return (gchar *) i_cal_component_get_uid (comp_data->icalcomp);
 }
 
 static gchar *
@@ -462,17 +460,10 @@ static void
 set_categories (ECalModelComponent *comp_data,
                 const gchar *value)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
        /* remove all categories first */
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_CATEGORIES_PROPERTY);
-       while (prop) {
-               icalproperty *to_remove = prop;
-               prop = icalcomponent_get_next_property (comp_data->icalcomp, ICAL_CATEGORIES_PROPERTY);
-
-               icalcomponent_remove_property (comp_data->icalcomp, to_remove);
-               icalproperty_free (to_remove);
-       }
+       e_cal_util_component_remove_property_by_kind (comp_data->icalcomp, I_CAL_CATEGORIES_PROPERTY, TRUE);
 
        if (comp_data->priv->categories_str)
                g_string_free (comp_data->priv->categories_str, TRUE);
@@ -482,8 +473,8 @@ set_categories (ECalModelComponent *comp_data,
         * it'll be populated on demand (in the get_categories() function)
        */
        if (value && *value) {
-               prop = icalproperty_new_categories (value);
-               icalcomponent_add_property (comp_data->icalcomp, prop);
+               prop = i_cal_property_new_categories (value);
+               i_cal_component_take_property (comp_data->icalcomp, prop);
        }
 }
 
@@ -491,31 +482,33 @@ static void
 set_classification (ECalModelComponent *comp_data,
                     const gchar *value)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_CLASS_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_CLASS_PROPERTY);
        if (!value || !(*value)) {
                if (prop) {
-                       icalcomponent_remove_property (comp_data->icalcomp, prop);
-                       icalproperty_free (prop);
+                       i_cal_component_remove_property (comp_data->icalcomp, prop);
+                       g_clear_object (&prop);
                }
        } else {
-               icalproperty_class ical_class;
+               ICalPropertyClass ical_class;
 
                if (!g_ascii_strcasecmp (value, "PUBLIC"))
-                       ical_class = ICAL_CLASS_PUBLIC;
+                       ical_class = I_CAL_CLASS_PUBLIC;
                else if (!g_ascii_strcasecmp (value, "PRIVATE"))
-                       ical_class = ICAL_CLASS_PRIVATE;
+                       ical_class = I_CAL_CLASS_PRIVATE;
                else if (!g_ascii_strcasecmp (value, "CONFIDENTIAL"))
-                       ical_class = ICAL_CLASS_CONFIDENTIAL;
+                       ical_class = I_CAL_CLASS_CONFIDENTIAL;
                else
-                       ical_class = ICAL_CLASS_NONE;
+                       ical_class = I_CAL_CLASS_NONE;
 
                if (!prop) {
-                       prop = icalproperty_new_class (ical_class);
-                       icalcomponent_add_property (comp_data->icalcomp, prop);
-               } else
-                       icalproperty_set_class (prop, ical_class);
+                       prop = i_cal_property_new_class (ical_class);
+                       i_cal_component_take_property (comp_data->icalcomp, prop);
+               } else {
+                       i_cal_property_set_class (prop, ical_class);
+                       g_clear_object (&prop);
+               }
        }
 }
 
@@ -523,27 +516,17 @@ static void
 set_description (ECalModelComponent *comp_data,
                  const gchar *value)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
        /* remove old description(s) */
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DESCRIPTION_PROPERTY);
-       while (prop) {
-               icalproperty *next;
-
-               next = icalcomponent_get_next_property (comp_data->icalcomp, ICAL_DESCRIPTION_PROPERTY);
-
-               icalcomponent_remove_property (comp_data->icalcomp, prop);
-               icalproperty_free (prop);
-
-               prop = next;
-       }
+       e_cal_util_component_remove_property_by_kind (comp_data->icalcomp, I_CAL_DESCRIPTION_PROPERTY, TRUE);
 
        /* now add the new description */
        if (!value || !(*value))
                return;
 
-       prop = icalproperty_new_description (value);
-       icalcomponent_add_property (comp_data->icalcomp, prop);
+       prop = i_cal_property_new_description (value);
+       i_cal_component_take_property (comp_data->icalcomp, prop);
 }
 
 static void
@@ -553,61 +536,62 @@ set_dtstart (ECalModel *model,
 {
        e_cal_model_update_comp_time (
                model, comp_data, value,
-               ICAL_DTSTART_PROPERTY,
-               icalproperty_set_dtstart,
-               icalproperty_new_dtstart);
+               I_CAL_DTSTART_PROPERTY,
+               i_cal_property_set_dtstart,
+               i_cal_property_new_dtstart);
 }
 
 static void
 set_summary (ECalModelComponent *comp_data,
              const gchar *value)
 {
-       icalproperty *prop;
+       ICalProperty *prop;
 
-       prop = icalcomponent_get_first_property (
-               comp_data->icalcomp, ICAL_SUMMARY_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_SUMMARY_PROPERTY);
 
        if (string_is_empty (value)) {
                if (prop) {
-                       icalcomponent_remove_property (comp_data->icalcomp, prop);
-                       icalproperty_free (prop);
+                       i_cal_component_remove_property (comp_data->icalcomp, prop);
+                       g_clear_object (&prop);
                }
        } else {
-               if (prop)
-                       icalproperty_set_summary (prop, value);
-               else {
-                       prop = icalproperty_new_summary (value);
-                       icalcomponent_add_property (comp_data->icalcomp, prop);
+               if (prop) {
+                       i_cal_property_set_summary (prop, value);
+                       g_clear_object (&prop);
+               } else {
+                       prop = i_cal_property_new_summary (value);
+                       i_cal_component_take_property (comp_data->icalcomp, prop);
                }
        }
 }
 
 static void
 datetime_to_zone (ECalClient *client,
-                  struct icaltimetype *tt,
-                  icaltimezone *tt_zone,
+                 ICalTimetype *tt,
+                 ICalTimezone *tt_zone,
                   const gchar *tzid)
 {
-       icaltimezone *from, *to;
+       ICalTimezone *from, *to;
        const gchar *tt_tzid = NULL;
 
        g_return_if_fail (tt != NULL);
 
        if (tt_zone)
-               tt_tzid = icaltimezone_get_tzid (tt_zone);
+               tt_tzid = i_cal_timezone_get_tzid (tt_zone);
 
        if (tt_tzid == NULL || tzid == NULL ||
            tt_tzid == tzid || g_str_equal (tt_tzid, tzid))
                return;
 
        from = tt_zone;
-       to = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+       to = i_cal_timezone_get_builtin_timezone_from_tzid (tzid);
        if (!to) {
-               /* do not check failure here, maybe the zone is not available there */
-               e_cal_client_get_timezone_sync (client, tzid, &to, NULL, NULL);
+               /* do not abort on failure here, maybe the zone is not available there */
+               if (!e_cal_client_get_timezone_sync (client, tzid, &to, NULL, NULL))
+                       to = NULL;
        }
 
-       icaltimezone_convert_time (tt, from, to);
+       i_cal_timezone_convert_time (tt, from, to);
 }
 
 static void
@@ -1190,9 +1174,9 @@ cal_model_dispose (GObject *object)
        g_clear_object (&priv->registry);
        g_clear_object (&priv->shell);
        g_clear_object (&priv->client_cache);
+       g_clear_object (&priv->zone);
 
-       g_free (priv->default_source_uid);
-       priv->default_source_uid = NULL;
+       g_clear_pointer (&priv->default_source_uid, g_free);
 
        /* Chain up to parent's dispose() method. */
        G_OBJECT_CLASS (e_cal_model_parent_class)->dispose (object);
@@ -1234,9 +1218,7 @@ cal_model_get_color_for_component (ECalModel *model,
        const gchar *extension_name;
        const gchar *uid;
        gint i, first_empty = 0;
-       #ifdef HAVE_ICAL_COLOR_PROPERTY
-       icalproperty *prop;
-       #endif
+       ICalProperty *prop;
 
        static AssignedColorData assigned_colors[] = {
                { "#BECEDD", NULL }, /* 190 206 221     Blue */
@@ -1253,20 +1235,22 @@ cal_model_get_color_for_component (ECalModel *model,
 
        g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
 
-       #ifdef HAVE_ICAL_COLOR_PROPERTY
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_COLOR_PROPERTY);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_COLOR_PROPERTY);
        if (prop) {
                GdkRGBA rgba;
 
-               color_spec = icalproperty_get_color (prop);
+               color_spec = i_cal_property_get_color (prop);
                if (color_spec && gdk_rgba_parse (&rgba, color_spec)) {
                        g_free (comp_data->color);
                        comp_data->color = g_strdup (color_spec);
 
+                       g_object_unref (prop);
+
                        return comp_data->color;
                }
+
+               g_object_unref (prop);
        }
-       #endif
 
        switch (e_cal_client_get_source_type (comp_data->client)) {
                case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
@@ -1398,7 +1382,7 @@ cal_model_create_component_from_values_thread (EAlertSinkThreadJobData *job_data
        ESource *source;
        EClient *client;
        ECalModelComponent *comp_data;
-       icalproperty *prop;
+       ICalProperty *prop;
        const gchar *source_uid;
        gchar *display_name;
        GError *local_error = NULL;
@@ -1456,15 +1440,17 @@ cal_model_create_component_from_values_thread (EAlertSinkThreadJobData *job_data
 
                        if (tt > 0) {
                                /* Store Memo DTSTART as date, not as date-time */
-                               struct icaltimetype itt = icaltime_from_timet_with_zone (tt,
-                                       icalcomponent_isa (comp_data->icalcomp) == ICAL_VJOURNAL_COMPONENT, 
e_cal_model_get_timezone (ccd->model));
-                               icalproperty *prop = icalcomponent_get_first_property (comp_data->icalcomp, 
ICAL_DTSTART_PROPERTY);
+                               ICalTimetype *itt = i_cal_time_from_timet_with_zone (tt,
+                                       i_cal_component_isa (comp_data->icalcomp) == 
I_CAL_VJOURNAL_COMPONENT, e_cal_model_get_timezone (ccd->model));
+
+                               prop = i_cal_component_get_first_property (comp_data->icalcomp, 
I_CAL_DTSTART_PROPERTY);
 
                                if (prop) {
-                                       icalproperty_set_dtstart (prop, itt);
+                                       i_cal_property_set_dtstart (prop, itt);
+                                       g_object_unref (prop);
                                } else {
-                                       prop = icalproperty_new_dtstart (itt);
-                                       icalcomponent_add_property (comp_data->icalcomp, prop);
+                                       prop = i_cal_property_new_dtstart (itt);
+                                       i_cal_component_take_property (comp_data->icalcomp, prop);
                                }
                        }
                }
@@ -1475,21 +1461,25 @@ cal_model_create_component_from_values_thread (EAlertSinkThreadJobData *job_data
                        model_class->fill_component_from_values (ccd->model, comp_data, ccd->values);
                }
 
-               prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_CLASS_PROPERTY);
-               if (!prop || icalproperty_get_class (prop) == ICAL_CLASS_NONE) {
-                       icalproperty_class ical_class = ICAL_CLASS_PUBLIC;
+               prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_CLASS_PROPERTY);
+               if (!prop || i_cal_property_get_class (prop) == I_CAL_CLASS_NONE) {
+                       ICalPropertyClass ical_class = I_CAL_CLASS_PUBLIC;
                        GSettings *settings;
 
                        settings = e_util_ref_settings ("org.gnome.evolution.calendar");
                        if (g_settings_get_boolean (settings, "classify-private"))
-                               ical_class = ICAL_CLASS_PRIVATE;
+                               ical_class = I_CAL_CLASS_PRIVATE;
                        g_object_unref (settings);
 
                        if (!prop) {
-                               prop = icalproperty_new_class (ical_class);
-                               icalcomponent_add_property (comp_data->icalcomp, prop);
-                       } else
-                               icalproperty_set_class (prop, ical_class);
+                               prop = i_cal_property_new_class (ical_class);
+                               i_cal_component_take_property (comp_data->icalcomp, prop);
+                       } else {
+                               i_cal_property_set_class (prop, ical_class);
+                               g_object_unref (prop);
+                       }
+               } else {
+                       g_clear_object (&prop);
                }
 
                ccd->success = e_cal_client_create_object_sync (comp_data->client, comp_data->icalcomp, &uid, 
cancellable, error);
@@ -1602,25 +1592,20 @@ cal_model_value_at (ETableModel *etm,
        case E_CAL_MODEL_FIELD_CREATED :
                return (gpointer) get_datetime_from_utc (
                        model, comp_data, ICAL_CREATED_PROPERTY,
-                       icalproperty_get_created, &comp_data->created);
+                       i_cal_property_get_created, &comp_data->created);
        case E_CAL_MODEL_FIELD_LASTMODIFIED :
                return (gpointer) get_datetime_from_utc (
-                       model, comp_data, ICAL_LASTMODIFIED_PROPERTY,
-                       icalproperty_get_lastmodified, &comp_data->lastmodified);
+                       model, comp_data, I_CAL_LASTMODIFIED_PROPERTY,
+                       i_cal_property_get_lastmodified, &comp_data->lastmodified);
        case E_CAL_MODEL_FIELD_HAS_ALARMS :
-               return GINT_TO_POINTER (
-                       icalcomponent_get_first_component (
-                               comp_data->icalcomp,
-                               ICAL_VALARM_COMPONENT) != NULL);
+               return GINT_TO_POINTER (e_cal_util_component_has_property (comp_data->icalcomp, 
I_CAL_VALARM_COMPONENT));
        case E_CAL_MODEL_FIELD_ICON :
        {
                ECalComponent *comp;
-               icalcomponent *icalcomp;
                gint retval = 0;
 
-               comp = e_cal_component_new ();
-               icalcomp = icalcomponent_new_clone (comp_data->icalcomp);
-               if (e_cal_component_set_icalcomponent (comp, icalcomp)) {
+               comp = e_cal_component_new_from_icalcomponent (i_cal_component_new_clone 
(comp_data->icalcomp));
+               if (comp) {
                        if (e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_JOURNAL) {
                                g_object_unref (comp);
                                return GINT_TO_POINTER (retval);
@@ -1633,14 +1618,14 @@ cal_model_value_at (ETableModel *etm,
                        else {
                                GSList *attendees = NULL, *sl;
 
-                               e_cal_component_get_attendee_list (comp, &attendees);
+                               attendees = e_cal_component_get_attendees (comp);
                                for (sl = attendees; sl != NULL; sl = sl->next) {
                                        ECalComponentAttendee *ca = sl->data;
                                        const gchar *text;
 
-                                       text = itip_strip_mailto (ca->value);
+                                       text = itip_strip_mailto (e_cal_component_attendee_get_value (ca));
                                        if (itip_address_is_user (registry, text)) {
-                                               if (ca->delto != NULL)
+                                               if (e_cal_component_attendee_get_delegatedto (ca) != NULL)
                                                        retval = 3;
                                                else
                                                        retval = 2;
@@ -1648,12 +1633,11 @@ cal_model_value_at (ETableModel *etm,
                                        }
                                }
 
-                               e_cal_component_free_attendee_list (attendees);
+                               g_slist_free_full (attendees, e_cal_component_attendee_free);
                        }
-               } else
-                       icalcomponent_free (icalcomp);
 
-               g_object_unref (comp);
+                       g_object_unref (comp);
+               }
 
                return GINT_TO_POINTER (retval);
        }
@@ -1664,7 +1648,7 @@ cal_model_value_at (ETableModel *etm,
        case E_CAL_MODEL_FIELD_SOURCE:
                return get_source_description (registry, comp_data);
        case E_CAL_MODEL_FIELD_CANCELLED:
-               return GINT_TO_POINTER (icalcomponent_get_status (comp_data->icalcomp) == 
ICAL_STATUS_CANCELLED ? 1 : 0);
+               return GINT_TO_POINTER (i_cal_component_get_status (comp_data->icalcomp) == 
I_CAL_STATUS_CANCELLED ? 1 : 0);
        }
 
        return (gpointer) "";
@@ -1765,11 +1749,11 @@ cal_model_duplicate_value (ETableModel *etm,
        case E_CAL_MODEL_FIELD_CANCELLED:
                return (gpointer) value;
        case E_CAL_MODEL_FIELD_COMPONENT :
-               return icalcomponent_new_clone ((icalcomponent *) value);
+               return i_cal_component_new_clone ((ICalComponent *) value);
        case E_CAL_MODEL_FIELD_DTSTART :
        case E_CAL_MODEL_FIELD_CREATED :
        case E_CAL_MODEL_FIELD_LASTMODIFIED :
-               return e_cal_model_copy_cell_date_value (value);
+               return e_cell_date_edit_value_copy (value);
        }
 
        return NULL;
@@ -1804,7 +1788,7 @@ cal_model_free_value (ETableModel *etm,
                break;
        case E_CAL_MODEL_FIELD_COMPONENT :
                if (value)
-                       icalcomponent_free ((icalcomponent *) value);
+                       g_object_unref ((ICalComponent *) value);
                break;
        }
 }
@@ -1937,13 +1921,14 @@ e_cal_model_get_component_index (ECalModel *model,
                if (comp_data) {
                        const gchar *uid;
                        gchar *rid = NULL;
-                       struct icaltimetype icalrid;
+                       ICalTimetype *iclrid;
                        gboolean has_rid = (id->rid && *id->rid);
 
-                       uid = icalcomponent_get_uid (comp_data->icalcomp);
-                       icalrid = icalcomponent_get_recurrenceid (comp_data->icalcomp);
-                       if (!icaltime_is_null_time (icalrid))
-                               rid = icaltime_as_ical_string_r (icalrid);
+                       uid = i_cal_component_get_uid (comp_data->icalcomp);
+                       iclrid = i_cal_component_get_recurrenceid (comp_data->icalcomp);
+                       if (!i_cal_time_is_null_time (iclrid))
+                               rid = i_cal_time_as_ical_string_r (iclrid);
+                       g_clear_object (&iclrid);
 
                        if (uid && *uid) {
                                if ((!client || comp_data->client == client) && strcmp (id->uid, uid) == 0) {
@@ -1975,7 +1960,7 @@ cal_model_data_subscriber_component_added_or_modified (ECalDataModelSubscriber *
        ECalModelComponent *comp_data;
        ETableModel *table_model;
        ECalComponentId *id;
-       icalcomponent *icalcomp;
+       ICalComponent *icomp;
        gint index;
 
        model = E_CAL_MODEL (subscriber);
@@ -1990,7 +1975,7 @@ cal_model_data_subscriber_component_added_or_modified (ECalDataModelSubscriber *
                return;
 
        table_model = E_TABLE_MODEL (model);
-       icalcomp = icalcomponent_new_clone (e_cal_component_get_icalcomponent (comp));
+       icomp = i_cal_component_new_clone (e_cal_component_get_icalcomponent (comp));
 
        if (index < 0) {
                e_table_model_pre_change (table_model);
@@ -1998,7 +1983,7 @@ cal_model_data_subscriber_component_added_or_modified (ECalDataModelSubscriber *
                comp_data = g_object_new (E_TYPE_CAL_MODEL_COMPONENT, NULL);
                comp_data->is_new_component = FALSE;
                comp_data->client = g_object_ref (client);
-               comp_data->icalcomp = icalcomp;
+               comp_data->icalcomp = icomp;
                e_cal_model_set_instance_times (comp_data, model->priv->zone);
                g_ptr_array_add (model->priv->objects, comp_data);
 
@@ -2007,7 +1992,7 @@ cal_model_data_subscriber_component_added_or_modified (ECalDataModelSubscriber *
                e_table_model_pre_change (table_model);
 
                comp_data = g_ptr_array_index (model->priv->objects, index);
-               e_cal_model_component_set_icalcomponent (comp_data, model, icalcomp);
+               e_cal_model_component_set_icalcomponent (comp_data, model, icomp);
 
                e_table_model_row_changed (table_model, index);
        }
@@ -2038,16 +2023,17 @@ e_cal_model_data_subscriber_component_removed (ECalDataModelSubscriber *subscrib
        ECalModel *model;
        ECalModelComponent *comp_data;
        ETableModel *table_model;
-       ECalComponentId id;
+       ECalComponentId *id;
        GSList *link;
        gint index;
 
        model = E_CAL_MODEL (subscriber);
 
-       id.uid = (gchar *) uid;
-       id.rid = (gchar *) rid;
+       id = e_cal_component_id_new (uid, rid);
+
+       index = e_cal_model_get_component_index (model, client, id);
 
-       index = e_cal_model_get_component_index (model, client, &id);
+       e_cal_component_id_free (id);
 
        if (index < 0)
                return;
@@ -2577,10 +2563,10 @@ e_cal_model_class_init (ECalModelClass *class)
                G_SIGNAL_RUN_LAST,
                G_STRUCT_OFFSET (ECalModelClass, timezone_changed),
                NULL, NULL,
-               e_marshal_VOID__POINTER_POINTER,
+               e_marshal_VOID__OBJECT_OBJECT,
                G_TYPE_NONE, 2,
-               G_TYPE_POINTER,
-               G_TYPE_POINTER);
+               I_CAL_TYPE_TIMEZONE,
+               I_CAL_TYPE_TIMEZONE);
 
        signals[OBJECT_CREATED] = g_signal_new (
                "object-created",
@@ -2640,25 +2626,25 @@ void
 e_cal_model_update_comp_time (ECalModel *model,
                               ECalModelComponent *comp_data,
                               gconstpointer time_value,
-                              icalproperty_kind kind,
-                              void (*set_func) (icalproperty *prop,
-                                                struct icaltimetype v),
-                              icalproperty * (*new_func) (struct icaltimetype v))
+                              ICalPropertyKind kind,
+                              void (*set_func) (ICalProperty *prop,
+                                                ICalTimetype *v),
+                              ICalProperty * (*new_func) (ICalTimetype *v))
 {
        ECellDateEditValue *dv = (ECellDateEditValue *) time_value;
-       icalproperty *prop;
-       icalparameter *param;
-       icaltimezone *model_zone;
-       struct icaltimetype tt;
+       ICalProperty *prop;
+       ICalParameter *param;
+       ICalTimezone *model_zone;
+       ICalTimetype *tt;
 
        g_return_if_fail (model != NULL);
        g_return_if_fail (comp_data != NULL);
        g_return_if_fail (set_func != NULL);
        g_return_if_fail (new_func != NULL);
 
-       prop = icalcomponent_get_first_property (comp_data->icalcomp, kind);
+       prop = i_cal_component_get_first_property (comp_data->icalcomp, kind);
        if (prop)
-               param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER);
+               param = i_cal_property_get_first_parameter (prop, I_CAL_TZID_PARAMETER);
        else
                param = NULL;
 
@@ -2666,39 +2652,43 @@ e_cal_model_update_comp_time (ECalModel *model,
         * we remove it if it exists. */
        if (!dv) {
                if (prop) {
-                       icalcomponent_remove_property (comp_data->icalcomp, prop);
-                       icalproperty_free (prop);
+                       i_cal_component_remove_property (comp_data->icalcomp, prop);
+                       g_object_unref (prop);
                }
 
                return;
        }
 
        model_zone = e_cal_model_get_timezone (model);
-       tt = dv->tt;
-       datetime_to_zone (comp_data->client, &tt, model_zone, param ? icalparameter_get_tzid (param) : NULL);
+       tt = e_cell_date_edit_value_get_time (dv);
+       datetime_to_zone (comp_data->client, tt, model_zone, param ? i_cal_parameter_get_tzid (param) : NULL);
 
        if (prop) {
                set_func (prop, tt);
        } else {
                prop = new_func (tt);
-               icalcomponent_add_property (comp_data->icalcomp, prop);
+               i_cal_component_take_property (comp_data->icalcomp, prop);
+
+               prop = i_cal_component_get_first_property (comp_data->icalcomp, kind);
        }
 
        if (param) {
-               const gchar *tzid = icalparameter_get_tzid (param);
+               const gchar *tzid = i_cal_parameter_get_tzid (param);
 
                /* If the TZID is set to "UTC", we don't want to save the TZID. */
                if (!tzid || !*tzid || !strcmp (tzid, "UTC")) {
-                       icalproperty_remove_parameter_by_kind (prop, ICAL_TZID_PARAMETER);
+                       i_cal_property_remove_parameter_by_kind (prop, I_CAL_TZID_PARAMETER);
                }
        } else if (model_zone) {
-               const gchar *tzid = icaltimezone_get_tzid (model_zone);
+               const gchar *tzid = i_cal_timezone_get_tzid (model_zone);
 
                if (tzid && *tzid) {
-                       param = icalparameter_new_tzid (tzid);
-                       icalproperty_add_parameter (prop, param);
+                       param = i_cal_parameter_new_tzid (tzid);
+                       i_cal_property_take_parameter (prop, param);
                }
        }
+
+       g_clear_object (&prop);
 }
 
 /**
@@ -2826,24 +2816,24 @@ e_cal_model_set_confirm_delete (ECalModel *model,
        g_object_notify (G_OBJECT (model), "confirm-delete");
 }
 
-icalcomponent_kind
+ICalComponentKind
 e_cal_model_get_component_kind (ECalModel *model)
 {
-       g_return_val_if_fail (E_IS_CAL_MODEL (model), ICAL_NO_COMPONENT);
+       g_return_val_if_fail (E_IS_CAL_MODEL (model), I_CAL_NO_COMPONENT);
 
        return model->priv->kind;
 }
 
 void
 e_cal_model_set_component_kind (ECalModel *model,
-                                icalcomponent_kind kind)
+                               ICalComponentKind kind)
 {
        g_return_if_fail (E_IS_CAL_MODEL (model));
 
        model->priv->kind = kind;
 }
 
-icaltimezone *
+ICalTimezone *
 e_cal_model_get_timezone (ECalModel *model)
 {
        g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
@@ -2853,9 +2843,10 @@ e_cal_model_get_timezone (ECalModel *model)
 
 void
 e_cal_model_set_timezone (ECalModel *model,
-                          icaltimezone *zone)
+                         const ICalTimezone *zone)
 {
-       icaltimezone *old_zone;
+       ICalTimezone *old_zone;
+
        g_return_if_fail (E_IS_CAL_MODEL (model));
 
        if (model->priv->zone == zone)
@@ -2863,7 +2854,7 @@ e_cal_model_set_timezone (ECalModel *model,
 
        e_table_model_pre_change (E_TABLE_MODEL (model));
        old_zone = model->priv->zone;
-       model->priv->zone = zone;
+       model->priv->zone = zone ? e_cal_util_copy_timezone (zone) : NULL;
 
        /* the timezone affects the times shown for date fields,
         * so we need to redisplay everything */
@@ -2872,7 +2863,9 @@ e_cal_model_set_timezone (ECalModel *model,
        g_object_notify (G_OBJECT (model), "timezone");
        g_signal_emit (
                model, signals[TIMEZONE_CHANGED], 0,
-               old_zone, zone);
+               old_zone, model->priv->zone);
+
+       g_clear_object (&old_zone);
 }
 
 gboolean
@@ -3636,18 +3629,20 @@ search_by_id_and_client (ECalModelPrivate *priv,
                if (comp_data) {
                        const gchar *uid;
                        gchar *rid = NULL;
-                       struct icaltimetype icalrid;
-                       gboolean has_rid = (id->rid && *id->rid);
+                       ICalTimetype *iclrid;
+                       gboolean has_rid = e_cal_component_id_get_rid (id) != NULL;
 
-                       uid = icalcomponent_get_uid (comp_data->icalcomp);
-                       icalrid = icalcomponent_get_recurrenceid (comp_data->icalcomp);
-                       if (!icaltime_is_null_time (icalrid))
-                               rid = icaltime_as_ical_string_r (icalrid);
+                       uid = i_cal_component_get_uid (comp_data->icalcomp);
+                       iclrid = i_cal_component_get_recurrenceid (comp_data->icalcomp);
+                       if (!i_cal_time_is_null_time (iclrid))
+                               rid = i_cal_time_as_ical_string_r (iclrid);
+                       g_clear_object (&iclrid);
 
                        if (uid && *uid) {
-                               if ((!client || comp_data->client == client) && !strcmp (id->uid, uid)) {
+                               if ((!client || comp_data->client == client) &&
+                                   !g_strcmp0 (e_cal_component_id_get_uid (id), uid)) {
                                        if (has_rid) {
-                                               if (!(rid && *rid && !strcmp (rid, id->rid))) {
+                                               if (!(rid && *rid && !g_strcmp0 (e_cal_component_id_get_rid 
(id), rid))) {
                                                        g_free (rid);
                                                        continue;
                                                }
@@ -3747,7 +3742,7 @@ e_cal_model_set_time_range (ECalModel *model,
 /**
  * e_cal_model_create_component_with_defaults_sync
  */
-icalcomponent *
+ICalComponent *
 e_cal_model_create_component_with_defaults_sync (ECalModel *model,
                                                 ECalClient *client,
                                                 gboolean all_day,
@@ -3755,13 +3750,13 @@ e_cal_model_create_component_with_defaults_sync (ECalModel *model,
                                                 GError **error)
 {
        ECalComponent *comp = NULL;
-       icalcomponent *icalcomp;
+       ICalComponent *icomp;
 
        g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
 
        if (client) {
                switch (model->priv->kind) {
-               case ICAL_VEVENT_COMPONENT :
+               case I_CAL_VEVENT_COMPONENT :
                        comp = cal_comp_event_new_with_defaults_sync (
                                client, all_day,
                                e_cal_model_get_use_default_reminder (model),
@@ -3769,10 +3764,10 @@ e_cal_model_create_component_with_defaults_sync (ECalModel *model,
                                e_cal_model_get_default_reminder_units (model),
                                cancellable, error);
                        break;
-               case ICAL_VTODO_COMPONENT :
+               case I_CAL_VTODO_COMPONENT :
                        comp = cal_comp_task_new_with_defaults_sync (client, cancellable, error);
                        break;
-               case ICAL_VJOURNAL_COMPONENT :
+               case I_CAL_VJOURNAL_COMPONENT :
                        comp = cal_comp_memo_new_with_defaults_sync (client, cancellable, error);
                        break;
                default:
@@ -3782,23 +3777,23 @@ e_cal_model_create_component_with_defaults_sync (ECalModel *model,
        }
 
        if (comp) {
-               icalcomp = icalcomponent_new_clone (e_cal_component_get_icalcomponent (comp));
+               icomp = i_cal_component_new_clone (e_cal_component_get_icalcomponent (comp));
                g_object_unref (comp);
        } else {
-               icalcomp = icalcomponent_new (model->priv->kind);
+               icomp = i_cal_component_new (model->priv->kind);
        }
 
        /* make sure the component has a UID */
-       if (!icalcomponent_get_uid (icalcomp)) {
+       if (!i_cal_component_get_uid (icomp)) {
                gchar *uid;
 
                uid = e_util_generate_uid ();
-               icalcomponent_set_uid (icalcomp, uid);
+               i_cal_component_set_uid (icomp, uid);
 
                g_free (uid);
        }
 
-       return icalcomp;
+       return icomp;
 }
 
 /**
@@ -3815,17 +3810,17 @@ e_cal_model_get_attendees_status_info (ECalModel *model,
                                        ECalClient *cal_client)
 {
        struct _values {
-               icalparameter_partstat status;
+               ICalParameterPartstat status;
                const gchar *caption;
                gint count;
        } values[] = {
-               { ICAL_PARTSTAT_ACCEPTED,    N_("Accepted"),     0 },
-               { ICAL_PARTSTAT_DECLINED,    N_("Declined"),     0 },
-               { ICAL_PARTSTAT_TENTATIVE,   N_("Tentative"),    0 },
-               { ICAL_PARTSTAT_DELEGATED,   N_("Delegated"),    0 },
-               { ICAL_PARTSTAT_NEEDSACTION, N_("Needs action"), 0 },
-               { ICAL_PARTSTAT_NONE,        N_("Other"),        0 },
-               { ICAL_PARTSTAT_X,           NULL,              -1 }
+               { I_CAL_PARTSTAT_ACCEPTED,    N_("Accepted"),     0 },
+               { I_CAL_PARTSTAT_DECLINED,    N_("Declined"),     0 },
+               { I_CAL_PARTSTAT_TENTATIVE,   N_("Tentative"),    0 },
+               { I_CAL_PARTSTAT_DELEGATED,   N_("Delegated"),    0 },
+               { I_CAL_PARTSTAT_NEEDSACTION, N_("Needs action"), 0 },
+               { I_CAL_PARTSTAT_NONE,        N_("Other"),        0 },
+               { I_CAL_PARTSTAT_X,           NULL,              -1 }
        };
 
        ESourceRegistry *registry;
@@ -3842,19 +3837,19 @@ e_cal_model_get_attendees_status_info (ECalModel *model,
            !itip_organizer_is_user_ex (registry, comp, cal_client, TRUE))
                return NULL;
 
-       e_cal_component_get_attendee_list (comp, &attendees);
+       attendees = e_cal_component_get_attendees (comp);
 
        for (a = attendees; a; a = a->next) {
                ECalComponentAttendee *att = a->data;
 
-               if (att && att->cutype == ICAL_CUTYPE_INDIVIDUAL &&
-                   (att->role == ICAL_ROLE_CHAIR ||
-                    att->role == ICAL_ROLE_REQPARTICIPANT ||
-                    att->role == ICAL_ROLE_OPTPARTICIPANT)) {
+               if (att && e_cal_component_attendee_get_cutype (att) == I_CAL_CUTYPE_INDIVIDUAL &&
+                   (e_cal_component_attendee_get_role (att) == I_CAL_ROLE_CHAIR ||
+                    e_cal_component_attendee_get_role (att) == I_CAL_ROLE_REQPARTICIPANT ||
+                    e_cal_component_attendee_get_role (att) == I_CAL_ROLE_OPTPARTICIPANT)) {
                        have = TRUE;
 
                        for (i = 0; values[i].count != -1; i++) {
-                               if (att->status == values[i].status || values[i].status == 
ICAL_PARTSTAT_NONE) {
+                               if (e_cal_component_attendee_get_partstat (att) == values[i].status || 
values[i].status == I_CAL_PARTSTAT_NONE) {
                                        values[i].count++;
                                        break;
                                }
@@ -3883,8 +3878,7 @@ e_cal_model_get_attendees_status_info (ECalModel *model,
                res = g_string_free (str, FALSE);
        }
 
-       if (attendees)
-               e_cal_component_free_attendee_list (attendees);
+       g_slist_free_full (attendees, e_cal_component_attendee_free);
 
        return res;
 }
@@ -3994,7 +3988,6 @@ e_cal_model_date_value_to_string (ECalModel *model,
 {
        ECalModelPrivate *priv;
        ECellDateEditValue *dv = (ECellDateEditValue *) value;
-       struct icaltimetype tt;
        struct tm tmp_tm;
        gchar buffer[64];
 
@@ -4006,18 +3999,7 @@ e_cal_model_date_value_to_string (ECalModel *model,
                return g_strdup ("");
 
        /* We currently convert all the dates to the current timezone. */
-       tt = dv->tt;
-       icaltimezone_convert_time (&tt, dv->zone, priv->zone);
-
-       tmp_tm.tm_year = tt.year - 1900;
-       tmp_tm.tm_mon = tt.month - 1;
-       tmp_tm.tm_mday = tt.day;
-       tmp_tm.tm_hour = tt.hour;
-       tmp_tm.tm_min = tt.minute;
-       tmp_tm.tm_sec = tt.second;
-       tmp_tm.tm_isdst = -1;
-
-       tmp_tm.tm_wday = time_day_of_week (tt.day, tt.month - 1, tt.year);
+       tmp_tm = icaltimetype_to_tm_with_zone (e_cell_date_edit_value_get_time (dv), 
e_cell_date_edit_value_get_zone (dv), priv->zone);
 
        memset (buffer, 0, sizeof (buffer));
        e_time_format_date_and_time (&tmp_tm, priv->use_24_hour_format,
@@ -4030,7 +4012,7 @@ typedef struct _GenerateInstacesData {
        ECalModelGenerateInstancesData mdata;
        ECalRecurInstanceFn cb;
        ECalClient *client;
-       icaltimezone *zone;
+       ICalTimezone *zone;
 } GenerateInstancesData;
 
 static gboolean
@@ -4099,31 +4081,34 @@ e_cal_model_get_object_array (ECalModel *model)
 
 void
 e_cal_model_set_instance_times (ECalModelComponent *comp_data,
-                                const icaltimezone *zone)
+                               const ICalTimezone *zone)
 {
-       if (icalcomponent_isa (comp_data->icalcomp) == ICAL_VEVENT_COMPONENT) {
-               struct icaltimetype start_time, end_time;
+       if (i_cal_component_isa (comp_data->icalcomp) == I_CAL_VEVENT_COMPONENT) {
+               ICalTimetype *start_time, *end_time;
 
-               start_time = icalcomponent_get_dtstart (comp_data->icalcomp);
-               end_time = icalcomponent_get_dtend (comp_data->icalcomp);
+               start_time = i_cal_component_get_dtstart (comp_data->icalcomp);
+               end_time = i_cal_component_get_dtend (comp_data->icalcomp);
 
-               if (start_time.is_date && icaltime_is_null_time (end_time)) {
+               if (i_cal_time_is_date (start_time) && i_cal_time_is_null_time (end_time)) {
                        /* If end_time is null and it's an all day event,
                         * just make start_time = end_time so that end_time
                         * will be a valid date
                         */
-                       end_time = start_time;
-                       icaltime_adjust (&end_time, 1, 0, 0, 0);
-                       icalcomponent_set_dtend (comp_data->icalcomp, end_time);
-               } else if (start_time.is_date && end_time.is_date &&
-                          (icaltime_compare_date_only (start_time, end_time) == 0)) {
+                       end_time = i_cal_time_new_clone (start_time);
+                       i_cal_time_adjust (end_time, 1, 0, 0, 0);
+                       i_cal_component_set_dtend (comp_data->icalcomp, end_time);
+               } else if (i_cal_time_is_date (start_time) && i_cal_time_is_date (end_time) &&
+                          (i_cal_time_compare_date_only (start_time, end_time) == 0)) {
                        /* If both DTSTART and DTEND are DATE values, and they are the
                         * same day, we add 1 day to DTEND. This means that most
                         * events created with the old Evolution behavior will still
                         * work OK. */
-                       icaltime_adjust (&end_time, 1, 0, 0, 0);
-                       icalcomponent_set_dtend (comp_data->icalcomp, end_time);
+                       i_cal_time_adjust (&end_time, 1, 0, 0, 0);
+                       i_cal_component_set_dtend (comp_data->icalcomp, end_time);
                }
+
+               g_clear_object (&start_time);
+               g_clear_object (&end_time);
        }
 
        cal_comp_get_instance_times (comp_data->client, comp_data->icalcomp, zone,
@@ -4191,20 +4176,3 @@ e_cal_model_emit_object_created (ECalModel *model,
 
        g_signal_emit (model, signals[OBJECT_CREATED], 0, where);
 }
-
-
-ECellDateEditValue *
-e_cal_model_copy_cell_date_value (const ECellDateEditValue *value)
-{
-       ECellDateEditValue *copy;
-
-       if (!value)
-               return NULL;
-
-
-       copy = g_new0 (ECellDateEditValue, 1);
-       copy->tt = value->tt;
-       copy->zone = value->zone;
-
-       return copy;
-}
diff --git a/src/calendar/gui/e-cal-model.h b/src/calendar/gui/e-cal-model.h
index ce56036782..0efcc7ac0e 100644
--- a/src/calendar/gui/e-cal-model.h
+++ b/src/calendar/gui/e-cal-model.h
@@ -105,7 +105,7 @@ struct _ECalModelComponent {
        GObject object;
 
        ECalClient *client;
-       icalcomponent *icalcomp;
+       ICalComponent *icalcomp;
        time_t instance_start;
        time_t instance_end;
        gboolean is_new_component;
@@ -162,8 +162,8 @@ struct _ECalModelClass {
        void            (*comps_deleted)        (ECalModel *model,
                                                 gpointer list);
        void            (*timezone_changed)     (ECalModel *model,
-                                                icaltimezone *old_zone,
-                                                icaltimezone *new_zone);
+                                                ICalTimezone *old_zone,
+                                                ICalTimezone *new_zone);
        void            (*object_created)       (ECalModel *model,
                                                 ECalClient *where);
 };
@@ -177,16 +177,16 @@ ESourceRegistry *
                e_cal_model_get_registry        (ECalModel *model);
 EShell *       e_cal_model_get_shell           (ECalModel *model);
 EClientCache * e_cal_model_get_client_cache    (ECalModel *model);
-icalcomponent_kind
+ICalComponentKind
                e_cal_model_get_component_kind  (ECalModel *model);
 void           e_cal_model_set_component_kind  (ECalModel *model,
-                                                icalcomponent_kind kind);
+                                                ICalcomponentKind kind);
 gboolean       e_cal_model_get_confirm_delete  (ECalModel *model);
 void           e_cal_model_set_confirm_delete  (ECalModel *model,
                                                 gboolean confirm_delete);
-icaltimezone * e_cal_model_get_timezone        (ECalModel *model);
+ICalTimezone * e_cal_model_get_timezone        (ECalModel *model);
 void           e_cal_model_set_timezone        (ECalModel *model,
-                                                icaltimezone *zone);
+                                                const ICalTimezone *zone);
 gboolean       e_cal_model_get_compress_weekend
                                                (ECalModel *model);
 void           e_cal_model_set_compress_weekend
@@ -334,7 +334,7 @@ void                e_cal_model_get_time_range      (ECalModel *model,
 void           e_cal_model_set_time_range      (ECalModel *model,
                                                 time_t start,
                                                 time_t end);
-icalcomponent *        e_cal_model_create_component_with_defaults_sync
+ICalComponent *        e_cal_model_create_component_with_defaults_sync
                                                (ECalModel *model,
                                                 ECalClient *client,
                                                 gboolean all_day,
@@ -375,7 +375,7 @@ void                e_cal_model_generate_instances_sync
                                                 gpointer cb_data);
 GPtrArray *    e_cal_model_get_object_array    (ECalModel *model);
 void           e_cal_model_set_instance_times  (ECalModelComponent *comp_data,
-                                                const icaltimezone *zone);
+                                                const ICalTimezone *zone);
 gboolean       e_cal_model_test_row_editable   (ECalModel *model,
                                                 gint row);
 void           e_cal_model_set_default_time_func
@@ -386,10 +386,10 @@ void              e_cal_model_set_default_time_func
 void           e_cal_model_update_comp_time    (ECalModel *model,
                                                 ECalModelComponent *comp_data,
                                                 gconstpointer time_value,
-                                                icalproperty_kind kind,
-                                                void (*set_func) (icalproperty *prop,
-                                                                  struct icaltimetype v),
-                                                icalproperty * (*new_func) (struct icaltimetype v));
+                                                ICalPropertyKind kind,
+                                                void (*set_func) (ICalProperty *prop,
+                                                                  ICalTimetype *v),
+                                                ICalProperty * (*new_func) (ICalTimetype *v));
 
 void           e_cal_model_emit_object_created (ECalModel *model,
                                                 ECalClient *where);
@@ -405,10 +405,6 @@ void               e_cal_model_util_set_value      (GHashTable *values,
 gpointer       e_cal_model_util_get_value      (GHashTable *values,
                                                 gint column);
 
-ECellDateEditValue *
-               e_cal_model_copy_cell_date_value
-                                               (const ECellDateEditValue *value);
-
 G_END_DECLS
 
 #endif /* E_CAL_MODEL_H */
diff --git a/src/calendar/gui/e-cell-date-edit-text.c b/src/calendar/gui/e-cell-date-edit-text.c
index 2c7043425c..afa5c47b3a 100644
--- a/src/calendar/gui/e-cell-date-edit-text.c
+++ b/src/calendar/gui/e-cell-date-edit-text.c
@@ -38,7 +38,7 @@
 struct _ECellDateEditTextPrivate {
 
        /* The timezone to display the date in. */
-       icaltimezone *timezone;
+       ICalTimezone *timezone;
 
        /* Whether to display in 24-hour format. */
        gboolean use_24_hour_format;
@@ -65,7 +65,7 @@ cell_date_edit_text_set_property (GObject *object,
                case PROP_TIMEZONE:
                        e_cell_date_edit_text_set_timezone (
                                E_CELL_DATE_EDIT_TEXT (object),
-                               g_value_get_pointer (value));
+                               g_value_get_object (value));
                        return;
 
                case PROP_USE_24_HOUR_FORMAT:
@@ -86,7 +86,7 @@ cell_date_edit_text_get_property (GObject *object,
 {
        switch (property_id) {
                case PROP_TIMEZONE:
-                       g_value_set_pointer (
+                       g_value_set_object (
                                value,
                                e_cell_date_edit_text_get_timezone (
                                E_CELL_DATE_EDIT_TEXT (object)));
@@ -103,6 +103,17 @@ cell_date_edit_text_get_property (GObject *object,
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 }
 
+static void
+cell_date_edit_text_finalize (GObject *object)
+{
+       ECellDateEditText *ecd = E_CELL_DATE_EDIT_TEXT (cell);
+
+       g_clear_object (&ecd->priv->timezone);
+
+       /* Chain up to parent's method. */
+       G_OBJECT_CLASS (e_cell_date_edit_text_parent_class)->finalize (object);
+}
+
 static gchar *
 cell_date_edit_text_get_text (ECellText *cell,
                               ETableModel *model,
@@ -111,7 +122,8 @@ cell_date_edit_text_get_text (ECellText *cell,
 {
        ECellDateEditText *ecd = E_CELL_DATE_EDIT_TEXT (cell);
        ECellDateEditValue *dv = e_table_model_value_at (model, col, row);
-       icaltimezone *timezone;
+       ICalTimezone *timezone;
+       ICalTimetype *tt;
        struct tm tmp_tm;
        gchar *res;
 
@@ -120,14 +132,16 @@ cell_date_edit_text_get_text (ECellText *cell,
 
        timezone = e_cell_date_edit_text_get_timezone (ecd);
 
+       tt = e_cell_date_edit_value_get_time (dv);
+
        /* Note that although the property may be in a different
         * timezone, we convert it to the current timezone to display
         * it in the table. If the user actually edits the value,
         * it will be set to the current timezone. See set_value (). */
-       tmp_tm = icaltimetype_to_tm_with_zone (&dv->tt, dv->zone, timezone);
+       tmp_tm = icaltimetype_to_tm_with_zone (tt, e_cell_date_edit_value_get_zone (dv), timezone);
 
        res = e_datetime_format_format_tm (
-               "calendar", "table", dv->tt.is_date ?
+               "calendar", "table", i_cal_time_is_date (tt) ?
                DTFormatKindDate : DTFormatKindDateTime, &tmp_tm);
 
        e_table_model_free_value (model, col, dv);
@@ -187,7 +201,7 @@ cell_date_edit_text_set_value (ECellText *cell,
        ECellDateEditText *ecd = E_CELL_DATE_EDIT_TEXT (cell);
        ETimeParseStatus status;
        struct tm tmp_tm;
-       ECellDateEditValue dv;
+       ECellDateEditValue *dv = NULL;
        ECellDateEditValue *value;
        gboolean is_date = TRUE;
 
@@ -207,28 +221,26 @@ cell_date_edit_text_set_value (ECellText *cell,
        if (status == E_TIME_PARSE_NONE) {
                value = NULL;
        } else {
-               dv.tt = icaltime_null_time ();
-
-               dv.tt.year = tmp_tm.tm_year + 1900;
-               dv.tt.month = tmp_tm.tm_mon + 1;
-               dv.tt.day = tmp_tm.tm_mday;
-               dv.tt.hour = tmp_tm.tm_hour;
-               dv.tt.minute = tmp_tm.tm_min;
-               dv.tt.second = tmp_tm.tm_sec;
-               dv.tt.is_date = is_date;
-
-               /* FIXME: We assume it is being set to the current timezone.
-                * Is that OK? */
+               ICalTimetype *tt;
+               ICalTimezone *zone;
+
+               tt = tm_to_icaltimetype (&tmp_tm, is_date);
+
                if (is_date) {
-                       dv.zone = NULL;
+                       zone = NULL;
                } else {
-                       dv.zone = e_cell_date_edit_text_get_timezone (ecd);
+                       zone = e_cell_date_edit_text_get_timezone (ecd);
                }
 
-               value = &dv;
+               dv = e_cell_date_edit_value_new (tt, zone);
+               value = dv;
+
+               g_clear_object (&tt);
        }
 
        e_table_model_set_value_at (model, col, row, value);
+
+       e_cell_date_edit_value_free (dv);
 }
 
 static void
@@ -242,6 +254,7 @@ e_cell_date_edit_text_class_init (ECellDateEditTextClass *class)
        object_class = G_OBJECT_CLASS (class);
        object_class->set_property = cell_date_edit_text_set_property;
        object_class->get_property = cell_date_edit_text_get_property;
+       object_class->finalize = cell_date_edit_text_finalize;
 
        cell_text_class = E_CELL_TEXT_CLASS (class);
        cell_text_class->get_text = cell_date_edit_text_get_text;
@@ -251,10 +264,11 @@ e_cell_date_edit_text_class_init (ECellDateEditTextClass *class)
        g_object_class_install_property (
                object_class,
                PROP_TIMEZONE,
-               g_param_spec_pointer (
+               g_param_spec_object (
                        "timezone",
                        "Time Zone",
                        NULL,
+                       I_CAL_TYPE_TIMEZONE,
                        G_PARAM_READWRITE));
 
        g_object_class_install_property (
@@ -273,7 +287,7 @@ e_cell_date_edit_text_init (ECellDateEditText *ecd)
 {
        ecd->priv = E_CELL_DATE_EDIT_TEXT_GET_PRIVATE (ecd);
 
-       ecd->priv->timezone = icaltimezone_get_utc_timezone ();
+       ecd->priv->timezone = e_cal_util_copy_timezone (i_cal_timezone_get_utc_timezone ());
        ecd->priv->use_24_hour_format = TRUE;
 }
 
@@ -298,7 +312,7 @@ e_cell_date_edit_text_new (const gchar *fontname,
        return cell;
 }
 
-icaltimezone *
+ICalTimezone *
 e_cell_date_edit_text_get_timezone (ECellDateEditText *ecd)
 {
        g_return_val_if_fail (E_IS_CELL_DATE_EDIT_TEXT (ecd), NULL);
@@ -308,14 +322,15 @@ e_cell_date_edit_text_get_timezone (ECellDateEditText *ecd)
 
 void
 e_cell_date_edit_text_set_timezone (ECellDateEditText *ecd,
-                                    icaltimezone *timezone)
+                                   const ICalTimezone *timezone)
 {
        g_return_if_fail (E_IS_CELL_DATE_EDIT_TEXT (ecd));
 
        if (ecd->priv->timezone == timezone)
                return;
 
-       ecd->priv->timezone = timezone;
+       g_clear_objct (&ecd->priv->timezone);
+       ecd->priv->timezone = timezone ? e_cal_util_copy_timezone (timezone) : NULL;
 
        g_object_notify (G_OBJECT (ecd), "timezone");
 }
@@ -349,7 +364,8 @@ e_cell_date_edit_compare_cb (gconstpointer a,
 {
        ECellDateEditValue *dv1 = (ECellDateEditValue *) a;
        ECellDateEditValue *dv2 = (ECellDateEditValue *) b;
-       struct icaltimetype tt;
+       ICalTimetype *tt;
+       gint res;
 
        /* First check if either is NULL. NULL dates sort last. */
        if (!dv1 || !dv2) {
@@ -362,10 +378,133 @@ e_cell_date_edit_compare_cb (gconstpointer a,
        }
 
        /* Copy the 2nd value and convert it to the same timezone as the first. */
-       tt = dv2->tt;
-
-       icaltimezone_convert_time (&tt, dv2->zone, dv1->zone);
+       tt = i_cal_timezone_convert_time (e_cell_date_edit_value_get_time (dv2), 
e_cell_date_edit_value_get_zone (dv2), e_cell_date_edit_value_get_zone (dv1));
 
        /* Now we can compare them. */
-       return icaltime_compare (dv1->tt, tt);
+       res = i_cal_time_compare (e_cell_date_edit_value_get_time (dv1), tt);
+
+       g_clear_object (&tt);
+
+       return res;
+}
+
+struct _ECellDateEditValue {
+       ICalTimetype *tt;
+       ICalTimezone *zone;
+};
+
+ECellDateEditValue *
+e_cell_date_edit_value_new (const ICalTimetype *tt,
+                           const ICalTimezone *zone)
+{
+       g_return_val_if_fail (I_CAL_IS_TIMETYPE (tt), NULL);
+       if (zone)
+               g_return_val_if_fail (I_CAL_IS_TIMEZONE (zone), NULL);
+
+       return e_cell_date_edit_value_new_take (i_cal_timetype_new_clone (tt),
+               zone ? e_cal_util_copy_timezone (zone) : NULL);
+}
+
+ECellDateEditValue *
+e_cell_date_edit_value_new_take (ICalTimetype *tt,
+                                ICalTimezone *zone)
+{
+       ECellDateEditValue *value;
+
+       g_return_val_if_fail (I_CAL_IS_TIMETYPE (tt), NULL);
+       if (zone)
+               g_return_val_if_fail (I_CAL_IS_TIMEZONE (zone), NULL);
+
+       value = g_new0 (ECellDateEditValue, 1);
+       value->tt = tt;
+       value->zone = zone;
+
+       return value;
+}
+
+ECellDateEditValue *
+e_cell_date_edit_value_copy (const ECellDateEditValue *src)
+{
+       if (!src)
+               return NULL;
+
+       return e_cell_date_edit_value_new (src->tt, src->zone);
+}
+
+void
+e_cell_date_edit_value_free (ECellDateEditValue *value)
+{
+       if (value) {
+               g_clear_object (&value->tt);
+               g_clear_object (&value->zone);
+               g_free (value);
+       }
+}
+
+ICalTimetype *
+e_cell_date_edit_value_get_time (const ECellDateEditValue *value)
+{
+       g_return_val_if_fail (value != NULL, NULL);
+
+       return value->tt;
+}
+
+void
+e_cell_date_edit_value_set_time (ECellDateEditValue *value,
+                                const ICalTimetype *tt)
+{
+       g_return_if_fail (value != NULL);
+       g_return_if_fail (I_CAL_IS_TIMETYPE (tt));
+
+       e_cell_date_edit_value_take_time (value, i_cal_timetype_new_clone (tt));
+}
+
+void
+e_cell_date_edit_value_take_time (ECellDateEditValue *value,
+                                 ICalTimetype *tt)
+{
+       g_return_if_fail (value != NULL);
+       g_return_if_fail (I_CAL_IS_TIMETYPE (tt));
+
+       if (value->tt != tt) {
+               g_clear_object (&value->tt);
+               value->tt = tt;
+       } else {
+               g_clear_object (&tt);
+       }
+}
+
+ICalTimezone *
+e_cell_date_edit_value_get_zone (const ECellDateEditValue *value)
+{
+       g_return_val_if_fail (value != NULL, NULL);
+
+       return value->zone;
+}
+
+void
+e_cell_date_edit_value_set_zone (ECellDateEditValue *value,
+                                const ICalTimezone *zone)
+{
+       g_return_if_fail (value != NULL);
+       if (zone)
+               g_return_if_fail (I_CAL_IS_TIMEZONE (zone));
+
+       e_cell_date_edit_value_take_zone (value, zone ? e_cal_util_copy_timezone (zone) : NULL);
+}
+
+void
+e_cell_date_edit_value_take_zone (ECellDateEditValue *value,
+                                 ICalTimezone *zone)
+{
+       g_return_if_fail (value != NULL);
+       if (zone)
+               g_return_if_fail (I_CAL_IS_TIMEZONE (zone));
+
+       if (zone != value->zone) {
+               g_clear_object (&value->zone);
+               value->zone = zone;
+       } else {
+               g_clear_object (&zone);
+       }
 }
diff --git a/src/calendar/gui/e-cell-date-edit-text.h b/src/calendar/gui/e-cell-date-edit-text.h
index 6e69981806..2d48580907 100644
--- a/src/calendar/gui/e-cell-date-edit-text.h
+++ b/src/calendar/gui/e-cell-date-edit-text.h
@@ -23,7 +23,7 @@
 #ifndef _E_CELL_DATE_EDIT_TEXT_H_
 #define _E_CELL_DATE_EDIT_TEXT_H_
 
-#include <libical/ical.h>
+#include <libecal/libecal.h>
 #include <e-util/e-util.h>
 
 /* Standard GObject macros */
@@ -47,15 +47,31 @@
 
 G_BEGIN_DECLS
 
+typedef struct _ECellDateEditValue ECellDateEditValue;
+
+ECellDateEditValue *
+               e_cell_date_edit_value_new      (const ICalTimetype *tt,
+                                                const ICalTimezone *zone);
+ECellDateEditValue *
+               e_cell_date_edit_value_new_take (ICalTimetype *tt,
+                                                ICalTimezone *zone);
+ECellDateEditValue *
+               e_cell_date_edit_value_copy     (const ECellDateEditValue *src);
+void           e_cell_date_edit_value_free     (ECellDateEditValue *value);
+ICalTimetype * e_cell_date_edit_value_get_time (const ECellDateEditValue *value);
+void           e_cell_date_edit_value_set_time (ECellDateEditValue *value,
+                                                const ICalTimetype *tt);
+void           e_cell_date_edit_value_take_time(ECellDateEditValue *value,
+                                                ICalTimetype *tt);
+ICalTimezone * e_cell_date_edit_value_get_zone (const ECellDateEditValue *value);
+void           e_cell_date_edit_value_set_zone (ECellDateEditValue *value,
+                                                const ICalTimezone *zone);
+void           e_cell_date_edit_value_take_zone(ECellDateEditValue *value,
+                                                ICalTimezone *zone);
+
 typedef struct _ECellDateEditText ECellDateEditText;
 typedef struct _ECellDateEditTextClass ECellDateEditTextClass;
 typedef struct _ECellDateEditTextPrivate ECellDateEditTextPrivate;
-typedef struct _ECellDateEditValue ECellDateEditValue;
-
-struct _ECellDateEditValue {
-       struct icaltimetype tt;
-       icaltimezone *zone;
-};
 
 struct _ECellDateEditText {
        ECellText parent;
diff --git a/src/calendar/gui/e-comp-editor-page-attachments.c 
b/src/calendar/gui/e-comp-editor-page-attachments.c
index 5fe0fd3ee9..4f28c57f70 100644
--- a/src/calendar/gui/e-comp-editor-page-attachments.c
+++ b/src/calendar/gui/e-comp-editor-page-attachments.c
@@ -281,7 +281,6 @@ ecep_attachments_fill_widgets (ECompEditorPage *page,
                if (!attach)
                        continue;
 
-               #ifdef HAVE_ICAL_FILENAME_PARAMETER
                param = icalproperty_get_first_parameter (prop, ICAL_FILENAME_PARAMETER);
                if (param) {
                        filename = g_strdup (icalparameter_get_filename (param));
@@ -290,7 +289,6 @@ ecep_attachments_fill_widgets (ECompEditorPage *page,
                                filename = NULL;
                        }
                }
-               #endif
 
                if (icalattach_get_is_url (attach)) {
                        const gchar *data;
@@ -433,9 +431,7 @@ ecep_attachments_fill_component (ECompEditorPage *page,
                gsize buf_size;
                gchar *buf, *uri, *description;
                GFile *file;
-               #ifdef HAVE_ICAL_FILENAME_PARAMETER
                GFileInfo *file_info;
-               #endif
 
                if (!attachment)
                        continue;
@@ -487,7 +483,6 @@ ecep_attachments_fill_component (ECompEditorPage *page,
                attach = icalattach_new_from_url (buf);
                prop = icalproperty_new_attach (attach);
 
-               #ifdef HAVE_ICAL_FILENAME_PARAMETER
                file_info = e_attachment_ref_file_info (attachment);
                if (file_info) {
                        const gchar *display_name = g_file_info_get_display_name (file_info);
@@ -501,7 +496,6 @@ ecep_attachments_fill_component (ECompEditorPage *page,
 
                        g_object_unref (file_info);
                }
-               #endif
 
                icalcomponent_add_property (component, prop);
 
diff --git a/src/calendar/gui/e-comp-editor-page-general.c b/src/calendar/gui/e-comp-editor-page-general.c
index 538aee1802..61b9ddcd9c 100644
--- a/src/calendar/gui/e-comp-editor-page-general.c
+++ b/src/calendar/gui/e-comp-editor-page-general.c
@@ -1424,31 +1424,29 @@ ecep_general_constructed (GObject *object)
 
        /* Returns NULL when not supported by libical */
        part = e_comp_editor_property_part_color_new ();
-       if (part) {
-               widget = e_comp_editor_property_part_get_edit_widget (part);
+       widget = e_comp_editor_property_part_get_edit_widget (part);
 
-               if (widget) {
-                       const gchar *tooltip;
+       if (widget) {
+               const gchar *tooltip;
 
-                       gtk_box_pack_start (GTK_BOX (page_general->priv->source_and_color_hbox), widget, 
FALSE, FALSE, 0);
+               gtk_box_pack_start (GTK_BOX (page_general->priv->source_and_color_hbox), widget, FALSE, 
FALSE, 0);
 
-                       if (g_strcmp0 (page_general->priv->source_extension_name, 
E_SOURCE_EXTENSION_CALENDAR) == 0) {
-                               tooltip = _("Override color of the event. If not set, then color of the 
calendar is used.");
-                       } else if (g_strcmp0 (page_general->priv->source_extension_name, 
E_SOURCE_EXTENSION_MEMO_LIST) == 0) {
-                               tooltip = _("Override color of the memo. If not set, then color of the memo 
list is used.");
-                       } else { /* E_SOURCE_EXTENSION_TASK_LIST */
-                               tooltip = _("Override color of the task. If not set, then color of the task 
list is used.");
-                       }
-
-                       gtk_widget_set_tooltip_text (widget, tooltip);
+               if (g_strcmp0 (page_general->priv->source_extension_name, E_SOURCE_EXTENSION_CALENDAR) == 0) {
+                       tooltip = _("Override color of the event. If not set, then color of the calendar is 
used.");
+               } else if (g_strcmp0 (page_general->priv->source_extension_name, 
E_SOURCE_EXTENSION_MEMO_LIST) == 0) {
+                       tooltip = _("Override color of the memo. If not set, then color of the memo list is 
used.");
+               } else { /* E_SOURCE_EXTENSION_TASK_LIST */
+                       tooltip = _("Override color of the task. If not set, then color of the task list is 
used.");
                }
 
-               page_general->priv->comp_color_changed_handler_id = g_signal_connect_swapped (part, "changed",
-                       G_CALLBACK (e_comp_editor_page_emit_changed), page_general);
-
-               page_general->priv->comp_color = part;
+               gtk_widget_set_tooltip_text (widget, tooltip);
        }
 
+       page_general->priv->comp_color_changed_handler_id = g_signal_connect_swapped (part, "changed",
+               G_CALLBACK (e_comp_editor_page_emit_changed), page_general);
+
+       page_general->priv->comp_color = part;
+
        widget = gtk_button_new_with_mnemonic (C_("ECompEditor", "Atte_ndees..."));
        g_object_set (G_OBJECT (widget),
                "hexpand", FALSE,
diff --git a/src/calendar/gui/e-comp-editor-property-parts.c b/src/calendar/gui/e-comp-editor-property-parts.c
index 967651f20f..05ee33be32 100644
--- a/src/calendar/gui/e-comp-editor-property-parts.c
+++ b/src/calendar/gui/e-comp-editor-property-parts.c
@@ -1664,7 +1664,6 @@ static void
 ecepp_color_fill_widget (ECompEditorPropertyPart *property_part,
                         icalcomponent *component)
 {
-       #ifdef HAVE_ICAL_COLOR_PROPERTY
        GtkWidget *edit_widget;
        icalproperty *prop;
        gboolean color_set = FALSE;
@@ -1695,14 +1694,12 @@ ecepp_color_fill_widget (ECompEditorPropertyPart *property_part,
 
                e_color_combo_set_current_color (E_COLOR_COMBO (edit_widget), &rgba);
        }
-       #endif
 }
 
 static void
 ecepp_color_fill_component (ECompEditorPropertyPart *property_part,
                            icalcomponent *component)
 {
-       #ifdef HAVE_ICAL_COLOR_PROPERTY
        GtkWidget *edit_widget;
        icalproperty *prop;
        GdkRGBA rgba;
@@ -1743,7 +1740,6 @@ ecepp_color_fill_component (ECompEditorPropertyPart *property_part,
                        g_warning ("%s: Failed to convert RGBA (%f,%f,%f,%f) to string", G_STRFUNC, rgba.red, 
rgba.green, rgba.blue, rgba.alpha);
                }
        }
-       #endif
 }
 
 static void
@@ -1765,9 +1761,5 @@ e_comp_editor_property_part_color_class_init (ECompEditorPropertyPartColorClass
 ECompEditorPropertyPart *
 e_comp_editor_property_part_color_new (void)
 {
-       #ifdef HAVE_ICAL_COLOR_PROPERTY
        return g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_COLOR, NULL);
-       #else
-       return NULL;
-       #endif
 }
diff --git a/src/calendar/gui/e-timezone-entry.c b/src/calendar/gui/e-timezone-entry.c
index 725780a1f3..a7225ee098 100644
--- a/src/calendar/gui/e-timezone-entry.c
+++ b/src/calendar/gui/e-timezone-entry.c
@@ -44,12 +44,7 @@ struct _ETimezoneEntryPrivate {
         * or from the timezone dialog. Note that we don't copy it or
         * use a ref count - we assume it is never destroyed for the
         * lifetime of this widget. */
-       icaltimezone *timezone;
-
-       /* This can be set to the default timezone. If the current timezone
-        * setting in the ETimezoneEntry matches this, then the entry field
-        * is hidden. This makes the user interface simpler. */
-       icaltimezone *default_zone;
+       ICalTimezone *timezone;
 
        GtkWidget *entry;
        GtkWidget *button;
@@ -80,17 +75,17 @@ timezone_entry_update_entry (ETimezoneEntry *timezone_entry)
 {
        const gchar *display_name;
        gchar *name_buffer;
-       icaltimezone *timezone;
+       ICalTimezone *timezone;
 
        timezone = e_timezone_entry_get_timezone (timezone_entry);
 
        if (timezone != NULL) {
-               display_name = icaltimezone_get_display_name (timezone);
+               display_name = i_cal_timezone_get_display_name (timezone);
 
                /* We check if it is one of our builtin timezone
                 * names, in which case we call gettext to translate
                 * it. If it isn't a builtin timezone name, we don't. */
-               if (icaltimezone_get_builtin_timezone (display_name))
+               if (i_cal_timezone_get_builtin_timezone (display_name))
                        display_name = _(display_name);
        } else
                display_name = "";
@@ -166,7 +161,7 @@ timezone_entry_button_clicked_cb (ETimezoneEntry *timezone_entry)
        ETimezoneDialog *timezone_dialog;
        GtkWidget *toplevel;
        GtkWidget *dialog;
-       icaltimezone *timezone;
+       ICalTimezone *timezone;
 
        timezone_dialog = e_timezone_dialog_new ();
 
@@ -200,7 +195,7 @@ timezone_entry_set_property (GObject *object,
                case PROP_TIMEZONE:
                        e_timezone_entry_set_timezone (
                                E_TIMEZONE_ENTRY (object),
-                               g_value_get_pointer (value));
+                               g_value_get_object (value));
                        return;
        }
 
@@ -215,7 +210,7 @@ timezone_entry_get_property (GObject *object,
 {
        switch (property_id) {
                case PROP_TIMEZONE:
-                       g_value_set_pointer (
+                       g_value_set_object (
                                value, e_timezone_entry_get_timezone (
                                E_TIMEZONE_ENTRY (object)));
                        return;
@@ -224,6 +219,17 @@ timezone_entry_get_property (GObject *object,
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 }
 
+static void
+timezone_entry_get_finalize (GObject *object)
+{
+       ETimezoneEntry *tzentry = E_TIMEZONE_ENTRY (tzentry);
+
+       g_clear_object (&tzentry->priv->timezone);
+
+       /* Chain up to parent's method. */
+       G_OBJECT_CLASS (e_timezone_entry_parent_class)->finalize (object);
+}
+
 static gboolean
 timezone_entry_mnemonic_activate (GtkWidget *widget,
                                   gboolean group_cycling)
@@ -285,6 +291,7 @@ e_timezone_entry_class_init (ETimezoneEntryClass *class)
        object_class = G_OBJECT_CLASS (class);
        object_class->set_property = timezone_entry_set_property;
        object_class->get_property = timezone_entry_get_property;
+       object_class->finalize = timezone_entry_get_finalize;
 
        widget_class = GTK_WIDGET_CLASS (class);
        widget_class->mnemonic_activate = timezone_entry_mnemonic_activate;
@@ -293,10 +300,11 @@ e_timezone_entry_class_init (ETimezoneEntryClass *class)
        g_object_class_install_property (
                object_class,
                PROP_TIMEZONE,
-               g_param_spec_pointer (
+               g_param_spec_object (
                        "timezone",
                        "Timezone",
                        NULL,
+                       I_CAL_TYPE_TIMEZONE,
                        G_PARAM_READWRITE));
 
        signals[CHANGED] = g_signal_new (
@@ -350,7 +358,7 @@ e_timezone_entry_new (void)
        return g_object_new (E_TYPE_TIMEZONE_ENTRY, NULL);
 }
 
-icaltimezone *
+ICalTimezone *
 e_timezone_entry_get_timezone (ETimezoneEntry *timezone_entry)
 {
        g_return_val_if_fail (E_IS_TIMEZONE_ENTRY (timezone_entry), NULL);
@@ -360,31 +368,19 @@ e_timezone_entry_get_timezone (ETimezoneEntry *timezone_entry)
 
 void
 e_timezone_entry_set_timezone (ETimezoneEntry *timezone_entry,
-                               icaltimezone *timezone)
+                              const ICalTimezone *timezone)
 {
        g_return_if_fail (E_IS_TIMEZONE_ENTRY (timezone_entry));
 
        if (timezone_entry->priv->timezone == timezone)
                return;
 
-       timezone_entry->priv->timezone = timezone;
+       g_clear_object (&timezone_entry->priv->timezone);
+       if (timezone)
+               timezone_entry->priv->timezone = e_cal_util_copy_timezone (timezone);
 
        timezone_entry_update_entry (timezone_entry);
        timezone_entry_add_relation (timezone_entry);
 
        g_object_notify (G_OBJECT (timezone_entry), "timezone");
 }
-
-/* Sets the default timezone. If the current timezone matches this,
- * then the entry field is hidden. This is useful since most people
- * do not use timezones so it makes the user interface simpler. */
-void
-e_timezone_entry_set_default_timezone (ETimezoneEntry *timezone_entry,
-                                       icaltimezone *timezone)
-{
-       g_return_if_fail (E_IS_TIMEZONE_ENTRY (timezone_entry));
-
-       timezone_entry->priv->default_zone = timezone;
-
-       timezone_entry_update_entry (timezone_entry);
-}
diff --git a/src/calendar/gui/e-timezone-entry.h b/src/calendar/gui/e-timezone-entry.h
index e5de7492b4..be59c6f590 100644
--- a/src/calendar/gui/e-timezone-entry.h
+++ b/src/calendar/gui/e-timezone-entry.h
@@ -72,16 +72,9 @@ struct _ETimezoneEntryClass {
 
 GType          e_timezone_entry_get_type       (void);
 GtkWidget *    e_timezone_entry_new            (void);
-icaltimezone * e_timezone_entry_get_timezone   (ETimezoneEntry *timezone_entry);
+ICalTimezone * e_timezone_entry_get_timezone   (ETimezoneEntry *timezone_entry);
 void           e_timezone_entry_set_timezone   (ETimezoneEntry *timezone_entry,
-                                                icaltimezone *timezone);
-
-/* Sets the default timezone. If the current timezone matches this,
- * then the entry field is hidden. This is useful since most people
- * do not use timezones so it makes the user interface simpler. */
-void           e_timezone_entry_set_default_timezone
-                                               (ETimezoneEntry *timezone_entry,
-                                                icaltimezone *timezone);
+                                                const ICalTimezone *timezone);
 
 G_END_DECLS
 
diff --git a/src/calendar/gui/e-to-do-pane.c b/src/calendar/gui/e-to-do-pane.c
index fdf55c9e68..8a4aa6116a 100644
--- a/src/calendar/gui/e-to-do-pane.c
+++ b/src/calendar/gui/e-to-do-pane.c
@@ -783,10 +783,8 @@ etdp_get_comp_colors (EToDoPane *to_do_pane,
                      time_t *out_nearest_due)
 {
        GdkRGBA *bgcolor = NULL, fgcolor;
-       #ifdef HAVE_ICAL_COLOR_PROPERTY
        GdkRGBA stack_bgcolor;
        icalproperty *prop;
-       #endif
 
        g_return_if_fail (E_IS_TO_DO_PANE (to_do_pane));
        g_return_if_fail (out_bgcolor);
@@ -800,7 +798,6 @@ etdp_get_comp_colors (EToDoPane *to_do_pane,
        g_return_if_fail (E_IS_CAL_CLIENT (client));
        g_return_if_fail (E_IS_CAL_COMPONENT (comp));
 
-       #ifdef HAVE_ICAL_COLOR_PROPERTY
        prop = icalcomponent_get_first_property (e_cal_component_get_icalcomponent (comp), 
ICAL_COLOR_PROPERTY);
        if (prop) {
                const gchar *color_spec;
@@ -810,7 +807,6 @@ etdp_get_comp_colors (EToDoPane *to_do_pane,
                        bgcolor = &stack_bgcolor;
                }
        }
-       #endif
 
        if (!bgcolor)
                bgcolor = g_hash_table_lookup (to_do_pane->priv->client_colors, e_client_get_source (E_CLIENT 
(client)));
diff --git a/src/calendar/gui/itip-utils.c b/src/calendar/gui/itip-utils.c
index 23d1769ada..114bb2b8c2 100644
--- a/src/calendar/gui/itip-utils.c
+++ b/src/calendar/gui/itip-utils.c
@@ -23,7 +23,11 @@
 
 #include <time.h>
 #include <glib/gi18n-lib.h>
-#include <libical/ical.h>
+
+#define LIBICAL_GLIB_UNSTABLE_API 1
+#include <libical-glib/libical-glib.h>
+#undef LIBICAL_GLIB_UNSTABLE_API
+
 #include <libsoup/soup.h>
 
 #include <composer/e-msg-composer.h>
diff --git a/src/calendar/gui/itip-utils.h b/src/calendar/gui/itip-utils.h
index 47b19fc437..86845762c8 100644
--- a/src/calendar/gui/itip-utils.h
+++ b/src/calendar/gui/itip-utils.h
@@ -19,7 +19,6 @@
 #ifndef ITIP_UTILS_H
 #define ITIP_UTILS_H
 
-#include <libical/ical.h>
 #include <string.h>
 #include <libecal/libecal.h>
 #include <calendar/gui/e-cal-model.h>
diff --git a/src/e-util/e-timezone-dialog.c b/src/e-util/e-timezone-dialog.c
index 3f613ae003..8533abc346 100644
--- a/src/e-util/e-timezone-dialog.c
+++ b/src/e-util/e-timezone-dialog.c
@@ -58,10 +58,10 @@
 struct _ETimezoneDialogPrivate {
        /* The selected timezone. May be NULL for a 'local time' (i.e. when
         * the displayed name is ""). */
-       icaltimezone *zone;
+       ICalTimezone *zone;
 
        /* In case a non-builtin timezone is used. */
-       GSList *custom_zones; /* icaltimezone * */
+       GSList *custom_zones; /* ICalTimezone * */
 
        GtkBuilder *builder;
 
@@ -99,10 +99,10 @@ static gboolean on_map_button_pressed               (GtkWidget      *w,
                                                 GdkEvent       *button_event,
                                                 gpointer        data);
 
-static icaltimezone * get_zone_from_point      (ETimezoneDialog *etd,
+static ICalTimezone * get_zone_from_point      (ETimezoneDialog *etd,
                                                 EMapPoint      *point);
 static void    set_map_timezone                (ETimezoneDialog *etd,
-                                                icaltimezone    *zone);
+                                                const ICalTimezone *zone);
 static void    on_combo_changed                (GtkComboBox    *combo,
                                                 ETimezoneDialog *etd);
 
@@ -165,9 +165,11 @@ e_timezone_dialog_dispose (GObject *object)
                priv->index = NULL;
        }
 
-       g_slist_free (priv->custom_zones);
+       g_slist_free_full (priv->custom_zones, g_object_unref);
        priv->custom_zones = NULL;
 
+       g_clear_object (&priv->zone);
+
        /* Chain up to parent's dispose() method. */
        G_OBJECT_CLASS (e_timezone_dialog_parent_class)->dispose (object);
 }
@@ -225,7 +227,7 @@ static void
 e_timezone_dialog_add_timezones (ETimezoneDialog *etd)
 {
        ETimezoneDialogPrivate *priv;
-       icalarray *zones;
+       ICalArray *zones;
        GtkComboBox *combo;
        GList *l, *list_items = NULL;
        GtkTreeStore *tree_store;
@@ -235,7 +237,7 @@ e_timezone_dialog_add_timezones (ETimezoneDialog *etd)
        GtkStyleContext *style_context;
        GHashTable *parents;
        const gchar *css;
-       gint i;
+       gint ii, sz;
        GError *error = NULL;
 
        priv = etd->priv;
@@ -243,23 +245,28 @@ e_timezone_dialog_add_timezones (ETimezoneDialog *etd)
        g_hash_table_remove_all (priv->index);
 
        /* Get the array of builtin timezones. */
-       zones = icaltimezone_get_builtin_timezones ();
+       zones = i_cal_timezone_get_builtin_timezones ();
 
-       for (i = 0; i < zones->num_elements; i++) {
-               icaltimezone *zone;
+       sz = i_cal_array_size (zones);
+       for (ii = 0; ii < sz; ii++) {
+               ICalTimezone *zone;
                gchar *location;
 
-               zone = icalarray_element_at (zones, i);
+               zone = i_cal_timezone_array_element_at (zones, ii);
+               if (!zone)
+                       continue;
 
-               location = _(icaltimezone_get_location (zone));
+               location = _(i_cal_timezone_get_location (zone));
 
                e_map_add_point (
                        priv->map, location,
-                       icaltimezone_get_longitude (zone),
-                       icaltimezone_get_latitude (zone),
+                       i_cal_timezone_get_longitude (zone),
+                       i_cal_timezone_get_latitude (zone),
                        E_TIMEZONE_DIALOG_MAP_POINT_NORMAL_RGBA);
 
                list_items = g_list_prepend (list_items, location);
+
+               g_clear_object (&zone);
        }
 
        list_items = g_list_sort (list_items, (GCompareFunc) g_utf8_collate);
@@ -286,7 +293,7 @@ e_timezone_dialog_add_timezones (ETimezoneDialog *etd)
        parents = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
 
        tree_store = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
-       for (l = list_items, i = 0; l != NULL; l = l->next, ++i) {
+       for (l = list_items, ii = 0; l != NULL; l = l->next, ++ii) {
                GtkTreeIter *piter, *parent = NULL;
                const gchar *name = NULL;
                const gchar *location = l->data;
@@ -415,19 +422,19 @@ get_local_offset (void)
 }
 #endif
 
-static icaltimezone *
+static ICalTimezone *
 get_local_timezone (void)
 {
-       icaltimezone *zone;
+       ICalTimezone *zone;
        gchar *location;
 
        tzset ();
        location = e_cal_system_timezone_get_location ();
 
        if (location)
-               zone = icaltimezone_get_builtin_timezone (location);
+               zone = i_cal_timezone_get_builtin_timezone (location);
        else
-               zone = icaltimezone_get_utc_timezone ();
+               zone = i_cal_timezone_get_utc_timezone ();
 
        g_free (location);
 
@@ -517,35 +524,36 @@ format_utc_offset (gint utc_offset,
 }
 
 static gchar *
-zone_display_name_with_offset (icaltimezone *zone)
+zone_display_name_with_offset (const ICalTimezone *zone)
 {
        const gchar *display_name;
        struct tm local;
-       struct icaltimetype tt;
+       ICalTimetype *tt;
        gint offset;
        gchar buffer[100];
        time_t now = time (NULL);
 
        gmtime_r ((const time_t *) &now, &local);
        tt = tm_to_icaltimetype (&local, TRUE);
-       offset = icaltimezone_get_utc_offset (zone, &tt, NULL);
+       offset = i_cal_timezone_get_utc_offset ((ICalTimezone *) zone, tt, NULL);
+       g_clear_object (&tt);
 
        format_utc_offset (offset, buffer);
 
-       display_name = icaltimezone_get_display_name (zone);
-       if (icaltimezone_get_builtin_timezone (display_name))
+       display_name = i_cal_timezone_get_display_name (zone);
+       if (i_cal_timezone_get_builtin_timezone (display_name))
                display_name = _(display_name);
 
        return g_strdup_printf ("%s (%s)", display_name, buffer);
 }
 
 static const gchar *
-zone_display_name (icaltimezone *zone)
+zone_display_name (const ICalTimezone *zone)
 {
        const gchar *display_name;
 
-       display_name = icaltimezone_get_display_name (zone);
-       if (icaltimezone_get_builtin_timezone (display_name))
+       display_name = i_cal_timezone_get_display_name (zone);
+       if (i_cal_timezone_get_builtin_timezone (display_name))
                display_name = _(display_name);
 
        return display_name;
@@ -585,7 +593,7 @@ on_map_motion (GtkWidget *widget,
        ETimezoneDialog *etd;
        ETimezoneDialogPrivate *priv;
        gdouble longitude, latitude;
-       icaltimezone *new_zone;
+       ICalTimezone *new_zone;
        gchar *display = NULL;
 
        etd = E_TIMEZONE_DIALOG (data);
@@ -614,6 +622,7 @@ on_map_motion (GtkWidget *widget,
        display = zone_display_name_with_offset (new_zone);
        gtk_label_set_text (GTK_LABEL (priv->preview_label), display);
 
+       g_clear_object (&new_zone);
        g_free (display);
 
        return TRUE;
@@ -713,6 +722,7 @@ on_map_button_pressed (GtkWidget *w,
                                E_TIMEZONE_DIALOG_MAP_POINT_NORMAL_RGBA);
                priv->point_selected = priv->point_hover;
 
+               g_clear_object (&priv->zone);
                priv->zone = get_zone_from_point (etd, priv->point_selected);
                timezone_combo_set_active_text (etd, zone_display_name (priv->zone));
        }
@@ -722,13 +732,13 @@ on_map_button_pressed (GtkWidget *w,
 
 /* Returns the translated timezone location of the given EMapPoint,
  * e.g. "Europe/London". */
-static icaltimezone *
+static ICalTimezone *
 get_zone_from_point (ETimezoneDialog *etd,
                      EMapPoint *point)
 {
-       icalarray *zones;
+       ICalArray *zones;
        gdouble longitude, latitude;
-       gint i;
+       gint ii, sz;
 
        if (point == NULL)
                return NULL;
@@ -736,23 +746,27 @@ get_zone_from_point (ETimezoneDialog *etd,
        e_map_point_get_location (point, &longitude, &latitude);
 
        /* Get the array of builtin timezones. */
-       zones = icaltimezone_get_builtin_timezones ();
+       zones = i_cal_timezone_get_builtin_timezones ();
+       sz = i_cal_array_size (zones);
 
-       for (i = 0; i < zones->num_elements; i++) {
-               icaltimezone *zone;
+       for (ii = 0; ii < sz; ii++) {
+               ICalTimezone *zone;
                gdouble zone_longitude, zone_latitude;
 
-               zone = icalarray_element_at (zones, i);
-               zone_longitude = icaltimezone_get_longitude (zone);
-               zone_latitude = icaltimezone_get_latitude (zone);
+               zone = i_cal_timezone_array_element_at (zones, ii);
+               zone_longitude = i_cal_timezone_get_longitude (zone);
+               zone_latitude = i_cal_timezone_get_latitude (zone);
 
                if (zone_longitude - 0.005 <= longitude &&
                    zone_longitude + 0.005 >= longitude &&
                    zone_latitude - 0.005 <= latitude &&
                    zone_latitude + 0.005 >= latitude)
                {
+                       /* The caller owns the reference */
                        return zone;
                }
+
+               g_clear_object (&zone);
        }
 
        g_return_val_if_reached (NULL);
@@ -762,10 +776,10 @@ get_zone_from_point (ETimezoneDialog *etd,
  * e_timezone_dialog_get_timezone:
  * @etd: the timezone dialog
  *
- * Return value: the currently-selected timezone, or %NULL if no timezone
- * is selected.
+ * Returns: (transfer none): the currently-selected timezone as an #ICalTimezone obejct,
+ *    or %NULL if no timezone is selected.
  **/
-icaltimezone *
+ICalTimezone *
 e_timezone_dialog_get_timezone (ETimezoneDialog *etd)
 {
        ETimezoneDialogPrivate *priv;
@@ -789,7 +803,7 @@ e_timezone_dialog_get_timezone (ETimezoneDialog *etd)
 
 void
 e_timezone_dialog_set_timezone (ETimezoneDialog *etd,
-                                icaltimezone *zone)
+                               const ICalTimezone *zone)
 {
        ETimezoneDialogPrivate *priv;
        gchar *display = NULL;
@@ -803,13 +817,13 @@ e_timezone_dialog_set_timezone (ETimezoneDialog *etd,
                display = zone_display_name_with_offset (zone);
 
        /* Add any unknown/custom timezone with defined location */
-       if (zone && icaltimezone_get_location (zone) &&
-           !g_hash_table_lookup (etd->priv->index, icaltimezone_get_location (zone))) {
+       if (zone && i_cal_timezone_get_location (zone) &&
+           !g_hash_table_lookup (etd->priv->index, i_cal_timezone_get_location (zone))) {
                GtkTreeStore *tree_store;
                GtkTreeIter *piter, iter;
                const gchar *location;
 
-               location = icaltimezone_get_location (zone);
+               location = i_cal_timezone_get_location (zone);
                tree_store = GTK_TREE_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX 
(etd->priv->timezone_combo)));
 
                gtk_tree_store_prepend (tree_store, &iter, NULL);
@@ -820,12 +834,14 @@ e_timezone_dialog_set_timezone (ETimezoneDialog *etd,
 
                g_hash_table_insert (etd->priv->index, (gchar *) location, piter);
 
-               etd->priv->custom_zones = g_slist_prepend (etd->priv->custom_zones, zone);
+               etd->priv->custom_zones = g_slist_prepend (etd->priv->custom_zones, e_cal_util_copy_timezone 
(zone));
        }
 
        priv = etd->priv;
 
-       priv->zone = zone;
+       g_clear_object (&priv->zone);
+
+       priv->zone = zone ? e_cal_util_copy_timezone (zone) : NULL;
 
        gtk_label_set_text (
                GTK_LABEL (priv->preview_label),
@@ -851,7 +867,7 @@ e_timezone_dialog_get_toplevel (ETimezoneDialog *etd)
 
 static void
 set_map_timezone (ETimezoneDialog *etd,
-                  icaltimezone *zone)
+                 const ICalTimezone *zone)
 {
        ETimezoneDialogPrivate *priv;
        EMapPoint *point;
@@ -860,8 +876,8 @@ set_map_timezone (ETimezoneDialog *etd,
        priv = etd->priv;
 
        if (zone) {
-               zone_longitude = icaltimezone_get_longitude (zone);
-               zone_latitude = icaltimezone_get_latitude (zone);
+               zone_longitude = i_cal_timezone_get_longitude (zone);
+               zone_latitude = i_cal_timezone_get_latitude (zone);
                point = e_map_get_closest_point (
                        priv->map,
                        zone_longitude,
@@ -884,42 +900,48 @@ on_combo_changed (GtkComboBox *combo_box,
 {
        ETimezoneDialogPrivate *priv;
        gchar *new_zone_name;
-       icalarray *zones;
-       icaltimezone *map_zone = NULL;
+       ICalArray *zones;
+       ICalTimezone *map_zone = NULL;
        gchar *location;
-       gint i;
+       gint ii, sz;
 
        priv = etd->priv;
 
        timezone_combo_get_active_text (
                GTK_COMBO_BOX (priv->timezone_combo), &new_zone_name);
 
+       g_clear_object (&priv->zone);
+
        if (!new_zone_name || !*new_zone_name)
                priv->zone = NULL;
        else if (!g_utf8_collate (new_zone_name, _("UTC")))
-               priv->zone = icaltimezone_get_utc_timezone ();
+               priv->zone = e_cal_util_copy_timezone (i_cal_timezone_get_utc_timezone ());
        else {
                priv->zone = NULL;
 
-               zones = icaltimezone_get_builtin_timezones ();
-               for (i = 0; i < zones->num_elements; i++) {
-                       map_zone = icalarray_element_at (zones, i);
-                       location = _(icaltimezone_get_location (map_zone));
+               zones = i_cal_timezone_get_builtin_timezones ();
+               sz = i_cal_array_size (zones);
+
+               for (ii = 0; ii < sz; ii++) {
+                       map_zone = i_cal_timezone_array_element_at (zones, ii);
+                       location = _(i_cal_timezone_get_location (map_zone));
                        if (!g_utf8_collate (new_zone_name, location)) {
                                priv->zone = map_zone;
                                break;
                        }
+
+                       g_clear_object (&map_zone);
                }
 
                if (!priv->zone) {
                        GSList *link;
 
                        for (link = priv->custom_zones; link; link = g_slist_next (link)) {
-                               icaltimezone *zone = link->data;
+                               ICalTimezone *zone = link->data;
 
-                               if (zone && g_utf8_collate (new_zone_name, _(icaltimezone_get_location 
(zone))) == 0) {
+                               if (zone && g_utf8_collate (new_zone_name, _(i_cal_timezone_get_location 
(zone))) == 0) {
                                        map_zone = zone;
-                                       priv->zone = zone;
+                                       priv->zone = e_cal_util_copy_timezone (zone);
                                        break;
                                }
                        }
diff --git a/src/e-util/e-timezone-dialog.h b/src/e-util/e-timezone-dialog.h
index 0be885b1e5..43f6bb81e6 100644
--- a/src/e-util/e-timezone-dialog.h
+++ b/src/e-util/e-timezone-dialog.h
@@ -29,7 +29,10 @@
 #define E_TIMEZONE_DIALOG_H
 
 #include <gtk/gtk.h>
-#include <libical/ical.h>
+
+#define LIBICAL_GLIB_UNSTABLE_API 1
+#include <libical-glib/libical-glib.h>
+#undef LIBICAL_GLIB_UNSTABLE_API
 
 /* Standard GObject macros */
 #define E_TYPE_TIMEZONE_DIALOG \
@@ -68,9 +71,9 @@ ETimezoneDialog *
                e_timezone_dialog_construct     (ETimezoneDialog  *etd);
 ETimezoneDialog *
                e_timezone_dialog_new           (void);
-icaltimezone * e_timezone_dialog_get_timezone  (ETimezoneDialog *etd);
+ICalTimezone * e_timezone_dialog_get_timezone  (ETimezoneDialog *etd);
 void           e_timezone_dialog_set_timezone  (ETimezoneDialog *etd,
-                                                icaltimezone *zone);
+                                                const ICalTimezone *zone);
 GtkWidget *    e_timezone_dialog_get_toplevel  (ETimezoneDialog *etd);
 
 #endif /* E_TIMEZONE_DIALOG_H */
diff --git a/src/e-util/test-source-selector.c b/src/e-util/test-source-selector.c
index 2d5df38c0b..f1bbb1197d 100644
--- a/src/e-util/test-source-selector.c
+++ b/src/e-util/test-source-selector.c
@@ -311,9 +311,13 @@ cal_view_objects_removed_cb (ECalClientView *client_view,
 
        for (link = (GSList *) uids; link; link = g_slist_next (link)) {
                ECalComponentId *id = link->data;
+               const gchar *uid, *rid;
+
+               uid = id ? e_cal_component_id_get_uid (id) : NULL;
+               rid = id ? e_cal_component_id_get_uid (id) : NULL;
 
                if (id)
-                       g_print ("\tuid:%s%s%s\n", id->uid, id->rid ? " rid:" : "", id->rid ? id->rid : "");
+                       g_print ("\tuid:%s%s%s\n", uid, rid ? " rid:" : "", rid ? rid : "");
                else
                        g_print ("\tnull\n");
        }
diff --git a/src/modules/calendar/e-cal-attachment-handler.c b/src/modules/calendar/e-cal-attachment-handler.c
index 5cf9cd755a..62112e3258 100644
--- a/src/modules/calendar/e-cal-attachment-handler.c
+++ b/src/modules/calendar/e-cal-attachment-handler.c
@@ -23,7 +23,6 @@
 #include "e-cal-attachment-handler.h"
 
 #include <glib/gi18n.h>
-#include <libical/ical.h>
 #include <camel/camel.h>
 #include <libecal/libecal.h>
 
diff --git a/src/shell/main.c b/src/shell/main.c
index abc140d55f..f3aadd2f5d 100644
--- a/src/shell/main.c
+++ b/src/shell/main.c
@@ -486,13 +486,7 @@ main (gint argc,
                exit (1);
        }
 
-#ifdef HAVE_ICAL_UNKNOWN_TOKEN_HANDLING
-       ical_set_unknown_token_handling_setting (ICAL_DISCARD_TOKEN);
-#endif
-
-#ifdef HAVE_ICALTZUTIL_SET_EXACT_VTIMEZONES_SUPPORT
-       icaltzutil_set_exact_vtimezones_support (0);
-#endif
+       i_cal_set_unknown_token_handling_setting (I_CAL_DISCARD_TOKEN);
 
 #ifdef G_OS_WIN32
        if (register_handlers || reinstall || show_icons) {


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