* 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;
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);
}
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;
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.
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;
}
- 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>");
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;
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);
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);
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%%;\">"
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) {
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);
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;