#include <signal.h>
#include "webcit.h"
#include "vcard.h"
+#include "webserver.h"
/*
strncpy(urlbuf, &buf[start], end - start);
urlbuf[end - start] = 0;
-
strncpy(outbuf, buf, start);
sprintf(&outbuf[start], "%cA HREF=%c%s%c TARGET=%c%s%c%c%s%c/A%c",
LB, QU, urlbuf, QU, QU, TARGET, QU, RB, urlbuf, LB, RB);
-
-
+/*
+ * I wanna SEE that message!
+ */
void read_message(long msgnum) {
char buf[SIZ];
char mime_partnum[SIZ];
int nhdr = 0;
int bq = 0;
char vcard_partnum[SIZ];
- char *vcard_source = NULL;
+ char cal_partnum[SIZ];
+ char *part_source = NULL;
strcpy(from, "");
strcpy(node, "");
strcpy(rfca, "");
strcpy(reply_to, "");
strcpy(vcard_partnum, "");
+ strcpy(cal_partnum, "");
- sprintf(buf, "MSG0 %ld", msgnum);
- serv_puts(buf);
+ serv_printf("MSG4 %ld", msgnum);
serv_gets(buf);
if (buf[0] != '1') {
wprintf("<STRONG>ERROR:</STRONG> %s<BR>\n", &buf[4]);
wprintf("COLOR=\"000000\"> ");
strcpy(m_subject, "");
- while (serv_gets(buf), strncasecmp(buf, "text", 4)) {
+ while (serv_gets(buf), strcasecmp(buf, "text")) {
if (!strncasecmp(buf, "nhdr=yes", 8))
nhdr = 1;
if (nhdr == 1)
msgnum, mime_partnum);
}
+ /*** begin handler prep ***/
if (!strcasecmp(mime_content_type, "text/x-vcard")) {
strcpy(vcard_partnum, mime_partnum);
}
+ if (!strcasecmp(mime_content_type, "text/calendar")) {
+ strcpy(cal_partnum, mime_partnum);
+ }
+
+ /*** end handler prep ***/
+
}
}
wprintf("</TR></TABLE>\n");
- if (format_type == 0) {
+ /*
+ * Learn the content type
+ */
+ strcpy(mime_content_type, "text/plain");
+ while (serv_gets(buf), (strlen(buf) > 0)) {
+ if (!strncasecmp(buf, "Content-type: ", 14)) {
+ safestrncpy(mime_content_type, &buf[14],
+ sizeof(mime_content_type));
+ }
+ }
+
+ /* Messages in legacy Citadel variformat get handled thusly... */
+ if (!strcasecmp(mime_content_type, "text/x-citadel-variformat")) {
fmout(NULL);
- } else {
+ }
+
+ /* Boring old 80-column fixed format text gets handled this way... */
+ else if (!strcasecmp(mime_content_type, "text/plain")) {
while (serv_gets(buf), strcmp(buf, "000")) {
while ((strlen(buf) > 0) && (isspace(buf[strlen(buf) - 1])))
buf[strlen(buf) - 1] = 0;
if ((bq == 0) &&
- ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) || (!strncmp(buf, " :-)", 4)))) {
+ ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) || (!strncmp(buf, " :-)", 4)))) {
wprintf("<FONT COLOR=\"000044\"><I>");
bq = 1;
} else if ((bq == 1) &&
- (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) && (strncmp(buf, " :-)", 4))) {
+ (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) && (strncmp(buf, " :-)", 4))) {
wprintf("</FONT></I>");
bq = 0;
}
escputs(buf);
wprintf("</TT><BR>\n");
}
+ wprintf("</I><BR>");
+ }
+
+ else /* HTML is fun, but we've got to strip it first */
+ if (!strcasecmp(mime_content_type, "text/html")) {
+ output_html();
+ }
+
+ /* Unknown weirdness */
+ else {
+ wprintf("I don't know how to display %s<BR>\n",
+ mime_content_type);
+ while (serv_gets(buf), strcmp(buf, "000")) { }
}
- wprintf("</I><BR>");
+
+ /* Afterwards, offer links to download attachments 'n' such */
if (mime_http != NULL) {
wprintf("%s", mime_http);
free(mime_http);
}
+ /* Handler for vCard parts */
if (strlen(vcard_partnum) > 0) {
- vcard_source = load_mimepart(msgnum, vcard_partnum);
- if (vcard_source != NULL) {
+ part_source = load_mimepart(msgnum, vcard_partnum);
+ if (part_source != NULL) {
/* If it's my vCard I can edit it */
if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
}
/* In all cases, display the full card */
- display_vcard(vcard_source, 0, 1);
- free(vcard_source);
+ display_vcard(part_source, 0, 1);
}
}
+ /* Handler for calendar parts */
+ if (strlen(cal_partnum) > 0) {
+ part_source = load_mimepart(msgnum, cal_partnum);
+ if (part_source != NULL) {
+ cal_process_attachment(part_source);
+ }
+ }
+
+ if (part_source) {
+ free(part_source);
+ part_source = NULL;
+ }
+
}
wprintf("Automatically cancelled because you have already "
"saved this message.<BR>\n");
} else {
- sprintf(buf, "ENT0 1|%s|0|0|%s",
+ sprintf(buf, "ENT0 1|%s|0|4|%s",
bstr("recp"),
bstr("subject") );
serv_puts(buf);
serv_gets(buf);
if (buf[0] == '4') {
- text_to_server(bstr("msgtext"));
+ serv_puts("Content-type: text/html");
+ serv_puts("");
+ text_to_server(bstr("msgtext"), 1);
serv_puts("000");
wprintf("Message has been posted.<BR>\n");
dont_post = atol(bstr("postseq"));
if (strlen(bstr("recp")) > 0) {
wprintf("<EM>%s</EM><BR>\n", &buf[4]);
}
- do_template("prompt_for_recipient.html");
+ do_template("prompt_for_recipient");
goto DONE;
}
if (buf[0] != '2') {