X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fcalendar%2Fserv_calendar.c;h=42914915cb2d08fe35e95f1afeb68e3a53a7c984;hb=f8d951444991ddc63a10229ab2c29bbf1ac3cc8c;hp=120493c8b7ac0d6d088098306bab7f1f44490fea;hpb=345e2ecf8e9a0511b335595c73342002b054ddb1;p=citadel.git diff --git a/citadel/modules/calendar/serv_calendar.c b/citadel/modules/calendar/serv_calendar.c index 120493c8b..42914915c 100644 --- a/citadel/modules/calendar/serv_calendar.c +++ b/citadel/modules/calendar/serv_calendar.c @@ -858,8 +858,10 @@ int ical_ctdl_is_overlap( * * Now both the proposed and existing events have been boiled down to start and end times. * Check for overlap and output any conflicts. + * + * Returns nonzero if a conflict was reported. This allows the caller to stop iterating. */ -void ical_conflicts_phase6(struct icaltimetype t1start, +int ical_conflicts_phase6(struct icaltimetype t1start, struct icaltimetype t1end, struct icaltimetype t2start, struct icaltimetype t2end, @@ -868,17 +870,19 @@ void ical_conflicts_phase6(struct icaltimetype t1start, char *conflict_event_summary, char *compare_uid) { + int conflict_reported = 0; /* 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)); + /* debugging cruft */ /* compare and output */ @@ -892,8 +896,10 @@ void ical_conflicts_phase6(struct icaltimetype t1start, conflict_event_uid))) ? 1 : 0 ) ); + conflict_reported = 1; } + return(conflict_reported); } @@ -958,9 +964,12 @@ void ical_conflicts_phase5(struct icaltimetype t1start, 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 - ); + if (ical_conflicts_phase6(t1start, t1end, t2start, t2end, + existing_msgnum, conflict_event_uid, conflict_event_summary, compare_uid)) + { + CtdlLogPrintf(CTDL_DEBUG, "Hit a conflict after %d iterations\n", num_recur); + num_recur = MAX_RECUR + 1; /* force it out of scope */ + } if (rrule) { t2start = icalrecur_iterator_next(ritr); @@ -970,6 +979,11 @@ void ical_conflicts_phase5(struct icaltimetype t1start, ++num_recur; } + if (icaltime_compare(t2start, t1end) < 0) { + CtdlLogPrintf(CTDL_DEBUG, "Went out of scope after %d iterations\n", num_recur); + num_recur = MAX_RECUR + 1; /* force it out of scope */ + } + } 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); @@ -1122,7 +1136,7 @@ void ical_conflicts(long msgnum, char *partnum) { msg = CtdlFetchMessage(msgnum, 1); if (msg == NULL) { - cprintf("%d Message %ld not found.\n", + cprintf("%d Message %ld not found\n", ERROR + ILLEGAL_VALUE, (long)msgnum ); @@ -1146,12 +1160,8 @@ void ical_conflicts(long msgnum, char *partnum) { icalcomponent_free(ird.cal); return; } - else { - cprintf("%d No calendar object found\n", ERROR + ROOM_NOT_FOUND); - return; - } - /* should never get here */ + cprintf("%d No calendar object found\n", ERROR + ROOM_NOT_FOUND); }