#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
-#include <ical.h>
+#include <libical/ical.h>
#include <libcitadel.h>
#include "citadel.h"
#include "server.h"
/* Encapsulate the subcomponent inside */
icalcomponent_add_component(encaps, subcomp);
- /* Convert all timestamps to UTC so we don't have to deal with
- * stupid VTIMEZONE crap.
- */
- ical_dezonify(encaps);
-
/* Return the object we just created. */
return(encaps);
}
return;
}
- ser = icalcomponent_as_ical_string(cal);
+ ser = icalcomponent_as_ical_string_r(cal);
if (ser == NULL) return;
/* If the caller supplied a user, write to that user's default calendar room */
}
/* In either case, now we can free the serialized calendar object */
-// free(ser);
+ free(ser);
}
}
/* Now generate the reply message and send it out. */
- serialized_reply = strdup(icalcomponent_as_ical_string(the_reply));
+ serialized_reply = icalcomponent_as_ical_string_r(the_reply);
icalcomponent_free(the_reply); /* don't need this anymore */
if (serialized_reply == NULL) return;
*/
void ical_locate_part(char *name, char *filename, char *partnum, char *disp,
void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
- void *cbuserdata) {
+ char *cbid, void *cbuserdata) {
struct ical_respond_data *ird = NULL;
}
ird->cal = icalcomponent_new_from_string(content);
- if (ird->cal != NULL) {
- ical_dezonify(ird->cal);
- }
}
*/
void ical_locate_original_event(char *name, char *filename, char *partnum, char *disp,
void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
- void *cbuserdata) {
+ char *cbid, void *cbuserdata) {
struct original_event_container *oec = NULL;
ical_merge_attendee_reply(original_event, cal);
/* Serialize it */
- serialized_event = strdup(icalcomponent_as_ical_string(original_event));
+ serialized_event = icalcomponent_as_ical_string_r(original_event);
icalcomponent_free(original_event); /* Don't need this anymore. */
if (serialized_event == NULL) return(2);
{
/* debugging cruft */
- time_t tt;
- tt = icaltime_as_timet(t1start);
- CtdlLogPrintf(CTDL_DEBUG, "PROPOSED START: %s", ctime(&tt));
- tt = icaltime_as_timet(t1end);
- CtdlLogPrintf(CTDL_DEBUG, " PROPOSED END: %s", ctime(&tt));
- tt = icaltime_as_timet(t2start);
- CtdlLogPrintf(CTDL_DEBUG, "EXISTING START: %s", ctime(&tt));
- tt = icaltime_as_timet(t2end);
- CtdlLogPrintf(CTDL_DEBUG, " EXISTING END: %s", ctime(&tt));
+ // time_t tt;
+ // tt = icaltime_as_timet(t1start);
+ // CtdlLogPrintf(CTDL_DEBUG, "PROPOSED START: %s", ctime(&tt));
+ // tt = icaltime_as_timet(t1end);
+ // CtdlLogPrintf(CTDL_DEBUG, " PROPOSED END: %s", ctime(&tt));
+ // tt = icaltime_as_timet(t2start);
+ // CtdlLogPrintf(CTDL_DEBUG, "EXISTING START: %s", ctime(&tt));
+ // tt = icaltime_as_timet(t2end);
+ // CtdlLogPrintf(CTDL_DEBUG, " EXISTING END: %s", ctime(&tt));
/* compare and output */
conflict_event_uid))) ? 1 : 0
)
);
- CtdlLogPrintf(CTDL_DEBUG, " --- CONFLICT --- \n");
- }
- else {
- CtdlLogPrintf(CTDL_DEBUG, " --- no conflict --- \n");
}
}
struct icaltimetype t2start, t2end;
icalproperty *p;
- /* initialization */
+ /* recur variables */
+ icalproperty *rrule = NULL;
+ struct icalrecurrencetype recur;
+ icalrecur_iterator *ritr = NULL;
+ struct icaldurationtype dur;
+ int num_recur = 0;
+ /* initialization */
strcpy(conflict_event_uid, "");
strcpy(conflict_event_summary, "");
t2start = icaltime_null_time();
t2end = icaltime_null_time();
-
/* existing event stuff */
-
p = ical_ctdl_get_subprop(existing_event, ICAL_DTSTART_PROPERTY);
if (p == NULL) return;
if (p != NULL) t2start = icalproperty_get_dtstart(p);
-
- p = ical_ctdl_get_subprop(existing_event, ICAL_DTEND_PROPERTY);
- if (p != NULL) t2end = icalproperty_get_dtend(p);
- p = ical_ctdl_get_subprop(existing_event, ICAL_UID_PROPERTY);
+ p = ical_ctdl_get_subprop(existing_event, ICAL_DTEND_PROPERTY);
if (p != NULL) {
- strcpy(conflict_event_uid, icalproperty_get_comment(p));
+ t2end = icalproperty_get_dtend(p);
+ dur = icaltime_subtract(t2end, t2start);
}
- p = ical_ctdl_get_subprop(existing_event, ICAL_SUMMARY_PROPERTY);
- if (p != NULL) {
- strcpy(conflict_event_summary, icalproperty_get_comment(p));
+ rrule = ical_ctdl_get_subprop(existing_event, ICAL_RRULE_PROPERTY);
+ if (rrule) {
+ recur = icalproperty_get_rrule(rrule);
+ ritr = icalrecur_iterator_new(recur, t2start);
+ CtdlLogPrintf(CTDL_DEBUG, "Recurrence found: %s\n", icalrecurrencetype_as_string(&recur));
}
+ do {
+ p = ical_ctdl_get_subprop(existing_event, ICAL_UID_PROPERTY);
+ if (p != NULL) {
+ strcpy(conflict_event_uid, icalproperty_get_comment(p));
+ }
+
+ p = ical_ctdl_get_subprop(existing_event, ICAL_SUMMARY_PROPERTY);
+ if (p != NULL) {
+ strcpy(conflict_event_summary, icalproperty_get_comment(p));
+ }
+
+ ical_conflicts_phase6(t1start, t1end, t2start, t2end,
+ existing_msgnum, conflict_event_uid, conflict_event_summary, compare_uid
+ );
- ical_conflicts_phase6(t1start, t1end, t2start, t2end,
- existing_msgnum, conflict_event_uid, conflict_event_summary, compare_uid
- );
+ if (rrule) {
+ t2start = icalrecur_iterator_next(ritr);
+ if (!icaltime_is_null_time(t2end)) {
+ t2end = icaltime_add(t2start, dur);
+ }
+ ++num_recur;
+ }
+ } while ( (rrule) && (!icaltime_is_null_time(t2start)) && (num_recur < MAX_RECUR) );
+ icalrecur_iterator_free(ritr);
+ if (num_recur > 0) CtdlLogPrintf(CTDL_DEBUG, "Iterated over existing event %d times.\n", num_recur);
}
icalproperty *p;
char compare_uid[SIZ];
+ /* recur variables */
+ icalproperty *rrule = NULL;
+ struct icalrecurrencetype recur;
+ icalrecur_iterator *ritr = NULL;
+ struct icaldurationtype dur;
+ int num_recur = 0;
/* initialization */
-
strcpy(compare_uid, "");
-
/* proposed event stuff */
p = ical_ctdl_get_subprop(proposed_event, ICAL_DTSTART_PROPERTY);
if (p != NULL) t1start = icalproperty_get_dtstart(p);
p = ical_ctdl_get_subprop(proposed_event, ICAL_DTEND_PROPERTY);
- if (p != NULL) t1end = icalproperty_get_dtend(p);
-
+ if (p != NULL) {
+ t1end = icalproperty_get_dtend(p);
+ dur = icaltime_subtract(t1end, t1start);
+ }
+
+ rrule = ical_ctdl_get_subprop(proposed_event, ICAL_RRULE_PROPERTY);
+ if (rrule) {
+ recur = icalproperty_get_rrule(rrule);
+ ritr = icalrecur_iterator_new(recur, t1start);
+ CtdlLogPrintf(CTDL_DEBUG, "Recurrence found: %s\n", icalrecurrencetype_as_string(&recur));
+ }
+
p = ical_ctdl_get_subprop(proposed_event, ICAL_UID_PROPERTY);
if (p != NULL) {
strcpy(compare_uid, icalproperty_get_comment(p));
}
- ical_conflicts_phase5(t1start, t1end, existing_event, existing_msgnum, compare_uid);
+ do {
+ ical_conflicts_phase5(t1start, t1end, existing_event, existing_msgnum, compare_uid);
+
+ if (rrule) {
+ t1start = icalrecur_iterator_next(ritr);
+ if (!icaltime_is_null_time(t1end)) {
+ t1end = icaltime_add(t1start, dur);
+ }
+ ++num_recur;
+ }
+
+ } while ( (rrule) && (!icaltime_is_null_time(t1start)) && (num_recur < MAX_RECUR) );
+ icalrecur_iterator_free(ritr);
+ if (num_recur > 0) CtdlLogPrintf(CTDL_DEBUG, "Iterated over proposed event %d times.\n", num_recur);
}
return;
}
- ical_dezonify(cal);
-
/* If this event is not opaque, the user isn't publishing it as
* busy time, so don't bother doing anything else.
*/
/* Serialize it */
CtdlLogPrintf(CTDL_DEBUG, "Serializing\n");
- serialized_request = strdup(icalcomponent_as_ical_string(encaps));
+ serialized_request = icalcomponent_as_ical_string_r(encaps);
icalcomponent_free(encaps); /* Don't need this anymore. */
cprintf("%d Here is the free/busy data:\n", LISTING_FOLLOWS);
(void *) encaps
);
- ser = strdup(icalcomponent_as_ical_string(encaps));
+ ser = icalcomponent_as_ical_string_r(encaps);
client_write(ser, strlen(ser));
free(ser);
cprintf("\n000\n");
cal = icalcomponent_new_from_string(calstream);
free(calstream);
- ical_dezonify(cal);
/* We got our data stream -- now do something with it. */
/* Set the method to REQUEST */
icalcomponent_set_method(encaps, ICAL_METHOD_REQUEST);
- /* Now make sure all of the DTSTART and DTEND properties are UTC. */
- ical_dezonify(the_request);
-
/* Here we go: put the VEVENT into the VCALENDAR. We now no longer
* are responsible for "the_request"'s memory -- it will be freed
* when we free "encaps".
icalcomponent_add_component(encaps, the_request);
/* Serialize it */
- serialized_request = strdup(icalcomponent_as_ical_string(encaps));
+ serialized_request = icalcomponent_as_ical_string_r(encaps);
icalcomponent_free(encaps); /* Don't need this anymore. */
if (serialized_request == NULL) return;
*/
void ical_obj_beforesave_backend(char *name, char *filename, char *partnum,
char *disp, void *content, char *cbtype, char *cbcharset, size_t length,
- char *encoding, void *cbuserdata)
+ char *encoding, char *cbid, void *cbuserdata)
{
icalcomponent *cal, *nested_event, *nested_todo, *whole_cal;
icalproperty *p;
*/
void ical_obj_aftersave_backend(char *name, char *filename, char *partnum,
char *disp, void *content, char *cbtype, char *cbcharset, size_t length,
- char *encoding, void *cbuserdata)
+ char *encoding, char *cbid, void *cbuserdata)
{
icalcomponent *cal;
return;
}
- ical_dezonify(cal);
ical_fixed_output_backend(cal, 0);
/* Free the memory we obtained from libical's constructor */
{
if (!threading)
{
+
+ /* Tell libical to return errors instead of aborting if it gets bad data */
+ icalerror_errors_are_fatal = 0;
+
+ /* Initialize our hook functions */
CtdlRegisterMessageHook(ical_obj_beforesave, EVT_BEFORESAVE);
CtdlRegisterMessageHook(ical_obj_aftersave, EVT_AFTERSAVE);
CtdlRegisterSessionHook(ical_create_room, EVT_LOGIN);