Bug 1558536 - C-C part: Adapt to array changes of nsISocketTransportService.create{Routed}Transport. r=darktrojan
authorJorg K <jorgk@jorgk.com>
Fri, 14 Jun 2019 00:21:55 +0200
changeset 35861 3e76c29bfb96ce9f785f63c4d2adb318f3664dbf
parent 35860 39836474eb698ff365f89544b0156419e4d71208
child 35862 18fc7a8887b9dd8cb2e92fb74597393750bfaa82
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersdarktrojan
bugs1558536
Bug 1558536 - C-C part: Adapt to array changes of nsISocketTransportService.create{Routed}Transport. r=darktrojan
chat/modules/socket.jsm
mail/components/accountcreation/content/guessConfig.js
mailnews/base/util/nsMsgProtocol.cpp
mailnews/db/gloda/modules/log4moz.js
mailnews/imap/src/nsImapProtocol.cpp
mailnews/test/resources/NetworkTestUtils.jsm
--- a/chat/modules/socket.jsm
+++ b/chat/modules/socket.jsm
@@ -539,17 +539,17 @@ var Socket = {
     this._resetBuffers();
 
     // Create a routed socket transport
     // We connect to host and port, but the origin host and origin port are
     // given to PSM (e.g. check the certificate).
     let socketTS = Cc["@mozilla.org/network/socket-transport-service;1"]
                       .getService(Ci.nsIRoutedSocketTransportService);
     this.transport =
-      socketTS.createRoutedTransport(this.security, this.security.length,
+      socketTS.createRoutedTransport(this.security,
                                      this.originHost, this.originPort,
                                      this.host, this.port,
                                      this.proxy);
 
     this._openStreams();
   },
 
   // Open the incoming and outgoing streams, and init the nsISocketTransport.
--- a/mail/components/accountcreation/content/guessConfig.js
+++ b/mail/components/accountcreation/content/guessConfig.js
@@ -981,24 +981,25 @@ function SocketUtil(hostname, port, ssl,
 
   // The timeout value plus 2 seconds
   setTimeout(timeoutFunc, (timeout * 1000) + 2000);
 
   var transportService = Cc["@mozilla.org/network/socket-transport-service;1"]
                          .getService(Ci.nsISocketTransportService);
 
   // @see NS_NETWORK_SOCKET_CONTRACTID_PREFIX
-  var socketTypeName = null;
+  var socketTypeName;
   if (ssl == SSL) {
-    socketTypeName = "ssl";
+    socketTypeName = ["ssl"];
   } else if (ssl == TLS) {
-    socketTypeName = "starttls";
+    socketTypeName = ["starttls"];
+  } else {
+    socketTypeName = [];
   }
-  var transport = transportService.createTransport([socketTypeName],
-                                                   ssl == NONE ? 0 : 1,
+  var transport = transportService.createTransport(socketTypeName,
                                                    hostname, port, proxy);
 
   transport.setTimeout(Ci.nsISocketTransport.TIMEOUT_CONNECT, timeout);
   transport.setTimeout(Ci.nsISocketTransport.TIMEOUT_READ_WRITE, timeout);
   try {
     transport.securityCallbacks = new BadCertHandler(sslErrorHandler);
   } catch (e) {
     _error(e);
--- a/mailnews/base/util/nsMsgProtocol.cpp
+++ b/mailnews/base/util/nsMsgProtocol.cpp
@@ -120,19 +120,21 @@ nsresult nsMsgProtocol::OpenNetworkSocke
   nsCOMPtr<nsISocketTransportService> socketService(
       do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID));
   NS_ENSURE_TRUE(socketService, NS_ERROR_FAILURE);
 
   // with socket connections we want to read as much data as arrives
   m_readCount = -1;
 
   nsCOMPtr<nsISocketTransport> strans;
-  rv = socketService->CreateTransport(
-      &connectionType, connectionType != nullptr, nsDependentCString(aHostName),
-      aGetPort, aProxyInfo, getter_AddRefs(strans));
+  AutoTArray<nsCString, 1> connectionTypeArray;
+  if (connectionType) connectionTypeArray.AppendElement(connectionType);
+  rv = socketService->CreateTransport(connectionTypeArray,
+                                      nsDependentCString(aHostName), aGetPort,
+                                      aProxyInfo, getter_AddRefs(strans));
   if (NS_FAILED(rv)) return rv;
 
   strans->SetSecurityCallbacks(callbacks);
 
   // creates cyclic reference!
   nsCOMPtr<nsIThread> currentThread(do_GetCurrentThread());
   strans->SetEventSink(this, currentThread);
 
--- a/mailnews/db/gloda/modules/log4moz.js
+++ b/mailnews/db/gloda/modules/log4moz.js
@@ -811,17 +811,17 @@ SocketAppender.prototype = {
   openStream() {
     let now = Date.now();
     if (now <= this._nextCheck) {
       return;
     }
     this._nextCheck = now + this._timeout_delay * 1000;
     try {
       this._transport = this._socketService.createTransport(
-        null, 0, // default socket type
+        [], // default socket type
         this._host, this._port,
         null); // no proxy
       this._transport.setTimeout(Ci.nsISocketTransport.TIMEOUT_CONNECT,
                                  this._timeout_delay);
       // do not set a timeout for TIMEOUT_READ_WRITE. The timeout is not
       //  entirely intuitive; your socket will time out if no one reads or
       //  writes to the socket within the timeout.  That, as you can imagine,
       //  is not what we want.
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -944,25 +944,26 @@ nsresult nsImapProtocol::SetupWithUrlCal
   else if (m_socketType == nsMsgSocketType::trySTARTTLS)
     connectionType = "starttls";
 
   int32_t port = -1;
   nsCOMPtr<nsIURI> uri = do_QueryInterface(m_runningUrl, &rv);
   if (NS_FAILED(rv)) return rv;
   uri->GetPort(&port);
 
-  rv = socketService->CreateTransport(
-      &connectionType, connectionType != nullptr, m_realHostName, port,
-      aProxyInfo, getter_AddRefs(m_transport));
+  AutoTArray<nsCString, 1> connectionTypeArray;
+  if (connectionType) connectionTypeArray.AppendElement(connectionType);
+  rv = socketService->CreateTransport(connectionTypeArray, m_realHostName, port,
+                                      aProxyInfo, getter_AddRefs(m_transport));
   if (NS_FAILED(rv) && m_socketType == nsMsgSocketType::trySTARTTLS) {
     connectionType = nullptr;
     m_socketType = nsMsgSocketType::plain;
-    rv = socketService->CreateTransport(
-        &connectionType, connectionType != nullptr, m_realHostName, port,
-        aProxyInfo, getter_AddRefs(m_transport));
+    rv = socketService->CreateTransport(connectionTypeArray, m_realHostName,
+                                        port, aProxyInfo,
+                                        getter_AddRefs(m_transport));
   }
 
   // remember so we can know whether we can issue a start tls or not...
   m_connectionType = connectionType;
   if (m_transport && m_mockChannel) {
     uint8_t qos;
     rv = GetQoSBits(&qos);
     if (NS_SUCCEEDED(rv)) m_transport->SetQoSBits(qos);
--- a/mailnews/test/resources/NetworkTestUtils.jsm
+++ b/mailnews/test/resources/NetworkTestUtils.jsm
@@ -142,17 +142,17 @@ SocksClient.prototype = {
       return;
     }
 
     // At this point, we contact the local server on that port and then we feed
     // the data back and forth. Easiest way to do that is to open the connection
     // and use the async copy to do it in a background thread.
     let sts = Cc["@mozilla.org/network/socket-transport-service;1"]
                 .getService(Ci.nsISocketTransportService);
-    let trans = sts.createTransport([], 0, "localhost", foundPort, null);
+    let trans = sts.createTransport([], "localhost", foundPort, null);
     let tunnelInput = trans.openInputStream(0, 1024, 1024);
     let tunnelOutput = trans.openOutputStream(0, 1024, 1024);
     this.sub_transport = trans;
     NetUtil.asyncCopy(tunnelInput, this.client_out);
     NetUtil.asyncCopy(this.client_in, tunnelOutput);
   },
 
   close() {