Explorar o código

owncloudcmd: Set proxy earlier #6281

In particular before the capability call.

Also warn if no proxy is set because the command line doesn't follow the
strict format requirements.

(cherry picked from commit d0e7f61db62b52af9c94e9a97e1d201a09c2bd1a)
Christian Kamm %!s(int64=8) %!d(string=hai) anos
pai
achega
81baebf113
Modificáronse 1 ficheiros con 24 adicións e 23 borrados
  1. 24 23
      src/cmd/cmd.cpp

+ 24 - 23
src/cmd/cmd.cpp

@@ -420,6 +420,30 @@ int main(int argc, char **argv)
         folder.chop(1);
         folder.chop(1);
     }
     }
 
 
+    if (!options.proxy.isNull()) {
+        QString host;
+        int port = 0;
+        bool ok;
+
+        QStringList pList = options.proxy.split(':');
+        if (pList.count() == 3) {
+            // http: //192.168.178.23 : 8080
+            //  0            1            2
+            host = pList.at(1);
+            if (host.startsWith("//"))
+                host.remove(0, 2);
+
+            port = pList.at(2).toInt(&ok);
+
+            QNetworkProxyFactory::setUseSystemConfiguration(false);
+            QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, host, port));
+        } else {
+            qFatal("Could not read httpproxy. The proxy should have the format \"http://hostname:port\".");
+        }
+    } else {
+        clientProxy.setupQtProxyFromConfig();
+    }
+
     SimpleSslErrorHandler *sslErrorHandler = new SimpleSslErrorHandler;
     SimpleSslErrorHandler *sslErrorHandler = new SimpleSslErrorHandler;
 
 
     HttpCredentialsText *cred = new HttpCredentialsText(user, password);
     HttpCredentialsText *cred = new HttpCredentialsText(user, password);
@@ -457,31 +481,8 @@ int main(int argc, char **argv)
     int restartCount = 0;
     int restartCount = 0;
 restart_sync:
 restart_sync:
 
 
-
     opts = &options;
     opts = &options;
 
 
-    if (!options.proxy.isNull()) {
-        QString host;
-        int port = 0;
-        bool ok;
-
-        QStringList pList = options.proxy.split(':');
-        if (pList.count() == 3) {
-            // http: //192.168.178.23 : 8080
-            //  0            1            2
-            host = pList.at(1);
-            if (host.startsWith("//"))
-                host.remove(0, 2);
-
-            port = pList.at(2).toInt(&ok);
-
-            QNetworkProxyFactory::setUseSystemConfiguration(false);
-            QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, host, port));
-        }
-    } else {
-        clientProxy.setupQtProxyFromConfig();
-    }
-
     QStringList selectiveSyncList;
     QStringList selectiveSyncList;
     if (!options.unsyncedfolders.isEmpty()) {
     if (!options.unsyncedfolders.isEmpty()) {
         QFile f(options.unsyncedfolders);
         QFile f(options.unsyncedfolders);