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")) {
494 if (!IsEmptyStr(mailto)) strcat(mailto, "<br />");
497 "<a href=\"display_enter"
498 "?force_room=_MAIL_?recp=");
500 urlesc(&mailto[strlen(mailto)], fullname);
501 urlesc(&mailto[strlen(mailto)], " <");
502 urlesc(&mailto[strlen(mailto)], thisvalue);
503 urlesc(&mailto[strlen(mailto)], ">");
505 strcat(mailto, "\">");
506 len = strlen(mailto);
507 stresc(mailto+len, SIZ - len, thisvalue, 1, 1);
508 strcat(mailto, "</A>");
510 else if (!strcasecmp(firsttoken, "tel")) {
511 if (!IsEmptyStr(phone)) strcat(phone, "<br />");
512 strcat(phone, thisvalue);
513 for (j=0; j<num_tokens(thisname, ';'); ++j) {
514 extract_token(buf, thisname, j, ';', sizeof buf);
515 if (!strcasecmp(buf, "tel"))
517 else if (!strcasecmp(buf, "work"))
518 strcat(phone, _(" (work)"));
519 else if (!strcasecmp(buf, "home"))
520 strcat(phone, _(" (home)"));
521 else if (!strcasecmp(buf, "cell"))
522 strcat(phone, _(" (cell)"));
530 else if (!strcasecmp(firsttoken, "adr")) {
533 wprintf(_("Address:"));
534 wprintf("</TD><TD>");
535 for (j=0; j<num_tokens(thisvalue, ';'); ++j) {
536 extract_token(buf, thisvalue, j, ';', sizeof buf);
537 if (!IsEmptyStr(buf)) {
539 if (j<3) wprintf("<br />");
543 wprintf("</TD></TR>\n");
546 else if (!strcasecmp(firsttoken, "version")) {
549 else if (!strcasecmp(firsttoken, "rev")) {
552 else if (!strcasecmp(firsttoken, "label")) {
557 /*** Don't show extra fields. They're ugly.
561 wprintf("</TD><TD>");
563 wprintf("</TD></TR>\n");
573 wprintf("<TR BGCOLOR=\"#AAAAAA\">"
574 "<TD COLSPAN=2 BGCOLOR=\"#FFFFFF\">"
575 "<IMG ALIGN=CENTER src=\"static/viewcontacts_48x.gif\">"
576 "<FONT SIZE=+1><B>");
578 wprintf("</B></FONT>");
579 if (!IsEmptyStr(title)) {
580 wprintf("<div align=right>");
584 if (!IsEmptyStr(org)) {
585 wprintf("<div align=right>");
589 wprintf("</TD></TR>\n");
591 if (!IsEmptyStr(phone)) {
593 wprintf(_("Telephone:"));
594 wprintf("</td><td>%s</td></tr>\n", phone);
596 if (!IsEmptyStr(mailto)) {
598 wprintf(_("E-mail:"));
599 wprintf("</td><td>%s</td></tr>\n", mailto);
605 wprintf("</table></div>\n");
611 * \brief Display a textual vCard
612 * (Converts to a vCard object and then calls the actual display function)
613 * Set 'full' to nonzero to display the whole card instead of a one-liner.
614 * Or, if "storename" is non-NULL, just store the person's name in that
615 * buffer instead of displaying the card at all.
616 * \param vcard_source the buffer containing the vcard text
617 * \param alpha what???
618 * \param full should we usse all lines?
619 * \param storename where to store???
621 void display_vcard(char *vcard_source, char alpha, int full, char *storename) {
627 v = vcard_load(vcard_source);
628 if (v == NULL) return;
630 name = vcard_get_prop(v, "n", 1, 0, 0);
636 if (storename != NULL) {
637 fetchname_parsed_vcard(v, storename);
639 else if ( (alpha == 0)
640 || ((isalpha(alpha)) && (tolower(alpha) == tolower(this_alpha)) )
641 || ((!isalpha(alpha)) && (!isalpha(this_alpha)))
643 display_parsed_vcard(v, full);
657 * \brief I wanna SEE that message!
658 * \param msgnum the citadel number of the message to display
659 * \param printable_view are we doing a print view?
660 * \param section Optional for encapsulated message/rfc822 submessage)
662 void read_message(long msgnum, int printable_view, char *section) {
664 char mime_partnum[256];
666 char mime_filename[256];
667 char escaped_mime_filename[256];
668 char mime_content_type[256];
669 char mime_charset[256];
670 char mime_disposition[256];
672 struct attach_link *attach_links = NULL;
673 int num_attach_links = 0;
674 char mime_submessages[256];
681 char reply_all[4096];
687 char vcard_partnum[256];
688 char cal_partnum[256];
689 char *part_source = NULL;
690 char msg4_partnum[32];
692 iconv_t ic = (iconv_t)(-1) ;
693 char *ibuf; /**< Buffer of characters to be converted */
694 char *obuf; /**< Buffer for converted characters */
695 size_t ibuflen; /**< Length of input buffer */
696 size_t obuflen; /**< Length of output buffer */
697 char *osav; /**< Saved pointer to output buffer */
703 strcpy(reply_to, "");
704 strcpy(reply_all, "");
705 strcpy(vcard_partnum, "");
706 strcpy(cal_partnum, "");
707 strcpy(mime_content_type, "text/plain");
708 strcpy(mime_charset, "us-ascii");
709 strcpy(mime_submessages, "");
711 serv_printf("MSG4 %ld|%s", msgnum, section);
712 serv_getln(buf, sizeof buf);
715 wprintf(_("ERROR:"));
716 wprintf("</strong> %s<br />\n", &buf[4]);
720 /** begin everythingamundo table */
721 if (!printable_view) {
722 wprintf("<div class=\"fix_scrollbar_bug message\" ");
723 wprintf("onMouseOver=document.getElementById(\"msg%ld\").style.visibility=\"visible\" ", msgnum);
724 wprintf("onMouseOut=document.getElementById(\"msg%ld\").style.visibility=\"hidden\" >", msgnum);
727 /** begin message header table */
728 wprintf("<div class=\"message_header\">");
730 strcpy(m_subject, "");
733 while (serv_getln(buf, sizeof buf), strcasecmp(buf, "text")) {
734 if (!strcmp(buf, "000")) {
736 wprintf(_("unexpected end of message"));
737 wprintf(" (1)</i><br /><br />\n");
741 if (!strncasecmp(buf, "nhdr=yes", 8))
745 if (!strncasecmp(buf, "type=", 5))
746 format_type = atoi(&buf[5]);
747 if (!strncasecmp(buf, "from=", 5)) {
748 strcpy(from, &buf[5]);
750 wprintf("<a href=\"showuser?who=");
752 utf8ify_rfc822_string(from);
759 if (!strncasecmp(buf, "subj=", 5)) {
760 safestrncpy(m_subject, &buf[5], sizeof m_subject);
762 if (!strncasecmp(buf, "cccc=", 5)) {
764 safestrncpy(m_cc, &buf[5], sizeof m_cc);
765 if (!IsEmptyStr(reply_all)) {
766 strcat(reply_all, ", ");
768 len = strlen(reply_all);
769 safestrncpy(&reply_all[len], &buf[5],
770 (sizeof reply_all - len) );
772 if ((!strncasecmp(buf, "hnod=", 5))
773 && (strcasecmp(&buf[5], serv_info.serv_humannode))) {
774 wprintf("(%s) ", &buf[5]);
776 if ((!strncasecmp(buf, "room=", 5))
777 && (strcasecmp(&buf[5], WC->wc_roomname))
778 && (!IsEmptyStr(&buf[5])) ) {
780 wprintf("%s> ", &buf[5]);
782 if (!strncasecmp(buf, "rfca=", 5)) {
783 strcpy(rfca, &buf[5]);
789 if (!strncasecmp(buf, "node=", 5)) {
790 strcpy(node, &buf[5]);
791 if ( ((WC->room_flags & QR_NETWORK)
792 || ((strcasecmp(&buf[5], serv_info.serv_nodename)
793 && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
794 && (IsEmptyStr(rfca))
796 wprintf("@%s ", &buf[5]);
799 if (!strncasecmp(buf, "rcpt=", 5)) {
802 if (!IsEmptyStr(reply_all)) {
803 strcat(reply_all, ", ");
805 len = strlen(reply_all);
806 safestrncpy(&reply_all[len], &buf[5],
807 (sizeof reply_all - len) );
809 utf8ify_rfc822_string(&buf[5]);
814 if (!strncasecmp(buf, "time=", 5)) {
815 webcit_fmt_date(now, atol(&buf[5]), 0);
821 if (!strncasecmp(buf, "part=", 5)) {
822 extract_token(mime_name, &buf[5], 0, '|', sizeof mime_filename);
823 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
824 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
825 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
826 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
827 mime_length = extract_int(&buf[5], 5);
830 striplt(mime_filename);
831 if ( (IsEmptyStr(mime_filename)) && (!IsEmptyStr(mime_name)) ) {
832 strcpy(mime_filename, mime_name);
835 if (!strcasecmp(mime_content_type, "message/rfc822")) {
836 if (!IsEmptyStr(mime_submessages)) {
837 strcat(mime_submessages, "|");
839 strcat(mime_submessages, mime_partnum);
841 else if ((!strcasecmp(mime_disposition, "inline"))
842 && (!strncasecmp(mime_content_type, "image/", 6)) ){
844 attach_links = realloc(attach_links,
845 (num_attach_links*sizeof(struct attach_link)));
846 safestrncpy(attach_links[num_attach_links-1].partnum, mime_partnum, 32);
847 snprintf(attach_links[num_attach_links-1].html, 1024,
848 "<img src=\"mimepart/%ld/%s/%s\">",
849 msgnum, mime_partnum, mime_filename);
851 else if ( ( (!strcasecmp(mime_disposition, "attachment"))
852 || (!strcasecmp(mime_disposition, "inline"))
853 || (!strcasecmp(mime_disposition, ""))
854 ) && (!IsEmptyStr(mime_content_type))
857 attach_links = realloc(attach_links,
858 (num_attach_links*sizeof(struct attach_link)));
859 safestrncpy(attach_links[num_attach_links-1].partnum, mime_partnum, 32);
860 urlesc(escaped_mime_filename, mime_filename);
861 snprintf(attach_links[num_attach_links-1].html, 1024,
862 "<img src=\"static/diskette_24x.gif\" "
863 "border=0 align=middle>\n"
864 "%s (%s, %d bytes) [ "
865 "<a href=\"mimepart/%ld/%s/%s\""
866 "target=\"wc.%ld.%s\">%s</a>"
868 "<a href=\"mimepart_download/%ld/%s/%s\">%s</a>"
871 mime_content_type, mime_length,
872 msgnum, mime_partnum, escaped_mime_filename,
873 msgnum, mime_partnum,
875 msgnum, mime_partnum, escaped_mime_filename,
880 /** begin handler prep ***/
881 if ( (!strcasecmp(mime_content_type, "text/x-vcard"))
882 || (!strcasecmp(mime_content_type, "text/vcard")) ) {
883 strcpy(vcard_partnum, mime_partnum);
886 if (!strcasecmp(mime_content_type, "text/calendar")) {
887 strcpy(cal_partnum, mime_partnum);
890 /** end handler prep ***/
896 /** Generate a reply-to address */
897 if (!IsEmptyStr(rfca)) {
898 if (!IsEmptyStr(from)) {
899 snprintf(reply_to, sizeof(reply_to), "%s <%s>", from, rfca);
902 strcpy(reply_to, rfca);
906 if ((!IsEmptyStr(node))
907 && (strcasecmp(node, serv_info.serv_nodename))
908 && (strcasecmp(node, serv_info.serv_humannode)) ) {
909 snprintf(reply_to, sizeof(reply_to), "%s @ %s",
913 snprintf(reply_to, sizeof(reply_to), "%s", from);
922 utf8ify_rfc822_string(m_cc);
923 utf8ify_rfc822_string(m_subject);
926 /** start msg buttons */
928 if (!printable_view) {
929 wprintf("<p id=\"msg%ld\" class=\"msgbuttons\" >\n",msgnum);
932 if ( (WC->wc_view == VIEW_MAILBOX) || (WC->wc_view == VIEW_BBS) ) {
933 wprintf("<a href=\"display_enter");
934 if (WC->is_mailbox) {
935 wprintf("?replyquote=%ld", msgnum);
938 urlescputs(reply_to);
939 if (!IsEmptyStr(m_subject)) {
940 wprintf("?subject=");
941 if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
942 urlescputs(m_subject);
944 wprintf("\"><span>[</span>%s<span>]</span></a> ", _("Reply"));
948 if ( (WC->wc_view == VIEW_MAILBOX) || (WC->wc_view == VIEW_BBS) ) {
949 if (!WC->is_mailbox) {
950 wprintf("<a href=\"display_enter");
951 wprintf("?replyquote=%ld", msgnum);
953 urlescputs(reply_to);
954 if (!IsEmptyStr(m_subject)) {
955 wprintf("?subject=");
956 if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
957 urlescputs(m_subject);
959 wprintf("\"><span>[</span>%s<span>]</span></a> ", _("ReplyQuoted"));
964 if (WC->wc_view == VIEW_MAILBOX) {
965 wprintf("<a href=\"display_enter");
966 wprintf("?replyquote=%ld", msgnum);
968 urlescputs(reply_to);
970 urlescputs(reply_all);
971 if (!IsEmptyStr(m_subject)) {
972 wprintf("?subject=");
973 if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
974 urlescputs(m_subject);
976 wprintf("\"><span>[</span>%s<span>]</span></a> ", _("ReplyAll"));
980 if (WC->wc_view == VIEW_MAILBOX) {
981 wprintf("<a href=\"display_enter?fwdquote=%ld?subject=", msgnum);
982 if (strncasecmp(m_subject, "Fwd:", 4)) wprintf("Fwd:%20");
983 urlescputs(m_subject);
984 wprintf("\"><span>[</span>%s<span>]</span></a> ", _("Forward"));
987 /** If this is one of my own rooms, or if I'm an Aide or Room Aide, I can move/delete */
988 if ( (WC->is_room_aide) || (WC->is_mailbox) || (WC->room_flags2 & QR2_COLLABDEL) ) {
990 wprintf("<a href=\"confirm_move_msg?msgid=%ld\"><span>[</span>%s<span>]</span></a> ",
994 wprintf("<a href=\"delete_msg?msgid=%ld\" "
995 "onClick=\"return confirm('%s');\">"
996 "<span>[</span>%s<span>]</span> "
997 "</a> ", msgnum, _("Delete this message?"), _("Delete")
1002 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'); \" >"
1003 "<span>[</span>%s<span>]</span></a>", msgnum, msgnum, _("Headers"));
1007 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'); \" >"
1008 "<span>[</span>%s<span>]</span></a>", msgnum, msgnum, _("Print"));
1014 if (!IsEmptyStr(m_cc)) {
1021 if (!IsEmptyStr(m_subject)) {
1022 wprintf("<p class=\"message_subject\">");
1023 wprintf(_("Subject:"));
1032 wprintf("<div class=\"message_content\">");
1035 * Learn the content type
1037 strcpy(mime_content_type, "text/plain");
1038 while (serv_getln(buf, sizeof buf), (!IsEmptyStr(buf))) {
1039 if (!strcmp(buf, "000")) {
1041 wprintf(_("unexpected end of message"));
1042 wprintf(" (2)</i><br /><br />\n");
1045 if (!strncasecmp(buf, "X-Citadel-MSG4-Partnum:", 23)) {
1046 safestrncpy(msg4_partnum, &buf[23], sizeof(msg4_partnum));
1047 striplt(msg4_partnum);
1049 if (!strncasecmp(buf, "Content-type:", 13)) {
1051 safestrncpy(mime_content_type, &buf[13], sizeof(mime_content_type));
1052 striplt(mime_content_type);
1053 len = strlen(mime_content_type);
1054 for (i=0; i<len; ++i) {
1055 if (!strncasecmp(&mime_content_type[i], "charset=", 8)) {
1056 safestrncpy(mime_charset, &mime_content_type[i+8],
1057 sizeof mime_charset);
1060 for (i=0; i<len; ++i) {
1061 if (mime_content_type[i] == ';') {
1062 mime_content_type[i] = 0;
1066 len = strlen(mime_charset);
1067 for (i=0; i<len; ++i) {
1068 if (mime_charset[i] == ';') {
1069 mime_charset[i] = 0;
1076 /** Set up a character set conversion if we need to (and if we can) */
1078 if (strchr(mime_charset, ';')) strcpy(strchr(mime_charset, ';'), "");
1079 if ( (strcasecmp(mime_charset, "us-ascii"))
1080 && (strcasecmp(mime_charset, "UTF-8"))
1081 && (strcasecmp(mime_charset, ""))
1083 ic = ctdl_iconv_open("UTF-8", mime_charset);
1084 if (ic == (iconv_t)(-1) ) {
1085 lprintf(5, "%s:%d iconv_open(UTF-8, %s) failed: %s\n",
1086 __FILE__, __LINE__, mime_charset, strerror(errno));
1091 /** Messages in legacy Citadel variformat get handled thusly... */
1092 if (!strcasecmp(mime_content_type, "text/x-citadel-variformat")) {
1096 /** Boring old 80-column fixed format text gets handled this way... */
1097 else if ( (!strcasecmp(mime_content_type, "text/plain"))
1098 || (!strcasecmp(mime_content_type, "text")) ) {
1100 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1103 if ((len > 0) && buf[len-1] == '\n') buf[--len] = 0;
1104 if ((len > 0) && buf[len-1] == '\r') buf[--len] = 0;
1107 if (ic != (iconv_t)(-1) ) {
1109 ibuflen = strlen(ibuf);
1111 obuf = (char *) malloc(obuflen);
1113 iconv(ic, &ibuf, &ibuflen, &obuf, &obuflen);
1114 osav[SIZ-obuflen] = 0;
1115 safestrncpy(buf, osav, sizeof buf);
1121 while ((!IsEmptyStr(buf)) && (isspace(buf[len-1])))
1124 ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) )) {
1125 wprintf("<blockquote>");
1127 } else if ((bq == 1) &&
1128 (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) ) {
1129 wprintf("</blockquote>");
1135 wprintf("</tt><br />\n");
1137 wprintf("</i><br />");
1140 else /** HTML is fun, but we've got to strip it first */
1141 if (!strcasecmp(mime_content_type, "text/html")) {
1142 output_html(mime_charset, (WC->wc_view == VIEW_WIKI ? 1 : 0));
1145 /** Unknown weirdness */
1147 wprintf(_("I don't know how to display %s"), mime_content_type);
1148 wprintf("<br />\n", mime_content_type);
1149 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { }
1152 /** If there are attached submessages, display them now... */
1153 if ( (!IsEmptyStr(mime_submessages)) && (!section[0]) ) {
1154 for (i=0; i<num_tokens(mime_submessages, '|'); ++i) {
1155 extract_token(buf, mime_submessages, i, '|', sizeof buf);
1156 /** use printable_view to suppress buttons */
1157 wprintf("<blockquote>");
1158 read_message(msgnum, 1, buf);
1159 wprintf("</blockquote>");
1164 /** Afterwards, offer links to download attachments 'n' such */
1165 if ( (num_attach_links > 0) && (!section[0]) ) {
1166 for (i=0; i<num_attach_links; ++i) {
1167 if (strcasecmp(attach_links[i].partnum, msg4_partnum)) {
1168 wprintf("%s", attach_links[i].html);
1173 /** Handler for vCard parts */
1174 if (!IsEmptyStr(vcard_partnum)) {
1175 part_source = load_mimepart(msgnum, vcard_partnum);
1176 if (part_source != NULL) {
1178 /** If it's my vCard I can edit it */
1179 if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
1180 || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))
1181 || (WC->wc_view == VIEW_ADDRESSBOOK)
1183 wprintf("<a href=\"edit_vcard?"
1184 "msgnum=%ld?partnum=%s\">",
1185 msgnum, vcard_partnum);
1186 wprintf("[%s]</a>", _("edit"));
1189 /** In all cases, display the full card */
1190 display_vcard(part_source, 0, 1, NULL);
1194 /** Handler for calendar parts */
1195 if (!IsEmptyStr(cal_partnum)) {
1196 part_source = load_mimepart(msgnum, cal_partnum);
1197 if (part_source != NULL) {
1198 cal_process_attachment(part_source,
1199 msgnum, cal_partnum);
1209 wprintf("</div>\n");
1211 /** end everythingamundo table */
1212 if (!printable_view) {
1213 wprintf("</div>\n");
1216 if (num_attach_links > 0) {
1221 if (ic != (iconv_t)(-1) ) {
1230 * \brief Unadorned HTML output of an individual message, suitable
1231 * for placing in a hidden iframe, for printing, or whatever
1233 * \param msgnum_as_string Message number, as a string instead of as a long int
1235 void embed_message(char *msgnum_as_string) {
1238 msgnum = atol(msgnum_as_string);
1239 begin_ajax_response();
1240 read_message(msgnum, 0, "");
1241 end_ajax_response();
1246 * \brief Printable view of a message
1248 * \param msgnum_as_string Message number, as a string instead of as a long int
1250 void print_message(char *msgnum_as_string) {
1253 msgnum = atol(msgnum_as_string);
1254 output_headers(0, 0, 0, 0, 0, 0);
1256 wprintf("Content-type: text/html\r\n"
1258 "Connection: close\r\n",
1262 wprintf("\r\n\r\n<html>\n"
1263 "<head><title>Printable view</title></head>\n"
1264 "<body onLoad=\" window.print(); window.close(); \">\n"
1267 read_message(msgnum, 1, "");
1269 wprintf("\n</body></html>\n\n");
1276 * \brief Display a message's headers
1278 * \param msgnum_as_string Message number, as a string instead of as a long int
1280 void display_headers(char *msgnum_as_string) {
1284 msgnum = atol(msgnum_as_string);
1285 output_headers(0, 0, 0, 0, 0, 0);
1287 wprintf("Content-type: text/plain\r\n"
1289 "Connection: close\r\n",
1293 serv_printf("MSG2 %ld|3", msgnum);
1294 serv_getln(buf, sizeof buf);
1295 if (buf[0] == '1') {
1296 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1297 wprintf("%s\n", buf);
1307 * \brief Read message in simple, JavaScript-embeddable form for 'forward'
1308 * or 'reply quoted' operations.
1310 * NOTE: it is VITALLY IMPORTANT that we output no single-quotes or linebreaks
1311 * in this function. Doing so would throw a JavaScript error in the
1312 * 'supplied text' argument to the editor.
1314 * \param msgnum Message number of the message we want to quote
1315 * \param forward_attachments Nonzero if we want attachments to be forwarded
1317 void pullquote_message(long msgnum, int forward_attachments, int include_headers) {
1319 char mime_partnum[256];
1320 char mime_filename[256];
1321 char mime_content_type[256];
1322 char mime_charset[256];
1323 char mime_disposition[256];
1325 char *attachments = NULL;
1327 int num_attachments = 0;
1328 struct wc_attachment *att, *aptr;
1329 char m_subject[256];
1335 int format_type = 0;
1340 iconv_t ic = (iconv_t)(-1) ;
1341 char *ibuf; /**< Buffer of characters to be converted */
1342 char *obuf; /**< Buffer for converted characters */
1343 size_t ibuflen; /**< Length of input buffer */
1344 size_t obuflen; /**< Length of output buffer */
1345 char *osav; /**< Saved pointer to output buffer */
1351 strcpy(reply_to, "");
1352 strcpy(mime_content_type, "text/plain");
1353 strcpy(mime_charset, "us-ascii");
1355 serv_printf("MSG4 %ld", msgnum);
1356 serv_getln(buf, sizeof buf);
1357 if (buf[0] != '1') {
1358 wprintf(_("ERROR:"));
1359 wprintf("%s<br />", &buf[4]);
1363 strcpy(m_subject, "");
1365 while (serv_getln(buf, sizeof buf), strcasecmp(buf, "text")) {
1366 if (!strcmp(buf, "000")) {
1367 wprintf("%s (3)", _("unexpected end of message"));
1370 if (include_headers) {
1371 if (!strncasecmp(buf, "nhdr=yes", 8))
1375 if (!strncasecmp(buf, "type=", 5))
1376 format_type = atoi(&buf[5]);
1377 if (!strncasecmp(buf, "from=", 5)) {
1378 strcpy(from, &buf[5]);
1379 wprintf(_("from "));
1381 utf8ify_rfc822_string(from);
1385 if (!strncasecmp(buf, "subj=", 5)) {
1386 strcpy(m_subject, &buf[5]);
1388 if ((!strncasecmp(buf, "hnod=", 5))
1389 && (strcasecmp(&buf[5], serv_info.serv_humannode))) {
1390 wprintf("(%s) ", &buf[5]);
1392 if ((!strncasecmp(buf, "room=", 5))
1393 && (strcasecmp(&buf[5], WC->wc_roomname))
1394 && (!IsEmptyStr(&buf[5])) ) {
1396 wprintf("%s> ", &buf[5]);
1398 if (!strncasecmp(buf, "rfca=", 5)) {
1399 strcpy(rfca, &buf[5]);
1405 if (!strncasecmp(buf, "node=", 5)) {
1406 strcpy(node, &buf[5]);
1407 if ( ((WC->room_flags & QR_NETWORK)
1408 || ((strcasecmp(&buf[5], serv_info.serv_nodename)
1409 && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
1410 && (IsEmptyStr(rfca))
1412 wprintf("@%s ", &buf[5]);
1415 if (!strncasecmp(buf, "rcpt=", 5)) {
1417 wprintf("%s ", &buf[5]);
1419 if (!strncasecmp(buf, "time=", 5)) {
1420 webcit_fmt_date(now, atol(&buf[5]), 0);
1421 wprintf("%s ", now);
1426 * Save attachment info for later. We can't start downloading them
1427 * yet because we're in the middle of a server transaction.
1429 if (!strncasecmp(buf, "part=", 5)) {
1430 ptr = malloc( (strlen(buf) + ((attachments != NULL) ? strlen(attachments) : 0)) ) ;
1433 sprintf(ptr, "%s%s\n",
1434 ((attachments != NULL) ? attachments : ""),
1439 lprintf(9, "attachments=<%s>\n", attachments);
1445 if (include_headers) {
1449 utf8ify_rfc822_string(m_subject);
1451 if (!IsEmptyStr(m_subject)) {
1452 wprintf(_("Subject:"));
1454 msgescputs(m_subject);
1465 * Learn the content type
1467 strcpy(mime_content_type, "text/plain");
1468 while (serv_getln(buf, sizeof buf), (!IsEmptyStr(buf))) {
1469 if (!strcmp(buf, "000")) {
1470 wprintf("%s (4)", _("unexpected end of message"));
1473 if (!strncasecmp(buf, "Content-type: ", 14)) {
1475 safestrncpy(mime_content_type, &buf[14],
1476 sizeof(mime_content_type));
1477 for (i=0; i<strlen(mime_content_type); ++i) {
1478 if (!strncasecmp(&mime_content_type[i], "charset=", 8)) {
1479 safestrncpy(mime_charset, &mime_content_type[i+8],
1480 sizeof mime_charset);
1483 len = strlen(mime_content_type);
1484 for (i=0; i<len; ++i) {
1485 if (mime_content_type[i] == ';') {
1486 mime_content_type[i] = 0;
1490 len = strlen(mime_charset);
1491 for (i=0; i<len; ++i) {
1492 if (mime_charset[i] == ';') {
1493 mime_charset[i] = 0;
1500 /** Set up a character set conversion if we need to (and if we can) */
1502 if ( (strcasecmp(mime_charset, "us-ascii"))
1503 && (strcasecmp(mime_charset, "UTF-8"))
1504 && (strcasecmp(mime_charset, ""))
1506 ic = ctdl_iconv_open("UTF-8", mime_charset);
1507 if (ic == (iconv_t)(-1) ) {
1508 lprintf(5, "%s:%d iconv_open(%s, %s) failed: %s\n",
1509 __FILE__, __LINE__, "UTF-8", mime_charset, strerror(errno));
1514 /** Messages in legacy Citadel variformat get handled thusly... */
1515 if (!strcasecmp(mime_content_type, "text/x-citadel-variformat")) {
1519 /* Boring old 80-column fixed format text gets handled this way... */
1520 else if (!strcasecmp(mime_content_type, "text/plain")) {
1521 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1524 if (buf[len-1] == '\n') buf[--len] = 0;
1525 if (buf[len-1] == '\r') buf[--len] = 0;
1528 if (ic != (iconv_t)(-1) ) {
1532 obuf = (char *) malloc(obuflen);
1534 iconv(ic, &ibuf, &ibuflen, &obuf, &obuflen);
1535 osav[SIZ-obuflen] = 0;
1536 safestrncpy(buf, osav, sizeof buf);
1542 while ((!IsEmptyStr(buf)) && (isspace(buf[len - 1])))
1545 ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) )) {
1546 wprintf("<blockquote>");
1548 } else if ((bq == 1) &&
1549 (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) ) {
1550 wprintf("</blockquote>");
1556 wprintf("</tt><br />");
1558 wprintf("</i><br />");
1561 /** HTML just gets escaped and stuffed back into the editor */
1562 else if (!strcasecmp(mime_content_type, "text/html")) {
1563 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1569 /** Unknown weirdness ... don't know how to handle this content type */
1571 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { }
1575 /** end of body handler */
1578 * If there were attachments, we have to download them and insert them
1579 * into the attachment chain for the forwarded message we are composing.
1581 if ( (forward_attachments) && (num_attachments) ) {
1582 for (i=0; i<num_attachments; ++i) {
1583 extract_token(buf, attachments, i, '\n', sizeof buf);
1584 extract_token(mime_filename, buf, 1, '|', sizeof mime_filename);
1585 extract_token(mime_partnum, buf, 2, '|', sizeof mime_partnum);
1586 extract_token(mime_disposition, buf, 3, '|', sizeof mime_disposition);
1587 extract_token(mime_content_type, buf, 4, '|', sizeof mime_content_type);
1588 mime_length = extract_int(buf, 5);
1591 * tracing ... uncomment if necessary
1594 lprintf(9, "fwd filename: %s\n", mime_filename);
1595 lprintf(9, "fwd partnum : %s\n", mime_partnum);
1596 lprintf(9, "fwd conttype: %s\n", mime_content_type);
1597 lprintf(9, "fwd dispose : %s\n", mime_disposition);
1598 lprintf(9, "fwd length : %d\n", mime_length);
1600 if ( (!strcasecmp(mime_disposition, "inline"))
1601 || (!strcasecmp(mime_disposition, "attachment")) ) {
1603 /* Create an attachment struct from this mime part... */
1604 att = malloc(sizeof(struct wc_attachment));
1605 memset(att, 0, sizeof(struct wc_attachment));
1606 att->length = mime_length;
1607 strcpy(att->content_type, mime_content_type);
1608 strcpy(att->filename, mime_filename);
1610 att->data = load_mimepart(msgnum, mime_partnum);
1612 /* And add it to the list. */
1613 if (WC->first_attachment == NULL) {
1614 WC->first_attachment = att;
1617 aptr = WC->first_attachment;
1618 while (aptr->next != NULL) aptr = aptr->next;
1627 if (ic != (iconv_t)(-1) ) {
1632 if (attachments != NULL) {
1638 * \brief Display one row in the mailbox summary view
1640 * \param num The row number to be displayed
1642 void display_summarized(int num) {
1645 wprintf("<tr id=\"m%ld\" style=\"font-weight:%s;\" "
1646 "onMouseDown=\"CtdlMoveMsgMouseDown(event,%ld)\">",
1647 WC->summ[num].msgnum,
1648 (WC->summ[num].is_new ? "bold" : "normal"),
1649 WC->summ[num].msgnum
1652 wprintf("<td width=%d%%>", SUBJ_COL_WIDTH_PCT);
1653 escputs(WC->summ[num].subj);
1656 wprintf("<td width=%d%%>", SENDER_COL_WIDTH_PCT);
1657 escputs(WC->summ[num].from);
1660 wprintf("<td width=%d%%>", DATE_PLUS_BUTTONS_WIDTH_PCT);
1661 webcit_fmt_date(datebuf, WC->summ[num].date, 1); /* brief */
1671 * \brief display the adressbook overview
1672 * \param msgnum the citadel message number
1673 * \param alpha what????
1675 void display_addressbook(long msgnum, char alpha) {
1677 char mime_partnum[SIZ];
1678 char mime_filename[SIZ];
1679 char mime_content_type[SIZ];
1680 char mime_disposition[SIZ];
1682 char vcard_partnum[SIZ];
1683 char *vcard_source = NULL;
1684 struct message_summary summ;
1686 memset(&summ, 0, sizeof(summ));
1687 safestrncpy(summ.subj, _("(no subject)"), sizeof summ.subj);
1689 sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */
1691 serv_getln(buf, sizeof buf);
1692 if (buf[0] != '1') return;
1694 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1695 if (!strncasecmp(buf, "part=", 5)) {
1696 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
1697 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
1698 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
1699 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
1700 mime_length = extract_int(&buf[5], 5);
1702 if ( (!strcasecmp(mime_content_type, "text/x-vcard"))
1703 || (!strcasecmp(mime_content_type, "text/vcard")) ) {
1704 strcpy(vcard_partnum, mime_partnum);
1710 if (!IsEmptyStr(vcard_partnum)) {
1711 vcard_source = load_mimepart(msgnum, vcard_partnum);
1712 if (vcard_source != NULL) {
1714 /** Display the summary line */
1715 display_vcard(vcard_source, alpha, 0, NULL);
1717 /** If it's my vCard I can edit it */
1718 if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
1719 || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))
1720 || (WC->wc_view == VIEW_ADDRESSBOOK)
1722 wprintf("<a href=\"edit_vcard?"
1723 "msgnum=%ld?partnum=%s\">",
1724 msgnum, vcard_partnum);
1725 wprintf("[%s]</a>", _("edit"));
1737 * \brief If it's an old "Firstname Lastname" style record, try to convert it.
1738 * \param namebuf name to analyze, reverse if nescessary
1740 void lastfirst_firstlast(char *namebuf) {
1741 char firstname[SIZ];
1745 if (namebuf == NULL) return;
1746 if (strchr(namebuf, ';') != NULL) return;
1748 i = num_tokens(namebuf, ' ');
1751 extract_token(lastname, namebuf, i-1, ' ', sizeof lastname);
1752 remove_token(namebuf, i-1, ' ');
1753 strcpy(firstname, namebuf);
1754 sprintf(namebuf, "%s; %s", lastname, firstname);
1758 * \brief fetch what??? name
1759 * \param msgnum the citadel message number
1760 * \param namebuf where to put the name in???
1762 void fetch_ab_name(long msgnum, char *namebuf) {
1764 char mime_partnum[SIZ];
1765 char mime_filename[SIZ];
1766 char mime_content_type[SIZ];
1767 char mime_disposition[SIZ];
1769 char vcard_partnum[SIZ];
1770 char *vcard_source = NULL;
1772 struct message_summary summ;
1774 if (namebuf == NULL) return;
1775 strcpy(namebuf, "");
1777 memset(&summ, 0, sizeof(summ));
1778 safestrncpy(summ.subj, "(no subject)", sizeof summ.subj);
1780 sprintf(buf, "MSG0 %ld|0", msgnum); /** unfortunately we need the mime info now */
1782 serv_getln(buf, sizeof buf);
1783 if (buf[0] != '1') return;
1785 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1786 if (!strncasecmp(buf, "part=", 5)) {
1787 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
1788 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
1789 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
1790 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
1791 mime_length = extract_int(&buf[5], 5);
1793 if ( (!strcasecmp(mime_content_type, "text/x-vcard"))
1794 || (!strcasecmp(mime_content_type, "text/vcard")) ) {
1795 strcpy(vcard_partnum, mime_partnum);
1801 if (!IsEmptyStr(vcard_partnum)) {
1802 vcard_source = load_mimepart(msgnum, vcard_partnum);
1803 if (vcard_source != NULL) {
1805 /* Grab the name off the card */
1806 display_vcard(vcard_source, 0, 0, namebuf);
1812 lastfirst_firstlast(namebuf);
1814 len = strlen(namebuf);
1815 for (i=0; i<len; ++i) {
1816 if (namebuf[i] != ';') return;
1818 strcpy(namebuf, _("(no name)"));
1824 * \brief Record compare function for sorting address book indices
1825 * \param ab1 adressbook one
1826 * \param ab2 adressbook two
1828 int abcmp(const void *ab1, const void *ab2) {
1830 (((const struct addrbookent *)ab1)->ab_name),
1831 (((const struct addrbookent *)ab2)->ab_name)
1837 * \brief Helper function for do_addrbook_view()
1838 * Converts a name into a three-letter tab label
1839 * \param tabbuf the tabbuffer to add name to
1840 * \param name the name to add to the tabbuffer
1842 void nametab(char *tabbuf, long len, char *name) {
1843 stresc(tabbuf, len, name, 0, 0);
1844 tabbuf[0] = toupper(tabbuf[0]);
1845 tabbuf[1] = tolower(tabbuf[1]);
1846 tabbuf[2] = tolower(tabbuf[2]);
1852 * \brief Render the address book using info we gathered during the scan
1853 * \param addrbook the addressbook to render
1854 * \param num_ab the number of the addressbook
1856 void do_addrbook_view(struct addrbookent *addrbook, int num_ab) {
1860 static int NAMESPERPAGE = 60;
1863 char tabfirst_label[64];
1865 char tablast_label[64];
1866 char this_tablabel[64];
1871 wprintf("<br /><br /><br /><div align=\"center\"><i>");
1872 wprintf(_("This address book is empty."));
1873 wprintf("</i></div>\n");
1878 qsort(addrbook, num_ab, sizeof(struct addrbookent), abcmp);
1881 num_pages = (num_ab / NAMESPERPAGE) + 1;
1883 tablabels = malloc(num_pages * sizeof (char *));
1884 if (tablabels == NULL) {
1885 wprintf("<br /><br /><br /><div align=\"center\"><i>");
1886 wprintf(_("An internal error has occurred."));
1887 wprintf("</i></div>\n");
1891 for (i=0; i<num_pages; ++i) {
1892 tabfirst = i * NAMESPERPAGE;
1893 tablast = tabfirst + NAMESPERPAGE - 1;
1894 if (tablast > (num_ab - 1)) tablast = (num_ab - 1);
1895 nametab(tabfirst_label, 64, addrbook[tabfirst].ab_name);
1896 nametab(tablast_label, 64, addrbook[tablast].ab_name);
1897 sprintf(this_tablabel, "%s - %s", tabfirst_label, tablast_label);
1898 tablabels[i] = strdup(this_tablabel);
1901 tabbed_dialog(num_pages, tablabels);
1904 for (i=0; i<num_ab; ++i) {
1906 if ((i / NAMESPERPAGE) != page) { /* New tab */
1907 page = (i / NAMESPERPAGE);
1909 wprintf("</tr></table>\n");
1910 end_tab(page-1, num_pages);
1912 begin_tab(page, num_pages);
1913 wprintf("<table border=0 cellspacing=0 cellpadding=3 width=100%%>\n");
1917 if ((displayed % 4) == 0) {
1918 if (displayed > 0) {
1922 wprintf("<tr bgcolor=\"#%s\">",
1923 (bg ? "DDDDDD" : "FFFFFF")
1929 wprintf("<a href=\"readfwd?startmsg=%ld&is_singlecard=1",
1930 addrbook[i].ab_msgnum);
1931 wprintf("?maxmsgs=1?is_summary=0?alpha=%s\">", bstr("alpha"));
1932 vcard_n_prettyize(addrbook[i].ab_name);
1933 escputs(addrbook[i].ab_name);
1934 wprintf("</a></td>\n");
1938 wprintf("</tr></table>\n");
1939 end_tab((num_pages-1), num_pages);
1941 for (i=0; i<num_pages; ++i) {
1950 * \brief load message pointers from the server
1951 * \param servcmd the citadel command to send to the citserver
1952 * \param with_headers what headers???
1954 int load_msg_ptrs(char *servcmd, int with_headers)
1965 int num_summ_alloc = 0;
1967 if (WC->summ != NULL) {
1972 num_summ_alloc = 100;
1974 WC->summ = malloc(num_summ_alloc * sizeof(struct message_summary));
1977 maxload = sizeof(WC->msgarr) / sizeof(long) ;
1979 serv_getln(buf, sizeof buf);
1980 if (buf[0] != '1') {
1983 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1984 if (nummsgs < maxload) {
1985 WC->msgarr[nummsgs] = extract_long(buf, 0);
1986 datestamp = extract_long(buf, 1);
1987 extract_token(fullname, buf, 2, '|', sizeof fullname);
1988 extract_token(nodename, buf, 3, '|', sizeof nodename);
1989 extract_token(inetaddr, buf, 4, '|', sizeof inetaddr);
1990 extract_token(subject, buf, 5, '|', sizeof subject);
1994 if (nummsgs > num_summ_alloc) {
1995 num_summ_alloc *= 2;
1996 WC->summ = realloc(WC->summ,
1997 num_summ_alloc * sizeof(struct message_summary));
2001 memset(&WC->summ[nummsgs-1], 0, sizeof(struct message_summary));
2002 WC->summ[nummsgs-1].msgnum = WC->msgarr[nummsgs-1];
2003 safestrncpy(WC->summ[nummsgs-1].subj,
2004 _("(no subject)"), sizeof WC->summ[nummsgs-1].subj);
2005 if (!IsEmptyStr(fullname)) {
2006 safestrncpy(WC->summ[nummsgs-1].from,
2007 fullname, sizeof WC->summ[nummsgs-1].from);
2009 if (!IsEmptyStr(subject)) {
2010 safestrncpy(WC->summ[nummsgs-1].subj, subject,
2011 sizeof WC->summ[nummsgs-1].subj);
2014 /** Handle subjects with RFC2047 encoding */
2015 utf8ify_rfc822_string(WC->summ[nummsgs-1].subj);
2017 if (strlen(WC->summ[nummsgs-1].subj) > 75) {
2018 strcpy(&WC->summ[nummsgs-1].subj[72], "...");
2021 if (!IsEmptyStr(nodename)) {
2022 if ( ((WC->room_flags & QR_NETWORK)
2023 || ((strcasecmp(nodename, serv_info.serv_nodename)
2024 && (strcasecmp(nodename, serv_info.serv_fqdn)))))
2026 strcat(WC->summ[nummsgs-1].from, " @ ");
2027 strcat(WC->summ[nummsgs-1].from, nodename);
2031 WC->summ[nummsgs-1].date = datestamp;
2034 /** Handle senders with RFC2047 encoding */
2035 utf8ify_rfc822_string(WC->summ[nummsgs-1].from);
2037 if (strlen(WC->summ[nummsgs-1].from) > 25) {
2038 strcpy(&WC->summ[nummsgs-1].from[22], "...");
2047 * \brief qsort() compatible function to compare two longs in descending order.
2049 * \param s1 first number to compare
2050 * \param s2 second number to compare
2052 int longcmp_r(const void *s1, const void *s2) {
2059 if (l1 > l2) return(-1);
2060 if (l1 < l2) return(+1);
2066 * \brief qsort() compatible function to compare two message summary structs by ascending subject.
2068 * \param s1 first item to compare
2069 * \param s2 second item to compare
2071 int summcmp_subj(const void *s1, const void *s2) {
2072 struct message_summary *summ1;
2073 struct message_summary *summ2;
2075 summ1 = (struct message_summary *)s1;
2076 summ2 = (struct message_summary *)s2;
2077 return strcasecmp(summ1->subj, summ2->subj);
2081 * \brief qsort() compatible function to compare two message summary structs by descending subject.
2083 * \param s1 first item to compare
2084 * \param s2 second item to compare
2086 int summcmp_rsubj(const void *s1, const void *s2) {
2087 struct message_summary *summ1;
2088 struct message_summary *summ2;
2090 summ1 = (struct message_summary *)s1;
2091 summ2 = (struct message_summary *)s2;
2092 return strcasecmp(summ2->subj, summ1->subj);
2096 * \brief qsort() compatible function to compare two message summary structs by ascending sender.
2098 * \param s1 first item to compare
2099 * \param s2 second item to compare
2101 int summcmp_sender(const void *s1, const void *s2) {
2102 struct message_summary *summ1;
2103 struct message_summary *summ2;
2105 summ1 = (struct message_summary *)s1;
2106 summ2 = (struct message_summary *)s2;
2107 return strcasecmp(summ1->from, summ2->from);
2111 * \brief qsort() compatible function to compare two message summary structs by descending sender.
2113 * \param s1 first item to compare
2114 * \param s2 second item to compare
2116 int summcmp_rsender(const void *s1, const void *s2) {
2117 struct message_summary *summ1;
2118 struct message_summary *summ2;
2120 summ1 = (struct message_summary *)s1;
2121 summ2 = (struct message_summary *)s2;
2122 return strcasecmp(summ2->from, summ1->from);
2126 * \brief qsort() compatible function to compare two message summary structs by ascending date.
2128 * \param s1 first item to compare
2129 * \param s2 second item to compare
2131 int summcmp_date(const void *s1, const void *s2) {
2132 struct message_summary *summ1;
2133 struct message_summary *summ2;
2135 summ1 = (struct message_summary *)s1;
2136 summ2 = (struct message_summary *)s2;
2138 if (summ1->date < summ2->date) return -1;
2139 else if (summ1->date > summ2->date) return +1;
2144 * \brief qsort() compatible function to compare two message summary structs by descending date.
2146 * \param s1 first item to compare
2147 * \param s2 second item to compare
2149 int summcmp_rdate(const void *s1, const void *s2) {
2150 struct message_summary *summ1;
2151 struct message_summary *summ2;
2153 summ1 = (struct message_summary *)s1;
2154 summ2 = (struct message_summary *)s2;
2156 if (summ1->date < summ2->date) return +1;
2157 else if (summ1->date > summ2->date) return -1;
2164 * \brief command loop for reading messages
2166 * \param oper Set to "readnew" or "readold" or "readfwd" or "headers"
2168 void readloop(char *oper)
2177 long *displayed_msgs = NULL;
2178 int num_displayed = 0;
2180 int is_addressbook = 0;
2181 int is_singlecard = 0;
2182 int is_calendar = 0;
2187 int lowest_displayed = (-1);
2188 int highest_displayed = 0;
2189 struct addrbookent *addrbook = NULL;
2191 char *sortby = NULL;
2192 char sortpref_name[128];
2193 char sortpref_value[128];
2194 char *subjsort_button;
2195 char *sendsort_button;
2196 char *datesort_button;
2197 int bbs_reverse = 0;
2198 struct wcsession *WCC = WC; /* This is done to make it run faster; WC is a function */
2200 if (WCC->wc_view == VIEW_WIKI) {
2201 sprintf(buf, "wiki?room=%s?page=home", WCC->wc_roomname);
2206 startmsg = atol(bstr("startmsg"));
2207 maxmsgs = atoi(bstr("maxmsgs"));
2208 is_summary = atoi(bstr("is_summary"));
2209 if (maxmsgs == 0) maxmsgs = DEFAULT_MAXMSGS;
2211 snprintf(sortpref_name, sizeof sortpref_name, "sort %s", WCC->wc_roomname);
2212 get_preference(sortpref_name, sortpref_value, sizeof sortpref_value);
2214 sortby = bstr("sortby");
2215 if ( (!IsEmptyStr(sortby)) && (strcasecmp(sortby, sortpref_value)) ) {
2216 set_preference(sortpref_name, sortby, 1);
2218 if (IsEmptyStr(sortby)) sortby = sortpref_value;
2221 if (IsEmptyStr(sortby)) sortby = "rdate";
2223 /** message board sort */
2224 if (!strcasecmp(sortby, "reverse")) {
2231 output_headers(1, 1, 1, 0, 0, 0);
2234 * When in summary mode, always show ALL messages instead of just
2235 * new or old. Otherwise, show what the user asked for.
2237 if (!strcmp(oper, "readnew")) {
2238 strcpy(cmd, "MSGS NEW");
2240 else if (!strcmp(oper, "readold")) {
2241 strcpy(cmd, "MSGS OLD");
2243 else if (!strcmp(oper, "do_search")) {
2244 sprintf(cmd, "MSGS SEARCH|%s", bstr("query"));
2247 strcpy(cmd, "MSGS ALL");
2250 if ((WCC->wc_view == VIEW_MAILBOX) && (maxmsgs > 1)) {
2252 if (!strcmp(oper, "do_search")) {
2253 sprintf(cmd, "MSGS SEARCH|%s", bstr("query"));
2256 strcpy(cmd, "MSGS ALL");
2260 if ((WCC->wc_view == VIEW_ADDRESSBOOK) && (maxmsgs > 1)) {
2262 if (!strcmp(oper, "do_search")) {
2263 sprintf(cmd, "MSGS SEARCH|%s", bstr("query"));
2266 strcpy(cmd, "MSGS ALL");
2271 if (is_summary) { /**< fetch header summary */
2272 snprintf(cmd, sizeof cmd, "MSGS %s|%s||1",
2273 (!strcmp(oper, "do_search") ? "SEARCH" : "ALL"),
2274 (!strcmp(oper, "do_search") ? bstr("query") : "")
2281 * Are we doing a summary view? If so, we need to know old messages
2282 * and new messages, so we can do that pretty boldface thing for the
2285 strcpy(old_msgs, "");
2288 serv_getln(buf, sizeof buf);
2289 if (buf[0] == '2') {
2290 strcpy(old_msgs, &buf[4]);
2294 is_singlecard = atoi(bstr("is_singlecard"));
2296 if (WCC->wc_default_view == VIEW_CALENDAR) { /**< calendar */
2298 strcpy(cmd, "MSGS ALL");
2301 if (WCC->wc_default_view == VIEW_TASKS) { /**< tasks */
2303 strcpy(cmd, "MSGS ALL");
2306 if (WCC->wc_default_view == VIEW_NOTES) { /**< notes */
2308 strcpy(cmd, "MSGS ALL");
2313 wprintf("<div align=center>%s</div>\n", _("Click on any note to edit it."));
2314 wprintf("<div id=\"new_notes_here\"></div>\n");
2317 nummsgs = load_msg_ptrs(cmd, is_summary);
2320 if ((!is_tasks) && (!is_calendar) && (!is_notes) && (!is_addressbook)) {
2321 wprintf("<div align=\"center\"><br /><em>");
2322 if (!strcmp(oper, "readnew")) {
2323 wprintf(_("No new messages."));
2324 } else if (!strcmp(oper, "readold")) {
2325 wprintf(_("No old messages."));
2327 wprintf(_("No messages here."));
2329 wprintf("</em><br /></div>\n");
2336 for (a = 0; a < nummsgs; ++a) {
2337 /** Are you a new message, or an old message? */
2339 if (is_msg_in_mset(old_msgs, WCC->msgarr[a])) {
2340 WCC->summ[a].is_new = 0;
2343 WCC->summ[a].is_new = 1;
2349 if (startmsg == 0L) {
2351 startmsg = WCC->msgarr[(nummsgs >= maxmsgs) ? (nummsgs - maxmsgs) : 0];
2354 startmsg = WCC->msgarr[0];
2359 if (!strcasecmp(sortby, "subject")) {
2360 qsort(WCC->summ, WCC->num_summ,
2361 sizeof(struct message_summary), summcmp_subj);
2363 else if (!strcasecmp(sortby, "rsubject")) {
2364 qsort(WCC->summ, WCC->num_summ,
2365 sizeof(struct message_summary), summcmp_rsubj);
2367 else if (!strcasecmp(sortby, "sender")) {
2368 qsort(WCC->summ, WCC->num_summ,
2369 sizeof(struct message_summary), summcmp_sender);
2371 else if (!strcasecmp(sortby, "rsender")) {
2372 qsort(WCC->summ, WCC->num_summ,
2373 sizeof(struct message_summary), summcmp_rsender);
2375 else if (!strcasecmp(sortby, "date")) {
2376 qsort(WCC->summ, WCC->num_summ,
2377 sizeof(struct message_summary), summcmp_date);
2379 else if (!strcasecmp(sortby, "rdate")) {
2380 qsort(WCC->summ, WCC->num_summ,
2381 sizeof(struct message_summary), summcmp_rdate);
2385 if (!strcasecmp(sortby, "subject")) {
2386 subjsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=rsubject\"><img border=\"0\" src=\"static/down_pointer.gif\" /></a>" ;
2388 else if (!strcasecmp(sortby, "rsubject")) {
2389 subjsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=subject\"><img border=\"0\" src=\"static/up_pointer.gif\" /></a>" ;
2392 subjsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=subject\"><img border=\"0\" src=\"static/sort_none.gif\" /></a>" ;
2395 if (!strcasecmp(sortby, "sender")) {
2396 sendsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=rsender\"><img border=\"0\" src=\"static/down_pointer.gif\" /></a>" ;
2398 else if (!strcasecmp(sortby, "rsender")) {
2399 sendsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=sender\"><img border=\"0\" src=\"static/up_pointer.gif\" /></a>" ;
2402 sendsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=sender\"><img border=\"0\" src=\"static/sort_none.gif\" /></a>" ;
2405 if (!strcasecmp(sortby, "date")) {
2406 datesort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=rdate\"><img border=\"0\" src=\"static/down_pointer.gif\" /></a>" ;
2408 else if (!strcasecmp(sortby, "rdate")) {
2409 datesort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=date\"><img border=\"0\" src=\"static/up_pointer.gif\" /></a>" ;
2412 datesort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=rdate\"><img border=\"0\" src=\"static/sort_none.gif\" /></a>" ;
2417 wprintf("<script language=\"javascript\" type=\"text/javascript\">"
2418 " document.onkeydown = CtdlMsgListKeyPress; "
2419 " if (document.layers) { "
2420 " document.captureEvents(Event.KEYPRESS); "
2425 /** note that Date and Delete are now in the same column */
2426 wprintf("<div id=\"message_list_hdr\">"
2427 "<div class=\"fix_scrollbar_bug\">"
2428 "<table cellspacing=0 style=\"width:100%%\">"
2431 wprintf("<th width=%d%%>%s %s</th>"
2432 "<th width=%d%%>%s %s</th>"
2433 "<th width=%d%%>%s %s"
2435 "<input type=\"submit\" name=\"delete_button\" id=\"delbutton\" "
2436 " onClick=\"CtdlDeleteSelectedMessages(event)\" "
2442 _("Subject"), subjsort_button,
2443 SENDER_COL_WIDTH_PCT,
2444 _("Sender"), sendsort_button,
2445 DATE_PLUS_BUTTONS_WIDTH_PCT,
2446 _("Date"), datesort_button,
2449 wprintf("</table></div></div>\n");
2451 wprintf("<div id=\"message_list\">"
2453 "<div class=\"fix_scrollbar_bug\">\n"
2455 "<table class=\"mailbox_summary\" id=\"summary_headers\" "
2456 "cellspacing=0 style=\"width:100%%;-moz-user-select:none;\">"
2462 * Set the "is_bbview" variable if it appears that we are looking at
2463 * a classic bulletin board view.
2465 if ((!is_tasks) && (!is_calendar) && (!is_addressbook)
2466 && (!is_notes) && (!is_singlecard) && (!is_summary)) {
2471 * If we're not currently looking at ALL requested
2472 * messages, then display the selector bar
2475 /** begin bbview scroller */
2476 wprintf("<form name=\"msgomatictop\" class=\"selector_top\" > \n <p>");
2477 wprintf(_("Reading #"), lowest_displayed, highest_displayed);
2479 wprintf("<select name=\"whichones\" size=\"1\" "
2480 "OnChange=\"location.href=msgomatictop.whichones.options"
2481 "[selectedIndex].value\">\n");
2484 for (b=nummsgs-1; b>=0; b = b - maxmsgs) {
2486 lo = b - maxmsgs + 2;
2488 wprintf("<option %s value="
2493 "%d-%d</option> \n",
2494 ((WCC->msgarr[lo-1] == startmsg) ? "selected" : ""),
2503 for (b=0; b<nummsgs; b = b + maxmsgs) {
2505 hi = b + maxmsgs + 1;
2506 if (hi > nummsgs) hi = nummsgs;
2507 wprintf("<option %s value="
2512 "%d-%d</option> \n",
2513 ((WCC->msgarr[b] == startmsg) ? "selected" : ""),
2522 wprintf("<option value=\"%s?startmsg=%ld"
2523 "?maxmsgs=9999999?is_summary=%d\">",
2525 WCC->msgarr[0], is_summary);
2527 wprintf("</option>");
2528 wprintf("</select> ");
2529 wprintf(_("of %d messages."), nummsgs);
2531 /** forward/reverse */
2532 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
2533 "OnChange=\"location.href='%s?sortby=forward'\"",
2534 (bbs_reverse ? "" : "checked"),
2538 wprintf(_("oldest to newest"));
2539 wprintf(" ");
2541 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
2542 "OnChange=\"location.href='%s?sortby=reverse'\"",
2543 (bbs_reverse ? "checked" : ""),
2547 wprintf(_("newest to oldest"));
2550 wprintf("</p></form>\n");
2551 /** end bbview scroller */
2556 wprintf ("<script src=\"/static/dragdrop.js\" type=\"text/javascript\"></script>\n");
2561 for (a = 0; a < nummsgs; ++a) {
2562 if ((WCC->msgarr[a] >= startmsg) && (num_displayed < maxmsgs)) {
2564 /** Display the message */
2566 display_summarized(a);
2568 else if (is_addressbook) {
2569 fetch_ab_name(WCC->msgarr[a], buf);
2571 addrbook = realloc(addrbook,
2572 (sizeof(struct addrbookent) * num_ab) );
2573 safestrncpy(addrbook[num_ab-1].ab_name, buf,
2574 sizeof(addrbook[num_ab-1].ab_name));
2575 addrbook[num_ab-1].ab_msgnum = WCC->msgarr[a];
2577 else if (is_calendar) {
2578 display_calendar(WCC->msgarr[a]);
2580 else if (is_tasks) {
2581 display_task(WCC->msgarr[a]);
2583 else if (is_notes) {
2584 display_note(WCC->msgarr[a]);
2587 if (displayed_msgs == NULL) {
2588 displayed_msgs = malloc(sizeof(long) *
2589 (maxmsgs<nummsgs ? maxmsgs : nummsgs));
2591 displayed_msgs[num_displayed] = WCC->msgarr[a];
2594 if (lowest_displayed < 0) lowest_displayed = a;
2595 highest_displayed = a;
2602 if (displayed_msgs != NULL) {
2604 qsort(displayed_msgs, num_displayed, sizeof(long), longcmp_r);
2607 /** if we do a split bbview in the future, begin messages div here */
2609 for (a=0; a<num_displayed; ++a) {
2610 read_message(displayed_msgs[a], 0, "");
2613 /** if we do a split bbview in the future, end messages div here */
2615 free(displayed_msgs);
2616 displayed_msgs = NULL;
2621 "</div>\n"); /**< end of 'fix_scrollbar_bug' div */
2622 wprintf("</div>"); /**< end of 'message_list' div */
2624 /** Here's the grab-it-to-resize-the-message-list widget */
2625 wprintf("<div id=\"resize_msglist\" "
2626 "onMouseDown=\"CtdlResizeMsgListMouseDown(event)\">"
2627 "<div class=\"fix_scrollbar_bug\"> <hr>"
2631 wprintf("<div id=\"preview_pane\">"); /**< The preview pane will initially be empty */
2635 * Bump these because although we're thinking in zero base, the user
2636 * is a drooling idiot and is thinking in one base.
2639 ++highest_displayed;
2642 * If we're not currently looking at ALL requested
2643 * messages, then display the selector bar
2646 /** begin bbview scroller */
2647 wprintf("<form name=\"msgomatic\" class=\"selector_bottom\" > \n <p>");
2648 wprintf(_("Reading #"), lowest_displayed, highest_displayed);
2650 wprintf("<select name=\"whichones\" size=\"1\" "
2651 "OnChange=\"location.href=msgomatic.whichones.options"
2652 "[selectedIndex].value\">\n");
2655 for (b=nummsgs-1; b>=0; b = b - maxmsgs) {
2657 lo = b - maxmsgs + 2;
2659 wprintf("<option %s value="
2664 "%d-%d</option> \n",
2665 ((WCC->msgarr[lo-1] == startmsg) ? "selected" : ""),
2674 for (b=0; b<nummsgs; b = b + maxmsgs) {
2676 hi = b + maxmsgs + 1;
2677 if (hi > nummsgs) hi = nummsgs;
2678 wprintf("<option %s value="
2683 "%d-%d</option> \n",
2684 ((WCC->msgarr[b] == startmsg) ? "selected" : ""),
2693 wprintf("<option value=\"%s?startmsg=%ld"
2694 "?maxmsgs=9999999?is_summary=%d\">",
2696 WCC->msgarr[0], is_summary);
2698 wprintf("</option>");
2699 wprintf("</select> ");
2700 wprintf(_("of %d messages."), nummsgs);
2702 /** forward/reverse */
2703 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
2704 "OnChange=\"location.href='%s?sortby=forward'\"",
2705 (bbs_reverse ? "" : "checked"),
2709 wprintf(_("oldest to newest"));
2710 wprintf(" ");
2711 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
2712 "OnChange=\"location.href='%s?sortby=reverse'\"",
2713 (bbs_reverse ? "checked" : ""),
2717 wprintf(_("newest to oldest"));
2720 wprintf("</p></form>\n");
2721 /** end bbview scroller */
2726 // wprintf ("</div>\n");
2727 wprintf ("<div id=\"wastebin\" align=middle>Drop notes here to remove them.</div>\n");
2728 wprintf ("<script type=\"text/javascript\">\n");
2729 // wprintf ("//<![CDATA[\n");
2730 wprintf ("Droppables.add(\"wastebin\",\n");
2732 wprintf ("\t\taccept:'notes',\n");
2733 wprintf ("\t\tonDrop:function(element)\n");
2734 wprintf ("\t\t{\n");
2735 wprintf ("\t\t\tElement.hide(element);\n");
2736 wprintf ("\t\t\tnew Ajax.Updater('notes', 'delnote',\n");
2737 wprintf ("\t\t\t{\n");
2738 wprintf ("\t\t\t\tasynchronous:true,\n");
2739 wprintf ("\t\t\t\tevalScripts:true,\n");
2740 wprintf ("\t\t\t\tonComplete:function(request)\n");
2741 wprintf ("\t\t\t\t{\n");
2742 wprintf ("\t\t\t\t\tElement.hide('indicator')\n");
2743 wprintf ("\t\t\t\t},\n");
2744 wprintf ("\t\t\t\tonLoading:function(request)\n");
2745 wprintf ("\t\t\t\t{\n");
2746 wprintf ("\t\t\t\t\tElement.show('indicator')\n");
2747 wprintf ("\t\t\t\t},\n");
2748 wprintf ("\t\t\t\tparameters:'id=' + encodeURIComponent(element.id)\n");
2749 wprintf ("\t\t\t})\n");
2750 wprintf ("\t\t}\n");
2752 // wprintf ("//]]>\n");
2753 wprintf ("</script>\n");
2760 do_tasks_view(); /** Render the task list */
2764 do_calendar_view(); /** Render the calendar */
2767 if (is_addressbook) {
2768 do_addrbook_view(addrbook, num_ab); /** Render the address book */
2771 /** Note: wDumpContent() will output one additional </div> tag. */
2772 wprintf("</div>\n"); /** end of 'content' div */
2775 /** free the summary */
2776 if (WCC->summ != NULL) {
2781 if (addrbook != NULL) free(addrbook);
2786 * \brief Back end for post_message()
2787 * ... this is where the actual message gets transmitted to the server.
2789 void post_mime_to_server(void) {
2791 int is_multipart = 0;
2793 struct wc_attachment *att;
2795 size_t encoded_length;
2796 size_t encoded_strlen;
2798 /** RFC2045 requires this, and some clients look for it... */
2799 serv_puts("MIME-Version: 1.0");
2800 serv_puts("X-Mailer: " PACKAGE_STRING);
2802 /** If there are attachments, we have to do multipart/mixed */
2803 if (WC->first_attachment != NULL) {
2808 sprintf(boundary, "Citadel--Multipart--%s--%04x--%04x",
2809 serv_info.serv_fqdn,
2814 /** Remember, serv_printf() appends an extra newline */
2815 serv_printf("Content-type: multipart/mixed; "
2816 "boundary=\"%s\"\n", boundary);
2817 serv_printf("This is a multipart message in MIME format.\n");
2818 serv_printf("--%s", boundary);
2821 serv_puts("Content-type: text/html; charset=utf-8");
2822 serv_puts("Content-Transfer-Encoding: quoted-printable");
2824 serv_puts("<html><body>\r\n");
2825 text_to_server_qp(bstr("msgtext")); /** Transmit message in quoted-printable encoding */
2826 serv_puts("</body></html>\r\n");
2830 /** Add in the attachments */
2831 for (att = WC->first_attachment; att!=NULL; att=att->next) {
2833 encoded_length = ((att->length * 150) / 100);
2834 encoded = malloc(encoded_length);
2835 if (encoded == NULL) break;
2836 encoded_strlen = CtdlEncodeBase64(encoded, att->data, att->length, 1);
2838 serv_printf("--%s", boundary);
2839 serv_printf("Content-type: %s", att->content_type);
2840 serv_printf("Content-disposition: attachment; "
2841 "filename=\"%s\"", att->filename);
2842 serv_puts("Content-transfer-encoding: base64");
2844 serv_write(encoded, encoded_strlen);
2849 serv_printf("--%s--", boundary);
2857 * \brief Post message (or don't post message)
2859 * Note regarding the "dont_post" variable:
2860 * A random value (actually, it's just a timestamp) is inserted as a hidden
2861 * field called "postseq" when the display_enter page is generated. This
2862 * value is checked when posting, using the static variable dont_post. If a
2863 * user attempts to post twice using the same dont_post value, the message is
2864 * discarded. This prevents the accidental double-saving of the same message
2865 * if the user happens to click the browser "back" button.
2867 void post_message(void)
2870 char encoded_subject[1024];
2871 static long dont_post = (-1L);
2872 struct wc_attachment *att, *aptr;
2873 int is_anonymous = 0;
2876 if (!IsEmptyStr(bstr("force_room"))) {
2877 gotoroom(bstr("force_room"));
2880 display_name = bstr("display_name");
2881 if (!strcmp(display_name, "__ANONYMOUS__")) {
2886 if (WC->upload_length > 0) {
2888 lprintf(9, "%s:%d: we are uploading %d bytes\n", __FILE__, __LINE__, WC->upload_length);
2889 /** There's an attachment. Save it to this struct... */
2890 att = malloc(sizeof(struct wc_attachment));
2891 memset(att, 0, sizeof(struct wc_attachment));
2892 att->length = WC->upload_length;
2893 strcpy(att->content_type, WC->upload_content_type);
2894 strcpy(att->filename, WC->upload_filename);
2897 /** And add it to the list. */
2898 if (WC->first_attachment == NULL) {
2899 WC->first_attachment = att;
2902 aptr = WC->first_attachment;
2903 while (aptr->next != NULL) aptr = aptr->next;
2908 * Mozilla sends a simple filename, which is what we want,
2909 * but Satan's Browser sends an entire pathname. Reduce
2910 * the path to just a filename if we need to.
2912 while (num_tokens(att->filename, '/') > 1) {
2913 remove_token(att->filename, 0, '/');
2915 while (num_tokens(att->filename, '\\') > 1) {
2916 remove_token(att->filename, 0, '\\');
2920 * Transfer control of this memory from the upload struct
2921 * to the attachment struct.
2923 att->data = WC->upload;
2924 WC->upload_length = 0;
2930 if (!IsEmptyStr(bstr("cancel_button"))) {
2931 sprintf(WC->ImportantMessage,
2932 _("Cancelled. Message was not posted."));
2933 } else if (!IsEmptyStr(bstr("attach_button"))) {
2936 } else if (atol(bstr("postseq")) == dont_post) {
2937 sprintf(WC->ImportantMessage,
2938 _("Automatically cancelled because you have already "
2939 "saved this message."));
2941 webcit_rfc2047encode(encoded_subject, sizeof encoded_subject, bstr("subject"));
2942 sprintf(buf, "ENT0 1|%s|%d|4|%s|%s||%s|%s|%s|%s",
2950 bstr("my_email_addr")
2953 serv_getln(buf, sizeof buf);
2954 if (buf[0] == '4') {
2955 post_mime_to_server();
2956 if ( (!IsEmptyStr(bstr("recp")))
2957 || (!IsEmptyStr(bstr("cc" )))
2958 || (!IsEmptyStr(bstr("bcc" )))
2960 sprintf(WC->ImportantMessage, _("Message has been sent.\n"));
2963 sprintf(WC->ImportantMessage, _("Message has been posted.\n"));
2965 dont_post = atol(bstr("postseq"));
2967 lprintf(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, buf);
2968 sprintf(WC->ImportantMessage, "%s", &buf[4]);
2974 free_attachments(WC);
2977 * We may have been supplied with instructions regarding the location
2978 * to which we must return after posting. If found, go there.
2980 if (!IsEmptyStr(bstr("return_to"))) {
2981 http_redirect(bstr("return_to"));
2984 * If we were editing a page in a wiki room, go to that page now.
2986 else if (!IsEmptyStr(bstr("wikipage"))) {
2987 snprintf(buf, sizeof buf, "wiki?page=%s", bstr("wikipage"));
2991 * Otherwise, just go to the "read messages" loop.
2994 readloop("readnew");
3002 * \brief display the message entry screen
3004 void display_enter(void)
3010 struct wc_attachment *att;
3011 int recipient_required = 0;
3012 int subject_required = 0;
3013 int recipient_bad = 0;
3015 int is_anonymous = 0;
3016 long existing_page = (-1L);
3020 if (!IsEmptyStr(bstr("force_room"))) {
3021 gotoroom(bstr("force_room"));
3024 display_name = bstr("display_name");
3025 if (!strcmp(display_name, "__ANONYMOUS__")) {
3030 /** First test to see whether this is a room that requires recipients to be entered */
3031 serv_puts("ENT0 0");
3032 serv_getln(buf, sizeof buf);
3034 if (!strncmp(buf, "570", 3)) { /** 570 means that we need a recipient here */
3035 recipient_required = 1;
3037 else if (buf[0] != '2') { /** Any other error means that we cannot continue */
3038 sprintf(WC->ImportantMessage, "%s", &buf[4]);
3039 readloop("readnew");
3043 /* Is the server strongly recommending that the user enter a message subject? */
3044 if ((buf[3] != '\0') && (buf[4] != '\0')) {
3045 subject_required = extract_int(&buf[4], 1);
3049 * Are we perhaps in an address book view? If so, then an "enter
3050 * message" command really means "add new entry."
3052 if (WC->wc_default_view == VIEW_ADDRESSBOOK) {
3053 do_edit_vcard(-1, "", "", WC->wc_roomname);
3057 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
3059 * Are we perhaps in a calendar room? If so, then an "enter
3060 * message" command really means "add new calendar item."
3062 if (WC->wc_default_view == VIEW_CALENDAR) {
3063 display_edit_event();
3068 * Are we perhaps in a tasks view? If so, then an "enter
3069 * message" command really means "add new task."
3071 if (WC->wc_default_view == VIEW_TASKS) {
3072 display_edit_task();
3078 * Otherwise proceed normally.
3079 * Do a custom room banner with no navbar...
3081 output_headers(1, 1, 2, 0, 0, 0);
3082 wprintf("<div id=\"banner\">\n");
3083 embed_room_banner(NULL, navbar_none);
3084 wprintf("</div>\n");
3085 wprintf("<div id=\"content\">\n"
3086 "<div class=\"fix_scrollbar_bug message \">");
3088 /** Now check our actual recipients if there are any */
3089 if (recipient_required) {
3090 sprintf(buf, "ENT0 0|%s|%d|0||%s||%s|%s|%s",
3094 bstr("cc"), bstr("bcc"), bstr("wikipage"));
3096 serv_getln(buf, sizeof buf);
3098 if (!strncmp(buf, "570", 3)) { /** 570 means we have an invalid recipient listed */
3099 if (!IsEmptyStr(bstr("recp")) &&
3100 !IsEmptyStr(bstr("cc" )) &&
3101 !IsEmptyStr(bstr("bcc" ))) {
3105 else if (buf[0] != '2') { /** Any other error means that we cannot continue */
3106 wprintf("<em>%s</em><br />\n", &buf[4]);
3111 /** If we got this far, we can display the message entry screen. */
3113 /** begin message entry screen */
3115 "enctype=\"multipart/form-data\" "
3117 "accept-charset=\"UTF-8\" "
3119 "name=\"enterform\""
3121 wprintf("<input type=\"hidden\" name=\"postseq\" value=\"%ld\">\n", now);
3122 if (WC->wc_view == VIEW_WIKI) {
3123 wprintf("<input type=\"hidden\" name=\"wikipage\" value=\"%s\">\n", bstr("wikipage"));
3125 wprintf("<input type=\"hidden\" name=\"return_to\" value=\"%s\">\n", bstr("return_to"));
3126 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
3127 wprintf("<input type=\"hidden\" name=\"force_room\" value=\"");
3128 escputs(WC->wc_roomname);
3131 /** submit or cancel buttons */
3132 wprintf("<p class=\"send_edit_msg\">");
3133 wprintf("<input type=\"submit\" name=\"send_button\" value=\"");
3134 if (recipient_required) {
3135 wprintf(_("Send message"));
3137 wprintf(_("Post message"));
3140 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">\n", _("Cancel"));
3145 wprintf("<img src=\"static/newmess3_24x.gif\" class=\"imgedit\">");
3146 wprintf(" "); /** header bar */
3147 webcit_fmt_date(buf, now, 0);
3149 wprintf("\n"); /** header bar */
3151 wprintf("<table width=\"100%%\" class=\"edit_msg_table\">");
3153 wprintf("<th><label for=\"from_id\" > ");
3154 wprintf(_(" <I>from</I> "));
3155 wprintf("</label></th>");
3157 wprintf("<td colspan=\"2\">");
3159 /* Allow the user to select any of his valid screen names */
3161 wprintf("<select name=\"display_name\" size=1 id=\"from_id\">\n");
3164 serv_getln(buf, sizeof buf);
3165 if (buf[0] == '1') {
3166 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3167 wprintf("<option %s value=\"",
3168 ((!strcasecmp(bstr("display_name"), buf)) ? "selected" : "")
3173 wprintf("</option>\n");
3177 if (WC->room_flags & QR_ANONOPT) {
3178 wprintf("<option %s value=\"__ANONYMOUS__\">%s</option>\n",
3179 ((!strcasecmp(bstr("__ANONYMOUS__"), WC->wc_fullname)) ? "selected" : ""),
3184 wprintf("</select>\n");
3186 /* If this is an email (not a post), allow the user to select any of his
3187 * valid email addresses.
3189 if (recipient_required) {
3191 serv_getln(buf, sizeof buf);
3192 if (buf[0] == '1') {
3193 wprintf("<select name=\"my_email_addr\" size=1>\n");
3194 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3195 wprintf("<option value=\"");
3199 wprintf("></option>\n");
3201 wprintf("</select>\n");
3205 wprintf(_(" <I>in</I> "));
3206 escputs(WC->wc_roomname);
3208 wprintf("</td></tr>");
3210 if (recipient_required) {
3212 wprintf("<tr><th><label for=\"recp_id\"> ");
3214 wprintf("</label></th>"
3215 "<td><input autocomplete=\"off\" type=\"text\" name=\"recp\" id=\"recp_id\" value=\"");
3216 escputs(bstr("recp"));
3217 wprintf("\" size=45 maxlength=1000 />");
3218 wprintf("<div class=\"auto_complete\" id=\"recp_name_choices\"></div>");
3219 wprintf("</td><td rowspan=\"3\" align=\"left\" valign=\"top\">");
3221 /** Pop open an address book -- begin **/
3223 "<a href=\"javascript:PopOpenAddressBook('recp_id|%s|cc_id|%s|bcc_id|%s');\" "
3225 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
3227 _("To:"), _("CC:"), _("BCC:"),
3228 _("Contacts"), _("Contacts")
3230 /** Pop open an address book -- end **/
3232 wprintf("</td></tr>");
3234 wprintf("<tr><th><label for=\"cc_id\"> ");
3236 wprintf("</label></th>"
3237 "<td><input autocomplete=\"off\" type=\"text\" name=\"cc\" id=\"cc_id\" value=\"");
3238 escputs(bstr("cc"));
3239 wprintf("\" size=45 maxlength=1000 />");
3240 wprintf("<div class=\"auto_complete\" id=\"cc_name_choices\"></div>");
3241 wprintf("</td></tr>");
3243 wprintf("<tr><th><label for=\"bcc_id\"> ");
3245 wprintf("</label></th>"
3246 "<td><input autocomplete=\"off\" type=\"text\" name=\"bcc\" id=\"bcc_id\" value=\"");
3247 escputs(bstr("bcc"));
3248 wprintf("\" size=45 maxlength=1000 />");
3249 wprintf("<div class=\"auto_complete\" id=\"bcc_name_choices\"></div>");
3250 wprintf("</td></tr>");
3252 /** Initialize the autocomplete ajax helpers (found in wclib.js) */
3253 wprintf("<script type=\"text/javascript\"> \n"
3254 " activate_entmsg_autocompleters(); \n"
3260 wprintf("<tr><th><label for=\"subject_id\" > ");
3261 if (recipient_required || subject_required) {
3262 wprintf(_("Subject:"));
3265 wprintf(_("Subject (optional):"));
3267 wprintf("</label></th>"
3268 "<td colspan=\"2\">"
3269 "<input type=\"text\" name=\"subject\" id=\"subject_id\" value=\" ");
3270 escputs(bstr("subject"));
3271 wprintf("\" size=45 maxlength=70>\n");
3272 wprintf("</td></tr>");
3274 wprintf("<tr><td colspan=\"3\">\n");
3276 wprintf("<textarea name=\"msgtext\" cols=\"80\" rows=\"15\">");
3278 /** If we're continuing from a previous edit, put our partially-composed message back... */
3279 msgescputs(bstr("msgtext"));
3281 /* If we're forwarding a message, insert it here... */
3282 if (atol(bstr("fwdquote")) > 0L) {
3283 wprintf("<br><div align=center><i>");
3284 wprintf(_("--- forwarded message ---"));
3285 wprintf("</i></div><br>");
3286 pullquote_message(atol(bstr("fwdquote")), 1, 1);
3289 /** If we're replying quoted, insert the quote here... */
3290 else if (atol(bstr("replyquote")) > 0L) {
3293 pullquote_message(atol(bstr("replyquote")), 0, 1);
3294 wprintf("</blockquote><br>");
3297 /** If we're editing a wiki page, insert the existing page here... */
3298 else if (WC->wc_view == VIEW_WIKI) {
3299 safestrncpy(buf, bstr("wikipage"), sizeof buf);
3300 str_wiki_index(buf);
3301 existing_page = locate_message_by_uid(buf);
3302 if (existing_page >= 0L) {
3303 pullquote_message(existing_page, 1, 0);
3307 /** Insert our signature if appropriate... */
3308 if ( (WC->is_mailbox) && (strcmp(bstr("sig_inserted"), "yes")) ) {
3309 get_preference("use_sig", buf, sizeof buf);
3310 if (!strcasecmp(buf, "yes")) {
3312 get_preference("signature", ebuf, sizeof ebuf);
3313 euid_unescapize(buf, ebuf);
3314 wprintf("<br>--<br>");
3316 for (i=0; i<len; ++i) {
3317 if (buf[i] == '\n') {
3320 else if (buf[i] == '<') {
3323 else if (buf[i] == '>') {
3326 else if (buf[i] == '&') {
3329 else if (buf[i] == '\"') {
3332 else if (buf[i] == '\'') {
3335 else if (isprint(buf[i])) {
3336 wprintf("%c", buf[i]);
3342 wprintf("</textarea>");
3345 * The following template embeds the TinyMCE richedit control, and automatically
3346 * transforms the textarea into a richedit textarea.
3348 do_template("richedit");
3350 /** Enumerate any attachments which are already in place... */
3351 wprintf("<div class=\"attachment buttons\"><img src=\"static/diskette_24x.gif\" class=\"imgedit\" > ");
3352 wprintf(_("Attachments:"));
3354 wprintf("<select name=\"which_attachment\" size=1>");
3355 for (att = WC->first_attachment; att != NULL; att = att->next) {
3356 wprintf("<option value=\"");
3357 urlescputs(att->filename);
3359 escputs(att->filename);
3360 /* wprintf(" (%s, %d bytes)",att->content_type,att->length); */
3361 wprintf("</option>\n");
3363 wprintf("</select>");
3365 /** Now offer the ability to attach additional files... */
3366 wprintf(" ");
3367 wprintf(_("Attach file:"));
3368 wprintf(" <input name=\"attachfile\" class=\"attachfile\" "
3369 "size=16 type=\"file\">\n "
3370 "<input type=\"submit\" name=\"attach_button\" value=\"%s\">\n", _("Add"));
3371 wprintf("</div>"); /* End of "attachment buttons" div */
3374 /** Make sure we only insert our signature once */
3375 if (strcmp(bstr("sig_inserted"), "yes")) {
3376 wprintf("<input type=\"hidden\" name=\"sig_inserted\" value=\"yes\">\n");
3379 wprintf("</td></tr></table>");
3381 wprintf("</form>\n");
3382 wprintf("</div>\n"); /* end of "fix_scrollbar_bug" div */
3384 /* NOTE: address_book_popup() will close the "content" div. Don't close it here. */
3385 DONE: address_book_popup();
3391 * \brief delete a message
3393 void delete_msg(void)
3398 msgid = atol(bstr("msgid"));
3400 if (WC->wc_is_trash) { /** Delete from Trash is a real delete */
3401 serv_printf("DELE %ld", msgid);
3403 else { /** Otherwise move it to Trash */
3404 serv_printf("MOVE %ld|_TRASH_|0", msgid);
3407 serv_getln(buf, sizeof buf);
3408 sprintf(WC->ImportantMessage, "%s", &buf[4]);
3410 readloop("readnew");
3415 * \brief move a message to another folder
3422 msgid = atol(bstr("msgid"));
3424 if (!IsEmptyStr(bstr("move_button"))) {
3425 sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
3427 serv_getln(buf, sizeof buf);
3428 sprintf(WC->ImportantMessage, "%s", &buf[4]);
3430 sprintf(WC->ImportantMessage, (_("The message was not moved.")));
3433 readloop("readnew");
3441 * \brief Confirm move of a message
3443 void confirm_move_msg(void)
3449 msgid = atol(bstr("msgid"));
3452 output_headers(1, 1, 2, 0, 0, 0);
3453 wprintf("<div id=\"banner\">\n");
3455 wprintf(_("Confirm move of message"));
3457 wprintf("</div>\n");
3459 wprintf("<div id=\"content\" class=\"service\">\n");
3461 wprintf("<CENTER>");
3463 wprintf(_("Move this message to:"));
3464 wprintf("<br />\n");
3466 wprintf("<form METHOD=\"POST\" action=\"move_msg\">\n");
3467 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
3468 wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n", bstr("msgid"));
3470 wprintf("<SELECT NAME=\"target_room\" SIZE=5>\n");
3472 serv_getln(buf, sizeof buf);
3473 if (buf[0] == '1') {
3474 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3475 extract_token(targ, buf, 0, '|', sizeof targ);
3476 wprintf("<OPTION>");
3481 wprintf("</SELECT>\n");
3482 wprintf("<br />\n");
3484 wprintf("<INPUT TYPE=\"submit\" NAME=\"move_button\" VALUE=\"%s\">", _("Move"));
3486 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
3487 wprintf("</form></CENTER>\n");
3489 wprintf("</CENTER>\n");