summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/metadatajob.cpp
diff options
context:
space:
mode:
authorKonstantin Podsvirov <konstantin@podsvirov.pro>2016-06-21 13:56:22 +0300
committerKonstantin Podsvirov <konstantin@podsvirov.pro>2016-07-07 05:19:34 +0000
commit80e8809b0b6a68100409ce664670ae493693b629 (patch)
tree20a68e18cd4c063dac2fa1a459f5e8fe7d9814e9 /src/libs/installer/metadatajob.cpp
parent810ea81009c594edb5f80110297e2562ca3c2b43 (diff)
Resolve relative URLs from Updates.xml
This change allows you to use relative URLs to update repositories. Absolute addresses are resolved relative to the current Updates.xml file is parsed. Documentation added to ifw-updates.html page. Change-Id: I5935355dfeee2236e9752cc2545c2d42da216f9e Reviewed-by: Konstantin Podsvirov <konstantin@podsvirov.pro> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src/libs/installer/metadatajob.cpp')
-rw-r--r--src/libs/installer/metadatajob.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/libs/installer/metadatajob.cpp b/src/libs/installer/metadatajob.cpp
index 5186df409..58b1ede8e 100644
--- a/src/libs/installer/metadatajob.cpp
+++ b/src/libs/installer/metadatajob.cpp
@@ -44,6 +44,14 @@
namespace QInstaller {
+static QUrl resolveUrl(const FileTaskResult &result, const QString &url)
+{
+ QUrl u(url);
+ if (u.isRelative())
+ return QUrl(result.taskItem().source()).resolved(u);
+ return u;
+}
+
MetadataJob::MetadataJob(QObject *parent)
: Job(parent)
, m_core(0)
@@ -379,7 +387,7 @@ MetadataJob::Status MetadataJob::parseUpdatesXml(const QList<FileTaskResult> &re
const QString action = el.attribute(QLatin1String("action"));
if (action == QLatin1String("add")) {
// add a new repository to the defaults list
- Repository repository(el.attribute(QLatin1String("url")), true);
+ Repository repository(resolveUrl(result, el.attribute(QLatin1String("url"))), true);
repository.setUsername(el.attribute(QLatin1String("username")));
repository.setPassword(el.attribute(QLatin1String("password")));
repository.setDisplayName(el.attribute(QLatin1String("displayname")));
@@ -389,14 +397,14 @@ MetadataJob::Status MetadataJob::parseUpdatesXml(const QList<FileTaskResult> &re
}
} else if (action == QLatin1String("remove")) {
// remove possible default repositories using the given server url
- Repository repository(el.attribute(QLatin1String("url")), true);
+ Repository repository(resolveUrl(result, el.attribute(QLatin1String("url"))), true);
repositoryUpdates.insertMulti(action, qMakePair(repository, Repository()));
qDebug() << "Repository to remove:" << repository.displayname();
} else if (action == QLatin1String("replace")) {
// replace possible default repositories using the given server url
- Repository oldRepository(el.attribute(QLatin1String("oldUrl")), true);
- Repository newRepository(el.attribute(QLatin1String("newUrl")), true);
+ Repository oldRepository(resolveUrl(result, el.attribute(QLatin1String("oldUrl"))), true);
+ Repository newRepository(resolveUrl(result, el.attribute(QLatin1String("newUrl"))), true);
newRepository.setUsername(el.attribute(QLatin1String("username")));
newRepository.setPassword(el.attribute(QLatin1String("password")));
newRepository.setDisplayName(el.attribute(QLatin1String("displayname")));