/**
* \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
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) [ "
/** 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
}
if (strlen(bstr("cancel_button")) > 0) {
- lprintf(9, "%s:%d: cancel button was pressed\n", __FILE__, __LINE__);
sprintf(WC->ImportantMessage,
_("Cancelled. Message was not posted."));
} else if (strlen(bstr("attach_button")) > 0) {
- lprintf(9, "%s:%d: attach button was pressed\n", __FILE__, __LINE__);
display_enter();
return;
} else if (atol(bstr("postseq")) == dont_post) {
- lprintf(9, "%s:%d: postseq does not match\n", __FILE__, __LINE__);
sprintf(WC->ImportantMessage,
_("Automatically cancelled because you have already "
"saved this message."));
} else {
rfc2047encode(encoded_subject, sizeof encoded_subject, bstr("subject"));
- sprintf(buf, "ENT0 1|%s|%d|4|%s|%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\n", __FILE__, __LINE__);
+ lprintf(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, buf);
sprintf(WC->ImportantMessage, "%s", &buf[4]);
display_enter();
return;
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");
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 */
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);
}