tags 517548 +patch thanks On Saturday 28 February 2009 15:57:22 Luca Niccoli wrote:
> When > Orage meets a UID it already knows, it should check the LAST-MODIFIED > field, and pick the entry which was most recently modified. Here is a patch. Cheers, Luca
--- src/ical-code.c 2009-03-01 21:30:23.000000000 +0100 +++ src/ical-code.c.new 2009-03-01 22:03:31.000000000 +0100 @@ -3919,14 +3919,50 @@ return(TRUE); } +icalcomponent *component_with_uid(char *uid) +{ + icalcomponent *c1; + const char *text; + + if (xfical_file_open(FALSE)) { + for (c1 = icalcomponent_get_first_component(ical, ICAL_VEVENT_COMPONENT); + c1 != 0; + c1 = icalcomponent_get_next_component(ical, ICAL_VEVENT_COMPONENT)) { + text = icalcomponent_get_uid(c1); + + if ((ORAGE_STR_EXISTS(text) && strcmp(text, uid) == 0) + && ((icalcomponent_isa(c1) == ICAL_VEVENT_COMPONENT) + || (icalcomponent_isa(c1) == ICAL_VTODO_COMPONENT) + || (icalcomponent_isa(c1) == ICAL_VJOURNAL_COMPONENT))) { + return (c1); + } + } + } + + return (NULL); +} + +icaltimetype component_lmtime(icalcomponent *c) +{ + icalproperty *p = NULL; + +for (p = icalcomponent_get_first_property(c, ICAL_ANY_PROPERTY); + p != 0; + p = icalcomponent_get_next_property(c, ICAL_ANY_PROPERTY)) { + if (icalproperty_isa(p) == ICAL_LASTMODIFIED_PROPERTY) + return icalvalue_get_datetime(icalproperty_get_value(p)); + } +} + gboolean xfical_import_file(char *file_name) { #undef P_N #define P_N "xfical_import_file: " icalset *file_ical = NULL; - char *ical_file_name = NULL; - icalcomponent *c1, *c2; + char *ical_file_name = NULL, *uid = NULL; + icalcomponent *c1, *c2, *c3; int cnt1 = 0, cnt2 = 0; + icaltimetype ilmtime, elmtime; #ifdef ORAGE_DEBUG orage_message(-100, P_N); @@ -3951,8 +3987,19 @@ if ((icalcomponent_isa(c2) == ICAL_VEVENT_COMPONENT) || (icalcomponent_isa(c2) == ICAL_VTODO_COMPONENT) || (icalcomponent_isa(c2) == ICAL_VJOURNAL_COMPONENT)) { + uid = icalcomponent_get_uid(c2); + c3 = component_with_uid(uid); cnt2++; - add_event(c2); + if ( c3 == NULL) + add_event(c2); + else { + ilmtime = component_lmtime(c3); + elmtime = component_lmtime(c2); + if (icaltime_compare(ilmtime, elmtime) < 0) { + xfical_appt_del(g_strconcat("O00.", uid, NULL)); + add_event(c2); + } + } } /* we ignore TIMEZONE component; Orage only uses internal * timezones from libical */
signature.asc
Description: This is a digitally signed message part.