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];
34 get_pref_long("weekstart", &weekstart, 17);
35 if (weekstart > 6) weekstart = 0;
37 lprintf(9, "display_edit_individual_event(%ld) calview=%s year=%s month=%s day=%s\n",
38 msgnum, bstr("calview"), bstr("year"), bstr("month"), bstr("day")
41 /* populate the weekday names - begin */
43 localtime_r(&now, &tm_now);
44 while (tm_now.tm_wday != 0) {
46 localtime_r(&now, &tm_now);
49 localtime_r(&now, &tm_now);
50 wc_strftime(weekday_labels[i], 32, "%A", &tm_now);
53 /* populate the weekday names - end */
56 strcpy(organizer_string, "");
57 strcpy(attendee_string, "");
59 if (supplied_vevent != NULL) {
60 vevent = supplied_vevent;
62 * If we're looking at a fully encapsulated VCALENDAR
63 * rather than a VEVENT component, attempt to use the first
64 * relevant VEVENT subcomponent. If there is none, the
65 * NULL returned by icalcomponent_get_first_component() will
66 * tell the next iteration of this function to create a
69 if (icalcomponent_isa(vevent) == ICAL_VCALENDAR_COMPONENT) {
70 display_edit_individual_event(
71 icalcomponent_get_first_component(
72 vevent, ICAL_VEVENT_COMPONENT),
79 vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT);
80 created_new_vevent = 1;
83 /* Learn the sequence */
84 p = icalcomponent_get_first_property(vevent, ICAL_SEQUENCE_PROPERTY);
86 sequence = icalproperty_get_sequence(p);
90 output_headers(1, 1, 2, 0, 0, 0);
91 wprintf("<div id=\"banner\">\n");
93 wprintf(_("Add or edit an event"));
97 wprintf("<div id=\"content\" class=\"service\">\n");
99 wprintf("<div class=\"fix_scrollbar_bug\">");
101 /************************************************************
102 * Uncomment this to see the UID in calendar events for debugging
104 p = icalcomponent_get_first_property(vevent, ICAL_UID_PROPERTY);
106 escputs((char *)icalproperty_get_comment(p));
109 wprintf("SEQUENCE == %d<br />\n", sequence);
110 *************************************************************/
112 wprintf("<FORM NAME=\"EventForm\" METHOD=\"POST\" action=\"save_event\">\n");
113 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
115 wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgnum\" VALUE=\"%ld\">\n",
117 wprintf("<INPUT TYPE=\"hidden\" NAME=\"calview\" VALUE=\"%s\">\n",
119 wprintf("<INPUT TYPE=\"hidden\" NAME=\"year\" VALUE=\"%s\">\n",
121 wprintf("<INPUT TYPE=\"hidden\" NAME=\"month\" VALUE=\"%s\">\n",
123 wprintf("<INPUT TYPE=\"hidden\" NAME=\"day\" VALUE=\"%s\">\n",
132 tabbed_dialog(3, tabnames);
135 /* Put it in a borderless table so it lines up nicely */
136 wprintf("<TABLE border=0 width=100%%>\n");
138 wprintf("<TR><TD><B>");
139 wprintf(_("Summary"));
140 wprintf("</B></TD><TD>\n"
141 "<INPUT TYPE=\"text\" NAME=\"summary\" "
142 "MAXLENGTH=\"64\" SIZE=\"64\" VALUE=\"");
143 p = icalcomponent_get_first_property(vevent, ICAL_SUMMARY_PROPERTY);
145 escputs((char *)icalproperty_get_comment(p));
147 wprintf("\"></TD></TR>\n");
149 wprintf("<TR><TD><B>");
150 wprintf(_("Location"));
151 wprintf("</B></TD><TD>\n"
152 "<INPUT TYPE=\"text\" NAME=\"location\" "
153 "MAXLENGTH=\"64\" SIZE=\"64\" VALUE=\"");
154 p = icalcomponent_get_first_property(vevent, ICAL_LOCATION_PROPERTY);
156 escputs((char *)icalproperty_get_comment(p));
158 wprintf("\"></TD></TR>\n");
160 wprintf("<TR><TD><B>");
162 wprintf("</B></TD><TD>\n");
163 p = icalcomponent_get_first_property(vevent, ICAL_DTSTART_PROPERTY);
165 t_start = icalproperty_get_dtstart(p);
166 if (t_start.is_date) {
173 localtime_r(&now, &tm_now);
174 if (havebstr("year")) {
175 tm_now.tm_year = ibstr("year") - 1900;
176 tm_now.tm_mon = ibstr("month") - 1;
177 tm_now.tm_mday = ibstr("day");
179 if (havebstr("hour")) {
180 tm_now.tm_hour = ibstr("hour");
181 tm_now.tm_min = ibstr("minute");
190 t_start = icaltime_from_timet_with_zone(
192 ((yesbstr("alldayevent")) ? 1 : 0),
193 icaltimezone_get_utc_timezone()
198 display_icaltimetype_as_webform(&t_start, "dtstart", 0);
200 wprintf("<INPUT TYPE=\"checkbox\" id=\"alldayevent\" NAME=\"alldayevent\" "
201 "VALUE=\"yes\" onclick=\"eventEditAllDay();\""
203 (t_start.is_date ? "CHECKED=\"CHECKED\"" : "" ),
207 wprintf("</TD></TR>\n");
210 * If this is an all-day-event, set the end time to be identical to
211 * the start time (the hour/minute/second will be set to midnight).
212 * Otherwise extract or create it.
214 wprintf("<TR><TD><B>");
216 wprintf("</B></TD><TD id=\"dtendcell\">\n");
217 if (t_start.is_date) {
221 p = icalcomponent_get_first_property(vevent,
222 ICAL_DTEND_PROPERTY);
224 t_end = icalproperty_get_dtend(p);
228 * If this is not an all-day event and there is no
229 * end time specified, make the default one hour
230 * from the start time.
235 t_end = icaltime_normalize(t_end);
236 /* t_end = icaltime_from_timet(now, 0); */
239 display_icaltimetype_as_webform(&t_end, "dtend", 0);
240 wprintf("</TD></TR>\n");
242 wprintf("<TR><TD><B>");
244 wprintf("</B></TD><TD>\n"
245 "<TEXTAREA NAME=\"description\" wrap=soft "
246 "ROWS=5 COLS=80 WIDTH=80>\n"
248 p = icalcomponent_get_first_property(vevent, ICAL_DESCRIPTION_PROPERTY);
250 escputs((char *)icalproperty_get_comment(p));
252 wprintf("</TEXTAREA></TD></TR>");
255 * For a new event, the user creating the event should be the
256 * organizer. Set this field accordingly.
258 if (icalcomponent_get_first_property(vevent, ICAL_ORGANIZER_PROPERTY)
260 sprintf(organizer_string, "MAILTO:%s", WC->cs_inet_email);
261 icalcomponent_add_property(vevent,
262 icalproperty_new_organizer(organizer_string)
267 * Determine who is the organizer of this event.
268 * We need to determine "me" or "not me."
270 organizer = icalcomponent_get_first_property(vevent, ICAL_ORGANIZER_PROPERTY);
271 if (organizer != NULL) {
272 strcpy(organizer_string, icalproperty_get_organizer(organizer));
273 if (!strncasecmp(organizer_string, "MAILTO:", 7)) {
274 strcpy(organizer_string, &organizer_string[7]);
275 striplt(organizer_string);
276 serv_printf("ISME %s", organizer_string);
277 serv_getln(buf, sizeof buf);
284 wprintf("<TR><TD><B>");
285 wprintf(_("Organizer"));
286 wprintf("</B></TD><TD>");
287 escputs(organizer_string);
288 if (organizer_is_me) {
289 wprintf(" <FONT SIZE=-1><I>");
290 wprintf(_("(you are the organizer)"));
291 wprintf("</I></FONT>\n");
295 * Transmit the organizer as a hidden field. We don't want the user
296 * to be able to change it, but we do want it fed back to the server,
297 * especially if this is a new event and there is no organizer already
298 * in the calendar object.
300 wprintf("<INPUT TYPE=\"hidden\" NAME=\"organizer\" VALUE=\"");
301 escputs(organizer_string);
304 wprintf("</TD></TR>\n");
307 wprintf("<TR><TD><B>");
308 wprintf(_("Show time as:"));
309 wprintf("</B></TD><TD>");
311 p = icalcomponent_get_first_property(vevent, ICAL_TRANSP_PROPERTY);
313 /** No transparency found. Default to opaque (busy). */
314 p = icalproperty_new_transp(ICAL_TRANSP_OPAQUE);
316 icalcomponent_add_property(vevent, p);
320 v = icalproperty_get_value(p);
326 wprintf("<INPUT TYPE=\"radio\" NAME=\"transp\" VALUE=\"transparent\"");
327 if (v != NULL) if (icalvalue_get_transp(v) == ICAL_TRANSP_TRANSPARENT)
331 wprintf(" ");
333 wprintf("<INPUT TYPE=\"radio\" NAME=\"transp\" VALUE=\"opaque\"");
334 if (v != NULL) if (icalvalue_get_transp(v) == ICAL_TRANSP_OPAQUE)
339 wprintf("</TD></TR>\n");
342 /** Done with properties. */
343 wprintf("</TABLE>\n");
347 /* Attendees tab (need to move things here) */
349 wprintf("<TABLE border=0 width=100%%>\n"); /* same table style as the event tab */
350 wprintf("<TR><TD><B>");
351 wprintf(_("Attendees"));
354 wprintf(_("(One per line)"));
355 wprintf("</font>\n");
357 /** Pop open an address book -- begin **/
359 " <a href=\"javascript:PopOpenAddressBook('attendees_box|%s');\" "
361 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
366 /* Pop open an address book -- end **/
369 "<TEXTAREA %s NAME=\"attendees\" id=\"attendees_box\" wrap=soft "
370 "ROWS=3 COLS=80 WIDTH=80>\n",
371 (organizer_is_me ? "" : "DISABLED ")
374 for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY);
376 attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
377 strcpy(attendee_string, icalproperty_get_attendee(attendee));
378 if (!strncasecmp(attendee_string, "MAILTO:", 7)) {
380 /** screen name or email address */
381 strcpy(attendee_string, &attendee_string[7]);
382 striplt(attendee_string);
383 if (i++) wprintf("\n");
384 escputs(attendee_string);
387 /** participant status */
388 partstat_as_string(buf, attendee);
392 wprintf("</TEXTAREA></TD></TR>\n");
393 wprintf("</TABLE>\n");
398 icalproperty *rrule = NULL;
399 struct icalrecurrencetype recur;
401 rrule = icalcomponent_get_first_property(vevent, ICAL_RRULE_PROPERTY);
403 recur = icalproperty_get_rrule(rrule);
406 /* blank recurrence with some sensible defaults */
407 memset(&recur, 0, sizeof(struct icalrecurrencetype));
409 recur.until = icaltime_null_time();
411 recur.freq = ICAL_WEEKLY_RECURRENCE;
414 wprintf("<INPUT TYPE=\"checkbox\" id=\"is_recur\" NAME=\"is_recur\" "
416 "onclick=\"RecurrenceShowHide();\""
418 (rrule ? "CHECKED=\"CHECKED\"" : "" ),
419 _("This is a recurring event")
422 wprintf("<div id=\"rrule_div\">\n"); /* begin 'rrule_div' div */
424 wprintf("<table border=0 width=100%%>\n"); /* same table style as the event tab */
426 /* Table row displaying raw RRULE data, FIXME remove when finished */
428 wprintf("<tr><td><b>");
430 wprintf("</b></td><td>");
431 wprintf("<tt>%s</tt>", icalrecurrencetype_as_string(&recur));
432 wprintf("</td></tr>\n");
435 char *frequency_units[] = {
446 wprintf("<tr><td><b>");
447 wprintf(_("Recurrence rule"));
448 wprintf("</b></td><td>");
450 if ((recur.freq < 0) || (recur.freq > 6)) recur.freq = 4;
451 wprintf("%s ", _("Repeats every"));
453 wprintf("<input type=\"text\" name=\"interval\" maxlength=\"3\" size=\"3\" ");
454 wprintf("value=\"%d\"> ", recur.interval);
456 wprintf("<select name=\"freq\" id=\"freq_selector\" size=\"1\" "
457 "onChange=\"RecurrenceShowHide();\">\n");
458 for (i=0; i<(sizeof frequency_units / sizeof(char *)); ++i) {
459 wprintf("<option %s%svalue=\"%d\">%s</option>\n",
460 ((i == recur.freq) ? "selected " : ""),
461 (((i == recur.freq) || ((i>=3)&&(i<=5))) ? "" : "disabled "),
466 wprintf("</select>\n");
468 wprintf("<div id=\"weekday_selector\">"); /* begin 'weekday_selector' div */
469 wprintf("%s<br>", _("on these weekdays:"));
471 char weekday_is_selected[7];
472 memset(weekday_is_selected, 0, 7);
474 for (i=0; i<ICAL_BY_DAY_SIZE; ++i) {
475 if (recur.by_day[i] == ICAL_RECURRENCE_ARRAY_MAX) {
476 i = ICAL_RECURRENCE_ARRAY_MAX; /* all done */
479 for (j=0; j<7; ++j) {
480 if (icalrecurrencetype_day_day_of_week(recur.by_day[i]) == j+1) {
481 weekday_is_selected[j] = 1;
487 for (j=0; j<7; ++j) {
488 i = ((j + (int)weekstart) % 7);
489 wprintf("<input type=\"checkbox\" name=\"weekday%d\" value=\"yes\"", i);
490 if (weekday_is_selected[i]) wprintf(" checked");
491 wprintf(">%s</input>\n", weekday_labels[i]);
493 wprintf("</div>\n"); /* end 'weekday_selector' div */
495 wprintf("</td></tr>\n");
498 int which_rrend_is_preselected = 0;
499 if (!icaltime_is_null_time(recur.until)) which_rrend_is_preselected = 2;
500 if (recur.count > 0) which_rrend_is_preselected = 1;
502 wprintf("<tr><td><b>");
503 wprintf(_("Recurrence range"));
504 wprintf("</b></td><td>\n");
506 wprintf("<input type=\"radio\" name=\"rrend\" id=\"rrend_none\" "
507 "%s onChange=\"RecurrenceShowHide();\">",
508 ((which_rrend_is_preselected == 0) ? "checked" : "")
510 wprintf("%s</input><br />\n", _("No ending date"));
512 wprintf("<input type=\"radio\" name=\"rrend\" id=\"rrend_count\" "
513 "%s onChange=\"RecurrenceShowHide();\">",
514 ((which_rrend_is_preselected == 1) ? "checked" : "")
516 wprintf(_("Repeat this event"));
517 wprintf("</input> ");
518 wprintf("<input type=\"text\" name=\"rrcount\" id=\"rrcount\" maxlength=\"3\" size=\"3\" ");
519 wprintf("value=\"%d\"> ", recur.count);
523 wprintf("<input type=\"radio\" name=\"rrend\" id=\"rrend_until\" "
524 "%s onChange=\"RecurrenceShowHide();\">",
525 ((which_rrend_is_preselected == 2) ? "checked" : "")
527 wprintf(_("Repeat this event until "));
530 if (icaltime_is_null_time(recur.until)) {
531 recur.until = icaltime_add(t_start, icaldurationtype_from_int(604800));
533 display_icaltimetype_as_webform(&recur.until, "rruntil", 1);
536 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")) {