diff --git a/mailnews/base/public/nsIMsgWindow.idl b/mailnews/base/public/nsIMsgWindow.idl
index 73d4aecf15d..c29fc0b753f 100644
--- a/mailnews/base/public/nsIMsgWindow.idl
+++ b/mailnews/base/public/nsIMsgWindow.idl
@@ -47,6 +47,8 @@ interface nsIMsgWindow : nsISupports {
void SetDOMWindow(in nsIDOMWindow window);
void StopUrls();
+ void SelectFolder(in string folderUri);
+ void SelectMessage(in string messageUri);
/* when the msg window is being unloaded from the content window,
* we can use this notification to force a flush on anything the
* msg window hangs on too. For some reason xpconnect is still hanging
@@ -55,3 +57,10 @@ interface nsIMsgWindow : nsISupports {
*/
void closeWindow();
};
+
+[scriptable, uuid(FAD93C80-1AC6-11d4-A8F6-006097222B83)]
+interface nsIMsgWindowCommands : nsISupports {
+
+ void SelectFolder(in string folderUri);
+ void SelectMessage(in string messageUri);
+};
diff --git a/mailnews/base/resources/content/mailWindow.js b/mailnews/base/resources/content/mailWindow.js
index 6b83ebf5ce3..f420dea10cf 100644
--- a/mailnews/base/resources/content/mailWindow.js
+++ b/mailnews/base/resources/content/mailWindow.js
@@ -61,6 +61,25 @@ var gMeterObserver;
var startTime = 0;
//End progress and Status variables
+function OnMailWindowUnload()
+{
+ mailSession.RemoveMsgWindow(msgWindow);
+ messenger.SetWindow(null, null);
+
+ var msgDS = folderDataSource.QueryInterface(Components.interfaces.nsIMsgRDFDataSource);
+ msgDS.window = null;
+
+ msgDS = messageDataSource.QueryInterface(Components.interfaces.nsIMsgRDFDataSource);
+ msgDS.window = null;
+
+ msgDS = accountManagerDataSource.QueryInterface(Components.interfaces.nsIMsgRDFDataSource);
+ msgDS.window = null;
+
+
+ msgWindow.closeWindow();
+
+}
+
function CreateMailWindowGlobals()
{
// get the messenger instance
@@ -75,6 +94,7 @@ function CreateMailWindowGlobals()
statusFeedback = Components.classes[statusFeedbackProgID].createInstance();
statusFeedback = statusFeedback.QueryInterface(Components.interfaces.nsIMsgStatusFeedback);
+ window.MsgWindowCommands = new nsMsgWindowCommands();
//Create message view object
messageView = Components.classes[messageViewProgID].createInstance();
messageView = messageView.QueryInterface(Components.interfaces.nsIMessageView);
@@ -111,7 +131,9 @@ function InitMsgWindow()
msgWindow.statusFeedback = statusFeedback;
msgWindow.messageView = messageView;
msgWindow.msgHeaderSink = messageHeaderSink;
- msgWindow.SetDOMWindow(window);
+ msgWindow.SetDOMWindow(window);
+ mailSession.AddMsgWindow(msgWindow);
+
}
function AddDataSources()
@@ -244,3 +266,29 @@ nsMsgStatusFeedback.prototype =
{
}
}
+
+
+function nsMsgWindowCommands()
+{
+}
+
+nsMsgWindowCommands.prototype =
+{
+ QueryInterface : function(iid)
+ {
+ if(iid.equals(Components.interfaces.nsIMsgWindowCommands))
+ return this;
+ throw Components.results.NS_NOINTERFACE;
+ },
+ SelectFolder: function(folderUri)
+ {
+
+ SelectFolder(folderUri);
+
+ },
+ SelectMessage: function(messageUri)
+ {
+ SelectMessage(messageUri);
+ }
+}
+
diff --git a/mailnews/base/resources/content/messageWindow.js b/mailnews/base/resources/content/messageWindow.js
index 3e5c375294b..0f7ef74eae8 100644
--- a/mailnews/base/resources/content/messageWindow.js
+++ b/mailnews/base/resources/content/messageWindow.js
@@ -70,9 +70,7 @@ function OnLoadMessageWindow()
function OnUnloadMessageWindow()
{
- messenger.SetWindow(null, null);
- msgWindow.closeWindow();
-
+ OnMailWindowUnload();
}
function CreateMessageWindowGlobals()
@@ -148,3 +146,14 @@ function SetNextMessageAfterDelete(messagesToCheck, useSelection)
{
gCurrentMessageIsDeleted = true;
}
+
+function SelectFolder(folderUri)
+{
+ gCurrentFolderUri = folderUri;
+}
+
+function SelectMessage(messageUri)
+{
+ gCurrentMessageUri = messageUri;
+ OpenURL(gCurrentMessageUri);
+}
diff --git a/mailnews/base/resources/content/messageWindow.xul b/mailnews/base/resources/content/messageWindow.xul
index 87c6cfa6de8..c55ec41caca 100644
--- a/mailnews/base/resources/content/messageWindow.xul
+++ b/mailnews/base/resources/content/messageWindow.xul
@@ -44,14 +44,20 @@ Rights Reserved.
windowtype="mail:messageWindow">
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/mailnews/base/resources/content/msgMail3PaneWindow.js b/mailnews/base/resources/content/msgMail3PaneWindow.js
index 4b13be851aa..30fe6a5e7e1 100644
--- a/mailnews/base/resources/content/msgMail3PaneWindow.js
+++ b/mailnews/base/resources/content/msgMail3PaneWindow.js
@@ -267,22 +267,10 @@ function OnUnloadMessenger()
if(mailSession)
{
mailSession.RemoveFolderListener(folderListener);
- mailSession.RemoveMsgWindow(msgWindow);
- messenger.SetWindow(null, null);
}
}
- var msgDS = folderDataSource.QueryInterface(Components.interfaces.nsIMsgRDFDataSource);
- msgDS.window = null;
-
- msgDS = messageDataSource.QueryInterface(Components.interfaces.nsIMsgRDFDataSource);
- msgDS.window = null;
-
- msgDS = accountManagerDataSource.QueryInterface(Components.interfaces.nsIMsgRDFDataSource);
- msgDS.window = null;
-
-
- msgWindow.closeWindow();
+ OnMailWindowUnload();
}
@@ -405,7 +393,6 @@ function AddToSession()
var mailSession = Components.classes[mailSessionProgID].getService(Components.interfaces.nsIMsgMailSession);
mailSession.AddFolderListener(folderListener);
- mailSession.AddMsgWindow(msgWindow);
} catch (ex) {
dump("Error adding to session\n");
}
@@ -1318,6 +1305,24 @@ function SetNextMessageAfterDelete(messagesToCheck, useSelection)
}
}
+function SelectFolder(folderUri)
+{
+ var tree = GetFolderTree();
+ var treeitem = document.getElementById(folderUri);
+ if(tree && treeitem)
+ ChangeSelection(tree, treeitem);
+}
+
+function SelectMessage(messageUri)
+{
+ var tree = GetThreadTree();
+ var treeitem = document.getElementById(messageUri);
+ if(tree && treeitem)
+ ChangeSelection(tree, treeitem);
+
+}
+
+
//3pane related commands. Need to go in own file. Putting here for the moment.
function MsgSortByDate()
{
diff --git a/mailnews/base/resources/content/threadPane.xul b/mailnews/base/resources/content/threadPane.xul
index afca9836df2..04eb1f7d2d5 100644
--- a/mailnews/base/resources/content/threadPane.xul
+++ b/mailnews/base/resources/content/threadPane.xul
@@ -79,7 +79,7 @@ Rights Reserved.
onclick="return top.ToggleMessageFlagged(event.target.parentNode.parentNode.parentNode)"
value="rdf:http://home.netscape.com/NC-rdf#Flagged" />
-
+
diff --git a/mailnews/base/src/nsMsgMailSession.cpp b/mailnews/base/src/nsMsgMailSession.cpp
index 30e25b46e26..0cffff23b1e 100644
--- a/mailnews/base/src/nsMsgMailSession.cpp
+++ b/mailnews/base/src/nsMsgMailSession.cpp
@@ -300,7 +300,7 @@ nsresult nsMsgMailSession::GetTopmostMsgWindow(nsIMsgWindow* *aMsgWindow)
if(count > 0)
{
- nsCOMPtr windowSupports = mWindows->ElementAt(0);
+ nsCOMPtr windowSupports = mWindows->ElementAt(count - 1);
if(windowSupports)
rv = windowSupports->QueryInterface(NS_GET_IID(nsIMsgWindow), (void**)aMsgWindow);
if(NS_FAILED(rv))
diff --git a/mailnews/base/src/nsMsgWindow.cpp b/mailnews/base/src/nsMsgWindow.cpp
index 1cb74b7e94b..a44a03e6fe2 100644
--- a/mailnews/base/src/nsMsgWindow.cpp
+++ b/mailnews/base/src/nsMsgWindow.cpp
@@ -35,6 +35,8 @@
#include "nsILoadGroup.h"
#include "nsIMsgMailNewsUrl.h"
#include "nsIInterfaceRequestor.h"
+#include "nsPIDOMWindow.h"
+
static NS_DEFINE_CID(kTransactionManagerCID, NS_TRANSACTIONMANAGER_CID);
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
@@ -76,6 +78,18 @@ nsresult nsMsgWindow::Init()
return rv;
}
+/* void SelectFolder (in string folderUri); */
+NS_IMETHODIMP nsMsgWindow::SelectFolder(const char *folderUri)
+{
+ return mMsgWindowCommands->SelectFolder(folderUri);
+}
+
+/* void SelectMessage (in string messasgeUri); */
+NS_IMETHODIMP nsMsgWindow::SelectMessage(const char *messageUri)
+{
+ return mMsgWindowCommands->SelectMessage(messageUri);
+}
+
NS_IMETHODIMP nsMsgWindow::CloseWindow()
{
nsresult rv = NS_OK;
@@ -232,6 +246,18 @@ NS_IMETHODIMP nsMsgWindow::SetDOMWindow(nsIDOMWindow *aWindow)
// we don't own mMessageWindowWebShell so don't try to keep a reference to it!
mMessageWindowWebShell = msgWebShell;
}
+
+ //Get nsIMsgWindowCommands object
+ nsCOMPtr xpConnectObj;
+ nsCOMPtr piDOMWindow(do_QueryInterface(aWindow));
+ if (piDOMWindow)
+ {
+ nsAutoString msgWindowCommandsWinId;
+ msgWindowCommandsWinId.AssignWithConversion("MsgWindowCommands");
+ piDOMWindow->GetObjectProperty(msgWindowCommandsWinId.GetUnicode(), getter_AddRefs(xpConnectObj));
+ mMsgWindowCommands = do_QueryInterface(xpConnectObj);
+ }
+
return rv;
}
diff --git a/mailnews/base/src/nsMsgWindow.h b/mailnews/base/src/nsMsgWindow.h
index 3031160abd0..940b0460e26 100644
--- a/mailnews/base/src/nsMsgWindow.h
+++ b/mailnews/base/src/nsMsgWindow.h
@@ -52,6 +52,7 @@ protected:
nsCOMPtr mTransactionManager;
nsCOMPtr mMessageView;
nsCOMPtr mOpenFolder;
+ nsCOMPtr mMsgWindowCommands;
// let's not make this a strong ref - we don't own it.
nsIWebShell *mRootWebShell;