зеркало из https://github.com/mozilla/pjs.git
More work on 17376. reviewed by bienvenu. Store open folder and keep array of msgWindows.
This commit is contained in:
Родитель
727a309c06
Коммит
8ab04409f1
|
@ -32,6 +32,8 @@
|
|||
#include "nsIMsgIncomingServer.idl"
|
||||
#include "nsIMsgAccountManager.idl"
|
||||
#include "nsIFolderListener.idl"
|
||||
#include "nsIMsgWindow.idl"
|
||||
#include "nsISupportsArray.idl"
|
||||
|
||||
interface nsIMsgFolderCache;
|
||||
interface nsIMsgStatusFeedback;
|
||||
|
@ -43,7 +45,7 @@ interface nsIMsgMailSession : nsISupports {
|
|||
readonly attribute nsIMsgIncomingServer currentServer;
|
||||
readonly attribute nsIMsgAccountManager accountManager;
|
||||
readonly attribute nsIMsgFolderCache folderCache;
|
||||
|
||||
|
||||
attribute nsIMsgStatusFeedback temporaryMsgStatusFeedback;
|
||||
|
||||
void Shutdown();
|
||||
|
@ -61,5 +63,9 @@ interface nsIMsgMailSession : nsISupports {
|
|||
void NotifyFolderItemAdded(in nsIFolder folder, in nsISupports item);
|
||||
void NotifyFolderItemDeleted(in nsIFolder folder, in nsISupports item);
|
||||
void NotifyFolderLoaded(in nsIFolder folder);
|
||||
|
||||
void AddMsgWindow(in nsIMsgWindow msgWindow);
|
||||
void RemoveMsgWindow(in nsIMsgWindow msgWindow);
|
||||
readonly attribute nsISupportsArray msgWindowsArray;
|
||||
};
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "nsISupports.idl"
|
||||
#include "nsIMsgStatusFeedback.idl"
|
||||
#include "nsIMessageView.idl"
|
||||
#include "nsIMsgFolder.idl"
|
||||
|
||||
interface nsITransactionManager;
|
||||
|
||||
|
@ -33,4 +34,5 @@ interface nsIMsgWindow : nsISupports {
|
|||
attribute nsIMsgStatusFeedback statusFeedback;
|
||||
attribute nsITransactionManager transactionManager;
|
||||
attribute nsIMessageView messageView;
|
||||
attribute nsIMsgFolder openFolder;
|
||||
};
|
|
@ -196,6 +196,7 @@ function ChangeFolderByDOMNode(folderNode)
|
|||
|
||||
function ChangeFolderByURI(uri)
|
||||
{
|
||||
dump('In ChangeFolderByURI\n');
|
||||
var resource = RDF.GetResource(uri);
|
||||
var msgfolder =
|
||||
resource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
|
@ -223,16 +224,21 @@ function ChangeFolderByURI(uri)
|
|||
{
|
||||
gCurrentLoadingFolderURI = "";
|
||||
msgfolder.updateFolder();
|
||||
RerootFolder(uri);
|
||||
RerootFolder(uri, msgfolder);
|
||||
}
|
||||
}
|
||||
|
||||
function RerootFolder(uri)
|
||||
function RerootFolder(uri, newFolder)
|
||||
{
|
||||
dump('In reroot folder\n');
|
||||
var folder = GetThreadTreeFolder();
|
||||
ClearThreadTreeSelection();
|
||||
|
||||
//Set the window's new open folder.
|
||||
msgWindow.openFolder = newFolder;
|
||||
|
||||
folder.setAttribute('ref', uri);
|
||||
|
||||
var afterFolderLoadTime = new Date();
|
||||
var timeToLoad = (afterFolderLoadTime.getTime() - gBeforeFolderLoadTime.getTime())/1000;
|
||||
if(showPerformance)
|
||||
|
|
|
@ -70,6 +70,7 @@ var folderListener = {
|
|||
|
||||
OnFolderLoaded: function (folder)
|
||||
{
|
||||
dump('In OnFolderLoader\n');
|
||||
if(folder)
|
||||
{
|
||||
var resource = folder.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
|
@ -81,8 +82,11 @@ var folderListener = {
|
|||
gCurrentLoadingFolderURI="";
|
||||
var msgFolder = folder.QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
if(msgFolder)
|
||||
{
|
||||
msgFolder.endFolderLoading();
|
||||
RerootFolder(uri);
|
||||
dump("before reroot in OnFolderLoaded\n");
|
||||
RerootFolder(uri, msgFolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +108,7 @@ function OnLoadMessenger()
|
|||
|
||||
loadStartFolder();
|
||||
|
||||
getFolderListener();
|
||||
AddToSession();
|
||||
|
||||
goSetDefaultController(DefaultController);
|
||||
}
|
||||
|
@ -117,7 +121,10 @@ function OnUnloadMessenger()
|
|||
{
|
||||
mailSession = mailSession.QueryInterface(Components.interfaces.nsIMsgMailSession);
|
||||
if(mailSession)
|
||||
{
|
||||
mailSession.RemoveFolderListener(folderListener);
|
||||
mailSession.RemoveMsgWindow(msgWindow);
|
||||
}
|
||||
}
|
||||
|
||||
saveWindowPosition();
|
||||
|
@ -208,14 +215,15 @@ function loadStartFolder()
|
|||
|
||||
}
|
||||
|
||||
function getFolderListener()
|
||||
function AddToSession()
|
||||
{
|
||||
try {
|
||||
var mailSession = Components.classes[mailSessionProgID].getService(Components.interfaces.nsIMsgMailSession);
|
||||
|
||||
mailSession.AddFolderListener(folderListener);
|
||||
mailSession.AddMsgWindow(msgWindow);
|
||||
} catch (ex) {
|
||||
dump("Error adding folder listener\n");
|
||||
dump("Error adding to session\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,6 +231,7 @@ function InitMsgWindow()
|
|||
{
|
||||
msgWindow.statusFeedback = statusFeedback;
|
||||
msgWindow.messageView = messageView;
|
||||
|
||||
}
|
||||
|
||||
function AddDataSources()
|
||||
|
|
|
@ -83,11 +83,6 @@ nsMessageViewDataSource::QueryInterface(REFNSIID iid, void** result)
|
|||
*result = NS_STATIC_CAST(nsIMessageView*, this);
|
||||
NS_ADDREF_THIS();
|
||||
}
|
||||
else if(iid.Equals(nsCOMTypeInfo<nsIMsgWindow>::GetIID()))
|
||||
{
|
||||
*result = NS_STATIC_CAST(nsIMsgWindow*, this);
|
||||
NS_ADDREF_THIS();
|
||||
}
|
||||
|
||||
if(*result)
|
||||
{
|
||||
|
@ -557,49 +552,6 @@ NS_IMETHODIMP nsMessageViewDataSource::SetShowThreads(PRBool aShowThreads)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMessageViewDataSource::GetStatusFeedback(nsIMsgStatusFeedback * *aStatusFeedback)
|
||||
{
|
||||
if(!aStatusFeedback)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aStatusFeedback = mStatusFeedback;
|
||||
NS_IF_ADDREF(*aStatusFeedback);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMessageViewDataSource::SetStatusFeedback(nsIMsgStatusFeedback * aStatusFeedback)
|
||||
{
|
||||
mStatusFeedback = aStatusFeedback;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsMessageViewDataSource::GetTransactionManager(nsITransactionManager * *aTransactionManager)
|
||||
{
|
||||
if(!aTransactionManager)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aTransactionManager = mTransactionManager;
|
||||
NS_IF_ADDREF(*aTransactionManager);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMessageViewDataSource::SetTransactionManager(nsITransactionManager * aTransactionManager)
|
||||
{
|
||||
mTransactionManager = aTransactionManager;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMessageViewDataSource::GetMessageView(nsIMessageView * *aMessageView)
|
||||
{
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMessageViewDataSource::SetMessageView(nsIMessageView * aMessageView)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMessageViewDataSource::createMessageNode(nsIMessage *message,
|
||||
|
|
|
@ -29,13 +29,12 @@
|
|||
#include "nsIMessage.h"
|
||||
#include "nsIMsgThread.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIMsgWindow.h"
|
||||
|
||||
/**
|
||||
* The mail data source.
|
||||
*/
|
||||
class nsMessageViewDataSource : public nsIRDFCompositeDataSource, public nsIMessageView,
|
||||
public nsIRDFObserver, public nsIMsgWindow
|
||||
public nsIRDFObserver
|
||||
{
|
||||
private:
|
||||
nsCOMPtr<nsISupportsArray> mObservers;
|
||||
|
@ -49,7 +48,6 @@ public:
|
|||
NS_DECL_NSIRDFCOMPOSITEDATASOURCE
|
||||
NS_DECL_NSIRDFOBSERVER
|
||||
NS_DECL_NSIMESSAGEVIEW
|
||||
NS_DECL_NSIMSGWINDOW
|
||||
nsMessageViewDataSource(void);
|
||||
virtual ~nsMessageViewDataSource (void);
|
||||
virtual nsresult Init();
|
||||
|
@ -72,8 +70,6 @@ protected:
|
|||
static nsIRDFResource* kNC_Sender;
|
||||
static nsIRDFResource* kNC_Status;
|
||||
|
||||
nsCOMPtr<nsIMsgStatusFeedback> mStatusFeedback;
|
||||
nsCOMPtr<nsITransactionManager> mTransactionManager;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -59,7 +59,10 @@ nsMsgMailSession::~nsMsgMailSession()
|
|||
nsresult nsMsgMailSession::Init()
|
||||
{
|
||||
nsresult rv = NS_NewISupportsArray(getter_AddRefs(mListeners));
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(mWindows));
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
@ -295,4 +298,25 @@ NS_IMETHODIMP nsMsgMailSession::NotifyFolderLoaded(nsIFolder *folder)
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsMsgMailSession::AddMsgWindow(nsIMsgWindow *msgWindow)
|
||||
{
|
||||
mWindows->AppendElement(msgWindow);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgMailSession::RemoveMsgWindow(nsIMsgWindow *msgWindow)
|
||||
{
|
||||
mWindows->RemoveElement(msgWindow);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgMailSession::GetMsgWindowsArray(nsISupportsArray * *aWindowsArray)
|
||||
{
|
||||
if(!aWindowsArray)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aWindowsArray = mWindows;
|
||||
NS_IF_ADDREF(*aWindowsArray);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ protected:
|
|||
nsIMsgAccountManager *m_accountManager;
|
||||
nsIMsgFolderCache *m_msgFolderCache;
|
||||
nsCOMPtr<nsISupportsArray> mListeners;
|
||||
nsCOMPtr<nsISupportsArray> mWindows;
|
||||
// stick this here temporarily
|
||||
nsCOMPtr <nsIMsgStatusFeedback> m_temporaryMsgStatusFeedback;
|
||||
|
||||
|
|
|
@ -85,3 +85,20 @@ NS_IMETHODIMP nsMsgWindow::SetMessageView(nsIMessageView * aMessageView)
|
|||
mMessageView = aMessageView;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgWindow::GetOpenFolder(nsIMsgFolder * *aOpenFolder)
|
||||
{
|
||||
if(!aOpenFolder)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aOpenFolder = mOpenFolder;
|
||||
NS_IF_ADDREF(*aOpenFolder);
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgWindow::SetOpenFolder(nsIMsgFolder * aOpenFolder)
|
||||
{
|
||||
mOpenFolder = aOpenFolder;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include "nsIMsgStatusFeedback.h"
|
||||
#include "nsITransactionManager.h"
|
||||
#include "nsIMessageView.h"
|
||||
#include "nsIMsgFolder.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsMsgWindow : public nsIMsgWindow {
|
||||
|
@ -40,7 +42,7 @@ protected:
|
|||
nsCOMPtr<nsIMsgStatusFeedback> mStatusFeedback;
|
||||
nsCOMPtr<nsITransactionManager> mTransactionManager;
|
||||
nsCOMPtr<nsIMessageView> mMessageView;
|
||||
|
||||
nsCOMPtr<nsIMsgFolder> mOpenFolder;
|
||||
};
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче