$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
1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
* webserver.c: warning fix
+
}
+/*
+ * 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
/*
* 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;
/*
* 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);
+ }
}
}
#endif
#define CALENDAR_ROOM_NAME "Calendar"
+#define PRODID "-//Citadel//NONSGML Citadel Calendar//EN"
#define SIZ 4096 /* generic buffer size */
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[];