* Update ical_dezonify() to use system tzdata
authorArt Cancro <ajc@citadel.org>
Tue, 25 Nov 2008 17:37:10 +0000 (17:37 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 25 Nov 2008 17:37:10 +0000 (17:37 +0000)
  (or built-in tzdata if running on windows) to locate timezone
  information, if a matching timezone was not found somewhere
  within the supplied component.

citadel/ical_dezonify.c
citadel/modules/calendar/serv_calendar.c
webcit/calendar.c
webcit/ical_dezonify.c
webcit/siteconfig.c

index 0e95bdc71318f3c9a26fe0ad9dbf0e23f168766c..776fe8634a1ff5e73d69539ba8b47d9bd8c1498e 100644 (file)
@@ -88,10 +88,22 @@ void ical_dezonify_backend(icalcomponent *cal,
                                /* CtdlLogPrintf(9, "                * ...and we handle that internally.\n"); */
                        }
                        else {
+                               /* try attached first */
                                t = icalcomponent_get_timezone(cal, tzid);
-                               /* CtdlLogPrintf(9, "                * ...and I %s have tzdata for that zone.\n",
+/*
+                               lprintf(9, "                * ...and I %s have tzdata for that zone.\n",
                                        (t ? "DO" : "DO NOT")
-                               ); */
+                               );
+*/
+                               /* then try built-in timezones */
+                               if (!t) {
+                                       t = icaltimezone_get_builtin_timezone(tzid);
+/*
+                                       if (t) {
+                                               lprintf(9, "                * Using system tzdata!\n");
+                                       }
+*/
+                               }
                        }
                }
 
index 775ab5f97b74acf42c5123faf721a44f04fe1e2d..b1610c7fecaad4efce96041a7a8888f802ec3e7e 100644 (file)
@@ -169,6 +169,15 @@ void ical_write_to_cal(struct ctdluser *u, icalcomponent *cal) {
 void ical_add(icalcomponent *cal, int recursion_level) {
        icalcomponent *c;
 
+#if 1
+       /* Write the whole thing because it may need to save timezones etc.
+        * FIXME - if this works, we can probably eliminate this entire function
+        */
+
+       ical_write_to_cal(&CC->user, cal);
+
+#else  /* this was the old code to kill everything but the VEVENT component ... probably ng now */
+
        /*
         * The VEVENT subcomponent is the one we're interested in saving.
         */
@@ -185,6 +194,7 @@ void ical_add(icalcomponent *cal, int recursion_level) {
                /* Recursively process subcomponent */
                ical_add(c, recursion_level+1);
        }
+#endif
 
 }
 
index 78994178acfdbbcd7189a40d99aa019638131671..73cff24e9c387826c029732e5f8d51309f60cdb1 100644 (file)
@@ -518,7 +518,7 @@ 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
+                               /*ical_dezonify(Cal->cal);*/    /* dezonify every recurrence - we may
                                                                 * have hit the start/end of DST */
                                Cal->event_start = icaltime_as_timet(next);
                                lprintf(9, "\e[32mREPEATS: %s, is_utc=%d, tzid=%s\e[0m\n",
@@ -981,6 +981,19 @@ 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) {
+                                       lprintf(9, "DTSTART IS %s\n", 
+                                               icaltime_as_ical_string(
+                                                       icalproperty_get_dtstart(p)
+                                               )
+                                       );
+                               }
+                               /* */
+
 
                                /* A which_kind of (-1) means just load the whole thing */
                                if (which_kind == (-1)) {
index ff501519d244d4fea49a6342fa1659cf156414a2..525af16e4dba85b08b02b10d4efb2cfc28ffa71c 100644 (file)
@@ -13,6 +13,8 @@
 #include "webcit.h"
 #include "webserver.h"
 
+#define DBG_ICAL       1
+
 
 /*
  * Figure out which time zone needs to be used for timestamps that are
@@ -77,12 +79,22 @@ void ical_dezonify_backend(icalcomponent *cal,
 #endif
                        }
                        else {
+                               /* try attached first */
                                t = icalcomponent_get_timezone(cal, tzid);
 #ifdef DBG_ICAL
                                lprintf(9, "                * ...and I %s have tzdata for that zone.\n",
                                        (t ? "DO" : "DO NOT")
                                );
 #endif
+                               /* then try built-in timezones */
+                               if (!t) {
+                                       t = icaltimezone_get_builtin_timezone(tzid);
+#ifdef DBG_ICAL
+                                       if (t) {
+                                               lprintf(9, "                * Using system tzdata!\n");
+                                       }
+#endif
+                               }
                        }
                }
 
index 5cdeae1bc39b60595154518e5a113b6fbabe4196..53d8684f2497e937068764e79bdb88a6dc8f47b3 100644 (file)
@@ -26,6 +26,10 @@ void LoadZoneFiles(void)
        Put(ZoneHash, HKEY("UTC"), ZName, HFreeStrBuf);
        zones = icaltimezone_get_builtin_timezones();
        for (z = 0; z < zones->num_elements; ++z) {
+               /* lprintf(9, "Location: %-40s tzid: %s\n",
+                       icaltimezone_get_location(icalarray_element_at(zones, z)),
+                       icaltimezone_get_tzid(icalarray_element_at(zones, z))
+               ); */
                this_zone = icaltimezone_get_location(icalarray_element_at(zones, z));
                len = strlen(this_zone);
                ZName = NewStrBufPlain(this_zone, len);