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 void read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, int printable_view, char *section) {
234 StrBuf *FoundCharset;
235 message_summary *Msg = NULL;
239 struct attach_link *attach_links = NULL;
240 int num_attach_links = 0;
241 // char mime_submessages[256] = "";
242 char reply_references[1024] = "";
246 char vcard_partnum[256] = "";
247 char cal_partnum[256] = "";
248 char *part_source = NULL;
249 char msg4_partnum[32] = "";
251 //// strcpy(mime_submessages, "");
254 serv_printf("MSG4 %ld|%s", msgnum, section);
255 StrBuf_ServGetln(Buf);
256 if (GetServerStatus(Buf, NULL) != 1) {
257 StrBufAppendPrintf(Target, "<strong>");
258 StrBufAppendPrintf(Target, _("ERROR:"));
259 StrBufAppendPrintf(Target, "</strong> %s<br />\n", &buf[4]);
263 svputlong("MsgPrintable", printable_view);
264 /** begin everythingamundo table */
268 Msg = (message_summary *)malloc(sizeof(message_summary));
269 memset(Msg, 0, sizeof(message_summary));
270 Msg->msgnum = msgnum;
271 FoundCharset = NewStrBuf();
272 while ((StrBuf_ServGetln(Buf)>=0) && !Done) {
273 if ( (StrLength(Buf)==3) &&
274 !strcmp(ChrPtr(Buf), "000"))
278 StrBufAppendPrintf(Target, "<i>");
279 StrBufAppendPrintf(Target, _("unexpected end of message"));
280 StrBufAppendPrintf(Target, " (1)</i><br /><br />\n");
281 StrBufAppendPrintf(Target, "</div>\n");
284 DestroyMessageSummary(Msg);
285 FreeStrBuf(&FoundCharset);
293 case 0:/* Citadel Message Headers */
294 if (StrLength(Buf) == 0) {
298 StrBufExtract_token(Token, Buf, 0, '=');
299 StrBufCutLeft(Buf, StrLength(Token) + 1);
301 lprintf(1, ":: [%s] = [%s]\n", ChrPtr(Token), ChrPtr(Buf));
302 if (GetHash(MsgHeaderHandler, SKEY(Token), &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(Token));
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(Token, Buf, 0, ':');
323 if (StrLength(Token) > 0) {
324 StrBufCutLeft(Buf, StrLength(Token) + 1);
325 lprintf(1, ":: [%s] = [%s]\n", ChrPtr(Token), ChrPtr(Buf));
326 if (GetHash(MsgHeaderHandler, SKEY(Token), &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 /* strip the bare contenttype, so we ommit charset etc. */
354 StrBufExtract_token(Buf, Msg->MsgBody.ContentType, 0, ';');
356 if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
358 RenderMimeFunc Render;
359 Render = (RenderMimeFunc)vHdr;
360 Render(&Msg->MsgBody, NULL, FoundCharset);
364 if (StrLength(Msg->reply_references)> 0) {
365 /* Trim down excessively long lists of thread references. We eliminate the
366 * second one in the list so that the thread root remains intact.
368 int rrtok = num_tokens(ChrPtr(Msg->reply_references), '|');
369 int rrlen = StrLength(Msg->reply_references);
370 if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
371 remove_token(reply_references, 1, '|');////todo
375 /* Generate a reply-to address */
376 if (StrLength(Msg->Rfca) > 0) {
377 if (Msg->reply_to == NULL)
378 Msg->reply_to = NewStrBuf();
379 if (StrLength(Msg->from) > 0) {
380 StrBufPrintf(Msg->reply_to, "%s <%s>", ChrPtr(Msg->from), ChrPtr(Msg->Rfca));
383 FlushStrBuf(Msg->reply_to);
384 StrBufAppendBuf(Msg->reply_to, Msg->Rfca, 0);
389 if ((StrLength(Msg->OtherNode)>0) &&
390 (strcasecmp(ChrPtr(Msg->OtherNode), serv_info.serv_nodename)) &&
391 (strcasecmp(ChrPtr(Msg->OtherNode), serv_info.serv_humannode)) )
393 if (Msg->reply_to == NULL)
394 Msg->reply_to = NewStrBuf();
395 StrBufPrintf(Msg->reply_to,
398 ChrPtr(Msg->OtherNode));
401 if (Msg->reply_to == NULL)
402 Msg->reply_to = NewStrBuf();
403 FlushStrBuf(Msg->reply_to);
404 StrBufAppendBuf(Msg->reply_to, Msg->from, 0);
407 DoTemplate(tmpl, tmpllen, Target, Msg, CTX_MAILSUM);
411 //// put message renderer lookup here.
412 ///ENDBODY: /* If there are attached submessages, display them now... */
414 /// if ( (!IsEmptyStr(mime_submessages)) && (!section[0]) ) {
415 /// for (i=0; i<num_tokens(mime_submessages, '|'); ++i) {
416 /// extract_token(buf, mime_submessages, i, '|', sizeof buf);
417 /// /** use printable_view to suppress buttons */
418 /// wprintf("<blockquote>");
419 /// read_message(msgnum, 1, buf);
420 /// wprintf("</blockquote>");
425 /* Afterwards, offer links to download attachments 'n' such */
426 if ( (num_attach_links > 0) && (!section[0]) ) {
427 for (i=0; i<num_attach_links; ++i) {
428 if (strcasecmp(attach_links[i].partnum, msg4_partnum)) {
429 wprintf("%s", attach_links[i].html);
434 /* Handler for vCard parts */
435 if (!IsEmptyStr(vcard_partnum)) {
436 part_source = load_mimepart(msgnum, vcard_partnum);
437 if (part_source != NULL) {
439 /** If it's my vCard I can edit it */
440 if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
441 || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))
442 || (WC->wc_view == VIEW_ADDRESSBOOK)
444 wprintf("<a href=\"edit_vcard?msgnum=%ld&partnum=%s\">",
445 msgnum, vcard_partnum);
446 wprintf("[%s]</a>", _("edit"));
449 /* In all cases, display the full card */
450 display_vcard(WC->WBuf, part_source, 0, 1, NULL,msgnum);
454 /* Handler for calendar parts */
455 if (!IsEmptyStr(cal_partnum)) {
465 /* end everythingamundo table */
466 if (!printable_view) {
470 if (num_attach_links > 0) {
473 DestroyMessageSummary(Msg);
474 FreeStrBuf(&FoundCharset);
482 * Unadorned HTML output of an individual message, suitable
483 * for placing in a hidden iframe, for printing, or whatever
485 * msgnum_as_string == Message number, as a string instead of as a long int
487 void embed_message(void) {
489 const StrBuf *Tmpl = sbstr("template");
491 msgnum = StrTol(WC->UrlFragment1);
492 if (StrLength(Tmpl) > 0)
493 read_message(WC->WBuf, SKEY(Tmpl), msgnum, 0, "");
495 read_message(WC->WBuf, HKEY("view_message"), msgnum, 0, "");
500 * Printable view of a message
502 * msgnum_as_string == Message number, as a string instead of as a long int
504 void print_message(void) {
507 msgnum = StrTol(WC->UrlFragment1);
508 output_headers(0, 0, 0, 0, 0, 0);
510 hprintf("Content-type: text/html\r\n"
511 "Server: " PACKAGE_STRING "\r\n"
512 "Connection: close\r\n");
516 read_message(WC->WBuf, HKEY("view_message_print"), msgnum, 1, "");
522 * Mobile browser view of message
524 * @param msg_num_as_string Message number as a string instead of as a long int
526 void mobile_message_view(void) {
528 msgnum = StrTol(WC->UrlFragment1);
529 output_headers(1, 0, 0, 0, 0, 1);
531 do_template("msgcontrols", NULL);
532 read_message(WC->WBuf, HKEY("view_message"), msgnum,1, "");
537 * \brief Display a message's headers
539 * \param msgnum_as_string Message number, as a string instead of as a long int
541 void display_headers(void) {
545 msgnum = StrTol(WC->UrlFragment1);
546 output_headers(0, 0, 0, 0, 0, 0);
548 hprintf("Content-type: text/plain\r\n"
550 "Connection: close\r\n",
554 serv_printf("MSG2 %ld|3", msgnum);
555 serv_getln(buf, sizeof buf);
557 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
558 wprintf("%s\n", buf);
568 * \brief Read message in simple, JavaScript-embeddable form for 'forward'
569 * or 'reply quoted' operations.
571 * NOTE: it is VITALLY IMPORTANT that we output no single-quotes or linebreaks
572 * in this function. Doing so would throw a JavaScript error in the
573 * 'supplied text' argument to the editor.
575 * \param msgnum Message number of the message we want to quote
576 * \param forward_attachments Nonzero if we want attachments to be forwarded
578 void pullquote_message(long msgnum, int forward_attachments, int include_headers) {
579 struct wcsession *WCC = WC;
581 char mime_partnum[256];
582 char mime_filename[256];
583 char mime_content_type[256];
584 char mime_charset[256];
585 char mime_disposition[256];
587 char *attachments = NULL;
589 int num_attachments = 0;
591 char m_subject[1024];
603 iconv_t ic = (iconv_t)(-1) ;
604 char *ibuf; /**< Buffer of characters to be converted */
605 char *obuf; /**< Buffer for converted characters */
606 size_t ibuflen; /**< Length of input buffer */
607 size_t obuflen; /**< Length of output buffer */
608 char *osav; /**< Saved pointer to output buffer */
614 strcpy(reply_to, "");
615 strcpy(mime_content_type, "text/plain");
616 strcpy(mime_charset, "us-ascii");
618 serv_printf("MSG4 %ld", msgnum);
619 serv_getln(buf, sizeof buf);
621 wprintf(_("ERROR:"));
622 wprintf("%s<br />", &buf[4]);
626 strcpy(m_subject, "");
628 while (serv_getln(buf, sizeof buf), strcasecmp(buf, "text")) {
629 if (!strcmp(buf, "000")) {
630 wprintf("%s (3)", _("unexpected end of message"));
633 if (include_headers) {
634 if (!strncasecmp(buf, "nhdr=yes", 8))
638 if (!strncasecmp(buf, "type=", 5))
639 format_type = atoi(&buf[5]);
640 if (!strncasecmp(buf, "from=", 5)) {
641 strcpy(from, &buf[5]);
643 utf8ify_rfc822_string(from);
646 if (!strncasecmp(buf, "subj=", 5)) {
647 strcpy(m_subject, &buf[5]);
649 if ((!strncasecmp(buf, "hnod=", 5))
650 && (strcasecmp(&buf[5], serv_info.serv_humannode))) {
651 wprintf("(%s) ", &buf[5]);
653 if ((!strncasecmp(buf, "room=", 5))
654 && (strcasecmp(&buf[5], WC->wc_roomname))
655 && (!IsEmptyStr(&buf[5])) ) {
657 wprintf("%s> ", &buf[5]);
659 if (!strncasecmp(buf, "rfca=", 5)) {
660 strcpy(rfca, &buf[5]);
665 if (!strncasecmp(buf, "node=", 5)) {
666 strcpy(node, &buf[5]);
667 if ( ((WC->room_flags & QR_NETWORK)
668 || ((strcasecmp(&buf[5], serv_info.serv_nodename)
669 && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
670 && (IsEmptyStr(rfca))
672 wprintf("@%s ", &buf[5]);
675 if (!strncasecmp(buf, "rcpt=", 5)) {
678 utf8ify_rfc822_string(to);
681 if (!strncasecmp(buf, "time=", 5)) {
682 webcit_fmt_date(now, atol(&buf[5]), 0);
688 * Save attachment info for later. We can't start downloading them
689 * yet because we're in the middle of a server transaction.
691 if (!strncasecmp(buf, "part=", 5)) {
692 ptr = malloc( (strlen(buf) + ((attachments != NULL) ? strlen(attachments) : 0)) ) ;
695 sprintf(ptr, "%s%s\n",
696 ((attachments != NULL) ? attachments : ""),
701 lprintf(9, "attachments=<%s>\n", attachments);
707 if (include_headers) {
710 utf8ify_rfc822_string(m_subject);
711 if (!IsEmptyStr(m_subject)) {
712 wprintf(_("Subject:"));
714 msgescputs(m_subject);
725 * Learn the content type
727 strcpy(mime_content_type, "text/plain");
728 while (serv_getln(buf, sizeof buf), (!IsEmptyStr(buf))) {
729 if (!strcmp(buf, "000")) {
730 wprintf("%s (4)", _("unexpected end of message"));
733 if (!strncasecmp(buf, "Content-type: ", 14)) {
735 safestrncpy(mime_content_type, &buf[14],
736 sizeof(mime_content_type));
737 for (i=0; i<strlen(mime_content_type); ++i) {
738 if (!strncasecmp(&mime_content_type[i], "charset=", 8)) {
739 safestrncpy(mime_charset, &mime_content_type[i+8],
740 sizeof mime_charset);
743 len = strlen(mime_content_type);
744 for (i=0; i<len; ++i) {
745 if (mime_content_type[i] == ';') {
746 mime_content_type[i] = 0;
750 len = strlen(mime_charset);
751 for (i=0; i<len; ++i) {
752 if (mime_charset[i] == ';') {
760 /** Set up a character set conversion if we need to (and if we can) */
762 if ( (strcasecmp(mime_charset, "us-ascii"))
763 && (strcasecmp(mime_charset, "UTF-8"))
764 && (strcasecmp(mime_charset, ""))
766 ctdl_iconv_open("UTF-8", mime_charset, &ic);
767 if (ic == (iconv_t)(-1) ) {
768 lprintf(5, "%s:%d iconv_open(%s, %s) failed: %s\n",
769 __FILE__, __LINE__, "UTF-8", mime_charset, strerror(errno));
774 /** Messages in legacy Citadel variformat get handled thusly... */
775 if (!strcasecmp(mime_content_type, "text/x-citadel-variformat")) {
779 /* Boring old 80-column fixed format text gets handled this way... */
780 else if (!strcasecmp(mime_content_type, "text/plain")) {
781 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
784 if ((len > 0) && (buf[len-1] == '\n')) buf[--len] = 0;
785 if ((len > 0) && (buf[len-1] == '\r')) buf[--len] = 0;
788 if (ic != (iconv_t)(-1) ) {
792 obuf = (char *) malloc(obuflen);
794 iconv(ic, &ibuf, &ibuflen, &obuf, &obuflen);
795 osav[SIZ-obuflen] = 0;
796 safestrncpy(buf, osav, sizeof buf);
802 while ((!IsEmptyStr(buf)) && (isspace(buf[len - 1])))
805 ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) )) {
806 wprintf("<blockquote>");
808 } else if ((bq == 1) &&
809 (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) ) {
810 wprintf("</blockquote>");
814 url(buf, sizeof(buf));
816 wprintf("</tt><br />");
818 wprintf("</i><br />");
821 /** HTML just gets escaped and stuffed back into the editor */
822 else if (!strcasecmp(mime_content_type, "text/html")) {
823 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
827 }//// TODO: charset? utf8?
829 /** Unknown weirdness ... don't know how to handle this content type */
831 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { }
835 /** end of body handler */
838 * If there were attachments, we have to download them and insert them
839 * into the attachment chain for the forwarded message we are composing.
841 if ( (forward_attachments) && (num_attachments) ) {
842 for (i=0; i<num_attachments; ++i) {
843 extract_token(buf, attachments, i, '\n', sizeof buf);
844 extract_token(mime_filename, buf, 1, '|', sizeof mime_filename);
845 extract_token(mime_partnum, buf, 2, '|', sizeof mime_partnum);
846 extract_token(mime_disposition, buf, 3, '|', sizeof mime_disposition);
847 extract_token(mime_content_type, buf, 4, '|', sizeof mime_content_type);
848 mime_length = extract_int(buf, 5);
851 * tracing ... uncomment if necessary
854 lprintf(9, "fwd filename: %s\n", mime_filename);
855 lprintf(9, "fwd partnum : %s\n", mime_partnum);
856 lprintf(9, "fwd conttype: %s\n", mime_content_type);
857 lprintf(9, "fwd dispose : %s\n", mime_disposition);
858 lprintf(9, "fwd length : %d\n", mime_length);
860 if ( (!strcasecmp(mime_disposition, "inline"))
861 || (!strcasecmp(mime_disposition, "attachment")) ) {
865 /* Create an attachment struct from this mime part... */
866 att = malloc(sizeof(wc_attachment));
867 memset(att, 0, sizeof(wc_attachment));
868 att->length = mime_length;
869 att->content_type = NewStrBufPlain(mime_content_type, -1);
870 att->filename = NewStrBufPlain(mime_filename, -1);
871 att->data = load_mimepart(msgnum, mime_partnum);
873 if (WCC->attachments == NULL)
874 WCC->attachments = NewHash(1, NULL);
875 /* And add it to the list. */
876 n = snprintf(N, sizeof N, "%d", GetCount(WCC->attachments) + 1);
877 Put(WCC->attachments, N, n, att, free_attachment);
884 if (ic != (iconv_t)(-1) ) {
889 if (attachments != NULL) {
897 void EvaluateMimePart(message_summary *Sum, StrBuf *Buf)
900 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
901 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
902 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
903 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
904 mime_length = extract_int(&buf[5], 5);
906 if ( (!strcasecmp(mime_content_type, "text/x-vcard"))
907 || (!strcasecmp(mime_content_type, "text/vcard")) ) {
908 strcpy(vcard_partnum, mime_partnum);
913 message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSubject, long MsgNum)
916 MsgPartEvaluatorFunc Eval;
917 message_summary *Msg;
926 serv_printf("MSG0 %ld|1", MsgNum); /* ask for headers only */
928 StrBuf_ServGetln(Buf);
929 if (GetServerStatus(Buf, NULL) == 1) {
934 Msg = (message_summary*)malloc(sizeof(message_summary));
935 memset(Msg, 0, sizeof(message_summary));
936 while (len = StrBuf_ServGetln(Buf),
938 strcmp(ChrPtr(Buf), "000")== 0)){
940 ebuf = strchr(ChrPtr(Buf), '=');
942 if (GetHash(MsgEvaluators, buf, nBuf, &vEval) && vEval != NULL) {
943 Eval = (MsgPartEvaluatorFunc) vEval;
944 StrBufCutLeft(Buf, nBuf + 1);
947 else lprintf(1, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf));
954 * \brief display the adressbook overview
955 * \param msgnum the citadel message number
956 * \param alpha what????
958 void display_addressbook(long msgnum, char alpha) {
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;
967 message_summary summ;////TODO: this will leak
969 memset(&summ, 0, sizeof(summ));
970 ///safestrncpy(summ.subj, _("(no subject)"), sizeof summ.subj);
971 ///Load Message headers
973 if (!IsEmptyStr(vcard_partnum)) {
974 vcard_source = load_mimepart(msgnum, vcard_partnum);
975 if (vcard_source != NULL) {
977 /** Display the summary line */
978 display_vcard(WC->WBuf, vcard_source, alpha, 0, NULL,msgnum);
980 /** If it's my vCard I can edit it */
981 if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
982 || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))
983 || (WC->wc_view == VIEW_ADDRESSBOOK)
985 wprintf("<a href=\"edit_vcard?"
986 "msgnum=%ld&partnum=%s\">",
987 msgnum, vcard_partnum);
988 wprintf("[%s]</a>", _("edit"));
1000 * \brief If it's an old "Firstname Lastname" style record, try to convert it.
1001 * \param namebuf name to analyze, reverse if nescessary
1003 void lastfirst_firstlast(char *namebuf) {
1004 char firstname[SIZ];
1008 if (namebuf == NULL) return;
1009 if (strchr(namebuf, ';') != NULL) return;
1011 i = num_tokens(namebuf, ' ');
1014 extract_token(lastname, namebuf, i-1, ' ', sizeof lastname);
1015 remove_token(namebuf, i-1, ' ');
1016 strcpy(firstname, namebuf);
1017 sprintf(namebuf, "%s; %s", lastname, firstname);
1021 * \brief fetch what??? name
1022 * \param msgnum the citadel message number
1023 * \param namebuf where to put the name in???
1025 void fetch_ab_name(message_summary *Msg, char *namebuf) {
1027 char mime_partnum[SIZ];
1028 char mime_filename[SIZ];
1029 char mime_content_type[SIZ];
1030 char mime_disposition[SIZ];
1032 char vcard_partnum[SIZ];
1033 char *vcard_source = NULL;
1035 message_summary summ;/// TODO this will lak
1037 if (namebuf == NULL) return;
1038 strcpy(namebuf, "");
1040 memset(&summ, 0, sizeof(summ));
1041 //////safestrncpy(summ.subj, "(no subject)", sizeof summ.subj);
1043 sprintf(buf, "MSG0 %ld|0", Msg->msgnum); /** unfortunately we need the mime info now */
1045 serv_getln(buf, sizeof buf);
1046 if (buf[0] != '1') return;
1048 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1049 if (!strncasecmp(buf, "part=", 5)) {
1050 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
1051 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
1052 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
1053 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
1054 mime_length = extract_int(&buf[5], 5);
1056 if ( (!strcasecmp(mime_content_type, "text/x-vcard"))
1057 || (!strcasecmp(mime_content_type, "text/vcard")) ) {
1058 strcpy(vcard_partnum, mime_partnum);
1064 if (!IsEmptyStr(vcard_partnum)) {
1065 vcard_source = load_mimepart(Msg->msgnum, vcard_partnum);
1066 if (vcard_source != NULL) {
1068 /* Grab the name off the card */
1069 display_vcard(WC->WBuf, vcard_source, 0, 0, namebuf, Msg->msgnum);
1075 lastfirst_firstlast(namebuf);
1077 len = strlen(namebuf);
1078 for (i=0; i<len; ++i) {
1079 if (namebuf[i] != ';') return;
1081 strcpy(namebuf, _("(no name)"));
1089 * load message pointers from the server for a "read messages" operation
1091 * servcmd: the citadel command to send to the citserver
1092 * with_headers: also include some of the headers with the message numbers (more expensive)
1094 int load_msg_ptrs(char *servcmd, int with_headers)
1096 StrBuf* FoundCharset = NULL;
1097 struct wcsession *WCC = WC;
1098 message_summary *Msg;
1101 ///time_t datestamp;
1102 //char fullname[128];
1103 //char nodename[128];
1104 //char inetaddr[128];
1105 //char subject[1024];
1112 ////int num_summ_alloc = 0;
1114 if (WCC->summ != NULL) {
1115 if (WCC->summ != NULL)
1116 DeleteHash(&WCC->summ);
1118 WCC->summ = NewHash(1, Flathash);
1120 maxload = 1000;/// TODO
1124 StrBuf_ServGetln(Buf);
1125 if (GetServerStatus(Buf, NULL) != 1) {
1129 // TODO if (with_headers) { //// TODO: Have Attachments?
1131 while (len = StrBuf_ServGetln(Buf),
1133 strcmp(ChrPtr(Buf), "000")!= 0))
1135 if (nummsgs < maxload) {
1136 Msg = (message_summary*)malloc(sizeof(message_summary));
1137 memset(Msg, 0, sizeof(message_summary));
1139 Msg->msgnum = StrBufExtract_long(Buf, 0, '|');
1140 Msg->date = StrBufExtract_long(Buf, 1, '|');
1142 Msg->from = NewStrBufPlain(NULL, StrLength(Buf));
1143 StrBufExtract_token(Buf2, Buf, 2, '|');
1144 if (StrLength(Buf2) != 0) {
1145 /** Handle senders with RFC2047 encoding */
1146 StrBuf_RFC822_to_Utf8(Msg->from, Buf2, WCC->DefaultCharset, FoundCharset);
1150 StrBufExtract_token(Buf2, Buf, 3, '|');
1151 if ((StrLength(Buf2) !=0 ) &&
1152 ( ((WCC->room_flags & QR_NETWORK)
1153 || ((strcasecmp(ChrPtr(Buf2), serv_info.serv_nodename)
1154 && (strcasecmp(ChrPtr(Buf2), serv_info.serv_fqdn)))))))
1156 StrBufAppendBufPlain(Msg->from, HKEY(" @ "), 0);
1157 StrBufAppendBuf(Msg->from, Buf2, 0);
1161 StrBufExtract_token(Msg->inetaddr, Buf, 4, '|');
1164 Msg->subj = NewStrBufPlain(NULL, StrLength(Buf));
1165 StrBufExtract_token(Buf2, Buf, 5, '|');
1166 if (StrLength(Buf2) == 0)
1167 StrBufAppendBufPlain(Msg->subj, _("(no subj)"), 0, -1);
1169 StrBuf_RFC822_to_Utf8(Msg->subj, Buf2, WCC->DefaultCharset, FoundCharset);
1170 if ((StrLength(Msg->subj) > 75) &&
1171 (StrBuf_Utf8StrLen(Msg->subj) > 75)) {
1172 StrBuf_Utf8StrCut(Msg->subj, 72);
1173 StrBufAppendBufPlain(Msg->subj, HKEY("..."), 0);
1178 if ((StrLength(Msg->from) > 25) &&
1179 (StrBuf_Utf8StrLen(Msg->from) > 25)) {
1180 StrBuf_Utf8StrCut(Msg->from, 23);
1181 StrBufAppendBufPlain(Msg->from, HKEY("..."), 0);
1183 Put(WCC->summ, (const char*)&Msg->msgnum, sizeof(Msg->msgnum), Msg, DestroyMessageSummary);
1198 * command loop for reading messages
1200 * Set oper to "readnew" or "readold" or "readfwd" or "headers"
1202 void readloop(char *oper)
1205 message_summary *Msg;
1214 long *displayed_msgs = NULL;
1215 int num_displayed = 0;
1217 int is_addressbook = 0;
1218 int is_singlecard = 0;
1219 int is_calendar = 0;
1220 struct calview calv;
1225 int lowest_displayed = (-1);
1226 int highest_displayed = 0;
1227 addrbookent *addrbook = NULL;
1229 const StrBuf *sortby = NULL;
1231 int SortBy = eRDate;
1232 const StrBuf *sortpref_value;
1233 int bbs_reverse = 0;
1234 struct wcsession *WCC = WC; /* This is done to make it run faster; WC is a function */
1236 const char *HashKey;
1239 if (WCC->wc_view == VIEW_WIKI) {
1240 sprintf(buf, "wiki?room=%s&page=home", WCC->wc_roomname);
1245 startmsg = lbstr("startmsg");
1246 maxmsgs = ibstr("maxmsgs");
1247 is_summary = (ibstr("is_summary") && !WCC->is_mobile);
1248 if (maxmsgs == 0) maxmsgs = DEFAULT_MAXMSGS;
1250 sortpref_value = get_room_pref("sort");
1252 sortby = sbstr("sortby");
1253 if ( (!IsEmptyStr(ChrPtr(sortby))) &&
1254 (strcasecmp(ChrPtr(sortby), ChrPtr(sortpref_value)) != 0)) {
1255 set_room_pref("sort", NewStrBufDup(sortby), 1);
1256 sortpref_value = NULL;
1257 sortpref_value = sortby;
1260 SortBy = StrToESort(sortpref_value);
1261 /* message board sort */
1262 if (SortBy == eReverse) {
1269 output_headers(1, 1, 1, 0, 0, 0);
1272 * When in summary mode, always show ALL messages instead of just
1273 * new or old. Otherwise, show what the user asked for.
1275 if (!strcmp(oper, "readnew")) {
1276 strcpy(cmd, "MSGS NEW");
1278 else if (!strcmp(oper, "readold")) {
1279 strcpy(cmd, "MSGS OLD");
1281 else if (!strcmp(oper, "do_search")) {
1282 snprintf(cmd, sizeof(cmd), "MSGS SEARCH|%s", bstr("query"));
1285 strcpy(cmd, "MSGS ALL");
1288 if ((WCC->wc_view == VIEW_MAILBOX) && (maxmsgs > 1) && !WCC->is_mobile) {
1290 if (!strcmp(oper, "do_search")) {
1291 snprintf(cmd, sizeof(cmd), "MSGS SEARCH|%s", bstr("query"));
1294 strcpy(cmd, "MSGS ALL");
1298 if ((WCC->wc_view == VIEW_ADDRESSBOOK) && (maxmsgs > 1)) {
1300 if (!strcmp(oper, "do_search")) {
1301 snprintf(cmd, sizeof(cmd), "MSGS SEARCH|%s", bstr("query"));
1304 strcpy(cmd, "MSGS ALL");
1309 if (is_summary) { /**< fetch header summary */
1310 snprintf(cmd, sizeof(cmd), "MSGS %s|%s||1",
1311 (!strcmp(oper, "do_search") ? "SEARCH" : "ALL"),
1312 (!strcmp(oper, "do_search") ? bstr("query") : "")
1317 if (WCC->is_mobile) {
1319 snprintf(cmd, sizeof(cmd), "MSGS %s|%s||1",
1320 (!strcmp(oper, "do_search") ? "SEARCH" : "ALL"),
1321 (!strcmp(oper, "do_search") ? bstr("query") : "")
1327 * Are we doing a summary view? If so, we need to know old messages
1328 * and new messages, so we can do that pretty boldface thing for the
1331 strcpy(old_msgs, "");
1332 if ((is_summary) || (WCC->wc_default_view == VIEW_CALENDAR) || WCC->is_mobile){
1334 serv_getln(buf, sizeof buf);
1335 if (buf[0] == '2') {
1336 strcpy(old_msgs, &buf[4]);
1340 is_singlecard = ibstr("is_singlecard");
1342 if (WCC->wc_default_view == VIEW_CALENDAR) { /**< calendar */
1344 strcpy(cmd, "MSGS ALL|||1");
1346 parse_calendar_view_request(&calv);
1348 if (WCC->wc_default_view == VIEW_TASKS) { /**< tasks */
1350 strcpy(cmd, "MSGS ALL");
1353 if (WCC->wc_default_view == VIEW_NOTES) { /**< notes */
1355 strcpy(cmd, "MSGS ALL");
1360 wprintf("<div id=\"new_notes_here\"></div>\n");
1363 nummsgs = load_msg_ptrs(cmd, (is_summary || WCC->is_mobile));
1366 if ((!is_tasks) && (!is_calendar) && (!is_notes) && (!is_addressbook)) {
1367 wprintf("<div align=\"center\"><br /><em>");
1368 if (!strcmp(oper, "readnew")) {
1369 wprintf(_("No new messages."));
1370 } else if (!strcmp(oper, "readold")) {
1371 wprintf(_("No old messages."));
1373 wprintf(_("No messages here."));
1375 wprintf("</em><br /></div>\n");
1381 if ((is_summary) || (WCC->wc_default_view == VIEW_CALENDAR) || WCC->is_mobile){
1383 message_summary *Msg;
1385 at = GetNewHashPos();
1386 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
1387 /** Are you a new message, or an old message? */
1388 Msg = (message_summary*) vMsg;
1390 if (is_msg_in_mset(old_msgs, Msg->msgnum)) {
1401 if (startmsg == 0L) {
1403 startmsg = WCC->msgarr[(nummsgs >= maxmsgs) ? (nummsgs - maxmsgs) : 0];
1406 startmsg = WCC->msgarr[0];
1410 if (is_summary || WCC->is_mobile) {
1411 SortByPayload(WCC->summ, SortFuncs[SortBy]);
1416 wprintf("<script language=\"javascript\" type=\"text/javascript\">"
1417 " document.onkeydown = CtdlMsgListKeyPress; "
1418 " if (document.layers) { "
1419 " document.captureEvents(Event.KEYPRESS); "
1424 /** note that Date and Delete are now in the same column */
1425 wprintf("<div id=\"message_list_hdr\">"
1426 "<div class=\"fix_scrollbar_bug\">"
1427 "<table cellspacing=0 style=\"width:100%%\">"
1430 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"
1431 "<th width=%d%%>%s <a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=%s\"><img border=\"0\" src=\"%s\" /></a> </th>\n"
1432 "<th width=%d%%>%s <a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=%s\"><img border=\"0\" src=\"%s\" /></a> \n"
1434 "<input type=\"submit\" name=\"delete_button\" id=\"delbutton\" "
1435 " onClick=\"CtdlDeleteSelectedMessages(event)\" "
1442 SortByStrings[SubjectInvertSortString[SortBy]],
1443 SortIcons[SortSubjectToIcon[SortBy]],
1444 SENDER_COL_WIDTH_PCT,
1446 SortByStrings[SenderInvertSortString[SortBy]],
1447 SortIcons[SortSenderToIcon[SortBy]],
1448 DATE_PLUS_BUTTONS_WIDTH_PCT,
1450 SortByStrings[DateInvertSortString[SortBy]],
1451 SortIcons[SortDateToIcon[SortBy]],
1454 wprintf("</table></div></div>\n");
1455 wprintf("<div id=\"message_list\">"
1457 "<div class=\"fix_scrollbar_bug\">\n"
1458 "<table class=\"mailbox_summary\" id=\"summary_headers\" "
1459 "cellspacing=0 style=\"width:100%%;-moz-user-select:none;\">"
1461 } else if (WCC->is_mobile) {
1462 wprintf("<div id=\"message_list\">");
1467 * Set the "is_bbview" variable if it appears that we are looking at
1468 * a classic bulletin board view.
1470 if ((!is_tasks) && (!is_calendar) && (!is_addressbook)
1471 && (!is_notes) && (!is_singlecard) && (!is_summary)) {
1476 * If we're not currently looking at ALL requested
1477 * messages, then display the selector bar
1480 /** begin bbview scroller */
1481 wprintf("<form name=\"msgomatictop\" class=\"selector_top\" > \n <p>");
1482 wprintf(_("Reading #"));//// TODO this isn't used, should it? : , lowest_displayed, highest_displayed);
1484 wprintf("<select name=\"whichones\" size=\"1\" "
1485 "OnChange=\"location.href=msgomatictop.whichones.options"
1486 "[selectedIndex].value\">\n");
1489 for (b=nummsgs-1; b>=0; b = b - maxmsgs) {
1491 lo = b - maxmsgs + 2;
1493 wprintf("<option %s value="
1498 "%d-%d</option> \n",
1499 ((WCC->msgarr[lo-1] == startmsg) ? "selected" : ""),
1508 for (b=0; b<nummsgs; b = b + maxmsgs) {
1510 hi = b + maxmsgs + 1;
1511 if (hi > nummsgs) hi = nummsgs;
1512 wprintf("<option %s value="
1517 "%d-%d</option> \n",
1518 ((WCC->msgarr[b] == startmsg) ? "selected" : ""),
1527 wprintf("<option value=\"%s?startmsg=%ld"
1528 "&maxmsgs=9999999&is_summary=%d\">",
1530 WCC->msgarr[0], is_summary);
1532 wprintf("</option>");
1533 wprintf("</select> ");
1534 wprintf(_("of %d messages."), nummsgs);
1536 /** forward/reverse */
1537 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
1538 "OnChange=\"location.href='%s?sortby=forward'\"",
1539 (bbs_reverse ? "" : "checked"),
1543 wprintf(_("oldest to newest"));
1544 wprintf(" ");
1546 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
1547 "OnChange=\"location.href='%s?sortby=reverse'\"",
1548 (bbs_reverse ? "checked" : ""),
1552 wprintf(_("newest to oldest"));
1555 wprintf("</p></form>\n");
1556 /** end bbview scroller */
1559 at = GetNewHashPos();
1560 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
1561 Msg = (message_summary*) vMsg;
1562 if ((Msg->msgnum >= startmsg) && (num_displayed < maxmsgs)) {
1564 /** Display the message */
1566 DoTemplate(HKEY("section_mailsummary"), NULL, Msg, CTX_MAILSUM);
1568 else if (is_addressbook) {
1569 fetch_ab_name(Msg, buf);
1571 addrbook = realloc(addrbook,
1572 (sizeof(addrbookent) * num_ab) );
1573 safestrncpy(addrbook[num_ab-1].ab_name, buf,
1574 sizeof(addrbook[num_ab-1].ab_name));
1575 addrbook[num_ab-1].ab_msgnum = Msg->msgnum;
1577 else if (is_calendar) {
1578 load_calendar_item(Msg, Msg->is_new, &calv);
1580 else if (is_tasks) {
1581 display_task(Msg, Msg->is_new);
1583 else if (is_notes) {
1584 display_note(Msg, Msg->is_new);
1585 } else if (WCC->is_mobile) {
1586 DoTemplate(HKEY("section_mailsummary"), NULL, Msg, CTX_MAILSUM);
1589 if (displayed_msgs == NULL) {
1590 displayed_msgs = malloc(sizeof(long) *
1591 (maxmsgs<nummsgs ? maxmsgs : nummsgs));
1593 displayed_msgs[num_displayed] = Msg->msgnum;
1596 if (lowest_displayed < 0) lowest_displayed = a;
1597 highest_displayed = a;
1605 if (displayed_msgs != NULL) {
1607 qsort(displayed_msgs, num_displayed, sizeof(long), qlongcmp_r);
1610 /** if we do a split bbview in the future, begin messages div here */
1612 for (a=0; a<num_displayed; ++a) {
1613 read_message(WC->WBuf, HKEY("view_message"), displayed_msgs[a], 0, "");
1616 /** if we do a split bbview in the future, end messages div here */
1618 free(displayed_msgs);
1619 displayed_msgs = NULL;
1624 "</div>\n"); /**< end of 'fix_scrollbar_bug' div */
1625 wprintf("</div>"); /**< end of 'message_list' div */
1627 /** Here's the grab-it-to-resize-the-message-list widget */
1628 wprintf("<div id=\"resize_msglist\" "
1629 "onMouseDown=\"CtdlResizeMsgListMouseDown(event)\">"
1630 "<div class=\"fix_scrollbar_bug\"> <hr>"
1634 wprintf("<div id=\"preview_pane\">"); /**< The preview pane will initially be empty */
1635 } else if (WCC->is_mobile) {
1640 * Bump these because although we're thinking in zero base, the user
1641 * is a drooling idiot and is thinking in one base.
1644 ++highest_displayed;
1647 * If we're not currently looking at ALL requested
1648 * messages, then display the selector bar
1651 /** begin bbview scroller */
1652 wprintf("<form name=\"msgomatic\" class=\"selector_bottom\" > \n <p>");
1653 wprintf(_("Reading #")); /// TODO: this isn't used: , lowest_displayed, highest_displayed);
1655 wprintf("<select name=\"whichones\" size=\"1\" "
1656 "OnChange=\"location.href=msgomatic.whichones.options"
1657 "[selectedIndex].value\">\n");
1660 for (b=nummsgs-1; b>=0; b = b - maxmsgs) {
1662 lo = b - maxmsgs + 2;
1664 wprintf("<option %s value="
1669 "%d-%d</option> \n",
1670 ((WCC->msgarr[lo-1] == startmsg) ? "selected" : ""),
1679 for (b=0; b<nummsgs; b = b + maxmsgs) {
1681 hi = b + maxmsgs + 1;
1682 if (hi > nummsgs) hi = nummsgs;
1683 wprintf("<option %s value="
1688 "%d-%d</option> \n",
1689 ((WCC->msgarr[b] == startmsg) ? "selected" : ""),
1698 wprintf("<option value=\"%s&startmsg=%ld"
1699 "&maxmsgs=9999999&is_summary=%d\">",
1701 WCC->msgarr[0], is_summary);
1703 wprintf("</option>");
1704 wprintf("</select> ");
1705 wprintf(_("of %d messages."), nummsgs);
1707 /** forward/reverse */
1708 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
1709 "OnChange=\"location.href='%s&sortby=forward'\"",
1710 (bbs_reverse ? "" : "checked"),
1714 wprintf(_("oldest to newest"));
1715 wprintf(" ");
1716 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
1717 "OnChange=\"location.href='%s&sortby=reverse'\"",
1718 (bbs_reverse ? "checked" : ""),
1722 wprintf(_("newest to oldest"));
1725 wprintf("</p></form>\n");
1726 /** end bbview scroller */
1731 do_tasks_view(); /** Render the task list */
1735 render_calendar_view(&calv);
1738 if (is_addressbook) {
1739 do_addrbook_view(addrbook, num_ab); /** Render the address book */
1742 /** Note: wDumpContent() will output one additional </div> tag. */
1743 wprintf("</div>\n"); /** end of 'content' div */
1746 /** free the summary */
1747 if (WCC->summ != NULL) {
1748 DeleteHash(&WCC->summ);
1750 if (addrbook != NULL) free(addrbook);
1755 * Back end for post_message()
1756 * ... this is where the actual message gets transmitted to the server.
1758 void post_mime_to_server(void) {
1759 struct wcsession *WCC = WC;
1760 char top_boundary[SIZ];
1761 char alt_boundary[SIZ];
1762 int is_multipart = 0;
1766 size_t encoded_length;
1767 size_t encoded_strlen;
1768 char *txtmail = NULL;
1770 sprintf(top_boundary, "Citadel--Multipart--%s--%04x--%04x",
1771 serv_info.serv_fqdn,
1775 sprintf(alt_boundary, "Citadel--Multipart--%s--%04x--%04x",
1776 serv_info.serv_fqdn,
1781 /* RFC2045 requires this, and some clients look for it... */
1782 serv_puts("MIME-Version: 1.0");
1783 serv_puts("X-Mailer: " PACKAGE_STRING);
1785 /* If there are attachments, we have to do multipart/mixed */
1786 if (GetCount(WCC->attachments) > 0) {
1791 /* Remember, serv_printf() appends an extra newline */
1792 serv_printf("Content-type: multipart/mixed; boundary=\"%s\"\n", top_boundary);
1793 serv_printf("This is a multipart message in MIME format.\n");
1794 serv_printf("--%s", top_boundary);
1797 /* Remember, serv_printf() appends an extra newline */
1798 serv_printf("Content-type: multipart/alternative; "
1799 "boundary=\"%s\"\n", alt_boundary);
1800 serv_printf("This is a multipart message in MIME format.\n");
1801 serv_printf("--%s", alt_boundary);
1803 serv_puts("Content-type: text/plain; charset=utf-8");
1804 serv_puts("Content-Transfer-Encoding: quoted-printable");
1806 txtmail = html_to_ascii(bstr("msgtext"), 0, 80, 0);
1807 text_to_server_qp(txtmail); /* Transmit message in quoted-printable encoding */
1810 serv_printf("--%s", alt_boundary);
1812 serv_puts("Content-type: text/html; charset=utf-8");
1813 serv_puts("Content-Transfer-Encoding: quoted-printable");
1815 serv_puts("<html><body>\r\n");
1816 text_to_server_qp(bstr("msgtext")); /* Transmit message in quoted-printable encoding */
1817 serv_puts("</body></html>\r\n");
1819 serv_printf("--%s--", alt_boundary);
1827 /* Add in the attachments */
1828 it = GetNewHashPos();
1829 while (GetNextHashPos(WCC->attachments, it, &len, &Key, &vAtt)) {
1830 att = (wc_attachment*)vAtt;
1831 encoded_length = ((att->length * 150) / 100);
1832 encoded = malloc(encoded_length);
1833 if (encoded == NULL) break;
1834 encoded_strlen = CtdlEncodeBase64(encoded, att->data, att->length, 1);
1836 serv_printf("--%s", top_boundary);
1837 serv_printf("Content-type: %s", ChrPtr(att->content_type));
1838 serv_printf("Content-disposition: attachment; filename=\"%s\"", ChrPtr(att->filename));
1839 serv_puts("Content-transfer-encoding: base64");
1841 serv_write(encoded, encoded_strlen);
1846 serv_printf("--%s--", top_boundary);
1855 * Post message (or don't post message)
1857 * Note regarding the "dont_post" variable:
1858 * A random value (actually, it's just a timestamp) is inserted as a hidden
1859 * field called "postseq" when the display_enter page is generated. This
1860 * value is checked when posting, using the static variable dont_post. If a
1861 * user attempts to post twice using the same dont_post value, the message is
1862 * discarded. This prevents the accidental double-saving of the same message
1863 * if the user happens to click the browser "back" button.
1865 void post_message(void)
1868 StrBuf *encoded_subject = NULL;
1869 static long dont_post = (-1L);
1871 int is_anonymous = 0;
1872 const StrBuf *display_name = NULL;
1873 struct wcsession *WCC = WC;
1875 if (havebstr("force_room")) {
1876 gotoroom(bstr("force_room"));
1879 if (havebstr("display_name")) {
1880 display_name = sbstr("display_name");
1881 if (!strcmp(ChrPtr(display_name), "__ANONYMOUS__")) {
1882 display_name = NULL;
1887 if (WCC->upload_length > 0) {
1892 lprintf(9, "%s:%d: we are uploading %d bytes\n", __FILE__, __LINE__, WCC->upload_length);
1893 /** There's an attachment. Save it to this struct... */
1894 att = malloc(sizeof(wc_attachment));
1895 memset(att, 0, sizeof(wc_attachment));
1896 att->length = WCC->upload_length;
1897 att->content_type = NewStrBufPlain(WCC->upload_content_type, -1);
1898 att->filename = NewStrBufPlain(WCC->upload_filename, -1);
1901 if (WCC->attachments == NULL)
1902 WCC->attachments = NewHash(1, NULL);
1903 /* And add it to the list. */
1904 n = snprintf(N, sizeof N, "%d", GetCount(WCC->attachments) + 1);
1905 Put(WCC->attachments, N, n, att, free_attachment);
1908 * Mozilla sends a simple filename, which is what we want,
1909 * but Satan's Browser sends an entire pathname. Reduce
1910 * the path to just a filename if we need to.
1912 pch = strrchr(ChrPtr(att->filename), '/');
1914 StrBufCutLeft(att->filename, pch - ChrPtr(att->filename));
1916 pch = strrchr(ChrPtr(att->filename), '\\');
1918 StrBufCutLeft(att->filename, pch - ChrPtr(att->filename));
1922 * Transfer control of this memory from the upload struct
1923 * to the attachment struct.
1925 att->data = WCC->upload;
1926 WCC->upload_length = 0;
1932 if (havebstr("cancel_button")) {
1933 sprintf(WCC->ImportantMessage,
1934 _("Cancelled. Message was not posted."));
1935 } else if (havebstr("attach_button")) {
1938 } else if (lbstr("postseq") == dont_post) {
1939 sprintf(WCC->ImportantMessage,
1940 _("Automatically cancelled because you have already "
1941 "saved this message."));
1943 const char CMD[] = "ENT0 1|%s|%d|4|%s|%s||%s|%s|%s|%s|%s";
1944 const StrBuf *Recp = NULL;
1945 const StrBuf *Cc = NULL;
1946 const StrBuf *Bcc = NULL;
1947 const StrBuf *Wikipage = NULL;
1948 const StrBuf *my_email_addr = NULL;
1949 StrBuf *CmdBuf = NULL;;
1950 StrBuf *references = NULL;
1952 if (havebstr("references"))
1954 const StrBuf *ref = sbstr("references");
1955 references = NewStrBufPlain(ChrPtr(ref), StrLength(ref));
1956 lprintf(9, "Converting: %s\n", ChrPtr(references));
1957 StrBufReplaceChars(references, '|', '!');
1958 lprintf(9, "Converted: %s\n", ChrPtr(references));
1960 if (havebstr("subject")) {
1963 * make enough room for the encoded string;
1964 * plus the QP header
1966 Subj = sbstr("subject");
1968 StrBufRFC2047encode(&encoded_subject, Subj);
1970 Recp = sbstr("recp");
1973 Wikipage = sbstr("wikipage");
1974 my_email_addr = sbstr("my_email_addr");
1976 CmdBuf = NewStrBufPlain(NULL,
1979 StrLength(encoded_subject) +
1982 StrLength(Wikipage) +
1983 StrLength(my_email_addr) +
1984 StrLength(references));
1986 StrBufPrintf(CmdBuf,
1990 ChrPtr(encoded_subject),
1991 ChrPtr(display_name),
1995 ChrPtr(my_email_addr),
1996 ChrPtr(references));
1997 FreeStrBuf(&references);
1999 lprintf(9, "%s\n", CmdBuf);
2000 serv_puts(ChrPtr(CmdBuf));
2001 serv_getln(buf, sizeof buf);
2002 FreeStrBuf(&CmdBuf);
2003 FreeStrBuf(&encoded_subject);
2004 if (buf[0] == '4') {
2005 post_mime_to_server();
2006 if ( (havebstr("recp"))
2007 || (havebstr("cc" ))
2008 || (havebstr("bcc" ))
2010 sprintf(WCC->ImportantMessage, _("Message has been sent.\n"));
2013 sprintf(WC->ImportantMessage, _("Message has been posted.\n"));
2015 dont_post = lbstr("postseq");
2017 lprintf(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, buf);
2018 sprintf(WC->ImportantMessage, "%s", &buf[4]);
2024 DeleteHash(&WCC->attachments);
2027 * We may have been supplied with instructions regarding the location
2028 * to which we must return after posting. If found, go there.
2030 if (havebstr("return_to")) {
2031 http_redirect(bstr("return_to"));
2034 * If we were editing a page in a wiki room, go to that page now.
2036 else if (havebstr("wikipage")) {
2037 snprintf(buf, sizeof buf, "wiki?page=%s", bstr("wikipage"));
2041 * Otherwise, just go to the "read messages" loop.
2044 readloop("readnew");
2052 * \brief display the message entry screen
2054 void display_enter(void)
2059 const StrBuf *display_name = NULL;
2060 /////wc_attachment *att;
2061 int recipient_required = 0;
2062 int subject_required = 0;
2063 int recipient_bad = 0;
2064 int is_anonymous = 0;
2065 long existing_page = (-1L);
2066 struct wcsession *WCC = WC;
2070 if (havebstr("force_room")) {
2071 gotoroom(bstr("force_room"));
2074 display_name = sbstr("display_name");
2075 if (!strcmp(ChrPtr(display_name), "__ANONYMOUS__")) {
2076 display_name = NULL;
2080 /** First test to see whether this is a room that requires recipients to be entered */
2081 serv_puts("ENT0 0");
2082 serv_getln(buf, sizeof buf);
2084 if (!strncmp(buf, "570", 3)) { /** 570 means that we need a recipient here */
2085 recipient_required = 1;
2087 else if (buf[0] != '2') { /** Any other error means that we cannot continue */
2088 sprintf(WCC->ImportantMessage, "%s", &buf[4]);
2089 readloop("readnew");
2093 /* Is the server strongly recommending that the user enter a message subject? */
2094 if ((buf[3] != '\0') && (buf[4] != '\0')) {
2095 subject_required = extract_int(&buf[4], 1);
2099 * Are we perhaps in an address book view? If so, then an "enter
2100 * message" command really means "add new entry."
2102 if (WCC->wc_default_view == VIEW_ADDRESSBOOK) {
2103 do_edit_vcard(-1, "", "", WCC->wc_roomname);
2108 * Are we perhaps in a calendar room? If so, then an "enter
2109 * message" command really means "add new calendar item."
2111 if (WCC->wc_default_view == VIEW_CALENDAR) {
2112 display_edit_event();
2117 * Are we perhaps in a tasks view? If so, then an "enter
2118 * message" command really means "add new task."
2120 if (WCC->wc_default_view == VIEW_TASKS) {
2121 display_edit_task();
2126 * Otherwise proceed normally.
2127 * Do a custom room banner with no navbar...
2129 output_headers(1, 1, 2, 0, 0, 0);
2132 wprintf("<div id=\"banner\">\n");
2133 embed_room_banner(NULL, navbar_none);
2134 wprintf("</div>\n");
2135 wprintf("<div id=\"content\">\n"
2136 "<div class=\"fix_scrollbar_bug message \">");
2138 /* Now check our actual recipients if there are any */
2139 if (recipient_required) {
2140 const StrBuf *Recp = NULL;
2141 const StrBuf *Cc = NULL;
2142 const StrBuf *Bcc = NULL;
2143 const StrBuf *Wikipage = NULL;
2144 StrBuf *CmdBuf = NULL;;
2145 const char CMD[] = "ENT0 0|%s|%d|0||%s||%s|%s|%s";
2147 Recp = sbstr("recp");
2150 Wikipage = sbstr("wikipage");
2152 CmdBuf = NewStrBufPlain(NULL,
2155 StrLength(display_name) +
2158 StrLength(Wikipage));
2160 StrBufPrintf(CmdBuf,
2164 ChrPtr(display_name),
2168 serv_puts(ChrPtr(CmdBuf));
2169 serv_getln(buf, sizeof buf);
2170 FreeStrBuf(&CmdBuf);
2172 if (!strncmp(buf, "570", 3)) { /** 570 means we have an invalid recipient listed */
2173 if (havebstr("recp") &&
2179 else if (buf[0] != '2') { /** Any other error means that we cannot continue */
2180 wprintf("<em>%s</em><br />\n", &buf[4]);/// -> important message
2184 DoTemplate(HKEY("edit_message"), NULL, NULL, CTX_NONE);
2185 address_book_popup();
2192 /** If we got this far, we can display the message entry screen. */
2194 /* begin message entry screen */
2196 "enctype=\"multipart/form-data\" "
2198 "accept-charset=\"UTF-8\" "
2200 "name=\"enterform\""
2202 wprintf("<input type=\"hidden\" name=\"postseq\" value=\"%ld\">\n", now);
2203 if (WCC->wc_view == VIEW_WIKI) {
2204 wprintf("<input type=\"hidden\" name=\"wikipage\" value=\"%s\">\n", bstr("wikipage"));
2206 wprintf("<input type=\"hidden\" name=\"return_to\" value=\"%s\">\n", bstr("return_to"));
2207 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WCC->nonce);
2208 wprintf("<input type=\"hidden\" name=\"force_room\" value=\"");
2209 escputs(WCC->wc_roomname);
2211 wprintf("<input type=\"hidden\" name=\"references\" value=\"");
2212 escputs(bstr("references"));
2215 /** submit or cancel buttons */
2216 wprintf("<p class=\"send_edit_msg\">");
2217 wprintf("<input type=\"submit\" name=\"send_button\" value=\"");
2218 if (recipient_required) {
2219 wprintf(_("Send message"));
2221 wprintf(_("Post message"));
2224 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">\n", _("Cancel"));
2229 wprintf("<img src=\"static/newmess3_24x.gif\" class=\"imgedit\">");
2230 wprintf(" "); /** header bar */
2231 webcit_fmt_date(buf, now, 0);
2233 wprintf("\n"); /** header bar */
2235 wprintf("<table width=\"100%%\" class=\"edit_msg_table\">");
2237 wprintf("<th><label for=\"from_id\" > ");
2238 wprintf(_(" <I>from</I> "));
2239 wprintf("</label></th>");
2241 wprintf("<td colspan=\"2\">");
2243 /* Allow the user to select any of his valid screen names */
2245 wprintf("<select name=\"display_name\" size=1 id=\"from_id\">\n");
2248 serv_getln(buf, sizeof buf);
2249 if (buf[0] == '1') {
2250 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2251 wprintf("<option %s value=\"",
2252 ((!strcasecmp(bstr("display_name"), buf)) ? "selected" : "")
2257 wprintf("</option>\n");
2261 if (WCC->room_flags & QR_ANONOPT) {
2262 wprintf("<option %s value=\"__ANONYMOUS__\">%s</option>\n",
2263 ((!strcasecmp(bstr("__ANONYMOUS__"), WCC->wc_fullname)) ? "selected" : ""),
2268 wprintf("</select>\n");
2270 /* If this is an email (not a post), allow the user to select any of his
2271 * valid email addresses.
2273 if (recipient_required) {
2275 serv_getln(buf, sizeof buf);
2276 if (buf[0] == '1') {
2277 wprintf("<select name=\"my_email_addr\" size=1>\n");
2278 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2279 wprintf("<option value=\"");
2283 wprintf("></option>\n");
2285 wprintf("</select>\n");
2289 wprintf(_(" <I>in</I> "));
2290 escputs(WCC->wc_roomname);
2292 wprintf("</td></tr>");
2294 if (recipient_required) {
2298 wprintf("<tr><th><label for=\"recp_id\"> ");
2300 wprintf("</label></th>"
2301 "<td><input autocomplete=\"off\" type=\"text\" name=\"recp\" id=\"recp_id\" value=\"");
2302 ccraw = xbstr("recp", &len);
2303 copy = (char*) malloc(len * 2 + 1);
2304 memcpy(copy, ccraw, len + 1);
2305 utf8ify_rfc822_string(copy);
2308 wprintf("\" size=45 maxlength=1000 />");
2309 wprintf("<div class=\"auto_complete\" id=\"recp_name_choices\"></div>");
2310 wprintf("</td><td rowspan=\"3\" align=\"left\" valign=\"top\">");
2312 /** Pop open an address book -- begin **/
2314 "<a href=\"javascript:PopOpenAddressBook('recp_id|%s|cc_id|%s|bcc_id|%s');\" "
2316 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2318 _("To:"), _("CC:"), _("BCC:"),
2319 _("Contacts"), _("Contacts")
2321 /** Pop open an address book -- end **/
2323 wprintf("</td></tr>");
2325 wprintf("<tr><th><label for=\"cc_id\"> ");
2327 wprintf("</label></th>"
2328 "<td><input autocomplete=\"off\" type=\"text\" name=\"cc\" id=\"cc_id\" value=\"");
2329 ccraw = xbstr("cc", &len);
2330 copy = (char*) malloc(len * 2 + 1);
2331 memcpy(copy, ccraw, len + 1);
2332 utf8ify_rfc822_string(copy);
2335 wprintf("\" size=45 maxlength=1000 />");
2336 wprintf("<div class=\"auto_complete\" id=\"cc_name_choices\"></div>");
2337 wprintf("</td></tr>");
2339 wprintf("<tr><th><label for=\"bcc_id\"> ");
2341 wprintf("</label></th>"
2342 "<td><input autocomplete=\"off\" type=\"text\" name=\"bcc\" id=\"bcc_id\" value=\"");
2343 ccraw = xbstr("bcc", &len);
2344 copy = (char*) malloc(len * 2 + 1);
2345 memcpy(copy, ccraw, len + 1);
2346 utf8ify_rfc822_string(copy);
2349 wprintf("\" size=45 maxlength=1000 />");
2350 wprintf("<div class=\"auto_complete\" id=\"bcc_name_choices\"></div>");
2351 wprintf("</td></tr>");
2353 /** Initialize the autocomplete ajax helpers (found in wclib.js) */
2354 wprintf("<script type=\"text/javascript\"> \n"
2355 " activate_entmsg_autocompleters(); \n"
2361 wprintf("<tr><th><label for=\"subject_id\" > ");
2362 if (recipient_required || subject_required) {
2363 wprintf(_("Subject:"));
2366 wprintf(_("Subject (optional):"));
2368 wprintf("</label></th>"
2369 "<td colspan=\"2\">"
2370 "<input type=\"text\" name=\"subject\" id=\"subject_id\" value=\"");
2371 escputs(bstr("subject"));
2372 wprintf("\" size=45 maxlength=70>\n");
2373 wprintf("</td></tr>");
2375 wprintf("<tr><td colspan=\"3\">\n");
2377 wprintf("<textarea name=\"msgtext\" cols=\"80\" rows=\"15\">");
2379 /** If we're continuing from a previous edit, put our partially-composed message back... */
2380 msgescputs(bstr("msgtext"));
2382 /* If we're forwarding a message, insert it here... */
2383 if (lbstr("fwdquote") > 0L) {
2384 wprintf("<br><div align=center><i>");
2385 wprintf(_("--- forwarded message ---"));
2386 wprintf("</i></div><br>");
2387 pullquote_message(lbstr("fwdquote"), 1, 1);
2390 /** If we're replying quoted, insert the quote here... */
2391 else if (lbstr("replyquote") > 0L) {
2394 pullquote_message(lbstr("replyquote"), 0, 1);
2395 wprintf("</blockquote><br>");
2398 /** If we're editing a wiki page, insert the existing page here... */
2399 else if (WCC->wc_view == VIEW_WIKI) {
2400 safestrncpy(buf, bstr("wikipage"), sizeof buf);
2401 str_wiki_index(buf);
2402 existing_page = locate_message_by_uid(buf);
2403 if (existing_page >= 0L) {
2404 pullquote_message(existing_page, 1, 0);
2408 /** Insert our signature if appropriate... */
2409 if ( (WCC->is_mailbox) && !yesbstr("sig_inserted") ) {
2411 get_pref_yesno("use_sig", &UseSig, 0);
2414 const char *sig, *esig;
2416 get_preference("signature", &ebuf);
2418 StrBufEUid_unescapize(Sig, ebuf);
2420 esig = sig + StrLength(Sig);
2421 wprintf("<br>--<br>");
2422 while (sig <= esig) {
2426 else if (*sig == '<') {
2429 else if (*sig == '>') {
2432 else if (*sig == '&') {
2435 else if (*sig == '\"') {
2438 else if (*sig == '\'') {
2441 else /* since we're utf 8, is this a good idea? if (isprint(*sig))*/ {
2442 wprintf("%c", *sig);
2450 wprintf("</textarea>\n");
2452 /** Make sure we only insert our signature once */
2453 /** We don't care if it was there or not before, it needs to be there now. */
2454 wprintf("<input type=\"hidden\" name=\"sig_inserted\" value=\"yes\">\n");
2457 * The following template embeds the TinyMCE richedit control, and automatically
2458 * transforms the textarea into a richedit textarea.
2460 do_template("richedit", NULL);
2462 /** Enumerate any attachments which are already in place... */
2463 wprintf("<div class=\"attachment buttons\"><img src=\"static/diskette_24x.gif\" class=\"imgedit\" > ");
2464 wprintf(_("Attachments:"));
2466 wprintf("<select name=\"which_attachment\" size=1>");
2468 for (att = WCC->first_attachment; att != NULL; att = att->next) {
2469 wprintf("<option value=\"");
2470 urlescputs(att->filename);
2472 escputs(att->filename);
2473 / * wprintf(" (%s, %d bytes)",att->content_type,att->length); * /
2474 wprintf("</option>\n");
2477 wprintf("</select>");
2479 /** Now offer the ability to attach additional files... */
2480 wprintf(" ");
2481 wprintf(_("Attach file:"));
2482 wprintf(" <input name=\"attachfile\" class=\"attachfile\" "
2483 "size=16 type=\"file\">\n "
2484 "<input type=\"submit\" name=\"attach_button\" value=\"%s\">\n", _("Add"));
2485 wprintf("</div>"); /* End of "attachment buttons" div */
2488 wprintf("</td></tr></table>");
2490 wprintf("</form>\n");
2491 wprintf("</div>\n"); /* end of "fix_scrollbar_bug" div */
2493 /* NOTE: address_book_popup() will close the "content" div. Don't close it here. */
2494 DONE: address_book_popup();
2500 * \brief delete a message
2502 void delete_msg(void)
2507 msgid = lbstr("msgid");
2509 if (WC->wc_is_trash) { /** Delete from Trash is a real delete */
2510 serv_printf("DELE %ld", msgid);
2512 else { /** Otherwise move it to Trash */
2513 serv_printf("MOVE %ld|_TRASH_|0", msgid);
2516 serv_getln(buf, sizeof buf);
2517 sprintf(WC->ImportantMessage, "%s", &buf[4]);
2519 readloop("readnew");
2524 * \brief move a message to another folder
2531 msgid = lbstr("msgid");
2533 if (havebstr("move_button")) {
2534 sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
2536 serv_getln(buf, sizeof buf);
2537 sprintf(WC->ImportantMessage, "%s", &buf[4]);
2539 sprintf(WC->ImportantMessage, (_("The message was not moved.")));
2542 readloop("readnew");
2550 * Confirm move of a message
2552 void confirm_move_msg(void)
2558 msgid = lbstr("msgid");
2561 output_headers(1, 1, 2, 0, 0, 0);
2562 wprintf("<div id=\"banner\">\n");
2564 wprintf(_("Confirm move of message"));
2566 wprintf("</div>\n");
2568 wprintf("<div id=\"content\" class=\"service\">\n");
2570 wprintf("<CENTER>");
2572 wprintf(_("Move this message to:"));
2573 wprintf("<br />\n");
2575 wprintf("<form METHOD=\"POST\" action=\"move_msg\">\n");
2576 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2577 wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n", bstr("msgid"));
2579 wprintf("<SELECT NAME=\"target_room\" SIZE=5>\n");
2581 serv_getln(buf, sizeof buf);
2582 if (buf[0] == '1') {
2583 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2584 extract_token(targ, buf, 0, '|', sizeof targ);
2585 wprintf("<OPTION>");
2590 wprintf("</SELECT>\n");
2591 wprintf("<br />\n");
2593 wprintf("<INPUT TYPE=\"submit\" NAME=\"move_button\" VALUE=\"%s\">", _("Move"));
2595 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2596 wprintf("</form></CENTER>\n");
2598 wprintf("</CENTER>\n");
2602 void readnew(void) { readloop("readnew");}
2603 void readold(void) { readloop("readold");}
2604 void readfwd(void) { readloop("readfwd");}
2605 void headers(void) { readloop("headers");}
2606 void do_search(void) { readloop("do_search");}
2617 WebcitAddUrlHandler(HKEY("readnew"), readnew, 0);
2618 WebcitAddUrlHandler(HKEY("readold"), readold, 0);
2619 WebcitAddUrlHandler(HKEY("readfwd"), readfwd, 0);
2620 WebcitAddUrlHandler(HKEY("headers"), headers, 0);
2621 WebcitAddUrlHandler(HKEY("do_search"), do_search, 0);
2622 WebcitAddUrlHandler(HKEY("display_enter"), display_enter, 0);
2623 WebcitAddUrlHandler(HKEY("post"), post_message, 0);
2624 WebcitAddUrlHandler(HKEY("move_msg"), move_msg, 0);
2625 WebcitAddUrlHandler(HKEY("delete_msg"), delete_msg, 0);
2626 WebcitAddUrlHandler(HKEY("confirm_move_msg"), confirm_move_msg, 0);
2627 WebcitAddUrlHandler(HKEY("msg"), embed_message, NEED_URL|AJAX);
2628 WebcitAddUrlHandler(HKEY("printmsg"), print_message, NEED_URL);
2629 WebcitAddUrlHandler(HKEY("mobilemsg"), mobile_message_view, NEED_URL);
2630 WebcitAddUrlHandler(HKEY("msgheaders"), display_headers, NEED_URL);