*
*/
-#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/socket.h>
-#include <limits.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <string.h>
-#include <pwd.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <pthread.h>
-#include <signal.h>
-#include <time.h>
#include "webcit.h"
#include "webserver.h"
case ICAL_METHOD_REQUEST:
wprintf("<TR><TD COLSPAN=2>\n"
"<IMG ALIGN=CENTER "
- "SRC=\"/static/vcalendar.gif\">"
+ "SRC=\"/static/calarea_48x.gif\">"
" "
"<B>Meeting invitation</B>"
"</TD></TR>\n"
case ICAL_METHOD_REPLY:
wprintf("<TR><TD COLSPAN=2>\n"
"<IMG ALIGN=CENTER "
- "SRC=\"/static/vcalendar.gif\">"
+ "SRC=\"/static/calarea_48x.gif\">"
" "
"<B>Attendee's reply to your invitation</B>"
"</TD></TR>\n"
case ICAL_METHOD_PUBLISH:
wprintf("<TR><TD COLSPAN=2>\n"
"<IMG ALIGN=CENTER "
- "SRC=\"/static/vcalendar.gif\">"
+ "SRC=\"/static/calarea_48x.gif\">"
" "
"<B>Published event</B>"
"</TD></TR>\n"
}
else {
tt = icaltime_as_timet(t);
- fmt_date(buf, tt);
+ fmt_date(buf, tt, 0);
wprintf("<TR><TD><B>Starting date/time:"
"</B></TD><TD>"
"%s</TD></TR>", buf
if (p != NULL) {
t = icalproperty_get_dtend(p);
tt = icaltime_as_timet(t);
- fmt_date(buf, tt);
+ fmt_date(buf, tt, 0);
wprintf("<TR><TD><B>Ending date/time:</B></TD><TD>"
"%s</TD></TR>", buf
);
/* Check for conflicts */
lprintf(9, "Checking server calendar for conflicts...\n");
serv_printf("ICAL conflicts|%ld|%s|", msgnum, cal_partnum);
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
if (buf[0] == '1') {
- while (serv_gets(buf), strcmp(buf, "000")) {
- extract(conflict_name, buf, 3);
+ while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+ extract_token(conflict_name, buf, 3, '|', sizeof conflict_name);
is_update = extract_int(buf, 4);
wprintf("<TR><TD><B><I>%s</I></B></TD>"
"<TD>"
lprintf(9, "...done.\n");
/* Display the Accept/Decline buttons */
- wprintf("<TR><TD COLSPAN=2>"
- "<FORM METHOD=\"GET\" "
- "ACTION=\"/respond_to_request\">\n"
- "<INPUT TYPE=\"submit\" NAME=\"sc\" "
- "VALUE=\"Accept\">\n"
- " "
- "<INPUT TYPE=\"submit\" NAME=\"sc\" "
- "VALUE=\"Tentative\">\n"
- " "
- "<INPUT TYPE=\"submit\" NAME=\"sc\" "
- "VALUE=\"Decline\">\n"
- "<INPUT TYPE=\"hidden\" NAME=\"msgnum\" "
- "VALUE=\"%ld\">"
- "<INPUT TYPE=\"hidden\" NAME=\"cal_partnum\" "
- "VALUE=\"%s\">"
- "</FORM>"
- "</TD></TR>\n",
+ wprintf("<TR><TD>How would you like to respond to this invitation?</td>"
+ "<td><FONT SIZE=+1>"
+ "<A HREF=\"/respond_to_request?msgnum=%ld&cal_partnum=%s&sc=Accept\">Accept</a>"
+ " | "
+ "<A HREF=\"/respond_to_request?msgnum=%ld&cal_partnum=%s&sc=Tentative\">Tentative</a>"
+ " | "
+ "<A HREF=\"/respond_to_request?msgnum=%ld&cal_partnum=%s&sc=Decline\">Decline</a>"
+ "</FONT></TD></TR>\n",
+ msgnum, cal_partnum,
+ msgnum, cal_partnum,
msgnum, cal_partnum
);
* In the future, if we want to validate this object before
* continuing, we can do it this way:
serv_printf("ICAL whatever|%ld|%s|", msgnum, cal_partnum);
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
}
***********/
/* Display the update buttons */
- wprintf("<TR><TD COLSPAN=2>"
+ wprintf("<TR><TD>"
"Click <i>Update</i> to accept this reply and "
"update your calendar."
- "<FORM METHOD=\"GET\" "
- "ACTION=\"/handle_rsvp\">\n"
- "<INPUT TYPE=\"submit\" NAME=\"sc\" "
- "VALUE=\"Update\">\n"
- " "
- "<INPUT TYPE=\"submit\" NAME=\"sc\" "
- "VALUE=\"Ignore\">\n"
- "<INPUT TYPE=\"hidden\" NAME=\"msgnum\" "
- "VALUE=\"%ld\">"
- "<INPUT TYPE=\"hidden\" NAME=\"cal_partnum\" "
- "VALUE=\"%s\">"
- "</FORM>"
+ "</td><td><font size=+1>"
+ "<a href=\"/handle_rsvp?msgnum=%ld&cal_partnum=%s&sc=Update\">Update</a>"
+ " | "
+ "<a href=\"/handle_rsvp?msgnum=%ld&cal_partnum=%s&sc=Ignore\">Ignore</a>"
+ "</font>"
"</TD></TR>\n",
+ msgnum, cal_partnum,
msgnum, cal_partnum
);
"<SPAN CLASS=\"titlebar\">Respond to meeting request</SPAN>"
"</TD></TR></TABLE>\n"
);
- wprintf("</div>\n<div id=\"text\">\n");
+ wprintf("</div>\n<div id=\"content\">\n");
serv_printf("ICAL respond|%s|%s|%s|",
bstr("msgnum"),
bstr("cal_partnum"),
bstr("sc")
);
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
wprintf("<TABLE BORDER=0><TR><TD>"
- "<IMG SRC=\"static/vcalendar.gif\" ALIGN=CENTER>"
+ "<IMG SRC=\"static/calarea_48x.gif\" ALIGN=CENTER>"
"</TD><TD>"
);
if (!strcasecmp(bstr("sc"), "accept")) {
"<SPAN CLASS=\"titlebar\">"
"Update your calendar with this RSVP</SPAN>"
"</TD></TR></TABLE>\n"
- "</div><div id=\"text\">\n"
+ "</div>\n<div id=\"content\">\n"
);
serv_printf("ICAL handle_rsvp|%s|%s|%s|",
bstr("cal_partnum"),
bstr("sc")
);
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
wprintf("<TABLE BORDER=0><TR><TD>"
- "<IMG SRC=\"static/vcalendar.gif\" ALIGN=CENTER>"
+ "<IMG SRC=\"static/calarea_48x.gif\" ALIGN=CENTER>"
"</TD><TD>"
);
if (!strcasecmp(bstr("sc"), "update")) {
output_headers(1, 1, 2, 0, 0, 0, 0);
wprintf("<div id=\"banner\">\n"
- "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
- "<SPAN CLASS=\"titlebar\">Edit task</SPAN>"
+ "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR>"
+ "<TD><IMG SRC=\"/static/taskmanag_48x.gif\"></TD>"
+ "<td><SPAN CLASS=\"titlebar\">Edit task</SPAN>"
"</TD></TR></TABLE>\n"
- "</div><div id=\"text\">\n"
+ "</div>\n<div id=\"content\">\n"
);
-
- do_template("beginbox_nt");
+ wprintf("<div id=\"fix_scrollbar_bug\">"
+ "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>");
+
wprintf("<FORM METHOD=\"POST\" ACTION=\"/save_task\">\n");
wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgnum\" VALUE=\"%ld\">\n",
msgnum);
wprintf("</FORM>\n");
- do_template("endbox");
+ wprintf("</td></tr></table></div>\n");
wDumpContent(1);
if (created_new_vtodo) {
char buf[SIZ];
int delete_existing = 0;
icalproperty *prop;
- icalcomponent *vtodo;
+ icalcomponent *vtodo, *encaps;
int created_new_vtodo = 0;
int i;
int sequence = 0;
+ struct icaltimetype t;
if (supplied_vtodo != NULL) {
vtodo = supplied_vtodo;
icalcomponent_remove_property(vtodo, prop);
icalproperty_free(prop);
}
+ icaltime_from_webform(&t, "dtstart");
icalcomponent_add_property(vtodo,
- icalproperty_new_dtstart(
- icaltime_from_webform("dtstart")
- )
+ icalproperty_new_dtstart(t)
);
while (prop = icalcomponent_get_first_property(vtodo,
icalcomponent_remove_property(vtodo, prop);
icalproperty_free(prop);
}
+ icaltime_from_webform(&t, "due");
icalcomponent_add_property(vtodo,
- icalproperty_new_due(
- icaltime_from_webform("due")
- )
+ icalproperty_new_due(t)
);
/* Give this task a UID if it doesn't have one. */
icalcomponent_add_property(vtodo,
icalproperty_new_sequence(sequence)
);
-
-
+
+ /*
+ * Encapsulate event into full VCALENDAR component. Clone it first,
+ * for two reasons: one, it's easier to just free the whole thing
+ * when we're done instead of unbundling, but more importantly, we
+ * can't encapsulate something that may already be encapsulated
+ * somewhere else.
+ */
+ lprintf(9, "Encapsulating into full VCALENDAR component\n");
+ encaps = ical_encapsulate_subcomponent(icalcomponent_new_clone(vtodo));
+
/* Serialize it and save it to the message base */
serv_puts("ENT0 1|||4");
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
if (buf[0] == '4') {
serv_puts("Content-type: text/calendar");
serv_puts("");
- serv_puts(icalcomponent_as_ical_string(vtodo));
+ serv_puts(icalcomponent_as_ical_string(encaps));
serv_puts("000");
/* Probably not necessary; the server will see the UID
*/
delete_existing = 1;
}
+ icalcomponent_free(encaps);
}
/*
if ( (delete_existing) && (msgnum > 0L) ) {
serv_printf("DELE %ld", atol(bstr("msgnum")));
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
}
if (created_new_vtodo) {
sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */
serv_puts(buf);
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
if (buf[0] != '1') return;
- while (serv_gets(buf), strcmp(buf, "000")) {
+ while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
if (!strncasecmp(buf, "part=", 5)) {
- extract(mime_filename, &buf[5], 1);
- extract(mime_partnum, &buf[5], 2);
- extract(mime_disposition, &buf[5], 3);
- extract(mime_content_type, &buf[5], 4);
+ extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
+ extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
+ extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
+ extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
mime_length = extract_int(&buf[5], 5);
if (!strcasecmp(mime_content_type, "text/calendar")) {
char buf[SIZ];
char *fb;
- extract_token(who, req, 1, ' ');
+ extract_token(who, req, 1, ' ', sizeof who);
if (!strncasecmp(who, "/freebusy/", 10)) {
strcpy(who, &who[10]);
}
unescape_input(who);
if ( (!strcasecmp(&who[strlen(who)-4], ".vcf"))
+ || (!strcasecmp(&who[strlen(who)-4], ".ifb"))
|| (!strcasecmp(&who[strlen(who)-4], ".vfb")) ) {
who[strlen(who)-4] = 0;
}
lprintf(9, "freebusy requested for <%s>\n", who);
serv_printf("ICAL freebusy|%s", who);
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
if (buf[0] != '1') {
wprintf("HTTP/1.0 404 %s\n", &buf[4]);
output_headers(0, 0, 0, 0, 0, 0, 0);
- wprintf("Content-Type: text/plain\n");
- wprintf("\n");
+ wprintf("Content-Type: text/plain\r\n");
+ wprintf("\r\n");
wprintf("%s\n", &buf[4]);
return;
}