Bläddra i källkod

Working PAC support

This goes along with e0f02c in csync/dav.
Daniel Molkentin 13 år sedan
förälder
incheckning
c93721258e
3 ändrade filer med 15 tillägg och 6 borttagningar
  1. 11 1
      src/mirall/owncloudfolder.cpp
  2. 2 3
      src/mirall/owncloudinfo.cpp
  3. 2 2
      src/mirall/owncloudinfo.h

+ 11 - 1
src/mirall/owncloudfolder.cpp

@@ -28,6 +28,8 @@
 #include <QTextStream>
 #include <QTimer>
 #include <QNetworkProxy>
+#include <QNetworkAccessManager>
+#include <QNetworkProxyFactory>
 
 namespace Mirall {
 
@@ -171,10 +173,18 @@ void ownCloudFolder::startSync(const QStringList &pathList)
         // in case of system proxy we set the proxy in csync explicitely to the
         // value of Qt as Qt should be able to handle the pac system configuration
         // while libproxy (through libneon) might not on the target platform
-        QNetworkProxy proxy = ownCloudInfo::instance()->qnamProxy();
+        QNetworkAccessManager *nam = ownCloudInfo::instance()->networkManager();
+        QNetworkProxy proxy = nam->proxy();
         if( (!proxyHost.isEmpty()) && (proxyPort != 0) ) {
             intProxy  = QNetworkProxy::HttpProxy; // switch to http proxy. Tells csync/owncloud to
             // explicitely set the proxy host and port.
+        } else {
+            QList<QNetworkProxy> proxies = QNetworkProxyFactory::systemProxyForQuery(QUrl(cfgFile.ownCloudUrl()));
+            if (proxies.isEmpty())
+                qWarning() << "No proxy for PAC found";
+            else {
+                proxy = proxies.first();
+            }
         }
 
         proxyHost = proxy.hostName();

+ 2 - 3
src/mirall/owncloudinfo.cpp

@@ -18,7 +18,6 @@
 #include "mirall/theme.h"
 #include <QtCore>
 #include <QtGui>
-#include <QAuthenticator>
 
 #if QT46_IMPL
 #include <QHttp>
@@ -450,9 +449,9 @@ QNetworkReply* ownCloudInfo::davRequest(const QString& reqVerb,  QNetworkRequest
 }
 #endif
 
-QNetworkProxy ownCloudInfo::qnamProxy()
+QNetworkAccessManager* ownCloudInfo::networkManager()
 {
-    return _manager->proxy();
+    return _manager;
 }
 
 

+ 2 - 2
src/mirall/owncloudinfo.h

@@ -84,9 +84,9 @@ public:
     QString configHandle(QNetworkReply *reply = 0);
 
     /**
-     * return the proxy the QNetworkAccessManager is using.
+     * return the central QNetworkAccessManager instance.
      */
-    QNetworkProxy qnamProxy();
+    QNetworkAccessManager* networkManager();
 
 signals:
     // result signal with url- and version string.