5 * \defgroup MsgDisp Functions which deal with the fetching and displaying of messages.
6 * \ingroup WebcitDisplayItems
11 #include "webserver.h"
14 #define SUBJ_COL_WIDTH_PCT 50 /**< Mailbox view column width */
15 #define SENDER_COL_WIDTH_PCT 30 /**< Mailbox view column width */
16 #define DATE_PLUS_BUTTONS_WIDTH_PCT 20 /**< Mailbox view column width */
19 * Address book entry (keep it short and sweet, it's just a quickie lookup
20 * which we can use to get to the real meat and bones later)
23 char ab_name[64]; /**< name string */
24 long ab_msgnum; /**< message number of address book entry */
32 * \brief Wrapper around iconv_open()
33 * Our version adds aliases for non-standard Microsoft charsets
34 * such as 'MS950', aliasing them to names like 'CP950'
36 * \param tocode Target encoding
37 * \param fromcode Source encoding
39 iconv_t ctdl_iconv_open(const char *tocode, const char *fromcode)
41 iconv_t ic = (iconv_t)(-1) ;
42 ic = iconv_open(tocode, fromcode);
43 if (ic == (iconv_t)(-1) ) {
44 char alias_fromcode[64];
45 if ( (strlen(fromcode) == 5) && (!strncasecmp(fromcode, "MS", 2)) ) {
46 safestrncpy(alias_fromcode, fromcode, sizeof alias_fromcode);
47 alias_fromcode[0] = 'C';
48 alias_fromcode[1] = 'P';
49 ic = iconv_open(tocode, alias_fromcode);
57 * \brief Handle subjects with RFC2047 encoding
59 * =?koi8-r?B?78bP0s3Mxc7JxSDXz9rE1dvO2c3JINvB0sHNySDP?=
60 * \param buf the stringbuffer to process
62 void utf8ify_rfc822_string(char *buf) {
68 iconv_t ic = (iconv_t)(-1) ;
69 char *ibuf; /**< Buffer of characters to be converted */
70 char *obuf; /**< Buffer for converted characters */
71 size_t ibuflen; /**< Length of input buffer */
72 size_t obuflen; /**< Length of output buffer */
73 char *isav; /**< Saved pointer to input buffer */
74 char *osav; /**< Saved pointer to output buffer */
77 int illegal_non_rfc2047_encoding = 0;
79 /** Sometimes, badly formed messages contain strings which were simply
80 * written out directly in some foreign character set instead of
81 * using RFC2047 encoding. This is illegal but we will attempt to
82 * handle it anyway by converting from a user-specified default
83 * charset to UTF-8 if we see any nonprintable characters.
86 for (i=0; i<len; ++i) {
87 if ((buf[i] < 32) || (buf[i] > 126)) {
88 illegal_non_rfc2047_encoding = 1;
89 i = len; ///< take a shortcut, it won't be more than one.
92 if (illegal_non_rfc2047_encoding) {
93 char default_header_charset[128];
94 get_preference("default_header_charset", default_header_charset, sizeof default_header_charset);
95 if ( (strcasecmp(default_header_charset, "UTF-8")) && (strcasecmp(default_header_charset, "us-ascii")) ) {
96 ic = ctdl_iconv_open("UTF-8", default_header_charset);
97 if (ic != (iconv_t)(-1) ) {
100 safestrncpy(ibuf, buf, 1024);
101 ibuflen = strlen(ibuf);
103 obuf = (char *) malloc(obuflen);
105 iconv(ic, &ibuf, &ibuflen, &obuf, &obuflen);
106 osav[1024-obuflen] = 0;
115 /** Now we handle foreign character sets properly encoded
118 while (start=strstr(buf, "=?"), end=strstr(buf, "?="),
119 ((start != NULL) && (end != NULL) && (end > start)) )
121 extract_token(charset, start, 1, '?', sizeof charset);
122 extract_token(encoding, start, 2, '?', sizeof encoding);
123 extract_token(istr, start, 3, '?', sizeof istr);
127 if (!strcasecmp(encoding, "B")) { /**< base64 */
128 ibuflen = CtdlDecodeBase64(ibuf, istr, strlen(istr));
130 else if (!strcasecmp(encoding, "Q")) { /**< quoted-printable */
138 if (istr[pos] == '_') istr[pos] = ' ';
142 ibuflen = CtdlDecodeQuotedPrintable(ibuf, istr, len);
145 strcpy(ibuf, istr); /**< unknown encoding */
146 ibuflen = strlen(istr);
149 ic = ctdl_iconv_open("UTF-8", charset);
150 if (ic != (iconv_t)(-1) ) {
152 obuf = (char *) malloc(obuflen);
154 iconv(ic, &ibuf, &ibuflen, &obuf, &obuflen);
155 osav[1024-obuflen] = 0;
160 remove_token(end, 0, '?');
161 remove_token(end, 0, '?');
162 remove_token(end, 0, '?');
163 remove_token(end, 0, '?');
164 strcpy(end, &end[1]);
166 snprintf(newbuf, sizeof newbuf, "%s%s%s", buf, osav, end);
175 remove_token(end, 0, '?');
176 remove_token(end, 0, '?');
177 remove_token(end, 0, '?');
178 remove_token(end, 0, '?');
179 strcpy(end, &end[1]);
181 snprintf(newbuf, sizeof newbuf, "%s(unreadable)%s", buf, end);
188 * Since spammers will go to all sorts of absurd lengths to get their
189 * messages through, there are LOTS of corrupt headers out there.
190 * So, prevent a really badly formed RFC2047 header from throwing
191 * this function into an infinite loop.
194 if (passes > 20) return;
204 * \brief RFC2047-encode a header field if necessary.
205 * If no non-ASCII characters are found, the string
206 * will be copied verbatim without encoding.
208 * \param target Target buffer.
209 * \param maxlen Maximum size of target buffer.
210 * \param source Source string to be encoded.
212 void webcit_rfc2047encode(char *target, int maxlen, char *source)
214 int need_to_encode = 0;
218 if (target == NULL) return;
219 len = strlen(source);
220 for (i=0; i<len; ++i) {
221 if ((source[i] < 32) || (source[i] > 126)) {
223 i = len; ///< shortcut. won't become more than 1
227 if (!need_to_encode) {
228 safestrncpy(target, source, maxlen);
232 strcpy(target, "=?UTF-8?Q?");
233 for (i=0; i<len; ++i) {
234 ch = (unsigned char) source[i];
235 if ((ch < 32) || (ch > 126) || (ch == 61)) {
236 sprintf(&target[strlen(target)], "=%02X", ch);
239 sprintf(&target[strlen(target)], "%c", ch);
243 strcat(target, "?=");
250 * \brief Look for URL's embedded in a buffer and make them linkable. We use a
251 * target window in order to keep the BBS session in its own window.
252 * \param buf the message buffer
257 char *start, *end, *pos;
264 for (pos = buf; (pos < end) && (start == NULL); ++pos) {
265 if (!strncasecmp(pos, "http://", 7))
267 if (!strncasecmp(pos, "ftp://", 6))
274 for (pos = buf+len; pos > start; --pos) {
275 if ( (!isprint(*pos))
294 strncpy(urlbuf, start, end - start);
295 urlbuf[end - start] = '\0';
298 strncpy(outbuf, buf, start - buf );
299 sprintf(&outbuf[start-buf], "%ca href=%c%s%c TARGET=%c%s%c%c%s%c/A%c",
300 LB, QU, urlbuf, QU, QU, TARGET, QU, RB, urlbuf, LB, RB);
302 if ( strlen(outbuf) < 250 )
308 * \brief Turn a vCard "n" (name) field into something displayable.
309 * \param name the name field to convert
311 void vcard_n_prettyize(char *name)
316 original_name = strdup(name);
317 len = strlen(original_name);
318 for (i=0; i<5; ++i) {
320 if (original_name[len-1] == ' ') {
321 original_name[--len] = 0;
323 if (original_name[len-1] == ';') {
324 original_name[--len] = 0;
330 for (i=0; i<len; ++i) {
331 if (original_name[i] == ';') {
336 name[j++] = original_name[i];
347 * \brief preparse a vcard name
348 * display_vcard() calls this after parsing the textual vCard into
349 * our 'struct vCard' data object.
350 * This gets called instead of display_parsed_vcard() if we are only looking
351 * to extract the person's name instead of displaying the card.
352 * \param v the vcard to retrieve the name from
353 * \param storename where to put the name at
355 void fetchname_parsed_vcard(struct vCard *v, char *storename) {
358 strcpy(storename, "");
360 name = vcard_get_prop(v, "n", 1, 0, 0);
362 strcpy(storename, name);
363 /* vcard_n_prettyize(storename); */
371 * \brief html print a vcard
372 * display_vcard() calls this after parsing the textual vCard into
373 * our 'struct vCard' data object.
375 * Set 'full' to nonzero to display the full card, otherwise it will only
376 * show a summary line.
378 * This code is a bit ugly, so perhaps an explanation is due: we do this
379 * in two passes through the vCard fields. On the first pass, we process
380 * fields we understand, and then render them in a pretty fashion at the
381 * end. Then we make a second pass, outputting all the fields we don't
382 * understand in a simple two-column name/value format.
383 * \param v the vCard to display
384 * \param full display all items of the vcard?
386 void display_parsed_vcard(struct vCard *v, int full) {
392 char *thisname, *thisvalue;
393 char firsttoken[SIZ];
402 strcpy(fullname, "");
410 name = vcard_get_prop(v, "fn", 1, 0, 0);
414 else if (name = vcard_get_prop(v, "n", 1, 0, 0), name != NULL) {
415 strcpy(fullname, name);
416 vcard_n_prettyize(fullname);
426 wprintf("<div align=center>"
427 "<table bgcolor=#aaaaaa width=50%%>");
428 for (pass=1; pass<=2; ++pass) {
430 if (v->numprops) for (i=0; i<(v->numprops); ++i) {
432 thisname = strdup(v->prop[i].name);
433 extract_token(firsttoken, thisname, 0, ';', sizeof firsttoken);
435 for (j=0; j<num_tokens(thisname, ';'); ++j) {
436 extract_token(buf, thisname, j, ';', sizeof buf);
437 if (!strcasecmp(buf, "encoding=quoted-printable")) {
439 remove_token(thisname, j, ';');
441 if (!strcasecmp(buf, "encoding=base64")) {
443 remove_token(thisname, j, ';');
447 len = strlen(v->prop[i].value);
450 // %ff can become 6 bytes in utf8
451 thisvalue = malloc(len * 2 + 3);
452 j = CtdlDecodeQuotedPrintable(
453 thisvalue, v->prop[i].value,
458 // ff will become one byte..
459 thisvalue = malloc(len + 50);
461 thisvalue, v->prop[i].value,
462 strlen(v->prop[i].value) );
465 thisvalue = strdup(v->prop[i].value);
468 /** Various fields we may encounter ***/
470 /** N is name, but only if there's no FN already there */
471 if (!strcasecmp(firsttoken, "n")) {
472 if (IsEmptyStr(fullname)) {
473 strcpy(fullname, thisvalue);
474 vcard_n_prettyize(fullname);
478 /** FN (full name) is a true 'display name' field */
479 else if (!strcasecmp(firsttoken, "fn")) {
480 strcpy(fullname, thisvalue);
484 else if (!strcasecmp(firsttoken, "title")) {
485 strcpy(title, thisvalue);
489 else if (!strcasecmp(firsttoken, "org")) {
490 strcpy(org, thisvalue);
493 else if (!strcasecmp(firsttoken, "email")) {
495 if (!IsEmptyStr(mailto)) strcat(mailto, "<br />");
497 "<a href=\"display_enter"
498 "?force_room=_MAIL_?recp=");
500 len = strlen(mailto);
501 urlesc(&mailto[len], SIZ - len, fullname);
502 len = strlen(mailto);
503 urlesc(&mailto[len], SIZ - len, " <");
504 len = strlen(mailto);
505 urlesc(&mailto[len], SIZ - len, thisvalue);
506 len = strlen(mailto);
507 urlesc(&mailto[len], SIZ - len, ">");
509 strcat(mailto, "\">");
510 len = strlen(mailto);
511 stresc(mailto+len, SIZ - len, thisvalue, 1, 1);
512 strcat(mailto, "</A>");
514 else if (!strcasecmp(firsttoken, "tel")) {
515 if (!IsEmptyStr(phone)) strcat(phone, "<br />");
516 strcat(phone, thisvalue);
517 for (j=0; j<num_tokens(thisname, ';'); ++j) {
518 extract_token(buf, thisname, j, ';', sizeof buf);
519 if (!strcasecmp(buf, "tel"))
521 else if (!strcasecmp(buf, "work"))
522 strcat(phone, _(" (work)"));
523 else if (!strcasecmp(buf, "home"))
524 strcat(phone, _(" (home)"));
525 else if (!strcasecmp(buf, "cell"))
526 strcat(phone, _(" (cell)"));
534 else if (!strcasecmp(firsttoken, "adr")) {
537 wprintf(_("Address:"));
538 wprintf("</TD><TD>");
539 for (j=0; j<num_tokens(thisvalue, ';'); ++j) {
540 extract_token(buf, thisvalue, j, ';', sizeof buf);
541 if (!IsEmptyStr(buf)) {
543 if (j<3) wprintf("<br />");
547 wprintf("</TD></TR>\n");
550 else if (!strcasecmp(firsttoken, "version")) {
553 else if (!strcasecmp(firsttoken, "rev")) {
556 else if (!strcasecmp(firsttoken, "label")) {
561 /*** Don't show extra fields. They're ugly.
565 wprintf("</TD><TD>");
567 wprintf("</TD></TR>\n");
577 wprintf("<TR BGCOLOR=\"#AAAAAA\">"
578 "<TD COLSPAN=2 BGCOLOR=\"#FFFFFF\">"
579 "<IMG ALIGN=CENTER src=\"static/viewcontacts_48x.gif\">"
580 "<FONT SIZE=+1><B>");
582 wprintf("</B></FONT>");
583 if (!IsEmptyStr(title)) {
584 wprintf("<div align=right>");
588 if (!IsEmptyStr(org)) {
589 wprintf("<div align=right>");
593 wprintf("</TD></TR>\n");
595 if (!IsEmptyStr(phone)) {
597 wprintf(_("Telephone:"));
598 wprintf("</td><td>%s</td></tr>\n", phone);
600 if (!IsEmptyStr(mailto)) {
602 wprintf(_("E-mail:"));
603 wprintf("</td><td>%s</td></tr>\n", mailto);
609 wprintf("</table></div>\n");
615 * \brief Display a textual vCard
616 * (Converts to a vCard object and then calls the actual display function)
617 * Set 'full' to nonzero to display the whole card instead of a one-liner.
618 * Or, if "storename" is non-NULL, just store the person's name in that
619 * buffer instead of displaying the card at all.
620 * \param vcard_source the buffer containing the vcard text
621 * \param alpha what???
622 * \param full should we usse all lines?
623 * \param storename where to store???
625 void display_vcard(char *vcard_source, char alpha, int full, char *storename) {
631 v = vcard_load(vcard_source);
632 if (v == NULL) return;
634 name = vcard_get_prop(v, "n", 1, 0, 0);
640 if (storename != NULL) {
641 fetchname_parsed_vcard(v, storename);
643 else if ( (alpha == 0)
644 || ((isalpha(alpha)) && (tolower(alpha) == tolower(this_alpha)) )
645 || ((!isalpha(alpha)) && (!isalpha(this_alpha)))
647 display_parsed_vcard(v, full);
661 * \brief I wanna SEE that message!
662 * \param msgnum the citadel number of the message to display
663 * \param printable_view are we doing a print view?
664 * \param section Optional for encapsulated message/rfc822 submessage)
666 void read_message(long msgnum, int printable_view, char *section) {
668 char mime_partnum[256];
670 char mime_filename[256];
671 char escaped_mime_filename[256];
672 char mime_content_type[256];
673 char mime_charset[256];
674 char mime_disposition[256];
676 struct attach_link *attach_links = NULL;
677 int num_attach_links = 0;
678 char mime_submessages[256];
685 char reply_all[4096];
691 char vcard_partnum[256];
692 char cal_partnum[256];
693 char *part_source = NULL;
694 char msg4_partnum[32];
696 iconv_t ic = (iconv_t)(-1) ;
697 char *ibuf; /**< Buffer of characters to be converted */
698 char *obuf; /**< Buffer for converted characters */
699 size_t ibuflen; /**< Length of input buffer */
700 size_t obuflen; /**< Length of output buffer */
701 char *osav; /**< Saved pointer to output buffer */
707 strcpy(reply_to, "");
708 strcpy(reply_all, "");
709 strcpy(vcard_partnum, "");
710 strcpy(cal_partnum, "");
711 strcpy(mime_content_type, "text/plain");
712 strcpy(mime_charset, "us-ascii");
713 strcpy(mime_submessages, "");
715 serv_printf("MSG4 %ld|%s", msgnum, section);
716 serv_getln(buf, sizeof buf);
719 wprintf(_("ERROR:"));
720 wprintf("</strong> %s<br />\n", &buf[4]);
724 /** begin everythingamundo table */
725 if (!printable_view) {
726 wprintf("<div class=\"fix_scrollbar_bug message\" ");
727 wprintf("onMouseOver=document.getElementById(\"msg%ld\").style.visibility=\"visible\" ", msgnum);
728 wprintf("onMouseOut=document.getElementById(\"msg%ld\").style.visibility=\"hidden\" >", msgnum);
731 /** begin message header table */
732 wprintf("<div class=\"message_header\">");
734 strcpy(m_subject, "");
737 while (serv_getln(buf, sizeof buf), strcasecmp(buf, "text")) {
738 if (!strcmp(buf, "000")) {
740 wprintf(_("unexpected end of message"));
741 wprintf(" (1)</i><br /><br />\n");
745 if (!strncasecmp(buf, "nhdr=yes", 8))
749 if (!strncasecmp(buf, "type=", 5))
750 format_type = atoi(&buf[5]);
751 if (!strncasecmp(buf, "from=", 5)) {
752 strcpy(from, &buf[5]);
754 wprintf("<a href=\"showuser?who=");
756 utf8ify_rfc822_string(from);
763 if (!strncasecmp(buf, "subj=", 5)) {
764 safestrncpy(m_subject, &buf[5], sizeof m_subject);
766 if (!strncasecmp(buf, "cccc=", 5)) {
768 safestrncpy(m_cc, &buf[5], sizeof m_cc);
769 if (!IsEmptyStr(reply_all)) {
770 strcat(reply_all, ", ");
772 len = strlen(reply_all);
773 safestrncpy(&reply_all[len], &buf[5],
774 (sizeof reply_all - len) );
776 if ((!strncasecmp(buf, "hnod=", 5))
777 && (strcasecmp(&buf[5], serv_info.serv_humannode))) {
778 wprintf("(%s) ", &buf[5]);
780 if ((!strncasecmp(buf, "room=", 5))
781 && (strcasecmp(&buf[5], WC->wc_roomname))
782 && (!IsEmptyStr(&buf[5])) ) {
784 wprintf("%s> ", &buf[5]);
786 if (!strncasecmp(buf, "rfca=", 5)) {
787 strcpy(rfca, &buf[5]);
793 if (!strncasecmp(buf, "node=", 5)) {
794 strcpy(node, &buf[5]);
795 if ( ((WC->room_flags & QR_NETWORK)
796 || ((strcasecmp(&buf[5], serv_info.serv_nodename)
797 && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
798 && (IsEmptyStr(rfca))
800 wprintf("@%s ", &buf[5]);
803 if (!strncasecmp(buf, "rcpt=", 5)) {
806 if (!IsEmptyStr(reply_all)) {
807 strcat(reply_all, ", ");
809 len = strlen(reply_all);
810 safestrncpy(&reply_all[len], &buf[5],
811 (sizeof reply_all - len) );
813 utf8ify_rfc822_string(&buf[5]);
818 if (!strncasecmp(buf, "time=", 5)) {
819 webcit_fmt_date(now, atol(&buf[5]), 0);
825 if (!strncasecmp(buf, "part=", 5)) {
826 extract_token(mime_name, &buf[5], 0, '|', sizeof mime_filename);
827 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
828 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
829 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
830 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
831 mime_length = extract_int(&buf[5], 5);
834 striplt(mime_filename);
835 if ( (IsEmptyStr(mime_filename)) && (!IsEmptyStr(mime_name)) ) {
836 strcpy(mime_filename, mime_name);
839 if (!strcasecmp(mime_content_type, "message/rfc822")) {
840 if (!IsEmptyStr(mime_submessages)) {
841 strcat(mime_submessages, "|");
843 strcat(mime_submessages, mime_partnum);
845 else if ((!strcasecmp(mime_disposition, "inline"))
846 && (!strncasecmp(mime_content_type, "image/", 6)) ){
848 attach_links = realloc(attach_links,
849 (num_attach_links*sizeof(struct attach_link)));
850 safestrncpy(attach_links[num_attach_links-1].partnum, mime_partnum, 32);
851 snprintf(attach_links[num_attach_links-1].html, 1024,
852 "<img src=\"mimepart/%ld/%s/%s\">",
853 msgnum, mime_partnum, mime_filename);
855 else if ( ( (!strcasecmp(mime_disposition, "attachment"))
856 || (!strcasecmp(mime_disposition, "inline"))
857 || (!strcasecmp(mime_disposition, ""))
858 ) && (!IsEmptyStr(mime_content_type))
861 attach_links = realloc(attach_links,
862 (num_attach_links*sizeof(struct attach_link)));
863 safestrncpy(attach_links[num_attach_links-1].partnum, mime_partnum, 32);
864 urlesc(escaped_mime_filename, 265, mime_filename);
865 snprintf(attach_links[num_attach_links-1].html, 1024,
866 "<img src=\"static/diskette_24x.gif\" "
867 "border=0 align=middle>\n"
868 "%s (%s, %d bytes) [ "
869 "<a href=\"mimepart/%ld/%s/%s\""
870 "target=\"wc.%ld.%s\">%s</a>"
872 "<a href=\"mimepart_download/%ld/%s/%s\">%s</a>"
875 mime_content_type, mime_length,
876 msgnum, mime_partnum, escaped_mime_filename,
877 msgnum, mime_partnum,
879 msgnum, mime_partnum, escaped_mime_filename,
884 /** begin handler prep ***/
885 if ( (!strcasecmp(mime_content_type, "text/x-vcard"))
886 || (!strcasecmp(mime_content_type, "text/vcard")) ) {
887 strcpy(vcard_partnum, mime_partnum);
890 if ( (!strcasecmp(mime_content_type, "text/calendar"))
891 || (!strcasecmp(mime_content_type, "application/ics")) ) {
892 strcpy(cal_partnum, mime_partnum);
895 /** end handler prep ***/
901 /** Generate a reply-to address */
902 if (!IsEmptyStr(rfca)) {
903 if (!IsEmptyStr(from)) {
904 snprintf(reply_to, sizeof(reply_to), "%s <%s>", from, rfca);
907 strcpy(reply_to, rfca);
911 if ((!IsEmptyStr(node))
912 && (strcasecmp(node, serv_info.serv_nodename))
913 && (strcasecmp(node, serv_info.serv_humannode)) ) {
914 snprintf(reply_to, sizeof(reply_to), "%s @ %s",
918 snprintf(reply_to, sizeof(reply_to), "%s", from);
927 utf8ify_rfc822_string(m_cc);
928 utf8ify_rfc822_string(m_subject);
931 /** start msg buttons */
933 if (!printable_view) {
934 wprintf("<p id=\"msg%ld\" class=\"msgbuttons\" >\n",msgnum);
937 if ( (WC->wc_view == VIEW_MAILBOX) || (WC->wc_view == VIEW_BBS) ) {
938 wprintf("<a href=\"display_enter");
939 if (WC->is_mailbox) {
940 wprintf("?replyquote=%ld", msgnum);
943 urlescputs(reply_to);
944 if (!IsEmptyStr(m_subject)) {
945 wprintf("?subject=");
946 if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
947 urlescputs(m_subject);
949 wprintf("\"><span>[</span>%s<span>]</span></a> ", _("Reply"));
953 if ( (WC->wc_view == VIEW_MAILBOX) || (WC->wc_view == VIEW_BBS) ) {
954 if (!WC->is_mailbox) {
955 wprintf("<a href=\"display_enter");
956 wprintf("?replyquote=%ld", msgnum);
958 urlescputs(reply_to);
959 if (!IsEmptyStr(m_subject)) {
960 wprintf("?subject=");
961 if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
962 urlescputs(m_subject);
964 wprintf("\"><span>[</span>%s<span>]</span></a> ", _("ReplyQuoted"));
969 if (WC->wc_view == VIEW_MAILBOX) {
970 wprintf("<a href=\"display_enter");
971 wprintf("?replyquote=%ld", msgnum);
973 urlescputs(reply_to);
975 urlescputs(reply_all);
976 if (!IsEmptyStr(m_subject)) {
977 wprintf("?subject=");
978 if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
979 urlescputs(m_subject);
981 wprintf("\"><span>[</span>%s<span>]</span></a> ", _("ReplyAll"));
985 if (WC->wc_view == VIEW_MAILBOX) {
986 wprintf("<a href=\"display_enter?fwdquote=%ld?subject=", msgnum);
987 if (strncasecmp(m_subject, "Fwd:", 4)) wprintf("Fwd:%20");
988 urlescputs(m_subject);
989 wprintf("\"><span>[</span>%s<span>]</span></a> ", _("Forward"));
992 /** If this is one of my own rooms, or if I'm an Aide or Room Aide, I can move/delete */
993 if ( (WC->is_room_aide) || (WC->is_mailbox) || (WC->room_flags2 & QR2_COLLABDEL) ) {
995 wprintf("<a href=\"confirm_move_msg?msgid=%ld\"><span>[</span>%s<span>]</span></a> ",
999 wprintf("<a href=\"delete_msg?msgid=%ld\" "
1000 "onClick=\"return confirm('%s');\">"
1001 "<span>[</span>%s<span>]</span> "
1002 "</a> ", msgnum, _("Delete this message?"), _("Delete")
1007 wprintf("<a href=\"#\" onClick=\"window.open('msgheaders/%ld', 'headers%ld', 'toolbar=no,location=no,directories=no,copyhistory=no,status=yes,scrollbars=yes,resizable=yes,width=600,height=400'); \" >"
1008 "<span>[</span>%s<span>]</span></a>", msgnum, msgnum, _("Headers"));
1012 wprintf("<a href=\"#\" onClick=\"window.open('printmsg/%ld', 'print%ld', 'toolbar=no,location=no,directories=no,copyhistory=no,status=yes,scrollbars=yes,resizable=yes,width=600,height=400'); \" >"
1013 "<span>[</span>%s<span>]</span></a>", msgnum, msgnum, _("Print"));
1019 if (!IsEmptyStr(m_cc)) {
1026 if (!IsEmptyStr(m_subject)) {
1027 wprintf("<p class=\"message_subject\">");
1028 wprintf(_("Subject:"));
1037 wprintf("<div class=\"message_content\">");
1040 * Learn the content type
1042 strcpy(mime_content_type, "text/plain");
1043 while (serv_getln(buf, sizeof buf), (!IsEmptyStr(buf))) {
1044 if (!strcmp(buf, "000")) {
1046 wprintf(_("unexpected end of message"));
1047 wprintf(" (2)</i><br /><br />\n");
1050 if (!strncasecmp(buf, "X-Citadel-MSG4-Partnum:", 23)) {
1051 safestrncpy(msg4_partnum, &buf[23], sizeof(msg4_partnum));
1052 striplt(msg4_partnum);
1054 if (!strncasecmp(buf, "Content-type:", 13)) {
1056 safestrncpy(mime_content_type, &buf[13], sizeof(mime_content_type));
1057 striplt(mime_content_type);
1058 len = strlen(mime_content_type);
1059 for (i=0; i<len; ++i) {
1060 if (!strncasecmp(&mime_content_type[i], "charset=", 8)) {
1061 safestrncpy(mime_charset, &mime_content_type[i+8],
1062 sizeof mime_charset);
1065 for (i=0; i<len; ++i) {
1066 if (mime_content_type[i] == ';') {
1067 mime_content_type[i] = 0;
1071 len = strlen(mime_charset);
1072 for (i=0; i<len; ++i) {
1073 if (mime_charset[i] == ';') {
1074 mime_charset[i] = 0;
1081 /** Set up a character set conversion if we need to (and if we can) */
1083 if (strchr(mime_charset, ';')) strcpy(strchr(mime_charset, ';'), "");
1084 if ( (strcasecmp(mime_charset, "us-ascii"))
1085 && (strcasecmp(mime_charset, "UTF-8"))
1086 && (strcasecmp(mime_charset, ""))
1088 ic = ctdl_iconv_open("UTF-8", mime_charset);
1089 if (ic == (iconv_t)(-1) ) {
1090 lprintf(5, "%s:%d iconv_open(UTF-8, %s) failed: %s\n",
1091 __FILE__, __LINE__, mime_charset, strerror(errno));
1096 /** Messages in legacy Citadel variformat get handled thusly... */
1097 if (!strcasecmp(mime_content_type, "text/x-citadel-variformat")) {
1101 /** Boring old 80-column fixed format text gets handled this way... */
1102 else if ( (!strcasecmp(mime_content_type, "text/plain"))
1103 || (!strcasecmp(mime_content_type, "text")) ) {
1105 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1108 if ((len > 0) && buf[len-1] == '\n') buf[--len] = 0;
1109 if ((len > 0) && buf[len-1] == '\r') buf[--len] = 0;
1112 if (ic != (iconv_t)(-1) ) {
1114 ibuflen = strlen(ibuf);
1116 obuf = (char *) malloc(obuflen);
1118 iconv(ic, &ibuf, &ibuflen, &obuf, &obuflen);
1119 osav[SIZ-obuflen] = 0;
1120 safestrncpy(buf, osav, sizeof buf);
1126 while ((!IsEmptyStr(buf)) && (isspace(buf[len-1])))
1129 ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) )) {
1130 wprintf("<blockquote>");
1132 } else if ((bq == 1) &&
1133 (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) ) {
1134 wprintf("</blockquote>");
1140 wprintf("</tt><br />\n");
1142 wprintf("</i><br />");
1145 else /** HTML is fun, but we've got to strip it first */
1146 if (!strcasecmp(mime_content_type, "text/html")) {
1147 output_html(mime_charset, (WC->wc_view == VIEW_WIKI ? 1 : 0));
1150 /** Unknown weirdness */
1152 wprintf(_("I don't know how to display %s"), mime_content_type);
1153 wprintf("<br />\n", mime_content_type);
1154 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { }
1157 /** If there are attached submessages, display them now... */
1158 if ( (!IsEmptyStr(mime_submessages)) && (!section[0]) ) {
1159 for (i=0; i<num_tokens(mime_submessages, '|'); ++i) {
1160 extract_token(buf, mime_submessages, i, '|', sizeof buf);
1161 /** use printable_view to suppress buttons */
1162 wprintf("<blockquote>");
1163 read_message(msgnum, 1, buf);
1164 wprintf("</blockquote>");
1169 /** Afterwards, offer links to download attachments 'n' such */
1170 if ( (num_attach_links > 0) && (!section[0]) ) {
1171 for (i=0; i<num_attach_links; ++i) {
1172 if (strcasecmp(attach_links[i].partnum, msg4_partnum)) {
1173 wprintf("%s", attach_links[i].html);
1178 /** Handler for vCard parts */
1179 if (!IsEmptyStr(vcard_partnum)) {
1180 part_source = load_mimepart(msgnum, vcard_partnum);
1181 if (part_source != NULL) {
1183 /** If it's my vCard I can edit it */
1184 if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
1185 || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))
1186 || (WC->wc_view == VIEW_ADDRESSBOOK)
1188 wprintf("<a href=\"edit_vcard?"
1189 "msgnum=%ld?partnum=%s\">",
1190 msgnum, vcard_partnum);
1191 wprintf("[%s]</a>", _("edit"));
1194 /** In all cases, display the full card */
1195 display_vcard(part_source, 0, 1, NULL);
1199 /** Handler for calendar parts */
1200 if (!IsEmptyStr(cal_partnum)) {
1201 part_source = load_mimepart(msgnum, cal_partnum);
1202 if (part_source != NULL) {
1203 cal_process_attachment(part_source,
1204 msgnum, cal_partnum);
1214 wprintf("</div>\n");
1216 /** end everythingamundo table */
1217 if (!printable_view) {
1218 wprintf("</div>\n");
1221 if (num_attach_links > 0) {
1226 if (ic != (iconv_t)(-1) ) {
1235 * \brief Unadorned HTML output of an individual message, suitable
1236 * for placing in a hidden iframe, for printing, or whatever
1238 * \param msgnum_as_string Message number, as a string instead of as a long int
1240 void embed_message(char *msgnum_as_string) {
1243 msgnum = atol(msgnum_as_string);
1244 begin_ajax_response();
1245 read_message(msgnum, 0, "");
1246 end_ajax_response();
1251 * \brief Printable view of a message
1253 * \param msgnum_as_string Message number, as a string instead of as a long int
1255 void print_message(char *msgnum_as_string) {
1258 msgnum = atol(msgnum_as_string);
1259 output_headers(0, 0, 0, 0, 0, 0);
1261 wprintf("Content-type: text/html\r\n"
1263 "Connection: close\r\n",
1267 wprintf("\r\n\r\n<html>\n"
1268 "<head><title>Printable view</title></head>\n"
1269 "<body onLoad=\" window.print(); window.close(); \">\n"
1272 read_message(msgnum, 1, "");
1274 wprintf("\n</body></html>\n\n");
1281 * \brief Display a message's headers
1283 * \param msgnum_as_string Message number, as a string instead of as a long int
1285 void display_headers(char *msgnum_as_string) {
1289 msgnum = atol(msgnum_as_string);
1290 output_headers(0, 0, 0, 0, 0, 0);
1292 wprintf("Content-type: text/plain\r\n"
1294 "Connection: close\r\n",
1298 serv_printf("MSG2 %ld|3", msgnum);
1299 serv_getln(buf, sizeof buf);
1300 if (buf[0] == '1') {
1301 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1302 wprintf("%s\n", buf);
1312 * \brief Read message in simple, JavaScript-embeddable form for 'forward'
1313 * or 'reply quoted' operations.
1315 * NOTE: it is VITALLY IMPORTANT that we output no single-quotes or linebreaks
1316 * in this function. Doing so would throw a JavaScript error in the
1317 * 'supplied text' argument to the editor.
1319 * \param msgnum Message number of the message we want to quote
1320 * \param forward_attachments Nonzero if we want attachments to be forwarded
1322 void pullquote_message(long msgnum, int forward_attachments, int include_headers) {
1324 char mime_partnum[256];
1325 char mime_filename[256];
1326 char mime_content_type[256];
1327 char mime_charset[256];
1328 char mime_disposition[256];
1330 char *attachments = NULL;
1332 int num_attachments = 0;
1333 struct wc_attachment *att, *aptr;
1334 char m_subject[256];
1340 int format_type = 0;
1345 iconv_t ic = (iconv_t)(-1) ;
1346 char *ibuf; /**< Buffer of characters to be converted */
1347 char *obuf; /**< Buffer for converted characters */
1348 size_t ibuflen; /**< Length of input buffer */
1349 size_t obuflen; /**< Length of output buffer */
1350 char *osav; /**< Saved pointer to output buffer */
1356 strcpy(reply_to, "");
1357 strcpy(mime_content_type, "text/plain");
1358 strcpy(mime_charset, "us-ascii");
1360 serv_printf("MSG4 %ld", msgnum);
1361 serv_getln(buf, sizeof buf);
1362 if (buf[0] != '1') {
1363 wprintf(_("ERROR:"));
1364 wprintf("%s<br />", &buf[4]);
1368 strcpy(m_subject, "");
1370 while (serv_getln(buf, sizeof buf), strcasecmp(buf, "text")) {
1371 if (!strcmp(buf, "000")) {
1372 wprintf("%s (3)", _("unexpected end of message"));
1375 if (include_headers) {
1376 if (!strncasecmp(buf, "nhdr=yes", 8))
1380 if (!strncasecmp(buf, "type=", 5))
1381 format_type = atoi(&buf[5]);
1382 if (!strncasecmp(buf, "from=", 5)) {
1383 strcpy(from, &buf[5]);
1384 wprintf(_("from "));
1386 utf8ify_rfc822_string(from);
1390 if (!strncasecmp(buf, "subj=", 5)) {
1391 strcpy(m_subject, &buf[5]);
1393 if ((!strncasecmp(buf, "hnod=", 5))
1394 && (strcasecmp(&buf[5], serv_info.serv_humannode))) {
1395 wprintf("(%s) ", &buf[5]);
1397 if ((!strncasecmp(buf, "room=", 5))
1398 && (strcasecmp(&buf[5], WC->wc_roomname))
1399 && (!IsEmptyStr(&buf[5])) ) {
1401 wprintf("%s> ", &buf[5]);
1403 if (!strncasecmp(buf, "rfca=", 5)) {
1404 strcpy(rfca, &buf[5]);
1410 if (!strncasecmp(buf, "node=", 5)) {
1411 strcpy(node, &buf[5]);
1412 if ( ((WC->room_flags & QR_NETWORK)
1413 || ((strcasecmp(&buf[5], serv_info.serv_nodename)
1414 && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
1415 && (IsEmptyStr(rfca))
1417 wprintf("@%s ", &buf[5]);
1420 if (!strncasecmp(buf, "rcpt=", 5)) {
1422 wprintf("%s ", &buf[5]);
1424 if (!strncasecmp(buf, "time=", 5)) {
1425 webcit_fmt_date(now, atol(&buf[5]), 0);
1426 wprintf("%s ", now);
1431 * Save attachment info for later. We can't start downloading them
1432 * yet because we're in the middle of a server transaction.
1434 if (!strncasecmp(buf, "part=", 5)) {
1435 ptr = malloc( (strlen(buf) + ((attachments != NULL) ? strlen(attachments) : 0)) ) ;
1438 sprintf(ptr, "%s%s\n",
1439 ((attachments != NULL) ? attachments : ""),
1444 lprintf(9, "attachments=<%s>\n", attachments);
1450 if (include_headers) {
1454 utf8ify_rfc822_string(m_subject);
1456 if (!IsEmptyStr(m_subject)) {
1457 wprintf(_("Subject:"));
1459 msgescputs(m_subject);
1470 * Learn the content type
1472 strcpy(mime_content_type, "text/plain");
1473 while (serv_getln(buf, sizeof buf), (!IsEmptyStr(buf))) {
1474 if (!strcmp(buf, "000")) {
1475 wprintf("%s (4)", _("unexpected end of message"));
1478 if (!strncasecmp(buf, "Content-type: ", 14)) {
1480 safestrncpy(mime_content_type, &buf[14],
1481 sizeof(mime_content_type));
1482 for (i=0; i<strlen(mime_content_type); ++i) {
1483 if (!strncasecmp(&mime_content_type[i], "charset=", 8)) {
1484 safestrncpy(mime_charset, &mime_content_type[i+8],
1485 sizeof mime_charset);
1488 len = strlen(mime_content_type);
1489 for (i=0; i<len; ++i) {
1490 if (mime_content_type[i] == ';') {
1491 mime_content_type[i] = 0;
1495 len = strlen(mime_charset);
1496 for (i=0; i<len; ++i) {
1497 if (mime_charset[i] == ';') {
1498 mime_charset[i] = 0;
1505 /** Set up a character set conversion if we need to (and if we can) */
1507 if ( (strcasecmp(mime_charset, "us-ascii"))
1508 && (strcasecmp(mime_charset, "UTF-8"))
1509 && (strcasecmp(mime_charset, ""))
1511 ic = ctdl_iconv_open("UTF-8", mime_charset);
1512 if (ic == (iconv_t)(-1) ) {
1513 lprintf(5, "%s:%d iconv_open(%s, %s) failed: %s\n",
1514 __FILE__, __LINE__, "UTF-8", mime_charset, strerror(errno));
1519 /** Messages in legacy Citadel variformat get handled thusly... */
1520 if (!strcasecmp(mime_content_type, "text/x-citadel-variformat")) {
1524 /* Boring old 80-column fixed format text gets handled this way... */
1525 else if (!strcasecmp(mime_content_type, "text/plain")) {
1526 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1529 if (buf[len-1] == '\n') buf[--len] = 0;
1530 if (buf[len-1] == '\r') buf[--len] = 0;
1533 if (ic != (iconv_t)(-1) ) {
1537 obuf = (char *) malloc(obuflen);
1539 iconv(ic, &ibuf, &ibuflen, &obuf, &obuflen);
1540 osav[SIZ-obuflen] = 0;
1541 safestrncpy(buf, osav, sizeof buf);
1547 while ((!IsEmptyStr(buf)) && (isspace(buf[len - 1])))
1550 ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) )) {
1551 wprintf("<blockquote>");
1553 } else if ((bq == 1) &&
1554 (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) ) {
1555 wprintf("</blockquote>");
1561 wprintf("</tt><br />");
1563 wprintf("</i><br />");
1566 /** HTML just gets escaped and stuffed back into the editor */
1567 else if (!strcasecmp(mime_content_type, "text/html")) {
1568 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1574 /** Unknown weirdness ... don't know how to handle this content type */
1576 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { }
1580 /** end of body handler */
1583 * If there were attachments, we have to download them and insert them
1584 * into the attachment chain for the forwarded message we are composing.
1586 if ( (forward_attachments) && (num_attachments) ) {
1587 for (i=0; i<num_attachments; ++i) {
1588 extract_token(buf, attachments, i, '\n', sizeof buf);
1589 extract_token(mime_filename, buf, 1, '|', sizeof mime_filename);
1590 extract_token(mime_partnum, buf, 2, '|', sizeof mime_partnum);
1591 extract_token(mime_disposition, buf, 3, '|', sizeof mime_disposition);
1592 extract_token(mime_content_type, buf, 4, '|', sizeof mime_content_type);
1593 mime_length = extract_int(buf, 5);
1596 * tracing ... uncomment if necessary
1599 lprintf(9, "fwd filename: %s\n", mime_filename);
1600 lprintf(9, "fwd partnum : %s\n", mime_partnum);
1601 lprintf(9, "fwd conttype: %s\n", mime_content_type);
1602 lprintf(9, "fwd dispose : %s\n", mime_disposition);
1603 lprintf(9, "fwd length : %d\n", mime_length);
1605 if ( (!strcasecmp(mime_disposition, "inline"))
1606 || (!strcasecmp(mime_disposition, "attachment")) ) {
1608 /* Create an attachment struct from this mime part... */
1609 att = malloc(sizeof(struct wc_attachment));
1610 memset(att, 0, sizeof(struct wc_attachment));
1611 att->length = mime_length;
1612 strcpy(att->content_type, mime_content_type);
1613 strcpy(att->filename, mime_filename);
1615 att->data = load_mimepart(msgnum, mime_partnum);
1617 /* And add it to the list. */
1618 if (WC->first_attachment == NULL) {
1619 WC->first_attachment = att;
1622 aptr = WC->first_attachment;
1623 while (aptr->next != NULL) aptr = aptr->next;
1632 if (ic != (iconv_t)(-1) ) {
1637 if (attachments != NULL) {
1643 * \brief Display one row in the mailbox summary view
1645 * \param num The row number to be displayed
1647 void display_summarized(int num) {
1650 wprintf("<tr id=\"m%ld\" style=\"font-weight:%s;\" "
1651 "onMouseDown=\"CtdlMoveMsgMouseDown(event,%ld)\">",
1652 WC->summ[num].msgnum,
1653 (WC->summ[num].is_new ? "bold" : "normal"),
1654 WC->summ[num].msgnum
1657 wprintf("<td width=%d%%>", SUBJ_COL_WIDTH_PCT);
1660 utf8ify_rfc822_string(WC->summ[num].subj);
1661 utf8ify_rfc822_string(WC->summ[num].from);
1663 escputs(WC->summ[num].subj);//////////////////////////////////TODO: QP DECODE
1666 wprintf("<td width=%d%%>", SENDER_COL_WIDTH_PCT);
1667 escputs(WC->summ[num].from);
1670 wprintf("<td width=%d%%>", DATE_PLUS_BUTTONS_WIDTH_PCT);
1671 webcit_fmt_date(datebuf, WC->summ[num].date, 1); /* brief */
1681 * \brief display the adressbook overview
1682 * \param msgnum the citadel message number
1683 * \param alpha what????
1685 void display_addressbook(long msgnum, char alpha) {
1687 char mime_partnum[SIZ];
1688 char mime_filename[SIZ];
1689 char mime_content_type[SIZ];
1690 char mime_disposition[SIZ];
1692 char vcard_partnum[SIZ];
1693 char *vcard_source = NULL;
1694 struct message_summary summ;
1696 memset(&summ, 0, sizeof(summ));
1697 safestrncpy(summ.subj, _("(no subject)"), sizeof summ.subj);
1699 sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */
1701 serv_getln(buf, sizeof buf);
1702 if (buf[0] != '1') return;
1704 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1705 if (!strncasecmp(buf, "part=", 5)) {
1706 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
1707 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
1708 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
1709 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
1710 mime_length = extract_int(&buf[5], 5);
1712 if ( (!strcasecmp(mime_content_type, "text/x-vcard"))
1713 || (!strcasecmp(mime_content_type, "text/vcard")) ) {
1714 strcpy(vcard_partnum, mime_partnum);
1720 if (!IsEmptyStr(vcard_partnum)) {
1721 vcard_source = load_mimepart(msgnum, vcard_partnum);
1722 if (vcard_source != NULL) {
1724 /** Display the summary line */
1725 display_vcard(vcard_source, alpha, 0, NULL);
1727 /** If it's my vCard I can edit it */
1728 if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
1729 || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))
1730 || (WC->wc_view == VIEW_ADDRESSBOOK)
1732 wprintf("<a href=\"edit_vcard?"
1733 "msgnum=%ld?partnum=%s\">",
1734 msgnum, vcard_partnum);
1735 wprintf("[%s]</a>", _("edit"));
1747 * \brief If it's an old "Firstname Lastname" style record, try to convert it.
1748 * \param namebuf name to analyze, reverse if nescessary
1750 void lastfirst_firstlast(char *namebuf) {
1751 char firstname[SIZ];
1755 if (namebuf == NULL) return;
1756 if (strchr(namebuf, ';') != NULL) return;
1758 i = num_tokens(namebuf, ' ');
1761 extract_token(lastname, namebuf, i-1, ' ', sizeof lastname);
1762 remove_token(namebuf, i-1, ' ');
1763 strcpy(firstname, namebuf);
1764 sprintf(namebuf, "%s; %s", lastname, firstname);
1768 * \brief fetch what??? name
1769 * \param msgnum the citadel message number
1770 * \param namebuf where to put the name in???
1772 void fetch_ab_name(long msgnum, char *namebuf) {
1774 char mime_partnum[SIZ];
1775 char mime_filename[SIZ];
1776 char mime_content_type[SIZ];
1777 char mime_disposition[SIZ];
1779 char vcard_partnum[SIZ];
1780 char *vcard_source = NULL;
1782 struct message_summary summ;
1784 if (namebuf == NULL) return;
1785 strcpy(namebuf, "");
1787 memset(&summ, 0, sizeof(summ));
1788 safestrncpy(summ.subj, "(no subject)", sizeof summ.subj);
1790 sprintf(buf, "MSG0 %ld|0", msgnum); /** unfortunately we need the mime info now */
1792 serv_getln(buf, sizeof buf);
1793 if (buf[0] != '1') return;
1795 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1796 if (!strncasecmp(buf, "part=", 5)) {
1797 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
1798 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
1799 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
1800 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
1801 mime_length = extract_int(&buf[5], 5);
1803 if ( (!strcasecmp(mime_content_type, "text/x-vcard"))
1804 || (!strcasecmp(mime_content_type, "text/vcard")) ) {
1805 strcpy(vcard_partnum, mime_partnum);
1811 if (!IsEmptyStr(vcard_partnum)) {
1812 vcard_source = load_mimepart(msgnum, vcard_partnum);
1813 if (vcard_source != NULL) {
1815 /* Grab the name off the card */
1816 display_vcard(vcard_source, 0, 0, namebuf);
1822 lastfirst_firstlast(namebuf);
1824 len = strlen(namebuf);
1825 for (i=0; i<len; ++i) {
1826 if (namebuf[i] != ';') return;
1828 strcpy(namebuf, _("(no name)"));
1834 * \brief Record compare function for sorting address book indices
1835 * \param ab1 adressbook one
1836 * \param ab2 adressbook two
1838 int abcmp(const void *ab1, const void *ab2) {
1840 (((const struct addrbookent *)ab1)->ab_name),
1841 (((const struct addrbookent *)ab2)->ab_name)
1847 * \brief Helper function for do_addrbook_view()
1848 * Converts a name into a three-letter tab label
1849 * \param tabbuf the tabbuffer to add name to
1850 * \param name the name to add to the tabbuffer
1852 void nametab(char *tabbuf, long len, char *name) {
1853 stresc(tabbuf, len, name, 0, 0);
1854 tabbuf[0] = toupper(tabbuf[0]);
1855 tabbuf[1] = tolower(tabbuf[1]);
1856 tabbuf[2] = tolower(tabbuf[2]);
1862 * \brief Render the address book using info we gathered during the scan
1863 * \param addrbook the addressbook to render
1864 * \param num_ab the number of the addressbook
1866 void do_addrbook_view(struct addrbookent *addrbook, int num_ab) {
1870 static int NAMESPERPAGE = 60;
1873 char tabfirst_label[64];
1875 char tablast_label[64];
1876 char this_tablabel[64];
1881 wprintf("<br /><br /><br /><div align=\"center\"><i>");
1882 wprintf(_("This address book is empty."));
1883 wprintf("</i></div>\n");
1888 qsort(addrbook, num_ab, sizeof(struct addrbookent), abcmp);
1891 num_pages = (num_ab / NAMESPERPAGE) + 1;
1893 tablabels = malloc(num_pages * sizeof (char *));
1894 if (tablabels == NULL) {
1895 wprintf("<br /><br /><br /><div align=\"center\"><i>");
1896 wprintf(_("An internal error has occurred."));
1897 wprintf("</i></div>\n");
1901 for (i=0; i<num_pages; ++i) {
1902 tabfirst = i * NAMESPERPAGE;
1903 tablast = tabfirst + NAMESPERPAGE - 1;
1904 if (tablast > (num_ab - 1)) tablast = (num_ab - 1);
1905 nametab(tabfirst_label, 64, addrbook[tabfirst].ab_name);
1906 nametab(tablast_label, 64, addrbook[tablast].ab_name);
1907 sprintf(this_tablabel, "%s - %s", tabfirst_label, tablast_label);
1908 tablabels[i] = strdup(this_tablabel);
1911 tabbed_dialog(num_pages, tablabels);
1914 for (i=0; i<num_ab; ++i) {
1916 if ((i / NAMESPERPAGE) != page) { /* New tab */
1917 page = (i / NAMESPERPAGE);
1919 wprintf("</tr></table>\n");
1920 end_tab(page-1, num_pages);
1922 begin_tab(page, num_pages);
1923 wprintf("<table border=0 cellspacing=0 cellpadding=3 width=100%%>\n");
1927 if ((displayed % 4) == 0) {
1928 if (displayed > 0) {
1932 wprintf("<tr bgcolor=\"#%s\">",
1933 (bg ? "DDDDDD" : "FFFFFF")
1939 wprintf("<a href=\"readfwd?startmsg=%ld&is_singlecard=1",
1940 addrbook[i].ab_msgnum);
1941 wprintf("?maxmsgs=1?is_summary=0?alpha=%s\">", bstr("alpha"));
1942 vcard_n_prettyize(addrbook[i].ab_name);
1943 escputs(addrbook[i].ab_name);
1944 wprintf("</a></td>\n");
1948 wprintf("</tr></table>\n");
1949 end_tab((num_pages-1), num_pages);
1951 for (i=0; i<num_pages; ++i) {
1960 * \brief load message pointers from the server
1961 * \param servcmd the citadel command to send to the citserver
1962 * \param with_headers what headers???
1964 int load_msg_ptrs(char *servcmd, int with_headers)
1975 int num_summ_alloc = 0;
1977 if (WC->summ != NULL) {
1982 num_summ_alloc = 100;
1984 WC->summ = malloc(num_summ_alloc * sizeof(struct message_summary));
1987 maxload = sizeof(WC->msgarr) / sizeof(long) ;
1989 serv_getln(buf, sizeof buf);
1990 if (buf[0] != '1') {
1993 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1994 if (nummsgs < maxload) {
1995 WC->msgarr[nummsgs] = extract_long(buf, 0);
1996 datestamp = extract_long(buf, 1);
1997 extract_token(fullname, buf, 2, '|', sizeof fullname);
1998 extract_token(nodename, buf, 3, '|', sizeof nodename);
1999 extract_token(inetaddr, buf, 4, '|', sizeof inetaddr);
2000 extract_token(subject, buf, 5, '|', sizeof subject);
2004 if (nummsgs > num_summ_alloc) {
2005 num_summ_alloc *= 2;
2006 WC->summ = realloc(WC->summ,
2007 num_summ_alloc * sizeof(struct message_summary));
2011 memset(&WC->summ[nummsgs-1], 0, sizeof(struct message_summary));
2012 WC->summ[nummsgs-1].msgnum = WC->msgarr[nummsgs-1];
2013 safestrncpy(WC->summ[nummsgs-1].subj,
2014 _("(no subject)"), sizeof WC->summ[nummsgs-1].subj);
2015 if (!IsEmptyStr(fullname)) {
2016 safestrncpy(WC->summ[nummsgs-1].from,
2017 fullname, sizeof WC->summ[nummsgs-1].from);
2019 if (!IsEmptyStr(subject)) {
2020 safestrncpy(WC->summ[nummsgs-1].subj, subject,
2021 sizeof WC->summ[nummsgs-1].subj);
2024 /** Handle subjects with RFC2047 encoding */
2025 utf8ify_rfc822_string(WC->summ[nummsgs-1].subj);
2027 if (strlen(WC->summ[nummsgs-1].subj) > 75) {
2028 strcpy(&WC->summ[nummsgs-1].subj[72], "...");
2031 if (!IsEmptyStr(nodename)) {
2032 if ( ((WC->room_flags & QR_NETWORK)
2033 || ((strcasecmp(nodename, serv_info.serv_nodename)
2034 && (strcasecmp(nodename, serv_info.serv_fqdn)))))
2036 strcat(WC->summ[nummsgs-1].from, " @ ");
2037 strcat(WC->summ[nummsgs-1].from, nodename);
2041 WC->summ[nummsgs-1].date = datestamp;
2044 /** Handle senders with RFC2047 encoding */
2045 utf8ify_rfc822_string(WC->summ[nummsgs-1].from);
2047 if (strlen(WC->summ[nummsgs-1].from) > 25) {
2048 strcpy(&WC->summ[nummsgs-1].from[22], "...");
2057 * \brief qsort() compatible function to compare two longs in descending order.
2059 * \param s1 first number to compare
2060 * \param s2 second number to compare
2062 int longcmp_r(const void *s1, const void *s2) {
2069 if (l1 > l2) return(-1);
2070 if (l1 < l2) return(+1);
2076 * \brief qsort() compatible function to compare two message summary structs by ascending subject.
2078 * \param s1 first item to compare
2079 * \param s2 second item to compare
2081 int summcmp_subj(const void *s1, const void *s2) {
2082 struct message_summary *summ1;
2083 struct message_summary *summ2;
2085 summ1 = (struct message_summary *)s1;
2086 summ2 = (struct message_summary *)s2;
2087 return strcasecmp(summ1->subj, summ2->subj);
2091 * \brief qsort() compatible function to compare two message summary structs by descending subject.
2093 * \param s1 first item to compare
2094 * \param s2 second item to compare
2096 int summcmp_rsubj(const void *s1, const void *s2) {
2097 struct message_summary *summ1;
2098 struct message_summary *summ2;
2100 summ1 = (struct message_summary *)s1;
2101 summ2 = (struct message_summary *)s2;
2102 return strcasecmp(summ2->subj, summ1->subj);
2106 * \brief qsort() compatible function to compare two message summary structs by ascending sender.
2108 * \param s1 first item to compare
2109 * \param s2 second item to compare
2111 int summcmp_sender(const void *s1, const void *s2) {
2112 struct message_summary *summ1;
2113 struct message_summary *summ2;
2115 summ1 = (struct message_summary *)s1;
2116 summ2 = (struct message_summary *)s2;
2117 return strcasecmp(summ1->from, summ2->from);
2121 * \brief qsort() compatible function to compare two message summary structs by descending sender.
2123 * \param s1 first item to compare
2124 * \param s2 second item to compare
2126 int summcmp_rsender(const void *s1, const void *s2) {
2127 struct message_summary *summ1;
2128 struct message_summary *summ2;
2130 summ1 = (struct message_summary *)s1;
2131 summ2 = (struct message_summary *)s2;
2132 return strcasecmp(summ2->from, summ1->from);
2136 * \brief qsort() compatible function to compare two message summary structs by ascending date.
2138 * \param s1 first item to compare
2139 * \param s2 second item to compare
2141 int summcmp_date(const void *s1, const void *s2) {
2142 struct message_summary *summ1;
2143 struct message_summary *summ2;
2145 summ1 = (struct message_summary *)s1;
2146 summ2 = (struct message_summary *)s2;
2148 if (summ1->date < summ2->date) return -1;
2149 else if (summ1->date > summ2->date) return +1;
2154 * \brief qsort() compatible function to compare two message summary structs by descending date.
2156 * \param s1 first item to compare
2157 * \param s2 second item to compare
2159 int summcmp_rdate(const void *s1, const void *s2) {
2160 struct message_summary *summ1;
2161 struct message_summary *summ2;
2163 summ1 = (struct message_summary *)s1;
2164 summ2 = (struct message_summary *)s2;
2166 if (summ1->date < summ2->date) return +1;
2167 else if (summ1->date > summ2->date) return -1;
2174 * \brief command loop for reading messages
2176 * \param oper Set to "readnew" or "readold" or "readfwd" or "headers"
2178 void readloop(char *oper)
2187 long *displayed_msgs = NULL;
2188 int num_displayed = 0;
2190 int is_addressbook = 0;
2191 int is_singlecard = 0;
2192 int is_calendar = 0;
2197 int lowest_displayed = (-1);
2198 int highest_displayed = 0;
2199 struct addrbookent *addrbook = NULL;
2201 char *sortby = NULL;
2202 char sortpref_name[128];
2203 char sortpref_value[128];
2204 char *subjsort_button;
2205 char *sendsort_button;
2206 char *datesort_button;
2207 int bbs_reverse = 0;
2208 struct wcsession *WCC = WC; /* This is done to make it run faster; WC is a function */
2210 if (WCC->wc_view == VIEW_WIKI) {
2211 sprintf(buf, "wiki?room=%s?page=home", WCC->wc_roomname);
2216 startmsg = atol(bstr("startmsg"));
2217 maxmsgs = atoi(bstr("maxmsgs"));
2218 is_summary = atoi(bstr("is_summary"));
2219 if (maxmsgs == 0) maxmsgs = DEFAULT_MAXMSGS;
2221 snprintf(sortpref_name, sizeof sortpref_name, "sort %s", WCC->wc_roomname);
2222 get_preference(sortpref_name, sortpref_value, sizeof sortpref_value);
2224 sortby = bstr("sortby");
2225 if ( (!IsEmptyStr(sortby)) && (strcasecmp(sortby, sortpref_value)) ) {
2226 set_preference(sortpref_name, sortby, 1);
2228 if (IsEmptyStr(sortby)) sortby = sortpref_value;
2231 if (IsEmptyStr(sortby)) sortby = "rdate";
2233 /** message board sort */
2234 if (!strcasecmp(sortby, "reverse")) {
2241 output_headers(1, 1, 1, 0, 0, 0);
2244 * When in summary mode, always show ALL messages instead of just
2245 * new or old. Otherwise, show what the user asked for.
2247 if (!strcmp(oper, "readnew")) {
2248 strcpy(cmd, "MSGS NEW");
2250 else if (!strcmp(oper, "readold")) {
2251 strcpy(cmd, "MSGS OLD");
2253 else if (!strcmp(oper, "do_search")) {
2254 sprintf(cmd, "MSGS SEARCH|%s", bstr("query"));
2257 strcpy(cmd, "MSGS ALL");
2260 if ((WCC->wc_view == VIEW_MAILBOX) && (maxmsgs > 1)) {
2262 if (!strcmp(oper, "do_search")) {
2263 sprintf(cmd, "MSGS SEARCH|%s", bstr("query"));
2266 strcpy(cmd, "MSGS ALL");
2270 if ((WCC->wc_view == VIEW_ADDRESSBOOK) && (maxmsgs > 1)) {
2272 if (!strcmp(oper, "do_search")) {
2273 sprintf(cmd, "MSGS SEARCH|%s", bstr("query"));
2276 strcpy(cmd, "MSGS ALL");
2281 if (is_summary) { /**< fetch header summary */
2282 snprintf(cmd, sizeof cmd, "MSGS %s|%s||1",
2283 (!strcmp(oper, "do_search") ? "SEARCH" : "ALL"),
2284 (!strcmp(oper, "do_search") ? bstr("query") : "")
2291 * Are we doing a summary view? If so, we need to know old messages
2292 * and new messages, so we can do that pretty boldface thing for the
2295 strcpy(old_msgs, "");
2298 serv_getln(buf, sizeof buf);
2299 if (buf[0] == '2') {
2300 strcpy(old_msgs, &buf[4]);
2304 is_singlecard = atoi(bstr("is_singlecard"));
2306 if (WCC->wc_default_view == VIEW_CALENDAR) { /**< calendar */
2308 strcpy(cmd, "MSGS ALL");
2311 if (WCC->wc_default_view == VIEW_TASKS) { /**< tasks */
2313 strcpy(cmd, "MSGS ALL");
2316 if (WCC->wc_default_view == VIEW_NOTES) { /**< notes */
2318 strcpy(cmd, "MSGS ALL");
2323 wprintf("<div align=center>%s</div>\n", _("Click on any note to edit it."));
2324 wprintf("<div id=\"new_notes_here\"></div>\n");
2327 nummsgs = load_msg_ptrs(cmd, is_summary);
2330 if ((!is_tasks) && (!is_calendar) && (!is_notes) && (!is_addressbook)) {
2331 wprintf("<div align=\"center\"><br /><em>");
2332 if (!strcmp(oper, "readnew")) {
2333 wprintf(_("No new messages."));
2334 } else if (!strcmp(oper, "readold")) {
2335 wprintf(_("No old messages."));
2337 wprintf(_("No messages here."));
2339 wprintf("</em><br /></div>\n");
2346 for (a = 0; a < nummsgs; ++a) {
2347 /** Are you a new message, or an old message? */
2349 if (is_msg_in_mset(old_msgs, WCC->msgarr[a])) {
2350 WCC->summ[a].is_new = 0;
2353 WCC->summ[a].is_new = 1;
2359 if (startmsg == 0L) {
2361 startmsg = WCC->msgarr[(nummsgs >= maxmsgs) ? (nummsgs - maxmsgs) : 0];
2364 startmsg = WCC->msgarr[0];
2369 if (!strcasecmp(sortby, "subject")) {
2370 qsort(WCC->summ, WCC->num_summ,
2371 sizeof(struct message_summary), summcmp_subj);
2373 else if (!strcasecmp(sortby, "rsubject")) {
2374 qsort(WCC->summ, WCC->num_summ,
2375 sizeof(struct message_summary), summcmp_rsubj);
2377 else if (!strcasecmp(sortby, "sender")) {
2378 qsort(WCC->summ, WCC->num_summ,
2379 sizeof(struct message_summary), summcmp_sender);
2381 else if (!strcasecmp(sortby, "rsender")) {
2382 qsort(WCC->summ, WCC->num_summ,
2383 sizeof(struct message_summary), summcmp_rsender);
2385 else if (!strcasecmp(sortby, "date")) {
2386 qsort(WCC->summ, WCC->num_summ,
2387 sizeof(struct message_summary), summcmp_date);
2389 else if (!strcasecmp(sortby, "rdate")) {
2390 qsort(WCC->summ, WCC->num_summ,
2391 sizeof(struct message_summary), summcmp_rdate);
2395 if (!strcasecmp(sortby, "subject")) {
2396 subjsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=rsubject\"><img border=\"0\" src=\"static/down_pointer.gif\" /></a>" ;
2398 else if (!strcasecmp(sortby, "rsubject")) {
2399 subjsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=subject\"><img border=\"0\" src=\"static/up_pointer.gif\" /></a>" ;
2402 subjsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=subject\"><img border=\"0\" src=\"static/sort_none.gif\" /></a>" ;
2405 if (!strcasecmp(sortby, "sender")) {
2406 sendsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=rsender\"><img border=\"0\" src=\"static/down_pointer.gif\" /></a>" ;
2408 else if (!strcasecmp(sortby, "rsender")) {
2409 sendsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=sender\"><img border=\"0\" src=\"static/up_pointer.gif\" /></a>" ;
2412 sendsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=sender\"><img border=\"0\" src=\"static/sort_none.gif\" /></a>" ;
2415 if (!strcasecmp(sortby, "date")) {
2416 datesort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=rdate\"><img border=\"0\" src=\"static/down_pointer.gif\" /></a>" ;
2418 else if (!strcasecmp(sortby, "rdate")) {
2419 datesort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=date\"><img border=\"0\" src=\"static/up_pointer.gif\" /></a>" ;
2422 datesort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=rdate\"><img border=\"0\" src=\"static/sort_none.gif\" /></a>" ;
2427 wprintf("<script language=\"javascript\" type=\"text/javascript\">"
2428 " document.onkeydown = CtdlMsgListKeyPress; "
2429 " if (document.layers) { "
2430 " document.captureEvents(Event.KEYPRESS); "
2435 /** note that Date and Delete are now in the same column */
2436 wprintf("<div id=\"message_list_hdr\">"
2437 "<div class=\"fix_scrollbar_bug\">"
2438 "<table cellspacing=0 style=\"width:100%%\">"
2441 wprintf("<th width=%d%%>%s %s</th>"
2442 "<th width=%d%%>%s %s</th>"
2443 "<th width=%d%%>%s %s"
2445 "<input type=\"submit\" name=\"delete_button\" id=\"delbutton\" "
2446 " onClick=\"CtdlDeleteSelectedMessages(event)\" "
2452 _("Subject"), subjsort_button,
2453 SENDER_COL_WIDTH_PCT,
2454 _("Sender"), sendsort_button,
2455 DATE_PLUS_BUTTONS_WIDTH_PCT,
2456 _("Date"), datesort_button,
2459 wprintf("</table></div></div>\n");
2461 wprintf("<div id=\"message_list\">"
2463 "<div class=\"fix_scrollbar_bug\">\n"
2465 "<table class=\"mailbox_summary\" id=\"summary_headers\" "
2466 "cellspacing=0 style=\"width:100%%;-moz-user-select:none;\">"
2472 * Set the "is_bbview" variable if it appears that we are looking at
2473 * a classic bulletin board view.
2475 if ((!is_tasks) && (!is_calendar) && (!is_addressbook)
2476 && (!is_notes) && (!is_singlecard) && (!is_summary)) {
2481 * If we're not currently looking at ALL requested
2482 * messages, then display the selector bar
2485 /** begin bbview scroller */
2486 wprintf("<form name=\"msgomatictop\" class=\"selector_top\" > \n <p>");
2487 wprintf(_("Reading #"), lowest_displayed, highest_displayed);
2489 wprintf("<select name=\"whichones\" size=\"1\" "
2490 "OnChange=\"location.href=msgomatictop.whichones.options"
2491 "[selectedIndex].value\">\n");
2494 for (b=nummsgs-1; b>=0; b = b - maxmsgs) {
2496 lo = b - maxmsgs + 2;
2498 wprintf("<option %s value="
2503 "%d-%d</option> \n",
2504 ((WCC->msgarr[lo-1] == startmsg) ? "selected" : ""),
2513 for (b=0; b<nummsgs; b = b + maxmsgs) {
2515 hi = b + maxmsgs + 1;
2516 if (hi > nummsgs) hi = nummsgs;
2517 wprintf("<option %s value="
2522 "%d-%d</option> \n",
2523 ((WCC->msgarr[b] == startmsg) ? "selected" : ""),
2532 wprintf("<option value=\"%s?startmsg=%ld"
2533 "?maxmsgs=9999999?is_summary=%d\">",
2535 WCC->msgarr[0], is_summary);
2537 wprintf("</option>");
2538 wprintf("</select> ");
2539 wprintf(_("of %d messages."), nummsgs);
2541 /** forward/reverse */
2542 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
2543 "OnChange=\"location.href='%s?sortby=forward'\"",
2544 (bbs_reverse ? "" : "checked"),
2548 wprintf(_("oldest to newest"));
2549 wprintf(" ");
2551 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
2552 "OnChange=\"location.href='%s?sortby=reverse'\"",
2553 (bbs_reverse ? "checked" : ""),
2557 wprintf(_("newest to oldest"));
2560 wprintf("</p></form>\n");
2561 /** end bbview scroller */
2566 wprintf ("<script src=\"/static/dragdrop.js\" type=\"text/javascript\"></script>\n");
2571 for (a = 0; a < nummsgs; ++a) {
2572 if ((WCC->msgarr[a] >= startmsg) && (num_displayed < maxmsgs)) {
2574 /** Display the message */
2576 display_summarized(a);
2578 else if (is_addressbook) {
2579 fetch_ab_name(WCC->msgarr[a], buf);
2581 addrbook = realloc(addrbook,
2582 (sizeof(struct addrbookent) * num_ab) );
2583 safestrncpy(addrbook[num_ab-1].ab_name, buf,
2584 sizeof(addrbook[num_ab-1].ab_name));
2585 addrbook[num_ab-1].ab_msgnum = WCC->msgarr[a];
2587 else if (is_calendar) {
2588 display_calendar(WCC->msgarr[a]);
2590 else if (is_tasks) {
2591 display_task(WCC->msgarr[a]);
2593 else if (is_notes) {
2594 display_note(WCC->msgarr[a]);
2597 if (displayed_msgs == NULL) {
2598 displayed_msgs = malloc(sizeof(long) *
2599 (maxmsgs<nummsgs ? maxmsgs : nummsgs));
2601 displayed_msgs[num_displayed] = WCC->msgarr[a];
2604 if (lowest_displayed < 0) lowest_displayed = a;
2605 highest_displayed = a;
2612 if (displayed_msgs != NULL) {
2614 qsort(displayed_msgs, num_displayed, sizeof(long), longcmp_r);
2617 /** if we do a split bbview in the future, begin messages div here */
2619 for (a=0; a<num_displayed; ++a) {
2620 read_message(displayed_msgs[a], 0, "");
2623 /** if we do a split bbview in the future, end messages div here */
2625 free(displayed_msgs);
2626 displayed_msgs = NULL;
2631 "</div>\n"); /**< end of 'fix_scrollbar_bug' div */
2632 wprintf("</div>"); /**< end of 'message_list' div */
2634 /** Here's the grab-it-to-resize-the-message-list widget */
2635 wprintf("<div id=\"resize_msglist\" "
2636 "onMouseDown=\"CtdlResizeMsgListMouseDown(event)\">"
2637 "<div class=\"fix_scrollbar_bug\"> <hr>"
2641 wprintf("<div id=\"preview_pane\">"); /**< The preview pane will initially be empty */
2645 * Bump these because although we're thinking in zero base, the user
2646 * is a drooling idiot and is thinking in one base.
2649 ++highest_displayed;
2652 * If we're not currently looking at ALL requested
2653 * messages, then display the selector bar
2656 /** begin bbview scroller */
2657 wprintf("<form name=\"msgomatic\" class=\"selector_bottom\" > \n <p>");
2658 wprintf(_("Reading #"), lowest_displayed, highest_displayed);
2660 wprintf("<select name=\"whichones\" size=\"1\" "
2661 "OnChange=\"location.href=msgomatic.whichones.options"
2662 "[selectedIndex].value\">\n");
2665 for (b=nummsgs-1; b>=0; b = b - maxmsgs) {
2667 lo = b - maxmsgs + 2;
2669 wprintf("<option %s value="
2674 "%d-%d</option> \n",
2675 ((WCC->msgarr[lo-1] == startmsg) ? "selected" : ""),
2684 for (b=0; b<nummsgs; b = b + maxmsgs) {
2686 hi = b + maxmsgs + 1;
2687 if (hi > nummsgs) hi = nummsgs;
2688 wprintf("<option %s value="
2693 "%d-%d</option> \n",
2694 ((WCC->msgarr[b] == startmsg) ? "selected" : ""),
2703 wprintf("<option value=\"%s?startmsg=%ld"
2704 "?maxmsgs=9999999?is_summary=%d\">",
2706 WCC->msgarr[0], is_summary);
2708 wprintf("</option>");
2709 wprintf("</select> ");
2710 wprintf(_("of %d messages."), nummsgs);
2712 /** forward/reverse */
2713 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
2714 "OnChange=\"location.href='%s?sortby=forward'\"",
2715 (bbs_reverse ? "" : "checked"),
2719 wprintf(_("oldest to newest"));
2720 wprintf(" ");
2721 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
2722 "OnChange=\"location.href='%s?sortby=reverse'\"",
2723 (bbs_reverse ? "checked" : ""),
2727 wprintf(_("newest to oldest"));
2730 wprintf("</p></form>\n");
2731 /** end bbview scroller */
2736 // wprintf ("</div>\n");
2737 wprintf ("<div id=\"wastebin\" align=middle>Drop notes here to remove them.</div>\n");
2738 wprintf ("<script type=\"text/javascript\">\n");
2739 // wprintf ("//<![CDATA[\n");
2740 wprintf ("Droppables.add(\"wastebin\",\n");
2742 wprintf ("\t\taccept:'notes',\n");
2743 wprintf ("\t\tonDrop:function(element)\n");
2744 wprintf ("\t\t{\n");
2745 wprintf ("\t\t\tElement.hide(element);\n");
2746 wprintf ("\t\t\tnew Ajax.Updater('notes', 'delnote',\n");
2747 wprintf ("\t\t\t{\n");
2748 wprintf ("\t\t\t\tasynchronous:true,\n");
2749 wprintf ("\t\t\t\tevalScripts:true,\n");
2750 wprintf ("\t\t\t\tonComplete:function(request)\n");
2751 wprintf ("\t\t\t\t{\n");
2752 wprintf ("\t\t\t\t\tElement.hide('indicator')\n");
2753 wprintf ("\t\t\t\t},\n");
2754 wprintf ("\t\t\t\tonLoading:function(request)\n");
2755 wprintf ("\t\t\t\t{\n");
2756 wprintf ("\t\t\t\t\tElement.show('indicator')\n");
2757 wprintf ("\t\t\t\t},\n");
2758 wprintf ("\t\t\t\tparameters:'id=' + encodeURIComponent(element.id)\n");
2759 wprintf ("\t\t\t})\n");
2760 wprintf ("\t\t}\n");
2762 // wprintf ("//]]>\n");
2763 wprintf ("</script>\n");
2770 do_tasks_view(); /** Render the task list */
2774 do_calendar_view(); /** Render the calendar */
2777 if (is_addressbook) {
2778 do_addrbook_view(addrbook, num_ab); /** Render the address book */
2781 /** Note: wDumpContent() will output one additional </div> tag. */
2782 wprintf("</div>\n"); /** end of 'content' div */
2785 /** free the summary */
2786 if (WCC->summ != NULL) {
2791 if (addrbook != NULL) free(addrbook);
2796 * \brief Back end for post_message()
2797 * ... this is where the actual message gets transmitted to the server.
2799 void post_mime_to_server(void) {
2801 int is_multipart = 0;
2803 struct wc_attachment *att;
2805 size_t encoded_length;
2806 size_t encoded_strlen;
2808 /** RFC2045 requires this, and some clients look for it... */
2809 serv_puts("MIME-Version: 1.0");
2810 serv_puts("X-Mailer: " PACKAGE_STRING);
2812 /** If there are attachments, we have to do multipart/mixed */
2813 if (WC->first_attachment != NULL) {
2818 sprintf(boundary, "Citadel--Multipart--%s--%04x--%04x",
2819 serv_info.serv_fqdn,
2824 /** Remember, serv_printf() appends an extra newline */
2825 serv_printf("Content-type: multipart/mixed; "
2826 "boundary=\"%s\"\n", boundary);
2827 serv_printf("This is a multipart message in MIME format.\n");
2828 serv_printf("--%s", boundary);
2831 serv_puts("Content-type: text/html; charset=utf-8");
2832 serv_puts("Content-Transfer-Encoding: quoted-printable");
2834 serv_puts("<html><body>\r\n");
2835 text_to_server_qp(bstr("msgtext")); /** Transmit message in quoted-printable encoding */
2836 serv_puts("</body></html>\r\n");
2840 /** Add in the attachments */
2841 for (att = WC->first_attachment; att!=NULL; att=att->next) {
2843 encoded_length = ((att->length * 150) / 100);
2844 encoded = malloc(encoded_length);
2845 if (encoded == NULL) break;
2846 encoded_strlen = CtdlEncodeBase64(encoded, att->data, att->length, 1);
2848 serv_printf("--%s", boundary);
2849 serv_printf("Content-type: %s", att->content_type);
2850 serv_printf("Content-disposition: attachment; "
2851 "filename=\"%s\"", att->filename);
2852 serv_puts("Content-transfer-encoding: base64");
2854 serv_write(encoded, encoded_strlen);
2859 serv_printf("--%s--", boundary);
2867 * \brief Post message (or don't post message)
2869 * Note regarding the "dont_post" variable:
2870 * A random value (actually, it's just a timestamp) is inserted as a hidden
2871 * field called "postseq" when the display_enter page is generated. This
2872 * value is checked when posting, using the static variable dont_post. If a
2873 * user attempts to post twice using the same dont_post value, the message is
2874 * discarded. This prevents the accidental double-saving of the same message
2875 * if the user happens to click the browser "back" button.
2877 void post_message(void)
2880 char encoded_subject[1024];
2881 static long dont_post = (-1L);
2882 struct wc_attachment *att, *aptr;
2883 int is_anonymous = 0;
2886 if (!IsEmptyStr(bstr("force_room"))) {
2887 gotoroom(bstr("force_room"));
2890 display_name = bstr("display_name");
2891 if (!strcmp(display_name, "__ANONYMOUS__")) {
2896 if (WC->upload_length > 0) {
2898 lprintf(9, "%s:%d: we are uploading %d bytes\n", __FILE__, __LINE__, WC->upload_length);
2899 /** There's an attachment. Save it to this struct... */
2900 att = malloc(sizeof(struct wc_attachment));
2901 memset(att, 0, sizeof(struct wc_attachment));
2902 att->length = WC->upload_length;
2903 strcpy(att->content_type, WC->upload_content_type);
2904 strcpy(att->filename, WC->upload_filename);
2907 /** And add it to the list. */
2908 if (WC->first_attachment == NULL) {
2909 WC->first_attachment = att;
2912 aptr = WC->first_attachment;
2913 while (aptr->next != NULL) aptr = aptr->next;
2918 * Mozilla sends a simple filename, which is what we want,
2919 * but Satan's Browser sends an entire pathname. Reduce
2920 * the path to just a filename if we need to.
2922 while (num_tokens(att->filename, '/') > 1) {
2923 remove_token(att->filename, 0, '/');
2925 while (num_tokens(att->filename, '\\') > 1) {
2926 remove_token(att->filename, 0, '\\');
2930 * Transfer control of this memory from the upload struct
2931 * to the attachment struct.
2933 att->data = WC->upload;
2934 WC->upload_length = 0;
2940 if (!IsEmptyStr(bstr("cancel_button"))) {
2941 sprintf(WC->ImportantMessage,
2942 _("Cancelled. Message was not posted."));
2943 } else if (!IsEmptyStr(bstr("attach_button"))) {
2946 } else if (atol(bstr("postseq")) == dont_post) {
2947 sprintf(WC->ImportantMessage,
2948 _("Automatically cancelled because you have already "
2949 "saved this message."));
2951 webcit_rfc2047encode(encoded_subject, sizeof encoded_subject, bstr("subject"));
2952 sprintf(buf, "ENT0 1|%s|%d|4|%s|%s||%s|%s|%s|%s",
2960 bstr("my_email_addr")
2963 serv_getln(buf, sizeof buf);
2964 if (buf[0] == '4') {
2965 post_mime_to_server();
2966 if ( (!IsEmptyStr(bstr("recp")))
2967 || (!IsEmptyStr(bstr("cc" )))
2968 || (!IsEmptyStr(bstr("bcc" )))
2970 sprintf(WC->ImportantMessage, _("Message has been sent.\n"));
2973 sprintf(WC->ImportantMessage, _("Message has been posted.\n"));
2975 dont_post = atol(bstr("postseq"));
2977 lprintf(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, buf);
2978 sprintf(WC->ImportantMessage, "%s", &buf[4]);
2984 free_attachments(WC);
2987 * We may have been supplied with instructions regarding the location
2988 * to which we must return after posting. If found, go there.
2990 if (!IsEmptyStr(bstr("return_to"))) {
2991 http_redirect(bstr("return_to"));
2994 * If we were editing a page in a wiki room, go to that page now.
2996 else if (!IsEmptyStr(bstr("wikipage"))) {
2997 snprintf(buf, sizeof buf, "wiki?page=%s", bstr("wikipage"));
3001 * Otherwise, just go to the "read messages" loop.
3004 readloop("readnew");
3012 * \brief display the message entry screen
3014 void display_enter(void)
3020 struct wc_attachment *att;
3021 int recipient_required = 0;
3022 int subject_required = 0;
3023 int recipient_bad = 0;
3025 int is_anonymous = 0;
3026 long existing_page = (-1L);
3030 if (!IsEmptyStr(bstr("force_room"))) {
3031 gotoroom(bstr("force_room"));
3034 display_name = bstr("display_name");
3035 if (!strcmp(display_name, "__ANONYMOUS__")) {
3040 /** First test to see whether this is a room that requires recipients to be entered */
3041 serv_puts("ENT0 0");
3042 serv_getln(buf, sizeof buf);
3044 if (!strncmp(buf, "570", 3)) { /** 570 means that we need a recipient here */
3045 recipient_required = 1;
3047 else if (buf[0] != '2') { /** Any other error means that we cannot continue */
3048 sprintf(WC->ImportantMessage, "%s", &buf[4]);
3049 readloop("readnew");
3053 /* Is the server strongly recommending that the user enter a message subject? */
3054 if ((buf[3] != '\0') && (buf[4] != '\0')) {
3055 subject_required = extract_int(&buf[4], 1);
3059 * Are we perhaps in an address book view? If so, then an "enter
3060 * message" command really means "add new entry."
3062 if (WC->wc_default_view == VIEW_ADDRESSBOOK) {
3063 do_edit_vcard(-1, "", "", WC->wc_roomname);
3067 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
3069 * Are we perhaps in a calendar room? If so, then an "enter
3070 * message" command really means "add new calendar item."
3072 if (WC->wc_default_view == VIEW_CALENDAR) {
3073 display_edit_event();
3078 * Are we perhaps in a tasks view? If so, then an "enter
3079 * message" command really means "add new task."
3081 if (WC->wc_default_view == VIEW_TASKS) {
3082 display_edit_task();
3088 * Otherwise proceed normally.
3089 * Do a custom room banner with no navbar...
3091 output_headers(1, 1, 2, 0, 0, 0);
3092 wprintf("<div id=\"banner\">\n");
3093 embed_room_banner(NULL, navbar_none);
3094 wprintf("</div>\n");
3095 wprintf("<div id=\"content\">\n"
3096 "<div class=\"fix_scrollbar_bug message \">");
3098 /** Now check our actual recipients if there are any */
3099 if (recipient_required) {
3100 sprintf(buf, "ENT0 0|%s|%d|0||%s||%s|%s|%s",
3104 bstr("cc"), bstr("bcc"), bstr("wikipage"));
3106 serv_getln(buf, sizeof buf);
3108 if (!strncmp(buf, "570", 3)) { /** 570 means we have an invalid recipient listed */
3109 if (!IsEmptyStr(bstr("recp")) &&
3110 !IsEmptyStr(bstr("cc" )) &&
3111 !IsEmptyStr(bstr("bcc" ))) {
3115 else if (buf[0] != '2') { /** Any other error means that we cannot continue */
3116 wprintf("<em>%s</em><br />\n", &buf[4]);
3121 /** If we got this far, we can display the message entry screen. */
3123 /** begin message entry screen */
3125 "enctype=\"multipart/form-data\" "
3127 "accept-charset=\"UTF-8\" "
3129 "name=\"enterform\""
3131 wprintf("<input type=\"hidden\" name=\"postseq\" value=\"%ld\">\n", now);
3132 if (WC->wc_view == VIEW_WIKI) {
3133 wprintf("<input type=\"hidden\" name=\"wikipage\" value=\"%s\">\n", bstr("wikipage"));
3135 wprintf("<input type=\"hidden\" name=\"return_to\" value=\"%s\">\n", bstr("return_to"));
3136 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
3137 wprintf("<input type=\"hidden\" name=\"force_room\" value=\"");
3138 escputs(WC->wc_roomname);
3141 /** submit or cancel buttons */
3142 wprintf("<p class=\"send_edit_msg\">");
3143 wprintf("<input type=\"submit\" name=\"send_button\" value=\"");
3144 if (recipient_required) {
3145 wprintf(_("Send message"));
3147 wprintf(_("Post message"));
3150 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">\n", _("Cancel"));
3155 wprintf("<img src=\"static/newmess3_24x.gif\" class=\"imgedit\">");
3156 wprintf(" "); /** header bar */
3157 webcit_fmt_date(buf, now, 0);
3159 wprintf("\n"); /** header bar */
3161 wprintf("<table width=\"100%%\" class=\"edit_msg_table\">");
3163 wprintf("<th><label for=\"from_id\" > ");
3164 wprintf(_(" <I>from</I> "));
3165 wprintf("</label></th>");
3167 wprintf("<td colspan=\"2\">");
3169 /* Allow the user to select any of his valid screen names */
3171 wprintf("<select name=\"display_name\" size=1 id=\"from_id\">\n");
3174 serv_getln(buf, sizeof buf);
3175 if (buf[0] == '1') {
3176 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3177 wprintf("<option %s value=\"",
3178 ((!strcasecmp(bstr("display_name"), buf)) ? "selected" : "")
3183 wprintf("</option>\n");
3187 if (WC->room_flags & QR_ANONOPT) {
3188 wprintf("<option %s value=\"__ANONYMOUS__\">%s</option>\n",
3189 ((!strcasecmp(bstr("__ANONYMOUS__"), WC->wc_fullname)) ? "selected" : ""),
3194 wprintf("</select>\n");
3196 /* If this is an email (not a post), allow the user to select any of his
3197 * valid email addresses.
3199 if (recipient_required) {
3201 serv_getln(buf, sizeof buf);
3202 if (buf[0] == '1') {
3203 wprintf("<select name=\"my_email_addr\" size=1>\n");
3204 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3205 wprintf("<option value=\"");
3209 wprintf("></option>\n");
3211 wprintf("</select>\n");
3215 wprintf(_(" <I>in</I> "));
3216 escputs(WC->wc_roomname);
3218 wprintf("</td></tr>");
3220 if (recipient_required) {
3222 wprintf("<tr><th><label for=\"recp_id\"> ");
3224 wprintf("</label></th>"
3225 "<td><input autocomplete=\"off\" type=\"text\" name=\"recp\" id=\"recp_id\" value=\"");
3226 escputs(bstr("recp"));
3227 wprintf("\" size=45 maxlength=1000 />");
3228 wprintf("<div class=\"auto_complete\" id=\"recp_name_choices\"></div>");
3229 wprintf("</td><td rowspan=\"3\" align=\"left\" valign=\"top\">");
3231 /** Pop open an address book -- begin **/
3233 "<a href=\"javascript:PopOpenAddressBook('recp_id|%s|cc_id|%s|bcc_id|%s');\" "
3235 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
3237 _("To:"), _("CC:"), _("BCC:"),
3238 _("Contacts"), _("Contacts")
3240 /** Pop open an address book -- end **/
3242 wprintf("</td></tr>");
3244 wprintf("<tr><th><label for=\"cc_id\"> ");
3246 wprintf("</label></th>"
3247 "<td><input autocomplete=\"off\" type=\"text\" name=\"cc\" id=\"cc_id\" value=\"");
3248 escputs(bstr("cc"));
3249 wprintf("\" size=45 maxlength=1000 />");
3250 wprintf("<div class=\"auto_complete\" id=\"cc_name_choices\"></div>");
3251 wprintf("</td></tr>");
3253 wprintf("<tr><th><label for=\"bcc_id\"> ");
3255 wprintf("</label></th>"
3256 "<td><input autocomplete=\"off\" type=\"text\" name=\"bcc\" id=\"bcc_id\" value=\"");
3257 escputs(bstr("bcc"));
3258 wprintf("\" size=45 maxlength=1000 />");
3259 wprintf("<div class=\"auto_complete\" id=\"bcc_name_choices\"></div>");
3260 wprintf("</td></tr>");
3262 /** Initialize the autocomplete ajax helpers (found in wclib.js) */
3263 wprintf("<script type=\"text/javascript\"> \n"
3264 " activate_entmsg_autocompleters(); \n"
3270 wprintf("<tr><th><label for=\"subject_id\" > ");
3271 if (recipient_required || subject_required) {
3272 wprintf(_("Subject:"));
3275 wprintf(_("Subject (optional):"));
3277 wprintf("</label></th>"
3278 "<td colspan=\"2\">"
3279 "<input type=\"text\" name=\"subject\" id=\"subject_id\" value=\"");
3280 escputs(bstr("subject"));
3281 wprintf("\" size=45 maxlength=70>\n");
3282 wprintf("</td></tr>");
3284 wprintf("<tr><td colspan=\"3\">\n");
3286 wprintf("<textarea name=\"msgtext\" cols=\"80\" rows=\"15\">");
3288 /** If we're continuing from a previous edit, put our partially-composed message back... */
3289 msgescputs(bstr("msgtext"));
3291 /* If we're forwarding a message, insert it here... */
3292 if (atol(bstr("fwdquote")) > 0L) {
3293 wprintf("<br><div align=center><i>");
3294 wprintf(_("--- forwarded message ---"));
3295 wprintf("</i></div><br>");
3296 pullquote_message(atol(bstr("fwdquote")), 1, 1);
3299 /** If we're replying quoted, insert the quote here... */
3300 else if (atol(bstr("replyquote")) > 0L) {
3303 pullquote_message(atol(bstr("replyquote")), 0, 1);
3304 wprintf("</blockquote><br>");
3307 /** If we're editing a wiki page, insert the existing page here... */
3308 else if (WC->wc_view == VIEW_WIKI) {
3309 safestrncpy(buf, bstr("wikipage"), sizeof buf);
3310 str_wiki_index(buf);
3311 existing_page = locate_message_by_uid(buf);
3312 if (existing_page >= 0L) {
3313 pullquote_message(existing_page, 1, 0);
3317 /** Insert our signature if appropriate... */
3318 if ( (WC->is_mailbox) && (strcmp(bstr("sig_inserted"), "yes")) ) {
3319 get_preference("use_sig", buf, sizeof buf);
3320 if (!strcasecmp(buf, "yes")) {
3322 get_preference("signature", ebuf, sizeof ebuf);
3323 euid_unescapize(buf, ebuf);
3324 wprintf("<br>--<br>");
3326 for (i=0; i<len; ++i) {
3327 if (buf[i] == '\n') {
3330 else if (buf[i] == '<') {
3333 else if (buf[i] == '>') {
3336 else if (buf[i] == '&') {
3339 else if (buf[i] == '\"') {
3342 else if (buf[i] == '\'') {
3345 else if (isprint(buf[i])) {
3346 wprintf("%c", buf[i]);
3352 wprintf("</textarea>\n");
3354 /** Make sure we only insert our signature once */
3355 /** We don't care if it was there or not before, it needs to be there now. */
3356 wprintf("<input type=\"hidden\" name=\"sig_inserted\" value=\"yes\">\n");
3359 * The following template embeds the TinyMCE richedit control, and automatically
3360 * transforms the textarea into a richedit textarea.
3362 do_template("richedit");
3364 /** Enumerate any attachments which are already in place... */
3365 wprintf("<div class=\"attachment buttons\"><img src=\"static/diskette_24x.gif\" class=\"imgedit\" > ");
3366 wprintf(_("Attachments:"));
3368 wprintf("<select name=\"which_attachment\" size=1>");
3369 for (att = WC->first_attachment; att != NULL; att = att->next) {
3370 wprintf("<option value=\"");
3371 urlescputs(att->filename);
3373 escputs(att->filename);
3374 /* wprintf(" (%s, %d bytes)",att->content_type,att->length); */
3375 wprintf("</option>\n");
3377 wprintf("</select>");
3379 /** Now offer the ability to attach additional files... */
3380 wprintf(" ");
3381 wprintf(_("Attach file:"));
3382 wprintf(" <input name=\"attachfile\" class=\"attachfile\" "
3383 "size=16 type=\"file\">\n "
3384 "<input type=\"submit\" name=\"attach_button\" value=\"%s\">\n", _("Add"));
3385 wprintf("</div>"); /* End of "attachment buttons" div */
3388 wprintf("</td></tr></table>");
3390 wprintf("</form>\n");
3391 wprintf("</div>\n"); /* end of "fix_scrollbar_bug" div */
3393 /* NOTE: address_book_popup() will close the "content" div. Don't close it here. */
3394 DONE: address_book_popup();
3400 * \brief delete a message
3402 void delete_msg(void)
3407 msgid = atol(bstr("msgid"));
3409 if (WC->wc_is_trash) { /** Delete from Trash is a real delete */
3410 serv_printf("DELE %ld", msgid);
3412 else { /** Otherwise move it to Trash */
3413 serv_printf("MOVE %ld|_TRASH_|0", msgid);
3416 serv_getln(buf, sizeof buf);
3417 sprintf(WC->ImportantMessage, "%s", &buf[4]);
3419 readloop("readnew");
3424 * \brief move a message to another folder
3431 msgid = atol(bstr("msgid"));
3433 if (!IsEmptyStr(bstr("move_button"))) {
3434 sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
3436 serv_getln(buf, sizeof buf);
3437 sprintf(WC->ImportantMessage, "%s", &buf[4]);
3439 sprintf(WC->ImportantMessage, (_("The message was not moved.")));
3442 readloop("readnew");
3450 * \brief Confirm move of a message
3452 void confirm_move_msg(void)
3458 msgid = atol(bstr("msgid"));
3461 output_headers(1, 1, 2, 0, 0, 0);
3462 wprintf("<div id=\"banner\">\n");
3464 wprintf(_("Confirm move of message"));
3466 wprintf("</div>\n");
3468 wprintf("<div id=\"content\" class=\"service\">\n");
3470 wprintf("<CENTER>");
3472 wprintf(_("Move this message to:"));
3473 wprintf("<br />\n");
3475 wprintf("<form METHOD=\"POST\" action=\"move_msg\">\n");
3476 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
3477 wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n", bstr("msgid"));
3479 wprintf("<SELECT NAME=\"target_room\" SIZE=5>\n");
3481 serv_getln(buf, sizeof buf);
3482 if (buf[0] == '1') {
3483 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3484 extract_token(targ, buf, 0, '|', sizeof targ);
3485 wprintf("<OPTION>");
3490 wprintf("</SELECT>\n");
3491 wprintf("<br />\n");
3493 wprintf("<INPUT TYPE=\"submit\" NAME=\"move_button\" VALUE=\"%s\">", _("Move"));
3495 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
3496 wprintf("</form></CENTER>\n");
3498 wprintf("</CENTER>\n");