add method to shut down connections
git-svn-id: svn://10.0.0.236/trunk@49384 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -121,6 +121,7 @@ interface nsIMsgAccountManager : nsISupports {
|
||||
|
||||
void WriteToFolderCache(in nsIMsgFolderCache folderCache);
|
||||
|
||||
void CloseCachedConnections();
|
||||
/* search for 4.x mailnews prefs, and migrate to 5.0 prefs */
|
||||
void UpgradePrefs();
|
||||
};
|
||||
|
||||
@@ -83,6 +83,9 @@ interface nsIMsgIncomingServer : nsISupports {
|
||||
|
||||
void WriteToFolderCache(in nsIMsgFolderCache folderCache);
|
||||
|
||||
// either we're going offline, or shutting down.
|
||||
void CloseCachedConnections();
|
||||
|
||||
/* access to generic attributes */
|
||||
boolean getBoolValue(in string attr);
|
||||
void setBoolValue(in string attr, in boolean value);
|
||||
|
||||
@@ -398,6 +398,7 @@ private:
|
||||
|
||||
// write out the server's cache through the given folder cache
|
||||
static PRBool writeFolderCache(nsHashKey *aKey, void *aData, void *closure);
|
||||
static PRBool closeCachedConnections(nsHashKey *aKey, void *aData, void *closure);
|
||||
|
||||
// methods for migration / upgrading
|
||||
nsresult MigrateIdentity(nsIMsgIdentity *identity);
|
||||
@@ -474,7 +475,7 @@ nsMsgAccountManager::nsMsgAccountManager() :
|
||||
|
||||
nsMsgAccountManager::~nsMsgAccountManager()
|
||||
{
|
||||
|
||||
CloseCachedConnections();
|
||||
if (m_prefs) nsServiceManager::ReleaseService(kPrefServiceCID, m_prefs);
|
||||
UnloadAccounts();
|
||||
NS_IF_RELEASE(m_accounts);
|
||||
@@ -842,6 +843,16 @@ PRBool nsMsgAccountManager::writeFolderCache(nsHashKey *aKey, void *aData,
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// enumaration for closing cached connections.
|
||||
PRBool nsMsgAccountManager::closeCachedConnections(nsHashKey *aKey, void *aData,
|
||||
void *closure)
|
||||
{
|
||||
nsIMsgIncomingServer *server = (nsIMsgIncomingServer*)aData;
|
||||
|
||||
server->CloseCachedConnections();
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* readonly attribute nsISupportsArray accounts; */
|
||||
NS_IMETHODIMP
|
||||
@@ -1094,6 +1105,12 @@ nsMsgAccountManager::UnloadAccounts()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgAccountManager::CloseCachedConnections()
|
||||
{
|
||||
m_incomingServers.Enumerate(closeCachedConnections, nsnull);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgAccountManager::WriteToFolderCache(nsIMsgFolderCache *folderCache)
|
||||
|
||||
@@ -53,6 +53,7 @@ nsMsgMailSession::~nsMsgMailSession()
|
||||
{
|
||||
// if (m_msgFolderCache)
|
||||
// m_accountManager->WriteToFolderCache(m_msgFolderCache);
|
||||
m_accountManager->CloseCachedConnections();
|
||||
m_accountManager->UnloadAccounts();
|
||||
}
|
||||
|
||||
|
||||
@@ -123,6 +123,14 @@ NS_IMETHODIMP nsMsgIncomingServer::WriteToFolderCache(nsIMsgFolderCache *folderC
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgIncomingServer::CloseCachedConnections()
|
||||
{
|
||||
// derived class should override if they cache connections.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgIncomingServer::GetServerURI(char **)
|
||||
{
|
||||
|
||||
@@ -74,6 +74,7 @@ public:
|
||||
NS_DECL_NSIIMAPSERVERSINK
|
||||
|
||||
NS_IMETHOD PerformBiff();
|
||||
NS_IMETHOD CloseCachedConnections();
|
||||
|
||||
protected:
|
||||
nsresult GetFolder(const char* name, nsIMsgFolder** pFolder);
|
||||
@@ -524,6 +525,30 @@ NS_IMETHODIMP nsImapIncomingServer::PerformBiff()
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::CloseCachedConnections()
|
||||
{
|
||||
|
||||
nsCOMPtr<nsIImapProtocol> connection;
|
||||
PR_CEnterMonitor(this);
|
||||
|
||||
// iterate through the connection cache closing open connections.
|
||||
PRUint32 cnt;
|
||||
nsCOMPtr<nsISupports> aSupport;
|
||||
|
||||
nsresult rv = m_connectionCache->Count(&cnt);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
for (PRUint32 i = 0; i < cnt; i++)
|
||||
{
|
||||
aSupport = getter_AddRefs(m_connectionCache->ElementAt(i));
|
||||
connection = do_QueryInterface(aSupport);
|
||||
if (connection)
|
||||
rv = connection->TellThreadToDie(PR_TRUE);
|
||||
}
|
||||
|
||||
PR_CExitMonitor(this);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult NS_NewImapIncomingServer(const nsIID& iid,
|
||||
void **result)
|
||||
@@ -1323,7 +1348,6 @@ NS_IMETHODIMP nsImapIncomingServer::PseudoInterruptMsgLoad(nsIMsgFolder *aFolder
|
||||
PRBool canRunUrl = PR_FALSE;
|
||||
PRBool hasToWait = PR_FALSE;
|
||||
nsCOMPtr<nsIImapProtocol> connection;
|
||||
nsCOMPtr<nsIImapProtocol> freeConnection;
|
||||
PRBool isBusy = PR_FALSE;
|
||||
PRBool isInboxConnection = PR_FALSE;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user