From 9aab156cb9a1f1cc3271d3cce78b43e1c08e0f4b Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 31 Aug 2004 20:31:01 +0000 Subject: [PATCH] * When saving VTODO (tasks), insert a UID if none is already present. Also increment the sequence, or insert one if none is already present. --- webcit/ChangeLog | 5 +++++ webcit/calendar.c | 29 +++++++++++++++++++++++++++++ webcit/event.c | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 399a07d86..c1dcd939c 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,8 @@ $Log$ +Revision 523.1 2004/08/31 20:31:01 ajc +* When saving VTODO (tasks), insert a UID if none is already present. Also + increment the sequence, or insert one if none is already present. + Revision 523.0 2004/08/31 03:02:37 ajc * THIS IS 5.23 @@ -2036,3 +2040,4 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix + diff --git a/webcit/calendar.c b/webcit/calendar.c index 300d0ebb8..4d16877c8 100644 --- a/webcit/calendar.c +++ b/webcit/calendar.c @@ -600,6 +600,8 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum) { icalproperty *prop; icalcomponent *vtodo; int created_new_vtodo = 0; + int i; + int sequence = 0; if (supplied_vtodo != NULL) { vtodo = supplied_vtodo; @@ -665,6 +667,33 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum) { icaltime_from_webform("due") ) ); + + /* Give this task a UID if it doesn't have one. */ + lprintf(9, "Give this task a UID if it doesn't have one.\n"); + if (icalcomponent_get_first_property(vtodo, + ICAL_UID_PROPERTY) == NULL) { + generate_new_uid(buf); + icalcomponent_add_property(vtodo, + icalproperty_new_uid(buf) + ); + } + + /* Increment the sequence ID */ + lprintf(9, "Increment the sequence ID\n"); + while (prop = icalcomponent_get_first_property(vtodo, + ICAL_SEQUENCE_PROPERTY), (prop != NULL) ) { + i = icalproperty_get_sequence(prop); + lprintf(9, "Sequence was %d\n", i); + if (i > sequence) sequence = i; + icalcomponent_remove_property(vtodo, prop); + icalproperty_free(prop); + } + ++sequence; + lprintf(9, "New sequence is %d. Adding...\n", sequence); + icalcomponent_add_property(vtodo, + icalproperty_new_sequence(sequence) + ); + /* Serialize it and save it to the message base */ serv_puts("ENT0 1|||4"); diff --git a/webcit/event.c b/webcit/event.c index 2ee004052..d7ed702a6 100644 --- a/webcit/event.c +++ b/webcit/event.c @@ -46,8 +46,8 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum) icalproperty *attendee = NULL; char attendee_string[SIZ]; char buf[SIZ]; - int i; int organizer_is_me = 0; + int i; int sequence = 0; now = time(NULL) % 60; /* mod 60 to force :00 seconds */ -- 2.39.2