00001
00002
00003
00008
00009
00010 #include "webcit.h"
00011 #include "webserver.h"
00012
00013 #ifndef WEBCIT_WITH_CALENDAR_SERVICE
00014
00022 void cal_process_attachment(char *part_source, long msgnum, char *cal_partnum) {
00023
00024 wprintf(_("<I>This message contains calendaring/scheduling information,"
00025 " but support for calendars is not available on this "
00026 "particular system. Please ask your system administrator to "
00027 "install a new version of the Citadel web service with "
00028 "calendaring enabled.</I><br />\n")
00029 );
00030
00031 }
00032
00037 void display_calendar(long msgnum) {
00038 wprintf(_("<i>"
00039 "Cannot display calendar item. You are seeing this error "
00040 "because your WebCit service has not been installed with "
00041 "calendar support. Please contact your system administrator."
00042 "</i><br />\n"));
00043 }
00044
00049 void display_task(long msgnum) {
00050 wprintf(_("<i>"
00051 "Cannot display to-do item. You are seeing this error "
00052 "because your WebCit service has not been installed with "
00053 "calendar support. Please contact your system administrator."
00054 "</i><br />\n"));
00055 }
00057 #else
00058
00059
00060
00061
00062
00063
00064
00073 void cal_process_object(icalcomponent *cal,
00074 int recursion_level,
00075 long msgnum,
00076 char *cal_partnum
00077 ) {
00078 icalcomponent *c;
00079 icalproperty *method = NULL;
00080 icalproperty_method the_method = ICAL_METHOD_NONE;
00081 icalproperty *p;
00082 struct icaltimetype t;
00083 time_t tt;
00084 char buf[256];
00085 char conflict_name[256];
00086 char conflict_message[256];
00087 int is_update = 0;
00088 char divname[32];
00089 static int divcount = 0;
00090
00091 sprintf(divname, "rsvp%04x", ++divcount);
00092
00094 if (recursion_level == 0) {
00095 wprintf("<div align=center><table border=0 bgcolor=\"#ffd\">\n");
00096 }
00097
00099 method = icalcomponent_get_first_property(cal, ICAL_METHOD_PROPERTY);
00100
00102 if (method != NULL) {
00103 the_method = icalproperty_get_method(method);
00104 char *title;
00105
00106 switch(the_method) {
00107 case ICAL_METHOD_REQUEST:
00108 title = _("Meeting invitation");
00109 break;
00110 case ICAL_METHOD_REPLY:
00111 title = _("Attendee's reply to your invitation");
00112 break;
00113 case ICAL_METHOD_PUBLISH:
00114 title = _("Published event");
00115 break;
00116 default:
00117 title = _("This is an unknown type of calendar item.");
00118 break;
00119 }
00120
00121 wprintf("<tr><td colspan=\"2\">\n");
00122 wprintf("<div id=\"%s_title\">", divname);
00123 wprintf("<img align=\"center\" "
00124 "src=\"static/calarea_48x.gif\">"
00125 " <b>%s</b></div></td></TD></TR>\n",
00126 title
00127 );
00128 }
00129
00130 p = icalcomponent_get_first_property(cal, ICAL_SUMMARY_PROPERTY);
00131 if (p != NULL) {
00132 wprintf("<TR><TD><B>");
00133 wprintf(_("Summary:"));
00134 wprintf("</B></TD><TD>");
00135 escputs((char *)icalproperty_get_comment(p));
00136 wprintf("</TD></TR>\n");
00137 }
00138
00139 p = icalcomponent_get_first_property(cal, ICAL_LOCATION_PROPERTY);
00140 if (p != NULL) {
00141 wprintf("<TR><TD><B>");
00142 wprintf(_("Location:"));
00143 wprintf("</B></TD><TD>");
00144 escputs((char *)icalproperty_get_comment(p));
00145 wprintf("</TD></TR>\n");
00146 }
00147
00152 if (icalcomponent_isa(cal) == ICAL_VEVENT_COMPONENT) {
00153
00154 p = icalcomponent_get_first_property(cal,
00155 ICAL_DTSTART_PROPERTY);
00156 if (p != NULL) {
00157 t = icalproperty_get_dtstart(p);
00158
00159 if (t.is_date) {
00160 struct tm d_tm;
00161 char d_str[32];
00162 memset(&d_tm, 0, sizeof d_tm);
00163 d_tm.tm_year = t.year - 1900;
00164 d_tm.tm_mon = t.month - 1;
00165 d_tm.tm_mday = t.day;
00166 wc_strftime(d_str, sizeof d_str, "%x", &d_tm);
00167 wprintf("<TR><TD><B>");
00168 wprintf(_("Date:"));
00169 wprintf("</B></TD><TD>%s</TD></TR>", d_str);
00170 }
00171 else {
00172 tt = icaltime_as_timet(t);
00173 fmt_date(buf, tt, 0);
00174 wprintf("<TR><TD><B>");
00175 wprintf(_("Starting date/time:"));
00176 wprintf("</B></TD><TD>%s</TD></TR>", buf);
00177 }
00178 }
00179
00180 p = icalcomponent_get_first_property(cal, ICAL_DTEND_PROPERTY);
00181 if (p != NULL) {
00182 t = icalproperty_get_dtend(p);
00183 tt = icaltime_as_timet(t);
00184 fmt_date(buf, tt, 0);
00185 wprintf("<TR><TD><B>");
00186 wprintf(_("Ending date/time:"));
00187 wprintf("</B></TD><TD>%s</TD></TR>", buf);
00188 }
00189
00190 }
00191
00192 p = icalcomponent_get_first_property(cal, ICAL_DESCRIPTION_PROPERTY);
00193 if (p != NULL) {
00194 wprintf("<TR><TD><B>");
00195 wprintf(_("Description:"));
00196 wprintf("</B></TD><TD>");
00197 escputs((char *)icalproperty_get_comment(p));
00198 wprintf("</TD></TR>\n");
00199 }
00200
00202 for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY); (p != NULL); p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) {
00203 wprintf("<TR><TD><B>");
00204 wprintf(_("Attendee:"));
00205 wprintf("</B></TD><TD>");
00206 safestrncpy(buf, icalproperty_get_attendee(p), sizeof buf);
00207 if (!strncasecmp(buf, "MAILTO:", 7)) {
00208
00210 strcpy(buf, &buf[7]);
00211 striplt(buf);
00212 escputs(buf);
00213 wprintf(" ");
00214
00216 partstat_as_string(buf, p);
00217 escputs(buf);
00218 }
00219 wprintf("</TD></TR>\n");
00220 }
00221
00223 for (c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT);
00224 (c != 0);
00225 c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)) {
00226
00227 cal_process_object(c, recursion_level+1, msgnum, cal_partnum);
00228 }
00229
00231 if (the_method == ICAL_METHOD_REQUEST) {
00232
00233
00234 lprintf(9, "Checking server calendar for conflicts...\n");
00235 serv_printf("ICAL conflicts|%ld|%s|", msgnum, cal_partnum);
00236 serv_getln(buf, sizeof buf);
00237 if (buf[0] == '1') {
00238 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
00239 extract_token(conflict_name, buf, 3, '|', sizeof conflict_name);
00240 is_update = extract_int(buf, 4);
00241
00242 if (is_update) {
00243 snprintf(conflict_message, sizeof conflict_message,
00244 _("This is an update of '%s' which is already in your calendar."), conflict_name);
00245 }
00246 else {
00247 snprintf(conflict_message, sizeof conflict_message,
00248 _("This event would conflict with '%s' which is already in your calendar."), conflict_name);
00249 }
00250
00251 wprintf("<TR><TD><B><I>%s</I></B></TD><td>",
00252 (is_update ?
00253 _("Update:") :
00254 _("CONFLICT:")
00255 )
00256 );
00257 escputs(conflict_message);
00258 wprintf("</TD></TR>\n");
00259 }
00260 }
00261 lprintf(9, "...done.\n");
00262
00264 wprintf("<tr><td colspan=2>"
00265 "<div id=\"%s_question\">"
00266 "%s "
00267 "<font size=+1>"
00268 "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Accept');\">%s</a>"
00269 " | "
00270 "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Tentative');\">%s</a>"
00271 " | "
00272 "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Decline');\">%s</a>"
00273 "</font>"
00274 "</div>"
00275 "</td></tr>\n",
00276 divname,
00277 _("How would you like to respond to this invitation?"),
00278 divname, divname, msgnum, cal_partnum, _("Accept"),
00279 divname, divname, msgnum, cal_partnum, _("Tentative"),
00280 divname, divname, msgnum, cal_partnum, _("Decline")
00281 );
00282
00283 }
00284
00286 if (the_method == ICAL_METHOD_REPLY) {
00287
00296 wprintf("<tr><td colspan=2>"
00297 "<div id=\"%s_question\">"
00298 "%s"
00299 "<font size=+1>"
00300 "<a href=\"javascript:HandleRSVP('%s_question','%s_title','%ld','%s','Update');\">%s</a>"
00301 " | "
00302 "<a href=\"javascript:HandleRSVP('%s_question','%s_title','%ld','%s','Ignore');\">%s</a>"
00303 "</font>"
00304 "</div>"
00305 "</td></tr>\n",
00306 divname,
00307 _("Click <i>Update</i> to accept this reply and update your calendar."),
00308 divname, divname, msgnum, cal_partnum, _("Update"),
00309 divname, divname, msgnum, cal_partnum, _("Ignore")
00310 );
00311
00312 }
00313
00315 if (recursion_level == 0) {
00316 wprintf("</tr></table></div>\n");
00317 }
00318 }
00319
00320
00329 void cal_process_attachment(char *part_source, long msgnum, char *cal_partnum) {
00330 icalcomponent *cal;
00331
00332 cal = icalcomponent_new_from_string(part_source);
00333
00334 if (cal == NULL) {
00335 wprintf(_("There was an error parsing this calendar item."));
00336 wprintf("<br />\n");
00337 return;
00338 }
00339
00340 ical_dezonify(cal);
00341 cal_process_object(cal, 0, msgnum, cal_partnum);
00342
00343
00344 icalcomponent_free(cal);
00345 }
00346
00347
00348
00349
00354 void respond_to_request(void) {
00355 char buf[1024];
00356
00357 begin_ajax_response();
00358
00359 serv_printf("ICAL respond|%s|%s|%s|",
00360 bstr("msgnum"),
00361 bstr("cal_partnum"),
00362 bstr("sc")
00363 );
00364 serv_getln(buf, sizeof buf);
00365
00366 if (buf[0] == '2') {
00367 wprintf("<table border=0 cellpadding=0><tr><td>");
00368 wprintf("<td><img align=\"center\" src=\"static/calarea_48x.gif\"></td><td><b><i>");
00369 if (!strcasecmp(bstr("sc"), "accept")) {
00370 wprintf(_("You have accepted this meeting invitation. "
00371 "It has been entered into your calendar.")
00372 );
00373 } else if (!strcasecmp(bstr("sc"), "tentative")) {
00374 wprintf(_("You have tentatively accepted this meeting invitation. "
00375 "It has been 'pencilled in' to your calendar.")
00376 );
00377 } else if (!strcasecmp(bstr("sc"), "decline")) {
00378 wprintf(_("You have declined this meeting invitation. "
00379 "It has <b>not</b> been entered into your calendar.")
00380 );
00381 }
00382 wprintf(" ");
00383 wprintf(_("A reply has been sent to the meeting organizer."));
00384 wprintf("</i></b></td></tr></table>");
00385 } else {
00386 wprintf("<img align=\"center\" src=\"static/error.gif\"> <b><i>");
00387 wprintf("%s\n", &buf[4]);
00388 }
00389
00390 end_ajax_response();
00391 }
00392
00393
00394
00398 void handle_rsvp(void) {
00399 char buf[1024];
00400
00401 begin_ajax_response();
00402
00403 serv_printf("ICAL handle_rsvp|%s|%s|%s|",
00404 bstr("msgnum"),
00405 bstr("cal_partnum"),
00406 bstr("sc")
00407 );
00408 serv_getln(buf, sizeof buf);
00409
00410 if (buf[0] == '2') {
00411 wprintf("<table border=0 cellpadding=0><tr><td>");
00412 wprintf("<td><img align=\"center\" src=\"static/calarea_48x.gif\"></td><td><b><i>");
00413 if (!strcasecmp(bstr("sc"), "update")) {
00414 wprintf(_("Your calendar has been updated to reflect this RSVP."));
00415 } else if (!strcasecmp(bstr("sc"), "ignore")) {
00416 wprintf(_("You have chosen to ignore this RSVP. "
00417 "Your calendar has <b>not</b> been updated.")
00418 );
00419 }
00420 wprintf("</i></b></td></tr></table>");
00421 } else {
00422 wprintf("<img src=\"static/error.gif\" align=center> %s\n", &buf[4]);
00423 }
00424
00425 end_ajax_response();
00426
00427 }
00428
00429
00430
00432
00433
00434
00435
00442
00443
00444
00452 void display_individual_cal(icalcomponent *cal, long msgnum) {
00453
00454 WC->num_cal += 1;
00455
00456 WC->disp_cal = realloc(WC->disp_cal,
00457 (sizeof(struct disp_cal) * WC->num_cal) );
00458 WC->disp_cal[WC->num_cal - 1].cal = icalcomponent_new_clone(cal);
00459
00460 WC->disp_cal[WC->num_cal - 1].cal_msgnum = msgnum;
00461 }
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471 void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum) {
00472 icalcomponent *vtodo;
00473 icalproperty *p;
00474 struct icaltimetype t;
00475 time_t now;
00476 int created_new_vtodo = 0;
00477
00478 now = time(NULL);
00479
00480 if (supplied_vtodo != NULL) {
00481 vtodo = supplied_vtodo;
00482
00491 if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
00492 display_edit_individual_task(
00493 icalcomponent_get_first_component(
00494 vtodo, ICAL_VTODO_COMPONENT
00495 ), msgnum
00496 );
00497 return;
00498 }
00499 }
00500 else {
00501 vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT);
00502 created_new_vtodo = 1;
00503 }
00504
00505 output_headers(1, 1, 2, 0, 0, 0);
00506 wprintf("<div id=\"banner\">\n"
00507 "<TABLE class=\"calendar_banner\"><TR>"
00508 "<TD><img src=\"static/taskmanag_48x.gif\"></TD>"
00509 "<td><SPAN CLASS=\"titlebar\">");
00510 wprintf(_("Edit task"));
00511 wprintf("</SPAN>"
00512 "</TD></TR></TABLE>\n"
00513 "</div>\n<div id=\"content\">\n"
00514 );
00515
00516 wprintf("<div class=\"fix_scrollbar_bug\">"
00517 "<table class=\"calendar_background\"><tr><td>");
00518
00519 wprintf("<FORM METHOD=\"POST\" action=\"save_task\">\n");
00520 wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgnum\" VALUE=\"%ld\">\n",
00521 msgnum);
00522
00523 wprintf("<TABLE border=0>\n");
00524
00525 wprintf("<TR><TD>");
00526 wprintf(_("Summary:"));
00527 wprintf("</TD><TD>"
00528 "<INPUT TYPE=\"text\" NAME=\"summary\" "
00529 "MAXLENGTH=\"64\" SIZE=\"64\" VALUE=\"");
00530 p = icalcomponent_get_first_property(vtodo, ICAL_SUMMARY_PROPERTY);
00531 if (p != NULL) {
00532 escputs((char *)icalproperty_get_comment(p));
00533 }
00534 wprintf("\"></TD></TR>\n");
00535
00536 wprintf("<TR><TD>");
00537 wprintf(_("Start date:"));
00538 wprintf("</TD><TD>");
00539 p = icalcomponent_get_first_property(vtodo, ICAL_DTSTART_PROPERTY);
00540 if (p != NULL) {
00541 t = icalproperty_get_dtstart(p);
00542 }
00543 else {
00544 t = icaltime_from_timet(now, 0);
00545 }
00546 display_icaltimetype_as_webform(&t, "dtstart");
00547 wprintf("</TD></TR>\n");
00548
00549 wprintf("<TR><TD>");
00550 wprintf(_("Due date:"));
00551 wprintf("</TD><TD>");
00552 p = icalcomponent_get_first_property(vtodo, ICAL_DUE_PROPERTY);
00553 if (p != NULL) {
00554 t = icalproperty_get_due(p);
00555 }
00556 else {
00557 t = icaltime_from_timet(now, 0);
00558 }
00559 display_icaltimetype_as_webform(&t, "due");
00560 wprintf("</TD></TR>\n");
00561 wprintf("<TR><TD>");
00562 wprintf(_("Description:"));
00563 wprintf("</TD><TD>");
00564 wprintf("<TEXTAREA NAME=\"description\" wrap=soft "
00565 "ROWS=10 COLS=80 WIDTH=80>\n"
00566 );
00567 p = icalcomponent_get_first_property(vtodo, ICAL_DESCRIPTION_PROPERTY);
00568 if (p != NULL) {
00569 escputs((char *)icalproperty_get_comment(p));
00570 }
00571 wprintf("</TEXTAREA></TD></TR></TABLE>\n");
00572
00573 wprintf("<CENTER>"
00574 "<INPUT TYPE=\"submit\" NAME=\"save_button\" VALUE=\"%s\">"
00575 " "
00576 "<INPUT TYPE=\"submit\" NAME=\"delete_button\" VALUE=\"%s\">\n"
00577 " "
00578 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">\n"
00579 "</CENTER>\n",
00580 _("Save"),
00581 _("Delete"),
00582 _("Cancel")
00583 );
00584
00585 wprintf("</FORM>\n");
00586
00587 wprintf("</td></tr></table></div>\n");
00588 wDumpContent(1);
00589
00590 if (created_new_vtodo) {
00591 icalcomponent_free(vtodo);
00592 }
00593 }
00594
00595
00596
00597
00598
00599
00600 void save_individual_task(icalcomponent *supplied_vtodo, long msgnum) {
00601 char buf[SIZ];
00602 int delete_existing = 0;
00603 icalproperty *prop;
00604 icalcomponent *vtodo, *encaps;
00605 int created_new_vtodo = 0;
00606 int i;
00607 int sequence = 0;
00608 struct icaltimetype t;
00609
00610 if (supplied_vtodo != NULL) {
00611 vtodo = supplied_vtodo;
00620 if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
00621 save_individual_task(
00622 icalcomponent_get_first_component(
00623 vtodo, ICAL_VTODO_COMPONENT
00624 ), msgnum
00625 );
00626 return;
00627 }
00628 }
00629 else {
00630 vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT);
00631 created_new_vtodo = 1;
00632 }
00633
00634 if (strlen(bstr("save_button")) > 0) {
00635
00638 while (prop = icalcomponent_get_first_property(vtodo,
00639 ICAL_SUMMARY_PROPERTY), prop != NULL) {
00640 icalcomponent_remove_property(vtodo, prop);
00641 icalproperty_free(prop);
00642 }
00643 icalcomponent_add_property(vtodo,
00644 icalproperty_new_summary(bstr("summary")));
00645
00646 while (prop = icalcomponent_get_first_property(vtodo,
00647 ICAL_DESCRIPTION_PROPERTY), prop != NULL) {
00648 icalcomponent_remove_property(vtodo, prop);
00649 icalproperty_free(prop);
00650 }
00651 icalcomponent_add_property(vtodo,
00652 icalproperty_new_description(bstr("description")));
00653
00654 while (prop = icalcomponent_get_first_property(vtodo,
00655 ICAL_DTSTART_PROPERTY), prop != NULL) {
00656 icalcomponent_remove_property(vtodo, prop);
00657 icalproperty_free(prop);
00658 }
00659 icaltime_from_webform(&t, "dtstart");
00660 icalcomponent_add_property(vtodo,
00661 icalproperty_new_dtstart(t)
00662 );
00663
00664 while (prop = icalcomponent_get_first_property(vtodo,
00665 ICAL_DUE_PROPERTY), prop != NULL) {
00666 icalcomponent_remove_property(vtodo, prop);
00667 icalproperty_free(prop);
00668 }
00669 icaltime_from_webform(&t, "due");
00670 icalcomponent_add_property(vtodo,
00671 icalproperty_new_due(t)
00672 );
00673
00675 lprintf(9, "Give this task a UID if it doesn't have one.\n");
00676 if (icalcomponent_get_first_property(vtodo,
00677 ICAL_UID_PROPERTY) == NULL) {
00678 generate_uuid(buf);
00679 icalcomponent_add_property(vtodo,
00680 icalproperty_new_uid(buf)
00681 );
00682 }
00683
00685 lprintf(9, "Increment the sequence ID\n");
00686 while (prop = icalcomponent_get_first_property(vtodo,
00687 ICAL_SEQUENCE_PROPERTY), (prop != NULL) ) {
00688 i = icalproperty_get_sequence(prop);
00689 lprintf(9, "Sequence was %d\n", i);
00690 if (i > sequence) sequence = i;
00691 icalcomponent_remove_property(vtodo, prop);
00692 icalproperty_free(prop);
00693 }
00694 ++sequence;
00695 lprintf(9, "New sequence is %d. Adding...\n", sequence);
00696 icalcomponent_add_property(vtodo,
00697 icalproperty_new_sequence(sequence)
00698 );
00699
00707 lprintf(9, "Encapsulating into a full VCALENDAR component\n");
00708 encaps = ical_encapsulate_subcomponent(icalcomponent_new_clone(vtodo));
00709
00710
00711 serv_puts("ENT0 1|||4");
00712 serv_getln(buf, sizeof buf);
00713 if (buf[0] == '4') {
00714 serv_puts("Content-type: text/calendar");
00715 serv_puts("");
00716 serv_puts(icalcomponent_as_ical_string(encaps));
00717 serv_puts("000");
00718
00724 delete_existing = 1;
00725 }
00726 icalcomponent_free(encaps);
00727 }
00728
00732 if (strlen(bstr("delete_button")) > 0) {
00733 delete_existing = 1;
00734 }
00735
00736 if ( (delete_existing) && (msgnum > 0L) ) {
00737 serv_printf("DELE %ld", atol(bstr("msgnum")));
00738 serv_getln(buf, sizeof buf);
00739 }
00740
00741 if (created_new_vtodo) {
00742 icalcomponent_free(vtodo);
00743 }
00744
00746 readloop("readfwd");
00747 }
00748
00749
00750
00763 void display_using_handler(long msgnum,
00764 char *mimetype,
00765 icalcomponent_kind which_kind,
00766 void (*callback)(icalcomponent *, long)
00767 ) {
00768 char buf[1024];
00769 char mime_partnum[256];
00770 char mime_filename[256];
00771 char mime_content_type[256];
00772 char mime_disposition[256];
00773 int mime_length;
00774 char relevant_partnum[256];
00775 char *relevant_source = NULL;
00776 icalcomponent *cal, *c;
00777
00778 sprintf(buf, "MSG0 %ld|0", msgnum);
00779 serv_puts(buf);
00780 serv_getln(buf, sizeof buf);
00781 if (buf[0] != '1') return;
00782
00783 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
00784 if (!strncasecmp(buf, "part=", 5)) {
00785 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
00786 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
00787 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
00788 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
00789 mime_length = extract_int(&buf[5], 5);
00790
00791 if (!strcasecmp(mime_content_type, "text/calendar")) {
00792 strcpy(relevant_partnum, mime_partnum);
00793 }
00794
00795 }
00796 }
00797
00798 if (strlen(relevant_partnum) > 0) {
00799 relevant_source = load_mimepart(msgnum, relevant_partnum);
00800 if (relevant_source != NULL) {
00801
00802 cal = icalcomponent_new_from_string(relevant_source);
00803 if (cal != NULL) {
00804
00805 ical_dezonify(cal);
00806
00808 if (icalcomponent_isa(cal) == which_kind) {
00809 callback(cal, msgnum);
00810 }
00811
00813 for (c = icalcomponent_get_first_component(cal,
00814 which_kind);
00815 (c != 0);
00816 c = icalcomponent_get_next_component(cal,
00817 which_kind)) {
00818 callback(c, msgnum);
00819 }
00820 icalcomponent_free(cal);
00821 }
00822 free(relevant_source);
00823 }
00824 }
00825
00826 }
00827
00832 void display_calendar(long msgnum) {
00833 display_using_handler(msgnum, "text/calendar",
00834 ICAL_VEVENT_COMPONENT,
00835 display_individual_cal);
00836 }
00837
00842 void display_task(long msgnum) {
00843 display_using_handler(msgnum, "text/calendar",
00844 ICAL_VTODO_COMPONENT,
00845 display_individual_cal);
00846 }
00847
00851 void display_edit_task(void) {
00852 long msgnum = 0L;
00853
00855 if (strlen(bstr("taskrm")) > 0) {
00856 gotoroom(bstr("taskrm"));
00857 }
00858
00859 msgnum = atol(bstr("msgnum"));
00860 if (msgnum > 0L) {
00862 display_using_handler(msgnum, "text/calendar",
00863 ICAL_VTODO_COMPONENT,
00864 display_edit_individual_task);
00865 }
00866 else {
00868 display_edit_individual_task(NULL, 0L);
00869 }
00870 }
00871
00875 void save_task(void) {
00876 long msgnum = 0L;
00877
00878 msgnum = atol(bstr("msgnum"));
00879 if (msgnum > 0L) {
00880 display_using_handler(msgnum, "text/calendar",
00881 ICAL_VTODO_COMPONENT,
00882 save_individual_task);
00883 }
00884 else {
00885 save_individual_task(NULL, 0L);
00886 }
00887 }
00888
00892 void display_edit_event(void) {
00893 long msgnum = 0L;
00894
00895 msgnum = atol(bstr("msgnum"));
00896 if (msgnum > 0L) {
00897
00898 display_using_handler(msgnum, "text/calendar",
00899 ICAL_VEVENT_COMPONENT,
00900 display_edit_individual_event);
00901 }
00902 else {
00903
00904 display_edit_individual_event(NULL, 0L);
00905 }
00906 }
00907
00911 void save_event(void) {
00912 long msgnum = 0L;
00913
00914 msgnum = atol(bstr("msgnum"));
00915
00916 if (msgnum > 0L) {
00917 display_using_handler(msgnum, "text/calendar",
00918 ICAL_VEVENT_COMPONENT,
00919 save_individual_event);
00920 }
00921 else {
00922 save_individual_event(NULL, 0L);
00923 }
00924 }
00925
00926
00927
00928
00929
00934 void do_freebusy(char *req) {
00935 char who[SIZ];
00936 char buf[SIZ];
00937 char *fb;
00938
00939 extract_token(who, req, 1, ' ', sizeof who);
00940 if (!strncasecmp(who, "/freebusy/", 10)) {
00941 strcpy(who, &who[10]);
00942 }
00943 unescape_input(who);
00944
00945 if ( (!strcasecmp(&who[strlen(who)-4], ".vcf"))
00946 || (!strcasecmp(&who[strlen(who)-4], ".ifb"))
00947 || (!strcasecmp(&who[strlen(who)-4], ".vfb")) ) {
00948 who[strlen(who)-4] = 0;
00949 }
00950
00951 lprintf(9, "freebusy requested for <%s>\n", who);
00952 serv_printf("ICAL freebusy|%s", who);
00953 serv_getln(buf, sizeof buf);
00954
00955 if (buf[0] != '1') {
00956 wprintf("HTTP/1.1 404 %s\n", &buf[4]);
00957 output_headers(0, 0, 0, 0, 0, 0);
00958 wprintf("Content-Type: text/plain\r\n");
00959 wprintf("\r\n");
00960 wprintf("%s\n", &buf[4]);
00961 return;
00962 }
00963
00964 fb = read_server_text();
00965 http_transmit_thing(fb, strlen(fb), "text/calendar", 0);
00966 free(fb);
00967 }
00968
00969
00970
00971 #endif
00972
00973