瀏覽代碼

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 8 年之前
父節點
當前提交
81baebf113
共有 1 個文件被更改,包括 24 次插入23 次删除
  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);
     }
 
+    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;
 
     HttpCredentialsText *cred = new HttpCredentialsText(user, password);
@@ -457,31 +481,8 @@ int main(int argc, char **argv)
     int restartCount = 0;
 restart_sync:
 
-
     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;
     if (!options.unsyncedfolders.isEmpty()) {
         QFile f(options.unsyncedfolders);