* Did a fairly significant reworking of the calendar
authorArt Cancro <ajc@citadel.org>
Tue, 25 Nov 2008 19:40:00 +0000 (19:40 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 25 Nov 2008 19:40:00 +0000 (19:40 +0000)
  processing loop.  We have to pass the entire chain through
  to the callback function in order to gain just-in-time
  dezonification and decapsulation.  This will work; I saw
  the recurrence stay within local time durin expansion.  Right
  now the expansion isn't happening at all, but I'll fix that
  shortly.

webcit/calendar.c
webcit/ical_dezonify.c

index 73cff24e9c387826c029732e5f8d51309f60cdb1..bbf37450f44c87e20df79541a210436ddcf836fd 100644 (file)
@@ -439,9 +439,21 @@ void display_individual_cal(icalcomponent *cal, long msgnum, char *from, int unr
        /* Note: anything we do here, we also have to do below for the recurrences. */
        Cal = (disp_cal*) malloc(sizeof(disp_cal));
        memset(Cal, 0, sizeof(disp_cal));
-
        Cal->cal = icalcomponent_new_clone(cal);
-       ical_dezonify(Cal->cal);                        /* just-in-time dezonify is necessary */
+
+       /* Dezonify and decapsulate at the very last moment */
+       ical_dezonify(Cal->cal);
+       icalcomponent *cptr;
+       if (icalcomponent_isa(Cal->cal) != ICAL_VEVENT_COMPONENT) {
+               cptr = icalcomponent_get_first_component(Cal->cal, ICAL_VEVENT_COMPONENT);
+               if (cptr) {
+                       cptr = icalcomponent_new_clone(cptr);
+                       icalcomponent_free(Cal->cal);
+                       Cal->cal = cptr;
+                       lprintf(9, "Deeeeeeeeeeeeeecapsulated!\n");
+               }
+       }
+
        Cal->unread = unread;
        len = strlen(from);
        Cal->from = (char*)malloc(len+ 1);
@@ -466,7 +478,7 @@ void display_individual_cal(icalcomponent *cal, long msgnum, char *from, int unr
        /* Do the same for the ending date and time.  It makes the day view much easier to render. */
        ps = icalcomponent_get_first_property(Cal->cal, ICAL_DTEND_PROPERTY);
        if (ps != NULL) {
-               dtend = icalproperty_get_dtstart(ps);
+               dtend = icalproperty_get_dtend(ps);
                Cal->event_end = icaltime_as_timet(dtend);
        }
 
@@ -505,7 +517,6 @@ void display_individual_cal(icalcomponent *cal, long msgnum, char *from, int unr
                        /* Note: anything we do here, we also have to do above for the root event. */
                        Cal = (disp_cal*) malloc(sizeof(disp_cal));
                        memset(Cal, 0, sizeof(disp_cal));
-               
                        Cal->cal = icalcomponent_new_clone(cal);
                        Cal->unread = unread;
                        len = strlen(from);
@@ -518,8 +529,31 @@ void display_individual_cal(icalcomponent *cal, long msgnum, char *from, int unr
                                icalcomponent_remove_property(Cal->cal, ps);
                                ps = icalproperty_new_dtstart(next);
                                icalcomponent_add_property(Cal->cal, ps);
-                               /*ical_dezonify(Cal->cal);*/    /* dezonify every recurrence - we may
-                                                                * have hit the start/end of DST */
+
+                               /* Dezonify and decapsulate each recurrence individually, otherwise
+                                * we slide over by an hour whenever we cross a DST boundary.
+                                */
+                               ical_dezonify(Cal->cal);
+                               icalcomponent *cptr;
+                               if (icalcomponent_isa(Cal->cal) != ICAL_VEVENT_COMPONENT) {
+                                       cptr = icalcomponent_get_first_component(Cal->cal,
+                                               ICAL_VEVENT_COMPONENT);
+                                       if (cptr) {
+                                               cptr = icalcomponent_new_clone(cptr);
+                                               icalcomponent_free(Cal->cal);
+                                               Cal->cal = cptr;
+                                               lprintf(9, "Deeeeeeeeeeeeeecapsulated!\n");
+                                       }
+                               }
+
+
+                               /* FIXME the above is broken, why? */
+
+
+
+
+
+
                                Cal->event_start = icaltime_as_timet(next);
                                lprintf(9, "\e[32mREPEATS: %s, is_utc=%d, tzid=%s\e[0m\n",
                                        icaltime_as_ical_string(next),
@@ -982,7 +1016,6 @@ void load_ical_object(long msgnum, int unread,
                        cal = icalcomponent_new_from_string(relevant_source);
                        if (cal != NULL) {
                                /* FIXME temp */
-                               lprintf(9, "HERE WE GO:\n%s\n", icalcomponent_as_ical_string(cal));
                                icalproperty *p;
                                p = icalcomponent_get_first_property(cal, ICAL_DTSTART_PROPERTY);
                                if (p) {
@@ -1029,8 +1062,8 @@ void load_ical_object(long msgnum, int unread,
  * Display a calendar item
  */
 void load_calendar_item(message_summary *Msg, int unread, struct calview *c) {
-       load_ical_object(Msg->msgnum, unread, ICAL_VEVENT_COMPONENT, display_individual_cal, c);
-       /* load_ical_object(Msg->msgnum, unread, (-1), display_individual_cal, c); */
+       /*load_ical_object(Msg->msgnum, unread, ICAL_VEVENT_COMPONENT, display_individual_cal, c);*/
+       load_ical_object(Msg->msgnum, unread, (-1), display_individual_cal, c);
 }
 
 /*
index 525af16e4dba85b08b02b10d4efb2cfc28ffa71c..11609590855f0c3cd9ba62fb8e36cfa42372eb9c 100644 (file)
@@ -13,9 +13,6 @@
 #include "webcit.h"
 #include "webserver.h"
 
-#define DBG_ICAL       1
-
-
 /*
  * Figure out which time zone needs to be used for timestamps that are
  * not UTC and do not have a time zone specified.