summaryrefslogtreecommitdiff
path: root/netwerk
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-03-23 10:46:00 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-03-23 10:46:00 +0100
commita363bd3d794b2bd4ba67186c7d2bff9b6f24d1b0 (patch)
tree610646ffc7a5d7602c8ba7ccde810d0400672aa8 /netwerk
parent969d50e373f28a57dfb78961e1f276492a855c6d (diff)
downloaduxp-a363bd3d794b2bd4ba67186c7d2bff9b6f24d1b0.tar.gz
Convert UI-dictating FTP errors to console errors.
Diffstat (limited to 'netwerk')
-rw-r--r--netwerk/protocol/ftp/FTPChannelChild.cpp41
-rw-r--r--netwerk/protocol/ftp/nsFtpConnectionThread.cpp81
2 files changed, 4 insertions, 118 deletions
diff --git a/netwerk/protocol/ftp/FTPChannelChild.cpp b/netwerk/protocol/ftp/FTPChannelChild.cpp
index f8284aae3c..f52586744a 100644
--- a/netwerk/protocol/ftp/FTPChannelChild.cpp
+++ b/netwerk/protocol/ftp/FTPChannelChild.cpp
@@ -516,33 +516,6 @@ FTPChannelChild::RecvOnStopRequest(const nsresult& aChannelStatus,
return true;
}
-class nsFtpChildAsyncAlert : public Runnable
-{
-public:
- nsFtpChildAsyncAlert(nsIPrompt *aPrompter, nsString aResponseMsg)
- : mPrompter(aPrompter)
- , mResponseMsg(aResponseMsg)
- {
- MOZ_COUNT_CTOR(nsFtpChildAsyncAlert);
- }
-protected:
- virtual ~nsFtpChildAsyncAlert()
- {
- MOZ_COUNT_DTOR(nsFtpChildAsyncAlert);
- }
-public:
- NS_IMETHOD Run() override
- {
- if (mPrompter) {
- mPrompter->Alert(nullptr, mResponseMsg.get());
- }
- return NS_OK;
- }
-private:
- nsCOMPtr<nsIPrompt> mPrompter;
- nsString mResponseMsg;
-};
-
class MaybeDivertOnStopFTPEvent : public ChannelEvent
{
public:
@@ -600,19 +573,7 @@ FTPChannelChild::DoOnStopRequest(const nsresult& aChannelStatus,
(void)mListener->OnStopRequest(this, mListenerContext, aChannelStatus);
if (NS_FAILED(aChannelStatus) && !aErrorMsg.IsEmpty()) {
- nsCOMPtr<nsIPrompt> prompter;
- GetCallback(prompter);
- if (prompter) {
- nsCOMPtr<nsIRunnable> alertEvent;
- if (aUseUTF8) {
- alertEvent = new nsFtpChildAsyncAlert(prompter,
- NS_ConvertUTF8toUTF16(aErrorMsg));
- } else {
- alertEvent = new nsFtpChildAsyncAlert(prompter,
- NS_ConvertASCIItoUTF16(aErrorMsg));
- }
- NS_DispatchToMainThread(alertEvent);
- }
+ NS_ERROR("FTP error on stop request.");
}
mListener = nullptr;
diff --git a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp
index 2ae12846a2..0dae7ca921 100644
--- a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp
+++ b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp
@@ -29,7 +29,6 @@
#include "nsIStreamListenerTee.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
-#include "nsIStringBundle.h"
#include "nsAuthInformationHolder.h"
#include "nsIProtocolProxyService.h"
#include "nsICancelable.h"
@@ -926,38 +925,7 @@ nsFtpState::R_syst() {
mServerType = FTP_VMS_TYPE;
} else {
NS_ERROR("Server type list format unrecognized.");
- // Guessing causes crashes.
- // (Of course, the parsing code should be more robust...)
- nsCOMPtr<nsIStringBundleService> bundleService =
- do_GetService(NS_STRINGBUNDLE_CONTRACTID);
- if (!bundleService)
- return FTP_ERROR;
-
- nsCOMPtr<nsIStringBundle> bundle;
- nsresult rv = bundleService->CreateBundle(NECKO_MSGS_URL,
- getter_AddRefs(bundle));
- if (NS_FAILED(rv))
- return FTP_ERROR;
-
- char16_t* ucs2Response = ToNewUnicode(mResponseMsg);
- const char16_t *formatStrings[1] = { ucs2Response };
- NS_NAMED_LITERAL_STRING(name, "UnsupportedFTPServer");
-
- nsXPIDLString formattedString;
- rv = bundle->FormatStringFromName(name.get(), formatStrings, 1,
- getter_Copies(formattedString));
- free(ucs2Response);
- if (NS_FAILED(rv))
- return FTP_ERROR;
-
- // TODO(darin): this code should not be dictating UI like this!
- nsCOMPtr<nsIPrompt> prompter;
- mChannel->GetCallback(prompter);
- if (prompter)
- prompter->Alert(nullptr, formattedString.get());
-
- // since we just alerted the user, clear mResponseMsg,
- // which is displayed to the user.
+ // clear mResponseMsg, which is displayed to the user.
mResponseMsg = "";
return FTP_ERROR;
}
@@ -1779,34 +1747,6 @@ nsFtpState::KillControlConnection()
mControlConnection = nullptr;
}
-class nsFtpAsyncAlert : public Runnable
-{
-public:
- nsFtpAsyncAlert(nsIPrompt *aPrompter, nsString aResponseMsg)
- : mPrompter(aPrompter)
- , mResponseMsg(aResponseMsg)
- {
- MOZ_COUNT_CTOR(nsFtpAsyncAlert);
- }
-protected:
- virtual ~nsFtpAsyncAlert()
- {
- MOZ_COUNT_DTOR(nsFtpAsyncAlert);
- }
-public:
- NS_IMETHOD Run() override
- {
- if (mPrompter) {
- mPrompter->Alert(nullptr, mResponseMsg.get());
- }
- return NS_OK;
- }
-private:
- nsCOMPtr<nsIPrompt> mPrompter;
- nsString mResponseMsg;
-};
-
-
nsresult
nsFtpState::StopProcessing()
{
@@ -1818,23 +1758,8 @@ nsFtpState::StopProcessing()
LOG_INFO(("FTP:(%x) nsFtpState stopping", this));
if (NS_FAILED(mInternalError) && !mResponseMsg.IsEmpty()) {
- // check to see if the control status is bad.
- // web shell wont throw an alert. we better:
-
- // XXX(darin): this code should not be dictating UI like this!
- nsCOMPtr<nsIPrompt> prompter;
- mChannel->GetCallback(prompter);
- if (prompter) {
- nsCOMPtr<nsIRunnable> alertEvent;
- if (mUseUTF8) {
- alertEvent = new nsFtpAsyncAlert(prompter,
- NS_ConvertUTF8toUTF16(mResponseMsg));
- } else {
- alertEvent = new nsFtpAsyncAlert(prompter,
- NS_ConvertASCIItoUTF16(mResponseMsg));
- }
- NS_DispatchToMainThread(alertEvent);
- }
+ NS_ERROR("FTP: bad control status.");
+ // check to see if the control status is bad; forward the error message.
nsCOMPtr<nsIFTPChannelParentInternal> ftpChanP;
mChannel->GetCallback(ftpChanP);
if (ftpChanP) {