summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/downloadfiletask.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/installer/downloadfiletask.cpp')
-rw-r--r--src/libs/installer/downloadfiletask.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libs/installer/downloadfiletask.cpp b/src/libs/installer/downloadfiletask.cpp
index bbb3cc4e3..0bd38615e 100644
--- a/src/libs/installer/downloadfiletask.cpp
+++ b/src/libs/installer/downloadfiletask.cpp
@@ -36,6 +36,7 @@
#include "downloadfiletask_p.h"
#include "observer.h"
+#include <QCoreApplication>
#include <QEventLoop>
#include <QFile>
#include <QFileInfo>
@@ -46,6 +47,13 @@
namespace QInstaller {
+ProxyAuthenticationRequiredException::ProxyAuthenticationRequiredException(const QNetworkProxy &proxy)
+ : FileTaskException(QCoreApplication::translate("ProxyAuthenticationRequiredException",
+ "Proxy requires authentication.")),
+ m_proxy(proxy)
+{
+}
+
Downloader::Downloader()
: m_finished(0)
{
@@ -80,6 +88,8 @@ void Downloader::download(QFutureInterface<FileTaskResult> &fi, const QList<File
m_nam.setProxyFactory(networkProxyFactory);
connect(&m_nam, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), this,
SLOT(onAuthenticationRequired(QNetworkReply*, QAuthenticator*)));
+ connect(&m_nam, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), this,
+ SLOT(onProxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
QTimer::singleShot(0, this, SLOT(doDownload()));
}
@@ -224,6 +234,12 @@ void Downloader::onFinished(QNetworkReply *reply)
void Downloader::onError(QNetworkReply::NetworkError error)
{
QNetworkReply *const reply = qobject_cast<QNetworkReply *>(sender());
+
+ if (error == QNetworkReply::ProxyAuthenticationRequiredError) {
+ // already handled by onProxyAuthenticationRequired
+ return;
+ }
+
if (reply) {
const Data &data = m_downloads[reply];
//: %2 is a sentence describing the error
@@ -275,6 +291,13 @@ void Downloader::onAuthenticationRequired(QNetworkReply *reply, QAuthenticator *
}
}
+void Downloader::onProxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *)
+{
+ // Report to GUI thread.
+ // (MetadataJob will ask for username/password, and restart the download ...)
+ m_futureInterface->reportException(ProxyAuthenticationRequiredException(proxy));
+}
+
// -- private