diff options
author | Rajyalakshmi Bommaraju <rajyalakshmi.bommaraju@intel.com> | 2009-12-11 04:30:10 -0800 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2010-01-11 18:10:13 +0100 |
commit | 9b823e29794c614afe52d11366c6e5efe1cc65df (patch) | |
tree | 387fec5b7d64b699fbe2ed6278f7695c0d189adc /src/backends/evolution/EvolutionCalendarSource.cpp | |
parent | 089327f4489d171e9f60ec9440dc97acf33a36a6 (diff) |
Evolution calendar: work around 'cannot encode item' problem (MB #7879)
This happens for corrupt calendar data where a VEVENT refers to a
VTIMEZONE that is not available. Work around this by removing the
broken TZID in case of failure, then retrying the encoding.
This treats such events as if they were using local time without
timezone information, which is also how the Evolution GUI deals
with such events. It is correct as long as users only deal with
such broken events in their own timezone.
Diffstat (limited to 'src/backends/evolution/EvolutionCalendarSource.cpp')
-rw-r--r-- | src/backends/evolution/EvolutionCalendarSource.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/backends/evolution/EvolutionCalendarSource.cpp b/src/backends/evolution/EvolutionCalendarSource.cpp index d97102d4..dc42ae97 100644 --- a/src/backends/evolution/EvolutionCalendarSource.cpp +++ b/src/backends/evolution/EvolutionCalendarSource.cpp @@ -582,8 +582,32 @@ string EvolutionCalendarSource::retrieveItemAsString(const ItemID &id) eptr<char> icalstr; icalstr = e_cal_get_component_as_string(m_calendar, comp); + if (!icalstr) { - throwError(string("could not encode item as iCal: ") + id.getLUID()); + // One reason why e_cal_get_component_as_string() can fail is + // that it uses a TZID which has no corresponding VTIMEZONE + // definition. Evolution GUI ignores the TZID and interprets + // the times as local time. Do the same when exporting the + // event by removing the bogus TZID. + icalproperty *prop = icalcomponent_get_first_property (comp, + ICAL_ANY_PROPERTY); + + while (prop) { + icalparameter *param = icalproperty_get_first_parameter(prop, + ICAL_TZID_PARAMETER); + while (param) { + icalproperty_remove_parameter_by_kind(prop, ICAL_TZID_PARAMETER); + param = icalproperty_get_next_parameter (prop, ICAL_TZID_PARAMETER); + } + prop = icalcomponent_get_next_property (comp, + ICAL_ANY_PROPERTY); + } + + // now try again + icalstr = icalcomponent_as_ical_string(comp); + if (!icalstr) { + throwError(string("could not encode item as iCalendar: ") + id.getLUID()); + } } /* |