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,
45 lprintf(9, "MSG4 %ld|%s\n", Msg->msgnum, ChrPtr(Msg->PartNum));
46 if (Msg->PartNum != NULL) {
47 serv_printf("MSG4 %ld|%s", Msg->msgnum, ChrPtr(Msg->PartNum));
50 serv_printf("MSG4 %ld", Msg->msgnum);
53 StrBuf_ServGetln(Buf);
54 if (GetServerStatus(Buf, NULL) != 1) {
56 StrBufAppendPrintf(*Error, "<strong>");
57 StrBufAppendPrintf(*Error, _("ERROR:"));
58 StrBufAppendPrintf(*Error, "</strong> %s<br />\n", &buf[4]);
63 /* begin everythingamundo table */
64 HdrToken = NewStrBuf();
65 while (StrBuf_ServGetln(Buf) >= 0) {
66 if ( (StrLength(Buf) ==3 ) &&
67 !strcmp(ChrPtr(Buf), "000"))
70 if (Msg->MsgBody->Data == NULL)
71 Msg->MsgBody->Data = NewStrBuf();
72 Msg->MsgBody->ContentType = NewStrBufPlain(HKEY("text/html"));
73 StrBufAppendPrintf(Msg->MsgBody->Data, "<div><i>");
74 StrBufAppendPrintf(Msg->MsgBody->Data, _("Empty message"));
75 StrBufAppendPrintf(Msg->MsgBody->Data, "</i><br /><br />\n");
76 StrBufAppendPrintf(Msg->MsgBody->Data, "</div>\n");
81 case 0:/* Citadel Message Headers */
82 if (StrLength(Buf) == 0) {
86 StrBufExtract_token(HdrToken, Buf, 0, '=');
87 StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
90 if (dbg_analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf));
92 /* look up one of the examine_* functions to parse the content */
93 if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
95 Hdr = (headereval*)vHdr;
96 Hdr->evaluator(Msg, Buf, FoundCharset);
101 else LogError(Target,
103 "don't know how to handle message header[%s]\n",
107 case 1:/* Message Mime Header */
108 if (StrLength(Buf) == 0) {
110 if (Msg->MsgBody->ContentType == NULL)
111 /* end of header or no header? */
112 Msg->MsgBody->ContentType = NewStrBufPlain(HKEY("text/plain"));
113 /* usual end of mime header */
117 StrBufExtract_token(HdrToken, Buf, 0, ':');
118 if (StrLength(HdrToken) > 0) {
119 StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
121 if (dbg_analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf));
123 /* the examine*'s know how to do with mime headers too... */
124 if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
126 Hdr = (headereval*)vHdr;
127 Hdr->evaluator(Msg, Buf, FoundCharset);
132 case 2: /* Message Body */
134 if (Msg->MsgBody->size_known > 0) {
135 StrBuf_ServGetBLOBBuffered(Msg->MsgBody->Data, Msg->MsgBody->length);
137 /*/ todo: check next line, if not 000, append following lines */
140 if (StrLength(Msg->MsgBody->Data) > 0)
141 StrBufAppendBufPlain(Msg->MsgBody->Data, "\n", 1, 0);
142 StrBufAppendBuf(Msg->MsgBody->Data, Buf, 0);
146 StrBufAppendBuf(Msg->MsgBody->Data, Buf, 0);
151 if (Msg->AllAttach == NULL)
152 Msg->AllAttach = NewHash(1,NULL);
153 /* now we put the body mimepart we read above into the mimelist */
154 Put(Msg->AllAttach, SKEY(Msg->MsgBody->PartNum), Msg->MsgBody, DestroyMime);
156 /* Generate a reply-to address */
157 if (StrLength(Msg->Rfca) > 0) {
158 if (Msg->reply_to == NULL)
159 Msg->reply_to = NewStrBuf();
160 if (StrLength(Msg->from) > 0) {
161 StrBufPrintf(Msg->reply_to, "%s <%s>", ChrPtr(Msg->from), ChrPtr(Msg->Rfca));
164 FlushStrBuf(Msg->reply_to);
165 StrBufAppendBuf(Msg->reply_to, Msg->Rfca, 0);
170 if ((StrLength(Msg->OtherNode)>0) &&
171 (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(WCC->serv_info->serv_nodename))) &&
172 (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(WCC->serv_info->serv_humannode)) ))
174 if (Msg->reply_to == NULL)
175 Msg->reply_to = NewStrBuf();
176 StrBufPrintf(Msg->reply_to,
179 ChrPtr(Msg->OtherNode));
182 if (Msg->reply_to == NULL)
183 Msg->reply_to = NewStrBuf();
184 FlushStrBuf(Msg->reply_to);
185 StrBufAppendBuf(Msg->reply_to, Msg->from, 0);
189 FreeStrBuf(&HdrToken);
196 * I wanna SEE that message!
198 * msgnum Message number to display
199 * printable_view Nonzero to display a printable view
200 * section Optional for encapsulated message/rfc822 submessage
202 int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, const StrBuf *PartNum, const StrBuf **OutMime)
205 StrBuf *FoundCharset;
208 message_summary *Msg = NULL;
212 WCTemplputParams SubTP;
213 StrBuf *Error = NULL;
216 FoundCharset = NewStrBuf();
217 Msg = (message_summary *)malloc(sizeof(message_summary));
218 memset(Msg, 0, sizeof(message_summary));
219 Msg->msgnum = msgnum;
220 Msg->PartNum = PartNum;
221 Msg->MsgBody = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
222 memset(Msg->MsgBody, 0, sizeof(wc_mime_attachment));
223 Msg->MsgBody->msgnum = msgnum;
225 if (!load_message(Msg, FoundCharset, &Error)) {
226 StrBufAppendBuf(Target, Error, 0);
230 /* Extract just the content-type (omit attributes such as "charset") */
231 StrBufExtract_token(Buf, Msg->MsgBody->ContentType, 0, ';');
233 StrBufLowerCase(Buf);
235 /* Locate a renderer capable of converting this MIME part into HTML */
236 if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
238 RenderMimeFuncStruct *Render;
239 Render = (RenderMimeFuncStruct*)vHdr;
240 Render->f(Msg->MsgBody, NULL, FoundCharset);
243 if (StrLength(Msg->reply_references)> 0) {
244 /* Trim down excessively long lists of thread references. We eliminate the
245 * second one in the list so that the thread root remains intact.
247 int rrtok = num_tokens(ChrPtr(Msg->reply_references), '|');
248 int rrlen = StrLength(Msg->reply_references);
249 if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
250 StrBufRemove_token(Msg->reply_references, 1, '|');
254 /* now check if we need to translate some mimeparts, and remove the duplicate */
255 it = GetNewHashPos(Msg->AllAttach, 0);
256 while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) &&
258 wc_mime_attachment *Mime = (wc_mime_attachment*) vMime;
259 evaluate_mime_part(Msg, Mime);
262 memset(&SubTP, 0, sizeof(WCTemplputParams));
263 SubTP.Filter.ContextType = CTX_MAILSUM;
265 *OutMime = DoTemplate(tmpl, tmpllen, Target, &SubTP);
267 DestroyMessageSummary(Msg);
268 FreeStrBuf(&FoundCharset);
275 HttpStatus(long CitadelStatus)
277 /* TODO: this doesn't realy work currently, the HTTP status isn't printed to the browser! */
278 long httpstatus = 502;
280 switch (MAJORCODE(CitadelStatus))
282 case LISTING_FOLLOWS:
287 switch (MINORCODE(CitadelStatus))
295 case HIGHER_ACCESS_REQUIRED:
296 case MAX_SESSIONS_EXCEEDED:
298 case RESOURCE_NOT_OPEN:
300 case INVALID_FLOOR_OPERATION:
306 case MESSAGE_NOT_FOUND:
316 case CMD_NOT_SUPPORTED:
317 case PASSWORD_REQUIRED:
318 case ALREADY_LOGGED_IN:
319 case USERNAME_REQUIRED:
321 case SERVER_SHUTTING_DOWN:
332 case START_CHAT_MODE:
336 httpstatus = 502; /* aeh... whut? */
344 * Unadorned HTML output of an individual message, suitable
345 * for placing in a hidden iframe, for printing, or whatever
347 void handle_one_message(void)
349 long CitStatus = ERROR;
351 const StrBuf *Destination;
357 StrBuf *CmdBuf = NULL;
361 pMsg = strchr(ChrPtr(WCC->Hdr->HR.ReqLine), '/');
363 HttpStatus(CitStatus);
367 msgnum = atol(pMsg + 1);
368 StrBufCutAt(WCC->Hdr->HR.ReqLine, 0, pMsg);
369 gotoroom(WCC->Hdr->HR.ReqLine);
370 switch (WCC->Hdr->HR.eReqType)
374 Tmpl = sbstr("template");
375 if (StrLength(Tmpl) > 0)
376 read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime);
378 read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
379 http_transmit_thing(ChrPtr(Mime), 0);
382 CmdBuf = NewStrBuf ();
383 if ((WCC->CurRoom.RAFlags & UA_ISTRASH) != 0) { /* Delete from Trash is a real delete */
384 serv_printf("DELE %ld", msgnum);
386 else { /* Otherwise move it to Trash */
387 serv_printf("MOVE %ld|_TRASH_|0", msgnum);
389 StrBuf_ServGetln(CmdBuf);
390 FlushStrBuf(WCC->ImportantMsg);
391 StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
392 GetServerStatus(CmdBuf, &CitStatus);
393 HttpStatus(CitStatus);
398 if (GetHash(WCC->Hdr->HTTPHeaders, HKEY("DESTINATION"), &vLine) &&
400 Destination = (StrBuf*) vLine;
401 serv_printf("MOVE %ld|%s|%d", msgnum, ChrPtr(Destination), CopyMessage);
402 StrBuf_ServGetln(CmdBuf);
403 FlushStrBuf(WCC->ImportantMsg);
404 StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
405 GetServerStatus(CmdBuf, &CitStatus);
406 HttpStatus(CitStatus);
419 * Unadorned HTML output of an individual message, suitable
420 * for placing in a hidden iframe, for printing, or whatever
422 void embed_message(void) {
427 StrBuf *CmdBuf = NULL;
429 msgnum = StrBufExtract_long(WCC->Hdr->HR.ReqLine, 0, '/');
430 switch (WCC->Hdr->HR.eReqType)
434 Tmpl = sbstr("template");
435 if (StrLength(Tmpl) > 0)
436 read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime);
438 read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
439 http_transmit_thing(ChrPtr(Mime), 0);
442 CmdBuf = NewStrBuf ();
443 if ((WCC->CurRoom.RAFlags & UA_ISTRASH) != 0) { /* Delete from Trash is a real delete */
444 serv_printf("DELE %ld", msgnum);
446 else { /* Otherwise move it to Trash */
447 serv_printf("MOVE %ld|_TRASH_|0", msgnum);
449 StrBuf_ServGetln(CmdBuf);
450 FlushStrBuf(WCC->ImportantMsg);
451 StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
461 * Printable view of a message
463 void print_message(void) {
467 msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
468 output_headers(0, 0, 0, 0, 0, 0);
470 hprintf("Content-type: text/html\r\n"
471 "Server: " PACKAGE_STRING "\r\n"
472 "Connection: close\r\n");
476 read_message(WC->WBuf, HKEY("view_message_print"), msgnum, NULL, &Mime);
482 * Mobile browser view of message
484 void mobile_message_view(void)
489 msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
490 output_headers(1, 0, 0, 0, 0, 1);
492 do_template("msgcontrols", NULL);
493 read_message(WC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
498 * Display a message's headers
500 void display_headers(void) {
504 msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
505 output_headers(0, 0, 0, 0, 0, 0);
507 hprintf("Content-type: text/plain\r\n"
509 "Connection: close\r\n",
513 serv_printf("MSG2 %ld|3", msgnum);
514 serv_getln(buf, sizeof buf);
516 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
517 wc_printf("%s\n", buf);
525 message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSubject, long MsgNum)
528 MsgPartEvaluatorStruct *Eval;
529 message_summary *Msg;
538 serv_printf("MSG0 %ld|1", MsgNum); /* ask for headers only */
540 StrBuf_ServGetln(Buf);
541 if (GetServerStatus(Buf, NULL) == 1) {
546 Msg = (message_summary*)malloc(sizeof(message_summary));
547 memset(Msg, 0, sizeof(message_summary));
548 while (len = StrBuf_ServGetln(Buf),
551 strcmp(ChrPtr(Buf), "000")))
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,
576 SharedMessageStatus *Stat,
577 load_msg_ptrs_detailheaders LH)
580 message_summary *Msg;
585 const char *Ptr = NULL;
587 Stat->lowest_found = LONG_MAX;
588 Stat->highest_found = LONG_MIN;
590 if (WCC->summ != NULL) {
591 DeleteHash(&WCC->summ);
593 WCC->summ = NewHash(1, Flathash);
597 StrBuf_ServGetln(Buf);
598 if (GetServerStatus(Buf, NULL) != 1) {
600 return (Stat->nummsgs);
603 while (len = StrBuf_ServGetln(Buf),
606 strcmp(ChrPtr(Buf), "000")!= 0)))
608 if (Stat->nummsgs < Stat->maxload) {
611 Msg = (message_summary*)malloc(sizeof(message_summary));
612 memset(Msg, 0, sizeof(message_summary));
614 Msg->msgnum = StrBufExtractNext_long(Buf, &Ptr, '|');
615 Msg->date = StrBufExtractNext_long(Buf, &Ptr, '|');
617 if (Stat->nummsgs == 0) {
618 if (Msg->msgnum < Stat->lowest_found) {
619 Stat->lowest_found = Msg->msgnum;
621 if (Msg->msgnum > Stat->highest_found) {
622 Stat->highest_found = Msg->msgnum;
626 if ((Msg->msgnum == 0) && (StrLength(Buf) < 32)) {
632 * as citserver probably gives us messages in forward date sorting
633 * nummsgs should be the same order as the message date.
635 if (Msg->date == 0) {
636 Msg->date = Stat->nummsgs;
637 if (StrLength(Buf) < 32)
640 if ((!skipit) && (LH != NULL)) {
641 if (!LH(Buf, &Ptr, Msg, Buf2)){
647 Put(WCC->summ, (const char *)&n, sizeof(n), Msg, DestroyMessageSummary);
653 return (Stat->nummsgs);
660 void load_seen_flags(void)
662 message_summary *Msg;
670 OldMsg = NewStrBuf();
672 StrBuf_ServGetln(OldMsg);
673 if (GetServerStatus(OldMsg, NULL) == 2) {
674 StrBufCutLeft(OldMsg, 4);
680 at = GetNewHashPos(WCC->summ, 0);
681 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
682 /* Are you a new message, or an old message? */
683 Msg = (message_summary*) vMsg;
684 if (is_msg_in_mset(ChrPtr(OldMsg), Msg->msgnum)) {
695 extern readloop_struct rlid[];
697 typedef struct _RoomRenderer{
700 GetParamsGetServerCall_func GetParamsGetServerCall;
701 PrintViewHeader_func PrintViewHeader;
702 LoadMsgFromServer_func LoadMsgFromServer;
703 RenderView_or_Tail_func RenderView_or_Tail;
704 View_Cleanup_func ViewCleanup;
705 load_msg_ptrs_detailheaders LHParse;
710 * command loop for reading messages
712 * Set oper to "readnew" or "readold" or "readfwd" or "headers" or "readgt" or "readlt" or "do_search"
714 void readloop(long oper, eCustomRoomRenderer ForceRenderer)
716 RoomRenderer *ViewMsg;
719 message_summary *Msg;
726 WCTemplputParams SubTP;
727 SharedMessageStatus Stat;
732 if (havebstr("is_summary") && (1 == (ibstr("is_summary")))) {
733 WCC->CurRoom.view = VIEW_MAILBOX;
736 if (havebstr("is_ajax") && (1 == (ibstr("is_ajax")))) {
740 if ((oper == do_search) && (WCC->CurRoom.view == VIEW_WIKI)) {
741 display_wiki_pagelist();
745 memset(&Stat, 0, sizeof(SharedMessageStatus));
746 Stat.maxload = 10000;
747 Stat.lowest_found = (-1);
748 Stat.highest_found = (-1);
749 if (ForceRenderer == eUseDefault)
750 GetHash(ReadLoopHandler, IKEY(WCC->CurRoom.view), &vViewMsg);
752 GetHash(ReadLoopHandler, IKEY(ForceRenderer), &vViewMsg);
753 if (vViewMsg == NULL) {
754 WCC->CurRoom.view = VIEW_BBS;
755 GetHash(ReadLoopHandler, IKEY(WCC->CurRoom.view), &vViewMsg);
757 if (vViewMsg == NULL) {
758 return; // TODO: print message
761 ViewMsg = (RoomRenderer*) vViewMsg;
763 output_headers(1, 1, 1, 0, 0, 0);
764 } else if (WCC->CurRoom.view == VIEW_MAILBOX) {
765 jsonMessageListHdr();
768 if (ViewMsg->GetParamsGetServerCall != NULL) {
769 r = ViewMsg->GetParamsGetServerCall(
784 case 300: /* the callback hook should do the work for us here, since he knows what to do. */
790 if (!IsEmptyStr(cmd))
791 Stat.nummsgs = load_msg_ptrs(cmd, &Stat, ViewMsg->LHParse);
795 memset(&SubTP, 0, sizeof(WCTemplputParams));
796 SubTP.Filter.ContextType = CTX_MAILSUM;
797 SubTP.Context = NULL;
798 SortIt = RetrieveSort(&SubTP, NULL, 0,
799 HKEY("date"), Stat.defaultsortorder);
801 SortByPayload(WCC->summ, SortIt);
803 if (Stat.startmsg < 0) {
807 if (Stat.load_seen) load_seen_flags();
810 * Print any inforation above the message list...
812 if (ViewMsg->PrintViewHeader != NULL)
813 ViewMsg->PrintViewHeader(&Stat, &ViewSpecific);
815 WCC->startmsg = Stat.startmsg;
816 WCC->maxmsgs = Stat.maxmsgs;
817 WCC->num_displayed = 0;
819 /* Put some helpful data in vars for mailsummary_json */
820 svputlong("READLOOP:TOTALMSGS", Stat.nummsgs);
821 svputlong("READLOOP:STARTMSG", Stat.startmsg);
822 svputlong("WCVIEW", WCC->CurRoom.view);
825 * iterate over each message. if we need to load an attachment, do it here.
828 if ((ViewMsg->LoadMsgFromServer != NULL) &&
831 at = GetNewHashPos(WCC->summ, 0);
832 Stat.num_displayed = i = 0;
833 while ( GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
834 Msg = (message_summary*) vMsg;
835 if ((Msg->msgnum >= Stat.startmsg) && (Stat.num_displayed <= Stat.maxmsgs)) {
836 ViewMsg->LoadMsgFromServer(&Stat, &ViewSpecific, Msg, Msg->is_new, i);
844 * Done iterating the message list. now tasks we want to do after.
846 if (ViewMsg->RenderView_or_Tail != NULL)
847 ViewMsg->RenderView_or_Tail(&Stat, &ViewSpecific, oper);
849 if (ViewMsg->ViewCleanup != NULL)
850 ViewMsg->ViewCleanup(&ViewSpecific);
854 if (WCC->summ != NULL) {
855 DeleteHash(&WCC->summ);
861 * Back end for post_message()
862 * ... this is where the actual message gets transmitted to the server.
864 void post_mime_to_server(void) {
866 char top_boundary[SIZ];
867 char alt_boundary[SIZ];
868 int is_multipart = 0;
870 wc_mime_attachment *att;
872 size_t encoded_length;
873 size_t encoded_strlen;
874 char *txtmail = NULL;
875 int include_text_alt = 0; /* Set to nonzero to include multipart/alternative text/plain */
877 sprintf(top_boundary, "Citadel--Multipart--%s--%04x--%04x",
878 ChrPtr(WCC->serv_info->serv_fqdn),
882 sprintf(alt_boundary, "Citadel--Multipart--%s--%04x--%04x",
883 ChrPtr(WCC->serv_info->serv_fqdn),
888 /* RFC2045 requires this, and some clients look for it... */
889 serv_puts("MIME-Version: 1.0");
890 serv_puts("X-Mailer: " PACKAGE_STRING);
892 /* If there are attachments, we have to do multipart/mixed */
893 if (GetCount(WCC->attachments) > 0) {
897 /* Only do multipart/alternative for mailboxes. BBS and Wiki rooms don't need it. */
898 if (WC->CurRoom.view == VIEW_MAILBOX) {
899 include_text_alt = 1;
903 /* Remember, serv_printf() appends an extra newline */
904 serv_printf("Content-type: multipart/mixed; boundary=\"%s\"\n", top_boundary);
905 serv_printf("This is a multipart message in MIME format.\n");
906 serv_printf("--%s", top_boundary);
909 /* Remember, serv_printf() appends an extra newline */
910 if (include_text_alt) {
911 serv_printf("Content-type: multipart/alternative; "
912 "boundary=\"%s\"\n", alt_boundary);
913 serv_printf("This is a multipart message in MIME format.\n");
914 serv_printf("--%s", alt_boundary);
916 serv_puts("Content-type: text/plain; charset=utf-8");
917 serv_puts("Content-Transfer-Encoding: quoted-printable");
919 txtmail = html_to_ascii(bstr("msgtext"), 0, 80, 0);
920 text_to_server_qp(txtmail); /* Transmit message in quoted-printable encoding */
923 serv_printf("\n--%s", alt_boundary);
926 serv_puts("Content-type: text/html; charset=utf-8");
927 serv_puts("Content-Transfer-Encoding: quoted-printable");
929 serv_puts("<html><body>\r\n");
930 text_to_server_qp(bstr("msgtext")); /* Transmit message in quoted-printable encoding */
931 serv_puts("</body></html>\r\n");
933 if (include_text_alt) {
934 serv_printf("--%s--", alt_boundary);
943 /* Add in the attachments */
944 it = GetNewHashPos(WCC->attachments, 0);
945 while (GetNextHashPos(WCC->attachments, it, &len, &Key, &vAtt)) {
946 att = (wc_mime_attachment *)vAtt;
947 if (att->length == 0)
949 encoded_length = ((att->length * 150) / 100);
950 encoded = malloc(encoded_length);
951 if (encoded == NULL) break;
952 encoded_strlen = CtdlEncodeBase64(encoded, ChrPtr(att->Data), StrLength(att->Data), 1);
954 serv_printf("--%s", top_boundary);
955 serv_printf("Content-type: %s", ChrPtr(att->ContentType));
956 serv_printf("Content-disposition: attachment; filename=\"%s\"", ChrPtr(att->FileName));
957 serv_puts("Content-transfer-encoding: base64");
959 serv_write(encoded, encoded_strlen);
964 serv_printf("--%s--", top_boundary);
973 * Post message (or don't post message)
975 * Note regarding the "dont_post" variable:
976 * A random value (actually, it's just a timestamp) is inserted as a hidden
977 * field called "postseq" when the display_enter page is generated. This
978 * value is checked when posting, using the static variable dont_post. If a
979 * user attempts to post twice using the same dont_post value, the message is
980 * discarded. This prevents the accidental double-saving of the same message
981 * if the user happens to click the browser "back" button.
983 void post_message(void)
986 StrBuf *EmailAddress;
989 StrBuf *encoded_subject = NULL;
990 static long dont_post = (-1L);
991 wc_mime_attachment *att;
992 int is_anonymous = 0;
993 const StrBuf *display_name = NULL;
997 if (havebstr("force_room")) {
998 gotoroom(sbstr("force_room"));
1001 if (havebstr("display_name")) {
1002 display_name = sbstr("display_name");
1003 if (!strcmp(ChrPtr(display_name), "__ANONYMOUS__")) {
1004 display_name = NULL;
1009 if (WCC->upload_length > 0) {
1016 /* There's an attachment. Save it to this struct... */
1017 lprintf(9, "Client is uploading %d bytes\n", WCC->upload_length);
1018 att = malloc(sizeof(wc_mime_attachment));
1019 memset(att, 0, sizeof(wc_mime_attachment ));
1020 att->length = WCC->upload_length;
1021 att->ContentType = NewStrBufPlain(WCC->upload_content_type, -1);
1022 att->FileName = NewStrBufDup(WCC->upload_filename);
1024 if (WCC->attachments == NULL) {
1025 WCC->attachments = NewHash(1, Flathash);
1028 /* And add it to the list. */
1030 if ((GetCount(WCC->attachments) > 0) &&
1031 GetHashAt(WCC->attachments,
1032 GetCount(WCC->attachments) -1,
1033 &newnlen, &newn, &v))
1034 n = *((int*) newn) + 1;
1035 Put(WCC->attachments, IKEY(n), att, DestroyMime);
1038 * Mozilla sends a simple filename, which is what we want,
1039 * but Satan's Browser sends an entire pathname. Reduce
1040 * the path to just a filename if we need to.
1042 pch = strrchr(ChrPtr(att->FileName), '/');
1044 StrBufCutLeft(att->FileName, pch - ChrPtr(att->FileName) + 1);
1046 pch = strrchr(ChrPtr(att->FileName), '\\');
1048 StrBufCutLeft(att->FileName, pch - ChrPtr(att->FileName) + 1);
1052 * Transfer control of this memory from the upload struct
1053 * to the attachment struct.
1055 att->Data = WCC->upload;
1057 WCC->upload_length = 0;
1062 if (havebstr("cancel_button")) {
1063 sprintf(WCC->ImportantMessage,
1064 _("Cancelled. Message was not posted."));
1065 } else if (havebstr("attach_button")) {
1068 } else if (lbstr("postseq") == dont_post) {
1069 sprintf(WCC->ImportantMessage,
1070 _("Automatically cancelled because you have already "
1071 "saved this message."));
1072 } else if (havebstr("remove_attach_button")) {
1073 /* now thats st00pit. need to find it by name. */
1075 StrBuf *WhichAttachment;
1080 WhichAttachment = NewStrBufDup(sbstr("which_attachment"));
1081 StrBufUnescape(WhichAttachment, 0);
1082 at = GetNewHashPos(WCC->attachments, 0);
1084 GetHashPos(WCC->attachments, at, &len, &key, &vAtt);
1086 att = (wc_mime_attachment*) vAtt;
1087 if ((att != NULL) &&
1088 (strcmp(ChrPtr(WhichAttachment),
1089 ChrPtr(att->FileName) ) == 0))
1091 DeleteEntryFromHash(WCC->attachments, at);
1095 while (NextHashPos(WCC->attachments, at));
1096 FreeStrBuf(&WhichAttachment);
1100 const char CMD[] = "ENT0 1|%s|%d|4|%s|%s||%s|%s|%s|%s|%s";
1101 StrBuf *Recp = NULL;
1104 const StrBuf *Wikipage = NULL;
1105 const StrBuf *my_email_addr = NULL;
1106 StrBuf *CmdBuf = NULL;
1107 StrBuf *references = NULL;
1111 save_to_drafts = havebstr("save_button");
1114 if (save_to_drafts) {
1115 /* temporarily change to the drafts room */
1116 serv_puts("GOTO _DRAFTS_");
1117 StrBuf_ServGetln(Buf);
1118 if (GetServerStatus(Buf, NULL) != 2) {
1119 /* You probably don't even have a dumb Drafts folder */
1120 StrBufCutLeft(Buf, 4);
1121 lprintf(9, "%s:%d: server save to drafts error: %s\n", __FILE__, __LINE__, ChrPtr(Buf));
1122 StrBufAppendBufPlain(WCC->ImportantMsg, _("Saved to Drafts failed: "), -1, 0);
1123 StrBufAppendBuf(WCC->ImportantMsg, Buf, 0);
1130 if (havebstr("references"))
1132 const StrBuf *ref = sbstr("references");
1133 references = NewStrBufDup(ref);
1134 if (*ChrPtr(references) == '|') { /* remove leading '|' if present */
1135 StrBufCutLeft(references, 1);
1137 StrBufReplaceChars(references, '|', '!');
1139 if (havebstr("subject")) {
1142 * make enough room for the encoded string;
1143 * plus the QP header
1145 Subj = sbstr("subject");
1147 StrBufRFC2047encode(&encoded_subject, Subj);
1149 UserName = NewStrBuf();
1150 EmailAddress = NewStrBuf();
1151 EncBuf = NewStrBuf();
1153 Recp = StrBufSanitizeEmailRecipientVector(sbstr("recp"), UserName, EmailAddress, EncBuf);
1154 Cc = StrBufSanitizeEmailRecipientVector(sbstr("cc"), UserName, EmailAddress, EncBuf);
1155 Bcc = StrBufSanitizeEmailRecipientVector(sbstr("bcc"), UserName, EmailAddress, EncBuf);
1157 FreeStrBuf(&UserName);
1158 FreeStrBuf(&EmailAddress);
1159 FreeStrBuf(&EncBuf);
1161 Wikipage = sbstr("page");
1162 my_email_addr = sbstr("my_email_addr");
1164 HeaderLen = StrLength(Recp) +
1165 StrLength(encoded_subject) +
1168 StrLength(Wikipage) +
1169 StrLength(my_email_addr) +
1170 StrLength(references);
1171 CmdBuf = NewStrBufPlain(NULL, sizeof (CMD) + HeaderLen);
1172 StrBufPrintf(CmdBuf,
1174 save_to_drafts?"":ChrPtr(Recp),
1176 ChrPtr(encoded_subject),
1177 ChrPtr(display_name),
1178 save_to_drafts?"":ChrPtr(Cc),
1179 save_to_drafts?"":ChrPtr(Bcc),
1181 ChrPtr(my_email_addr),
1182 ChrPtr(references));
1183 FreeStrBuf(&references);
1184 FreeStrBuf(&encoded_subject);
1186 if ((HeaderLen + StrLength(sbstr("msgtext")) < 10) &&
1187 (GetCount(WCC->attachments) == 0)){
1188 StrBufAppendBufPlain(WCC->ImportantMsg, _("Refusing to post empty message.\n"), -1, 0);
1189 FreeStrBuf(&CmdBuf);
1194 lprintf(9, "%s\n", ChrPtr(CmdBuf));
1195 serv_puts(ChrPtr(CmdBuf));
1196 FreeStrBuf(&CmdBuf);
1198 StrBuf_ServGetln(Buf);
1199 if (GetServerStatus(Buf, NULL) == 4) {
1200 if (save_to_drafts) {
1201 if ( (havebstr("recp"))
1202 || (havebstr("cc" ))
1203 || (havebstr("bcc" )) ) {
1204 /* save recipient headers or room to post to */
1205 serv_printf("To: %s", ChrPtr(Recp));
1206 serv_printf("Cc: %s", ChrPtr(Cc));
1207 serv_printf("Bcc: %s", ChrPtr(Bcc));
1209 serv_printf("X-Citadel-Room: %s", ChrPtr(WC->CurRoom.name));
1212 post_mime_to_server();
1213 if (save_to_drafts) {
1214 StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been saved to Drafts.\n"), -1, 0);
1215 gotoroom(WCC->CurRoom.name);
1219 } else if ( (havebstr("recp"))
1220 || (havebstr("cc" ))
1221 || (havebstr("bcc" ))
1223 StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been sent.\n"), -1, 0);
1226 StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been posted.\n"), -1, 0);
1228 dont_post = lbstr("postseq");
1230 StrBufCutLeft(Buf, 4);
1232 lprintf(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, ChrPtr(Buf));
1233 StrBufAppendBuf(WCC->ImportantMsg, Buf, 0);
1234 if (save_to_drafts) gotoroom(WCC->CurRoom.name);
1248 DeleteHash(&WCC->attachments);
1251 * We may have been supplied with instructions regarding the location
1252 * to which we must return after posting. If found, go there.
1254 if (havebstr("return_to")) {
1255 http_redirect(bstr("return_to"));
1258 * If we were editing a page in a wiki room, go to that page now.
1260 else if (havebstr("page")) {
1261 snprintf(buf, sizeof buf, "wiki?page=%s", bstr("page"));
1265 * Otherwise, just go to the "read messages" loop.
1268 readloop(readnew, eUseDefault);
1276 * display the message entry screen
1278 void display_enter(void)
1282 const StrBuf *display_name = NULL;
1283 int recipient_required = 0;
1284 int subject_required = 0;
1285 int recipient_bad = 0;
1286 int is_anonymous = 0;
1287 wcsession *WCC = WC;
1291 if (havebstr("force_room")) {
1292 gotoroom(sbstr("force_room"));
1295 display_name = sbstr("display_name");
1296 if (!strcmp(ChrPtr(display_name), "__ANONYMOUS__")) {
1297 display_name = NULL;
1301 /* First test to see whether this is a room that requires recipients to be entered */
1302 serv_puts("ENT0 0");
1303 serv_getln(buf, sizeof buf);
1305 if (!strncmp(buf, "570", 3)) { /* 570 means that we need a recipient here */
1306 recipient_required = 1;
1308 else if (buf[0] != '2') { /* Any other error means that we cannot continue */
1309 sprintf(WCC->ImportantMessage, "%s", &buf[4]);
1310 readloop(readnew, eUseDefault);
1314 /* Is the server strongly recommending that the user enter a message subject? */
1315 if ((buf[3] != '\0') && (buf[4] != '\0')) {
1316 subject_required = extract_int(&buf[4], 1);
1320 * Are we perhaps in an address book view? If so, then an "enter
1321 * message" command really means "add new entry."
1323 if (WCC->CurRoom.defview == VIEW_ADDRESSBOOK) {
1324 do_edit_vcard(-1, "", NULL, NULL, "", ChrPtr(WCC->CurRoom.name));
1329 * Are we perhaps in a calendar room? If so, then an "enter
1330 * message" command really means "add new calendar item."
1332 if (WCC->CurRoom.defview == VIEW_CALENDAR) {
1333 display_edit_event();
1338 * Are we perhaps in a tasks view? If so, then an "enter
1339 * message" command really means "add new task."
1341 if (WCC->CurRoom.defview == VIEW_TASKS) {
1342 display_edit_task();
1347 * Otherwise proceed normally.
1348 * Do a custom room banner with no navbar...
1351 if (recipient_required) {
1352 const StrBuf *Recp = NULL;
1353 const StrBuf *Cc = NULL;
1354 const StrBuf *Bcc = NULL;
1355 const StrBuf *Wikipage = NULL;
1356 StrBuf *CmdBuf = NULL;
1357 const char CMD[] = "ENT0 0|%s|%d|0||%s||%s|%s|%s";
1359 Recp = sbstr("recp");
1362 Wikipage = sbstr("page");
1364 CmdBuf = NewStrBufPlain(NULL,
1367 StrLength(display_name) +
1370 StrLength(Wikipage));
1372 StrBufPrintf(CmdBuf,
1376 ChrPtr(display_name),
1380 serv_puts(ChrPtr(CmdBuf));
1381 serv_getln(buf, sizeof buf);
1382 FreeStrBuf(&CmdBuf);
1384 if (!strncmp(buf, "570", 3)) { /* 570 means we have an invalid recipient listed */
1385 if (havebstr("recp") &&
1391 else if (buf[0] != '2') { /* Any other error means that we cannot continue */
1392 wc_printf("<em>%s</em><br />\n", &buf[4]); /* TODO -> important message */
1396 svputlong("RCPTREQUIRED", recipient_required);
1397 svputlong("SUBJREQUIRED", recipient_required || subject_required);
1400 output_headers(1, 0, 0, 0, 1, 0);
1401 DoTemplate(HKEY("edit_message"), NULL, &NoCtx);
1410 void delete_msg(void)
1415 msgid = lbstr("msgid");
1417 if ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0) { /* Delete from Trash is a real delete */
1418 serv_printf("DELE %ld", msgid);
1420 else { /* Otherwise move it to Trash */
1421 serv_printf("MOVE %ld|_TRASH_|0", msgid);
1424 serv_getln(buf, sizeof buf);
1425 sprintf(WC->ImportantMessage, "%s", &buf[4]);
1426 readloop(readnew, eUseDefault);
1431 * move a message to another room
1438 msgid = lbstr("msgid");
1440 if (havebstr("move_button")) {
1441 sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
1443 serv_getln(buf, sizeof buf);
1444 sprintf(WC->ImportantMessage, "%s", &buf[4]);
1446 sprintf(WC->ImportantMessage, (_("The message was not moved.")));
1449 readloop(readnew, eUseDefault);
1454 * Confirm move of a message
1456 void confirm_move_msg(void)
1461 output_headers(1, 1, 2, 0, 0, 0);
1462 wc_printf("<div id=\"banner\">\n");
1464 wc_printf(_("Confirm move of message"));
1466 wc_printf("</div>\n");
1468 wc_printf("<div id=\"content\" class=\"service\">\n");
1470 wc_printf("<CENTER>");
1472 wc_printf(_("Move this message to:"));
1473 wc_printf("<br />\n");
1475 wc_printf("<form METHOD=\"POST\" action=\"move_msg\">\n");
1476 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1477 wc_printf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n", bstr("msgid"));
1479 wc_printf("<SELECT NAME=\"target_room\" SIZE=5>\n");
1481 serv_getln(buf, sizeof buf);
1482 if (buf[0] == '1') {
1483 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1484 extract_token(targ, buf, 0, '|', sizeof targ);
1485 wc_printf("<OPTION>");
1490 wc_printf("</SELECT>\n");
1491 wc_printf("<br />\n");
1493 wc_printf("<INPUT TYPE=\"submit\" NAME=\"move_button\" VALUE=\"%s\">", _("Move"));
1494 wc_printf(" ");
1495 wc_printf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1496 wc_printf("</form></CENTER>\n");
1498 wc_printf("</CENTER>\n");
1504 * Generic function to output an arbitrary MIME attachment from
1505 * message being composed
1507 * partnum The MIME part to be output
1508 * filename Fake filename to give
1509 * force_download Nonzero to force set the Content-Type: header to "application/octet-stream"
1511 void postpart(StrBuf *partnum, StrBuf *filename, int force_download)
1514 StrBuf *content_type;
1515 wc_mime_attachment *part;
1518 i = StrToi(partnum);
1519 if (GetHash(WC->attachments, IKEY(i), &vPart) &&
1521 part = (wc_mime_attachment*) vPart;
1522 if (force_download) {
1523 content_type = NewStrBufPlain(HKEY("application/octet-stream"));
1526 content_type = NewStrBufDup(part->ContentType);
1528 StrBufAppendBuf(WC->WBuf, part->Data, 0);
1529 http_transmit_thing(ChrPtr(content_type), 0);
1531 hprintf("HTTP/1.1 404 %s\n", ChrPtr(partnum));
1532 output_headers(0, 0, 0, 0, 0, 0);
1533 hprintf("Content-Type: text/plain\r\n");
1535 wc_printf(_("An error occurred while retrieving this part: %s/%s\n"),
1536 ChrPtr(partnum), ChrPtr(filename));
1539 FreeStrBuf(&content_type);
1544 * Generic function to output an arbitrary MIME part from an arbitrary
1545 * message number on the server.
1547 * msgnum Number of the item on the citadel server
1548 * partnum The MIME part to be output
1549 * force_download Nonzero to force set the Content-Type: header to "application/octet-stream"
1551 void mimepart(int force_download)
1555 wcsession *WCC = WC;
1558 StrBuf *ContentType = NewStrBufPlain(HKEY("application/octet-stream"));
1561 att = Buf = NewStrBuf();
1562 msgnum = StrBufExtract_long(WCC->Hdr->HR.ReqLine, 0, '/');
1563 StrBufExtract_token(att, WCC->Hdr->HR.ReqLine, 1, '/');
1565 serv_printf("OPNA %ld|%s", msgnum, ChrPtr(att));
1566 StrBuf_ServGetln(Buf);
1567 if (GetServerStatus(Buf, NULL) == 2) {
1568 StrBufCutLeft(Buf, 4);
1569 bytes = StrBufExtract_long(Buf, 0, '|');
1570 if (!force_download) {
1571 StrBufExtract_token(ContentType, Buf, 3, '|');
1574 serv_read_binary(WCC->WBuf, bytes, Buf);
1576 StrBuf_ServGetln(Buf);
1577 CT = ChrPtr(ContentType);
1579 if (!force_download) {
1580 if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) {
1581 StrBufExtract_token(Buf, WCC->Hdr->HR.ReqLine, 2, '/');
1582 CT = GuessMimeByFilename(SKEY(Buf));
1584 if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) {
1585 CT = GuessMimeType(SKEY(WCC->WBuf));
1588 http_transmit_thing(CT, 0);
1590 StrBufCutLeft(Buf, 4);
1591 hprintf("HTTP/1.1 404 %s\n", ChrPtr(Buf));
1592 output_headers(0, 0, 0, 0, 0, 0);
1593 hprintf("Content-Type: text/plain\r\n");
1595 wc_printf(_("An error occurred while retrieving this part: %s\n"),
1599 FreeStrBuf(&ContentType);
1605 * Read any MIME part of a message, from the server, into memory.
1607 StrBuf *load_mimepart(long msgnum, char *partnum)
1613 serv_printf("DLAT %ld|%s", msgnum, partnum);
1614 StrBuf_ServGetln(Buf);
1615 if (GetServerStatus(Buf, NULL) == 6) {
1616 StrBufCutLeft(Buf, 4);
1617 bytes = StrBufExtract_long(Buf, 0, '|');
1620 StrBuf_ServGetBLOBBuffered(Buf, bytes);
1630 * Read any MIME part of a message, from the server, into memory.
1632 void MimeLoadData(wc_mime_attachment *Mime)
1637 /* TODO: is there a chance the content type is different from the one we know? */
1639 serv_printf("DLAT %ld|%s", Mime->msgnum, ChrPtr(Mime->PartNum));
1641 StrBuf_ServGetln(Buf);
1642 if (GetServerStatus(Buf, NULL) == 6) {
1643 Ptr = &(ChrPtr(Buf)[4]);
1644 bytes = StrBufExtractNext_long(Buf, &Ptr, '|');
1645 StrBufSkip_NTokenS(Buf, &Ptr, '|', 3); /* filename, cbtype, mimetype */
1646 if (Mime->Charset == NULL) Mime->Charset = NewStrBuf();
1647 StrBufExtract_NextToken(Mime->Charset, Buf, &Ptr, '|');
1649 if (Mime->Data == NULL)
1650 Mime->Data = NewStrBufPlain(NULL, bytes);
1651 StrBuf_ServGetBLOBBuffered(Mime->Data, bytes);
1654 FlushStrBuf(Mime->Data);
1655 /* TODO XImportant message */
1663 void view_mimepart(void) {
1667 void download_mimepart(void) {
1671 void view_postpart(void) {
1672 StrBuf *filename = NewStrBuf();
1673 StrBuf *partnum = NewStrBuf();
1675 StrBufExtract_token(partnum, WC->Hdr->HR.ReqLine, 0, '/');
1676 StrBufExtract_token(filename, WC->Hdr->HR.ReqLine, 1, '/');
1678 postpart(partnum, filename, 0);
1680 FreeStrBuf(&filename);
1681 FreeStrBuf(&partnum);
1684 void download_postpart(void) {
1685 StrBuf *filename = NewStrBuf();
1686 StrBuf *partnum = NewStrBuf();
1688 StrBufExtract_token(partnum, WC->Hdr->HR.ReqLine, 0, '/');
1689 StrBufExtract_token(filename, WC->Hdr->HR.ReqLine, 1, '/');
1691 postpart(partnum, filename, 1);
1693 FreeStrBuf(&filename);
1694 FreeStrBuf(&partnum);
1697 void h_readnew(void) { readloop(readnew, eUseDefault);}
1698 void h_readold(void) { readloop(readold, eUseDefault);}
1699 void h_readfwd(void) { readloop(readfwd, eUseDefault);}
1700 void h_headers(void) { readloop(headers, eUseDefault);}
1701 void h_do_search(void) { readloop(do_search, eUseDefault);}
1702 void h_readgt(void) { readloop(readgt, eUseDefault);}
1703 void h_readlt(void) { readloop(readlt, eUseDefault);}
1705 void jsonMessageListHdr(void)
1707 /* TODO: make a generic function */
1708 hprintf("HTTP/1.1 200 OK\r\n");
1709 hprintf("Content-type: application/json; charset=utf-8\r\n");
1710 hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
1711 hprintf("Connection: close\r\n");
1712 hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n");
1717 /* Output message list in JSON format */
1718 void jsonMessageList(void) {
1719 const StrBuf *room = sbstr("room");
1720 long oper = (havebstr("query")) ? do_search : readnew;
1723 readloop(oper, eUseDefault);
1727 void RegisterReadLoopHandlerset(
1729 GetParamsGetServerCall_func GetParamsGetServerCall,
1730 PrintViewHeader_func PrintViewHeader,
1731 load_msg_ptrs_detailheaders LH,
1732 LoadMsgFromServer_func LoadMsgFromServer,
1733 RenderView_or_Tail_func RenderView_or_Tail,
1734 View_Cleanup_func ViewCleanup
1737 RoomRenderer *Handler;
1739 Handler = (RoomRenderer*) malloc(sizeof(RoomRenderer));
1741 Handler->RoomType = RoomType;
1742 Handler->GetParamsGetServerCall = GetParamsGetServerCall;
1743 Handler->PrintViewHeader = PrintViewHeader;
1744 Handler->LoadMsgFromServer = LoadMsgFromServer;
1745 Handler->RenderView_or_Tail = RenderView_or_Tail;
1746 Handler->ViewCleanup = ViewCleanup;
1747 Handler->LHParse = LH;
1749 Put(ReadLoopHandler, IKEY(RoomType), Handler, NULL);
1756 RegisterPreference("use_sig",
1757 _("Attach signature to email messages?"),
1760 RegisterPreference("signature", _("Use this signature:"), PRF_QP_STRING, NULL);
1761 RegisterPreference("default_header_charset",
1762 _("Default character set for email headers:"),
1765 RegisterPreference("defaultfrom", _("Preferred email address"), PRF_STRING, NULL);
1766 RegisterPreference("defaultname",
1767 _("Preferred display name for email messages"),
1770 RegisterPreference("defaulthandle",
1771 _("Preferred display name for bulletin board posts"),
1774 RegisterPreference("mailbox",_("Mailbox view mode"), PRF_STRING, NULL);
1776 WebcitAddUrlHandler(HKEY("readnew"), "", 0, h_readnew, NEED_URL);
1777 WebcitAddUrlHandler(HKEY("readold"), "", 0, h_readold, NEED_URL);
1778 WebcitAddUrlHandler(HKEY("readfwd"), "", 0, h_readfwd, NEED_URL);
1779 WebcitAddUrlHandler(HKEY("headers"), "", 0, h_headers, NEED_URL);
1780 WebcitAddUrlHandler(HKEY("readgt"), "", 0, h_readgt, NEED_URL);
1781 WebcitAddUrlHandler(HKEY("readlt"), "", 0, h_readlt, NEED_URL);
1782 WebcitAddUrlHandler(HKEY("do_search"), "", 0, h_do_search, 0);
1783 WebcitAddUrlHandler(HKEY("display_enter"), "", 0, display_enter, 0);
1784 WebcitAddUrlHandler(HKEY("post"), "", 0, post_message, PROHIBIT_STARTPAGE);
1785 WebcitAddUrlHandler(HKEY("move_msg"), "", 0, move_msg, PROHIBIT_STARTPAGE);
1786 WebcitAddUrlHandler(HKEY("delete_msg"), "", 0, delete_msg, PROHIBIT_STARTPAGE);
1787 WebcitAddUrlHandler(HKEY("confirm_move_msg"), "", 0, confirm_move_msg, PROHIBIT_STARTPAGE);
1788 WebcitAddUrlHandler(HKEY("msg"), "", 0, embed_message, NEED_URL);
1789 WebcitAddUrlHandler(HKEY("message"), "", 0, handle_one_message, NEED_URL|XHTTP_COMMANDS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
1790 WebcitAddUrlHandler(HKEY("printmsg"), "", 0, print_message, NEED_URL);
1791 WebcitAddUrlHandler(HKEY("mobilemsg"), "", 0, mobile_message_view, NEED_URL);
1792 WebcitAddUrlHandler(HKEY("msgheaders"), "", 0, display_headers, NEED_URL);
1794 WebcitAddUrlHandler(HKEY("mimepart"), "", 0, view_mimepart, NEED_URL);
1795 WebcitAddUrlHandler(HKEY("mimepart_download"), "", 0, download_mimepart, NEED_URL);
1796 WebcitAddUrlHandler(HKEY("postpart"), "", 0, view_postpart, NEED_URL|PROHIBIT_STARTPAGE);
1797 WebcitAddUrlHandler(HKEY("postpart_download"), "", 0, download_postpart, NEED_URL|PROHIBIT_STARTPAGE);
1800 WebcitAddUrlHandler(HKEY("roommsgs"), "", 0, jsonMessageList,0);
1805 SessionDetachModule_MSG
1808 DeleteHash(&sess->summ);