4 * Functions which handle calendar objects and their processing/display.
6 * Copyright (c) 1996-2010 by the citadel.org team
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "webserver.h"
28 * Process a calendar object. At this point it's already been deserialized by cal_process_attachment()
30 * cal: the calendar object
31 * recursion_level: Number of times we've recursed into this function
32 * msgnum: Message number on the Citadel server
33 * cal_partnum: MIME part number within that message containing the calendar object
35 void cal_process_object(StrBuf *Target,
39 const char *cal_partnum)
42 icalproperty *method = NULL;
43 icalproperty_method the_method = ICAL_METHOD_NONE;
45 struct icaltimetype t;
48 char conflict_name[256];
49 char conflict_message[256];
52 static int divcount = 0;
54 sprintf(divname, "rsvp%04x", ++divcount);
56 /* Convert timezones to something easy to display.
57 * It's safe to do this in memory because we're only changing it on the
58 * display side -- when we tell the server to do something with the object,
59 * the server will be working with its original copy in the database.
61 if ((cal) && (recursion_level == 0)) {
65 /* Leading HTML for the display of this object */
66 if (recursion_level == 0) {
67 StrBufAppendPrintf(Target, "<div class=\"mimepart\">\n");
70 /* Look for a method */
71 method = icalcomponent_get_first_property(cal, ICAL_METHOD_PROPERTY);
73 /* See what we need to do with this */
76 the_method = icalproperty_get_method(method);
78 StrBufAppendPrintf(Target, "<div id=\"%s_title\">", divname);
79 StrBufAppendPrintf(Target, "<img src=\"static/calarea_48x.gif\">");
80 StrBufAppendPrintf(Target, "<span>");
82 case ICAL_METHOD_REQUEST:
83 title = _("Meeting invitation");
85 case ICAL_METHOD_REPLY:
86 title = _("Attendee's reply to your invitation");
88 case ICAL_METHOD_PUBLISH:
89 title = _("Published event");
92 title = _("This is an unknown type of calendar item.");
95 StrBufAppendPrintf(Target, "</span>");
97 StrBufAppendPrintf(Target, " %s",title);
98 StrBufAppendPrintf(Target, "</div>");
101 StrBufAppendPrintf(Target, "<dl>");
102 p = icalcomponent_get_first_property(cal, ICAL_SUMMARY_PROPERTY);
104 StrBufAppendPrintf(Target, "<dt>");
105 StrBufAppendPrintf(Target, _("Summary:"));
106 StrBufAppendPrintf(Target, "</dt><dd>");
107 StrEscAppend(Target, NULL, (char *)icalproperty_get_comment(p), 0, 0);
108 StrBufAppendPrintf(Target, "</dd>\n");
111 p = icalcomponent_get_first_property(cal, ICAL_LOCATION_PROPERTY);
113 StrBufAppendPrintf(Target, "<dt>");
114 StrBufAppendPrintf(Target, _("Location:"));
115 StrBufAppendPrintf(Target, "</dt><dd>");
116 StrEscAppend(Target, NULL, (char *)icalproperty_get_comment(p), 0, 0);
117 StrBufAppendPrintf(Target, "</dd>\n");
121 * Only show start/end times if we're actually looking at the VEVENT
122 * component. Otherwise it shows bogus dates for things like timezone.
124 if (icalcomponent_isa(cal) == ICAL_VEVENT_COMPONENT) {
126 p = icalcomponent_get_first_property(cal, ICAL_DTSTART_PROPERTY);
128 t = icalproperty_get_dtstart(p);
133 memset(&d_tm, 0, sizeof d_tm);
134 d_tm.tm_year = t.year - 1900;
135 d_tm.tm_mon = t.month - 1;
136 d_tm.tm_mday = t.day;
137 wc_strftime(d_str, sizeof d_str, "%x", &d_tm);
138 StrBufAppendPrintf(Target, "<dt>");
139 StrBufAppendPrintf(Target, _("Date:"));
140 StrBufAppendPrintf(Target, "</dt><dd>%s</dd>", d_str);
143 tt = icaltime_as_timet(t);
144 webcit_fmt_date(buf, 256, tt, DATEFMT_FULL);
145 StrBufAppendPrintf(Target, "<dt>");
146 StrBufAppendPrintf(Target, _("Starting date/time:"));
147 StrBufAppendPrintf(Target, "</dt><dd>%s</dd>", buf);
151 p = icalcomponent_get_first_property(cal, ICAL_DTEND_PROPERTY);
153 t = icalproperty_get_dtend(p);
154 tt = icaltime_as_timet(t);
155 webcit_fmt_date(buf, 256, tt, DATEFMT_FULL);
156 StrBufAppendPrintf(Target, "<dt>");
157 StrBufAppendPrintf(Target, _("Ending date/time:"));
158 StrBufAppendPrintf(Target, "</dt><dd>%s</dd>", buf);
163 p = icalcomponent_get_first_property(cal, ICAL_DESCRIPTION_PROPERTY);
165 StrBufAppendPrintf(Target, "<dt>");
166 StrBufAppendPrintf(Target, _("Description:"));
167 StrBufAppendPrintf(Target, "</dt><dd>");
168 StrEscAppend(Target, NULL, (char *)icalproperty_get_comment(p), 0, 0);
169 StrBufAppendPrintf(Target, "</dd>\n");
172 if (icalcomponent_get_first_property(cal, ICAL_RRULE_PROPERTY)) {
173 /* Unusual string syntax used here in order to re-use existing translations */
174 StrBufAppendPrintf(Target, "<dt>%s:</dt><dd>%s.</dd>\n",
176 _("This is a recurring event")
180 /* If the component has attendees, iterate through them. */
181 for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY);
183 p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) {
184 StrBufAppendPrintf(Target, "<dt>");
185 StrBufAppendPrintf(Target, _("Attendee:"));
186 StrBufAppendPrintf(Target, "</dt><dd>");
187 safestrncpy(buf, icalproperty_get_attendee(p), sizeof buf);
188 if (!strncasecmp(buf, "MAILTO:", 7)) {
190 /** screen name or email address */
191 strcpy(buf, &buf[7]);
193 StrEscAppend(Target, NULL, buf, 0, 0);
194 StrBufAppendPrintf(Target, " ");
196 /** participant status */
197 partstat_as_string(buf, p);
198 StrEscAppend(Target, NULL, buf, 0, 0);
200 StrBufAppendPrintf(Target, "</dd>\n");
203 /* If the component has subcomponents, recurse through them. */
204 for (c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT);
206 c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)) {
207 /* Recursively process subcomponent */
208 cal_process_object(Target, c, recursion_level+1, msgnum, cal_partnum);
211 /* If this is a REQUEST, display conflicts and buttons */
212 if (the_method == ICAL_METHOD_REQUEST) {
214 /* Check for conflicts */
215 lprintf(9, "Checking server calendar for conflicts...\n");
216 serv_printf("ICAL conflicts|%ld|%s|", msgnum, cal_partnum);
217 serv_getln(buf, sizeof buf);
219 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
220 extract_token(conflict_name, buf, 3, '|', sizeof conflict_name);
221 is_update = extract_int(buf, 4);
224 snprintf(conflict_message, sizeof conflict_message,
225 _("This is an update of '%s' which is already in your calendar."), conflict_name);
228 snprintf(conflict_message, sizeof conflict_message,
229 _("This event would conflict with '%s' which is already in your calendar."), conflict_name);
232 StrBufAppendPrintf(Target, "<dt>%s",
238 StrBufAppendPrintf(Target, "</dt><dd>");
239 StrEscAppend(Target, NULL, conflict_message, 0, 0);
240 StrBufAppendPrintf(Target, "</dd>\n");
243 lprintf(9, "...done.\n");
245 StrBufAppendPrintf(Target, "</dl>");
247 /* Display the Accept/Decline buttons */
248 StrBufAppendPrintf(Target, "<p id=\"%s_question\">"
250 " <span class=\"button_link\"> "
251 "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Accept');\">%s</a>"
252 "</span> <span class=\"button_link\">"
253 "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Tentative');\">%s</a>"
254 "</span> <span class=\"button_link\">"
255 "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Decline');\">%s</a>"
258 _("How would you like to respond to this invitation?"),
259 divname, divname, msgnum, cal_partnum, _("Accept"),
260 divname, divname, msgnum, cal_partnum, _("Tentative"),
261 divname, divname, msgnum, cal_partnum, _("Decline")
266 /* If this is a REPLY, display update button */
267 if (the_method == ICAL_METHOD_REPLY) {
269 /* Display the update buttons */
270 StrBufAppendPrintf(Target, "<p id=\"%s_question\" >"
272 " <span class=\"button_link\"> "
273 "<a href=\"javascript:HandleRSVP('%s_question','%s_title','%ld','%s','Update');\">%s</a>"
274 "</span> <span class=\"button_link\">"
275 "<a href=\"javascript:HandleRSVP('%s_question','%s_title','%ld','%s','Ignore');\">%s</a>"
278 _("Click <i>Update</i> to accept this reply and update your calendar."),
279 divname, divname, msgnum, cal_partnum, _("Update"),
280 divname, divname, msgnum, cal_partnum, _("Ignore")
285 /* Trailing HTML for the display of this object */
286 if (recursion_level == 0) {
287 StrBufAppendPrintf(Target, "<p> </p></div>\n");
293 * Deserialize a calendar object in a message so it can be displayed.
295 void cal_process_attachment(wc_mime_attachment *Mime)
299 cal = icalcomponent_new_from_string(ChrPtr(Mime->Data));
300 FlushStrBuf(Mime->Data);
302 StrBufAppendPrintf(Mime->Data, _("There was an error parsing this calendar item."));
303 StrBufAppendPrintf(Mime->Data, "<br />\n");
307 cal_process_object(Mime->Data, cal, 0, Mime->msgnum, ChrPtr(Mime->PartNum));
309 /* Free the memory we obtained from libical's constructor */
310 icalcomponent_free(cal);
317 * Respond to a meeting request - accept/decline meeting
319 void respond_to_request(void)
323 begin_ajax_response();
325 serv_printf("ICAL respond|%s|%s|%s|",
330 serv_getln(buf, sizeof buf);
333 wc_printf("<img src=\"static/calarea_48x.gif\"><span>");
334 if (!strcasecmp(bstr("sc"), "accept")) {
335 wc_printf(_("You have accepted this meeting invitation. "
336 "It has been entered into your calendar.")
338 } else if (!strcasecmp(bstr("sc"), "tentative")) {
339 wc_printf(_("You have tentatively accepted this meeting invitation. "
340 "It has been 'pencilled in' to your calendar.")
342 } else if (!strcasecmp(bstr("sc"), "decline")) {
343 wc_printf(_("You have declined this meeting invitation. "
344 "It has <b>not</b> been entered into your calendar.")
348 wc_printf(_("A reply has been sent to the meeting organizer."));
349 wc_printf("</span>");
351 wc_printf("<img align=\"center\" src=\"static/error.gif\"><span>");
352 wc_printf("%s\n", &buf[4]);
353 wc_printf("</span>");
362 * Handle an incoming RSVP
364 void handle_rsvp(void)
368 begin_ajax_response();
370 serv_printf("ICAL handle_rsvp|%s|%s|%s|",
375 serv_getln(buf, sizeof buf);
378 wc_printf("<img src=\"static/calarea_48x.gif\"><span>");
379 if (!strcasecmp(bstr("sc"), "update")) {
380 wc_printf(_("Your calendar has been updated to reflect this RSVP."));
381 } else if (!strcasecmp(bstr("sc"), "ignore")) {
382 wc_printf(_("You have chosen to ignore this RSVP. "
383 "Your calendar has <b>not</b> been updated.")
386 wc_printf("</span>");
388 wc_printf("<img src=\"static/error.gif\"><span> %s\n", &buf[4]);
389 wc_printf("</span>");
399 * free memory allocated using libical
401 void delete_cal(void *vCal)
403 disp_cal *Cal = (disp_cal*) vCal;
404 icalcomponent_free(Cal->cal);
410 * This is the meat-and-bones of the first part of our two-phase calendar display.
411 * As we encounter calendar items in messages being read from the server, we break out
412 * any iCalendar objects and store them in a hash table. Later on, the second phase will
413 * use this hash table to render the calendar for display.
415 void display_individual_cal(icalcomponent *cal, long msgnum, char *from, int unread, calview *calv)
417 icalproperty *ps = NULL;
418 struct icaltimetype dtstart, dtend;
419 struct icaldurationtype dur;
423 time_t final_recurrence = 0;
424 icalcomponent *cptr = NULL;
426 /* recur variables */
427 icalproperty *rrule = NULL;
428 struct icalrecurrencetype recur;
429 icalrecur_iterator *ritr = NULL;
430 struct icaltimetype next;
434 dtstart = icaltime_null_time();
435 dtend = icaltime_null_time();
437 if (WCC->disp_cal_items == NULL)
438 WCC->disp_cal_items = NewHash(0, Flathash);
440 /* Note: anything we do here, we also have to do below for the recurrences. */
441 Cal = (disp_cal*) malloc(sizeof(disp_cal));
442 memset(Cal, 0, sizeof(disp_cal));
443 Cal->cal = icalcomponent_new_clone(cal);
445 /* Dezonify and decapsulate at the very last moment */
446 /* lprintf(9, "INITIAL: %s\n", icaltime_as_ical_string(icalproperty_get_dtstart(
447 icalcomponent_get_first_property(icalcomponent_get_first_component(
448 Cal->cal, ICAL_VEVENT_COMPONENT), ICAL_DTSTART_PROPERTY)))
450 ical_dezonify(Cal->cal);
451 if (icalcomponent_isa(Cal->cal) != ICAL_VEVENT_COMPONENT) {
452 cptr = icalcomponent_get_first_component(Cal->cal, ICAL_VEVENT_COMPONENT);
454 cptr = icalcomponent_new_clone(cptr);
455 icalcomponent_free(Cal->cal);
460 Cal->unread = unread;
462 Cal->from = (char*)malloc(len+ 1);
463 memcpy(Cal->from, from, len + 1);
464 Cal->cal_msgnum = msgnum;
466 /* Precalculate the starting date and time of this event, and store it in our top-level
467 * structure. Later, when we are rendering the calendar, we can just peek at these values
468 * without having to break apart every calendar item.
470 ps = icalcomponent_get_first_property(Cal->cal, ICAL_DTSTART_PROPERTY);
472 dtstart = icalproperty_get_dtstart(ps);
473 Cal->event_start = icaltime_as_timet(dtstart);
476 /* Do the same for the ending date and time. It makes the day view much easier to render. */
477 ps = icalcomponent_get_first_property(Cal->cal, ICAL_DTEND_PROPERTY);
479 dtend = icalproperty_get_dtend(ps);
480 Cal->event_end = icaltime_as_timet(dtend);
483 /* Store it in the hash list. */
484 Put(WCC->disp_cal_items,
485 (char*) &Cal->event_start,
486 sizeof(Cal->event_start),
490 /****************************** handle recurring events ******************************/
492 if (icaltime_is_null_time(dtstart)) return; /* Can't recur without a start time */
494 if (!icaltime_is_null_time(dtend)) { /* Need duration for recurrences */
495 dur = icaltime_subtract(dtend, dtstart);
499 * Just let libical iterate the recurrence, and keep looping back to the top of this function,
500 * adding new hash entries that all point back to the same msgnum, until either the iteration
501 * stops or some outer bound is reached. The display code will automatically do the Right Thing.
504 if (icalcomponent_isa(cptr) != ICAL_VEVENT_COMPONENT) {
505 cptr = icalcomponent_get_first_component(cptr, ICAL_VEVENT_COMPONENT);
508 ps = icalcomponent_get_first_property(cptr, ICAL_DTSTART_PROPERTY);
509 if (ps == NULL) return;
510 dtstart = icalproperty_get_dtstart(ps);
511 rrule = icalcomponent_get_first_property(cptr, ICAL_RRULE_PROPERTY);
513 recur = icalproperty_get_rrule(rrule);
514 ritr = icalrecur_iterator_new(recur, dtstart);
517 while (next = icalrecur_iterator_next(ritr), ((!icaltime_is_null_time(next))&&(!stop_rr)) ) {
519 if (num_recur > 1) { /* Skip the first one. We already did it at the root. */
521 /* lprintf(9, "REPEATS: %s\n", icaltime_as_ical_string(next)); */
523 /* Note: anything we do here, we also have to do above for the root event. */
524 Cal = (disp_cal*) malloc(sizeof(disp_cal));
525 memset(Cal, 0, sizeof(disp_cal));
526 Cal->cal = icalcomponent_new_clone(cal);
527 Cal->unread = unread;
529 Cal->from = (char*)malloc(len+ 1);
530 memcpy(Cal->from, from, len + 1);
531 Cal->cal_msgnum = msgnum;
533 if (icalcomponent_isa(Cal->cal) == ICAL_VEVENT_COMPONENT) {
537 cptr = icalcomponent_get_first_component(Cal->cal, ICAL_VEVENT_COMPONENT);
540 ps = icalcomponent_get_first_property(cptr, ICAL_DTSTART_PROPERTY);
542 icalcomponent_remove_property(cptr, ps);
543 ps = icalproperty_new_dtstart(next);
544 icalcomponent_add_property(cptr, ps);
546 Cal->event_start = icaltime_as_timet(next);
547 final_recurrence = Cal->event_start;
550 ps = icalcomponent_get_first_property(cptr, ICAL_DTEND_PROPERTY);
552 icalcomponent_remove_property(cptr, ps);
554 /* Make a new dtend */
555 ps = icalproperty_new_dtend(icaltime_add(next, dur));
557 /* and stick it somewhere */
558 icalcomponent_add_property(cptr, ps);
563 /* Dezonify and decapsulate at the very last moment */
564 ical_dezonify(Cal->cal);
565 if (icalcomponent_isa(Cal->cal) != ICAL_VEVENT_COMPONENT) {
566 cptr = icalcomponent_get_first_component(Cal->cal, ICAL_VEVENT_COMPONENT);
568 cptr = icalcomponent_new_clone(cptr);
569 icalcomponent_free(Cal->cal);
574 if ( (Cal->event_start > calv->lower_bound)
575 && (Cal->event_start < calv->upper_bound) ) {
576 Put(WCC->disp_cal_items,
577 (char*) &Cal->event_start,
578 sizeof(Cal->event_start),
587 /* If an upper bound is set, stop when we go out of scope */
588 if (final_recurrence > calv->upper_bound) stop_rr = 1;
591 icalrecur_iterator_free(ritr);
592 /* lprintf(9, "Performed %d recurrences; final one is %s", num_recur, ctime(&final_recurrence)); */
601 void process_ical_object(long msgnum, int unread,
604 icalcomponent_kind which_kind,
605 IcalCallbackFunc CallBack,
609 icalcomponent *cal, *c;
611 cal = icalcomponent_new_from_string(FlatIcal);
614 /* A which_kind of (-1) means just load the whole thing */
615 if (which_kind == (-1)) {
616 CallBack(cal, msgnum, from, unread, calv);
619 /* Otherwise recurse and hunt */
622 /* Simple components of desired type */
623 if (icalcomponent_isa(cal) == which_kind) {
624 CallBack(cal, msgnum, from, unread, calv);
627 /* Subcomponents of desired type */
628 for (c = icalcomponent_get_first_component(cal, which_kind);
630 c = icalcomponent_get_next_component(cal, which_kind)) {
631 CallBack(c, msgnum, from, unread, calv);
636 icalcomponent_free(cal);
641 * Code common to all icalendar display handlers. Given a message number and a MIME
642 * type, we load the message and hunt for that MIME type. If found, we load
643 * the relevant part, deserialize it into a libical component, filter it for
644 * the requested object type, and feed it to the specified handler.
646 void load_ical_object(long msgnum, int unread,
647 icalcomponent_kind which_kind,
648 IcalCallbackFunc CallBack,
658 char mime_partnum[256];
659 char mime_filename[256];
660 char mime_content_type[256];
661 char mime_disposition[256];
663 char relevant_partnum[256];
664 char *relevant_source = NULL;
665 int phase = 0; /* 0 = citadel headers, 1 = mime headers, 2 = body */
666 char msg4_content_type[256] = "";
667 char msg4_content_encoding[256] = "";
668 int msg4_content_length = 0;
670 relevant_partnum[0] = '\0';
671 serv_printf("MSG4 %ld", msgnum); /* we need the mime headers */
673 StrBuf_ServGetln(Buf);
674 if (GetServerStatus(Buf, NULL) != 1) {
678 while (!Done && (StrBuf_ServGetln(Buf)>=0)) {
679 if ( (StrLength(Buf)==3) &&
680 !strcmp(ChrPtr(Buf), "000")) {
687 if (!strncasecmp(bptr, "part=", 5)) {
688 extract_token(mime_filename, &bptr[5], 1, '|', sizeof mime_filename);
689 extract_token(mime_partnum, &bptr[5], 2, '|', sizeof mime_partnum);
690 extract_token(mime_disposition, &bptr[5], 3, '|', sizeof mime_disposition);
691 extract_token(mime_content_type, &bptr[5], 4, '|', sizeof mime_content_type);
692 mime_length = extract_int(&bptr[5], 5);
694 if ( (!strcasecmp(mime_content_type, "text/calendar"))
695 || (!strcasecmp(mime_content_type, "application/ics"))
696 || (!strcasecmp(mime_content_type, "text/vtodo"))
697 || (!strcasecmp(mime_content_type, "text/todo"))
699 strcpy(relevant_partnum, mime_partnum);
702 else if (!strncasecmp(bptr, "from=", 4)) {
703 extract_token(from, bptr, 1, '=', sizeof(from));
705 else if ((phase == 0) && (!strncasecmp(bptr, "text", 4))) {
710 if (!IsEmptyStr(bptr)) {
711 if (!strncasecmp(bptr, "Content-type: ", 14)) {
712 safestrncpy(msg4_content_type, &bptr[14], sizeof msg4_content_type);
713 striplt(msg4_content_type);
715 else if (!strncasecmp(bptr, "Content-transfer-encoding: ", 27)) {
716 safestrncpy(msg4_content_encoding, &bptr[27], sizeof msg4_content_encoding);
717 striplt(msg4_content_type);
719 else if ((!strncasecmp(bptr, "Content-length: ", 16))) {
720 msg4_content_length = atoi(&bptr[16]);
727 if ((msg4_content_length > 0)
728 && ( !strcasecmp(msg4_content_encoding, "7bit"))
729 && ((!strcasecmp(mime_content_type, "text/calendar"))
730 || (!strcasecmp(mime_content_type, "application/ics"))
731 || (!strcasecmp(mime_content_type, "text/vtodo"))
732 || (!strcasecmp(mime_content_type, "text/todo"))
740 Data = NewStrBufPlain(NULL, msg4_content_length * 2);
741 if (msg4_content_length > 0) {
742 StrBuf_ServGetBLOBBuffered(Data, msg4_content_length);
746 StrBufAppendBuf(Data, Buf, 0);
747 StrBufAppendBufPlain(Data, "\r\n", 1, 0);
750 StrBufAppendBuf(Data, Buf, 0);
755 /* If MSG4 didn't give us the part we wanted, but we know that we can find it
756 * as one of the other MIME parts, attempt to load it now.
758 if ((Data == NULL) && (!IsEmptyStr(relevant_partnum))) {
759 Data = load_mimepart(msgnum, relevant_partnum);
763 relevant_source = (char*) ChrPtr(Data);
764 process_ical_object(msgnum, unread,
773 icalmemory_free_ring();
777 * Display a calendar item
779 int calendar_LoadMsgFromServer(SharedMessageStatus *Stat,
781 message_summary* Msg,
785 calview *c = (calview*) *ViewSpecific;
786 load_ical_object(Msg->msgnum, is_new, (-1), display_individual_cal, c, 1);
791 * display the editor component for an event
793 void display_edit_event(void) {
796 msgnum = lbstr("msgnum");
799 load_ical_object(msgnum, 0, ICAL_VEVENT_COMPONENT, display_edit_individual_event, NULL, 0);
803 display_edit_individual_event(NULL, 0L, "", 0, NULL);
808 * save an edited event
810 void save_event(void) {
813 msgnum = lbstr("msgnum");
816 load_ical_object(msgnum, 0, (-1), save_individual_event, NULL, 0);
819 save_individual_event(NULL, 0L, "", 0, NULL);
828 * Anonymous request of freebusy data for a user
830 void do_freebusy(void)
832 const char *req = ChrPtr(WC->Hdr->HR.ReqLine);
838 extract_token(who, req, 0, ' ', sizeof who);
839 if (!strncasecmp(who, "/freebusy/", 10)) {
840 strcpy(who, &who[10]);
845 if ( (!strcasecmp(&who[len-4], ".vcf"))
846 || (!strcasecmp(&who[len-4], ".ifb"))
847 || (!strcasecmp(&who[len-4], ".vfb")) ) {
851 lprintf(9, "freebusy requested for <%s>\n", who);
852 serv_printf("ICAL freebusy|%s", who);
853 serv_getln(buf, sizeof buf);
856 hprintf("HTTP/1.1 404 %s\n", &buf[4]);
857 output_headers(0, 0, 0, 0, 0, 0);
858 hprintf("Content-Type: text/plain\r\n");
859 wc_printf("%s\n", &buf[4]);
864 read_server_text(WC->WBuf, &lines);
865 http_transmit_thing("text/calendar", 0);
870 int calendar_Cleanup(void **ViewSpecific)
874 c = (calview *) *ViewSpecific;
878 *ViewSpecific = NULL;
883 int __calendar_Cleanup(void **ViewSpecific)
887 c = (calview *) *ViewSpecific;
890 *ViewSpecific = NULL;
900 RegisterReadLoopHandlerset(
902 calendar_GetParamsGetServerCall,
905 calendar_LoadMsgFromServer,
906 calendar_RenderView_or_Tail,
909 RegisterReadLoopHandlerset(
911 calendar_GetParamsGetServerCall,
914 calendar_LoadMsgFromServer,
915 calendar_RenderView_or_Tail,
920 RegisterPreference("daystart", _("Calendar day view begins at:"), PRF_INT, NULL);
921 RegisterPreference("dayend", _("Calendar day view ends at:"), PRF_INT, NULL);
922 RegisterPreference("weekstart", _("Week starts on:"), PRF_INT, NULL);
924 WebcitAddUrlHandler(HKEY("freebusy"), "", 0, do_freebusy, COOKIEUNNEEDED|ANONYMOUS|FORCE_SESSIONCLOSE);
925 WebcitAddUrlHandler(HKEY("display_edit_task"), "", 0, display_edit_task, 0);
926 WebcitAddUrlHandler(HKEY("display_edit_event"), "", 0, display_edit_event, 0);
927 WebcitAddUrlHandler(HKEY("save_event"), "", 0, save_event, 0);
928 WebcitAddUrlHandler(HKEY("respond_to_request"), "", 0, respond_to_request, 0);
929 WebcitAddUrlHandler(HKEY("handle_rsvp"), "", 0, handle_rsvp, 0);