diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index b4edeea3a40..c67f952c8a9 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -2308,11 +2308,22 @@ nsDocShell::OnStateChange(nsIWebProgress *aProgress, nsIRequest *aRequest, } NS_IMETHODIMP -nsDocShell::OnLocationChange(nsIURI *aURI) +nsDocShell::OnLocationChange(nsIWebProgress *aProgress, + nsIRequest *aRequest, + nsIURI *aURI) { return NS_OK; } +NS_IMETHODIMP +nsDocShell::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) +{ + return NS_OK; +} + //***************************************************************************** // nsDocShell: Content Viewer Management //***************************************************************************** @@ -3275,7 +3286,7 @@ void nsDocShell::SetCurrentURI(nsIURI* aURI) NS_ASSERTION(loader, "No document loader"); if (loader) { - loader->FireOnLocationChange(aURI); + loader->FireOnLocationChange(nsnull, nsnull, aURI); } } diff --git a/embedding/browser/activex/src/control/WebBrowserContainer.cpp b/embedding/browser/activex/src/control/WebBrowserContainer.cpp index 42005a9ee2e..a3e1aee0fb3 100644 --- a/embedding/browser/activex/src/control/WebBrowserContainer.cpp +++ b/embedding/browser/activex/src/control/WebBrowserContainer.cpp @@ -263,13 +263,23 @@ NS_IMETHODIMP CWebBrowserContainer::OnStateChange(nsIWebProgress* aWebProgress, /* void onLocationChange (in nsIURI location); */ -NS_IMETHODIMP CWebBrowserContainer::OnLocationChange(nsIURI *location) +NS_IMETHODIMP CWebBrowserContainer::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI *location) { // nsXPIDLCString aPath; // location->GetPath(getter_Copies(aPath)); return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +CWebBrowserContainer::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) +{ + return NS_OK; +} /////////////////////////////////////////////////////////////////////////////// // nsIURIContentListener diff --git a/embedding/browser/gtk/src/GtkMozEmbedChrome.cpp b/embedding/browser/gtk/src/GtkMozEmbedChrome.cpp index ab1eb0a34eb..5ec0ae69faa 100644 --- a/embedding/browser/gtk/src/GtkMozEmbedChrome.cpp +++ b/embedding/browser/gtk/src/GtkMozEmbedChrome.cpp @@ -680,7 +680,9 @@ NS_IMETHODIMP GtkMozEmbedChrome::OnStateChange(nsIWebProgress *progress, nsIRequ return NS_OK; } -NS_IMETHODIMP GtkMozEmbedChrome::OnLocationChange(nsIURI *aLocation) +NS_IMETHODIMP GtkMozEmbedChrome::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI *aLocation) { PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::OnLocationChange\n")); char *newURIString = NULL; @@ -694,6 +696,15 @@ NS_IMETHODIMP GtkMozEmbedChrome::OnLocationChange(nsIURI *aLocation) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +GtkMozEmbedChrome::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) +{ + return NS_OK; +} + // nsIBaseWindow interface NS_IMETHODIMP GtkMozEmbedChrome::InitWindow(nativeWindow parentNativeWindow, diff --git a/embedding/browser/photon/src/MozEmbedChrome.cpp b/embedding/browser/photon/src/MozEmbedChrome.cpp index 790cf0510a1..fd918fbe3ae 100644 --- a/embedding/browser/photon/src/MozEmbedChrome.cpp +++ b/embedding/browser/photon/src/MozEmbedChrome.cpp @@ -680,7 +680,9 @@ NS_IMETHODIMP MozEmbedChrome::OnStateChange(nsIWebProgress *progress, nsIRequest return NS_OK; } -NS_IMETHODIMP MozEmbedChrome::OnLocationChange(nsIURI *aLocation) +NS_IMETHODIMP MozEmbedChrome::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI *aLocation) { PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("MozEmbedChrome::OnLocationChange\n")); char *newURIString = NULL; @@ -694,6 +696,15 @@ NS_IMETHODIMP MozEmbedChrome::OnLocationChange(nsIURI *aLocation) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +MozEmbedChrome::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) +{ + return NS_OK; +} + // nsIBaseWindow interface NS_IMETHODIMP MozEmbedChrome::InitWindow(nativeWindow parentNativeWindow, diff --git a/embedding/browser/powerplant/source/CWebBrowserChrome.cpp b/embedding/browser/powerplant/source/CWebBrowserChrome.cpp index 0d8d0a247e0..3f8518e6696 100644 --- a/embedding/browser/powerplant/source/CWebBrowserChrome.cpp +++ b/embedding/browser/powerplant/source/CWebBrowserChrome.cpp @@ -277,7 +277,9 @@ NS_IMETHODIMP CWebBrowserChrome::OnStateChange(nsIWebProgress *progress, nsIRequ } -NS_IMETHODIMP CWebBrowserChrome::OnLocationChange(nsIURI *location) +NS_IMETHODIMP CWebBrowserChrome::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI *location) { NS_ENSURE_TRUE(mBrowserWindow, NS_ERROR_NOT_INITIALIZED); @@ -295,6 +297,14 @@ NS_IMETHODIMP CWebBrowserChrome::OnLocationChange(nsIURI *location) return NS_OK; } +NS_IMETHODIMP +CWebBrowserChrome::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) +{ + return NS_OK; +} //***************************************************************************** // CWebBrowserChrome::nsIBaseWindow diff --git a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp index fa559f1a218..fb98143e5b5 100644 --- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp +++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp @@ -452,12 +452,26 @@ nsDocShellTreeOwner::OnStateChange(nsIWebProgress* aProgress, aStatus); } -NS_IMETHODIMP nsDocShellTreeOwner::OnLocationChange(nsIURI* aURI) +NS_IMETHODIMP nsDocShellTreeOwner::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI* aURI) { if(!mOwnerProgressListener) return NS_OK; - return mOwnerProgressListener->OnLocationChange(aURI); + return mOwnerProgressListener->OnLocationChange(aWebProgress, aRequest, aURI); +} + +NS_IMETHODIMP +nsDocShellTreeOwner::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) +{ + if(!mOwnerProgressListener) + return NS_OK; + + return mOwnerProgressListener->OnStatusChange(aWebProgress, aRequest, aStatus, aMessage); } //***************************************************************************** diff --git a/embedding/tests/winEmbed/WebBrowserChrome.cpp b/embedding/tests/winEmbed/WebBrowserChrome.cpp index e10d0a3d3b5..079098c12be 100644 --- a/embedding/tests/winEmbed/WebBrowserChrome.cpp +++ b/embedding/tests/winEmbed/WebBrowserChrome.cpp @@ -215,11 +215,21 @@ NS_IMETHODIMP WebBrowserChrome::OnStateChange(nsIWebProgress *progress, nsIReque } -NS_IMETHODIMP WebBrowserChrome::OnLocationChange(nsIURI *location) +NS_IMETHODIMP WebBrowserChrome::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI *location) { return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +WebBrowserChrome::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) +{ + return NS_OK; +} //***************************************************************************** // WebBrowserChrome::nsIBaseWindow diff --git a/extensions/datetime/nsDateTimeChannel.cpp b/extensions/datetime/nsDateTimeChannel.cpp index b7ea8b5ccf3..881d14768c9 100644 --- a/extensions/datetime/nsDateTimeChannel.cpp +++ b/extensions/datetime/nsDateTimeChannel.cpp @@ -339,7 +339,7 @@ NS_IMETHODIMP nsDateTimeChannel::SetLoadGroup(nsILoadGroup* aLoadGroup) { if (mLoadGroup) // if we already had a load group remove ourselves... - (void)mLoadGroup->RemoveChannel(this, nsnull, nsnull, nsnull); + (void)mLoadGroup->RemoveChannel(this, nsnull, NS_OK, nsnull); mLoadGroup = aLoadGroup; if (mLoadGroup) { @@ -394,12 +394,12 @@ nsDateTimeChannel::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { NS_IMETHODIMP nsDateTimeChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, - nsresult aStatus, const PRUnichar* aMsg) { + nsresult aStatus, const PRUnichar* aStatusArg) { if (mLoadGroup) { - nsresult rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aMsg); + nsresult rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aStatusArg); if (NS_FAILED(rv)) return rv; } - return mListener->OnStopRequest(this, aContext, aStatus, aMsg); + return mListener->OnStopRequest(this, aContext, aStatus, aStatusArg); } diff --git a/extensions/finger/nsFingerChannel.cpp b/extensions/finger/nsFingerChannel.cpp index 106a638fea8..465a1d89770 100644 --- a/extensions/finger/nsFingerChannel.cpp +++ b/extensions/finger/nsFingerChannel.cpp @@ -443,7 +443,8 @@ nsFingerChannel::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { NS_IMETHODIMP nsFingerChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, - nsresult aStatus, const PRUnichar* aMsg) { + nsresult aStatus, const PRUnichar* aStatusArg) +{ #ifdef DEBUG_bryner printf("nsFingerChannel::OnStopRequest, mActAsObserver=%d\n", mActAsObserver); @@ -453,10 +454,10 @@ nsFingerChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, if (NS_FAILED(aStatus) || !mActAsObserver) { if (mLoadGroup) { - rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aMsg); + rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aStatusArg); if (NS_FAILED(rv)) return rv; } - rv = mListener->OnStopRequest(this, aContext, aStatus, aMsg); + rv = mListener->OnStopRequest(this, aContext, aStatus, aStatusArg); mTransport = 0; return rv; } else { diff --git a/extensions/psm-glue/src/nsSecureBrowserUIImpl.cpp b/extensions/psm-glue/src/nsSecureBrowserUIImpl.cpp index 9d118c31648..d586f7e0251 100644 --- a/extensions/psm-glue/src/nsSecureBrowserUIImpl.cpp +++ b/extensions/psm-glue/src/nsSecureBrowserUIImpl.cpp @@ -446,7 +446,9 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress, NS_IMETHODIMP -nsSecureBrowserUIImpl::OnLocationChange(nsIURI* aLocation) +nsSecureBrowserUIImpl::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI* aLocation) { mCurrentURI = aLocation; @@ -459,6 +461,14 @@ nsSecureBrowserUIImpl::OnLocationChange(nsIURI* aLocation) return NS_OK; } +NS_IMETHODIMP +nsSecureBrowserUIImpl::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) +{ + return NS_OK; +} nsresult nsSecureBrowserUIImpl::IsURLHTTPS(nsIURI* aURL, PRBool* value) diff --git a/htmlparser/src/nsParser.cpp b/htmlparser/src/nsParser.cpp index 9c1336357d9..b0ae7136688 100644 --- a/htmlparser/src/nsParser.cpp +++ b/htmlparser/src/nsParser.cpp @@ -2030,13 +2030,15 @@ nsParser::OnProgress(nsIChannel* channel, nsISupports* aContext, PRUint32 aProgr * @return error code -- 0 if ok, non-zero if error. */ nsresult -nsParser::OnStatus(nsIChannel* channel, nsISupports* aContext, const PRUnichar* aMsg) +nsParser::OnStatus(nsIChannel* channel, nsISupports* aContext, + nsresult aStatus, const PRUnichar* aStatusArg) { - nsresult result=0; + nsresult rv; if (nsnull != mProgressEventSink) { - mProgressEventSink->OnStatus(channel, aContext, aMsg); + rv = mProgressEventSink->OnStatus(channel, aContext, aStatus, aStatusArg); + NS_ASSERTION(NS_SUCCEEDED(rv), "dropping error result"); } - return result; + return NS_OK; } #ifdef rickgdebug diff --git a/htmlparser/src/nsParser.h b/htmlparser/src/nsParser.h index 0d4db268fda..9257e3303cb 100644 --- a/htmlparser/src/nsParser.h +++ b/htmlparser/src/nsParser.h @@ -69,6 +69,7 @@ #include "nsHTMLTags.h" #include "nsDTDUtils.h" #include "nsTimer.h" +#include "nsIProgressEventSink.h" class IContentSink; class nsIDTD; @@ -250,9 +251,7 @@ CLASS_EXPORT_HTMLPARS nsParser : public nsIParser, // These methods are callback methods used by // net lib to let us know about our inputstream. //********************************************* - // nsIProgressEventSink methods: - NS_IMETHOD OnProgress(nsIChannel* channel, nsISupports* context, PRUint32 Progress, PRUint32 ProgressMax); - NS_IMETHOD OnStatus(nsIChannel* channel, nsISupports* context, const PRUnichar* aMmsg); + NS_DECL_NSIPROGRESSEVENTSINK // nsIStreamObserver methods: NS_DECL_NSISTREAMOBSERVER diff --git a/intl/strres/public/nsIStringBundle.idl b/intl/strres/public/nsIStringBundle.idl index d693473e133..45d03d8243e 100644 --- a/intl/strres/public/nsIStringBundle.idl +++ b/intl/strres/public/nsIStringBundle.idl @@ -73,4 +73,14 @@ interface nsIStringBundleService : nsISupports nsIStringBundle CreateExtensibleBundle([const] in string aRegistryKey, in nsILocale aLocale); + + /** + * Formats a message string from a status code and status arguments. + * @param aStatus - The status code. This is mapped into a string ID and + * and used in the string lookup process (see nsIErrorService). + * @param aStatusArg - The status message argument(s). Multiple arguments + * can be separated by newline ('\n') characters. + * @return the formatted message + */ + wstring formatStatusMessage(in nsresult aStatus, in wstring aStatusArg); }; diff --git a/intl/strres/src/nsStringBundle.cpp b/intl/strres/src/nsStringBundle.cpp index 8fb98c44617..34af243b281 100644 --- a/intl/strres/src/nsStringBundle.cpp +++ b/intl/strres/src/nsStringBundle.cpp @@ -49,12 +49,14 @@ #include "nsAutoLock.h" #include "nsTextFormatter.h" #include "nsIChromeRegistry.h" +#include "nsIErrorService.h" #include "nsAcceptLang.h" // for nsIAcceptLang static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID); static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID); +static NS_DEFINE_CID(kErrorServiceCID, NS_ERRORSERVICE_CID); // XXX investigate need for proper locking in this module //static PRInt32 gLockCount = 0; @@ -181,7 +183,8 @@ nsStringBundle::FormatStringFromName(const PRUnichar *aName, PRUnichar **aResult) { nsAutoString formatStr; - GetStringFromName(aName, formatStr); + nsresult rv = GetStringFromName(aName, formatStr); + if (NS_FAILED(rv)) return rv; return FormatString(formatStr.GetUnicode(), aParams, aLength, aResult); } @@ -657,7 +660,10 @@ public: private: nsresult getStringBundle(const char *aUrl, nsILocale* aLocale, nsIStringBundle** aResult); - + nsresult FormatWithBundle(nsIStringBundle* bundle, nsresult aStatus, + PRUint32 argCount, PRUnichar** argArray, + PRUnichar* *result); + bundleCacheEntry_t *insertIntoCache(nsIStringBundle *aBundle, nsStringKey *aHashKey); @@ -668,7 +674,8 @@ private: PLArenaPool mCacheEntryPool; // reuse the same uri structure over and over - nsCOMPtr mScratchUri; + nsCOMPtr mScratchUri; + nsCOMPtr mErrorService; }; nsStringBundleService::nsStringBundleService() : @@ -686,6 +693,8 @@ nsStringBundleService::nsStringBundleService() : mScratchUri = do_CreateInstance(kStandardUrlCID); NS_ASSERTION(mScratchUri, "Couldn't create scratch URI"); + mErrorService = do_GetService(kErrorServiceCID); + NS_ASSERTION(mErrorService, "Couldn't get error service"); } nsStringBundleService::~nsStringBundleService() @@ -855,6 +864,119 @@ nsStringBundleService::CreateExtensibleBundle(const char* aRegistryKey, return res; } +#define GLOBAL_PROPERTIES "chrome://global/locale/xpcom.properties" + +nsresult +nsStringBundleService::FormatWithBundle(nsIStringBundle* bundle, nsresult aStatus, + PRUint32 argCount, PRUnichar** argArray, + PRUnichar* *result) +{ + nsresult rv; + nsXPIDLCString key; + + // then find a key into the string bundle for that particular error: + rv = mErrorService->GetErrorStringBundleKey(aStatus, getter_Copies(key)); + + // first try looking up the error message with the string key: + if (NS_SUCCEEDED(rv)) { + nsAutoString name; name.AssignWithConversion(key); + rv = bundle->FormatStringFromName(name.GetUnicode(), (const PRUnichar**)argArray, + argCount, result); + } + + // if the string key fails, try looking up the error message with the int key: + if (NS_FAILED(rv)) { + PRUint16 code = NS_ERROR_GET_CODE(aStatus); + rv = bundle->FormatStringFromID(code, (const PRUnichar**)argArray, argCount, result); + } + + // If the int key fails, try looking up the default error message. E.g. print: + // An unknown error has occurred (0x804B0003). + if (NS_FAILED(rv)) { + nsAutoString statusStr; statusStr.AppendInt(aStatus, 16); + const PRUnichar* otherArgArray[1]; + otherArgArray[0] = statusStr.GetUnicode(); + PRUint16 code = NS_ERROR_GET_CODE(NS_ERROR_FAILURE); + rv = bundle->FormatStringFromID(code, otherArgArray, 1, result); + } + + return rv; +} + +NS_IMETHODIMP +nsStringBundleService::FormatStatusMessage(nsresult aStatus, + const PRUnichar* aStatusArg, + PRUnichar* *result) +{ + nsresult rv; + PRUint32 i, argCount = 0; + nsCOMPtr bundle; + nsXPIDLCString stringBundleURL; + + // XXX hack for mailnews who has already formatted their messages: + if (aStatus == NS_OK && aStatusArg) { + *result = nsCRT::strdup(aStatusArg); + return NS_OK; + } + + if (aStatus == NS_OK) { + return NS_ERROR_FAILURE; // no message to format + } + + // format the arguments: + nsAutoString args(aStatusArg); + argCount = args.CountChar('\n') + 1; + NS_ENSURE_ARG(argCount <= 10); // enforce 10-parameter limit + PRUnichar* argArray[10]; + + // convert the aStatusArg into a PRUnichar array + if (argCount == 1) { + // avoid construction for the simple case: + argArray[0] = (PRUnichar*)aStatusArg; + } + else if (argCount > 1) { + PRInt32 offset = 0; + for (i = 0; i < argCount; i++) { + PRInt32 pos = args.FindChar('\n', PR_FALSE, offset); + if (pos = -1) + pos = args.Length(); + nsAutoString arg; + args.Mid(arg, offset, pos); + argArray[i] = arg.ToNewUnicode(); + if (argArray[i] == nsnull) { + rv = NS_ERROR_OUT_OF_MEMORY; + argCount = i - 1; // don't try to free uninitialized memory + goto done; + } + offset = pos + 1; + } + } + + // find the string bundle for the error's module: + rv = mErrorService->GetErrorStringBundle(NS_ERROR_GET_MODULE(aStatus), + getter_Copies(stringBundleURL)); + if (NS_SUCCEEDED(rv)) { + rv = getStringBundle(stringBundleURL, nsnull, getter_AddRefs(bundle)); + if (NS_SUCCEEDED(rv)) { + rv = FormatWithBundle(bundle, aStatus, argCount, argArray, result); + } + } + if (NS_FAILED(rv)) { + rv = getStringBundle(GLOBAL_PROPERTIES, nsnull, getter_AddRefs(bundle)); + if (NS_SUCCEEDED(rv)) { + rv = FormatWithBundle(bundle, aStatus, argCount, argArray, result); + } + } + +done: + if (argCount > 1) { + for (i = 0; i < argCount; i++) { + if (argArray[i]) + nsMemory::Free(argArray[i]); + } + } + return rv; +} NS_IMETHODIMP NS_NewStringBundleService(nsISupports* aOuter, const nsIID& aIID, diff --git a/mailnews/base/src/nsMsgStatusFeedback.cpp b/mailnews/base/src/nsMsgStatusFeedback.cpp index be7369a0eb2..bb84b1c7c77 100644 --- a/mailnews/base/src/nsMsgStatusFeedback.cpp +++ b/mailnews/base/src/nsMsgStatusFeedback.cpp @@ -138,11 +138,22 @@ nsMsgStatusFeedback::OnStateChange(nsIWebProgress* aWebProgress, return NS_OK; } -NS_IMETHODIMP nsMsgStatusFeedback::OnLocationChange(nsIURI* aLocation) +NS_IMETHODIMP nsMsgStatusFeedback::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI* aLocation) { return NS_OK; } +NS_IMETHODIMP +nsMsgStatusFeedback::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) +{ + return NS_OK; +} + NS_IMETHODIMP nsMsgStatusFeedback::ShowStatusString(const PRUnichar *status) { @@ -340,7 +351,15 @@ NS_IMETHODIMP nsMsgStatusFeedback::OnProgress(nsIChannel* channel, nsISupports* aProgress /* current total progress */, aProgressMax /* max total progress */); } -NS_IMETHODIMP nsMsgStatusFeedback::OnStatus(nsIChannel* channel, nsISupports* ctxt, const PRUnichar* aMsg) +NS_IMETHODIMP nsMsgStatusFeedback::OnStatus(nsIChannel* channel, nsISupports* ctxt, + nsresult aStatus, const PRUnichar* aStatusArg) { - return ShowStatusString(aMsg); + nsresult rv; + nsCOMPtr sbs = do_GetService(kStringBundleServiceCID, &rv); + if (NS_FAILED(rv)) return rv; + nsXPIDLString str; + rv = sbs->FormatStatusMessage(aStatus, aStatusArg, getter_Copies(str)); + if (NS_FAILED(rv)) return rv; + nsAutoString msg = str; + return ShowStatusString(msg.GetUnicode()); } diff --git a/mailnews/compose/src/nsURLFetcher.cpp b/mailnews/compose/src/nsURLFetcher.cpp index f60e6aaf50c..12e3bc47ec4 100644 --- a/mailnews/compose/src/nsURLFetcher.cpp +++ b/mailnews/compose/src/nsURLFetcher.cpp @@ -410,7 +410,19 @@ nsURLFetcher::OnStateChange(nsIWebProgress *aProgress, nsIRequest *aRequest, } NS_IMETHODIMP -nsURLFetcher::OnLocationChange(nsIURI *aURI) +nsURLFetcher::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI *aURI) { return NS_OK; } + +NS_IMETHODIMP +nsURLFetcher::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) +{ + return NS_OK; +} + diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index fcbbe47f976..3bdf8c8ecfb 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -3563,7 +3563,7 @@ nsImapMailFolder::ProgressStatus(nsIImapProtocol* aProtocol, nsTextFormatter::smprintf_free(printfString); } } - progressSink->OnStatus(mockChannel, nsnull, progressMsg); + progressSink->OnStatus(mockChannel, nsnull, NS_OK, progressMsg); // XXX i18n message } } } @@ -3592,7 +3592,7 @@ nsImapMailFolder::PercentProgress(nsIImapProtocol* aProtocol, { progressSink->OnProgress(mockChannel, nsnull, aInfo->currentProgress, aInfo->maxProgress); if (aInfo->message) - progressSink->OnStatus(mockChannel, nsnull, aInfo->message); + progressSink->OnStatus(mockChannel, nsnull, NS_OK, aInfo->message); // XXX i18n message } diff --git a/mailnews/local/src/nsPop3Protocol.cpp b/mailnews/local/src/nsPop3Protocol.cpp index f98a62ba85f..e742f0284e7 100644 --- a/mailnews/local/src/nsPop3Protocol.cpp +++ b/mailnews/local/src/nsPop3Protocol.cpp @@ -472,8 +472,8 @@ void nsPop3Protocol::UpdateStatus(PRInt32 aStatusID) { if (m_statusFeedback) { - PRUnichar * statusString = nsnull; - mStringService->GetStringByID(aStatusID, &statusString); + PRUnichar * statusString = nsnull; + mStringService->GetStringByID(aStatusID, &statusString); UpdateStatusWithString(statusString); nsCRT::free(statusString); } @@ -481,8 +481,11 @@ void nsPop3Protocol::UpdateStatus(PRInt32 aStatusID) void nsPop3Protocol::UpdateStatusWithString(PRUnichar * aStatusString) { - if (mProgressEventSink) - mProgressEventSink->OnStatus(this, m_channelContext, aStatusString); + nsresult rv; + if (mProgressEventSink) { + rv = mProgressEventSink->OnStatus(this, m_channelContext, NS_OK, aStatusString); // XXX i18n message + NS_ASSERTION(NS_SUCCEEDED(rv), "dropping error result"); + } } void nsPop3Protocol::UpdateProgressPercent (PRUint32 totalDone, PRUint32 total) @@ -674,7 +677,9 @@ nsresult nsPop3Protocol::LoadUrl(nsIURI* aURL, nsISupports * /* aConsumer */) server->SetServerBusy(PR_TRUE); // the server is now busy } - m_pop3ConData->uidlinfo = net_pop3_load_state(host, GetUsername(), mailDirectory); + m_pop3ConData->uidlinfo = net_pop3_load_state(host, GetUsername(), mailDirectory); + + m_pop3ConData->uidlinfo = net_pop3_load_state(host, GetUsername(), mailDirectory); m_pop3ConData->biffstate = nsIMsgFolder::nsMsgBiffState_NoMail; const char* uidl = PL_strcasestr(queryPart, "uidl="); diff --git a/mailnews/news/src/nsNNTPProtocol.cpp b/mailnews/news/src/nsNNTPProtocol.cpp index 8f9bf409f51..613a2704347 100644 --- a/mailnews/news/src/nsNNTPProtocol.cpp +++ b/mailnews/news/src/nsNNTPProtocol.cpp @@ -5014,12 +5014,14 @@ void nsNNTPProtocol::SetProgressBarPercent(PRUint32 aProgress, PRUint32 aProgres void nsNNTPProtocol::SetProgressStatus(char *message) { + nsresult rv; PR_LOG(NNTP,PR_LOG_ALWAYS,("nsNNTPProtocol::SetProgressStatus(%s)",message)); if (mProgressEventSink) { nsAutoString formattedString; formattedString.AssignWithConversion(message); - mProgressEventSink->OnStatus(this, m_channelContext, formattedString.GetUnicode()); + rv = mProgressEventSink->OnStatus(this, m_channelContext, NS_OK, formattedString.GetUnicode()); // XXX i18n message + NS_ASSERTION(NS_SUCCEEDED(rv), "dropping error result"); } } diff --git a/modules/libjar/nsJARChannel.cpp b/modules/libjar/nsJARChannel.cpp index 71a471c6b07..5db30a99d94 100644 --- a/modules/libjar/nsJARChannel.cpp +++ b/modules/libjar/nsJARChannel.cpp @@ -72,10 +72,8 @@ public: return NS_OK; } - NS_IMETHOD OnStopRequest(nsIChannel* jarCacheTransport, - nsISupports* context, - nsresult status, - const PRUnichar* aMsg) { + NS_IMETHOD OnStopRequest(nsIChannel* jarCacheTransport, nsISupports* context, + nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; nsAutoMonitor monitor(mJARChannel->mMonitor); @@ -88,11 +86,11 @@ public: if (NS_SUCCEEDED(rv)) { PR_LOG(gJarProtocolLog, PR_LOG_DEBUG, ("nsJarProtocol: jar download complete %s status=%x", - (const char*)jarURLStr, status)); + (const char*)jarURLStr, aStatus)); } } #endif - if (NS_SUCCEEDED(status) && mJARChannel->mJarCacheTransport) { + if (NS_SUCCEEDED(aStatus) && mJARChannel->mJarCacheTransport) { NS_ASSERTION(jarCacheTransport == (mJARChannel->mJarCacheTransport).get(), "wrong transport"); // after successfully downloading the jar file to the cache, @@ -528,7 +526,7 @@ nsJARChannel::EnsureJARFileAvailable(OnJARFileAvailableFun onJARFileAvailable, error: if (NS_FAILED(rv) && mLoadGroup) { - nsresult rv2 = mLoadGroup->RemoveChannel(this, nsnull, rv, nsnull); // XXX fix error message + nsresult rv2 = mLoadGroup->RemoveChannel(this, nsnull, NS_OK, nsnull); NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveChannel failed"); } return rv; @@ -864,10 +862,8 @@ nsJARChannel::OnStartRequest(nsIChannel* jarExtractionTransport, } NS_IMETHODIMP -nsJARChannel::OnStopRequest(nsIChannel* jarExtractionTransport, - nsISupports* context, - nsresult status, - const PRUnichar* aMsg) +nsJARChannel::OnStopRequest(nsIChannel* jarExtractionTransport, nsISupports* context, + nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; #ifdef PR_LOGGING @@ -877,14 +873,14 @@ nsJARChannel::OnStopRequest(nsIChannel* jarExtractionTransport, if (NS_SUCCEEDED(rv)) { PR_LOG(gJarProtocolLog, PR_LOG_DEBUG, ("nsJarProtocol: jar extraction complete %s status=%x", - (const char*)jarURLStr, status)); + (const char*)jarURLStr, aStatus)); } #endif - rv = mUserListener->OnStopRequest(this, mUserContext, status, aMsg); + rv = mUserListener->OnStopRequest(this, mUserContext, aStatus, aStatusArg); if (mLoadGroup) { if (NS_SUCCEEDED(rv)) { - mLoadGroup->RemoveChannel(this, context, status, aMsg); + mLoadGroup->RemoveChannel(this, context, aStatus, aStatusArg); } } diff --git a/modules/plugin/base/src/nsPluginHostImpl.cpp b/modules/plugin/base/src/nsPluginHostImpl.cpp index 9fdbd96e380..2b6281d949b 100644 --- a/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -1170,8 +1170,9 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnProgress(nsIChannel* channel, } NS_IMETHODIMP nsPluginStreamListenerPeer::OnStatus(nsIChannel* channel, - nsISupports* aContext, - const PRUnichar* aMsg) + nsISupports* aContext, + nsresult aStatus, + const PRUnichar* aStatusArg) { return NS_OK; } diff --git a/modules/plugin/nglsrc/nsPluginHostImpl.cpp b/modules/plugin/nglsrc/nsPluginHostImpl.cpp index 9fdbd96e380..2b6281d949b 100644 --- a/modules/plugin/nglsrc/nsPluginHostImpl.cpp +++ b/modules/plugin/nglsrc/nsPluginHostImpl.cpp @@ -1170,8 +1170,9 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnProgress(nsIChannel* channel, } NS_IMETHODIMP nsPluginStreamListenerPeer::OnStatus(nsIChannel* channel, - nsISupports* aContext, - const PRUnichar* aMsg) + nsISupports* aContext, + nsresult aStatus, + const PRUnichar* aStatusArg) { return NS_OK; } diff --git a/netwerk/base/public/netCore.h b/netwerk/base/public/netCore.h index 24e632db1d4..c2ae18a73ae 100644 --- a/netwerk/base/public/netCore.h +++ b/netwerk/base/public/netCore.h @@ -61,4 +61,7 @@ #endif /* !XP_PC */ #endif /* !_IMPL_NS_NET */ +// Where most necko status messages come from: +#define NECKO_MSGS_URL "chrome://necko/locale/necko.properties" + #endif // __netCore_h__ diff --git a/netwerk/base/public/nsIFileTransportService.idl b/netwerk/base/public/nsIFileTransportService.idl index be903d822db..d7b2f78cb19 100644 --- a/netwerk/base/public/nsIFileTransportService.idl +++ b/netwerk/base/public/nsIFileTransportService.idl @@ -74,4 +74,11 @@ interface nsIFileTransportService : nsISupports 0x11d2, \ {0x93, 0x1b, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \ } + +/** + * Status nsresult codes: used with nsIProgressEventSink::OnStatus + */ +#define NS_NET_STATUS_READ_FROM NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 8) +#define NS_NET_STATUS_WROTE_TO NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 9) + %} diff --git a/netwerk/base/public/nsILoadGroup.idl b/netwerk/base/public/nsILoadGroup.idl index a3b09832c97..9c16bafc9fb 100644 --- a/netwerk/base/public/nsILoadGroup.idl +++ b/netwerk/base/public/nsILoadGroup.idl @@ -28,7 +28,6 @@ interface nsIStreamObserver; interface nsIStreamListener; interface nsIInputStream; - [scriptable, uuid(60fdf550-5392-11d3-9a97-0080c7cb1080)] interface nsILoadGroupListenerFactory : nsISupports { @@ -75,7 +74,7 @@ interface nsILoadGroup : nsIRequest void removeChannel(in nsIChannel channel, in nsISupports ctxt, in nsresult status, - in wstring errorMsg); + in wstring statusArg); /** * Returns the channels contained directly in this group. diff --git a/netwerk/base/public/nsIProgressEventSink.idl b/netwerk/base/public/nsIProgressEventSink.idl index c5aa41d547b..1260b37d7e5 100644 --- a/netwerk/base/public/nsIProgressEventSink.idl +++ b/netwerk/base/public/nsIProgressEventSink.idl @@ -43,9 +43,18 @@ interface nsIProgressEventSink : nsISupports /** * Notify the EventSink with a status message for the URL load.
+ * @param status - A status code denoting the type of notification. This + * can be a message to be displayed (e.g. for file I/O, + * STATUS_READ_FROM, or STATUS_WROTE_TO), or can be an event + * to be programmatically handled. + * @param statusArg - An argument or arguments to the status notification. + * These arguments will be formatted into any status or error + * message. Multiple arguments can be passed by delimiting them + * with newline ('\n') characters. */ void onStatus(in nsIChannel channel, in nsISupports ctxt, - in wstring aMsg); + in nsresult status, + in wstring statusArg); }; diff --git a/netwerk/base/public/nsISocketTransport.idl b/netwerk/base/public/nsISocketTransport.idl index 7b9e5916ad5..54feb3dbc34 100644 --- a/netwerk/base/public/nsISocketTransport.idl +++ b/netwerk/base/public/nsISocketTransport.idl @@ -25,6 +25,9 @@ [scriptable, uuid(785CA0F0-C39E-11d3-9ED6-0010A4053FD0)] interface nsISocketTransport : nsISupports { + /** + * + */ attribute boolean reuseConnection; /** diff --git a/netwerk/base/public/nsISocketTransportService.idl b/netwerk/base/public/nsISocketTransportService.idl index b6555b04272..04894ac19de 100644 --- a/netwerk/base/public/nsISocketTransportService.idl +++ b/netwerk/base/public/nsISocketTransportService.idl @@ -99,4 +99,13 @@ interface nsISocketTransportService : nsISupports #define NS_ERROR_NET_TIMEOUT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 14) +/** + * Status nsresult codes: used with nsIProgressEventSink::OnStatus + */ +#define NS_NET_STATUS_RESOLVING_HOST NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 3) +#define NS_NET_STATUS_CONNECTED_TO NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 4) +#define NS_NET_STATUS_SENDING_TO NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 5) +#define NS_NET_STATUS_RECEIVING_FROM NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 6) +#define NS_NET_STATUS_CONNECTING_TO NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 7) + %} diff --git a/netwerk/base/public/nsIStreamObserver.idl b/netwerk/base/public/nsIStreamObserver.idl index a2213d6b4d7..bccbae7c720 100644 --- a/netwerk/base/public/nsIStreamObserver.idl +++ b/netwerk/base/public/nsIStreamObserver.idl @@ -28,13 +28,21 @@ interface nsIChannel; [scriptable, uuid(fd91e2e0-1481-11d3-9333-00104ba0fd40)] interface nsIStreamObserver : nsISupports { + /** + * Called to signify the beginning of an asyncronous request. + */ void onStartRequest(in nsIChannel channel, in nsISupports ctxt); + /** + * Called to signify the end of an asyncronous request. + * @param notif - a notification object containing any error code and error parameters + * (may be null if the notification status is NS_OK) + */ void onStopRequest(in nsIChannel channel, - in nsISupports ctxt, + in nsISupports ctxt, in nsresult status, - in wstring errorMsg); + in wstring statusArg); }; /** diff --git a/netwerk/base/src/nsAsyncStreamListener.cpp b/netwerk/base/src/nsAsyncStreamListener.cpp index bf46c7c4c2f..24c82a4442e 100644 --- a/netwerk/base/src/nsAsyncStreamListener.cpp +++ b/netwerk/base/src/nsAsyncStreamListener.cpp @@ -254,15 +254,15 @@ public: nsOnStopRequestEvent(nsAsyncStreamObserver* listener, nsISupports* context, nsIChannel* channel) : nsStreamListenerEvent(listener, channel, context), - mStatus(NS_OK), mMessage(nsnull) {} + mStatus(NS_OK) {} virtual ~nsOnStopRequestEvent(); - nsresult Init(nsresult status, const PRUnichar* aMsg); + nsresult Init(nsresult aStatus, const PRUnichar* aStatusArg); NS_IMETHOD HandleEvent(); protected: nsresult mStatus; - PRUnichar* mMessage; + nsString mStatusArg; }; nsOnStopRequestEvent::~nsOnStopRequestEvent() @@ -270,10 +270,10 @@ nsOnStopRequestEvent::~nsOnStopRequestEvent() } nsresult -nsOnStopRequestEvent::Init(nsresult status, const PRUnichar* aMsg) +nsOnStopRequestEvent::Init(nsresult aStatus, const PRUnichar* aStatusArg) { - mStatus = status; - mMessage = (PRUnichar*)aMsg; + mStatus = aStatus; + mStatusArg = aStatusArg; return NS_OK; } @@ -281,30 +281,29 @@ NS_IMETHODIMP nsOnStopRequestEvent::HandleEvent() { #if defined(PR_LOGGING) - if (!gStreamEventLog) - gStreamEventLog = PR_NewLogModule("netlibStreamEvent"); - PR_LOG(gStreamEventLog, PR_LOG_DEBUG, - ("netlibEvent: Handle Stop [event=%x]", this)); + if (!gStreamEventLog) + gStreamEventLog = PR_NewLogModule("netlibStreamEvent"); + PR_LOG(gStreamEventLog, PR_LOG_DEBUG, + ("netlibEvent: Handle Stop [event=%x]", this)); #endif - nsIStreamObserver* receiver = (nsIStreamObserver*)mListener->GetReceiver(); - nsresult status = NS_OK; - nsresult rv = mChannel->GetStatus(&status); - NS_ASSERTION(NS_SUCCEEDED(rv), "GetStatus failed"); + nsIStreamObserver* receiver = (nsIStreamObserver*)mListener->GetReceiver(); + nsresult status = NS_OK; + nsresult rv = mChannel->GetStatus(&status); + NS_ASSERTION(NS_SUCCEEDED(rv), "GetStatus failed"); - // - // If the consumer returned a failure code, then pass it out in the - // OnStopRequest(...) notification... - // - if (NS_SUCCEEDED(rv) && NS_FAILED(status)) { - mStatus = status; - } - return receiver->OnStopRequest(mChannel, mContext, mStatus, mMessage); + // + // If the consumer returned a failure code, then pass it out in the + // OnStopRequest(...) notification... + // + if (NS_SUCCEEDED(rv) && NS_FAILED(status)) { + mStatus = status; + } + return receiver->OnStopRequest(mChannel, mContext, mStatus, mStatusArg.GetUnicode()); } NS_IMETHODIMP nsAsyncStreamObserver::OnStopRequest(nsIChannel* channel, nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg) + nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; @@ -317,7 +316,7 @@ nsAsyncStreamObserver::OnStopRequest(nsIChannel* channel, nsISupports* context, if (event == nsnull) return NS_ERROR_OUT_OF_MEMORY; - rv = event->Init(aStatus, aMsg); + rv = event->Init(aStatus, aStatusArg); if (NS_FAILED(rv)) goto failed; #if defined(PR_LOGGING) PLEventQueue *equeue; diff --git a/netwerk/base/src/nsAsyncStreamListener.h b/netwerk/base/src/nsAsyncStreamListener.h index e044b820783..1bc49738e3d 100644 --- a/netwerk/base/src/nsAsyncStreamListener.h +++ b/netwerk/base/src/nsAsyncStreamListener.h @@ -73,10 +73,9 @@ public: NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg) + nsresult aStatus, const PRUnichar* aStatusArg) { - return nsAsyncStreamObserver::OnStopRequest(channel, context, aStatus, aMsg); + return nsAsyncStreamObserver::OnStopRequest(channel, context, aStatus, aStatusArg); } NS_IMETHOD OnDataAvailable(nsIChannel* channel, nsISupports* context, diff --git a/netwerk/base/src/nsDirectoryIndexStream.cpp b/netwerk/base/src/nsDirectoryIndexStream.cpp index 1d1f7f65824..a328ae8e9b9 100644 --- a/netwerk/base/src/nsDirectoryIndexStream.cpp +++ b/netwerk/base/src/nsDirectoryIndexStream.cpp @@ -146,7 +146,7 @@ nsDirectoryIndexStream::Read(char* aBuf, PRUint32 aCount, PRUint32* aReadCount) // If anything is enqueued (or left-over) in mBuf, then feed it to // the reader first. - while (mOffset < mBuf.Length() && aCount != 0) { + while (mOffset < (PRInt32)mBuf.Length() && aCount != 0) { *(aBuf++) = char(mBuf.CharAt(mOffset++)); --aCount; ++nread; @@ -260,7 +260,7 @@ nsDirectoryIndexStream::Read(char* aBuf, PRUint32 aCount, PRUint32* aReadCount) // ...and once we've either run out of directory entries, or // filled up the buffer, then we'll push it to the reader. - while (mOffset < mBuf.Length() && aCount != 0) { + while (mOffset < (PRInt32)mBuf.Length() && aCount != 0) { *(aBuf++) = char(mBuf.CharAt(mOffset++)); --aCount; ++nread; diff --git a/netwerk/base/src/nsFileTransport.cpp b/netwerk/base/src/nsFileTransport.cpp index a5f739dda49..bbd37f5518d 100644 --- a/netwerk/base/src/nsFileTransport.cpp +++ b/netwerk/base/src/nsFileTransport.cpp @@ -374,8 +374,6 @@ nsFileTransport::Process(void) ("nsFileTransport: OPEN_FOR_READ [this=%x %s]", this, mStreamName.GetBuffer())); mStatus = mStreamIO->Open(&mContentType, &mTotalAmount); - - // if we're reading: if (mListener) { nsresult rv = mListener->OnStartRequest(this, mContext); // always send the start notification if (NS_SUCCEEDED(mStatus)) @@ -504,20 +502,18 @@ nsFileTransport::Process(void) mSource = null_nsCOMPtr(); + nsresult rv; if (mListener) { - // XXX where do we get the done message? - nsresult rv = mListener->OnStopRequest(this, mContext, mStatus, nsnull); + rv = mListener->OnStopRequest(this, mContext, mStatus, nsnull); NS_ASSERTION(NS_SUCCEEDED(rv), "unexpected OnStopRequest failure"); mListener = null_nsCOMPtr(); } if (mProgress && !(mLoadAttributes & LOAD_BACKGROUND)) { - // XXX fix up this message for i18n - nsAutoString msg; - msg.AssignWithConversion("Read "); - nsXPIDLCString spec; - (void) - msg.AppendWithConversion(mStreamName); - (void)mProgress->OnStatus(this, mContext, msg.GetUnicode()); + nsAutoString fileName; fileName.AssignWithConversion(mStreamName); + rv = mProgress->OnStatus(this, mContext, + NS_NET_STATUS_READ_FROM, + fileName.GetUnicode()); + NS_ASSERTION(NS_SUCCEEDED(rv), "unexpected OnStopRequest failure"); } mContext = null_nsCOMPtr(); @@ -530,9 +526,10 @@ nsFileTransport::Process(void) ("nsFileTransport: OPEN_FOR_WRITE [this=%x %s]", this, mStreamName.GetBuffer())); mStatus = mStreamIO->Open(&mContentType, &mTotalAmount); - if (mObserver) { - mStatus = mObserver->OnStartRequest(this, mContext); // always send the start notification + nsresult rv = mObserver->OnStartRequest(this, mContext); // always send the start notification + if (NS_SUCCEEDED(mStatus)) + mStatus = rv; } mXferState = NS_FAILED(mStatus) ? END_WRITE : START_WRITE; @@ -666,17 +663,18 @@ nsFileTransport::Process(void) mSource = null_nsCOMPtr(); } + nsresult rv; if (mObserver) { - // XXX where do we get the done message? - (void)mObserver->OnStopRequest(this, mContext, mStatus, nsnull); + rv = mObserver->OnStopRequest(this, mContext, mStatus, nsnull); + NS_ASSERTION(NS_SUCCEEDED(rv), "unexpected OnStopRequest failure"); mObserver = null_nsCOMPtr(); } if (mProgress && !(mLoadAttributes & LOAD_BACKGROUND)) { - // XXX fix up this message for i18n - nsAutoString msg; - msg.AssignWithConversion("Wrote "); - msg.AssignWithConversion(mStreamName); - (void)mProgress->OnStatus(this, mContext, msg.GetUnicode()); + nsAutoString fileName; fileName.AssignWithConversion(mStreamName); + rv = mProgress->OnStatus(this, mContext, + NS_NET_STATUS_WROTE_TO, + fileName.GetUnicode()); + NS_ASSERTION(NS_SUCCEEDED(rv), "unexpected OnStopRequest failure"); } mContext = null_nsCOMPtr(); diff --git a/netwerk/base/src/nsIOService.cpp b/netwerk/base/src/nsIOService.cpp index 56f0ab48a15..9762a9137ab 100644 --- a/netwerk/base/src/nsIOService.cpp +++ b/netwerk/base/src/nsIOService.cpp @@ -32,11 +32,14 @@ #include "nsLoadGroup.h" #include "nsInputStreamChannel.h" #include "nsXPIDLString.h" +#include "nsIErrorService.h" +#include "netCore.h" static NS_DEFINE_CID(kFileTransportService, NS_FILETRANSPORTSERVICE_CID); static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID); static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); static NS_DEFINE_CID(kDNSServiceCID, NS_DNSSERVICE_CID); +static NS_DEFINE_CID(kErrorServiceCID, NS_ERRORSERVICE_CID); //////////////////////////////////////////////////////////////////////////////// @@ -66,7 +69,27 @@ nsIOService::Init() rv = nsServiceManager::GetService(kDNSServiceCID, NS_GET_IID(nsIDNSService), getter_AddRefs(mDNSService)); - + + // XXX hack until xpidl supports error info directly (http://bugzilla.mozilla.org/show_bug.cgi?id=13423) + nsCOMPtr errorService = do_GetService(kErrorServiceCID, &rv); + if (NS_SUCCEEDED(rv)) { + rv = errorService->RegisterErrorStringBundle(NS_ERROR_MODULE_NETWORK, NECKO_MSGS_URL); + if (NS_FAILED(rv)) return rv; + rv = errorService->RegisterErrorStringBundleKey(NS_NET_STATUS_READ_FROM, "ReadFrom"); + if (NS_FAILED(rv)) return rv; + rv = errorService->RegisterErrorStringBundleKey(NS_NET_STATUS_WROTE_TO, "WroteTo"); + if (NS_FAILED(rv)) return rv; + rv = errorService->RegisterErrorStringBundleKey(NS_NET_STATUS_RESOLVING_HOST, "ResolvingHost"); + if (NS_FAILED(rv)) return rv; + rv = errorService->RegisterErrorStringBundleKey(NS_NET_STATUS_CONNECTED_TO, "ConnectedTo"); + if (NS_FAILED(rv)) return rv; + rv = errorService->RegisterErrorStringBundleKey(NS_NET_STATUS_SENDING_TO, "SendingTo"); + if (NS_FAILED(rv)) return rv; + rv = errorService->RegisterErrorStringBundleKey(NS_NET_STATUS_RECEIVING_FROM, "ReceivingFrom"); + if (NS_FAILED(rv)) return rv; + rv = errorService->RegisterErrorStringBundleKey(NS_NET_STATUS_CONNECTING_TO, "ConnectingTo"); + if (NS_FAILED(rv)) return rv; + } return rv; } diff --git a/netwerk/base/src/nsInputStreamChannel.cpp b/netwerk/base/src/nsInputStreamChannel.cpp index 043ba70ea42..e8352601e00 100644 --- a/netwerk/base/src/nsInputStreamChannel.cpp +++ b/netwerk/base/src/nsInputStreamChannel.cpp @@ -327,7 +327,8 @@ nsStreamIOChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) done: if (NS_FAILED(rv)) { - nsresult rv2 = mLoadGroup->RemoveChannel(this, ctxt, rv, nsnull); // XXX fix error message + nsresult rv2; + rv2 = mLoadGroup->RemoveChannel(this, ctxt, rv, nsnull); NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveChannel failed"); // release the transport so that we don't think we're in progress mFileTransport = nsnull; @@ -389,7 +390,8 @@ nsStreamIOChannel::AsyncWrite(nsIInputStream *fromStream, done: if (NS_FAILED(rv)) { - nsresult rv2 = mLoadGroup->RemoveChannel(this, ctxt, rv, nsnull); // XXX fix error message + nsresult rv2; + rv2 = mLoadGroup->RemoveChannel(this, ctxt, rv, nsnull); NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveChannel failed"); // release the transport so that we don't think we're in progress mFileTransport = nsnull; @@ -598,21 +600,24 @@ nsStreamIOChannel::OnStartRequest(nsIChannel* transportChannel, nsISupports* con NS_IMETHODIMP nsStreamIOChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* context, - nsresult aStatus, const PRUnichar* aMsg) + nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; - rv = mUserObserver->OnStopRequest(this, context, aStatus, aMsg); + rv = mUserObserver->OnStopRequest(this, context, aStatus, aStatusArg); + if (NS_FAILED(rv)) return rv; if (mLoadGroup) { if (NS_SUCCEEDED(rv)) { - mLoadGroup->RemoveChannel(this, context, aStatus, aMsg); + rv = mLoadGroup->RemoveChannel(this, context, aStatus, aStatusArg); + if (NS_FAILED(rv)) return rv; } } // Release the reference to the consumer stream listener... mUserObserver = null_nsCOMPtr(); mFileTransport = null_nsCOMPtr(); + return mStreamIO->Close(aStatus); } diff --git a/netwerk/base/src/nsLoadGroup.cpp b/netwerk/base/src/nsLoadGroup.cpp index 8e264d0b800..6d231e20c69 100644 --- a/netwerk/base/src/nsLoadGroup.cpp +++ b/netwerk/base/src/nsLoadGroup.cpp @@ -31,6 +31,7 @@ #include "nsIURI.h" #include "prlog.h" #include "nsCRT.h" +#include "netCore.h" #if defined(PR_LOGGING) // @@ -477,8 +478,8 @@ nsLoadGroup::AddChannel(nsIChannel *channel, nsISupports* ctxt) } NS_IMETHODIMP -nsLoadGroup::RemoveChannel(nsIChannel *channel, nsISupports* ctxt, - nsresult status, const PRUnichar *errorMsg) +nsLoadGroup::RemoveChannel(nsIChannel *channel, nsISupports* ctxt, + nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; @@ -489,10 +490,10 @@ nsLoadGroup::RemoveChannel(nsIChannel *channel, nsISupports* ctxt, nsCOMPtr uri; if (channel) { - rv = channel->GetURI(getter_AddRefs(uri)); + rv = channel->GetURI(getter_AddRefs(uri)); } else { - rv = NS_ERROR_NULL_POINTER; + rv = NS_ERROR_NULL_POINTER; } if (NS_SUCCEEDED(rv)) @@ -504,7 +505,7 @@ nsLoadGroup::RemoveChannel(nsIChannel *channel, nsISupports* ctxt, PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, ("LOADGROUP [%x]: Removing channel %x %s status %x (count=%d).\n", - this, channel, uriStr, status, count-1)); + this, channel, uriStr, aStatus, count-1)); nsCRT::free(uriStr); } #endif /* PR_LOGGING */ @@ -541,7 +542,7 @@ nsLoadGroup::RemoveChannel(nsIChannel *channel, nsISupports* ctxt, "(foreground count=%d).\n", this, channel, mForegroundCount)); - rv = observer->OnStopRequest(channel, ctxt, status, errorMsg); + rv = observer->OnStopRequest(channel, ctxt, aStatus, aStatusArg); if (NS_FAILED(rv)) { PR_LOG(gLoadGroupLog, PR_LOG_ERROR, ("LOADGROUP [%x]: OnStopRequest for channel %x FAILED.\n", diff --git a/netwerk/base/src/nsSocketTransport.cpp b/netwerk/base/src/nsSocketTransport.cpp index 83fbb804d9c..3ca65340f77 100644 --- a/netwerk/base/src/nsSocketTransport.cpp +++ b/netwerk/base/src/nsSocketTransport.cpp @@ -540,6 +540,7 @@ nsresult nsSocketTransport::Process(PRInt16 aSelectFlags) mOnStartReadFired = PR_TRUE; mReadListener -> OnStartRequest (this , mReadContext); } + mReadListener -> OnStopRequest(this, mReadContext, mStatus, nsnull); mReadListener = null_nsCOMPtr (); mReadContext = null_nsCOMPtr (); @@ -570,6 +571,7 @@ nsresult nsSocketTransport::Process(PRInt16 aSelectFlags) mOnStartWriteFired = PR_TRUE; mWriteObserver -> OnStartRequest (this, mWriteContext); } + mWriteObserver -> OnStopRequest(this, mWriteContext, mStatus, nsnull); mWriteObserver = null_nsCOMPtr (); mWriteContext = null_nsCOMPtr (); @@ -2410,82 +2412,36 @@ nsSocketTransport::SetSocketConnectTimeout (PRUint32 a_Seconds) nsresult nsSocketTransport::fireStatus(PRUint32 aCode) { - // need to optimize this - TODO - nsXPIDLString tempmesg; - nsresult rv = GetSocketErrorString(aCode, getter_Copies(tempmesg)); + if (!mEventSink) + return NS_ERROR_FAILURE; - nsAutoString mesg(tempmesg); - mesg.AppendWithConversion(mHostName); - - if (NS_FAILED(rv)) return rv; - - return mEventSink ? mEventSink->OnStatus(this, - mReadContext, - mesg.GetUnicode()) // this gets freed elsewhere. - : NS_ERROR_FAILURE; -} - -//TODO l10n and i18n stuff here! -nsresult -nsSocketTransport::GetSocketErrorString(PRUint32 iCode, - PRUnichar** oString) const -{ - nsresult rv = NS_ERROR_FAILURE; - if (!oString) - return NS_ERROR_NULL_POINTER; - - *oString = nsnull; - - switch (iCode) /* these are currently just nsSocketState - (as in nsSocketTransport.h) */ - { - case eSocketState_Created: - case eSocketState_WaitDNS: - { - // STRING USE WARNING: this needs to be looked at -- scc - mService -> GetNeckoStringByName ("ResolvingHost", oString); - if (!*oString) return NS_ERROR_OUT_OF_MEMORY; - rv = NS_OK; - } - break; - case eSocketState_Connected: - { - // STRING USE WARNING: this needs to be looked at -- scc - mService -> GetNeckoStringByName ("ConnectedTo", oString); - if (!*oString) return NS_ERROR_OUT_OF_MEMORY; - rv = NS_OK; - } - break; - case eSocketState_WaitReadWrite: - { - // STRING USE WARNING: this needs to be looked at -- scc - static nsAutoString frommesg; frommesg.AssignWithConversion("Transferring data from "); - static nsAutoString tomesg; tomesg.AssignWithConversion("Sending request to "); - if (mWriteContext == nsnull) - mService -> GetNeckoStringByName ("SendingRequestTo", oString); - else - mService -> GetNeckoStringByName ("TransferringDataFrom", oString); - - if (!*oString) return NS_ERROR_OUT_OF_MEMORY; - rv = NS_OK; - } - break; - case eSocketState_WaitConnect: - { - // STRING USE WARNING: this needs to be looked at -- scc - mService -> GetNeckoStringByName ("ConnectingTo", oString); - if (!*oString) return NS_ERROR_OUT_OF_MEMORY; - rv = NS_OK; - } - break; - case eSocketState_Closed: - case eSocketState_Done: - case eSocketState_Timeout: - case eSocketState_Error: - case eSocketState_Max: - default: - return rv; // just return error, ie no status strings for this case - break; + nsresult status; + switch (aCode) { + case eSocketState_Created: + case eSocketState_WaitDNS: + status = NS_NET_STATUS_RESOLVING_HOST; + break; + case eSocketState_Connected: + status = NS_NET_STATUS_CONNECTED_TO; + break; + case eSocketState_WaitReadWrite: + status = mWriteContext + ? NS_NET_STATUS_RECEIVING_FROM + : NS_NET_STATUS_SENDING_TO; + break; + case eSocketState_WaitConnect: + status = NS_NET_STATUS_CONNECTING_TO; + break; + case eSocketState_Closed: + case eSocketState_Done: + case eSocketState_Timeout: + case eSocketState_Error: + case eSocketState_Max: + default: + status = NS_OK; + break; } - return rv; + + nsAutoString host; host.AssignWithConversion(mHostName); + return mEventSink->OnStatus(this, mReadContext, status, host.GetUnicode()); } diff --git a/netwerk/base/src/nsSocketTransport.h b/netwerk/base/src/nsSocketTransport.h index 247d9aacb08..4fcc27bfd7d 100644 --- a/netwerk/base/src/nsSocketTransport.h +++ b/netwerk/base/src/nsSocketTransport.h @@ -170,8 +170,7 @@ protected: nsresult doWriteFromStream(PRUint32 *aCount); nsresult fireStatus(PRUint32 aCode); - nsresult GetSocketErrorString(PRUint32 iCode, PRUnichar** oString) const; - + private: PRIntervalTime mSocketTimeout; PRIntervalTime mSocketConnectTimeout; diff --git a/netwerk/base/src/nsSocketTransportService.h b/netwerk/base/src/nsSocketTransportService.h index a65c2019432..03a2ee35bd5 100644 --- a/netwerk/base/src/nsSocketTransportService.h +++ b/netwerk/base/src/nsSocketTransportService.h @@ -47,8 +47,6 @@ #define MAX_OPEN_CONNECTIONS 50 #define DEFAULT_POLL_TIMEOUT_IN_MS 35*1000 -#define NECKO_MSGS_URL "chrome://necko/locale/necko.properties" - // Forward declarations... class nsSocketTransport; diff --git a/netwerk/base/src/nsStreamLoader.cpp b/netwerk/base/src/nsStreamLoader.cpp index a8465704727..c63e62cef85 100644 --- a/netwerk/base/src/nsStreamLoader.cpp +++ b/netwerk/base/src/nsStreamLoader.cpp @@ -112,12 +112,13 @@ nsStreamLoader::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) NS_IMETHODIMP nsStreamLoader::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, - nsresult status, const PRUnichar *errorMsg) + nsresult aStatus, const PRUnichar* aStatusArg) { + nsresult rv; mChannel = channel; - nsresult rv = mObserver->OnStreamComplete(this, mContext, status, - mData.Length(), - mData.GetBuffer()); + rv = mObserver->OnStreamComplete(this, mContext, aStatus, + mData.Length(), + mData.GetBuffer()); return rv; } diff --git a/netwerk/base/src/nsSyncStreamListener.cpp b/netwerk/base/src/nsSyncStreamListener.cpp index 5341445add5..bb3ccf27548 100644 --- a/netwerk/base/src/nsSyncStreamListener.cpp +++ b/netwerk/base/src/nsSyncStreamListener.cpp @@ -61,8 +61,7 @@ nsSyncStreamListener::OnStartRequest(nsIChannel* channel, nsISupports* context) NS_IMETHODIMP nsSyncStreamListener::OnStopRequest(nsIChannel* channel, nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg) + nsresult aStatus, const PRUnichar* aStatusArg) { // XXX what do we do with the status and error message? return mOutputStream->Close(); diff --git a/netwerk/cache/filecache/nsDiskCacheRecordChannel.cpp b/netwerk/cache/filecache/nsDiskCacheRecordChannel.cpp index 98e84836831..9cadec8228f 100644 --- a/netwerk/cache/filecache/nsDiskCacheRecordChannel.cpp +++ b/netwerk/cache/filecache/nsDiskCacheRecordChannel.cpp @@ -641,15 +641,15 @@ nsDiskCacheRecordChannel::OnStartRequest(nsIChannel* transportChannel, nsISuppor NS_IMETHODIMP nsDiskCacheRecordChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* context, - nsresult aStatus, const PRUnichar* aMsg) + nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; - rv = mRealListener->OnStopRequest(this, context, aStatus, aMsg); + rv = mRealListener->OnStopRequest(this, context, aStatus, aStatusArg); if (mLoadGroup) { if (NS_SUCCEEDED(rv)) { - mLoadGroup->RemoveChannel(this, context, aStatus, aMsg); + mLoadGroup->RemoveChannel(this, context, aStatus, aStatusArg); } } @@ -674,7 +674,7 @@ nsDiskCacheRecordChannel::OnDataAvailable(nsIChannel* transportChannel, nsISuppo // insure that the transport will go away even if it is blocked waiting // for the consumer to empty the pipe... // - if (NS_FAILED(rv && mFileTransport)) { + if (NS_FAILED(rv) && mFileTransport) { mFileTransport->Cancel(rv); } return rv; diff --git a/netwerk/cache/memcache/nsMemCacheChannel.cpp b/netwerk/cache/memcache/nsMemCacheChannel.cpp index b226498acbb..594f84fd135 100644 --- a/netwerk/cache/memcache/nsMemCacheChannel.cpp +++ b/netwerk/cache/memcache/nsMemCacheChannel.cpp @@ -138,15 +138,15 @@ public: NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *aContext, - nsresult status, const PRUnichar *errorMsg) { + nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; NS_ASSERTION(mDownstreamListener, "no downstream listener"); if (mDownstreamListener) { - rv = mDownstreamListener->OnStopRequest(mChannel, aContext, status, errorMsg); - mDownstreamListener = 0; + rv = mDownstreamListener->OnStopRequest(mChannel, aContext, aStatus, aStatusArg); + mDownstreamListener = 0; } // Tricky: causes this instance to be free'ed because mEventQueueStreamListener // has a circular reference back to this. diff --git a/netwerk/cache/mgr/nsCachedNetData.cpp b/netwerk/cache/mgr/nsCachedNetData.cpp index 8dac07adbc0..b25ef6064b7 100644 --- a/netwerk/cache/mgr/nsCachedNetData.cpp +++ b/netwerk/cache/mgr/nsCachedNetData.cpp @@ -1151,19 +1151,19 @@ public: } NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, - nsresult status, const PRUnichar *errorMsg) { - if (NS_FAILED(status)) + nsresult aStatus, const PRUnichar* aStatusArg) { + if (NS_FAILED(aStatus)) mCacheEntry->SetFlag(nsCachedNetData::TRUNCATED_CONTENT); mCacheEntry->ClearFlag(nsCachedNetData::VESTIGIAL); mCacheEntry->ClearFlag(nsCachedNetData::UPDATE_IN_PROGRESS); - if (mCacheStream ) - mCacheStream->Close(); + if (mCacheStream ) + mCacheStream->Close(); // Tell any stream-as-file observers that the file has been completely written mCacheEntry->Notify(nsIStreamAsFileObserver::NOTIFY_AVAILABLE, NS_OK); - return mOriginalListener->OnStopRequest(channel, ctxt, status, errorMsg); + return mOriginalListener->OnStopRequest(channel, ctxt, aStatus, aStatusArg); } NS_IMETHOD OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, diff --git a/netwerk/protocol/datetime/src/nsDateTimeChannel.cpp b/netwerk/protocol/datetime/src/nsDateTimeChannel.cpp index b7ea8b5ccf3..881d14768c9 100644 --- a/netwerk/protocol/datetime/src/nsDateTimeChannel.cpp +++ b/netwerk/protocol/datetime/src/nsDateTimeChannel.cpp @@ -339,7 +339,7 @@ NS_IMETHODIMP nsDateTimeChannel::SetLoadGroup(nsILoadGroup* aLoadGroup) { if (mLoadGroup) // if we already had a load group remove ourselves... - (void)mLoadGroup->RemoveChannel(this, nsnull, nsnull, nsnull); + (void)mLoadGroup->RemoveChannel(this, nsnull, NS_OK, nsnull); mLoadGroup = aLoadGroup; if (mLoadGroup) { @@ -394,12 +394,12 @@ nsDateTimeChannel::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { NS_IMETHODIMP nsDateTimeChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, - nsresult aStatus, const PRUnichar* aMsg) { + nsresult aStatus, const PRUnichar* aStatusArg) { if (mLoadGroup) { - nsresult rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aMsg); + nsresult rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aStatusArg); if (NS_FAILED(rv)) return rv; } - return mListener->OnStopRequest(this, aContext, aStatus, aMsg); + return mListener->OnStopRequest(this, aContext, aStatus, aStatusArg); } diff --git a/netwerk/protocol/file/src/nsFileChannel.cpp b/netwerk/protocol/file/src/nsFileChannel.cpp index 93c864d638f..738f9a7eb43 100644 --- a/netwerk/protocol/file/src/nsFileChannel.cpp +++ b/netwerk/protocol/file/src/nsFileChannel.cpp @@ -620,7 +620,7 @@ nsFileChannel::OnStartRequest(nsIChannel* transportChannel, nsISupports* context NS_IMETHODIMP nsFileChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* context, - nsresult aStatus, const PRUnichar* aMsg) + nsresult aStatus, const PRUnichar* aStatusArg) { #ifdef DEBUG NS_ASSERTION(mInitiator == PR_CurrentThread(), @@ -629,11 +629,11 @@ nsFileChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* context, nsresult rv; - rv = mRealListener->OnStopRequest(this, context, aStatus, aMsg); + rv = mRealListener->OnStopRequest(this, context, aStatus, aStatusArg); if (mLoadGroup) { if (NS_SUCCEEDED(rv)) { - mLoadGroup->RemoveChannel(this, context, aStatus, aMsg); + mLoadGroup->RemoveChannel(this, context, aStatus, aStatusArg); } } @@ -692,14 +692,12 @@ nsFileChannel::GetInterface(const nsIID &anIID, void **aResult ) //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -nsFileChannel::OnStatus(nsIChannel *aChannel, - nsISupports *aContext, - const PRUnichar *aMsg) +nsFileChannel::OnStatus(nsIChannel *aChannel, nsISupports* ctxt, + nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; - if (mProgress) { - mProgress->OnStatus(this, aContext, aMsg); + rv = mProgress->OnStatus(aChannel, ctxt, aStatus, aStatusArg); } return rv; } @@ -710,12 +708,12 @@ nsFileChannel::OnProgress(nsIChannel* aChannel, PRUint32 aProgress, PRUint32 aProgressMax) { - nsresult rv = NS_OK; - + nsresult rv; if (mProgress) { rv = mProgress->OnProgress(this, aContext, aProgress, aProgressMax); + NS_ASSERTION(NS_SUCCEEDED(rv), "dropping error result"); } - return rv; + return NS_OK; } diff --git a/netwerk/protocol/finger/src/nsFingerChannel.cpp b/netwerk/protocol/finger/src/nsFingerChannel.cpp index 106a638fea8..465a1d89770 100644 --- a/netwerk/protocol/finger/src/nsFingerChannel.cpp +++ b/netwerk/protocol/finger/src/nsFingerChannel.cpp @@ -443,7 +443,8 @@ nsFingerChannel::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { NS_IMETHODIMP nsFingerChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, - nsresult aStatus, const PRUnichar* aMsg) { + nsresult aStatus, const PRUnichar* aStatusArg) +{ #ifdef DEBUG_bryner printf("nsFingerChannel::OnStopRequest, mActAsObserver=%d\n", mActAsObserver); @@ -453,10 +454,10 @@ nsFingerChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, if (NS_FAILED(aStatus) || !mActAsObserver) { if (mLoadGroup) { - rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aMsg); + rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aStatusArg); if (NS_FAILED(rv)) return rv; } - rv = mListener->OnStopRequest(this, aContext, aStatus, aMsg); + rv = mListener->OnStopRequest(this, aContext, aStatus, aStatusArg); mTransport = 0; return rv; } else { diff --git a/netwerk/protocol/ftp/public/nsIFTPChannel.idl b/netwerk/protocol/ftp/public/nsIFTPChannel.idl index e4cd5ec2bb2..4e580ddc04c 100644 --- a/netwerk/protocol/ftp/public/nsIFTPChannel.idl +++ b/netwerk/protocol/ftp/public/nsIFTPChannel.idl @@ -33,3 +33,14 @@ interface nsIFTPChannel : nsIChannel readonly attribute PRBool UsingProxy; readonly attribute PRBool UsingTransparentProxy; }; + +%{C++ + +/** + * Status nsresult codes: used with nsINotification objects + */ +#define NS_NET_STATUS_BEGIN_FTP_TRANSACTION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 27) +#define NS_NET_STATUS_END_FTP_TRANSACTION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 28) + + +%} diff --git a/netwerk/protocol/ftp/src/nsFTPChannel.cpp b/netwerk/protocol/ftp/src/nsFTPChannel.cpp index a5731eeea0d..234127eb921 100644 --- a/netwerk/protocol/ftp/src/nsFTPChannel.cpp +++ b/netwerk/protocol/ftp/src/nsFTPChannel.cpp @@ -29,8 +29,9 @@ #include "nsNetUtil.h" #include "nsMimeTypes.h" -static NS_DEFINE_CID(kMIMEServiceCID, NS_MIMESERVICE_CID); - +static NS_DEFINE_CID(kMIMEServiceCID, NS_MIMESERVICE_CID); +static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); + #if defined(PR_LOGGING) extern PRLogModuleInfo* gFTPLog; #endif /* PR_LOGGING */ @@ -296,8 +297,10 @@ nsFTPChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) mUserContext = ctxt; if (mEventSink) { - nsAutoString statusMsg; statusMsg.AssignWithConversion("Beginning FTP transaction."); - rv = mEventSink->OnStatus(this, ctxt, statusMsg.GetUnicode()); + nsCOMPtr serv = do_GetService(kIOServiceCID, &rv); + if (NS_FAILED(rv)) return rv; + + rv = mEventSink->OnStatus(this, ctxt, NS_NET_STATUS_BEGIN_FTP_TRANSACTION, nsnull); if (NS_FAILED(rv)) return rv; } @@ -609,19 +612,21 @@ nsFTPChannel::GetInterface(const nsIID &anIID, void **aResult ) { // nsIProgressEventSink methods NS_IMETHODIMP -nsFTPChannel::OnStatus(nsIChannel *aChannel, - nsISupports *aContext, - const PRUnichar *aMsg) { +nsFTPChannel::OnStatus(nsIChannel *aChannel, nsISupports *aContext, + nsresult aStatus, const PRUnichar* aStatusArg) +{ + if (!mEventSink) + return NS_OK; + + nsAutoString str; if (mProxyChannel) { - // XXX We're appending the *real* host to this string - // XXX coming from the proxy channel progress notifications. - // XXX This assumes the proxy channel was setup using a null host name - nsAutoString msg(aMsg); - msg.AppendWithConversion(NS_STATIC_CAST(const char*, mHost)); - return mEventSink ? mEventSink->OnStatus(this, aContext, msg.GetUnicode()) : NS_OK; - } else { - return mEventSink ? mEventSink->OnStatus(this, aContext, aMsg) : NS_OK; + if (aStatusArg) { + str.Append(aStatusArg); + str.AppendWithConversion("\n"); + } + str.AppendWithConversion(mHost); } + return mEventSink->OnStatus(this, aContext, aStatus, str.GetUnicode()); } NS_IMETHODIMP @@ -634,22 +639,23 @@ nsFTPChannel::OnProgress(nsIChannel* aChannel, nsISupports* aContext, // nsIStreamObserver methods. NS_IMETHODIMP nsFTPChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, - nsresult aStatus, const PRUnichar* aMsg) { + nsresult aStatus, const PRUnichar* aStatusArg) +{ nsresult rv = NS_OK; mConnThread = nsnull; if (mLoadGroup) { - rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aMsg); + rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aStatusArg); if (NS_FAILED(rv)) return rv; } if (mObserver) { - rv = mObserver->OnStopRequest(this, aContext, aStatus, aMsg); + rv = mObserver->OnStopRequest(this, aContext, aStatus, aStatusArg); if (NS_FAILED(rv)) return rv; } if (mListener) { - rv = mListener->OnStopRequest(this, aContext, aStatus, aMsg); + rv = mListener->OnStopRequest(this, aContext, aStatus, aStatusArg); if (NS_FAILED(rv)) return rv; } return rv; diff --git a/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp b/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp index 088a38eba74..d435ab18ba8 100644 --- a/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp +++ b/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp @@ -39,7 +39,7 @@ #include "nsIDNSService.h" // for host error code #include "nsIWalletService.h" #include "nsIProxy.h" -#include "nsIAllocator.h" +#include "nsIMemory.h" static NS_DEFINE_CID(kWalletServiceCID, NS_WALLETSERVICE_CID); static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID); @@ -47,6 +47,7 @@ static NS_DEFINE_CID(kMIMEServiceCID, NS_MIMESERVICE_CID); static NS_DEFINE_CID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID); static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); +static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); #define FTP_COMMAND_CHANNEL_SEG_SIZE 64 #define FTP_COMMAND_CHANNEL_MAX_SIZE 512 @@ -1736,7 +1737,7 @@ nsFtpConnectionThread::Init(nsIProtocolHandler* aHandler, rv = mURL->GetPath(&path); if (NS_FAILED(rv)) return rv; mPath = nsUnescape(path); - nsAllocator::Free(path); + nsMemory::Free(path); // pull any username and/or password out of the uri nsXPIDLCString uname; @@ -1794,20 +1795,16 @@ nsFtpConnectionThread::SetWriteStream(nsIInputStream* aInStream, PRUint32 aWrite nsresult nsFtpConnectionThread::StopProcessing() { nsresult rv; - PRUnichar* errorMsg = nsnull; // kill the event loop mKeepRunning = PR_FALSE; - // setup any internal error message to propegate +#if 0 if (NS_FAILED(mInternalError)) { - // generate a FTP specific error msg. - rv = MapResultCodeToString(mInternalError, &errorMsg); - if (NS_FAILED(rv)) return rv; - - //if (mCPipe) (void)mCPipe->Cancel(); - //if (mDPipe) (void)mDPipe->Cancel(); + if (mCPipe) (void)mCPipe->Cancel(); + if (mDPipe) (void)mDPipe->Cancel(); } +#endif // Release the transports mCPipe = 0; @@ -1822,6 +1819,9 @@ nsFtpConnectionThread::StopProcessing() { // we never got to the point that the transport would be // taking over notifications. we'll handle them our selves. + nsCOMPtr serv = do_GetService(kIOServiceCID, &rv); + if (NS_FAILED(rv)) return rv; + if (mObserver) { nsCOMPtr asyncObserver; rv = NS_NewAsyncStreamObserver(getter_AddRefs(asyncObserver), mObserver, mEventQueue); @@ -1829,7 +1829,7 @@ nsFtpConnectionThread::StopProcessing() { // we only want to fire OnStop. No OnStart has been fired, and // we only want to propagate an error. - rv = asyncObserver->OnStopRequest(mChannel, mObserverContext, mInternalError, errorMsg); + rv = asyncObserver->OnStopRequest(mChannel, mObserverContext, mInternalError, nsnull); if (NS_FAILED(rv)) return rv; } @@ -1840,7 +1840,7 @@ nsFtpConnectionThread::StopProcessing() { // we only want to fire OnStop. No OnStart has been fired, and // we only want to propagate an error. - rv = asyncListener->OnStopRequest(mChannel, mListenerContext, mInternalError, errorMsg); + rv = asyncListener->OnStopRequest(mChannel, mListenerContext, mInternalError, nsnull); if (NS_FAILED(rv)) return rv; } } @@ -1870,36 +1870,6 @@ nsFtpConnectionThread::FindActionState(void) { return FTP_ERROR; } -nsresult -nsFtpConnectionThread::MapResultCodeToString(nsresult aResultCode, PRUnichar* *aOutMsg) { - nsCAutoString errorMsg; - switch (aResultCode) { - case NS_ERROR_FTP_LOGIN: - errorMsg = "FTP: Login failed."; - break; - case NS_ERROR_FTP_MODE: - errorMsg = "FTP: MODE command failed."; - break; - case NS_ERROR_FTP_CWD: - errorMsg = "FTP: CWD command failed."; - break; - case NS_ERROR_FTP_PASV: - errorMsg = "FTP: PASV command failed."; - break; - case NS_ERROR_FTP_DEL_DIR: - errorMsg = "FTP: DEL directory command failed."; - break; - case NS_ERROR_FTP_MKDIR: - errorMsg = "FTP: MKDIR command failed"; - break; - default: - errorMsg = "Unknown FTP error."; - } // END: switch - *aOutMsg = errorMsg.ToNewUnicode(); - return NS_OK; -} - - void nsFtpConnectionThread::SetDirMIMEType(nsString& aString) { // the from content type is a string of the form diff --git a/netwerk/protocol/ftp/src/nsFtpConnectionThread.h b/netwerk/protocol/ftp/src/nsFtpConnectionThread.h index ae02c898de4..ec1c52b51c5 100644 --- a/netwerk/protocol/ftp/src/nsFtpConnectionThread.h +++ b/netwerk/protocol/ftp/src/nsFtpConnectionThread.h @@ -138,7 +138,6 @@ private: // internal methods nsresult StopProcessing(); FTP_STATE FindActionState(void); - nsresult MapResultCodeToString(nsresult aResultCode, PRUnichar* *aOutMsg); void SetDirMIMEType(nsString& aString); nsresult Process(); diff --git a/netwerk/protocol/ftp/src/nsFtpProtocolHandler.cpp b/netwerk/protocol/ftp/src/nsFtpProtocolHandler.cpp index d6174c49716..859be63ff24 100644 --- a/netwerk/protocol/ftp/src/nsFtpProtocolHandler.cpp +++ b/netwerk/protocol/ftp/src/nsFtpProtocolHandler.cpp @@ -47,7 +47,7 @@ // For proxification of FTP URLs #include "nsIHTTPProtocolHandler.h" #include "nsIHTTPChannel.h" - +#include "nsIErrorService.h" #if defined(PR_LOGGING) // @@ -68,6 +68,7 @@ PRLogModuleInfo* gFTPLog = nsnull; static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID); static NS_DEFINE_CID(kProtocolProxyServiceCID, NS_PROTOCOLPROXYSERVICE_CID); static NS_DEFINE_CID(kHTTPHandlerCID, NS_IHTTPHANDLER_CID); +static NS_DEFINE_CID(kErrorServiceCID, NS_ERRORSERVICE_CID); //////////////////////////////////////////////////////////////////////////////// @@ -111,6 +112,14 @@ nsFtpProtocolHandler::Init() { mLock = PR_NewLock(); if (!mLock) return NS_ERROR_OUT_OF_MEMORY; + // XXX hack until xpidl supports error info directly (http://bugzilla.mozilla.org/show_bug.cgi?id=13423) + nsCOMPtr errorService = do_GetService(kErrorServiceCID, &rv); + if (NS_SUCCEEDED(rv)) { + rv = errorService->RegisterErrorStringBundleKey(NS_NET_STATUS_BEGIN_FTP_TRANSACTION, "BeginFTPTransaction"); + if (NS_FAILED(rv)) return rv; + rv = errorService->RegisterErrorStringBundleKey(NS_NET_STATUS_END_FTP_TRANSACTION, "EndFTPTransaction"); + if (NS_FAILED(rv)) return rv; + } return rv; } diff --git a/netwerk/protocol/http/src/nsHTTPChannel.cpp b/netwerk/protocol/http/src/nsHTTPChannel.cpp index 047c818c349..9ae115b35a8 100644 --- a/netwerk/protocol/http/src/nsHTTPChannel.cpp +++ b/netwerk/protocol/http/src/nsHTTPChannel.cpp @@ -58,6 +58,7 @@ #include "nsIEventQueueService.h" #include "nsIProxyObjectManager.h" #include "nsIWalletService.h" +#include "netCore.h" // FIXME - Temporary include. Delete this when cache is enabled on all // platforms @@ -839,12 +840,12 @@ nsHTTPChannel::GetInterface(const nsIID &anIID, void **aResult ) { // nsIProgressEventSink methods NS_IMETHODIMP -nsHTTPChannel::OnStatus(nsIChannel *aChannel, - nsISupports *aContext, - const PRUnichar *aMsg) { +nsHTTPChannel::OnStatus(nsIChannel *aChannel, nsISupports *aContext, + nsresult aStatus, const PRUnichar* aStatusArg) +{ nsresult rv = NS_OK; if (mProgressEventSink) { - rv = mProgressEventSink->OnStatus(this, aContext, aMsg); + rv = mProgressEventSink->OnStatus(this, aContext, aStatus, aStatusArg); } return rv; } @@ -1714,10 +1715,8 @@ nsresult nsHTTPChannel::Redirect(const char *aNewLocation, return rv; } -nsresult nsHTTPChannel::ResponseCompleted( - nsIStreamListener *aListener, - nsresult aStatus, - const PRUnichar* aMsg) +nsresult nsHTTPChannel::ResponseCompleted(nsIStreamListener *aListener, + nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; @@ -1727,7 +1726,7 @@ nsresult nsHTTPChannel::ResponseCompleted( this, (void*)mResponseDataListener, aStatus)); #if 0 - if (NS_FAILED (aStatus) && !mResponse) + if (NS_FAILED (status) && !mResponse) { // ruslan: must have failed during connect phase @@ -1736,7 +1735,7 @@ nsresult nsHTTPChannel::ResponseCompleted( if (NS_SUCCEEDED (rv1)) { - aStatus = NS_ERROR_GENERATE_SUCCESS (NS_ERROR_MODULE_NETWORK, NS_ERROR_GET_CODE (aStatus)); + status = NS_ERROR_GENERATE_SUCCESS (NS_ERROR_MODULE_NETWORK, NS_ERROR_GET_CODE (status)); return NS_OK; } } @@ -1754,7 +1753,7 @@ nsresult nsHTTPChannel::ResponseCompleted( // Call the consumer OnStopRequest(...) to end the request... if (aListener) { - rv = aListener->OnStopRequest(this, mResponseContext, aStatus, aMsg); + rv = aListener->OnStopRequest(this, mResponseContext, aStatus, aStatusArg); if (NS_FAILED (rv)) { @@ -1788,7 +1787,7 @@ nsresult nsHTTPChannel::ResponseCompleted( // if (mLoadGroup) - mLoadGroup->RemoveChannel(this, nsnull, aStatus, nsnull); + mLoadGroup->RemoveChannel(this, nsnull, aStatus, aStatusArg); // Null out pointers that are no longer needed... @@ -2719,10 +2718,10 @@ nsSyncHelper::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) NS_IMETHODIMP nsSyncHelper::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, - nsresult aStatus, const PRUnichar *aMsg) + nsresult aStatus, const PRUnichar* aStatusArg) { mProcessing = PR_FALSE; - return mListener->OnStopRequest(aChannel, aContext, aStatus, aMsg); + return mListener->OnStopRequest(aChannel, aContext, aStatus, aStatusArg); } diff --git a/netwerk/protocol/http/src/nsHTTPChannel.h b/netwerk/protocol/http/src/nsHTTPChannel.h index 11163c608ee..553b50082de 100644 --- a/netwerk/protocol/http/src/nsHTTPChannel.h +++ b/netwerk/protocol/http/src/nsHTTPChannel.h @@ -97,8 +97,7 @@ public: nsIChannel **aResult, PRInt32 aStatusCode); nsresult ResponseCompleted(nsIStreamListener *aListener, - nsresult aStatus, - const PRUnichar* aMsg); + nsresult aStatus, const PRUnichar* aStatusArg); nsresult SetResponse(nsHTTPResponse* i_pResp); nsresult GetResponseContext(nsISupports** aContext); diff --git a/netwerk/protocol/http/src/nsHTTPRequest.cpp b/netwerk/protocol/http/src/nsHTTPRequest.cpp index cf15f853de8..0f2182ca2c0 100644 --- a/netwerk/protocol/http/src/nsHTTPRequest.cpp +++ b/netwerk/protocol/http/src/nsHTTPRequest.cpp @@ -704,17 +704,16 @@ nsHTTPPipelinedRequest::OnStartRequest(nsIChannel* channel, nsISupports* i_Conte NS_IMETHODIMP nsHTTPPipelinedRequest::OnStopRequest(nsIChannel* channel, nsISupports* i_Context, - nsresult iStatus, - const PRUnichar* i_Msg) + nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; nsCOMPtr trans = do_QueryInterface(mTransport, &rv); nsHTTPRequest * req =(nsHTTPRequest *) mRequests->ElementAt(0); - - rv = iStatus; - PR_LOG(gHTTPLog, PR_LOG_DEBUG,("\nnsHTTPRequest::OnStopRequest() [this=%x], iStatus=%u\n", this, iStatus)); + rv = aStatus; + + PR_LOG(gHTTPLog, PR_LOG_DEBUG,("\nnsHTTPRequest::OnStopRequest() [this=%x], aStatus=%u\n", this, aStatus)); if (NS_SUCCEEDED(rv)) { @@ -731,11 +730,11 @@ nsHTTPPipelinedRequest::OnStopRequest(nsIChannel* channel, nsISupports* i_Contex if (mInputStream) { PR_LOG(gHTTPLog, PR_LOG_ALWAYS, -("nsHTTPRequest [this=%x]. " - "Writing PUT/POST data to the server.\n", this)); + ("nsHTTPRequest [this=%x]. " + "Writing PUT/POST data to the server.\n", this)); rv = mTransport->AsyncWrite(mInputStream, this, -(nsISupports*)(nsIRequest*)req->mConnection); + (nsISupports*)(nsIRequest*)req->mConnection); /* the mInputStream is released below... */ } @@ -745,9 +744,9 @@ nsHTTPPipelinedRequest::OnStopRequest(nsIChannel* channel, nsISupports* i_Contex else { PR_LOG(gHTTPLog, PR_LOG_ALWAYS, -("nsHTTPRequest [this=%x]. " + ("nsHTTPRequest [this=%x]. " "Finished writing request to server." - "\tStatus: %x\n", this, iStatus)); + "\tStatus: %x\n", this, aStatus)); if (mListener == nsnull) { @@ -783,9 +782,9 @@ nsHTTPPipelinedRequest::OnStopRequest(nsIChannel* channel, nsISupports* i_Contex else { PR_LOG(gHTTPLog, PR_LOG_ERROR, -("nsHTTPRequest [this=%x]. Error writing request to server." - "\tStatus: %x\n", this, iStatus)); - rv = iStatus; + ("nsHTTPRequest [this=%x]. Error writing request to server." + "\tStatus: %x\n", this, aStatus)); + rv = aStatus; } // @@ -833,7 +832,7 @@ nsHTTPPipelinedRequest::OnStopRequest(nsIChannel* channel, nsISupports* i_Contex { nsCOMPtr consumer; req->mConnection->GetResponseDataListener(getter_AddRefs(consumer)); - req->mConnection->ResponseCompleted(consumer, rv, i_Msg); + req->mConnection->ResponseCompleted(consumer, rv, nsnull); // Notify the HTTPChannel that the request has finished diff --git a/netwerk/protocol/http/src/nsHTTPResponseListener.cpp b/netwerk/protocol/http/src/nsHTTPResponseListener.cpp index 44a919a5e8a..bcdc12b4545 100644 --- a/netwerk/protocol/http/src/nsHTTPResponseListener.cpp +++ b/netwerk/protocol/http/src/nsHTTPResponseListener.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * The contents of this file are subject to the Netscape Public * License Version 1.1 (the "License"); you may not use this file @@ -45,6 +45,7 @@ #include "nsXPIDLString.h" #include "nsIIOService.h" + static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID) ; #if defined(PR_LOGGING) @@ -149,10 +150,8 @@ nsHTTPCacheListener::OnStartRequest(nsIChannel *aChannel, } NS_IMETHODIMP -nsHTTPCacheListener::OnStopRequest(nsIChannel *aChannel, - nsISupports *aContext, - nsresult aStatus, - const PRUnichar *aErrorMsg) +nsHTTPCacheListener::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, + nsresult aStatus, const PRUnichar* aStatusArg) { PR_LOG(gHTTPLog, PR_LOG_DEBUG, ("nsHTTPCacheListener::OnStopRequest [this=%x]\n", this)) ; @@ -162,9 +161,7 @@ nsHTTPCacheListener::OnStopRequest(nsIChannel *aChannel, // is no socket transport involved nsnull is passed as the // transport... // - nsresult rv = mChannel->ResponseCompleted(mResponseDataListener, - aStatus, - aErrorMsg) ; + nsresult rv = mChannel->ResponseCompleted(mResponseDataListener, aStatus, aStatusArg) ; // NS_IF_RELEASE(mChannel) ; return rv; } @@ -664,7 +661,8 @@ nsHTTPServerListener::OnStartRequest(nsIChannel* channel, nsISupports* i_pContex } NS_IMETHODIMP -nsHTTPServerListener::OnStopRequest(nsIChannel* channel, nsISupports* i_pContext, nsresult i_Status, const PRUnichar* i_pMsg) +nsHTTPServerListener::OnStopRequest(nsIChannel* channel, nsISupports* i_pContext, + nsresult i_Status, const PRUnichar* aStatusArg) { nsresult rv = i_Status, channelStatus = NS_OK; @@ -672,7 +670,7 @@ nsHTTPServerListener::OnStopRequest(nsIChannel* channel, nsISupports* i_pContext mChannel->GetStatus(&channelStatus) ; PR_LOG(gHTTPLog, PR_LOG_ALWAYS, -("nsHTTPServerListener::OnStopRequest [this=%x]." + ("nsHTTPServerListener::OnStopRequest [this=%x]." "\tStatus = %x, mDataReceived=%d\n", this, i_Status, mDataReceived)) ; if (NS_SUCCEEDED(channelStatus) && !mDataReceived @@ -718,7 +716,7 @@ nsHTTPServerListener::OnStopRequest(nsIChannel* channel, nsISupports* i_pContext if (status != 304 || !mChannel->mCachedResponse) { - mChannel->ResponseCompleted(mResponseDataListener, i_Status, i_pMsg) ; + mChannel->ResponseCompleted(mResponseDataListener, i_Status, aStatusArg); mChannel->mHTTPServerListener = 0; } @@ -787,7 +785,7 @@ nsHTTPServerListener::OnStopRequest(nsIChannel* channel, nsISupports* i_pContext while (NS_SUCCEEDED(mPipelinedRequest->AdvanceToNextRequest()) ) { OnStartRequest(nsnull, nsnull) ; - mChannel->ResponseCompleted(mResponseDataListener, i_Status, i_pMsg) ; + mChannel->ResponseCompleted(mResponseDataListener, i_Status, aStatusArg); mChannel->mHTTPServerListener = 0; } @@ -1157,13 +1155,11 @@ nsHTTPFinalListener::OnStartRequest(nsIChannel *aChannel, } NS_IMETHODIMP -nsHTTPFinalListener::OnStopRequest(nsIChannel *aChannel, - nsISupports *aContext, - nsresult aStatus, - const PRUnichar *aErrorMsg) +nsHTTPFinalListener::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, + nsresult aStatus, const PRUnichar* aStatusArg) { PR_LOG(gHTTPLog, PR_LOG_DEBUG, -("nsHTTPFinalListener::OnStopRequest [this=%x]" + ("nsHTTPFinalListener::OnStopRequest [this=%x]" ", mOnStopFired=%u\n", this, mOnStopFired)) ; if (mShutdown || mOnStopFired) @@ -1192,7 +1188,7 @@ nsHTTPFinalListener::OnStopRequest(nsIChannel *aChannel, } mOnStopFired = PR_TRUE; - nsresult rv = mListener->OnStopRequest(aChannel, aContext, aStatus, aErrorMsg) ; + nsresult rv = mListener->OnStopRequest(aChannel, aContext, aStatus, aStatusArg) ; return rv; } diff --git a/netwerk/protocol/jar/src/nsJARChannel.cpp b/netwerk/protocol/jar/src/nsJARChannel.cpp index 71a471c6b07..5db30a99d94 100644 --- a/netwerk/protocol/jar/src/nsJARChannel.cpp +++ b/netwerk/protocol/jar/src/nsJARChannel.cpp @@ -72,10 +72,8 @@ public: return NS_OK; } - NS_IMETHOD OnStopRequest(nsIChannel* jarCacheTransport, - nsISupports* context, - nsresult status, - const PRUnichar* aMsg) { + NS_IMETHOD OnStopRequest(nsIChannel* jarCacheTransport, nsISupports* context, + nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; nsAutoMonitor monitor(mJARChannel->mMonitor); @@ -88,11 +86,11 @@ public: if (NS_SUCCEEDED(rv)) { PR_LOG(gJarProtocolLog, PR_LOG_DEBUG, ("nsJarProtocol: jar download complete %s status=%x", - (const char*)jarURLStr, status)); + (const char*)jarURLStr, aStatus)); } } #endif - if (NS_SUCCEEDED(status) && mJARChannel->mJarCacheTransport) { + if (NS_SUCCEEDED(aStatus) && mJARChannel->mJarCacheTransport) { NS_ASSERTION(jarCacheTransport == (mJARChannel->mJarCacheTransport).get(), "wrong transport"); // after successfully downloading the jar file to the cache, @@ -528,7 +526,7 @@ nsJARChannel::EnsureJARFileAvailable(OnJARFileAvailableFun onJARFileAvailable, error: if (NS_FAILED(rv) && mLoadGroup) { - nsresult rv2 = mLoadGroup->RemoveChannel(this, nsnull, rv, nsnull); // XXX fix error message + nsresult rv2 = mLoadGroup->RemoveChannel(this, nsnull, NS_OK, nsnull); NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveChannel failed"); } return rv; @@ -864,10 +862,8 @@ nsJARChannel::OnStartRequest(nsIChannel* jarExtractionTransport, } NS_IMETHODIMP -nsJARChannel::OnStopRequest(nsIChannel* jarExtractionTransport, - nsISupports* context, - nsresult status, - const PRUnichar* aMsg) +nsJARChannel::OnStopRequest(nsIChannel* jarExtractionTransport, nsISupports* context, + nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; #ifdef PR_LOGGING @@ -877,14 +873,14 @@ nsJARChannel::OnStopRequest(nsIChannel* jarExtractionTransport, if (NS_SUCCEEDED(rv)) { PR_LOG(gJarProtocolLog, PR_LOG_DEBUG, ("nsJarProtocol: jar extraction complete %s status=%x", - (const char*)jarURLStr, status)); + (const char*)jarURLStr, aStatus)); } #endif - rv = mUserListener->OnStopRequest(this, mUserContext, status, aMsg); + rv = mUserListener->OnStopRequest(this, mUserContext, aStatus, aStatusArg); if (mLoadGroup) { if (NS_SUCCEEDED(rv)) { - mLoadGroup->RemoveChannel(this, context, status, aMsg); + mLoadGroup->RemoveChannel(this, context, aStatus, aStatusArg); } } diff --git a/netwerk/protocol/res/src/nsResChannel.cpp b/netwerk/protocol/res/src/nsResChannel.cpp index 57c18e53401..9331a47a54b 100644 --- a/netwerk/protocol/res/src/nsResChannel.cpp +++ b/netwerk/protocol/res/src/nsResChannel.cpp @@ -408,7 +408,7 @@ nsResChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) } while (NS_FAILED(rv)); if (NS_FAILED(rv)) { - (void)EndRequest(rv, nsnull); // XXX need error message + (void)EndRequest(rv, nsnull); } return rv; @@ -461,7 +461,7 @@ nsResChannel::AsyncWrite(nsIInputStream *fromStream, } while (NS_FAILED(rv)); if (NS_FAILED(rv)) { - (void)EndRequest(rv, nsnull); // XXX need error message + (void)EndRequest(rv, nsnull); } return rv; @@ -679,7 +679,7 @@ nsResChannel::OnStartRequest(nsIChannel* transportChannel, nsISupports* context) NS_IMETHODIMP nsResChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* context, - nsresult aStatus, const PRUnichar* aMsg) + nsresult aStatus, const PRUnichar* aStatusArg) { #ifdef DEBUG NS_ASSERTION(mInitiator == PR_CurrentThread(), @@ -696,18 +696,18 @@ nsResChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* context, break; } } - return EndRequest(aStatus, aMsg); + return EndRequest(aStatus, aStatusArg); } nsresult -nsResChannel::EndRequest(nsresult aStatus, const PRUnichar* aMsg) +nsResChannel::EndRequest(nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; - rv = mUserObserver->OnStopRequest(this, mUserContext, aStatus, aMsg); + rv = mUserObserver->OnStopRequest(this, mUserContext, aStatus, aStatusArg); #if 0 // we don't add the resource channel to the group (although maybe we should) if (mLoadGroup) { if (NS_SUCCEEDED(rv)) { - mLoadGroup->RemoveChannel(this, context, aStatus, aMsg); + mLoadGroup->RemoveChannel(this, context, notif); } } #endif diff --git a/netwerk/protocol/res/src/nsResChannel.h b/netwerk/protocol/res/src/nsResChannel.h index df57e815e88..82ee436226f 100644 --- a/netwerk/protocol/res/src/nsResChannel.h +++ b/netwerk/protocol/res/src/nsResChannel.h @@ -91,7 +91,7 @@ protected: } nsresult EnsureNextResolvedChannel(); - nsresult EndRequest(nsresult status, const PRUnichar* msg); + nsresult EndRequest(nsresult aStatus, const PRUnichar* aStatusArg); protected: nsCOMPtr mOriginalURI; diff --git a/netwerk/resources/locale/en-US/necko.properties b/netwerk/resources/locale/en-US/necko.properties index bb7337dbba9..98e45142af2 100644 --- a/netwerk/resources/locale/en-US/necko.properties +++ b/netwerk/resources/locale/en-US/necko.properties @@ -19,8 +19,26 @@ # # downloadHeadersTitlePrefix=Download headers for: -ResolvingHost=Resolving host -ConnectedTo=Connected to -ConnectingTo=Connecting to -SendingRequestTo=Sending request to -TransferringDataFrom=Transferring data from +#ResolvingHost=Resolving host +#ConnectedTo=Connected to +#ConnectingTo=Connecting to +#SendingRequestTo=Sending request to +#TransferringDataFrom=Transferring data from + +3=Resolving host %1$S +4=Connected to %1$S +5=Sending request to %1$S +6=Transferring data from %1$S +7=Connecting to %1$S +8=Read %1$S +9=Wrote %1$S + +ResolvingHost=Resolving host %1$S +ConnectedTo=Connected to %1$S +SendingTo=Sending request to %1$S +ReceivingFrom=Transferring data from %1$S +ConnectingTo=Connecting to %1$S +ReadFrom=Read %1$S +WroteTo=Wrote %1$S +BeginFTPTransaction=Beginning FTP transaction +EndFTPTransaction=Finished FTP transaction diff --git a/netwerk/socket/base/nsSOCKSIOLayer.cpp b/netwerk/socket/base/nsSOCKSIOLayer.cpp index c938c08391e..78338ccbbcb 100644 --- a/netwerk/socket/base/nsSOCKSIOLayer.cpp +++ b/netwerk/socket/base/nsSOCKSIOLayer.cpp @@ -377,8 +377,8 @@ nsSOCKSIOLayerConnect(PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime time // destination port PRUint16 destPort = PR_NetAddrInetPort(addr); - request[request_len-1] = destPort >> 8; - request[request_len-2] = destPort; + request[request_len-1] = (unsigned char)(destPort >> 8); + request[request_len-2] = (unsigned char)destPort; if (PR_Write(fd, request, request_len) != request_len) { // bad write diff --git a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp index 7691e09622f..6d85721fe02 100644 --- a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp +++ b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp @@ -1148,7 +1148,7 @@ mozTXTToHTMLConv::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) NS_IMETHODIMP mozTXTToHTMLConv::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, - nsresult status, const PRUnichar *errorMsg) + nsresult aStatus, const PRUnichar* aStatusArg) { return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/netwerk/streamconv/converters/nsFTPDirListingConv.cpp b/netwerk/streamconv/converters/nsFTPDirListingConv.cpp index ea8916758b8..92b933b45b1 100644 --- a/netwerk/streamconv/converters/nsFTPDirListingConv.cpp +++ b/netwerk/streamconv/converters/nsFTPDirListingConv.cpp @@ -354,16 +354,16 @@ nsFTPDirListingConv::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { NS_IMETHODIMP nsFTPDirListingConv::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, - nsresult status, const PRUnichar *errorMsg) { + nsresult aStatus, const PRUnichar* aStatusArg) { // we don't care about stop. move along... nsCOMPtr loadgroup; nsresult rv = mPartChannel->GetLoadGroup(getter_AddRefs(loadgroup)); if (NS_FAILED(rv)) return rv; if (loadgroup) - (void)loadgroup->RemoveChannel(mPartChannel, nsnull, nsnull, nsnull); + (void)loadgroup->RemoveChannel(mPartChannel, nsnull, aStatus, aStatusArg); - return mFinalListener->OnStopRequest(mPartChannel, ctxt, status, errorMsg); + return mFinalListener->OnStopRequest(mPartChannel, ctxt, aStatus, aStatusArg); } diff --git a/netwerk/streamconv/converters/nsHTTPChunkConv.cpp b/netwerk/streamconv/converters/nsHTTPChunkConv.cpp index 9eea4987592..7d0f1dfb6b2 100644 --- a/netwerk/streamconv/converters/nsHTTPChunkConv.cpp +++ b/netwerk/streamconv/converters/nsHTTPChunkConv.cpp @@ -102,9 +102,10 @@ nsHTTPChunkConv::OnStartRequest (nsIChannel *aChannel, nsISupports *aContext) } NS_IMETHODIMP -nsHTTPChunkConv::OnStopRequest (nsIChannel *aChannel, nsISupports *aContext, nsresult status, const PRUnichar *errorMsg) +nsHTTPChunkConv::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, + nsresult aStatus, const PRUnichar* aStatusArg) { - return mListener -> OnStopRequest (aChannel, aContext, status, errorMsg); + return mListener->OnStopRequest(aChannel, aContext, aStatus, aStatusArg); } NS_IMETHODIMP diff --git a/netwerk/streamconv/converters/nsHTTPCompressConv.cpp b/netwerk/streamconv/converters/nsHTTPCompressConv.cpp index 3ef4f9d4590..e8923e274ff 100644 --- a/netwerk/streamconv/converters/nsHTTPCompressConv.cpp +++ b/netwerk/streamconv/converters/nsHTTPCompressConv.cpp @@ -101,9 +101,10 @@ nsHTTPCompressConv::OnStartRequest (nsIChannel *aChannel, nsISupports *aContext) } NS_IMETHODIMP -nsHTTPCompressConv::OnStopRequest (nsIChannel *aChannel, nsISupports *aContext, nsresult status, const PRUnichar *errorMsg) +nsHTTPCompressConv::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, + nsresult aStatus, const PRUnichar* aStatusArg) { - return mListener -> OnStopRequest (aChannel, aContext, status, errorMsg); + return mListener->OnStopRequest(aChannel, aContext, aStatus, aStatusArg); } NS_IMETHODIMP diff --git a/netwerk/streamconv/converters/nsMultiMixedConv.cpp b/netwerk/streamconv/converters/nsMultiMixedConv.cpp index c2f5c580afa..f2e1dfb0c58 100644 --- a/netwerk/streamconv/converters/nsMultiMixedConv.cpp +++ b/netwerk/streamconv/converters/nsMultiMixedConv.cpp @@ -250,10 +250,11 @@ nsMultiMixedConv::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { NS_IMETHODIMP nsMultiMixedConv::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, - nsresult status, const PRUnichar *errorMsg) { - nsresult rv = NS_OK; - if (NS_FAILED(status)) { - if (mPartChannel) { + nsresult aStatus, const PRUnichar* aStatusArg) { + nsresult rv = NS_OK; + + if (NS_FAILED(aStatus)) { + if (mPartChannel) { // we've already fired an onstart. // push any buffered data out and then push // an onstop out. @@ -264,25 +265,24 @@ nsMultiMixedConv::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, mBuffer = nsnull; mBufLen = 0; } - rv = mFinalListener->OnStopRequest(mPartChannel, mContext, - status, errorMsg); + rv = mFinalListener->OnStopRequest(mPartChannel, mContext, aStatus, aStatusArg); } else { rv = mFinalListener->OnStartRequest(channel, ctxt); if (NS_FAILED(rv)) return rv; - rv = mFinalListener->OnStopRequest(channel, ctxt, status, errorMsg); + rv = mFinalListener->OnStopRequest(channel, ctxt, aStatus, aStatusArg); + } + } + else { + if (mBufLen > 0 && mBuffer) + { + SendData(mBuffer, mBufLen); + nsMemory::Free(mBuffer); + mBuffer = nsnull; + mBufLen = 0; + rv = SendStop (); } - } - else - if (mBufLen > 0 && mBuffer) - { - SendData(mBuffer, mBufLen); - nsMemory::Free(mBuffer); - mBuffer = nsnull; - mBufLen = 0; - rv = SendStop (); } - return rv; } diff --git a/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp b/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp index b9f2972e6ee..7c039c7f5f0 100644 --- a/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp +++ b/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp @@ -84,7 +84,7 @@ nsTXTToHTMLConv::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { NS_IMETHODIMP nsTXTToHTMLConv::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, - nsresult aStatus, const PRUnichar *aMsg) { + nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; if (mToken) { // we still have an outstanding token @@ -109,7 +109,7 @@ nsTXTToHTMLConv::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, inputData, 0, mBuffer.Length()); if (NS_FAILED(rv)) return rv; - return mListener->OnStopRequest(aChannel, aContext, aStatus, aMsg); + return mListener->OnStopRequest(aChannel, aContext, aStatus, aStatusArg); } // nsITXTToHTMLConv methods diff --git a/netwerk/streamconv/converters/nsUnknownDecoder.cpp b/netwerk/streamconv/converters/nsUnknownDecoder.cpp index 77adf2d012d..5532ae72c69 100644 --- a/netwerk/streamconv/converters/nsUnknownDecoder.cpp +++ b/netwerk/streamconv/converters/nsUnknownDecoder.cpp @@ -196,10 +196,8 @@ nsUnknownDecoder::OnStartRequest(nsIChannel *aChannel, nsISupports *aCtxt) } NS_IMETHODIMP -nsUnknownDecoder::OnStopRequest(nsIChannel *aChannel, - nsISupports *aCtxt, - nsresult aStatus, - const PRUnichar *aErrorMsg) +nsUnknownDecoder::OnStopRequest(nsIChannel *aChannel, nsISupports *aCtxt, + nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; @@ -221,7 +219,7 @@ nsUnknownDecoder::OnStopRequest(nsIChannel *aChannel, } } - rv = mNextListener->OnStopRequest(aChannel, aCtxt, aStatus, aErrorMsg); + rv = mNextListener->OnStopRequest(aChannel, aCtxt, aStatus, aStatusArg); mNextListener = 0; return rv; diff --git a/netwerk/streamconv/test/Converters.cpp b/netwerk/streamconv/test/Converters.cpp index 6f4f07143f7..397e70258fa 100644 --- a/netwerk/streamconv/test/Converters.cpp +++ b/netwerk/streamconv/test/Converters.cpp @@ -99,8 +99,8 @@ TestConverter::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { NS_IMETHODIMP TestConverter::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, - nsresult status, const PRUnichar *errorMsg) { - return mListener->OnStopRequest(channel, ctxt, status, errorMsg); + nsresult aStatus, const PRUnichar* aStatusArg) { + return mListener->OnStopRequest(channel, ctxt, aStatus, aStatusArg); }; diff --git a/netwerk/streamconv/test/TestStreamConv.cpp b/netwerk/streamconv/test/TestStreamConv.cpp index d81674f3f81..90f6e6199fe 100644 --- a/netwerk/streamconv/test/TestStreamConv.cpp +++ b/netwerk/streamconv/test/TestStreamConv.cpp @@ -107,7 +107,8 @@ public: return NS_OK; } - NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) + NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, + nsresult aStatus, const PRUnichar* aStatusArg) { return NS_OK; } diff --git a/netwerk/test/TestCacheMgr.cpp b/netwerk/test/TestCacheMgr.cpp index ac3ac2ab93c..40f87f0af6f 100644 --- a/netwerk/test/TestCacheMgr.cpp +++ b/netwerk/test/TestCacheMgr.cpp @@ -217,10 +217,8 @@ public: return NS_OK; } - NS_IMETHOD OnStopRequest(nsIChannel* channel, - nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg) { + NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports* context, + nsresult aStatus, const PRUnichar* aStatusArg) { PRIntervalTime endTime; PRIntervalTime duration; diff --git a/netwerk/test/TestCallbacks.cpp b/netwerk/test/TestCallbacks.cpp index 4fa0b930a8f..e95a93b6cb8 100644 --- a/netwerk/test/TestCallbacks.cpp +++ b/netwerk/test/TestCallbacks.cpp @@ -118,7 +118,7 @@ Consumer::OnStartRequest(nsIChannel *aChannel, nsISupports* aContext) { NS_IMETHODIMP Consumer::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, - nsresult aStatus, const PRUnichar* aMsg) { + nsresult aStatus, const PRUnichar* aStatusArg) { fprintf(stderr, "Consumer::OnStop() -> in\n\n"); if (!mOnStart) { diff --git a/netwerk/test/TestFileInput.cpp b/netwerk/test/TestFileInput.cpp index 43cc7480684..31a18368c90 100644 --- a/netwerk/test/TestFileInput.cpp +++ b/netwerk/test/TestFileInput.cpp @@ -140,10 +140,8 @@ public: return NS_OK; } - NS_IMETHOD OnStopRequest(nsIChannel* channel, - nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg) { + NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports* context, + nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; PR_EnterMonitor(mMonitor); PRIntervalTime endTime = PR_IntervalNow(); diff --git a/netwerk/test/TestFileTransport.cpp b/netwerk/test/TestFileTransport.cpp index cbbc41cd73b..388feacfe12 100644 --- a/netwerk/test/TestFileTransport.cpp +++ b/netwerk/test/TestFileTransport.cpp @@ -51,8 +51,8 @@ public: } NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, - nsresult status, const PRUnichar *errorMsg) { - printf("ending status=%0x total=%d\n", status, mTotal); + nsresult aStatus, const PRUnichar* aStatusArg) { + printf("ending status=%0x total=%d\n", aStatus, mTotal); if (--mStopCount == 0) gDone = PR_TRUE; return NS_OK; @@ -240,8 +240,8 @@ public: } NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, - nsresult status, const PRUnichar *errorMsg) { - printf("stream closed: status %x\n", status); + nsresult aStatus, const PRUnichar* aStatusArg) { + printf("stream closed: status %x\n", aStatus); return NS_OK; } diff --git a/netwerk/test/TestProtocols.cpp b/netwerk/test/TestProtocols.cpp index dd2d02b842a..23ac8bb8bb9 100644 --- a/netwerk/test/TestProtocols.cpp +++ b/netwerk/test/TestProtocols.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * The contents of this file are subject to the Netscape Public * License Version 1.1 (the "License"); you may not use this file @@ -280,10 +280,8 @@ OpenObserver::OnStartRequest(nsIChannel* channel, nsISupports* context) } NS_IMETHODIMP -OpenObserver::OnStopRequest(nsIChannel* channel, - nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg) +OpenObserver::OnStopRequest(nsIChannel* channel, nsISupports* context, + nsresult aStatus, const PRUnichar* aStatusArg) { printf("\n+++ OpenObserver::OnStopRequest (status = %x) +++." "\tContext = %p\n", @@ -371,10 +369,8 @@ InputTestConsumer::OnDataAvailable(nsIChannel* channel, NS_IMETHODIMP -InputTestConsumer::OnStopRequest(nsIChannel* channel, - nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg) +InputTestConsumer::OnStopRequest(nsIChannel* channel, nsISupports* context, + nsresult aStatus, const PRUnichar* aStatusArg) { URLLoadInfo* info = (URLLoadInfo*)context; @@ -420,7 +416,7 @@ InputTestConsumer::OnStopRequest(nsIChannel* channel, pURI->GetSpec(&location); } - printf("\nFinished loading: %s Status Code: %x\n", location ? location : "UNKNOWN URL", aStatus); + printf("\nFinished loading: %s Status Code: %x\n", location ? location : "UNKNOWN URL", status); if (location) { nsCRT::free(location); @@ -461,7 +457,6 @@ NS_IMPL_ISUPPORTS1(nsNotificationCallbacks, nsIInterfaceRequestor) //////////////////////////////////////////////////////////////////////////////// - nsresult StartLoadingURL(const char* aUrlString) { nsresult rv; diff --git a/netwerk/test/TestRawCache.cpp b/netwerk/test/TestRawCache.cpp index 8f79d9c32f3..c3bf98995d1 100644 --- a/netwerk/test/TestRawCache.cpp +++ b/netwerk/test/TestRawCache.cpp @@ -37,6 +37,7 @@ #include "prenv.h" #include "nsIFileStreams.h" #include "nsIFileSpec.h" + // Number of test entries to be placed in the cache #define NUM_CACHE_ENTRIES 250 @@ -227,10 +228,8 @@ public: return NS_OK; } - NS_IMETHOD OnStopRequest(nsIChannel* channel, - nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg) { + NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports* context, + nsresult aStatus, const PRUnichar* aStatusArg) { PRIntervalTime endTime; PRIntervalTime duration; diff --git a/netwerk/test/TestRes.cpp b/netwerk/test/TestRes.cpp index 00bda4edcec..dd9ab94afa8 100644 --- a/netwerk/test/TestRes.cpp +++ b/netwerk/test/TestRes.cpp @@ -29,6 +29,7 @@ #include "nsIEventQueueService.h" #include "nsIURI.h" #include "nsCRT.h" + static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); @@ -142,7 +143,7 @@ public: } NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, - nsresult status, const PRUnichar *errorMsg) { + nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; nsCOMPtr uri; rv = channel->GetURI(getter_AddRefs(uri)); @@ -150,7 +151,7 @@ public: char* str; rv = uri->GetSpec(&str); if (NS_SUCCEEDED(rv)) { - fprintf(stdout, "Ending load %s, status=%x\n", str, status); + fprintf(stdout, "Ending load %s, status=%x\n", str, aStatus); nsCRT::free(str); } } diff --git a/netwerk/test/TestSocketIO.cpp b/netwerk/test/TestSocketIO.cpp index 7a15aa153f2..f57c99129a7 100644 --- a/netwerk/test/TestSocketIO.cpp +++ b/netwerk/test/TestSocketIO.cpp @@ -116,10 +116,8 @@ InputTestConsumer::OnDataAvailable(nsIChannel* channel, NS_IMETHODIMP -InputTestConsumer::OnStopRequest(nsIChannel* channel, - nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg) +InputTestConsumer::OnStopRequest(nsIChannel* channel, nsISupports* context, + nsresult aStatus, const PRUnichar* aStatusArg) { gKeepRunning = 0; printf("\n+++ InputTestConsumer::OnStopRequest (status = %x) +++\n", aStatus); @@ -169,8 +167,7 @@ TestWriteObserver::OnStartRequest(nsIChannel* channel, nsISupports* context) NS_IMETHODIMP TestWriteObserver::OnStopRequest(nsIChannel* channel, nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg) + nsresult aStatus, const PRUnichar* aStatusArg) { printf("\n+++ TestWriteObserver::OnStopRequest (status = %x) +++\n", aStatus); diff --git a/netwerk/test/TestSocketInput.cpp b/netwerk/test/TestSocketInput.cpp index 643497d558d..3543a3edd5b 100644 --- a/netwerk/test/TestSocketInput.cpp +++ b/netwerk/test/TestSocketInput.cpp @@ -61,8 +61,7 @@ public: PRUint32 aLength); NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg); + nsresult aStatus, const PRUnichar* aStatusArg); }; @@ -111,10 +110,8 @@ InputTestConsumer::OnDataAvailable(nsIChannel* channel, NS_IMETHODIMP -InputTestConsumer::OnStopRequest(nsIChannel* channel, - nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg) +InputTestConsumer::OnStopRequest(nsIChannel* channel, nsISupports* context, + nsresult aStatus, const PRUnichar* aStatusArg) { gKeepRunning = 0; printf("+++ OnStopRequest status %x +++\n", aStatus); diff --git a/netwerk/test/TestSocketTransport.cpp b/netwerk/test/TestSocketTransport.cpp index ffb5591c7e4..0c559b6e9be 100644 --- a/netwerk/test/TestSocketTransport.cpp +++ b/netwerk/test/TestSocketTransport.cpp @@ -54,7 +54,6 @@ #include "nsITimer.h" #include "nsIInterfaceRequestor.h" #include "nsIProgressEventSink.h" - #include "nsCRT.h" #if defined(XP_MAC) @@ -154,12 +153,14 @@ public: return NS_NOINTERFACE; } - NS_IMETHOD OnProgress(nsIChannel *channel, nsISupports *ctxt, PRUint32 aProgress, PRUint32 aProgressMax) { + NS_IMETHOD OnProgress(nsIChannel *channel, nsISupports *ctxt, + PRUint32 aProgress, PRUint32 aProgressMax) { putc('+', stderr); return NS_OK; } - NS_IMETHOD OnStatus(nsIChannel *channel, nsISupports *ctxt, const PRUnichar *aMsg) { + NS_IMETHOD OnStatus(nsIChannel *channel, nsISupports *ctxt, + nsresult aStatus, const PRUnichar* aStatusArg) { putc('?', stderr); return NS_OK; } @@ -216,10 +217,8 @@ TestConnectionOpenObserver::OnStartRequest(nsIChannel* channel, nsISupports* con } NS_IMETHODIMP -TestConnectionOpenObserver::OnStopRequest(nsIChannel* channel, - nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg) +TestConnectionOpenObserver::OnStopRequest(nsIChannel* channel, nsISupports* context, + nsresult aStatus, const PRUnichar* aStatusArg) { if (gVerbose || NS_FAILED(aStatus)) printf("\n+++ TestConnectionOpenObserver::OnStopRequest (status = %x) +++." @@ -276,10 +275,8 @@ TestConnection::OnDataAvailable(nsIChannel* channel, nsISupports* context, NS_IMETHODIMP -TestConnection::OnStopRequest(nsIChannel* channel, - nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg) +TestConnection::OnStopRequest(nsIChannel* channel, nsISupports* context, + nsresult aStatus, const PRUnichar* aStatusArg) { if (gVerbose || NS_FAILED(aStatus)) printf("\n+++ TestConnection::OnStopRequest (status = %x) +++." diff --git a/parser/htmlparser/src/nsParser.cpp b/parser/htmlparser/src/nsParser.cpp index 9c1336357d9..b0ae7136688 100644 --- a/parser/htmlparser/src/nsParser.cpp +++ b/parser/htmlparser/src/nsParser.cpp @@ -2030,13 +2030,15 @@ nsParser::OnProgress(nsIChannel* channel, nsISupports* aContext, PRUint32 aProgr * @return error code -- 0 if ok, non-zero if error. */ nsresult -nsParser::OnStatus(nsIChannel* channel, nsISupports* aContext, const PRUnichar* aMsg) +nsParser::OnStatus(nsIChannel* channel, nsISupports* aContext, + nsresult aStatus, const PRUnichar* aStatusArg) { - nsresult result=0; + nsresult rv; if (nsnull != mProgressEventSink) { - mProgressEventSink->OnStatus(channel, aContext, aMsg); + rv = mProgressEventSink->OnStatus(channel, aContext, aStatus, aStatusArg); + NS_ASSERTION(NS_SUCCEEDED(rv), "dropping error result"); } - return result; + return NS_OK; } #ifdef rickgdebug diff --git a/parser/htmlparser/src/nsParser.h b/parser/htmlparser/src/nsParser.h index 0d4db268fda..9257e3303cb 100644 --- a/parser/htmlparser/src/nsParser.h +++ b/parser/htmlparser/src/nsParser.h @@ -69,6 +69,7 @@ #include "nsHTMLTags.h" #include "nsDTDUtils.h" #include "nsTimer.h" +#include "nsIProgressEventSink.h" class IContentSink; class nsIDTD; @@ -250,9 +251,7 @@ CLASS_EXPORT_HTMLPARS nsParser : public nsIParser, // These methods are callback methods used by // net lib to let us know about our inputstream. //********************************************* - // nsIProgressEventSink methods: - NS_IMETHOD OnProgress(nsIChannel* channel, nsISupports* context, PRUint32 Progress, PRUint32 ProgressMax); - NS_IMETHOD OnStatus(nsIChannel* channel, nsISupports* context, const PRUnichar* aMmsg); + NS_DECL_NSIPROGRESSEVENTSINK // nsIStreamObserver methods: NS_DECL_NSISTREAMOBSERVER diff --git a/uriloader/base/nsDocLoader.cpp b/uriloader/base/nsDocLoader.cpp index 46df5d7752e..a629ef5ef63 100644 --- a/uriloader/base/nsDocLoader.cpp +++ b/uriloader/base/nsDocLoader.cpp @@ -40,7 +40,9 @@ #include "nsIDocument.h" #include "nsIPresShell.h" #include "nsIPresContext.h" +#include "nsIStringBundle.h" +static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); #if defined(PR_LOGGING) // @@ -1109,8 +1111,21 @@ NS_IMETHODIMP nsDocLoaderImpl::OnProgress(nsIChannel* aChannel, nsISupports* ctx return NS_OK; } -NS_IMETHODIMP nsDocLoaderImpl::OnStatus(nsIChannel* channel, nsISupports* ctxt, const PRUnichar* aMsg) +NS_IMETHODIMP nsDocLoaderImpl::OnStatus(nsIChannel* aChannel, nsISupports* ctxt, + nsresult aStatus, const PRUnichar* aStatusArg) { + // + // Fire progress notifications out to any registered nsIWebProgressListeners + // + if (aStatus) { + nsresult rv; + nsCOMPtr sbs = do_GetService(kStringBundleServiceCID, &rv); + if (NS_FAILED(rv)) return rv; + nsXPIDLString msg; + rv = sbs->FormatStatusMessage(aStatus, aStatusArg, getter_Copies(msg)); + if (NS_FAILED(rv)) return rv; + FireOnStatusChange(this, aChannel, aStatus, msg); + } return NS_OK; } @@ -1245,7 +1260,9 @@ void nsDocLoaderImpl::FireOnStateChange(nsIWebProgress *aProgress, NS_IMETHODIMP -nsDocLoaderImpl::FireOnLocationChange(nsIURI *aUri) +nsDocLoaderImpl::FireOnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI *aUri) { PRInt32 count; @@ -1261,7 +1278,33 @@ nsDocLoaderImpl::FireOnLocationChange(nsIURI *aUri) continue; } - listener->OnLocationChange(aUri); + listener->OnLocationChange(aWebProgress, aRequest, aUri); + } + + return NS_OK; +} + +NS_IMETHODIMP +nsDocLoaderImpl::FireOnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) +{ + PRInt32 count; + + count = mListenerList.Count(); + while (count > 0) { + nsIWebProgressListener *listener; + + listener = NS_STATIC_CAST(nsIWebProgressListener*, + mListenerList.ElementAt(--count)); + + NS_ASSERTION(listener, "NULL listener found in list."); + if (! listener) { + continue; + } + + listener->OnStatusChange(aWebProgress, aRequest, aStatus, aMessage); } return NS_OK; diff --git a/uriloader/base/nsIDocumentLoader.idl b/uriloader/base/nsIDocumentLoader.idl index 980ba59919d..9102736d38a 100644 --- a/uriloader/base/nsIDocumentLoader.idl +++ b/uriloader/base/nsIDocumentLoader.idl @@ -30,6 +30,8 @@ interface nsIDocumentLoaderObserver; interface nsIContentViewerContainer; interface nsIChannel; interface nsIURI; +interface nsIWebProgress; +interface nsIRequest; [scriptable, uuid(f43ba260-0737-11d2-beb9-00805f8a66dc)] interface nsIDocumentLoader : nsISupports @@ -50,6 +52,12 @@ interface nsIDocumentLoader : nsISupports // called between a parent doc loader and it's child. void clearParentDocLoader(); - void fireOnLocationChange(in nsIURI aUri); + void fireOnLocationChange(in nsIWebProgress aWebProgress, + in nsIRequest aRequest, + in nsIURI aUri); + void fireOnStatusChange(in nsIWebProgress aWebProgress, + in nsIRequest aRequest, + in nsresult aStatus, + in wstring aMessage); }; diff --git a/uriloader/base/nsIWebProgressListener.idl b/uriloader/base/nsIWebProgressListener.idl index 3d5566cd4c0..79a6843eb9a 100644 --- a/uriloader/base/nsIWebProgressListener.idl +++ b/uriloader/base/nsIWebProgressListener.idl @@ -110,5 +110,16 @@ interface nsIWebProgressListener : nsISupports @param location - The URI of the location that is being loaded. */ - void onLocationChange(in nsIURI location); -}; \ No newline at end of file + void onLocationChange(in nsIWebProgress aWebProgress, + in nsIRequest aRequest, + in nsIURI location); + + /** + * Notification that the status has changed. The status message is usually + * printed in the status bar of the browser. + */ + void onStatusChange(in nsIWebProgress aWebProgress, + in nsIRequest aRequest, + in nsresult aStatus, + in wstring aMessage); +}; diff --git a/webshell/tests/viewer/nsBrowserWindow.cpp b/webshell/tests/viewer/nsBrowserWindow.cpp index 02c49f365a4..1d87819149c 100644 --- a/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/webshell/tests/viewer/nsBrowserWindow.cpp @@ -2176,11 +2176,19 @@ nsBrowserWindow::OnProgress(nsIChannel* channel, nsISupports *ctxt, } NS_IMETHODIMP -nsBrowserWindow::OnStatus(nsIChannel* channel, nsISupports *ctxt, const PRUnichar *aMsg) +nsBrowserWindow::OnStatus(nsIChannel* channel, nsISupports *ctxt, + nsresult aStatus, const PRUnichar *aStatusArg) { if (mStatus) { + nsresult rv; + nsCOMPtr sbs = do_GetService(kStringBundleServiceCID, &rv); + if (NS_FAILED(rv)) return rv; + nsXPIDLString msg; + rv = sbs->FormatStatusMessage(aStatus, aStatusArg, getter_Copies(msg)); + if (NS_FAILED(rv)) return rv; PRUint32 size; - mStatus->SetText(aMsg,size); + nsAutoString msg2 = msg; + mStatus->SetText(msg2, size); } return NS_OK; } diff --git a/webshell/tests/viewer/nsWebBrowserChrome.cpp b/webshell/tests/viewer/nsWebBrowserChrome.cpp index 3eacca57b93..2f81faa9fd3 100644 --- a/webshell/tests/viewer/nsWebBrowserChrome.cpp +++ b/webshell/tests/viewer/nsWebBrowserChrome.cpp @@ -447,7 +447,9 @@ nsWebBrowserChrome::OnStateChange(nsIWebProgress* aProgress, return NS_OK; } -NS_IMETHODIMP nsWebBrowserChrome::OnLocationChange(nsIURI* aURI) +NS_IMETHODIMP nsWebBrowserChrome::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI* aURI) { nsXPIDLCString spec; @@ -465,6 +467,19 @@ NS_IMETHODIMP nsWebBrowserChrome::OnLocationChange(nsIURI* aURI) return NS_OK; } +NS_IMETHODIMP +nsWebBrowserChrome::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) +{ + if (mBrowserWindow->mStatus) { + PRUint32 size; + mBrowserWindow->mStatus->SetText(aMessage, size); + } + return NS_OK; +} + //***************************************************************************** // nsWebBrowserChrome: Helpers //***************************************************************************** @@ -574,7 +589,7 @@ void nsWebBrowserChrome::OnLoadFinished(nsIRequest* aRequest, if(mBrowserWindow->mStatus) { - PRUint32 size; +// PRUint32 size; msg.AppendWithConversion(" done."); diff --git a/xpcom/base/makefile.win b/xpcom/base/makefile.win index 879f0b8cb83..0620d57fd26 100644 --- a/xpcom/base/makefile.win +++ b/xpcom/base/makefile.win @@ -109,7 +109,10 @@ CPP_OBJS = \ include <$(DEPTH)\config\rules.mak> +LOCALEDIR=$(DIST)\bin\chrome\locales\en-US\global\locale + install:: $(DLL) + $(MAKE_INSTALL) xpcom.properties $(LOCALEDIR) # $(MAKE_INSTALL) $(LIBNAME).$(DLL_SUFFIX) $(DIST)\bin # $(MAKE_INSTALL) $(LIBNAME).$(LIB_SUFFIX) $(DIST)\lib diff --git a/xpcom/base/nsErrorService.cpp b/xpcom/base/nsErrorService.cpp index 5b7c5a5c530..583664b1be1 100644 --- a/xpcom/base/nsErrorService.cpp +++ b/xpcom/base/nsErrorService.cpp @@ -120,19 +120,19 @@ nsErrorService::GetErrorStringBundle(PRInt16 errorModule, char **result) NS_IMETHODIMP nsErrorService::RegisterErrorStringBundleKey(nsresult error, const char *stringBundleKey) { - return mErrorStringBundleKeyMap.Put(NS_ERROR_GET_CODE(error), stringBundleKey); + return mErrorStringBundleKeyMap.Put(error, stringBundleKey); } NS_IMETHODIMP nsErrorService::UnregisterErrorStringBundleKey(nsresult error) { - return mErrorStringBundleKeyMap.Remove(NS_ERROR_GET_CODE(error)); + return mErrorStringBundleKeyMap.Remove(error); } NS_IMETHODIMP nsErrorService::GetErrorStringBundleKey(nsresult error, char **result) { - char* value = mErrorStringBundleKeyMap.Get(NS_ERROR_GET_CODE(error)); + char* value = mErrorStringBundleKeyMap.Get(error); if (value == nsnull) return NS_ERROR_OUT_OF_MEMORY; *result = value; diff --git a/xpcom/base/xpcom.properties b/xpcom/base/xpcom.properties new file mode 100644 index 00000000000..e69de29bb2d diff --git a/xpfe/appshell/public/nsIXULBrowserWindow.idl b/xpfe/appshell/public/nsIXULBrowserWindow.idl index 00d82751f40..905ed94d91f 100644 --- a/xpfe/appshell/public/nsIXULBrowserWindow.idl +++ b/xpfe/appshell/public/nsIXULBrowserWindow.idl @@ -54,10 +54,10 @@ interface nsIXULBrowserWindow : nsISupports void setDefaultStatus(in wstring status); /* - Tells the browser window that there is a status change with the window. - These status flags are specified in nsIWebProgress. + Tells the browser window that there is a state change with the window. + These state flags are specified in nsIWebProgress. */ - void onStatusChange(in nsIChannel aChannel, in unsigned long aProgressStatusFlags); + void onStateChange(in nsIChannel aChannel, in unsigned long aProgressStateFlags); /* Tells the browser window that the location of the window has changed. @@ -68,6 +68,11 @@ interface nsIXULBrowserWindow : nsISupports Tells the browser window that the progress for the current load has changed. */ void onProgress (in nsIChannel aChannel, in long aCurrentProgress, in long aMaxProgress); + + /* + Tells the browser window that a new status message is available. + */ + void onStatus(in nsIChannel aChannel, in nsresult aStatus, in wstring aMsg); }; diff --git a/xpfe/appshell/src/nsChromeTreeOwner.cpp b/xpfe/appshell/src/nsChromeTreeOwner.cpp index 354113c07a7..297ca78f49e 100644 --- a/xpfe/appshell/src/nsChromeTreeOwner.cpp +++ b/xpfe/appshell/src/nsChromeTreeOwner.cpp @@ -342,13 +342,24 @@ nsChromeTreeOwner::OnStateChange(nsIWebProgress* aWebProgress, return NS_OK; } -NS_IMETHODIMP nsChromeTreeOwner::OnLocationChange(nsIURI* aLocation) +NS_IMETHODIMP nsChromeTreeOwner::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI* aLocation) { // If loading a new root .xul document, then redo chrome. mXULWindow->mChromeLoaded = PR_FALSE; return NS_OK; } +NS_IMETHODIMP +nsChromeTreeOwner::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) +{ + return NS_OK; +} + //***************************************************************************** // nsChromeTreeOwner: Helpers //***************************************************************************** diff --git a/xpfe/browser/public/nsIXULBrowserWindow.idl b/xpfe/browser/public/nsIXULBrowserWindow.idl index 00d82751f40..905ed94d91f 100644 --- a/xpfe/browser/public/nsIXULBrowserWindow.idl +++ b/xpfe/browser/public/nsIXULBrowserWindow.idl @@ -54,10 +54,10 @@ interface nsIXULBrowserWindow : nsISupports void setDefaultStatus(in wstring status); /* - Tells the browser window that there is a status change with the window. - These status flags are specified in nsIWebProgress. + Tells the browser window that there is a state change with the window. + These state flags are specified in nsIWebProgress. */ - void onStatusChange(in nsIChannel aChannel, in unsigned long aProgressStatusFlags); + void onStateChange(in nsIChannel aChannel, in unsigned long aProgressStateFlags); /* Tells the browser window that the location of the window has changed. @@ -68,6 +68,11 @@ interface nsIXULBrowserWindow : nsISupports Tells the browser window that the progress for the current load has changed. */ void onProgress (in nsIChannel aChannel, in long aCurrentProgress, in long aMaxProgress); + + /* + Tells the browser window that a new status message is available. + */ + void onStatus(in nsIChannel aChannel, in nsresult aStatus, in wstring aMsg); }; diff --git a/xpfe/browser/resources/content/navigator.js b/xpfe/browser/resources/content/navigator.js index 07c149d849e..0cb344428de 100644 --- a/xpfe/browser/resources/content/navigator.js +++ b/xpfe/browser/resources/content/navigator.js @@ -215,48 +215,48 @@ function nsXULBrowserWindow() nsXULBrowserWindow.prototype = { - QueryInterface : function(iid) - { - if(iid.equals(Components.interfaces.nsIXULBrowserWindow)) - return this; - throw Components.results.NS_NOINTERFACE; - }, - setJSStatus : function(status) - { - if(status == "") - jsStatus = null; - else - jsStatus = status; - UpdateStatusField(); - }, - setJSDefaultStatus : function(status) - { - if(status == "") - jsDefaultStatus = null; - else - jsDefaultStatus = status; - UpdateStatusField(); - }, - setDefaultStatus : function(status) - { - if(status == "") - defaultStatus = null; - else - defaultStatus = status; - UpdateStatusField(); - }, - setOverLink : function(link) - { - if(link == "") - overLink = null; - else - overLink = link; - UpdateStatusField(); - }, + QueryInterface : function(iid) + { + if(iid.equals(Components.interfaces.nsIXULBrowserWindow)) + return this; + throw Components.results.NS_NOINTERFACE; + }, + setJSStatus : function(status) + { + if(status == "") + jsStatus = null; + else + jsStatus = status; + UpdateStatusField(); + }, + setJSDefaultStatus : function(status) + { + if(status == "") + jsDefaultStatus = null; + else + jsDefaultStatus = status; + UpdateStatusField(); + }, + setDefaultStatus : function(status) + { + if(status == "") + defaultStatus = null; + else + defaultStatus = status; + UpdateStatusField(); + }, + setOverLink : function(link) + { + if(link == "") + overLink = null; + else + overLink = link; + UpdateStatusField(); + }, onProgress : function (channel, current, max) { - if(!statusMeter) - statusMeter = document.getElementById("statusbar-icon"); + if(!statusMeter) + statusMeter = document.getElementById("statusbar-icon"); var percentage = 0; if (!useRealProgressFlag && (channel != null)) { @@ -275,19 +275,19 @@ nsXULBrowserWindow.prototype = statusMeter.setAttribute("mode","undetermined"); } }, - onStatusChange : function(channel, status) - { - if(!throbberElement) - throbberElement = document.getElementById("navigator-throbber"); - if(!statusMeter) - statusMeter = document.getElementById("statusbar-icon"); - if(!stopButton) - stopButton = document.getElementById("stop-button"); - if(!stopMenu) - stopMenu = document.getElementById("menuitem-stop"); + onStateChange : function(channel, state) + { + if(!throbberElement) + throbberElement = document.getElementById("navigator-throbber"); + if(!statusMeter) + statusMeter = document.getElementById("statusbar-icon"); + if(!stopButton) + stopButton = document.getElementById("stop-button"); + if(!stopMenu) + stopMenu = document.getElementById("menuitem-stop"); - if (status & Components.interfaces.nsIWebProgressListener.flag_start) { - if(status & Components.interfaces.nsIWebProgressListener.flag_is_network) { + if (state & Components.interfaces.nsIWebProgressListener.flag_start) { + if(state & Components.interfaces.nsIWebProgressListener.flag_is_network) { // Remember when loading commenced. startTime = (new Date()).getTime(); // Turn progress meter on. @@ -304,25 +304,27 @@ nsXULBrowserWindow.prototype = totalRequests = 0; finishedRequests = 0; } - if (status & Components.interfaces.nsIWebProgressListener.flag_is_request) { + if (state & Components.interfaces.nsIWebProgressListener.flag_is_request) { totalRequests += 1; } } - else if (status & Components.interfaces.nsIWebProgressListener.flag_stop) { - if (status & Components.interfaces.nsIWebProgressListener.flag_is_request) { + else if (state & Components.interfaces.nsIWebProgressListener.flag_stop) { + if (state & Components.interfaces.nsIWebProgressListener.flag_is_request) { finishedRequests += 1; if (!useRealProgressFlag) { this.onProgress(null, finishedRequests, totalRequests); } } - if(status & Components.interfaces.nsIWebProgressListener.flag_is_network) { + if(state & Components.interfaces.nsIWebProgressListener.flag_is_network) { // Record page loading time. var elapsed = ( (new Date()).getTime() - startTime ) / 1000; var msg = bundle.GetStringFromName("nv_done") + " (" + elapsed + " secs)"; dump( msg + "\n" ); defaultStatus = msg; UpdateStatusField(); - window.XULBrowserWindow.setDefaultStatus(msg); + //window.XULBrowserWindow.setDefaultStatus(msg); + //this.setDefaultStatus(msg); + this.setOverLink(msg); // Turn progress meter off. statusMeter.setAttribute("mode","normal"); statusMeter.value = 0; // be sure to clear the progress bar @@ -334,8 +336,8 @@ nsXULBrowserWindow.prototype = stopMenu.setAttribute("disabled", true); } } - else if (status & Components.interfaces.nsIWebProgressListener.flag_transferring) { - if (status & Components.interfaces.nsIWebProgressListener.flag_is_document) { + else if (state & Components.interfaces.nsIWebProgressListener.flag_transferring) { + if (state & Components.interfaces.nsIWebProgressListener.flag_is_document) { var ctype=channel.contentType; if (ctype != "text/html") { @@ -343,25 +345,30 @@ nsXULBrowserWindow.prototype = } statusMeter.setAttribute("mode", "normal"); } - if (status & Components.interfaces.nsIWebProgressListener.flag_is_request) { + if (state & Components.interfaces.nsIWebProgressListener.flag_is_request) { if (!useRealProgressFlag) { this.onProgress(null, finishedRequests, totalRequests); } } } - }, - onLocationChange : function(location) - { - if(!locationFld) - locationFld = document.getElementById("urlbar"); + }, + onLocationChange : function(location) + { + if(!locationFld) + locationFld = document.getElementById("urlbar"); - // We should probably not do this if the value has changed since the user - // searched - locationFld.setAttribute("value", location); + // We should probably not do this if the value has changed since the user + // searched + locationFld.setAttribute("value", location); - UpdateBackForwardButtons(); - } + UpdateBackForwardButtons(); + }, + onStatus : function(channel, status, msg) + { + this.setOverLink(msg); + //this.setDefaultStatus(msg); + } } function UpdateBackForwardButtons() @@ -1503,8 +1510,13 @@ var leakDetector = null; // Dumps current set of memory leaks. function dumpMemoryLeaks() { - if (leakDetector == null) - leakDetector = createInstance("component://netscape/xpcom/leakdetector", "nsILeakDetector"); + if (leakDetector == null) { + leakDetector = createInstance("component://netscape/xpcom/leakdetector", "nsILeakDetector"); + if (leakDetector == null) { + dump("Could not create leak detector, leak detection probably\n"); + dump("not compiled into this browser\n"); + } + } if (leakDetector != null) leakDetector.dumpLeaks(); } diff --git a/xpfe/browser/src/nsBrowserInstance.cpp b/xpfe/browser/src/nsBrowserInstance.cpp index a282427de50..1824bbc3469 100644 --- a/xpfe/browser/src/nsBrowserInstance.cpp +++ b/xpfe/browser/src/nsBrowserInstance.cpp @@ -1736,15 +1736,16 @@ nsBrowserInstance::OnStateChange(nsIWebProgress* aWebProgress, channel = do_QueryInterface(aRequest, &rv); if (NS_SUCCEEDED(rv)) { - mXULBrowserWindow->OnStatusChange(channel, aProgressStateFlags); + mXULBrowserWindow->OnStateChange(channel, aProgressStateFlags); } } return NS_OK; } -NS_IMETHODIMP nsBrowserInstance::OnLocationChange(nsIURI* aLocation) +NS_IMETHODIMP nsBrowserInstance::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI* aLocation) { - EnsureXULBrowserWindow(); if(!mXULBrowserWindow) return NS_OK; @@ -1757,6 +1758,25 @@ NS_IMETHODIMP nsBrowserInstance::OnLocationChange(nsIURI* aLocation) return NS_OK; } +NS_IMETHODIMP +nsBrowserInstance::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) +{ + EnsureXULBrowserWindow(); + if(mXULBrowserWindow) { + nsresult rv; + nsCOMPtr channel; + + channel = do_QueryInterface(aRequest, &rv); + if (NS_SUCCEEDED(rv)) { + mXULBrowserWindow->OnStatus(channel, aStatus, aMessage); + } + } + return NS_OK; +} + //***************************************************************************** // nsBrowserInstance: Helpers //***************************************************************************** diff --git a/xpfe/components/xfer/src/nsStreamXferOp.cpp b/xpfe/components/xfer/src/nsStreamXferOp.cpp index 2dcd703ae3a..8d0bd007072 100644 --- a/xpfe/components/xfer/src/nsStreamXferOp.cpp +++ b/xpfe/components/xfer/src/nsStreamXferOp.cpp @@ -42,6 +42,9 @@ #include "prprf.h" +#include "nsIStringBundle.h" +static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); + #ifdef NS_DEBUG #define DEBUG_PRINTF PR_fprintf #else @@ -396,11 +399,17 @@ nsStreamXferOp::OnProgress(nsIChannel* channel, nsISupports* aContext, NS_IMETHODIMP nsStreamXferOp::OnStatus( nsIChannel *channel, nsISupports *aContext, - const PRUnichar *aMsg ) { + nsresult aStatus, + const PRUnichar *aStatusArg) { nsresult rv = NS_OK; if ( mObserver ) { - nsString msg = aMsg; + nsCOMPtr sbs = do_GetService(kStringBundleServiceCID, &rv); + if (NS_FAILED(rv)) return rv; + nsXPIDLString str; + rv = sbs->FormatStatusMessage(aStatus, aStatusArg, getter_Copies(str)); + if (NS_FAILED(rv)) return rv; + nsAutoString msg = str; rv = mObserver->Observe( (nsIStreamTransferOperation*)this, NS_ConvertASCIItoUCS2( NS_ISTREAMTRANSFER_PROGID ";onStatus" ).GetUnicode(), msg.GetUnicode() ); diff --git a/xpinstall/src/nsXPInstallManager.cpp b/xpinstall/src/nsXPInstallManager.cpp index 392b996dab3..f422bfda548 100644 --- a/xpinstall/src/nsXPInstallManager.cpp +++ b/xpinstall/src/nsXPInstallManager.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * The contents of this file are subject to the Netscape Public * License Version 1.1 (the "License"); you may not use this file @@ -817,7 +817,7 @@ nsXPInstallManager::OnProgress(nsIChannel *channel, nsISupports *ctxt, PRUint32 rv = channel->GetContentLength(&mContentLength); if (NS_FAILED(rv)) return rv; } - mLastUpdate = now; + mLastUpdate = now; rv = mDlg->SetProgress(aProgress, mContentLength, PROGRESS_BAR); } @@ -825,13 +825,20 @@ nsXPInstallManager::OnProgress(nsIChannel *channel, nsISupports *ctxt, PRUint32 } NS_IMETHODIMP -nsXPInstallManager::OnStatus(nsIChannel *channel, nsISupports *ctxt, const PRUnichar *aMsg) +nsXPInstallManager::OnStatus(nsIChannel *channel, nsISupports *ctxt, + nsresult aStatus, const PRUnichar *aStatusArg) { + nsresult rv; PRTime now = PR_Now(); if (!mCancelled && TimeToUpdate(now)) { - mLastUpdate = now; - return mDlg->SetActionText(aMsg); + mLastUpdate = now; + nsCOMPtr sbs = do_GetService(kStringBundleServiceCID, &rv); + if (NS_FAILED(rv)) return rv; + nsXPIDLString msg; + rv = sbs->FormatStatusMessage(aStatus, aStatusArg, getter_Copies(msg)); + if (NS_FAILED(rv)) return rv; + return mDlg->SetActionText(msg); } else return NS_OK;