4 * Editing calendar events.
11 * Display an event by itself (for editing)
12 * supplied_vevent the event to edit
13 * msgnum reference on the citserver
15 void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, char *from, int unread) {
16 icalcomponent *vevent;
19 struct icaltimetype t_start, t_end;
22 int created_new_vevent = 0;
23 icalproperty *organizer = NULL;
24 char organizer_string[SIZ];
25 icalproperty *attendee = NULL;
26 char attendee_string[SIZ];
28 int organizer_is_me = 0;
31 char weekday_labels[7][32];
33 lprintf(9, "display_edit_individual_event(%ld) calview=%s year=%s month=%s day=%s\n",
34 msgnum, bstr("calview"), bstr("year"), bstr("month"), bstr("day")
37 /* populate the weekday names - begin */
39 localtime_r(&now, &tm_now);
40 while (tm_now.tm_wday != 0) {
42 localtime_r(&now, &tm_now);
45 localtime_r(&now, &tm_now);
46 wc_strftime(weekday_labels[i], 32, "%A", &tm_now);
49 /* populate the weekday names - end */
52 strcpy(organizer_string, "");
53 strcpy(attendee_string, "");
55 if (supplied_vevent != NULL) {
56 vevent = supplied_vevent;
58 * If we're looking at a fully encapsulated VCALENDAR
59 * rather than a VEVENT component, attempt to use the first
60 * relevant VEVENT subcomponent. If there is none, the
61 * NULL returned by icalcomponent_get_first_component() will
62 * tell the next iteration of this function to create a
65 if (icalcomponent_isa(vevent) == ICAL_VCALENDAR_COMPONENT) {
66 display_edit_individual_event(
67 icalcomponent_get_first_component(
68 vevent, ICAL_VEVENT_COMPONENT),
75 vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT);
76 created_new_vevent = 1;
79 /* Learn the sequence */
80 p = icalcomponent_get_first_property(vevent, ICAL_SEQUENCE_PROPERTY);
82 sequence = icalproperty_get_sequence(p);
86 output_headers(1, 1, 2, 0, 0, 0);
87 wprintf("<div id=\"banner\">\n");
89 wprintf(_("Add or edit an event"));
93 wprintf("<div id=\"content\" class=\"service\">\n");
95 wprintf("<div class=\"fix_scrollbar_bug\">");
97 /************************************************************
98 * Uncomment this to see the UID in calendar events for debugging
100 p = icalcomponent_get_first_property(vevent, ICAL_UID_PROPERTY);
102 escputs((char *)icalproperty_get_comment(p));
105 wprintf("SEQUENCE == %d<br />\n", sequence);
106 *************************************************************/
108 wprintf("<FORM NAME=\"EventForm\" METHOD=\"POST\" action=\"save_event\">\n");
109 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
111 wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgnum\" VALUE=\"%ld\">\n",
113 wprintf("<INPUT TYPE=\"hidden\" NAME=\"calview\" VALUE=\"%s\">\n",
115 wprintf("<INPUT TYPE=\"hidden\" NAME=\"year\" VALUE=\"%s\">\n",
117 wprintf("<INPUT TYPE=\"hidden\" NAME=\"month\" VALUE=\"%s\">\n",
119 wprintf("<INPUT TYPE=\"hidden\" NAME=\"day\" VALUE=\"%s\">\n",
128 tabbed_dialog(3, tabnames);
131 /* Put it in a borderless table so it lines up nicely */
132 wprintf("<TABLE border=0 width=100%%>\n");
134 wprintf("<TR><TD><B>");
135 wprintf(_("Summary"));
136 wprintf("</B></TD><TD>\n"
137 "<INPUT TYPE=\"text\" NAME=\"summary\" "
138 "MAXLENGTH=\"64\" SIZE=\"64\" VALUE=\"");
139 p = icalcomponent_get_first_property(vevent, ICAL_SUMMARY_PROPERTY);
141 escputs((char *)icalproperty_get_comment(p));
143 wprintf("\"></TD></TR>\n");
145 wprintf("<TR><TD><B>");
146 wprintf(_("Location"));
147 wprintf("</B></TD><TD>\n"
148 "<INPUT TYPE=\"text\" NAME=\"location\" "
149 "MAXLENGTH=\"64\" SIZE=\"64\" VALUE=\"");
150 p = icalcomponent_get_first_property(vevent, ICAL_LOCATION_PROPERTY);
152 escputs((char *)icalproperty_get_comment(p));
154 wprintf("\"></TD></TR>\n");
156 wprintf("<TR><TD><B>");
158 wprintf("</B></TD><TD>\n");
159 p = icalcomponent_get_first_property(vevent, ICAL_DTSTART_PROPERTY);
161 t_start = icalproperty_get_dtstart(p);
162 if (t_start.is_date) {
169 localtime_r(&now, &tm_now);
170 if (havebstr("year")) {
171 tm_now.tm_year = ibstr("year") - 1900;
172 tm_now.tm_mon = ibstr("month") - 1;
173 tm_now.tm_mday = ibstr("day");
175 if (havebstr("hour")) {
176 tm_now.tm_hour = ibstr("hour");
177 tm_now.tm_min = ibstr("minute");
186 t_start = icaltime_from_timet_with_zone(
188 ((yesbstr("alldayevent")) ? 1 : 0),
189 icaltimezone_get_utc_timezone()
194 display_icaltimetype_as_webform(&t_start, "dtstart", 0);
196 wprintf("<INPUT TYPE=\"checkbox\" id=\"alldayevent\" NAME=\"alldayevent\" "
197 "VALUE=\"yes\" onclick=\"eventEditAllDay();\""
199 (t_start.is_date ? "CHECKED=\"CHECKED\"" : "" ),
203 wprintf("</TD></TR>\n");
206 * If this is an all-day-event, set the end time to be identical to
207 * the start time (the hour/minute/second will be set to midnight).
208 * Otherwise extract or create it.
210 wprintf("<TR><TD><B>");
212 wprintf("</B></TD><TD id=\"dtendcell\">\n");
213 if (t_start.is_date) {
217 p = icalcomponent_get_first_property(vevent,
218 ICAL_DTEND_PROPERTY);
220 t_end = icalproperty_get_dtend(p);
224 * If this is not an all-day event and there is no
225 * end time specified, make the default one hour
226 * from the start time.
231 t_end = icaltime_normalize(t_end);
232 /* t_end = icaltime_from_timet(now, 0); */
235 display_icaltimetype_as_webform(&t_end, "dtend", 0);
236 wprintf("</TD></TR>\n");
238 wprintf("<TR><TD><B>");
240 wprintf("</B></TD><TD>\n"
241 "<TEXTAREA NAME=\"description\" wrap=soft "
242 "ROWS=5 COLS=80 WIDTH=80>\n"
244 p = icalcomponent_get_first_property(vevent, ICAL_DESCRIPTION_PROPERTY);
246 escputs((char *)icalproperty_get_comment(p));
248 wprintf("</TEXTAREA></TD></TR>");
251 * For a new event, the user creating the event should be the
252 * organizer. Set this field accordingly.
254 if (icalcomponent_get_first_property(vevent, ICAL_ORGANIZER_PROPERTY)
256 sprintf(organizer_string, "MAILTO:%s", WC->cs_inet_email);
257 icalcomponent_add_property(vevent,
258 icalproperty_new_organizer(organizer_string)
263 * Determine who is the organizer of this event.
264 * We need to determine "me" or "not me."
266 organizer = icalcomponent_get_first_property(vevent, ICAL_ORGANIZER_PROPERTY);
267 if (organizer != NULL) {
268 strcpy(organizer_string, icalproperty_get_organizer(organizer));
269 if (!strncasecmp(organizer_string, "MAILTO:", 7)) {
270 strcpy(organizer_string, &organizer_string[7]);
271 striplt(organizer_string);
272 serv_printf("ISME %s", organizer_string);
273 serv_getln(buf, sizeof buf);
280 wprintf("<TR><TD><B>");
281 wprintf(_("Organizer"));
282 wprintf("</B></TD><TD>");
283 escputs(organizer_string);
284 if (organizer_is_me) {
285 wprintf(" <FONT SIZE=-1><I>");
286 wprintf(_("(you are the organizer)"));
287 wprintf("</I></FONT>\n");
291 * Transmit the organizer as a hidden field. We don't want the user
292 * to be able to change it, but we do want it fed back to the server,
293 * especially if this is a new event and there is no organizer already
294 * in the calendar object.
296 wprintf("<INPUT TYPE=\"hidden\" NAME=\"organizer\" VALUE=\"");
297 escputs(organizer_string);
300 wprintf("</TD></TR>\n");
303 wprintf("<TR><TD><B>");
304 wprintf(_("Show time as:"));
305 wprintf("</B></TD><TD>");
307 p = icalcomponent_get_first_property(vevent, ICAL_TRANSP_PROPERTY);
309 /** No transparency found. Default to opaque (busy). */
310 p = icalproperty_new_transp(ICAL_TRANSP_OPAQUE);
312 icalcomponent_add_property(vevent, p);
316 v = icalproperty_get_value(p);
322 wprintf("<INPUT TYPE=\"radio\" NAME=\"transp\" VALUE=\"transparent\"");
323 if (v != NULL) if (icalvalue_get_transp(v) == ICAL_TRANSP_TRANSPARENT)
327 wprintf(" ");
329 wprintf("<INPUT TYPE=\"radio\" NAME=\"transp\" VALUE=\"opaque\"");
330 if (v != NULL) if (icalvalue_get_transp(v) == ICAL_TRANSP_OPAQUE)
335 wprintf("</TD></TR>\n");
338 /** Done with properties. */
339 wprintf("</TABLE>\n");
343 /* Attendees tab (need to move things here) */
345 wprintf("<TABLE border=0 width=100%%>\n"); /* same table style as the event tab */
346 wprintf("<TR><TD><B>");
347 wprintf(_("Attendees"));
350 wprintf(_("(One per line)"));
351 wprintf("</font>\n");
353 /** Pop open an address book -- begin **/
355 " <a href=\"javascript:PopOpenAddressBook('attendees_box|%s');\" "
357 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
362 /* Pop open an address book -- end **/
365 "<TEXTAREA %s NAME=\"attendees\" id=\"attendees_box\" wrap=soft "
366 "ROWS=3 COLS=80 WIDTH=80>\n",
367 (organizer_is_me ? "" : "DISABLED ")
370 for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY);
372 attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
373 strcpy(attendee_string, icalproperty_get_attendee(attendee));
374 if (!strncasecmp(attendee_string, "MAILTO:", 7)) {
376 /** screen name or email address */
377 strcpy(attendee_string, &attendee_string[7]);
378 striplt(attendee_string);
379 if (i++) wprintf("\n");
380 escputs(attendee_string);
383 /** participant status */
384 partstat_as_string(buf, attendee);
388 wprintf("</TEXTAREA></TD></TR>\n");
389 wprintf("</TABLE>\n");
394 icalproperty *rrule = NULL;
395 struct icalrecurrencetype recur;
397 rrule = icalcomponent_get_first_property(vevent, ICAL_RRULE_PROPERTY);
399 recur = icalproperty_get_rrule(rrule);
402 /* blank recurrence with some sensible defaults */
403 memset(&recur, 0, sizeof(struct icalrecurrencetype));
405 recur.until = icaltime_null_time();
407 recur.freq = ICAL_WEEKLY_RECURRENCE;
410 wprintf("<INPUT TYPE=\"checkbox\" id=\"is_recur\" NAME=\"is_recur\" "
412 "onclick=\"RecurrenceShowHide();\""
414 (rrule ? "CHECKED=\"CHECKED\"" : "" ),
415 _("This is a repeating event")
418 wprintf("<div id=\"rrule\">\n"); /* begin 'rrule' div */
420 wprintf("<table border=0 width=100%%>\n"); /* same table style as the event tab */
422 /* Table row displaying raw RRULE data, FIXME remove when finished */
424 wprintf("<tr><td><b>");
426 wprintf("</b></td><td>");
427 wprintf("<tt>%s</tt>", icalrecurrencetype_as_string(&recur));
428 wprintf("</td></tr>\n");
431 char *frequency_units[] = {
445 wprintf("<tr><td><b>");
446 wprintf(_("Recurrence rule"));
447 wprintf("</b></td><td>");
448 if ((recur.freq < 0) || (recur.freq > 6)) recur.freq = 4;
449 wprintf("%s ", _("Repeats every"));
451 wprintf("<input type=\"text\" name=\"interval\" maxlength=\"3\" size=\"3\" ");
452 wprintf("value=\"%d\"> ", recur.interval);
454 wprintf("<select name=\"freq\" id=\"freq_selector\" size=\"1\" "
455 "onChange=\"RecurrenceShowHide();\">\n");
456 for (i=0; i<(sizeof frequency_units / sizeof(char *)); ++i) {
457 wprintf("<option %s%svalue=\"%d\">%s</option>\n",
458 ((i == recur.freq) ? "selected " : ""),
459 (((i == recur.freq) || ((i>=3)&&(i<=5))) ? "" : "disabled "),
464 wprintf("</select>\n");
466 wprintf("<div id=\"weekday_selector\">"); /* begin 'weekday_selector' div */
467 wprintf("%s<br>", _("on these weekdays:"));
469 char weekday_is_selected[7];
470 memset(weekday_is_selected, 0, 7);
472 for (i=0; i<ICAL_BY_DAY_SIZE; ++i) {
473 if (recur.by_day[i] == ICAL_RECURRENCE_ARRAY_MAX) {
474 i = ICAL_RECURRENCE_ARRAY_MAX; /* all done */
477 for (j=0; j<7; ++j) {
478 if (icalrecurrencetype_day_day_of_week(recur.by_day[i]) == j+1) {
479 weekday_is_selected[j] = 1;
485 for (i=0; i<7; ++i) {
486 wprintf("<input type=\"checkbox\" name=\"weekday%d\" value=\"yes\"", i);
487 if (weekday_is_selected[i]) wprintf(" checked");
488 wprintf(">%s</input>\n", weekday_labels[i]);
490 wprintf("</div>\n"); /* end 'weekday_selector' div */
492 wprintf("</td></tr>\n");
495 int which_rrend_is_preselected = 0;
496 if (!icaltime_is_null_time(recur.until)) which_rrend_is_preselected = 2;
497 if (recur.count > 0) which_rrend_is_preselected = 1;
499 wprintf("<tr><td><b>");
500 wprintf(_("Recurrence range"));
501 wprintf("</b></td><td>\n");
503 wprintf("<input type=\"radio\" name=\"rrend\" id=\"rrend_none\" "
504 "%s onChange=\"RecurrenceShowHide();\">",
505 ((which_rrend_is_preselected == 0) ? "checked" : "")
507 wprintf("%s</input><br />\n", _("No ending date"));
509 wprintf("<input type=\"radio\" name=\"rrend\" id=\"rrend_count\" "
510 "%s onChange=\"RecurrenceShowHide();\">",
511 ((which_rrend_is_preselected == 1) ? "checked" : "")
513 wprintf(_("Repeat this event"));
514 wprintf("</input> ");
515 wprintf("<input type=\"text\" name=\"rrcount\" id=\"rrcount\" maxlength=\"3\" size=\"3\" ");
516 wprintf("value=\"%d\"> ", recur.count);
520 wprintf("<input type=\"radio\" name=\"rrend\" id=\"rrend_until\" "
521 "%s onChange=\"RecurrenceShowHide();\">",
522 ((which_rrend_is_preselected == 2) ? "checked" : "")
524 wprintf(_("Repeat this event until "));
527 if (icaltime_is_null_time(recur.until)) {
528 recur.until = icaltime_add(t_start, icaldurationtype_from_int(604800));
530 display_icaltimetype_as_webform(&recur.until, "rruntil", 1);
533 wprintf("</td></tr>\n");
538 wprintf("</table>\n");
539 wprintf("</div>\n"); /* end 'rrule' div */
543 /* submit buttons (common area beneath the tabs) */
546 "<INPUT TYPE=\"submit\" NAME=\"save_button\" VALUE=\"%s\">"
548 "<INPUT TYPE=\"submit\" NAME=\"delete_button\" VALUE=\"%s\">\n"
550 "<INPUT TYPE=\"submit\" NAME=\"check_button\" "
553 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">\n"
557 _("Check attendee availability"),
560 wprintf("</FORM>\n");
565 wprintf("<script type=\"text/javascript\"> \n"
566 "eventEditAllDay(); \n"
567 "RecurrenceShowHide(); \n"
570 address_book_popup();
573 if (created_new_vevent) {
574 icalcomponent_free(vevent);
579 * Save an edited event
581 * supplied_vevent: the event to save
582 * msgnum: the index on the citserver
584 void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *from, int unread) {
587 icalcomponent *vevent, *encaps;
588 int created_new_vevent = 0;
589 int all_day_event = 0;
590 struct icaltimetype event_start, t;
591 icalproperty *attendee = NULL;
592 char attendee_string[SIZ];
595 char form_attendees[SIZ];
596 char organizer_string[SIZ];
598 enum icalproperty_transp formtransp = ICAL_TRANSP_NONE;
600 if (supplied_vevent != NULL) {
601 vevent = supplied_vevent;
603 * If we're looking at a fully encapsulated VCALENDAR
604 * rather than a VEVENT component, attempt to use the first
605 * relevant VEVENT subcomponent. If there is none, the
606 * NULL returned by icalcomponent_get_first_component() will
607 * tell the next iteration of this function to create a
610 if (icalcomponent_isa(vevent) == ICAL_VCALENDAR_COMPONENT) {
611 save_individual_event(
612 icalcomponent_get_first_component(
613 vevent, ICAL_VEVENT_COMPONENT),
620 vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT);
621 created_new_vevent = 1;
624 if ( (havebstr("save_button"))
625 || (havebstr("check_button")) ) {
627 /** Replace values in the component with ones from the form */
629 while (prop = icalcomponent_get_first_property(vevent,
630 ICAL_SUMMARY_PROPERTY), prop != NULL) {
631 icalcomponent_remove_property(vevent, prop);
632 icalproperty_free(prop);
635 if (havebstr("summary")) {
637 icalcomponent_add_property(vevent,
638 icalproperty_new_summary(bstr("summary")));
640 icalcomponent_add_property(vevent,
641 icalproperty_new_summary("Untitled Event"));
644 while (prop = icalcomponent_get_first_property(vevent,
645 ICAL_LOCATION_PROPERTY), prop != NULL) {
646 icalcomponent_remove_property(vevent, prop);
647 icalproperty_free(prop);
649 if (havebstr("location")) {
650 icalcomponent_add_property(vevent,
651 icalproperty_new_location(bstr("location")));
653 while (prop = icalcomponent_get_first_property(vevent,
654 ICAL_DESCRIPTION_PROPERTY), prop != NULL) {
655 icalcomponent_remove_property(vevent, prop);
656 icalproperty_free(prop);
658 if (havebstr("description")) {
659 icalcomponent_add_property(vevent,
660 icalproperty_new_description(bstr("description")));
663 while (prop = icalcomponent_get_first_property(vevent,
664 ICAL_DTSTART_PROPERTY), prop != NULL) {
665 icalcomponent_remove_property(vevent, prop);
666 icalproperty_free(prop);
669 if (yesbstr("alldayevent")) {
677 icaltime_from_webform_dateonly(&event_start, "dtstart");
680 icaltime_from_webform(&event_start, "dtstart");
684 * The following odd-looking snippet of code looks like it
685 * takes some unnecessary steps. It is done this way because
686 * libical incorrectly turns an "all day event" into a normal
687 * event starting at midnight (i.e. it serializes as date/time
688 * instead of just date) unless icalvalue_new_date() is used.
689 * So we force it, if this is an all day event.
691 prop = icalproperty_new_dtstart(event_start);
693 icalproperty_set_value(prop, icalvalue_new_date(event_start));
696 if (prop) icalcomponent_add_property(vevent, prop);
697 else icalproperty_free(prop);
699 while (prop = icalcomponent_get_first_property(vevent,
700 ICAL_DTEND_PROPERTY), prop != NULL) {
701 icalcomponent_remove_property(vevent, prop);
702 icalproperty_free(prop);
704 while (prop = icalcomponent_get_first_property(vevent,
705 ICAL_DURATION_PROPERTY), prop != NULL) {
706 icalcomponent_remove_property(vevent, prop);
707 icalproperty_free(prop);
710 if (all_day_event == 0) {
711 icaltime_from_webform(&t, "dtend");
712 icalcomponent_add_property(vevent,
713 icalproperty_new_dtend(icaltime_normalize(t)
718 /** See if transparency is indicated */
719 if (havebstr("transp")) {
720 if (!strcasecmp(bstr("transp"), "opaque")) {
721 formtransp = ICAL_TRANSP_OPAQUE;
723 else if (!strcasecmp(bstr("transp"), "transparent")) {
724 formtransp = ICAL_TRANSP_TRANSPARENT;
727 while (prop = icalcomponent_get_first_property(vevent, ICAL_TRANSP_PROPERTY),
729 icalcomponent_remove_property(vevent, prop);
730 icalproperty_free(prop);
733 icalcomponent_add_property(vevent, icalproperty_new_transp(formtransp));
736 /** Give this event a UID if it doesn't have one. */
737 if (icalcomponent_get_first_property(vevent,
738 ICAL_UID_PROPERTY) == NULL) {
740 icalcomponent_add_property(vevent, icalproperty_new_uid(buf));
743 /** Increment the sequence ID */
744 while (prop = icalcomponent_get_first_property(vevent,
745 ICAL_SEQUENCE_PROPERTY), (prop != NULL) ) {
746 i = icalproperty_get_sequence(prop);
747 if (i > sequence) sequence = i;
748 icalcomponent_remove_property(vevent, prop);
749 icalproperty_free(prop);
752 icalcomponent_add_property(vevent,
753 icalproperty_new_sequence(sequence)
757 * Set the organizer, only if one does not already exist *and*
758 * the form is supplying one
760 strcpy(buf, bstr("organizer"));
761 if ( (icalcomponent_get_first_property(vevent,
762 ICAL_ORGANIZER_PROPERTY) == NULL)
763 && (!IsEmptyStr(buf)) ) {
765 /** set new organizer */
766 sprintf(organizer_string, "MAILTO:%s", buf);
767 icalcomponent_add_property(vevent,
768 icalproperty_new_organizer(organizer_string)
774 * Add any new attendees listed in the web form
777 /* First, strip out the parenthesized partstats. */
778 strcpy(form_attendees, bstr("attendees"));
779 stripout(form_attendees, '(', ')');
781 /* Next, change any commas to newlines, because we want newline-separated attendees. */
782 j = strlen(form_attendees);
783 for (i=0; i<j; ++i) {
784 if (form_attendees[i] == ',') {
785 form_attendees[i] = '\n';
786 while (isspace(form_attendees[i+1])) {
787 strcpy(&form_attendees[i+1], &form_attendees[i+2]);
793 for (i=0; i<num_tokens(form_attendees, '\n'); ++i) {
794 extract_token(buf, form_attendees, i, '\n', sizeof buf);
796 if (!IsEmptyStr(buf)) {
797 sprintf(attendee_string, "MAILTO:%s", buf);
800 for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY); attendee != NULL; attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
801 if (!strcasecmp(attendee_string,
802 icalproperty_get_attendee(attendee)))
808 icalcomponent_add_property(vevent,
809 icalproperty_new_attendee(attendee_string)
816 * Remove any attendees *not* listed in the web form
818 STARTOVER: for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY); attendee != NULL; attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
819 strcpy(attendee_string, icalproperty_get_attendee(attendee));
820 if (!strncasecmp(attendee_string, "MAILTO:", 7)) {
821 strcpy(attendee_string, &attendee_string[7]);
822 striplt(attendee_string);
824 for (i=0; i<num_tokens(form_attendees, '\n'); ++i) {
825 extract_token(buf, form_attendees, i, '\n', sizeof buf);
827 if (!strcasecmp(buf, attendee_string)) ++foundit;
830 icalcomponent_remove_property(vevent, attendee);
831 icalproperty_free(attendee);
838 * Encapsulate event into full VCALENDAR component. Clone it first,
839 * for two reasons: one, it's easier to just free the whole thing
840 * when we're done instead of unbundling, but more importantly, we
841 * can't encapsulate something that may already be encapsulated
844 encaps = ical_encapsulate_subcomponent(icalcomponent_new_clone(vevent));
846 /* Set the method to PUBLISH */
847 icalcomponent_set_method(encaps, ICAL_METHOD_PUBLISH);
849 /** If the user clicked 'Save' then save it to the server. */
850 if ( (encaps != NULL) && (havebstr("save_button")) ) {
851 serv_puts("ENT0 1|||4|||1|");
852 serv_getln(buf, sizeof buf);
854 serv_puts("Content-type: text/calendar");
856 serv_puts(icalcomponent_as_ical_string(encaps));
859 if ( (buf[0] == '8') || (buf[0] == '4') ) {
860 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
864 strcpy(WC->ImportantMessage, &buf[4]);
866 icalmemory_free_ring ();
867 icalcomponent_free(encaps);
871 /** Or, check attendee availability if the user asked for that. */
872 if ( (encaps != NULL) && (havebstr("check_button")) ) {
874 /* Call this function, which does the real work */
875 check_attendee_availability(encaps);
877 /** This displays the form again, with our annotations */
878 display_edit_individual_event(encaps, msgnum, from, unread);
880 icalcomponent_free(encaps);
883 if (encaps != NULL) {
884 icalcomponent_free(encaps);
891 * If the user clicked 'Delete' then delete it.
893 if ( (havebstr("delete_button")) && (msgnum > 0L) ) {
894 serv_printf("DELE %ld", lbstr("msgnum"));
895 serv_getln(buf, sizeof buf);
898 if (created_new_vevent) {
899 icalcomponent_free(vevent);
902 /* If this was a save or delete, go back to the calendar view. */
903 if (!havebstr("check_button")) {