Bug #345251 --> remove calls to getojbectproperty on a DOM Window as that API is going away. While I'm here, clean up and simplifying nsIMsgStatusFeedback, nsimsgWindow. Combine nsIMsgWindowCommands and nsIMsgPaneController into a single interface.

sr=bienvenu
This commit is contained in:
scott%scott-macgregor.org 2006-07-22 01:20:09 +00:00
Родитель 4429dc4c6b
Коммит 3f14f0bfc2
27 изменённых файлов: 200 добавлений и 309 удалений

Просмотреть файл

@ -110,7 +110,7 @@ function onLoad()
{
gFilterListMsgWindow = Components.classes["@mozilla.org/messenger/msgwindow;1"].createInstance(Components.interfaces.nsIMsgWindow);
gFilterListMsgWindow.statusFeedback = gStatusFeedback;
gFilterListMsgWindow.SetDOMWindow(window);
gFilterListMsgWindow.domWindow = window;
gFilterBundle = document.getElementById("bundle_filter");
gFilterTree = document.getElementById("filterTree");

Просмотреть файл

@ -52,7 +52,6 @@ var messenger;
var pref;
var prefServices;
var statusFeedback;
var messagePaneController;
var msgWindow;
var msgComposeService;
@ -157,8 +156,9 @@ function CreateMailWindowGlobals()
.getInterface(Components.interfaces.nsIXULWindow)
.XULBrowserWindow = window.MsgStatusFeedback;
statusFeedback = Components.classes[statusFeedbackContractID].createInstance();
statusFeedback = Components.classes[statusFeedbackContractID].createInstance();
statusFeedback = statusFeedback.QueryInterface(Components.interfaces.nsIMsgStatusFeedback);
statusFeedback.setWrappedStatusFeedback(window.MsgStatusFeedback);
/*
not in use unless we want the lock button back
@ -183,8 +183,6 @@ function CreateMailWindowGlobals()
}
*/
window.MsgWindowCommands = new nsMsgWindowCommands();
//Create message window object
msgWindow = Components.classes[msgWindowContractID].createInstance();
msgWindow = msgWindow.QueryInterface(Components.interfaces.nsIMsgWindow);
@ -215,10 +213,10 @@ function CreateMailWindowGlobals()
function InitMsgWindow()
{
msgWindow.messagePaneController = new nsMessagePaneController();
msgWindow.windowCommands = new nsMsgWindowCommands();
msgWindow.statusFeedback = statusFeedback;
msgWindow.msgHeaderSink = messageHeaderSink;
msgWindow.SetDOMWindow(window);
msgWindow.domWindow = window;
mailSession.AddMsgWindow(msgWindow);
getBrowser().docShell.allowAuth = false;
msgWindow.rootDocShell.allowAuth = true;
@ -321,6 +319,7 @@ nsMsgStatusFeedback.prototype =
{
if (iid.equals(Components.interfaces.nsIMsgStatusFeedback) ||
iid.equals(Components.interfaces.nsIXULBrowserWindow) ||
iid.equals(Components.interfaces.nsISupportsWeakReference) ||
iid.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_NOINTERFACE;
@ -436,10 +435,7 @@ nsMsgStatusFeedback.prototype =
this.statusBar.value = percentage;
this.statusBar.label = Math.round(percentage) + "%";
}
},
closeWindow : function(percent)
{
}
}
}
@ -456,29 +452,17 @@ nsMsgWindowCommands.prototype =
return this;
throw Components.results.NS_NOINTERFACE;
},
SelectFolder: function(folderUri)
selectFolder: function(folderUri)
{
SelectFolder(folderUri);
},
SelectMessage: function(messageUri)
selectMessage: function(messageUri)
{
SelectMessage(messageUri);
}
}
function nsMessagePaneController()
{
}
nsMessagePaneController.prototype =
{
QueryInterface : function(iid)
{
if (iid.equals(Components.interfaces.nsIMsgMessagePaneController) ||
iid.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_NOINTERFACE;
},
clearMsgPane: function()
{
if (gDBView)
@ -486,7 +470,7 @@ nsMessagePaneController.prototype =
else
setTitleFromFolder(null,null);
ClearMessagePane();
}
}
}
function StopUrls()

Просмотреть файл

@ -184,7 +184,7 @@ function SubscribeOnLoad()
msgWindow = Components.classes[msgWindowContractID].createInstance(Components.interfaces.nsIMsgWindow);
msgWindow.statusFeedback = gStatusFeedback;
msgWindow.SetDOMWindow(window);
msgWindow.domWindow = window;
msgWindow.rootDocShell.allowAuth = true;
// look in arguments[0] for parameters

Просмотреть файл

@ -1922,7 +1922,7 @@ function GenericSendMessage( msgType )
progress.registerListener(progressListener);
gSendOrSaveOperationInProgress = true;
}
msgWindow.SetDOMWindow(window);
msgWindow.domWindow = window;
msgWindow.rootDocShell.allowAuth = true;
gMsgCompose.SendMsg(msgType, getCurrentIdentity(), currentAccountKey, msgWindow, progress);
}

Просмотреть файл

@ -468,7 +468,7 @@ var progressNotifier = {
// Nice touch: select the folder that now contains the newly subscribed feed...this is particularly nice
// if we just finished subscribing to a feed URL that the operating system gave us.
this.mMsgWindow.SelectFolder(feed.folder.URI);
this.mMsgWindow.windowCommands.selectFolder(feed.folder.URI);
}
else if (feed.folder)
feed.folder.setMsgDatabase(null);

Просмотреть файл

@ -37,18 +37,15 @@
#include "nsISupports.idl"
interface nsIDocShell;
interface nsIDOMWindow;
[scriptable, uuid(a0032cf0-49e9-11d3-8d77-00805f8a6617)]
[scriptable, uuid(FD1321EC-C84E-4939-B26B-8CFC676C8333)]
interface nsIMsgStatusFeedback : nsISupports {
void showStatusString(in wstring status);
void startMeteors();
void stopMeteors();
void showProgress(in long percent);
void setStatusString(in wstring status); // will be displayed until next user action
[noscript] void setDocShell(in nsIDocShell shell, in nsIDOMWindow window);
void closeWindow();
void setStatusString(in wstring status); // will be displayed until next user action
/* aStatusFeedback: a wrapped JS status feedback object */
void setWrappedStatusFeedback(in nsIMsgStatusFeedback aStatusFeedback);
};

Просмотреть файл

@ -46,25 +46,17 @@ interface nsIMsgHeaderSink;
interface nsIPrompt;
interface nsIAuthPrompt;
/*
* This interface can be used to set data specific to a window.
*/
/* nsIMsgMessagePaneController is used to control the visiblity of the message pane
including the header overlay and the body.
*/
[scriptable, uuid(923DE63D-EEB9-4574-850B-322C1A4667ED)]
interface nsIMsgMessagePaneController : nsISupports {
void clearMsgPane();
[scriptable, uuid(0A5C52F3-D1F3-4b6b-AE71-2B95C48BBC6B)]
interface nsIMsgWindowCommands : nsISupports {
void selectFolder(in string folderUri);
void selectMessage(in string messageUri);
void clearMsgPane();
};
[scriptable, uuid(BCE0AB71-11FF-428E-9EDC-69ABAD73b697)]
[scriptable, uuid(C4A53DDE-1502-40f1-8D00-71F636D545BE)]
interface nsIMsgWindow : nsISupports {
attribute nsIMsgMessagePaneController messagePaneController;
attribute nsIMsgStatusFeedback statusFeedback;
attribute nsIMsgWindowCommands windowCommands;
attribute nsIMsgHeaderSink msgHeaderSink;
attribute nsITransactionManager transactionManager;
attribute nsIMsgFolder openFolder;
@ -81,12 +73,11 @@ interface nsIMsgWindow : nsISupports {
there's no convenient place to clear it.
*/
attribute boolean stopped;
void SetDOMWindow(in nsIDOMWindowInternal window);
attribute nsIDOMWindowInternal domWindow;
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
@ -95,10 +86,3 @@ 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);
};

Просмотреть файл

@ -52,7 +52,6 @@ var messenger;
var pref;
var prefServices;
var statusFeedback;
var messagePaneController;
var msgWindow;
var msgComposeService;
@ -122,8 +121,6 @@ function OnMailWindowUnload()
msgDS = accountManagerDataSource.QueryInterface(Components.interfaces.nsIMsgRDFDataSource);
msgDS.window = null;
msgWindow.closeWindow();
}
@ -154,6 +151,7 @@ function CreateMailWindowGlobals()
statusFeedback = Components.classes[statusFeedbackContractID].createInstance();
statusFeedback = statusFeedback.QueryInterface(Components.interfaces.nsIMsgStatusFeedback);
statusFeedback.setWrappedStatusFeedback(window.MsgStatusFeedback);
/*
not in use unless we want the lock button back
@ -207,10 +205,10 @@ function CreateMailWindowGlobals()
function InitMsgWindow()
{
msgWindow.messagePaneController = new nsMessagePaneController();
msgWindow.windowCommands = new nsMsgWindowCommands();
msgWindow.statusFeedback = statusFeedback;
msgWindow.msgHeaderSink = messageHeaderSink;
msgWindow.SetDOMWindow(window);
msgWindow.domWindow = window;
mailSession.AddMsgWindow(msgWindow);
var messagepane = document.getElementById("messagepane");
@ -362,6 +360,7 @@ nsMsgStatusFeedback.prototype =
{
if (iid.equals(Components.interfaces.nsIMsgStatusFeedback) ||
iid.equals(Components.interfaces.nsIXULBrowserWindow) ||
iid.equals(Components.interfaces.nsISupportsWeakReference) ||
iid.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_NOINTERFACE;
@ -468,10 +467,7 @@ nsMsgStatusFeedback.prototype =
this.statusBar.value = percentage;
this.statusBar.label = Math.round(percentage) + "%";
}
},
closeWindow : function(percent)
{
}
}
}
@ -488,29 +484,17 @@ nsMsgWindowCommands.prototype =
return this;
throw Components.results.NS_NOINTERFACE;
},
SelectFolder: function(folderUri)
selectFolder: function(folderUri)
{
SelectFolder(folderUri);
},
SelectMessage: function(messageUri)
selectMessage: function(messageUri)
{
SelectMessage(messageUri);
}
}
function nsMessagePaneController()
{
}
nsMessagePaneController.prototype =
{
QueryInterface : function(iid)
{
if (iid.equals(Components.interfaces.nsIMsgMessagePaneController) ||
iid.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_NOINTERFACE;
},
clearMsgPane: function()
{
if (gDBView)
@ -518,7 +502,7 @@ nsMessagePaneController.prototype =
else
setTitleFromFolder(null,null);
ClearMessagePane();
}
}
}
function StopUrls()

Просмотреть файл

@ -125,7 +125,7 @@ function selectCancelButton()
function selectOnLoad()
{
gMsgWindow = Components.classes[msgWindowContractID].createInstance(Components.interfaces.nsIMsgWindow);
gMsgWindow.SetDOMWindow(window);
gMsgWindow.domWindow = window;
gAccountManager = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager);
gSynchronizeTree = document.getElementById('synchronizeTree');

Просмотреть файл

@ -186,7 +186,7 @@ function SubscribeOnLoad()
msgWindow = Components.classes[msgWindowContractID].createInstance(Components.interfaces.nsIMsgWindow);
msgWindow.statusFeedback = gStatusFeedback;
msgWindow.SetDOMWindow(window);
msgWindow.domWindow = window;
msgWindow.rootDocShell.allowAuth = true;
// look in arguments[0] for parameters

Просмотреть файл

@ -408,7 +408,7 @@ function GetFilterEditorMsgWindow()
var msgWindowContractID = "@mozilla.org/messenger/msgwindow;1";
var nsIMsgWindow = Components.interfaces.nsIMsgWindow;
gFilterEditorMsgWindow = Components.classes[msgWindowContractID].createInstance(nsIMsgWindow);
gFilterEditorMsgWindow.SetDOMWindow(window);
gFilterEditorMsgWindow.domWindow = window;
}
return gFilterEditorMsgWindow;
}

Просмотреть файл

@ -95,7 +95,7 @@ function onLoad()
{
gFilterListMsgWindow = Components.classes["@mozilla.org/messenger/msgwindow;1"].createInstance(Components.interfaces.nsIMsgWindow);
gFilterListMsgWindow.statusFeedback = gStatusFeedback;
gFilterListMsgWindow.SetDOMWindow(window);
gFilterListMsgWindow.domWindow = window;
gFilterBundle = document.getElementById("bundle_filter");
gFilterTree = document.getElementById("filterTree");

Просмотреть файл

@ -318,7 +318,7 @@ function initializeSearchWindowWidgets()
msgWindow = Components.classes[msgWindowContractID].createInstance(nsIMsgWindow);
msgWindow.statusFeedback = gStatusFeedback;
msgWindow.SetDOMWindow(window);
msgWindow.domWindow = window;
// functionality to enable/disable buttons using nsSearchResultsController
// depending of whether items are selected in the search results thread pane.

Просмотреть файл

@ -107,8 +107,6 @@
#include "nsIMsgIncomingServer.h"
#include "nsIMsgMessageService.h"
#include "nsIMsgStatusFeedback.h"
#include "nsMsgRDFUtils.h"
#include "nsIMsgHdr.h"
@ -341,83 +339,63 @@ nsMessenger::~nsMessenger()
NS_IMPL_ISUPPORTS3(nsMessenger, nsIMessenger, nsIObserver, nsISupportsWeakReference)
NS_IMPL_GETSET(nsMessenger, SendingUnsentMsgs, PRBool, mSendingUnsentMsgs)
NS_IMETHODIMP
nsMessenger::SetWindow(nsIDOMWindowInternal *aWin, nsIMsgWindow *aMsgWindow)
NS_IMETHODIMP nsMessenger::SetWindow(nsIDOMWindowInternal *aWin, nsIMsgWindow *aMsgWindow)
{
nsCOMPtr<nsIPrefBranch2> pbi = do_GetService(NS_PREFSERVICE_CONTRACTID);
nsresult rv;
if(!aWin)
nsCOMPtr<nsIPrefBranch2> pbi = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
if (aWin)
{
mMsgWindow = aMsgWindow;
mWindow = aWin;
nsCOMPtr<nsPIDOMWindow> win( do_QueryInterface(aWin) );
NS_ENSURE_TRUE(win, NS_ERROR_FAILURE);
nsIDocShell *docShell = win->GetDocShell();
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(docShell));
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocShellTreeItem> rootDocShellAsItem;
docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(rootDocShellAsItem));
nsCOMPtr<nsIDocShellTreeNode> rootDocShellAsNode(do_QueryInterface(rootDocShellAsItem));
if (rootDocShellAsNode)
{
nsCOMPtr<nsIDocShellTreeItem> childAsItem;
rv = rootDocShellAsNode->FindChildWithName(NS_LITERAL_STRING("messagepane").get(),
PR_TRUE, PR_FALSE, nsnull, nsnull, getter_AddRefs(childAsItem));
mDocShell = do_QueryInterface(childAsItem);
if (NS_SUCCEEDED(rv) && mDocShell) {
mCurrentDisplayCharset = ""; // Important! Clear out mCurrentDisplayCharset so we reset a default charset on mDocshell the next time we try to load something into it.
if (aMsgWindow)
{
aMsgWindow->GetTransactionManager(getter_AddRefs(mTxnMgr));
// Add pref observer
pbi->AddObserver(MAILNEWS_ALLOW_PLUGINS_PREF_NAME, this, PR_TRUE);
SetDisplayProperties();
}
}
}
// we don't always have a message pane, like in the addressbook
// so if we don't have a docshell, use the one for the xul window.
// we do this so OpenURL() will work.
if (!mDocShell)
mDocShell = docShell;
} // if aWin
else
{
// it isn't an error to pass in null for aWin, in fact it means we are shutting
// down and we should start cleaning things up...
if (mMsgWindow)
{
nsCOMPtr<nsIMsgStatusFeedback> aStatusFeedback;
mMsgWindow->GetStatusFeedback(getter_AddRefs(aStatusFeedback));
if (aStatusFeedback)
aStatusFeedback->SetDocShell(nsnull, nsnull);
// Remove pref observer
if (pbi)
pbi->RemoveObserver(MAILNEWS_ALLOW_PLUGINS_PREF_NAME, this);
}
return NS_OK;
// Remove pref observer
pbi->RemoveObserver(MAILNEWS_ALLOW_PLUGINS_PREF_NAME, this);
}
mMsgWindow = aMsgWindow;
mWindow = aWin;
nsCOMPtr<nsPIDOMWindow> win( do_QueryInterface(aWin) );
NS_ENSURE_TRUE(win, NS_ERROR_FAILURE);
nsIDocShell *docShell = win->GetDocShell();
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(docShell));
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocShellTreeItem> rootDocShellAsItem;
docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(rootDocShellAsItem));
nsCOMPtr<nsIDocShellTreeNode> rootDocShellAsNode(do_QueryInterface(rootDocShellAsItem));
if (rootDocShellAsNode)
{
nsCOMPtr<nsIDocShellTreeItem> childAsItem;
nsresult rv = rootDocShellAsNode->FindChildWithName(NS_LITERAL_STRING("messagepane").get(),
PR_TRUE, PR_FALSE, nsnull, nsnull, getter_AddRefs(childAsItem));
mDocShell = do_QueryInterface(childAsItem);
if (NS_SUCCEEDED(rv) && mDocShell) {
mCurrentDisplayCharset = ""; // Important! Clear out mCurrentDisplayCharset so we reset a default charset on mDocshell the next time we try to load something into it.
if (aMsgWindow)
{
nsCOMPtr<nsIMsgStatusFeedback> aStatusFeedback;
aMsgWindow->GetStatusFeedback(getter_AddRefs(aStatusFeedback));
if (aStatusFeedback)
aStatusFeedback->SetDocShell(mDocShell, mWindow);
aMsgWindow->GetTransactionManager(getter_AddRefs(mTxnMgr));
// Add pref observer
if (pbi)
pbi->AddObserver(MAILNEWS_ALLOW_PLUGINS_PREF_NAME, this, PR_TRUE);
SetDisplayProperties();
}
}
}
// we don't always have a message pane, like in the addressbook
// so if we don't havea docshell, use the one for the xul window.
// we do this so OpenURL() will work.
if (!mDocShell)
mDocShell = docShell;
return NS_OK;
}
@ -2672,9 +2650,12 @@ void nsDelAttachListener::SelectNewMessage()
if (displayUri.Equals(messageUri))
{
mMessageFolder->GenerateMessageURI(mNewMessageKey, getter_Copies(displayUri));
if (displayUri)
if (displayUri && mMsgWindow)
{
mMsgWindow->SelectMessage(displayUri);
nsCOMPtr<nsIMsgWindowCommands> windowCommands;
mMsgWindow->GetWindowCommands(getter_AddRefs(windowCommands));
if (windowCommands)
windowCommands->SelectMessage(displayUri);
}
}
mNewMessageKey = PR_UINT32_MAX;

Просмотреть файл

@ -81,27 +81,24 @@
static void openMailWindow(const PRUnichar * aMailWindowName, const char * aFolderUri)
{
nsCOMPtr<nsIWindowMediator> mediator ( do_GetService(NS_WINDOWMEDIATOR_CONTRACTID) );
if (!mediator)
nsCOMPtr<nsIMsgMailSession> mailSession ( do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv));
if (NS_FAILED(rv))
return;
nsCOMPtr<nsIDOMWindowInternal> domWindow;
mediator->GetMostRecentWindow(aMailWindowName, getter_AddRefs(domWindow));
if (domWindow)
nsCOMPtr<nsIMsgWindow> topMostMsgWindow;
rv = mailSession->GetTopmostMsgWindow(getter_AddRefs(topMostMsgWindow));
if (topMostMsgWindow)
{
if (aFolderUri)
{
nsCOMPtr<nsPIDOMWindow> piDOMWindow(do_QueryInterface(domWindow));
if (piDOMWindow)
{
nsCOMPtr<nsISupports> xpConnectObj;
piDOMWindow->GetObjectProperty(NS_LITERAL_STRING("MsgWindowCommands").get(), getter_AddRefs(xpConnectObj));
nsCOMPtr<nsIMsgWindowCommands> msgWindowCommands = do_QueryInterface(xpConnectObj);
if (msgWindowCommands)
msgWindowCommands->SelectFolder(aFolderUri);
}
nsCOMPtr<nsIMsgWindowCommands> windowCommands;
topMostMsgWindow->GetWindowCommands(getter_AddRefs(windowCommands));
if (windowCommands)
windowCommands->SelectFolder(aFolderUri);
}
nsCOMPtr<nsIDOMWindowInternal> domWindow;
topMostMsgWindow->GetDomWindow(getter_AddRefs(domWindow));
domWindow->Focus();
}
else

Просмотреть файл

@ -141,28 +141,26 @@ static void activateWindow( nsIDOMWindowInternal *win )
static void openMailWindow(const PRUnichar * aMailWindowName, const char * aFolderUri)
{
nsCOMPtr<nsIWindowMediator> mediator ( do_GetService(NS_WINDOWMEDIATOR_CONTRACTID) );
if (!mediator)
nsresult rv;
nsCOMPtr<nsIMsgMailSession> mailSession ( do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv));
if (NS_FAILED(rv))
return;
nsCOMPtr<nsIDOMWindowInternal> domWindow;
mediator->GetMostRecentWindow(aMailWindowName, getter_AddRefs(domWindow));
if (domWindow)
nsCOMPtr<nsIMsgWindow> topMostMsgWindow;
rv = mailSession->GetTopmostMsgWindow(getter_AddRefs(topMostMsgWindow));
if (topMostMsgWindow)
{
if (aFolderUri)
{
nsCOMPtr<nsPIDOMWindow> piDOMWindow(do_QueryInterface(domWindow));
if (piDOMWindow)
{
nsCOMPtr<nsISupports> xpConnectObj;
piDOMWindow->GetObjectProperty(NS_LITERAL_STRING("MsgWindowCommands").get(), getter_AddRefs(xpConnectObj));
nsCOMPtr<nsIMsgWindowCommands> msgWindowCommands = do_QueryInterface(xpConnectObj);
if (msgWindowCommands)
msgWindowCommands->SelectFolder(aFolderUri);
}
nsCOMPtr<nsIMsgWindowCommands> windowCommands;
topMostMsgWindow->GetWindowCommands(getter_AddRefs(windowCommands));
if (windowCommands)
windowCommands->SelectFolder(aFolderUri);
}
activateWindow(domWindow);
nsCOMPtr<nsIDOMWindowInternal> domWindow;
topMostMsgWindow->GetDomWindow(getter_AddRefs(domWindow));
if (domWindow)
activateWindow(domWindow);
}
else
{

Просмотреть файл

@ -1089,9 +1089,11 @@ NS_IMETHODIMP nsMsgDBView::SelectionChanged()
m_currentlyDisplayedViewIndex = nsMsgViewIndex_None;
// if we used to have one item selected, and now we have more than one, we should clear the message pane.
nsCOMPtr <nsIMsgMessagePaneController> controller;
if ((mNumSelectedRows == 1) && (numSelected > 1) && mMsgWindow && NS_SUCCEEDED(mMsgWindow->GetMessagePaneController(getter_AddRefs(controller))) && controller) {
controller->ClearMsgPane();
nsCOMPtr <nsIMsgWindowCommands> windowCommands;
if ((mNumSelectedRows == 1) && (numSelected > 1) && mMsgWindow
&& NS_SUCCEEDED(mMsgWindow->GetWindowCommands(getter_AddRefs(windowCommands)))
&& windowCommands) {
windowCommands->ClearMsgPane();
}
}

Просмотреть файл

@ -749,9 +749,9 @@ NS_IMETHODIMP nsMsgGroupView::LoadMessageByViewIndex(nsMsgViewIndex aViewIndex)
if (m_flags[aViewIndex] & MSG_VIEW_FLAG_DUMMY)
{
// if we used to have one item selected, and now we have more than one, we should clear the message pane.
nsCOMPtr <nsIMsgMessagePaneController> controller;
if (mMsgWindow && NS_SUCCEEDED(mMsgWindow->GetMessagePaneController(getter_AddRefs(controller))) && controller)
controller->ClearMsgPane();
nsCOMPtr <nsIMsgWindowCommands> windowCommands;
if (mMsgWindow && NS_SUCCEEDED(mMsgWindow->GetWindowCommands(getter_AddRefs(windowCommands))) && windowCommands)
windowCommands->ClearMsgPane();
return NS_OK;
}
else

Просмотреть файл

@ -345,14 +345,7 @@ NS_IMETHODIMP nsMsgProgress::ShowProgress(PRInt32 percent)
return NS_ERROR_NOT_IMPLEMENTED;
}
/* [noscript] void setDocShell (in nsIDocShell shell, in nsIDOMWindowInternal window); */
NS_IMETHODIMP nsMsgProgress::SetDocShell(nsIDocShell *shell, nsIDOMWindow *window)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void closeWindow (); */
NS_IMETHODIMP nsMsgProgress::CloseWindow()
NS_IMETHODIMP nsMsgProgress::SetWrappedStatusFeedback(nsIMsgStatusFeedback * aJSStatusFeedback)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

Просмотреть файл

@ -40,8 +40,6 @@
#include "nsXPIDLString.h"
#include "nsIWebProgress.h"
#include "nsIDOMWindowInternal.h"
#include "nsPIDOMWindow.h"
#include "nsIXULBrowserWindow.h"
#include "nsMsgStatusFeedback.h"
#include "nsIDocumentViewer.h"
@ -232,15 +230,17 @@ nsMsgStatusFeedback::OnSecurityChange(nsIWebProgress *aWebProgress,
NS_IMETHODIMP
nsMsgStatusFeedback::ShowStatusString(const PRUnichar *status)
{
if (mStatusFeedback)
mStatusFeedback->ShowStatusString(status);
nsCOMPtr<nsIMsgStatusFeedback> jsStatusFeedback(do_QueryReferent(mJSStatusFeedbackWeak));
if (jsStatusFeedback)
jsStatusFeedback->ShowStatusString(status);
return NS_OK;
}
NS_IMETHODIMP
nsMsgStatusFeedback::SetStatusString(const PRUnichar *status)
{
nsCOMPtr <nsIXULBrowserWindow> xulBrowserWindow = do_QueryInterface(mStatusFeedback);
nsCOMPtr<nsIMsgStatusFeedback> jsStatusFeedback(do_QueryReferent(mJSStatusFeedbackWeak));
nsCOMPtr <nsIXULBrowserWindow> xulBrowserWindow = do_QueryInterface(jsStatusFeedback);
if (xulBrowserWindow)
xulBrowserWindow->SetJSDefaultStatus(nsDependentString(status));
return NS_OK;
@ -272,48 +272,34 @@ nsMsgStatusFeedback::ShowProgress(PRInt32 percentage)
}
m_lastProgressTime = nowMS;
if (mStatusFeedback)
mStatusFeedback->ShowProgress(percentage);
nsCOMPtr<nsIMsgStatusFeedback> jsStatusFeedback(do_QueryReferent(mJSStatusFeedbackWeak));
if (jsStatusFeedback)
jsStatusFeedback->ShowProgress(percentage);
return NS_OK;
}
NS_IMETHODIMP
nsMsgStatusFeedback::StartMeteors()
{
if (mStatusFeedback)
mStatusFeedback->StartMeteors();
nsCOMPtr<nsIMsgStatusFeedback> jsStatusFeedback(do_QueryReferent(mJSStatusFeedbackWeak));
if (jsStatusFeedback)
jsStatusFeedback->StartMeteors();
return NS_OK;
}
NS_IMETHODIMP
nsMsgStatusFeedback::StopMeteors()
{
if (mStatusFeedback)
mStatusFeedback->StopMeteors();
nsCOMPtr<nsIMsgStatusFeedback> jsStatusFeedback(do_QueryReferent(mJSStatusFeedbackWeak));
if (jsStatusFeedback)
jsStatusFeedback->StopMeteors();
return NS_OK;
}
NS_IMETHODIMP nsMsgStatusFeedback::CloseWindow()
NS_IMETHODIMP nsMsgStatusFeedback::SetWrappedStatusFeedback(nsIMsgStatusFeedback * aJSStatusFeedback)
{
mWindow = nsnull;
mStatusFeedback = nsnull;
return NS_OK;
}
NS_IMETHODIMP nsMsgStatusFeedback::SetDocShell(nsIDocShell *shell, nsIDOMWindow *aWindow)
{
nsCOMPtr<nsPIDOMWindow> piDOMWindow(do_QueryInterface(aWindow));
if (piDOMWindow)
{
nsCOMPtr<nsISupports> xpConnectObj;
piDOMWindow->GetObjectProperty(NS_LITERAL_STRING("MsgStatusFeedback").get(), getter_AddRefs(xpConnectObj));
mStatusFeedback = do_QueryInterface(xpConnectObj);
}
mWindow = aWindow;
NS_ENSURE_ARG_POINTER(aJSStatusFeedback);
mJSStatusFeedbackWeak = do_GetWeakReference(aJSStatusFeedback);
return NS_OK;
}

Просмотреть файл

@ -39,7 +39,6 @@
#define _nsMsgStatusFeedback_h
#include "nsIWebProgressListener.h"
#include "nsIDOMWindowInternal.h"
#include "nsIObserver.h"
#include "nsITimer.h"
#include "nsCOMPtr.h"
@ -64,18 +63,16 @@ public:
NS_DECL_NSIPROGRESSEVENTSINK
protected:
nsIDOMWindow *mWindow;
PRBool m_meteorsSpinning;
PRInt32 m_lastPercent;
PRInt64 m_lastProgressTime;
void BeginObserving();
void EndObserving();
// the JS status feedback implementation object...eventually this object
// will replace this very C++ class you are looking at.
nsCOMPtr<nsIMsgStatusFeedback> mStatusFeedback;
nsWeakPtr mJSStatusFeedbackWeak;
nsCOMPtr<nsIStringBundle> mBundle;
nsCOMPtr <nsIAtom> m_msgLoadedAtom;

Просмотреть файл

@ -135,19 +135,6 @@ void nsMsgWindow::GetMessageWindowDocShell(nsIDocShell ** aDocShell)
NS_IF_ADDREF(*aDocShell);
}
/* 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) ? mMsgWindowCommands->SelectMessage(messageUri)
: NS_ERROR_NULL_POINTER;;
}
NS_IMETHODIMP nsMsgWindow::CloseWindow()
{
nsresult rv = NS_OK;
@ -155,13 +142,8 @@ NS_IMETHODIMP nsMsgWindow::CloseWindow()
if (NS_SUCCEEDED(rv))
rv = dispatcher->UnRegisterContentListener(this);
// make sure the status feedback object
// knows the window is going away...
if (mStatusFeedback)
mStatusFeedback->CloseWindow();
mMsgPaneController = nsnull;
mMsgWindowCommands = nsnull;
mStatusFeedback = nsnull;
StopUrls();
@ -187,20 +169,18 @@ NS_IMETHODIMP nsMsgWindow::GetStatusFeedback(nsIMsgStatusFeedback * *aStatusFeed
if(!aStatusFeedback)
return NS_ERROR_NULL_POINTER;
*aStatusFeedback = mStatusFeedback;
NS_IF_ADDREF(*aStatusFeedback);
NS_IF_ADDREF(*aStatusFeedback = mStatusFeedback);
return NS_OK;
}
NS_IMETHODIMP nsMsgWindow::SetStatusFeedback(nsIMsgStatusFeedback * aStatusFeedback)
{
mStatusFeedback = aStatusFeedback;
nsCOMPtr<nsIDocShell> messageWindowDocShell;
GetMessageWindowDocShell(getter_AddRefs(messageWindowDocShell));
// register our status feedback object as a web progress listener
nsCOMPtr<nsIWebProgress> webProgress(do_GetInterface(messageWindowDocShell));
mStatusFeedback = aStatusFeedback;
// register our status feedback object
if (webProgress && mStatusFeedback && messageWindowDocShell)
{
nsCOMPtr<nsIWebProgressListener> webProgressListener = do_QueryInterface(mStatusFeedback);
@ -210,18 +190,16 @@ NS_IMETHODIMP nsMsgWindow::SetStatusFeedback(nsIMsgStatusFeedback * aStatusFeedb
return NS_OK;
}
NS_IMETHODIMP nsMsgWindow::GetMessagePaneController(nsIMsgMessagePaneController * * aMsgPaneController)
NS_IMETHODIMP nsMsgWindow::SetWindowCommands(nsIMsgWindowCommands * aMsgWindowCommands)
{
NS_ENSURE_ARG(aMsgPaneController);
*aMsgPaneController = mMsgPaneController;
NS_IF_ADDREF(*aMsgPaneController);
mMsgWindowCommands = aMsgWindowCommands;
return NS_OK;
}
NS_IMETHODIMP nsMsgWindow::SetMessagePaneController(nsIMsgMessagePaneController * aMsgPaneController)
NS_IMETHODIMP nsMsgWindow::GetWindowCommands(nsIMsgWindowCommands **aMsgWindowCommands)
{
mMsgPaneController = aMsgPaneController;
NS_ENSURE_ARG_POINTER(aMsgWindowCommands);
NS_IF_ADDREF(*aMsgWindowCommands = mMsgWindowCommands);
return NS_OK;
}
@ -338,12 +316,20 @@ NS_IMETHODIMP nsMsgWindow::SetCharsetOverride(PRBool aCharsetOverride)
return NS_OK;
}
NS_IMETHODIMP nsMsgWindow::SetDOMWindow(nsIDOMWindowInternal *aWindow)
NS_IMETHODIMP nsMsgWindow::GetDomWindow(nsIDOMWindowInternal **aWindow)
{
if (!aWindow)
return NS_ERROR_NULL_POINTER;
NS_ENSURE_ARG_POINTER(aWindow);
if (mDomWindow)
CallQueryReferent(mDomWindow.get(), aWindow);
else
*aWindow = nsnull;
return NS_OK;
}
nsresult rv = NS_OK;
NS_IMETHODIMP nsMsgWindow::SetDomWindow(nsIDOMWindowInternal * aWindow)
{
NS_ENSURE_ARG_POINTER(aWindow);
mDomWindow = do_GetWeakReference(aWindow);
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(aWindow));
nsIDocShell *docShell = nsnull;
@ -363,19 +349,9 @@ NS_IMETHODIMP nsMsgWindow::SetDOMWindow(nsIDOMWindowInternal *aWindow)
// force ourselves to figure out the message pane
nsCOMPtr<nsIDocShell> messageWindowDocShell;
GetMessageWindowDocShell(getter_AddRefs(messageWindowDocShell));
SetStatusFeedback(mStatusFeedback);
}
//Get nsIMsgWindowCommands object
nsCOMPtr<nsISupports> xpConnectObj;
nsCOMPtr<nsPIDOMWindow> piDOMWindow(do_QueryInterface(aWindow));
if (piDOMWindow)
{
piDOMWindow->GetObjectProperty(NS_LITERAL_STRING("MsgWindowCommands").get(), getter_AddRefs(xpConnectObj));
mMsgWindowCommands = do_QueryInterface(xpConnectObj);
}
return rv;
return NS_OK;
}
NS_IMETHODIMP nsMsgWindow::StopUrls()
@ -505,8 +481,8 @@ nsMsgWindow::DisplayHTMLInMessagePane(const PRUnichar *title, const PRUnichar *b
{
nsresult rv;
if (clearMsgHdr && mMsgPaneController)
mMsgPaneController->ClearMsgPane();
if (clearMsgHdr && mMsgWindowCommands)
mMsgWindowCommands->ClearMsgPane();
nsString htmlStr;
htmlStr.Append(NS_LITERAL_STRING("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></head><body>").get());

Просмотреть файл

@ -67,7 +67,6 @@ public:
protected:
nsCOMPtr<nsIMsgHeaderSink> mMsgHeaderSink;
nsCOMPtr<nsIMsgStatusFeedback> mStatusFeedback;
nsCOMPtr<nsIMsgMessagePaneController> mMsgPaneController;
nsCOMPtr<nsITransactionManager> mTransactionManager;
nsCOMPtr<nsIMsgFolder> mOpenFolder;
nsCOMPtr<nsIMsgWindowCommands> mMsgWindowCommands;
@ -75,6 +74,7 @@ protected:
// let's not make this a strong ref - we don't own it.
nsWeakPtr mRootDocShellWeak;
nsWeakPtr mMessageWindowDocShellWeak;
nsWeakPtr mDomWindow;
nsCString mMailCharacterSet;
PRBool mCharsetOverride;

Просмотреть файл

@ -1867,7 +1867,7 @@ function GenericSendMessage( msgType )
progress.registerListener(progressListener);
gSendOrSaveOperationInProgress = true;
}
msgWindow.SetDOMWindow(window);
msgWindow.domWindow = window;
msgWindow.rootDocShell.allowAuth = true;
gMsgCompose.SendMsg(msgType, getCurrentIdentity(), currentAccountKey, msgWindow, progress);
}

Просмотреть файл

@ -5048,7 +5048,10 @@ nsImapMailFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode)
if (msgFolder)
{
msgFolder->GetURI(getter_Copies(uri));
msgWindow->SelectFolder(uri.get());
nsCOMPtr<nsIMsgWindowCommands> windowCommands;
msgWindow->GetWindowCommands(getter_AddRefs(windowCommands));
if (windowCommands)
windowCommands->SelectFolder(uri.get());
}
}
}

Просмотреть файл

@ -2729,9 +2729,12 @@ NS_IMETHODIMP nsImapService::NewChannel(nsIURI *aURI, nsIChannel **_retval)
{
nsXPIDLCString uri;
rootFolder->GetURI(getter_Copies(uri));
uri.Append('/');
uri.Append('/');
uri.Append(fullFolderName);
msgWindow->SelectFolder(uri.get());
nsCOMPtr<nsIMsgWindowCommands> windowCommands;
msgWindow->GetWindowCommands(getter_AddRefs(windowCommands));
if (windowCommands)
windowCommands->SelectFolder(uri.get());
// error out this channel, so it'll stop trying to run the url.
*_retval = nsnull;
rv = NS_ERROR_FAILURE;

Просмотреть файл

@ -3133,7 +3133,10 @@ NS_IMETHODIMP nsMsgLocalMailFolder::SelectDownloadMsg()
{
nsCAutoString newuri;
nsBuildLocalMessageURI(mBaseMessageURI, mDownloadSelectKey, newuri);
mDownloadWindow->SelectMessage(newuri.get());
nsCOMPtr<nsIMsgWindowCommands> windowCommands;
mDownloadWindow->GetWindowCommands(getter_AddRefs(windowCommands));
if (windowCommands)
windowCommands->SelectMessage(newuri.get());
mDownloadState = DOWNLOAD_STATE_DIDSEL;
}
return NS_OK;
@ -3327,9 +3330,12 @@ nsMsgLocalMailFolder::OnStopRunningUrl(nsIURI * aUrl, nsresult aExitCode)
if (NS_SUCCEEDED(rv))
{
pop3sink->GetMessageUri(getter_Copies(newMessageUri));
if(msgWindow)
if (msgWindow)
{
msgWindow->SelectMessage(newMessageUri);
nsCOMPtr<nsIMsgWindowCommands> windowCommands;
msgWindow->GetWindowCommands(getter_AddRefs(windowCommands));
if (windowCommands)
windowCommands->SelectMessage(newMessageUri);
}
}
}