]> code.citadel.org Git - citadel.git/blobdiff - webcit/messages.c
Allow multiple addresses to be selected.
[citadel.git] / webcit / messages.c
index 3bba9f7e95d672cf613a9d566510272486a24640..db930c7230b05f611aa25b94398e76b396d380ad 100644 (file)
@@ -32,7 +32,7 @@ struct addrbookent {
 /**
  * \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
@@ -254,13 +254,10 @@ void url(char *buf)
 
        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))
@@ -272,18 +269,24 @@ void url(char *buf)
        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);
@@ -646,6 +649,7 @@ struct attach_link {
 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];
@@ -718,7 +722,7 @@ void read_message(long msgnum, int printable_view, char *section) {
                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;
                }
@@ -797,12 +801,19 @@ void read_message(long msgnum, int printable_view, char *section) {
                }
 
                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, "|");
@@ -1010,7 +1021,7 @@ void read_message(long msgnum, int printable_view, char *section) {
                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, "X-Citadel-MSG4-Partnum:", 23)) {
@@ -1268,7 +1279,7 @@ void display_headers(char *msgnum_as_string) {
 
 /**
  * \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
@@ -1327,7 +1338,7 @@ void pullquote_message(long msgnum, int forward_attachments, int include_headers
 
        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) {
@@ -1430,7 +1441,7 @@ void pullquote_message(long msgnum, int forward_attachments, int 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)) {
@@ -3004,6 +3015,15 @@ void display_enter(void)
                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(
+                       "&nbsp;<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>");
@@ -3015,6 +3035,15 @@ void display_enter(void)
                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(
+                       "&nbsp;<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>");
@@ -3026,6 +3055,14 @@ void display_enter(void)
                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(
+                       "&nbsp;<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) */
@@ -3037,7 +3074,12 @@ void display_enter(void)
 
        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=\"");
@@ -3181,11 +3223,11 @@ void display_enter(void)
        }
 
        wprintf("</form>\n");
-
        wprintf("</td></tr></table></div>\n");
-DONE:  wDumpContent(1);
-}
 
+DONE:  address_book_popup();
+       wDumpContent(1);
+}
 
 
 /**