* Added new readloop command 'readgt' which will produce messages with numbers greate...
[citadel.git] / webcit / messages.c
index ca9ea892bc6ef8a3fdc5de3de82960b212015ac0..55cf61d406b6377d21cc9264603a018e2bfe9f56 100644 (file)
@@ -609,6 +609,11 @@ int load_msg_ptrs(const char *servcmd, int with_headers)
 
                        Msg->msgnum = StrBufExtractNext_long(Buf, &Ptr, '|');
                        Msg->date = StrBufExtractNext_long(Buf, &Ptr, '|');
+
+                       if ((Msg->msgnum == 0) && (StrLength(Buf) < 32)) {
+                               free(Msg);
+                               continue;
+                       }
                        /* 
                         * as citserver probably gives us messages in forward date sorting
                         * nummsgs should be the same order as the message date.
@@ -622,7 +627,7 @@ int load_msg_ptrs(const char *servcmd, int with_headers)
                                Msg->from = NewStrBufPlain(NULL, StrLength(Buf));
                                StrBufExtract_NextToken(Buf2, Buf, &Ptr, '|');
                                if (StrLength(Buf2) != 0) {
-                                       /** Handle senders with RFC2047 encoding */
+                                       /* Handle senders with RFC2047 encoding */
                                        StrBuf_RFC822_to_Utf8(Msg->from, Buf2, WCC->DefaultCharset, FoundCharset);
                                }
                        
@@ -812,7 +817,7 @@ extern readloop_struct rlid[];
 /*
  * command loop for reading messages
  *
- * Set oper to "readnew" or "readold" or "readfwd" or "headers"
+ * Set oper to "readnew" or "readold" or "readfwd" or "headers" or "readgt"
  */
 void readloop(long oper)
 {
@@ -922,7 +927,6 @@ void readloop(long oper)
                care_for_empty_list = 1;
 
                rlid[oper].cmd(cmd, sizeof(cmd));
-               SetAccessCommand(oper);
 
                if (havebstr("maxmsgs"))
                        maxmsgs = ibstr("maxmsgs");
@@ -1312,10 +1316,9 @@ void post_message(void)
                 * Transfer control of this memory from the upload struct
                 * to the attachment struct.
                 */
-               att->Data = NewStrBufPlain(WCC->upload, WCC->upload_length);
-               free(WCC->upload);
-               WCC->upload_length = 0;
+               att->Data = WCC->upload;
                WCC->upload = NULL;
+               WCC->upload_length = 0;
                display_enter();
                return;
        }
@@ -1345,7 +1348,7 @@ void post_message(void)
                Buf = NewStrBuf();
 
                if (save_to_drafts) {
-                       /** temporarily change to the drafts room */
+                       /* temporarily change to the drafts room */
                        serv_puts("GOTO _DRAFTS_");
                        StrBuf_ServGetln(Buf);
                        if (GetServerStatus(Buf, NULL) != 2) {
@@ -1905,6 +1908,7 @@ void h_readold(void) { readloop(readold);}
 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 jsonMessageListHdr(void) 
 {
@@ -1963,6 +1967,7 @@ InitModule_MSG
        WebcitAddUrlHandler(HKEY("readold"), h_readold, NEED_URL);
        WebcitAddUrlHandler(HKEY("readfwd"), h_readfwd, NEED_URL);
        WebcitAddUrlHandler(HKEY("headers"), h_headers, NEED_URL);
+       WebcitAddUrlHandler(HKEY("readgt"), h_readgt, NEED_URL);
        WebcitAddUrlHandler(HKEY("do_search"), h_do_search, 0);
        WebcitAddUrlHandler(HKEY("display_enter"), display_enter, 0);
        WebcitAddUrlHandler(HKEY("post"), post_message, 0);