* More encapsulation. Warning: there are bugs in this!!
authorArt Cancro <ajc@citadel.org>
Thu, 13 Mar 2003 05:57:17 +0000 (05:57 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 13 Mar 2003 05:57:17 +0000 (05:57 +0000)
webcit/ChangeLog
webcit/calendar_tools.c
webcit/event.c
webcit/webcit.h

index 73fdbc3c28a5a748f830e71c5c6c31ee2aa29e1b..3ea57ecf77f3d2c5851c526f3cbb65f0f08b998e 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 410.3  2003/03/13 05:57:17  ajc
+* More encapsulation.  Warning: there are bugs in this!!
+
 Revision 410.2  2003/03/13 05:20:23  ajc
 * Various changes to the calendar service to handle messages containing
   fully encapsulated VCALENDAR components instead of only unencapsulated
@@ -1285,3 +1288,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 37d953f1542478c7e9d7cb4ba93ad75a512bb828..546badb3e53913fc23d09822fde9ce675ec36057 100644 (file)
@@ -230,4 +230,46 @@ void partstat_as_string(char *buf, icalproperty *attendee) {
 }
 
 
+/*
+ * Utility function to encapsulate a subcomponent into a full VCALENDAR
+ */
+icalcomponent *ical_encapsulate_subcomponent(icalcomponent *subcomp) {
+       icalcomponent *encaps;
+
+       /* If we're already looking at a full VCALENDAR component,
+        * don't bother ... just return itself.
+        */
+       if (icalcomponent_isa(subcomp) == ICAL_VCALENDAR_COMPONENT) {
+               return subcomp;
+       }
+
+       /* Encapsulate the VEVENT component into a complete VCALENDAR */
+       encaps = icalcomponent_new(ICAL_VCALENDAR_COMPONENT);
+       if (encaps == NULL) {
+               lprintf(3, "Error at %s:%d - could not allocate component!\n",
+                       __FILE__, __LINE__);
+               return NULL;
+       }
+
+       /* Set the Product ID */
+       icalcomponent_add_property(encaps, icalproperty_new_prodid(PRODID));
+
+       /* Set the Version Number */
+       icalcomponent_add_property(encaps, icalproperty_new_version("2.0"));
+
+       /* Encapsulate the subcomponent inside */
+       icalcomponent_add_component(encaps, subcomp);
+
+       /* Convert all timestamps to UTC so we don't have to deal with
+        * stupid VTIMEZONE crap.
+        */
+       ical_dezonify(encaps);
+
+       /* Return the object we just created. */
+       return(encaps);
+}
+
+
+
+
 #endif
index bf939b53c3f54c5c7cfa285736a9c1777bfcddfb..324879de6b8fae0cab960a0d453c809352d8c6b2 100644 (file)
@@ -405,12 +405,11 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
 /*
  * Save an edited event
  * 
- * ok
  */
 void save_individual_event(icalcomponent *supplied_vevent, long msgnum) {
        char buf[SIZ];
        icalproperty *prop;
-       icalcomponent *vevent;
+       icalcomponent *vevent, *encaps;
        int created_new_vevent = 0;
        int all_day_event = 0;
        struct icaltimetype event_start;
@@ -647,13 +646,20 @@ STARTOVER:
                /*
                 * Serialize it and save it to the message base
                 */
-               serv_puts("ENT0 1|||4");
-               serv_gets(buf);
-               if (buf[0] == '4') {
-                       serv_puts("Content-type: text/calendar");
-                       serv_puts("");
-                       serv_puts(icalcomponent_as_ical_string(vevent));
-                       serv_puts("000");
+               encaps = ical_encapsulate_subcomponent(vevent);
+               if (encaps != NULL) {
+                       serv_puts("ENT0 1|||4");
+                       serv_gets(buf);
+                       if (buf[0] == '4') {
+                               serv_puts("Content-type: text/calendar");
+                               serv_puts("");
+                               serv_puts(icalcomponent_as_ical_string(encaps));
+                               serv_puts("000");
+                       }
+                       if (encaps != vevent) {
+                               icalcomponent_remove_component(encaps, vevent);
+                               icalcomponent_free(encaps);
+                       }
                }
        }
 
index 08473b0d97f9c4cf4513473f719ee3a828fa4e6e..550566bd19014585a7ebf8dfe55ca837abc3fad8 100644 (file)
@@ -16,6 +16,7 @@
 #endif
 
 #define CALENDAR_ROOM_NAME     "Calendar"
+#define PRODID "-//Citadel//NONSGML Citadel Calendar//EN"
 
 #define SIZ                    4096            /* generic buffer size */
 
@@ -382,6 +383,7 @@ void respond_to_request(void);
 void handle_rsvp(void);
 void ical_dezonify(icalcomponent *cal);
 void partstat_as_string(char *buf, icalproperty *attendee);
+icalcomponent *ical_encapsulate_subcomponent(icalcomponent *subcomp);
 #endif
 
 extern char *months[];