зеркало из https://github.com/mozilla/pjs.git
fix rename of parent folder when one of the child folders has been opened in the ui, r/sr=mscott 209022
This commit is contained in:
Родитель
d37d9a3e5f
Коммит
70413c6445
|
@ -74,6 +74,7 @@
|
|||
#include "nsIRDFService.h"
|
||||
#include "nsTextFormatter.h"
|
||||
#include "nsCPasswordManager.h"
|
||||
#include "nsMsgDBCID.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
|
@ -89,6 +90,7 @@ static PRTime gtimeOfLastPurgeCheck; //variable to know when to check for pur
|
|||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kCollationFactoryCID, NS_COLLATIONFACTORY_CID);
|
||||
static NS_DEFINE_CID(kCMailDB, NS_MAILDB_CID);
|
||||
|
||||
nsIAtom* nsMsgDBFolder::mFolderLoadedAtom=nsnull;
|
||||
nsIAtom* nsMsgDBFolder::mDeleteOrMoveMsgCompletedAtom=nsnull;
|
||||
|
@ -250,6 +252,13 @@ NS_IMETHODIMP nsMsgDBFolder::ForceDBClosed()
|
|||
mDatabase->ForceClosed();
|
||||
mDatabase = nsnull;
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIMsgDatabase> mailDBFactory;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kCMailDB, nsnull, NS_GET_IID(nsIMsgDatabase), (void **) getter_AddRefs(mailDBFactory));
|
||||
if (NS_SUCCEEDED(rv) && mailDBFactory)
|
||||
mailDBFactory->ForceFolderDBClosed(this);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -3153,13 +3162,16 @@ void nsMsgDBFolder::ChangeNumPendingUnread(PRInt32 delta)
|
|||
mNumPendingUnreadMessages += delta;
|
||||
PRInt32 newUnreadMessages = mNumUnreadMessages + mNumPendingUnreadMessages;
|
||||
NS_ASSERTION(newUnreadMessages >= 0, "shouldn't have negative unread message count");
|
||||
nsCOMPtr<nsIMsgDatabase> db;
|
||||
nsCOMPtr<nsIDBFolderInfo> folderInfo;
|
||||
nsresult rv = GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), getter_AddRefs(db));
|
||||
if (NS_SUCCEEDED(rv) && folderInfo)
|
||||
folderInfo->SetImapUnreadPendingMessages(mNumPendingUnreadMessages);
|
||||
if (newUnreadMessages >= 0)
|
||||
{
|
||||
nsCOMPtr<nsIMsgDatabase> db;
|
||||
nsCOMPtr<nsIDBFolderInfo> folderInfo;
|
||||
nsresult rv = GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), getter_AddRefs(db));
|
||||
if (NS_SUCCEEDED(rv) && folderInfo)
|
||||
folderInfo->SetImapUnreadPendingMessages(mNumPendingUnreadMessages);
|
||||
|
||||
NotifyIntPropertyChanged(kTotalUnreadMessagesAtom, oldUnreadMessages, newUnreadMessages);
|
||||
NotifyIntPropertyChanged(kTotalUnreadMessagesAtom, oldUnreadMessages, newUnreadMessages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3660,7 +3672,7 @@ NS_IMETHODIMP nsMsgDBFolder::GetNumNewMessages(PRBool deep, PRInt32 *aNumNewMess
|
|||
{
|
||||
PRInt32 num;
|
||||
folder->GetNumNewMessages(deep, &num);
|
||||
if (num >= 0) // it's legal for counts to be negative if we don't know
|
||||
if (num > 0) // it's legal for counts to be negative if we don't know
|
||||
numNewMessages += num;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,9 +108,10 @@ interface nsMsgDBCommitType
|
|||
[scriptable, uuid(9188bc83-f92e-11d2-81ef-0060083a0bcf)]
|
||||
|
||||
interface nsIMsgDatabase : nsIDBChangeAnnouncer {
|
||||
nsIMsgDatabase Open(in nsIFileSpec folderName, in boolean create, in boolean upgrading);
|
||||
nsIMsgDatabase OpenFolderDB(in nsIMsgFolder folder, in boolean create, in boolean upgrading);
|
||||
void Close(in boolean forceCommit);
|
||||
nsIMsgDatabase Open(in nsIFileSpec aFolderName, in boolean aCreate, in boolean aUpgrading);
|
||||
nsIMsgDatabase OpenFolderDB(in nsIMsgFolder aFolder, in boolean aCreate, in boolean aUpgrading);
|
||||
void forceFolderDBClosed(in nsIMsgFolder aFolder);
|
||||
void Close(in boolean aForceCommit);
|
||||
|
||||
void Commit(in nsMsgDBCommit commitType);
|
||||
// Force closed is evil, and we should see if we can do without it.
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#include "prprf.h"
|
||||
#include "nsTime.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsLocalFolderSummarySpec.h"
|
||||
|
||||
#include "nsILocale.h"
|
||||
#include "nsLocaleCID.h"
|
||||
|
@ -787,10 +788,10 @@ nsMsgDatabase::~nsMsgDatabase()
|
|||
|
||||
if (m_mdbAllThreadsTable)
|
||||
m_mdbAllThreadsTable->Release();
|
||||
|
||||
if (m_mdbStore)
|
||||
{
|
||||
m_mdbStore->Release();
|
||||
}
|
||||
|
||||
if (m_mdbEnv)
|
||||
{
|
||||
m_mdbEnv->Release(); //??? is this right?
|
||||
|
@ -1072,6 +1073,31 @@ nsresult nsMsgDatabase::CloseMDB(PRBool commit)
|
|||
return(NS_OK);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDatabase::ForceFolderDBClosed(nsIMsgFolder *aFolder)
|
||||
{
|
||||
NS_ENSURE_ARG(aFolder);
|
||||
nsCOMPtr <nsIFileSpec> folderPath;
|
||||
nsFileSpec folderName;
|
||||
|
||||
nsresult rv = aFolder->GetPath(getter_AddRefs(folderPath));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
folderPath->GetFileSpec(&folderName);
|
||||
nsLocalFolderSummarySpec summarySpec(folderName);
|
||||
|
||||
|
||||
nsFileSpec dbPath(summarySpec);
|
||||
|
||||
nsIMsgDatabase *mailDB = (nsMsgDatabase *) FindInCache(dbPath);
|
||||
if (mailDB)
|
||||
{
|
||||
mailDB->ForceClosed();
|
||||
//FindInCache AddRef's
|
||||
mailDB->Release();
|
||||
}
|
||||
return(NS_OK);
|
||||
}
|
||||
|
||||
|
||||
// force the database to close - this'll flush out anybody holding onto
|
||||
// a database without having a listener!
|
||||
// This is evil in the com world, but there are times we need to delete the file.
|
||||
|
|
Загрузка…
Ссылка в новой задаче