diff options
Diffstat (limited to 'src/libs/kdtools/updatesinfo.cpp')
-rw-r--r-- | src/libs/kdtools/updatesinfo.cpp | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/libs/kdtools/updatesinfo.cpp b/src/libs/kdtools/updatesinfo.cpp index fafeb4f18..e82c1c1fb 100644 --- a/src/libs/kdtools/updatesinfo.cpp +++ b/src/libs/kdtools/updatesinfo.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB) +** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -39,8 +40,9 @@ using namespace KDUpdater; -UpdatesInfoData::UpdatesInfoData() +UpdatesInfoData::UpdatesInfoData(const bool postLoadComponentScript) : error(UpdatesInfo::NotYetReadError) + , m_postLoadComponentScript(postLoadComponentScript) { } @@ -71,8 +73,10 @@ void UpdatesInfoData::parseFile(const QString &updateXmlFile) applicationName = reader.readElementText(); } else if (reader.name() == QLatin1String("ApplicationVersion")) { applicationVersion = reader.readElementText(); + } else if (reader.name() == QLatin1String("Checksum")) { + checkSha1CheckSum = (reader.readElementText()); } else if (reader.name() == QLatin1String("PackageUpdate")) { - if (!parsePackageUpdateElement(reader)) + if (!parsePackageUpdateElement(reader, checkSha1CheckSum)) return; //error handled in subroutine } else { reader.skipCurrentElement(); @@ -98,7 +102,7 @@ void UpdatesInfoData::parseFile(const QString &updateXmlFile) error = UpdatesInfo::NoError; } -bool UpdatesInfoData::parsePackageUpdateElement(QXmlStreamReader &reader) +bool UpdatesInfoData::parsePackageUpdateElement(QXmlStreamReader &reader, const QString &checkSha1CheckSum) { UpdateInfo info; QHash<QString, QVariant> scriptHash; @@ -132,7 +136,14 @@ bool UpdatesInfoData::parsePackageUpdateElement(QXmlStreamReader &reader) parseOperations(reader, info.data); } else if (elementName == QLatin1String("Script")) { const QXmlStreamAttributes attr = reader.attributes(); - const bool postLoad = attr.value(QLatin1String("postLoad")).toString().toLower() == QInstaller::scTrue ? true : false; + bool postLoad = false; + // postLoad can be set either to individual components or to whole repositories. + // If individual components has the postLoad attribute, it overwrites the repository value. + if (attr.hasAttribute(QLatin1String("postLoad"))) + postLoad = attr.value(QLatin1String("postLoad")).toString().toLower() == QInstaller::scTrue ? true : false; + else if (m_postLoadComponentScript) + postLoad = true; + if (postLoad) scriptHash.insert(QLatin1String("postLoadScript"), reader.readElementText()); else @@ -156,7 +167,7 @@ bool UpdatesInfoData::parsePackageUpdateElement(QXmlStreamReader &reader) setInvalidContentError(tr("PackageUpdate element without ReleaseDate")); return false; } - + info.data[QLatin1String("CheckSha1CheckSum")] = checkSha1CheckSum; updateInfoList.append(info); return true; } @@ -235,8 +246,8 @@ void UpdatesInfoData::parseLicenses(QXmlStreamReader &reader, QHash<QString, QVa // // UpdatesInfo // -UpdatesInfo::UpdatesInfo() - : d(new UpdatesInfoData) +UpdatesInfo::UpdatesInfo(const bool postLoadComponentScript) + : d(new UpdatesInfoData(postLoadComponentScript)) { } @@ -264,6 +275,10 @@ void UpdatesInfo::setFileName(const QString &updateXmlFile) d->updateInfoList.clear(); d->updateXmlFile = updateXmlFile; +} + +void UpdatesInfo::parseFile() +{ d->parseFile(d->updateXmlFile); } @@ -282,6 +297,11 @@ QString UpdatesInfo::applicationVersion() const return d->applicationVersion; } +QString UpdatesInfo::checkSha1CheckSum() const +{ + return d->checkSha1CheckSum; +} + int UpdatesInfo::updateInfoCount() const { return d->updateInfoList.count(); |