]> code.citadel.org Git - citadel.git/blobdiff - webcit/messages.c
* Added "|END" to the session cookie before base64-ing it. This fixes a
[citadel.git] / webcit / messages.c
index 01f8bb04d51acc22cc52db6393ef3e5f86c1a0fe..fc02aa1835b7a59fdb2728df52d6f59eb2ecede7 100644 (file)
@@ -368,6 +368,11 @@ void read_message(long msgnum) {
                return;
        }
 
+       /* begin everythingamundo table */
+       wprintf("<table width=100% border=1 cellspacing=0 "
+               "cellpadding=0><TR><TD>\n");
+
+       /* begin message header table */
        wprintf("<TABLE WIDTH=100%% BORDER=0 CELLSPACING=0 "
                "CELLPADDING=1 BGCOLOR=\"#CCCCCC\"><TR><TD>\n");
 
@@ -542,7 +547,7 @@ void read_message(long msgnum) {
 
        /* Begin body */
        wprintf("<TABLE BORDER=0 WIDTH=100%% BGCOLOR=#FFFFFF "
-               "CELLPADDING=0 CELLSPACING=0><TR><TD>");
+               "CELLPADDING=1 CELLSPACING=0><TR><TD>");
 
        /* 
         * Learn the content type
@@ -641,6 +646,9 @@ void read_message(long msgnum) {
 
 ENDBODY:
        wprintf("</TD></TR></TABLE>\n");
+
+       /* end everythingamundo table */
+       wprintf("</TD></TR></TABLE><BR>\n");
 }
 
 
@@ -1285,6 +1293,11 @@ void post_mime_to_server(void) {
        struct wc_attachment *att;
        char *encoded;
        size_t encoded_length;
+       int is_html = 0;
+
+       if (!strcasecmp(bstr("msg_format"), "html")) {
+               is_html = 1;
+       }
        
        /* If there are attachments, we have to do multipart/mixed */
        if (WC->first_attachment != NULL) {
@@ -1307,7 +1320,15 @@ void post_mime_to_server(void) {
 
        serv_puts("Content-type: text/html");
        serv_puts("");
-       text_to_server(bstr("msgtext"), 1);
+       serv_puts("<HTML><BODY>\n");
+       if (is_html) {
+               text_to_server(bstr("msgtext"), 0);
+       }
+       else {
+               text_to_server(bstr("msgtext"), 1);
+       }
+       serv_puts("</BODY></HTML>\n");
+       
 
        if (is_multipart) {
 
@@ -1429,6 +1450,15 @@ void display_enter(void)
                gotoroom(bstr("force_room"), 0);
        }
 
+       /* Are we perhaps in an address book view?  If so, then an "enter
+        * message" command really means "add new entry."
+        */
+       if (WC->wc_view == 2) {
+               do_edit_vcard(-1, "", "");
+               return;
+       }
+
+       /* Otherwise proceed normally */
        output_headers(1);
        sprintf(buf, "ENT0 0|%s|0|0", bstr("recp"));
        serv_puts(buf);
@@ -1452,13 +1482,13 @@ void display_enter(void)
        now = time(NULL);
        fmt_date(buf, now);
        strcat(&buf[strlen(buf)], " <I>from</I> ");
-       stresc(&buf[strlen(buf)], WC->wc_username, 1);
+       stresc(&buf[strlen(buf)], WC->wc_username, 1, 1);
        if (strlen(bstr("recp")) > 0) {
                strcat(&buf[strlen(buf)], " <I>to</I> ");
-               stresc(&buf[strlen(buf)], bstr("recp"), 1);
+               stresc(&buf[strlen(buf)], bstr("recp"), 1, 1);
        }
        strcat(&buf[strlen(buf)], " <I>in</I> ");
-       stresc(&buf[strlen(buf)], WC->wc_roomname, 1);
+       stresc(&buf[strlen(buf)], WC->wc_roomname, 1, 1);
        svprintf("BOXTITLE", WCS_STRING, buf);
        do_template("beginbox");
 
@@ -1466,25 +1496,56 @@ void display_enter(void)
 
        wprintf("<FORM ENCTYPE=\"multipart/form-data\" "
                "METHOD=\"POST\" ACTION=\"/post\" "
-               "NAME=\"enterform\">\n");
+               "NAME=\"enterform\""
+               "onSubmit=\"return submitForm();\""
+               ">\n");
        wprintf("<INPUT TYPE=\"hidden\" NAME=\"recp\" VALUE=\"%s\">\n",
                bstr("recp"));
        wprintf("<INPUT TYPE=\"hidden\" NAME=\"postseq\" VALUE=\"%ld\">\n",
                now);
-       wprintf("<IMG SRC=\"static/enter.gif\" ALIGN=MIDDLE ALT=\" \" "
-               "onLoad=\"document.enterform.msgtext.focus();\" >");
+       wprintf("<IMG SRC=\"static/enter.gif\" ALIGN=MIDDLE ALT=\" \">");
+               /* "onLoad=\"document.enterform.msgtext.focus();\" " */
        wprintf("<FONT SIZE=-1>Subject (optional):</FONT>"
                "<INPUT TYPE=\"text\" NAME=\"subject\" VALUE=\"");
        escputs(bstr("subject"));
        wprintf("\" MAXLENGTH=70>"
-               "&nbsp;&nbsp;&nbsp;"
-               "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Save message\">"
+               "&nbsp;"
+       );
+
+       wprintf("<INPUT TYPE=\"radio\" NAME=\"msg_format\"");
+       if (!strcasecmp(bstr("msg_format"), "text")) wprintf("CHECKED ");
+       wprintf("VALUE=\"text\">text&nbsp;\n");
+
+       wprintf("<INPUT TYPE=\"radio\" NAME=\"msg_format\"");
+       if (strcasecmp(bstr("msg_format"), "text")) wprintf("CHECKED ");
+       wprintf("VALUE=\"html\">HTML&nbsp;\n");
+
+       wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Save message\">"
                "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><BR>\n");
 
+       wprintf("<SCRIPT language=\"JavaScript\" type=\"text/javascript\" "
+               "src=\"static/richtext.js\"></SCRIPT>\n"
+               "<SCRIPT language=\"JavaScript\" type=\"text/javascript\">\n"
+               "function submitForm() { \n"
+               "  updateRTE('msgtext'); \n"
+               "  return true; \n"
+               "} \n"
+               "  \n"
+               "initRTE(\"static/\", \"static/\", \"\"); \n"
+               "</script> \n"
+               "<noscript>JAVASCRIPT MUST BE ENABLED.</noscript> \n"
+               "<SCRIPT language=\"javascript\" type=\"text/javascript\"> \n"
+               "writeRichText('msgtext', '");
+       msgescputs(bstr("msgtext"));
+       wprintf("', '100%%', 200, true, false); \n"
+               "</script> \n");
+
+/*
        wprintf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=25 COLS=80 "
                "WIDTH=80>");
        escputs(bstr("msgtext"));
        wprintf("</TEXTAREA><BR>\n");
+*/
 
        /* Enumerate any attachments which are already in place... */
        for (att = WC->first_attachment; att != NULL; att = att->next) {
@@ -1496,7 +1557,8 @@ void display_enter(void)
        }
 
        /* Now offer the ability to attach additional files... */
-       wprintf("Attach file: <input NAME=\"attachfile\" "
+       wprintf("&nbsp;&nbsp;&nbsp;"
+               "Attach file: <input NAME=\"attachfile\" "
                "SIZE=48 TYPE=\"file\">\n&nbsp;&nbsp;"
                "<input type=\"submit\" name=\"attach\" value=\"Add\">\n");