*/
/**
* \defgroup MsgDisp Functions which deal with the fetching and displaying of messages.
+ * \ingroup WebcitDisplayItems
*
*/
/*@{*/
#include "webserver.h"
#include "groupdav.h"
-#define SUBJ_COL_WIDTH_PCT 50 /**< ??? */
-#define SENDER_COL_WIDTH_PCT 30 /**< ??? */
-#define DATE_PLUS_BUTTONS_WIDTH_PCT 20 /**< ??? */
+#define SUBJ_COL_WIDTH_PCT 50 /**< Mailbox view column width */
+#define SENDER_COL_WIDTH_PCT 30 /**< Mailbox view column width */
+#define DATE_PLUS_BUTTONS_WIDTH_PCT 20 /**< Mailbox view column width */
/**
* Address book entry (keep it short and sweet, it's just a quickie lookup
*/
struct addrbookent {
char ab_name[64]; /**< name string */
- long ab_msgnum; /**< number in the citadel???? */
+ long ab_msgnum; /**< message number of address book entry */
};
#ifdef HAVE_ICONV
+
+/**
+ * \brief Wrapper around iconv_open()
+ * Our version adds aliases for non-standard Microsoft charsets
+ * such as 'MS950', aliasing them to names like 'CP950'
+ *
+ * \param tocode Target encoding
+ * \param fromcode Source encoding
+ */
+iconv_t ctdl_iconv_open(const char *tocode, const char *fromcode)
+{
+ iconv_t ic = (iconv_t)(-1) ;
+ ic = iconv_open(tocode, fromcode);
+ if (ic == (iconv_t)(-1) ) {
+ char alias_fromcode[64];
+ if ( (strlen(fromcode) == 5) && (!strncasecmp(fromcode, "MS", 2)) ) {
+ safestrncpy(alias_fromcode, fromcode, sizeof alias_fromcode);
+ alias_fromcode[0] = 'C';
+ alias_fromcode[1] = 'P';
+ ic = iconv_open(tocode, alias_fromcode);
+ }
+ }
+ return(ic);
+}
+
+
/**
* \brief Handle subjects with RFC2047 encoding
* such as:
char encoding[16];
char istr[1024];
iconv_t ic = (iconv_t)(-1) ;
- char *ibuf; /**< Buffer of characters to be converted */
- char *obuf; /**< Buffer for converted characters */
- size_t ibuflen; /**< Length of input buffer */
- size_t obuflen; /**< Length of output buffer */
- char *isav; /**< Saved pointer to input buffer */
- char *osav; /**< Saved pointer to output buffer */
+ char *ibuf; /**< Buffer of characters to be converted */
+ char *obuf; /**< Buffer for converted characters */
+ size_t ibuflen; /**< Length of input buffer */
+ size_t obuflen; /**< Length of output buffer */
+ char *isav; /**< Saved pointer to input buffer */
+ char *osav; /**< Saved pointer to output buffer */
int passes = 0;
+ int i;
+ int illegal_non_rfc2047_encoding = 0;
+ /** Sometimes, badly formed messages contain strings which were simply
+ * written out directly in some foreign character set instead of
+ * using RFC2047 encoding. This is illegal but we will attempt to
+ * handle it anyway by converting from a user-specified default
+ * charset to UTF-8 if we see any nonprintable characters.
+ */
+ for (i=0; i<strlen(buf); ++i) {
+ if ((buf[i] < 32) || (buf[i] > 126)) {
+ illegal_non_rfc2047_encoding = 1;
+ }
+ }
+ if (illegal_non_rfc2047_encoding) {
+ char default_header_charset[128];
+ get_preference("default_header_charset", default_header_charset, sizeof default_header_charset);
+ if ( (strcasecmp(default_header_charset, "UTF-8")) && (strcasecmp(default_header_charset, "us-ascii")) ) {
+ ic = ctdl_iconv_open("UTF-8", default_header_charset);
+ if (ic != (iconv_t)(-1) ) {
+ ibuf = malloc(1024);
+ isav = ibuf;
+ safestrncpy(ibuf, buf, 1024);
+ ibuflen = strlen(ibuf);
+ obuflen = 1024;
+ obuf = (char *) malloc(obuflen);
+ osav = obuf;
+ iconv(ic, &ibuf, &ibuflen, &obuf, &obuflen);
+ osav[1024-obuflen] = 0;
+ strcpy(buf, osav);
+ free(osav);
+ iconv_close(ic);
+ free(isav);
+ }
+ }
+ }
+
+ /** Now we handle foreign character sets properly encoded
+ * in RFC2047 format.
+ */
while (start=strstr(buf, "=?"), end=strstr(buf, "?="),
((start != NULL) && (end != NULL) && (end > start)) )
{
extract_token(encoding, start, 2, '?', sizeof encoding);
extract_token(istr, start, 3, '?', sizeof istr);
- /*strcpy(start, "");
- ++end;
- ++end;*/
-
ibuf = malloc(1024);
isav = ibuf;
if (!strcasecmp(encoding, "B")) { /**< base64 */
ibuflen = CtdlDecodeQuotedPrintable(ibuf, istr, strlen(istr));
}
else {
- strcpy(ibuf, istr); /**< huh? */
+ strcpy(ibuf, istr); /**< unknown encoding */
ibuflen = strlen(istr);
}
- ic = iconv_open("UTF-8", charset);
+ ic = ctdl_iconv_open("UTF-8", charset);
if (ic != (iconv_t)(-1) ) {
- obuf = malloc(1024);
obuflen = 1024;
obuf = (char *) malloc(obuflen);
osav = obuf;
#endif
+
+
+/**
+ * \brief RFC2047-encode a header field if necessary.
+ * If no non-ASCII characters are found, the string
+ * will be copied verbatim without encoding.
+ *
+ * \param target Target buffer.
+ * \param maxlen Maximum size of target buffer.
+ * \param source Source string to be encoded.
+ */
+void rfc2047encode(char *target, int maxlen, char *source)
+{
+ int need_to_encode = 0;
+ int i;
+ unsigned char ch;
+
+ if (target == NULL) return;
+
+ for (i=0; i<strlen(source); ++i) {
+ if ((source[i] < 32) || (source[i] > 126)) {
+ need_to_encode = 1;
+ }
+ }
+
+ if (!need_to_encode) {
+ safestrncpy(target, source, maxlen);
+ return;
+ }
+
+ strcpy(target, "=?UTF-8?Q?");
+ for (i=0; i<strlen(source); ++i) {
+ ch = (unsigned char) source[i];
+ if ((ch < 32) || (ch > 126) || (ch == 61)) {
+ sprintf(&target[strlen(target)], "=%02X", ch);
+ }
+ else {
+ sprintf(&target[strlen(target)], "%c", ch);
+ }
+ }
+
+ strcat(target, "?=");
+}
+
+
+
+
/**
* \brief Look for URL's embedded in a buffer and make them linkable. We use a
* target window in order to keep the BBS session in its own window.
}
if (!strncasecmp(buf, "rcpt=", 5)) {
wprintf(_("to "));
- escputs(&buf[5]);
- wprintf(" ");
if (strlen(reply_all) > 0) {
strcat(reply_all, ", ");
}
safestrncpy(&reply_all[strlen(reply_all)], &buf[5],
(sizeof reply_all - strlen(reply_all)) );
+#ifdef HAVE_ICONV
+ utf8ify_rfc822_string(&buf[5]);
+#endif
+ escputs(&buf[5]);
+ wprintf(" ");
}
if (!strncasecmp(buf, "time=", 5)) {
fmt_date(now, atol(&buf[5]), 0);
|| (!strcasecmp(mime_disposition, "inline")) ) {
snprintf(&mime_http[strlen(mime_http)],
(sizeof(mime_http) - strlen(mime_http) - 1),
- "<a href=\"mimepart/%ld/%s/%s\" "
- "target=\"wc.%ld.%s\">"
"<img src=\"static/diskette_24x.gif\" "
"border=0 align=middle>\n"
- "%s (%s, %d bytes)</a><br />\n",
+ "%s (%s, %d bytes) [ "
+ "<a href=\"mimepart/%ld/%s/%s\""
+ "target=\"wc.%ld.%s\">%s</a>"
+ " | "
+ "<a href=\"mimepart_download/%ld/%s/%s\">%s</a>"
+ " ]<br />\n",
+ mime_filename,
+ mime_content_type, mime_length,
msgnum, mime_partnum, mime_filename,
msgnum, mime_partnum,
- mime_filename,
- mime_content_type, mime_length
+ _("View"),
+ msgnum, mime_partnum, mime_filename,
+ _("Download")
);
}
wprintf("</tr></table>\n");
/** Begin body */
- wprintf("<table border=0 width=100%% bgcolor=\"#FFFFFF\" "
+ wprintf("<table class=\"messages_background\" "
"cellpadding=1 cellspacing=0><tr><td>");
/**
mime_content_type[i] = 0;
}
}
+ for (i=0; i<strlen(mime_charset); ++i) {
+ if (mime_charset[i] == ';') {
+ mime_charset[i] = 0;
+ }
+ }
}
}
&& (strcasecmp(mime_charset, "UTF-8"))
&& (strcasecmp(mime_charset, ""))
) {
- ic = iconv_open("UTF-8", mime_charset);
+ ic = ctdl_iconv_open("UTF-8", mime_charset);
if (ic == (iconv_t)(-1) ) {
lprintf(5, "%s:%d iconv_open(UTF-8, %s) failed: %s\n",
__FILE__, __LINE__, mime_charset, strerror(errno));
else /** HTML is fun, but we've got to strip it first */
if (!strcasecmp(mime_content_type, "text/html")) {
- output_html(mime_charset);
+ output_html(mime_charset, (WC->wc_view == VIEW_WIKI ? 1 : 0));
}
/** Unknown weirdness */
/**
* \brief Unadorned HTML output of an individual message, suitable
* for placing in a hidden iframe, for printing, or whatever
- * \param msgnum_as_string the message to embed???
+ *
+ * \param msgnum_as_string Message number, as a string instead of as a long int
*/
void embed_message(char *msgnum_as_string) {
long msgnum = 0L;
/**
* \brief Printable view of a message
- * \param msgnum_as_string the message to print???
+ *
+ * \param msgnum_as_string Message number, as a string instead of as a long int
*/
void print_message(char *msgnum_as_string) {
long msgnum = 0L;
/**
* \brief Display a message's headers
- * \param msgnum_as_string the message headers to print???
+ *
+ * \param msgnum_as_string Message number, as a string instead of as a long int
*/
void display_headers(char *msgnum_as_string) {
long msgnum = 0L;
/**
* \brief Read message in simple, JavaScript-embeddable form for 'forward'
- * or 'reply quoted' operations.
+ * or 'reply quoted' operations.
*
* NOTE: it is VITALLY IMPORTANT that we output no single-quotes or linebreaks
* in this function. Doing so would throw a JavaScript error in the
* 'supplied text' argument to the editor.
- * \param msgnum the citadel message number
- * \param forward_attachments atachment to forward???
+ *
+ * \param msgnum Message number of the message we want to quote
+ * \param forward_attachments Nonzero if we want attachments to be forwarded
*/
-void pullquote_message(long msgnum, int forward_attachments) {
+void pullquote_message(long msgnum, int forward_attachments, int include_headers) {
char buf[SIZ];
char mime_partnum[256];
char mime_filename[256];
char mime_charset[256];
char mime_disposition[256];
int mime_length;
- char mime_http[SIZ];
char *attachments = NULL;
+ char *ptr = NULL;
int num_attachments = 0;
struct wc_attachment *att, *aptr;
char m_subject[256];
strcpy(node, "");
strcpy(rfca, "");
strcpy(reply_to, "");
- strcpy(mime_http, "");
strcpy(mime_content_type, "text/plain");
strcpy(mime_charset, "us-ascii");
wprintf(_("unexpected end of message"));
return;
}
- if (!strncasecmp(buf, "nhdr=yes", 8))
- nhdr = 1;
- if (nhdr == 1)
- buf[0] = '_';
- if (!strncasecmp(buf, "type=", 5))
- format_type = atoi(&buf[5]);
- if (!strncasecmp(buf, "from=", 5)) {
- strcpy(from, &buf[5]);
- wprintf(_("from "));
+ if (include_headers) {
+ if (!strncasecmp(buf, "nhdr=yes", 8))
+ nhdr = 1;
+ if (nhdr == 1)
+ buf[0] = '_';
+ if (!strncasecmp(buf, "type=", 5))
+ format_type = atoi(&buf[5]);
+ if (!strncasecmp(buf, "from=", 5)) {
+ strcpy(from, &buf[5]);
+ wprintf(_("from "));
#ifdef HAVE_ICONV
- utf8ify_rfc822_string(from);
+ utf8ify_rfc822_string(from);
#endif
- msgescputs(from);
- }
- if (!strncasecmp(buf, "subj=", 5)) {
- strcpy(m_subject, &buf[5]);
- }
- if ((!strncasecmp(buf, "hnod=", 5))
- && (strcasecmp(&buf[5], serv_info.serv_humannode))) {
- wprintf("(%s) ", &buf[5]);
- }
- if ((!strncasecmp(buf, "room=", 5))
- && (strcasecmp(&buf[5], WC->wc_roomname))
- && (strlen(&buf[5])>0) ) {
- wprintf(_("in "));
- wprintf("%s> ", &buf[5]);
- }
- if (!strncasecmp(buf, "rfca=", 5)) {
- strcpy(rfca, &buf[5]);
- wprintf("<");
- msgescputs(rfca);
- wprintf("> ");
- }
-
- if (!strncasecmp(buf, "node=", 5)) {
- strcpy(node, &buf[5]);
- if ( ((WC->room_flags & QR_NETWORK)
- || ((strcasecmp(&buf[5], serv_info.serv_nodename)
- && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
- && (strlen(rfca)==0)
- ) {
- wprintf("@%s ", &buf[5]);
+ msgescputs(from);
+ }
+ if (!strncasecmp(buf, "subj=", 5)) {
+ strcpy(m_subject, &buf[5]);
+ }
+ if ((!strncasecmp(buf, "hnod=", 5))
+ && (strcasecmp(&buf[5], serv_info.serv_humannode))) {
+ wprintf("(%s) ", &buf[5]);
+ }
+ if ((!strncasecmp(buf, "room=", 5))
+ && (strcasecmp(&buf[5], WC->wc_roomname))
+ && (strlen(&buf[5])>0) ) {
+ wprintf(_("in "));
+ wprintf("%s> ", &buf[5]);
+ }
+ if (!strncasecmp(buf, "rfca=", 5)) {
+ strcpy(rfca, &buf[5]);
+ wprintf("<");
+ msgescputs(rfca);
+ wprintf("> ");
+ }
+
+ if (!strncasecmp(buf, "node=", 5)) {
+ strcpy(node, &buf[5]);
+ if ( ((WC->room_flags & QR_NETWORK)
+ || ((strcasecmp(&buf[5], serv_info.serv_nodename)
+ && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
+ && (strlen(rfca)==0)
+ ) {
+ wprintf("@%s ", &buf[5]);
+ }
+ }
+ if (!strncasecmp(buf, "rcpt=", 5)) {
+ wprintf(_("to "));
+ wprintf("%s ", &buf[5]);
+ }
+ if (!strncasecmp(buf, "time=", 5)) {
+ fmt_date(now, atol(&buf[5]), 0);
+ wprintf("%s ", now);
}
- }
- if (!strncasecmp(buf, "rcpt=", 5)) {
- wprintf(_("to "));
- wprintf("%s ", &buf[5]);
- }
- if (!strncasecmp(buf, "time=", 5)) {
- fmt_date(now, atol(&buf[5]), 0);
- wprintf("%s ", now);
}
/**
* yet because we're in the middle of a server transaction.
*/
if (!strncasecmp(buf, "part=", 5)) {
- ++num_attachments;
- attachments = realloc(attachments, (num_attachments * 1024));
- strcat(attachments, &buf[5]);
- strcat(attachments, "\n");
+ ptr = malloc( (strlen(buf) + ((attachments != NULL) ? strlen(attachments) : 0)) ) ;
+ if (ptr != NULL) {
+ ++num_attachments;
+ sprintf(ptr, "%s%s\n",
+ ((attachments != NULL) ? attachments : ""),
+ &buf[5]
+ );
+ free(attachments);
+ attachments = ptr;
+ lprintf(9, "attachments=<%s>\n", attachments);
+ }
}
}
- wprintf("<br>");
+ if (include_headers) {
+ wprintf("<br>");
#ifdef HAVE_ICONV
- utf8ify_rfc822_string(m_subject);
+ utf8ify_rfc822_string(m_subject);
#endif
- if (strlen(m_subject) > 0) {
- wprintf(_("Subject:"));
- wprintf(" ");
- msgescputs(m_subject);
+ if (strlen(m_subject) > 0) {
+ wprintf(_("Subject:"));
+ wprintf(" ");
+ msgescputs(m_subject);
+ wprintf("<br />");
+ }
+
+ /**
+ * Begin body
+ */
wprintf("<br />");
}
- /**
- * Begin body
- */
- wprintf("<br>");
-
/**
* Learn the content type
*/
mime_content_type[i] = 0;
}
}
+ for (i=0; i<strlen(mime_charset); ++i) {
+ if (mime_charset[i] == ';') {
+ mime_charset[i] = 0;
+ }
+ }
}
}
&& (strcasecmp(mime_charset, "UTF-8"))
&& (strcasecmp(mime_charset, ""))
) {
- ic = iconv_open("UTF-8", mime_charset);
+ ic = ctdl_iconv_open("UTF-8", mime_charset);
if (ic == (iconv_t)(-1) ) {
- lprintf(5, "%s:%d iconv_open() failed: %s\n",
- __FILE__, __LINE__, strerror(errno));
+ lprintf(5, "%s:%d iconv_open(%s, %s) failed: %s\n",
+ __FILE__, __LINE__, "UTF-8", mime_charset, strerror(errno));
}
}
#endif
/** HTML just gets escaped and stuffed back into the editor */
else if (!strcasecmp(mime_content_type, "text/html")) {
while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+ strcat(buf, "\n");
msgescputs(buf);
}
}
/*
* tracing ... uncomment if necessary
*
+ */
lprintf(9, "fwd filename: %s\n", mime_filename);
lprintf(9, "fwd partnum : %s\n", mime_partnum);
lprintf(9, "fwd conttype: %s\n", mime_content_type);
lprintf(9, "fwd dispose : %s\n", mime_disposition);
lprintf(9, "fwd length : %d\n", mime_length);
- */
if ( (!strcasecmp(mime_disposition, "inline"))
|| (!strcasecmp(mime_disposition, "attachment")) ) {
}
}
- free(attachments);
}
#ifdef HAVE_ICONV
iconv_close(ic);
}
#endif
+
+ if (attachments != NULL) {
+ free(attachments);
+ }
}
/**
- * \brief display sumarized item???
- * \param num hom many? which???
+ * \brief Display one row in the mailbox summary view
+ *
+ * \param num The row number to be displayed
*/
void display_summarized(int num) {
char datebuf[64];
serv_puts(servcmd);
serv_getln(buf, sizeof buf);
if (buf[0] != '1') {
- wprintf("<EM>%s</EM><br />\n", &buf[4]);
return (nummsgs);
}
while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
}
/**
- * \brief compare what????
- * \param s1 first thing to compare
- * \param s2 second thing to compare
+ * \brief qsort() compatible function to compare two longs in descending order.
+ *
+ * \param s1 first number to compare
+ * \param s2 second number to compare
*/
int longcmp_r(const void *s1, const void *s2) {
long l1;
/**
- * \brief compare what????
- * \param s1 first thing to compare
- * \param s2 second thing to compare
+ * \brief qsort() compatible function to compare two message summary structs by ascending subject.
+ *
+ * \param s1 first item to compare
+ * \param s2 second item to compare
*/
int summcmp_subj(const void *s1, const void *s2) {
struct message_summary *summ1;
}
/**
- * \brief compare what????
- * \param s1 first thing to compare
- * \param s2 second thing to compare
+ * \brief qsort() compatible function to compare two message summary structs by descending subject.
+ *
+ * \param s1 first item to compare
+ * \param s2 second item to compare
*/
int summcmp_rsubj(const void *s1, const void *s2) {
struct message_summary *summ1;
}
/**
- * \brief compare what????
- * \param s1 first thing to compare
- * \param s2 second thing to compare
+ * \brief qsort() compatible function to compare two message summary structs by ascending sender.
+ *
+ * \param s1 first item to compare
+ * \param s2 second item to compare
*/
int summcmp_sender(const void *s1, const void *s2) {
struct message_summary *summ1;
}
/**
- * \brief compare what????
- * \param s1 first thing to compare
- * \param s2 second thing to compare
+ * \brief qsort() compatible function to compare two message summary structs by descending sender.
+ *
+ * \param s1 first item to compare
+ * \param s2 second item to compare
*/
int summcmp_rsender(const void *s1, const void *s2) {
struct message_summary *summ1;
}
/**
- * \brief compare what????
- * \param s1 first thing to compare
- * \param s2 second thing to compare
+ * \brief qsort() compatible function to compare two message summary structs by ascending date.
+ *
+ * \param s1 first item to compare
+ * \param s2 second item to compare
*/
int summcmp_date(const void *s1, const void *s2) {
struct message_summary *summ1;
}
/**
- * \brief compare what????
- * \param s1 first thing to compare
- * \param s2 second thing to compare
+ * \brief qsort() compatible function to compare two message summary structs by descending date.
+ *
+ * \param s1 first item to compare
+ * \param s2 second item to compare
*/
int summcmp_rdate(const void *s1, const void *s2) {
struct message_summary *summ1;
else return 0;
}
+
+
/**
* \brief command loop for reading messages
- * \param oper what???
+ *
+ * \param oper Set to "readnew" or "readold" or "readfwd" or "headers"
*/
void readloop(char *oper)
{
- char cmd[SIZ];
+ char cmd[256];
char buf[SIZ];
char old_msgs[SIZ];
int a, b;
else if (!strcmp(oper, "readold")) {
strcpy(cmd, "MSGS OLD");
}
+ else if (!strcmp(oper, "do_search")) {
+ sprintf(cmd, "MSGS SEARCH|%s", bstr("query"));
+ }
else {
strcpy(cmd, "MSGS ALL");
}
if ((WC->wc_view == VIEW_MAILBOX) && (maxmsgs > 1)) {
is_summary = 1;
- strcpy(cmd, "MSGS ALL");
+ if (!strcmp(oper, "do_search")) {
+ sprintf(cmd, "MSGS SEARCH|%s", bstr("query"));
+ }
+ else {
+ strcpy(cmd, "MSGS ALL");
+ }
}
if ((WC->wc_view == VIEW_ADDRESSBOOK) && (maxmsgs > 1)) {
is_addressbook = 1;
- strcpy(cmd, "MSGS ALL");
+ if (!strcmp(oper, "do_search")) {
+ sprintf(cmd, "MSGS SEARCH|%s", bstr("query"));
+ }
+ else {
+ strcpy(cmd, "MSGS ALL");
+ }
maxmsgs = 9999999;
}
- if (is_summary) {
- strcpy(cmd, "MSGS ALL|||1"); /**< fetch header summary */
+ if (is_summary) { /**< fetch header summary */
+ snprintf(cmd, sizeof cmd, "MSGS %s|%s||1",
+ (!strcmp(oper, "do_search") ? "SEARCH" : "ALL"),
+ (!strcmp(oper, "do_search") ? bstr("query") : "")
+ );
startmsg = 1;
maxmsgs = 9999999;
}
is_singlecard = atoi(bstr("is_singlecard"));
- if (WC->wc_view == VIEW_CALENDAR) { /**< calendar */
+ if (WC->wc_default_view == VIEW_CALENDAR) { /**< calendar */
is_calendar = 1;
strcpy(cmd, "MSGS ALL");
maxmsgs = 32767;
}
- if (WC->wc_view == VIEW_TASKS) { /**< tasks */
+ if (WC->wc_default_view == VIEW_TASKS) { /**< tasks */
is_tasks = 1;
strcpy(cmd, "MSGS ALL");
maxmsgs = 32767;
}
- if (WC->wc_view == VIEW_NOTES) { /**< notes */
+ if (WC->wc_default_view == VIEW_NOTES) { /**< notes */
is_notes = 1;
strcpy(cmd, "MSGS ALL");
maxmsgs = 32767;
}
+ if (is_notes) {
+ wprintf("<div align=center>%s</div>\n", _("Click on any note to edit it."));
+ wprintf("<div id=\"new_notes_here\"></div>\n");
+ }
+
nummsgs = load_msg_ptrs(cmd, is_summary);
if (nummsgs == 0) {
if ((!is_tasks) && (!is_calendar) && (!is_notes) && (!is_addressbook)) {
- wprintf("<em>");
+ wprintf("<div align=\"center\"><br /><em>");
if (!strcmp(oper, "readnew")) {
wprintf(_("No new messages."));
} else if (!strcmp(oper, "readold")) {
} else {
wprintf(_("No messages here."));
}
- wprintf("</em>\n");
+ wprintf("</em><br /></div>\n");
}
goto DONE;
/** RFC2045 requires this, and some clients look for it... */
serv_puts("MIME-Version: 1.0");
+ serv_puts("X-Mailer: " SERVER);
/** If there are attachments, we have to do multipart/mixed */
if (WC->first_attachment != NULL) {
}
if (is_multipart) {
- sprintf(boundary, "---Citadel-Multipart-%s-%04x%04x---",
+ sprintf(boundary, "=_Citadel_Multipart_%s_%04x%04x",
serv_info.serv_fqdn,
getpid(),
++seq
}
serv_puts("Content-type: text/html; charset=utf-8");
+ serv_puts("Content-Transfer-Encoding: quoted-printable");
serv_puts("");
- serv_puts("<html><body>\n"); /** Future templates go here */
- text_to_server(bstr("msgtext"), 0);
- serv_puts("</body></html>\n");
+ serv_puts("<html><body>\r\n");
+ text_to_server_qp(bstr("msgtext")); /** Transmit message in quoted-printable encoding */
+ serv_puts("</body></html>\r\n");
-
if (is_multipart) {
/** Add in the attachments */
encoded_length = ((att->length * 150) / 100);
encoded = malloc(encoded_length);
if (encoded == NULL) break;
- CtdlEncodeBase64(encoded, att->data, att->length);
+ CtdlEncodeBase64(encoded, att->data, att->length, 1);
serv_printf("--%s", boundary);
serv_printf("Content-type: %s", att->content_type);
*/
void post_message(void)
{
- char buf[SIZ];
+ char buf[1024];
+ char encoded_subject[1024];
static long dont_post = (-1L);
struct wc_attachment *att, *aptr;
int is_anonymous = 0;
_("Automatically cancelled because you have already "
"saved this message."));
} else {
- sprintf(buf, "ENT0 1|%s|%d|4|%s|||%s|%s",
+ rfc2047encode(encoded_subject, sizeof encoded_subject, bstr("subject"));
+ sprintf(buf, "ENT0 1|%s|%d|4|%s|||%s|%s|%s",
bstr("recp"),
is_anonymous,
- bstr("subject"),
+ encoded_subject,
bstr("cc"),
- bstr("bcc")
+ bstr("bcc"),
+ bstr("wikipage")
);
serv_puts(buf);
serv_getln(buf, sizeof buf);
}
free_attachments(WC);
- readloop("readnew");
+
+ /**
+ * We may have been supplied with instructions regarding the location
+ * to which we must return after posting. If found, go there.
+ */
+ if (strlen(bstr("return_to")) > 0) {
+ http_redirect(bstr("return_to"));
+ }
+ /**
+ * If we were editing a page in a wiki room, go to that page now.
+ */
+ else if (strlen(bstr("wikipage")) > 0) {
+ snprintf(buf, sizeof buf, "wiki?page=%s", bstr("wikipage"));
+ http_redirect(buf);
+ }
+ /**
+ * Otherwise, just go to the "read messages" loop.
+ */
+ else {
+ readloop("readnew");
+ }
}
int recipient_bad = 0;
int i;
int is_anonymous = 0;
+ long existing_page = (-1L);
if (strlen(bstr("force_room")) > 0) {
gotoroom(bstr("force_room"));
is_anonymous = 1;
}
+ /** First test to see whether this is a room that requires recipients to be entered */
+ serv_puts("ENT0 0");
+ serv_getln(buf, sizeof buf);
+ if (!strncmp(buf, "570", 3)) { /** 570 means that we need a recipient here */
+ recipient_required = 1;
+ }
+ else if (buf[0] != '2') { /** Any other error means that we cannot continue */
+ sprintf(WC->ImportantMessage, "%s", &buf[4]);
+ readloop("readnew");
+ return;
+ }
+
/**
* Are we perhaps in an address book view? If so, then an "enter
* message" command really means "add new entry."
*/
- if (WC->wc_view == VIEW_ADDRESSBOOK) {
+ if (WC->wc_default_view == VIEW_ADDRESSBOOK) {
do_edit_vcard(-1, "", "");
return;
}
#ifdef WEBCIT_WITH_CALENDAR_SERVICE
/**
- * Are we perhaps in a calendar view? If so, then an "enter
+ * Are we perhaps in a calendar room? If so, then an "enter
* message" command really means "add new calendar item."
*/
- if (WC->wc_view == VIEW_CALENDAR) {
+ if (WC->wc_default_view == VIEW_CALENDAR) {
display_edit_event();
return;
}
* Are we perhaps in a tasks view? If so, then an "enter
* message" command really means "add new task."
*/
- if (WC->wc_view == VIEW_TASKS) {
+ if (WC->wc_default_view == VIEW_TASKS) {
display_edit_task();
return;
}
wprintf("</div>\n");
wprintf("<div id=\"content\">\n"
"<div class=\"fix_scrollbar_bug\">"
- "<table width=100%% border=0 bgcolor=\"#ffffff\"><tr><td>");
-
- /** First test to see whether this is a room that requires recipients to be entered */
- serv_puts("ENT0 0");
- serv_getln(buf, sizeof buf);
- if (!strncmp(buf, "570", 3)) { /** 570 means that we need a recipient here */
- recipient_required = 1;
- }
- else if (buf[0] != '2') { /** Any other error means that we cannot continue */
- wprintf("<EM>%s</EM><br />\n", &buf[4]);
- goto DONE;
- }
+ "<table class=\"messages_background\"><tr><td>");
/** Now check our actual recipients if there are any */
if (recipient_required) {
- sprintf(buf, "ENT0 0|%s|%d|0||||%s|%s", bstr("recp"), is_anonymous, bstr("cc"), bstr("bcc"));
+ sprintf(buf, "ENT0 0|%s|%d|0||||%s|%s|%s", bstr("recp"), is_anonymous,
+ bstr("cc"), bstr("bcc"), bstr("wikipage"));
serv_puts(buf);
serv_getln(buf, sizeof buf);
}
}
else if (buf[0] != '2') { /** Any other error means that we cannot continue */
- wprintf("<EM>%s</EM><br />\n", &buf[4]);
+ wprintf("<em>%s</em><br />\n", &buf[4]);
goto DONE;
}
}
stresc(&buf[strlen(buf)], WC->wc_roomname, 1, 1);
/** begin message entry screen */
- wprintf("<form enctype=\"multipart/form-data\" "
- "method=\"POST\" action=\"post\" "
+ wprintf("<form "
+ "enctype=\"multipart/form-data\" "
+ "method=\"POST\" "
+ "accept-charset=\"UTF-8\" "
+ "action=\"post\" "
"name=\"enterform\""
">\n");
wprintf("<input type=\"hidden\" name=\"postseq\" value=\"%ld\">\n", now);
+ if (WC->wc_view == VIEW_WIKI) {
+ wprintf("<input type=\"hidden\" name=\"wikipage\" value=\"%s\">\n", bstr("wikipage"));
+ }
+ wprintf("<input type=\"hidden\" name=\"return_to\" value=\"%s\">\n", bstr("return_to"));
wprintf("<img src=\"static/newmess3_24x.gif\" align=middle alt=\" \">");
wprintf("%s\n", buf); /** header bar */
wprintf("<br><div align=center><i>");
wprintf(_("--- forwarded message ---"));
wprintf("</i></div><br>");
- pullquote_message(atol(bstr("fwdquote")), 1);
+ pullquote_message(atol(bstr("fwdquote")), 1, 1);
}
/** If we're replying quoted, insert the quote here... */
else if (atol(bstr("replyquote")) > 0L) {
wprintf("<br>"
"<blockquote>");
- pullquote_message(atol(bstr("replyquote")), 0);
- wprintf("</blockquote>\n\n");
+ pullquote_message(atol(bstr("replyquote")), 0, 1);
+ wprintf("</blockquote><br>");
+ }
+
+ /** If we're editing a wiki page, insert the existing page here... */
+ else if (WC->wc_view == VIEW_WIKI) {
+ safestrncpy(buf, bstr("wikipage"), sizeof buf);
+ str_wiki_index(buf);
+ existing_page = locate_message_by_uid(buf);
+ if (existing_page >= 0L) {
+ pullquote_message(existing_page, 1, 0);
+ }
}
/** Insert our signature if appropriate... */
" theme : \"advanced\", plugins : \"iespell\", "
" theme_advanced_buttons1 : \"bold, italic, underline, strikethrough, justifyleft, justifycenter, justifyright, justifyfull, bullist, numlist, cut, copy, paste, link, image, help, forecolor, iespell, code\", "
" theme_advanced_buttons2 : \"\", "
- " theme_advanced_buttons3 : \"\" "
+ " theme_advanced_buttons3 : \"\", "
+ " content_css : \"static/webcit-tinymce.css\" "
"});"
"</script>\n"
);
msgid = atol(bstr("msgid"));
- output_headers(1, 1, 1, 0, 0, 0);
-
if (WC->wc_is_trash) { /** Delete from Trash is a real delete */
serv_printf("DELE %ld", msgid);
}
}
serv_getln(buf, sizeof buf);
- wprintf("<EM>%s</EM><br />\n", &buf[4]);
+ sprintf(WC->ImportantMessage, "%s", &buf[4]);
- wDumpContent(1);
+ readloop("readnew");
+}
+
+
+/**
+ * \brief move a message to another folder
+ */
+void move_msg(void)
+{
+ long msgid;
+ char buf[SIZ];
+
+ msgid = atol(bstr("msgid"));
+
+ if (strlen(bstr("move_button")) > 0) {
+ sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
+ serv_puts(buf);
+ serv_getln(buf, sizeof buf);
+ sprintf(WC->ImportantMessage, "%s", &buf[4]);
+ } else {
+ sprintf(WC->ImportantMessage, (_("The message was not moved.")));
+ }
+
+ readloop("readnew");
}
+
/**
* \brief Confirm move of a message
*/
}
-/**
- * \brief move a message to another folder
- */
-void move_msg(void)
-{
- long msgid;
- char buf[SIZ];
-
- msgid = atol(bstr("msgid"));
-
- if (strlen(bstr("move_button")) > 0) {
- sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
- serv_puts(buf);
- serv_getln(buf, sizeof buf);
- sprintf(WC->ImportantMessage, "%s", &buf[4]);
- } else {
- sprintf(WC->ImportantMessage, (_("The message was not moved.")));
- }
-
- readloop("readnew");
-
-}
-
-
/*@}*/