2 * Functions which deal with the fetching and displaying of messages.
9 HashList *MsgHeaderHandler = NULL;
10 HashList *MsgEvaluators = NULL;
11 HashList *MimeRenderHandler = NULL;
12 HashList *ReadLoopHandler = NULL;
13 int dbg_analyze_msg = 0;
15 #define SUBJ_COL_WIDTH_PCT 50 /* Mailbox view column width */
16 #define SENDER_COL_WIDTH_PCT 30 /* Mailbox view column width */
17 #define DATE_PLUS_BUTTONS_WIDTH_PCT 20 /* Mailbox view column width */
19 void jsonMessageListHdr(void);
21 void display_enter(void);
23 typedef void (*MsgPartEvaluatorFunc)(message_summary *Sum, StrBuf *Buf);
25 typedef struct _MsgPartEvaluatorStruct {
26 MsgPartEvaluatorFunc f;
27 } MsgPartEvaluatorStruct;
29 int load_message(message_summary *Msg,
43 if (Msg->PartNum != NULL) {
44 serv_printf("MSG4 %ld|%s", Msg->msgnum, ChrPtr(Msg->PartNum));
47 serv_printf("MSG4 %ld", Msg->msgnum);
50 StrBuf_ServGetln(Buf);
51 if (GetServerStatus(Buf, NULL) != 1) {
53 StrBufAppendPrintf(*Error, "<strong>");
54 StrBufAppendPrintf(*Error, _("ERROR:"));
55 StrBufAppendPrintf(*Error, "</strong> %s<br />\n", &buf[4]);
60 /* begin everythingamundo table */
61 HdrToken = NewStrBuf();
62 while (!Done && StrBuf_ServGetln(Buf)>=0) {
63 if ( (StrLength(Buf)==3) &&
64 !strcmp(ChrPtr(Buf), "000"))
68 if (Msg->MsgBody->Data == NULL)
69 Msg->MsgBody->Data = NewStrBuf();
70 Msg->MsgBody->ContentType = NewStrBufPlain(HKEY("text/html"));
71 StrBufAppendPrintf(Msg->MsgBody->Data, "<div><i>");
72 StrBufAppendPrintf(Msg->MsgBody->Data, _("Empty message"));
73 StrBufAppendPrintf(Msg->MsgBody->Data, "</i><br /><br />\n");
74 StrBufAppendPrintf(Msg->MsgBody->Data, "</div>\n");
79 case 0:/* Citadel Message Headers */
80 if (StrLength(Buf) == 0) {
84 StrBufExtract_token(HdrToken, Buf, 0, '=');
85 StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
88 if (dbg_analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf));
90 /* look up one of the examine_* functions to parse the content */
91 if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
93 Hdr = (headereval*)vHdr;
94 Hdr->evaluator(Msg, Buf, FoundCharset);
101 "don't know how to handle message header[%s]\n",
105 case 1:/* Message Mime Header */
106 if (StrLength(Buf) == 0) {
108 if (Msg->MsgBody->ContentType == NULL)
109 /* end of header or no header? */
110 Msg->MsgBody->ContentType = NewStrBufPlain(HKEY("text/plain"));
111 /* usual end of mime header */
115 StrBufExtract_token(HdrToken, Buf, 0, ':');
116 if (StrLength(HdrToken) > 0) {
117 StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
119 if (dbg_analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf));
121 /* the examine*'s know how to do with mime headers too... */
122 if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
124 Hdr = (headereval*)vHdr;
125 Hdr->evaluator(Msg, Buf, FoundCharset);
130 case 2: /* Message Body */
132 if (Msg->MsgBody->size_known > 0) {
133 StrBuf_ServGetBLOBBuffered(Msg->MsgBody->Data, Msg->MsgBody->length);
135 /*/ todo: check next line, if not 000, append following lines */
138 if (StrLength(Msg->MsgBody->Data) > 0)
139 StrBufAppendBufPlain(Msg->MsgBody->Data, "\n", 1, 0);
140 StrBufAppendBuf(Msg->MsgBody->Data, Buf, 0);
144 StrBufAppendBuf(Msg->MsgBody->Data, Buf, 0);
149 if (Msg->AllAttach == NULL)
150 Msg->AllAttach = NewHash(1,NULL);
151 /* now we put the body mimepart we read above into the mimelist */
152 Put(Msg->AllAttach, SKEY(Msg->MsgBody->PartNum), Msg->MsgBody, DestroyMime);
154 /* Generate a reply-to address */
155 if (StrLength(Msg->Rfca) > 0) {
156 if (Msg->reply_to == NULL)
157 Msg->reply_to = NewStrBuf();
158 if (StrLength(Msg->from) > 0) {
159 StrBufPrintf(Msg->reply_to, "%s <%s>", ChrPtr(Msg->from), ChrPtr(Msg->Rfca));
162 FlushStrBuf(Msg->reply_to);
163 StrBufAppendBuf(Msg->reply_to, Msg->Rfca, 0);
168 if ((StrLength(Msg->OtherNode)>0) &&
169 (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(WCC->serv_info->serv_nodename))) &&
170 (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(WCC->serv_info->serv_humannode)) ))
172 if (Msg->reply_to == NULL)
173 Msg->reply_to = NewStrBuf();
174 StrBufPrintf(Msg->reply_to,
177 ChrPtr(Msg->OtherNode));
180 if (Msg->reply_to == NULL)
181 Msg->reply_to = NewStrBuf();
182 FlushStrBuf(Msg->reply_to);
183 StrBufAppendBuf(Msg->reply_to, Msg->from, 0);
187 FreeStrBuf(&HdrToken);
194 * I wanna SEE that message!
196 * msgnum Message number to display
197 * printable_view Nonzero to display a printable view
198 * section Optional for encapsulated message/rfc822 submessage
200 int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, const StrBuf *PartNum, const StrBuf **OutMime)
203 StrBuf *FoundCharset;
206 message_summary *Msg = NULL;
210 WCTemplputParams SubTP;
211 StrBuf *Error = NULL;
214 FoundCharset = NewStrBuf();
215 Msg = (message_summary *)malloc(sizeof(message_summary));
216 memset(Msg, 0, sizeof(message_summary));
217 Msg->msgnum = msgnum;
218 Msg->PartNum = PartNum;
219 Msg->MsgBody = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
220 memset(Msg->MsgBody, 0, sizeof(wc_mime_attachment));
221 Msg->MsgBody->msgnum = msgnum;
223 if (!load_message(Msg, FoundCharset, &Error)) {
224 StrBufAppendBuf(Target, Error, 0);
228 /* Extract just the content-type (omit attributes such as "charset") */
229 StrBufExtract_token(Buf, Msg->MsgBody->ContentType, 0, ';');
231 StrBufLowerCase(Buf);
233 /* Locate a renderer capable of converting this MIME part into HTML */
234 if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
236 RenderMimeFuncStruct *Render;
237 Render = (RenderMimeFuncStruct*)vHdr;
238 Render->f(Msg->MsgBody, NULL, FoundCharset);
241 if (StrLength(Msg->reply_references)> 0) {
242 /* Trim down excessively long lists of thread references. We eliminate the
243 * second one in the list so that the thread root remains intact.
245 int rrtok = num_tokens(ChrPtr(Msg->reply_references), '|');
246 int rrlen = StrLength(Msg->reply_references);
247 if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
248 StrBufRemove_token(Msg->reply_references, 1, '|');
252 /* now check if we need to translate some mimeparts, and remove the duplicate */
253 it = GetNewHashPos(Msg->AllAttach, 0);
254 while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) &&
256 wc_mime_attachment *Mime = (wc_mime_attachment*) vMime;
257 evaluate_mime_part(Msg, Mime);
260 memset(&SubTP, 0, sizeof(WCTemplputParams));
261 SubTP.Filter.ContextType = CTX_MAILSUM;
263 *OutMime = DoTemplate(tmpl, tmpllen, Target, &SubTP);
265 DestroyMessageSummary(Msg);
266 FreeStrBuf(&FoundCharset);
273 HttpStatus(long CitadelStatus)
275 long httpstatus = 502;
277 switch (MAJORCODE(CitadelStatus))
279 case LISTING_FOLLOWS:
284 switch (MINORCODE(CitadelStatus))
292 case HIGHER_ACCESS_REQUIRED:
293 case MAX_SESSIONS_EXCEEDED:
295 case RESOURCE_NOT_OPEN:
297 case INVALID_FLOOR_OPERATION:
303 case MESSAGE_NOT_FOUND:
313 case CMD_NOT_SUPPORTED:
314 case PASSWORD_REQUIRED:
315 case ALREADY_LOGGED_IN:
316 case USERNAME_REQUIRED:
318 case SERVER_SHUTTING_DOWN:
329 case START_CHAT_MODE:
333 httpstatus = 502; /* aeh... whut? */
341 * Unadorned HTML output of an individual message, suitable
342 * for placing in a hidden iframe, for printing, or whatever
344 void handle_one_message(void)
348 const StrBuf *Destination;
354 StrBuf *CmdBuf = NULL;
358 pMsg = strchr(ChrPtr(WCC->Hdr->HR.ReqLine), '/');
360 HttpStatus(CitStatus);
364 msgnum = atol(pMsg + 1);
365 StrBufCutAt(WCC->Hdr->HR.ReqLine, 0, pMsg);
366 gotoroom(WCC->Hdr->HR.ReqLine);
367 switch (WCC->Hdr->HR.eReqType)
371 Tmpl = sbstr("template");
372 if (StrLength(Tmpl) > 0)
373 read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime);
375 read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
376 http_transmit_thing(ChrPtr(Mime), 0);
379 CmdBuf = NewStrBuf ();
380 if ((WCC->CurRoom.RAFlags & UA_ISTRASH) != 0) { /* Delete from Trash is a real delete */
381 serv_printf("DELE %ld", msgnum);
383 else { /* Otherwise move it to Trash */
384 serv_printf("MOVE %ld|_TRASH_|0", msgnum);
386 StrBuf_ServGetln(CmdBuf);
387 FlushStrBuf(WCC->ImportantMsg);
388 StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
389 GetServerStatus(CmdBuf, &CitStatus);
390 HttpStatus(CitStatus);
395 if (GetHash(WCC->Hdr->HTTPHeaders, HKEY("DESTINATION"), &vLine) &&
397 Destination = (StrBuf*) vLine;
398 serv_printf("MOVE %ld|%s|%d", msgnum, ChrPtr(Destination), CopyMessage);
399 StrBuf_ServGetln(CmdBuf);
400 FlushStrBuf(WCC->ImportantMsg);
401 StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
402 GetServerStatus(CmdBuf, &CitStatus);
403 HttpStatus(CitStatus);
416 * Unadorned HTML output of an individual message, suitable
417 * for placing in a hidden iframe, for printing, or whatever
419 void embed_message(void) {
424 StrBuf *CmdBuf = NULL;
426 msgnum = StrBufExtract_long(WCC->Hdr->HR.ReqLine, 0, '/');
427 switch (WCC->Hdr->HR.eReqType)
431 Tmpl = sbstr("template");
432 if (StrLength(Tmpl) > 0)
433 read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime);
435 read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
436 http_transmit_thing(ChrPtr(Mime), 0);
439 CmdBuf = NewStrBuf ();
440 if ((WCC->CurRoom.RAFlags & UA_ISTRASH) != 0) { /* Delete from Trash is a real delete */
441 serv_printf("DELE %ld", msgnum);
443 else { /* Otherwise move it to Trash */
444 serv_printf("MOVE %ld|_TRASH_|0", msgnum);
446 StrBuf_ServGetln(CmdBuf);
447 FlushStrBuf(WCC->ImportantMsg);
448 StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
458 * Printable view of a message
460 void print_message(void) {
464 msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
465 output_headers(0, 0, 0, 0, 0, 0);
467 hprintf("Content-type: text/html\r\n"
468 "Server: " PACKAGE_STRING "\r\n"
469 "Connection: close\r\n");
473 read_message(WC->WBuf, HKEY("view_message_print"), msgnum, NULL, &Mime);
479 * Mobile browser view of message
481 void mobile_message_view(void)
486 msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
487 output_headers(1, 0, 0, 0, 0, 1);
489 do_template("msgcontrols", NULL);
490 read_message(WC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
495 * Display a message's headers
497 void display_headers(void) {
501 msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
502 output_headers(0, 0, 0, 0, 0, 0);
504 hprintf("Content-type: text/plain\r\n"
506 "Connection: close\r\n",
510 serv_printf("MSG2 %ld|3", msgnum);
511 serv_getln(buf, sizeof buf);
513 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
514 wc_printf("%s\n", buf);
522 message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSubject, long MsgNum)
525 MsgPartEvaluatorStruct *Eval;
526 message_summary *Msg;
535 serv_printf("MSG0 %ld|1", MsgNum); /* ask for headers only */
537 StrBuf_ServGetln(Buf);
538 if (GetServerStatus(Buf, NULL) == 1) {
543 Msg = (message_summary*)malloc(sizeof(message_summary));
544 memset(Msg, 0, sizeof(message_summary));
545 while (len = StrBuf_ServGetln(Buf),
547 strcmp(ChrPtr(Buf), "000")== 0)){
549 ebuf = strchr(ChrPtr(Buf), '=');
551 if (GetHash(MsgEvaluators, buf, nBuf, &vEval) && vEval != NULL) {
552 Eval = (MsgPartEvaluatorStruct*) vEval;
553 StrBufCutLeft(Buf, nBuf + 1);
556 else lprintf(1, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf));
566 * load message pointers from the server for a "read messages" operation
568 * servcmd: the citadel command to send to the citserver
570 int load_msg_ptrs(const char *servcmd,
571 SharedMessageStatus *Stat,
572 load_msg_ptrs_detailheaders LH)
575 message_summary *Msg;
580 const char *Ptr = NULL;
582 Stat->lowest_found = LONG_MAX;
583 Stat->highest_found = LONG_MIN;
585 if (WCC->summ != NULL) {
586 DeleteHash(&WCC->summ);
588 WCC->summ = NewHash(1, Flathash);
592 StrBuf_ServGetln(Buf);
593 if (GetServerStatus(Buf, NULL) != 1) {
595 return (Stat->nummsgs);
598 while (len = StrBuf_ServGetln(Buf), ((len != 3) || strcmp(ChrPtr(Buf), "000")!= 0))
600 if (Stat->nummsgs < Stat->maxload) {
603 Msg = (message_summary*)malloc(sizeof(message_summary));
604 memset(Msg, 0, sizeof(message_summary));
606 Msg->msgnum = StrBufExtractNext_long(Buf, &Ptr, '|');
607 Msg->date = StrBufExtractNext_long(Buf, &Ptr, '|');
609 if (Stat->nummsgs == 0) {
610 if (Msg->msgnum < Stat->lowest_found) {
611 Stat->lowest_found = Msg->msgnum;
613 if (Msg->msgnum > Stat->highest_found) {
614 Stat->highest_found = Msg->msgnum;
618 if ((Msg->msgnum == 0) && (StrLength(Buf) < 32)) {
624 * as citserver probably gives us messages in forward date sorting
625 * nummsgs should be the same order as the message date.
627 if (Msg->date == 0) {
628 Msg->date = Stat->nummsgs;
629 if (StrLength(Buf) < 32)
632 if ((!skipit) && (LH != NULL)) {
633 if (!LH(Buf, &Ptr, Msg, Buf2)){
639 Put(WCC->summ, (const char *)&n, sizeof(n), Msg, DestroyMessageSummary);
645 return (Stat->nummsgs);
652 void load_seen_flags(void)
654 message_summary *Msg;
662 OldMsg = NewStrBuf();
664 StrBuf_ServGetln(OldMsg);
665 if (GetServerStatus(OldMsg, NULL) == 2) {
666 StrBufCutLeft(OldMsg, 4);
672 at = GetNewHashPos(WCC->summ, 0);
673 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
674 /* Are you a new message, or an old message? */
675 Msg = (message_summary*) vMsg;
676 if (is_msg_in_mset(ChrPtr(OldMsg), Msg->msgnum)) {
687 extern readloop_struct rlid[];
689 typedef struct _RoomRenderer{
692 GetParamsGetServerCall_func GetParamsGetServerCall;
693 PrintViewHeader_func PrintViewHeader;
694 LoadMsgFromServer_func LoadMsgFromServer;
695 RenderView_or_Tail_func RenderView_or_Tail;
696 View_Cleanup_func ViewCleanup;
697 load_msg_ptrs_detailheaders LHParse;
702 * command loop for reading messages
704 * Set oper to "readnew" or "readold" or "readfwd" or "headers" or "readgt" or "readlt" or "do_search"
706 void readloop(long oper, eCustomRoomRenderer ForceRenderer)
708 RoomRenderer *ViewMsg;
711 message_summary *Msg;
718 WCTemplputParams SubTP;
719 SharedMessageStatus Stat;
722 if (havebstr("is_summary") && (1 == (ibstr("is_summary")))) {
723 WCC->CurRoom.view = VIEW_MAILBOX;
726 if (havebstr("is_ajax") && (1 == (ibstr("is_ajax")))) {
730 if ((oper == do_search) && (WCC->CurRoom.view == VIEW_WIKI)) {
731 display_wiki_pagelist();
735 memset(&Stat, 0, sizeof(SharedMessageStatus));
736 Stat.maxload = 10000;
737 Stat.lowest_found = (-1);
738 Stat.highest_found = (-1);
739 if (ForceRenderer == eUseDefault)
740 GetHash(ReadLoopHandler, IKEY(WCC->CurRoom.view), &vViewMsg);
742 GetHash(ReadLoopHandler, IKEY(ForceRenderer), &vViewMsg);
743 if (vViewMsg == NULL) {
744 WCC->CurRoom.view = VIEW_BBS;
745 GetHash(ReadLoopHandler, IKEY(WCC->CurRoom.view), &vViewMsg);
747 if (vViewMsg == NULL) {
748 return; // TODO: print message
751 ViewMsg = (RoomRenderer*) vViewMsg;
753 output_headers(1, 1, 1, 0, 0, 0);
754 } else if (WCC->CurRoom.view == VIEW_MAILBOX) {
755 jsonMessageListHdr();
758 if (ViewMsg->GetParamsGetServerCall != NULL) {
759 r = ViewMsg->GetParamsGetServerCall(
774 case 300: /* the callback hook should do the work for us here, since he knows what to do. */
780 if (!IsEmptyStr(cmd))
781 Stat.nummsgs = load_msg_ptrs(cmd, &Stat, ViewMsg->LHParse);
785 memset(&SubTP, 0, sizeof(WCTemplputParams));
786 SubTP.Filter.ContextType = CTX_MAILSUM;
787 SubTP.Context = NULL;
788 SortIt = RetrieveSort(&SubTP, NULL, 0,
789 HKEY("date"), Stat.defaultsortorder);
791 SortByPayload(WCC->summ, SortIt);
793 if (Stat.startmsg < 0) {
797 if (Stat.load_seen) load_seen_flags();
800 * Print any inforation above the message list...
802 if (ViewMsg->PrintViewHeader != NULL)
803 ViewMsg->PrintViewHeader(&Stat, &ViewSpecific);
805 WCC->startmsg = Stat.startmsg;
806 WCC->maxmsgs = Stat.maxmsgs;
807 WCC->num_displayed = 0;
809 /* Put some helpful data in vars for mailsummary_json */
814 StrBufPrintf(Foo, "%ld", Stat.nummsgs);
815 PutBstr(HKEY("__READLOOP:TOTALMSGS"), NewStrBufDup(Foo));
816 StrBufPrintf(Foo, "%ld", Stat.startmsg);
817 PutBstr(HKEY("__READLOOP:STARTMSG"), Foo);
821 * iterate over each message. if we need to load an attachment, do it here.
824 if ((ViewMsg->LoadMsgFromServer != NULL) &&
827 at = GetNewHashPos(WCC->summ, 0);
828 Stat.num_displayed = i = 0;
829 while ( GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
830 Msg = (message_summary*) vMsg;
831 if ((Msg->msgnum >= Stat.startmsg) && (Stat.num_displayed <= Stat.maxmsgs)) {
832 ViewMsg->LoadMsgFromServer(&Stat, &ViewSpecific, Msg, Msg->is_new, i);
840 * Done iterating the message list. now tasks we want to do after.
842 if (ViewMsg->RenderView_or_Tail != NULL)
843 ViewMsg->RenderView_or_Tail(&Stat, &ViewSpecific, oper);
845 if (ViewMsg->ViewCleanup != NULL)
846 ViewMsg->ViewCleanup(&ViewSpecific);
850 if (WCC->summ != NULL) {
851 DeleteHash(&WCC->summ);
857 * Back end for post_message()
858 * ... this is where the actual message gets transmitted to the server.
860 void post_mime_to_server(void) {
862 char top_boundary[SIZ];
863 char alt_boundary[SIZ];
864 int is_multipart = 0;
866 wc_mime_attachment *att;
868 size_t encoded_length;
869 size_t encoded_strlen;
870 char *txtmail = NULL;
871 int include_text_alt = 0; /* Set to nonzero to include multipart/alternative text/plain */
873 sprintf(top_boundary, "Citadel--Multipart--%s--%04x--%04x",
874 ChrPtr(WCC->serv_info->serv_fqdn),
878 sprintf(alt_boundary, "Citadel--Multipart--%s--%04x--%04x",
879 ChrPtr(WCC->serv_info->serv_fqdn),
884 /* RFC2045 requires this, and some clients look for it... */
885 serv_puts("MIME-Version: 1.0");
886 serv_puts("X-Mailer: " PACKAGE_STRING);
888 /* If there are attachments, we have to do multipart/mixed */
889 if (GetCount(WCC->attachments) > 0) {
893 /* Only do multipart/alternative for mailboxes. BBS and Wiki rooms don't need it. */
894 if (WC->CurRoom.view == VIEW_MAILBOX) {
895 include_text_alt = 1;
899 /* Remember, serv_printf() appends an extra newline */
900 serv_printf("Content-type: multipart/mixed; boundary=\"%s\"\n", top_boundary);
901 serv_printf("This is a multipart message in MIME format.\n");
902 serv_printf("--%s", top_boundary);
905 /* Remember, serv_printf() appends an extra newline */
906 if (include_text_alt) {
907 serv_printf("Content-type: multipart/alternative; "
908 "boundary=\"%s\"\n", alt_boundary);
909 serv_printf("This is a multipart message in MIME format.\n");
910 serv_printf("--%s", alt_boundary);
912 serv_puts("Content-type: text/plain; charset=utf-8");
913 serv_puts("Content-Transfer-Encoding: quoted-printable");
915 txtmail = html_to_ascii(bstr("msgtext"), 0, 80, 0);
916 text_to_server_qp(txtmail); /* Transmit message in quoted-printable encoding */
919 serv_printf("--%s", alt_boundary);
922 serv_puts("Content-type: text/html; charset=utf-8");
923 serv_puts("Content-Transfer-Encoding: quoted-printable");
925 serv_puts("<html><body>\r\n");
926 text_to_server_qp(bstr("msgtext")); /* Transmit message in quoted-printable encoding */
927 serv_puts("</body></html>\r\n");
929 if (include_text_alt) {
930 serv_printf("--%s--", alt_boundary);
939 /* Add in the attachments */
940 it = GetNewHashPos(WCC->attachments, 0);
941 while (GetNextHashPos(WCC->attachments, it, &len, &Key, &vAtt)) {
942 att = (wc_mime_attachment *)vAtt;
943 if (att->length == 0)
945 encoded_length = ((att->length * 150) / 100);
946 encoded = malloc(encoded_length);
947 if (encoded == NULL) break;
948 encoded_strlen = CtdlEncodeBase64(encoded, ChrPtr(att->Data), StrLength(att->Data), 1);
950 serv_printf("--%s", top_boundary);
951 serv_printf("Content-type: %s", ChrPtr(att->ContentType));
952 serv_printf("Content-disposition: attachment; filename=\"%s\"", ChrPtr(att->FileName));
953 serv_puts("Content-transfer-encoding: base64");
955 serv_write(encoded, encoded_strlen);
960 serv_printf("--%s--", top_boundary);
969 * Post message (or don't post message)
971 * Note regarding the "dont_post" variable:
972 * A random value (actually, it's just a timestamp) is inserted as a hidden
973 * field called "postseq" when the display_enter page is generated. This
974 * value is checked when posting, using the static variable dont_post. If a
975 * user attempts to post twice using the same dont_post value, the message is
976 * discarded. This prevents the accidental double-saving of the same message
977 * if the user happens to click the browser "back" button.
979 void post_message(void)
982 StrBuf *EmailAddress;
985 StrBuf *encoded_subject = NULL;
986 static long dont_post = (-1L);
987 wc_mime_attachment *att;
988 int is_anonymous = 0;
989 const StrBuf *display_name = NULL;
993 if (havebstr("force_room")) {
994 gotoroom(sbstr("force_room"));
997 if (havebstr("display_name")) {
998 display_name = sbstr("display_name");
999 if (!strcmp(ChrPtr(display_name), "__ANONYMOUS__")) {
1000 display_name = NULL;
1005 if (WCC->upload_length > 0) {
1012 /* There's an attachment. Save it to this struct... */
1013 lprintf(9, "Client is uploading %d bytes\n", WCC->upload_length);
1014 att = malloc(sizeof(wc_mime_attachment));
1015 memset(att, 0, sizeof(wc_mime_attachment ));
1016 att->length = WCC->upload_length;
1017 att->ContentType = NewStrBufPlain(WCC->upload_content_type, -1);
1018 att->FileName = NewStrBufDup(WCC->upload_filename);
1020 if (WCC->attachments == NULL) {
1021 WCC->attachments = NewHash(1, Flathash);
1024 /* And add it to the list. */
1026 if ((GetCount(WCC->attachments) > 0) &&
1027 GetHashAt(WCC->attachments,
1028 GetCount(WCC->attachments) -1,
1029 &newnlen, &newn, &v))
1030 n = *((int*) newn) + 1;
1031 Put(WCC->attachments, IKEY(n), att, DestroyMime);
1034 * Mozilla sends a simple filename, which is what we want,
1035 * but Satan's Browser sends an entire pathname. Reduce
1036 * the path to just a filename if we need to.
1038 pch = strrchr(ChrPtr(att->FileName), '/');
1040 StrBufCutLeft(att->FileName, pch - ChrPtr(att->FileName) + 1);
1042 pch = strrchr(ChrPtr(att->FileName), '\\');
1044 StrBufCutLeft(att->FileName, pch - ChrPtr(att->FileName) + 1);
1048 * Transfer control of this memory from the upload struct
1049 * to the attachment struct.
1051 att->Data = WCC->upload;
1053 WCC->upload_length = 0;
1058 if (havebstr("cancel_button")) {
1059 sprintf(WCC->ImportantMessage,
1060 _("Cancelled. Message was not posted."));
1061 } else if (havebstr("attach_button")) {
1064 } else if (lbstr("postseq") == dont_post) {
1065 sprintf(WCC->ImportantMessage,
1066 _("Automatically cancelled because you have already "
1067 "saved this message."));
1068 } else if (havebstr("remove_attach_button")) {
1069 /* now thats st00pit. need to find it by name. */
1071 StrBuf *WhichAttachment;
1076 WhichAttachment = NewStrBufDup(sbstr("which_attachment"));
1077 StrBufUnescape(WhichAttachment, 0);
1078 at = GetNewHashPos(WCC->attachments, 0);
1080 GetHashPos(WCC->attachments, at, &len, &key, &vAtt);
1082 att = (wc_mime_attachment*) vAtt;
1083 if ((att != NULL) &&
1084 (strcmp(ChrPtr(WhichAttachment),
1085 ChrPtr(att->FileName) ) == 0))
1087 DeleteEntryFromHash(WCC->attachments, at);
1091 while (NextHashPos(WCC->attachments, at));
1092 FreeStrBuf(&WhichAttachment);
1096 const char CMD[] = "ENT0 1|%s|%d|4|%s|%s||%s|%s|%s|%s|%s";
1097 StrBuf *Recp = NULL;
1100 const StrBuf *Wikipage = NULL;
1101 const StrBuf *my_email_addr = NULL;
1102 StrBuf *CmdBuf = NULL;
1103 StrBuf *references = NULL;
1107 save_to_drafts = havebstr("save_button");
1110 if (save_to_drafts) {
1111 /* temporarily change to the drafts room */
1112 serv_puts("GOTO _DRAFTS_");
1113 StrBuf_ServGetln(Buf);
1114 if (GetServerStatus(Buf, NULL) != 2) {
1115 /* You probably don't even have a dumb Drafts folder */
1116 StrBufCutLeft(Buf, 4);
1117 lprintf(9, "%s:%d: server save to drafts error: %s\n", __FILE__, __LINE__, ChrPtr(Buf));
1118 StrBufAppendBufPlain(WCC->ImportantMsg, _("Saved to Drafts failed: "), -1, 0);
1119 StrBufAppendBuf(WCC->ImportantMsg, Buf, 0);
1126 if (havebstr("references"))
1128 const StrBuf *ref = sbstr("references");
1129 references = NewStrBufDup(ref);
1130 if (*ChrPtr(references) == '|') { /* remove leading '|' if present */
1131 StrBufCutLeft(references, 1);
1133 StrBufReplaceChars(references, '|', '!');
1135 if (havebstr("subject")) {
1138 * make enough room for the encoded string;
1139 * plus the QP header
1141 Subj = sbstr("subject");
1143 StrBufRFC2047encode(&encoded_subject, Subj);
1145 UserName = NewStrBuf();
1146 EmailAddress = NewStrBuf();
1147 EncBuf = NewStrBuf();
1149 Recp = StrBufSanitizeEmailRecipientVector(sbstr("recp"), UserName, EmailAddress, EncBuf);
1150 Cc = StrBufSanitizeEmailRecipientVector(sbstr("cc"), UserName, EmailAddress, EncBuf);
1151 Bcc = StrBufSanitizeEmailRecipientVector(sbstr("bcc"), UserName, EmailAddress, EncBuf);
1153 FreeStrBuf(&UserName);
1154 FreeStrBuf(&EmailAddress);
1155 FreeStrBuf(&EncBuf);
1157 Wikipage = sbstr("page");
1158 my_email_addr = sbstr("my_email_addr");
1160 HeaderLen = StrLength(Recp) +
1161 StrLength(encoded_subject) +
1164 StrLength(Wikipage) +
1165 StrLength(my_email_addr) +
1166 StrLength(references);
1167 CmdBuf = NewStrBufPlain(NULL, sizeof (CMD) + HeaderLen);
1168 StrBufPrintf(CmdBuf,
1170 save_to_drafts?"":ChrPtr(Recp),
1172 ChrPtr(encoded_subject),
1173 ChrPtr(display_name),
1174 save_to_drafts?"":ChrPtr(Cc),
1175 save_to_drafts?"":ChrPtr(Bcc),
1177 ChrPtr(my_email_addr),
1178 ChrPtr(references));
1179 FreeStrBuf(&references);
1180 FreeStrBuf(&encoded_subject);
1182 if ((HeaderLen + StrLength(sbstr("msgtext")) < 10) &&
1183 (GetCount(WCC->attachments) == 0)){
1184 StrBufAppendBufPlain(WCC->ImportantMsg, _("Refusing to post empty message.\n"), -1, 0);
1185 FreeStrBuf(&CmdBuf);
1190 lprintf(9, "%s\n", ChrPtr(CmdBuf));
1191 serv_puts(ChrPtr(CmdBuf));
1192 FreeStrBuf(&CmdBuf);
1194 StrBuf_ServGetln(Buf);
1195 if (GetServerStatus(Buf, NULL) == 4) {
1196 if (save_to_drafts) {
1197 if ( (havebstr("recp"))
1198 || (havebstr("cc" ))
1199 || (havebstr("bcc" )) ) {
1200 /* save recipient headers or room to post to */
1201 serv_printf("To: %s", ChrPtr(Recp));
1202 serv_printf("Cc: %s", ChrPtr(Cc));
1203 serv_printf("Bcc: %s", ChrPtr(Bcc));
1205 serv_printf("X-Citadel-Room: %s", ChrPtr(WC->CurRoom.name));
1208 post_mime_to_server();
1209 if (save_to_drafts) {
1210 StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been saved to Drafts.\n"), -1, 0);
1211 gotoroom(WCC->CurRoom.name);
1215 } else if ( (havebstr("recp"))
1216 || (havebstr("cc" ))
1217 || (havebstr("bcc" ))
1219 StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been sent.\n"), -1, 0);
1222 StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been posted.\n"), -1, 0);
1224 dont_post = lbstr("postseq");
1226 StrBufCutLeft(Buf, 4);
1228 lprintf(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, ChrPtr(Buf));
1229 StrBufAppendBuf(WCC->ImportantMsg, Buf, 0);
1230 if (save_to_drafts) gotoroom(WCC->CurRoom.name);
1243 DeleteHash(&WCC->attachments);
1246 * We may have been supplied with instructions regarding the location
1247 * to which we must return after posting. If found, go there.
1249 if (havebstr("return_to")) {
1250 http_redirect(bstr("return_to"));
1253 * If we were editing a page in a wiki room, go to that page now.
1255 else if (havebstr("page")) {
1256 snprintf(buf, sizeof buf, "wiki?page=%s", bstr("page"));
1260 * Otherwise, just go to the "read messages" loop.
1263 readloop(readnew, eUseDefault);
1271 * display the message entry screen
1273 void display_enter(void)
1277 const StrBuf *display_name = NULL;
1278 int recipient_required = 0;
1279 int subject_required = 0;
1280 int recipient_bad = 0;
1281 int is_anonymous = 0;
1282 wcsession *WCC = WC;
1286 if (havebstr("force_room")) {
1287 gotoroom(sbstr("force_room"));
1290 display_name = sbstr("display_name");
1291 if (!strcmp(ChrPtr(display_name), "__ANONYMOUS__")) {
1292 display_name = NULL;
1296 /* First test to see whether this is a room that requires recipients to be entered */
1297 serv_puts("ENT0 0");
1298 serv_getln(buf, sizeof buf);
1300 if (!strncmp(buf, "570", 3)) { /* 570 means that we need a recipient here */
1301 recipient_required = 1;
1303 else if (buf[0] != '2') { /* Any other error means that we cannot continue */
1304 sprintf(WCC->ImportantMessage, "%s", &buf[4]);
1305 readloop(readnew, eUseDefault);
1309 /* Is the server strongly recommending that the user enter a message subject? */
1310 if ((buf[3] != '\0') && (buf[4] != '\0')) {
1311 subject_required = extract_int(&buf[4], 1);
1315 * Are we perhaps in an address book view? If so, then an "enter
1316 * message" command really means "add new entry."
1318 if (WCC->CurRoom.defview == VIEW_ADDRESSBOOK) {
1319 do_edit_vcard(-1, "", NULL, NULL, "", ChrPtr(WCC->CurRoom.name));
1324 * Are we perhaps in a calendar room? If so, then an "enter
1325 * message" command really means "add new calendar item."
1327 if (WCC->CurRoom.defview == VIEW_CALENDAR) {
1328 display_edit_event();
1333 * Are we perhaps in a tasks view? If so, then an "enter
1334 * message" command really means "add new task."
1336 if (WCC->CurRoom.defview == VIEW_TASKS) {
1337 display_edit_task();
1342 * Otherwise proceed normally.
1343 * Do a custom room banner with no navbar...
1346 if (recipient_required) {
1347 const StrBuf *Recp = NULL;
1348 const StrBuf *Cc = NULL;
1349 const StrBuf *Bcc = NULL;
1350 const StrBuf *Wikipage = NULL;
1351 StrBuf *CmdBuf = NULL;
1352 const char CMD[] = "ENT0 0|%s|%d|0||%s||%s|%s|%s";
1354 Recp = sbstr("recp");
1357 Wikipage = sbstr("page");
1359 CmdBuf = NewStrBufPlain(NULL,
1362 StrLength(display_name) +
1365 StrLength(Wikipage));
1367 StrBufPrintf(CmdBuf,
1371 ChrPtr(display_name),
1375 serv_puts(ChrPtr(CmdBuf));
1376 serv_getln(buf, sizeof buf);
1377 FreeStrBuf(&CmdBuf);
1379 if (!strncmp(buf, "570", 3)) { /* 570 means we have an invalid recipient listed */
1380 if (havebstr("recp") &&
1386 else if (buf[0] != '2') { /* Any other error means that we cannot continue */
1387 wc_printf("<em>%s</em><br />\n", &buf[4]); /* TODO -> important message */
1391 if (recipient_required)
1392 PutBstr(HKEY("__RCPTREQUIRED"), NewStrBufPlain(HKEY("1")));
1393 if (recipient_required || subject_required)
1394 PutBstr(HKEY("__SUBJREQUIRED"), NewStrBufPlain(HKEY("1")));
1397 output_headers(1, 0, 0, 0, 1, 0);
1398 DoTemplate(HKEY("edit_message"), NULL, &NoCtx);
1407 void delete_msg(void)
1412 msgid = lbstr("msgid");
1414 if ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0) { /* Delete from Trash is a real delete */
1415 serv_printf("DELE %ld", msgid);
1417 else { /* Otherwise move it to Trash */
1418 serv_printf("MOVE %ld|_TRASH_|0", msgid);
1421 serv_getln(buf, sizeof buf);
1422 sprintf(WC->ImportantMessage, "%s", &buf[4]);
1423 readloop(readnew, eUseDefault);
1428 * move a message to another room
1435 msgid = lbstr("msgid");
1437 if (havebstr("move_button")) {
1438 sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
1440 serv_getln(buf, sizeof buf);
1441 sprintf(WC->ImportantMessage, "%s", &buf[4]);
1443 sprintf(WC->ImportantMessage, (_("The message was not moved.")));
1446 readloop(readnew, eUseDefault);
1451 * Confirm move of a message
1453 void confirm_move_msg(void)
1459 msgid = lbstr("msgid");
1462 output_headers(1, 1, 2, 0, 0, 0);
1463 wc_printf("<div id=\"banner\">\n");
1465 wc_printf(_("Confirm move of message"));
1467 wc_printf("</div>\n");
1469 wc_printf("<div id=\"content\" class=\"service\">\n");
1471 wc_printf("<CENTER>");
1473 wc_printf(_("Move this message to:"));
1474 wc_printf("<br />\n");
1476 wc_printf("<form METHOD=\"POST\" action=\"move_msg\">\n");
1477 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1478 wc_printf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n", bstr("msgid"));
1480 wc_printf("<SELECT NAME=\"target_room\" SIZE=5>\n");
1482 serv_getln(buf, sizeof buf);
1483 if (buf[0] == '1') {
1484 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1485 extract_token(targ, buf, 0, '|', sizeof targ);
1486 wc_printf("<OPTION>");
1491 wc_printf("</SELECT>\n");
1492 wc_printf("<br />\n");
1494 wc_printf("<INPUT TYPE=\"submit\" NAME=\"move_button\" VALUE=\"%s\">", _("Move"));
1495 wc_printf(" ");
1496 wc_printf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1497 wc_printf("</form></CENTER>\n");
1499 wc_printf("</CENTER>\n");
1505 * Generic function to output an arbitrary MIME attachment from
1506 * message being composed
1508 * partnum The MIME part to be output
1509 * filename Fake filename to give
1510 * force_download Nonzero to force set the Content-Type: header to "application/octet-stream"
1512 void postpart(StrBuf *partnum, StrBuf *filename, int force_download)
1515 StrBuf *content_type;
1516 wc_mime_attachment *part;
1519 i = StrToi(partnum);
1520 if (GetHash(WC->attachments, IKEY(i), &vPart) &&
1522 part = (wc_mime_attachment*) vPart;
1523 if (force_download) {
1524 content_type = NewStrBufPlain(HKEY("application/octet-stream"));
1527 content_type = NewStrBufDup(part->ContentType);
1529 StrBufAppendBuf(WC->WBuf, part->Data, 0);
1530 http_transmit_thing(ChrPtr(content_type), 0);
1532 hprintf("HTTP/1.1 404 %s\n", ChrPtr(partnum));
1533 output_headers(0, 0, 0, 0, 0, 0);
1534 hprintf("Content-Type: text/plain\r\n");
1536 wc_printf(_("An error occurred while retrieving this part: %s/%s\n"),
1537 ChrPtr(partnum), ChrPtr(filename));
1540 FreeStrBuf(&content_type);
1545 * Generic function to output an arbitrary MIME part from an arbitrary
1546 * message number on the server.
1548 * msgnum Number of the item on the citadel server
1549 * partnum The MIME part to be output
1550 * force_download Nonzero to force set the Content-Type: header to "application/octet-stream"
1552 void mimepart(int force_download)
1556 wcsession *WCC = WC;
1559 StrBuf *ContentType = NewStrBufPlain(HKEY("application/octet-stream"));
1562 att = Buf = NewStrBuf();
1563 msgnum = StrBufExtract_long(WCC->Hdr->HR.ReqLine, 0, '/');
1564 StrBufExtract_token(att, WCC->Hdr->HR.ReqLine, 1, '/');
1566 serv_printf("OPNA %ld|%s", msgnum, ChrPtr(att));
1567 StrBuf_ServGetln(Buf);
1568 if (GetServerStatus(Buf, NULL) == 2) {
1569 StrBufCutLeft(Buf, 4);
1570 bytes = StrBufExtract_long(Buf, 0, '|');
1571 if (!force_download) {
1572 StrBufExtract_token(ContentType, Buf, 3, '|');
1575 serv_read_binary(WCC->WBuf, bytes, Buf);
1577 StrBuf_ServGetln(Buf);
1578 CT = ChrPtr(ContentType);
1580 if (!force_download) {
1581 if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) {
1582 StrBufExtract_token(Buf, WCC->Hdr->HR.ReqLine, 2, '/');
1583 CT = GuessMimeByFilename(SKEY(Buf));
1585 if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) {
1586 CT = GuessMimeType(SKEY(WCC->WBuf));
1589 http_transmit_thing(CT, 0);
1591 StrBufCutLeft(Buf, 4);
1592 hprintf("HTTP/1.1 404 %s\n", ChrPtr(Buf));
1593 output_headers(0, 0, 0, 0, 0, 0);
1594 hprintf("Content-Type: text/plain\r\n");
1596 wc_printf(_("An error occurred while retrieving this part: %s\n"),
1600 FreeStrBuf(&ContentType);
1606 * Read any MIME part of a message, from the server, into memory.
1608 StrBuf *load_mimepart(long msgnum, char *partnum)
1614 serv_printf("DLAT %ld|%s", msgnum, partnum);
1615 StrBuf_ServGetln(Buf);
1616 if (GetServerStatus(Buf, NULL) == 6) {
1617 StrBufCutLeft(Buf, 4);
1618 bytes = StrBufExtract_long(Buf, 0, '|');
1621 StrBuf_ServGetBLOBBuffered(Buf, bytes);
1631 * Read any MIME part of a message, from the server, into memory.
1633 void MimeLoadData(wc_mime_attachment *Mime)
1638 /* TODO: is there a chance the content type is different from the one we know? */
1640 serv_printf("DLAT %ld|%s", Mime->msgnum, ChrPtr(Mime->PartNum));
1642 StrBuf_ServGetln(Buf);
1643 if (GetServerStatus(Buf, NULL) == 6) {
1644 Ptr = &(ChrPtr(Buf)[4]);
1645 bytes = StrBufExtractNext_long(Buf, &Ptr, '|');
1646 StrBufSkip_NTokenS(Buf, &Ptr, '|', 3); /* filename, cbtype, mimetype */
1647 if (Mime->Charset == NULL) Mime->Charset = NewStrBuf();
1648 StrBufExtract_NextToken(Mime->Charset, Buf, &Ptr, '|');
1650 if (Mime->Data == NULL)
1651 Mime->Data = NewStrBufPlain(NULL, bytes);
1652 StrBuf_ServGetBLOBBuffered(Mime->Data, bytes);
1655 FlushStrBuf(Mime->Data);
1656 /* TODO XImportant message */
1664 void view_mimepart(void) {
1668 void download_mimepart(void) {
1672 void view_postpart(void) {
1673 StrBuf *filename = NewStrBuf();
1674 StrBuf *partnum = NewStrBuf();
1676 StrBufExtract_token(partnum, WC->Hdr->HR.ReqLine, 0, '/');
1677 StrBufExtract_token(filename, WC->Hdr->HR.ReqLine, 1, '/');
1679 postpart(partnum, filename, 0);
1681 FreeStrBuf(&filename);
1682 FreeStrBuf(&partnum);
1685 void download_postpart(void) {
1686 StrBuf *filename = NewStrBuf();
1687 StrBuf *partnum = NewStrBuf();
1689 StrBufExtract_token(partnum, WC->Hdr->HR.ReqLine, 0, '/');
1690 StrBufExtract_token(filename, WC->Hdr->HR.ReqLine, 1, '/');
1692 postpart(partnum, filename, 1);
1694 FreeStrBuf(&filename);
1695 FreeStrBuf(&partnum);
1698 void h_readnew(void) { readloop(readnew, eUseDefault);}
1699 void h_readold(void) { readloop(readold, eUseDefault);}
1700 void h_readfwd(void) { readloop(readfwd, eUseDefault);}
1701 void h_headers(void) { readloop(headers, eUseDefault);}
1702 void h_do_search(void) { readloop(do_search, eUseDefault);}
1703 void h_readgt(void) { readloop(readgt, eUseDefault);}
1704 void h_readlt(void) { readloop(readlt, eUseDefault);}
1706 void jsonMessageListHdr(void)
1708 /* TODO: make a generic function */
1709 hprintf("HTTP/1.1 200 OK\r\n");
1710 hprintf("Content-type: application/json; charset=utf-8\r\n");
1711 hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
1712 hprintf("Connection: close\r\n");
1713 hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n");
1718 /* Output message list in JSON format */
1719 void jsonMessageList(void) {
1720 const StrBuf *room = sbstr("room");
1721 long oper = (havebstr("query")) ? do_search : readnew;
1724 readloop(oper, eUseDefault);
1728 void RegisterReadLoopHandlerset(
1730 GetParamsGetServerCall_func GetParamsGetServerCall,
1731 PrintViewHeader_func PrintViewHeader,
1732 load_msg_ptrs_detailheaders LH,
1733 LoadMsgFromServer_func LoadMsgFromServer,
1734 RenderView_or_Tail_func RenderView_or_Tail,
1735 View_Cleanup_func ViewCleanup
1738 RoomRenderer *Handler;
1740 Handler = (RoomRenderer*) malloc(sizeof(RoomRenderer));
1742 Handler->RoomType = RoomType;
1743 Handler->GetParamsGetServerCall = GetParamsGetServerCall;
1744 Handler->PrintViewHeader = PrintViewHeader;
1745 Handler->LoadMsgFromServer = LoadMsgFromServer;
1746 Handler->RenderView_or_Tail = RenderView_or_Tail;
1747 Handler->ViewCleanup = ViewCleanup;
1748 Handler->LHParse = LH;
1750 Put(ReadLoopHandler, IKEY(RoomType), Handler, NULL);
1757 RegisterPreference("use_sig",
1758 _("Attach signature to email messages?"),
1761 RegisterPreference("signature", _("Use this signature:"), PRF_QP_STRING, NULL);
1762 RegisterPreference("default_header_charset",
1763 _("Default character set for email headers:"),
1766 RegisterPreference("defaultfrom", _("Preferred email address"), PRF_STRING, NULL);
1767 RegisterPreference("defaultname",
1768 _("Preferred display name for email messages"),
1771 RegisterPreference("defaulthandle",
1772 _("Preferred display name for bulletin board posts"),
1775 RegisterPreference("mailbox",_("Mailbox view mode"), PRF_STRING, NULL);
1777 WebcitAddUrlHandler(HKEY("readnew"), "", 0, h_readnew, ANONYMOUS|NEED_URL);
1778 WebcitAddUrlHandler(HKEY("readold"), "", 0, h_readold, ANONYMOUS|NEED_URL);
1779 WebcitAddUrlHandler(HKEY("readfwd"), "", 0, h_readfwd, ANONYMOUS|NEED_URL);
1780 WebcitAddUrlHandler(HKEY("headers"), "", 0, h_headers, NEED_URL);
1781 WebcitAddUrlHandler(HKEY("readgt"), "", 0, h_readgt, ANONYMOUS|NEED_URL);
1782 WebcitAddUrlHandler(HKEY("readlt"), "", 0, h_readlt, ANONYMOUS|NEED_URL);
1783 WebcitAddUrlHandler(HKEY("do_search"), "", 0, h_do_search, 0);
1784 WebcitAddUrlHandler(HKEY("display_enter"), "", 0, display_enter, 0);
1785 WebcitAddUrlHandler(HKEY("post"), "", 0, post_message, PROHIBIT_STARTPAGE);
1786 WebcitAddUrlHandler(HKEY("move_msg"), "", 0, move_msg, PROHIBIT_STARTPAGE);
1787 WebcitAddUrlHandler(HKEY("delete_msg"), "", 0, delete_msg, PROHIBIT_STARTPAGE);
1788 WebcitAddUrlHandler(HKEY("confirm_move_msg"), "", 0, confirm_move_msg, PROHIBIT_STARTPAGE);
1789 WebcitAddUrlHandler(HKEY("msg"), "", 0, embed_message, NEED_URL);
1790 WebcitAddUrlHandler(HKEY("message"), "", 0, handle_one_message, NEED_URL|XHTTP_COMMANDS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
1791 WebcitAddUrlHandler(HKEY("printmsg"), "", 0, print_message, NEED_URL);
1792 WebcitAddUrlHandler(HKEY("mobilemsg"), "", 0, mobile_message_view, NEED_URL);
1793 WebcitAddUrlHandler(HKEY("msgheaders"), "", 0, display_headers, NEED_URL);
1795 WebcitAddUrlHandler(HKEY("mimepart"), "", 0, view_mimepart, NEED_URL);
1796 WebcitAddUrlHandler(HKEY("mimepart_download"), "", 0, download_mimepart, NEED_URL);
1797 WebcitAddUrlHandler(HKEY("postpart"), "", 0, view_postpart, NEED_URL|PROHIBIT_STARTPAGE);
1798 WebcitAddUrlHandler(HKEY("postpart_download"), "", 0, download_postpart, NEED_URL|PROHIBIT_STARTPAGE);
1801 WebcitAddUrlHandler(HKEY("roommsgs"), "", 0, jsonMessageList,0);
1806 SessionDetachModule_MSG
1809 DeleteHash(&sess->summ);