*/
/**
* \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:
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;
}
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")
);
}
&& (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));
/**
* \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, int include_headers) {
char buf[SIZ];
&& (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));
}
/**
- * \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];
}
/**
- * \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)
{
is_singlecard = atoi(bstr("is_singlecard"));
- if (WC->wc_view == VIEW_CALENDAR) { /**< calendar */
+ if ((WC->wc_view == VIEW_CALENDAR) ||
+ (WC->wc_view == VIEW_CALBRIEF)){ /**< calendar */
is_calendar = 1;
strcpy(cmd, "MSGS ALL");
maxmsgs = 32767;
}
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 */
* Are we perhaps in a calendar view? If so, then an "enter
* message" command really means "add new calendar item."
*/
- if (WC->wc_view == VIEW_CALENDAR) {
+ if ((WC->wc_view == VIEW_CALENDAR) ||
+ (WC->wc_view == VIEW_CALBRIEF)){
display_edit_event();
return;
}
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);