4 * Functions which deal with the fetching and displaying of messages.
12 HashList *MsgHeaderHandler = NULL;
13 HashList *MsgEvaluators = NULL;
14 HashList *MimeRenderHandler = NULL;
15 HashList *ReadLoopHandler = NULL;
16 int dbg_analyze_msg = 0;
18 #define SUBJ_COL_WIDTH_PCT 50 /* Mailbox view column width */
19 #define SENDER_COL_WIDTH_PCT 30 /* Mailbox view column width */
20 #define DATE_PLUS_BUTTONS_WIDTH_PCT 20 /* Mailbox view column width */
22 void jsonMessageListHdr(void);
24 void display_enter(void);
26 typedef void (*MsgPartEvaluatorFunc)(message_summary *Sum, StrBuf *Buf);
28 typedef struct _MsgPartEvaluatorStruct {
29 MsgPartEvaluatorFunc f;
30 } MsgPartEvaluatorStruct;
32 int load_message(message_summary *Msg,
46 lprintf(9, "MSG4 %ld|%s\n", Msg->msgnum, ChrPtr(Msg->PartNum));
47 if (Msg->PartNum != NULL) {
48 serv_printf("MSG4 %ld|%s", Msg->msgnum, ChrPtr(Msg->PartNum));
51 serv_printf("MSG4 %ld", Msg->msgnum);
54 StrBuf_ServGetln(Buf);
55 if (GetServerStatus(Buf, NULL) != 1) {
57 StrBufAppendPrintf(*Error, "<strong>");
58 StrBufAppendPrintf(*Error, _("ERROR:"));
59 StrBufAppendPrintf(*Error, "</strong> %s<br />\n", &buf[4]);
64 /* begin everythingamundo table */
65 HdrToken = NewStrBuf();
66 while ((StrBuf_ServGetln(Buf)>=0) && !Done) {
67 if ( (StrLength(Buf)==3) &&
68 !strcmp(ChrPtr(Buf), "000"))
72 lprintf(1, _("unexpected end of message"));
73 if (Msg->MsgBody->Data == NULL)
74 Msg->MsgBody->Data = NewStrBuf();
75 Msg->MsgBody->ContentType = NewStrBufPlain(HKEY("text/html"));
76 StrBufAppendPrintf(Msg->MsgBody->Data, "<div><i>");
77 StrBufAppendPrintf(Msg->MsgBody->Data, _("unexpected end of message"));
78 StrBufAppendPrintf(Msg->MsgBody->Data, " (1)</i><br /><br />\n");
79 StrBufAppendPrintf(Msg->MsgBody->Data, "</div>\n");
84 case 0:/* Citadel Message Headers */
85 if (StrLength(Buf) == 0) {
89 StrBufExtract_token(HdrToken, Buf, 0, '=');
90 StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
93 if (dbg_analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf));
95 /* look up one of the examine_* functions to parse the content */
96 if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
98 Hdr = (headereval*)vHdr;
99 Hdr->evaluator(Msg, Buf, FoundCharset);
100 if (Hdr->Type == 1) {
104 else LogError(Target,
106 "don't know how to handle message header[%s]\n",
110 case 1:/* Message Mime Header */
111 if (StrLength(Buf) == 0) {
113 if (Msg->MsgBody->ContentType == NULL)
114 /* end of header or no header? */
115 Msg->MsgBody->ContentType = NewStrBufPlain(HKEY("text/plain"));
116 /* usual end of mime header */
120 StrBufExtract_token(HdrToken, Buf, 0, ':');
121 if (StrLength(HdrToken) > 0) {
122 StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
124 if (dbg_analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf));
126 /* the examine*'s know how to do with mime headers too... */
127 if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
129 Hdr = (headereval*)vHdr;
130 Hdr->evaluator(Msg, Buf, FoundCharset);
135 case 2: /* Message Body */
137 if (Msg->MsgBody->size_known > 0) {
138 StrBuf_ServGetBLOBBuffered(Msg->MsgBody->Data, Msg->MsgBody->length);
140 /*/ todo: check next line, if not 000, append following lines */
143 if (StrLength(Msg->MsgBody->Data) > 0)
144 StrBufAppendBufPlain(Msg->MsgBody->Data, "\n", 1, 0);
145 StrBufAppendBuf(Msg->MsgBody->Data, Buf, 0);
149 StrBufAppendBuf(Msg->MsgBody->Data, Buf, 0);
154 if (Msg->AllAttach == NULL)
155 Msg->AllAttach = NewHash(1,NULL);
156 /* now we put the body mimepart we read above into the mimelist */
157 Put(Msg->AllAttach, SKEY(Msg->MsgBody->PartNum), Msg->MsgBody, DestroyMime);
159 /* Generate a reply-to address */
160 if (StrLength(Msg->Rfca) > 0) {
161 if (Msg->reply_to == NULL)
162 Msg->reply_to = NewStrBuf();
163 if (StrLength(Msg->from) > 0) {
164 StrBufPrintf(Msg->reply_to, "%s <%s>", ChrPtr(Msg->from), ChrPtr(Msg->Rfca));
167 FlushStrBuf(Msg->reply_to);
168 StrBufAppendBuf(Msg->reply_to, Msg->Rfca, 0);
173 if ((StrLength(Msg->OtherNode)>0) &&
174 (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(WCC->serv_info->serv_nodename))) &&
175 (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(WCC->serv_info->serv_humannode)) ))
177 if (Msg->reply_to == NULL)
178 Msg->reply_to = NewStrBuf();
179 StrBufPrintf(Msg->reply_to,
182 ChrPtr(Msg->OtherNode));
185 if (Msg->reply_to == NULL)
186 Msg->reply_to = NewStrBuf();
187 FlushStrBuf(Msg->reply_to);
188 StrBufAppendBuf(Msg->reply_to, Msg->from, 0);
192 FreeStrBuf(&HdrToken);
199 * I wanna SEE that message!
201 * msgnum Message number to display
202 * printable_view Nonzero to display a printable view
203 * section Optional for encapsulated message/rfc822 submessage
205 int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, const StrBuf *PartNum, const StrBuf **OutMime)
208 StrBuf *FoundCharset;
211 message_summary *Msg = NULL;
215 WCTemplputParams SubTP;
216 StrBuf *Error = NULL;
219 FoundCharset = NewStrBuf();
220 Msg = (message_summary *)malloc(sizeof(message_summary));
221 memset(Msg, 0, sizeof(message_summary));
222 Msg->msgnum = msgnum;
223 Msg->PartNum = PartNum;
224 Msg->MsgBody = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
225 memset(Msg->MsgBody, 0, sizeof(wc_mime_attachment));
226 Msg->MsgBody->msgnum = msgnum;
228 if (!load_message(Msg, FoundCharset, &Error)) {
229 StrBufAppendBuf(Target, Error, 0);
233 /* strip the bare contenttype, so we ommit charset etc. */
234 StrBufExtract_token(Buf, Msg->MsgBody->ContentType, 0, ';');
236 StrBufLowerCase(Buf);
237 /* look up the renderer, that will convert this mimeitem into the htmlized form */
238 if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
240 RenderMimeFuncStruct *Render;
241 Render = (RenderMimeFuncStruct*)vHdr;
242 Render->f(Msg->MsgBody, NULL, FoundCharset);
245 if (StrLength(Msg->reply_references)> 0) {
246 /* Trim down excessively long lists of thread references. We eliminate the
247 * second one in the list so that the thread root remains intact.
249 int rrtok = num_tokens(ChrPtr(Msg->reply_references), '|');
250 int rrlen = StrLength(Msg->reply_references);
251 if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
252 StrBufRemove_token(Msg->reply_references, 1, '|');
256 /* now check if we need to translate some mimeparts, and remove the duplicate */
257 it = GetNewHashPos(Msg->AllAttach, 0);
258 while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) &&
260 wc_mime_attachment *Mime = (wc_mime_attachment*) vMime;
261 evaluate_mime_part(Msg, Mime);
264 memset(&SubTP, 0, sizeof(WCTemplputParams));
265 SubTP.Filter.ContextType = CTX_MAILSUM;
267 *OutMime = DoTemplate(tmpl, tmpllen, Target, &SubTP);
269 DestroyMessageSummary(Msg);
270 FreeStrBuf(&FoundCharset);
277 HttpStatus(long CitadelStatus)
279 long httpstatus = 502;
281 switch (MAJORCODE(CitadelStatus))
283 case LISTING_FOLLOWS:
288 switch (MINORCODE(CitadelStatus))
296 case HIGHER_ACCESS_REQUIRED:
297 case MAX_SESSIONS_EXCEEDED:
299 case RESOURCE_NOT_OPEN:
301 case INVALID_FLOOR_OPERATION:
307 case MESSAGE_NOT_FOUND:
317 case CMD_NOT_SUPPORTED:
318 case PASSWORD_REQUIRED:
319 case ALREADY_LOGGED_IN:
320 case USERNAME_REQUIRED:
322 case SERVER_SHUTTING_DOWN:
333 case START_CHAT_MODE:
337 httpstatus = 502; /* aeh... whut? */
345 * Unadorned HTML output of an individual message, suitable
346 * for placing in a hidden iframe, for printing, or whatever
348 void handle_one_message(void)
352 const StrBuf *Destination;
358 StrBuf *CmdBuf = NULL;
362 pMsg = strchr(ChrPtr(WCC->Hdr->HR.ReqLine), '/');
364 HttpStatus(CitStatus);
368 msgnum = atol(pMsg + 1);
369 StrBufCutAt(WCC->Hdr->HR.ReqLine, 0, pMsg);
370 gotoroom(WCC->Hdr->HR.ReqLine);
371 switch (WCC->Hdr->HR.eReqType)
375 Tmpl = sbstr("template");
376 if (StrLength(Tmpl) > 0)
377 read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime);
379 read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
380 http_transmit_thing(ChrPtr(Mime), 0);
383 CmdBuf = NewStrBuf ();
384 if (WCC->wc_is_trash) { /* Delete from Trash is a real delete */
385 serv_printf("DELE %ld", msgnum);
387 else { /* Otherwise move it to Trash */
388 serv_printf("MOVE %ld|_TRASH_|0", msgnum);
390 StrBuf_ServGetln(CmdBuf);
391 FlushStrBuf(WCC->ImportantMsg);
392 StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
393 GetServerStatus(CmdBuf, &CitStatus);
394 HttpStatus(CitStatus);
399 if (GetHash(WCC->Hdr->HTTPHeaders, HKEY("DESTINATION"), &vLine) &&
401 Destination = (StrBuf*) vLine;
402 serv_printf("MOVE %ld|%s|%d", msgnum, ChrPtr(Destination), CopyMessage);
403 StrBuf_ServGetln(CmdBuf);
404 FlushStrBuf(WCC->ImportantMsg);
405 StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
406 GetServerStatus(CmdBuf, &CitStatus);
407 HttpStatus(CitStatus);
420 * Unadorned HTML output of an individual message, suitable
421 * for placing in a hidden iframe, for printing, or whatever
423 void embed_message(void) {
428 StrBuf *CmdBuf = NULL;
430 msgnum = StrBufExtract_long(WCC->Hdr->HR.ReqLine, 0, '/');
431 switch (WCC->Hdr->HR.eReqType)
435 Tmpl = sbstr("template");
436 if (StrLength(Tmpl) > 0)
437 read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime);
439 read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
440 http_transmit_thing(ChrPtr(Mime), 0);
443 CmdBuf = NewStrBuf ();
444 if (WCC->wc_is_trash) { /* Delete from Trash is a real delete */
445 serv_printf("DELE %ld", msgnum);
447 else { /* Otherwise move it to Trash */
448 serv_printf("MOVE %ld|_TRASH_|0", msgnum);
450 StrBuf_ServGetln(CmdBuf);
451 FlushStrBuf(WCC->ImportantMsg);
452 StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
462 * Printable view of a message
464 void print_message(void) {
468 msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
469 output_headers(0, 0, 0, 0, 0, 0);
471 hprintf("Content-type: text/html\r\n"
472 "Server: " PACKAGE_STRING "\r\n"
473 "Connection: close\r\n");
477 read_message(WC->WBuf, HKEY("view_message_print"), msgnum, NULL, &Mime);
483 * Mobile browser view of message
485 void mobile_message_view(void)
490 msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
491 output_headers(1, 0, 0, 0, 0, 1);
493 do_template("msgcontrols", NULL);
494 read_message(WC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
499 * Display a message's headers
501 void display_headers(void) {
505 msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
506 output_headers(0, 0, 0, 0, 0, 0);
508 hprintf("Content-type: text/plain\r\n"
510 "Connection: close\r\n",
514 serv_printf("MSG2 %ld|3", msgnum);
515 serv_getln(buf, sizeof buf);
517 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
518 wprintf("%s\n", buf);
526 message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSubject, long MsgNum)
529 MsgPartEvaluatorStruct *Eval;
530 message_summary *Msg;
539 serv_printf("MSG0 %ld|1", MsgNum); /* ask for headers only */
541 StrBuf_ServGetln(Buf);
542 if (GetServerStatus(Buf, NULL) == 1) {
547 Msg = (message_summary*)malloc(sizeof(message_summary));
548 memset(Msg, 0, sizeof(message_summary));
549 while (len = StrBuf_ServGetln(Buf),
551 strcmp(ChrPtr(Buf), "000")== 0)){
553 ebuf = strchr(ChrPtr(Buf), '=');
555 if (GetHash(MsgEvaluators, buf, nBuf, &vEval) && vEval != NULL) {
556 Eval = (MsgPartEvaluatorStruct*) vEval;
557 StrBufCutLeft(Buf, nBuf + 1);
560 else lprintf(1, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf));
570 * load message pointers from the server for a "read messages" operation
572 * servcmd: the citadel command to send to the citserver
574 int load_msg_ptrs(const char *servcmd, SharedMessageStatus *Stat)
576 StrBuf* FoundCharset = NULL;
578 message_summary *Msg;
583 const char *Ptr = NULL;
585 Stat->lowest_found = LONG_MAX;
586 Stat->highest_found = LONG_MIN;
588 if (WCC->summ != NULL) {
589 DeleteHash(&WCC->summ);
591 WCC->summ = NewHash(1, Flathash);
595 StrBuf_ServGetln(Buf);
596 if (GetServerStatus(Buf, NULL) != 1) {
598 return (Stat->nummsgs);
601 while (len = StrBuf_ServGetln(Buf), ((len != 3) || strcmp(ChrPtr(Buf), "000")!= 0))
603 if (Stat->nummsgs < Stat->maxload) {
606 Msg = (message_summary*)malloc(sizeof(message_summary));
607 memset(Msg, 0, sizeof(message_summary));
609 Msg->msgnum = StrBufExtractNext_long(Buf, &Ptr, '|');
610 Msg->date = StrBufExtractNext_long(Buf, &Ptr, '|');
612 if (Stat->nummsgs == 0) {
613 if (Msg->msgnum < Stat->lowest_found) {
614 Stat->lowest_found = Msg->msgnum;
616 if (Msg->msgnum > Stat->highest_found) {
617 Stat->highest_found = Msg->msgnum;
621 if ((Msg->msgnum == 0) && (StrLength(Buf) < 32)) {
627 * as citserver probably gives us messages in forward date sorting
628 * nummsgs should be the same order as the message date.
630 if (Msg->date == 0) {
631 Msg->date = Stat->nummsgs;
632 if (StrLength(Buf) < 32)
636 Msg->from = NewStrBufPlain(NULL, StrLength(Buf));
637 StrBufExtract_NextToken(Buf2, Buf, &Ptr, '|');
638 if (StrLength(Buf2) != 0) {
639 /* Handle senders with RFC2047 encoding */
640 StrBuf_RFC822_to_Utf8(Msg->from, Buf2, WCC->DefaultCharset, FoundCharset);
644 StrBufExtract_NextToken(Buf2, Buf, &Ptr, '|');
645 if ((StrLength(Buf2) !=0 ) &&
646 ( ((WCC->room_flags & QR_NETWORK)
647 || ((strcasecmp(ChrPtr(Buf2), ChrPtr(WCC->serv_info->serv_nodename))
648 && (strcasecmp(ChrPtr(Buf2), ChrPtr(WCC->serv_info->serv_fqdn))))))))
650 StrBufAppendBufPlain(Msg->from, HKEY(" @ "), 0);
651 StrBufAppendBuf(Msg->from, Buf2, 0);
654 /* Internet address (not used)
655 * StrBufExtract_token(Msg->inetaddr, Buf, 4, '|');
657 StrBufSkip_NTokenS(Buf, &Ptr, '|', 1);
658 Msg->subj = NewStrBufPlain(NULL, StrLength(Buf));
659 StrBufExtract_NextToken(Buf2, Buf, &Ptr, '|');
660 if (StrLength(Buf2) == 0)
661 StrBufAppendBufPlain(Msg->subj, _("(no subject)"), -1,0);
663 StrBuf_RFC822_to_Utf8(Msg->subj, Buf2, WCC->DefaultCharset, FoundCharset);
664 if ((StrLength(Msg->subj) > 75) &&
665 (StrBuf_Utf8StrLen(Msg->subj) > 75)) {
666 StrBuf_Utf8StrCut(Msg->subj, 72);
667 StrBufAppendBufPlain(Msg->subj, HKEY("..."), 0);
671 if ((StrLength(Msg->from) > 25) &&
672 (StrBuf_Utf8StrLen(Msg->from) > 25)) {
673 StrBuf_Utf8StrCut(Msg->from, 23);
674 StrBufAppendBufPlain(Msg->from, HKEY("..."), 0);
678 Put(WCC->summ, (const char *)&n, sizeof(n), Msg, DestroyMessageSummary);
684 return (Stat->nummsgs);
688 inline message_summary* GetMessagePtrAt(int n, HashList *Summ)
696 GetHashAt(Summ, n, &HKLen, &Key, &vMsg);
697 return (message_summary*) vMsg;
702 void load_seen_flags(void)
704 message_summary *Msg;
712 OldMsg = NewStrBuf();
714 StrBuf_ServGetln(OldMsg);
715 if (GetServerStatus(OldMsg, NULL) == 2) {
716 StrBufCutLeft(OldMsg, 4);
722 at = GetNewHashPos(WCC->summ, 0);
723 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
724 /* Are you a new message, or an old message? */
725 Msg = (message_summary*) vMsg;
726 if (is_msg_in_mset(ChrPtr(OldMsg), Msg->msgnum)) {
737 extern readloop_struct rlid[];
739 typedef struct _RoomRenderer{
742 GetParamsGetServerCall_func GetParamsGetServerCall;
743 PrintViewHeader_func PrintViewHeader;
744 LoadMsgFromServer_func LoadMsgFromServer;
745 RenderView_or_Tail_func RenderView_or_Tail;
746 View_Cleanup_func ViewCleanup;
751 * command loop for reading messages
753 * Set oper to "readnew" or "readold" or "readfwd" or "headers" or "readgt"
755 void readloop(long oper)
757 RoomRenderer *ViewMsg;
760 message_summary *Msg;
767 WCTemplputParams SubTP;
768 SharedMessageStatus Stat;
771 if (havebstr("is_summary") && (1 == (ibstr("is_summary"))))
772 WCC->wc_view = VIEW_MAILBOX;
774 memset(&Stat, 0, sizeof(SharedMessageStatus));
775 Stat.maxload = 10000;
776 Stat.lowest_found = (-1);
777 Stat.highest_found = (-1);
778 GetHash(ReadLoopHandler, IKEY(WCC->wc_view), &vViewMsg);
779 if (vViewMsg == NULL) {
780 WCC->wc_view = VIEW_BBS;
781 GetHash(ReadLoopHandler, IKEY(WCC->wc_view), &vViewMsg);
783 if (vViewMsg == NULL)
784 return;///TODO: print message
786 ViewMsg = (RoomRenderer*) vViewMsg;
788 output_headers(1, 1, 1, 0, 0, 0);
789 } else if (WCC->wc_view == VIEW_MAILBOX) {
790 jsonMessageListHdr();
793 if (ViewMsg->GetParamsGetServerCall != NULL) {
794 r = ViewMsg->GetParamsGetServerCall(
809 case 300: /* the callback hook should do the work for us here, since he knows what to do. */
815 if (!IsEmptyStr(cmd))
816 Stat.nummsgs = load_msg_ptrs(cmd, &Stat);
820 memset(&SubTP, 0, sizeof(WCTemplputParams));
821 SubTP.Filter.ContextType = CTX_NONE;
822 SubTP.Context = NULL;
823 SortIt = RetrieveSort(&SubTP, NULL, 0,
824 HKEY("date"), Stat.defaultsortorder);
826 SortByPayload(WCC->summ, SortIt);
828 if (Stat.startmsg < 0)
829 Stat.startmsg = (Stat.reverse) ? Stat.nummsgs - 1 : 0;
831 if (Stat.load_seen) load_seen_flags();
834 * Print any inforation above the message list...
836 if (ViewMsg->PrintViewHeader != NULL)
837 ViewMsg->PrintViewHeader(&Stat, &ViewSpecific);
839 WCC->startmsg = Stat.startmsg;
840 WCC->maxmsgs = Stat.maxmsgs;
841 WCC->num_displayed = 0;
843 /* Put some helpful data in vars for mailsummary_json */
844 svputlong("READLOOP:TOTALMSGS", Stat.nummsgs);
845 svputlong("READLOOP:STARTMSG", Stat.startmsg);
846 svputlong("WCVIEW", WCC->wc_view);
849 * iterate over each message. if we need to load an attachment, do it here.
852 if ((ViewMsg->LoadMsgFromServer != NULL) &&
855 at = GetNewHashPos(WCC->summ, 0);
856 Stat.num_displayed = i = 0;
857 while ( GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
858 Msg = (message_summary*) vMsg;
859 if ((Msg->msgnum >= Stat.startmsg) && (Stat.num_displayed <= Stat.maxmsgs)) {
860 ViewMsg->LoadMsgFromServer(&Stat, &ViewSpecific, Msg, Msg->is_new, i);
868 * Done iterating the message list. now tasks we want to do after.
870 if (ViewMsg->RenderView_or_Tail != NULL)
871 ViewMsg->RenderView_or_Tail(&Stat, &ViewSpecific, oper);
873 if (ViewMsg->ViewCleanup != NULL)
874 ViewMsg->ViewCleanup(&ViewSpecific);
878 if (WCC->summ != NULL) {
879 DeleteHash(&WCC->summ);
885 * Back end for post_message()
886 * ... this is where the actual message gets transmitted to the server.
888 void post_mime_to_server(void) {
890 char top_boundary[SIZ];
891 char alt_boundary[SIZ];
892 int is_multipart = 0;
894 wc_mime_attachment *att;
896 size_t encoded_length;
897 size_t encoded_strlen;
898 char *txtmail = NULL;
900 sprintf(top_boundary, "Citadel--Multipart--%s--%04x--%04x",
901 ChrPtr(WCC->serv_info->serv_fqdn),
905 sprintf(alt_boundary, "Citadel--Multipart--%s--%04x--%04x",
906 ChrPtr(WCC->serv_info->serv_fqdn),
911 /* RFC2045 requires this, and some clients look for it... */
912 serv_puts("MIME-Version: 1.0");
913 serv_puts("X-Mailer: " PACKAGE_STRING);
915 /* If there are attachments, we have to do multipart/mixed */
916 if (GetCount(WCC->attachments) > 0) {
921 /* Remember, serv_printf() appends an extra newline */
922 serv_printf("Content-type: multipart/mixed; boundary=\"%s\"\n", top_boundary);
923 serv_printf("This is a multipart message in MIME format.\n");
924 serv_printf("--%s", top_boundary);
927 /* Remember, serv_printf() appends an extra newline */
928 serv_printf("Content-type: multipart/alternative; "
929 "boundary=\"%s\"\n", alt_boundary);
930 serv_printf("This is a multipart message in MIME format.\n");
931 serv_printf("--%s", alt_boundary);
933 serv_puts("Content-type: text/plain; charset=utf-8");
934 serv_puts("Content-Transfer-Encoding: quoted-printable");
936 txtmail = html_to_ascii(bstr("msgtext"), 0, 80, 0);
937 text_to_server_qp(txtmail); /* Transmit message in quoted-printable encoding */
940 serv_printf("--%s", alt_boundary);
942 serv_puts("Content-type: text/html; charset=utf-8");
943 serv_puts("Content-Transfer-Encoding: quoted-printable");
945 serv_puts("<html><body>\r\n");
946 text_to_server_qp(bstr("msgtext")); /* Transmit message in quoted-printable encoding */
947 serv_puts("</body></html>\r\n");
949 serv_printf("--%s--", alt_boundary);
957 /* Add in the attachments */
958 it = GetNewHashPos(WCC->attachments, 0);
959 while (GetNextHashPos(WCC->attachments, it, &len, &Key, &vAtt)) {
960 att = (wc_mime_attachment *)vAtt;
961 if (att->length == 0)
963 encoded_length = ((att->length * 150) / 100);
964 encoded = malloc(encoded_length);
965 if (encoded == NULL) break;
966 encoded_strlen = CtdlEncodeBase64(encoded, ChrPtr(att->Data), StrLength(att->Data), 1);
968 serv_printf("--%s", top_boundary);
969 serv_printf("Content-type: %s", ChrPtr(att->ContentType));
970 serv_printf("Content-disposition: attachment; filename=\"%s\"", ChrPtr(att->FileName));
971 serv_puts("Content-transfer-encoding: base64");
973 serv_write(encoded, encoded_strlen);
978 serv_printf("--%s--", top_boundary);
987 * Post message (or don't post message)
989 * Note regarding the "dont_post" variable:
990 * A random value (actually, it's just a timestamp) is inserted as a hidden
991 * field called "postseq" when the display_enter page is generated. This
992 * value is checked when posting, using the static variable dont_post. If a
993 * user attempts to post twice using the same dont_post value, the message is
994 * discarded. This prevents the accidental double-saving of the same message
995 * if the user happens to click the browser "back" button.
997 void post_message(void)
1000 StrBuf *encoded_subject = NULL;
1001 static long dont_post = (-1L);
1002 wc_mime_attachment *att;
1003 int is_anonymous = 0;
1004 const StrBuf *display_name = NULL;
1005 wcsession *WCC = WC;
1008 if (havebstr("force_room")) {
1009 gotoroom(sbstr("force_room"));
1012 if (havebstr("display_name")) {
1013 display_name = sbstr("display_name");
1014 if (!strcmp(ChrPtr(display_name), "__ANONYMOUS__")) {
1015 display_name = NULL;
1020 if (WCC->upload_length > 0) {
1025 /* There's an attachment. Save it to this struct... */
1026 lprintf(9, "Client is uploading %d bytes\n", WCC->upload_length);
1027 att = malloc(sizeof(wc_mime_attachment));
1028 memset(att, 0, sizeof(wc_mime_attachment ));
1029 att->length = WCC->upload_length;
1030 att->ContentType = NewStrBufPlain(WCC->upload_content_type, -1);
1031 att->FileName = NewStrBufPlain(WCC->upload_filename, -1);
1033 if (WCC->attachments == NULL) {
1034 WCC->attachments = NewHash(1, NULL);
1037 /* And add it to the list. */
1038 n = snprintf(N, sizeof N, "%d", GetCount(WCC->attachments) + 1);
1039 Put(WCC->attachments, N, n, att, DestroyMime);
1042 * Mozilla sends a simple filename, which is what we want,
1043 * but Satan's Browser sends an entire pathname. Reduce
1044 * the path to just a filename if we need to.
1046 pch = strrchr(ChrPtr(att->FileName), '/');
1048 StrBufCutLeft(att->FileName, pch - ChrPtr(att->FileName) + 1);
1050 pch = strrchr(ChrPtr(att->FileName), '\\');
1052 StrBufCutLeft(att->FileName, pch - ChrPtr(att->FileName) + 1);
1056 * Transfer control of this memory from the upload struct
1057 * to the attachment struct.
1059 att->Data = WCC->upload;
1061 WCC->upload_length = 0;
1066 if (havebstr("cancel_button")) {
1067 sprintf(WCC->ImportantMessage,
1068 _("Cancelled. Message was not posted."));
1069 } else if (havebstr("attach_button")) {
1072 } else if (lbstr("postseq") == dont_post) {
1073 sprintf(WCC->ImportantMessage,
1074 _("Automatically cancelled because you have already "
1075 "saved this message."));
1077 const char CMD[] = "ENT0 1|%s|%d|4|%s|%s||%s|%s|%s|%s|%s";
1078 const StrBuf *Recp = NULL;
1079 const StrBuf *Cc = NULL;
1080 const StrBuf *Bcc = NULL;
1081 const StrBuf *Wikipage = NULL;
1082 const StrBuf *my_email_addr = NULL;
1083 StrBuf *CmdBuf = NULL;
1084 StrBuf *references = NULL;
1087 save_to_drafts = havebstr("save_button");
1090 if (save_to_drafts) {
1091 /* temporarily change to the drafts room */
1092 serv_puts("GOTO _DRAFTS_");
1093 StrBuf_ServGetln(Buf);
1094 if (GetServerStatus(Buf, NULL) != 2) {
1095 /* You probably don't even have a dumb Drafts folder */
1096 StrBufCutLeft(Buf, 4);
1097 lprintf(9, "%s:%d: server save to drafts error: %s\n", __FILE__, __LINE__, ChrPtr(Buf));
1098 StrBufAppendBufPlain(WCC->ImportantMsg, _("Saved to Drafts failed: "), -1, 0);
1099 StrBufAppendBuf(WCC->ImportantMsg, Buf, 0);
1106 if (havebstr("references"))
1108 const StrBuf *ref = sbstr("references");
1109 references = NewStrBufDup(ref);
1110 if (*ChrPtr(references) == '|') { /* remove leading '|' if present */
1111 StrBufCutLeft(references, 1);
1113 StrBufReplaceChars(references, '|', '!');
1115 if (havebstr("subject")) {
1118 * make enough room for the encoded string;
1119 * plus the QP header
1121 Subj = sbstr("subject");
1123 StrBufRFC2047encode(&encoded_subject, Subj);
1125 Recp = sbstr("recp");
1128 Wikipage = sbstr("wikipage");
1129 my_email_addr = sbstr("my_email_addr");
1131 CmdBuf = NewStrBufPlain(NULL,
1134 StrLength(encoded_subject) +
1137 StrLength(Wikipage) +
1138 StrLength(my_email_addr) +
1139 StrLength(references));
1141 StrBufPrintf(CmdBuf,
1143 save_to_drafts?"":ChrPtr(Recp),
1145 ChrPtr(encoded_subject),
1146 ChrPtr(display_name),
1147 save_to_drafts?"":ChrPtr(Cc),
1148 save_to_drafts?"":ChrPtr(Bcc),
1150 ChrPtr(my_email_addr),
1151 ChrPtr(references));
1152 FreeStrBuf(&references);
1153 FreeStrBuf(&encoded_subject);
1155 lprintf(9, "%s\n", ChrPtr(CmdBuf));
1156 serv_puts(ChrPtr(CmdBuf));
1157 FreeStrBuf(&CmdBuf);
1159 StrBuf_ServGetln(Buf);
1160 if (GetServerStatus(Buf, NULL) == 4) {
1161 if (save_to_drafts) {
1162 if ( (havebstr("recp"))
1163 || (havebstr("cc" ))
1164 || (havebstr("bcc" )) ) {
1165 /* save recipient headers or room to post to */
1166 serv_printf("To: %s", ChrPtr(Recp));
1167 serv_printf("Cc: %s", ChrPtr(Cc));
1168 serv_printf("Bcc: %s", ChrPtr(Bcc));
1170 serv_printf("X-Citadel-Room: %s", ChrPtr(WC->wc_roomname));
1173 post_mime_to_server();
1174 if (save_to_drafts) {
1175 StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been saved to Drafts.\n"), -1, 0);
1176 gotoroom(WCC->wc_roomname);
1180 } else if ( (havebstr("recp"))
1181 || (havebstr("cc" ))
1182 || (havebstr("bcc" ))
1184 StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been sent.\n"), -1, 0);
1187 StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been posted.\n"), -1, 0);
1189 dont_post = lbstr("postseq");
1191 StrBufCutLeft(Buf, 4);
1193 lprintf(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, ChrPtr(Buf));
1194 StrBufAppendBuf(WCC->ImportantMsg, Buf, 0);
1195 if (save_to_drafts) gotoroom(WCC->wc_roomname);
1203 DeleteHash(&WCC->attachments);
1206 * We may have been supplied with instructions regarding the location
1207 * to which we must return after posting. If found, go there.
1209 if (havebstr("return_to")) {
1210 http_redirect(bstr("return_to"));
1213 * If we were editing a page in a wiki room, go to that page now.
1215 else if (havebstr("wikipage")) {
1216 snprintf(buf, sizeof buf, "wiki?page=%s", bstr("wikipage"));
1220 * Otherwise, just go to the "read messages" loop.
1231 * display the message entry screen
1233 void display_enter(void)
1237 const StrBuf *display_name = NULL;
1238 int recipient_required = 0;
1239 int subject_required = 0;
1240 int recipient_bad = 0;
1241 int is_anonymous = 0;
1242 wcsession *WCC = WC;
1246 if (havebstr("force_room")) {
1247 gotoroom(sbstr("force_room"));
1250 display_name = sbstr("display_name");
1251 if (!strcmp(ChrPtr(display_name), "__ANONYMOUS__")) {
1252 display_name = NULL;
1256 /* First test to see whether this is a room that requires recipients to be entered */
1257 serv_puts("ENT0 0");
1258 serv_getln(buf, sizeof buf);
1260 if (!strncmp(buf, "570", 3)) { /* 570 means that we need a recipient here */
1261 recipient_required = 1;
1263 else if (buf[0] != '2') { /* Any other error means that we cannot continue */
1264 sprintf(WCC->ImportantMessage, "%s", &buf[4]);
1269 /* Is the server strongly recommending that the user enter a message subject? */
1270 if ((buf[3] != '\0') && (buf[4] != '\0')) {
1271 subject_required = extract_int(&buf[4], 1);
1275 * Are we perhaps in an address book view? If so, then an "enter
1276 * message" command really means "add new entry."
1278 if (WCC->wc_default_view == VIEW_ADDRESSBOOK) {
1279 do_edit_vcard(-1, "", NULL, NULL, "", ChrPtr(WCC->wc_roomname));
1284 * Are we perhaps in a calendar room? If so, then an "enter
1285 * message" command really means "add new calendar item."
1287 if (WCC->wc_default_view == VIEW_CALENDAR) {
1288 display_edit_event();
1293 * Are we perhaps in a tasks view? If so, then an "enter
1294 * message" command really means "add new task."
1296 if (WCC->wc_default_view == VIEW_TASKS) {
1297 display_edit_task();
1302 * Otherwise proceed normally.
1303 * Do a custom room banner with no navbar...
1306 if (recipient_required) {
1307 const StrBuf *Recp = NULL;
1308 const StrBuf *Cc = NULL;
1309 const StrBuf *Bcc = NULL;
1310 const StrBuf *Wikipage = NULL;
1311 StrBuf *CmdBuf = NULL;
1312 const char CMD[] = "ENT0 0|%s|%d|0||%s||%s|%s|%s";
1314 Recp = sbstr("recp");
1317 Wikipage = sbstr("wikipage");
1319 CmdBuf = NewStrBufPlain(NULL,
1322 StrLength(display_name) +
1325 StrLength(Wikipage));
1327 StrBufPrintf(CmdBuf,
1331 ChrPtr(display_name),
1335 serv_puts(ChrPtr(CmdBuf));
1336 serv_getln(buf, sizeof buf);
1337 FreeStrBuf(&CmdBuf);
1339 if (!strncmp(buf, "570", 3)) { /* 570 means we have an invalid recipient listed */
1340 if (havebstr("recp") &&
1346 else if (buf[0] != '2') { /* Any other error means that we cannot continue */
1347 wprintf("<em>%s</em><br />\n", &buf[4]); /* TODO -> important message */
1351 svputlong("RCPTREQUIRED", recipient_required);
1352 svputlong("SUBJREQUIRED", recipient_required || subject_required);
1355 output_headers(1, 0, 0, 0, 1, 0);
1356 DoTemplate(HKEY("edit_message"), NULL, &NoCtx);
1365 void delete_msg(void)
1370 msgid = lbstr("msgid");
1372 if (WC->wc_is_trash) { /* Delete from Trash is a real delete */
1373 serv_printf("DELE %ld", msgid);
1375 else { /* Otherwise move it to Trash */
1376 serv_printf("MOVE %ld|_TRASH_|0", msgid);
1379 serv_getln(buf, sizeof buf);
1380 sprintf(WC->ImportantMessage, "%s", &buf[4]);
1386 * move a message to another room
1393 msgid = lbstr("msgid");
1395 if (havebstr("move_button")) {
1396 sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
1398 serv_getln(buf, sizeof buf);
1399 sprintf(WC->ImportantMessage, "%s", &buf[4]);
1401 sprintf(WC->ImportantMessage, (_("The message was not moved.")));
1409 * Confirm move of a message
1411 void confirm_move_msg(void)
1417 msgid = lbstr("msgid");
1420 output_headers(1, 1, 2, 0, 0, 0);
1421 wprintf("<div id=\"banner\">\n");
1423 wprintf(_("Confirm move of message"));
1425 wprintf("</div>\n");
1427 wprintf("<div id=\"content\" class=\"service\">\n");
1429 wprintf("<CENTER>");
1431 wprintf(_("Move this message to:"));
1432 wprintf("<br />\n");
1434 wprintf("<form METHOD=\"POST\" action=\"move_msg\">\n");
1435 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1436 wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n", bstr("msgid"));
1438 wprintf("<SELECT NAME=\"target_room\" SIZE=5>\n");
1440 serv_getln(buf, sizeof buf);
1441 if (buf[0] == '1') {
1442 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1443 extract_token(targ, buf, 0, '|', sizeof targ);
1444 wprintf("<OPTION>");
1449 wprintf("</SELECT>\n");
1450 wprintf("<br />\n");
1452 wprintf("<INPUT TYPE=\"submit\" NAME=\"move_button\" VALUE=\"%s\">", _("Move"));
1454 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1455 wprintf("</form></CENTER>\n");
1457 wprintf("</CENTER>\n");
1463 * Generic function to output an arbitrary MIME attachment from
1464 * message being composed
1466 * partnum The MIME part to be output
1467 * filename Fake filename to give
1468 * force_download Nonzero to force set the Content-Type: header to "application/octet-stream"
1470 void postpart(StrBuf *partnum, StrBuf *filename, int force_download)
1473 StrBuf *content_type;
1474 wc_mime_attachment *part;
1476 if (GetHash(WC->attachments, SKEY(partnum), &vPart) &&
1478 part = (wc_mime_attachment*) vPart;
1479 if (force_download) {
1480 content_type = NewStrBufPlain(HKEY("application/octet-stream"));
1483 content_type = NewStrBufDup(part->ContentType);
1485 StrBufAppendBuf(WC->WBuf, part->Data, 0);
1486 http_transmit_thing(ChrPtr(content_type), 0);
1488 hprintf("HTTP/1.1 404 %s\n", ChrPtr(partnum));
1489 output_headers(0, 0, 0, 0, 0, 0);
1490 hprintf("Content-Type: text/plain\r\n");
1492 wprintf(_("An error occurred while retrieving this part: %s/%s\n"),
1493 ChrPtr(partnum), ChrPtr(filename));
1496 FreeStrBuf(&content_type);
1501 * Generic function to output an arbitrary MIME part from an arbitrary
1502 * message number on the server.
1504 * msgnum Number of the item on the citadel server
1505 * partnum The MIME part to be output
1506 * force_download Nonzero to force set the Content-Type: header to "application/octet-stream"
1508 void mimepart(int force_download)
1512 wcsession *WCC = WC;
1515 StrBuf *ContentType = NewStrBufPlain(HKEY("application/octet-stream"));
1518 att = Buf = NewStrBuf();
1519 msgnum = StrBufExtract_long(WCC->Hdr->HR.ReqLine, 0, '/');
1520 StrBufExtract_token(att, WCC->Hdr->HR.ReqLine, 1, '/');
1522 serv_printf("OPNA %ld|%s", msgnum, ChrPtr(att));
1523 StrBuf_ServGetln(Buf);
1524 if (GetServerStatus(Buf, NULL) == 2) {
1525 StrBufCutLeft(Buf, 4);
1526 bytes = StrBufExtract_long(Buf, 0, '|');
1527 if (!force_download) {
1528 StrBufExtract_token(ContentType, Buf, 3, '|');
1531 read_server_binary(WCC->WBuf, bytes, Buf);
1533 StrBuf_ServGetln(Buf);
1534 CT = ChrPtr(ContentType);
1536 if (!force_download) {
1537 if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) {
1538 StrBufExtract_token(Buf, WCC->Hdr->HR.ReqLine, 2, '/');
1539 CT = GuessMimeByFilename(SKEY(Buf));
1541 if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) {
1542 CT = GuessMimeType(SKEY(WCC->WBuf));
1545 http_transmit_thing(CT, 0);
1547 StrBufCutLeft(Buf, 4);
1548 hprintf("HTTP/1.1 404 %s\n", ChrPtr(Buf));
1549 output_headers(0, 0, 0, 0, 0, 0);
1550 hprintf("Content-Type: text/plain\r\n");
1552 wprintf(_("An error occurred while retrieving this part: %s\n"),
1556 FreeStrBuf(&ContentType);
1562 * Read any MIME part of a message, from the server, into memory.
1564 StrBuf *load_mimepart(long msgnum, char *partnum)
1570 serv_printf("DLAT %ld|%s", msgnum, partnum);
1571 StrBuf_ServGetln(Buf);
1572 if (GetServerStatus(Buf, NULL) == 6) {
1573 StrBufCutLeft(Buf, 4);
1574 bytes = StrBufExtract_long(Buf, 0, '|');
1577 StrBuf_ServGetBLOBBuffered(Buf, bytes);
1587 * Read any MIME part of a message, from the server, into memory.
1589 void MimeLoadData(wc_mime_attachment *Mime)
1593 /* TODO: is there a chance the content type is different from the one we know? */
1594 serv_printf("DLAT %ld|%s", Mime->msgnum, ChrPtr(Mime->PartNum));
1596 StrBuf_ServGetln(Buf);
1597 if (GetServerStatus(Buf, NULL) == 6) {
1598 bytes = extract_long(&(ChrPtr(Buf)[4]), 0);
1600 if (Mime->Data == NULL)
1601 Mime->Data = NewStrBufPlain(NULL, bytes);
1602 StrBuf_ServGetBLOBBuffered(Mime->Data, bytes);
1605 FlushStrBuf(Mime->Data);
1606 /* TODO XImportant message */
1614 void view_mimepart(void) {
1618 void download_mimepart(void) {
1622 void view_postpart(void) {
1623 StrBuf *filename = NewStrBuf();
1624 StrBuf *partnum = NewStrBuf();
1626 StrBufExtract_token(partnum, WC->Hdr->HR.ReqLine, 0, '/');
1627 StrBufExtract_token(filename, WC->Hdr->HR.ReqLine, 1, '/');
1629 postpart(partnum, filename, 0);
1631 FreeStrBuf(&filename);
1632 FreeStrBuf(&partnum);
1635 void download_postpart(void) {
1636 StrBuf *filename = NewStrBuf();
1637 StrBuf *partnum = NewStrBuf();
1639 StrBufExtract_token(partnum, WC->Hdr->HR.ReqLine, 0, '/');
1640 StrBufExtract_token(filename, WC->Hdr->HR.ReqLine, 1, '/');
1642 postpart(partnum, filename, 1);
1644 FreeStrBuf(&filename);
1645 FreeStrBuf(&partnum);
1648 void h_readnew(void) { readloop(readnew);}
1649 void h_readold(void) { readloop(readold);}
1650 void h_readfwd(void) { readloop(readfwd);}
1651 void h_headers(void) { readloop(headers);}
1652 void h_do_search(void) { readloop(do_search);}
1653 void h_readgt(void) { readloop(readgt);}
1655 void jsonMessageListHdr(void)
1657 /* TODO: make a generic function */
1658 hprintf("HTTP/1.1 200 OK\r\n");
1659 hprintf("Content-type: application/json; charset=utf-8\r\n");
1660 hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
1661 hprintf("Connection: close\r\n");
1662 hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n");
1667 /* Output message list in JSON format */
1668 void jsonMessageList(void) {
1669 const StrBuf *room = sbstr("room");
1670 long oper = (havebstr("query")) ? do_search : readnew;
1677 void RegisterReadLoopHandlerset(
1679 GetParamsGetServerCall_func GetParamsGetServerCall,
1680 PrintViewHeader_func PrintViewHeader,
1681 LoadMsgFromServer_func LoadMsgFromServer,
1682 RenderView_or_Tail_func RenderView_or_Tail,
1683 View_Cleanup_func ViewCleanup
1686 RoomRenderer *Handler;
1688 Handler = (RoomRenderer*) malloc(sizeof(RoomRenderer));
1690 Handler->RoomType = RoomType;
1691 Handler->GetParamsGetServerCall = GetParamsGetServerCall;
1692 Handler->PrintViewHeader = PrintViewHeader;
1693 Handler->LoadMsgFromServer = LoadMsgFromServer;
1694 Handler->RenderView_or_Tail = RenderView_or_Tail;
1695 Handler->ViewCleanup = ViewCleanup;
1697 Put(ReadLoopHandler, IKEY(RoomType), Handler, NULL);
1704 RegisterPreference("use_sig",
1705 _("Attach signature to email messages?"),
1708 RegisterPreference("signature", _("Use this signature:"), PRF_QP_STRING, NULL);
1709 RegisterPreference("default_header_charset",
1710 _("Default character set for email headers:"),
1713 RegisterPreference("defaultfrom", _("Preferred email address"), PRF_STRING, NULL);
1714 RegisterPreference("defaultname",
1715 _("Preferred display name for email messages"),
1718 RegisterPreference("defaulthandle",
1719 _("Preferred display name for bulletin board posts"),
1722 RegisterPreference("mailbox",_("Mailbox view mode"), PRF_STRING, NULL);
1724 WebcitAddUrlHandler(HKEY("readnew"), h_readnew, NEED_URL);
1725 WebcitAddUrlHandler(HKEY("readold"), h_readold, NEED_URL);
1726 WebcitAddUrlHandler(HKEY("readfwd"), h_readfwd, NEED_URL);
1727 WebcitAddUrlHandler(HKEY("headers"), h_headers, NEED_URL);
1728 WebcitAddUrlHandler(HKEY("readgt"), h_readgt, NEED_URL);
1729 WebcitAddUrlHandler(HKEY("do_search"), h_do_search, 0);
1730 WebcitAddUrlHandler(HKEY("display_enter"), display_enter, 0);
1731 WebcitAddUrlHandler(HKEY("post"), post_message, 0);
1732 WebcitAddUrlHandler(HKEY("move_msg"), move_msg, 0);
1733 WebcitAddUrlHandler(HKEY("delete_msg"), delete_msg, 0);
1734 WebcitAddUrlHandler(HKEY("confirm_move_msg"), confirm_move_msg, 0);
1735 WebcitAddUrlHandler(HKEY("msg"), embed_message, NEED_URL);
1736 WebcitAddUrlHandler(HKEY("message"), handle_one_message, NEED_URL|XHTTP_COMMANDS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
1737 WebcitAddUrlHandler(HKEY("printmsg"), print_message, NEED_URL);
1738 WebcitAddUrlHandler(HKEY("mobilemsg"), mobile_message_view, NEED_URL);
1739 WebcitAddUrlHandler(HKEY("msgheaders"), display_headers, NEED_URL);
1741 WebcitAddUrlHandler(HKEY("mimepart"), view_mimepart, NEED_URL);
1742 WebcitAddUrlHandler(HKEY("mimepart_download"), download_mimepart, NEED_URL);
1743 WebcitAddUrlHandler(HKEY("postpart"), view_postpart, NEED_URL);
1744 WebcitAddUrlHandler(HKEY("postpart_download"), download_postpart, NEED_URL);
1747 WebcitAddUrlHandler(HKEY("roommsgs"), jsonMessageList,0);
1752 SessionDetachModule_MSG
1755 DeleteHash(&sess->summ);