/* begin everythingamundo table */
HdrToken = NewStrBuf();
- while ((StrBuf_ServGetln(Buf)>=0) && !Done) {
+ while (!Done && StrBuf_ServGetln(Buf)>=0) {
if ( (StrLength(Buf)==3) &&
!strcmp(ChrPtr(Buf), "000"))
{
FreeStrBuf(&Error);
}
- /* strip the bare contenttype, so we ommit charset etc. */
+ /* Extract just the content-type (omit attributes such as "charset") */
StrBufExtract_token(Buf, Msg->MsgBody->ContentType, 0, ';');
StrBufTrim(Buf);
StrBufLowerCase(Buf);
- /* look up the renderer, that will convert this mimeitem into the htmlized form */
+
+ /* Locate a renderer capable of converting this MIME part into HTML */
if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
(vHdr != NULL)) {
RenderMimeFuncStruct *Render;
serv_getln(buf, sizeof buf);
if (buf[0] == '1') {
while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- wprintf("%s\n", buf);
+ wc_printf("%s\n", buf);
}
}
/*
* command loop for reading messages
*
- * Set oper to "readnew" or "readold" or "readfwd" or "headers" or "readgt"
+ * Set oper to "readnew" or "readold" or "readfwd" or "headers" or "readgt" or "readlt" or "do_search"
*/
void readloop(long oper)
{
void *vMsg;
message_summary *Msg;
char cmd[256] = "";
- int i;
+ int i, r;
wcsession *WCC = WC;
HashPos *at;
const char *HashKey;
SharedMessageStatus Stat;
void *ViewSpecific;
- if (havebstr("is_summary") && (1 == (ibstr("is_summary"))))
+ if (havebstr("is_summary") && (1 == (ibstr("is_summary")))) {
WCC->wc_view = VIEW_MAILBOX;
+ }
+
+ if (havebstr("is_ajax") && (1 == (ibstr("is_ajax")))) {
+ WCC->is_ajax = 1;
+ }
+
+ if ((oper == do_search) && (WCC->wc_view == VIEW_WIKI)) {
+ display_wiki_pagelist();
+ return;
+ }
memset(&Stat, 0, sizeof(SharedMessageStatus));
Stat.maxload = 10000;
WCC->wc_view = VIEW_BBS;
GetHash(ReadLoopHandler, IKEY(WCC->wc_view), &vViewMsg);
}
- if (vViewMsg == NULL)
- return;///TODO: print message
+ if (vViewMsg == NULL) {
+ return; // TODO: print message
+ }
ViewMsg = (RoomRenderer*) vViewMsg;
if (!WCC->is_ajax) {
jsonMessageListHdr();
}
- switch(ViewMsg->GetParamsGetServerCall(
+ if (ViewMsg->GetParamsGetServerCall != NULL) {
+ r = ViewMsg->GetParamsGetServerCall(
&Stat,
&ViewSpecific,
oper,
- cmd, sizeof(cmd)))
+ cmd, sizeof(cmd)
+ );
+ } else {
+ r = 0;
+ }
+ switch(r)
{
case 400:
case 404:
if (Stat.sortit) {
CompareFunc SortIt;
memset(&SubTP, 0, sizeof(WCTemplputParams));
- SubTP.Filter.ContextType = CTX_NONE;
+ SubTP.Filter.ContextType = CTX_MAILSUM;
SubTP.Context = NULL;
SortIt = RetrieveSort(&SubTP, NULL, 0,
HKEY("date"), Stat.defaultsortorder);
size_t encoded_length;
size_t encoded_strlen;
char *txtmail = NULL;
+ int include_text_alt = 0; /* Set to nonzero to include multipart/alternative text/plain */
sprintf(top_boundary, "Citadel--Multipart--%s--%04x--%04x",
ChrPtr(WCC->serv_info->serv_fqdn),
is_multipart = 1;
}
+ /* Only do multipart/alternative for mailboxes. BBS and Wiki rooms don't need it. */
+ if (WC->wc_view == VIEW_MAILBOX) {
+ include_text_alt = 1;
+ }
+
if (is_multipart) {
/* Remember, serv_printf() appends an extra newline */
serv_printf("Content-type: multipart/mixed; boundary=\"%s\"\n", top_boundary);
}
/* Remember, serv_printf() appends an extra newline */
- serv_printf("Content-type: multipart/alternative; "
- "boundary=\"%s\"\n", alt_boundary);
- serv_printf("This is a multipart message in MIME format.\n");
- serv_printf("--%s", alt_boundary);
+ if (include_text_alt) {
+ serv_printf("Content-type: multipart/alternative; "
+ "boundary=\"%s\"\n", alt_boundary);
+ serv_printf("This is a multipart message in MIME format.\n");
+ serv_printf("--%s", alt_boundary);
- serv_puts("Content-type: text/plain; charset=utf-8");
- serv_puts("Content-Transfer-Encoding: quoted-printable");
- serv_puts("");
- txtmail = html_to_ascii(bstr("msgtext"), 0, 80, 0);
- text_to_server_qp(txtmail); /* Transmit message in quoted-printable encoding */
- free(txtmail);
+ serv_puts("Content-type: text/plain; charset=utf-8");
+ serv_puts("Content-Transfer-Encoding: quoted-printable");
+ serv_puts("");
+ txtmail = html_to_ascii(bstr("msgtext"), 0, 80, 0);
+ text_to_server_qp(txtmail); /* Transmit message in quoted-printable encoding */
+ free(txtmail);
- serv_printf("--%s", alt_boundary);
+ serv_printf("--%s", alt_boundary);
+ }
serv_puts("Content-type: text/html; charset=utf-8");
serv_puts("Content-Transfer-Encoding: quoted-printable");
text_to_server_qp(bstr("msgtext")); /* Transmit message in quoted-printable encoding */
serv_puts("</body></html>\r\n");
- serv_printf("--%s--", alt_boundary);
+ if (include_text_alt) {
+ serv_printf("--%s--", alt_boundary);
+ }
if (is_multipart) {
long len;
it = GetNewHashPos(WCC->attachments, 0);
while (GetNextHashPos(WCC->attachments, it, &len, &Key, &vAtt)) {
att = (wc_mime_attachment *)vAtt;
+ if (att->length == 0)
+ continue;
encoded_length = ((att->length * 150) / 100);
encoded = malloc(encoded_length);
if (encoded == NULL) break;
Recp = sbstr("recp");
Cc = sbstr("cc");
Bcc = sbstr("bcc");
- Wikipage = sbstr("wikipage");
+ Wikipage = sbstr("page");
my_email_addr = sbstr("my_email_addr");
CmdBuf = NewStrBufPlain(NULL,
/*
* If we were editing a page in a wiki room, go to that page now.
*/
- else if (havebstr("wikipage")) {
- snprintf(buf, sizeof buf, "wiki?page=%s", bstr("wikipage"));
+ else if (havebstr("page")) {
+ snprintf(buf, sizeof buf, "wiki?page=%s", bstr("page"));
http_redirect(buf);
}
/*
Recp = sbstr("recp");
Cc = sbstr("cc");
Bcc = sbstr("bcc");
- Wikipage = sbstr("wikipage");
+ Wikipage = sbstr("page");
CmdBuf = NewStrBufPlain(NULL,
sizeof (CMD) +
}
}
else if (buf[0] != '2') { /* Any other error means that we cannot continue */
- wprintf("<em>%s</em><br />\n", &buf[4]); /* TODO -> important message */
+ wc_printf("<em>%s</em><br />\n", &buf[4]); /* TODO -> important message */
return;
}
}
output_headers(1, 1, 2, 0, 0, 0);
- wprintf("<div id=\"banner\">\n");
- wprintf("<h1>");
- wprintf(_("Confirm move of message"));
- wprintf("</h1>");
- wprintf("</div>\n");
+ wc_printf("<div id=\"banner\">\n");
+ wc_printf("<h1>");
+ wc_printf(_("Confirm move of message"));
+ wc_printf("</h1>");
+ wc_printf("</div>\n");
- wprintf("<div id=\"content\" class=\"service\">\n");
+ wc_printf("<div id=\"content\" class=\"service\">\n");
- wprintf("<CENTER>");
+ wc_printf("<CENTER>");
- wprintf(_("Move this message to:"));
- wprintf("<br />\n");
+ wc_printf(_("Move this message to:"));
+ wc_printf("<br />\n");
- wprintf("<form METHOD=\"POST\" action=\"move_msg\">\n");
- wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
- wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n", bstr("msgid"));
+ wc_printf("<form METHOD=\"POST\" action=\"move_msg\">\n");
+ wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
+ wc_printf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n", bstr("msgid"));
- wprintf("<SELECT NAME=\"target_room\" SIZE=5>\n");
+ wc_printf("<SELECT NAME=\"target_room\" SIZE=5>\n");
serv_puts("LKRA");
serv_getln(buf, sizeof buf);
if (buf[0] == '1') {
while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
extract_token(targ, buf, 0, '|', sizeof targ);
- wprintf("<OPTION>");
+ wc_printf("<OPTION>");
escputs(targ);
- wprintf("\n");
+ wc_printf("\n");
}
}
- wprintf("</SELECT>\n");
- wprintf("<br />\n");
+ wc_printf("</SELECT>\n");
+ wc_printf("<br />\n");
- wprintf("<INPUT TYPE=\"submit\" NAME=\"move_button\" VALUE=\"%s\">", _("Move"));
- wprintf(" ");
- wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
- wprintf("</form></CENTER>\n");
+ wc_printf("<INPUT TYPE=\"submit\" NAME=\"move_button\" VALUE=\"%s\">", _("Move"));
+ wc_printf(" ");
+ wc_printf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
+ wc_printf("</form></CENTER>\n");
- wprintf("</CENTER>\n");
+ wc_printf("</CENTER>\n");
wDumpContent(1);
}
hprintf("HTTP/1.1 404 %s\n", ChrPtr(partnum));
output_headers(0, 0, 0, 0, 0, 0);
hprintf("Content-Type: text/plain\r\n");
- wprintf(_("An error occurred while retrieving this part: %s/%s\n"),
+ begin_burst();
+ wc_printf(_("An error occurred while retrieving this part: %s/%s\n"),
ChrPtr(partnum), ChrPtr(filename));
end_burst();
}
hprintf("HTTP/1.1 404 %s\n", ChrPtr(Buf));
output_headers(0, 0, 0, 0, 0, 0);
hprintf("Content-Type: text/plain\r\n");
- wprintf(_("An error occurred while retrieving this part: %s\n"),
+ begin_burst();
+ wc_printf(_("An error occurred while retrieving this part: %s\n"),
ChrPtr(Buf));
end_burst();
}
void h_headers(void) { readloop(headers);}
void h_do_search(void) { readloop(do_search);}
void h_readgt(void) { readloop(readgt);}
+void h_readlt(void) { readloop(readlt);}
void jsonMessageListHdr(void)
{
Handler->ViewCleanup = ViewCleanup;
Put(ReadLoopHandler, IKEY(RoomType), Handler, NULL);
-
}
void
NULL);
RegisterPreference("mailbox",_("Mailbox view mode"), PRF_STRING, NULL);
- WebcitAddUrlHandler(HKEY("readnew"), h_readnew, NEED_URL);
- WebcitAddUrlHandler(HKEY("readold"), h_readold, NEED_URL);
- WebcitAddUrlHandler(HKEY("readfwd"), h_readfwd, NEED_URL);
- WebcitAddUrlHandler(HKEY("headers"), h_headers, NEED_URL);
- WebcitAddUrlHandler(HKEY("readgt"), h_readgt, NEED_URL);
- WebcitAddUrlHandler(HKEY("do_search"), h_do_search, 0);
- WebcitAddUrlHandler(HKEY("display_enter"), display_enter, 0);
- WebcitAddUrlHandler(HKEY("post"), post_message, 0);
- WebcitAddUrlHandler(HKEY("move_msg"), move_msg, 0);
- WebcitAddUrlHandler(HKEY("delete_msg"), delete_msg, 0);
- WebcitAddUrlHandler(HKEY("confirm_move_msg"), confirm_move_msg, 0);
- WebcitAddUrlHandler(HKEY("msg"), embed_message, NEED_URL);
- WebcitAddUrlHandler(HKEY("message"), handle_one_message, NEED_URL|XHTTP_COMMANDS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
- WebcitAddUrlHandler(HKEY("printmsg"), print_message, NEED_URL);
- WebcitAddUrlHandler(HKEY("mobilemsg"), mobile_message_view, NEED_URL);
- WebcitAddUrlHandler(HKEY("msgheaders"), display_headers, NEED_URL);
-
- WebcitAddUrlHandler(HKEY("mimepart"), view_mimepart, NEED_URL);
- WebcitAddUrlHandler(HKEY("mimepart_download"), download_mimepart, NEED_URL);
- WebcitAddUrlHandler(HKEY("postpart"), view_postpart, NEED_URL);
- WebcitAddUrlHandler(HKEY("postpart_download"), download_postpart, NEED_URL);
+ WebcitAddUrlHandler(HKEY("readnew"), "", 0, h_readnew, NEED_URL);
+ WebcitAddUrlHandler(HKEY("readold"), "", 0, h_readold, NEED_URL);
+ WebcitAddUrlHandler(HKEY("readfwd"), "", 0, h_readfwd, NEED_URL);
+ WebcitAddUrlHandler(HKEY("headers"), "", 0, h_headers, NEED_URL);
+ WebcitAddUrlHandler(HKEY("readgt"), "", 0, h_readgt, NEED_URL);
+ WebcitAddUrlHandler(HKEY("readlt"), "", 0, h_readlt, NEED_URL);
+ WebcitAddUrlHandler(HKEY("do_search"), "", 0, h_do_search, 0);
+ WebcitAddUrlHandler(HKEY("display_enter"), "", 0, display_enter, 0);
+ WebcitAddUrlHandler(HKEY("post"), "", 0, post_message, 0);
+ WebcitAddUrlHandler(HKEY("move_msg"), "", 0, move_msg, 0);
+ WebcitAddUrlHandler(HKEY("delete_msg"), "", 0, delete_msg, 0);
+ WebcitAddUrlHandler(HKEY("confirm_move_msg"), "", 0, confirm_move_msg, 0);
+ WebcitAddUrlHandler(HKEY("msg"), "", 0, embed_message, NEED_URL);
+ WebcitAddUrlHandler(HKEY("message"), "", 0, handle_one_message, NEED_URL|XHTTP_COMMANDS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
+ WebcitAddUrlHandler(HKEY("printmsg"), "", 0, print_message, NEED_URL);
+ WebcitAddUrlHandler(HKEY("mobilemsg"), "", 0, mobile_message_view, NEED_URL);
+ WebcitAddUrlHandler(HKEY("msgheaders"), "", 0, display_headers, NEED_URL);
+
+ WebcitAddUrlHandler(HKEY("mimepart"), "", 0, view_mimepart, NEED_URL);
+ WebcitAddUrlHandler(HKEY("mimepart_download"), "", 0, download_mimepart, NEED_URL);
+ WebcitAddUrlHandler(HKEY("postpart"), "", 0, view_postpart, NEED_URL);
+ WebcitAddUrlHandler(HKEY("postpart_download"), "", 0, download_postpart, NEED_URL);
/* json */
- WebcitAddUrlHandler(HKEY("roommsgs"), jsonMessageList,0);
+ WebcitAddUrlHandler(HKEY("roommsgs"), "", 0, jsonMessageList,0);
return ;
}