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 (!Done && StrBuf_ServGetln(Buf)>=0) {
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 /* Extract just the content-type (omit attributes such as "charset") */
234 StrBufExtract_token(Buf, Msg->MsgBody->ContentType, 0, ';');
236 StrBufLowerCase(Buf);
238 /* Locate a renderer capable of converting this MIME part into HTML */
239 if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
241 RenderMimeFuncStruct *Render;
242 Render = (RenderMimeFuncStruct*)vHdr;
243 Render->f(Msg->MsgBody, NULL, FoundCharset);
246 if (StrLength(Msg->reply_references)> 0) {
247 /* Trim down excessively long lists of thread references. We eliminate the
248 * second one in the list so that the thread root remains intact.
250 int rrtok = num_tokens(ChrPtr(Msg->reply_references), '|');
251 int rrlen = StrLength(Msg->reply_references);
252 if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
253 StrBufRemove_token(Msg->reply_references, 1, '|');
257 /* now check if we need to translate some mimeparts, and remove the duplicate */
258 it = GetNewHashPos(Msg->AllAttach, 0);
259 while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) &&
261 wc_mime_attachment *Mime = (wc_mime_attachment*) vMime;
262 evaluate_mime_part(Msg, Mime);
265 memset(&SubTP, 0, sizeof(WCTemplputParams));
266 SubTP.Filter.ContextType = CTX_MAILSUM;
268 *OutMime = DoTemplate(tmpl, tmpllen, Target, &SubTP);
270 DestroyMessageSummary(Msg);
271 FreeStrBuf(&FoundCharset);
278 HttpStatus(long CitadelStatus)
280 long httpstatus = 502;
282 switch (MAJORCODE(CitadelStatus))
284 case LISTING_FOLLOWS:
289 switch (MINORCODE(CitadelStatus))
297 case HIGHER_ACCESS_REQUIRED:
298 case MAX_SESSIONS_EXCEEDED:
300 case RESOURCE_NOT_OPEN:
302 case INVALID_FLOOR_OPERATION:
308 case MESSAGE_NOT_FOUND:
318 case CMD_NOT_SUPPORTED:
319 case PASSWORD_REQUIRED:
320 case ALREADY_LOGGED_IN:
321 case USERNAME_REQUIRED:
323 case SERVER_SHUTTING_DOWN:
334 case START_CHAT_MODE:
338 httpstatus = 502; /* aeh... whut? */
346 * Unadorned HTML output of an individual message, suitable
347 * for placing in a hidden iframe, for printing, or whatever
349 void handle_one_message(void)
353 const StrBuf *Destination;
359 StrBuf *CmdBuf = NULL;
363 pMsg = strchr(ChrPtr(WCC->Hdr->HR.ReqLine), '/');
365 HttpStatus(CitStatus);
369 msgnum = atol(pMsg + 1);
370 StrBufCutAt(WCC->Hdr->HR.ReqLine, 0, pMsg);
371 gotoroom(WCC->Hdr->HR.ReqLine);
372 switch (WCC->Hdr->HR.eReqType)
376 Tmpl = sbstr("template");
377 if (StrLength(Tmpl) > 0)
378 read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime);
380 read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
381 http_transmit_thing(ChrPtr(Mime), 0);
384 CmdBuf = NewStrBuf ();
385 if ((WCC->CurRoom.RAFlags & UA_ISTRASH) != 0) { /* Delete from Trash is a real delete */
386 serv_printf("DELE %ld", msgnum);
388 else { /* Otherwise move it to Trash */
389 serv_printf("MOVE %ld|_TRASH_|0", msgnum);
391 StrBuf_ServGetln(CmdBuf);
392 FlushStrBuf(WCC->ImportantMsg);
393 StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
394 GetServerStatus(CmdBuf, &CitStatus);
395 HttpStatus(CitStatus);
400 if (GetHash(WCC->Hdr->HTTPHeaders, HKEY("DESTINATION"), &vLine) &&
402 Destination = (StrBuf*) vLine;
403 serv_printf("MOVE %ld|%s|%d", msgnum, ChrPtr(Destination), CopyMessage);
404 StrBuf_ServGetln(CmdBuf);
405 FlushStrBuf(WCC->ImportantMsg);
406 StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
407 GetServerStatus(CmdBuf, &CitStatus);
408 HttpStatus(CitStatus);
421 * Unadorned HTML output of an individual message, suitable
422 * for placing in a hidden iframe, for printing, or whatever
424 void embed_message(void) {
429 StrBuf *CmdBuf = NULL;
431 msgnum = StrBufExtract_long(WCC->Hdr->HR.ReqLine, 0, '/');
432 switch (WCC->Hdr->HR.eReqType)
436 Tmpl = sbstr("template");
437 if (StrLength(Tmpl) > 0)
438 read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime);
440 read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
441 http_transmit_thing(ChrPtr(Mime), 0);
444 CmdBuf = NewStrBuf ();
445 if ((WCC->CurRoom.RAFlags & UA_ISTRASH) != 0) { /* Delete from Trash is a real delete */
446 serv_printf("DELE %ld", msgnum);
448 else { /* Otherwise move it to Trash */
449 serv_printf("MOVE %ld|_TRASH_|0", msgnum);
451 StrBuf_ServGetln(CmdBuf);
452 FlushStrBuf(WCC->ImportantMsg);
453 StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
463 * Printable view of a message
465 void print_message(void) {
469 msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
470 output_headers(0, 0, 0, 0, 0, 0);
472 hprintf("Content-type: text/html\r\n"
473 "Server: " PACKAGE_STRING "\r\n"
474 "Connection: close\r\n");
478 read_message(WC->WBuf, HKEY("view_message_print"), msgnum, NULL, &Mime);
484 * Mobile browser view of message
486 void mobile_message_view(void)
491 msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
492 output_headers(1, 0, 0, 0, 0, 1);
494 do_template("msgcontrols", NULL);
495 read_message(WC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
500 * Display a message's headers
502 void display_headers(void) {
506 msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
507 output_headers(0, 0, 0, 0, 0, 0);
509 hprintf("Content-type: text/plain\r\n"
511 "Connection: close\r\n",
515 serv_printf("MSG2 %ld|3", msgnum);
516 serv_getln(buf, sizeof buf);
518 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
519 wc_printf("%s\n", buf);
527 message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSubject, long MsgNum)
530 MsgPartEvaluatorStruct *Eval;
531 message_summary *Msg;
540 serv_printf("MSG0 %ld|1", MsgNum); /* ask for headers only */
542 StrBuf_ServGetln(Buf);
543 if (GetServerStatus(Buf, NULL) == 1) {
548 Msg = (message_summary*)malloc(sizeof(message_summary));
549 memset(Msg, 0, sizeof(message_summary));
550 while (len = StrBuf_ServGetln(Buf),
552 strcmp(ChrPtr(Buf), "000")== 0)){
554 ebuf = strchr(ChrPtr(Buf), '=');
556 if (GetHash(MsgEvaluators, buf, nBuf, &vEval) && vEval != NULL) {
557 Eval = (MsgPartEvaluatorStruct*) vEval;
558 StrBufCutLeft(Buf, nBuf + 1);
561 else lprintf(1, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf));
571 * load message pointers from the server for a "read messages" operation
573 * servcmd: the citadel command to send to the citserver
575 int load_msg_ptrs(const char *servcmd, SharedMessageStatus *Stat)
577 StrBuf* FoundCharset = NULL;
579 message_summary *Msg;
584 const char *Ptr = NULL;
586 Stat->lowest_found = LONG_MAX;
587 Stat->highest_found = LONG_MIN;
589 if (WCC->summ != NULL) {
590 DeleteHash(&WCC->summ);
592 WCC->summ = NewHash(1, Flathash);
596 StrBuf_ServGetln(Buf);
597 if (GetServerStatus(Buf, NULL) != 1) {
599 return (Stat->nummsgs);
602 while (len = StrBuf_ServGetln(Buf), ((len != 3) || strcmp(ChrPtr(Buf), "000")!= 0))
604 if (Stat->nummsgs < Stat->maxload) {
607 Msg = (message_summary*)malloc(sizeof(message_summary));
608 memset(Msg, 0, sizeof(message_summary));
610 Msg->msgnum = StrBufExtractNext_long(Buf, &Ptr, '|');
611 Msg->date = StrBufExtractNext_long(Buf, &Ptr, '|');
613 if (Stat->nummsgs == 0) {
614 if (Msg->msgnum < Stat->lowest_found) {
615 Stat->lowest_found = Msg->msgnum;
617 if (Msg->msgnum > Stat->highest_found) {
618 Stat->highest_found = Msg->msgnum;
622 if ((Msg->msgnum == 0) && (StrLength(Buf) < 32)) {
628 * as citserver probably gives us messages in forward date sorting
629 * nummsgs should be the same order as the message date.
631 if (Msg->date == 0) {
632 Msg->date = Stat->nummsgs;
633 if (StrLength(Buf) < 32)
637 Msg->from = NewStrBufPlain(NULL, StrLength(Buf));
638 StrBufExtract_NextToken(Buf2, Buf, &Ptr, '|');
639 if (StrLength(Buf2) != 0) {
640 /* Handle senders with RFC2047 encoding */
641 StrBuf_RFC822_to_Utf8(Msg->from, Buf2, WCC->DefaultCharset, FoundCharset);
645 StrBufExtract_NextToken(Buf2, Buf, &Ptr, '|');
646 if ((StrLength(Buf2) !=0 ) &&
647 ( ((WCC->CurRoom.QRFlags & QR_NETWORK)
648 || ((strcasecmp(ChrPtr(Buf2), ChrPtr(WCC->serv_info->serv_nodename))
649 && (strcasecmp(ChrPtr(Buf2), ChrPtr(WCC->serv_info->serv_fqdn))))))))
651 StrBufAppendBufPlain(Msg->from, HKEY(" @ "), 0);
652 StrBufAppendBuf(Msg->from, Buf2, 0);
655 /* Internet address (not used)
656 * StrBufExtract_token(Msg->inetaddr, Buf, 4, '|');
658 StrBufSkip_NTokenS(Buf, &Ptr, '|', 1);
659 Msg->subj = NewStrBufPlain(NULL, StrLength(Buf));
660 StrBufExtract_NextToken(Buf2, Buf, &Ptr, '|');
661 if (StrLength(Buf2) == 0)
662 StrBufAppendBufPlain(Msg->subj, _("(no subject)"), -1,0);
664 StrBuf_RFC822_to_Utf8(Msg->subj, Buf2, WCC->DefaultCharset, FoundCharset);
665 if ((StrLength(Msg->subj) > 75) &&
666 (StrBuf_Utf8StrLen(Msg->subj) > 75)) {
667 StrBuf_Utf8StrCut(Msg->subj, 72);
668 StrBufAppendBufPlain(Msg->subj, HKEY("..."), 0);
672 if ((StrLength(Msg->from) > 25) &&
673 (StrBuf_Utf8StrLen(Msg->from) > 25)) {
674 StrBuf_Utf8StrCut(Msg->from, 23);
675 StrBufAppendBufPlain(Msg->from, HKEY("..."), 0);
679 Put(WCC->summ, (const char *)&n, sizeof(n), Msg, DestroyMessageSummary);
685 return (Stat->nummsgs);
689 inline message_summary* GetMessagePtrAt(int n, HashList *Summ)
697 GetHashAt(Summ, n, &HKLen, &Key, &vMsg);
698 return (message_summary*) vMsg;
703 void load_seen_flags(void)
705 message_summary *Msg;
713 OldMsg = NewStrBuf();
715 StrBuf_ServGetln(OldMsg);
716 if (GetServerStatus(OldMsg, NULL) == 2) {
717 StrBufCutLeft(OldMsg, 4);
723 at = GetNewHashPos(WCC->summ, 0);
724 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
725 /* Are you a new message, or an old message? */
726 Msg = (message_summary*) vMsg;
727 if (is_msg_in_mset(ChrPtr(OldMsg), Msg->msgnum)) {
738 extern readloop_struct rlid[];
740 typedef struct _RoomRenderer{
743 GetParamsGetServerCall_func GetParamsGetServerCall;
744 PrintViewHeader_func PrintViewHeader;
745 LoadMsgFromServer_func LoadMsgFromServer;
746 RenderView_or_Tail_func RenderView_or_Tail;
747 View_Cleanup_func ViewCleanup;
752 * command loop for reading messages
754 * Set oper to "readnew" or "readold" or "readfwd" or "headers" or "readgt" or "readlt" or "do_search"
756 void readloop(long oper)
758 RoomRenderer *ViewMsg;
761 message_summary *Msg;
768 WCTemplputParams SubTP;
769 SharedMessageStatus Stat;
772 if (havebstr("is_summary") && (1 == (ibstr("is_summary")))) {
773 WCC->CurRoom.view = VIEW_MAILBOX;
776 if (havebstr("is_ajax") && (1 == (ibstr("is_ajax")))) {
780 if ((oper == do_search) && (WCC->CurRoom.view == VIEW_WIKI)) {
781 display_wiki_pagelist();
785 memset(&Stat, 0, sizeof(SharedMessageStatus));
786 Stat.maxload = 10000;
787 Stat.lowest_found = (-1);
788 Stat.highest_found = (-1);
789 GetHash(ReadLoopHandler, IKEY(WCC->CurRoom.view), &vViewMsg);
790 if (vViewMsg == NULL) {
791 WCC->CurRoom.view = VIEW_BBS;
792 GetHash(ReadLoopHandler, IKEY(WCC->CurRoom.view), &vViewMsg);
794 if (vViewMsg == NULL) {
795 return; // TODO: print message
798 ViewMsg = (RoomRenderer*) vViewMsg;
800 output_headers(1, 1, 1, 0, 0, 0);
801 } else if (WCC->CurRoom.view == VIEW_MAILBOX) {
802 jsonMessageListHdr();
805 if (ViewMsg->GetParamsGetServerCall != NULL) {
806 r = ViewMsg->GetParamsGetServerCall(
821 case 300: /* the callback hook should do the work for us here, since he knows what to do. */
827 if (!IsEmptyStr(cmd))
828 Stat.nummsgs = load_msg_ptrs(cmd, &Stat);
832 memset(&SubTP, 0, sizeof(WCTemplputParams));
833 SubTP.Filter.ContextType = CTX_MAILSUM;
834 SubTP.Context = NULL;
835 SortIt = RetrieveSort(&SubTP, NULL, 0,
836 HKEY("date"), Stat.defaultsortorder);
838 SortByPayload(WCC->summ, SortIt);
840 if (Stat.startmsg < 0) {
844 if (Stat.load_seen) load_seen_flags();
847 * Print any inforation above the message list...
849 if (ViewMsg->PrintViewHeader != NULL)
850 ViewMsg->PrintViewHeader(&Stat, &ViewSpecific);
852 WCC->startmsg = Stat.startmsg;
853 WCC->maxmsgs = Stat.maxmsgs;
854 WCC->num_displayed = 0;
856 /* Put some helpful data in vars for mailsummary_json */
857 svputlong("READLOOP:TOTALMSGS", Stat.nummsgs);
858 svputlong("READLOOP:STARTMSG", Stat.startmsg);
859 svputlong("WCVIEW", WCC->CurRoom.view);
862 * iterate over each message. if we need to load an attachment, do it here.
865 if ((ViewMsg->LoadMsgFromServer != NULL) &&
868 at = GetNewHashPos(WCC->summ, 0);
869 Stat.num_displayed = i = 0;
870 while ( GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
871 Msg = (message_summary*) vMsg;
872 if ((Msg->msgnum >= Stat.startmsg) && (Stat.num_displayed <= Stat.maxmsgs)) {
873 ViewMsg->LoadMsgFromServer(&Stat, &ViewSpecific, Msg, Msg->is_new, i);
881 * Done iterating the message list. now tasks we want to do after.
883 if (ViewMsg->RenderView_or_Tail != NULL)
884 ViewMsg->RenderView_or_Tail(&Stat, &ViewSpecific, oper);
886 if (ViewMsg->ViewCleanup != NULL)
887 ViewMsg->ViewCleanup(&ViewSpecific);
891 if (WCC->summ != NULL) {
892 DeleteHash(&WCC->summ);
898 * Back end for post_message()
899 * ... this is where the actual message gets transmitted to the server.
901 void post_mime_to_server(void) {
903 char top_boundary[SIZ];
904 char alt_boundary[SIZ];
905 int is_multipart = 0;
907 wc_mime_attachment *att;
909 size_t encoded_length;
910 size_t encoded_strlen;
911 char *txtmail = NULL;
912 int include_text_alt = 0; /* Set to nonzero to include multipart/alternative text/plain */
914 sprintf(top_boundary, "Citadel--Multipart--%s--%04x--%04x",
915 ChrPtr(WCC->serv_info->serv_fqdn),
919 sprintf(alt_boundary, "Citadel--Multipart--%s--%04x--%04x",
920 ChrPtr(WCC->serv_info->serv_fqdn),
925 /* RFC2045 requires this, and some clients look for it... */
926 serv_puts("MIME-Version: 1.0");
927 serv_puts("X-Mailer: " PACKAGE_STRING);
929 /* If there are attachments, we have to do multipart/mixed */
930 if (GetCount(WCC->attachments) > 0) {
934 /* Only do multipart/alternative for mailboxes. BBS and Wiki rooms don't need it. */
935 if (WC->CurRoom.view == VIEW_MAILBOX) {
936 include_text_alt = 1;
940 /* Remember, serv_printf() appends an extra newline */
941 serv_printf("Content-type: multipart/mixed; boundary=\"%s\"\n", top_boundary);
942 serv_printf("This is a multipart message in MIME format.\n");
943 serv_printf("--%s", top_boundary);
946 /* Remember, serv_printf() appends an extra newline */
947 if (include_text_alt) {
948 serv_printf("Content-type: multipart/alternative; "
949 "boundary=\"%s\"\n", alt_boundary);
950 serv_printf("This is a multipart message in MIME format.\n");
951 serv_printf("--%s", alt_boundary);
953 serv_puts("Content-type: text/plain; charset=utf-8");
954 serv_puts("Content-Transfer-Encoding: quoted-printable");
956 txtmail = html_to_ascii(bstr("msgtext"), 0, 80, 0);
957 text_to_server_qp(txtmail); /* Transmit message in quoted-printable encoding */
960 serv_printf("--%s", alt_boundary);
963 serv_puts("Content-type: text/html; charset=utf-8");
964 serv_puts("Content-Transfer-Encoding: quoted-printable");
966 serv_puts("<html><body>\r\n");
967 text_to_server_qp(bstr("msgtext")); /* Transmit message in quoted-printable encoding */
968 serv_puts("</body></html>\r\n");
970 if (include_text_alt) {
971 serv_printf("--%s--", alt_boundary);
980 /* Add in the attachments */
981 it = GetNewHashPos(WCC->attachments, 0);
982 while (GetNextHashPos(WCC->attachments, it, &len, &Key, &vAtt)) {
983 att = (wc_mime_attachment *)vAtt;
984 if (att->length == 0)
986 encoded_length = ((att->length * 150) / 100);
987 encoded = malloc(encoded_length);
988 if (encoded == NULL) break;
989 encoded_strlen = CtdlEncodeBase64(encoded, ChrPtr(att->Data), StrLength(att->Data), 1);
991 serv_printf("--%s", top_boundary);
992 serv_printf("Content-type: %s", ChrPtr(att->ContentType));
993 serv_printf("Content-disposition: attachment; filename=\"%s\"", ChrPtr(att->FileName));
994 serv_puts("Content-transfer-encoding: base64");
996 serv_write(encoded, encoded_strlen);
1001 serv_printf("--%s--", top_boundary);
1010 * Post message (or don't post message)
1012 * Note regarding the "dont_post" variable:
1013 * A random value (actually, it's just a timestamp) is inserted as a hidden
1014 * field called "postseq" when the display_enter page is generated. This
1015 * value is checked when posting, using the static variable dont_post. If a
1016 * user attempts to post twice using the same dont_post value, the message is
1017 * discarded. This prevents the accidental double-saving of the same message
1018 * if the user happens to click the browser "back" button.
1020 void post_message(void)
1023 StrBuf *encoded_subject = NULL;
1024 static long dont_post = (-1L);
1025 wc_mime_attachment *att;
1026 int is_anonymous = 0;
1027 const StrBuf *display_name = NULL;
1028 wcsession *WCC = WC;
1031 if (havebstr("force_room")) {
1032 gotoroom(sbstr("force_room"));
1035 if (havebstr("display_name")) {
1036 display_name = sbstr("display_name");
1037 if (!strcmp(ChrPtr(display_name), "__ANONYMOUS__")) {
1038 display_name = NULL;
1043 if (WCC->upload_length > 0) {
1048 /* There's an attachment. Save it to this struct... */
1049 lprintf(9, "Client is uploading %d bytes\n", WCC->upload_length);
1050 att = malloc(sizeof(wc_mime_attachment));
1051 memset(att, 0, sizeof(wc_mime_attachment ));
1052 att->length = WCC->upload_length;
1053 att->ContentType = NewStrBufPlain(WCC->upload_content_type, -1);
1054 att->FileName = NewStrBufPlain(WCC->upload_filename, -1);
1056 if (WCC->attachments == NULL) {
1057 WCC->attachments = NewHash(1, NULL);
1060 /* And add it to the list. */
1061 n = snprintf(N, sizeof N, "%d", GetCount(WCC->attachments) + 1);
1062 Put(WCC->attachments, N, n, att, DestroyMime);
1065 * Mozilla sends a simple filename, which is what we want,
1066 * but Satan's Browser sends an entire pathname. Reduce
1067 * the path to just a filename if we need to.
1069 pch = strrchr(ChrPtr(att->FileName), '/');
1071 StrBufCutLeft(att->FileName, pch - ChrPtr(att->FileName) + 1);
1073 pch = strrchr(ChrPtr(att->FileName), '\\');
1075 StrBufCutLeft(att->FileName, pch - ChrPtr(att->FileName) + 1);
1079 * Transfer control of this memory from the upload struct
1080 * to the attachment struct.
1082 att->Data = WCC->upload;
1084 WCC->upload_length = 0;
1089 if (havebstr("cancel_button")) {
1090 sprintf(WCC->ImportantMessage,
1091 _("Cancelled. Message was not posted."));
1092 } else if (havebstr("attach_button")) {
1095 } else if (lbstr("postseq") == dont_post) {
1096 sprintf(WCC->ImportantMessage,
1097 _("Automatically cancelled because you have already "
1098 "saved this message."));
1100 const char CMD[] = "ENT0 1|%s|%d|4|%s|%s||%s|%s|%s|%s|%s";
1101 const StrBuf *Recp = NULL;
1102 const StrBuf *Cc = NULL;
1103 const StrBuf *Bcc = NULL;
1104 const StrBuf *Wikipage = NULL;
1105 const StrBuf *my_email_addr = NULL;
1106 StrBuf *CmdBuf = NULL;
1107 StrBuf *references = NULL;
1110 save_to_drafts = havebstr("save_button");
1113 if (save_to_drafts) {
1114 /* temporarily change to the drafts room */
1115 serv_puts("GOTO _DRAFTS_");
1116 StrBuf_ServGetln(Buf);
1117 if (GetServerStatus(Buf, NULL) != 2) {
1118 /* You probably don't even have a dumb Drafts folder */
1119 StrBufCutLeft(Buf, 4);
1120 lprintf(9, "%s:%d: server save to drafts error: %s\n", __FILE__, __LINE__, ChrPtr(Buf));
1121 StrBufAppendBufPlain(WCC->ImportantMsg, _("Saved to Drafts failed: "), -1, 0);
1122 StrBufAppendBuf(WCC->ImportantMsg, Buf, 0);
1129 if (havebstr("references"))
1131 const StrBuf *ref = sbstr("references");
1132 references = NewStrBufDup(ref);
1133 if (*ChrPtr(references) == '|') { /* remove leading '|' if present */
1134 StrBufCutLeft(references, 1);
1136 StrBufReplaceChars(references, '|', '!');
1138 if (havebstr("subject")) {
1141 * make enough room for the encoded string;
1142 * plus the QP header
1144 Subj = sbstr("subject");
1146 StrBufRFC2047encode(&encoded_subject, Subj);
1148 Recp = sbstr("recp");
1151 Wikipage = sbstr("page");
1152 my_email_addr = sbstr("my_email_addr");
1154 CmdBuf = NewStrBufPlain(NULL,
1157 StrLength(encoded_subject) +
1160 StrLength(Wikipage) +
1161 StrLength(my_email_addr) +
1162 StrLength(references));
1164 StrBufPrintf(CmdBuf,
1166 save_to_drafts?"":ChrPtr(Recp),
1168 ChrPtr(encoded_subject),
1169 ChrPtr(display_name),
1170 save_to_drafts?"":ChrPtr(Cc),
1171 save_to_drafts?"":ChrPtr(Bcc),
1173 ChrPtr(my_email_addr),
1174 ChrPtr(references));
1175 FreeStrBuf(&references);
1176 FreeStrBuf(&encoded_subject);
1178 lprintf(9, "%s\n", ChrPtr(CmdBuf));
1179 serv_puts(ChrPtr(CmdBuf));
1180 FreeStrBuf(&CmdBuf);
1182 StrBuf_ServGetln(Buf);
1183 if (GetServerStatus(Buf, NULL) == 4) {
1184 if (save_to_drafts) {
1185 if ( (havebstr("recp"))
1186 || (havebstr("cc" ))
1187 || (havebstr("bcc" )) ) {
1188 /* save recipient headers or room to post to */
1189 serv_printf("To: %s", ChrPtr(Recp));
1190 serv_printf("Cc: %s", ChrPtr(Cc));
1191 serv_printf("Bcc: %s", ChrPtr(Bcc));
1193 serv_printf("X-Citadel-Room: %s", ChrPtr(WC->CurRoom.name));
1196 post_mime_to_server();
1197 if (save_to_drafts) {
1198 StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been saved to Drafts.\n"), -1, 0);
1199 gotoroom(WCC->CurRoom.name);
1203 } else if ( (havebstr("recp"))
1204 || (havebstr("cc" ))
1205 || (havebstr("bcc" ))
1207 StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been sent.\n"), -1, 0);
1210 StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been posted.\n"), -1, 0);
1212 dont_post = lbstr("postseq");
1214 StrBufCutLeft(Buf, 4);
1216 lprintf(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, ChrPtr(Buf));
1217 StrBufAppendBuf(WCC->ImportantMsg, Buf, 0);
1218 if (save_to_drafts) gotoroom(WCC->CurRoom.name);
1226 DeleteHash(&WCC->attachments);
1229 * We may have been supplied with instructions regarding the location
1230 * to which we must return after posting. If found, go there.
1232 if (havebstr("return_to")) {
1233 http_redirect(bstr("return_to"));
1236 * If we were editing a page in a wiki room, go to that page now.
1238 else if (havebstr("page")) {
1239 snprintf(buf, sizeof buf, "wiki?page=%s", bstr("page"));
1243 * Otherwise, just go to the "read messages" loop.
1254 * display the message entry screen
1256 void display_enter(void)
1260 const StrBuf *display_name = NULL;
1261 int recipient_required = 0;
1262 int subject_required = 0;
1263 int recipient_bad = 0;
1264 int is_anonymous = 0;
1265 wcsession *WCC = WC;
1269 if (havebstr("force_room")) {
1270 gotoroom(sbstr("force_room"));
1273 display_name = sbstr("display_name");
1274 if (!strcmp(ChrPtr(display_name), "__ANONYMOUS__")) {
1275 display_name = NULL;
1279 /* First test to see whether this is a room that requires recipients to be entered */
1280 serv_puts("ENT0 0");
1281 serv_getln(buf, sizeof buf);
1283 if (!strncmp(buf, "570", 3)) { /* 570 means that we need a recipient here */
1284 recipient_required = 1;
1286 else if (buf[0] != '2') { /* Any other error means that we cannot continue */
1287 sprintf(WCC->ImportantMessage, "%s", &buf[4]);
1292 /* Is the server strongly recommending that the user enter a message subject? */
1293 if ((buf[3] != '\0') && (buf[4] != '\0')) {
1294 subject_required = extract_int(&buf[4], 1);
1298 * Are we perhaps in an address book view? If so, then an "enter
1299 * message" command really means "add new entry."
1301 if (WCC->CurRoom.defview == VIEW_ADDRESSBOOK) {
1302 do_edit_vcard(-1, "", NULL, NULL, "", ChrPtr(WCC->CurRoom.name));
1307 * Are we perhaps in a calendar room? If so, then an "enter
1308 * message" command really means "add new calendar item."
1310 if (WCC->CurRoom.defview == VIEW_CALENDAR) {
1311 display_edit_event();
1316 * Are we perhaps in a tasks view? If so, then an "enter
1317 * message" command really means "add new task."
1319 if (WCC->CurRoom.defview == VIEW_TASKS) {
1320 display_edit_task();
1325 * Otherwise proceed normally.
1326 * Do a custom room banner with no navbar...
1329 if (recipient_required) {
1330 const StrBuf *Recp = NULL;
1331 const StrBuf *Cc = NULL;
1332 const StrBuf *Bcc = NULL;
1333 const StrBuf *Wikipage = NULL;
1334 StrBuf *CmdBuf = NULL;
1335 const char CMD[] = "ENT0 0|%s|%d|0||%s||%s|%s|%s";
1337 Recp = sbstr("recp");
1340 Wikipage = sbstr("page");
1342 CmdBuf = NewStrBufPlain(NULL,
1345 StrLength(display_name) +
1348 StrLength(Wikipage));
1350 StrBufPrintf(CmdBuf,
1354 ChrPtr(display_name),
1358 serv_puts(ChrPtr(CmdBuf));
1359 serv_getln(buf, sizeof buf);
1360 FreeStrBuf(&CmdBuf);
1362 if (!strncmp(buf, "570", 3)) { /* 570 means we have an invalid recipient listed */
1363 if (havebstr("recp") &&
1369 else if (buf[0] != '2') { /* Any other error means that we cannot continue */
1370 wc_printf("<em>%s</em><br />\n", &buf[4]); /* TODO -> important message */
1374 svputlong("RCPTREQUIRED", recipient_required);
1375 svputlong("SUBJREQUIRED", recipient_required || subject_required);
1378 output_headers(1, 0, 0, 0, 1, 0);
1379 DoTemplate(HKEY("edit_message"), NULL, &NoCtx);
1388 void delete_msg(void)
1393 msgid = lbstr("msgid");
1395 if ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0) { /* Delete from Trash is a real delete */
1396 serv_printf("DELE %ld", msgid);
1398 else { /* Otherwise move it to Trash */
1399 serv_printf("MOVE %ld|_TRASH_|0", msgid);
1402 serv_getln(buf, sizeof buf);
1403 sprintf(WC->ImportantMessage, "%s", &buf[4]);
1409 * move a message to another room
1416 msgid = lbstr("msgid");
1418 if (havebstr("move_button")) {
1419 sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
1421 serv_getln(buf, sizeof buf);
1422 sprintf(WC->ImportantMessage, "%s", &buf[4]);
1424 sprintf(WC->ImportantMessage, (_("The message was not moved.")));
1432 * Confirm move of a message
1434 void confirm_move_msg(void)
1440 msgid = lbstr("msgid");
1443 output_headers(1, 1, 2, 0, 0, 0);
1444 wc_printf("<div id=\"banner\">\n");
1446 wc_printf(_("Confirm move of message"));
1448 wc_printf("</div>\n");
1450 wc_printf("<div id=\"content\" class=\"service\">\n");
1452 wc_printf("<CENTER>");
1454 wc_printf(_("Move this message to:"));
1455 wc_printf("<br />\n");
1457 wc_printf("<form METHOD=\"POST\" action=\"move_msg\">\n");
1458 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1459 wc_printf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n", bstr("msgid"));
1461 wc_printf("<SELECT NAME=\"target_room\" SIZE=5>\n");
1463 serv_getln(buf, sizeof buf);
1464 if (buf[0] == '1') {
1465 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1466 extract_token(targ, buf, 0, '|', sizeof targ);
1467 wc_printf("<OPTION>");
1472 wc_printf("</SELECT>\n");
1473 wc_printf("<br />\n");
1475 wc_printf("<INPUT TYPE=\"submit\" NAME=\"move_button\" VALUE=\"%s\">", _("Move"));
1476 wc_printf(" ");
1477 wc_printf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1478 wc_printf("</form></CENTER>\n");
1480 wc_printf("</CENTER>\n");
1486 * Generic function to output an arbitrary MIME attachment from
1487 * message being composed
1489 * partnum The MIME part to be output
1490 * filename Fake filename to give
1491 * force_download Nonzero to force set the Content-Type: header to "application/octet-stream"
1493 void postpart(StrBuf *partnum, StrBuf *filename, int force_download)
1496 StrBuf *content_type;
1497 wc_mime_attachment *part;
1499 if (GetHash(WC->attachments, SKEY(partnum), &vPart) &&
1501 part = (wc_mime_attachment*) vPart;
1502 if (force_download) {
1503 content_type = NewStrBufPlain(HKEY("application/octet-stream"));
1506 content_type = NewStrBufDup(part->ContentType);
1508 StrBufAppendBuf(WC->WBuf, part->Data, 0);
1509 http_transmit_thing(ChrPtr(content_type), 0);
1511 hprintf("HTTP/1.1 404 %s\n", ChrPtr(partnum));
1512 output_headers(0, 0, 0, 0, 0, 0);
1513 hprintf("Content-Type: text/plain\r\n");
1515 wc_printf(_("An error occurred while retrieving this part: %s/%s\n"),
1516 ChrPtr(partnum), ChrPtr(filename));
1519 FreeStrBuf(&content_type);
1524 * Generic function to output an arbitrary MIME part from an arbitrary
1525 * message number on the server.
1527 * msgnum Number of the item on the citadel server
1528 * partnum The MIME part to be output
1529 * force_download Nonzero to force set the Content-Type: header to "application/octet-stream"
1531 void mimepart(int force_download)
1535 wcsession *WCC = WC;
1538 StrBuf *ContentType = NewStrBufPlain(HKEY("application/octet-stream"));
1541 att = Buf = NewStrBuf();
1542 msgnum = StrBufExtract_long(WCC->Hdr->HR.ReqLine, 0, '/');
1543 StrBufExtract_token(att, WCC->Hdr->HR.ReqLine, 1, '/');
1545 serv_printf("OPNA %ld|%s", msgnum, ChrPtr(att));
1546 StrBuf_ServGetln(Buf);
1547 if (GetServerStatus(Buf, NULL) == 2) {
1548 StrBufCutLeft(Buf, 4);
1549 bytes = StrBufExtract_long(Buf, 0, '|');
1550 if (!force_download) {
1551 StrBufExtract_token(ContentType, Buf, 3, '|');
1554 read_server_binary(WCC->WBuf, bytes, Buf);
1556 StrBuf_ServGetln(Buf);
1557 CT = ChrPtr(ContentType);
1559 if (!force_download) {
1560 if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) {
1561 StrBufExtract_token(Buf, WCC->Hdr->HR.ReqLine, 2, '/');
1562 CT = GuessMimeByFilename(SKEY(Buf));
1564 if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) {
1565 CT = GuessMimeType(SKEY(WCC->WBuf));
1568 http_transmit_thing(CT, 0);
1570 StrBufCutLeft(Buf, 4);
1571 hprintf("HTTP/1.1 404 %s\n", ChrPtr(Buf));
1572 output_headers(0, 0, 0, 0, 0, 0);
1573 hprintf("Content-Type: text/plain\r\n");
1575 wc_printf(_("An error occurred while retrieving this part: %s\n"),
1579 FreeStrBuf(&ContentType);
1585 * Read any MIME part of a message, from the server, into memory.
1587 StrBuf *load_mimepart(long msgnum, char *partnum)
1593 serv_printf("DLAT %ld|%s", msgnum, partnum);
1594 StrBuf_ServGetln(Buf);
1595 if (GetServerStatus(Buf, NULL) == 6) {
1596 StrBufCutLeft(Buf, 4);
1597 bytes = StrBufExtract_long(Buf, 0, '|');
1600 StrBuf_ServGetBLOBBuffered(Buf, bytes);
1610 * Read any MIME part of a message, from the server, into memory.
1612 void MimeLoadData(wc_mime_attachment *Mime)
1616 /* TODO: is there a chance the content type is different from the one we know? */
1617 serv_printf("DLAT %ld|%s", Mime->msgnum, ChrPtr(Mime->PartNum));
1619 StrBuf_ServGetln(Buf);
1620 if (GetServerStatus(Buf, NULL) == 6) {
1621 bytes = extract_long(&(ChrPtr(Buf)[4]), 0);
1623 if (Mime->Data == NULL)
1624 Mime->Data = NewStrBufPlain(NULL, bytes);
1625 StrBuf_ServGetBLOBBuffered(Mime->Data, bytes);
1628 FlushStrBuf(Mime->Data);
1629 /* TODO XImportant message */
1637 void view_mimepart(void) {
1641 void download_mimepart(void) {
1645 void view_postpart(void) {
1646 StrBuf *filename = NewStrBuf();
1647 StrBuf *partnum = NewStrBuf();
1649 StrBufExtract_token(partnum, WC->Hdr->HR.ReqLine, 0, '/');
1650 StrBufExtract_token(filename, WC->Hdr->HR.ReqLine, 1, '/');
1652 postpart(partnum, filename, 0);
1654 FreeStrBuf(&filename);
1655 FreeStrBuf(&partnum);
1658 void download_postpart(void) {
1659 StrBuf *filename = NewStrBuf();
1660 StrBuf *partnum = NewStrBuf();
1662 StrBufExtract_token(partnum, WC->Hdr->HR.ReqLine, 0, '/');
1663 StrBufExtract_token(filename, WC->Hdr->HR.ReqLine, 1, '/');
1665 postpart(partnum, filename, 1);
1667 FreeStrBuf(&filename);
1668 FreeStrBuf(&partnum);
1671 void h_readnew(void) { readloop(readnew);}
1672 void h_readold(void) { readloop(readold);}
1673 void h_readfwd(void) { readloop(readfwd);}
1674 void h_headers(void) { readloop(headers);}
1675 void h_do_search(void) { readloop(do_search);}
1676 void h_readgt(void) { readloop(readgt);}
1677 void h_readlt(void) { readloop(readlt);}
1679 void jsonMessageListHdr(void)
1681 /* TODO: make a generic function */
1682 hprintf("HTTP/1.1 200 OK\r\n");
1683 hprintf("Content-type: application/json; charset=utf-8\r\n");
1684 hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
1685 hprintf("Connection: close\r\n");
1686 hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n");
1691 /* Output message list in JSON format */
1692 void jsonMessageList(void) {
1693 const StrBuf *room = sbstr("room");
1694 long oper = (havebstr("query")) ? do_search : readnew;
1701 void RegisterReadLoopHandlerset(
1703 GetParamsGetServerCall_func GetParamsGetServerCall,
1704 PrintViewHeader_func PrintViewHeader,
1705 LoadMsgFromServer_func LoadMsgFromServer,
1706 RenderView_or_Tail_func RenderView_or_Tail,
1707 View_Cleanup_func ViewCleanup
1710 RoomRenderer *Handler;
1712 Handler = (RoomRenderer*) malloc(sizeof(RoomRenderer));
1714 Handler->RoomType = RoomType;
1715 Handler->GetParamsGetServerCall = GetParamsGetServerCall;
1716 Handler->PrintViewHeader = PrintViewHeader;
1717 Handler->LoadMsgFromServer = LoadMsgFromServer;
1718 Handler->RenderView_or_Tail = RenderView_or_Tail;
1719 Handler->ViewCleanup = ViewCleanup;
1721 Put(ReadLoopHandler, IKEY(RoomType), Handler, NULL);
1728 RegisterPreference("use_sig",
1729 _("Attach signature to email messages?"),
1732 RegisterPreference("signature", _("Use this signature:"), PRF_QP_STRING, NULL);
1733 RegisterPreference("default_header_charset",
1734 _("Default character set for email headers:"),
1737 RegisterPreference("defaultfrom", _("Preferred email address"), PRF_STRING, NULL);
1738 RegisterPreference("defaultname",
1739 _("Preferred display name for email messages"),
1742 RegisterPreference("defaulthandle",
1743 _("Preferred display name for bulletin board posts"),
1746 RegisterPreference("mailbox",_("Mailbox view mode"), PRF_STRING, NULL);
1748 WebcitAddUrlHandler(HKEY("readnew"), "", 0, h_readnew, NEED_URL);
1749 WebcitAddUrlHandler(HKEY("readold"), "", 0, h_readold, NEED_URL);
1750 WebcitAddUrlHandler(HKEY("readfwd"), "", 0, h_readfwd, NEED_URL);
1751 WebcitAddUrlHandler(HKEY("headers"), "", 0, h_headers, NEED_URL);
1752 WebcitAddUrlHandler(HKEY("readgt"), "", 0, h_readgt, NEED_URL);
1753 WebcitAddUrlHandler(HKEY("readlt"), "", 0, h_readlt, NEED_URL);
1754 WebcitAddUrlHandler(HKEY("do_search"), "", 0, h_do_search, 0);
1755 WebcitAddUrlHandler(HKEY("display_enter"), "", 0, display_enter, 0);
1756 WebcitAddUrlHandler(HKEY("post"), "", 0, post_message, 0);
1757 WebcitAddUrlHandler(HKEY("move_msg"), "", 0, move_msg, 0);
1758 WebcitAddUrlHandler(HKEY("delete_msg"), "", 0, delete_msg, 0);
1759 WebcitAddUrlHandler(HKEY("confirm_move_msg"), "", 0, confirm_move_msg, 0);
1760 WebcitAddUrlHandler(HKEY("msg"), "", 0, embed_message, NEED_URL);
1761 WebcitAddUrlHandler(HKEY("message"), "", 0, handle_one_message, NEED_URL|XHTTP_COMMANDS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
1762 WebcitAddUrlHandler(HKEY("printmsg"), "", 0, print_message, NEED_URL);
1763 WebcitAddUrlHandler(HKEY("mobilemsg"), "", 0, mobile_message_view, NEED_URL);
1764 WebcitAddUrlHandler(HKEY("msgheaders"), "", 0, display_headers, NEED_URL);
1766 WebcitAddUrlHandler(HKEY("mimepart"), "", 0, view_mimepart, NEED_URL);
1767 WebcitAddUrlHandler(HKEY("mimepart_download"), "", 0, download_mimepart, NEED_URL);
1768 WebcitAddUrlHandler(HKEY("postpart"), "", 0, view_postpart, NEED_URL);
1769 WebcitAddUrlHandler(HKEY("postpart_download"), "", 0, download_postpart, NEED_URL);
1772 WebcitAddUrlHandler(HKEY("roommsgs"), "", 0, jsonMessageList,0);
1777 SessionDetachModule_MSG
1780 DeleteHash(&sess->summ);