diff --git a/mailnews/base/public/nsIMsgMailSession.idl b/mailnews/base/public/nsIMsgMailSession.idl index dd88ac348c0a..f1387e967fb8 100644 --- a/mailnews/base/public/nsIMsgMailSession.idl +++ b/mailnews/base/public/nsIMsgMailSession.idl @@ -67,5 +67,6 @@ interface nsIMsgMailSession : nsISupports { void AddMsgWindow(in nsIMsgWindow msgWindow); void RemoveMsgWindow(in nsIMsgWindow msgWindow); readonly attribute nsISupportsArray msgWindowsArray; + boolean IsFolderOpenInWindow(in nsIMsgFolder folder); }; diff --git a/mailnews/base/src/nsMsgMailSession.cpp b/mailnews/base/src/nsMsgMailSession.cpp index e4d97e2177d5..be250fe3b5d4 100644 --- a/mailnews/base/src/nsMsgMailSession.cpp +++ b/mailnews/base/src/nsMsgMailSession.cpp @@ -28,6 +28,7 @@ #include "nsIFileLocator.h" #include "nsFileLocations.h" #include "nsIMsgStatusFeedback.h" +#include "nsIMsgWindow.h" NS_IMPL_ISUPPORTS(nsMsgMailSession, nsCOMTypeInfo::GetIID()); @@ -36,10 +37,6 @@ static NS_DEFINE_CID(kMsgFolderCacheCID, NS_MSGFOLDERCACHE_CID); static NS_DEFINE_IID(kIFileLocatorIID, NS_IFILELOCATOR_IID); static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID); -//static NS_DEFINE_CID(kMsgIdentityCID, NS_MSGIDENTITY_CID); -//static NS_DEFINE_CID(kPop3IncomingServerCID, NS_POP3INCOMINGSERVER_CID); -//static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); - nsMsgMailSession::nsMsgMailSession(): mRefCnt(0), @@ -320,3 +317,32 @@ NS_IMETHODIMP nsMsgMailSession::GetMsgWindowsArray(nsISupportsArray * *aWindowsA return NS_OK; } +NS_IMETHODIMP nsMsgMailSession::IsFolderOpenInWindow(nsIMsgFolder *folder, PRBool *aResult) +{ + if (!aResult) + return NS_ERROR_NULL_POINTER; + *aResult = PR_FALSE; + + PRUint32 count; + nsresult rv = mWindows->Count(&count); + if (NS_FAILED(rv)) return rv; + + if (mWindows) + { + for(PRUint32 i = 0; i < count; i++) + { + nsCOMPtr openWindow = getter_AddRefs((nsIMsgWindow*)mWindows->ElementAt(i)); + nsCOMPtr openFolder; + if (openWindow) + openWindow->GetOpenFolder(getter_AddRefs(openFolder)); + if (folder == openFolder.get()) + { + *aResult = PR_TRUE; + break; + } + } + } + + return NS_OK; +} +