Move vcard.c into libcitadel.
[citadel.git] / webcit / messages.c
index abe91b05e77848873b194289ddebbca617a6d6da..ed90acba343cddb75906c1f58008102b76fdc278 100644 (file)
@@ -8,7 +8,6 @@
  */
 /*@{*/
 #include "webcit.h"
-#include "vcard.h"
 #include "webserver.h"
 #include "groupdav.h"
 
@@ -210,7 +209,7 @@ void utf8ify_rfc822_string(char *buf) {
  * \param      maxlen          Maximum size of target buffer.
  * \param      source          Source string to be encoded.
  */
-void rfc2047encode(char *target, int maxlen, char *source)
+void webcit_rfc2047encode(char *target, int maxlen, char *source)
 {
        int need_to_encode = 0;
        int i, len;
@@ -813,7 +812,7 @@ void read_message(long msgnum, int printable_view, char *section) {
                        wprintf(" ");
                }
                if (!strncasecmp(buf, "time=", 5)) {
-                       fmt_date(now, atol(&buf[5]), 0);
+                       webcit_fmt_date(now, atol(&buf[5]), 0);
                        wprintf("<span>");
                        wprintf("%s ", now);
                        wprintf("</span>");
@@ -1257,7 +1256,7 @@ void print_message(char *msgnum_as_string) {
        wprintf("Content-type: text/html\r\n"
                "Server: %s\r\n"
                "Connection: close\r\n",
-               SERVER);
+               PACKAGE_STRING);
        begin_burst();
 
        wprintf("\r\n\r\n<html>\n"
@@ -1288,7 +1287,7 @@ void display_headers(char *msgnum_as_string) {
        wprintf("Content-type: text/plain\r\n"
                "Server: %s\r\n"
                "Connection: close\r\n",
-               SERVER);
+               PACKAGE_STRING);
        begin_burst();
 
        serv_printf("MSG2 %ld|3", msgnum);
@@ -1418,7 +1417,7 @@ void pullquote_message(long msgnum, int forward_attachments, int include_headers
                                wprintf("%s ", &buf[5]);
                        }
                        if (!strncasecmp(buf, "time=", 5)) {
-                               fmt_date(now, atol(&buf[5]), 0);
+                               webcit_fmt_date(now, atol(&buf[5]), 0);
                                wprintf("%s ", now);
                        }
                }
@@ -1659,7 +1658,7 @@ void display_summarized(int num) {
        wprintf("</td>");
 
        wprintf("<td width=%d%%>", DATE_PLUS_BUTTONS_WIDTH_PCT);
-       fmt_date(datebuf, WC->summ[num].date, 1);       /* brief */
+       webcit_fmt_date(datebuf, WC->summ[num].date, 1);        /* brief */
        escputs(datebuf);
        wprintf("</td>");
 
@@ -1929,7 +1928,7 @@ void do_addrbook_view(struct addrbookent *addrbook, int num_ab) {
 
                wprintf("<a href=\"readfwd?startmsg=%ld&is_singlecard=1",
                        addrbook[i].ab_msgnum);
-               wprintf("?maxmsgs=1?summary=0?alpha=%s\">", bstr("alpha"));
+               wprintf("?maxmsgs=1?is_summary=0?alpha=%s\">", bstr("alpha"));
                vcard_n_prettyize(addrbook[i].ab_name);
                escputs(addrbook[i].ab_name);
                wprintf("</a></td>\n");
@@ -2196,19 +2195,20 @@ void readloop(char *oper)
        char *sendsort_button;
        char *datesort_button;
        int bbs_reverse = 0;
+       struct wcsession *WCC = WC;     /* This is done to make it run faster; WC is a function */
 
-       if (WC->wc_view == VIEW_WIKI) {
-               sprintf(buf, "wiki?room=%s?page=home", WC->wc_roomname);
+       if (WCC->wc_view == VIEW_WIKI) {
+               sprintf(buf, "wiki?room=%s?page=home", WCC->wc_roomname);
                http_redirect(buf);
                return;
        }
 
        startmsg = atol(bstr("startmsg"));
        maxmsgs = atoi(bstr("maxmsgs"));
-       is_summary = atoi(bstr("summary"));
+       is_summary = atoi(bstr("is_summary"));
        if (maxmsgs == 0) maxmsgs = DEFAULT_MAXMSGS;
 
-       snprintf(sortpref_name, sizeof sortpref_name, "sort %s", WC->wc_roomname);
+       snprintf(sortpref_name, sizeof sortpref_name, "sort %s", WCC->wc_roomname);
        get_preference(sortpref_name, sortpref_value, sizeof sortpref_value);
 
        sortby = bstr("sortby");
@@ -2247,7 +2247,7 @@ void readloop(char *oper)
                strcpy(cmd, "MSGS ALL");
        }
 
-       if ((WC->wc_view == VIEW_MAILBOX) && (maxmsgs > 1)) {
+       if ((WCC->wc_view == VIEW_MAILBOX) && (maxmsgs > 1)) {
                is_summary = 1;
                if (!strcmp(oper, "do_search")) {
                        sprintf(cmd, "MSGS SEARCH|%s", bstr("query"));
@@ -2257,7 +2257,7 @@ void readloop(char *oper)
                }
        }
 
-       if ((WC->wc_view == VIEW_ADDRESSBOOK) && (maxmsgs > 1)) {
+       if ((WCC->wc_view == VIEW_ADDRESSBOOK) && (maxmsgs > 1)) {
                is_addressbook = 1;
                if (!strcmp(oper, "do_search")) {
                        sprintf(cmd, "MSGS SEARCH|%s", bstr("query"));
@@ -2293,17 +2293,17 @@ void readloop(char *oper)
 
        is_singlecard = atoi(bstr("is_singlecard"));
 
-       if (WC->wc_default_view == VIEW_CALENDAR) {             /**< calendar */
+       if (WCC->wc_default_view == VIEW_CALENDAR) {            /**< calendar */
                is_calendar = 1;
                strcpy(cmd, "MSGS ALL");
                maxmsgs = 32767;
        }
-       if (WC->wc_default_view == VIEW_TASKS) {                /**< tasks */
+       if (WCC->wc_default_view == VIEW_TASKS) {               /**< tasks */
                is_tasks = 1;
                strcpy(cmd, "MSGS ALL");
                maxmsgs = 32767;
        }
-       if (WC->wc_default_view == VIEW_NOTES) {                /**< notes */
+       if (WCC->wc_default_view == VIEW_NOTES) {               /**< notes */
                is_notes = 1;
                strcpy(cmd, "MSGS ALL");
                maxmsgs = 32767;
@@ -2336,11 +2336,11 @@ void readloop(char *oper)
                for (a = 0; a < nummsgs; ++a) {
                        /** Are you a new message, or an old message? */
                        if (is_summary) {
-                               if (is_msg_in_mset(old_msgs, WC->msgarr[a])) {
-                                       WC->summ[a].is_new = 0;
+                               if (is_msg_in_mset(old_msgs, WCC->msgarr[a])) {
+                                       WCC->summ[a].is_new = 0;
                                }
                                else {
-                                       WC->summ[a].is_new = 1;
+                                       WCC->summ[a].is_new = 1;
                                }
                        }
                }
@@ -2348,68 +2348,68 @@ void readloop(char *oper)
 
        if (startmsg == 0L) {
                if (bbs_reverse) {
-                       startmsg = WC->msgarr[(nummsgs >= maxmsgs) ? (nummsgs - maxmsgs) : 0];
+                       startmsg = WCC->msgarr[(nummsgs >= maxmsgs) ? (nummsgs - maxmsgs) : 0];
                }
                else {
-                       startmsg = WC->msgarr[0];
+                       startmsg = WCC->msgarr[0];
                }
        }
 
        if (is_summary) {
                if (!strcasecmp(sortby, "subject")) {
-                       qsort(WC->summ, WC->num_summ,
+                       qsort(WCC->summ, WCC->num_summ,
                                sizeof(struct message_summary), summcmp_subj);
                }
                else if (!strcasecmp(sortby, "rsubject")) {
-                       qsort(WC->summ, WC->num_summ,
+                       qsort(WCC->summ, WCC->num_summ,
                                sizeof(struct message_summary), summcmp_rsubj);
                }
                else if (!strcasecmp(sortby, "sender")) {
-                       qsort(WC->summ, WC->num_summ,
+                       qsort(WCC->summ, WCC->num_summ,
                                sizeof(struct message_summary), summcmp_sender);
                }
                else if (!strcasecmp(sortby, "rsender")) {
-                       qsort(WC->summ, WC->num_summ,
+                       qsort(WCC->summ, WCC->num_summ,
                                sizeof(struct message_summary), summcmp_rsender);
                }
                else if (!strcasecmp(sortby, "date")) {
-                       qsort(WC->summ, WC->num_summ,
+                       qsort(WCC->summ, WCC->num_summ,
                                sizeof(struct message_summary), summcmp_date);
                }
                else if (!strcasecmp(sortby, "rdate")) {
-                       qsort(WC->summ, WC->num_summ,
+                       qsort(WCC->summ, WCC->num_summ,
                                sizeof(struct message_summary), summcmp_rdate);
                }
        }
 
        if (!strcasecmp(sortby, "subject")) {
-               subjsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?summary=1?sortby=rsubject\"><img border=\"0\" src=\"static/down_pointer.gif\" /></a>" ;
+               subjsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=rsubject\"><img border=\"0\" src=\"static/down_pointer.gif\" /></a>" ;
        }
        else if (!strcasecmp(sortby, "rsubject")) {
-               subjsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?summary=1?sortby=subject\"><img border=\"0\" src=\"static/up_pointer.gif\" /></a>" ;
+               subjsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=subject\"><img border=\"0\" src=\"static/up_pointer.gif\" /></a>" ;
        }
        else {
-               subjsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?summary=1?sortby=subject\"><img border=\"0\" src=\"static/sort_none.gif\" /></a>" ;
+               subjsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=subject\"><img border=\"0\" src=\"static/sort_none.gif\" /></a>" ;
        }
 
        if (!strcasecmp(sortby, "sender")) {
-               sendsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?summary=1?sortby=rsender\"><img border=\"0\" src=\"static/down_pointer.gif\" /></a>" ;
+               sendsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=rsender\"><img border=\"0\" src=\"static/down_pointer.gif\" /></a>" ;
        }
        else if (!strcasecmp(sortby, "rsender")) {
-               sendsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?summary=1?sortby=sender\"><img border=\"0\" src=\"static/up_pointer.gif\" /></a>" ;
+               sendsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=sender\"><img border=\"0\" src=\"static/up_pointer.gif\" /></a>" ;
        }
        else {
-               sendsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?summary=1?sortby=sender\"><img border=\"0\" src=\"static/sort_none.gif\" /></a>" ;
+               sendsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=sender\"><img border=\"0\" src=\"static/sort_none.gif\" /></a>" ;
        }
 
        if (!strcasecmp(sortby, "date")) {
-               datesort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?summary=1?sortby=rdate\"><img border=\"0\" src=\"static/down_pointer.gif\" /></a>" ;
+               datesort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=rdate\"><img border=\"0\" src=\"static/down_pointer.gif\" /></a>" ;
        }
        else if (!strcasecmp(sortby, "rdate")) {
-               datesort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?summary=1?sortby=date\"><img border=\"0\" src=\"static/up_pointer.gif\" /></a>" ;
+               datesort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=date\"><img border=\"0\" src=\"static/up_pointer.gif\" /></a>" ;
        }
        else {
-               datesort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?summary=1?sortby=rdate\"><img border=\"0\" src=\"static/sort_none.gif\" /></a>" ;
+               datesort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=rdate\"><img border=\"0\" src=\"static/sort_none.gif\" /></a>" ;
        }
 
        if (is_summary) {
@@ -2473,7 +2473,7 @@ void readloop(char *oper)
         */
        if (is_bbview) {
                /** begin bbview scroller */
-               wprintf("<form name=\"msgomatictop\" class=\"selector_top\" >");
+               wprintf("<form name=\"msgomatictop\" class=\"selector_top\" > \n <p>");
                wprintf(_("Reading #"), lowest_displayed, highest_displayed);
 
                wprintf("<select name=\"whichones\" size=\"1\" "
@@ -2489,11 +2489,11 @@ void readloop(char *oper)
                                        "\"%s"
                                        "?startmsg=%ld"
                                        "?maxmsgs=%d"
-                                       "?summary=%d\">"
+                                       "?is_summary=%d\">"
                                        "%d-%d</option> \n",
-                                       ((WC->msgarr[lo-1] == startmsg) ? "selected" : ""),
+                                       ((WCC->msgarr[lo-1] == startmsg) ? "selected" : ""),
                                        oper,
-                                       WC->msgarr[lo-1],
+                                       WCC->msgarr[lo-1],
                                        maxmsgs,
                                        is_summary,
                                        hi, lo);
@@ -2508,11 +2508,11 @@ void readloop(char *oper)
                                        "\"%s"
                                        "?startmsg=%ld"
                                        "?maxmsgs=%d"
-                                       "?summary=%d\">"
+                                       "?is_summary=%d\">"
                                        "%d-%d</option> \n",
-                                       ((WC->msgarr[b] == startmsg) ? "selected" : ""),
+                                       ((WCC->msgarr[b] == startmsg) ? "selected" : ""),
                                        oper,
-                                       WC->msgarr[lo-1],
+                                       WCC->msgarr[lo-1],
                                        maxmsgs,
                                        is_summary,
                                        lo, hi);
@@ -2520,9 +2520,9 @@ void readloop(char *oper)
                }
 
                wprintf("<option value=\"%s?startmsg=%ld"
-                       "?maxmsgs=9999999?summary=%d\">",
+                       "?maxmsgs=9999999?is_summary=%d\">",
                        oper,
-                       WC->msgarr[0], is_summary);
+                       WCC->msgarr[0], is_summary);
                wprintf(_("All"));
                wprintf("</option>");
                wprintf("</select> ");
@@ -2547,43 +2547,48 @@ void readloop(char *oper)
                wprintf(_("newest to oldest"));
                wprintf("\n");
        
-               wprintf("</select></form>\n");
+               wprintf("</p></form>\n");
                /** end bbview scroller */
        }
 
+       if (is_notes)
+       {
+               wprintf ("<script src=\"/static/dragdrop.js\" type=\"text/javascript\"></script>\n");
+       }
+
 
 
        for (a = 0; a < nummsgs; ++a) {
-               if ((WC->msgarr[a] >= startmsg) && (num_displayed < maxmsgs)) {
+               if ((WCC->msgarr[a] >= startmsg) && (num_displayed < maxmsgs)) {
 
                        /** Display the message */
                        if (is_summary) {
                                display_summarized(a);
                        }
                        else if (is_addressbook) {
-                               fetch_ab_name(WC->msgarr[a], buf);
+                               fetch_ab_name(WCC->msgarr[a], buf);
                                ++num_ab;
                                addrbook = realloc(addrbook,
                                        (sizeof(struct addrbookent) * num_ab) );
                                safestrncpy(addrbook[num_ab-1].ab_name, buf,
                                        sizeof(addrbook[num_ab-1].ab_name));
-                               addrbook[num_ab-1].ab_msgnum = WC->msgarr[a];
+                               addrbook[num_ab-1].ab_msgnum = WCC->msgarr[a];
                        }
                        else if (is_calendar) {
-                               display_calendar(WC->msgarr[a]);
+                               display_calendar(WCC->msgarr[a]);
                        }
                        else if (is_tasks) {
-                               display_task(WC->msgarr[a]);
+                               display_task(WCC->msgarr[a]);
                        }
                        else if (is_notes) {
-                               display_note(WC->msgarr[a]);
+                               display_note(WCC->msgarr[a]);
                        }
                        else {
                                if (displayed_msgs == NULL) {
                                        displayed_msgs = malloc(sizeof(long) *
                                                                (maxmsgs<nummsgs ? maxmsgs : nummsgs));
                                }
-                               displayed_msgs[num_displayed] = WC->msgarr[a];
+                               displayed_msgs[num_displayed] = WCC->msgarr[a];
                        }
 
                        if (lowest_displayed < 0) lowest_displayed = a;
@@ -2593,7 +2598,6 @@ void readloop(char *oper)
                }
        }
 
-
        /** Output loop */
        if (displayed_msgs != NULL) {
                if (bbs_reverse) {
@@ -2640,7 +2644,7 @@ void readloop(char *oper)
         */
        if (is_bbview) {
                /** begin bbview scroller */
-               wprintf("<form name=\"msgomatic\" class=\"selector_bottom\" >");
+               wprintf("<form name=\"msgomatic\" class=\"selector_bottom\" > \n <p>");
                wprintf(_("Reading #"), lowest_displayed, highest_displayed);
 
                wprintf("<select name=\"whichones\" size=\"1\" "
@@ -2656,11 +2660,11 @@ void readloop(char *oper)
                                        "\"%s"
                                        "?startmsg=%ld"
                                        "?maxmsgs=%d"
-                                       "?summary=%d\">"
+                                       "?is_summary=%d\">"
                                        "%d-%d</option> \n",
-                                       ((WC->msgarr[lo-1] == startmsg) ? "selected" : ""),
+                                       ((WCC->msgarr[lo-1] == startmsg) ? "selected" : ""),
                                        oper,
-                                       WC->msgarr[lo-1],
+                                       WCC->msgarr[lo-1],
                                        maxmsgs,
                                        is_summary,
                                        hi, lo);
@@ -2675,11 +2679,11 @@ void readloop(char *oper)
                                        "\"%s"
                                        "?startmsg=%ld"
                                        "?maxmsgs=%d"
-                                       "?summary=%d\">"
+                                       "?is_summary=%d\">"
                                        "%d-%d</option> \n",
-                                       ((WC->msgarr[b] == startmsg) ? "selected" : ""),
+                                       ((WCC->msgarr[b] == startmsg) ? "selected" : ""),
                                        oper,
-                                       WC->msgarr[lo-1],
+                                       WCC->msgarr[lo-1],
                                        maxmsgs,
                                        is_summary,
                                        lo, hi);
@@ -2687,9 +2691,9 @@ void readloop(char *oper)
                }
 
                wprintf("<option value=\"%s?startmsg=%ld"
-                       "?maxmsgs=9999999?summary=%d\">",
+                       "?maxmsgs=9999999?is_summary=%d\">",
                        oper,
-                       WC->msgarr[0], is_summary);
+                       WCC->msgarr[0], is_summary);
                wprintf(_("All"));
                wprintf("</option>");
                wprintf("</select> ");
@@ -2713,9 +2717,43 @@ void readloop(char *oper)
                wprintf(_("newest to oldest"));
                wprintf("\n");
 
-               wprintf("</form>\n");
+               wprintf("</p></form>\n");
                /** end bbview scroller */
        }
+       
+       if (is_notes)
+       {
+//             wprintf ("</div>\n");
+               wprintf ("<div id=\"wastebin\" align=middle>Drop notes here to remove them.</div>\n");
+               wprintf ("<script type=\"text/javascript\">\n");
+//             wprintf ("//<![CDATA[\n");
+               wprintf ("Droppables.add(\"wastebin\",\n");
+               wprintf ("\t{\n");
+               wprintf ("\t\taccept:'notes',\n");
+               wprintf ("\t\tonDrop:function(element)\n");
+               wprintf ("\t\t{\n");
+               wprintf ("\t\t\tElement.hide(element);\n");
+               wprintf ("\t\t\tnew Ajax.Updater('notes', 'delnote',\n");
+               wprintf ("\t\t\t{\n");
+               wprintf ("\t\t\t\tasynchronous:true,\n");
+               wprintf ("\t\t\t\tevalScripts:true,\n");
+               wprintf ("\t\t\t\tonComplete:function(request)\n");
+               wprintf ("\t\t\t\t{\n");
+               wprintf ("\t\t\t\t\tElement.hide('indicator')\n");
+               wprintf ("\t\t\t\t},\n");
+               wprintf ("\t\t\t\tonLoading:function(request)\n");
+               wprintf ("\t\t\t\t{\n");
+               wprintf ("\t\t\t\t\tElement.show('indicator')\n");
+               wprintf ("\t\t\t\t},\n");
+               wprintf ("\t\t\t\tparameters:'id=' + encodeURIComponent(element.id)\n");
+               wprintf ("\t\t\t})\n");
+               wprintf ("\t\t}\n");
+               wprintf ("\t})\n");
+//             wprintf ("//]]>\n");
+               wprintf ("</script>\n");
+       }
+
+
 
 DONE:
        if (is_tasks) {
@@ -2735,10 +2773,10 @@ DONE:
        wDumpContent(1);
 
        /** free the summary */
-       if (WC->summ != NULL) {
-               free(WC->summ);
-               WC->num_summ = 0;
-               WC->summ = NULL;
+       if (WCC->summ != NULL) {
+               free(WCC->summ);
+               WCC->num_summ = 0;
+               WCC->summ = NULL;
        }
        if (addrbook != NULL) free(addrbook);
 }
@@ -2759,7 +2797,7 @@ void post_mime_to_server(void) {
 
        /** RFC2045 requires this, and some clients look for it... */
        serv_puts("MIME-Version: 1.0");
-       serv_puts("X-Mailer: " SERVER);
+       serv_puts("X-Mailer: " PACKAGE_STRING);
 
        /** If there are attachments, we have to do multipart/mixed */
        if (WC->first_attachment != NULL) {
@@ -2795,7 +2833,7 @@ void post_mime_to_server(void) {
                        encoded_length = ((att->length * 150) / 100);
                        encoded = malloc(encoded_length);
                        if (encoded == NULL) break;
-                       encoded_strlen = CtdlEncodeBase64(&encoded, att->data, att->length, &encoded_length, 1);
+                       encoded_strlen = CtdlEncodeBase64(encoded, att->data, att->length, 1);
 
                        serv_printf("--%s", boundary);
                        serv_printf("Content-type: %s", att->content_type);
@@ -2835,6 +2873,10 @@ void post_message(void)
        int is_anonymous = 0;
        char *display_name;
 
+       if (!IsEmptyStr(bstr("force_room"))) {
+               gotoroom(bstr("force_room"));
+       }
+
        display_name = bstr("display_name");
        if (!strcmp(display_name, "__ANONYMOUS__")) {
                display_name = "";
@@ -2896,7 +2938,7 @@ void post_message(void)
                        _("Automatically cancelled because you have already "
                        "saved this message."));
        } else {
-               rfc2047encode(encoded_subject, sizeof encoded_subject, bstr("subject"));
+               webcit_rfc2047encode(encoded_subject, sizeof encoded_subject, bstr("subject"));
                sprintf(buf, "ENT0 1|%s|%d|4|%s|%s||%s|%s|%s|%s",
                        bstr("recp"),
                        is_anonymous,
@@ -3008,7 +3050,7 @@ void display_enter(void)
         * message" command really means "add new entry."
         */
        if (WC->wc_default_view == VIEW_ADDRESSBOOK) {
-               do_edit_vcard(-1, "", "");
+               do_edit_vcard(-1, "", "", WC->wc_roomname);
                return;
        }
 
@@ -3082,6 +3124,9 @@ void display_enter(void)
        }
        wprintf("<input type=\"hidden\" name=\"return_to\" value=\"%s\">\n", bstr("return_to"));
        wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"force_room\" value=\"");
+       escputs(WC->wc_roomname);
+       wprintf("\">\n");
 
        /** submit or cancel buttons */
         wprintf("<p class=\"send_edit_msg\">");
@@ -3099,14 +3144,17 @@ void display_enter(void)
 
        wprintf("<img src=\"static/newmess3_24x.gif\" class=\"imgedit\">");
        wprintf("  ");  /** header bar */
-       fmt_date(buf, now, 0);
+       webcit_fmt_date(buf, now, 0);
        wprintf("%s", buf);
        wprintf("\n");  /** header bar */
 
-       wprintf("<div>");
-       wprintf("<label for=\"from_id\" > ");
+       wprintf("<table width=\"100%%\" class=\"edit_msg_table\">");
+       wprintf("<tr>");
+       wprintf("<th><label for=\"from_id\" > ");
        wprintf(_(" <I>from</I> "));
-       wprintf("</label>");
+       wprintf("</label></th>");
+
+       wprintf("<td colspan=\"2\">");
 
        /* Allow the user to select any of his valid screen names */
 
@@ -3156,66 +3204,74 @@ void display_enter(void)
 
        wprintf(_(" <I>in</I> "));
        escputs(WC->wc_roomname);
-       wprintf("</div>");
+
+       wprintf("</td></tr>");
 
        if (recipient_required) {
 
-               wprintf("<div style=\"float: left;\"><label for=\"recp_id\"> ");
+               wprintf("<tr><th><label for=\"recp_id\"> ");
                wprintf(_("To:"));
-               wprintf("</label>"
-                       "<input autocomplete=\"off\" type=\"text\" name=\"recp\" id=\"recp_id\" value=\"");
+               wprintf("</label></th>"
+                       "<td><input autocomplete=\"off\" type=\"text\" name=\"recp\" id=\"recp_id\" value=\"");
                escputs(bstr("recp"));
                wprintf("\" size=45 maxlength=1000 />");
                wprintf("<div class=\"auto_complete\" id=\"recp_name_choices\"></div>");
+               wprintf("</td><td rowspan=\"3\" align=\"left\" valign=\"top\">");
 
+               /** Pop open an address book -- begin **/
+               wprintf(
+                       "<a href=\"javascript:PopOpenAddressBook('recp_id|%s|cc_id|%s|bcc_id|%s');\" "
+                       "title=\"%s\">"
+                       "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
+                       "&nbsp;%s</a>",
+                       _("To:"), _("CC:"), _("BCC:"),
+                       _("Contacts"), _("Contacts")
+               );
+               /** Pop open an address book -- end **/
+
+               wprintf("</td></tr>");
 
-               wprintf("<br/><label for=\"cc_id\"> ");
+               wprintf("<tr><th><label for=\"cc_id\"> ");
                wprintf(_("CC:"));
-               wprintf("</label>"
-                       "<input autocomplete=\"off\" type=\"text\" name=\"cc\" id=\"cc_id\" value=\"");
+               wprintf("</label></th>"
+                       "<td><input autocomplete=\"off\" type=\"text\" name=\"cc\" id=\"cc_id\" value=\"");
                escputs(bstr("cc"));
                wprintf("\" size=45 maxlength=1000 />");
                wprintf("<div class=\"auto_complete\" id=\"cc_name_choices\"></div>");
-               wprintf("<br/><label for=\"bcc_id\"> ");
+               wprintf("</td></tr>");
+
+               wprintf("<tr><th><label for=\"bcc_id\"> ");
                wprintf(_("BCC:"));
-               wprintf("</label>"
-                       "<input autocomplete=\"off\" type=\"text\" name=\"bcc\" id=\"bcc_id\" value=\"");
+               wprintf("</label></th>"
+                       "<td><input autocomplete=\"off\" type=\"text\" name=\"bcc\" id=\"bcc_id\" value=\"");
                escputs(bstr("bcc"));
                wprintf("\" size=45 maxlength=1000 />");
                wprintf("<div class=\"auto_complete\" id=\"bcc_name_choices\"></div>");
+               wprintf("</td></tr>");
 
                /** Initialize the autocomplete ajax helpers (found in wclib.js) */
                wprintf("<script type=\"text/javascript\">      \n"
                        " activate_entmsg_autocompleters();     \n"
                        "</script>                              \n"
                );
-               wprintf("</div>");
 
-               /** Pop open an address book -- begin **/
-               wprintf(
-                       "<a href=\"javascript:PopOpenAddressBook('recp_id|%s|cc_id|%s|bcc_id|%s');\" "
-                       "title=\"%s\">"
-                       "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
-                       "&nbsp;%s</a>",
-                       _("To:"), _("CC:"), _("BCC:"),
-                       _("Contacts"), _("Contacts")
-               );
-               /** Pop open an address book -- end **/
        }
 
-       wprintf("<div style=\"clear: both;\"><label for=\"subject_id\" > ");
+       wprintf("<tr><th><label for=\"subject_id\" > ");
        if (recipient_required || subject_required) {
                wprintf(_("Subject:"));
        }
        else {
                wprintf(_("Subject (optional):"));
        }
-       wprintf("</label>"
+       wprintf("</label></th>"
+               "<td colspan=\"2\">"
                "<input type=\"text\" name=\"subject\" id=\"subject_id\" value=\" ");
        escputs(bstr("subject"));
        wprintf("\" size=45 maxlength=70>\n");
+       wprintf("</td></tr>");
 
-       wprintf("</div>\n");
+       wprintf("<tr><td colspan=\"3\">\n");
 
        wprintf("<textarea name=\"msgtext\" cols=\"80\" rows=\"15\">");
 
@@ -3312,17 +3368,20 @@ void display_enter(void)
        wprintf(" <input name=\"attachfile\" class=\"attachfile\" "
                "size=16 type=\"file\">\n&nbsp;&nbsp;"
                "<input type=\"submit\" name=\"attach_button\" value=\"%s\">\n", _("Add"));
-       wprintf("</div>");
+       wprintf("</div>");      /* End of "attachment buttons" div */
 
 
        /** Make sure we only insert our signature once */
        if (strcmp(bstr("sig_inserted"), "yes")) {
                wprintf("<input type=\"hidden\" name=\"sig_inserted\" value=\"yes\">\n");
        }
-
+       
+       wprintf("</td></tr></table>");
+       
        wprintf("</form>\n");
-       wprintf("</div></div>\n");
+       wprintf("</div>\n");    /* end of "fix_scrollbar_bug" div */
 
+       /* NOTE: address_book_popup() will close the "content" div.  Don't close it here. */
 DONE:  address_book_popup();
        wDumpContent(1);
 }