Mailnews New Management
The folder m_newMsgs array stores the items from the database m_newSet during the time when the database is unloaded.
The folder hasNewMessages is the main item that the UI looks at to set the New decoration on the folder. Method UpdateNewMessages, which only gets called when the database is first opened in Local and Imap folder, also does SetHasNewMessages based on the contents of m_newMsgs. I suspect that hasNewMessages is meant as a way to retrieve whether there are new messages without opening the database. That implies that when the database IS open, it is appropriate to SetHasNewMessages to match the m_newList in the database.
nsMsgDBFolder has this cryptic code and comment:
//GGGG check for new mail here and call SetNewMessages...?? -- ONE OF THE 2 PLACES if(mDatabase) m_newMsgs.Clear();
What I believe the code is doing is, if the database is open, there is no need for m_newMsgs, so clear it to free up memory.
m_saveNewMsgs is "previous set of new msgs, which we might want to run junk controls on. This is in addition to "new" hdrs in the db, which might get cleared because the user clicked away from the folder." That is, the concept of "new" is overloaded to mean both 1) messages that should count as "new" as displayed by the UI, and 2) recent messages that still need processing. Seems to me these concepts ought to be better separated.
The folder attribute numNewMessages (which is the folder object mNumNewBiffMessages) could be replaced perhaps by a pending count of undownloaded messages plus the count of the database m_newList. As far as I can tell, this is mostly used in the folder tray icon. Most (all?) other uses of GetNumNewMessages are associated with maintaining that count, that is are followed by SetNumNewMessages with a delta value.
This code in nsImapMailFolder, called from protocol proxy based on folder information, looks dodgy:
if (m_performingBiff && numNewUnread) { // We must ensure that the server knows that we are performing biff. // Otherwise the stand-alone biff won't fire. nsCOMPtr<nsIMsgIncomingServer> server; if (NS_SUCCEEDED(GetServer(getter_AddRefs(server))) && server) server->SetPerformingBiff(true); SetNumNewMessages(numNewUnread); }
That is, the numNewMessages is set to match an unread count from the folder.