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 teh 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 /** Leading HTML for the display of this object */
90 if (recursion_level == 0) {
91 wprintf("<CENTER><TABLE border=0>\n");
94 /** Look for a method */
95 method = icalcomponent_get_first_property(cal, ICAL_METHOD_PROPERTY);
97 /** See what we need to do with this */
99 the_method = icalproperty_get_method(method);
101 case ICAL_METHOD_REQUEST:
102 wprintf("<tr><td colspan=\"2\">\n"
103 "<img align=\"center\" "
104 "src=\"static/calarea_48x.gif\">"
107 wprintf(_("Meeting invitation"));
108 wprintf("</B></TD></TR>\n");
110 case ICAL_METHOD_REPLY:
111 wprintf("<TR><TD COLSPAN=2>\n"
113 "src=\"static/calarea_48x.gif\">"
116 wprintf(_("Attendee's reply to your invitation"));
117 wprintf("</B></TD></TR>\n");
119 case ICAL_METHOD_PUBLISH:
120 wprintf("<TR><TD COLSPAN=2>\n"
122 "src=\"static/calarea_48x.gif\">"
125 wprintf(_("Published event"));
126 wprintf("</B></TD></TR>\n");
129 wprintf("<TR><TD COLSPAN=2>");
130 wprintf(_("This is an unknown type of calendar item."));
131 wprintf("</TD></TR>\n");
136 p = icalcomponent_get_first_property(cal, ICAL_SUMMARY_PROPERTY);
138 wprintf("<TR><TD><B>");
139 wprintf(_("Summary:"));
140 wprintf("</B></TD><TD>");
141 escputs((char *)icalproperty_get_comment(p));
142 wprintf("</TD></TR>\n");
145 p = icalcomponent_get_first_property(cal, ICAL_LOCATION_PROPERTY);
147 wprintf("<TR><TD><B>");
148 wprintf(_("Location:"));
149 wprintf("</B></TD><TD>");
150 escputs((char *)icalproperty_get_comment(p));
151 wprintf("</TD></TR>\n");
155 * Only show start/end times if we're actually looking at the VEVENT
156 * component. Otherwise it shows bogus dates for things like timezone.
158 if (icalcomponent_isa(cal) == ICAL_VEVENT_COMPONENT) {
160 p = icalcomponent_get_first_property(cal,
161 ICAL_DTSTART_PROPERTY);
163 t = icalproperty_get_dtstart(p);
168 memset(&d_tm, 0, sizeof d_tm);
169 d_tm.tm_year = t.year - 1900;
170 d_tm.tm_mon = t.month - 1;
171 d_tm.tm_mday = t.day;
172 wc_strftime(d_str, sizeof d_str, "%x", &d_tm);
173 wprintf("<TR><TD><B>");
175 wprintf("</B></TD><TD>%s</TD></TR>", d_str);
178 tt = icaltime_as_timet(t);
179 fmt_date(buf, tt, 0);
180 wprintf("<TR><TD><B>");
181 wprintf(_("Starting date/time:"));
182 wprintf("</B></TD><TD>%s</TD></TR>", buf);
186 p = icalcomponent_get_first_property(cal, ICAL_DTEND_PROPERTY);
188 t = icalproperty_get_dtend(p);
189 tt = icaltime_as_timet(t);
190 fmt_date(buf, tt, 0);
191 wprintf("<TR><TD><B>");
192 wprintf(_("Ending date/time:"));
193 wprintf("</B></TD><TD>%s</TD></TR>", buf);
198 p = icalcomponent_get_first_property(cal, ICAL_DESCRIPTION_PROPERTY);
200 wprintf("<TR><TD><B>");
201 wprintf(_("Description:"));
202 wprintf("</B></TD><TD>");
203 escputs((char *)icalproperty_get_comment(p));
204 wprintf("</TD></TR>\n");
207 /** If the component has attendees, iterate through them. */
208 for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY); (p != NULL); p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) {
209 wprintf("<TR><TD><B>");
210 wprintf(_("Attendee:"));
211 wprintf("</B></TD><TD>");
212 safestrncpy(buf, icalproperty_get_attendee(p), sizeof buf);
213 if (!strncasecmp(buf, "MAILTO:", 7)) {
215 /** screen name or email address */
216 strcpy(buf, &buf[7]);
221 /** participant status */
222 partstat_as_string(buf, p);
225 wprintf("</TD></TR>\n");
228 /** If the component has subcomponents, recurse through them. */
229 for (c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT);
231 c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)) {
232 /* Recursively process subcomponent */
233 cal_process_object(c, recursion_level+1, msgnum, cal_partnum);
236 /** If this is a REQUEST, display conflicts and buttons */
237 if (the_method == ICAL_METHOD_REQUEST) {
239 /* Check for conflicts */
240 lprintf(9, "Checking server calendar for conflicts...\n");
241 serv_printf("ICAL conflicts|%ld|%s|", msgnum, cal_partnum);
242 serv_getln(buf, sizeof buf);
244 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
245 extract_token(conflict_name, buf, 3, '|', sizeof conflict_name);
246 is_update = extract_int(buf, 4);
249 snprintf(conflict_message, sizeof conflict_message,
250 _("This is an update of '%s' which is already in your calendar."), conflict_name);
253 snprintf(conflict_message, sizeof conflict_message,
254 _("This event would conflict with '%s' which is already in your calendar."), conflict_name);
257 wprintf("<TR><TD><B><I>%s</I></B></TD><td>",
263 escputs(conflict_message);
264 wprintf("</TD></TR>\n");
267 lprintf(9, "...done.\n");
269 /** Display the Accept/Decline buttons */
270 wprintf("<tr><td>%s</td>"
272 "<a href=\"respond_to_request?msgnum=%ld&cal_partnum=%s&sc=Accept\">%s</a>"
274 "<a href=\"respond_to_request?msgnum=%ld&cal_partnum=%s&sc=Tentative\">%s</a>"
276 "<a href=\"respond_to_request?msgnum=%ld&cal_partnum=%s&sc=Decline\">%s</a>"
277 "</FONT></TD></TR>\n",
278 _("How would you like to respond to this invitation?"),
279 msgnum, cal_partnum, _("Accept"),
280 msgnum, cal_partnum, _("Tentative"),
281 msgnum, cal_partnum, _("Decline")
286 /** If this is a REPLY, display update button */
287 if (the_method == ICAL_METHOD_REPLY) {
289 /** \todo In the future, if we want to validate this object before \
290 * continuing, we can do it this way:
291 serv_printf("ICAL whatever|%ld|%s|", msgnum, cal_partnum);
292 serv_getln(buf, sizeof buf);
296 /** Display the update buttons */
299 "</td><td><font size=+1>"
300 "<a href=\"handle_rsvp?msgnum=%ld&cal_partnum=%s&sc=Update\">%s</a>"
302 "<a href=\"handle_rsvp?msgnum=%ld&cal_partnum=%s&sc=Ignore\">%s</a>"
305 _("Click <i>Update</i> to accept this reply and update your calendar."),
306 msgnum, cal_partnum, _("Update"),
307 msgnum, cal_partnum, _("Ignore")
312 /** Trailing HTML for the display of this object */
313 if (recursion_level == 0) {
315 wprintf("</TR></TABLE></CENTER>\n");
321 * \brief process calendar mail atachment
322 * Deserialize a calendar object in a message so it can be processed.
323 * (This is the main entry point for these things)
324 * \param part_source the part of the message we want to parse
325 * \param msgnum number of the mesage in our db
326 * \param cal_partnum the number of the calendar item
328 void cal_process_attachment(char *part_source, long msgnum, char *cal_partnum) {
331 cal = icalcomponent_new_from_string(part_source);
334 wprintf(_("There was an error parsing this calendar item."));
340 cal_process_object(cal, 0, msgnum, cal_partnum);
342 /* Free the memory we obtained from libical's constructor */
343 icalcomponent_free(cal);
350 * \brief accept/decline meeting
351 * Respond to a meeting request
353 void respond_to_request(void) {
356 output_headers(1, 1, 2, 0, 0, 0);
358 wprintf("<div id=\"banner\">\n");
359 wprintf("<TABLE class=\"calendar_banner\"><TR><TD>"
360 "<SPAN CLASS=\"titlebar\">");
361 wprintf(_("Respond to meeting request"));
363 "</TD></TR></TABLE>\n"
365 wprintf("</div>\n<div id=\"content\">\n");
367 serv_printf("ICAL respond|%s|%s|%s|",
372 serv_getln(buf, sizeof buf);
375 wprintf("<TABLE BORDER=0><TR><TD>"
376 "<img src=\"static/calarea_48x.gif\" ALIGN=CENTER>"
379 if (!strcasecmp(bstr("sc"), "accept")) {
380 wprintf(_("You have accepted this meeting invitation. "
381 "It has been entered into your calendar.")
383 } else if (!strcasecmp(bstr("sc"), "tentative")) {
384 wprintf(_("You have tentatively accepted this meeting invitation. "
385 "It has been 'pencilled in' to your calendar.")
387 } else if (!strcasecmp(bstr("sc"), "decline")) {
388 wprintf(_("You have declined this meeting invitation. "
389 "It has <b>not</b> been entered into your calendar.")
393 wprintf(_("A reply has been sent to the meeting organizer."));
394 wprintf("</TD></TR></TABLE>\n");
396 wprintf("<img src=\"static/error.gif\" ALIGN=CENTER>"
400 wprintf("<a href=\"dotskip?room=");
401 urlescputs(WC->wc_roomname);
402 wprintf("\"><br />");
403 wprintf(_("Return to messages"));
404 wprintf("</A><br />\n");
412 * \brief Handle an incoming RSVP
414 void handle_rsvp(void) {
417 output_headers(1, 1, 2, 0, 0, 0);
419 wprintf("<div id=\"banner\">\n");
420 wprintf("<TABLE class=\"calendar_banner\"><TR><TD>"
421 "<SPAN CLASS=\"titlebar\">");
422 wprintf(_("Update your calendar with this RSVP"));
424 "</TD></TR></TABLE>\n"
425 "</div>\n<div id=\"content\">\n"
428 serv_printf("ICAL handle_rsvp|%s|%s|%s|",
433 serv_getln(buf, sizeof buf);
436 wprintf("<TABLE BORDER=0><TR><TD>"
437 "<img src=\"static/calarea_48x.gif\" ALIGN=CENTER>"
440 if (!strcasecmp(bstr("sc"), "update")) {
441 wprintf(_("Your calendar has been updated to reflect this RSVP."));
442 } else if (!strcasecmp(bstr("sc"), "ignore")) {
443 wprintf(_("You have chosen to ignore this RSVP. "
444 "Your calendar has <b>not</b> been updated.")
447 wprintf("</TD></TR></TABLE>\n"
450 wprintf("<img src=\"static/error.gif\" ALIGN=CENTER>"
454 wprintf("<a href=\"dotskip?room=");
455 urlescputs(WC->wc_roomname);
456 wprintf("\"><br />");
457 wprintf(_("Return to messages"));
458 wprintf("</A><br />\n");
466 /*-----------------------------------------------------------------------**/
471 * \defgroup MsgDisplayHandlers Display handlers for message reading
472 * \ingroup Calendaring
480 * \brief get items, keep them.
481 * If we're reading calendar items, just store them for now. We have to
482 * sort and re-output them later when we draw the calendar.
483 * \param cal Our calendar to process
484 * \param msgnum number of the mesage in our db
486 void display_individual_cal(icalcomponent *cal, long msgnum) {
490 WC->disp_cal = realloc(WC->disp_cal,
491 (sizeof(struct disp_cal) * WC->num_cal) );
492 WC->disp_cal[WC->num_cal - 1].cal = icalcomponent_new_clone(cal);
494 WC->disp_cal[WC->num_cal - 1].cal_msgnum = msgnum;
501 * Display a task by itself (for editing)
502 * \param supplied_vtodo the todo item we want to edit
503 * \param msgnum number of the mesage in our db
505 void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum) {
506 icalcomponent *vtodo;
508 struct icaltimetype t;
510 int created_new_vtodo = 0;
514 if (supplied_vtodo != NULL) {
515 vtodo = supplied_vtodo;
518 * If we're looking at a fully encapsulated VCALENDAR
519 * rather than a VTODO component, attempt to use the first
520 * relevant VTODO subcomponent. If there is none, the
521 * NULL returned by icalcomponent_get_first_component() will
522 * tell the next iteration of this function to create a
525 if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
526 display_edit_individual_task(
527 icalcomponent_get_first_component(
528 vtodo, ICAL_VTODO_COMPONENT
535 vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT);
536 created_new_vtodo = 1;
539 output_headers(1, 1, 2, 0, 0, 0);
540 wprintf("<div id=\"banner\">\n"
541 "<TABLE class=\"calendar_banner\"><TR>"
542 "<TD><img src=\"static/taskmanag_48x.gif\"></TD>"
543 "<td><SPAN CLASS=\"titlebar\">");
544 wprintf(_("Edit task"));
546 "</TD></TR></TABLE>\n"
547 "</div>\n<div id=\"content\">\n"
550 wprintf("<div class=\"fix_scrollbar_bug\">"
551 "<table class=\"calendar_background\"><tr><td>");
553 wprintf("<FORM METHOD=\"POST\" action=\"save_task\">\n");
554 wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgnum\" VALUE=\"%ld\">\n",
557 wprintf("<TABLE border=0>\n");
560 wprintf(_("Summary:"));
562 "<INPUT TYPE=\"text\" NAME=\"summary\" "
563 "MAXLENGTH=\"64\" SIZE=\"64\" VALUE=\"");
564 p = icalcomponent_get_first_property(vtodo, ICAL_SUMMARY_PROPERTY);
566 escputs((char *)icalproperty_get_comment(p));
568 wprintf("\"></TD></TR>\n");
571 wprintf(_("Start date:"));
572 wprintf("</TD><TD>");
573 p = icalcomponent_get_first_property(vtodo, ICAL_DTSTART_PROPERTY);
575 t = icalproperty_get_dtstart(p);
578 t = icaltime_from_timet(now, 0);
580 display_icaltimetype_as_webform(&t, "dtstart");
581 wprintf("</TD></TR>\n");
584 wprintf(_("Due date:"));
585 wprintf("</TD><TD>");
586 p = icalcomponent_get_first_property(vtodo, ICAL_DUE_PROPERTY);
588 t = icalproperty_get_due(p);
591 t = icaltime_from_timet(now, 0);
593 display_icaltimetype_as_webform(&t, "due");
594 wprintf("</TD></TR>\n");
596 wprintf(_("Description:"));
597 wprintf("</TD><TD>");
598 wprintf("<TEXTAREA NAME=\"description\" wrap=soft "
599 "ROWS=10 COLS=80 WIDTH=80>\n"
601 p = icalcomponent_get_first_property(vtodo, ICAL_DESCRIPTION_PROPERTY);
603 escputs((char *)icalproperty_get_comment(p));
605 wprintf("</TEXTAREA></TD></TR></TABLE>\n");
608 "<INPUT TYPE=\"submit\" NAME=\"save_button\" VALUE=\"%s\">"
610 "<INPUT TYPE=\"submit\" NAME=\"delete_button\" VALUE=\"%s\">\n"
612 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">\n"
619 wprintf("</FORM>\n");
621 wprintf("</td></tr></table></div>\n");
624 if (created_new_vtodo) {
625 icalcomponent_free(vtodo);
630 * \brief Save an edited task
631 * \param supplied_vtodo the task to save
632 * \param msgnum number of the mesage in our db
634 void save_individual_task(icalcomponent *supplied_vtodo, long msgnum) {
636 int delete_existing = 0;
638 icalcomponent *vtodo, *encaps;
639 int created_new_vtodo = 0;
642 struct icaltimetype t;
644 if (supplied_vtodo != NULL) {
645 vtodo = supplied_vtodo;
647 * If we're looking at a fully encapsulated VCALENDAR
648 * rather than a VTODO component, attempt to use the first
649 * relevant VTODO subcomponent. If there is none, the
650 * NULL returned by icalcomponent_get_first_component() will
651 * tell the next iteration of this function to create a
654 if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
655 save_individual_task(
656 icalcomponent_get_first_component(
657 vtodo, ICAL_VTODO_COMPONENT
664 vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT);
665 created_new_vtodo = 1;
668 if (strlen(bstr("save_button")) > 0) {
670 /** Replace values in the component with ones from the form */
672 while (prop = icalcomponent_get_first_property(vtodo,
673 ICAL_SUMMARY_PROPERTY), prop != NULL) {
674 icalcomponent_remove_property(vtodo, prop);
675 icalproperty_free(prop);
677 icalcomponent_add_property(vtodo,
678 icalproperty_new_summary(bstr("summary")));
680 while (prop = icalcomponent_get_first_property(vtodo,
681 ICAL_DESCRIPTION_PROPERTY), prop != NULL) {
682 icalcomponent_remove_property(vtodo, prop);
683 icalproperty_free(prop);
685 icalcomponent_add_property(vtodo,
686 icalproperty_new_description(bstr("description")));
688 while (prop = icalcomponent_get_first_property(vtodo,
689 ICAL_DTSTART_PROPERTY), prop != NULL) {
690 icalcomponent_remove_property(vtodo, prop);
691 icalproperty_free(prop);
693 icaltime_from_webform(&t, "dtstart");
694 icalcomponent_add_property(vtodo,
695 icalproperty_new_dtstart(t)
698 while (prop = icalcomponent_get_first_property(vtodo,
699 ICAL_DUE_PROPERTY), prop != NULL) {
700 icalcomponent_remove_property(vtodo, prop);
701 icalproperty_free(prop);
703 icaltime_from_webform(&t, "due");
704 icalcomponent_add_property(vtodo,
705 icalproperty_new_due(t)
708 /** Give this task a UID if it doesn't have one. */
709 lprintf(9, "Give this task a UID if it doesn't have one.\n");
710 if (icalcomponent_get_first_property(vtodo,
711 ICAL_UID_PROPERTY) == NULL) {
713 icalcomponent_add_property(vtodo,
714 icalproperty_new_uid(buf)
718 /** Increment the sequence ID */
719 lprintf(9, "Increment the sequence ID\n");
720 while (prop = icalcomponent_get_first_property(vtodo,
721 ICAL_SEQUENCE_PROPERTY), (prop != NULL) ) {
722 i = icalproperty_get_sequence(prop);
723 lprintf(9, "Sequence was %d\n", i);
724 if (i > sequence) sequence = i;
725 icalcomponent_remove_property(vtodo, prop);
726 icalproperty_free(prop);
729 lprintf(9, "New sequence is %d. Adding...\n", sequence);
730 icalcomponent_add_property(vtodo,
731 icalproperty_new_sequence(sequence)
735 * Encapsulate event into full VCALENDAR component. Clone it first,
736 * for two reasons: one, it's easier to just free the whole thing
737 * when we're done instead of unbundling, but more importantly, we
738 * can't encapsulate something that may already be encapsulated
741 lprintf(9, "Encapsulating into full VCALENDAR component\n");
742 encaps = ical_encapsulate_subcomponent(icalcomponent_new_clone(vtodo));
744 /* Serialize it and save it to the message base */
745 serv_puts("ENT0 1|||4");
746 serv_getln(buf, sizeof buf);
748 serv_puts("Content-type: text/calendar");
750 serv_puts(icalcomponent_as_ical_string(encaps));
754 * Probably not necessary; the server will see the UID
755 * of the object and delete the old one anyway, but
760 icalcomponent_free(encaps);
764 * If the user clicked 'Delete' then explicitly delete the message.
766 if (strlen(bstr("delete_button")) > 0) {
770 if ( (delete_existing) && (msgnum > 0L) ) {
771 serv_printf("DELE %ld", atol(bstr("msgnum")));
772 serv_getln(buf, sizeof buf);
775 if (created_new_vtodo) {
776 icalcomponent_free(vtodo);
779 /** Go back to the task list */
786 * \brief generic item handler
787 * Code common to all display handlers. Given a message number and a MIME
788 * type, we load the message and hunt for that MIME type. If found, we load
789 * the relevant part, deserialize it into a libical component, filter it for
790 * the requested object type, and feed it to the specified handler.
791 * \param mimetype mimetyp of our object
792 * \param which_kind sort of ical type
793 * \param msgnum number of the mesage in our db
794 * \param callback a funcion \todo
797 void display_using_handler(long msgnum,
799 icalcomponent_kind which_kind,
800 void (*callback)(icalcomponent *, long)
803 char mime_partnum[SIZ];
804 char mime_filename[SIZ];
805 char mime_content_type[SIZ];
806 char mime_disposition[SIZ];
808 char relevant_partnum[SIZ];
809 char *relevant_source = NULL;
810 icalcomponent *cal, *c;
812 sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */
814 serv_getln(buf, sizeof buf);
815 if (buf[0] != '1') return;
817 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
818 if (!strncasecmp(buf, "part=", 5)) {
819 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
820 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
821 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
822 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
823 mime_length = extract_int(&buf[5], 5);
825 if (!strcasecmp(mime_content_type, "text/calendar")) {
826 strcpy(relevant_partnum, mime_partnum);
832 if (strlen(relevant_partnum) > 0) {
833 relevant_source = load_mimepart(msgnum, relevant_partnum);
834 if (relevant_source != NULL) {
836 cal = icalcomponent_new_from_string(relevant_source);
841 /** Simple components of desired type */
842 if (icalcomponent_isa(cal) == which_kind) {
843 callback(cal, msgnum);
846 /** Subcomponents of desired type */
847 for (c = icalcomponent_get_first_component(cal,
850 c = icalcomponent_get_next_component(cal,
854 icalcomponent_free(cal);
856 free(relevant_source);
863 * \brief display whole calendar
864 * \param msgnum number of the mesage in our db
866 void display_calendar(long msgnum) {
867 display_using_handler(msgnum, "text/calendar",
868 ICAL_VEVENT_COMPONENT,
869 display_individual_cal);
873 * \brief display whole taksview
874 * \param msgnum number of the mesage in our db
876 void display_task(long msgnum) {
877 display_using_handler(msgnum, "text/calendar",
878 ICAL_VTODO_COMPONENT,
879 display_individual_cal);
883 * \brief display the editor component for a task
885 void display_edit_task(void) {
888 /** Force change the room if we have to */
889 if (strlen(bstr("taskrm")) > 0) {
890 gotoroom(bstr("taskrm"));
893 msgnum = atol(bstr("msgnum"));
896 display_using_handler(msgnum, "text/calendar",
897 ICAL_VTODO_COMPONENT,
898 display_edit_individual_task);
902 display_edit_individual_task(NULL, 0L);
907 *\brief save an edited task
909 void save_task(void) {
912 msgnum = atol(bstr("msgnum"));
914 display_using_handler(msgnum, "text/calendar",
915 ICAL_VTODO_COMPONENT,
916 save_individual_task);
919 save_individual_task(NULL, 0L);
924 * \brief display the editor component for an event
926 void display_edit_event(void) {
929 msgnum = atol(bstr("msgnum"));
932 display_using_handler(msgnum, "text/calendar",
933 ICAL_VEVENT_COMPONENT,
934 display_edit_individual_event);
938 display_edit_individual_event(NULL, 0L);
943 * \brief save an edited event
945 void save_event(void) {
948 msgnum = atol(bstr("msgnum"));
951 display_using_handler(msgnum, "text/calendar",
952 ICAL_VEVENT_COMPONENT,
953 save_individual_event);
956 save_individual_event(NULL, 0L);
965 * \brief freebusy display (for client software)
966 * \param req dunno. ?????
968 void do_freebusy(char *req) {
973 extract_token(who, req, 1, ' ', sizeof who);
974 if (!strncasecmp(who, "/freebusy/", 10)) {
975 strcpy(who, &who[10]);
979 if ( (!strcasecmp(&who[strlen(who)-4], ".vcf"))
980 || (!strcasecmp(&who[strlen(who)-4], ".ifb"))
981 || (!strcasecmp(&who[strlen(who)-4], ".vfb")) ) {
982 who[strlen(who)-4] = 0;
985 lprintf(9, "freebusy requested for <%s>\n", who);
986 serv_printf("ICAL freebusy|%s", who);
987 serv_getln(buf, sizeof buf);
990 wprintf("HTTP/1.1 404 %s\n", &buf[4]);
991 output_headers(0, 0, 0, 0, 0, 0);
992 wprintf("Content-Type: text/plain\r\n");
994 wprintf("%s\n", &buf[4]);
998 fb = read_server_text();
999 http_transmit_thing(fb, strlen(fb), "text/calendar", 0);
1005 #endif /* WEBCIT_WITH_CALENDAR_SERVICE */