cyrus-imapd/1966c22fc4249a1157a4d4c1224138ce78653514.patch
Jason Tibbitts 8fddca24c0 Libical3 support
- Rebuild for new libical.
- Add patch to fix compilation error with new libical.
- Disable two tests which fail due to the new libical.
2017-11-14 12:14:03 -06:00

241 lines
9.9 KiB
Diff

From 1966c22fc4249a1157a4d4c1224138ce78653514 Mon Sep 17 00:00:00 2001
From: Ken Murchison <murch@andrew.cmu.edu>
Date: Sat, 21 Oct 2017 19:04:08 -0400
Subject: [PATCH] Account for the removal of icaltimetype.is_utc field in
upcoming libical
---
configure.ac | 5 +++++
imap/http_caldav.c | 2 +-
imap/http_caldav_sched.c | 4 ++--
imap/http_tzdist.c | 22 +++++++++++-----------
imap/ical_support.c | 9 +++++++++
imap/ical_support.h | 2 ++
imap/jmap_ical.c | 4 ++--
imap/xcal.c | 4 ++--
8 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/configure.ac b/configure.ac
index b7f2d0da9..8eb11966d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1492,6 +1492,11 @@ dnl
icalrecur_freq_to_string, icalrecur_weekday_to_string],
[], [], [[#include <libical/ical.h>]])
+ AC_CHECK_MEMBER(icaltimetype.is_utc,
+ AC_DEFINE(ICALTIME_HAS_IS_UTC,[],
+ [Does icaltimetype have is_utc field?]),
+ [], [#include <libical/ical.h>])
+
AC_CHECK_LIB(ical, icalproperty_new_acknowledged,
AC_DEFINE(HAVE_VALARM_EXT_PROPS,[],
[Do we have built-in support for VALARM extensions props?]))
diff --git a/imap/http_caldav.c b/imap/http_caldav.c
index eb9d4add1..4cb11d228 100644
--- a/imap/http_caldav.c
+++ b/imap/http_caldav.c
@@ -2391,7 +2391,7 @@ static struct icaltimetype icaltime_from_rfc3339_string(const char *str)
goto fail;
}
- tt.is_utc = 1;
+ icaltime_set_utc(&tt, 1);
return tt;
fail:
diff --git a/imap/http_caldav_sched.c b/imap/http_caldav_sched.c
index 1dc97a501..b896d871a 100644
--- a/imap/http_caldav_sched.c
+++ b/imap/http_caldav_sched.c
@@ -355,7 +355,7 @@ static int imip_send_sendmail(icalcomponent *ical,
cp += sprintf(cp, "%s, %02u %s %04u",
day_of_week[icaltime_day_of_week(start)-1],
start.day, month_of_year[start.month-1], start.year);
- if (!start.is_date) {
+ if (!icaltime_is_date(start)) {
cp += sprintf(cp, " %02u:%02u", start.hour, start.minute);
if (start.second) cp += sprintf(cp, ":%02u", start.second);
strcpy(cp, " UTC");
@@ -370,7 +370,7 @@ static int imip_send_sendmail(icalcomponent *ical,
day_of_week[icaltime_day_of_week(end)-1],
end.day, month_of_year[end.month-1], end.year);
}
- if (!end.is_date) {
+ if (!icaltime_is_date(end)) {
cp += sprintf(cp, " %02u:%02u", end.hour, end.minute);
if (end.second) cp += sprintf(cp, ":%02u", end.second);
strcpy(cp, " UTC");
diff --git a/imap/http_tzdist.c b/imap/http_tzdist.c
index 258440ce9..a88e8bf68 100644
--- a/imap/http_tzdist.c
+++ b/imap/http_tzdist.c
@@ -1376,7 +1376,7 @@ static void truncate_vtimezone(icalcomponent *vtz,
/* Adjust DTSTART observance to UTC */
icaltime_adjust(&obs.onset, 0, 0, 0, -obs.offset_from);
- obs.onset.is_utc = 1;
+ icaltime_set_utc(&obs.onset, 1);
/* Check DTSTART vs window close */
if (!icaltime_is_null_time(end) &&
@@ -1451,7 +1451,7 @@ static void truncate_vtimezone(icalcomponent *vtz,
if (!eternal) {
/* Adjust UNTIL to local time (for iterator) */
icaltime_adjust(&rrule.until, 0, 0, 0, obs.offset_from);
- rrule.until.is_utc = 0;
+ icaltime_set_utc(&rrule.until, 0);
}
if (trunc_dtstart) {
@@ -1475,7 +1475,7 @@ static void truncate_vtimezone(icalcomponent *vtz,
/* Adjust observance to UTC */
icaltime_adjust(&obs.onset, 0, 0, 0, -obs.offset_from);
- obs.onset.is_utc = 1;
+ icaltime_set_utc(&obs.onset, 1);
if (trunc_until && icaltime_compare(obs.onset, end) >= 0) {
/* Observance is on/after window close */
@@ -1580,7 +1580,7 @@ static void truncate_vtimezone(icalcomponent *vtz,
/* Adjust observance to UTC */
icaltime_adjust(&obs.onset, 0, 0, 0, -obs.offset_from);
- obs.onset.is_utc = 1;
+ icaltime_set_utc(&obs.onset, 1);
if (!icaltime_is_null_time(end) &&
icaltime_compare(obs.onset, end) >= 0) {
@@ -1691,7 +1691,7 @@ static void truncate_vtimezone(icalcomponent *vtz,
case ICAL_DTSTART_PROPERTY:
/* Adjust window open to local time */
icaltime_adjust(&start, 0, 0, 0, tombstone.offset_from);
- start.is_utc = 0;
+ icaltime_set_utc(&start, 0);
icalproperty_set_dtstart(prop, start);
break;
@@ -1775,14 +1775,14 @@ static int action_get(struct transaction_t *txn)
/* Sanity check the parameters */
if ((param = hash_lookup("start", &txn->req_qparams))) {
start = icaltime_from_string(param->s);
- if (param->next || !start.is_utc) { /* once only, UTC */
+ if (param->next || !icaltime_is_utc(start)) { /* once only, UTC */
return json_error_response(txn, TZ_INVALID_START, param, &start);
}
}
if ((param = hash_lookup("end", &txn->req_qparams))) {
end = icaltime_from_string(param->s);
- if (param->next || !end.is_utc /* once only, UTC */
+ if (param->next || !icaltime_is_utc(end) /* once only, UTC */
|| icaltime_compare(end, start) <= 0) { /* end MUST be > start */
return json_error_response(txn, TZ_INVALID_END, param, &end);
}
@@ -1956,7 +1956,7 @@ static int action_expand(struct transaction_t *txn)
return json_error_response(txn, TZ_INVALID_START, param, NULL);
start = icaltime_from_string(param->s);
- if (!start.is_utc) /* MUST be UTC */
+ if (!icaltime_is_utc(start)) /* MUST be UTC */
return json_error_response(txn, TZ_INVALID_START, param, &start);
param = hash_lookup("end", &txn->req_qparams);
@@ -1964,7 +1964,7 @@ static int action_expand(struct transaction_t *txn)
return json_error_response(txn, TZ_INVALID_END, param, NULL);
end = icaltime_from_string(param->s);
- if (!end.is_utc /* MUST be UTC */
+ if (!icaltime_is_utc(end) /* MUST be UTC */
|| icaltime_compare(end, start) <= 0) { /* end MUST be > start */
return json_error_response(txn, TZ_INVALID_END, param, &end);
}
@@ -2237,7 +2237,7 @@ static int json_error_response(struct transaction_t *txn, long tz_code,
else if (param->next) fmt = "Multiple %s parameters";
else if (!param->s || !param->s[0]) fmt = "Missing %s value";
else if (!time) fmt = "Invalid %s value";
- else if (!time->is_utc) fmt = "Invalid %s UTC value";
+ else if (!icaltime_is_utc(*time)) fmt = "Invalid %s UTC value";
else fmt = "End date-time <= start date-time";
assert(!buf_len(&txn->buf));
@@ -2500,7 +2500,7 @@ static struct buf *_icaltimezone_as_tzfile(icalcomponent* ical,
for (n = 0; n < obsarray->num_elements; n++) {
long long int t;
unsigned typeidx;
- icaltimetype tt_1601 = { 1601, 1, 1, 0, 0, 0, 1, 0, 0, NULL };
+ icaltimetype tt_1601 = icaltime_from_string("1601-01-01T00:00:00Z");
obs = icalarray_element_at(obsarray, n);
t = icaltime_to_gmtime64(obs->onset);
diff --git a/imap/ical_support.c b/imap/ical_support.c
index 3deb649b1..13861b25a 100644
--- a/imap/ical_support.c
+++ b/imap/ical_support.c
@@ -833,6 +833,15 @@ icalrecurrenceset_get_utc_timespan(icalcomponent *ical,
return span;
}
+EXPORTED void icaltime_set_utc(struct icaltimetype *t, int set)
+{
+#ifdef ICALTIME_HAS_IS_UTC
+ t->is_utc = set;
+#else
+ icaltime_set_timezone(t, set ? icaltimezone_get_utc_timezone() : NULL);
+#endif
+}
+
#ifndef HAVE_TZDIST_PROPS
diff --git a/imap/ical_support.h b/imap/ical_support.h
index 8db35ed1f..0336d59e1 100644
--- a/imap/ical_support.h
+++ b/imap/ical_support.h
@@ -100,6 +100,8 @@ extern struct icalperiodtype icalrecurrenceset_get_utc_timespan(icalcomponent *i
void*),
void *cb_rock);
+extern void icaltime_set_utc(struct icaltimetype *t, int set);
+
/* Functions not declared in in libical < v2.0 */
diff --git a/imap/jmap_ical.c b/imap/jmap_ical.c
index c0d4910f5..dd8460f36 100644
--- a/imap/jmap_ical.c
+++ b/imap/jmap_ical.c
@@ -737,7 +737,7 @@ static const char *tzid_from_icalprop(icalproperty *prop, int guess) {
} else {
icalvalue *val = icalproperty_get_value(prop);
icaltimetype dt = icalvalue_get_datetime(val);
- if (icaltime_is_valid_time(dt) && dt.is_utc) {
+ if (icaltime_is_valid_time(dt) && icaltime_is_utc(dt)) {
tzid = "Etc/UTC";
}
}
@@ -2615,7 +2615,7 @@ static icalproperty *dtprop_to_ical(icalcomponent *comp,
/* Set the new property. */
prop = icalproperty_new(kind);
icalproperty_set_value(prop, val);
- if (tz && !dt.is_utc) {
+ if (tz && !icaltime_is_utc(dt)) {
icalparameter *param = icalproperty_get_first_parameter(prop, ICAL_TZID_PARAMETER);
const char *tzid = icaltimezone_get_location(tz);
if (param) {
diff --git a/imap/xcal.c b/imap/xcal.c
index 27a32d96b..36129fdcc 100644
--- a/imap/xcal.c
+++ b/imap/xcal.c
@@ -115,8 +115,8 @@ const char *icaltime_as_iso_string(const struct icaltimetype tt)
static char str[21];
const char *fmt;
- if (tt.is_date) fmt = "%04d-%02d-%02d";
- else if (tt.is_utc) fmt = "%04d-%02d-%02dT%02d:%02d:%02dZ";
+ if (icaltime_is_date(tt)) fmt = "%04d-%02d-%02d";
+ else if (icaltime_is_utc(tt)) fmt = "%04d-%02d-%02dT%02d:%02d:%02dZ";
else fmt = "%04d-%02d-%02dT%02d:%02d:%02d";
snprintf(str, sizeof(str), fmt, tt.year, tt.month, tt.day,