more work on folder cache
git-svn-id: svn://10.0.0.236/trunk@39902 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -83,7 +83,7 @@ interface nsIMsgFolder : nsIFolder {
|
||||
|
||||
attribute unsigned long depth;
|
||||
|
||||
void UpdateSummaryTotals();
|
||||
void UpdateSummaryTotals(in boolean force);
|
||||
void SummaryChanged();
|
||||
long GetNumUnread(in boolean deep);
|
||||
long GetTotalMessages(in boolean deep);
|
||||
@@ -143,7 +143,7 @@ interface nsIMsgFolder : nsIFolder {
|
||||
nsIMessage CreateMessageFromMsgDBHdr(in nsIMsgDBHdr msgDBHdr);
|
||||
void GetNewMessages();
|
||||
|
||||
void WriteToFolderCache(in nsIMsgFolderCacheElement folderCacheElem);
|
||||
void WriteToFolderCache(in nsIMsgFolderCache folderCache);
|
||||
attribute wstring charset;
|
||||
attribute unsigned long BiffState;
|
||||
attribute long NumNewMessages;
|
||||
|
||||
@@ -150,7 +150,7 @@ NS_IMETHODIMP nsMsgImapMailFolder::GetName(PRUnichar** name)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgImapMailFolder::UpdateSummaryTotals()
|
||||
NS_IMETHODIMP nsMsgImapMailFolder::UpdateSummaryTotals(PRBool force)
|
||||
{
|
||||
//We need to read this info from the database
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ NS_IMETHODIMP nsMsgDBFolder::OnKeyChange(nsMsgKey aKeyChanged, PRUint32 aOldFlag
|
||||
{
|
||||
SendFlagNotifications(msgSupports, aOldFlags, aNewFlags);
|
||||
}
|
||||
UpdateSummaryTotals();
|
||||
UpdateSummaryTotals(PR_TRUE);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
@@ -302,7 +302,7 @@ NS_IMETHODIMP nsMsgDBFolder::OnKeyDeleted(nsMsgKey aKeyChanged, PRInt32 aFlags,
|
||||
{
|
||||
NotifyItemDeleted(msgSupports);
|
||||
}
|
||||
UpdateSummaryTotals();
|
||||
UpdateSummaryTotals(PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ NS_IMETHODIMP nsMsgDBFolder::OnKeyAdded(nsMsgKey aKeyChanged, PRInt32 aFlags,
|
||||
{
|
||||
NotifyItemAdded(msgSupports);
|
||||
}
|
||||
// UpdateSummaryTotals();
|
||||
// UpdateSummaryTotals(PR_TRUE);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
@@ -361,7 +361,46 @@ nsresult nsMsgDBFolder::ReadFromFolderCache(nsIMsgFolderCacheElement *element)
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDBFolder::WriteToFolderCache(nsIMsgFolderCacheElement *element)
|
||||
NS_IMETHODIMP nsMsgDBFolder::WriteToFolderCache(nsIMsgFolderCache *folderCache)
|
||||
{
|
||||
nsCOMPtr <nsIEnumerator> aEnumerator;
|
||||
|
||||
nsresult rv = GetSubFolders(getter_AddRefs(aEnumerator));
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
char *uri = nsnull;
|
||||
rv = GetURI(&uri);
|
||||
|
||||
if (folderCache)
|
||||
{
|
||||
nsCOMPtr <nsIMsgFolderCacheElement> cacheElement;
|
||||
rv = folderCache->GetCacheElement(uri, PR_TRUE, getter_AddRefs(cacheElement));
|
||||
if (NS_SUCCEEDED(rv) && cacheElement)
|
||||
rv = WriteToFolderCacheElem(cacheElement);
|
||||
}
|
||||
PR_FREEIF(uri);
|
||||
|
||||
|
||||
nsCOMPtr<nsISupports> aItem;
|
||||
|
||||
rv = aEnumerator->First();
|
||||
while(NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = aEnumerator->CurrentItem(getter_AddRefs(aItem));
|
||||
if (NS_FAILED(rv)) break;
|
||||
nsCOMPtr<nsIMsgFolder> aMsgFolder(do_QueryInterface(aItem, &rv));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
if (folderCache)
|
||||
rv = aMsgFolder->WriteToFolderCache(folderCache);
|
||||
}
|
||||
rv = aEnumerator->Next();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDBFolder::WriteToFolderCacheElem(nsIMsgFolderCacheElement *element)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
||||
@@ -57,7 +57,8 @@ public:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_IMETHOD WriteToFolderCache(nsIMsgFolderCacheElement *element);
|
||||
NS_IMETHOD WriteToFolderCache(nsIMsgFolderCache *folderCache);
|
||||
NS_IMETHOD WriteToFolderCacheElem(nsIMsgFolderCacheElement *element);
|
||||
|
||||
protected:
|
||||
virtual nsresult ReadDBFolderInfo(PRBool force);
|
||||
|
||||
@@ -708,7 +708,7 @@ NS_IMETHODIMP nsMsgFolder::SetDepth(PRUint32 depth)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgFolder::UpdateSummaryTotals()
|
||||
NS_IMETHODIMP nsMsgFolder::UpdateSummaryTotals(PRBool /* force */)
|
||||
{
|
||||
//We don't support this
|
||||
return NS_OK;
|
||||
@@ -716,7 +716,7 @@ NS_IMETHODIMP nsMsgFolder::UpdateSummaryTotals()
|
||||
|
||||
NS_IMETHODIMP nsMsgFolder::SummaryChanged()
|
||||
{
|
||||
UpdateSummaryTotals();
|
||||
UpdateSummaryTotals(PR_FALSE);
|
||||
#ifdef HAVE_MASTER
|
||||
if (mMaster)
|
||||
mMaster->BroadcastFolderChanged(this);
|
||||
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
|
||||
// updates num messages and num unread - should be pure virtual
|
||||
// when I get around to implementing in all subclasses?
|
||||
NS_IMETHOD UpdateSummaryTotals();
|
||||
NS_IMETHOD UpdateSummaryTotals(PRBool force);
|
||||
NS_IMETHOD SummaryChanged();
|
||||
NS_IMETHOD GetNumUnread(PRBool deep, PRInt32 *numUnread); // How many unread messages in this folder.
|
||||
NS_IMETHOD GetTotalMessages(PRBool deep, PRInt32 *totalMessages); // Total number of messages in this folder.
|
||||
|
||||
@@ -100,42 +100,14 @@ nsMsgIncomingServer::PerformBiff()
|
||||
|
||||
NS_IMETHODIMP nsMsgIncomingServer::WriteToFolderCache(nsIMsgFolderCache *folderCache)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (m_rootFolder)
|
||||
{
|
||||
nsCOMPtr <nsIEnumerator> aEnumerator;
|
||||
|
||||
nsresult rv = m_rootFolder->GetSubFolders(getter_AddRefs(aEnumerator));
|
||||
if(NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsISupports> aItem;
|
||||
nsCOMPtr<nsIMsgFolder> trashFolder;
|
||||
|
||||
rv = aEnumerator->First();
|
||||
while(NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = aEnumerator->CurrentItem(getter_AddRefs(aItem));
|
||||
if (NS_FAILED(rv)) break;
|
||||
nsCOMPtr<nsIMsgFolder> aMsgFolder(do_QueryInterface(aItem, &rv));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
char *uri = nsnull;
|
||||
rv = aMsgFolder->GetURI(&uri);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
if (folderCache)
|
||||
{
|
||||
nsCOMPtr <nsIMsgFolderCacheElement> cacheElement;
|
||||
rv = folderCache->GetCacheElement(uri, PR_TRUE, getter_AddRefs(cacheElement));
|
||||
if (NS_SUCCEEDED(rv) && cacheElement)
|
||||
rv = aMsgFolder->WriteToFolderCache(cacheElement);
|
||||
}
|
||||
PR_FREEIF(uri);
|
||||
}
|
||||
rv = aEnumerator->Next();
|
||||
}
|
||||
nsCOMPtr <nsIMsgFolder> msgFolder = do_QueryInterface(m_rootFolder, &rv);
|
||||
if (NS_SUCCEEDED(rv) && msgFolder)
|
||||
rv = msgFolder->WriteToFolderCache(folderCache);
|
||||
}
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
char *
|
||||
|
||||
@@ -364,7 +364,7 @@ NS_IMETHODIMP nsImapMailFolder::GetSubFolders(nsIEnumerator* *result)
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateSummaryTotals();
|
||||
UpdateSummaryTotals(PR_FALSE);
|
||||
// Look for a directory for this mail folder, and recurse into it.
|
||||
// e.g. if the folder is "inbox", look for "inbox.sbd".
|
||||
#if 0
|
||||
@@ -429,7 +429,7 @@ nsresult nsImapMailFolder::GetDatabase()
|
||||
else
|
||||
{
|
||||
//Otherwise we have a valid database so lets extract necessary info.
|
||||
UpdateSummaryTotals();
|
||||
UpdateSummaryTotals(PR_FALSE);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -679,7 +679,7 @@ NS_IMETHODIMP nsImapMailFolder::BuildFolderURL(char **url)
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailFolder::UpdateSummaryTotals()
|
||||
NS_IMETHODIMP nsImapMailFolder::UpdateSummaryTotals(PRBool force)
|
||||
{
|
||||
// could we move this into nsMsgDBFolder, or do we need to deal
|
||||
// with the pending imap counts?
|
||||
@@ -688,7 +688,7 @@ NS_IMETHODIMP nsImapMailFolder::UpdateSummaryTotals()
|
||||
PRInt32 oldUnreadMessages = mNumUnreadMessages;
|
||||
PRInt32 oldTotalMessages = mNumTotalMessages;
|
||||
//We need to read this info from the database
|
||||
ReadDBFolderInfo(PR_TRUE);
|
||||
ReadDBFolderInfo(force);
|
||||
|
||||
// If we asked, but didn't get any, stop asking
|
||||
if (mNumUnreadMessages == -1)
|
||||
|
||||
@@ -112,7 +112,7 @@ public:
|
||||
|
||||
NS_IMETHOD BuildFolderURL(char **url);
|
||||
|
||||
NS_IMETHOD UpdateSummaryTotals() ;
|
||||
NS_IMETHOD UpdateSummaryTotals(PRBool force) ;
|
||||
|
||||
NS_IMETHOD GetExpungedBytesCount(PRUint32 *count);
|
||||
NS_IMETHOD GetDeletable (PRBool *deletable);
|
||||
|
||||
@@ -355,7 +355,7 @@ nsMsgLocalMailFolder::GetSubFolders(nsIEnumerator* *result)
|
||||
SetFlag(newFlags);
|
||||
rv = CreateSubFolders(path);
|
||||
}
|
||||
UpdateSummaryTotals();
|
||||
UpdateSummaryTotals(PR_FALSE);
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
mInitialized = PR_TRUE; // XXX do this on failure too?
|
||||
@@ -433,7 +433,7 @@ nsresult nsMsgLocalMailFolder::GetDatabase()
|
||||
else
|
||||
{
|
||||
//Otherwise we have a valid database so lets extract necessary info.
|
||||
UpdateSummaryTotals();
|
||||
UpdateSummaryTotals(PR_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -835,12 +835,12 @@ nsresult nsMsgLocalMailFolder::GetDBFolderInfoAndDB(nsIDBFolderInfo **folderInf
|
||||
return openErr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::UpdateSummaryTotals()
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::UpdateSummaryTotals(PRBool force)
|
||||
{
|
||||
PRInt32 oldUnreadMessages = mNumUnreadMessages;
|
||||
PRInt32 oldTotalMessages = mNumTotalMessages;
|
||||
//We need to read this info from the database
|
||||
ReadDBFolderInfo(PR_TRUE);
|
||||
ReadDBFolderInfo(force);
|
||||
|
||||
// If we asked, but didn't get any, stop asking
|
||||
if (mNumUnreadMessages == -1)
|
||||
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
|
||||
NS_IMETHOD BuildFolderURL(char **url);
|
||||
|
||||
NS_IMETHOD UpdateSummaryTotals() ;
|
||||
NS_IMETHOD UpdateSummaryTotals(PRBool force) ;
|
||||
|
||||
NS_IMETHOD GetExpungedBytesCount(PRUint32 *count);
|
||||
NS_IMETHOD GetDeletable (PRBool *deletable);
|
||||
|
||||
@@ -557,7 +557,7 @@ nsresult nsMsgNewsFolder::GetDatabase()
|
||||
rv = mDatabase->AddListener(this);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = UpdateSummaryTotals();
|
||||
rv = UpdateSummaryTotals(PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
@@ -1008,7 +1008,7 @@ nsresult nsMsgNewsFolder::GetDBFolderInfoAndDB(nsIDBFolderInfo **folderInfo, ns
|
||||
return openErr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgNewsFolder::UpdateSummaryTotals()
|
||||
NS_IMETHODIMP nsMsgNewsFolder::UpdateSummaryTotals(PRBool force)
|
||||
{
|
||||
#ifdef DEBUG_NEWS
|
||||
printf("nsMsgNewsFolder::UpdateSummaryTotals(%s)\n",mURI);
|
||||
@@ -1017,7 +1017,7 @@ NS_IMETHODIMP nsMsgNewsFolder::UpdateSummaryTotals()
|
||||
PRInt32 oldUnreadMessages = mNumUnreadMessages;
|
||||
PRInt32 oldTotalMessages = mNumTotalMessages;
|
||||
//We need to read this info from the database
|
||||
ReadDBFolderInfo(PR_TRUE);
|
||||
ReadDBFolderInfo(force);
|
||||
|
||||
// If we asked, but didn't get any, stop asking
|
||||
if (mNumUnreadMessages == -1)
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
|
||||
NS_IMETHOD BuildFolderURL(char **url);
|
||||
|
||||
NS_IMETHOD UpdateSummaryTotals() ;
|
||||
NS_IMETHOD UpdateSummaryTotals(PRBool force) ;
|
||||
|
||||
NS_IMETHOD GetExpungedBytesCount(PRUint32 *count);
|
||||
NS_IMETHOD GetDeletable (PRBool *deletable);
|
||||
|
||||
Reference in New Issue
Block a user