summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/metadatajob.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@theqtcompany.com>2014-11-18 15:49:27 +0100
committerKai Koehne <kai.koehne@theqtcompany.com>2014-11-18 16:21:36 +0100
commit1f411319e4bb849487a85e8ea051b94417372ff4 (patch)
tree2441e1e371beffba129d7a8e8303eeabf3ff911a /src/libs/installer/metadatajob.cpp
parent6df883de4ae674a9b351f04e74c80bfa89d5faa6 (diff)
Ask for proxy credentials in modal dialog
If a proxy requires authentication, DownloadFileTask will throw an exception of type ProxyAuthenticationRequiredException. This exception is handled in MetadataJob to first ask the user for credentials, storing them in PackageManagerProxyFactory, and then retriggering the download. Change-Id: I0d69504d3f90d503d83c7b2229bc670756fa1463 GPush-Base: 9aeb0197e58d630ef7e657bb05671d6ec7b3f5ec Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
Diffstat (limited to 'src/libs/installer/metadatajob.cpp')
-rw-r--r--src/libs/installer/metadatajob.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libs/installer/metadatajob.cpp b/src/libs/installer/metadatajob.cpp
index 5e5a27416..6cb5652c2 100644
--- a/src/libs/installer/metadatajob.cpp
+++ b/src/libs/installer/metadatajob.cpp
@@ -37,6 +37,7 @@
#include "packagemanagercore.h"
#include "packagemanagerproxyfactory.h"
#include "productkeycheck.h"
+#include "proxycredentialsdialog.h"
#include "settings.h"
#include <QTemporaryDir>
@@ -116,6 +117,25 @@ void MetadataJob::xmlTaskFinished()
try {
m_xmlTask.waitForFinished();
status = parseUpdatesXml(m_xmlTask.future().results());
+ } catch (const ProxyAuthenticationRequiredException &e) {
+ //! will be shown as title in the UI dialog
+
+ const QNetworkProxy proxy = e.proxy();
+ ProxyCredentialsDialog proxyCredentials(proxy);
+ qDebug() << e.message();
+
+ if (proxyCredentials.exec() == QDialog::Accepted) {
+ qDebug() << "Retrying with new credentials ...";
+ PackageManagerProxyFactory *factory = m_core->proxyFactory();
+
+ factory->setProxyCredentials(proxy, proxyCredentials.userName(),
+ proxyCredentials.password());
+ m_core->setProxyFactory(factory);
+ status = XmlDownloadRetry;
+ } else {
+ reset();
+ emitFinishedWithError(QInstaller::DownloadError, tr("Missing proxy credentials."));
+ }
} catch (const FileTaskException &e) {
reset();
emitFinishedWithError(QInstaller::DownloadError, e.message());