2 * Functions which handle calendar objects and their processing/display.
4 * Copyright (c) 1996-2010 by the citadel.org team
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "webserver.h"
26 * Process a calendar object. At this point it's already been deserialized by cal_process_attachment()
28 * cal: the calendar object
29 * recursion_level: Number of times we've recursed into this function
30 * msgnum: Message number on the Citadel server
31 * cal_partnum: MIME part number within that message containing the calendar object
33 void cal_process_object(StrBuf *Target,
37 const char *cal_partnum)
40 icalproperty *method = NULL;
41 icalproperty_method the_method = ICAL_METHOD_NONE;
43 struct icaltimetype t;
46 char conflict_name[256];
47 char conflict_message[256];
50 static int divcount = 0;
52 sprintf(divname, "rsvp%04x", ++divcount);
54 /* Convert timezones to something easy to display.
55 * It's safe to do this in memory because we're only changing it on the
56 * display side -- when we tell the server to do something with the object,
57 * the server will be working with its original copy in the database.
59 if ((cal) && (recursion_level == 0)) {
63 /* Leading HTML for the display of this object */
64 if (recursion_level == 0) {
65 StrBufAppendPrintf(Target, "<div class=\"mimepart\">\n");
68 /* Look for a method */
69 method = icalcomponent_get_first_property(cal, ICAL_METHOD_PROPERTY);
71 /* See what we need to do with this */
74 the_method = icalproperty_get_method(method);
76 StrBufAppendPrintf(Target, "<div id=\"%s_title\">", divname);
77 StrBufAppendPrintf(Target, "<img src=\"static/calarea_48x.gif\">");
78 StrBufAppendPrintf(Target, "<span>");
80 case ICAL_METHOD_REQUEST:
81 title = _("Meeting invitation");
83 case ICAL_METHOD_REPLY:
84 title = _("Attendee's reply to your invitation");
86 case ICAL_METHOD_PUBLISH:
87 title = _("Published event");
90 title = _("This is an unknown type of calendar item.");
93 StrBufAppendPrintf(Target, "</span>");
95 StrBufAppendPrintf(Target, " %s",title);
96 StrBufAppendPrintf(Target, "</div>");
99 StrBufAppendPrintf(Target, "<dl>");
100 p = icalcomponent_get_first_property(cal, ICAL_SUMMARY_PROPERTY);
102 StrBufAppendPrintf(Target, "<dt>");
103 StrBufAppendPrintf(Target, _("Summary:"));
104 StrBufAppendPrintf(Target, "</dt><dd>");
105 StrEscAppend(Target, NULL, (char *)icalproperty_get_comment(p), 0, 0);
106 StrBufAppendPrintf(Target, "</dd>\n");
109 p = icalcomponent_get_first_property(cal, ICAL_LOCATION_PROPERTY);
111 StrBufAppendPrintf(Target, "<dt>");
112 StrBufAppendPrintf(Target, _("Location:"));
113 StrBufAppendPrintf(Target, "</dt><dd>");
114 StrEscAppend(Target, NULL, (char *)icalproperty_get_comment(p), 0, 0);
115 StrBufAppendPrintf(Target, "</dd>\n");
119 * Only show start/end times if we're actually looking at the VEVENT
120 * component. Otherwise it shows bogus dates for things like timezone.
122 if (icalcomponent_isa(cal) == ICAL_VEVENT_COMPONENT) {
124 p = icalcomponent_get_first_property(cal, ICAL_DTSTART_PROPERTY);
126 t = icalproperty_get_dtstart(p);
131 memset(&d_tm, 0, sizeof d_tm);
132 d_tm.tm_year = t.year - 1900;
133 d_tm.tm_mon = t.month - 1;
134 d_tm.tm_mday = t.day;
135 wc_strftime(d_str, sizeof d_str, "%x", &d_tm);
136 StrBufAppendPrintf(Target, "<dt>");
137 StrBufAppendPrintf(Target, _("Date:"));
138 StrBufAppendPrintf(Target, "</dt><dd>%s</dd>", d_str);
141 tt = icaltime_as_timet(t);
142 webcit_fmt_date(buf, 256, tt, DATEFMT_FULL);
143 StrBufAppendPrintf(Target, "<dt>");
144 StrBufAppendPrintf(Target, _("Starting date/time:"));
145 StrBufAppendPrintf(Target, "</dt><dd>%s</dd>", buf);
149 p = icalcomponent_get_first_property(cal, ICAL_DTEND_PROPERTY);
151 t = icalproperty_get_dtend(p);
152 tt = icaltime_as_timet(t);
153 webcit_fmt_date(buf, 256, tt, DATEFMT_FULL);
154 StrBufAppendPrintf(Target, "<dt>");
155 StrBufAppendPrintf(Target, _("Ending date/time:"));
156 StrBufAppendPrintf(Target, "</dt><dd>%s</dd>", buf);
161 p = icalcomponent_get_first_property(cal, ICAL_DESCRIPTION_PROPERTY);
163 StrBufAppendPrintf(Target, "<dt>");
164 StrBufAppendPrintf(Target, _("Description:"));
165 StrBufAppendPrintf(Target, "</dt><dd>");
166 StrEscAppend(Target, NULL, (char *)icalproperty_get_comment(p), 0, 0);
167 StrBufAppendPrintf(Target, "</dd>\n");
170 if (icalcomponent_get_first_property(cal, ICAL_RRULE_PROPERTY)) {
171 /* Unusual string syntax used here in order to re-use existing translations */
172 StrBufAppendPrintf(Target, "<dt>%s:</dt><dd>%s.</dd>\n",
174 _("This is a recurring event")
178 /* If the component has attendees, iterate through them. */
179 for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY);
181 p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) {
182 StrBufAppendPrintf(Target, "<dt>");
183 StrBufAppendPrintf(Target, _("Attendee:"));
184 StrBufAppendPrintf(Target, "</dt><dd>");
185 safestrncpy(buf, icalproperty_get_attendee(p), sizeof buf);
186 if (!strncasecmp(buf, "MAILTO:", 7)) {
188 /** screen name or email address */
189 strcpy(buf, &buf[7]);
191 StrEscAppend(Target, NULL, buf, 0, 0);
192 StrBufAppendPrintf(Target, " ");
194 /** participant status */
195 partstat_as_string(buf, p);
196 StrEscAppend(Target, NULL, buf, 0, 0);
198 StrBufAppendPrintf(Target, "</dd>\n");
201 /* If the component has subcomponents, recurse through them. */
202 for (c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT);
204 c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)) {
205 /* Recursively process subcomponent */
206 cal_process_object(Target, c, recursion_level+1, msgnum, cal_partnum);
209 /* If this is a REQUEST, display conflicts and buttons */
210 if (the_method == ICAL_METHOD_REQUEST) {
212 /* Check for conflicts */
213 lprintf(9, "Checking server calendar for conflicts...\n");
214 serv_printf("ICAL conflicts|%ld|%s|", msgnum, cal_partnum);
215 serv_getln(buf, sizeof buf);
217 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
218 extract_token(conflict_name, buf, 3, '|', sizeof conflict_name);
219 is_update = extract_int(buf, 4);
222 snprintf(conflict_message, sizeof conflict_message,
223 _("This is an update of '%s' which is already in your calendar."), conflict_name);
226 snprintf(conflict_message, sizeof conflict_message,
227 _("This event would conflict with '%s' which is already in your calendar."), conflict_name);
230 StrBufAppendPrintf(Target, "<dt>%s",
236 StrBufAppendPrintf(Target, "</dt><dd>");
237 StrEscAppend(Target, NULL, conflict_message, 0, 0);
238 StrBufAppendPrintf(Target, "</dd>\n");
241 lprintf(9, "...done.\n");
243 StrBufAppendPrintf(Target, "</dl>");
245 /* Display the Accept/Decline buttons */
246 StrBufAppendPrintf(Target, "<p id=\"%s_question\">"
248 " <span class=\"button_link\"> "
249 "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Accept');\">%s</a>"
250 "</span> <span class=\"button_link\">"
251 "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Tentative');\">%s</a>"
252 "</span> <span class=\"button_link\">"
253 "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Decline');\">%s</a>"
256 _("How would you like to respond to this invitation?"),
257 divname, divname, msgnum, cal_partnum, _("Accept"),
258 divname, divname, msgnum, cal_partnum, _("Tentative"),
259 divname, divname, msgnum, cal_partnum, _("Decline")
264 /* If this is a REPLY, display update button */
265 if (the_method == ICAL_METHOD_REPLY) {
267 /* Display the update buttons */
268 StrBufAppendPrintf(Target, "<p id=\"%s_question\" >"
270 " <span class=\"button_link\"> "
271 "<a href=\"javascript:HandleRSVP('%s_question','%s_title','%ld','%s','Update');\">%s</a>"
272 "</span> <span class=\"button_link\">"
273 "<a href=\"javascript:HandleRSVP('%s_question','%s_title','%ld','%s','Ignore');\">%s</a>"
276 _("Click <i>Update</i> to accept this reply and update your calendar."),
277 divname, divname, msgnum, cal_partnum, _("Update"),
278 divname, divname, msgnum, cal_partnum, _("Ignore")
283 /* Trailing HTML for the display of this object */
284 if (recursion_level == 0) {
285 StrBufAppendPrintf(Target, "<p> </p></div>\n");
291 * Deserialize a calendar object in a message so it can be displayed.
293 void cal_process_attachment(wc_mime_attachment *Mime)
297 cal = icalcomponent_new_from_string(ChrPtr(Mime->Data));
298 FlushStrBuf(Mime->Data);
300 StrBufAppendPrintf(Mime->Data, _("There was an error parsing this calendar item."));
301 StrBufAppendPrintf(Mime->Data, "<br />\n");
305 cal_process_object(Mime->Data, cal, 0, Mime->msgnum, ChrPtr(Mime->PartNum));
307 /* Free the memory we obtained from libical's constructor */
308 icalcomponent_free(cal);
315 * Respond to a meeting request - accept/decline meeting
317 void respond_to_request(void)
321 begin_ajax_response();
323 serv_printf("ICAL respond|%s|%s|%s|",
328 serv_getln(buf, sizeof buf);
331 wc_printf("<img src=\"static/calarea_48x.gif\"><span>");
332 if (!strcasecmp(bstr("sc"), "accept")) {
333 wc_printf(_("You have accepted this meeting invitation. "
334 "It has been entered into your calendar.")
336 } else if (!strcasecmp(bstr("sc"), "tentative")) {
337 wc_printf(_("You have tentatively accepted this meeting invitation. "
338 "It has been 'pencilled in' to your calendar.")
340 } else if (!strcasecmp(bstr("sc"), "decline")) {
341 wc_printf(_("You have declined this meeting invitation. "
342 "It has <b>not</b> been entered into your calendar.")
346 wc_printf(_("A reply has been sent to the meeting organizer."));
347 wc_printf("</span>");
349 wc_printf("<img align=\"center\" src=\"static/error.gif\"><span>");
350 wc_printf("%s\n", &buf[4]);
351 wc_printf("</span>");
360 * Handle an incoming RSVP
362 void handle_rsvp(void)
366 begin_ajax_response();
368 serv_printf("ICAL handle_rsvp|%s|%s|%s|",
373 serv_getln(buf, sizeof buf);
376 wc_printf("<img src=\"static/calarea_48x.gif\"><span>");
377 if (!strcasecmp(bstr("sc"), "update")) {
378 wc_printf(_("Your calendar has been updated to reflect this RSVP."));
379 } else if (!strcasecmp(bstr("sc"), "ignore")) {
380 wc_printf(_("You have chosen to ignore this RSVP. "
381 "Your calendar has <b>not</b> been updated.")
384 wc_printf("</span>");
386 wc_printf("<img src=\"static/error.gif\"><span> %s\n", &buf[4]);
387 wc_printf("</span>");
397 * free memory allocated using libical
399 void delete_cal(void *vCal)
401 disp_cal *Cal = (disp_cal*) vCal;
402 icalcomponent_free(Cal->cal);
408 * This is the meat-and-bones of the first part of our two-phase calendar display.
409 * As we encounter calendar items in messages being read from the server, we break out
410 * any iCalendar objects and store them in a hash table. Later on, the second phase will
411 * use this hash table to render the calendar for display.
413 void display_individual_cal(icalcomponent *cal, long msgnum, char *from, int unread, calview *calv)
415 icalproperty *ps = NULL;
416 struct icaltimetype dtstart, dtend;
417 struct icaldurationtype dur;
421 time_t final_recurrence = 0;
422 icalcomponent *cptr = NULL;
424 /* recur variables */
425 icalproperty *rrule = NULL;
426 struct icalrecurrencetype recur;
427 icalrecur_iterator *ritr = NULL;
428 struct icaltimetype next;
432 dtstart = icaltime_null_time();
433 dtend = icaltime_null_time();
435 if (WCC->disp_cal_items == NULL)
436 WCC->disp_cal_items = NewHash(0, Flathash);
438 /* Note: anything we do here, we also have to do below for the recurrences. */
439 Cal = (disp_cal*) malloc(sizeof(disp_cal));
440 memset(Cal, 0, sizeof(disp_cal));
441 Cal->cal = icalcomponent_new_clone(cal);
443 /* Dezonify and decapsulate at the very last moment */
444 /* lprintf(9, "INITIAL: %s\n", icaltime_as_ical_string(icalproperty_get_dtstart(
445 icalcomponent_get_first_property(icalcomponent_get_first_component(
446 Cal->cal, ICAL_VEVENT_COMPONENT), ICAL_DTSTART_PROPERTY)))
448 ical_dezonify(Cal->cal);
449 if (icalcomponent_isa(Cal->cal) != ICAL_VEVENT_COMPONENT) {
450 cptr = icalcomponent_get_first_component(Cal->cal, ICAL_VEVENT_COMPONENT);
452 cptr = icalcomponent_new_clone(cptr);
453 icalcomponent_free(Cal->cal);
458 Cal->unread = unread;
460 Cal->from = (char*)malloc(len+ 1);
461 memcpy(Cal->from, from, len + 1);
462 Cal->cal_msgnum = msgnum;
464 /* Precalculate the starting date and time of this event, and store it in our top-level
465 * structure. Later, when we are rendering the calendar, we can just peek at these values
466 * without having to break apart every calendar item.
468 ps = icalcomponent_get_first_property(Cal->cal, ICAL_DTSTART_PROPERTY);
470 dtstart = icalproperty_get_dtstart(ps);
471 Cal->event_start = icaltime_as_timet(dtstart);
474 /* Do the same for the ending date and time. It makes the day view much easier to render. */
475 ps = icalcomponent_get_first_property(Cal->cal, ICAL_DTEND_PROPERTY);
477 dtend = icalproperty_get_dtend(ps);
478 Cal->event_end = icaltime_as_timet(dtend);
481 /* Store it in the hash list. */
482 Put(WCC->disp_cal_items,
483 (char*) &Cal->event_start,
484 sizeof(Cal->event_start),
488 /****************************** handle recurring events ******************************/
490 if (icaltime_is_null_time(dtstart)) return; /* Can't recur without a start time */
492 if (!icaltime_is_null_time(dtend)) { /* Need duration for recurrences */
493 dur = icaltime_subtract(dtend, dtstart);
497 * Just let libical iterate the recurrence, and keep looping back to the top of this function,
498 * adding new hash entries that all point back to the same msgnum, until either the iteration
499 * stops or some outer bound is reached. The display code will automatically do the Right Thing.
502 if (icalcomponent_isa(cptr) != ICAL_VEVENT_COMPONENT) {
503 cptr = icalcomponent_get_first_component(cptr, ICAL_VEVENT_COMPONENT);
506 ps = icalcomponent_get_first_property(cptr, ICAL_DTSTART_PROPERTY);
507 if (ps == NULL) return;
508 dtstart = icalproperty_get_dtstart(ps);
509 rrule = icalcomponent_get_first_property(cptr, ICAL_RRULE_PROPERTY);
511 recur = icalproperty_get_rrule(rrule);
512 ritr = icalrecur_iterator_new(recur, dtstart);
515 while (next = icalrecur_iterator_next(ritr), ((!icaltime_is_null_time(next))&&(!stop_rr)) ) {
517 if (num_recur > 1) { /* Skip the first one. We already did it at the root. */
519 /* lprintf(9, "REPEATS: %s\n", icaltime_as_ical_string(next)); */
521 /* Note: anything we do here, we also have to do above for the root event. */
522 Cal = (disp_cal*) malloc(sizeof(disp_cal));
523 memset(Cal, 0, sizeof(disp_cal));
524 Cal->cal = icalcomponent_new_clone(cal);
525 Cal->unread = unread;
527 Cal->from = (char*)malloc(len+ 1);
528 memcpy(Cal->from, from, len + 1);
529 Cal->cal_msgnum = msgnum;
531 if (icalcomponent_isa(Cal->cal) == ICAL_VEVENT_COMPONENT) {
535 cptr = icalcomponent_get_first_component(Cal->cal, ICAL_VEVENT_COMPONENT);
538 ps = icalcomponent_get_first_property(cptr, ICAL_DTSTART_PROPERTY);
540 icalcomponent_remove_property(cptr, ps);
541 ps = icalproperty_new_dtstart(next);
542 icalcomponent_add_property(cptr, ps);
544 Cal->event_start = icaltime_as_timet(next);
545 final_recurrence = Cal->event_start;
548 ps = icalcomponent_get_first_property(cptr, ICAL_DTEND_PROPERTY);
550 icalcomponent_remove_property(cptr, ps);
552 /* Make a new dtend */
553 ps = icalproperty_new_dtend(icaltime_add(next, dur));
555 /* and stick it somewhere */
556 icalcomponent_add_property(cptr, ps);
561 /* Dezonify and decapsulate at the very last moment */
562 ical_dezonify(Cal->cal);
563 if (icalcomponent_isa(Cal->cal) != ICAL_VEVENT_COMPONENT) {
564 cptr = icalcomponent_get_first_component(Cal->cal, ICAL_VEVENT_COMPONENT);
566 cptr = icalcomponent_new_clone(cptr);
567 icalcomponent_free(Cal->cal);
572 if ( (Cal->event_start > calv->lower_bound)
573 && (Cal->event_start < calv->upper_bound) ) {
574 Put(WCC->disp_cal_items,
575 (char*) &Cal->event_start,
576 sizeof(Cal->event_start),
585 /* If an upper bound is set, stop when we go out of scope */
586 if (final_recurrence > calv->upper_bound) stop_rr = 1;
589 icalrecur_iterator_free(ritr);
590 /* lprintf(9, "Performed %d recurrences; final one is %s", num_recur, ctime(&final_recurrence)); */
599 void process_ical_object(long msgnum, int unread,
602 icalcomponent_kind which_kind,
603 IcalCallbackFunc CallBack,
607 icalcomponent *cal, *c;
609 cal = icalcomponent_new_from_string(FlatIcal);
612 /* A which_kind of (-1) means just load the whole thing */
613 if (which_kind == (-1)) {
614 CallBack(cal, msgnum, from, unread, calv);
617 /* Otherwise recurse and hunt */
620 /* Simple components of desired type */
621 if (icalcomponent_isa(cal) == which_kind) {
622 CallBack(cal, msgnum, from, unread, calv);
625 /* Subcomponents of desired type */
626 for (c = icalcomponent_get_first_component(cal, which_kind);
628 c = icalcomponent_get_next_component(cal, which_kind)) {
629 CallBack(c, msgnum, from, unread, calv);
634 icalcomponent_free(cal);
639 * Code common to all icalendar display handlers. Given a message number and a MIME
640 * type, we load the message and hunt for that MIME type. If found, we load
641 * the relevant part, deserialize it into a libical component, filter it for
642 * the requested object type, and feed it to the specified handler.
644 void load_ical_object(long msgnum, int unread,
645 icalcomponent_kind which_kind,
646 IcalCallbackFunc CallBack,
656 char mime_partnum[256];
657 char mime_filename[256];
658 char mime_content_type[256];
659 char mime_disposition[256];
661 char relevant_partnum[256];
662 char *relevant_source = NULL;
663 int phase = 0; /* 0 = citadel headers, 1 = mime headers, 2 = body */
664 char msg4_content_type[256] = "";
665 char msg4_content_encoding[256] = "";
666 int msg4_content_length = 0;
668 relevant_partnum[0] = '\0';
669 serv_printf("MSG4 %ld", msgnum); /* we need the mime headers */
671 StrBuf_ServGetln(Buf);
672 if (GetServerStatus(Buf, NULL) != 1) {
676 while (!Done && (StrBuf_ServGetln(Buf)>=0)) {
677 if ( (StrLength(Buf)==3) &&
678 !strcmp(ChrPtr(Buf), "000")) {
685 if (!strncasecmp(bptr, "part=", 5)) {
686 extract_token(mime_filename, &bptr[5], 1, '|', sizeof mime_filename);
687 extract_token(mime_partnum, &bptr[5], 2, '|', sizeof mime_partnum);
688 extract_token(mime_disposition, &bptr[5], 3, '|', sizeof mime_disposition);
689 extract_token(mime_content_type, &bptr[5], 4, '|', sizeof mime_content_type);
690 mime_length = extract_int(&bptr[5], 5);
692 if ( (!strcasecmp(mime_content_type, "text/calendar"))
693 || (!strcasecmp(mime_content_type, "application/ics"))
694 || (!strcasecmp(mime_content_type, "text/vtodo"))
695 || (!strcasecmp(mime_content_type, "text/todo"))
697 strcpy(relevant_partnum, mime_partnum);
700 else if (!strncasecmp(bptr, "from=", 4)) {
701 extract_token(from, bptr, 1, '=', sizeof(from));
703 else if ((phase == 0) && (!strncasecmp(bptr, "text", 4))) {
708 if (!IsEmptyStr(bptr)) {
709 if (!strncasecmp(bptr, "Content-type: ", 14)) {
710 safestrncpy(msg4_content_type, &bptr[14], sizeof msg4_content_type);
711 striplt(msg4_content_type);
713 else if (!strncasecmp(bptr, "Content-transfer-encoding: ", 27)) {
714 safestrncpy(msg4_content_encoding, &bptr[27], sizeof msg4_content_encoding);
715 striplt(msg4_content_type);
717 else if ((!strncasecmp(bptr, "Content-length: ", 16))) {
718 msg4_content_length = atoi(&bptr[16]);
725 if ((msg4_content_length > 0)
726 && ( !strcasecmp(msg4_content_encoding, "7bit"))
727 && ((!strcasecmp(mime_content_type, "text/calendar"))
728 || (!strcasecmp(mime_content_type, "application/ics"))
729 || (!strcasecmp(mime_content_type, "text/vtodo"))
730 || (!strcasecmp(mime_content_type, "text/todo"))
738 Data = NewStrBufPlain(NULL, msg4_content_length * 2);
739 if (msg4_content_length > 0) {
740 StrBuf_ServGetBLOBBuffered(Data, msg4_content_length);
744 StrBufAppendBuf(Data, Buf, 0);
745 StrBufAppendBufPlain(Data, "\r\n", 1, 0);
748 StrBufAppendBuf(Data, Buf, 0);
753 /* If MSG4 didn't give us the part we wanted, but we know that we can find it
754 * as one of the other MIME parts, attempt to load it now.
756 if ((Data == NULL) && (!IsEmptyStr(relevant_partnum))) {
757 Data = load_mimepart(msgnum, relevant_partnum);
761 relevant_source = (char*) ChrPtr(Data);
762 process_ical_object(msgnum, unread,
771 icalmemory_free_ring();
775 * Display a calendar item
777 int calendar_LoadMsgFromServer(SharedMessageStatus *Stat,
779 message_summary* Msg,
783 calview *c = (calview*) *ViewSpecific;
784 load_ical_object(Msg->msgnum, is_new, (-1), display_individual_cal, c, 1);
789 * display the editor component for an event
791 void display_edit_event(void) {
794 msgnum = lbstr("msgnum");
797 load_ical_object(msgnum, 0, ICAL_VEVENT_COMPONENT, display_edit_individual_event, NULL, 0);
801 display_edit_individual_event(NULL, 0L, "", 0, NULL);
806 * save an edited event
808 void save_event(void) {
811 msgnum = lbstr("msgnum");
814 load_ical_object(msgnum, 0, (-1), save_individual_event, NULL, 0);
817 save_individual_event(NULL, 0L, "", 0, NULL);
826 * Anonymous request of freebusy data for a user
828 void do_freebusy(void)
830 const char *req = ChrPtr(WC->Hdr->HR.ReqLine);
836 extract_token(who, req, 0, ' ', sizeof who);
837 if (!strncasecmp(who, "/freebusy/", 10)) {
838 strcpy(who, &who[10]);
843 if ( (!strcasecmp(&who[len-4], ".vcf"))
844 || (!strcasecmp(&who[len-4], ".ifb"))
845 || (!strcasecmp(&who[len-4], ".vfb")) ) {
849 lprintf(9, "freebusy requested for <%s>\n", who);
850 serv_printf("ICAL freebusy|%s", who);
851 serv_getln(buf, sizeof buf);
854 hprintf("HTTP/1.1 404 %s\n", &buf[4]);
855 output_headers(0, 0, 0, 0, 0, 0);
856 hprintf("Content-Type: text/plain\r\n");
857 wc_printf("%s\n", &buf[4]);
862 read_server_text(WC->WBuf, &lines);
863 http_transmit_thing("text/calendar", 0);
868 int calendar_Cleanup(void **ViewSpecific)
872 c = (calview *) *ViewSpecific;
876 *ViewSpecific = NULL;
881 int __calendar_Cleanup(void **ViewSpecific)
885 c = (calview *) *ViewSpecific;
888 *ViewSpecific = NULL;
898 RegisterReadLoopHandlerset(
900 calendar_GetParamsGetServerCall,
903 calendar_LoadMsgFromServer,
904 calendar_RenderView_or_Tail,
907 RegisterReadLoopHandlerset(
909 calendar_GetParamsGetServerCall,
912 calendar_LoadMsgFromServer,
913 calendar_RenderView_or_Tail,
918 RegisterPreference("daystart", _("Calendar day view begins at:"), PRF_INT, NULL);
919 RegisterPreference("dayend", _("Calendar day view ends at:"), PRF_INT, NULL);
920 RegisterPreference("weekstart", _("Week starts on:"), PRF_INT, NULL);
922 WebcitAddUrlHandler(HKEY("freebusy"), "", 0, do_freebusy, COOKIEUNNEEDED|ANONYMOUS|FORCE_SESSIONCLOSE);
923 WebcitAddUrlHandler(HKEY("display_edit_task"), "", 0, display_edit_task, 0);
924 WebcitAddUrlHandler(HKEY("display_edit_event"), "", 0, display_edit_event, 0);
925 WebcitAddUrlHandler(HKEY("save_event"), "", 0, save_event, 0);
926 WebcitAddUrlHandler(HKEY("respond_to_request"), "", 0, respond_to_request, 0);
927 WebcitAddUrlHandler(HKEY("handle_rsvp"), "", 0, handle_rsvp, 0);