mirror of
https://github.com/asterisk/asterisk.git
synced 2026-06-09 11:55:19 +00:00
res_calendar: Fix build with libical 4.X
libical 4.0 removed the icaltime_add() function in favor of icaltime_adjust(). Additionally, the callback signature for icalcomponent_foreach_recurrence() was updated to use a const pointer for the icaltime_span argument. This commit adds conditional compilation using ICAL_MAJOR_VERSION to support both libical 3.X and the new 4.X API, ensuring backward compatibility. Fixes: #1957
This commit is contained in:
committed by
Asterisk Development Team
parent
859e020b98
commit
63f17a6ba0
@@ -31,6 +31,12 @@
|
||||
#include "asterisk.h"
|
||||
|
||||
#include <libical/ical.h>
|
||||
|
||||
#if ICAL_MAJOR_VERSION >= 4
|
||||
#define ICAL_SPAN_CONST const
|
||||
#else
|
||||
#define ICAL_SPAN_CONST
|
||||
#endif
|
||||
#include <ne_session.h>
|
||||
#include <ne_uri.h>
|
||||
#include <ne_request.h>
|
||||
@@ -349,7 +355,7 @@ static time_t icalfloat_to_timet(icaltimetype time)
|
||||
* span here, and instead will grab the start and end from the component, which will
|
||||
* allow us to test for floating times or dates.
|
||||
*/
|
||||
static void caldav_add_event(icalcomponent *comp, struct icaltime_span *span, void *data)
|
||||
static void caldav_add_event(icalcomponent *comp, ICAL_SPAN_CONST struct icaltime_span *span, void *data)
|
||||
{
|
||||
struct caldav_pvt *pvt = data;
|
||||
struct ast_calendar_event *event;
|
||||
@@ -464,7 +470,17 @@ static void caldav_add_event(icalcomponent *comp, struct icaltime_span *span, vo
|
||||
} else { /* Offset from either dtstart or dtend */
|
||||
/* XXX Technically you can check RELATED to see if the event fires from the END of the event
|
||||
* But, I'm not sure I've ever seen anyone implement it in calendaring software, so I'm ignoring for now */
|
||||
#if ICAL_MAJOR_VERSION >= 4
|
||||
tmp = start;
|
||||
int sign = trigger.duration.is_neg ? -1 : 1;
|
||||
icaltime_adjust(&tmp,
|
||||
sign * (trigger.duration.days + trigger.duration.weeks * 7),
|
||||
sign * trigger.duration.hours,
|
||||
sign * trigger.duration.minutes,
|
||||
sign * trigger.duration.seconds);
|
||||
#else
|
||||
tmp = icaltime_add(start, trigger.duration);
|
||||
#endif
|
||||
event->alarm = icaltime_as_timet_with_zone(tmp, icaltime_get_timezone(start));
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,12 @@
|
||||
#include "asterisk.h"
|
||||
|
||||
#include <libical/ical.h>
|
||||
|
||||
#if ICAL_MAJOR_VERSION >= 4
|
||||
#define ICAL_SPAN_CONST const
|
||||
#else
|
||||
#define ICAL_SPAN_CONST
|
||||
#endif
|
||||
#include <ne_session.h>
|
||||
#include <ne_uri.h>
|
||||
#include <ne_request.h>
|
||||
@@ -191,7 +197,7 @@ static time_t icalfloat_to_timet(icaltimetype time)
|
||||
* allow us to test for floating times or dates.
|
||||
*/
|
||||
|
||||
static void icalendar_add_event(icalcomponent *comp, struct icaltime_span *span, void *data)
|
||||
static void icalendar_add_event(icalcomponent *comp, ICAL_SPAN_CONST struct icaltime_span *span, void *data)
|
||||
{
|
||||
struct icalendar_pvt *pvt = data;
|
||||
struct ast_calendar_event *event;
|
||||
@@ -341,7 +347,17 @@ static void icalendar_add_event(icalcomponent *comp, struct icaltime_span *span,
|
||||
} else { /* Offset from either dtstart or dtend */
|
||||
/* XXX Technically you can check RELATED to see if the event fires from the END of the event
|
||||
* But, I'm not sure I've ever seen anyone implement it in calendaring software, so I'm ignoring for now */
|
||||
#if ICAL_MAJOR_VERSION >= 4
|
||||
tmp = start;
|
||||
int sign = trigger.duration.is_neg ? -1 : 1;
|
||||
icaltime_adjust(&tmp,
|
||||
sign * (trigger.duration.days + trigger.duration.weeks * 7),
|
||||
sign * trigger.duration.hours,
|
||||
sign * trigger.duration.minutes,
|
||||
sign * trigger.duration.seconds);
|
||||
#else
|
||||
tmp = icaltime_add(start, trigger.duration);
|
||||
#endif
|
||||
event->alarm = icaltime_as_timet_with_zone(tmp, icaltime_get_timezone(start));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user