* Use new MSet-Matcher to retrieve seen state (10% of what we do in big mboxes)
authorWilfried Goesgens <dothebart@citadel.org>
Mon, 25 Oct 2010 14:58:01 +0000 (16:58 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Mon, 25 Oct 2010 14:58:01 +0000 (16:58 +0200)
webcit/messages.c
webcit/messages.h
webcit/msg_renderers.c

index feb665dfaa0b314104018521e11893ba4cc1b3e1..d62f69bdf648542c8ab55acf1b6b24c8623c2f52 100644 (file)
@@ -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++;
                }
index eac391a2881a3587400705c4ee52121d1f510cfe..a04529db25ddfcd9fc76db44669293053b57eb8c 100644 (file)
@@ -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;
 
 
index d53d7199a4f47fb34df2edd91c86a72bb6aa0102..a7c819ba026a0a70a65e8df7d2bc0725ec187140 100644 (file)
@@ -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)