From: Art Cancro Date: Wed, 29 Jul 2009 03:09:46 +0000 (+0000) Subject: * Modified load_msg_pointers(), gave it the ability to return the lowest and highest... X-Git-Tag: v7.86~950 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=54fe998e164cbe292653f7f6206ad700adfdb18b * Modified load_msg_pointers(), gave it the ability to return the lowest and highest message numbers it retrieved to the caller --- diff --git a/webcit/messages.c b/webcit/messages.c index 59d70ff79..8060e2248 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -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("

"); diff --git a/webcit/messages.h b/webcit/messages.h index e004bd051..29ed7b3b5 100644 --- a/webcit/messages.h +++ b/webcit/messages.h @@ -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); diff --git a/webcit/smtpqueue.c b/webcit/smtpqueue.c index dcc03c7d8..2e74064ec 100644 --- a/webcit/smtpqueue.c +++ b/webcit/smtpqueue.c @@ -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("" diff --git a/webcit/summary.c b/webcit/summary.c index cbc22f654..ae2588da2 100644 --- a/webcit/summary.c +++ b/webcit/summary.c @@ -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); diff --git a/webcit/useredit.c b/webcit/useredit.c index adca6f6c4..1396fdebc 100644 --- a/webcit/useredit.c +++ b/webcit/useredit.c @@ -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;