* Began preparing freebusy generation for recurring events. It does _something_...
authorArt Cancro <ajc@citadel.org>
Mon, 29 Dec 2008 16:49:45 +0000 (16:49 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 29 Dec 2008 16:49:45 +0000 (16:49 +0000)
citadel/modules/calendar/serv_calendar.c

index 3d63bcdc26cf8fe2a3e7908f51899bb4a9557ca2..432f9d51b2d64efd8f1736975c7dd94d7b3dc726 100644 (file)
@@ -1221,17 +1221,29 @@ void ical_conflicts(long msgnum, char *partnum) {
 
 /*
  * Look for busy time in a VEVENT and add it to the supplied VFREEBUSY.
+ *
+ * fb                  The VFREEBUSY component to which we are appending
+ * top_level_cal       The top-level VCALENDAR component which contains VEVENT to be added
+ * cal                 Caller supplies NULL, but we then use this variable for recursion
  */
-void ical_add_to_freebusy(icalcomponent *fb, icalcomponent *cal) {
+void ical_add_to_freebusy(icalcomponent *fb, icalcomponent *top_level_cal, icalcomponent *cal) {
        icalproperty *p;
        icalvalue *v;
        struct icalperiodtype my_period;
 
-       if (cal == NULL) return;
+       if (!top_level_cal) return;
+       if (!cal) cal = top_level_cal;
+
        my_period = icalperiodtype_null_period();
 
+       /* Convert all time zones to UTC (FIXME this won't work with recurring events) */
+       if (icalcomponent_isa(cal) != ICAL_VCALENDAR_COMPONENT) {
+               ical_dezonify(cal);
+       }
+
+       /* Now boil it down to the VEVENT only (FIXME this won't work with recurring events) */
        if (icalcomponent_isa(cal) != ICAL_VEVENT_COMPONENT) {
-               ical_add_to_freebusy(fb,
+               ical_add_to_freebusy(fb, top_level_cal,
                        icalcomponent_get_first_component(
                                cal, ICAL_VEVENT_COMPONENT
                        )
@@ -1338,7 +1350,7 @@ void ical_freebusy_backend(long msgnum, void *data) {
 
        if (ird.cal == NULL) return;
 
-       ical_add_to_freebusy(cal, ird.cal);
+       ical_add_to_freebusy(cal, ird.cal, NULL);
 
        /* Now free the memory. */
        icalcomponent_free(ird.cal);