5 * \defgroup calav Functions which handle calendar objects and their processing/display.
6 * \todo parts aren't parsed by doxygen
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);
166 wprintf("<TR><TD><B>");
168 wprintf("</B></TD><TD>"
169 "%s %d, %d</TD></TR>",
175 tt = icaltime_as_timet(t);
176 fmt_date(buf, tt, 0);
177 wprintf("<TR><TD><B>");
178 wprintf(_("Starting date/time:"));
179 wprintf("</B></TD><TD>%s</TD></TR>", buf);
183 p = icalcomponent_get_first_property(cal, ICAL_DTEND_PROPERTY);
185 t = icalproperty_get_dtend(p);
186 tt = icaltime_as_timet(t);
187 fmt_date(buf, tt, 0);
188 wprintf("<TR><TD><B>");
189 wprintf(_("Ending date/time:"));
190 wprintf("</B></TD><TD>%s</TD></TR>", buf);
195 p = icalcomponent_get_first_property(cal, ICAL_DESCRIPTION_PROPERTY);
197 wprintf("<TR><TD><B>");
198 wprintf(_("Description:"));
199 wprintf("</B></TD><TD>");
200 escputs((char *)icalproperty_get_comment(p));
201 wprintf("</TD></TR>\n");
204 /** If the component has attendees, iterate through them. */
205 for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY); (p != NULL); p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) {
206 wprintf("<TR><TD><B>");
207 wprintf(_("Attendee:"));
208 wprintf("</B></TD><TD>");
209 safestrncpy(buf, icalproperty_get_attendee(p), sizeof buf);
210 if (!strncasecmp(buf, "MAILTO:", 7)) {
212 /** screen name or email address */
213 strcpy(buf, &buf[7]);
218 /** participant status */
219 partstat_as_string(buf, p);
222 wprintf("</TD></TR>\n");
225 /** If the component has subcomponents, recurse through them. */
226 for (c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT);
228 c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)) {
229 /* Recursively process subcomponent */
230 cal_process_object(c, recursion_level+1, msgnum, cal_partnum);
233 /** If this is a REQUEST, display conflicts and buttons */
234 if (the_method == ICAL_METHOD_REQUEST) {
236 /* Check for conflicts */
237 lprintf(9, "Checking server calendar for conflicts...\n");
238 serv_printf("ICAL conflicts|%ld|%s|", msgnum, cal_partnum);
239 serv_getln(buf, sizeof buf);
241 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
242 extract_token(conflict_name, buf, 3, '|', sizeof conflict_name);
243 is_update = extract_int(buf, 4);
246 snprintf(conflict_message, sizeof conflict_message,
247 _("This is an update of '%s' which is already in your calendar."), conflict_name);
250 snprintf(conflict_message, sizeof conflict_message,
251 _("This event would conflict with '%s' which is already in your calendar."), conflict_name);
254 wprintf("<TR><TD><B><I>%s</I></B></TD><td>",
260 escputs(conflict_message);
261 wprintf("</TD></TR>\n");
264 lprintf(9, "...done.\n");
266 /** Display the Accept/Decline buttons */
267 wprintf("<TR><TD>How would you like to respond to this invitation?</td>"
269 "<a href=\"respond_to_request?msgnum=%ld&cal_partnum=%s&sc=Accept\">%s</a>"
271 "<a href=\"respond_to_request?msgnum=%ld&cal_partnum=%s&sc=Tentative\">%s</a>"
273 "<a href=\"respond_to_request?msgnum=%ld&cal_partnum=%s&sc=Decline\">%s</a>"
274 "</FONT></TD></TR>\n",
275 msgnum, cal_partnum, _("Accept"),
276 msgnum, cal_partnum, _("Tentative"),
277 msgnum, cal_partnum, _("Decline")
282 /** If this is a REPLY, display update button */
283 if (the_method == ICAL_METHOD_REPLY) {
285 /** \todo In the future, if we want to validate this object before \
286 * continuing, we can do it this way:
287 serv_printf("ICAL whatever|%ld|%s|", msgnum, cal_partnum);
288 serv_getln(buf, sizeof buf);
292 /** Display the update buttons */
295 "</td><td><font size=+1>"
296 "<a href=\"handle_rsvp?msgnum=%ld&cal_partnum=%s&sc=Update\">%s</a>"
298 "<a href=\"handle_rsvp?msgnum=%ld&cal_partnum=%s&sc=Ignore\">%s</a>"
301 _("Click <i>Update</i> to accept this reply and update your calendar."),
302 msgnum, cal_partnum, _("Update"),
303 msgnum, cal_partnum, _("Ignore")
308 /** Trailing HTML for the display of this object */
309 if (recursion_level == 0) {
311 wprintf("</TR></TABLE></CENTER>\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 output_headers(1, 1, 2, 0, 0, 0);
354 wprintf("<div id=\"banner\">\n");
355 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
356 "<SPAN CLASS=\"titlebar\">");
357 wprintf(_("Respond to meeting request"));
359 "</TD></TR></TABLE>\n"
361 wprintf("</div>\n<div id=\"content\">\n");
363 serv_printf("ICAL respond|%s|%s|%s|",
368 serv_getln(buf, sizeof buf);
371 wprintf("<TABLE BORDER=0><TR><TD>"
372 "<img src=\"static/calarea_48x.gif\" ALIGN=CENTER>"
375 if (!strcasecmp(bstr("sc"), "accept")) {
376 wprintf(_("You have accepted this meeting invitation. "
377 "It has been entered into your calendar.")
379 } else if (!strcasecmp(bstr("sc"), "tentative")) {
380 wprintf(_("You have tentatively accepted this meeting invitation. "
381 "It has been 'pencilled in' to your calendar.")
383 } else if (!strcasecmp(bstr("sc"), "decline")) {
384 wprintf(_("You have declined this meeting invitation. "
385 "It has <b>not</b> been entered into your calendar.")
389 wprintf(_("A reply has been sent to the meeting organizer."));
390 wprintf("</TD></TR></TABLE>\n");
392 wprintf("<img src=\"static/error.gif\" ALIGN=CENTER>"
396 wprintf("<a href=\"dotskip?room=");
397 urlescputs(WC->wc_roomname);
398 wprintf("\"><br />");
399 wprintf(_("Return to messages"));
400 wprintf("</A><br />\n");
408 * \brief Handle an incoming RSVP
410 void handle_rsvp(void) {
413 output_headers(1, 1, 2, 0, 0, 0);
415 wprintf("<div id=\"banner\">\n");
416 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
417 "<SPAN CLASS=\"titlebar\">");
418 wprintf(_("Update your calendar with this RSVP"));
420 "</TD></TR></TABLE>\n"
421 "</div>\n<div id=\"content\">\n"
424 serv_printf("ICAL handle_rsvp|%s|%s|%s|",
429 serv_getln(buf, sizeof buf);
432 wprintf("<TABLE BORDER=0><TR><TD>"
433 "<img src=\"static/calarea_48x.gif\" ALIGN=CENTER>"
436 if (!strcasecmp(bstr("sc"), "update")) {
437 wprintf(_("Your calendar has been updated to reflect this RSVP."));
438 } else if (!strcasecmp(bstr("sc"), "ignore")) {
439 wprintf(_("You have chosen to ignore this RSVP. "
440 "Your calendar has <b>not</b> been updated.")
443 wprintf("</TD></TR></TABLE>\n"
446 wprintf("<img src=\"static/error.gif\" ALIGN=CENTER>"
450 wprintf("<a href=\"dotskip?room=");
451 urlescputs(WC->wc_roomname);
452 wprintf("\"><br />");
453 wprintf(_("Return to messages"));
454 wprintf("</A><br />\n");
462 /*-----------------------------------------------------------------------**/
467 * \defgroup MsgDisplayHandlers Display handlers for message reading
468 * \todo why does doxygen not parse this? and generate another group?
476 * \brief get items, keep them.
477 * If we're reading calendar items, just store them for now. We have to
478 * sort and re-output them later when we draw the calendar.
479 * \param cal Our calendar to process
480 * \param msgnum number of the mesage in our db
482 void display_individual_cal(icalcomponent *cal, long msgnum) {
486 WC->disp_cal = realloc(WC->disp_cal,
487 (sizeof(struct disp_cal) * WC->num_cal) );
488 WC->disp_cal[WC->num_cal - 1].cal = icalcomponent_new_clone(cal);
490 WC->disp_cal[WC->num_cal - 1].cal_msgnum = msgnum;
497 * Display a task by itself (for editing)
498 * \param supplied_vtodo the todo item we want to edit
499 * \param msgnum number of the mesage in our db
501 void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum) {
502 icalcomponent *vtodo;
504 struct icaltimetype t;
506 int created_new_vtodo = 0;
510 if (supplied_vtodo != NULL) {
511 vtodo = supplied_vtodo;
514 * If we're looking at a fully encapsulated VCALENDAR
515 * rather than a VTODO component, attempt to use the first
516 * relevant VTODO subcomponent. If there is none, the
517 * NULL returned by icalcomponent_get_first_component() will
518 * tell the next iteration of this function to create a
521 if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
522 display_edit_individual_task(
523 icalcomponent_get_first_component(
524 vtodo, ICAL_VTODO_COMPONENT
531 vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT);
532 created_new_vtodo = 1;
535 output_headers(1, 1, 2, 0, 0, 0);
536 wprintf("<div id=\"banner\">\n"
537 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR>"
538 "<TD><img src=\"static/taskmanag_48x.gif\"></TD>"
539 "<td><SPAN CLASS=\"titlebar\">");
540 wprintf(_("Edit task"));
542 "</TD></TR></TABLE>\n"
543 "</div>\n<div id=\"content\">\n"
546 wprintf("<div class=\"fix_scrollbar_bug\">"
547 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>");
549 wprintf("<FORM METHOD=\"POST\" action=\"save_task\">\n");
550 wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgnum\" VALUE=\"%ld\">\n",
553 wprintf("<TABLE border=0>\n");
556 wprintf(_("Summary:"));
558 "<INPUT TYPE=\"text\" NAME=\"summary\" "
559 "MAXLENGTH=\"64\" SIZE=\"64\" VALUE=\"");
560 p = icalcomponent_get_first_property(vtodo, ICAL_SUMMARY_PROPERTY);
562 escputs((char *)icalproperty_get_comment(p));
564 wprintf("\"></TD></TR>\n");
567 wprintf(_("Start date:"));
568 wprintf("</TD><TD>");
569 p = icalcomponent_get_first_property(vtodo, ICAL_DTSTART_PROPERTY);
571 t = icalproperty_get_dtstart(p);
574 t = icaltime_from_timet(now, 0);
576 display_icaltimetype_as_webform(&t, "dtstart");
577 wprintf("</TD></TR>\n");
580 wprintf(_("Due date:"));
581 wprintf("</TD><TD>");
582 p = icalcomponent_get_first_property(vtodo, ICAL_DUE_PROPERTY);
584 t = icalproperty_get_due(p);
587 t = icaltime_from_timet(now, 0);
589 display_icaltimetype_as_webform(&t, "due");
590 wprintf("</TD></TR>\n");
592 wprintf(_("Description:"));
593 wprintf("</TD><TD>");
594 wprintf("<TEXTAREA NAME=\"description\" wrap=soft "
595 "ROWS=10 COLS=80 WIDTH=80>\n"
597 p = icalcomponent_get_first_property(vtodo, ICAL_DESCRIPTION_PROPERTY);
599 escputs((char *)icalproperty_get_comment(p));
601 wprintf("</TEXTAREA></TD></TR></TABLE>\n");
604 "<INPUT TYPE=\"submit\" NAME=\"save_button\" VALUE=\"%s\">"
606 "<INPUT TYPE=\"submit\" NAME=\"delete_button\" VALUE=\"%s\">\n"
608 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">\n"
615 wprintf("</FORM>\n");
617 wprintf("</td></tr></table></div>\n");
620 if (created_new_vtodo) {
621 icalcomponent_free(vtodo);
626 * \brief Save an edited task
627 * \param supplied_vtodo the task to save
628 * \param msgnum number of the mesage in our db
630 void save_individual_task(icalcomponent *supplied_vtodo, long msgnum) {
632 int delete_existing = 0;
634 icalcomponent *vtodo, *encaps;
635 int created_new_vtodo = 0;
638 struct icaltimetype t;
640 if (supplied_vtodo != NULL) {
641 vtodo = supplied_vtodo;
643 * If we're looking at a fully encapsulated VCALENDAR
644 * rather than a VTODO component, attempt to use the first
645 * relevant VTODO subcomponent. If there is none, the
646 * NULL returned by icalcomponent_get_first_component() will
647 * tell the next iteration of this function to create a
650 if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
651 save_individual_task(
652 icalcomponent_get_first_component(
653 vtodo, ICAL_VTODO_COMPONENT
660 vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT);
661 created_new_vtodo = 1;
664 if (strlen(bstr("save_button")) > 0) {
666 /** Replace values in the component with ones from the form */
668 while (prop = icalcomponent_get_first_property(vtodo,
669 ICAL_SUMMARY_PROPERTY), prop != NULL) {
670 icalcomponent_remove_property(vtodo, prop);
671 icalproperty_free(prop);
673 icalcomponent_add_property(vtodo,
674 icalproperty_new_summary(bstr("summary")));
676 while (prop = icalcomponent_get_first_property(vtodo,
677 ICAL_DESCRIPTION_PROPERTY), prop != NULL) {
678 icalcomponent_remove_property(vtodo, prop);
679 icalproperty_free(prop);
681 icalcomponent_add_property(vtodo,
682 icalproperty_new_description(bstr("description")));
684 while (prop = icalcomponent_get_first_property(vtodo,
685 ICAL_DTSTART_PROPERTY), prop != NULL) {
686 icalcomponent_remove_property(vtodo, prop);
687 icalproperty_free(prop);
689 icaltime_from_webform(&t, "dtstart");
690 icalcomponent_add_property(vtodo,
691 icalproperty_new_dtstart(t)
694 while (prop = icalcomponent_get_first_property(vtodo,
695 ICAL_DUE_PROPERTY), prop != NULL) {
696 icalcomponent_remove_property(vtodo, prop);
697 icalproperty_free(prop);
699 icaltime_from_webform(&t, "due");
700 icalcomponent_add_property(vtodo,
701 icalproperty_new_due(t)
704 /** Give this task a UID if it doesn't have one. */
705 lprintf(9, "Give this task a UID if it doesn't have one.\n");
706 if (icalcomponent_get_first_property(vtodo,
707 ICAL_UID_PROPERTY) == NULL) {
709 icalcomponent_add_property(vtodo,
710 icalproperty_new_uid(buf)
714 /** Increment the sequence ID */
715 lprintf(9, "Increment the sequence ID\n");
716 while (prop = icalcomponent_get_first_property(vtodo,
717 ICAL_SEQUENCE_PROPERTY), (prop != NULL) ) {
718 i = icalproperty_get_sequence(prop);
719 lprintf(9, "Sequence was %d\n", i);
720 if (i > sequence) sequence = i;
721 icalcomponent_remove_property(vtodo, prop);
722 icalproperty_free(prop);
725 lprintf(9, "New sequence is %d. Adding...\n", sequence);
726 icalcomponent_add_property(vtodo,
727 icalproperty_new_sequence(sequence)
731 * Encapsulate event into full VCALENDAR component. Clone it first,
732 * for two reasons: one, it's easier to just free the whole thing
733 * when we're done instead of unbundling, but more importantly, we
734 * can't encapsulate something that may already be encapsulated
737 lprintf(9, "Encapsulating into full VCALENDAR component\n");
738 encaps = ical_encapsulate_subcomponent(icalcomponent_new_clone(vtodo));
740 /* Serialize it and save it to the message base */
741 serv_puts("ENT0 1|||4");
742 serv_getln(buf, sizeof buf);
744 serv_puts("Content-type: text/calendar");
746 serv_puts(icalcomponent_as_ical_string(encaps));
750 * Probably not necessary; the server will see the UID
751 * of the object and delete the old one anyway, but
756 icalcomponent_free(encaps);
760 * If the user clicked 'Delete' then explicitly delete the message.
762 if (strlen(bstr("delete_button")) > 0) {
766 if ( (delete_existing) && (msgnum > 0L) ) {
767 serv_printf("DELE %ld", atol(bstr("msgnum")));
768 serv_getln(buf, sizeof buf);
771 if (created_new_vtodo) {
772 icalcomponent_free(vtodo);
775 /** Go back to the task list */
782 * \brief generic item handler
783 * Code common to all display handlers. Given a message number and a MIME
784 * type, we load the message and hunt for that MIME type. If found, we load
785 * the relevant part, deserialize it into a libical component, filter it for
786 * the requested object type, and feed it to the specified handler.
787 * \param mimetype mimetyp of our object
788 * \param which_kind sort of ical type
789 * \param msgnum number of the mesage in our db
790 * \param callback a funcion \todo
793 void display_using_handler(long msgnum,
795 icalcomponent_kind which_kind,
796 void (*callback)(icalcomponent *, long)
799 char mime_partnum[SIZ];
800 char mime_filename[SIZ];
801 char mime_content_type[SIZ];
802 char mime_disposition[SIZ];
804 char relevant_partnum[SIZ];
805 char *relevant_source = NULL;
806 icalcomponent *cal, *c;
808 sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */
810 serv_getln(buf, sizeof buf);
811 if (buf[0] != '1') return;
813 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
814 if (!strncasecmp(buf, "part=", 5)) {
815 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
816 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
817 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
818 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
819 mime_length = extract_int(&buf[5], 5);
821 if (!strcasecmp(mime_content_type, "text/calendar")) {
822 strcpy(relevant_partnum, mime_partnum);
828 if (strlen(relevant_partnum) > 0) {
829 relevant_source = load_mimepart(msgnum, relevant_partnum);
830 if (relevant_source != NULL) {
832 cal = icalcomponent_new_from_string(relevant_source);
837 /** Simple components of desired type */
838 if (icalcomponent_isa(cal) == which_kind) {
839 callback(cal, msgnum);
842 /** Subcomponents of desired type */
843 for (c = icalcomponent_get_first_component(cal,
846 c = icalcomponent_get_next_component(cal,
850 icalcomponent_free(cal);
852 free(relevant_source);
859 * \brief display whole calendar
860 * \param msgnum number of the mesage in our db
862 void display_calendar(long msgnum) {
863 display_using_handler(msgnum, "text/calendar",
864 ICAL_VEVENT_COMPONENT,
865 display_individual_cal);
869 * \brief display whole taksview
870 * \param msgnum number of the mesage in our db
872 void display_task(long msgnum) {
873 display_using_handler(msgnum, "text/calendar",
874 ICAL_VTODO_COMPONENT,
875 display_individual_cal);
879 * \brief display the editor component for a task
881 void display_edit_task(void) {
884 /** Force change the room if we have to */
885 if (strlen(bstr("taskrm")) > 0) {
886 gotoroom(bstr("taskrm"));
889 msgnum = atol(bstr("msgnum"));
892 display_using_handler(msgnum, "text/calendar",
893 ICAL_VTODO_COMPONENT,
894 display_edit_individual_task);
898 display_edit_individual_task(NULL, 0L);
903 *\brief save an edited task
905 void save_task(void) {
908 msgnum = atol(bstr("msgnum"));
910 display_using_handler(msgnum, "text/calendar",
911 ICAL_VTODO_COMPONENT,
912 save_individual_task);
915 save_individual_task(NULL, 0L);
920 * \brief display the editor component for an event
922 void display_edit_event(void) {
925 msgnum = atol(bstr("msgnum"));
928 display_using_handler(msgnum, "text/calendar",
929 ICAL_VEVENT_COMPONENT,
930 display_edit_individual_event);
934 display_edit_individual_event(NULL, 0L);
939 * \brief save an edited event
941 void save_event(void) {
944 msgnum = atol(bstr("msgnum"));
947 display_using_handler(msgnum, "text/calendar",
948 ICAL_VEVENT_COMPONENT,
949 save_individual_event);
952 save_individual_event(NULL, 0L);
961 * \brief freebusy display (for client software)
962 * \param req dunno. ?????
964 void do_freebusy(char *req) {
969 extract_token(who, req, 1, ' ', sizeof who);
970 if (!strncasecmp(who, "/freebusy/", 10)) {
971 strcpy(who, &who[10]);
975 if ( (!strcasecmp(&who[strlen(who)-4], ".vcf"))
976 || (!strcasecmp(&who[strlen(who)-4], ".ifb"))
977 || (!strcasecmp(&who[strlen(who)-4], ".vfb")) ) {
978 who[strlen(who)-4] = 0;
981 lprintf(9, "freebusy requested for <%s>\n", who);
982 serv_printf("ICAL freebusy|%s", who);
983 serv_getln(buf, sizeof buf);
986 wprintf("HTTP/1.1 404 %s\n", &buf[4]);
987 output_headers(0, 0, 0, 0, 0, 0);
988 wprintf("Content-Type: text/plain\r\n");
990 wprintf("%s\n", &buf[4]);
994 fb = read_server_text();
995 http_transmit_thing(fb, strlen(fb), "text/calendar", 0);
1001 #endif /* WEBCIT_WITH_CALENDAR_SERVICE */