QNAM: Improve internal proxyAuthenticationRequired()
authorMarkus Goetz <Markus.Goetz@nokia.com>
Tue, 5 Apr 2011 14:42:33 +0000 (16:42 +0200)
committerMarkus Goetz <Markus.Goetz@nokia.com>
Tue, 3 May 2011 14:34:50 +0000 (16:34 +0200)
Make it independent from the backend architecture
to improve refactorability.

Reviewed-by: Peter Hartmann
src/network/access/qnetworkaccessbackend.cpp
src/network/access/qnetworkaccessmanager.cpp
src/network/access/qnetworkaccessmanager_p.h

index 2847cd5..8a53d2d 100644 (file)
@@ -315,7 +315,7 @@ void QNetworkAccessBackend::error(QNetworkReply::NetworkError code, const QStrin
 void QNetworkAccessBackend::proxyAuthenticationRequired(const QNetworkProxy &proxy,
                                                         QAuthenticator *authenticator)
 {
-    manager->proxyAuthenticationRequired(this, proxy, authenticator);
+    manager->proxyAuthenticationRequired(proxy, synchronous, authenticator, &reply->lastProxyAuthentication);
 }
 #endif
 
index a809583..34ac170 100644 (file)
@@ -1088,9 +1088,10 @@ void QNetworkAccessManagerPrivate::authenticationRequired(QAuthenticator *authen
 }
 
 #ifndef QT_NO_NETWORKPROXY
-void QNetworkAccessManagerPrivate::proxyAuthenticationRequired(QNetworkAccessBackend *backend,
-                                                               const QNetworkProxy &proxy,
-                                                               QAuthenticator *authenticator)
+void QNetworkAccessManagerPrivate::proxyAuthenticationRequired(const QNetworkProxy &proxy,
+                                                               bool synchronous,
+                                                               QAuthenticator *authenticator,
+                                                               QNetworkProxy *lastProxyAuthentication)
 {
     Q_Q(QNetworkAccessManager);
     // ### FIXME Tracking of successful authentications
@@ -1100,7 +1101,7 @@ void QNetworkAccessManagerPrivate::proxyAuthenticationRequired(QNetworkAccessBac
     //      proxyAuthenticationRequired gets emitted again
     // possible solution: some tracking inside the authenticator
     //      or a new function proxyAuthenticationSucceeded(true|false)
-    if (proxy != backend->reply->lastProxyAuthentication) {
+    if (proxy != *lastProxyAuthentication) {
         QNetworkAuthenticationCredential cred = authenticationManager->fetchCachedProxyCredentials(proxy);
         if (!cred.isNull()) {
             authenticator->setUser(cred.user);
@@ -1111,10 +1112,10 @@ void QNetworkAccessManagerPrivate::proxyAuthenticationRequired(QNetworkAccessBac
 
     // if we emit a signal here in synchronous mode, the user might spin
     // an event loop, which might recurse and lead to problems
-    if (backend->isSynchronous())
+    if (synchronous)
         return;
 
-    backend->reply->lastProxyAuthentication = proxy;
+    *lastProxyAuthentication = proxy;
     emit q->proxyAuthenticationRequired(proxy, authenticator);
     authenticationManager->cacheProxyCredentials(proxy, authenticator);
 }
index a8237b3..f5e13e3 100644 (file)
@@ -104,8 +104,10 @@ public:
                                                              const QAuthenticator *auth = 0);
 
 #ifndef QT_NO_NETWORKPROXY
-    void proxyAuthenticationRequired(QNetworkAccessBackend *backend, const QNetworkProxy &proxy,
-                                     QAuthenticator *authenticator);
+    void proxyAuthenticationRequired(const QNetworkProxy &proxy,
+                                bool synchronous,
+                                QAuthenticator *authenticator,
+                                QNetworkProxy *lastProxyAuthentication);
     void cacheProxyCredentials(const QNetworkProxy &proxy, const QAuthenticator *auth);
     QNetworkAuthenticationCredential *fetchCachedProxyCredentials(const QNetworkProxy &proxy,
                                                              const QAuthenticator *auth = 0);