* When saving VTODO (tasks), insert a UID if none is already present. Also
authorArt Cancro <ajc@citadel.org>
Tue, 31 Aug 2004 20:31:01 +0000 (20:31 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 31 Aug 2004 20:31:01 +0000 (20:31 +0000)
  increment the sequence, or insert one if none is already present.

webcit/ChangeLog
webcit/calendar.c
webcit/event.c

index 399a07d86133b990237ef8dfef2e16e80ab7226c..c1dcd939cf36db57a979fe16576d66ad92bb737b 100644 (file)
@@ -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 <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
+
index 300d0ebb81f9f18e611bf2af064b739b352baf9d..4d16877c843883cb6f7c159a12b9ee8481c1c9c9 100644 (file)
@@ -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");
index 2ee0040524b893cfe980dbf480544dd1a3db44f0..d7ed702a619aa9cc0e6431d1f49bfe3ba24fae32 100644 (file)
@@ -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 */