* When saving a calendar event, increment the SEQUENCE property.
authorArt Cancro <ajc@citadel.org>
Fri, 20 Dec 2002 04:50:01 +0000 (04:50 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 20 Dec 2002 04:50:01 +0000 (04:50 +0000)
webcit/ChangeLog
webcit/event.c

index f36f481d147139c666fe3f69e773846d3422e0a6..299117903496d7befdc0033585b43efb023acc7d 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 400.67  2002/12/20 04:50:00  ajc
+* When saving a calendar event, increment the SEQUENCE property.
+
 Revision 400.66  2002/12/18 05:03:39  ajc
 * In the calendar code, changed all "struct tm *" to "struct tm" and changed
   all "tm = localtime(foo)" to "memcpy(&tm, localtime(foo), sizeof(struct tm))"
@@ -1183,3 +1186,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 0cca6db2a05e28a7b4c00c0a8a39c8dc698276a8..e54240db2096d0a59ceb2a68fa30a374268ea4fe 100644 (file)
@@ -46,6 +46,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
        char buf[SIZ];
        int i;
        int organizer_is_me = 0;
+       int sequence = 0;
 
        now = time(NULL);
        strcpy(organizer_string, "");
@@ -59,6 +60,13 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
                created_new_vevent = 1;
        }
 
+       /* Learn the sequence */
+       p = icalcomponent_get_first_property(vevent, ICAL_SEQUENCE_PROPERTY);
+       if (p != NULL) {
+               sequence = icalproperty_get_sequence(p);
+       }
+
+       /* Begin output */
        output_headers(3);
        wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>"
                "<IMG ALIGN=CENTER SRC=\"/static/vcalendar.gif\">"
@@ -74,6 +82,8 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
        if (p != NULL) {
                escputs((char *)icalproperty_get_comment(p));
        }
+       wprintf("<BR>\n");
+       wprintf("SEQUENCE == %d<BR>\n", sequence);
        *************************************************************/
 
        wprintf("<FORM NAME=\"EventForm\" METHOD=\"POST\" ACTION=\"/save_event\">\n");
@@ -339,6 +349,7 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum) {
        int foundit;
        char form_attendees[SIZ];
        char organizer_string[SIZ];
+       int sequence = 0;
 
        if (supplied_vevent != NULL) {
                vevent = supplied_vevent;
@@ -359,7 +370,7 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum) {
                }
                icalcomponent_add_property(vevent,
                        icalproperty_new_summary(bstr("summary")));
-               
+
                while (prop = icalcomponent_get_first_property(vevent,
                      ICAL_LOCATION_PROPERTY), prop != NULL) {
                        icalcomponent_remove_property(vevent, prop);
@@ -445,6 +456,19 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum) {
                        );
                }
 
+               /* Increment the sequence ID */
+               while (prop = icalcomponent_get_first_property(vevent,
+                     ICAL_SEQUENCE_PROPERTY), (prop != NULL) ) {
+                       i = icalproperty_get_sequence(prop);
+                       if (i > sequence) sequence = i;
+                       icalcomponent_remove_property(vevent, prop);
+                       icalproperty_free(prop);
+               }
+               ++sequence;
+               icalcomponent_add_property(vevent,
+                       icalproperty_new_sequence(sequence)
+               );
+               
                /* Set the organizer, only if one does not already exist *and*
                 * the form is supplying one
                 */