* Modified load_msg_pointers(), gave it the ability to return the lowest and highest...
authorArt Cancro <ajc@citadel.org>
Wed, 29 Jul 2009 03:09:46 +0000 (03:09 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 29 Jul 2009 03:09:46 +0000 (03:09 +0000)
webcit/messages.c
webcit/messages.h
webcit/smtpqueue.c
webcit/summary.c
webcit/useredit.c

index 59d70ff79a457fa2e904bff0b0b29251e2440f75..8060e2248a3b0e6b996dd3caef29f5a1eea40672 100644 (file)
@@ -571,7 +571,7 @@ message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSu
  * servcmd:            the citadel command to send to the citserver
  * with_headers:       also include some of the headers with the message numbers (more expensive)
  */
-int load_msg_ptrs(const char *servcmd, int with_headers)
+int load_msg_ptrs(const char *servcmd, int with_headers, long *lowest_found, long *highest_found)
 {
        StrBuf* FoundCharset = NULL;
         wcsession *WCC = WC;
@@ -584,6 +584,9 @@ int load_msg_ptrs(const char *servcmd, int with_headers)
        int skipit;
        const char *Ptr = NULL;
 
+       if (lowest_found) *lowest_found = LONG_MAX;
+       if (highest_found) *highest_found = LONG_MIN;
+
        if (WCC->summ != NULL) {
                DeleteHash(&WCC->summ);
        }
@@ -598,9 +601,7 @@ int load_msg_ptrs(const char *servcmd, int with_headers)
                return (nummsgs);
        }
        Buf2 = NewStrBuf();
-       while (len = StrBuf_ServGetln(Buf),
-              ((len != 3)  ||
-               strcmp(ChrPtr(Buf), "000")!= 0))
+       while (len = StrBuf_ServGetln(Buf), ((len != 3) || strcmp(ChrPtr(Buf), "000")!= 0))
        {
                if (nummsgs < maxload) {
                        skipit = 0;
@@ -611,10 +612,20 @@ int load_msg_ptrs(const char *servcmd, int with_headers)
                        Msg->msgnum = StrBufExtractNext_long(Buf, &Ptr, '|');
                        Msg->date = StrBufExtractNext_long(Buf, &Ptr, '|');
 
+                       if (nummsgs == 0) {
+                               if ((lowest_found) && (Msg->msgnum < *lowest_found)) {
+                                       *lowest_found = Msg->msgnum;
+                               }
+                               if ((highest_found) && (Msg->msgnum > *highest_found)) {
+                                       *highest_found = Msg->msgnum;
+                               }
+                       }
+
                        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.
@@ -854,6 +865,8 @@ void readloop(long oper)
        WCTemplputParams SubTP;
        char *ab_name;
        const StrBuf *Mime;
+       long lowest_found = (-1);
+       long highest_found = (-1);
 
        if (havebstr("is_summary") && (1 == (ibstr("is_summary"))))
                WCC->wc_view = VIEW_MAILBOX;
@@ -939,7 +952,7 @@ void readloop(long oper)
                
        }
 
-       nummsgs = load_msg_ptrs(cmd, with_headers);
+       nummsgs = load_msg_ptrs(cmd, with_headers, &lowest_found, &highest_found);
        if (nummsgs == 0) {
                if (care_for_empty_list) {
                        wprintf("<div class=\"nomsgs\"><br><em>");
index e004bd051999932540ac9abffd682a4c2f1e1407..29ed7b3b5f6428dcea482191541a34341aa0ea36 100644 (file)
@@ -17,26 +17,23 @@ struct wc_mime_attachment {
        StrBuf *ContentType;
        StrBuf *Charset;
        StrBuf *Data;
-       size_t length;                     /* length of the mimeattachment */
+       size_t length;          /* length of the mimeattachment */
        long size_known;
-       long lvalue;               /* if we put a long... */
-       long msgnum;            /**< the message number on the citadel server derived from message_summary */
+       long lvalue;            /* if we put a long... */
+       long msgnum;            /* the message number on the citadel server derived from message_summary */
        const RenderMimeFuncStruct *Renderer;
 };
 void DestroyMime(void *vMime);
 
 
-/*
- * \brief message summary structure. ???
- */
 typedef struct _message_summary {
-       time_t date;        /**< its creation date */
-       long msgnum;            /**< the message number on the citadel server */
+       time_t date;            /* its creation date */
+       long msgnum;            /* the message number on the citadel server */
        int nhdr;
        int format_type;
-       StrBuf *from;           /**< the author */
-       StrBuf *to;             /**< the recipient */
-       StrBuf *subj;           /**< the title / subject */
+       StrBuf *from;           /* the author */
+       StrBuf *to;             /* the recipient */
+       StrBuf *subj;           /* the title / subject */
        StrBuf *reply_inreplyto;
        StrBuf *reply_references;
        StrBuf *reply_to;
@@ -48,17 +45,17 @@ typedef struct _message_summary {
        StrBuf *OtherNode;
        const StrBuf *PartNum;
 
-       HashList *Attachments;  /**< list of Attachments */
+       HashList *Attachments;  /* list of attachments */
        HashList *Submessages;
        HashList *AttachLinks;
 
        HashList *AllAttach;
 
-       int is_new;         /**< is it yet read? */
-       int hasattachments;     /* does it have attachments? */
+       int is_new;
+       int hasattachments;
 
 
-       /** The mime part of the message */
+       /* The mime part of the message */
        wc_mime_attachment *MsgBody;
 } message_summary;
 void DestroyMessageSummary(void *vMsg);
@@ -96,4 +93,4 @@ int load_message(message_summary *Msg,
                 StrBuf **Error);
 
 
-int load_msg_ptrs(const char *servcmd, int with_headers);
+int load_msg_ptrs(const char *servcmd, int with_headers, long *lowest_found, long *highest_found);
index dcc03c7d8c71556cc2fc54ce211954edecb39d82..2e74064ec9f5386c76e8a336f5cb90ed1d7ed196 100644 (file)
@@ -178,7 +178,7 @@ void display_smtpqueue_inner_div(void) {
        FreeStrBuf(&Buf);
        if (!strcasecmp(ChrPtr(WCC->wc_roomname), "__CitadelSMTPspoolout__")) {
 
-               num_msgs = load_msg_ptrs("MSGS ALL", 0);
+               num_msgs = load_msg_ptrs("MSGS ALL", 0, NULL, NULL);
                if (num_msgs > 0) {
                         wprintf("<table class=\"mailbox_summary\" rules=rows "
                                "cellpadding=2 style=\"width:100%%;\">"
index cbc22f6547ed94d28448851dd6b1e567d03b7aba..ae2588da2651a541f7dd5523afe3757bc4c2a874 100644 (file)
@@ -92,7 +92,7 @@ void tasks_section(void) {
                num_msgs = 0;
        }
        else {
-               num_msgs = load_msg_ptrs("MSGS ALL", 0);
+               num_msgs = load_msg_ptrs("MSGS ALL", 0, NULL, NULL);
        }
 
        if (num_msgs > 0) {
@@ -133,7 +133,7 @@ void calendar_section(void) {
                num_msgs = 0;
        }
        else {
-               num_msgs = load_msg_ptrs("MSGS ALL", 0);
+               num_msgs = load_msg_ptrs("MSGS ALL", 0, NULL, NULL);
        }
 
        parse_calendar_view_request(&c);
index adca6f6c40d854fd28fb23a8120ceafc8dc58e16..1396fdebcccc8dae409b69d712a3e8b59e875d8a 100644 (file)
@@ -424,7 +424,7 @@ long locate_user_vcard_in_this_room(message_summary **VCMsg, wc_mime_attachment
 TRYAGAIN:
        Done = 0;
        /* Search for the user's vCard */
-       if (load_msg_ptrs("MSGS ALL||||1", 1) > 0) {
+       if (load_msg_ptrs("MSGS ALL||||1", 1, NULL, NULL) > 0) {
                at = GetNewHashPos(WCC->summ, 0);
                while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
                        Msg = (message_summary*) vMsg;