From 54c53c773c3d40a2e1ebaf4d8d2e7f694a893c74 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 25 Nov 2008 17:37:10 +0000 Subject: [PATCH] * Update ical_dezonify() to use system tzdata (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 | 16 ++++++++++++++-- citadel/modules/calendar/serv_calendar.c | 10 ++++++++++ webcit/calendar.c | 15 ++++++++++++++- webcit/ical_dezonify.c | 12 ++++++++++++ webcit/siteconfig.c | 4 ++++ 5 files changed, 54 insertions(+), 3 deletions(-) diff --git a/citadel/ical_dezonify.c b/citadel/ical_dezonify.c index 0e95bdc71..776fe8634 100644 --- a/citadel/ical_dezonify.c +++ b/citadel/ical_dezonify.c @@ -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"); + } +*/ + } } } diff --git a/citadel/modules/calendar/serv_calendar.c b/citadel/modules/calendar/serv_calendar.c index 775ab5f97..b1610c7fe 100644 --- a/citadel/modules/calendar/serv_calendar.c +++ b/citadel/modules/calendar/serv_calendar.c @@ -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 } diff --git a/webcit/calendar.c b/webcit/calendar.c index 78994178a..73cff24e9 100644 --- a/webcit/calendar.c +++ b/webcit/calendar.c @@ -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, "REPEATS: %s, is_utc=%d, tzid=%s\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)) { diff --git a/webcit/ical_dezonify.c b/webcit/ical_dezonify.c index ff501519d..525af16e4 100644 --- a/webcit/ical_dezonify.c +++ b/webcit/ical_dezonify.c @@ -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 + } } } diff --git a/webcit/siteconfig.c b/webcit/siteconfig.c index 5cdeae1bc..53d8684f2 100644 --- a/webcit/siteconfig.c +++ b/webcit/siteconfig.c @@ -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); -- 2.30.2