4 * Functions which deal with the fetching and displaying of messages.
12 HashList *MsgHeaderHandler = NULL;
13 HashList *MsgEvaluators = NULL;
14 HashList *MimeRenderHandler = NULL;
16 #define SUBJ_COL_WIDTH_PCT 50 /**< Mailbox view column width */
17 #define SENDER_COL_WIDTH_PCT 30 /**< Mailbox view column width */
18 #define DATE_PLUS_BUTTONS_WIDTH_PCT 20 /**< Mailbox view column width */
22 void display_enter(void);
23 int longcmp_r(const void *s1, const void *s2);
24 int summcmp_subj(const void *s1, const void *s2);
25 int summcmp_rsubj(const void *s1, const void *s2);
26 int summcmp_sender(const void *s1, const void *s2);
27 int summcmp_rsender(const void *s1, const void *s2);
28 int summcmp_date(const void *s1, const void *s2);
29 int summcmp_rdate(const void *s1, const void *s2);
31 /*----------------------------------------------------------------------------*/
34 typedef void (*MsgPartEvaluatorFunc)(message_summary *Sum, StrBuf *Buf);
38 const char* SortIcons[3] = {
39 "static/up_pointer.gif",
40 "static/down_pointer.gif",
41 "static/sort_none.gif"
55 /* SortEnum to plain string representation */
56 static const char* SortByStrings[] = {
67 /* SortEnum to sort-Function Table */
68 const CompareFunc SortFuncs[eUnSet] = {
78 /* given a SortEnum, which icon should we choose? */
79 const int SortDateToIcon[eUnSet] = { eUp, eDown, eNone, eNone, eNone, eNone, eNone};
80 const int SortSubjectToIcon[eUnSet] = { eNone, eNone, eUp, eDown, eNone, eNone, eNone};
81 const int SortSenderToIcon[eUnSet] = { eNone, eNone, eNone, eNone, eUp, eDown, eNone};
83 /* given a SortEnum, which would be the "opposite" search option? */
84 const int DateInvertSortString[eUnSet] = { eRDate, eDate, eDate, eDate, eDate, eDate, eDate};
85 const int SubjectInvertSortString[eUnSet] = { eSubject, eSubject, eRSubject, eUnSet, eSubject, eSubject, eSubject};
86 const int SenderInvertSortString[eUnSet] = { eSender, eSender, eSender, eSender, eRSender, eUnSet, eSender};
90 /*----------------------------------------------------------------------------*/
93 * Translates sortoption String to its SortEnum representation
94 * returns the enum matching the string; defaults to RDate
97 int StrToESort (const StrBuf *sortby)
101 if (!IsEmptyStr(ChrPtr(sortby))) while (result < eUnSet){
102 if (!strcasecmp(ChrPtr(sortby),
103 SortByStrings[result]))
111 typedef int (*QSortFunction) (const void*, const void*);
114 * qsort() compatible function to compare two longs in descending order.
116 int longcmp_r(const void *s1, const void *s2) {
120 l1 = *(long *)GetSearchPayload(s1);
121 l2 = *(long *)GetSearchPayload(s2);
123 if (l1 > l2) return(-1);
124 if (l1 < l2) return(+1);
129 * qsort() compatible function to compare two longs in descending order.
131 int qlongcmp_r(const void *s1, const void *s2) {
135 if (l1 > l2) return(-1);
136 if (l1 < l2) return(+1);
142 * qsort() compatible function to compare two message summary structs by ascending subject.
144 int summcmp_subj(const void *s1, const void *s2) {
145 message_summary *summ1;
146 message_summary *summ2;
148 summ1 = (message_summary *)GetSearchPayload(s1);
149 summ2 = (message_summary *)GetSearchPayload(s2);
150 return strcasecmp(ChrPtr(summ1->subj), ChrPtr(summ2->subj));
154 * qsort() compatible function to compare two message summary structs by descending subject.
156 int summcmp_rsubj(const void *s1, const void *s2) {
157 message_summary *summ1;
158 message_summary *summ2;
160 summ1 = (message_summary *)GetSearchPayload(s1);
161 summ2 = (message_summary *)GetSearchPayload(s2);
162 return strcasecmp(ChrPtr(summ2->subj), ChrPtr(summ1->subj));
166 * qsort() compatible function to compare two message summary structs by ascending sender.
168 int summcmp_sender(const void *s1, const void *s2) {
169 message_summary *summ1;
170 message_summary *summ2;
172 summ1 = (message_summary *)GetSearchPayload(s1);
173 summ2 = (message_summary *)GetSearchPayload(s2);
174 return strcasecmp(ChrPtr(summ1->from), ChrPtr(summ2->from));
178 * qsort() compatible function to compare two message summary structs by descending sender.
180 int summcmp_rsender(const void *s1, const void *s2) {
181 message_summary *summ1;
182 message_summary *summ2;
184 summ1 = (message_summary *)GetSearchPayload(s1);
185 summ2 = (message_summary *)GetSearchPayload(s2);
186 return strcasecmp(ChrPtr(summ2->from), ChrPtr(summ1->from));
190 * qsort() compatible function to compare two message summary structs by ascending date.
192 int summcmp_date(const void *s1, const void *s2) {
193 message_summary *summ1;
194 message_summary *summ2;
196 summ1 = (message_summary *)GetSearchPayload(s1);
197 summ2 = (message_summary *)GetSearchPayload(s2);
199 if (summ1->date < summ2->date) return -1;
200 else if (summ1->date > summ2->date) return +1;
205 * qsort() compatible function to compare two message summary structs by descending date.
207 int summcmp_rdate(const void *s1, const void *s2) {
208 message_summary *summ1;
209 message_summary *summ2;
211 summ1 = (message_summary *)GetSearchPayload(s1);
212 summ2 = (message_summary *)GetSearchPayload(s2);
214 if (summ1->date < summ2->date) return +1;
215 else if (summ1->date > summ2->date) return -1;
225 * I wanna SEE that message!
227 * msgnum Message number to display
228 * printable_view Nonzero to display a printable view
229 * section Optional for encapsulated message/rfc822 submessage
231 int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, int printable_view, const StrBuf *PartNum) {
234 StrBuf *FoundCharset;
237 message_summary *Msg = NULL;
241 // char mime_submessages[256] = "";
242 char reply_references[1024] = "";
249 lprintf(1, "----------%s---------MSG4 %ld|%s--------------\n", tmpl, msgnum, ChrPtr(PartNum));
250 serv_printf("MSG4 %ld|%s", msgnum, ChrPtr(PartNum));
251 StrBuf_ServGetln(Buf);
252 if (GetServerStatus(Buf, NULL) != 1) {
253 StrBufAppendPrintf(Target, "<strong>");
254 StrBufAppendPrintf(Target, _("ERROR:"));
255 StrBufAppendPrintf(Target, "</strong> %s<br />\n", &buf[4]);
260 /** begin everythingamundo table */
263 HdrToken = NewStrBuf();
264 Msg = (message_summary *)malloc(sizeof(message_summary));
265 memset(Msg, 0, sizeof(message_summary));
266 Msg->msgnum = msgnum;
267 Msg->PartNum = PartNum;
268 Msg->MsgBody = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
269 memset(Msg->MsgBody, 0, sizeof(wc_mime_attachment));
270 FoundCharset = NewStrBuf();
271 while ((StrBuf_ServGetln(Buf)>=0) && !Done) {
272 if ( (StrLength(Buf)==3) &&
273 !strcmp(ChrPtr(Buf), "000"))
277 lprintf(1, _("unexpected end of message"));
278 StrBufAppendPrintf(Target, "<i>");
279 StrBufAppendPrintf(Target, _("unexpected end of message"));
280 StrBufAppendPrintf(Target, " (1)</i><br /><br />\n");
281 StrBufAppendPrintf(Target, "</div>\n");
283 FreeStrBuf(&HdrToken);
284 DestroyMessageSummary(Msg);
285 FreeStrBuf(&FoundCharset);
293 case 0:/* Citadel Message Headers */
294 if (StrLength(Buf) == 0) {
298 StrBufExtract_token(HdrToken, Buf, 0, '=');
299 StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
301 lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf));
302 if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
304 Hdr = (headereval*)vHdr;
305 Hdr->evaluator(Msg, Buf, FoundCharset);
306 if (Hdr->Type == 1) {
310 else lprintf(1, "don't know how to handle message header[%s]\n", ChrPtr(HdrToken));
312 case 1:/* Message Mime Header */
313 if (StrLength(Buf) == 0) {
315 if (Msg->MsgBody->ContentType == NULL)
316 /* end of header or no header? */
317 Msg->MsgBody->ContentType = NewStrBufPlain(HKEY("text/plain"));
318 /* usual end of mime header */
322 StrBufExtract_token(HdrToken, Buf, 0, ':');
323 if (StrLength(HdrToken) > 0) {
324 StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
325 lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf));
326 if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
328 Hdr = (headereval*)vHdr;
329 Hdr->evaluator(Msg, Buf, FoundCharset);
334 case 2: /* Message Body */
336 if (Msg->MsgBody->size_known > 0) {
337 StrBuf_ServGetBLOB(Msg->MsgBody->Data, Msg->MsgBody->length);
339 /// todo: check next line, if not 000, append following lines
342 if (StrLength(Msg->MsgBody->Data) > 0)
343 StrBufAppendBufPlain(Msg->MsgBody->Data, "\n", 1, 0);
344 StrBufAppendBuf(Msg->MsgBody->Data, Buf, 0);
348 StrBufAppendBuf(Msg->MsgBody->Data, Buf, 0);
353 if (Msg->AllAttach == NULL)
354 Msg->AllAttach = NewHash(1,NULL);
355 Put(Msg->AllAttach, SKEY(Msg->MsgBody->PartNum), Msg->MsgBody, DestroyMime);
358 /* strip the bare contenttype, so we ommit charset etc. */
359 StrBufExtract_token(Buf, Msg->MsgBody->ContentType, 0, ';');
361 if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
363 RenderMimeFunc Render;
364 Render = (RenderMimeFunc)vHdr;
365 Render(Msg->MsgBody, NULL, FoundCharset);
368 if (StrLength(Msg->reply_references)> 0) {
369 /* Trim down excessively long lists of thread references. We eliminate the
370 * second one in the list so that the thread root remains intact.
372 int rrtok = num_tokens(ChrPtr(Msg->reply_references), '|');
373 int rrlen = StrLength(Msg->reply_references);
374 if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
375 remove_token(reply_references, 1, '|');////todo
379 /* Generate a reply-to address */
380 if (StrLength(Msg->Rfca) > 0) {
381 if (Msg->reply_to == NULL)
382 Msg->reply_to = NewStrBuf();
383 if (StrLength(Msg->from) > 0) {
384 StrBufPrintf(Msg->reply_to, "%s <%s>", ChrPtr(Msg->from), ChrPtr(Msg->Rfca));
387 FlushStrBuf(Msg->reply_to);
388 StrBufAppendBuf(Msg->reply_to, Msg->Rfca, 0);
393 if ((StrLength(Msg->OtherNode)>0) &&
394 (strcasecmp(ChrPtr(Msg->OtherNode), serv_info.serv_nodename)) &&
395 (strcasecmp(ChrPtr(Msg->OtherNode), serv_info.serv_humannode)) )
397 if (Msg->reply_to == NULL)
398 Msg->reply_to = NewStrBuf();
399 StrBufPrintf(Msg->reply_to,
402 ChrPtr(Msg->OtherNode));
405 if (Msg->reply_to == NULL)
406 Msg->reply_to = NewStrBuf();
407 FlushStrBuf(Msg->reply_to);
408 StrBufAppendBuf(Msg->reply_to, Msg->from, 0);
411 it = GetNewHashPos();
412 while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) &&
414 wc_mime_attachment *Mime = (wc_mime_attachment*) vMime;
415 evaluate_mime_part(Msg, Mime);
419 DoTemplate(tmpl, tmpllen, Target, Msg, CTX_MAILSUM);
421 DestroyMessageSummary(Msg);
422 FreeStrBuf(&FoundCharset);
423 FreeStrBuf(&HdrToken);
431 * Unadorned HTML output of an individual message, suitable
432 * for placing in a hidden iframe, for printing, or whatever
434 * msgnum_as_string == Message number, as a string instead of as a long int
436 void embed_message(void) {
438 const StrBuf *Tmpl = sbstr("template");
440 msgnum = StrTol(WC->UrlFragment1);
441 if (StrLength(Tmpl) > 0)
442 read_message(WC->WBuf, SKEY(Tmpl), msgnum, 0, NULL);
444 read_message(WC->WBuf, HKEY("view_message"), msgnum, 0, NULL);
449 * Printable view of a message
451 * msgnum_as_string == Message number, as a string instead of as a long int
453 void print_message(void) {
456 msgnum = StrTol(WC->UrlFragment1);
457 output_headers(0, 0, 0, 0, 0, 0);
459 hprintf("Content-type: text/html\r\n"
460 "Server: " PACKAGE_STRING "\r\n"
461 "Connection: close\r\n");
465 read_message(WC->WBuf, HKEY("view_message_print"), msgnum, 1, NULL);
471 * Mobile browser view of message
473 * @param msg_num_as_string Message number as a string instead of as a long int
475 void mobile_message_view(void) {
477 msgnum = StrTol(WC->UrlFragment1);
478 output_headers(1, 0, 0, 0, 0, 1);
480 do_template("msgcontrols", NULL);
481 read_message(WC->WBuf, HKEY("view_message"), msgnum,1, NULL);
486 * \brief Display a message's headers
488 * \param msgnum_as_string Message number, as a string instead of as a long int
490 void display_headers(void) {
494 msgnum = StrTol(WC->UrlFragment1);
495 output_headers(0, 0, 0, 0, 0, 0);
497 hprintf("Content-type: text/plain\r\n"
499 "Connection: close\r\n",
503 serv_printf("MSG2 %ld|3", msgnum);
504 serv_getln(buf, sizeof buf);
506 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
507 wprintf("%s\n", buf);
517 * \brief Read message in simple, JavaScript-embeddable form for 'forward'
518 * or 'reply quoted' operations.
520 * NOTE: it is VITALLY IMPORTANT that we output no single-quotes or linebreaks
521 * in this function. Doing so would throw a JavaScript error in the
522 * 'supplied text' argument to the editor.
524 * \param msgnum Message number of the message we want to quote
525 * \param forward_attachments Nonzero if we want attachments to be forwarded
527 void pullquote_message(long msgnum, int forward_attachments, int include_headers) {
528 struct wcsession *WCC = WC;
530 char mime_partnum[256];
531 char mime_filename[256];
532 char mime_content_type[256];
533 char mime_charset[256];
534 char mime_disposition[256];
536 char *attachments = NULL;
538 int num_attachments = 0;
540 char m_subject[1024];
552 iconv_t ic = (iconv_t)(-1) ;
553 char *ibuf; /**< Buffer of characters to be converted */
554 char *obuf; /**< Buffer for converted characters */
555 size_t ibuflen; /**< Length of input buffer */
556 size_t obuflen; /**< Length of output buffer */
557 char *osav; /**< Saved pointer to output buffer */
563 strcpy(reply_to, "");
564 strcpy(mime_content_type, "text/plain");
565 strcpy(mime_charset, "us-ascii");
567 serv_printf("MSG4 %ld", msgnum);
568 serv_getln(buf, sizeof buf);
570 wprintf(_("ERROR:"));
571 wprintf("%s<br />", &buf[4]);
575 strcpy(m_subject, "");
577 while (serv_getln(buf, sizeof buf), strcasecmp(buf, "text")) {
578 if (!strcmp(buf, "000")) {
579 wprintf("%s (3)", _("unexpected end of message"));
582 if (include_headers) {
583 if (!strncasecmp(buf, "nhdr=yes", 8))
587 if (!strncasecmp(buf, "type=", 5))
588 format_type = atoi(&buf[5]);
589 if (!strncasecmp(buf, "from=", 5)) {
590 strcpy(from, &buf[5]);
592 utf8ify_rfc822_string(from);
595 if (!strncasecmp(buf, "subj=", 5)) {
596 strcpy(m_subject, &buf[5]);
598 if ((!strncasecmp(buf, "hnod=", 5))
599 && (strcasecmp(&buf[5], serv_info.serv_humannode))) {
600 wprintf("(%s) ", &buf[5]);
602 if ((!strncasecmp(buf, "room=", 5))
603 && (strcasecmp(&buf[5], WC->wc_roomname))
604 && (!IsEmptyStr(&buf[5])) ) {
606 wprintf("%s> ", &buf[5]);
608 if (!strncasecmp(buf, "rfca=", 5)) {
609 strcpy(rfca, &buf[5]);
614 if (!strncasecmp(buf, "node=", 5)) {
615 strcpy(node, &buf[5]);
616 if ( ((WC->room_flags & QR_NETWORK)
617 || ((strcasecmp(&buf[5], serv_info.serv_nodename)
618 && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
619 && (IsEmptyStr(rfca))
621 wprintf("@%s ", &buf[5]);
624 if (!strncasecmp(buf, "rcpt=", 5)) {
627 utf8ify_rfc822_string(to);
630 if (!strncasecmp(buf, "time=", 5)) {
631 webcit_fmt_date(now, atol(&buf[5]), 0);
637 * Save attachment info for later. We can't start downloading them
638 * yet because we're in the middle of a server transaction.
640 if (!strncasecmp(buf, "part=", 5)) {
641 ptr = malloc( (strlen(buf) + ((attachments != NULL) ? strlen(attachments) : 0)) ) ;
644 sprintf(ptr, "%s%s\n",
645 ((attachments != NULL) ? attachments : ""),
650 lprintf(9, "attachments=<%s>\n", attachments);
656 if (include_headers) {
659 utf8ify_rfc822_string(m_subject);
660 if (!IsEmptyStr(m_subject)) {
661 wprintf(_("Subject:"));
663 msgescputs(m_subject);
674 * Learn the content type
676 strcpy(mime_content_type, "text/plain");
677 while (serv_getln(buf, sizeof buf), (!IsEmptyStr(buf))) {
678 if (!strcmp(buf, "000")) {
679 wprintf("%s (4)", _("unexpected end of message"));
682 if (!strncasecmp(buf, "Content-type: ", 14)) {
684 safestrncpy(mime_content_type, &buf[14],
685 sizeof(mime_content_type));
686 for (i=0; i<strlen(mime_content_type); ++i) {
687 if (!strncasecmp(&mime_content_type[i], "charset=", 8)) {
688 safestrncpy(mime_charset, &mime_content_type[i+8],
689 sizeof mime_charset);
692 len = strlen(mime_content_type);
693 for (i=0; i<len; ++i) {
694 if (mime_content_type[i] == ';') {
695 mime_content_type[i] = 0;
699 len = strlen(mime_charset);
700 for (i=0; i<len; ++i) {
701 if (mime_charset[i] == ';') {
709 /** Set up a character set conversion if we need to (and if we can) */
711 if ( (strcasecmp(mime_charset, "us-ascii"))
712 && (strcasecmp(mime_charset, "UTF-8"))
713 && (strcasecmp(mime_charset, ""))
715 ctdl_iconv_open("UTF-8", mime_charset, &ic);
716 if (ic == (iconv_t)(-1) ) {
717 lprintf(5, "%s:%d iconv_open(%s, %s) failed: %s\n",
718 __FILE__, __LINE__, "UTF-8", mime_charset, strerror(errno));
723 /** Messages in legacy Citadel variformat get handled thusly... */
724 if (!strcasecmp(mime_content_type, "text/x-citadel-variformat")) {
728 /* Boring old 80-column fixed format text gets handled this way... */
729 else if (!strcasecmp(mime_content_type, "text/plain")) {
730 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
733 if ((len > 0) && (buf[len-1] == '\n')) buf[--len] = 0;
734 if ((len > 0) && (buf[len-1] == '\r')) buf[--len] = 0;
737 if (ic != (iconv_t)(-1) ) {
741 obuf = (char *) malloc(obuflen);
743 iconv(ic, &ibuf, &ibuflen, &obuf, &obuflen);
744 osav[SIZ-obuflen] = 0;
745 safestrncpy(buf, osav, sizeof buf);
751 while ((!IsEmptyStr(buf)) && (isspace(buf[len - 1])))
754 ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) )) {
755 wprintf("<blockquote>");
757 } else if ((bq == 1) &&
758 (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) ) {
759 wprintf("</blockquote>");
763 url(buf, sizeof(buf));
765 wprintf("</tt><br />");
767 wprintf("</i><br />");
770 /** HTML just gets escaped and stuffed back into the editor */
771 else if (!strcasecmp(mime_content_type, "text/html")) {
772 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
776 }//// TODO: charset? utf8?
778 /** Unknown weirdness ... don't know how to handle this content type */
780 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { }
784 /** end of body handler */
787 * If there were attachments, we have to download them and insert them
788 * into the attachment chain for the forwarded message we are composing.
790 if ( (forward_attachments) && (num_attachments) ) {
791 for (i=0; i<num_attachments; ++i) {
792 extract_token(buf, attachments, i, '\n', sizeof buf);
793 extract_token(mime_filename, buf, 1, '|', sizeof mime_filename);
794 extract_token(mime_partnum, buf, 2, '|', sizeof mime_partnum);
795 extract_token(mime_disposition, buf, 3, '|', sizeof mime_disposition);
796 extract_token(mime_content_type, buf, 4, '|', sizeof mime_content_type);
797 mime_length = extract_int(buf, 5);
800 * tracing ... uncomment if necessary
803 lprintf(9, "fwd filename: %s\n", mime_filename);
804 lprintf(9, "fwd partnum : %s\n", mime_partnum);
805 lprintf(9, "fwd conttype: %s\n", mime_content_type);
806 lprintf(9, "fwd dispose : %s\n", mime_disposition);
807 lprintf(9, "fwd length : %d\n", mime_length);
809 if ( (!strcasecmp(mime_disposition, "inline"))
810 || (!strcasecmp(mime_disposition, "attachment")) ) {
814 /* Create an attachment struct from this mime part... */
815 att = malloc(sizeof(wc_attachment));
816 memset(att, 0, sizeof(wc_attachment));
817 att->length = mime_length;
818 att->content_type = NewStrBufPlain(mime_content_type, -1);
819 att->filename = NewStrBufPlain(mime_filename, -1);
820 att->data = load_mimepart(msgnum, mime_partnum);
822 if (WCC->attachments == NULL)
823 WCC->attachments = NewHash(1, NULL);
824 /* And add it to the list. */
825 n = snprintf(N, sizeof N, "%d", GetCount(WCC->attachments) + 1);
826 Put(WCC->attachments, N, n, att, free_attachment);
833 if (ic != (iconv_t)(-1) ) {
838 if (attachments != NULL) {
846 message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSubject, long MsgNum)
849 MsgPartEvaluatorFunc Eval;
850 message_summary *Msg;
859 serv_printf("MSG0 %ld|1", MsgNum); /* ask for headers only */
861 StrBuf_ServGetln(Buf);
862 if (GetServerStatus(Buf, NULL) == 1) {
867 Msg = (message_summary*)malloc(sizeof(message_summary));
868 memset(Msg, 0, sizeof(message_summary));
869 while (len = StrBuf_ServGetln(Buf),
871 strcmp(ChrPtr(Buf), "000")== 0)){
873 ebuf = strchr(ChrPtr(Buf), '=');
875 if (GetHash(MsgEvaluators, buf, nBuf, &vEval) && vEval != NULL) {
876 Eval = (MsgPartEvaluatorFunc) vEval;
877 StrBufCutLeft(Buf, nBuf + 1);
880 else lprintf(1, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf));
887 * \brief display the adressbook overview
888 * \param msgnum the citadel message number
889 * \param alpha what????
891 void display_addressbook(long msgnum, char alpha) {
893 /* char mime_partnum[SIZ]; */
894 /* char mime_filename[SIZ]; */
895 /* char mime_content_type[SIZ]; */
896 ///char mime_disposition[SIZ];
898 char vcard_partnum[SIZ];
899 char *vcard_source = NULL;
900 message_summary summ;////TODO: this will leak
902 memset(&summ, 0, sizeof(summ));
903 ///safestrncpy(summ.subj, _("(no subject)"), sizeof summ.subj);
904 ///Load Message headers
906 if (!IsEmptyStr(vcard_partnum)) {
907 vcard_source = load_mimepart(msgnum, vcard_partnum);
908 if (vcard_source != NULL) {
910 /** Display the summary line */
911 display_vcard(WC->WBuf, vcard_source, alpha, 0, NULL,msgnum);
913 /** If it's my vCard I can edit it */
914 if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
915 || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))
916 || (WC->wc_view == VIEW_ADDRESSBOOK)
918 wprintf("<a href=\"edit_vcard?"
919 "msgnum=%ld&partnum=%s\">",
920 msgnum, vcard_partnum);
921 wprintf("[%s]</a>", _("edit"));
933 * \brief If it's an old "Firstname Lastname" style record, try to convert it.
934 * \param namebuf name to analyze, reverse if nescessary
936 void lastfirst_firstlast(char *namebuf) {
941 if (namebuf == NULL) return;
942 if (strchr(namebuf, ';') != NULL) return;
944 i = num_tokens(namebuf, ' ');
947 extract_token(lastname, namebuf, i-1, ' ', sizeof lastname);
948 remove_token(namebuf, i-1, ' ');
949 strcpy(firstname, namebuf);
950 sprintf(namebuf, "%s; %s", lastname, firstname);
954 * \brief fetch what??? name
955 * \param msgnum the citadel message number
956 * \param namebuf where to put the name in???
958 void fetch_ab_name(message_summary *Msg, char *namebuf) {
960 char mime_partnum[SIZ];
961 char mime_filename[SIZ];
962 char mime_content_type[SIZ];
963 char mime_disposition[SIZ];
965 char vcard_partnum[SIZ];
966 char *vcard_source = NULL;
968 message_summary summ;/// TODO this will lak
970 if (namebuf == NULL) return;
973 memset(&summ, 0, sizeof(summ));
974 //////safestrncpy(summ.subj, "(no subject)", sizeof summ.subj);
976 sprintf(buf, "MSG0 %ld|0", Msg->msgnum); /** unfortunately we need the mime info now */
978 serv_getln(buf, sizeof buf);
979 if (buf[0] != '1') return;
981 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
982 if (!strncasecmp(buf, "part=", 5)) {
983 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
984 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
985 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
986 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
987 mime_length = extract_int(&buf[5], 5);
989 if ( (!strcasecmp(mime_content_type, "text/x-vcard"))
990 || (!strcasecmp(mime_content_type, "text/vcard")) ) {
991 strcpy(vcard_partnum, mime_partnum);
997 if (!IsEmptyStr(vcard_partnum)) {
998 vcard_source = load_mimepart(Msg->msgnum, vcard_partnum);
999 if (vcard_source != NULL) {
1001 /* Grab the name off the card */
1002 display_vcard(WC->WBuf, vcard_source, 0, 0, namebuf, Msg->msgnum);
1008 lastfirst_firstlast(namebuf);
1010 len = strlen(namebuf);
1011 for (i=0; i<len; ++i) {
1012 if (namebuf[i] != ';') return;
1014 strcpy(namebuf, _("(no name)"));
1022 * load message pointers from the server for a "read messages" operation
1024 * servcmd: the citadel command to send to the citserver
1025 * with_headers: also include some of the headers with the message numbers (more expensive)
1027 int load_msg_ptrs(char *servcmd, int with_headers)
1029 StrBuf* FoundCharset = NULL;
1030 struct wcsession *WCC = WC;
1031 message_summary *Msg;
1034 ///time_t datestamp;
1035 //char fullname[128];
1036 //char nodename[128];
1037 //char inetaddr[128];
1038 //char subject[1024];
1045 ////int num_summ_alloc = 0;
1047 if (WCC->summ != NULL) {
1048 if (WCC->summ != NULL)
1049 DeleteHash(&WCC->summ);
1051 WCC->summ = NewHash(1, Flathash);
1053 maxload = 1000;/// TODO
1057 StrBuf_ServGetln(Buf);
1058 if (GetServerStatus(Buf, NULL) != 1) {
1062 // TODO if (with_headers) { //// TODO: Have Attachments?
1064 while (len = StrBuf_ServGetln(Buf),
1066 strcmp(ChrPtr(Buf), "000")!= 0))
1068 if (nummsgs < maxload) {
1069 Msg = (message_summary*)malloc(sizeof(message_summary));
1070 memset(Msg, 0, sizeof(message_summary));
1072 Msg->msgnum = StrBufExtract_long(Buf, 0, '|');
1073 Msg->date = StrBufExtract_long(Buf, 1, '|');
1075 Msg->from = NewStrBufPlain(NULL, StrLength(Buf));
1076 StrBufExtract_token(Buf2, Buf, 2, '|');
1077 if (StrLength(Buf2) != 0) {
1078 /** Handle senders with RFC2047 encoding */
1079 StrBuf_RFC822_to_Utf8(Msg->from, Buf2, WCC->DefaultCharset, FoundCharset);
1083 StrBufExtract_token(Buf2, Buf, 3, '|');
1084 if ((StrLength(Buf2) !=0 ) &&
1085 ( ((WCC->room_flags & QR_NETWORK)
1086 || ((strcasecmp(ChrPtr(Buf2), serv_info.serv_nodename)
1087 && (strcasecmp(ChrPtr(Buf2), serv_info.serv_fqdn)))))))
1089 StrBufAppendBufPlain(Msg->from, HKEY(" @ "), 0);
1090 StrBufAppendBuf(Msg->from, Buf2, 0);
1094 StrBufExtract_token(Msg->inetaddr, Buf, 4, '|');
1097 Msg->subj = NewStrBufPlain(NULL, StrLength(Buf));
1098 StrBufExtract_token(Buf2, Buf, 5, '|');
1099 if (StrLength(Buf2) == 0)
1100 StrBufAppendBufPlain(Msg->subj, _("(no subj)"), 0, -1);
1102 StrBuf_RFC822_to_Utf8(Msg->subj, Buf2, WCC->DefaultCharset, FoundCharset);
1103 if ((StrLength(Msg->subj) > 75) &&
1104 (StrBuf_Utf8StrLen(Msg->subj) > 75)) {
1105 StrBuf_Utf8StrCut(Msg->subj, 72);
1106 StrBufAppendBufPlain(Msg->subj, HKEY("..."), 0);
1111 if ((StrLength(Msg->from) > 25) &&
1112 (StrBuf_Utf8StrLen(Msg->from) > 25)) {
1113 StrBuf_Utf8StrCut(Msg->from, 23);
1114 StrBufAppendBufPlain(Msg->from, HKEY("..."), 0);
1116 Put(WCC->summ, (const char*)&Msg->msgnum, sizeof(Msg->msgnum), Msg, DestroyMessageSummary);
1131 * command loop for reading messages
1133 * Set oper to "readnew" or "readold" or "readfwd" or "headers"
1135 void readloop(char *oper)
1138 message_summary *Msg;
1147 long *displayed_msgs = NULL;
1148 int num_displayed = 0;
1150 int is_addressbook = 0;
1151 int is_singlecard = 0;
1152 int is_calendar = 0;
1153 struct calview calv;
1158 int lowest_displayed = (-1);
1159 int highest_displayed = 0;
1160 addrbookent *addrbook = NULL;
1162 const StrBuf *sortby = NULL;
1164 int SortBy = eRDate;
1165 const StrBuf *sortpref_value;
1166 int bbs_reverse = 0;
1167 struct wcsession *WCC = WC; /* This is done to make it run faster; WC is a function */
1169 const char *HashKey;
1172 if (WCC->wc_view == VIEW_WIKI) {
1173 sprintf(buf, "wiki?room=%s&page=home", WCC->wc_roomname);
1178 startmsg = lbstr("startmsg");
1179 maxmsgs = ibstr("maxmsgs");
1180 is_summary = (ibstr("is_summary") && !WCC->is_mobile);
1181 if (maxmsgs == 0) maxmsgs = DEFAULT_MAXMSGS;
1183 sortpref_value = get_room_pref("sort");
1185 sortby = sbstr("sortby");
1186 if ( (!IsEmptyStr(ChrPtr(sortby))) &&
1187 (strcasecmp(ChrPtr(sortby), ChrPtr(sortpref_value)) != 0)) {
1188 set_room_pref("sort", NewStrBufDup(sortby), 1);
1189 sortpref_value = NULL;
1190 sortpref_value = sortby;
1193 SortBy = StrToESort(sortpref_value);
1194 /* message board sort */
1195 if (SortBy == eReverse) {
1202 output_headers(1, 1, 1, 0, 0, 0);
1205 * When in summary mode, always show ALL messages instead of just
1206 * new or old. Otherwise, show what the user asked for.
1208 if (!strcmp(oper, "readnew")) {
1209 strcpy(cmd, "MSGS NEW");
1211 else if (!strcmp(oper, "readold")) {
1212 strcpy(cmd, "MSGS OLD");
1214 else if (!strcmp(oper, "do_search")) {
1215 snprintf(cmd, sizeof(cmd), "MSGS SEARCH|%s", bstr("query"));
1218 strcpy(cmd, "MSGS ALL");
1221 if ((WCC->wc_view == VIEW_MAILBOX) && (maxmsgs > 1) && !WCC->is_mobile) {
1223 if (!strcmp(oper, "do_search")) {
1224 snprintf(cmd, sizeof(cmd), "MSGS SEARCH|%s", bstr("query"));
1227 strcpy(cmd, "MSGS ALL");
1231 if ((WCC->wc_view == VIEW_ADDRESSBOOK) && (maxmsgs > 1)) {
1233 if (!strcmp(oper, "do_search")) {
1234 snprintf(cmd, sizeof(cmd), "MSGS SEARCH|%s", bstr("query"));
1237 strcpy(cmd, "MSGS ALL");
1242 if (is_summary) { /**< fetch header summary */
1243 snprintf(cmd, sizeof(cmd), "MSGS %s|%s||1",
1244 (!strcmp(oper, "do_search") ? "SEARCH" : "ALL"),
1245 (!strcmp(oper, "do_search") ? bstr("query") : "")
1250 if (WCC->is_mobile) {
1252 snprintf(cmd, sizeof(cmd), "MSGS %s|%s||1",
1253 (!strcmp(oper, "do_search") ? "SEARCH" : "ALL"),
1254 (!strcmp(oper, "do_search") ? bstr("query") : "")
1260 * Are we doing a summary view? If so, we need to know old messages
1261 * and new messages, so we can do that pretty boldface thing for the
1264 strcpy(old_msgs, "");
1265 if ((is_summary) || (WCC->wc_default_view == VIEW_CALENDAR) || WCC->is_mobile){
1267 serv_getln(buf, sizeof buf);
1268 if (buf[0] == '2') {
1269 strcpy(old_msgs, &buf[4]);
1273 is_singlecard = ibstr("is_singlecard");
1275 if (WCC->wc_default_view == VIEW_CALENDAR) { /**< calendar */
1277 strcpy(cmd, "MSGS ALL|||1");
1279 parse_calendar_view_request(&calv);
1281 if (WCC->wc_default_view == VIEW_TASKS) { /**< tasks */
1283 strcpy(cmd, "MSGS ALL");
1286 if (WCC->wc_default_view == VIEW_NOTES) { /**< notes */
1288 strcpy(cmd, "MSGS ALL");
1293 wprintf("<div id=\"new_notes_here\"></div>\n");
1296 nummsgs = load_msg_ptrs(cmd, (is_summary || WCC->is_mobile));
1299 if ((!is_tasks) && (!is_calendar) && (!is_notes) && (!is_addressbook)) {
1300 wprintf("<div align=\"center\"><br /><em>");
1301 if (!strcmp(oper, "readnew")) {
1302 wprintf(_("No new messages."));
1303 } else if (!strcmp(oper, "readold")) {
1304 wprintf(_("No old messages."));
1306 wprintf(_("No messages here."));
1308 wprintf("</em><br /></div>\n");
1314 if ((is_summary) || (WCC->wc_default_view == VIEW_CALENDAR) || WCC->is_mobile){
1316 message_summary *Msg;
1318 at = GetNewHashPos();
1319 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
1320 /** Are you a new message, or an old message? */
1321 Msg = (message_summary*) vMsg;
1323 if (is_msg_in_mset(old_msgs, Msg->msgnum)) {
1334 if (startmsg == 0L) {
1336 startmsg = WCC->msgarr[(nummsgs >= maxmsgs) ? (nummsgs - maxmsgs) : 0];
1339 startmsg = WCC->msgarr[0];
1343 if (is_summary || WCC->is_mobile) {
1344 SortByPayload(WCC->summ, SortFuncs[SortBy]);
1349 wprintf("<script language=\"javascript\" type=\"text/javascript\">"
1350 " document.onkeydown = CtdlMsgListKeyPress; "
1351 " if (document.layers) { "
1352 " document.captureEvents(Event.KEYPRESS); "
1357 /** note that Date and Delete are now in the same column */
1358 wprintf("<div id=\"message_list_hdr\">"
1359 "<div class=\"fix_scrollbar_bug\">"
1360 "<table cellspacing=0 style=\"width:100%%\">"
1363 wprintf("<th width=%d%%>%s <a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=%s\"><img border=\"0\" src=\"%s\" /></a> </th>\n"
1364 "<th width=%d%%>%s <a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=%s\"><img border=\"0\" src=\"%s\" /></a> </th>\n"
1365 "<th width=%d%%>%s <a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=%s\"><img border=\"0\" src=\"%s\" /></a> \n"
1367 "<input type=\"submit\" name=\"delete_button\" id=\"delbutton\" "
1368 " onClick=\"CtdlDeleteSelectedMessages(event)\" "
1375 SortByStrings[SubjectInvertSortString[SortBy]],
1376 SortIcons[SortSubjectToIcon[SortBy]],
1377 SENDER_COL_WIDTH_PCT,
1379 SortByStrings[SenderInvertSortString[SortBy]],
1380 SortIcons[SortSenderToIcon[SortBy]],
1381 DATE_PLUS_BUTTONS_WIDTH_PCT,
1383 SortByStrings[DateInvertSortString[SortBy]],
1384 SortIcons[SortDateToIcon[SortBy]],
1387 wprintf("</table></div></div>\n");
1388 wprintf("<div id=\"message_list\">"
1390 "<div class=\"fix_scrollbar_bug\">\n"
1391 "<table class=\"mailbox_summary\" id=\"summary_headers\" "
1392 "cellspacing=0 style=\"width:100%%;-moz-user-select:none;\">"
1394 } else if (WCC->is_mobile) {
1395 wprintf("<div id=\"message_list\">");
1400 * Set the "is_bbview" variable if it appears that we are looking at
1401 * a classic bulletin board view.
1403 if ((!is_tasks) && (!is_calendar) && (!is_addressbook)
1404 && (!is_notes) && (!is_singlecard) && (!is_summary)) {
1409 * If we're not currently looking at ALL requested
1410 * messages, then display the selector bar
1413 /** begin bbview scroller */
1414 wprintf("<form name=\"msgomatictop\" class=\"selector_top\" > \n <p>");
1415 wprintf(_("Reading #"));//// TODO this isn't used, should it? : , lowest_displayed, highest_displayed);
1417 wprintf("<select name=\"whichones\" size=\"1\" "
1418 "OnChange=\"location.href=msgomatictop.whichones.options"
1419 "[selectedIndex].value\">\n");
1422 for (b=nummsgs-1; b>=0; b = b - maxmsgs) {
1424 lo = b - maxmsgs + 2;
1426 wprintf("<option %s value="
1431 "%d-%d</option> \n",
1432 ((WCC->msgarr[lo-1] == startmsg) ? "selected" : ""),
1441 for (b=0; b<nummsgs; b = b + maxmsgs) {
1443 hi = b + maxmsgs + 1;
1444 if (hi > nummsgs) hi = nummsgs;
1445 wprintf("<option %s value="
1450 "%d-%d</option> \n",
1451 ((WCC->msgarr[b] == startmsg) ? "selected" : ""),
1460 wprintf("<option value=\"%s?startmsg=%ld"
1461 "&maxmsgs=9999999&is_summary=%d\">",
1463 WCC->msgarr[0], is_summary);
1465 wprintf("</option>");
1466 wprintf("</select> ");
1467 wprintf(_("of %d messages."), nummsgs);
1469 /** forward/reverse */
1470 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
1471 "OnChange=\"location.href='%s?sortby=forward'\"",
1472 (bbs_reverse ? "" : "checked"),
1476 wprintf(_("oldest to newest"));
1477 wprintf(" ");
1479 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
1480 "OnChange=\"location.href='%s?sortby=reverse'\"",
1481 (bbs_reverse ? "checked" : ""),
1485 wprintf(_("newest to oldest"));
1488 wprintf("</p></form>\n");
1489 /** end bbview scroller */
1492 at = GetNewHashPos();
1493 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
1494 Msg = (message_summary*) vMsg;
1495 if ((Msg->msgnum >= startmsg) && (num_displayed < maxmsgs)) {
1497 /** Display the message */
1499 DoTemplate(HKEY("section_mailsummary"), NULL, Msg, CTX_MAILSUM);
1501 else if (is_addressbook) {
1502 fetch_ab_name(Msg, buf);
1504 addrbook = realloc(addrbook,
1505 (sizeof(addrbookent) * num_ab) );
1506 safestrncpy(addrbook[num_ab-1].ab_name, buf,
1507 sizeof(addrbook[num_ab-1].ab_name));
1508 addrbook[num_ab-1].ab_msgnum = Msg->msgnum;
1510 else if (is_calendar) {
1511 load_calendar_item(Msg, Msg->is_new, &calv);
1513 else if (is_tasks) {
1514 display_task(Msg, Msg->is_new);
1516 else if (is_notes) {
1517 display_note(Msg, Msg->is_new);
1518 } else if (WCC->is_mobile) {
1519 DoTemplate(HKEY("section_mailsummary"), NULL, Msg, CTX_MAILSUM);
1522 if (displayed_msgs == NULL) {
1523 displayed_msgs = malloc(sizeof(long) *
1524 (maxmsgs<nummsgs ? maxmsgs : nummsgs));
1526 displayed_msgs[num_displayed] = Msg->msgnum;
1529 if (lowest_displayed < 0) lowest_displayed = a;
1530 highest_displayed = a;
1538 if (displayed_msgs != NULL) {
1540 qsort(displayed_msgs, num_displayed, sizeof(long), qlongcmp_r);
1543 /** if we do a split bbview in the future, begin messages div here */
1545 for (a=0; a<num_displayed; ++a) {
1546 read_message(WC->WBuf, HKEY("view_message"), displayed_msgs[a], 0, NULL);
1549 /** if we do a split bbview in the future, end messages div here */
1551 free(displayed_msgs);
1552 displayed_msgs = NULL;
1557 "</div>\n"); /**< end of 'fix_scrollbar_bug' div */
1558 wprintf("</div>"); /**< end of 'message_list' div */
1560 /** Here's the grab-it-to-resize-the-message-list widget */
1561 wprintf("<div id=\"resize_msglist\" "
1562 "onMouseDown=\"CtdlResizeMsgListMouseDown(event)\">"
1563 "<div class=\"fix_scrollbar_bug\"> <hr>"
1567 wprintf("<div id=\"preview_pane\">"); /**< The preview pane will initially be empty */
1568 } else if (WCC->is_mobile) {
1573 * Bump these because although we're thinking in zero base, the user
1574 * is a drooling idiot and is thinking in one base.
1577 ++highest_displayed;
1580 * If we're not currently looking at ALL requested
1581 * messages, then display the selector bar
1584 /** begin bbview scroller */
1585 wprintf("<form name=\"msgomatic\" class=\"selector_bottom\" > \n <p>");
1586 wprintf(_("Reading #")); /// TODO: this isn't used: , lowest_displayed, highest_displayed);
1588 wprintf("<select name=\"whichones\" size=\"1\" "
1589 "OnChange=\"location.href=msgomatic.whichones.options"
1590 "[selectedIndex].value\">\n");
1593 for (b=nummsgs-1; b>=0; b = b - maxmsgs) {
1595 lo = b - maxmsgs + 2;
1597 wprintf("<option %s value="
1602 "%d-%d</option> \n",
1603 ((WCC->msgarr[lo-1] == startmsg) ? "selected" : ""),
1612 for (b=0; b<nummsgs; b = b + maxmsgs) {
1614 hi = b + maxmsgs + 1;
1615 if (hi > nummsgs) hi = nummsgs;
1616 wprintf("<option %s value="
1621 "%d-%d</option> \n",
1622 ((WCC->msgarr[b] == startmsg) ? "selected" : ""),
1631 wprintf("<option value=\"%s&startmsg=%ld"
1632 "&maxmsgs=9999999&is_summary=%d\">",
1634 WCC->msgarr[0], is_summary);
1636 wprintf("</option>");
1637 wprintf("</select> ");
1638 wprintf(_("of %d messages."), nummsgs);
1640 /** forward/reverse */
1641 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
1642 "OnChange=\"location.href='%s&sortby=forward'\"",
1643 (bbs_reverse ? "" : "checked"),
1647 wprintf(_("oldest to newest"));
1648 wprintf(" ");
1649 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
1650 "OnChange=\"location.href='%s&sortby=reverse'\"",
1651 (bbs_reverse ? "checked" : ""),
1655 wprintf(_("newest to oldest"));
1658 wprintf("</p></form>\n");
1659 /** end bbview scroller */
1664 do_tasks_view(); /** Render the task list */
1668 render_calendar_view(&calv);
1671 if (is_addressbook) {
1672 do_addrbook_view(addrbook, num_ab); /** Render the address book */
1675 /** Note: wDumpContent() will output one additional </div> tag. */
1676 wprintf("</div>\n"); /** end of 'content' div */
1679 /** free the summary */
1680 if (WCC->summ != NULL) {
1681 DeleteHash(&WCC->summ);
1683 if (addrbook != NULL) free(addrbook);
1688 * Back end for post_message()
1689 * ... this is where the actual message gets transmitted to the server.
1691 void post_mime_to_server(void) {
1692 struct wcsession *WCC = WC;
1693 char top_boundary[SIZ];
1694 char alt_boundary[SIZ];
1695 int is_multipart = 0;
1699 size_t encoded_length;
1700 size_t encoded_strlen;
1701 char *txtmail = NULL;
1703 sprintf(top_boundary, "Citadel--Multipart--%s--%04x--%04x",
1704 serv_info.serv_fqdn,
1708 sprintf(alt_boundary, "Citadel--Multipart--%s--%04x--%04x",
1709 serv_info.serv_fqdn,
1714 /* RFC2045 requires this, and some clients look for it... */
1715 serv_puts("MIME-Version: 1.0");
1716 serv_puts("X-Mailer: " PACKAGE_STRING);
1718 /* If there are attachments, we have to do multipart/mixed */
1719 if (GetCount(WCC->attachments) > 0) {
1724 /* Remember, serv_printf() appends an extra newline */
1725 serv_printf("Content-type: multipart/mixed; boundary=\"%s\"\n", top_boundary);
1726 serv_printf("This is a multipart message in MIME format.\n");
1727 serv_printf("--%s", top_boundary);
1730 /* Remember, serv_printf() appends an extra newline */
1731 serv_printf("Content-type: multipart/alternative; "
1732 "boundary=\"%s\"\n", alt_boundary);
1733 serv_printf("This is a multipart message in MIME format.\n");
1734 serv_printf("--%s", alt_boundary);
1736 serv_puts("Content-type: text/plain; charset=utf-8");
1737 serv_puts("Content-Transfer-Encoding: quoted-printable");
1739 txtmail = html_to_ascii(bstr("msgtext"), 0, 80, 0);
1740 text_to_server_qp(txtmail); /* Transmit message in quoted-printable encoding */
1743 serv_printf("--%s", alt_boundary);
1745 serv_puts("Content-type: text/html; charset=utf-8");
1746 serv_puts("Content-Transfer-Encoding: quoted-printable");
1748 serv_puts("<html><body>\r\n");
1749 text_to_server_qp(bstr("msgtext")); /* Transmit message in quoted-printable encoding */
1750 serv_puts("</body></html>\r\n");
1752 serv_printf("--%s--", alt_boundary);
1760 /* Add in the attachments */
1761 it = GetNewHashPos();
1762 while (GetNextHashPos(WCC->attachments, it, &len, &Key, &vAtt)) {
1763 att = (wc_attachment*)vAtt;
1764 encoded_length = ((att->length * 150) / 100);
1765 encoded = malloc(encoded_length);
1766 if (encoded == NULL) break;
1767 encoded_strlen = CtdlEncodeBase64(encoded, att->data, att->length, 1);
1769 serv_printf("--%s", top_boundary);
1770 serv_printf("Content-type: %s", ChrPtr(att->content_type));
1771 serv_printf("Content-disposition: attachment; filename=\"%s\"", ChrPtr(att->filename));
1772 serv_puts("Content-transfer-encoding: base64");
1774 serv_write(encoded, encoded_strlen);
1779 serv_printf("--%s--", top_boundary);
1788 * Post message (or don't post message)
1790 * Note regarding the "dont_post" variable:
1791 * A random value (actually, it's just a timestamp) is inserted as a hidden
1792 * field called "postseq" when the display_enter page is generated. This
1793 * value is checked when posting, using the static variable dont_post. If a
1794 * user attempts to post twice using the same dont_post value, the message is
1795 * discarded. This prevents the accidental double-saving of the same message
1796 * if the user happens to click the browser "back" button.
1798 void post_message(void)
1801 StrBuf *encoded_subject = NULL;
1802 static long dont_post = (-1L);
1804 int is_anonymous = 0;
1805 const StrBuf *display_name = NULL;
1806 struct wcsession *WCC = WC;
1808 if (havebstr("force_room")) {
1809 gotoroom(bstr("force_room"));
1812 if (havebstr("display_name")) {
1813 display_name = sbstr("display_name");
1814 if (!strcmp(ChrPtr(display_name), "__ANONYMOUS__")) {
1815 display_name = NULL;
1820 if (WCC->upload_length > 0) {
1825 lprintf(9, "%s:%d: we are uploading %d bytes\n", __FILE__, __LINE__, WCC->upload_length);
1826 /** There's an attachment. Save it to this struct... */
1827 att = malloc(sizeof(wc_attachment));
1828 memset(att, 0, sizeof(wc_attachment));
1829 att->length = WCC->upload_length;
1830 att->content_type = NewStrBufPlain(WCC->upload_content_type, -1);
1831 att->filename = NewStrBufPlain(WCC->upload_filename, -1);
1834 if (WCC->attachments == NULL)
1835 WCC->attachments = NewHash(1, NULL);
1836 /* And add it to the list. */
1837 n = snprintf(N, sizeof N, "%d", GetCount(WCC->attachments) + 1);
1838 Put(WCC->attachments, N, n, att, free_attachment);
1841 * Mozilla sends a simple filename, which is what we want,
1842 * but Satan's Browser sends an entire pathname. Reduce
1843 * the path to just a filename if we need to.
1845 pch = strrchr(ChrPtr(att->filename), '/');
1847 StrBufCutLeft(att->filename, pch - ChrPtr(att->filename));
1849 pch = strrchr(ChrPtr(att->filename), '\\');
1851 StrBufCutLeft(att->filename, pch - ChrPtr(att->filename));
1855 * Transfer control of this memory from the upload struct
1856 * to the attachment struct.
1858 att->data = WCC->upload;
1859 WCC->upload_length = 0;
1865 if (havebstr("cancel_button")) {
1866 sprintf(WCC->ImportantMessage,
1867 _("Cancelled. Message was not posted."));
1868 } else if (havebstr("attach_button")) {
1871 } else if (lbstr("postseq") == dont_post) {
1872 sprintf(WCC->ImportantMessage,
1873 _("Automatically cancelled because you have already "
1874 "saved this message."));
1876 const char CMD[] = "ENT0 1|%s|%d|4|%s|%s||%s|%s|%s|%s|%s";
1877 const StrBuf *Recp = NULL;
1878 const StrBuf *Cc = NULL;
1879 const StrBuf *Bcc = NULL;
1880 const StrBuf *Wikipage = NULL;
1881 const StrBuf *my_email_addr = NULL;
1882 StrBuf *CmdBuf = NULL;;
1883 StrBuf *references = NULL;
1885 if (havebstr("references"))
1887 const StrBuf *ref = sbstr("references");
1888 references = NewStrBufPlain(ChrPtr(ref), StrLength(ref));
1889 lprintf(9, "Converting: %s\n", ChrPtr(references));
1890 StrBufReplaceChars(references, '|', '!');
1891 lprintf(9, "Converted: %s\n", ChrPtr(references));
1893 if (havebstr("subject")) {
1896 * make enough room for the encoded string;
1897 * plus the QP header
1899 Subj = sbstr("subject");
1901 StrBufRFC2047encode(&encoded_subject, Subj);
1903 Recp = sbstr("recp");
1906 Wikipage = sbstr("wikipage");
1907 my_email_addr = sbstr("my_email_addr");
1909 CmdBuf = NewStrBufPlain(NULL,
1912 StrLength(encoded_subject) +
1915 StrLength(Wikipage) +
1916 StrLength(my_email_addr) +
1917 StrLength(references));
1919 StrBufPrintf(CmdBuf,
1923 ChrPtr(encoded_subject),
1924 ChrPtr(display_name),
1928 ChrPtr(my_email_addr),
1929 ChrPtr(references));
1930 FreeStrBuf(&references);
1932 lprintf(9, "%s\n", CmdBuf);
1933 serv_puts(ChrPtr(CmdBuf));
1934 serv_getln(buf, sizeof buf);
1935 FreeStrBuf(&CmdBuf);
1936 FreeStrBuf(&encoded_subject);
1937 if (buf[0] == '4') {
1938 post_mime_to_server();
1939 if ( (havebstr("recp"))
1940 || (havebstr("cc" ))
1941 || (havebstr("bcc" ))
1943 sprintf(WCC->ImportantMessage, _("Message has been sent.\n"));
1946 sprintf(WC->ImportantMessage, _("Message has been posted.\n"));
1948 dont_post = lbstr("postseq");
1950 lprintf(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, buf);
1951 sprintf(WC->ImportantMessage, "%s", &buf[4]);
1957 DeleteHash(&WCC->attachments);
1960 * We may have been supplied with instructions regarding the location
1961 * to which we must return after posting. If found, go there.
1963 if (havebstr("return_to")) {
1964 http_redirect(bstr("return_to"));
1967 * If we were editing a page in a wiki room, go to that page now.
1969 else if (havebstr("wikipage")) {
1970 snprintf(buf, sizeof buf, "wiki?page=%s", bstr("wikipage"));
1974 * Otherwise, just go to the "read messages" loop.
1977 readloop("readnew");
1985 * \brief display the message entry screen
1987 void display_enter(void)
1992 const StrBuf *display_name = NULL;
1993 /////wc_attachment *att;
1994 int recipient_required = 0;
1995 int subject_required = 0;
1996 int recipient_bad = 0;
1997 int is_anonymous = 0;
1998 long existing_page = (-1L);
1999 struct wcsession *WCC = WC;
2003 if (havebstr("force_room")) {
2004 gotoroom(bstr("force_room"));
2007 display_name = sbstr("display_name");
2008 if (!strcmp(ChrPtr(display_name), "__ANONYMOUS__")) {
2009 display_name = NULL;
2013 /** First test to see whether this is a room that requires recipients to be entered */
2014 serv_puts("ENT0 0");
2015 serv_getln(buf, sizeof buf);
2017 if (!strncmp(buf, "570", 3)) { /** 570 means that we need a recipient here */
2018 recipient_required = 1;
2020 else if (buf[0] != '2') { /** Any other error means that we cannot continue */
2021 sprintf(WCC->ImportantMessage, "%s", &buf[4]);
2022 readloop("readnew");
2026 /* Is the server strongly recommending that the user enter a message subject? */
2027 if ((buf[3] != '\0') && (buf[4] != '\0')) {
2028 subject_required = extract_int(&buf[4], 1);
2032 * Are we perhaps in an address book view? If so, then an "enter
2033 * message" command really means "add new entry."
2035 if (WCC->wc_default_view == VIEW_ADDRESSBOOK) {
2036 do_edit_vcard(-1, "", "", WCC->wc_roomname);
2041 * Are we perhaps in a calendar room? If so, then an "enter
2042 * message" command really means "add new calendar item."
2044 if (WCC->wc_default_view == VIEW_CALENDAR) {
2045 display_edit_event();
2050 * Are we perhaps in a tasks view? If so, then an "enter
2051 * message" command really means "add new task."
2053 if (WCC->wc_default_view == VIEW_TASKS) {
2054 display_edit_task();
2059 * Otherwise proceed normally.
2060 * Do a custom room banner with no navbar...
2062 output_headers(1, 1, 2, 0, 0, 0);
2065 wprintf("<div id=\"banner\">\n");
2066 embed_room_banner(NULL, navbar_none);
2067 wprintf("</div>\n");
2068 wprintf("<div id=\"content\">\n"
2069 "<div class=\"fix_scrollbar_bug message \">");
2071 /* Now check our actual recipients if there are any */
2072 if (recipient_required) {
2073 const StrBuf *Recp = NULL;
2074 const StrBuf *Cc = NULL;
2075 const StrBuf *Bcc = NULL;
2076 const StrBuf *Wikipage = NULL;
2077 StrBuf *CmdBuf = NULL;;
2078 const char CMD[] = "ENT0 0|%s|%d|0||%s||%s|%s|%s";
2080 Recp = sbstr("recp");
2083 Wikipage = sbstr("wikipage");
2085 CmdBuf = NewStrBufPlain(NULL,
2088 StrLength(display_name) +
2091 StrLength(Wikipage));
2093 StrBufPrintf(CmdBuf,
2097 ChrPtr(display_name),
2101 serv_puts(ChrPtr(CmdBuf));
2102 serv_getln(buf, sizeof buf);
2103 FreeStrBuf(&CmdBuf);
2105 if (!strncmp(buf, "570", 3)) { /** 570 means we have an invalid recipient listed */
2106 if (havebstr("recp") &&
2112 else if (buf[0] != '2') { /** Any other error means that we cannot continue */
2113 wprintf("<em>%s</em><br />\n", &buf[4]);/// -> important message
2117 svputlong("RCPTREQUIRED", recipient_required);
2118 svputlong("SUBJREQUIRED", recipient_required || subject_required);
2119 DoTemplate(HKEY("edit_message"), NULL, NULL, CTX_NONE);
2120 address_book_popup();
2127 /** If we got this far, we can display the message entry screen. */
2129 /* begin message entry screen */
2131 "enctype=\"multipart/form-data\" "
2133 "accept-charset=\"UTF-8\" "
2135 "name=\"enterform\""
2137 wprintf("<input type=\"hidden\" name=\"postseq\" value=\"%ld\">\n", now);
2138 if (WCC->wc_view == VIEW_WIKI) {
2139 wprintf("<input type=\"hidden\" name=\"wikipage\" value=\"%s\">\n", bstr("wikipage"));
2141 wprintf("<input type=\"hidden\" name=\"return_to\" value=\"%s\">\n", bstr("return_to"));
2142 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WCC->nonce);
2143 wprintf("<input type=\"hidden\" name=\"force_room\" value=\"");
2144 escputs(WCC->wc_roomname);
2146 wprintf("<input type=\"hidden\" name=\"references\" value=\"");
2147 escputs(bstr("references"));
2150 /** submit or cancel buttons */
2151 wprintf("<p class=\"send_edit_msg\">");
2152 wprintf("<input type=\"submit\" name=\"send_button\" value=\"");
2153 if (recipient_required) {
2154 wprintf(_("Send message"));
2156 wprintf(_("Post message"));
2159 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">\n", _("Cancel"));
2164 wprintf("<img src=\"static/newmess3_24x.gif\" class=\"imgedit\">");
2165 wprintf(" "); /** header bar */
2166 webcit_fmt_date(buf, now, 0);
2168 wprintf("\n"); /** header bar */
2170 wprintf("<table width=\"100%%\" class=\"edit_msg_table\">");
2172 wprintf("<th><label for=\"from_id\" > ");
2173 wprintf(_(" <I>from</I> "));
2174 wprintf("</label></th>");
2176 wprintf("<td colspan=\"2\">");
2178 /* Allow the user to select any of his valid screen names */
2180 wprintf("<select name=\"display_name\" size=1 id=\"from_id\">\n");
2183 serv_getln(buf, sizeof buf);
2184 if (buf[0] == '1') {
2185 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2186 wprintf("<option %s value=\"",
2187 ((!strcasecmp(bstr("display_name"), buf)) ? "selected" : "")
2192 wprintf("</option>\n");
2196 if (WCC->room_flags & QR_ANONOPT) {
2197 wprintf("<option %s value=\"__ANONYMOUS__\">%s</option>\n",
2198 ((!strcasecmp(bstr("__ANONYMOUS__"), WCC->wc_fullname)) ? "selected" : ""),
2203 wprintf("</select>\n");
2205 /* If this is an email (not a post), allow the user to select any of his
2206 * valid email addresses.
2208 if (recipient_required) {
2210 serv_getln(buf, sizeof buf);
2211 if (buf[0] == '1') {
2212 wprintf("<select name=\"my_email_addr\" size=1>\n");
2213 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2214 wprintf("<option value=\"");
2218 wprintf("></option>\n");
2220 wprintf("</select>\n");
2224 wprintf(_(" <I>in</I> "));
2225 escputs(WCC->wc_roomname);
2227 wprintf("</td></tr>");
2229 if (recipient_required) {
2233 wprintf("<tr><th><label for=\"recp_id\"> ");
2235 wprintf("</label></th>"
2236 "<td><input autocomplete=\"off\" type=\"text\" name=\"recp\" id=\"recp_id\" value=\"");
2237 ccraw = xbstr("recp", &len);
2238 copy = (char*) malloc(len * 2 + 1);
2239 memcpy(copy, ccraw, len + 1);
2240 utf8ify_rfc822_string(copy);
2243 wprintf("\" size=45 maxlength=1000 />");
2244 wprintf("<div class=\"auto_complete\" id=\"recp_name_choices\"></div>");
2245 wprintf("</td><td rowspan=\"3\" align=\"left\" valign=\"top\">");
2247 /** Pop open an address book -- begin **/
2249 "<a href=\"javascript:PopOpenAddressBook('recp_id|%s|cc_id|%s|bcc_id|%s');\" "
2251 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2253 _("To:"), _("CC:"), _("BCC:"),
2254 _("Contacts"), _("Contacts")
2256 /** Pop open an address book -- end **/
2258 wprintf("</td></tr>");
2260 wprintf("<tr><th><label for=\"cc_id\"> ");
2262 wprintf("</label></th>"
2263 "<td><input autocomplete=\"off\" type=\"text\" name=\"cc\" id=\"cc_id\" value=\"");
2264 ccraw = xbstr("cc", &len);
2265 copy = (char*) malloc(len * 2 + 1);
2266 memcpy(copy, ccraw, len + 1);
2267 utf8ify_rfc822_string(copy);
2270 wprintf("\" size=45 maxlength=1000 />");
2271 wprintf("<div class=\"auto_complete\" id=\"cc_name_choices\"></div>");
2272 wprintf("</td></tr>");
2274 wprintf("<tr><th><label for=\"bcc_id\"> ");
2276 wprintf("</label></th>"
2277 "<td><input autocomplete=\"off\" type=\"text\" name=\"bcc\" id=\"bcc_id\" value=\"");
2278 ccraw = xbstr("bcc", &len);
2279 copy = (char*) malloc(len * 2 + 1);
2280 memcpy(copy, ccraw, len + 1);
2281 utf8ify_rfc822_string(copy);
2284 wprintf("\" size=45 maxlength=1000 />");
2285 wprintf("<div class=\"auto_complete\" id=\"bcc_name_choices\"></div>");
2286 wprintf("</td></tr>");
2288 /** Initialize the autocomplete ajax helpers (found in wclib.js) */
2289 wprintf("<script type=\"text/javascript\"> \n"
2290 " activate_entmsg_autocompleters(); \n"
2296 wprintf("<tr><th><label for=\"subject_id\" > ");
2297 if (recipient_required || subject_required) {
2298 wprintf(_("Subject:"));
2301 wprintf(_("Subject (optional):"));
2303 wprintf("</label></th>"
2304 "<td colspan=\"2\">"
2305 "<input type=\"text\" name=\"subject\" id=\"subject_id\" value=\"");
2306 escputs(bstr("subject"));
2307 wprintf("\" size=45 maxlength=70>\n");
2308 wprintf("</td></tr>");
2310 wprintf("<tr><td colspan=\"3\">\n");
2312 wprintf("<textarea name=\"msgtext\" cols=\"80\" rows=\"15\">");
2314 /** If we're continuing from a previous edit, put our partially-composed message back... */
2315 msgescputs(bstr("msgtext"));
2317 /* If we're forwarding a message, insert it here... */
2318 if (lbstr("fwdquote") > 0L) {
2319 wprintf("<br><div align=center><i>");
2320 wprintf(_("--- forwarded message ---"));
2321 wprintf("</i></div><br>");
2322 pullquote_message(lbstr("fwdquote"), 1, 1);
2325 /** If we're replying quoted, insert the quote here... */
2326 else if (lbstr("replyquote") > 0L) {
2329 pullquote_message(lbstr("replyquote"), 0, 1);
2330 wprintf("</blockquote><br>");
2333 /** If we're editing a wiki page, insert the existing page here... */
2334 else if (WCC->wc_view == VIEW_WIKI) {
2335 safestrncpy(buf, bstr("wikipage"), sizeof buf);
2336 str_wiki_index(buf);
2337 existing_page = locate_message_by_uid(buf);
2338 if (existing_page >= 0L) {
2339 pullquote_message(existing_page, 1, 0);
2343 /** Insert our signature if appropriate... */
2344 if ( (WCC->is_mailbox) && !yesbstr("sig_inserted") ) {
2346 get_pref_yesno("use_sig", &UseSig, 0);
2349 const char *sig, *esig;
2351 get_preference("signature", &ebuf);
2353 StrBufEUid_unescapize(Sig, ebuf);
2355 esig = sig + StrLength(Sig);
2356 wprintf("<br>--<br>");
2357 while (sig <= esig) {
2361 else if (*sig == '<') {
2364 else if (*sig == '>') {
2367 else if (*sig == '&') {
2370 else if (*sig == '\"') {
2373 else if (*sig == '\'') {
2376 else /* since we're utf 8, is this a good idea? if (isprint(*sig))*/ {
2377 wprintf("%c", *sig);
2385 wprintf("</textarea>\n");
2387 /** Make sure we only insert our signature once */
2388 /** We don't care if it was there or not before, it needs to be there now. */
2389 wprintf("<input type=\"hidden\" name=\"sig_inserted\" value=\"yes\">\n");
2392 * The following template embeds the TinyMCE richedit control, and automatically
2393 * transforms the textarea into a richedit textarea.
2395 do_template("richedit", NULL);
2397 /** Enumerate any attachments which are already in place... */
2398 wprintf("<div class=\"attachment buttons\"><img src=\"static/diskette_24x.gif\" class=\"imgedit\" > ");
2399 wprintf(_("Attachments:"));
2401 wprintf("<select name=\"which_attachment\" size=1>");
2403 for (att = WCC->first_attachment; att != NULL; att = att->next) {
2404 wprintf("<option value=\"");
2405 urlescputs(att->filename);
2407 escputs(att->filename);
2408 / * wprintf(" (%s, %d bytes)",att->content_type,att->length); * /
2409 wprintf("</option>\n");
2412 wprintf("</select>");
2414 /** Now offer the ability to attach additional files... */
2415 wprintf(" ");
2416 wprintf(_("Attach file:"));
2417 wprintf(" <input name=\"attachfile\" class=\"attachfile\" "
2418 "size=16 type=\"file\">\n "
2419 "<input type=\"submit\" name=\"attach_button\" value=\"%s\">\n", _("Add"));
2420 wprintf("</div>"); /* End of "attachment buttons" div */
2423 wprintf("</td></tr></table>");
2425 wprintf("</form>\n");
2426 wprintf("</div>\n"); /* end of "fix_scrollbar_bug" div */
2428 /* NOTE: address_book_popup() will close the "content" div. Don't close it here. */
2429 DONE: address_book_popup();
2435 * \brief delete a message
2437 void delete_msg(void)
2442 msgid = lbstr("msgid");
2444 if (WC->wc_is_trash) { /** Delete from Trash is a real delete */
2445 serv_printf("DELE %ld", msgid);
2447 else { /** Otherwise move it to Trash */
2448 serv_printf("MOVE %ld|_TRASH_|0", msgid);
2451 serv_getln(buf, sizeof buf);
2452 sprintf(WC->ImportantMessage, "%s", &buf[4]);
2454 readloop("readnew");
2459 * \brief move a message to another folder
2466 msgid = lbstr("msgid");
2468 if (havebstr("move_button")) {
2469 sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
2471 serv_getln(buf, sizeof buf);
2472 sprintf(WC->ImportantMessage, "%s", &buf[4]);
2474 sprintf(WC->ImportantMessage, (_("The message was not moved.")));
2477 readloop("readnew");
2485 * Confirm move of a message
2487 void confirm_move_msg(void)
2493 msgid = lbstr("msgid");
2496 output_headers(1, 1, 2, 0, 0, 0);
2497 wprintf("<div id=\"banner\">\n");
2499 wprintf(_("Confirm move of message"));
2501 wprintf("</div>\n");
2503 wprintf("<div id=\"content\" class=\"service\">\n");
2505 wprintf("<CENTER>");
2507 wprintf(_("Move this message to:"));
2508 wprintf("<br />\n");
2510 wprintf("<form METHOD=\"POST\" action=\"move_msg\">\n");
2511 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2512 wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n", bstr("msgid"));
2514 wprintf("<SELECT NAME=\"target_room\" SIZE=5>\n");
2516 serv_getln(buf, sizeof buf);
2517 if (buf[0] == '1') {
2518 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2519 extract_token(targ, buf, 0, '|', sizeof targ);
2520 wprintf("<OPTION>");
2525 wprintf("</SELECT>\n");
2526 wprintf("<br />\n");
2528 wprintf("<INPUT TYPE=\"submit\" NAME=\"move_button\" VALUE=\"%s\">", _("Move"));
2530 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2531 wprintf("</form></CENTER>\n");
2533 wprintf("</CENTER>\n");
2537 void readnew(void) { readloop("readnew");}
2538 void readold(void) { readloop("readold");}
2539 void readfwd(void) { readloop("readfwd");}
2540 void headers(void) { readloop("headers");}
2541 void do_search(void) { readloop("do_search");}
2552 WebcitAddUrlHandler(HKEY("readnew"), readnew, 0);
2553 WebcitAddUrlHandler(HKEY("readold"), readold, 0);
2554 WebcitAddUrlHandler(HKEY("readfwd"), readfwd, 0);
2555 WebcitAddUrlHandler(HKEY("headers"), headers, 0);
2556 WebcitAddUrlHandler(HKEY("do_search"), do_search, 0);
2557 WebcitAddUrlHandler(HKEY("display_enter"), display_enter, 0);
2558 WebcitAddUrlHandler(HKEY("post"), post_message, 0);
2559 WebcitAddUrlHandler(HKEY("move_msg"), move_msg, 0);
2560 WebcitAddUrlHandler(HKEY("delete_msg"), delete_msg, 0);
2561 WebcitAddUrlHandler(HKEY("confirm_move_msg"), confirm_move_msg, 0);
2562 WebcitAddUrlHandler(HKEY("msg"), embed_message, NEED_URL|AJAX);
2563 WebcitAddUrlHandler(HKEY("printmsg"), print_message, NEED_URL);
2564 WebcitAddUrlHandler(HKEY("mobilemsg"), mobile_message_view, NEED_URL);
2565 WebcitAddUrlHandler(HKEY("msgheaders"), display_headers, NEED_URL);