4 * Functions which handle calendar objects and their processing/display.
12 * Process a calendar object. At this point it's already been deserialized by cal_process_attachment()
14 * cal: the calendar object
15 * recursion_level: Number of times we've recursed into this function
16 * msgnum: Message number on the Citadel server
17 * cal_partnum: MIME part number within that message containing the calendar object
19 void cal_process_object(StrBuf *Target,
23 const char *cal_partnum)
26 icalproperty *method = NULL;
27 icalproperty_method the_method = ICAL_METHOD_NONE;
29 struct icaltimetype t;
32 char conflict_name[256];
33 char conflict_message[256];
36 static int divcount = 0;
38 sprintf(divname, "rsvp%04x", ++divcount);
40 /* Convert timezones to something easy to display.
41 * It's safe to do this in memory because we're only changing it on the
42 * display side -- when we tell the server to do something with the object,
43 * the server will be working with its original copy in the database.
45 if ((cal) && (recursion_level == 0)) {
49 /* Leading HTML for the display of this object */
50 if (recursion_level == 0) {
51 StrBufAppendPrintf(Target, "<div class=\"mimepart\">\n");
54 /* Look for a method */
55 method = icalcomponent_get_first_property(cal, ICAL_METHOD_PROPERTY);
57 /* See what we need to do with this */
60 the_method = icalproperty_get_method(method);
62 StrBufAppendPrintf(Target, "<div id=\"%s_title\">", divname);
63 StrBufAppendPrintf(Target, "<img src=\"static/calarea_48x.gif\">");
64 StrBufAppendPrintf(Target, "<span>");
66 case ICAL_METHOD_REQUEST:
67 title = _("Meeting invitation");
69 case ICAL_METHOD_REPLY:
70 title = _("Attendee's reply to your invitation");
72 case ICAL_METHOD_PUBLISH:
73 title = _("Published event");
76 title = _("This is an unknown type of calendar item.");
79 StrBufAppendPrintf(Target, "</span>");
81 StrBufAppendPrintf(Target, " %s",title);
82 StrBufAppendPrintf(Target, "</div>");
85 StrBufAppendPrintf(Target, "<dl>");
86 p = icalcomponent_get_first_property(cal, ICAL_SUMMARY_PROPERTY);
88 StrBufAppendPrintf(Target, "<dt>");
89 StrBufAppendPrintf(Target, _("Summary:"));
90 StrBufAppendPrintf(Target, "</dt><dd>");
91 StrEscAppend(Target, NULL, (char *)icalproperty_get_comment(p), 0, 0);
92 StrBufAppendPrintf(Target, "</dd>\n");
95 p = icalcomponent_get_first_property(cal, ICAL_LOCATION_PROPERTY);
97 StrBufAppendPrintf(Target, "<dt>");
98 StrBufAppendPrintf(Target, _("Location:"));
99 StrBufAppendPrintf(Target, "</dt><dd>");
100 StrEscAppend(Target, NULL, (char *)icalproperty_get_comment(p), 0, 0);
101 StrBufAppendPrintf(Target, "</dd>\n");
105 * Only show start/end times if we're actually looking at the VEVENT
106 * component. Otherwise it shows bogus dates for things like timezone.
108 if (icalcomponent_isa(cal) == ICAL_VEVENT_COMPONENT) {
110 p = icalcomponent_get_first_property(cal, ICAL_DTSTART_PROPERTY);
112 t = icalproperty_get_dtstart(p);
117 memset(&d_tm, 0, sizeof d_tm);
118 d_tm.tm_year = t.year - 1900;
119 d_tm.tm_mon = t.month - 1;
120 d_tm.tm_mday = t.day;
121 wc_strftime(d_str, sizeof d_str, "%x", &d_tm);
122 StrBufAppendPrintf(Target, "<dt>");
123 StrBufAppendPrintf(Target, _("Date:"));
124 StrBufAppendPrintf(Target, "</dt><dd>%s</dd>", d_str);
127 tt = icaltime_as_timet(t);
128 webcit_fmt_date(buf, 256, tt, DATEFMT_FULL);
129 StrBufAppendPrintf(Target, "<dt>");
130 StrBufAppendPrintf(Target, _("Starting date/time:"));
131 StrBufAppendPrintf(Target, "</dt><dd>%s</dd>", buf);
135 p = icalcomponent_get_first_property(cal, ICAL_DTEND_PROPERTY);
137 t = icalproperty_get_dtend(p);
138 tt = icaltime_as_timet(t);
139 webcit_fmt_date(buf, 256, tt, DATEFMT_FULL);
140 StrBufAppendPrintf(Target, "<dt>");
141 StrBufAppendPrintf(Target, _("Ending date/time:"));
142 StrBufAppendPrintf(Target, "</dt><dd>%s</dd>", buf);
147 p = icalcomponent_get_first_property(cal, ICAL_DESCRIPTION_PROPERTY);
149 StrBufAppendPrintf(Target, "<dt>");
150 StrBufAppendPrintf(Target, _("Description:"));
151 StrBufAppendPrintf(Target, "</dt><dd>");
152 StrEscAppend(Target, NULL, (char *)icalproperty_get_comment(p), 0, 0);
153 StrBufAppendPrintf(Target, "</dd>\n");
156 if (icalcomponent_get_first_property(cal, ICAL_RRULE_PROPERTY)) {
157 /* Unusual string syntax used here in order to re-use existing translations */
158 StrBufAppendPrintf(Target, "<dt>%s:</dt><dd>%s.</dd>\n",
160 _("This is a recurring event")
164 /* If the component has attendees, iterate through them. */
165 for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY);
167 p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) {
168 StrBufAppendPrintf(Target, "<dt>");
169 StrBufAppendPrintf(Target, _("Attendee:"));
170 StrBufAppendPrintf(Target, "</dt><dd>");
171 safestrncpy(buf, icalproperty_get_attendee(p), sizeof buf);
172 if (!strncasecmp(buf, "MAILTO:", 7)) {
174 /** screen name or email address */
175 strcpy(buf, &buf[7]);
177 StrEscAppend(Target, NULL, buf, 0, 0);
178 StrBufAppendPrintf(Target, " ");
180 /** participant status */
181 partstat_as_string(buf, p);
182 StrEscAppend(Target, NULL, buf, 0, 0);
184 StrBufAppendPrintf(Target, "</dd>\n");
187 /* If the component has subcomponents, recurse through them. */
188 for (c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT);
190 c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)) {
191 /* Recursively process subcomponent */
192 cal_process_object(Target, c, recursion_level+1, msgnum, cal_partnum);
195 /* If this is a REQUEST, display conflicts and buttons */
196 if (the_method == ICAL_METHOD_REQUEST) {
198 /* Check for conflicts */
199 lprintf(9, "Checking server calendar for conflicts...\n");
200 serv_printf("ICAL conflicts|%ld|%s|", msgnum, cal_partnum);
201 serv_getln(buf, sizeof buf);
203 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
204 extract_token(conflict_name, buf, 3, '|', sizeof conflict_name);
205 is_update = extract_int(buf, 4);
208 snprintf(conflict_message, sizeof conflict_message,
209 _("This is an update of '%s' which is already in your calendar."), conflict_name);
212 snprintf(conflict_message, sizeof conflict_message,
213 _("This event would conflict with '%s' which is already in your calendar."), conflict_name);
216 StrBufAppendPrintf(Target, "<dt>%s",
222 StrBufAppendPrintf(Target, "</dt><dd>");
223 StrEscAppend(Target, NULL, conflict_message, 0, 0);
224 StrBufAppendPrintf(Target, "</dd>\n");
227 lprintf(9, "...done.\n");
229 StrBufAppendPrintf(Target, "</dl>");
231 /* Display the Accept/Decline buttons */
232 StrBufAppendPrintf(Target, "<p id=\"%s_question\">"
234 " <span class=\"button_link\"> "
235 "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Accept');\">%s</a>"
236 "</span> <span class=\"button_link\">"
237 "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Tentative');\">%s</a>"
238 "</span> <span class=\"button_link\">"
239 "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Decline');\">%s</a>"
242 _("How would you like to respond to this invitation?"),
243 divname, divname, msgnum, cal_partnum, _("Accept"),
244 divname, divname, msgnum, cal_partnum, _("Tentative"),
245 divname, divname, msgnum, cal_partnum, _("Decline")
250 /* If this is a REPLY, display update button */
251 if (the_method == ICAL_METHOD_REPLY) {
253 /* Display the update buttons */
254 StrBufAppendPrintf(Target, "<p id=\"%s_question\" >"
256 " <span class=\"button_link\"> "
257 "<a href=\"javascript:HandleRSVP('%s_question','%s_title','%ld','%s','Update');\">%s</a>"
258 "</span> <span class=\"button_link\">"
259 "<a href=\"javascript:HandleRSVP('%s_question','%s_title','%ld','%s','Ignore');\">%s</a>"
262 _("Click <i>Update</i> to accept this reply and update your calendar."),
263 divname, divname, msgnum, cal_partnum, _("Update"),
264 divname, divname, msgnum, cal_partnum, _("Ignore")
269 /* Trailing HTML for the display of this object */
270 if (recursion_level == 0) {
271 StrBufAppendPrintf(Target, "<p> </p></div>\n");
277 * Deserialize a calendar object in a message so it can be displayed.
279 void cal_process_attachment(wc_mime_attachment *Mime)
283 cal = icalcomponent_new_from_string(ChrPtr(Mime->Data));
284 FlushStrBuf(Mime->Data);
286 StrBufAppendPrintf(Mime->Data, _("There was an error parsing this calendar item."));
287 StrBufAppendPrintf(Mime->Data, "<br />\n");
291 cal_process_object(Mime->Data, cal, 0, Mime->msgnum, ChrPtr(Mime->PartNum));
293 /* Free the memory we obtained from libical's constructor */
294 icalcomponent_free(cal);
301 * Respond to a meeting request - accept/decline meeting
303 void respond_to_request(void)
307 begin_ajax_response();
309 serv_printf("ICAL respond|%s|%s|%s|",
314 serv_getln(buf, sizeof buf);
317 wprintf("<img src=\"static/calarea_48x.gif\"><span>");
318 if (!strcasecmp(bstr("sc"), "accept")) {
319 wprintf(_("You have accepted this meeting invitation. "
320 "It has been entered into your calendar.")
322 } else if (!strcasecmp(bstr("sc"), "tentative")) {
323 wprintf(_("You have tentatively accepted this meeting invitation. "
324 "It has been 'pencilled in' to your calendar.")
326 } else if (!strcasecmp(bstr("sc"), "decline")) {
327 wprintf(_("You have declined this meeting invitation. "
328 "It has <b>not</b> been entered into your calendar.")
332 wprintf(_("A reply has been sent to the meeting organizer."));
335 wprintf("<img align=\"center\" src=\"static/error.gif\"><span>");
336 wprintf("%s\n", &buf[4]);
346 * Handle an incoming RSVP
348 void handle_rsvp(void)
352 begin_ajax_response();
354 serv_printf("ICAL handle_rsvp|%s|%s|%s|",
359 serv_getln(buf, sizeof buf);
362 wprintf("<img src=\"static/calarea_48x.gif\"><span>");
363 if (!strcasecmp(bstr("sc"), "update")) {
364 wprintf(_("Your calendar has been updated to reflect this RSVP."));
365 } else if (!strcasecmp(bstr("sc"), "ignore")) {
366 wprintf(_("You have chosen to ignore this RSVP. "
367 "Your calendar has <b>not</b> been updated.")
372 wprintf("<img src=\"static/error.gif\"><span> %s\n", &buf[4]);
383 * free memory allocated using libical
385 void delete_cal(void *vCal)
387 disp_cal *Cal = (disp_cal*) vCal;
388 icalcomponent_free(Cal->cal);
394 * This is the meat-and-bones of the first part of our two-phase calendar display.
395 * As we encounter calendar items in messages being read from the server, we break out
396 * any iCalendar objects and store them in a hash table. Later on, the second phase will
397 * use this hash table to render the calendar for display.
399 void display_individual_cal(icalcomponent *cal, long msgnum, char *from, int unread, calview *calv)
401 icalproperty *ps = NULL;
402 struct icaltimetype dtstart, dtend;
403 struct icaldurationtype dur;
407 time_t final_recurrence = 0;
408 icalcomponent *cptr = NULL;
410 /* recur variables */
411 icalproperty *rrule = NULL;
412 struct icalrecurrencetype recur;
413 icalrecur_iterator *ritr = NULL;
414 struct icaltimetype next;
418 dtstart = icaltime_null_time();
419 dtend = icaltime_null_time();
421 if (WCC->disp_cal_items == NULL)
422 WCC->disp_cal_items = NewHash(0, Flathash);
424 /* Note: anything we do here, we also have to do below for the recurrences. */
425 Cal = (disp_cal*) malloc(sizeof(disp_cal));
426 memset(Cal, 0, sizeof(disp_cal));
427 Cal->cal = icalcomponent_new_clone(cal);
429 /* Dezonify and decapsulate at the very last moment */
430 /* lprintf(9, "INITIAL: %s\n", icaltime_as_ical_string(icalproperty_get_dtstart(
431 icalcomponent_get_first_property(icalcomponent_get_first_component(
432 Cal->cal, ICAL_VEVENT_COMPONENT), ICAL_DTSTART_PROPERTY)))
434 ical_dezonify(Cal->cal);
435 if (icalcomponent_isa(Cal->cal) != ICAL_VEVENT_COMPONENT) {
436 cptr = icalcomponent_get_first_component(Cal->cal, ICAL_VEVENT_COMPONENT);
438 cptr = icalcomponent_new_clone(cptr);
439 icalcomponent_free(Cal->cal);
444 Cal->unread = unread;
446 Cal->from = (char*)malloc(len+ 1);
447 memcpy(Cal->from, from, len + 1);
448 Cal->cal_msgnum = msgnum;
450 /* Precalculate the starting date and time of this event, and store it in our top-level
451 * structure. Later, when we are rendering the calendar, we can just peek at these values
452 * without having to break apart every calendar item.
454 ps = icalcomponent_get_first_property(Cal->cal, ICAL_DTSTART_PROPERTY);
456 dtstart = icalproperty_get_dtstart(ps);
457 Cal->event_start = icaltime_as_timet(dtstart);
460 /* Do the same for the ending date and time. It makes the day view much easier to render. */
461 ps = icalcomponent_get_first_property(Cal->cal, ICAL_DTEND_PROPERTY);
463 dtend = icalproperty_get_dtend(ps);
464 Cal->event_end = icaltime_as_timet(dtend);
467 /* Store it in the hash list. */
468 Put(WCC->disp_cal_items,
469 (char*) &Cal->event_start,
470 sizeof(Cal->event_start),
474 /****************************** handle recurring events ******************************/
476 if (icaltime_is_null_time(dtstart)) return; /* Can't recur without a start time */
478 if (!icaltime_is_null_time(dtend)) { /* Need duration for recurrences */
479 dur = icaltime_subtract(dtend, dtstart);
483 * Just let libical iterate the recurrence, and keep looping back to the top of this function,
484 * adding new hash entries that all point back to the same msgnum, until either the iteration
485 * stops or some outer bound is reached. The display code will automatically do the Right Thing.
488 if (icalcomponent_isa(cptr) != ICAL_VEVENT_COMPONENT) {
489 cptr = icalcomponent_get_first_component(cptr, ICAL_VEVENT_COMPONENT);
492 ps = icalcomponent_get_first_property(cptr, ICAL_DTSTART_PROPERTY);
493 if (ps == NULL) return;
494 dtstart = icalproperty_get_dtstart(ps);
495 rrule = icalcomponent_get_first_property(cptr, ICAL_RRULE_PROPERTY);
497 recur = icalproperty_get_rrule(rrule);
498 ritr = icalrecur_iterator_new(recur, dtstart);
501 while (next = icalrecur_iterator_next(ritr), ((!icaltime_is_null_time(next))&&(!stop_rr)) ) {
503 if (num_recur > 1) { /* Skip the first one. We already did it at the root. */
505 /* lprintf(9, "REPEATS: %s\n", icaltime_as_ical_string(next)); */
507 /* Note: anything we do here, we also have to do above for the root event. */
508 Cal = (disp_cal*) malloc(sizeof(disp_cal));
509 memset(Cal, 0, sizeof(disp_cal));
510 Cal->cal = icalcomponent_new_clone(cal);
511 Cal->unread = unread;
513 Cal->from = (char*)malloc(len+ 1);
514 memcpy(Cal->from, from, len + 1);
515 Cal->cal_msgnum = msgnum;
517 if (icalcomponent_isa(Cal->cal) == ICAL_VEVENT_COMPONENT) {
521 cptr = icalcomponent_get_first_component(Cal->cal, ICAL_VEVENT_COMPONENT);
524 ps = icalcomponent_get_first_property(cptr, ICAL_DTSTART_PROPERTY);
526 icalcomponent_remove_property(cptr, ps);
527 ps = icalproperty_new_dtstart(next);
528 icalcomponent_add_property(cptr, ps);
530 Cal->event_start = icaltime_as_timet(next);
531 final_recurrence = Cal->event_start;
534 ps = icalcomponent_get_first_property(cptr, ICAL_DTEND_PROPERTY);
536 icalcomponent_remove_property(cptr, ps);
538 /* Make a new dtend */
539 ps = icalproperty_new_dtend(icaltime_add(next, dur));
541 /* and stick it somewhere */
542 icalcomponent_add_property(cptr, ps);
547 /* Dezonify and decapsulate at the very last moment */
548 ical_dezonify(Cal->cal);
549 if (icalcomponent_isa(Cal->cal) != ICAL_VEVENT_COMPONENT) {
550 cptr = icalcomponent_get_first_component(Cal->cal, ICAL_VEVENT_COMPONENT);
552 cptr = icalcomponent_new_clone(cptr);
553 icalcomponent_free(Cal->cal);
558 if ( (Cal->event_start > calv->lower_bound)
559 && (Cal->event_start < calv->upper_bound) ) {
560 Put(WCC->disp_cal_items,
561 (char*) &Cal->event_start,
562 sizeof(Cal->event_start),
571 /* If an upper bound is set, stop when we go out of scope */
572 if (final_recurrence > calv->upper_bound) stop_rr = 1;
575 icalrecur_iterator_free(ritr);
576 /* lprintf(9, "Performed %d recurrences; final one is %s", num_recur, ctime(&final_recurrence)); */
585 void process_ical_object(long msgnum, int unread,
588 icalcomponent_kind which_kind,
589 IcalCallbackFunc CallBack,
593 icalcomponent *cal, *c;
595 cal = icalcomponent_new_from_string(FlatIcal);
598 /* A which_kind of (-1) means just load the whole thing */
599 if (which_kind == (-1)) {
600 CallBack(cal, msgnum, from, unread, calv);
603 /* Otherwise recurse and hunt */
606 /* Simple components of desired type */
607 if (icalcomponent_isa(cal) == which_kind) {
608 CallBack(cal, msgnum, from, unread, calv);
611 /* Subcomponents of desired type */
612 for (c = icalcomponent_get_first_component(cal, which_kind);
614 c = icalcomponent_get_next_component(cal, which_kind)) {
615 CallBack(c, msgnum, from, unread, calv);
620 icalcomponent_free(cal);
625 * Code common to all icalendar display handlers. Given a message number and a MIME
626 * type, we load the message and hunt for that MIME type. If found, we load
627 * the relevant part, deserialize it into a libical component, filter it for
628 * the requested object type, and feed it to the specified handler.
630 void load_ical_object(long msgnum, int unread,
631 icalcomponent_kind which_kind,
632 IcalCallbackFunc CallBack,
642 char mime_partnum[256];
643 char mime_filename[256];
644 char mime_content_type[256];
645 char mime_disposition[256];
647 char relevant_partnum[256];
648 char *relevant_source = NULL;
649 int phase = 0; /* 0 = citadel headers, 1 = mime headers, 2 = body */
650 char msg4_content_type[256] = "";
651 char msg4_content_encoding[256] = "";
652 int msg4_content_length = 0;
654 relevant_partnum[0] = '\0';
655 serv_printf("MSG4 %ld", msgnum); /* we need the mime headers */
657 StrBuf_ServGetln(Buf);
658 if (GetServerStatus(Buf, NULL) != 1) {
662 while (!Done && (StrBuf_ServGetln(Buf)>=0)) {
663 if ( (StrLength(Buf)==3) &&
664 !strcmp(ChrPtr(Buf), "000")) {
671 if (!strncasecmp(bptr, "part=", 5)) {
672 extract_token(mime_filename, &bptr[5], 1, '|', sizeof mime_filename);
673 extract_token(mime_partnum, &bptr[5], 2, '|', sizeof mime_partnum);
674 extract_token(mime_disposition, &bptr[5], 3, '|', sizeof mime_disposition);
675 extract_token(mime_content_type, &bptr[5], 4, '|', sizeof mime_content_type);
676 mime_length = extract_int(&bptr[5], 5);
678 if ( (!strcasecmp(mime_content_type, "text/calendar"))
679 || (!strcasecmp(mime_content_type, "application/ics"))
680 || (!strcasecmp(mime_content_type, "text/vtodo"))
681 || (!strcasecmp(mime_content_type, "text/todo"))
683 strcpy(relevant_partnum, mime_partnum);
686 else if (!strncasecmp(bptr, "from=", 4)) {
687 extract_token(from, bptr, 1, '=', sizeof(from));
689 else if ((phase == 0) && (!strncasecmp(bptr, "text", 4))) {
694 if (!IsEmptyStr(bptr)) {
695 if (!strncasecmp(bptr, "Content-type: ", 14)) {
696 safestrncpy(msg4_content_type, &bptr[14], sizeof msg4_content_type);
697 striplt(msg4_content_type);
699 else if (!strncasecmp(bptr, "Content-transfer-encoding: ", 27)) {
700 safestrncpy(msg4_content_encoding, &bptr[27], sizeof msg4_content_encoding);
701 striplt(msg4_content_type);
703 else if ((!strncasecmp(bptr, "Content-length: ", 16))) {
704 msg4_content_length = atoi(&bptr[16]);
711 if ((msg4_content_length > 0)
712 && ( !strcasecmp(msg4_content_encoding, "7bit"))
713 && ((!strcasecmp(mime_content_type, "text/calendar"))
714 || (!strcasecmp(mime_content_type, "application/ics"))
715 || (!strcasecmp(mime_content_type, "text/vtodo"))
716 || (!strcasecmp(mime_content_type, "text/todo"))
724 Data = NewStrBufPlain(NULL, msg4_content_length * 2);
725 if (msg4_content_length > 0) {
726 StrBuf_ServGetBLOBBuffered(Data, msg4_content_length);
730 StrBufAppendBuf(Data, Buf, 0);
731 StrBufAppendBufPlain(Data, "\r\n", 1, 0);
734 StrBufAppendBuf(Data, Buf, 0);
739 /* If MSG4 didn't give us the part we wanted, but we know that we can find it
740 * as one of the other MIME parts, attempt to load it now.
742 if ((Data == NULL) && (!IsEmptyStr(relevant_partnum))) {
743 Data = load_mimepart(msgnum, relevant_partnum);
747 relevant_source = (char*) ChrPtr(Data);
748 process_ical_object(msgnum, unread,
757 icalmemory_free_ring();
761 * Display a calendar item
763 int calendar_LoadMsgFromServer(SharedMessageStatus *Stat,
765 message_summary* Msg,
769 calview *c = (calview*) *ViewSpecific;
770 load_ical_object(Msg->msgnum, is_new, (-1), display_individual_cal, c, 1);
775 * display the editor component for an event
777 void display_edit_event(void) {
780 msgnum = lbstr("msgnum");
783 load_ical_object(msgnum, 0, ICAL_VEVENT_COMPONENT, display_edit_individual_event, NULL, 0);
787 display_edit_individual_event(NULL, 0L, "", 0, NULL);
792 * save an edited event
794 void save_event(void) {
797 msgnum = lbstr("msgnum");
800 load_ical_object(msgnum, 0, (-1), save_individual_event, NULL, 0);
803 save_individual_event(NULL, 0L, "", 0, NULL);
812 * Anonymous request of freebusy data for a user
814 void do_freebusy(void)
816 const char *req = ChrPtr(WC->Hdr->HR.ReqLine);
822 extract_token(who, req, 0, ' ', sizeof who);
823 if (!strncasecmp(who, "/freebusy/", 10)) {
824 strcpy(who, &who[10]);
829 if ( (!strcasecmp(&who[len-4], ".vcf"))
830 || (!strcasecmp(&who[len-4], ".ifb"))
831 || (!strcasecmp(&who[len-4], ".vfb")) ) {
835 lprintf(9, "freebusy requested for <%s>\n", who);
836 serv_printf("ICAL freebusy|%s", who);
837 serv_getln(buf, sizeof buf);
840 hprintf("HTTP/1.1 404 %s\n", &buf[4]);
841 output_headers(0, 0, 0, 0, 0, 0);
842 hprintf("Content-Type: text/plain\r\n");
843 wprintf("%s\n", &buf[4]);
848 read_server_text(WC->WBuf, &lines);
849 http_transmit_thing("text/calendar", 0);
854 int calendar_Cleanup(void **ViewSpecific)
858 c = (calview *) *ViewSpecific;
862 *ViewSpecific = NULL;
867 int __calendar_Cleanup(void **ViewSpecific)
871 c = (calview *) *ViewSpecific;
874 *ViewSpecific = NULL;
884 RegisterReadLoopHandlerset(
886 calendar_GetParamsGetServerCall,
888 calendar_LoadMsgFromServer,
889 calendar_RenderView_or_Tail,
892 RegisterReadLoopHandlerset(
894 calendar_GetParamsGetServerCall,
896 calendar_LoadMsgFromServer,
897 calendar_RenderView_or_Tail,
902 RegisterPreference("daystart", _("Calendar day view begins at:"), PRF_INT, NULL);
903 RegisterPreference("dayend", _("Calendar day view ends at:"), PRF_INT, NULL);
904 RegisterPreference("weekstart", _("Week starts on:"), PRF_INT, NULL);
906 WebcitAddUrlHandler(HKEY("freebusy"), "", 0, do_freebusy, COOKIEUNNEEDED|ANONYMOUS|FORCE_SESSIONCLOSE);
907 WebcitAddUrlHandler(HKEY("display_edit_task"), "", 0, display_edit_task, 0);
908 WebcitAddUrlHandler(HKEY("display_edit_event"), "", 0, display_edit_event, 0);
909 WebcitAddUrlHandler(HKEY("save_event"), "", 0, save_event, 0);
910 WebcitAddUrlHandler(HKEY("respond_to_request"), "", 0, respond_to_request, 0);
911 WebcitAddUrlHandler(HKEY("handle_rsvp"), "", 0, handle_rsvp, 0);