libical3 compatibility , patches submitted by Adrian Bunk
[citadel.git] / citadel / modules / calendar / serv_calendar.c
index 5fc4bffc41d9c782e5edc150a36de194b6d351a5..6c7071d4e55d33aa4b9080f3beff3964814a60a0 100644 (file)
@@ -3,7 +3,7 @@
  * room on a Citadel server.  It handles iCalendar objects using the
  * iTIP protocol.  See RFCs 2445 and 2446.
  *
- * Copyright (c) 1987-2015 by the citadel.org team
+ * Copyright (c) 1987-2018 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 3.
@@ -143,7 +143,6 @@ void ical_write_to_cal(struct ctdluser *u, icalcomponent *cal) {
                msg->cm_format_type = 4;
                CM_SetField(msg, eAuthor, CCC->user.fullname, strlen(CCC->user.fullname));
                CM_SetField(msg, eOriginalRoom, CCC->room.QRname, strlen(CCC->room.QRname));
-               CM_SetField(msg, eNodeName, CtdlGetConfigStr("c_nodename"), strlen(CtdlGetConfigStr("c_nodename")));
                CM_SetField(msg, eHumanNode, CtdlGetConfigStr("c_humannode"), strlen(CtdlGetConfigStr("c_humannode")));
 
                MsgBody = NewStrBufPlain(NULL, serlen + 100);
@@ -235,7 +234,7 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
                /* We found our own address in the attendee list. */
                if (me_attend) {
                        /* Change the partstat from NEEDS-ACTION to ACCEPT or DECLINE */
-                       icalproperty_remove_parameter(me_attend, ICAL_PARTSTAT_PARAMETER);
+                       icalproperty_remove_parameter_by_kind(me_attend, ICAL_PARTSTAT_PARAMETER);
 
                        if (!strcasecmp(action, "accept")) {
                                partstat = icalparameter_new_partstat(ICAL_PARTSTAT_ACCEPTED);
@@ -1370,7 +1369,6 @@ void ical_add_to_freebusy(icalcomponent *fb, icalcomponent *top_level_cal) {
                        if (!icaltime_is_null_time(dtend)) {
                                dtend = icaltime_add(dtstart, dur);
                                dtend.zone = dtstart.zone;
-                               dtend.is_utc = dtstart.is_utc;
                        }
                        ++num_recur;
                }
@@ -1520,7 +1518,7 @@ void ical_freebusy(char *who) {
        icalcomponent_set_method(fb, ICAL_METHOD_PUBLISH);
 
        /* Set the DTSTAMP to right now. */
-       icalcomponent_set_dtstamp(fb, icaltime_from_timet(time(NULL), 0));
+       icalcomponent_set_dtstamp(fb, icaltime_from_timet_with_zone(time(NULL), 0, icaltimezone_get_utc_timezone()));
 
        /* Add the user's email address as ORGANIZER */
        sprintf(buf, "MAILTO:%s", who);
@@ -1541,10 +1539,10 @@ void ical_freebusy(char *who) {
         * to yesterday and tomorrow as default values.
         */
        if (icalcomponent_get_first_property(fb, ICAL_DTSTART_PROPERTY) == NULL) {
-               icalcomponent_set_dtstart(fb, icaltime_from_timet(time(NULL)-86400L, 0));
+               icalcomponent_set_dtstart(fb, icaltime_from_timet_with_zone(time(NULL)-86400L, 0, icaltimezone_get_utc_timezone()));
        }
        if (icalcomponent_get_first_property(fb, ICAL_DTEND_PROPERTY) == NULL) {
-               icalcomponent_set_dtend(fb, icaltime_from_timet(time(NULL)+86400L, 0));
+               icalcomponent_set_dtend(fb, icaltime_from_timet_with_zone(time(NULL)+86400L, 0, icaltimezone_get_utc_timezone()));
        }
 
        /* Put the freebusy component into the calendar component */
@@ -2580,8 +2578,12 @@ CTDL_MODULE_INIT(calendar)
        {
 
                /* Tell libical to return errors instead of aborting if it gets bad data */
-               // icalerror_errors_are_fatal = 0; (this was the old way)
+
+#ifdef LIBICAL_ICAL_EXPORT     // cheap and sleazy way to detect libical >=2.0
                icalerror_set_errors_are_fatal(0);
+#else
+               icalerror_errors_are_fatal = 0;
+#endif
 
                /* Use our own application prefix in tzid's generated from system tzdata */
                icaltimezone_set_tzid_prefix("/citadel.org/");