build: Support libical 4
libical 4 changed several APIs used by GNOME Calendar: - libical-glib now provides autoptr cleanup for ICalTime, so only define it ourselves for older versions. - i_cal_recurrence_get/set_by_day() were removed in favor of the dynamically sized by-rule arrays; add local helpers on top of i_cal_recurrence_get/set_by(). - i_cal_errno_return() was renamed to i_cal_error_icalerrno(). Also make the create-tzid event test independent of line folding, which differs between libical versions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,30 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
|
#if ICAL_MAJOR_VERSION >= 4
|
||||||
|
/* libical 4 replaced the fixed-size by_day array with dynamically sized arrays */
|
||||||
|
static gshort
|
||||||
|
i_cal_recurrence_get_by_day (ICalRecurrence *rrule,
|
||||||
|
guint index)
|
||||||
|
{
|
||||||
|
if (index >= i_cal_recurrence_get_by_array_size (rrule, I_CAL_BY_DAY))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return i_cal_recurrence_get_by (rrule, I_CAL_BY_DAY, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
i_cal_recurrence_set_by_day (ICalRecurrence *rrule,
|
||||||
|
guint index,
|
||||||
|
gshort value)
|
||||||
|
{
|
||||||
|
if (index >= i_cal_recurrence_get_by_array_size (rrule, I_CAL_BY_DAY))
|
||||||
|
i_cal_recurrence_resize_by_array (rrule, I_CAL_BY_DAY, index + 1);
|
||||||
|
|
||||||
|
i_cal_recurrence_set_by (rrule, I_CAL_BY_DAY, index, value);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
G_DEFINE_BOXED_TYPE (GcalRecurrence, gcal_recurrence, gcal_recurrence_ref, gcal_recurrence_unref)
|
G_DEFINE_BOXED_TYPE (GcalRecurrence, gcal_recurrence, gcal_recurrence_ref, gcal_recurrence_unref)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -147,7 +147,11 @@ read_file_in_thread (GTask *task,
|
|||||||
g_assert (g_utf8_validate (contents, length, NULL));
|
g_assert (g_utf8_validate (contents, length, NULL));
|
||||||
|
|
||||||
component = i_cal_parser_parse_string (contents);
|
component = i_cal_parser_parse_string (contents);
|
||||||
|
#if ICAL_MAJOR_VERSION >= 4
|
||||||
|
ical_error = i_cal_error_icalerrno ();
|
||||||
|
#else
|
||||||
ical_error = i_cal_errno_return ();
|
ical_error = i_cal_errno_return ();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (ical_error != I_CAL_NO_ERROR)
|
if (ical_error != I_CAL_NO_ERROR)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -60,7 +60,9 @@ typedef void (*GcalAskRecurrenceCallback) (GcalEvent *event,
|
|||||||
GcalRecurrenceModType modtype,
|
GcalRecurrenceModType modtype,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
|
#if ICAL_MAJOR_VERSION < 4
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ICalTime, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ICalTime, g_object_unref)
|
||||||
|
#endif
|
||||||
|
|
||||||
gchar* gcal_util_get_weekday (gint i);
|
gchar* gcal_util_get_weekday (gint i);
|
||||||
|
|
||||||
|
|||||||
+6
-2
@@ -323,6 +323,7 @@ event_date_create_tzid (void)
|
|||||||
g_autoptr (GDateTime) datetime = NULL;
|
g_autoptr (GDateTime) datetime = NULL;
|
||||||
g_autoptr (GTimeZone) tz = NULL;
|
g_autoptr (GTimeZone) tz = NULL;
|
||||||
g_autofree gchar *ical_string = NULL;
|
g_autofree gchar *ical_string = NULL;
|
||||||
|
GString *unfolded = NULL;
|
||||||
|
|
||||||
ECalComponent *comp = NULL;
|
ECalComponent *comp = NULL;
|
||||||
ICalComponent *ical_comp = NULL;
|
ICalComponent *ical_comp = NULL;
|
||||||
@@ -352,9 +353,12 @@ event_date_create_tzid (void)
|
|||||||
datetime = g_date_time_new (tz, 2017, 8, 18, 3, 00, 00.);
|
datetime = g_date_time_new (tz, 2017, 8, 18, 3, 00, 00.);
|
||||||
gcal_event_set_date_end (event, datetime);
|
gcal_event_set_date_end (event, datetime);
|
||||||
|
|
||||||
ical_string = i_cal_component_as_ical_string (ical_comp);
|
/* Unfold lines, since the folding position differs between libical versions */
|
||||||
|
unfolded = g_string_new_take (i_cal_component_as_ical_string (ical_comp));
|
||||||
|
g_string_replace (unfolded, "\r\n ", "", 0);
|
||||||
|
ical_string = g_string_free (g_steal_pointer (&unfolded), FALSE);
|
||||||
g_assert_true (strstr (ical_string, "DTSTART;TZID=Europe/London:20170818T010000\r\n") != NULL);
|
g_assert_true (strstr (ical_string, "DTSTART;TZID=Europe/London:20170818T010000\r\n") != NULL);
|
||||||
g_assert_true (strstr (ical_string, "DTEND;TZID=/freeassociation.sourceforge.net/Europe/London:\r\n 20170818T030000\r\n") != NULL);
|
g_assert_true (strstr (ical_string, "DTEND;TZID=/freeassociation.sourceforge.net/Europe/London:20170818T030000\r\n") != NULL);
|
||||||
g_clear_pointer (&ical_string, g_free);
|
g_clear_pointer (&ical_string, g_free);
|
||||||
|
|
||||||
g_setenv ("TZ", "UTC", TRUE);
|
g_setenv ("TZ", "UTC", TRUE);
|
||||||
|
|||||||
Reference in New Issue
Block a user