[X2Go-Commits] [pale-moon] 17/24: Convert UI-dictating FTP errors to console errors.

git-admin at x2go.org git-admin at x2go.org
Thu Apr 25 09:06:08 CEST 2019


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch upstream/28.4.1
in repository pale-moon.

commit 1af286ffef9b71ed8dbe68b8d25484f47dfd75ec
Author: wolfbeast <mcwerewolf at wolfbeast.com>
Date:   Sat Mar 23 10:46:00 2019 +0100

    Convert UI-dictating FTP errors to console errors.
---
 netwerk/protocol/ftp/FTPChannelChild.cpp       | 41 +------------
 netwerk/protocol/ftp/nsFtpConnectionThread.cpp | 81 +-------------------------
 2 files changed, 4 insertions(+), 118 deletions(-)

diff --git a/netwerk/protocol/ftp/FTPChannelChild.cpp b/netwerk/protocol/ftp/FTPChannelChild.cpp
index f8284aa..f525867 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 2ae1284..0dae7ca 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) {

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/pale-moon.git


More information about the x2go-commits mailing list