use the same way to display all banners and services contents
[citadel.git] / webcit / messages.c
index 2635365b21c7a3c98ac5fabcc1ae33d59cd0593a..eed0838855985a4c724a0371027e2114c12f6433 100644 (file)
@@ -254,50 +254,52 @@ void rfc2047encode(char *target, int maxlen, char *source)
  */
 void url(char *buf)
 {
-       int pos, len;
-       int start, end;
+       int len;
+       char *start, *end, *pos;
        char urlbuf[SIZ];
        char outbuf[1024];
-       start = (-1);
-       len = end = strlen(buf);
 
-       for (pos = 0; pos < len; ++pos) {
-               if (!strncasecmp(&buf[pos], "http://", 7))
+       start = NULL;
+       len = strlen(buf);
+       end = buf + len;
+       for (pos = buf; (pos < end) && (start == NULL); ++pos) {
+               if (!strncasecmp(pos, "http://", 7))
                        start = pos;
-               if (!strncasecmp(&buf[pos], "ftp://", 6))
+               if (!strncasecmp(pos, "ftp://", 6))
                        start = pos;
        }
 
-       if (start < 0)
+       if (start == NULL)
                return;
 
-       for (pos = len; pos > start; --pos) {
-               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] == ')')
+       for (pos = buf+len; pos > start; --pos) {
+               if (  (!isprint(*pos))
+                  || (isspace(*pos))
+                  || (*pos == '{')
+                  || (*pos == '}')
+                  || (*pos == '|')
+                  || (*pos == '\\')
+                  || (*pos == '^')
+                  || (*pos == '[')
+                  || (*pos == ']')
+                  || (*pos == '`')
+                  || (*pos == '<')
+                  || (*pos == '>')
+                  || (*pos == '(')
+                  || (*pos == ')')
                ) {
                        end = pos;
                }
        }
 
-       strncpy(urlbuf, &buf[start], end - start);
-       urlbuf[end - start] = 0;
+       strncpy(urlbuf, start, end - start);
+       urlbuf[end - start] = '\0';
 
-       strncpy(outbuf, buf, start);
-       sprintf(&outbuf[start], "%ca href=%c%s%c TARGET=%c%s%c%c%s%c/A%c",
+       if (start != buf)
+               strncpy(outbuf, buf, start - buf );
+       sprintf(&outbuf[start-buf], "%ca href=%c%s%c TARGET=%c%s%c%c%s%c/A%c",
                LB, QU, urlbuf, QU, QU, TARGET, QU, RB, urlbuf, LB, RB);
-       strcat(outbuf, &buf[end]);
+       strcat(outbuf, end);
        if ( strlen(outbuf) < 250 )
                strcpy(buf, outbuf);
 }
@@ -720,99 +722,9 @@ void read_message(long msgnum, int printable_view, char *section) {
                 wprintf("onMouseOut=document.getElementById(\"msg%ld\").style.visibility=\"hidden\" >", msgnum);
         }
 
-        /** start msg buttons */
-
-        if (!printable_view) {
-                wprintf("<p id=\"msg%ld\" class=\"msgbuttons\" >\n",msgnum);
-
-               /** Reply */
-               if ( (WC->wc_view == VIEW_MAILBOX) || (WC->wc_view == VIEW_BBS) ) {
-                       wprintf("<a href=\"display_enter");
-                       if (WC->is_mailbox) {
-                               wprintf("?replyquote=%ld", msgnum);
-                       }
-                       wprintf("?recp=");
-                       urlescputs(reply_to);
-                       if (!IsEmptyStr(m_subject)) {
-                               wprintf("?subject=");
-                               if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
-                               urlescputs(m_subject);
-                       }
-                       wprintf("\"><span>[</span>%s<span>]</span></a> ", _("Reply"));
-               }
-
-               /** ReplyQuoted */
-               if ( (WC->wc_view == VIEW_MAILBOX) || (WC->wc_view == VIEW_BBS) ) {
-                       if (!WC->is_mailbox) {
-                               wprintf("<a href=\"display_enter");
-                               wprintf("?replyquote=%ld", msgnum);
-                               wprintf("?recp=");
-                               urlescputs(reply_to);
-                               if (!IsEmptyStr(m_subject)) {
-                                       wprintf("?subject=");
-                                       if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
-                                       urlescputs(m_subject);
-                               }
-                               wprintf("\"><span>[</span>%s<span>]</span></a> ", _("ReplyQuoted"));
-                       }
-               }
-
-               /** ReplyAll */
-               if (WC->wc_view == VIEW_MAILBOX) {
-                       wprintf("<a href=\"display_enter");
-                       wprintf("?replyquote=%ld", msgnum);
-                       wprintf("?recp=");
-                       urlescputs(reply_to);
-                       wprintf("?cc=");
-                       urlescputs(reply_all);
-                       if (!IsEmptyStr(m_subject)) {
-                               wprintf("?subject=");
-                               if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
-                               urlescputs(m_subject);
-                       }
-                       wprintf("\"><span>[</span>%s<span>]</span></a> ", _("ReplyAll"));
-               }
-
-               /** Forward */
-               if (WC->wc_view == VIEW_MAILBOX) {
-                       wprintf("<a href=\"display_enter?fwdquote=%ld?subject=", msgnum);
-                       if (strncasecmp(m_subject, "Fwd:", 4)) wprintf("Fwd:%20");
-                       urlescputs(m_subject);
-                       wprintf("\"><span>[</span>%s<span>]</span></a> ", _("Forward"));
-               }
-
-               /** 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) || (WC->room_flags2 & QR2_COLLABDEL) ) {
-                       /** Move */
-                       wprintf("<a href=\"confirm_move_msg?msgid=%ld\"><span>[</span>%s<span>]</span></a> ",
-                               msgnum, _("Move"));
-       
-                       /** Delete */
-                       wprintf("<a href=\"delete_msg?msgid=%ld\" "
-                               "onClick=\"return confirm('%s');\">"
-                               "<span>[</span>%s<span>]</span> "
-                               "</a> ", msgnum, _("Delete this message?"), _("Delete")
-                       );
-               }
-
-               /** Headers */
-               wprintf("<a href=\"#\" onClick=\"window.open('msgheaders/%ld', 'headers%ld', 'toolbar=no,location=no,directories=no,copyhistory=no,status=yes,scrollbars=yes,resizable=yes,width=600,height=400'); \" >"
-                       "<span>[</span>%s<span>]</span></a>", msgnum, msgnum, _("Headers"));
-
-
-               /** Print */
-               wprintf("<a href=\"#\" onClick=\"window.open('printmsg/%ld', 'print%ld', 'toolbar=no,location=no,directories=no,copyhistory=no,status=yes,scrollbars=yes,resizable=yes,width=600,height=400'); \" >"
-                       "<span>[</span>%s<span>]</span></a>", msgnum, msgnum, _("Print"));
-
-               wprintf("</p>");
-
-       }
-
        /** begin message header table */
        wprintf("<div class=\"message_header\">");
 
-
-
        strcpy(m_subject, "");
        strcpy(m_cc, "");
 
@@ -832,7 +744,6 @@ void read_message(long msgnum, int printable_view, char *section) {
                        format_type = atoi(&buf[5]);
                if (!strncasecmp(buf, "from=", 5)) {
                        strcpy(from, &buf[5]);
-                       wprintf("<br />");
                        wprintf(_("from "));
                        wprintf("<a href=\"showuser?who=");
 #ifdef HAVE_ICONV
@@ -900,7 +811,9 @@ void read_message(long msgnum, int printable_view, char *section) {
                }
                if (!strncasecmp(buf, "time=", 5)) {
                        fmt_date(now, atol(&buf[5]), 0);
+                       wprintf("<span>");
                        wprintf("%s ", now);
+                       wprintf("</span>");
                }
 
                if (!strncasecmp(buf, "part=", 5)) {
@@ -1002,27 +915,116 @@ void read_message(long msgnum, int printable_view, char *section) {
                wprintf("****");
        }
 
-       wprintf("</div>");
-
 #ifdef HAVE_ICONV
        utf8ify_rfc822_string(m_cc);
        utf8ify_rfc822_string(m_subject);
 #endif
+
+        /** start msg buttons */
+
+        if (!printable_view) {
+                wprintf("<p id=\"msg%ld\" class=\"msgbuttons\" >\n",msgnum);
+
+               /** Reply */
+               if ( (WC->wc_view == VIEW_MAILBOX) || (WC->wc_view == VIEW_BBS) ) {
+                       wprintf("<a href=\"display_enter");
+                       if (WC->is_mailbox) {
+                               wprintf("?replyquote=%ld", msgnum);
+                       }
+                       wprintf("?recp=");
+                       urlescputs(reply_to);
+                       if (!IsEmptyStr(m_subject)) {
+                               wprintf("?subject=");
+                               if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
+                               urlescputs(m_subject);
+                       }
+                       wprintf("\"><span>[</span>%s<span>]</span></a> ", _("Reply"));
+               }
+
+               /** ReplyQuoted */
+               if ( (WC->wc_view == VIEW_MAILBOX) || (WC->wc_view == VIEW_BBS) ) {
+                       if (!WC->is_mailbox) {
+                               wprintf("<a href=\"display_enter");
+                               wprintf("?replyquote=%ld", msgnum);
+                               wprintf("?recp=");
+                               urlescputs(reply_to);
+                               if (!IsEmptyStr(m_subject)) {
+                                       wprintf("?subject=");
+                                       if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
+                                       urlescputs(m_subject);
+                               }
+                               wprintf("\"><span>[</span>%s<span>]</span></a> ", _("ReplyQuoted"));
+                       }
+               }
+
+               /** ReplyAll */
+               if (WC->wc_view == VIEW_MAILBOX) {
+                       wprintf("<a href=\"display_enter");
+                       wprintf("?replyquote=%ld", msgnum);
+                       wprintf("?recp=");
+                       urlescputs(reply_to);
+                       wprintf("?cc=");
+                       urlescputs(reply_all);
+                       if (!IsEmptyStr(m_subject)) {
+                               wprintf("?subject=");
+                               if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
+                               urlescputs(m_subject);
+                       }
+                       wprintf("\"><span>[</span>%s<span>]</span></a> ", _("ReplyAll"));
+               }
+
+               /** Forward */
+               if (WC->wc_view == VIEW_MAILBOX) {
+                       wprintf("<a href=\"display_enter?fwdquote=%ld?subject=", msgnum);
+                       if (strncasecmp(m_subject, "Fwd:", 4)) wprintf("Fwd:%20");
+                       urlescputs(m_subject);
+                       wprintf("\"><span>[</span>%s<span>]</span></a> ", _("Forward"));
+               }
+
+               /** 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) || (WC->room_flags2 & QR2_COLLABDEL) ) {
+                       /** Move */
+                       wprintf("<a href=\"confirm_move_msg?msgid=%ld\"><span>[</span>%s<span>]</span></a> ",
+                               msgnum, _("Move"));
+       
+                       /** Delete */
+                       wprintf("<a href=\"delete_msg?msgid=%ld\" "
+                               "onClick=\"return confirm('%s');\">"
+                               "<span>[</span>%s<span>]</span> "
+                               "</a> ", msgnum, _("Delete this message?"), _("Delete")
+                       );
+               }
+
+               /** Headers */
+               wprintf("<a href=\"#\" onClick=\"window.open('msgheaders/%ld', 'headers%ld', 'toolbar=no,location=no,directories=no,copyhistory=no,status=yes,scrollbars=yes,resizable=yes,width=600,height=400'); \" >"
+                       "<span>[</span>%s<span>]</span></a>", msgnum, msgnum, _("Headers"));
+
+
+               /** Print */
+               wprintf("<a href=\"#\" onClick=\"window.open('printmsg/%ld', 'print%ld', 'toolbar=no,location=no,directories=no,copyhistory=no,status=yes,scrollbars=yes,resizable=yes,width=600,height=400'); \" >"
+                       "<span>[</span>%s<span>]</span></a>", msgnum, msgnum, _("Print"));
+
+               wprintf("</p>");
+
+       }
+
        if (!IsEmptyStr(m_cc)) {
-               wprintf("<div class=\"message_subject\">");
+               wprintf("<p>");
                wprintf(_("CC:"));
                wprintf(" ");
                escputs(m_cc);
-               wprintf("</div>");
+               wprintf("</p>");
        }
        if (!IsEmptyStr(m_subject)) {
-               wprintf("<div class=\"message_subject\">");
+               wprintf("<p class=\"message_subject\">");
                wprintf(_("Subject:"));
                wprintf(" ");
                escputs(m_subject);
-               wprintf("</div>");
+               wprintf("</p>");
        }
 
+       wprintf("</div>");
+
        /** Begin body */
        wprintf("<div class=\"message_content\">");
 
@@ -1546,7 +1548,7 @@ void pullquote_message(long msgnum, int forward_attachments, int include_headers
                        }
                        wprintf("<tt>");
                        url(buf);
-                       msgescputs(buf);
+                       msgescputs1(buf);
                        wprintf("</tt><br />");
                }
                wprintf("</i><br />");
@@ -2450,6 +2452,103 @@ void readloop(char *oper)
                );
        }
 
+
+       /**
+        * Set the "is_bbview" variable if it appears that we are looking at
+        * a classic bulletin board view.
+        */
+       if ((!is_tasks) && (!is_calendar) && (!is_addressbook)
+             && (!is_notes) && (!is_singlecard) && (!is_summary)) {
+               is_bbview = 1;
+       }
+
+       /**
+        * If we're not currently looking at ALL requested
+        * messages, then display the selector bar
+        */
+       if (is_bbview) {
+               /** begin bbview scroller */
+               wprintf("<form name=\"msgomatic\" class=\"selector_top\" >");
+               wprintf(_("Reading #"), lowest_displayed, highest_displayed);
+
+               wprintf("<select name=\"whichones\" size=\"1\" "
+                       "OnChange=\"location.href=msgomatictop.whichones.options"
+                       "[selectedIndex].value\">\n");
+
+               if (bbs_reverse) {
+                       for (b=nummsgs-1; b>=0; b = b - maxmsgs) {
+                               hi = b + 1;
+                               lo = b - maxmsgs + 2;
+                               if (lo < 1) lo = 1;
+                               wprintf("<option %s value="
+                                       "\"%s"
+                                       "?startmsg=%ld"
+                                       "?maxmsgs=%d"
+                                       "?summary=%d\">"
+                                       "%d-%d</option> \n",
+                                       ((WC->msgarr[lo-1] == startmsg) ? "selected" : ""),
+                                       oper,
+                                       WC->msgarr[lo-1],
+                                       maxmsgs,
+                                       is_summary,
+                                       hi, lo);
+                       }
+               }
+               else {
+                       for (b=0; b<nummsgs; b = b + maxmsgs) {
+                               lo = b + 1;
+                               hi = b + maxmsgs + 1;
+                               if (hi > nummsgs) hi = nummsgs;
+                               wprintf("<option %s value="
+                                       "\"%s"
+                                       "?startmsg=%ld"
+                                       "?maxmsgs=%d"
+                                       "?summary=%d\">"
+                                       "%d-%d</option> \n",
+                                       ((WC->msgarr[b] == startmsg) ? "selected" : ""),
+                                       oper,
+                                       WC->msgarr[lo-1],
+                                       maxmsgs,
+                                       is_summary,
+                                       lo, hi);
+                       }
+               }
+
+               wprintf("<option value=\"%s?startmsg=%ld"
+                       "?maxmsgs=9999999?summary=%d\">",
+                       oper,
+                       WC->msgarr[0], is_summary);
+               wprintf(_("All"));
+               wprintf("</option>");
+               wprintf("</select> ");
+               wprintf(_("of %d messages."), nummsgs);
+
+               /** forward/reverse */
+               wprintf("&nbsp;<select name=\"direction\" size=\"1\" "
+                       "OnChange=\"location.href=msgomatictop.direction.options"
+                       "[selectedIndex].value\">\n"
+               );
+
+               wprintf("<option %s value=\"%s?sortby=forward\">",
+                       (bbs_reverse ? "" : "selected"),
+                       oper
+               );
+               wprintf(_("oldest to newest"));
+               wprintf("</option>\n");
+       
+               wprintf("<option %s value=\"%s?sortby=reverse\">",
+                       (bbs_reverse ? "selected" : ""),
+                       oper
+               );
+               wprintf(_("newest to oldest"));
+               wprintf("</option>\n");
+       
+               wprintf("</select></form>\n");
+               /** end bbview scroller */
+       }
+
+
+
        for (a = 0; a < nummsgs; ++a) {
                if ((WC->msgarr[a] >= startmsg) && (num_displayed < maxmsgs)) {
 
@@ -2490,14 +2589,6 @@ void readloop(char *oper)
                }
        }
 
-       /**
-        * Set the "is_bbview" variable if it appears that we are looking at
-        * a classic bulletin board view.
-        */
-       if ((!is_tasks) && (!is_calendar) && (!is_addressbook)
-             && (!is_notes) && (!is_singlecard) && (!is_summary)) {
-               is_bbview = 1;
-       }
 
        /** Output loop */
        if (displayed_msgs != NULL) {
@@ -2545,7 +2636,7 @@ void readloop(char *oper)
         */
        if (is_bbview) {
                /** begin bbview scroller */
-               wprintf("<form name=\"msgomatic\">");
+               wprintf("<form name=\"msgomatic\" class=\"selector_bottom\" >");
                wprintf(_("Reading #"), lowest_displayed, highest_displayed);
 
                wprintf("<select name=\"whichones\" size=\"1\" "
@@ -2592,12 +2683,11 @@ void readloop(char *oper)
                }
 
                wprintf("<option value=\"%s?startmsg=%ld"
-                       "?maxmsgs=9999999?summary=%d\">"
-                       "ALL"
-                       "</option> ",
+                       "?maxmsgs=9999999?summary=%d\">",
                        oper,
                        WC->msgarr[0], is_summary);
-
+               wprintf(_("All"));
+               wprintf("</option>");
                wprintf("</select> ");
                wprintf(_("of %d messages."), nummsgs);
 
@@ -2607,15 +2697,19 @@ void readloop(char *oper)
                        "[selectedIndex].value\">\n"
                );
 
-               wprintf("<option %s value=\"%s?sortby=forward\">oldest to newest</option>\n",
+               wprintf("<option %s value=\"%s?sortby=forward\">",
                        (bbs_reverse ? "" : "selected"),
                        oper
                );
+               wprintf(_("oldest to newest"));
+               wprintf("</option>\n");
        
-               wprintf("<option %s value=\"%s?sortby=reverse\">newest to oldest</option>\n",
+               wprintf("<option %s value=\"%s?sortby=reverse\">",
                        (bbs_reverse ? "selected" : ""),
                        oper
                );
+               wprintf(_("newest to oldest"));
+               wprintf("</option>\n");
        
                wprintf("</select></form>\n");
                /** end bbview scroller */
@@ -3295,12 +3389,12 @@ void confirm_move_msg(void)
 
        output_headers(1, 1, 2, 0, 0, 0);
        wprintf("<div id=\"banner\">\n");
-       wprintf("<TABLE WIDTH=100%% BORDER=0><TR><TD>");
-       wprintf("<SPAN CLASS=\"titlebar\">");
+       wprintf("<h1>");
        wprintf(_("Confirm move of message"));
-       wprintf("</SPAN>\n");
-       wprintf("</TD></TR></TABLE>\n");
-       wprintf("</div>\n<div id=\"content\">\n");
+       wprintf("</h1>");
+       wprintf("</div>\n");
+
+       wprintf("<div id=\"content\" class=\"service\">\n");
 
        wprintf("<CENTER>");