From d9f66010689b4b008677c138f077b00e0f5f0be6 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Mon, 25 Oct 2010 16:58:01 +0200 Subject: [PATCH] * Use new MSet-Matcher to retrieve seen state (10% of what we do in big mboxes) --- webcit/messages.c | 53 +++++++++++++++++++++++++++++------------- webcit/messages.h | 6 +++-- webcit/msg_renderers.c | 2 +- 3 files changed, 42 insertions(+), 19 deletions(-) diff --git a/webcit/messages.c b/webcit/messages.c index feb665dfa..d62f69bdf 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -647,17 +647,40 @@ int load_msg_ptrs(const char *servcmd, - - -void load_seen_flags(void) +/** + * \brief sets FlagToSet for each of ScanMe that appears in MatchMSet + * \param ScanMe List of BasicMsgStruct to be searched it MatchSet + * \param MatchMSet MSet we want to flag + * \param FlagToSet Flag to set on each BasicMsgStruct->Flags if in MSet + */ +void SetFlagsFromMSet(HashList *ScanMe, MSet *MatchMSet, int FlagToSet, int Reverse) { - message_summary *Msg; const char *HashKey; long HKLen; HashPos *at; void *vMsg; + message_summary *Msg; + + at = GetNewHashPos(ScanMe, 0); + while (GetNextHashPos(ScanMe, at, &HKLen, &HashKey, &vMsg)) { + /* Are you a new message, or an old message? */ + Msg = (message_summary*) vMsg; + if (Reverse && IsInMSetList(MatchMSet, Msg->msgnum)) { + Msg->Flags = Msg->Flags | FlagToSet; + } + else if (!Reverse && !IsInMSetList(MatchMSet, Msg->msgnum)) { + Msg->Flags = Msg->Flags | FlagToSet; + } + } + DeleteHashPos(&at); +} + + +void load_seen_flags(void) +{ StrBuf *OldMsg; wcsession *WCC = WC; + MSet *MatchMSet; OldMsg = NewStrBuf(); serv_puts("GTSN"); @@ -669,19 +692,13 @@ void load_seen_flags(void) FreeStrBuf(&OldMsg); return; } - at = GetNewHashPos(WCC->summ, 0); - while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) { - /* Are you a new message, or an old message? */ - Msg = (message_summary*) vMsg; - if (is_msg_in_mset(ChrPtr(OldMsg), Msg->msgnum)) { - Msg->is_new = 0; - } - else { - Msg->is_new = 1; - } + + if (ParseMSet(&MatchMSet, OldMsg)) + { + SetFlagsFromMSet(WCC->summ, MatchMSet, MSGFLAG_READ, 0); } + DeleteMSet(&MatchMSet); FreeStrBuf(&OldMsg); - DeleteHashPos(&at); } extern readloop_struct rlid[]; @@ -829,7 +846,11 @@ void readloop(long oper, eCustomRoomRenderer ForceRenderer) while ( GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) { Msg = (message_summary*) vMsg; if ((Msg->msgnum >= Stat.startmsg) && (Stat.num_displayed <= Stat.maxmsgs)) { - ViewMsg->LoadMsgFromServer(&Stat, &ViewSpecific, Msg, Msg->is_new, i); + ViewMsg->LoadMsgFromServer(&Stat, + &ViewSpecific, + Msg, + (Msg->Flags & MSGFLAG_READ) != 0, + i); } i++; } diff --git a/webcit/messages.h b/webcit/messages.h index eac391a28..a04529db2 100644 --- a/webcit/messages.h +++ b/webcit/messages.h @@ -25,10 +25,13 @@ struct wc_mime_attachment { }; void DestroyMime(void *vMime); +#define MSGFLAG_READ (1<<0) typedef struct _message_summary { - time_t date; /* its creation date */ long msgnum; /* the message number on the citadel server */ + int Flags; + + time_t date; /* its creation date */ int nhdr; int format_type; StrBuf *euid; @@ -52,7 +55,6 @@ typedef struct _message_summary { HashList *AllAttach; - int is_new; int hasattachments; diff --git a/webcit/msg_renderers.c b/webcit/msg_renderers.c index d53d7199a..a7c819ba0 100644 --- a/webcit/msg_renderers.c +++ b/webcit/msg_renderers.c @@ -310,7 +310,7 @@ void tmplput_MAIL_SUMM_INREPLYTO(StrBuf *Target, WCTemplputParams *TP) int Conditional_MAIL_SUMM_UNREAD(StrBuf *Target, WCTemplputParams *TP) { message_summary *Msg = (message_summary*) CTX; - return Msg->is_new != 0; + return (Msg->Flags & MSGFLAG_READ) != 0; } void examine_wefw(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) -- 2.30.2