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 if (Msg->MsgBody->Data == NULL)
73 Msg->MsgBody->Data = NewStrBuf();
74 Msg->MsgBody->ContentType = NewStrBufPlain(HKEY("text/html"));
75 StrBufAppendPrintf(Msg->MsgBody->Data, "<div><i>");
76 StrBufAppendPrintf(Msg->MsgBody->Data, _("Empty message"));
77 StrBufAppendPrintf(Msg->MsgBody->Data, "</i><br /><br />\n");
78 StrBufAppendPrintf(Msg->MsgBody->Data, "</div>\n");
83 case 0:/* Citadel Message Headers */
84 if (StrLength(Buf) == 0) {
88 StrBufExtract_token(HdrToken, Buf, 0, '=');
89 StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
92 if (dbg_analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf));
94 /* look up one of the examine_* functions to parse the content */
95 if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
97 Hdr = (headereval*)vHdr;
98 Hdr->evaluator(Msg, Buf, FoundCharset);
103 else LogError(Target,
105 "don't know how to handle message header[%s]\n",
109 case 1:/* Message Mime Header */
110 if (StrLength(Buf) == 0) {
112 if (Msg->MsgBody->ContentType == NULL)
113 /* end of header or no header? */
114 Msg->MsgBody->ContentType = NewStrBufPlain(HKEY("text/plain"));
115 /* usual end of mime header */
119 StrBufExtract_token(HdrToken, Buf, 0, ':');
120 if (StrLength(HdrToken) > 0) {
121 StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
123 if (dbg_analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf));
125 /* the examine*'s know how to do with mime headers too... */
126 if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
128 Hdr = (headereval*)vHdr;
129 Hdr->evaluator(Msg, Buf, FoundCharset);
134 case 2: /* Message Body */
136 if (Msg->MsgBody->size_known > 0) {
137 StrBuf_ServGetBLOBBuffered(Msg->MsgBody->Data, Msg->MsgBody->length);
139 /*/ todo: check next line, if not 000, append following lines */
142 if (StrLength(Msg->MsgBody->Data) > 0)
143 StrBufAppendBufPlain(Msg->MsgBody->Data, "\n", 1, 0);
144 StrBufAppendBuf(Msg->MsgBody->Data, Buf, 0);
148 StrBufAppendBuf(Msg->MsgBody->Data, Buf, 0);
153 if (Msg->AllAttach == NULL)
154 Msg->AllAttach = NewHash(1,NULL);
155 /* now we put the body mimepart we read above into the mimelist */
156 Put(Msg->AllAttach, SKEY(Msg->MsgBody->PartNum), Msg->MsgBody, DestroyMime);
158 /* Generate a reply-to address */
159 if (StrLength(Msg->Rfca) > 0) {
160 if (Msg->reply_to == NULL)
161 Msg->reply_to = NewStrBuf();
162 if (StrLength(Msg->from) > 0) {
163 StrBufPrintf(Msg->reply_to, "%s <%s>", ChrPtr(Msg->from), ChrPtr(Msg->Rfca));
166 FlushStrBuf(Msg->reply_to);
167 StrBufAppendBuf(Msg->reply_to, Msg->Rfca, 0);
172 if ((StrLength(Msg->OtherNode)>0) &&
173 (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(WCC->serv_info->serv_nodename))) &&
174 (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(WCC->serv_info->serv_humannode)) ))
176 if (Msg->reply_to == NULL)
177 Msg->reply_to = NewStrBuf();
178 StrBufPrintf(Msg->reply_to,
181 ChrPtr(Msg->OtherNode));
184 if (Msg->reply_to == NULL)
185 Msg->reply_to = NewStrBuf();
186 FlushStrBuf(Msg->reply_to);
187 StrBufAppendBuf(Msg->reply_to, Msg->from, 0);
191 FreeStrBuf(&HdrToken);
198 * I wanna SEE that message!
200 * msgnum Message number to display
201 * printable_view Nonzero to display a printable view
202 * section Optional for encapsulated message/rfc822 submessage
204 int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, const StrBuf *PartNum, const StrBuf **OutMime)
207 StrBuf *FoundCharset;
210 message_summary *Msg = NULL;
214 WCTemplputParams SubTP;
215 StrBuf *Error = NULL;
218 FoundCharset = NewStrBuf();
219 Msg = (message_summary *)malloc(sizeof(message_summary));
220 memset(Msg, 0, sizeof(message_summary));
221 Msg->msgnum = msgnum;
222 Msg->PartNum = PartNum;
223 Msg->MsgBody = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
224 memset(Msg->MsgBody, 0, sizeof(wc_mime_attachment));
225 Msg->MsgBody->msgnum = msgnum;
227 if (!load_message(Msg, FoundCharset, &Error)) {
228 StrBufAppendBuf(Target, Error, 0);
232 /* Extract just the content-type (omit attributes such as "charset") */
233 StrBufExtract_token(Buf, Msg->MsgBody->ContentType, 0, ';');
235 StrBufLowerCase(Buf);
237 /* Locate a renderer capable of converting this MIME part into HTML */
238 if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
240 RenderMimeFuncStruct *Render;
241 Render = (RenderMimeFuncStruct*)vHdr;
242 Render->f(Msg->MsgBody, NULL, FoundCharset);
245 if (StrLength(Msg->reply_references)> 0) {
246 /* Trim down excessively long lists of thread references. We eliminate the
247 * second one in the list so that the thread root remains intact.
249 int rrtok = num_tokens(ChrPtr(Msg->reply_references), '|');
250 int rrlen = StrLength(Msg->reply_references);
251 if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
252 StrBufRemove_token(Msg->reply_references, 1, '|');
256 /* now check if we need to translate some mimeparts, and remove the duplicate */
257 it = GetNewHashPos(Msg->AllAttach, 0);
258 while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) &&
260 wc_mime_attachment *Mime = (wc_mime_attachment*) vMime;
261 evaluate_mime_part(Msg, Mime);
264 memset(&SubTP, 0, sizeof(WCTemplputParams));
265 SubTP.Filter.ContextType = CTX_MAILSUM;
267 *OutMime = DoTemplate(tmpl, tmpllen, Target, &SubTP);
269 DestroyMessageSummary(Msg);
270 FreeStrBuf(&FoundCharset);
277 HttpStatus(long CitadelStatus)
279 long httpstatus = 502;
281 switch (MAJORCODE(CitadelStatus))
283 case LISTING_FOLLOWS:
288 switch (MINORCODE(CitadelStatus))
296 case HIGHER_ACCESS_REQUIRED:
297 case MAX_SESSIONS_EXCEEDED:
299 case RESOURCE_NOT_OPEN:
301 case INVALID_FLOOR_OPERATION:
307 case MESSAGE_NOT_FOUND:
317 case CMD_NOT_SUPPORTED:
318 case PASSWORD_REQUIRED:
319 case ALREADY_LOGGED_IN:
320 case USERNAME_REQUIRED:
322 case SERVER_SHUTTING_DOWN:
333 case START_CHAT_MODE:
337 httpstatus = 502; /* aeh... whut? */
345 * Unadorned HTML output of an individual message, suitable
346 * for placing in a hidden iframe, for printing, or whatever
348 void handle_one_message(void)
352 const StrBuf *Destination;
358 StrBuf *CmdBuf = NULL;
362 pMsg = strchr(ChrPtr(WCC->Hdr->HR.ReqLine), '/');
364 HttpStatus(CitStatus);
368 msgnum = atol(pMsg + 1);
369 StrBufCutAt(WCC->Hdr->HR.ReqLine, 0, pMsg);
370 gotoroom(WCC->Hdr->HR.ReqLine);
371 switch (WCC->Hdr->HR.eReqType)
375 Tmpl = sbstr("template");
376 if (StrLength(Tmpl) > 0)
377 read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime);
379 read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
380 http_transmit_thing(ChrPtr(Mime), 0);
383 CmdBuf = NewStrBuf ();
384 if ((WCC->CurRoom.RAFlags & UA_ISTRASH) != 0) { /* Delete from Trash is a real delete */
385 serv_printf("DELE %ld", msgnum);
387 else { /* Otherwise move it to Trash */
388 serv_printf("MOVE %ld|_TRASH_|0", msgnum);
390 StrBuf_ServGetln(CmdBuf);
391 FlushStrBuf(WCC->ImportantMsg);
392 StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
393 GetServerStatus(CmdBuf, &CitStatus);
394 HttpStatus(CitStatus);
399 if (GetHash(WCC->Hdr->HTTPHeaders, HKEY("DESTINATION"), &vLine) &&
401 Destination = (StrBuf*) vLine;
402 serv_printf("MOVE %ld|%s|%d", msgnum, ChrPtr(Destination), CopyMessage);
403 StrBuf_ServGetln(CmdBuf);
404 FlushStrBuf(WCC->ImportantMsg);
405 StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
406 GetServerStatus(CmdBuf, &CitStatus);
407 HttpStatus(CitStatus);
420 * Unadorned HTML output of an individual message, suitable
421 * for placing in a hidden iframe, for printing, or whatever
423 void embed_message(void) {
428 StrBuf *CmdBuf = NULL;
430 msgnum = StrBufExtract_long(WCC->Hdr->HR.ReqLine, 0, '/');
431 switch (WCC->Hdr->HR.eReqType)
435 Tmpl = sbstr("template");
436 if (StrLength(Tmpl) > 0)
437 read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime);
439 read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
440 http_transmit_thing(ChrPtr(Mime), 0);
443 CmdBuf = NewStrBuf ();
444 if ((WCC->CurRoom.RAFlags & UA_ISTRASH) != 0) { /* Delete from Trash is a real delete */
445 serv_printf("DELE %ld", msgnum);
447 else { /* Otherwise move it to Trash */
448 serv_printf("MOVE %ld|_TRASH_|0", msgnum);
450 StrBuf_ServGetln(CmdBuf);
451 FlushStrBuf(WCC->ImportantMsg);
452 StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
462 * Printable view of a message
464 void print_message(void) {
468 msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
469 output_headers(0, 0, 0, 0, 0, 0);
471 hprintf("Content-type: text/html\r\n"
472 "Server: " PACKAGE_STRING "\r\n"
473 "Connection: close\r\n");
477 read_message(WC->WBuf, HKEY("view_message_print"), msgnum, NULL, &Mime);
483 * Mobile browser view of message
485 void mobile_message_view(void)
490 msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
491 output_headers(1, 0, 0, 0, 0, 1);
493 do_template("msgcontrols", NULL);
494 read_message(WC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
499 * Display a message's headers
501 void display_headers(void) {
505 msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
506 output_headers(0, 0, 0, 0, 0, 0);
508 hprintf("Content-type: text/plain\r\n"
510 "Connection: close\r\n",
514 serv_printf("MSG2 %ld|3", msgnum);
515 serv_getln(buf, sizeof buf);
517 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
518 wc_printf("%s\n", buf);
526 message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSubject, long MsgNum)
529 MsgPartEvaluatorStruct *Eval;
530 message_summary *Msg;
539 serv_printf("MSG0 %ld|1", MsgNum); /* ask for headers only */
541 StrBuf_ServGetln(Buf);
542 if (GetServerStatus(Buf, NULL) == 1) {
547 Msg = (message_summary*)malloc(sizeof(message_summary));
548 memset(Msg, 0, sizeof(message_summary));
549 while (len = StrBuf_ServGetln(Buf),
551 strcmp(ChrPtr(Buf), "000")== 0)){
553 ebuf = strchr(ChrPtr(Buf), '=');
555 if (GetHash(MsgEvaluators, buf, nBuf, &vEval) && vEval != NULL) {
556 Eval = (MsgPartEvaluatorStruct*) vEval;
557 StrBufCutLeft(Buf, nBuf + 1);
560 else lprintf(1, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf));
570 * load message pointers from the server for a "read messages" operation
572 * servcmd: the citadel command to send to the citserver
574 int load_msg_ptrs(const char *servcmd,
575 SharedMessageStatus *Stat,
576 load_msg_ptrs_detailheaders LH)
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)
636 if ((!skipit) && (LH != NULL)) {
637 if (!LH(Buf, &Ptr, Msg, Buf2)){
643 Put(WCC->summ, (const char *)&n, sizeof(n), Msg, DestroyMessageSummary);
649 return (Stat->nummsgs);
656 void load_seen_flags(void)
658 message_summary *Msg;
666 OldMsg = NewStrBuf();
668 StrBuf_ServGetln(OldMsg);
669 if (GetServerStatus(OldMsg, NULL) == 2) {
670 StrBufCutLeft(OldMsg, 4);
676 at = GetNewHashPos(WCC->summ, 0);
677 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
678 /* Are you a new message, or an old message? */
679 Msg = (message_summary*) vMsg;
680 if (is_msg_in_mset(ChrPtr(OldMsg), Msg->msgnum)) {
691 extern readloop_struct rlid[];
693 typedef struct _RoomRenderer{
696 GetParamsGetServerCall_func GetParamsGetServerCall;
697 PrintViewHeader_func PrintViewHeader;
698 LoadMsgFromServer_func LoadMsgFromServer;
699 RenderView_or_Tail_func RenderView_or_Tail;
700 View_Cleanup_func ViewCleanup;
701 load_msg_ptrs_detailheaders LHParse;
706 * command loop for reading messages
708 * Set oper to "readnew" or "readold" or "readfwd" or "headers" or "readgt" or "readlt" or "do_search"
710 void readloop(long oper, eCustomRoomRenderer ForceRenderer)
712 RoomRenderer *ViewMsg;
715 message_summary *Msg;
722 WCTemplputParams SubTP;
723 SharedMessageStatus Stat;
726 if (havebstr("is_summary") && (1 == (ibstr("is_summary")))) {
727 WCC->CurRoom.view = VIEW_MAILBOX;
730 if (havebstr("is_ajax") && (1 == (ibstr("is_ajax")))) {
734 if ((oper == do_search) && (WCC->CurRoom.view == VIEW_WIKI)) {
735 display_wiki_pagelist();
739 memset(&Stat, 0, sizeof(SharedMessageStatus));
740 Stat.maxload = 10000;
741 Stat.lowest_found = (-1);
742 Stat.highest_found = (-1);
743 if (ForceRenderer == eUseDefault)
744 GetHash(ReadLoopHandler, IKEY(WCC->CurRoom.view), &vViewMsg);
746 GetHash(ReadLoopHandler, IKEY(ForceRenderer), &vViewMsg);
747 if (vViewMsg == NULL) {
748 WCC->CurRoom.view = VIEW_BBS;
749 GetHash(ReadLoopHandler, IKEY(WCC->CurRoom.view), &vViewMsg);
751 if (vViewMsg == NULL) {
752 return; // TODO: print message
755 ViewMsg = (RoomRenderer*) vViewMsg;
757 output_headers(1, 1, 1, 0, 0, 0);
758 } else if (WCC->CurRoom.view == VIEW_MAILBOX) {
759 jsonMessageListHdr();
762 if (ViewMsg->GetParamsGetServerCall != NULL) {
763 r = ViewMsg->GetParamsGetServerCall(
778 case 300: /* the callback hook should do the work for us here, since he knows what to do. */
784 if (!IsEmptyStr(cmd))
785 Stat.nummsgs = load_msg_ptrs(cmd, &Stat, ViewMsg->LHParse);
789 memset(&SubTP, 0, sizeof(WCTemplputParams));
790 SubTP.Filter.ContextType = CTX_MAILSUM;
791 SubTP.Context = NULL;
792 SortIt = RetrieveSort(&SubTP, NULL, 0,
793 HKEY("date"), Stat.defaultsortorder);
795 SortByPayload(WCC->summ, SortIt);
797 if (Stat.startmsg < 0) {
801 if (Stat.load_seen) load_seen_flags();
804 * Print any inforation above the message list...
806 if (ViewMsg->PrintViewHeader != NULL)
807 ViewMsg->PrintViewHeader(&Stat, &ViewSpecific);
809 WCC->startmsg = Stat.startmsg;
810 WCC->maxmsgs = Stat.maxmsgs;
811 WCC->num_displayed = 0;
813 /* Put some helpful data in vars for mailsummary_json */
814 svputlong("READLOOP:TOTALMSGS", Stat.nummsgs);
815 svputlong("READLOOP:STARTMSG", Stat.startmsg);
818 * iterate over each message. if we need to load an attachment, do it here.
821 if ((ViewMsg->LoadMsgFromServer != NULL) &&
824 at = GetNewHashPos(WCC->summ, 0);
825 Stat.num_displayed = i = 0;
826 while ( GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
827 Msg = (message_summary*) vMsg;
828 if ((Msg->msgnum >= Stat.startmsg) && (Stat.num_displayed <= Stat.maxmsgs)) {
829 ViewMsg->LoadMsgFromServer(&Stat, &ViewSpecific, Msg, Msg->is_new, i);
837 * Done iterating the message list. now tasks we want to do after.
839 if (ViewMsg->RenderView_or_Tail != NULL)
840 ViewMsg->RenderView_or_Tail(&Stat, &ViewSpecific, oper);
842 if (ViewMsg->ViewCleanup != NULL)
843 ViewMsg->ViewCleanup(&ViewSpecific);
847 if (WCC->summ != NULL) {
848 DeleteHash(&WCC->summ);
854 * Back end for post_message()
855 * ... this is where the actual message gets transmitted to the server.
857 void post_mime_to_server(void) {
859 char top_boundary[SIZ];
860 char alt_boundary[SIZ];
861 int is_multipart = 0;
863 wc_mime_attachment *att;
865 size_t encoded_length;
866 size_t encoded_strlen;
867 char *txtmail = NULL;
868 int include_text_alt = 0; /* Set to nonzero to include multipart/alternative text/plain */
870 sprintf(top_boundary, "Citadel--Multipart--%s--%04x--%04x",
871 ChrPtr(WCC->serv_info->serv_fqdn),
875 sprintf(alt_boundary, "Citadel--Multipart--%s--%04x--%04x",
876 ChrPtr(WCC->serv_info->serv_fqdn),
881 /* RFC2045 requires this, and some clients look for it... */
882 serv_puts("MIME-Version: 1.0");
883 serv_puts("X-Mailer: " PACKAGE_STRING);
885 /* If there are attachments, we have to do multipart/mixed */
886 if (GetCount(WCC->attachments) > 0) {
890 /* Only do multipart/alternative for mailboxes. BBS and Wiki rooms don't need it. */
891 if (WC->CurRoom.view == VIEW_MAILBOX) {
892 include_text_alt = 1;
896 /* Remember, serv_printf() appends an extra newline */
897 serv_printf("Content-type: multipart/mixed; boundary=\"%s\"\n", top_boundary);
898 serv_printf("This is a multipart message in MIME format.\n");
899 serv_printf("--%s", top_boundary);
902 /* Remember, serv_printf() appends an extra newline */
903 if (include_text_alt) {
904 serv_printf("Content-type: multipart/alternative; "
905 "boundary=\"%s\"\n", alt_boundary);
906 serv_printf("This is a multipart message in MIME format.\n");
907 serv_printf("--%s", alt_boundary);
909 serv_puts("Content-type: text/plain; charset=utf-8");
910 serv_puts("Content-Transfer-Encoding: quoted-printable");
912 txtmail = html_to_ascii(bstr("msgtext"), 0, 80, 0);
913 text_to_server_qp(txtmail); /* Transmit message in quoted-printable encoding */
916 serv_printf("--%s", alt_boundary);
919 serv_puts("Content-type: text/html; charset=utf-8");
920 serv_puts("Content-Transfer-Encoding: quoted-printable");
922 serv_puts("<html><body>\r\n");
923 text_to_server_qp(bstr("msgtext")); /* Transmit message in quoted-printable encoding */
924 serv_puts("</body></html>\r\n");
926 if (include_text_alt) {
927 serv_printf("--%s--", alt_boundary);
936 /* Add in the attachments */
937 it = GetNewHashPos(WCC->attachments, 0);
938 while (GetNextHashPos(WCC->attachments, it, &len, &Key, &vAtt)) {
939 att = (wc_mime_attachment *)vAtt;
940 if (att->length == 0)
942 encoded_length = ((att->length * 150) / 100);
943 encoded = malloc(encoded_length);
944 if (encoded == NULL) break;
945 encoded_strlen = CtdlEncodeBase64(encoded, ChrPtr(att->Data), StrLength(att->Data), 1);
947 serv_printf("--%s", top_boundary);
948 serv_printf("Content-type: %s", ChrPtr(att->ContentType));
949 serv_printf("Content-disposition: attachment; filename=\"%s\"", ChrPtr(att->FileName));
950 serv_puts("Content-transfer-encoding: base64");
952 serv_write(encoded, encoded_strlen);
957 serv_printf("--%s--", top_boundary);
966 * Post message (or don't post message)
968 * Note regarding the "dont_post" variable:
969 * A random value (actually, it's just a timestamp) is inserted as a hidden
970 * field called "postseq" when the display_enter page is generated. This
971 * value is checked when posting, using the static variable dont_post. If a
972 * user attempts to post twice using the same dont_post value, the message is
973 * discarded. This prevents the accidental double-saving of the same message
974 * if the user happens to click the browser "back" button.
976 void post_message(void)
979 StrBuf *EmailAddress;
982 StrBuf *encoded_subject = NULL;
983 static long dont_post = (-1L);
984 wc_mime_attachment *att;
985 int is_anonymous = 0;
986 const StrBuf *display_name = NULL;
990 if (havebstr("force_room")) {
991 gotoroom(sbstr("force_room"));
994 if (havebstr("display_name")) {
995 display_name = sbstr("display_name");
996 if (!strcmp(ChrPtr(display_name), "__ANONYMOUS__")) {
1002 if (WCC->upload_length > 0) {
1009 /* There's an attachment. Save it to this struct... */
1010 lprintf(9, "Client is uploading %d bytes\n", WCC->upload_length);
1011 att = malloc(sizeof(wc_mime_attachment));
1012 memset(att, 0, sizeof(wc_mime_attachment ));
1013 att->length = WCC->upload_length;
1014 att->ContentType = NewStrBufPlain(WCC->upload_content_type, -1);
1015 att->FileName = NewStrBufDup(WCC->upload_filename);
1017 if (WCC->attachments == NULL) {
1018 WCC->attachments = NewHash(1, Flathash);
1021 /* And add it to the list. */
1023 if ((GetCount(WCC->attachments) > 0) &&
1024 GetHashAt(WCC->attachments,
1025 GetCount(WCC->attachments) -1,
1026 &newnlen, &newn, &v))
1027 n = *((int*) newn) + 1;
1028 Put(WCC->attachments, IKEY(n), att, DestroyMime);
1031 * Mozilla sends a simple filename, which is what we want,
1032 * but Satan's Browser sends an entire pathname. Reduce
1033 * the path to just a filename if we need to.
1035 pch = strrchr(ChrPtr(att->FileName), '/');
1037 StrBufCutLeft(att->FileName, pch - ChrPtr(att->FileName) + 1);
1039 pch = strrchr(ChrPtr(att->FileName), '\\');
1041 StrBufCutLeft(att->FileName, pch - ChrPtr(att->FileName) + 1);
1045 * Transfer control of this memory from the upload struct
1046 * to the attachment struct.
1048 att->Data = WCC->upload;
1050 WCC->upload_length = 0;
1055 if (havebstr("cancel_button")) {
1056 sprintf(WCC->ImportantMessage,
1057 _("Cancelled. Message was not posted."));
1058 } else if (havebstr("attach_button")) {
1061 } else if (lbstr("postseq") == dont_post) {
1062 sprintf(WCC->ImportantMessage,
1063 _("Automatically cancelled because you have already "
1064 "saved this message."));
1065 } else if (havebstr("remove_attach_button")) {
1066 /* now thats st00pit. need to find it by name. */
1068 StrBuf *WhichAttachment;
1073 WhichAttachment = NewStrBufDup(sbstr("which_attachment"));
1074 StrBufUnescape(WhichAttachment, 0);
1075 at = GetNewHashPos(WCC->attachments, 0);
1077 GetHashPos(WCC->attachments, at, &len, &key, &vAtt);
1079 att = (wc_mime_attachment*) vAtt;
1080 if ((att != NULL) &&
1081 (strcmp(ChrPtr(WhichAttachment),
1082 ChrPtr(att->FileName) ) == 0))
1084 DeleteEntryFromHash(WCC->attachments, at);
1088 while (NextHashPos(WCC->attachments, at));
1089 FreeStrBuf(&WhichAttachment);
1093 const char CMD[] = "ENT0 1|%s|%d|4|%s|%s||%s|%s|%s|%s|%s";
1094 StrBuf *Recp = NULL;
1097 const StrBuf *Wikipage = NULL;
1098 const StrBuf *my_email_addr = NULL;
1099 StrBuf *CmdBuf = NULL;
1100 StrBuf *references = NULL;
1104 save_to_drafts = havebstr("save_button");
1107 if (save_to_drafts) {
1108 /* temporarily change to the drafts room */
1109 serv_puts("GOTO _DRAFTS_");
1110 StrBuf_ServGetln(Buf);
1111 if (GetServerStatus(Buf, NULL) != 2) {
1112 /* You probably don't even have a dumb Drafts folder */
1113 StrBufCutLeft(Buf, 4);
1114 lprintf(9, "%s:%d: server save to drafts error: %s\n", __FILE__, __LINE__, ChrPtr(Buf));
1115 StrBufAppendBufPlain(WCC->ImportantMsg, _("Saved to Drafts failed: "), -1, 0);
1116 StrBufAppendBuf(WCC->ImportantMsg, Buf, 0);
1123 if (havebstr("references"))
1125 const StrBuf *ref = sbstr("references");
1126 references = NewStrBufDup(ref);
1127 if (*ChrPtr(references) == '|') { /* remove leading '|' if present */
1128 StrBufCutLeft(references, 1);
1130 StrBufReplaceChars(references, '|', '!');
1132 if (havebstr("subject")) {
1135 * make enough room for the encoded string;
1136 * plus the QP header
1138 Subj = sbstr("subject");
1140 StrBufRFC2047encode(&encoded_subject, Subj);
1142 UserName = NewStrBuf();
1143 EmailAddress = NewStrBuf();
1144 EncBuf = NewStrBuf();
1146 Recp = StrBufSanitizeEmailRecipientVector(sbstr("recp"), UserName, EmailAddress, EncBuf);
1147 Cc = StrBufSanitizeEmailRecipientVector(sbstr("cc"), UserName, EmailAddress, EncBuf);
1148 Bcc = StrBufSanitizeEmailRecipientVector(sbstr("bcc"), UserName, EmailAddress, EncBuf);
1150 FreeStrBuf(&UserName);
1151 FreeStrBuf(&EmailAddress);
1152 FreeStrBuf(&EncBuf);
1154 Wikipage = sbstr("page");
1155 my_email_addr = sbstr("my_email_addr");
1157 HeaderLen = StrLength(Recp) +
1158 StrLength(encoded_subject) +
1161 StrLength(Wikipage) +
1162 StrLength(my_email_addr) +
1163 StrLength(references);
1164 CmdBuf = NewStrBufPlain(NULL, sizeof (CMD) + HeaderLen);
1165 StrBufPrintf(CmdBuf,
1167 save_to_drafts?"":ChrPtr(Recp),
1169 ChrPtr(encoded_subject),
1170 ChrPtr(display_name),
1171 save_to_drafts?"":ChrPtr(Cc),
1172 save_to_drafts?"":ChrPtr(Bcc),
1174 ChrPtr(my_email_addr),
1175 ChrPtr(references));
1176 FreeStrBuf(&references);
1177 FreeStrBuf(&encoded_subject);
1179 if ((HeaderLen + StrLength(sbstr("msgtext")) < 10) &&
1180 (GetCount(WCC->attachments) == 0)){
1181 StrBufAppendBufPlain(WCC->ImportantMsg, _("Refusing to post empty message.\n"), -1, 0);
1182 FreeStrBuf(&CmdBuf);
1187 lprintf(9, "%s\n", ChrPtr(CmdBuf));
1188 serv_puts(ChrPtr(CmdBuf));
1189 FreeStrBuf(&CmdBuf);
1191 StrBuf_ServGetln(Buf);
1192 if (GetServerStatus(Buf, NULL) == 4) {
1193 if (save_to_drafts) {
1194 if ( (havebstr("recp"))
1195 || (havebstr("cc" ))
1196 || (havebstr("bcc" )) ) {
1197 /* save recipient headers or room to post to */
1198 serv_printf("To: %s", ChrPtr(Recp));
1199 serv_printf("Cc: %s", ChrPtr(Cc));
1200 serv_printf("Bcc: %s", ChrPtr(Bcc));
1202 serv_printf("X-Citadel-Room: %s", ChrPtr(WC->CurRoom.name));
1205 post_mime_to_server();
1206 if (save_to_drafts) {
1207 StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been saved to Drafts.\n"), -1, 0);
1208 gotoroom(WCC->CurRoom.name);
1212 } else if ( (havebstr("recp"))
1213 || (havebstr("cc" ))
1214 || (havebstr("bcc" ))
1216 StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been sent.\n"), -1, 0);
1219 StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been posted.\n"), -1, 0);
1221 dont_post = lbstr("postseq");
1223 StrBufCutLeft(Buf, 4);
1225 lprintf(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, ChrPtr(Buf));
1226 StrBufAppendBuf(WCC->ImportantMsg, Buf, 0);
1227 if (save_to_drafts) gotoroom(WCC->CurRoom.name);
1240 DeleteHash(&WCC->attachments);
1243 * We may have been supplied with instructions regarding the location
1244 * to which we must return after posting. If found, go there.
1246 if (havebstr("return_to")) {
1247 http_redirect(bstr("return_to"));
1250 * If we were editing a page in a wiki room, go to that page now.
1252 else if (havebstr("page")) {
1253 snprintf(buf, sizeof buf, "wiki?page=%s", bstr("page"));
1257 * Otherwise, just go to the "read messages" loop.
1260 readloop(readnew, eUseDefault);
1268 * display the message entry screen
1270 void display_enter(void)
1274 const StrBuf *display_name = NULL;
1275 int recipient_required = 0;
1276 int subject_required = 0;
1277 int recipient_bad = 0;
1278 int is_anonymous = 0;
1279 wcsession *WCC = WC;
1283 if (havebstr("force_room")) {
1284 gotoroom(sbstr("force_room"));
1287 display_name = sbstr("display_name");
1288 if (!strcmp(ChrPtr(display_name), "__ANONYMOUS__")) {
1289 display_name = NULL;
1293 /* First test to see whether this is a room that requires recipients to be entered */
1294 serv_puts("ENT0 0");
1295 serv_getln(buf, sizeof buf);
1297 if (!strncmp(buf, "570", 3)) { /* 570 means that we need a recipient here */
1298 recipient_required = 1;
1300 else if (buf[0] != '2') { /* Any other error means that we cannot continue */
1301 sprintf(WCC->ImportantMessage, "%s", &buf[4]);
1302 readloop(readnew, eUseDefault);
1306 /* Is the server strongly recommending that the user enter a message subject? */
1307 if ((buf[3] != '\0') && (buf[4] != '\0')) {
1308 subject_required = extract_int(&buf[4], 1);
1312 * Are we perhaps in an address book view? If so, then an "enter
1313 * message" command really means "add new entry."
1315 if (WCC->CurRoom.defview == VIEW_ADDRESSBOOK) {
1316 do_edit_vcard(-1, "", NULL, NULL, "", ChrPtr(WCC->CurRoom.name));
1321 * Are we perhaps in a calendar room? If so, then an "enter
1322 * message" command really means "add new calendar item."
1324 if (WCC->CurRoom.defview == VIEW_CALENDAR) {
1325 display_edit_event();
1330 * Are we perhaps in a tasks view? If so, then an "enter
1331 * message" command really means "add new task."
1333 if (WCC->CurRoom.defview == VIEW_TASKS) {
1334 display_edit_task();
1339 * Otherwise proceed normally.
1340 * Do a custom room banner with no navbar...
1343 if (recipient_required) {
1344 const StrBuf *Recp = NULL;
1345 const StrBuf *Cc = NULL;
1346 const StrBuf *Bcc = NULL;
1347 const StrBuf *Wikipage = NULL;
1348 StrBuf *CmdBuf = NULL;
1349 const char CMD[] = "ENT0 0|%s|%d|0||%s||%s|%s|%s";
1351 Recp = sbstr("recp");
1354 Wikipage = sbstr("page");
1356 CmdBuf = NewStrBufPlain(NULL,
1359 StrLength(display_name) +
1362 StrLength(Wikipage));
1364 StrBufPrintf(CmdBuf,
1368 ChrPtr(display_name),
1372 serv_puts(ChrPtr(CmdBuf));
1373 serv_getln(buf, sizeof buf);
1374 FreeStrBuf(&CmdBuf);
1376 if (!strncmp(buf, "570", 3)) { /* 570 means we have an invalid recipient listed */
1377 if (havebstr("recp") &&
1383 else if (buf[0] != '2') { /* Any other error means that we cannot continue */
1384 wc_printf("<em>%s</em><br />\n", &buf[4]); /* TODO -> important message */
1388 svputlong("RCPTREQUIRED", recipient_required);
1389 svputlong("SUBJREQUIRED", recipient_required || subject_required);
1392 output_headers(1, 0, 0, 0, 1, 0);
1393 DoTemplate(HKEY("edit_message"), NULL, &NoCtx);
1402 void delete_msg(void)
1407 msgid = lbstr("msgid");
1409 if ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0) { /* Delete from Trash is a real delete */
1410 serv_printf("DELE %ld", msgid);
1412 else { /* Otherwise move it to Trash */
1413 serv_printf("MOVE %ld|_TRASH_|0", msgid);
1416 serv_getln(buf, sizeof buf);
1417 sprintf(WC->ImportantMessage, "%s", &buf[4]);
1418 readloop(readnew, eUseDefault);
1423 * move a message to another room
1430 msgid = lbstr("msgid");
1432 if (havebstr("move_button")) {
1433 sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
1435 serv_getln(buf, sizeof buf);
1436 sprintf(WC->ImportantMessage, "%s", &buf[4]);
1438 sprintf(WC->ImportantMessage, (_("The message was not moved.")));
1441 readloop(readnew, eUseDefault);
1446 * Confirm move of a message
1448 void confirm_move_msg(void)
1454 msgid = lbstr("msgid");
1457 output_headers(1, 1, 2, 0, 0, 0);
1458 wc_printf("<div id=\"banner\">\n");
1460 wc_printf(_("Confirm move of message"));
1462 wc_printf("</div>\n");
1464 wc_printf("<div id=\"content\" class=\"service\">\n");
1466 wc_printf("<CENTER>");
1468 wc_printf(_("Move this message to:"));
1469 wc_printf("<br />\n");
1471 wc_printf("<form METHOD=\"POST\" action=\"move_msg\">\n");
1472 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1473 wc_printf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n", bstr("msgid"));
1475 wc_printf("<SELECT NAME=\"target_room\" SIZE=5>\n");
1477 serv_getln(buf, sizeof buf);
1478 if (buf[0] == '1') {
1479 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1480 extract_token(targ, buf, 0, '|', sizeof targ);
1481 wc_printf("<OPTION>");
1486 wc_printf("</SELECT>\n");
1487 wc_printf("<br />\n");
1489 wc_printf("<INPUT TYPE=\"submit\" NAME=\"move_button\" VALUE=\"%s\">", _("Move"));
1490 wc_printf(" ");
1491 wc_printf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1492 wc_printf("</form></CENTER>\n");
1494 wc_printf("</CENTER>\n");
1500 * Generic function to output an arbitrary MIME attachment from
1501 * message being composed
1503 * partnum The MIME part to be output
1504 * filename Fake filename to give
1505 * force_download Nonzero to force set the Content-Type: header to "application/octet-stream"
1507 void postpart(StrBuf *partnum, StrBuf *filename, int force_download)
1510 StrBuf *content_type;
1511 wc_mime_attachment *part;
1514 i = StrToi(partnum);
1515 if (GetHash(WC->attachments, IKEY(i), &vPart) &&
1517 part = (wc_mime_attachment*) vPart;
1518 if (force_download) {
1519 content_type = NewStrBufPlain(HKEY("application/octet-stream"));
1522 content_type = NewStrBufDup(part->ContentType);
1524 StrBufAppendBuf(WC->WBuf, part->Data, 0);
1525 http_transmit_thing(ChrPtr(content_type), 0);
1527 hprintf("HTTP/1.1 404 %s\n", ChrPtr(partnum));
1528 output_headers(0, 0, 0, 0, 0, 0);
1529 hprintf("Content-Type: text/plain\r\n");
1531 wc_printf(_("An error occurred while retrieving this part: %s/%s\n"),
1532 ChrPtr(partnum), ChrPtr(filename));
1535 FreeStrBuf(&content_type);
1540 * Generic function to output an arbitrary MIME part from an arbitrary
1541 * message number on the server.
1543 * msgnum Number of the item on the citadel server
1544 * partnum The MIME part to be output
1545 * force_download Nonzero to force set the Content-Type: header to "application/octet-stream"
1547 void mimepart(int force_download)
1551 wcsession *WCC = WC;
1554 StrBuf *ContentType = NewStrBufPlain(HKEY("application/octet-stream"));
1557 att = Buf = NewStrBuf();
1558 msgnum = StrBufExtract_long(WCC->Hdr->HR.ReqLine, 0, '/');
1559 StrBufExtract_token(att, WCC->Hdr->HR.ReqLine, 1, '/');
1561 serv_printf("OPNA %ld|%s", msgnum, ChrPtr(att));
1562 StrBuf_ServGetln(Buf);
1563 if (GetServerStatus(Buf, NULL) == 2) {
1564 StrBufCutLeft(Buf, 4);
1565 bytes = StrBufExtract_long(Buf, 0, '|');
1566 if (!force_download) {
1567 StrBufExtract_token(ContentType, Buf, 3, '|');
1570 serv_read_binary(WCC->WBuf, bytes, Buf);
1572 StrBuf_ServGetln(Buf);
1573 CT = ChrPtr(ContentType);
1575 if (!force_download) {
1576 if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) {
1577 StrBufExtract_token(Buf, WCC->Hdr->HR.ReqLine, 2, '/');
1578 CT = GuessMimeByFilename(SKEY(Buf));
1580 if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) {
1581 CT = GuessMimeType(SKEY(WCC->WBuf));
1584 http_transmit_thing(CT, 0);
1586 StrBufCutLeft(Buf, 4);
1587 hprintf("HTTP/1.1 404 %s\n", ChrPtr(Buf));
1588 output_headers(0, 0, 0, 0, 0, 0);
1589 hprintf("Content-Type: text/plain\r\n");
1591 wc_printf(_("An error occurred while retrieving this part: %s\n"),
1595 FreeStrBuf(&ContentType);
1601 * Read any MIME part of a message, from the server, into memory.
1603 StrBuf *load_mimepart(long msgnum, char *partnum)
1609 serv_printf("DLAT %ld|%s", msgnum, partnum);
1610 StrBuf_ServGetln(Buf);
1611 if (GetServerStatus(Buf, NULL) == 6) {
1612 StrBufCutLeft(Buf, 4);
1613 bytes = StrBufExtract_long(Buf, 0, '|');
1616 StrBuf_ServGetBLOBBuffered(Buf, bytes);
1626 * Read any MIME part of a message, from the server, into memory.
1628 void MimeLoadData(wc_mime_attachment *Mime)
1633 /* TODO: is there a chance the content type is different from the one we know? */
1635 serv_printf("DLAT %ld|%s", Mime->msgnum, ChrPtr(Mime->PartNum));
1637 StrBuf_ServGetln(Buf);
1638 if (GetServerStatus(Buf, NULL) == 6) {
1639 Ptr = &(ChrPtr(Buf)[4]);
1640 bytes = StrBufExtractNext_long(Buf, &Ptr, '|');
1641 StrBufSkip_NTokenS(Buf, &Ptr, '|', 3); /* filename, cbtype, mimetype */
1642 if (Mime->Charset == NULL) Mime->Charset = NewStrBuf();
1643 StrBufExtract_NextToken(Mime->Charset, Buf, &Ptr, '|');
1645 if (Mime->Data == NULL)
1646 Mime->Data = NewStrBufPlain(NULL, bytes);
1647 StrBuf_ServGetBLOBBuffered(Mime->Data, bytes);
1650 FlushStrBuf(Mime->Data);
1651 /* TODO XImportant message */
1659 void view_mimepart(void) {
1663 void download_mimepart(void) {
1667 void view_postpart(void) {
1668 StrBuf *filename = NewStrBuf();
1669 StrBuf *partnum = NewStrBuf();
1671 StrBufExtract_token(partnum, WC->Hdr->HR.ReqLine, 0, '/');
1672 StrBufExtract_token(filename, WC->Hdr->HR.ReqLine, 1, '/');
1674 postpart(partnum, filename, 0);
1676 FreeStrBuf(&filename);
1677 FreeStrBuf(&partnum);
1680 void download_postpart(void) {
1681 StrBuf *filename = NewStrBuf();
1682 StrBuf *partnum = NewStrBuf();
1684 StrBufExtract_token(partnum, WC->Hdr->HR.ReqLine, 0, '/');
1685 StrBufExtract_token(filename, WC->Hdr->HR.ReqLine, 1, '/');
1687 postpart(partnum, filename, 1);
1689 FreeStrBuf(&filename);
1690 FreeStrBuf(&partnum);
1693 void h_readnew(void) { readloop(readnew, eUseDefault);}
1694 void h_readold(void) { readloop(readold, eUseDefault);}
1695 void h_readfwd(void) { readloop(readfwd, eUseDefault);}
1696 void h_headers(void) { readloop(headers, eUseDefault);}
1697 void h_do_search(void) { readloop(do_search, eUseDefault);}
1698 void h_readgt(void) { readloop(readgt, eUseDefault);}
1699 void h_readlt(void) { readloop(readlt, eUseDefault);}
1701 void jsonMessageListHdr(void)
1703 /* TODO: make a generic function */
1704 hprintf("HTTP/1.1 200 OK\r\n");
1705 hprintf("Content-type: application/json; charset=utf-8\r\n");
1706 hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
1707 hprintf("Connection: close\r\n");
1708 hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n");
1713 /* Output message list in JSON format */
1714 void jsonMessageList(void) {
1715 const StrBuf *room = sbstr("room");
1716 long oper = (havebstr("query")) ? do_search : readnew;
1719 readloop(oper, eUseDefault);
1723 void RegisterReadLoopHandlerset(
1725 GetParamsGetServerCall_func GetParamsGetServerCall,
1726 PrintViewHeader_func PrintViewHeader,
1727 load_msg_ptrs_detailheaders LH,
1728 LoadMsgFromServer_func LoadMsgFromServer,
1729 RenderView_or_Tail_func RenderView_or_Tail,
1730 View_Cleanup_func ViewCleanup
1733 RoomRenderer *Handler;
1735 Handler = (RoomRenderer*) malloc(sizeof(RoomRenderer));
1737 Handler->RoomType = RoomType;
1738 Handler->GetParamsGetServerCall = GetParamsGetServerCall;
1739 Handler->PrintViewHeader = PrintViewHeader;
1740 Handler->LoadMsgFromServer = LoadMsgFromServer;
1741 Handler->RenderView_or_Tail = RenderView_or_Tail;
1742 Handler->ViewCleanup = ViewCleanup;
1743 Handler->LHParse = LH;
1745 Put(ReadLoopHandler, IKEY(RoomType), Handler, NULL);
1752 RegisterPreference("use_sig",
1753 _("Attach signature to email messages?"),
1756 RegisterPreference("signature", _("Use this signature:"), PRF_QP_STRING, NULL);
1757 RegisterPreference("default_header_charset",
1758 _("Default character set for email headers:"),
1761 RegisterPreference("defaultfrom", _("Preferred email address"), PRF_STRING, NULL);
1762 RegisterPreference("defaultname",
1763 _("Preferred display name for email messages"),
1766 RegisterPreference("defaulthandle",
1767 _("Preferred display name for bulletin board posts"),
1770 RegisterPreference("mailbox",_("Mailbox view mode"), PRF_STRING, NULL);
1772 WebcitAddUrlHandler(HKEY("readnew"), "", 0, h_readnew, NEED_URL);
1773 WebcitAddUrlHandler(HKEY("readold"), "", 0, h_readold, NEED_URL);
1774 WebcitAddUrlHandler(HKEY("readfwd"), "", 0, h_readfwd, NEED_URL);
1775 WebcitAddUrlHandler(HKEY("headers"), "", 0, h_headers, NEED_URL);
1776 WebcitAddUrlHandler(HKEY("readgt"), "", 0, h_readgt, NEED_URL);
1777 WebcitAddUrlHandler(HKEY("readlt"), "", 0, h_readlt, NEED_URL);
1778 WebcitAddUrlHandler(HKEY("do_search"), "", 0, h_do_search, 0);
1779 WebcitAddUrlHandler(HKEY("display_enter"), "", 0, display_enter, 0);
1780 WebcitAddUrlHandler(HKEY("post"), "", 0, post_message, PROHIBIT_STARTPAGE);
1781 WebcitAddUrlHandler(HKEY("move_msg"), "", 0, move_msg, PROHIBIT_STARTPAGE);
1782 WebcitAddUrlHandler(HKEY("delete_msg"), "", 0, delete_msg, PROHIBIT_STARTPAGE);
1783 WebcitAddUrlHandler(HKEY("confirm_move_msg"), "", 0, confirm_move_msg, PROHIBIT_STARTPAGE);
1784 WebcitAddUrlHandler(HKEY("msg"), "", 0, embed_message, NEED_URL);
1785 WebcitAddUrlHandler(HKEY("message"), "", 0, handle_one_message, NEED_URL|XHTTP_COMMANDS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
1786 WebcitAddUrlHandler(HKEY("printmsg"), "", 0, print_message, NEED_URL);
1787 WebcitAddUrlHandler(HKEY("mobilemsg"), "", 0, mobile_message_view, NEED_URL);
1788 WebcitAddUrlHandler(HKEY("msgheaders"), "", 0, display_headers, NEED_URL);
1790 WebcitAddUrlHandler(HKEY("mimepart"), "", 0, view_mimepart, NEED_URL);
1791 WebcitAddUrlHandler(HKEY("mimepart_download"), "", 0, download_mimepart, NEED_URL);
1792 WebcitAddUrlHandler(HKEY("postpart"), "", 0, view_postpart, NEED_URL|PROHIBIT_STARTPAGE);
1793 WebcitAddUrlHandler(HKEY("postpart_download"), "", 0, download_postpart, NEED_URL|PROHIBIT_STARTPAGE);
1796 WebcitAddUrlHandler(HKEY("roommsgs"), "", 0, jsonMessageList,0);
1801 SessionDetachModule_MSG
1804 DeleteHash(&sess->summ);