/**
* \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
void read_message(long msgnum, int printable_view, char *section) {
char buf[SIZ];
char mime_partnum[256];
+ char mime_name[256];
char mime_filename[256];
char mime_content_type[256];
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, "");
if (!strcmp(buf, "000")) {
wprintf("<i>");
wprintf(_("unexpected end of message"));
- wprintf("</i><br /><br />\n");
+ wprintf(" (1)</i><br /><br />\n");
wprintf("</span>\n");
return;
}
}
if (!strncasecmp(buf, "part=", 5)) {
+ extract_token(mime_name, &buf[5], 0, '|', sizeof mime_filename);
extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
mime_length = extract_int(&buf[5], 5);
+ striplt(mime_name);
+ striplt(mime_filename);
+ if ( (strlen(mime_filename) == 0) && (strlen(mime_name) > 0) ) {
+ strcpy(mime_filename, mime_name);
+ }
+
if (!strcasecmp(mime_content_type, "message/rfc822")) {
if (strlen(mime_submessages) > 0) {
strcat(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"));
if (!strcmp(buf, "000")) {
wprintf("<i>");
wprintf(_("unexpected end of message"));
- wprintf("</i><br /><br />\n");
+ wprintf(" (2)</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
while (serv_getln(buf, sizeof buf), strcasecmp(buf, "text")) {
if (!strcmp(buf, "000")) {
- wprintf(_("unexpected end of message"));
+ wprintf("%s (3)", _("unexpected end of message"));
return;
}
if (include_headers) {
strcpy(mime_content_type, "text/plain");
while (serv_getln(buf, sizeof buf), (strlen(buf) > 0)) {
if (!strcmp(buf, "000")) {
- wprintf(_("unexpected end of message"));
+ wprintf("%s (4)", _("unexpected end of message"));
goto ENDBODY;
}
if (!strncasecmp(buf, "Content-type: ", 14)) {
}
if (is_multipart) {
- sprintf(boundary, "=_Citadel_Multipart_%s_%04x%04x",
+ sprintf(boundary, "Citadel--Multipart--%s--%04x--%04x",
serv_info.serv_fqdn,
getpid(),
++seq
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|%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;
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('recp_id');\" title=\"%s\">"
+ "<img align=middle border=0 width=16 height=16 src=\"static/viewcontacts_16x.gif\">"
+ "</a>", _("Contacts")
+ );
+ /** Pop open an address book -- end **/
+
wprintf("</td><td></td></tr>\n");
wprintf("<tr><td>");
escputs(bstr("cc"));
wprintf("\" size=50 maxlength=1000 />");
wprintf("<div class=\"auto_complete\" id=\"cc_name_choices\"></div>");
+
+ /** Pop open an address book -- begin **/
+ wprintf(
+ " <a href=\"javascript:PopOpenAddressBook('cc_id');\" title=\"%s\">"
+ "<img align=middle border=0 width=16 height=16 src=\"static/viewcontacts_16x.gif\">"
+ "</a>", _("Contacts")
+ );
+ /** Pop open an address book -- end **/
+
wprintf("</td><td></td></tr>\n");
wprintf("<tr><td>");
escputs(bstr("bcc"));
wprintf("\" size=50 maxlength=1000 />");
wprintf("<div class=\"auto_complete\" id=\"bcc_name_choices\"></div>");
+
+ /** Pop open an address book -- begin **/
+ wprintf(
+ " <a href=\"javascript:PopOpenAddressBook('bcc_id');\" title=\"%s\">"
+ "<img align=middle border=0 width=16 height=16 src=\"static/viewcontacts_16x.gif\">"
+ "</a>", _("Contacts")
+ );
+ /** Pop open an address book -- end **/
wprintf("</td><td></td></tr>\n");
/** Initialize the autocomplete ajax helpers (found in wclib.js) */
wprintf("<tr><td>");
wprintf("<font size=-1>");
- wprintf(_("Subject (optional):"));
+ if (recipient_required) {
+ wprintf(_("Subject:"));
+ }
+ else {
+ wprintf(_("Subject (optional):"));
+ }
wprintf("</font>");
wprintf("</td><td>"
"<input type=\"text\" name=\"subject\" value=\"");
}
wprintf("</form>\n");
-
wprintf("</td></tr></table></div>\n");
-DONE: wDumpContent(1);
-}
+DONE: address_book_popup();
+ wDumpContent(1);
+}
/**