4 * Functions which handle calendar objects and their processing/display.
12 * \brief Process a calendar object
13 * ...at this point it's already been deserialized by cal_process_attachment()
14 * \param cal the calendar object
15 * \param recursion_level call stack depth ??????
16 * \param msgnum number of the mesage in our db
17 * \param cal_partnum of the calendar object ????
19 void cal_process_object(icalcomponent *cal,
25 icalproperty *method = NULL;
26 icalproperty_method the_method = ICAL_METHOD_NONE;
28 struct icaltimetype t;
31 char conflict_name[256];
32 char conflict_message[256];
35 static int divcount = 0;
37 sprintf(divname, "rsvp%04x", ++divcount);
39 /** Leading HTML for the display of this object */
40 if (recursion_level == 0) {
41 wprintf("<div class=\"mimepart\">\n");
44 /** Look for a method */
45 method = icalcomponent_get_first_property(cal, ICAL_METHOD_PROPERTY);
47 /** See what we need to do with this */
49 the_method = icalproperty_get_method(method);
52 wprintf("<div id=\"%s_title\">", divname);
53 wprintf("<img src=\"static/calarea_48x.gif\">");
56 case ICAL_METHOD_REQUEST:
57 title = _("Meeting invitation");
59 case ICAL_METHOD_REPLY:
60 title = _("Attendee's reply to your invitation");
62 case ICAL_METHOD_PUBLISH:
63 title = _("Published event");
66 title = _("This is an unknown type of calendar item.");
71 wprintf(" %s",title);
76 p = icalcomponent_get_first_property(cal, ICAL_SUMMARY_PROPERTY);
79 wprintf(_("Summary:"));
81 escputs((char *)icalproperty_get_comment(p));
85 p = icalcomponent_get_first_property(cal, ICAL_LOCATION_PROPERTY);
88 wprintf(_("Location:"));
90 escputs((char *)icalproperty_get_comment(p));
95 * Only show start/end times if we're actually looking at the VEVENT
96 * component. Otherwise it shows bogus dates for things like timezone.
98 if (icalcomponent_isa(cal) == ICAL_VEVENT_COMPONENT) {
100 p = icalcomponent_get_first_property(cal,
101 ICAL_DTSTART_PROPERTY);
103 t = icalproperty_get_dtstart(p);
108 memset(&d_tm, 0, sizeof d_tm);
109 d_tm.tm_year = t.year - 1900;
110 d_tm.tm_mon = t.month - 1;
111 d_tm.tm_mday = t.day;
112 wc_strftime(d_str, sizeof d_str, "%x", &d_tm);
115 wprintf("</dt><dd>%s</dd>", d_str);
118 tt = icaltime_as_timet(t);
119 webcit_fmt_date(buf, tt, 0);
121 wprintf(_("Starting date/time:"));
122 wprintf("</dt><dd>%s</dd>", buf);
126 p = icalcomponent_get_first_property(cal, ICAL_DTEND_PROPERTY);
128 t = icalproperty_get_dtend(p);
129 tt = icaltime_as_timet(t);
130 webcit_fmt_date(buf, tt, 0);
132 wprintf(_("Ending date/time:"));
133 wprintf("</dt><dd>%s</dd>", buf);
138 p = icalcomponent_get_first_property(cal, ICAL_DESCRIPTION_PROPERTY);
141 wprintf(_("Description:"));
142 wprintf("</dt><dd>");
143 escputs((char *)icalproperty_get_comment(p));
147 /** If the component has attendees, iterate through them. */
148 for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY);
150 p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) {
152 wprintf(_("Attendee:"));
153 wprintf("</dt><dd>");
154 safestrncpy(buf, icalproperty_get_attendee(p), sizeof buf);
155 if (!strncasecmp(buf, "MAILTO:", 7)) {
157 /** screen name or email address */
158 strcpy(buf, &buf[7]);
163 /** participant status */
164 partstat_as_string(buf, p);
170 /** If the component has subcomponents, recurse through them. */
171 for (c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT);
173 c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)) {
174 /* Recursively process subcomponent */
175 cal_process_object(c, recursion_level+1, msgnum, cal_partnum);
178 /** If this is a REQUEST, display conflicts and buttons */
179 if (the_method == ICAL_METHOD_REQUEST) {
181 /* Check for conflicts */
182 lprintf(9, "Checking server calendar for conflicts...\n");
183 serv_printf("ICAL conflicts|%ld|%s|", msgnum, cal_partnum);
184 serv_getln(buf, sizeof buf);
186 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
187 extract_token(conflict_name, buf, 3, '|', sizeof conflict_name);
188 is_update = extract_int(buf, 4);
191 snprintf(conflict_message, sizeof conflict_message,
192 _("This is an update of '%s' which is already in your calendar."), conflict_name);
195 snprintf(conflict_message, sizeof conflict_message,
196 _("This event would conflict with '%s' which is already in your calendar."), conflict_name);
205 wprintf("</dt><dd>");
206 escputs(conflict_message);
210 lprintf(9, "...done.\n");
214 /** Display the Accept/Decline buttons */
215 wprintf("<p id=\"%s_question\">"
217 " <span class=\"button_link\"> "
218 "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Accept');\">%s</a>"
219 "</span> <span class=\"button_link\">"
220 "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Tentative');\">%s</a>"
221 "</span> <span class=\"button_link\">"
222 "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Decline');\">%s</a>"
225 _("How would you like to respond to this invitation?"),
226 divname, divname, msgnum, cal_partnum, _("Accept"),
227 divname, divname, msgnum, cal_partnum, _("Tentative"),
228 divname, divname, msgnum, cal_partnum, _("Decline")
233 /** If this is a REPLY, display update button */
234 if (the_method == ICAL_METHOD_REPLY) {
236 /** \todo In the future, if we want to validate this object before \
237 * continuing, we can do it this way:
238 serv_printf("ICAL whatever|%ld|%s|", msgnum, cal_partnum);
239 serv_getln(buf, sizeof buf);
243 /** Display the update buttons */
244 wprintf("<p id=\"%s_question\" >"
246 " <span class=\"button_link\"> "
247 "<a href=\"javascript:HandleRSVP('%s_question','%s_title','%ld','%s','Update');\">%s</a>"
248 "</span> <span class=\"button_link\">"
249 "<a href=\"javascript:HandleRSVP('%s_question','%s_title','%ld','%s','Ignore');\">%s</a>"
252 _("Click <i>Update</i> to accept this reply and update your calendar."),
253 divname, divname, msgnum, cal_partnum, _("Update"),
254 divname, divname, msgnum, cal_partnum, _("Ignore")
259 /** Trailing HTML for the display of this object */
260 if (recursion_level == 0) {
261 wprintf("<p> </p></div>\n");
267 * \brief process calendar mail atachment
268 * Deserialize a calendar object in a message so it can be processed.
269 * (This is the main entry point for these things)
270 * \param part_source the part of the message we want to parse
271 * \param msgnum number of the mesage in our db
272 * \param cal_partnum the number of the calendar item
274 void cal_process_attachment(char *part_source, long msgnum, char *cal_partnum)
278 cal = icalcomponent_new_from_string(part_source);
281 wprintf(_("There was an error parsing this calendar item."));
287 cal_process_object(cal, 0, msgnum, cal_partnum);
289 /* Free the memory we obtained from libical's constructor */
290 icalcomponent_free(cal);
297 * \brief accept/decline meeting
298 * Respond to a meeting request
300 void respond_to_request(void)
304 begin_ajax_response();
306 serv_printf("ICAL respond|%s|%s|%s|",
311 serv_getln(buf, sizeof buf);
314 wprintf("<img src=\"static/calarea_48x.gif\"><span>");
315 if (!strcasecmp(bstr("sc"), "accept")) {
316 wprintf(_("You have accepted this meeting invitation. "
317 "It has been entered into your calendar.")
319 } else if (!strcasecmp(bstr("sc"), "tentative")) {
320 wprintf(_("You have tentatively accepted this meeting invitation. "
321 "It has been 'pencilled in' to your calendar.")
323 } else if (!strcasecmp(bstr("sc"), "decline")) {
324 wprintf(_("You have declined this meeting invitation. "
325 "It has <b>not</b> been entered into your calendar.")
329 wprintf(_("A reply has been sent to the meeting organizer."));
332 wprintf("<img align=\"center\" src=\"static/error.gif\"><span>");
333 wprintf("%s\n", &buf[4]);
343 * \brief Handle an incoming RSVP
345 void handle_rsvp(void)
349 begin_ajax_response();
351 serv_printf("ICAL handle_rsvp|%s|%s|%s|",
356 serv_getln(buf, sizeof buf);
359 wprintf("<img src=\"static/calarea_48x.gif\"><span>");
360 if (!strcasecmp(bstr("sc"), "update")) {
361 wprintf(_("Your calendar has been updated to reflect this RSVP."));
362 } else if (!strcasecmp(bstr("sc"), "ignore")) {
363 wprintf(_("You have chosen to ignore this RSVP. "
364 "Your calendar has <b>not</b> been updated.")
369 wprintf("<img src=\"static/error.gif\"><span> %s\n", &buf[4]);
379 /*-----------------------------------------------------------------------**/
384 * \defgroup MsgDisplayHandlers Display handlers for message reading
385 * \ingroup Calendaring
393 * \brief get items, keep them.
394 * If we're reading calendar items, just store them for now. We have to
395 * sort and re-output them later when we draw the calendar.
396 * \param cal Our calendar to process
397 * \param msgnum number of the mesage in our db
399 void display_individual_cal(icalcomponent *cal, long msgnum, char *from, int unread)
401 struct wcsession *WCC = WC; /* stack this for faster access (WC is a function) */
404 WCC->disp_cal = realloc(WC->disp_cal, (sizeof(struct disp_cal) * WCC->num_cal) );
405 WCC->disp_cal[WCC->num_cal - 1].cal = icalcomponent_new_clone(cal);
406 WCC->disp_cal[WCC->num_cal - 1].unread = unread;
407 WCC->disp_cal[WCC->num_cal - 1].from = malloc (strlen(from) + 1);
408 strcpy (WCC->disp_cal[WCC->num_cal - 1].from, from);
409 ical_dezonify(WCC->disp_cal[WCC->num_cal - 1].cal);
410 WCC->disp_cal[WCC->num_cal - 1].cal_msgnum = msgnum;
417 * Display a task by itself (for editing)
418 * \param supplied_vtodo the todo item we want to edit
419 * \param msgnum number of the mesage in our db
421 void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, char *from, int unread)
423 icalcomponent *vtodo;
425 struct icaltimetype IcalTime;
427 int created_new_vtodo = 0;
428 icalproperty_status todoStatus;
432 if (supplied_vtodo != NULL) {
433 vtodo = supplied_vtodo;
436 * If we're looking at a fully encapsulated VCALENDAR
437 * rather than a VTODO component, attempt to use the first
438 * relevant VTODO subcomponent. If there is none, the
439 * NULL returned by icalcomponent_get_first_component() will
440 * tell the next iteration of this function to create a
443 if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
444 display_edit_individual_task(
445 icalcomponent_get_first_component(
446 vtodo, ICAL_VTODO_COMPONENT
455 vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT);
456 created_new_vtodo = 1;
459 // TODO: Can we take all this and move it into a template?
460 output_headers(1, 1, 1, 0, 0, 0);
461 wprintf("<!-- start task edit form -->");
462 p = icalcomponent_get_first_property(vtodo, ICAL_SUMMARY_PROPERTY);
463 // Get summary early for title
464 wprintf("<div class=\"box\">\n");
465 wprintf("<div class=\"boxlabel\">");
466 wprintf(_("Edit task"));
469 escputs((char *)icalproperty_get_comment(p));
473 wprintf("<div class=\"boxcontent\">\n");
474 wprintf("<FORM METHOD=\"POST\" action=\"save_task\">\n");
475 wprintf("<div style=\"display: none;\">\n ");
476 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
477 wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgnum\" VALUE=\"%ld\">\n",
480 wprintf("<table class=\"calendar_background\"><tr><td>");
481 wprintf("<TABLE STYLE=\"border: none;\">\n");
484 wprintf(_("Summary:"));
486 "<INPUT TYPE=\"text\" NAME=\"summary\" "
487 "MAXLENGTH=\"64\" SIZE=\"64\" VALUE=\"");
488 p = icalcomponent_get_first_property(vtodo, ICAL_SUMMARY_PROPERTY);
490 escputs((char *)icalproperty_get_comment(p));
492 wprintf("\"></TD></TR>\n");
495 wprintf(_("Start date:"));
496 wprintf("</TD><TD>");
497 p = icalcomponent_get_first_property(vtodo, ICAL_DTSTART_PROPERTY);
498 wprintf("<INPUT TYPE=\"CHECKBOX\" NAME=\"nodtstart\" ID=\"nodtstart\" VALUE=\"NODTSTART\" ");
500 wprintf("CHECKED=\"CHECKED\"");
503 wprintf(_("No date"));
509 IcalTime = icalproperty_get_dtstart(p);
512 IcalTime = icaltime_current_time_with_zone(get_default_icaltimezone());
513 display_icaltimetype_as_webform(&IcalTime, "dtstart");
514 wprintf("</TD></TR>\n");
517 wprintf(_("Due date:"));
518 wprintf("</TD><TD>");
519 p = icalcomponent_get_first_property(vtodo, ICAL_DUE_PROPERTY);
520 wprintf("<INPUT TYPE=\"CHECKBOX\" NAME=\"nodue\" ID=\"nodue\" VALUE=\"NODUE\"");
522 wprintf("CHECKED=\"CHECKED\"");
525 wprintf(_("No date"));
530 IcalTime = icalproperty_get_due(p);
533 IcalTime = icaltime_current_time_with_zone(get_default_icaltimezone());
534 display_icaltimetype_as_webform(&IcalTime, "due");
536 wprintf("</TD></TR>\n");
537 todoStatus = icalcomponent_get_status(vtodo);
538 wprintf("<TR><TD>\n");
539 wprintf(_("Completed:"));
540 wprintf("</TD><TD>");
541 wprintf("<INPUT TYPE=\"CHECKBOX\" NAME=\"STATUS\" VALUE=\"COMPLETED\"");
542 if (todoStatus == ICAL_STATUS_COMPLETED) {
543 wprintf(" CHECKED=\"CHECKED\"");
546 wprintf("</TD></TR>");
547 // start category field
548 p = icalcomponent_get_first_property(vtodo, ICAL_CATEGORIES_PROPERTY);
550 wprintf(_("Category:"));
551 wprintf("</TD><TD>");
552 wprintf("<INPUT TYPE=\"text\" NAME=\"category\" MAXLENGTH=\"32\" SIZE=\"32\" VALUE=\"");
554 escputs((char *)icalproperty_get_categories(p));
557 wprintf("</TD></TR>\n ");
558 // end category field
560 wprintf(_("Description:"));
561 wprintf("</TD><TD>");
562 wprintf("<TEXTAREA NAME=\"description\" "
563 "ROWS=\"10\" COLS=\"80\">\n"
565 p = icalcomponent_get_first_property(vtodo, ICAL_DESCRIPTION_PROPERTY);
567 escputs((char *)icalproperty_get_comment(p));
569 wprintf("</TEXTAREA></TD></TR></TABLE>\n");
571 wprintf("<SPAN STYLE=\"text-align: center;\">"
572 "<INPUT TYPE=\"submit\" NAME=\"save_button\" VALUE=\"%s\">"
574 "<INPUT TYPE=\"submit\" NAME=\"delete_button\" VALUE=\"%s\">\n"
576 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">\n"
582 wprintf("</td></tr></table>");
583 wprintf("</FORM>\n");
584 wprintf("</div></div></div>\n");
585 wprintf("<!-- end task edit form -->");
588 if (created_new_vtodo) {
589 icalcomponent_free(vtodo);
594 * \brief Save an edited task
595 * \param supplied_vtodo the task to save
596 * \param msgnum number of the mesage in our db
598 void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from, int unread)
601 int delete_existing = 0;
603 icalcomponent *vtodo, *encaps;
604 int created_new_vtodo = 0;
607 struct icaltimetype t;
609 if (supplied_vtodo != NULL) {
610 vtodo = supplied_vtodo;
612 * If we're looking at a fully encapsulated VCALENDAR
613 * rather than a VTODO component, attempt to use the first
614 * relevant VTODO subcomponent. If there is none, the
615 * NULL returned by icalcomponent_get_first_component() will
616 * tell the next iteration of this function to create a
619 if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
620 save_individual_task(
621 icalcomponent_get_first_component(
622 vtodo, ICAL_VTODO_COMPONENT),
629 vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT);
630 created_new_vtodo = 1;
633 if (havebstr("save_button")) {
635 /** Replace values in the component with ones from the form */
637 while (prop = icalcomponent_get_first_property(vtodo,
638 ICAL_SUMMARY_PROPERTY), prop != NULL) {
639 icalcomponent_remove_property(vtodo, prop);
640 icalproperty_free(prop);
642 if (havebstr("summary")) {
644 icalcomponent_add_property(vtodo,
645 icalproperty_new_summary(bstr("summary")));
647 icalcomponent_add_property(vtodo,
648 icalproperty_new_summary("Untitled Task"));
651 while (prop = icalcomponent_get_first_property(vtodo,
652 ICAL_DESCRIPTION_PROPERTY), prop != NULL) {
653 icalcomponent_remove_property(vtodo, prop);
654 icalproperty_free(prop);
656 if (!IsEmptyStr(bstr("description"))) {
657 icalcomponent_add_property(vtodo,
658 icalproperty_new_description(bstr("description")));
661 while (prop = icalcomponent_get_first_property(vtodo,
662 ICAL_DTSTART_PROPERTY), prop != NULL) {
663 icalcomponent_remove_property(vtodo, prop);
664 icalproperty_free(prop);
666 if (IsEmptyStr(bstr("nodtstart"))) {
667 icaltime_from_webform(&t, "dtstart");
668 icalcomponent_add_property(vtodo,
669 icalproperty_new_dtstart(t)
672 while(prop = icalcomponent_get_first_property(vtodo,
673 ICAL_STATUS_PROPERTY), prop != NULL) {
674 icalcomponent_remove_property(vtodo,prop);
675 icalproperty_free(prop);
677 if (!IsEmptyStr(bstr("status"))) {
678 icalproperty_status taskStatus = icalproperty_string_to_status(
680 icalcomponent_set_status(vtodo, taskStatus);
682 while (prop = icalcomponent_get_first_property(vtodo,
683 ICAL_CATEGORIES_PROPERTY), prop != NULL) {
684 icalcomponent_remove_property(vtodo,prop);
685 icalproperty_free(prop);
687 if (!IsEmptyStr(bstr("category"))) {
688 prop = icalproperty_new_categories(bstr("category"));
689 icalcomponent_add_property(vtodo,prop);
691 while (prop = icalcomponent_get_first_property(vtodo,
692 ICAL_DUE_PROPERTY), prop != NULL) {
693 icalcomponent_remove_property(vtodo, prop);
694 icalproperty_free(prop);
696 if (IsEmptyStr(bstr("nodue"))) {
697 icaltime_from_webform(&t, "due");
698 icalcomponent_add_property(vtodo,
699 icalproperty_new_due(t)
702 /** Give this task a UID if it doesn't have one. */
703 lprintf(9, "Give this task a UID if it doesn't have one.\n");
704 if (icalcomponent_get_first_property(vtodo,
705 ICAL_UID_PROPERTY) == NULL) {
707 icalcomponent_add_property(vtodo,
708 icalproperty_new_uid(buf)
712 /** Increment the sequence ID */
713 lprintf(9, "Increment the sequence ID\n");
714 while (prop = icalcomponent_get_first_property(vtodo,
715 ICAL_SEQUENCE_PROPERTY), (prop != NULL) ) {
716 i = icalproperty_get_sequence(prop);
717 lprintf(9, "Sequence was %d\n", i);
718 if (i > sequence) sequence = i;
719 icalcomponent_remove_property(vtodo, prop);
720 icalproperty_free(prop);
723 lprintf(9, "New sequence is %d. Adding...\n", sequence);
724 icalcomponent_add_property(vtodo,
725 icalproperty_new_sequence(sequence)
729 * Encapsulate event into full VCALENDAR component. Clone it first,
730 * for two reasons: one, it's easier to just free the whole thing
731 * when we're done instead of unbundling, but more importantly, we
732 * can't encapsulate something that may already be encapsulated
735 lprintf(9, "Encapsulating into a full VCALENDAR component\n");
736 encaps = ical_encapsulate_subcomponent(icalcomponent_new_clone(vtodo));
738 /* Serialize it and save it to the message base */
739 serv_puts("ENT0 1|||4");
740 serv_getln(buf, sizeof buf);
742 serv_puts("Content-type: text/calendar");
744 serv_puts(icalcomponent_as_ical_string(encaps));
748 * Probably not necessary; the server will see the UID
749 * of the object and delete the old one anyway, but
754 icalcomponent_free(encaps);
758 * If the user clicked 'Delete' then explicitly delete the message.
760 if (havebstr("delete_button")) {
764 if ( (delete_existing) && (msgnum > 0L) ) {
765 serv_printf("DELE %ld", lbstr("msgnum"));
766 serv_getln(buf, sizeof buf);
769 if (created_new_vtodo) {
770 icalcomponent_free(vtodo);
773 /** Go back to the task list */
780 * \brief generic item handler
781 * Code common to all display handlers. Given a message number and a MIME
782 * type, we load the message and hunt for that MIME type. If found, we load
783 * the relevant part, deserialize it into a libical component, filter it for
784 * the requested object type, and feed it to the specified handler.
785 * \param mimetype mimetyp of our object
786 * \param which_kind sort of ical type
787 * \param msgnum number of the mesage in our db
788 * \param callback a funcion \todo
791 void display_using_handler(long msgnum, int unread,
792 icalcomponent_kind which_kind,
793 void (*callback)(icalcomponent *, long, char*, int)
798 char mime_partnum[256];
799 char mime_filename[256];
800 char mime_content_type[256];
801 char mime_disposition[256];
803 char relevant_partnum[256];
804 char *relevant_source = NULL;
805 icalcomponent *cal, *c;
807 relevant_partnum[0] = '\0';
808 sprintf(buf, "MSG4 %ld", msgnum); /* we need the mime headers */
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 || (!strcasecmp(mime_content_type, "application/ics"))
823 || (!strcasecmp(mime_content_type, "text/vtodo"))
825 strcpy(relevant_partnum, mime_partnum);
828 else if (!strncasecmp(buf, "from=", 4)) {
829 extract_token(from, buf, 1, '=', sizeof(from));
833 if (!IsEmptyStr(relevant_partnum)) {
834 relevant_source = load_mimepart(msgnum, relevant_partnum);
835 if (relevant_source != NULL) {
837 cal = icalcomponent_new_from_string(relevant_source);
842 /** Simple components of desired type */
843 if (icalcomponent_isa(cal) == which_kind) {
844 callback(cal, msgnum, from, unread);
847 /** Subcomponents of desired type */
848 for (c = icalcomponent_get_first_component(cal,
851 c = icalcomponent_get_next_component(cal,
853 callback(c, msgnum, from, unread);
855 icalcomponent_free(cal);
857 free(relevant_source);
860 icalmemory_free_ring();
864 * \brief display whole calendar
865 * \param msgnum number of the mesage in our db
867 void display_calendar(long msgnum, int unread) {
868 display_using_handler(msgnum, unread,
869 ICAL_VEVENT_COMPONENT,
870 display_individual_cal);
874 * \brief display whole taksview
875 * \param msgnum number of the mesage in our db
877 void display_task(long msgnum, int unread) {
878 display_using_handler(msgnum, unread,
879 ICAL_VTODO_COMPONENT,
880 display_individual_cal);
884 * \brief display the editor component for a task
886 void display_edit_task(void) {
889 /** Force change the room if we have to */
890 if (havebstr("taskrm")) {
891 gotoroom((char *)bstr("taskrm"));
894 msgnum = lbstr("msgnum");
897 display_using_handler(msgnum, 0,
898 ICAL_VTODO_COMPONENT,
899 display_edit_individual_task);
903 display_edit_individual_task(NULL, 0L, "", 0);
908 *\brief save an edited task
910 void save_task(void) {
913 msgnum = lbstr("msgnum");
915 display_using_handler(msgnum, 0,
916 ICAL_VTODO_COMPONENT,
917 save_individual_task);
920 save_individual_task(NULL, 0L, "", 0);
925 * \brief display the editor component for an event
927 void display_edit_event(void) {
930 msgnum = lbstr("msgnum");
933 display_using_handler(msgnum, 0,
934 ICAL_VEVENT_COMPONENT,
935 display_edit_individual_event);
939 display_edit_individual_event(NULL, 0L, "", 0);
944 * \brief save an edited event
946 void save_event(void) {
949 msgnum = lbstr("msgnum");
952 display_using_handler(msgnum, 0,
953 ICAL_VEVENT_COMPONENT,
954 save_individual_event);
957 save_individual_event(NULL, 0L, "", 0);
966 * \brief freebusy display (for client software)
967 * \param req dunno. ?????
969 void do_freebusy(char *req) {
975 extract_token(who, req, 1, ' ', sizeof who);
976 if (!strncasecmp(who, "/freebusy/", 10)) {
977 strcpy(who, &who[10]);
982 if ( (!strcasecmp(&who[len-4], ".vcf"))
983 || (!strcasecmp(&who[len-4], ".ifb"))
984 || (!strcasecmp(&who[len-4], ".vfb")) ) {
988 lprintf(9, "freebusy requested for <%s>\n", who);
989 serv_printf("ICAL freebusy|%s", who);
990 serv_getln(buf, sizeof buf);
993 wprintf("HTTP/1.1 404 %s\n", &buf[4]);
994 output_headers(0, 0, 0, 0, 0, 0);
995 wprintf("Content-Type: text/plain\r\n");
997 wprintf("%s\n", &buf[4]);
1001 fb = read_server_text();
1002 http_transmit_thing(fb, strlen(fb), "text/calendar", 0);