From 99c43630c6c1465ff21a783a2198779b837ad62a Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Thu, 22 Jul 2010 14:21:32 +0100 Subject: [PATCH] Add TZID to recurrenceid property, return correct component on recursion --- calitem_to_ical.c | 72 ++++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/calitem_to_ical.c b/calitem_to_ical.c index f64f6ce..34c4407 100644 --- a/calitem_to_ical.c +++ b/calitem_to_ical.c @@ -74,23 +74,25 @@ icalcomponent *ews_calitem_to_ical(xmlNode *xml_node, const gchar *parent_id, dtstart = dtend = icaltime_null_time(); - calcomp = icalcomponent_new_vcalendar(); - icalcomponent_set_method(calcomp, ICAL_METHOD_PUBLISH); - prop = icalproperty_new_version("2.0"); - icalcomponent_add_property(calcomp, prop); - if (parent_zone) + if (parent_zone) { + calcomp = NULL; icaltz = parent_zone; - else { + } else { + calcomp = icalcomponent_new_vcalendar(); + icalcomponent_set_method(calcomp, ICAL_METHOD_PUBLISH); + prop = icalproperty_new_version("2.0"); + icalcomponent_add_property(calcomp, prop); + icaltz = get_meeting_timezone(xml_node, error); if (icaltz) freetz = TRUE; - else { + else icaltz = get_timezone(xml_node, error); - if (icaltz) { - icalcomponent *comp = icaltimezone_get_component(icaltz); - icalcomponent_add_component(calcomp, comp); - } + + if (icaltz) { + icalcomponent *comp = icaltimezone_get_component(icaltz); + icalcomponent_add_component(calcomp, comp); } } @@ -229,30 +231,39 @@ icalcomponent *ews_calitem_to_ical(xmlNode *xml_node, const gchar *parent_id, } free(deletia); } - icalcomponent_add_component(calcomp, comp); + if (calcomp) { + icalcomponent_add_component(calcomp, comp); - if (modifia) { - const char *uid = icalcomponent_get_uid(comp); - - for (i = 0; i < modifia_count; i++) { - printf("Modified: %s\n", modifia[i]); - if (fetch_subitem) { - comp = fetch_subitem(fetch_subitem_priv, modifia[i], uid, icaltz, error); - if (!comp) - goto err; + if (modifia) { + const char *uid = icalcomponent_get_uid(comp); + + for (i = 0; i < modifia_count; i++) { + if (fetch_subitem) { + comp = fetch_subitem(fetch_subitem_priv, modifia[i], uid, icaltz, error); + if (!comp) + goto err; + icalcomponent_add_component(calcomp, comp); + } } + free(modifia); } - free(modifia); } if (freetz) icaltimezone_free(icaltz, 1); - return calcomp; + + return calcomp?:comp; err: - icalcomponent_free(calcomp); + if (comp) + icalcomponent_free(comp); + if (calcomp) + icalcomponent_free(calcomp); if (deletia) free(deletia); + if (modifia) + free(modifia); + return NULL; } @@ -395,14 +406,23 @@ gboolean process_time(icalcomponent *comp, xmlNode *xml_node, icaltimetype *ical gboolean process_orig_start(icalcomponent *comp, xmlNode *xml_node, icaltimezone *icaltz, GError **error) { + icalproperty *prop; + const char *tzid = NULL; icaltimetype t; if (!process_time(comp, xml_node, &t, error)) return FALSE; - if (icaltz) + if (icaltz) { t = icaltime_convert_to_zone(t, icaltz); - icalcomponent_set_recurrenceid(comp, t); + } + + /* Grr, icalproperty_add_recurrenceid() doesn't include TZID */ + prop = icalproperty_new_recurrenceid(t); + tzid = icaltime_get_tzid(t); + if (tzid) + icalproperty_add_parameter(prop, icalparameter_new_tzid(tzid)); + icalcomponent_add_property(comp, prop); return TRUE; } -- 2.49.0