]> code.citadel.org Git - citadel.git/blobdiff - webcit/messages.c
Big change to calendar view functions. We now declare
[citadel.git] / webcit / messages.c
index 360be933d45a1266973369940d13d703a683331e..ce6a3dc795f7395ca06f9469569f0343a5f367f1 100644 (file)
@@ -1071,6 +1071,8 @@ void read_message(long msgnum, int printable_view, char *section) {
 
         /** start msg buttons */
 
+       char Urlsep = '?';
+
         if (!printable_view) {
                 wprintf("<p id=\"msg%ld\" class=\"msgbuttons\" >\n",msgnum);
 
@@ -1078,16 +1080,18 @@ void read_message(long msgnum, int printable_view, char *section) {
                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("%creplyquote=%ld", Urlsep, msgnum);
+                               Urlsep = '&';
                        }
-                       wprintf("?recp=");
+                       wprintf("%crecp=", Urlsep);
+                       Urlsep = '&';
                        urlescputs(reply_to);
                        if (!IsEmptyStr(m_subject)) {
-                               wprintf("?subject=");
+                               wprintf("%csubject=", Urlsep);
                                if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%%20");
                                urlescputs(m_subject);
                        }
-                       wprintf("?references=");
+                       wprintf("%creferences=", Urlsep);
                        if (!IsEmptyStr(reply_references)) {
                                urlescputs(reply_references);
                                urlescputs("|");
@@ -1101,14 +1105,14 @@ void read_message(long msgnum, int printable_view, char *section) {
                        if (!WC->is_mailbox) {
                                wprintf("<a href=\"display_enter");
                                wprintf("?replyquote=%ld", msgnum);
-                               wprintf("?recp=");
+                               wprintf("&recp=");
                                urlescputs(reply_to);
                                if (!IsEmptyStr(m_subject)) {
-                                       wprintf("?subject=");
+                                       wprintf("&subject=");
                                        if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%%20");
                                        urlescputs(m_subject);
                                }
-                               wprintf("?references=");
+                               wprintf("&references=");
                                if (!IsEmptyStr(reply_references)) {
                                        urlescputs(reply_references);
                                        urlescputs("|");
@@ -1122,16 +1126,16 @@ void read_message(long msgnum, int printable_view, char *section) {
                if (WC->wc_view == VIEW_MAILBOX) {
                        wprintf("<a href=\"display_enter");
                        wprintf("?replyquote=%ld", msgnum);
-                       wprintf("?recp=");
+                       wprintf("&recp=");
                        urlescputs(reply_to);
-                       wprintf("?cc=");
+                       wprintf("&cc=");
                        urlescputs(reply_all);
                        if (!IsEmptyStr(m_subject)) {
-                               wprintf("?subject=");
+                               wprintf("&subject=");
                                if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%%20");
                                urlescputs(m_subject);
                        }
-                       wprintf("?references=");
+                       wprintf("&references=");
                        if (!IsEmptyStr(reply_references)) {
                                urlescputs(reply_references);
                                urlescputs("|");
@@ -1142,7 +1146,7 @@ void read_message(long msgnum, int printable_view, char *section) {
 
                /* Forward */
                if (WC->wc_view == VIEW_MAILBOX) {
-                       wprintf("<a href=\"display_enter?fwdquote=%ld?subject=", msgnum);
+                       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"));
@@ -1301,7 +1305,7 @@ void read_message(long msgnum, int printable_view, char *section) {
 
        /* HTML is fun, but we've got to strip it first */
        else if (!strcasecmp(mime_content_type, "text/html")) {
-               output_html(mime_charset, (WC->wc_view == VIEW_WIKI ? 1 : 0));
+               output_html(mime_charset, (WC->wc_view == VIEW_WIKI ? 1 : 0), msgnum);
        }
 
        /* Unknown weirdness */
@@ -1343,7 +1347,7 @@ ENDBODY:  /* If there are attached submessages, display them now... */
                                || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))
                                || (WC->wc_view == VIEW_ADDRESSBOOK)
                        ) {
-                               wprintf("<a href=\"edit_vcard?msgnum=%ld?partnum=%s\">",
+                               wprintf("<a href=\"edit_vcard?msgnum=%ld&partnum=%s\">",
                                        msgnum, vcard_partnum);
                                wprintf("[%s]</a>", _("edit"));
                        }
@@ -1691,8 +1695,8 @@ void pullquote_message(long msgnum, int forward_attachments, int include_headers
                while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
                        int len;
                        len = strlen(buf);
-                       if (buf[len-1] == '\n') buf[--len] = 0;
-                       if (buf[len-1] == '\r') buf[--len] = 0;
+                       if ((len > 0) && (buf[len-1] == '\n')) buf[--len] = 0;
+                       if ((len > 0) && (buf[len-1] == '\r')) buf[--len] = 0;
 
 #ifdef HAVE_ICONV
                        if (ic != (iconv_t)(-1) ) {
@@ -1814,7 +1818,7 @@ void display_summarized(int num) {
        wprintf("<tr id=\"m%ld\" style=\"font-weight:%s;\" "
                "onMouseDown=\"CtdlMoveMsgMouseDown(event,%ld)\">",
                WC->summ[num].msgnum,
-               (WC->summ[num].is_new ? "bold" : "normal"),
+               ((WC->summ[num].is_new) ? "bold" : "normal"),
                WC->summ[num].msgnum
        );
 
@@ -1908,7 +1912,7 @@ void display_addressbook(long msgnum, char alpha) {
                                || (WC->wc_view == VIEW_ADDRESSBOOK)
                        ) {
                                wprintf("<a href=\"edit_vcard?"
-                                       "msgnum=%ld?partnum=%s\">",
+                                       "msgnum=%ld&partnum=%s\">",
                                        msgnum, vcard_partnum);
                                wprintf("[%s]</a>", _("edit"));
                        }
@@ -2114,7 +2118,7 @@ void do_addrbook_view(struct addrbookent *addrbook, int num_ab) {
        
                wprintf("<td>");
 
-               wprintf("<a href=\"readfwd?startmsg=%ld&is_singlecard=1",
+               wprintf("<a href=\"readfwd?startmsg=%ld?is_singlecard=1",
                        addrbook[i].ab_msgnum);
                wprintf("?maxmsgs=1?is_summary=0?alpha=%s\">", bstr("alpha"));
                vcard_n_prettyize(addrbook[i].ab_name);
@@ -2123,10 +2127,18 @@ void do_addrbook_view(struct addrbookent *addrbook, int num_ab) {
                ++displayed;
        }
 
+       /* Placeholders for empty columns at end */
+       if ((num_ab % 4) != 0) {
+               for (i=0; i<(4-(num_ab % 4)); ++i) {
+                       wprintf("<td>&nbsp;</td>");
+               }
+       }
+
        wprintf("</tr></table>\n");
        end_tab((num_pages-1), num_pages);
 
-       begin_tab(num_pages, num_pages);        /* There are no submit buttons so this is empty */
+       begin_tab(num_pages, num_pages);
+       /* FIXME there ought to be something here */
        end_tab(num_pages, num_pages);
 
        for (i=0; i<num_pages; ++i) {
@@ -2433,6 +2445,7 @@ void readloop(char *oper)
        int is_addressbook = 0;
        int is_singlecard = 0;
        int is_calendar = 0;
+       struct calview calv;
        int is_tasks = 0;
        int is_notes = 0;
        int is_bbview = 0;
@@ -2449,7 +2462,7 @@ void readloop(char *oper)
        struct wcsession *WCC = WC;     /* This is done to make it run faster; WC is a function */
 
        if (WCC->wc_view == VIEW_WIKI) {
-               sprintf(buf, "wiki?room=%s?page=home", WCC->wc_roomname);
+               sprintf(buf, "wiki?room=%s&page=home", WCC->wc_roomname);
                http_redirect(buf);
                return;
        }
@@ -2555,6 +2568,7 @@ void readloop(char *oper)
                is_calendar = 1;
                strcpy(cmd, "MSGS ALL|||1");
                maxmsgs = 32767;
+               parse_calendar_view_request(&calv);
        }
        if (WCC->wc_default_view == VIEW_TASKS) {               /**< tasks */
                is_tasks = 1;
@@ -2699,9 +2713,9 @@ void readloop(char *oper)
                                if (lo < 1) lo = 1;
                                wprintf("<option %s value="
                                        "\"%s"
-                                       "?startmsg=%ld"
-                                       "?maxmsgs=%d"
-                                       "?is_summary=%d\">"
+                                       "&startmsg=%ld"
+                                       "&maxmsgs=%d"
+                                       "&is_summary=%d\">"
                                        "%d-%d</option> \n",
                                        ((WCC->msgarr[lo-1] == startmsg) ? "selected" : ""),
                                        oper,
@@ -2718,9 +2732,9 @@ void readloop(char *oper)
                                if (hi > nummsgs) hi = nummsgs;
                                wprintf("<option %s value="
                                        "\"%s"
-                                       "?startmsg=%ld"
-                                       "?maxmsgs=%d"
-                                       "?is_summary=%d\">"
+                                       "&startmsg=%ld"
+                                       "&maxmsgs=%d"
+                                       "&is_summary=%d\">"
                                        "%d-%d</option> \n",
                                        ((WCC->msgarr[b] == startmsg) ? "selected" : ""),
                                        oper,
@@ -2732,7 +2746,7 @@ void readloop(char *oper)
                }
 
                wprintf("<option value=\"%s?startmsg=%ld"
-                       "?maxmsgs=9999999?is_summary=%d\">",
+                       "&maxmsgs=9999999&is_summary=%d\">",
                        oper,
                        WCC->msgarr[0], is_summary);
                wprintf(_("All"));
@@ -2779,7 +2793,7 @@ void readloop(char *oper)
                                addrbook[num_ab-1].ab_msgnum = WCC->msgarr[a];
                        }
                        else if (is_calendar) {
-                               display_calendar(WCC->msgarr[a], WCC->summ[a].is_new);
+                               load_calendar_item(WCC->msgarr[a], WCC->summ[a].is_new, &calv);
                        }
                        else if (is_tasks) {
                                display_task(WCC->msgarr[a], WCC->summ[a].is_new);
@@ -2866,9 +2880,9 @@ void readloop(char *oper)
                                if (lo < 1) lo = 1;
                                wprintf("<option %s value="
                                        "\"%s"
-                                       "?startmsg=%ld"
-                                       "?maxmsgs=%d"
-                                       "?is_summary=%d\">"
+                                       "&startmsg=%ld"
+                                       "&maxmsgs=%d"
+                                       "&is_summary=%d\">"
                                        "%d-%d</option> \n",
                                        ((WCC->msgarr[lo-1] == startmsg) ? "selected" : ""),
                                        oper,
@@ -2885,9 +2899,9 @@ void readloop(char *oper)
                                if (hi > nummsgs) hi = nummsgs;
                                wprintf("<option %s value="
                                        "\"%s"
-                                       "?startmsg=%ld"
-                                       "?maxmsgs=%d"
-                                       "?is_summary=%d\">"
+                                       "&startmsg=%ld"
+                                       "&maxmsgs=%d"
+                                       "&is_summary=%d\">"
                                        "%d-%d</option> \n",
                                        ((WCC->msgarr[b] == startmsg) ? "selected" : ""),
                                        oper,
@@ -2898,8 +2912,8 @@ void readloop(char *oper)
                        }
                }
 
-               wprintf("<option value=\"%s?startmsg=%ld"
-                       "?maxmsgs=9999999?is_summary=%d\">",
+               wprintf("<option value=\"%s&startmsg=%ld"
+                       "&maxmsgs=9999999&is_summary=%d\">",
                        oper,
                        WCC->msgarr[0], is_summary);
                wprintf(_("All"));
@@ -2909,7 +2923,7 @@ void readloop(char *oper)
 
                /** forward/reverse */
                wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
-                       "OnChange=\"location.href='%s?sortby=forward'\"",  
+                       "OnChange=\"location.href='%s&sortby=forward'\"",  
                        (bbs_reverse ? "" : "checked"),
                        oper
                );
@@ -2917,7 +2931,7 @@ void readloop(char *oper)
                wprintf(_("oldest to newest"));
                wprintf("&nbsp;&nbsp;&nbsp;&nbsp;");
                wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
-                       "OnChange=\"location.href='%s?sortby=reverse'\"", 
+                       "OnChange=\"location.href='%s&sortby=reverse'\"", 
                        (bbs_reverse ? "checked" : ""),
                        oper
                );
@@ -2935,7 +2949,7 @@ DONE:
        }
 
        if (is_calendar) {
-               do_calendar_view();     /** Render the calendar */
+               render_calendar_view(&calv);
        }
 
        if (is_addressbook) {
@@ -3191,6 +3205,7 @@ void post_message(void)
                             ChrPtr(Wikipage),
                             ChrPtr(my_email_addr),
                             ChrPtr(references));
+               FreeStrBuf(&references);
 
                lprintf(9, "%s\n", CmdBuf);
                serv_puts(ChrPtr(CmdBuf));
@@ -3630,6 +3645,7 @@ void display_enter(void)
                                } 
                                sig ++;
                        }
+                       FreeStrBuf(&Sig);
                }
        }