ibuflen = CtdlDecodeBase64(ibuf, istr, strlen(istr));
}
else if (!strcasecmp(encoding, "Q")) { /**< quoted-printable */
- ibuflen = CtdlDecodeQuotedPrintable(ibuf, istr, strlen(istr));
+ size_t len;
+ long pos;
+
+ len = strlen(istr);
+ pos = 0;
+ while (pos < len)
+ {
+ if (istr[pos] == '_') istr[pos] = ' ';
+ pos++;
+ }
+
+ ibuflen = CtdlDecodeQuotedPrintable(ibuf, istr, len);
}
else {
strcpy(ibuf, istr); /**< unknown encoding */
#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.
}
/** begin handler prep ***/
- if (!strcasecmp(mime_content_type, "text/x-vcard")) {
+ if ( (!strcasecmp(mime_content_type, "text/x-vcard"))
+ || (!strcasecmp(mime_content_type, "text/vcard")) ) {
strcpy(vcard_partnum, mime_partnum);
}
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>");
/**
extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
mime_length = extract_int(&buf[5], 5);
- if (!strcasecmp(mime_content_type, "text/x-vcard")) {
+ if ( (!strcasecmp(mime_content_type, "text/x-vcard"))
+ || (!strcasecmp(mime_content_type, "text/vcard")) ) {
strcpy(vcard_partnum, mime_partnum);
}
memset(&summ, 0, sizeof(summ));
safestrncpy(summ.subj, "(no subject)", sizeof summ.subj);
- sprintf(buf, "MSG0 %ld|1", msgnum); /** ask for headers only */
+ sprintf(buf, "MSG0 %ld|0", msgnum); /** unfortunately we need the mime info now */
serv_puts(buf);
serv_getln(buf, sizeof buf);
if (buf[0] != '1') return;
extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
mime_length = extract_int(&buf[5], 5);
- if (!strcasecmp(mime_content_type, "text/x-vcard")) {
+ if ( (!strcasecmp(mime_content_type, "text/x-vcard"))
+ || (!strcasecmp(mime_content_type, "text/vcard")) ) {
strcpy(vcard_partnum, mime_partnum);
}
*/
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;
}
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;
);
}
- 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");
- }
-
for (a = 0; a < nummsgs; ++a) {
if ((WC->msgarr[a] >= startmsg) && (num_displayed < maxmsgs)) {
/** 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) {
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;
+ char *display_name;
- if (!strcasecmp(bstr("is_anonymous"), "yes")) {
+ display_name = bstr("display_name");
+ if (!strcmp(display_name, "__ANONYMOUS__")) {
+ display_name = "";
is_anonymous = 1;
}
_("Automatically cancelled because you have already "
"saved this message."));
} else {
- sprintf(buf, "ENT0 1|%s|%d|4|%s|||%s|%s|%s",
+ rfc2047encode(encoded_subject, sizeof encoded_subject, bstr("subject"));
+ sprintf(buf, "ENT0 1|%s|%d|4|%s|%s||%s|%s|%s",
bstr("recp"),
is_anonymous,
- bstr("subject"),
+ encoded_subject,
+ display_name,
bstr("cc"),
bstr("bcc"),
bstr("wikipage")
char buf[SIZ];
char ebuf[SIZ];
long now;
+ char *display_name;
struct wc_attachment *att;
int recipient_required = 0;
int recipient_bad = 0;
int is_anonymous = 0;
long existing_page = (-1L);
+ now = time(NULL);
+
if (strlen(bstr("force_room")) > 0) {
gotoroom(bstr("force_room"));
}
- if (!strcasecmp(bstr("is_anonymous"), "yes")) {
+ display_name = bstr("display_name");
+ if (!strcmp(display_name, "__ANONYMOUS__")) {
+ display_name = "";
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."
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|%s", bstr("recp"), is_anonymous,
+ sprintf(buf, "ENT0 0|%s|%d|0||%s||%s|%s|%s",
+ bstr("recp"),
+ is_anonymous,
+ display_name,
bstr("cc"), bstr("bcc"), bstr("wikipage"));
serv_puts(buf);
serv_getln(buf, sizeof buf);
/** If we got this far, we can display the message entry screen. */
- now = time(NULL);
- fmt_date(buf, now, 0);
- strcat(&buf[strlen(buf)], _(" <I>from</I> "));
- stresc(&buf[strlen(buf)], WC->wc_fullname, 1, 1);
-
- /* Don't need this anymore, it's in the input box below
- if (strlen(bstr("recp")) > 0) {
- strcat(&buf[strlen(buf)], _(" <I>to</I> "));
- stresc(&buf[strlen(buf)], bstr("recp"), 1, 1);
- }
- */
-
- strcat(&buf[strlen(buf)], _(" <I>in</I> "));
- stresc(&buf[strlen(buf)], WC->wc_roomname, 1, 1);
-
/** begin message entry screen */
wprintf("<form "
"enctype=\"multipart/form-data\" "
}
wprintf("<input type=\"hidden\" name=\"return_to\" value=\"%s\">\n", bstr("return_to"));
+ /** header bar */
+
wprintf("<img src=\"static/newmess3_24x.gif\" align=middle alt=\" \">");
- wprintf("%s\n", buf); /** header bar */
+ fmt_date(buf, now, 0);
+ wprintf("%s ", buf);
+
+ wprintf(_(" <I>from</I> "));
+
+ wprintf("<select name=\"display_name\" size=1>\n");
+
+ serv_puts("GVSN");
+ serv_getln(buf, sizeof buf);
+ if (buf[0] == '1') {
+ while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+ wprintf("<option %s value=\"",
+ ((!strcasecmp(bstr("display_name"), buf)) ? "selected" : "")
+ );
+ escputs(buf);
+ wprintf("\">");
+ escputs(buf);
+ wprintf("</option>\n");
+ }
+ }
+
if (WC->room_flags & QR_ANONOPT) {
- wprintf(" "
- "<input type=\"checkbox\" name=\"is_anonymous\" value=\"yes\" %s>",
- (is_anonymous ? "checked" : "")
+ wprintf("<option %s value=\"__ANONYMOUS__\">%s</option>\n",
+ ((!strcasecmp(bstr("__ANONYMOUS__"), WC->wc_fullname)) ? "selected" : ""),
+ _("Anonymous")
);
- wprintf("Anonymous");
}
+
+ wprintf("</select>\n");
+
+ wprintf(_(" <I>in</I> "));
+ escputs(WC->wc_roomname);
wprintf("<br>\n"); /** header bar */
wprintf("<table border=\"0\" width=\"100%%\">\n");
" 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 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");
-
-}
-
-
/*@}*/