]> code.citadel.org Git - citadel.git/blobdiff - webcit/messages.c
* *** HUGE CHANGES *** *** WARNING: NOT FULLY FUNCTIONAL ***
[citadel.git] / webcit / messages.c
index 5fdec2ed28acc9f363c441533778f48ef3bd8062..5030cb2faec8e0490de1061b6bdca75cf466ef95 100644 (file)
@@ -206,7 +206,7 @@ void display_parsed_vcard(struct vCard *v, int full) {
                        }
        
                        else if (!strcasecmp(firsttoken, "email")) {
-                               if (strlen(mailto) > 0) strcat(mailto, "<BR>");
+                               if (strlen(mailto) > 0) strcat(mailto, "<br />");
                                strcat(mailto,
                                        "<A HREF=\"/display_enter"
                                        "?force_room=_MAIL_&recp=");
@@ -216,7 +216,7 @@ void display_parsed_vcard(struct vCard *v, int full) {
                                strcat(mailto, "</A>");
                        }
                        else if (!strcasecmp(firsttoken, "tel")) {
-                               if (strlen(phone) > 0) strcat(phone, "<BR>");
+                               if (strlen(phone) > 0) strcat(phone, "<br />");
                                strcat(phone, thisvalue);
                                for (j=0; j<num_tokens(thisname, ';'); ++j) {
                                        extract_token(buf, thisname, j, ';');
@@ -242,7 +242,7 @@ void display_parsed_vcard(struct vCard *v, int full) {
                                                extract_token(buf, thisvalue, j, ';');
                                                if (strlen(buf) > 0) {
                                                        escputs(buf);
-                                                       wprintf("<BR>");
+                                                       wprintf("<br />");
                                                }
                                        }
                                        wprintf("</TD></TR>\n");
@@ -364,7 +364,7 @@ void read_message(long msgnum) {
        serv_printf("MSG4 %ld", msgnum);
        serv_gets(buf);
        if (buf[0] != '1') {
-               wprintf("<STRONG>ERROR:</STRONG> %s<BR>\n", &buf[4]);
+               wprintf("<STRONG>ERROR:</STRONG> %s<br />\n", &buf[4]);
                return;
        }
 
@@ -381,7 +381,7 @@ void read_message(long msgnum) {
 
        while (serv_gets(buf), strcasecmp(buf, "text")) {
                if (!strcmp(buf, "000")) {
-                       wprintf("<I>unexpected end of message</I><BR><BR>\n");
+                       wprintf("<I>unexpected end of message</I><br /><br />\n");
                        wprintf("</SPAN>\n");
                        return;
                }
@@ -447,7 +447,7 @@ void read_message(long msgnum) {
                                        "TARGET=\"wc.%ld.%s\">"
                                        "<IMG SRC=\"/static/attachment.gif\" "
                                        "BORDER=0 ALIGN=MIDDLE>\n"
-                                       "Part %s: %s (%s, %d bytes)</A><BR>\n",
+                                       "Part %s: %s (%s, %d bytes)</A><br />\n",
                                        msgnum, mime_partnum,
                                        msgnum, mime_partnum,
                                        mime_partnum, mime_filename,
@@ -498,51 +498,46 @@ void read_message(long msgnum) {
                wprintf("****");
        }
 
-       wprintf("</SPAN></TD>");
+       wprintf("</SPAN>");
+       if (strlen(m_subject) > 0) {
+               wprintf("<br />"
+                       "<SPAN CLASS=\"message_subject\">"
+                       "Subject: %s"
+                       "</SPAN>", m_subject
+               );
+       }
+       wprintf("</TD>\n");
 
-       wprintf("<TD ALIGN=RIGHT>\n"
-               "<TABLE BORDER=0><TR>\n");
+       /* start msg buttons */
+       wprintf("<TD ALIGN=RIGHT>\n");
+       wprintf("<FORM METHOD=\"POST\" ACTION=\"/do_stuff_to_one_msg\">\n");
+       wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%ld\">\n",
+               msgnum);
+       wprintf("<INPUT TYPE=\"hidden\" NAME=\"recp\" VALUE=\"");
+       escputs(reply_to);
+       wprintf("\">\n");
 
-       wprintf("<TD BGCOLOR=\"#AAAADD\">"
-               "<A HREF=\"/display_enter?recp=");
-       urlescputs(reply_to);
        if (!strncasecmp(m_subject, "Re:", 2)) {
-               wprintf("&subject=");
+               wprintf("<INPUT TYPE=\"hidden\" NAME=\"subject\" VALUE=\"");
                escputs(m_subject);
+               wprintf("\">\n");
        }
        else if (strlen(m_subject) > 0) {
-               wprintf("&subject=Re:%%20");
+               wprintf("<INPUT TYPE=\"hidden\" NAME=\"subject\" VALUE=\"Re: ");
                escputs(m_subject);
+               wprintf("\">\n");
        }
-       wprintf("\"><FONT SIZE=-1>Reply</FONT></A></TD>\n", msgnum);
-
-       if (WC->is_room_aide) {
-               wprintf("<TD BGCOLOR=\"#AAAADD\">"
-                       "<A HREF=\"/confirm_move_msg"
-                       "&msgid=%ld"
-                       "\"><FONT SIZE=-1>Move</FONT></A>"
-                       "</TD>\n", msgnum);
 
-               wprintf("<TD BGCOLOR=\"#AAAADD\">"
-                       "<A HREF=\"/delete_msg"
-                       "&msgid=%ld\""
-                       "onClick=\"return confirm('Delete this message?');\""
-                       "><FONT SIZE=-1>Del</FONT></A>"
-                       "</TD>\n", msgnum);
-       }
-
-       wprintf("</TR></TABLE>\n"
-               "</TD>\n");
+       wprintf("<INPUT TYPE=\"submit\" NAME=\"msg_oper\" STYLE=\"font-family: Bitstream Vera Sans,Arial,Helvetica,sans-serif; font-size: 7pt; background: blue; color: #FFFFFF;\" VALUE=\"Reply\">\n");
 
-       if (strlen(m_subject) > 0) {
-               wprintf("<TR><TD>"
-                       "<SPAN CLASS=\"message_subject\">"
-                       "Subject: %s"
-                       "</SPAN>"
-                       "</TD><TD>&nbsp;</TD></TR>\n", m_subject);
+       if (WC->is_room_aide)  {
+               wprintf("<INPUT TYPE=\"submit\" NAME=\"msg_oper\" STYLE=\"font-family: Bitstream Vera Sans,Arial,Helvetica,sans-serif; font-size: 7pt; background: blue; color: #FFFFFF;\"VALUE=\"Move\">\n"
+                       "<INPUT TYPE=\"submit\" NAME=\"msg_oper\" STYLE=\"font-family: Bitstream Vera Sans,Arial,Helvetica,sans-serif; font-size: 7pt; background: blue; color: #FFFFFF;\" VALUE=\"Delete\""
+                       "onClick=\"return confirm('Delete this message?');\">\n");
        }
 
-       wprintf("</TR></TABLE>\n");
+       wprintf("</FORM>\n"
+               "</TD></TR></TABLE>\n");
 
        /* Begin body */
        wprintf("<TABLE BORDER=0 WIDTH=100%% BGCOLOR=#FFFFFF "
@@ -554,7 +549,7 @@ void read_message(long msgnum) {
        strcpy(mime_content_type, "text/plain");
        while (serv_gets(buf), (strlen(buf) > 0)) {
                if (!strcmp(buf, "000")) {
-                       wprintf("<I>unexpected end of message</I><BR><BR>\n");
+                       wprintf("<I>unexpected end of message</I><br /><br />\n");
                        goto ENDBODY;
                }
                if (!strncasecmp(buf, "Content-type: ", 14)) {
@@ -577,19 +572,19 @@ void read_message(long msgnum) {
                                buf[strlen(buf) - 1] = 0;
                        if ((bq == 0) &&
                        ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) || (!strncmp(buf, " :-)", 4)))) {
-                               wprintf("<SPAN CLASS=\"pull_quote\">");
+                               wprintf("<BLOCKQUOTE>");
                                bq = 1;
                        } else if ((bq == 1) &&
                                (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) && (strncmp(buf, " :-)", 4))) {
-                               wprintf("</SPAN>");
+                               wprintf("</BLOCKQUOTE>");
                                bq = 0;
                        }
                        wprintf("<TT>");
                        url(buf);
                        escputs(buf);
-                       wprintf("</TT><BR>\n");
+                       wprintf("</TT><br />\n");
                }
-               wprintf("</I><BR>");
+               wprintf("</I><br />");
        }
 
        else /* HTML is fun, but we've got to strip it first */
@@ -599,7 +594,7 @@ void read_message(long msgnum) {
 
        /* Unknown weirdness */
        else {
-               wprintf("I don't know how to display %s<BR>\n",
+               wprintf("I don't know how to display %s<br />\n",
                        mime_content_type);
                while (serv_gets(buf), strcmp(buf, "000")) { }
        }
@@ -647,7 +642,7 @@ ENDBODY:
        wprintf("</TD></TR></TABLE>\n");
 
        /* end everythingamundo table */
-       wprintf("</TD></TR></TABLE><BR>\n");
+       wprintf("</TD></TR></TABLE><br />\n");
 }
 
 
@@ -955,7 +950,7 @@ void do_addrbook_view(struct addrbookent *addrbook, int num_ab) {
                        wprintf("</B>\n");
                }
        }
-       wprintf("<BR>\n");
+       wprintf("<br />\n");
 
        wprintf("<TABLE border=0 cellspacing=0 "
                "cellpadding=3 width=100%%>\n"
@@ -1005,7 +1000,7 @@ int load_msg_ptrs(char *servcmd)
        serv_puts(servcmd);
        serv_gets(buf);
        if (buf[0] != '1') {
-               wprintf("<EM>%s</EM><BR>\n", &buf[4]);
+               wprintf("<EM>%s</EM><br />\n", &buf[4]);
                return (nummsgs);
        }
        while (serv_gets(buf), strcmp(buf, "000")) {
@@ -1037,6 +1032,7 @@ void readloop(char *oper)
        int is_singlecard = 0;
        int is_calendar = 0;
        int is_tasks = 0;
+       int is_notes = 0;
        int remaining_messages;
        int lo, hi;
        int lowest_displayed = (-1);
@@ -1053,7 +1049,7 @@ void readloop(char *oper)
        is_summary = atoi(bstr("summary"));
        if (maxmsgs == 0) maxmsgs = DEFAULT_MAXMSGS;
 
-       output_headers(1);
+       output_headers(1, 1, 1, 0, 0, 0, 0);
 
        /* When in summary mode, always show ALL messages instead of just
         * new or old.  Otherwise, show what the user asked for.
@@ -1107,13 +1103,17 @@ void readloop(char *oper)
                is_tasks = 1;
                strcpy(cmd, "MSGS ALL");
                maxmsgs = 32767;
-               wprintf("<UL>");
+       }
+       if (WC->wc_view == VIEW_NOTES) {                /* notes */
+               is_notes = 1;
+               strcpy(cmd, "MSGS ALL");
+               maxmsgs = 32767;
        }
 
        nummsgs = load_msg_ptrs(cmd);
        if (nummsgs == 0) {
 
-               if ((!is_tasks) && (!is_calendar)) {
+               if ((!is_tasks) && (!is_calendar) && (!is_notes)) {
                        if (!strcmp(oper, "readnew")) {
                                wprintf("<EM>No new messages.</EM>\n");
                        } else if (!strcmp(oper, "readold")) {
@@ -1194,6 +1194,9 @@ void readloop(char *oper)
                        else if (is_tasks) {
                                display_task(WC->msgarr[a]);
                        }
+                       else if (is_notes) {
+                               display_note(WC->msgarr[a]);
+                       }
                        else {
                                read_message(WC->msgarr[a]);
                        }
@@ -1215,10 +1218,6 @@ void readloop(char *oper)
                wprintf("</TABLE>\n");
        }
 
-       if (is_tasks) {
-               wprintf("</UL>\n");
-       }
-
        /* Bump these because although we're thinking in zero base, the user
         * is a drooling idiot and is thinking in one base.
         */
@@ -1227,7 +1226,7 @@ void readloop(char *oper)
 
        /* If we're only looking at one message, do a prev/next thing */
        if (num_displayed == 1) {
-          if ((!is_tasks) && (!is_calendar) && (!is_addressbook) && (!is_singlecard)) {
+          if ((!is_tasks) && (!is_calendar) && (!is_addressbook) && (!is_notes) && (!is_singlecard)) {
 
                wprintf("<CENTER>"
                        "<TABLE BORDER=0 WIDTH=100%% BGCOLOR=\"#DDDDDD\"><TR><TD>"
@@ -1276,7 +1275,7 @@ void readloop(char *oper)
         * messages, then display the selector bar
         */
        if (num_displayed > 1) {
-          if ((!is_tasks) && (!is_calendar) && (!is_addressbook) && (!is_singlecard)) {
+          if ((!is_tasks) && (!is_calendar) && (!is_addressbook) && (!is_notes) && (!is_singlecard)) {
                wprintf("<CENTER>"
                        "<TABLE BORDER=0 WIDTH=100%% BGCOLOR=\"#DDDDDD\"><TR><TD>"
                        "Reading #%d-%d of %d messages.</TD>\n"
@@ -1331,9 +1330,7 @@ void readloop(char *oper)
 
 DONE:
        if (is_tasks) {
-               wprintf("<A HREF=\"/display_edit_task?msgnum=0\">"
-                       "Add new task</A>\n"
-               );
+               do_tasks_view();        /* Render the task list */
        }
 
        if (is_calendar) {
@@ -1517,7 +1514,7 @@ void display_enter(void)
        struct wc_attachment *att;
 
        if (strlen(bstr("force_room")) > 0) {
-               gotoroom(bstr("force_room"), 0);
+               gotoroom(bstr("force_room"));
        }
 
        /* Are we perhaps in an address book view?  If so, then an "enter
@@ -1528,6 +1525,7 @@ void display_enter(void)
                return;
        }
 
+#ifdef WEBCIT_WITH_CALENDAR_SERVICE
        /* Are we perhaps in a calendar view?  If so, then an "enter
         * message" command really means "add new calendar item."
         */
@@ -1543,9 +1541,10 @@ void display_enter(void)
                display_edit_task();
                return;
        }
+#endif
 
        /* Otherwise proceed normally */
-       output_headers(1);
+       output_headers(1, 1, 1, 0, 0, 0, 0);
        sprintf(buf, "ENT0 0|%s|0|0", bstr("recp"));
        serv_puts(buf);
        serv_gets(buf);
@@ -1553,7 +1552,7 @@ void display_enter(void)
        if (!strncmp(buf, "570", 3)) {
                if (strlen(bstr("recp")) > 0) {
                        svprintf("RECPERROR", WCS_STRING,
-                               "<SPAN CLASS=\"errormsg\">%s</SPAN><BR>\n",
+                               "<SPAN CLASS=\"errormsg\">%s</SPAN><br />\n",
                                &buf[4]
                        );
                }
@@ -1561,7 +1560,7 @@ void display_enter(void)
                goto DONE;
        }
        if (buf[0] != '2') {
-               wprintf("<EM>%s</EM><BR>\n", &buf[4]);
+               wprintf("<EM>%s</EM><br />\n", &buf[4]);
                goto DONE;
        }
 
@@ -1589,21 +1588,28 @@ void display_enter(void)
                bstr("recp"));
        wprintf("<INPUT TYPE=\"hidden\" NAME=\"postseq\" VALUE=\"%ld\">\n",
                now);
+
+       wprintf("<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>\n");
+       wprintf("<TR><TD ALIGN=LEFT>");
        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>"
+       wprintf("\" SIZE=40 MAXLENGTH=70>"
                "&nbsp;"
        );
+       wprintf("</TD>");
 
+       wprintf("<TD ALIGN=RIGHT>");
        wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Save message\">"
-               "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><BR>\n");
+               "&nbsp;"
+               "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><br />\n");
+       wprintf("</TD></TR></TABLE>\n");
 
-       wprintf("<SCRIPT language=\"JavaScript\" type=\"text/javascript\" "
-               "src=\"static/richtext_compressed.js\"></SCRIPT>\n"
-               "<SCRIPT language=\"JavaScript\" type=\"text/javascript\">\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"
@@ -1611,8 +1617,8 @@ void display_enter(void)
                "  \n"
                "initRTE(\"static/\", \"static/\", \"\"); \n"
                "</script> \n"
-               "<noscript>JAVASCRIPT MUST BE ENABLED.</noscript> \n"
-               "<SCRIPT language=\"javascript\" type=\"text/javascript\"> \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"
@@ -1624,7 +1630,7 @@ void display_enter(void)
        wprintf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=25 COLS=80 "
                "WIDTH=80>");
        escputs(bstr("msgtext"));
-       wprintf("</TEXTAREA><BR>\n");
+       wprintf("</TEXTAREA><br />\n");
  */
 
        /* Enumerate any attachments which are already in place... */
@@ -1632,7 +1638,7 @@ void display_enter(void)
                wprintf("<IMG SRC=\"/static/attachment.gif\" "
                        "BORDER=0 ALIGN=MIDDLE> Attachment: ");
                escputs(att->filename);
-               wprintf(" (%s, %d bytes)<BR>\n",
+               wprintf(" (%s, %d bytes)<br />\n",
                        att->content_type, att->length);
        }
 
@@ -1661,12 +1667,12 @@ void delete_msg(void)
 
        msgid = atol(bstr("msgid"));
 
-       output_headers(1);
+       output_headers(1, 1, 1, 0, 0, 0, 0);
 
        sprintf(buf, "DELE %ld", msgid);
        serv_puts(buf);
        serv_gets(buf);
-       wprintf("<EM>%s</EM><BR>\n", &buf[4]);
+       wprintf("<EM>%s</EM><br />\n", &buf[4]);
 
        wDumpContent(1);
 }
@@ -1685,7 +1691,7 @@ void confirm_move_msg(void)
 
        msgid = atol(bstr("msgid"));
 
-       output_headers(1);
+       output_headers(1, 1, 1, 0, 0, 0, 0);
 
        wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>");
        wprintf("<FONT SIZE=+1 COLOR=\"#FFFFFF\"");
@@ -1694,7 +1700,7 @@ void confirm_move_msg(void)
 
        wprintf("<CENTER>");
 
-       wprintf("Move this message to:<BR>\n");
+       wprintf("Move this message to:<br />\n");
 
        wprintf("<FORM METHOD=\"POST\" ACTION=\"/move_msg\">\n");
        wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n",
@@ -1713,9 +1719,10 @@ void confirm_move_msg(void)
                }
        }
        wprintf("</SELECT>\n");
-       wprintf("<BR>\n");
+       wprintf("<br />\n");
 
        wprintf("<INPUT TYPE=\"submit\" NAME=\"yesno\" VALUE=\"Move\">");
+       wprintf("&nbsp;");
        wprintf("<INPUT TYPE=\"submit\" NAME=\"yesno\" VALUE=\"Cancel\">");
        wprintf("</FORM></CENTER>\n");
 
@@ -1732,22 +1739,51 @@ void move_msg(void)
 
        msgid = atol(bstr("msgid"));
 
-       output_headers(1);
+       output_headers(1, 1, 1, 0, 0, 0, 0);
 
        if (!strcasecmp(bstr("yesno"), "Move")) {
                sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
                serv_puts(buf);
                serv_gets(buf);
-               wprintf("<EM>%s</EM><BR>\n", &buf[4]);
+               wprintf("<EM>%s</EM><br />\n", &buf[4]);
        } else {
-               wprintf("<EM>Message not moved.</EM><BR>\n");
+               wprintf("<EM>Message not moved.</EM><br />\n");
        }
 
        wDumpContent(1);
 }
 
+/*
+ * This gets called when a user selects Reply/Move/Del etc. on *one* message.
+ */
+void do_stuff_to_one_msg(void) {
+       char *msg_oper;
+
+       msg_oper = bstr("msg_oper");
+
+       if (!strcasecmp(msg_oper, "Delete")) {
+               delete_msg();   /* It's already been confirmed using JS */
+               return;
+       }
+       if (!strcasecmp(msg_oper, "Move")) {
+               confirm_move_msg();
+               return;
+       }
+       if (!strcasecmp(msg_oper, "Reply")) {
+               display_enter();        /* recp and subject already set */
+               return;
+       }
+
+       /* should never get here.  FIXME: display an error */
+
+}
 
 
+/*
+ * This gets called when a user selects multiple messages in a summary
+ * list and then clicks to perform a transformation of some sort on them
+ * (such as deleting them).
+ */
 void do_stuff_to_msgs(void) {
        char buf[SIZ];
        char sc[SIZ];