+ if (ical_conflicts_phase6(t1start, t1end, t2start, t2end,
+ existing_msgnum, conflict_event_uid, conflict_event_summary, compare_uid))
+ {
+ num_recur = MAX_RECUR + 1; /* force it out of scope, no need to continue */
+ }
+
+ if (rrule) {
+ t2start = icalrecur_iterator_next(ritr);
+ if (!icaltime_is_null_time(t2end)) {
+ const icaltimezone *hold_zone = t2end.zone;
+ t2end = icaltime_add(t2start, dur);
+ t2end.zone = hold_zone;
+ }
+ ++num_recur;
+ }
+
+ if (icaltime_compare(t2start, t1end) < 0) {
+ 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);
+}
+
+
+/*
+ * Phase 4 of "hunt for conflicts"
+ * Called by ical_hunt_for_conflicts_backend()
+ *
+ * At this point we've got it boiled down to two icalcomponent events in memory.
+ * If they conflict, output something to the client.
+ */
+void ical_conflicts_phase4(icalcomponent *proposed_event,
+ icalcomponent *existing_event,
+ long existing_msgnum)
+{
+ struct icaltimetype t1start, t1end;
+ 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 */
+ t1end = icaltime_null_time();
+ *compare_uid = '\0';
+
+ /* proposed event stuff */
+
+ p = ical_ctdl_get_subprop(proposed_event, ICAL_DTSTART_PROPERTY);
+ if (p == NULL)
+ return;
+ else
+ t1start = icalproperty_get_dtstart(p);
+
+ if (icaltime_is_utc(t1start)) {
+ t1start.zone = icaltimezone_get_utc_timezone();
+ }
+ else {
+ t1start.zone = icalcomponent_get_timezone(proposed_event,
+ icalparameter_get_tzid(
+ icalproperty_get_first_parameter(p, ICAL_TZID_PARAMETER)
+ )
+ );
+ if (!t1start.zone) {
+ t1start.zone = get_default_icaltimezone();
+ }
+ }
+
+ p = ical_ctdl_get_subprop(proposed_event, ICAL_DTEND_PROPERTY);