icalcomponent *ical_encapsulate_subcomponent(icalcomponent *subcomp) {
icalcomponent *encaps;
+ lprintf(9, "ical_encapsulate_subcomponent() called\n");
+
+ if (subcomp == NULL) {
+ lprintf(3, "ERROR: called with NULL argument!\n");
+ return NULL;
+ }
+
/* If we're already looking at a full VCALENDAR component,
* don't bother ... just return itself.
*/
if (icalcomponent_isa(subcomp) == ICAL_VCALENDAR_COMPONENT) {
+ lprintf(9, "Already encapsulated. Returning itself.\n");
return subcomp;
}
/* Encapsulate the VEVENT component into a complete VCALENDAR */
+ lprintf(9, "Creating new calendar component\n");
encaps = icalcomponent_new(ICAL_VCALENDAR_COMPONENT);
if (encaps == NULL) {
lprintf(3, "Error at %s:%d - could not allocate component!\n",
icalcomponent_add_property(encaps, icalproperty_new_version("2.0"));
/* Encapsulate the subcomponent inside */
+ lprintf(9, "Doing the encapsulation\n");
+
+ lprintf(9, "Here's what we've got so far:\n-----%s\n-----\n",
+ icalcomponent_as_ical_string(encaps)
+ );
+ lprintf(9, "Here's what we want to insert:\n-----%s\n-----\n",
+ icalcomponent_as_ical_string(subcomp)
+ );
+
icalcomponent_add_component(encaps, subcomp);
/* Convert all timestamps to UTC so we don't have to deal with
* stupid VTIMEZONE crap.
*/
+ lprintf(9, "Dezonifying it all\n");
ical_dezonify(encaps);
/* Return the object we just created. */
+ lprintf(9, "...done!\n");
return(encaps);
}
icalproperty_free(prop);
}
- lprintf(9, "adding new property\n");
+ lprintf(9, "adding new property...\n");
icalcomponent_add_property(vevent, icalproperty_new_transp(formtransp));
+ lprintf(9, "...added it.\n");
}
/* Give this event a UID if it doesn't have one. */
+ lprintf(9, "Give this event a UID if it doesn't have one.\n");
if (icalcomponent_get_first_property(vevent,
ICAL_UID_PROPERTY) == NULL) {
generate_new_uid(buf);
}
/* Increment the sequence ID */
+ lprintf(9, "Increment the sequence ID\n");
while (prop = icalcomponent_get_first_property(vevent,
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(vevent, prop);
icalproperty_free(prop);
}
++sequence;
+ lprintf(9, "New sequence is %d. Adding...\n", 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
*/
+ lprintf(9, "Setting the organizer...\n");
strcpy(buf, bstr("organizer"));
if ( (icalcomponent_get_first_property(vevent,
ICAL_ORGANIZER_PROPERTY) == NULL)
/*
* Add any new attendees listed in the web form
*/
+ lprintf(9, "Add any new attendees\n");
/* First, strip out the parenthesized partstats. */
strcpy(form_attendees, bstr("attendees"));
/*
* Remove any attendees *not* listed in the web form
*/
-STARTOVER:
+STARTOVER: lprintf(9, "Remove unlisted attendees\n");
for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY); attendee != NULL; attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
strcpy(attendee_string, icalproperty_get_attendee(attendee));
if (!strncasecmp(attendee_string, "MAILTO:", 7)) {
/*
* Serialize it and save it to the message base
*/
+ lprintf(9, "Encapsulating into full VCALENDAR component\n");
encaps = ical_encapsulate_subcomponent(vevent);
+ lprintf(9, "Serializing it for saving\n");
if (encaps != NULL) {
serv_puts("ENT0 1|||4");
serv_gets(buf);
/*
* If the user clicked 'Delete' then delete it.
*/
+ lprintf(9, "Checking to see if we have to delete an old event\n");
if ( (!strcasecmp(bstr("sc"), "Delete")) && (msgnum > 0L) ) {
serv_printf("DELE %ld", atol(bstr("msgnum")));
serv_gets(buf);