diff options
author | Konstantin Podsvirov <konstantin@podsvirov.pro> | 2016-06-21 13:56:22 +0300 |
---|---|---|
committer | Iikka Eklund <iikka.eklund@qt.io> | 2016-11-08 10:23:16 +0000 |
commit | 82dfa6992e5c311d21395a23d48208224d584f4c (patch) | |
tree | 8ff27fe43ac1e154c4bc71346dfe372de4b1c810 /src | |
parent | c1b54a0a7b6c34a348a8f30826c8fc2d4b62d615 (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: I025bdc3044d1ca9d6abcce3ccdc043d5f03667fc
Reviewed-by: Konstantin Podsvirov <konstantin@podsvirov.pro>
Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/installer/metadatajob.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/libs/installer/metadatajob.cpp b/src/libs/installer/metadatajob.cpp index aad387232..584d23b0d 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) : KDJob(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,15 +397,15 @@ 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); repository.setDisplayName(el.attribute(QLatin1String("displayname"))); 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"))); |