/**
* \brief Wrapper around iconv_open()
* Our version adds aliases for non-standard Microsoft charsets
- * such as 'MS950', aliasing them to names like 'CP950'
+ * such as 'MS950', aliasing them to names like 'CP950'
*
* \param tocode Target encoding
* \param fromcode Source encoding
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 */
int pos;
int start, end;
- char ench;
char urlbuf[SIZ];
char outbuf[1024];
-
start = (-1);
end = strlen(buf);
- ench = 0;
for (pos = 0; pos < strlen(buf); ++pos) {
if (!strncasecmp(&buf[pos], "http://", 7))
if (start < 0)
return;
- if ((start > 0) && (buf[start - 1] == '<'))
- ench = '>';
- if ((start > 0) && (buf[start - 1] == '['))
- ench = ']';
- if ((start > 0) && (buf[start - 1] == '('))
- ench = ')';
- if ((start > 0) && (buf[start - 1] == '{'))
- ench = '}';
-
for (pos = strlen(buf); pos > start; --pos) {
- if ((buf[pos] == ' ') || (buf[pos] == ench))
+ if ( (!isprint(buf[pos]))
+ || (isspace(buf[pos]))
+ || (buf[pos] == '{')
+ || (buf[pos] == '}')
+ || (buf[pos] == '|')
+ || (buf[pos] == '\\')
+ || (buf[pos] == '^')
+ || (buf[pos] == '[')
+ || (buf[pos] == ']')
+ || (buf[pos] == '`')
+ || (buf[pos] == '<')
+ || (buf[pos] == '>')
+ || (buf[pos] == '(')
+ || (buf[pos] == ')')
+ ) {
end = pos;
+ }
}
strncpy(urlbuf, &buf[start], end - start);
}
+struct attach_link {
+ char partnum[32];
+ char html[1024];
+};
+
+
/**
* \brief I wanna SEE that message!
* \param msgnum the citadel number of the message to display
char mime_charset[256];
char mime_disposition[256];
int mime_length;
- char mime_http[SIZ];
+ struct attach_link *attach_links = NULL;
+ int num_attach_links = 0;
char mime_submessages[256];
char m_subject[256];
char m_cc[1024];
char vcard_partnum[256];
char cal_partnum[256];
char *part_source = NULL;
+ char msg4_partnum[32];
#ifdef HAVE_ICONV
iconv_t ic = (iconv_t)(-1) ;
char *ibuf; /**< Buffer of characters to be converted */
strcpy(reply_all, "");
strcpy(vcard_partnum, "");
strcpy(cal_partnum, "");
- strcpy(mime_http, "");
strcpy(mime_content_type, "text/plain");
strcpy(mime_charset, "us-ascii");
strcpy(mime_submessages, "");
}
else if ((!strcasecmp(mime_disposition, "inline"))
&& (!strncasecmp(mime_content_type, "image/", 6)) ){
- snprintf(&mime_http[strlen(mime_http)],
- (sizeof(mime_http) - strlen(mime_http) - 1),
+ ++num_attach_links;
+ attach_links = realloc(attach_links,
+ (num_attach_links*sizeof(struct attach_link)));
+ safestrncpy(attach_links[num_attach_links-1].partnum, mime_partnum, 32);
+ snprintf(attach_links[num_attach_links-1].html, 1024,
"<img src=\"mimepart/%ld/%s/%s\">",
msgnum, mime_partnum, mime_filename);
}
- else if ( (!strcasecmp(mime_disposition, "attachment"))
- || (!strcasecmp(mime_disposition, "inline")) ) {
- snprintf(&mime_http[strlen(mime_http)],
- (sizeof(mime_http) - strlen(mime_http) - 1),
+ else if ( ( (!strcasecmp(mime_disposition, "attachment"))
+ || (!strcasecmp(mime_disposition, "inline"))
+ || (!strcasecmp(mime_disposition, ""))
+ ) && (strlen(mime_content_type) > 0)
+ ) {
+ ++num_attach_links;
+ attach_links = realloc(attach_links,
+ (num_attach_links*sizeof(struct attach_link)));
+ safestrncpy(attach_links[num_attach_links-1].partnum, mime_partnum, 32);
+ snprintf(attach_links[num_attach_links-1].html, 1024,
"<img src=\"static/diskette_24x.gif\" "
"border=0 align=middle>\n"
"%s (%s, %d bytes) [ "
}
/** 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);
}
/** Generate a reply-to address */
if (strlen(rfca) > 0) {
- strcpy(reply_to, rfca);
+ if (strlen(from) > 0) {
+ snprintf(reply_to, sizeof(reply_to), "%s <%s>", from, rfca);
+ }
+ else {
+ strcpy(reply_to, rfca);
+ }
}
else {
if ( (strlen(node) > 0)
}
/** If this is one of my own rooms, or if I'm an Aide or Room Aide, I can move/delete */
- if ( (WC->is_room_aide) || (WC->is_mailbox) ) {
+ if ( (WC->is_room_aide) || (WC->is_mailbox) || (WC->room_flags2 & QR2_COLLABDEL) ) {
/** Move */
wprintf("<a href=\"confirm_move_msg?msgid=%ld\">[%s]</a> ",
msgnum, _("Move"));
wprintf("</i><br /><br />\n");
goto ENDBODY;
}
- if (!strncasecmp(buf, "Content-type: ", 14)) {
- safestrncpy(mime_content_type, &buf[14],
- sizeof(mime_content_type));
+ if (!strncasecmp(buf, "X-Citadel-MSG4-Partnum:", 23)) {
+ safestrncpy(msg4_partnum, &buf[23], sizeof(msg4_partnum));
+ striplt(msg4_partnum);
+ }
+ if (!strncasecmp(buf, "Content-type:", 13)) {
+ safestrncpy(mime_content_type, &buf[13], sizeof(mime_content_type));
+ striplt(mime_content_type);
for (i=0; i<strlen(mime_content_type); ++i) {
if (!strncasecmp(&mime_content_type[i], "charset=", 8)) {
safestrncpy(mime_charset, &mime_content_type[i+8],
/** Afterwards, offer links to download attachments 'n' such */
- if ( (strlen(mime_http) > 0) && (!section[0]) ) {
- wprintf("%s", mime_http);
+ if ( (num_attach_links > 0) && (!section[0]) ) {
+ for (i=0; i<num_attach_links; ++i) {
+ if (strcasecmp(attach_links[i].partnum, msg4_partnum)) {
+ wprintf("%s", attach_links[i].html);
+ }
+ }
}
/** Handler for vCard parts */
wprintf("</div><br />\n");
}
+ if (num_attach_links > 0) {
+ free(attach_links);
+ }
+
#ifdef HAVE_ICONV
if (ic != (iconv_t)(-1) ) {
iconv_close(ic);
/**
* \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
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);
}
}
if (is_multipart) {
- sprintf(boundary, "=_Citadel_Multipart_%s_%04x%04x",
+ sprintf(boundary, "Citadel--Multipart--%s--%04x--%04x",
serv_info.serv_fqdn,
getpid(),
++seq
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;
}
if (WC->upload_length > 0) {
+ lprintf(9, "%s:%d: we are uploading %d bytes\n", __FILE__, __LINE__, WC->upload_length);
/** There's an attachment. Save it to this struct... */
att = malloc(sizeof(struct wc_attachment));
memset(att, 0, sizeof(struct wc_attachment));
"saved this message."));
} else {
rfc2047encode(encoded_subject, sizeof encoded_subject, bstr("subject"));
- sprintf(buf, "ENT0 1|%s|%d|4|%s|||%s|%s|%s",
+ sprintf(buf, "ENT0 1|%s|%d|4|%s|%s||%s|%s|%s|%s",
bstr("recp"),
is_anonymous,
encoded_subject,
+ display_name,
bstr("cc"),
bstr("bcc"),
- bstr("wikipage")
+ bstr("wikipage"),
+ bstr("my_email_addr")
);
serv_puts(buf);
serv_getln(buf, sizeof buf);
}
dont_post = atol(bstr("postseq"));
} else {
+ lprintf(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, buf);
sprintf(WC->ImportantMessage, "%s", &buf[4]);
display_enter();
return;
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;
}
/** 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> "));
+
+ /* Allow the user to select any of his valid screen names */
+
+ 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");
+
+ /* If this is an email (not a post), allow the user to select any of his
+ * valid email addresses.
+ */
+ if (recipient_required) {
+ serv_puts("GVEA");
+ serv_getln(buf, sizeof buf);
+ if (buf[0] == '1') {
+ wprintf("<select name=\"my_email_addr\" size=1>\n");
+ while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+ wprintf("<option value=\"");
+ escputs(buf);
+ wprintf("\"><");
+ escputs(buf);
+ wprintf("></option>\n");
+ }
+ wprintf("</select>\n");
+ }
+ }
+
+ wprintf(_(" <I>in</I> "));
+ escputs(WC->wc_roomname);
wprintf("<br>\n"); /** header bar */
wprintf("<table border=\"0\" width=\"100%%\">\n");
escputs(bstr("recp"));
wprintf("\" size=50 maxlength=1000 />");
wprintf("<div class=\"auto_complete\" id=\"recp_name_choices\"></div>");
+
+ /** Pop open an address book -- begin **/
+
+ wprintf(
+ "<a href=\"javascript:PopOpenAddressBook();\" title=\"FIXME\">"
+ "<img border=0 width=16 height=16 src=\"static/viewcontacts_16x.gif\">"
+ "</a>"
+ );
+
+ /** Pop open an address book -- end **/
+
wprintf("</td><td></td></tr>\n");
wprintf("<tr><td>");
wprintf("</form>\n");
wprintf("</td></tr></table></div>\n");
+
+ /* Close the main div, now open a new one, hidden initially, for address book popups.
+ * Remember: the popup div will be closed by wDumpContent, which will think it's merely
+ * closing the main div. FIXME put this in its own function so we can use it from the
+ * calendar too.
+ */
+ wprintf("</div><div id=\"address_book_popup\" style=\"display:none;\">");
+ svprintf("BOXTITLE", WCS_STRING, _("Contacts") );
+ do_template("beginbox");
+ wprintf("<div id=\"address_book_inner_div\"></div>");
+ wprintf("<div align=center><p class=\"close_popup\" "
+ "onclick=\"javascript:Effect.Fade('address_book_popup', { duration: 0.5 });\" "
+ ">");
+ wprintf(_("Close window"));
+ wprintf("</p></div>");
+ do_template("endbox");
+
DONE: wDumpContent(1);
}