]> code.citadel.org Git - citadel.git/blob - webcit/event.c
* Various changes to the calendar service to handle messages containing
[citadel.git] / webcit / event.c
1 /*
2  * $Id$
3  *
4  * Editing calendar events.
5  *
6  */
7
8 #include <ctype.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include <stdio.h>
12 #include <fcntl.h>
13 #include <signal.h>
14 #include <sys/types.h>
15 #include <sys/wait.h>
16 #include <sys/socket.h>
17 #include <limits.h>
18 #include <netinet/in.h>
19 #include <netdb.h>
20 #include <string.h>
21 #include <pwd.h>
22 #include <errno.h>
23 #include <stdarg.h>
24 #include <pthread.h>
25 #include <signal.h>
26 #include <time.h>
27 #include "webcit.h"
28 #include "webserver.h"
29
30
31 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
32
33 /*
34  * Display an event by itself (for editing)
35  *
36  * ok
37  */
38 void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum) {
39         icalcomponent *vevent;
40         icalproperty *p;
41         icalvalue *v;
42         struct icaltimetype t_start, t_end;
43         time_t now;
44         struct tm tm_now;
45         int created_new_vevent = 0;
46         icalproperty *organizer = NULL;
47         char organizer_string[SIZ];
48         icalproperty *attendee = NULL;
49         char attendee_string[SIZ];
50         char buf[SIZ];
51         int i;
52         int organizer_is_me = 0;
53         int sequence = 0;
54
55         now = time(NULL) % 60;  /* mod 60 to force :00 seconds */
56         strcpy(organizer_string, "");
57         strcpy(attendee_string, "");
58
59         if (supplied_vevent != NULL) {
60                 vevent = supplied_vevent;
61                 /* If we're looking at a fully encapsulated VCALENDAR
62                  * rather than a VTODO component, attempt to use the first
63                  * relevant VTODO subcomponent.  If there is none, the
64                  * NULL returned by icalcomponent_get_first_component() will
65                  * tell the next iteration of this function to create a
66                  * new one.
67                  */
68                 if (icalcomponent_isa(vevent) == ICAL_VCALENDAR_COMPONENT) {
69                         display_edit_individual_event(
70                                 icalcomponent_get_first_component(
71                                         vevent, ICAL_VTODO_COMPONENT
72                                 ), msgnum
73                         );
74                         return;
75                 }
76         }
77         else {
78                 vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT);
79                 created_new_vevent = 1;
80         }
81
82         /* Learn the sequence */
83         p = icalcomponent_get_first_property(vevent, ICAL_SEQUENCE_PROPERTY);
84         if (p != NULL) {
85                 sequence = icalproperty_get_sequence(p);
86         }
87
88         /* Begin output */
89         output_headers(3);
90         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>"
91                 "<IMG ALIGN=CENTER SRC=\"/static/vcalendar.gif\">"
92                 "<FONT SIZE=+1 COLOR=\"FFFFFF\""
93                 "<B>Edit event</B>"
94                 "</FONT></TD></TR></TABLE><BR>\n"
95         );
96
97         /************************************************************
98          * Uncomment this to see the UID in calendar events for debugging
99         wprintf("UID == ");
100         p = icalcomponent_get_first_property(vevent, ICAL_UID_PROPERTY);
101         if (p != NULL) {
102                 escputs((char *)icalproperty_get_comment(p));
103         }
104         wprintf("<BR>\n");
105         wprintf("SEQUENCE == %d<BR>\n", sequence);
106         *************************************************************/
107
108         wprintf("<FORM NAME=\"EventForm\" METHOD=\"POST\" ACTION=\"/save_event\">\n");
109
110         wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgnum\" VALUE=\"%ld\">\n",
111                 msgnum);
112         wprintf("<INPUT TYPE=\"hidden\" NAME=\"calview\" VALUE=\"%s\">\n",
113                 bstr("calview"));
114         wprintf("<INPUT TYPE=\"hidden\" NAME=\"year\" VALUE=\"%s\">\n",
115                 bstr("year"));
116         wprintf("<INPUT TYPE=\"hidden\" NAME=\"month\" VALUE=\"%s\">\n",
117                 bstr("month"));
118         wprintf("<INPUT TYPE=\"hidden\" NAME=\"day\" VALUE=\"%s\">\n",
119                 bstr("day"));
120
121         /* Put it in a borderless table so it lines up nicely */
122         wprintf("<TABLE border=0 width=100%%>\n");
123
124         wprintf("<TR><TD><B>Summary</B></TD><TD>\n"
125                 "<INPUT TYPE=\"text\" NAME=\"summary\" "
126                 "MAXLENGTH=\"64\" SIZE=\"64\" VALUE=\"");
127         p = icalcomponent_get_first_property(vevent, ICAL_SUMMARY_PROPERTY);
128         if (p != NULL) {
129                 escputs((char *)icalproperty_get_comment(p));
130         }
131         wprintf("\"></TD></TR>\n");
132
133         wprintf("<TR><TD><B>Location</B></TD><TD>\n"
134                 "<INPUT TYPE=\"text\" NAME=\"location\" "
135                 "MAXLENGTH=\"64\" SIZE=\"64\" VALUE=\"");
136         p = icalcomponent_get_first_property(vevent, ICAL_LOCATION_PROPERTY);
137         if (p != NULL) {
138                 escputs((char *)icalproperty_get_comment(p));
139         }
140         wprintf("\"></TD></TR>\n");
141
142         wprintf("<TR><TD><B>Start</B></TD><TD>\n");
143         p = icalcomponent_get_first_property(vevent, ICAL_DTSTART_PROPERTY);
144         if (p != NULL) {
145                 t_start = icalproperty_get_dtstart(p);
146                 if (t_start.is_date) {
147                         t_start.hour = 0;
148                         t_start.minute = 0;
149                         t_start.second = 0;
150                 }
151         }
152         else {
153                 memcpy(&tm_now, localtime(&now), sizeof(struct tm));
154                 tm_now.tm_year = atoi(bstr("year")) - 1900;
155                 tm_now.tm_mon = atoi(bstr("month")) - 1;
156                 tm_now.tm_mday = atoi(bstr("day"));
157                 if (strlen(bstr("hour")) > 0) {
158                         tm_now.tm_hour = atoi(bstr("hour"));
159                         tm_now.tm_min = atoi(bstr("minute"));
160                         tm_now.tm_sec = 0;
161                 }
162                 else {
163                         tm_now.tm_hour = 9;
164                         tm_now.tm_min = 0;
165                         tm_now.tm_sec = 0;
166                 }
167
168                 t_start = icaltime_from_timet_with_zone(
169                         mktime(&tm_now),
170                         ((!strcasecmp(bstr("alldayevent"), "yes")) ? 1 : 0),
171                         icaltimezone_get_utc_timezone
172                 );
173                 t_start.is_utc = 1;
174
175         }
176         display_icaltimetype_as_webform(&t_start, "dtstart");
177
178         wprintf("<INPUT TYPE=\"checkbox\" NAME=\"alldayevent\" "
179                 "VALUE=\"yes\" onClick=\"
180
181                         if (this.checked) {
182                                 this.form.dtstart_hour.value='0';
183                                 this.form.dtstart_hour.disabled = true;
184                                 this.form.dtstart_minute.value='0';
185                                 this.form.dtstart_minute.disabled = true;
186                                 this.form.dtend_hour.value='0';
187                                 this.form.dtend_hour.disabled = true;
188                                 this.form.dtend_minute.value='0';
189                                 this.form.dtend_minute.disabled = true;
190                                 this.form.dtend_month.disabled = true;
191                                 this.form.dtend_day.disabled = true;
192                                 this.form.dtend_year.disabled = true;
193                         }
194                         else {
195                                 this.form.dtstart_hour.disabled = false;
196                                 this.form.dtstart_minute.disabled = false;
197                                 this.form.dtend_hour.disabled = false;
198                                 this.form.dtend_minute.disabled = false;
199                                 this.form.dtend_month.disabled = false;
200                                 this.form.dtend_day.disabled = false;
201                                 this.form.dtend_year.disabled = false;
202                         }
203
204
205                 \" %s >All day event",
206                 (t_start.is_date ? "CHECKED" : "" )
207         );
208
209         wprintf("</TD></TR>\n");
210
211         /* If this is an all-day-event, set the end time to be identical to
212          * the start time (the hour/minute/second will be set to midnight).
213          * Otherwise extract or create it.
214          */
215         wprintf("<TR><TD><B>End</B></TD><TD>\n");
216         if (t_start.is_date) {
217                 t_end = t_start;
218         }
219         else {
220                 p = icalcomponent_get_first_property(vevent,
221                                                         ICAL_DTEND_PROPERTY);
222                 if (p != NULL) {
223                         t_end = icalproperty_get_dtend(p);
224                 }
225                 else {
226                         /* If this is not an all-day event and there is no
227                          * end time specified, make the default one hour
228                          * from the start time.
229                          */
230                         t_end = t_start;
231                         t_end.hour += 1;
232                         t_end.second = 0;
233                         t_end = icaltime_normalize(t_end);
234                         /* t_end = icaltime_from_timet(now, 0); */
235                 }
236         }
237         display_icaltimetype_as_webform(&t_end, "dtend");
238         wprintf("</TD></TR>\n");
239
240         wprintf("<TR><TD><B>Notes</B></TD><TD>\n"
241                 "<TEXTAREA NAME=\"description\" wrap=soft "
242                 "ROWS=10 COLS=80 WIDTH=80>\n"
243         );
244         p = icalcomponent_get_first_property(vevent, ICAL_DESCRIPTION_PROPERTY);
245         if (p != NULL) {
246                 escputs((char *)icalproperty_get_comment(p));
247         }
248         wprintf("</TEXTAREA></TD></TR>");
249
250         /* For a new event, the user creating the event should be the
251          * organizer.  Set this field accordingly.
252          */
253         if (icalcomponent_get_first_property(vevent, ICAL_ORGANIZER_PROPERTY)
254            == NULL) {
255                 sprintf(organizer_string, "MAILTO:%s", WC->cs_inet_email);
256                 icalcomponent_add_property(vevent,
257                         icalproperty_new_organizer(organizer_string)
258                 );
259         }
260
261         /* Determine who is the organizer of this event.
262          * We need to determine "me" or "not me."
263          */
264         organizer = icalcomponent_get_first_property(vevent,
265                                                 ICAL_ORGANIZER_PROPERTY);
266         if (organizer != NULL) {
267                 strcpy(organizer_string, icalproperty_get_organizer(organizer));
268                 if (!strncasecmp(organizer_string, "MAILTO:", 7)) {
269                         strcpy(organizer_string, &organizer_string[7]);
270                         striplt(organizer_string);
271                         lprintf(9, "ISME %s\n", organizer_string);
272                         serv_printf("ISME %s", organizer_string);
273                         serv_gets(buf);
274                         lprintf(9, "%s\n", buf);
275                         if (buf[0] == '2') {
276                                 organizer_is_me = 1;
277                         }
278                 }
279         }
280
281         wprintf("<TR><TD><B>Organizer</B></TD><TD>");
282         escputs(organizer_string);
283         if (organizer_is_me) {
284                 wprintf(" <FONT SIZE=-1><I>"
285                         "(you are the organizer)</I></FONT>\n");
286         }
287
288         /*
289          * Transmit the organizer as a hidden field.   We don't want the user
290          * to be able to change it, but we do want it fed back to the server,
291          * especially if this is a new event and there is no organizer already
292          * in the calendar object.
293          */
294         wprintf("<INPUT TYPE=\"hidden\" NAME=\"organizer\" VALUE=\"");
295         escputs(organizer_string);
296         wprintf("\">");
297
298         wprintf("</TD></TR>\n");
299
300         /* Transparency */
301         wprintf("<TR><TD><B>Show time as:</B></TD><TD>");
302
303         p = icalcomponent_get_first_property(vevent, ICAL_TRANSP_PROPERTY);
304         if (p == NULL) {
305                 /* No transparency found.  Default to opaque (busy). */
306                 p = icalproperty_new_transp(ICAL_TRANSP_OPAQUE);
307                 if (p != NULL) {
308                         icalcomponent_add_property(vevent, p);
309                 }
310         }
311         if (p != NULL) {
312                 v = icalproperty_get_value(p);
313         }
314         else {
315                 v = NULL;
316         }
317
318         wprintf("<INPUT TYPE=\"radio\" NAME=\"transp\" VALUE=\"transparent\"");
319         if (v != NULL) if (icalvalue_get_transp(v) == ICAL_TRANSP_TRANSPARENT)
320                 wprintf(" CHECKED");
321         wprintf(">Free&nbsp;&nbsp;");
322
323         wprintf("<INPUT TYPE=\"radio\" NAME=\"transp\" VALUE=\"opaque\"");
324         if (v != NULL) if (icalvalue_get_transp(v) == ICAL_TRANSP_OPAQUE)
325                 wprintf(" CHECKED");
326         wprintf(">Busy");
327
328         wprintf("</TD></TR>\n");
329
330         /* Attendees */
331         wprintf("<TR><TD><B>Attendees</B><BR>"
332                 "<FONT SIZE=-2>(Separate multiple attendees with commas)"
333                 "</FONT></TD><TD>"
334                 "<TEXTAREA %s NAME=\"attendees\" wrap=soft "
335                 "ROWS=3 COLS=80 WIDTH=80>\n",
336                 (organizer_is_me ? "" : "DISABLED ")
337         );
338         i = 0;
339         for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY); attendee != NULL; attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
340                 strcpy(attendee_string, icalproperty_get_attendee(attendee));
341                 if (!strncasecmp(attendee_string, "MAILTO:", 7)) {
342
343                         /* screen name or email address */
344                         strcpy(attendee_string, &attendee_string[7]);
345                         striplt(attendee_string);
346                         if (i++) wprintf(", ");
347                         escputs(attendee_string);
348                         wprintf(" ");
349
350                         /* participant status */
351                         partstat_as_string(buf, attendee);
352                         escputs(buf);
353                 }
354         }
355         wprintf("</TEXTAREA></TD></TR>\n");
356
357         /* Done with properties. */
358         wprintf("</TABLE>\n<CENTER>"
359                 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Save\">"
360                 "&nbsp;&nbsp;"
361                 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">\n"
362                 "&nbsp;&nbsp;"
363                 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">\n"
364                 "</CENTER>\n"
365         );
366
367         wprintf("</FORM>\n");
368         
369         wprintf("<SCRIPT language=\"javascript\">
370                 <!--
371
372                         if (document.EventForm.alldayevent.checked) {
373                                 document.EventForm.dtstart_hour.value='0';
374                                 document.EventForm.dtstart_hour.disabled = true;
375                                 document.EventForm.dtstart_minute.value='0';
376                                 document.EventForm.dtstart_minute.disabled = true;
377                                 document.EventForm.dtend_hour.value='0';
378                                 document.EventForm.dtend_hour.disabled = true;
379                                 document.EventForm.dtend_minute.value='0';
380                                 document.EventForm.dtend_minute.disabled = true;
381                                 document.EventForm.dtend_month.disabled = true;
382                                 document.EventForm.dtend_day.disabled = true;
383                                 document.EventForm.dtend_year.disabled = true;
384                         }
385                         else {
386                                 document.EventForm.dtstart_hour.disabled = false;
387                                 document.EventForm.dtstart_minute.disabled = false;
388                                 document.EventForm.dtend_hour.disabled = false;
389                                 document.EventForm.dtend_minute.disabled = false;
390                                 document.EventForm.dtend_month.disabled = false;
391                                 document.EventForm.dtend_day.disabled = false;
392                                 document.EventForm.dtend_year.disabled = false;
393                         }
394                 //-->
395                 </SCRIPT>
396         ");
397
398         wDumpContent(1);
399
400         if (created_new_vevent) {
401                 icalcomponent_free(vevent);
402         }
403 }
404
405 /*
406  * Save an edited event
407  * 
408  * ok
409  */
410 void save_individual_event(icalcomponent *supplied_vevent, long msgnum) {
411         char buf[SIZ];
412         icalproperty *prop;
413         icalcomponent *vevent;
414         int created_new_vevent = 0;
415         int all_day_event = 0;
416         struct icaltimetype event_start;
417         icalproperty *attendee = NULL;
418         char attendee_string[SIZ];
419         int i;
420         int foundit;
421         char form_attendees[SIZ];
422         char organizer_string[SIZ];
423         int sequence = 0;
424         enum icalproperty_transp formtransp = ICAL_TRANSP_NONE;
425
426         if (supplied_vevent != NULL) {
427                 vevent = supplied_vevent;
428                 /* If we're looking at a fully encapsulated VCALENDAR
429                  * rather than a VTODO component, attempt to use the first
430                  * relevant VTODO subcomponent.  If there is none, the
431                  * NULL returned by icalcomponent_get_first_component() will
432                  * tell the next iteration of this function to create a
433                  * new one.
434                  */
435                 if (icalcomponent_isa(vevent) == ICAL_VCALENDAR_COMPONENT) {
436                         save_individual_event(
437                                 icalcomponent_get_first_component(
438                                         vevent, ICAL_VTODO_COMPONENT
439                                 ), msgnum
440                         );
441                         return;
442                 }
443         }
444         else {
445                 vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT);
446                 created_new_vevent = 1;
447         }
448
449         if (!strcasecmp(bstr("sc"), "Save")) {
450
451                 /* Replace values in the component with ones from the form */
452
453                 while (prop = icalcomponent_get_first_property(vevent,
454                       ICAL_SUMMARY_PROPERTY), prop != NULL) {
455                         icalcomponent_remove_property(vevent, prop);
456                         icalproperty_free(prop);
457                 }
458                 icalcomponent_add_property(vevent,
459                         icalproperty_new_summary(bstr("summary")));
460
461                 while (prop = icalcomponent_get_first_property(vevent,
462                       ICAL_LOCATION_PROPERTY), prop != NULL) {
463                         icalcomponent_remove_property(vevent, prop);
464                         icalproperty_free(prop);
465                 }
466                 icalcomponent_add_property(vevent,
467                         icalproperty_new_location(bstr("location")));
468                 
469                 while (prop = icalcomponent_get_first_property(vevent,
470                       ICAL_DESCRIPTION_PROPERTY), prop != NULL) {
471                         icalcomponent_remove_property(vevent, prop);
472                         icalproperty_free(prop);
473                 }
474                 icalcomponent_add_property(vevent,
475                         icalproperty_new_description(bstr("description")));
476         
477                 while (prop = icalcomponent_get_first_property(vevent,
478                       ICAL_DTSTART_PROPERTY), prop != NULL) {
479                         icalcomponent_remove_property(vevent, prop);
480                         icalproperty_free(prop);
481                 }
482
483                 if (!strcmp(bstr("alldayevent"), "yes")) {
484                         all_day_event = 1;
485                 }
486                 else {
487                         all_day_event = 0;
488                 }
489
490                 event_start = icaltime_from_webform("dtstart");
491                 if (all_day_event) {
492                         event_start.is_date = 1;
493                         event_start.hour = 0;
494                         event_start.minute = 0;
495                         event_start.second = 0;
496                 }
497
498
499                 /* The following odd-looking snippet of code looks like it
500                  * takes some unnecessary steps.  It is done this way because
501                  * libical incorrectly turns an "all day event" into a normal
502                  * event starting at midnight (i.e. it serializes as date/time
503                  * instead of just date) unless icalvalue_new_date() is used.
504                  * So we force it, if this is an all day event.
505                  */
506                 prop = icalproperty_new_dtstart(event_start);
507                 if (all_day_event) {
508                         icalproperty_set_value(prop,
509                                 icalvalue_new_date(event_start)
510                         );
511                 }
512
513                 if (prop) icalcomponent_add_property(vevent, prop);
514                 else icalproperty_free(prop);
515
516                 while (prop = icalcomponent_get_first_property(vevent,
517                       ICAL_DTEND_PROPERTY), prop != NULL) {
518                         icalcomponent_remove_property(vevent, prop);
519                         icalproperty_free(prop);
520                 }
521                 while (prop = icalcomponent_get_first_property(vevent,
522                       ICAL_DURATION_PROPERTY), prop != NULL) {
523                         icalcomponent_remove_property(vevent, prop);
524                         icalproperty_free(prop);
525                 }
526
527                 if (all_day_event == 0) {
528                         icalcomponent_add_property(vevent,
529                                 icalproperty_new_dtend(icaltime_normalize(
530                                         icaltime_from_webform("dtend"))
531                                 )
532                         );
533                 }
534
535                 /* See if transparency is indicated */
536                 if (strlen(bstr("transp")) > 0) {
537                         if (!strcasecmp(bstr("transp"), "opaque")) {
538                                 formtransp = ICAL_TRANSP_OPAQUE;
539                         }
540                         else if (!strcasecmp(bstr("transp"), "transparent")) {
541                                 formtransp = ICAL_TRANSP_TRANSPARENT;
542                         }
543
544                         while (prop = icalcomponent_get_first_property(vevent, ICAL_TRANSP_PROPERTY),
545                               (prop != NULL)) {
546                                 icalcomponent_remove_property(vevent, prop);
547                                 icalproperty_free(prop);
548                         }
549
550                         lprintf(9, "adding new property\n");
551                         icalcomponent_add_property(vevent, icalproperty_new_transp(formtransp));
552                 }
553
554                 /* Give this event a UID if it doesn't have one. */
555                 if (icalcomponent_get_first_property(vevent,
556                    ICAL_UID_PROPERTY) == NULL) {
557                         generate_new_uid(buf);
558                         icalcomponent_add_property(vevent,
559                                 icalproperty_new_uid(buf)
560                         );
561                 }
562
563                 /* Increment the sequence ID */
564                 while (prop = icalcomponent_get_first_property(vevent,
565                       ICAL_SEQUENCE_PROPERTY), (prop != NULL) ) {
566                         i = icalproperty_get_sequence(prop);
567                         if (i > sequence) sequence = i;
568                         icalcomponent_remove_property(vevent, prop);
569                         icalproperty_free(prop);
570                 }
571                 ++sequence;
572                 icalcomponent_add_property(vevent,
573                         icalproperty_new_sequence(sequence)
574                 );
575                 
576                 /* Set the organizer, only if one does not already exist *and*
577                  * the form is supplying one
578                  */
579                 strcpy(buf, bstr("organizer"));
580                 if ( (icalcomponent_get_first_property(vevent,
581                    ICAL_ORGANIZER_PROPERTY) == NULL) 
582                    && (strlen(buf) > 0) ) {
583
584                         /* set new organizer */
585                         sprintf(organizer_string, "MAILTO:%s", buf);
586                         icalcomponent_add_property(vevent,
587                                 icalproperty_new_organizer(organizer_string)
588                         );
589
590                 }
591
592                 /*
593                  * Add any new attendees listed in the web form
594                  */
595
596                 /* First, strip out the parenthesized partstats.  */
597                 strcpy(form_attendees, bstr("attendees"));
598                 stripout(form_attendees, '(', ')');
599
600                 /* Now iterate! */
601                 for (i=0; i<num_tokens(form_attendees, ','); ++i) {
602                         extract_token(buf, form_attendees, i, ',');
603                         striplt(buf);
604                         if (strlen(buf) > 0) {
605                                 lprintf(9, "Attendee: <%s>\n", buf);
606                                 sprintf(attendee_string, "MAILTO:%s", buf);
607                                 foundit = 0;
608
609                                 for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY); attendee != NULL; attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
610                                         if (!strcasecmp(attendee_string,
611                                            icalproperty_get_attendee(attendee)))
612                                                 ++foundit;
613                                 }
614
615
616                                 if (foundit == 0) {
617                                         icalcomponent_add_property(vevent,
618                                                 icalproperty_new_attendee(attendee_string)
619                                         );
620                                 }
621                         }
622                 }
623
624                 /*
625                  * Remove any attendees *not* listed in the web form
626                  */
627 STARTOVER:
628                 for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY); attendee != NULL; attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
629                         strcpy(attendee_string, icalproperty_get_attendee(attendee));
630                         if (!strncasecmp(attendee_string, "MAILTO:", 7)) {
631                                 strcpy(attendee_string, &attendee_string[7]);
632                                 striplt(attendee_string);
633                                 foundit = 0;
634                                 for (i=0; i<num_tokens(form_attendees, ','); ++i) {
635                                         extract_token(buf, form_attendees, i, ',');
636                                         striplt(buf);
637                                         if (!strcasecmp(buf, attendee_string)) ++foundit;
638                                 }
639                                 if (foundit == 0) {
640                                         icalcomponent_remove_property(vevent, attendee);
641                                         icalproperty_free(attendee);
642                                         goto STARTOVER;
643                                 }
644                         }
645                 }
646
647                 /*
648                  * Serialize it and save it to the message base
649                  */
650                 serv_puts("ENT0 1|||4");
651                 serv_gets(buf);
652                 if (buf[0] == '4') {
653                         serv_puts("Content-type: text/calendar");
654                         serv_puts("");
655                         serv_puts(icalcomponent_as_ical_string(vevent));
656                         serv_puts("000");
657                 }
658         }
659
660         /*
661          * If the user clicked 'Delete' then delete it.
662          */
663         if ( (!strcasecmp(bstr("sc"), "Delete")) && (msgnum > 0L) ) {
664                 serv_printf("DELE %ld", atol(bstr("msgnum")));
665                 serv_gets(buf);
666         }
667
668         if (created_new_vevent) {
669                 icalcomponent_free(vevent);
670         }
671
672         /* Go back to the event list */
673         readloop("readfwd");
674 }
675
676
677 #endif /* WEBCIT_WITH_CALENDAR_SERVICE */