5 * \defgroup calav Functions which handle calendar objects and their processing/display.
11 #include "webserver.h"
13 #ifndef WEBCIT_WITH_CALENDAR_SERVICE
16 * \brief get around non existing types
17 * Handler stubs for builds with no calendar library available
18 * \param part_source dummy pointer to the source
19 * \param msgnum number of the mesage in the db
20 * \param cal_partnum number of the calendar part
22 void cal_process_attachment(char *part_source, long msgnum, char *cal_partnum) {
24 wprintf(_("<I>This message contains calendaring/scheduling information,"
25 " but support for calendars is not available on this "
26 "particular system. Please ask your system administrator to "
27 "install a new version of the Citadel web service with "
28 "calendaring enabled.</I><br />\n")
34 * \brief say we can't display calendar items
35 * \param msgnum number of the mesage in our db
37 void display_calendar(long msgnum) {
39 "Cannot display calendar item. You are seeing this error "
40 "because your WebCit service has not been installed with "
41 "calendar support. Please contact your system administrator."
46 * \brief say we can't display task items
47 * \param msgnum number of the mesage in our db
49 void display_task(long msgnum) {
51 "Cannot display to-do item. You are seeing this error "
52 "because your WebCit service has not been installed with "
53 "calendar support. Please contact your system administrator."
56 /** ok, we have calendaring available */
57 #else /* WEBCIT_WITH_CALENDAR_SERVICE */
60 /****** End of handler stubs. Everything below this line is real. ******/
66 * \brief Process a calendar object
67 * ...at this point it's already been deserialized by cal_process_attachment()
68 * \param cal the calendar object
69 * \param recursion_level call stack depth ??????
70 * \param msgnum number of the mesage in our db
71 * \param cal_partnum of the calendar object ????
73 void cal_process_object(icalcomponent *cal,
79 icalproperty *method = NULL;
80 icalproperty_method the_method = ICAL_METHOD_NONE;
82 struct icaltimetype t;
85 char conflict_name[256];
86 char conflict_message[256];
89 static int divcount = 0;
91 sprintf(divname, "rsvp%04x", ++divcount);
93 /** Leading HTML for the display of this object */
94 if (recursion_level == 0) {
95 wprintf("<div class=\"mimepart\">\n");
98 /** Look for a method */
99 method = icalcomponent_get_first_property(cal, ICAL_METHOD_PROPERTY);
101 /** See what we need to do with this */
102 if (method != NULL) {
103 the_method = icalproperty_get_method(method);
106 wprintf("<div id=\"%s_title\">", divname);
107 wprintf("<img src=\"static/calarea_48x.gif\">");
110 case ICAL_METHOD_REQUEST:
111 title = _("Meeting invitation");
113 case ICAL_METHOD_REPLY:
114 title = _("Attendee's reply to your invitation");
116 case ICAL_METHOD_PUBLISH:
117 title = _("Published event");
120 title = _("This is an unknown type of calendar item.");
125 wprintf(" %s",title);
130 p = icalcomponent_get_first_property(cal, ICAL_SUMMARY_PROPERTY);
133 wprintf(_("Summary:"));
134 wprintf("</dt><dd>");
135 escputs((char *)icalproperty_get_comment(p));
139 p = icalcomponent_get_first_property(cal, ICAL_LOCATION_PROPERTY);
142 wprintf(_("Location:"));
143 wprintf("</dt><dd>");
144 escputs((char *)icalproperty_get_comment(p));
149 * Only show start/end times if we're actually looking at the VEVENT
150 * component. Otherwise it shows bogus dates for things like timezone.
152 if (icalcomponent_isa(cal) == ICAL_VEVENT_COMPONENT) {
154 p = icalcomponent_get_first_property(cal,
155 ICAL_DTSTART_PROPERTY);
157 t = icalproperty_get_dtstart(p);
162 memset(&d_tm, 0, sizeof d_tm);
163 d_tm.tm_year = t.year - 1900;
164 d_tm.tm_mon = t.month - 1;
165 d_tm.tm_mday = t.day;
166 wc_strftime(d_str, sizeof d_str, "%x", &d_tm);
169 wprintf("</dt><dd>%s</dd>", d_str);
172 tt = icaltime_as_timet(t);
173 fmt_date(buf, tt, 0);
175 wprintf(_("Starting date/time:"));
176 wprintf("</dt><dd>%s</dd>", buf);
180 p = icalcomponent_get_first_property(cal, ICAL_DTEND_PROPERTY);
182 t = icalproperty_get_dtend(p);
183 tt = icaltime_as_timet(t);
184 fmt_date(buf, tt, 0);
186 wprintf(_("Ending date/time:"));
187 wprintf("</dt><dd>%s</dd>", buf);
192 p = icalcomponent_get_first_property(cal, ICAL_DESCRIPTION_PROPERTY);
195 wprintf(_("Description:"));
196 wprintf("</dt><dd>");
197 escputs((char *)icalproperty_get_comment(p));
201 /** If the component has attendees, iterate through them. */
202 for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY); (p != NULL); p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) {
204 wprintf(_("Attendee:"));
205 wprintf("</dt><dd>");
206 safestrncpy(buf, icalproperty_get_attendee(p), sizeof buf);
207 if (!strncasecmp(buf, "MAILTO:", 7)) {
209 /** screen name or email address */
210 strcpy(buf, &buf[7]);
215 /** participant status */
216 partstat_as_string(buf, p);
222 /** If the component has subcomponents, recurse through them. */
223 for (c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT);
225 c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)) {
226 /* Recursively process subcomponent */
227 cal_process_object(c, recursion_level+1, msgnum, cal_partnum);
230 /** If this is a REQUEST, display conflicts and buttons */
231 if (the_method == ICAL_METHOD_REQUEST) {
233 /* Check for conflicts */
234 lprintf(9, "Checking server calendar for conflicts...\n");
235 serv_printf("ICAL conflicts|%ld|%s|", msgnum, cal_partnum);
236 serv_getln(buf, sizeof buf);
238 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
239 extract_token(conflict_name, buf, 3, '|', sizeof conflict_name);
240 is_update = extract_int(buf, 4);
243 snprintf(conflict_message, sizeof conflict_message,
244 _("This is an update of '%s' which is already in your calendar."), conflict_name);
247 snprintf(conflict_message, sizeof conflict_message,
248 _("This event would conflict with '%s' which is already in your calendar."), conflict_name);
257 wprintf("</dt><dd>");
258 escputs(conflict_message);
262 lprintf(9, "...done.\n");
266 /** Display the Accept/Decline buttons */
267 wprintf("<p id=\"%s_question\" class=\"buttons\">"
269 "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Accept');\">%s</a>"
271 "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Tentative');\">%s</a>"
273 "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Decline');\">%s</a>"
276 _("How would you like to respond to this invitation?"),
277 divname, divname, msgnum, cal_partnum, _("Accept"),
278 divname, divname, msgnum, cal_partnum, _("Tentative"),
279 divname, divname, msgnum, cal_partnum, _("Decline")
284 /** If this is a REPLY, display update button */
285 if (the_method == ICAL_METHOD_REPLY) {
287 /** \todo In the future, if we want to validate this object before \
288 * continuing, we can do it this way:
289 serv_printf("ICAL whatever|%ld|%s|", msgnum, cal_partnum);
290 serv_getln(buf, sizeof buf);
294 /** Display the update buttons */
295 wprintf("<p id=\"%s_question\" class=\"buttons\">"
297 "<a href=\"javascript:HandleRSVP('%s_question','%s_title','%ld','%s','Update');\">%s</a>"
299 "<a href=\"javascript:HandleRSVP('%s_question','%s_title','%ld','%s','Ignore');\">%s</a>"
302 _("Click <i>Update</i> to accept this reply and update your calendar."),
303 divname, divname, msgnum, cal_partnum, _("Update"),
304 divname, divname, msgnum, cal_partnum, _("Ignore")
309 /** Trailing HTML for the display of this object */
310 if (recursion_level == 0) {
311 wprintf("<p> </p></div>\n");
317 * \brief process calendar mail atachment
318 * Deserialize a calendar object in a message so it can be processed.
319 * (This is the main entry point for these things)
320 * \param part_source the part of the message we want to parse
321 * \param msgnum number of the mesage in our db
322 * \param cal_partnum the number of the calendar item
324 void cal_process_attachment(char *part_source, long msgnum, char *cal_partnum) {
327 cal = icalcomponent_new_from_string(part_source);
330 wprintf(_("There was an error parsing this calendar item."));
336 cal_process_object(cal, 0, msgnum, cal_partnum);
338 /* Free the memory we obtained from libical's constructor */
339 icalcomponent_free(cal);
346 * \brief accept/decline meeting
347 * Respond to a meeting request
349 void respond_to_request(void) {
352 begin_ajax_response();
354 serv_printf("ICAL respond|%s|%s|%s|",
359 serv_getln(buf, sizeof buf);
362 wprintf("<img src=\"static/calarea_48x.gif\"><span>");
363 if (!strcasecmp(bstr("sc"), "accept")) {
364 wprintf(_("You have accepted this meeting invitation. "
365 "It has been entered into your calendar.")
367 } else if (!strcasecmp(bstr("sc"), "tentative")) {
368 wprintf(_("You have tentatively accepted this meeting invitation. "
369 "It has been 'pencilled in' to your calendar.")
371 } else if (!strcasecmp(bstr("sc"), "decline")) {
372 wprintf(_("You have declined this meeting invitation. "
373 "It has <b>not</b> been entered into your calendar.")
377 wprintf(_("A reply has been sent to the meeting organizer."));
380 wprintf("<img align=\"center\" src=\"static/error.gif\"><span>");
381 wprintf("%s\n", &buf[4]);
391 * \brief Handle an incoming RSVP
393 void handle_rsvp(void) {
396 begin_ajax_response();
398 serv_printf("ICAL handle_rsvp|%s|%s|%s|",
403 serv_getln(buf, sizeof buf);
406 wprintf("<img src=\"static/calarea_48x.gif\"><span>");
407 if (!strcasecmp(bstr("sc"), "update")) {
408 wprintf(_("Your calendar has been updated to reflect this RSVP."));
409 } else if (!strcasecmp(bstr("sc"), "ignore")) {
410 wprintf(_("You have chosen to ignore this RSVP. "
411 "Your calendar has <b>not</b> been updated.")
416 wprintf("<img src=\"static/error.gif\"><span> %s\n", &buf[4]);
427 /*-----------------------------------------------------------------------**/
432 * \defgroup MsgDisplayHandlers Display handlers for message reading
433 * \ingroup Calendaring
441 * \brief get items, keep them.
442 * If we're reading calendar items, just store them for now. We have to
443 * sort and re-output them later when we draw the calendar.
444 * \param cal Our calendar to process
445 * \param msgnum number of the mesage in our db
447 void display_individual_cal(icalcomponent *cal, long msgnum)
449 icalproperty *ps = NULL;
450 struct icaltimetype t;
451 struct wcsession *WCC;
452 struct disp_cal *Cal;
461 WCC->disp_cal = realloc(WCC->disp_cal,
462 (sizeof(struct disp_cal) * WCC->num_cal) );
464 Cal = &WCC->disp_cal[WCC->num_cal - 1];
465 Cal->cal = icalcomponent_new_clone(cal);
467 Cal->cal_msgnum = msgnum;
469 //! Precalculate some Values we can use for easy comparison later.
470 ps = icalcomponent_get_first_property(Cal->cal, ICAL_DTSTART_PROPERTY);
472 t = icalproperty_get_dtstart(ps);
473 event_ts = icaltime_as_timet(t);
475 if (t.is_date) { //! calculate whether we are a day event.
476 Cal->start_hour = -1;
479 localtime_r(&event_ts, &event);
483 Cal->start_day = mktime (&event);
485 else { //! Precalc start day and start day + hour
486 localtime_r(&event_ts, &event);
489 memcpy (&event_hr, &event, sizeof(struct tm));
490 Cal->start_hour = mktime (&event_hr);
492 Cal->start_day = mktime (&event);
494 ps = icalcomponent_get_first_property(Cal->cal, ICAL_DTEND_PROPERTY);
495 if (ps != NULL) { //! Precalc the end day and end day + hour
496 t = icalproperty_get_dtstart(ps);
497 event_ts = icaltime_as_timet(t);
498 localtime_r(&event_ts, &event);
501 memcpy (&event_hr, &event, sizeof(struct tm));
502 Cal->end_hour = mktime (&event);
504 Cal->end_day = mktime (&event);
515 Cal->multi_day_event = Cal->start_day != Cal->end_day;
522 * Display a task by itself (for editing)
523 * \param supplied_vtodo the todo item we want to edit
524 * \param msgnum number of the mesage in our db
526 void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum) {
527 icalcomponent *vtodo;
529 struct icaltimetype t;
531 int created_new_vtodo = 0;
535 if (supplied_vtodo != NULL) {
536 vtodo = supplied_vtodo;
539 * If we're looking at a fully encapsulated VCALENDAR
540 * rather than a VTODO component, attempt to use the first
541 * relevant VTODO subcomponent. If there is none, the
542 * NULL returned by icalcomponent_get_first_component() will
543 * tell the next iteration of this function to create a
546 if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
547 display_edit_individual_task(
548 icalcomponent_get_first_component(
549 vtodo, ICAL_VTODO_COMPONENT
556 vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT);
557 created_new_vtodo = 1;
560 output_headers(1, 1, 2, 0, 0, 0);
561 wprintf("<div id=\"banner\">\n");
562 wprintf("<img src=\"static/taskmanag_48x.gif\">");
564 wprintf(_("Edit task"));
568 wprintf("<div id=\"content\" class=\"service\">\n");
570 wprintf("<div class=\"fix_scrollbar_bug\">"
571 "<table class=\"calendar_background\"><tr><td>");
573 wprintf("<FORM METHOD=\"POST\" action=\"save_task\">\n");
574 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
575 wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgnum\" VALUE=\"%ld\">\n",
578 wprintf("<TABLE border=0>\n");
581 wprintf(_("Summary:"));
583 "<INPUT TYPE=\"text\" NAME=\"summary\" "
584 "MAXLENGTH=\"64\" SIZE=\"64\" VALUE=\"");
585 p = icalcomponent_get_first_property(vtodo, ICAL_SUMMARY_PROPERTY);
587 escputs((char *)icalproperty_get_comment(p));
589 wprintf("\"></TD></TR>\n");
592 wprintf(_("Start date:"));
593 wprintf("</TD><TD>");
594 p = icalcomponent_get_first_property(vtodo, ICAL_DTSTART_PROPERTY);
596 t = icalproperty_get_dtstart(p);
599 t = icaltime_from_timet(now, 0);
601 display_icaltimetype_as_webform(&t, "dtstart");
602 wprintf("</TD></TR>\n");
605 wprintf(_("Due date:"));
606 wprintf("</TD><TD>");
607 p = icalcomponent_get_first_property(vtodo, ICAL_DUE_PROPERTY);
609 t = icalproperty_get_due(p);
612 t = icaltime_from_timet(now, 0);
614 display_icaltimetype_as_webform(&t, "due");
615 wprintf("</TD></TR>\n");
617 wprintf(_("Description:"));
618 wprintf("</TD><TD>");
619 wprintf("<TEXTAREA NAME=\"description\" wrap=soft "
620 "ROWS=10 COLS=80 WIDTH=80>\n"
622 p = icalcomponent_get_first_property(vtodo, ICAL_DESCRIPTION_PROPERTY);
624 escputs((char *)icalproperty_get_comment(p));
626 wprintf("</TEXTAREA></TD></TR></TABLE>\n");
629 "<INPUT TYPE=\"submit\" NAME=\"save_button\" VALUE=\"%s\">"
631 "<INPUT TYPE=\"submit\" NAME=\"delete_button\" VALUE=\"%s\">\n"
633 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">\n"
640 wprintf("</FORM>\n");
642 wprintf("</td></tr></table></div>\n");
645 if (created_new_vtodo) {
646 icalcomponent_free(vtodo);
651 * \brief Save an edited task
652 * \param supplied_vtodo the task to save
653 * \param msgnum number of the mesage in our db
655 void save_individual_task(icalcomponent *supplied_vtodo, long msgnum) {
657 int delete_existing = 0;
659 icalcomponent *vtodo, *encaps;
660 int created_new_vtodo = 0;
663 struct icaltimetype t;
665 if (supplied_vtodo != NULL) {
666 vtodo = supplied_vtodo;
668 * If we're looking at a fully encapsulated VCALENDAR
669 * rather than a VTODO component, attempt to use the first
670 * relevant VTODO subcomponent. If there is none, the
671 * NULL returned by icalcomponent_get_first_component() will
672 * tell the next iteration of this function to create a
675 if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
676 save_individual_task(
677 icalcomponent_get_first_component(
678 vtodo, ICAL_VTODO_COMPONENT
685 vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT);
686 created_new_vtodo = 1;
689 if (!IsEmptyStr(bstr("save_button"))) {
691 /** Replace values in the component with ones from the form */
693 while (prop = icalcomponent_get_first_property(vtodo,
694 ICAL_SUMMARY_PROPERTY), prop != NULL) {
695 icalcomponent_remove_property(vtodo, prop);
696 icalproperty_free(prop);
698 if (!IsEmptyStr(bstr("summary"))) {
700 icalcomponent_add_property(vtodo,
701 icalproperty_new_summary(bstr("summary")));
703 icalcomponent_add_property(vtodo,
704 icalproperty_new_summary("Untitled Task"));
707 while (prop = icalcomponent_get_first_property(vtodo,
708 ICAL_DESCRIPTION_PROPERTY), prop != NULL) {
709 icalcomponent_remove_property(vtodo, prop);
710 icalproperty_free(prop);
712 icalcomponent_add_property(vtodo,
713 icalproperty_new_description(bstr("description")));
715 while (prop = icalcomponent_get_first_property(vtodo,
716 ICAL_DTSTART_PROPERTY), prop != NULL) {
717 icalcomponent_remove_property(vtodo, prop);
718 icalproperty_free(prop);
720 icaltime_from_webform(&t, "dtstart");
721 icalcomponent_add_property(vtodo,
722 icalproperty_new_dtstart(t)
725 while (prop = icalcomponent_get_first_property(vtodo,
726 ICAL_DUE_PROPERTY), prop != NULL) {
727 icalcomponent_remove_property(vtodo, prop);
728 icalproperty_free(prop);
730 icaltime_from_webform(&t, "due");
731 icalcomponent_add_property(vtodo,
732 icalproperty_new_due(t)
735 /** Give this task a UID if it doesn't have one. */
736 lprintf(9, "Give this task a UID if it doesn't have one.\n");
737 if (icalcomponent_get_first_property(vtodo,
738 ICAL_UID_PROPERTY) == NULL) {
740 icalcomponent_add_property(vtodo,
741 icalproperty_new_uid(buf)
745 /** Increment the sequence ID */
746 lprintf(9, "Increment the sequence ID\n");
747 while (prop = icalcomponent_get_first_property(vtodo,
748 ICAL_SEQUENCE_PROPERTY), (prop != NULL) ) {
749 i = icalproperty_get_sequence(prop);
750 lprintf(9, "Sequence was %d\n", i);
751 if (i > sequence) sequence = i;
752 icalcomponent_remove_property(vtodo, prop);
753 icalproperty_free(prop);
756 lprintf(9, "New sequence is %d. Adding...\n", sequence);
757 icalcomponent_add_property(vtodo,
758 icalproperty_new_sequence(sequence)
762 * Encapsulate event into full VCALENDAR component. Clone it first,
763 * for two reasons: one, it's easier to just free the whole thing
764 * when we're done instead of unbundling, but more importantly, we
765 * can't encapsulate something that may already be encapsulated
768 lprintf(9, "Encapsulating into a full VCALENDAR component\n");
769 encaps = ical_encapsulate_subcomponent(icalcomponent_new_clone(vtodo));
771 /* Serialize it and save it to the message base */
772 serv_puts("ENT0 1|||4");
773 serv_getln(buf, sizeof buf);
775 serv_puts("Content-type: text/calendar");
777 serv_puts(icalcomponent_as_ical_string(encaps));
781 * Probably not necessary; the server will see the UID
782 * of the object and delete the old one anyway, but
787 icalcomponent_free(encaps);
791 * If the user clicked 'Delete' then explicitly delete the message.
793 if (!IsEmptyStr(bstr("delete_button"))) {
797 if ( (delete_existing) && (msgnum > 0L) ) {
798 serv_printf("DELE %ld", atol(bstr("msgnum")));
799 serv_getln(buf, sizeof buf);
802 if (created_new_vtodo) {
803 icalcomponent_free(vtodo);
806 /** Go back to the task list */
813 * \brief generic item handler
814 * Code common to all display handlers. Given a message number and a MIME
815 * type, we load the message and hunt for that MIME type. If found, we load
816 * the relevant part, deserialize it into a libical component, filter it for
817 * the requested object type, and feed it to the specified handler.
818 * \param mimetype mimetyp of our object
819 * \param which_kind sort of ical type
820 * \param msgnum number of the mesage in our db
821 * \param callback a funcion \todo
824 void display_using_handler(long msgnum,
826 icalcomponent_kind which_kind,
827 void (*callback)(icalcomponent *, long)
830 char mime_partnum[256];
831 char mime_filename[256];
832 char mime_content_type[256];
833 char mime_disposition[256];
835 char relevant_partnum[256];
836 char *relevant_source = NULL;
837 icalcomponent *cal, *c;
839 relevant_partnum[0] = '\0';
840 sprintf(buf, "MSG0 %ld|0", msgnum); /* unfortunately we need the mime headers */
842 serv_getln(buf, sizeof buf);
843 if (buf[0] != '1') return;
845 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
846 if (!strncasecmp(buf, "part=", 5)) {
847 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
848 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
849 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
850 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
851 mime_length = extract_int(&buf[5], 5);
853 if (!strcasecmp(mime_content_type, "text/calendar")) {
854 strcpy(relevant_partnum, mime_partnum);
856 else if (!strcasecmp(mime_content_type, "text/vtodo")) {
857 strcpy(relevant_partnum, mime_partnum);
863 if (!IsEmptyStr(relevant_partnum)) {
864 relevant_source = load_mimepart(msgnum, relevant_partnum);
865 if (relevant_source != NULL) {
867 cal = icalcomponent_new_from_string(relevant_source);
872 /** Simple components of desired type */
873 if (icalcomponent_isa(cal) == which_kind) {
874 callback(cal, msgnum);
877 /** Subcomponents of desired type */
878 for (c = icalcomponent_get_first_component(cal,
881 c = icalcomponent_get_next_component(cal,
885 icalcomponent_free(cal);
887 free(relevant_source);
894 * \brief display whole calendar
895 * \param msgnum number of the mesage in our db
897 void display_calendar(long msgnum) {
898 display_using_handler(msgnum, "text/calendar",
899 ICAL_VEVENT_COMPONENT,
900 display_individual_cal);
904 * \brief display whole taksview
905 * \param msgnum number of the mesage in our db
907 void display_task(long msgnum) {
908 display_using_handler(msgnum, "text/calendar",
909 ICAL_VTODO_COMPONENT,
910 display_individual_cal);
914 * \brief display the editor component for a task
916 void display_edit_task(void) {
919 /** Force change the room if we have to */
920 if (!IsEmptyStr(bstr("taskrm"))) {
921 gotoroom(bstr("taskrm"));
924 msgnum = atol(bstr("msgnum"));
927 display_using_handler(msgnum, "text/calendar",
928 ICAL_VTODO_COMPONENT,
929 display_edit_individual_task);
933 display_edit_individual_task(NULL, 0L);
938 *\brief save an edited task
940 void save_task(void) {
943 msgnum = atol(bstr("msgnum"));
945 display_using_handler(msgnum, "text/calendar",
946 ICAL_VTODO_COMPONENT,
947 save_individual_task);
950 save_individual_task(NULL, 0L);
955 * \brief display the editor component for an event
957 void display_edit_event(void) {
960 msgnum = atol(bstr("msgnum"));
963 display_using_handler(msgnum, "text/calendar",
964 ICAL_VEVENT_COMPONENT,
965 display_edit_individual_event);
969 display_edit_individual_event(NULL, 0L);
974 * \brief save an edited event
976 void save_event(void) {
979 msgnum = atol(bstr("msgnum"));
982 display_using_handler(msgnum, "text/calendar",
983 ICAL_VEVENT_COMPONENT,
984 save_individual_event);
987 save_individual_event(NULL, 0L);
996 * \brief freebusy display (for client software)
997 * \param req dunno. ?????
999 void do_freebusy(char *req) {
1005 extract_token(who, req, 1, ' ', sizeof who);
1006 if (!strncasecmp(who, "/freebusy/", 10)) {
1007 strcpy(who, &who[10]);
1009 unescape_input(who);
1012 if ( (!strcasecmp(&who[len-4], ".vcf"))
1013 || (!strcasecmp(&who[len-4], ".ifb"))
1014 || (!strcasecmp(&who[len-4], ".vfb")) ) {
1018 lprintf(9, "freebusy requested for <%s>\n", who);
1019 serv_printf("ICAL freebusy|%s", who);
1020 serv_getln(buf, sizeof buf);
1022 if (buf[0] != '1') {
1023 wprintf("HTTP/1.1 404 %s\n", &buf[4]);
1024 output_headers(0, 0, 0, 0, 0, 0);
1025 wprintf("Content-Type: text/plain\r\n");
1027 wprintf("%s\n", &buf[4]);
1031 fb = read_server_text();
1032 http_transmit_thing(fb, strlen(fb), "text/calendar", 0);
1038 #endif /* WEBCIT_WITH_CALENDAR_SERVICE */