diff options
Diffstat (limited to 'src/libs/installer/repository.cpp')
-rw-r--r-- | src/libs/installer/repository.cpp | 64 |
1 files changed, 55 insertions, 9 deletions
diff --git a/src/libs/installer/repository.cpp b/src/libs/installer/repository.cpp index 50f3eceb6..f7035e732 100644 --- a/src/libs/installer/repository.cpp +++ b/src/libs/installer/repository.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -35,7 +35,7 @@ #include <QDir> /*! - \fn inline uint QInstaller::qHash(const Repository &repository) + \fn inline hashValue QInstaller::qHash(const Repository &repository) Returns a hash of the \a repository. */ @@ -49,8 +49,8 @@ Repository::Repository() : m_default(false) , m_enabled(false) , m_compressed(false) + , m_postLoadComponentScript(false) { - registerMetaType(); } /*! @@ -63,10 +63,11 @@ Repository::Repository(const Repository &other) , m_username(other.m_username) , m_password(other.m_password) , m_displayname(other.m_displayname) - , m_compressed(other.m_compressed) , m_categoryname(other.m_categoryname) + , m_compressed(other.m_compressed) + , m_xmlChecksum(other.m_xmlChecksum) + , m_postLoadComponentScript(other.m_postLoadComponentScript) { - registerMetaType(); } /*! @@ -78,8 +79,8 @@ Repository::Repository(const QUrl &url, bool isDefault, bool compressed) , m_default(isDefault) , m_enabled(true) , m_compressed(compressed) + , m_postLoadComponentScript(false) { - registerMetaType(); } /*! @@ -224,6 +225,28 @@ void Repository::setCategoryName(const QString &categoryname) } /*! + Returns the expected checksum of the repository, which is the checksum + calculated from the \c Updates.xml document at the root of the repository. + + This value is used as a hint when looking for already fetched repositories + from the local cache. If the installer has cached a repository with a matching + checksum, it can skip downloading the \c Updates.xml file for that repository again. +*/ +QByteArray Repository::xmlChecksum() const +{ + return m_xmlChecksum; +} + +/*! + Sets the expected checksum of the repository to \c checksum. The checksum + is calculated from the \c Updates.xml document at the root of the repository. +*/ +void Repository::setXmlChecksum(const QByteArray &checksum) +{ + m_xmlChecksum = checksum; +} + +/*! Returns true if repository is compressed */ bool Repository::isCompressed() const @@ -232,13 +255,31 @@ bool Repository::isCompressed() const } /*! + \internal +*/ +bool Repository::postLoadComponentScript() const +{ + return m_postLoadComponentScript; +} + +/*! + \internal +*/ +void Repository::setPostLoadComponentScript(const bool postLoad) +{ + m_postLoadComponentScript = postLoad; +} + +/*! Compares the values of this repository to \a other and returns true if they are equal (same server, default state, enabled state as well as username and password). \sa operator!=() */ bool Repository::operator==(const Repository &other) const { return m_url == other.m_url && m_default == other.m_default && m_enabled == other.m_enabled - && m_username == other.m_username && m_password == other.m_password && m_displayname == other.m_displayname; + && m_username == other.m_username && m_password == other.m_password + && m_displayname == other.m_displayname && m_xmlChecksum == other.m_xmlChecksum + && m_postLoadComponentScript == other.m_postLoadComponentScript; } /*! @@ -266,6 +307,8 @@ const Repository &Repository::operator=(const Repository &other) m_displayname = other.m_displayname; m_compressed = other.m_compressed; m_categoryname = other.m_categoryname; + m_xmlChecksum = other.m_xmlChecksum; + m_postLoadComponentScript = other.m_postLoadComponentScript; return *this; } @@ -273,7 +316,9 @@ const Repository &Repository::operator=(const Repository &other) void Repository::registerMetaType() { qRegisterMetaType<Repository>("Repository"); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) qRegisterMetaTypeStreamOperators<Repository>("Repository"); +#endif } /*! @@ -283,7 +328,7 @@ QDataStream &operator>>(QDataStream &istream, Repository &repository) { QByteArray url, username, password, displayname, compressed; istream >> url >> repository.m_default >> repository.m_enabled >> username >> password - >> displayname >> repository.m_categoryname; + >> displayname >> repository.m_categoryname >> repository.m_xmlChecksum >> repository.m_postLoadComponentScript; repository.setUrl(QUrl::fromEncoded(QByteArray::fromBase64(url))); repository.setUsername(QString::fromUtf8(QByteArray::fromBase64(username))); repository.setPassword(QString::fromUtf8(QByteArray::fromBase64(password))); @@ -298,7 +343,8 @@ QDataStream &operator<<(QDataStream &ostream, const Repository &repository) { return ostream << repository.m_url.toEncoded().toBase64() << repository.m_default << repository.m_enabled << repository.m_username.toUtf8().toBase64() << repository.m_password.toUtf8().toBase64() - << repository.m_displayname.toUtf8().toBase64() << repository.m_categoryname.toUtf8().toBase64(); + << repository.m_displayname.toUtf8().toBase64() << repository.m_categoryname.toUtf8().toBase64() + << repository.m_xmlChecksum.toBase64() << repository.m_postLoadComponentScript; } } |