$darkmode
A guide to help developers port their code from libical v3.x to libical 4.0.
Some CMake option names have been removed or renamed (deprecated) to the LIBICAL namespace.
Please change your build scripts to use the new names before the next major release.
User-specific:
| Old Name | New Name |
|---|---|
| ICAL_ALLOW_EMPTY_PROPERTIES | removed |
| ICAL_BUILD_DOCS | LIBICAL_BUILD_DOCS |
| ICAL_ERRORS_ARE_FATAL | removed |
| ICAL_GLIB | LIBICAL_GLIB |
| ICAL_GLIB_VAPI | LIBICAL_GLIB_VAPI |
| ICAL_GLIB_BUILD_DOCS | LIBICAL_GLIB_BUILD_DOCS |
| USE_BUILTIN_TZDATA | LIBICAL_ENABLE_BUILTIN_TZDATA |
| USE_32BIT_TIME_T | LIBICAL_ENABLE_MSVC_32BIT_TIME_T |
| GOBJECT_INTROSPECTION | LIBICAL_GOBJECT_INTROSPECTION |
| WITH_CXX_BINDINGS | LIBICAL_CXX_BINDINGS |
| ENABLE_LTO_BUILD | CMAKE_INTERPROCEDURAL_OPTIMIZATION |
| SHARED_ONLY | removed |
| STATIC_ONLY | LIBICAL_STATIC |
Developer-specific:
| Old Name | New Name |
|---|---|
| ABI_DUMPER | LIBICAL_DEVMODE_ABI_DUMPER |
| ADDRESS_SANITIZER | LIBICAL_DEVMODE_ADDRESS_SANITIZER |
| LIBICAL_SYNCMODE_THREADLOCAL | LIBICAL_DEVMODE_SYNCMODE_THREADLOCAL |
| THREAD_SANITIZER | LIBICAL_DEVMODE_THREAD_SANITIZER |
| UNDEFINED_SANITIZER | LIBICAL_DEVMODE_UNDEFINED_SANITIZER |
To continue supporting the 3.0 version you can use conditional compilation, like so:
you can handle code that no longer exists in 4.0 with:
The ICAL_ENABLE_ERRORS_ARE_FATAL conditional compile macro and accompanying CMake option ICAL_ENABLE_ERRORS_ARE_FATAL are removed.
To abort whenever an error is encountered use the icalerror_set_errors_are_fatal() and icalerror_get_errors_are_fatal() functions.
The ICAL_ALLOW_EMPTY_PROPERTIES conditional compile macro and accompanying CMake option ICAL_ALLOW_EMPTY_PROPERTIES are removed.
To allow empty properties you can use the new runtime functions icalproperty_set_allow_empty_properties() and icalproperty_get_allow_empty_properties().
The PVL_USE_MACROS conditional compile macro is removed. The pvl unit always compiles the pvl_data function.
The ICAL_SETERROR_ISFUNC conditional compile macro is removed. The icalerror unit always compiles the icalerror_set_errno function.
The ICAL_BOOLEAN_TRUE and ICAL_BOOLEAN_FALSE macros are removed. The C library is C99 standards compliant and uses bool types.
icalrecurrencetype_from_string() was replaced by icalrecurrencetype_new_from_string(), which returns a struct icalrecurrencetype * rather than a struct icalrecurrencetype. Free the allocated memory using icalrecurrencetype_unref().struct icalrecurrencetype * rather than struct icalrecurrencetype:icalproperty_get_exrule()icalproperty_get_rrule()icalproperty_new_exrule()icalproperty_new_rrule()icalproperty_set_exrule()icalproperty_set_rrule()icalproperty_vanew_exrule()icalproperty_vanew_rrule()icalrecur_iterator_new()icalvalue_get_recur()icalvalue_new_recur()icalvalue_set_recur()struct icalrecurrencetype * rather than struct icalrecurrencetype:icalproperty_get_exrule()icalproperty_get_rrule()icalvalue_get_recur()icaltimezone_convert_time() now populates the icaltimetype zone member on conversion; i.e. the timezone information is not lost during a conversion.icaldurationtype_from_int() and icaldurationtype_as_int() have been renamed to icaldurationtype_from_seconds() and icaldurationtype_as_seconds(), respectively. The functionality of icaldurationtype_from_seconds has not changed. The functionality for icaldurationtype_as_seconds has changed, such that a duration with days or weeks fails with a ICAL_MALFORMEDDATA_ERROR and returns 0. To preserve the former logic of icaldurationtype_as_int, use he newly introduced icaldurationtype_as_utc_seconds.icaltime_add() and icaltime_subtract() functions are now called icalduration_extend() and icalduration_from_times(). Their functionality has not changed.get_zone_directory() and set_zone_directory() functions are have been renamed to icaltimezone_get_zone_directory() and icaltimezone_set_zone_directory(), respectively.icaltzutil_set_zone_directory() and icaltzutil_get_zone_directory() functions are now called icaltimezone_set_system_zone_directory() and icaltimezone_get_system_zone_directory() respectively.icalvalue_compare() function returned 0 if unknown or null value types were encountered; in this version, ICAL_XLICCOMPARETYPE_NONE is returned instead.icalcomponent_get_status() returned 0 if a problem parsing the status property was detected; in this version, ICAL_STATUS_NONE is returned instead.ical_bt() and icalerrno_return() functions have been renamed to icalerror_backtrace() and icalerror_icalerrno()` respectively for the sake of consistent function name-spacing.The following functions have been added:
ical_get_invalid_rrule_handling_setting()ical_set_invalid_rrule_handling_setting()icalarray_set_element_at()icalcluster_clone()icalcompiter_is_valid()icalcomponent_clone()icalcomponent_get_component_name()icalcomponent_get_component_name_r()icalcomponent_get_iana_name()icalcomponent_get_x_name()icalcomponent_new_iana()icalcomponent_set_iana_name()icalcomponent_set_x_name()icallimit_get()icallimit_set()icalparameter_clone()icalparameter_decode_value()icalparameter_is_multivalued()icalparameter_kind_value_kind()icalparser_get_ctrl()icalparser_set_ctrl()icalproperty_clone()icalproperty_get_allow_empty_properties()icalproperty_get_iana_name()icalproperty_new_iana()icalproperty_set_allow_empty_properties()icalproperty_set_iana_name()icalpropiter_is_valid()icalrecur_iterator_prev()icalrecur_resize_by()icalrecurrencetype_clone()icalrecurrencetype_clone()icalrecurrencetype_encode_day()icalrecurrencetype_encode_month()icalrecurrencetype_new()icalrecurrencetype_new_from_string()icalrecurrencetype_ref()icalrecurrencetype_ref()icalrecurrencetype_unref()icalrecurrencetype_unref()icaltimezone_set_system_zone_directory()icaltimezone_tzid_prefix()icalvalue_clone()icalstrarray and icalenumarray data typesicalmime_parse() has been removed. Please use another library if you need a MIME parser.icaltime_week_number() has been removed. (it never properly accounted for the start day of the week in different locales).icalrecurrencetype_clear() has been removed.icaltimezone_release_zone_tab() has been removed. Use `icaltimezone_free_builtin_timezones() instead.icalrecurrencetype_rscale_is_supported() has been removed as RSCALE=GREGORIAN is supported without libicu now. Replace icalrecurrencetype_rscale_is_supported() calls with a true condition.caldat()icalcluster_new_clone()icalcomponent_new_clone()icalparameter_new_clone()icalproperty_new_clone()icalvalue_new_clone()juldat()icalerror_assert()icalerror_check_arg()icalerror_check_arg_re()icalerror_check_arg_rv()icalerror_check_arg_rx()icalerror_check_arg_rz()icalerror_check_component_type()icalerror_check_parameter_type()icalerror_check_property_type()icalerror_check_value_type()icalerror_crash_here()icalerror_stop_here()icalerror_warn()icalerrprintf()icalproperty_new_impl()icalpvl_*()icalrecurrencetype_clear()icaltime_span_contains()icaltime_span_new()icaltime_span_overlaps()icaltimezone_array_append_from_vtimezone()icaltimezone_array_free()icaltimezone_array_new()icaltzutil_fetch_timezone()These convenience macros were added in version 3 to ease porting from older versions. They have been removed in version 4 and should be replaced with their actual function names as follows:
| Old Macro Name | Actual Function Name |
|---|---|
| icalenum_action_to_string | icalproperty_action_to_string |
| icalenum_class_to_string | icalproperty_class_to_string |
| icalenum_component_kind_to_string | icalcomponent_kind_to_string |
| icalenum_method_to_string | icalproperty_method_to_string |
| icalenum_participanttype_to_string | icalproperty_participanttype_to_string |
| icalenum_property_kind_to_string | icalproperty_kind_to_string |
| icalenum_property_kind_to_value_kind | icalproperty_kind_to_value_kind |
| icalenum_resourcetype_to_string | icalproperty_resourcetype_to_string |
| icalenum_status_to_string | icalproperty_status_to_string |
| icalenum_string_to_action | icalproperty_string_to_action |
| icalenum_string_to_class | icalproperty_string_to_class |
| icalenum_string_to_component_kind | icalcomponent_string_to_kind |
| icalenum_string_to_method | icalproperty_string_to_method |
| icalenum_string_to_participanttype | icalproperty_string_to_participanttype |
| icalenum_string_to_property_kind | icalproperty_string_to_kind |
| icalenum_string_to_resourcetype | icalproperty_string_to_resourcetype |
| icalenum_string_to_status | icalproperty_string_to_status |
| icalenum_string_to_transp | icalproperty_string_to_transp |
| icalenum_string_to_value_kind | icalvalue_string_to_kind |
| icalenum_transp_to_string | icalproperty_transp_to_string |
| icalenum_value_kind_to_string | icalvalue_kind_to_string |
Many function signatures have been changed to use const pointers.
A number of function signatures have been changed to use 'bool' rather than 'int' types.
This is implemented using the C99 standards compliant <stdbool.h> header.
Replace all ical*_new_clone() function calls with ical*_clone() . ie, use icalcomponent_clone() rather then icalcomponent_new_clone().
icalrecurrencetype now passed by referenceThe way struct icalrecurrencetype is passed between functions has been changed. While it was usually passed by value in 3.0, it is now passed by reference. A reference counting mechanism is applied that takes care of de-allocating an instance as soon as the reference counter goes to 0.
Code like this in libical 3.0:
changes to this in libical 4.0:
icalgeotype now uses character strings rather than doublesThe members of struct icalgeotype for latitude ('lat) and longitude ('lon) have been changed to use ICAL_GEO_LEN long character strings rather than the double type.
This means that simple assignments in 3.0 must be replaced by string copies.
becomes
and
becomes
The icaltime_adjust function no longer adjusts null icaltimetypes.
icalvalue and icalpropertyCode like this in libical 3.0:
changes to this in libical 4.0:
Support for these multi-valued parameters is added in libical 4.0.
You can access the 'nth' value for such parameters using the new "_nth" functions.
For example, to access the first delegated-to attendee use
The icaltimezone_set_tzid_prefix function now allows setting an empty prefix. In older libical versions, calling icaltimezone_set_tzid_prefix with an empty tzid prefix would reset to the BUILTIN_TZID_PREFIX value (i.e. ""/freeassociation.sourceforge.net/").
The new publicly visible function icaltimezone_tzid_prefix returns the current tzid prefix string.
Note that the tzid prefix must be globally unique (such as a domain name owned by the developer of the calling application), and begin and end with forward slashes. The tzid string must be fewer than 256 characters long.
struct icalrecurrencetype * rather than const struct icalrecurrencetype &:ICalProperty.set_exrule()ICalProperty.set_rrule()ICalValue.set_recur()struct icalrecurrencetype * rather than struct icalrecurrencetype:ICalProperty.get_exrule()ICalProperty.get_rrule()ICalValue.get_recur()icalrecurrencetype.by_xxx static arrays replaced by dynamically allocated onesI.e. memory short by_hour[ICAL_BY_DAY_SIZE] etc. are replaced by
Memory is allocated in the required size using the new icalrecur_resize_by() function. It is automatically freed together with the containing icalrecurrencetype. As the size of the array is stored explicitly, no termination of the array with special value ICAL_RECURRENCE_ARRAY_MAX is required anymore. The array is iterated by comparing the iterator to the size member value.
icalrecurrencetype.by_xxx static arrays usage from 3.0 to 4.0Code like this in libical 3.0:
changes to something like this in libical 4.0:
ICalGLib.Recurrence.*_by_* methodsi_cal_recurrence_*_by_xxx* methods have been replaced by more generic versions that take the 'by' type (day, month, ...) as a parameter.
i_cal_bt and i_cal_errno_return are renamed to i_calerror_backtrace and i_cal_errno_return, respectively.
ICalGLib.Recurrence.*_by_* methods from 3.0 to 4.0Code like this in libical 3.0:
changes to something like this in libical 4.0:
1.8.10