]> code.citadel.org Git - citadel.git/blobdiff - webcit/messages.c
* Enhance the older/newer logic. It's still not quite right.
[citadel.git] / webcit / messages.c
index 3e00496567e69794273886aa16fa709e0f71edf7..b793f308c291554efe48c8ab65c66d9f485c751e 100644 (file)
@@ -63,7 +63,7 @@ int load_message(message_summary *Msg,
 
        /* begin everythingamundo table */
        HdrToken = NewStrBuf();
-       while ((StrBuf_ServGetln(Buf)>=0) && !Done) {
+       while (!Done && StrBuf_ServGetln(Buf)>=0) {
                if ( (StrLength(Buf)==3) && 
                    !strcmp(ChrPtr(Buf), "000")) 
                {
@@ -751,7 +751,7 @@ typedef struct _RoomRenderer{
 /*
  * command loop for reading messages
  *
- * Set oper to "readnew" or "readold" or "readfwd" or "headers" or "readgt"
+ * Set oper to "readnew" or "readold" or "readfwd" or "headers" or "readgt" or "readlt" or "do_search"
  */
 void readloop(long oper)
 {
@@ -769,8 +769,18 @@ void readloop(long oper)
        SharedMessageStatus Stat;
        void *ViewSpecific;
 
-       if (havebstr("is_summary") && (1 == (ibstr("is_summary"))))
+       if (havebstr("is_summary") && (1 == (ibstr("is_summary")))) {
                WCC->wc_view = VIEW_MAILBOX;
+       }
+
+       if (havebstr("is_ajax") && (1 == (ibstr("is_ajax")))) {
+               WCC->is_ajax = 1;
+       }
+
+       if ((oper == do_search) && (WCC->wc_view == VIEW_WIKI)) {
+               display_wiki_pagelist();
+               return;
+       }
 
        memset(&Stat, 0, sizeof(SharedMessageStatus));
        Stat.maxload = 10000;
@@ -781,8 +791,9 @@ void readloop(long oper)
                WCC->wc_view = VIEW_BBS;
                GetHash(ReadLoopHandler, IKEY(WCC->wc_view), &vViewMsg);
        }
-       if (vViewMsg == NULL)
-               return;///TODO: print message
+       if (vViewMsg == NULL) {
+               return;                 // TODO: print message
+       }
 
        ViewMsg = (RoomRenderer*) vViewMsg;
        if (!WCC->is_ajax) {
@@ -819,7 +830,7 @@ void readloop(long oper)
        if (Stat.sortit) {
                CompareFunc SortIt;
                memset(&SubTP, 0, sizeof(WCTemplputParams));
-               SubTP.Filter.ContextType = CTX_NONE;
+               SubTP.Filter.ContextType = CTX_MAILSUM;
                SubTP.Context = NULL;
                SortIt =  RetrieveSort(&SubTP, NULL, 0,
                                       HKEY("date"), Stat.defaultsortorder);
@@ -1136,7 +1147,7 @@ void post_message(void)
                Recp = sbstr("recp");
                Cc = sbstr("cc");
                Bcc = sbstr("bcc");
-               Wikipage = sbstr("wikipage");
+               Wikipage = sbstr("page");
                my_email_addr = sbstr("my_email_addr");
                
                CmdBuf = NewStrBufPlain(NULL, 
@@ -1223,8 +1234,8 @@ void post_message(void)
        /*
         *  If we were editing a page in a wiki room, go to that page now.
         */
-       else if (havebstr("wikipage")) {
-               snprintf(buf, sizeof buf, "wiki?page=%s", bstr("wikipage"));
+       else if (havebstr("page")) {
+               snprintf(buf, sizeof buf, "wiki?page=%s", bstr("page"));
                http_redirect(buf);
        }
        /*
@@ -1325,7 +1336,7 @@ void display_enter(void)
                Recp = sbstr("recp");
                Cc = sbstr("cc");
                Bcc = sbstr("bcc");
-               Wikipage = sbstr("wikipage");
+               Wikipage = sbstr("page");
                
                CmdBuf = NewStrBufPlain(NULL, 
                                        sizeof (CMD) + 
@@ -1662,6 +1673,7 @@ void h_readfwd(void) { readloop(readfwd);}
 void h_headers(void) { readloop(headers);}
 void h_do_search(void) { readloop(do_search);}
 void h_readgt(void) { readloop(readgt);}
+void h_readlt(void) { readloop(readlt);}
 
 void jsonMessageListHdr(void) 
 {
@@ -1737,6 +1749,7 @@ InitModule_MSG
        WebcitAddUrlHandler(HKEY("readfwd"), "", 0, h_readfwd, NEED_URL);
        WebcitAddUrlHandler(HKEY("headers"), "", 0, h_headers, NEED_URL);
        WebcitAddUrlHandler(HKEY("readgt"), "", 0, h_readgt, NEED_URL);
+       WebcitAddUrlHandler(HKEY("readlt"), "", 0, h_readlt, NEED_URL);
        WebcitAddUrlHandler(HKEY("do_search"), "", 0, h_do_search, 0);
        WebcitAddUrlHandler(HKEY("display_enter"), "", 0, display_enter, 0);
        WebcitAddUrlHandler(HKEY("post"), "", 0, post_message, 0);