fix a couple problems with news unread counts, including marking missing articles as read, sr=mscott part of 298737
git-svn-id: svn://10.0.0.236/trunk@217357 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
71b6295893
commit
55b9de05ed
@ -41,7 +41,7 @@
|
||||
interface nsIMsgWindow;
|
||||
interface nsINntpIncomingServer;
|
||||
|
||||
[scriptable, uuid(02699533-7ba8-4e78-94dc-a20374fb2711)]
|
||||
[scriptable, uuid(5731576B-617B-462E-9270-19599510C602)]
|
||||
interface nsIMsgNewsFolder : nsISupports {
|
||||
attribute string groupUsername;
|
||||
attribute string groupPassword;
|
||||
@ -84,4 +84,5 @@ interface nsIMsgNewsFolder : nsISupports {
|
||||
|
||||
void getNextNMessages(in nsIMsgWindow aMsgWindow);
|
||||
void notifyDownloadedLine(in string line, in nsMsgKey key);
|
||||
void notifyFinishedDownloadinghdrs();
|
||||
};
|
||||
|
||||
@ -134,17 +134,73 @@ nsNNTPNewsgroupList::Initialize(nsINntpUrl *runningURL, nsIMsgNewsFolder *newsFo
|
||||
nsresult
|
||||
nsNNTPNewsgroupList::CleanUp()
|
||||
{
|
||||
if (m_newsDB) {
|
||||
// here we make sure that there aren't missing articles in the unread set
|
||||
// So if an article is the unread set, and the known arts set, but isn't in the
|
||||
// db, then we should mark it read in the unread set.
|
||||
if (m_newsDB)
|
||||
{
|
||||
if (m_knownArts.set)
|
||||
{
|
||||
nsCOMPtr <nsIDBFolderInfo> folderInfo;
|
||||
m_newsDB->GetDBFolderInfo(getter_AddRefs(folderInfo));
|
||||
PRInt32 firstKnown = m_knownArts.set->GetFirstMember();
|
||||
PRInt32 lastKnown = m_knownArts.set->GetLastMember();
|
||||
if (folderInfo)
|
||||
{
|
||||
PRUint32 lastMissingCheck;
|
||||
folderInfo->GetUint32Property("lastMissingCheck", 0, &lastMissingCheck);
|
||||
if (lastMissingCheck)
|
||||
firstKnown = lastMissingCheck + 1;
|
||||
}
|
||||
PRBool done = firstKnown > lastKnown; // just in case...
|
||||
PRBool foundMissingArticle = PR_FALSE;
|
||||
while (!done)
|
||||
{
|
||||
PRInt32 firstUnreadStart, firstUnreadEnd;
|
||||
m_set->FirstMissingRange(firstKnown, lastKnown, &firstUnreadStart, &firstUnreadEnd);
|
||||
if (firstUnreadStart)
|
||||
{
|
||||
while (firstUnreadStart <= firstUnreadEnd)
|
||||
{
|
||||
PRBool containsKey;
|
||||
m_newsDB->ContainsKey(firstUnreadStart, &containsKey);
|
||||
if (!containsKey)
|
||||
{
|
||||
m_set->Add(firstUnreadStart);
|
||||
foundMissingArticle = PR_TRUE;
|
||||
}
|
||||
firstUnreadStart++;
|
||||
}
|
||||
firstKnown = firstUnreadStart;
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
}
|
||||
if (folderInfo)
|
||||
folderInfo->SetUint32Property("lastMissingCheck", lastKnown);
|
||||
|
||||
if (foundMissingArticle)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsINewsDatabase> db(do_QueryInterface(m_newsDB, &rv));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
db->SetReadSet(m_set);
|
||||
}
|
||||
}
|
||||
m_newsDB->Commit(nsMsgDBCommitType::kSessionCommit);
|
||||
m_newsDB->Close(PR_TRUE);
|
||||
m_newsDB = nsnull;
|
||||
}
|
||||
|
||||
if (m_knownArts.set) {
|
||||
if (m_knownArts.set)
|
||||
{
|
||||
delete m_knownArts.set;
|
||||
m_knownArts.set = nsnull;
|
||||
}
|
||||
|
||||
if (m_newsFolder)
|
||||
m_newsFolder->NotifyFinishedDownloadinghdrs();
|
||||
|
||||
m_newsFolder = nsnull;
|
||||
m_runningURL = nsnull;
|
||||
|
||||
@ -967,10 +1023,6 @@ nsNNTPNewsgroupList::FinishXOVERLINE(int status, int *newstatus)
|
||||
|
||||
if (m_lastProcessedNumber)
|
||||
AddToKnownArticles(m_firstMsgNumber, m_lastProcessedNumber);
|
||||
if (m_newsDB) {
|
||||
m_newsDB->Close(PR_TRUE);
|
||||
m_newsDB = nsnull;
|
||||
}
|
||||
|
||||
k = &m_knownArts;
|
||||
|
||||
|
||||
@ -2510,7 +2510,15 @@ PRInt32 nsNNTPProtocol::ReadArticle(nsIInputStream * inputStream, PRUint32 lengt
|
||||
|
||||
char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData, nsnull, PR_TRUE);
|
||||
if (m_newsFolder && line)
|
||||
m_newsFolder->NotifyDownloadedLine(line, m_key);
|
||||
{
|
||||
const char *unescapedLine = line;
|
||||
// lines beginning with '.' are escaped by nntp server
|
||||
// or is it just '.' on a line by itself?
|
||||
if (line[0] == '.' && line[1] == '.')
|
||||
unescapedLine++;
|
||||
m_newsFolder->NotifyDownloadedLine(unescapedLine, m_key);
|
||||
|
||||
}
|
||||
|
||||
if(pauseForMoreData)
|
||||
{
|
||||
|
||||
@ -793,8 +793,6 @@ nsMsgNewsFolder::UpdateSummaryFromNNTPInfo(PRInt32 oldest, PRInt32 youngest, PRI
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRBool newsrcHasChanged = PR_FALSE;
|
||||
PRInt32 oldUnreadMessages = mNumUnreadMessages;
|
||||
PRInt32 oldTotalMessages = mNumTotalMessages;
|
||||
|
||||
/* First, mark all of the articles now known to be expired as read. */
|
||||
if (oldest > 1)
|
||||
@ -985,8 +983,6 @@ nsMsgNewsFolder::DeleteMessages(nsISupportsArray *messages, nsIMsgWindow *aMsgWi
|
||||
|
||||
NS_IMETHODIMP nsMsgNewsFolder::GetNewMessages(nsIMsgWindow *aMsgWindow, nsIUrlListener *aListener)
|
||||
{
|
||||
ChangeNumPendingTotalMessages(-GetNumPendingTotalMessages());
|
||||
ChangeNumPendingUnread(-GetNumPendingUnread());
|
||||
return GetNewsMessages(aMsgWindow, PR_FALSE, aListener);
|
||||
}
|
||||
|
||||
@ -1805,6 +1801,13 @@ NS_IMETHODIMP nsMsgNewsFolder::NotifyDownloadedLine(const char *line, nsMsgKey k
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgNewsFolder::NotifyFinishedDownloadinghdrs()
|
||||
{
|
||||
ChangeNumPendingTotalMessages(-GetNumPendingTotalMessages());
|
||||
ChangeNumPendingUnread(-GetNumPendingUnread());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgNewsFolder::Compact(nsIUrlListener *aListener, nsIMsgWindow *aMsgWindow)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user