diff options
-rw-r--r-- | src/libs/installer/component.cpp | 1 | ||||
-rw-r--r-- | src/libs/installer/installer.pro | 6 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore_p.cpp | 24 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore_p.h | 4 | ||||
-rw-r--r-- | src/libs/installer/packagesource.cpp | 91 | ||||
-rw-r--r-- | src/libs/installer/packagesource.h (renamed from src/libs/kdtools/kdupdaterupdatesourcesinfo.h) | 55 | ||||
-rw-r--r-- | src/libs/kdtools/kdtools.pri | 2 | ||||
-rw-r--r-- | src/libs/kdtools/kdupdaterupdatefinder.cpp | 57 | ||||
-rw-r--r-- | src/libs/kdtools/kdupdaterupdatefinder.h | 4 | ||||
-rw-r--r-- | src/libs/kdtools/kdupdaterupdatesourcesinfo.cpp | 191 |
10 files changed, 151 insertions, 284 deletions
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index e2a9cf2e1..5fe679ad8 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -43,7 +43,6 @@ #include "remoteclient.h" #include "settings.h" -#include <kdupdaterupdatesourcesinfo.h> #include <kdupdaterupdateoperationfactory.h> #include <productkeycheck.h> diff --git a/src/libs/installer/installer.pro b/src/libs/installer/installer.pro index 87af31f3c..b9d9a20cb 100644 --- a/src/libs/installer/installer.pro +++ b/src/libs/installer/installer.pro @@ -124,7 +124,8 @@ HEADERS += packagemanagercore.h \ serverauthenticationdialog.h \ keepaliveobject.h \ systeminfo.h \ - localsocket.h + localsocket.h \ + packagesource.h SOURCES += packagemanagercore.cpp \ packagemanagercore_p.cpp \ @@ -198,7 +199,8 @@ SOURCES += packagemanagercore.cpp \ proxycredentialsdialog.cpp \ serverauthenticationdialog.cpp \ keepaliveobject.cpp \ - systeminfo.cpp + systeminfo.cpp \ + packagesource.cpp FORMS += proxycredentialsdialog.ui \ serverauthenticationdialog.ui diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index 34378fb7a..0b51be1c8 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -57,7 +57,6 @@ #include "kdselfrestarter.h" #include "kdupdaterfiledownloaderfactory.h" -#include "kdupdaterupdatesourcesinfo.h" #include "kdupdaterupdateoperationfactory.h" #include <productkeycheck.h> @@ -571,11 +570,8 @@ void PackageManagerCorePrivate::initialize(const QHash<QString, QString> ¶ms if (isInstaller() || m_packagesInfo->applicationVersion().isEmpty()) m_packagesInfo->setApplicationVersion(QLatin1String(QUOTE(IFW_REPOSITORY_FORMAT_VERSION))); - if (isInstaller()) { - // TODO: this seems to be wrong, we should ask for ProductName defaulting to applicationName... - m_updateSourcesInfo.addUpdateSource(m_data.settings().applicationName(), m_data.settings() - .applicationName(), QString(), QUrl(QLatin1String("resource://metadata/")), 0); - } + if (isInstaller()) + m_packageSources.insert(PackageSource(QUrl(QLatin1String("resource://metadata/")), 0)); m_metadataJob.disconnect(); m_metadataJob.setAutoDelete(false); @@ -2096,7 +2092,7 @@ PackagesList PackageManagerCorePrivate::remotePackages() m_updateFinder = new KDUpdater::UpdateFinder; m_updateFinder->setAutoDelete(false); m_updateFinder->setPackagesInfo(m_packagesInfo); - m_updateFinder->setUpdateSourcesInfo(m_updateSourcesInfo); + m_updateFinder->setPackageSources(m_packageSources); m_updateFinder->run(); if (m_updateFinder->updates().isEmpty()) { @@ -2189,16 +2185,13 @@ bool PackageManagerCorePrivate::addUpdateResourcesFromRepositories(bool parseChe return m_updateSourcesAdded; } - m_updateSourcesInfo.clear(); - if (isInstaller()) { - m_updateSourcesInfo.addUpdateSource(m_data.settings().applicationName(), m_data.settings() - .applicationName(), QString(), QUrl(QLatin1String("resource://metadata/")), 0); - } + m_packageSources.clear(); + if (isInstaller()) + m_packageSources.insert(PackageSource(QUrl(QLatin1String("resource://metadata/")), 0)); m_updates = false; m_updateSourcesAdded = false; - const QString &appName = m_data.settings().applicationName(); foreach (const Metadata &data, metadata) { if (statusCanceledOrFailed()) return false; @@ -2232,12 +2225,11 @@ bool PackageManagerCorePrivate::addUpdateResourcesFromRepositories(bool parseChe if (!checksum.isNull()) m_core->setTestChecksum(checksum.toElement().text().toLower() == scTrue); } - m_updateSourcesInfo.addUpdateSource(appName, appName, QString(), QUrl::fromLocalFile(data - .directory), 1); + m_packageSources.insert(PackageSource(QUrl::fromLocalFile(data.directory), 1)); ProductKeyCheck::instance()->addPackagesFromXml(data.directory + QLatin1String("/Updates.xml")); } - if (m_updateSourcesInfo.updateSourceInfoCount() == 0) { + if (m_packageSources.count() == 0) { setStatus(PackageManagerCore::Failure, tr("Could not find any update source information.")); return false; } diff --git a/src/libs/installer/packagemanagercore_p.h b/src/libs/installer/packagemanagercore_p.h index 6dbebd94c..0a5e5ca17 100644 --- a/src/libs/installer/packagemanagercore_p.h +++ b/src/libs/installer/packagemanagercore_p.h @@ -39,11 +39,11 @@ #include "packagemanagercore.h" #include "packagemanagercoredata.h" #include "packagemanagerproxyfactory.h" +#include "packagesource.h" #include "qinstallerglobal.h" #include "kdsysinfo.h" #include "kdupdaterupdatefinder.h" -#include "kdupdaterupdatesourcesinfo.h" #include <QObject> @@ -176,7 +176,7 @@ signals: public: UpdateFinder *m_updateFinder; - UpdateSourcesInfo m_updateSourcesInfo; + QSet<PackageSource> m_packageSources; std::shared_ptr<PackagesInfo> m_packagesInfo; QStringList m_filesForDelayedDeletion; diff --git a/src/libs/installer/packagesource.cpp b/src/libs/installer/packagesource.cpp new file mode 100644 index 000000000..e58ba870c --- /dev/null +++ b/src/libs/installer/packagesource.cpp @@ -0,0 +1,91 @@ +/************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Installer Framework. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** +** $QT_END_LICENSE$ +** +**************************************************************************/ + +#include "packagesource.h" + +namespace QInstaller { + +/*! + \inmodule QtInstallerFramework + \class QInstaller::PackageSource + \brief The PackageSource class specifies a single package source. + + An package source represents a link to an repository that contains packages applicable by + the installer or package maintenance application. This structure describes a single package + source in terms of url and priority. While different repositories can host the same packages, + packages coming from a higher priority source take precedence over lower priority packages + during applicable package computation. +*/ + +/*! + \fn PackageSource::PackageSource() + + Constructs an empty package source info object. The object's priority is set to -1. The url is + initialized using a \l{default-constructed value}. +*/ + +/*! + \fn PackageSource::PackageSource(const QUrl &u, int p) + + Constructs an package source info object. The object's url is set to \a u, while the priority + is set to \a p. +*/ + +/*! + \variable PackageSource::url + \brief The URL of the package source. +*/ + +/*! + \variable PackageSource::priority + \brief The priority of the package source. +*/ + +/*! + Returns the hash value for the \a key, using \a seed to seed the calculation. +*/ +uint QInstaller::qHash(const PackageSource &key, uint seed) +{ + return qHash(key.url, seed) ^ key.priority; +} + +/*! + Returns \c true if \a lhs and \a rhs are equal; otherwise returns \c false. +*/ +bool QInstaller::operator==(const PackageSource &lhs, const PackageSource &rhs) +{ + return lhs.url == rhs.url && lhs.priority == rhs.priority; +} + +} // namespace QInstaller diff --git a/src/libs/kdtools/kdupdaterupdatesourcesinfo.h b/src/libs/installer/packagesource.h index cc483a370..6bc565c15 100644 --- a/src/libs/kdtools/kdupdaterupdatesourcesinfo.h +++ b/src/libs/installer/packagesource.h @@ -1,6 +1,5 @@ -/**************************************************************************** +/************************************************************************** ** -** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB) ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** @@ -31,52 +30,34 @@ ** ** $QT_END_LICENSE$ ** -****************************************************************************/ +**************************************************************************/ -#ifndef KD_UPDATER_UPDATE_SOURCES_INFO_H -#define KD_UPDATER_UPDATE_SOURCES_INFO_H +#ifndef PACKAGESOURCE_H +#define PACKAGESOURCE_H -#include "kdtoolsglobal.h" +#include "installer_global.h" #include <QUrl> -namespace KDUpdater { +namespace QInstaller { -struct KDTOOLS_EXPORT UpdateSourceInfo +struct INSTALLER_EXPORT PackageSource { - UpdateSourceInfo() : priority(-1) { } + PackageSource() + : priority(-1) + {} + PackageSource(const QUrl &u, int p) + : url(u) + , priority(p) + {} - QString name; - QString title; - QString description; QUrl url; int priority; }; -KDTOOLS_EXPORT bool operator==(const UpdateSourceInfo &lhs, const UpdateSourceInfo &rhs); +INSTALLER_EXPORT uint qHash(const PackageSource &key, uint seed); +INSTALLER_EXPORT bool operator==(const PackageSource &lhs, const PackageSource &rhs); -inline bool operator!=(const UpdateSourceInfo &lhs, const UpdateSourceInfo &rhs) -{ - return !operator==(lhs, rhs); -} - -class KDTOOLS_EXPORT UpdateSourcesInfo -{ -public: - int updateSourceInfoCount() const; - UpdateSourceInfo updateSourceInfo(int index) const; - - void addUpdateSourceInfo(const UpdateSourceInfo &info); - void addUpdateSource(const QString &name, const QString &title, - const QString &description, const QUrl &url, int priority); - - void clear(); - void removeUpdateSourceInfo(const UpdateSourceInfo &info); - -private: - QList<UpdateSourceInfo> m_updateSourceInfoList; -}; - -} // namespace KDUpdater +} // namespace QInstaller -#endif // KD_UPDATER_UPDATE_SOURCES_INFO_H +#endif // PACKAGESOURCE_H diff --git a/src/libs/kdtools/kdtools.pri b/src/libs/kdtools/kdtools.pri index 3898f1c5c..e684f32e6 100644 --- a/src/libs/kdtools/kdtools.pri +++ b/src/libs/kdtools/kdtools.pri @@ -28,7 +28,6 @@ HEADERS += $$PWD/kdupdater.h \ $$PWD/kdupdaterupdateoperation.h \ $$PWD/kdupdaterupdateoperationfactory.h \ $$PWD/kdupdaterupdateoperations.h \ - $$PWD/kdupdaterupdatesourcesinfo.h \ $$PWD/kdupdatertask.h \ $$PWD/kdupdaterupdatefinder.h \ $$PWD/kdupdaterupdatesinfo_p.h \ @@ -42,7 +41,6 @@ SOURCES += $$PWD/kdupdaterfiledownloader.cpp \ $$PWD/kdupdaterupdateoperation.cpp \ $$PWD/kdupdaterupdateoperationfactory.cpp \ $$PWD/kdupdaterupdateoperations.cpp \ - $$PWD/kdupdaterupdatesourcesinfo.cpp \ $$PWD/kdupdatertask.cpp \ $$PWD/kdupdaterupdatefinder.cpp \ $$PWD/kdupdaterupdatesinfo.cpp \ diff --git a/src/libs/kdtools/kdupdaterupdatefinder.cpp b/src/libs/kdtools/kdupdaterupdatefinder.cpp index 2fbba4ae5..d57e59108 100644 --- a/src/libs/kdtools/kdupdaterupdatefinder.cpp +++ b/src/libs/kdtools/kdupdaterupdatefinder.cpp @@ -34,7 +34,6 @@ ****************************************************************************/ #include "kdupdaterupdatefinder.h" -#include "kdupdaterupdatesourcesinfo.h" #include "kdupdaterpackagesinfo.h" #include "kdupdaterupdate.h" #include "kdupdaterfiledownloader.h" @@ -48,6 +47,7 @@ #include <QFileInfo> using namespace KDUpdater; +using namespace QInstaller; /*! \inmodule kdupdater @@ -86,10 +86,10 @@ public: struct Data { Data() : downloader(0) {} - Data(const UpdateSourceInfo &i, FileDownloader *d = 0) + Data(const PackageSource &i, FileDownloader *d = 0) : info(i), downloader(d) {} - UpdateSourceInfo info; + PackageSource info; FileDownloader *downloader; }; UpdateFinder *q; @@ -108,11 +108,11 @@ public: bool computeApplicableUpdates(); QList<UpdateInfo> applicableUpdates(UpdatesInfo *updatesInfo); - void createUpdateObjects(const UpdateSourceInfo &sourceInfo, const QList<UpdateInfo> &updateInfoList); - Resolution checkPriorityAndVersion(const UpdateSourceInfo &sourceInfo, const QVariantHash &data) const; + void createUpdateObjects(const PackageSource &source, const QList<UpdateInfo> &updateInfoList); + Resolution checkPriorityAndVersion(const PackageSource &source, const QVariantHash &data) const; void slotDownloadDone(); - UpdateSourcesInfo m_updateSourcesInfo; + QSet<PackageSource> packageSources; std::weak_ptr<PackagesInfo> m_packagesInfo; }; @@ -153,7 +153,7 @@ void UpdateFinder::Private::clear() This method computes the updates that can be applied on the application by studying the application's KDUpdater::PackagesInfo object and the UpdateXML files - from each of the update sources described in KDUpdater::UpdateSourcesInfo. + from each of the update sources described in QInstaller::PackageSource. This function can take a long time to complete. The following signals are emitted during the execution of this function @@ -161,7 +161,7 @@ void UpdateFinder::Private::clear() The function creates KDUpdater::Update objects on the stack. All KDUpdater::Update objects are made children of the application associated with this finder. - The update sources are fetched from the KDUpdater::UpdateSourcesInfo object associated with + The update sources are fetched from the QInstaller::PackageSource object associated with the application. Package information is extracted from the KDUpdater::PackagesInfo object associated with the application. @@ -189,9 +189,9 @@ void UpdateFinder::Private::computeUpdates() return; } - // Now do some quick sanity checks on the update sources info - if (m_updateSourcesInfo.updateSourceInfoCount() <= 0) { - q->reportError(tr("No update sources information set for this application.")); + // Now do some quick sanity checks on the package sources. + if (packageSources.count() <= 0) { + q->reportError(tr("No package sources set for this application.")); return; } @@ -244,14 +244,9 @@ void UpdateFinder::Private::cancelComputeUpdates() */ bool UpdateFinder::Private::downloadUpdateXMLFiles() { - if (m_updateSourcesInfo.updateSourceInfoCount() <= 0) - return false; - // create UpdatesInfo for each update source - for (int i = 0; i < m_updateSourcesInfo.updateSourceInfoCount(); i++) { - const UpdateSourceInfo info = m_updateSourcesInfo.updateSourceInfo(i); + foreach (const PackageSource &info, packageSources) { const QUrl url = QString::fromLatin1("%1/Updates.xml").arg(info.url.toString()); - if (url.scheme() != QLatin1String("resource") && url.scheme() != QLatin1String("file")) { // create FileDownloader (except for local files and resources) FileDownloader *downloader = FileDownloaderFactory::instance().create(url.scheme(), q); @@ -299,8 +294,8 @@ bool UpdateFinder::Private::downloadUpdateXMLFiles() const Data data = m_updatesInfoList.value(updatesInfo); if (data.downloader) { if (!data.downloader->isDownloaded()) { - q->reportError(tr("Could not download update source %1 from ('%2')").arg(data.info - .name, data.info.url.toString())); + q->reportError(tr("Could not download package source %1 from ('%2')").arg(data + .downloader->url().fileName(), data.info.url.toString())); } else { updatesInfo->setFileName(data.downloader->downloadedFileName()); } @@ -345,7 +340,7 @@ bool UpdateFinder::Private::computeApplicableUpdates() if (cancel) return false; - const UpdateSourceInfo updateSource = m_updatesInfoList.value(updatesInfo).info; + const PackageSource updateSource = m_updatesInfoList.value(updatesInfo).info; // Create Update objects for updates that have a valid // UpdateFile @@ -392,11 +387,11 @@ QList<UpdateInfo> UpdateFinder::Private::applicableUpdates(UpdatesInfo *updatesI return updatesInfo->updatesInfo(); } -void UpdateFinder::Private::createUpdateObjects(const UpdateSourceInfo &sourceInfo, +void UpdateFinder::Private::createUpdateObjects(const PackageSource &source, const QList<UpdateInfo> &updateInfoList) { foreach (const UpdateInfo &info, updateInfoList) { - const Resolution value = checkPriorityAndVersion(sourceInfo, info.data); + const Resolution value = checkPriorityAndVersion(source, info.data); if (value == Resolution::KeepExisting) continue; @@ -405,7 +400,7 @@ void UpdateFinder::Private::createUpdateObjects(const UpdateSourceInfo &sourceIn delete updates.take(name); // Create and register the update - updates.insert(name, new Update(sourceInfo.priority, sourceInfo.url, info.data)); + updates.insert(name, new Update(source.priority, source.url, info.data)); } } @@ -415,7 +410,7 @@ void UpdateFinder::Private::createUpdateObjects(const UpdateSourceInfo &sourceIn priority, use the new new package, otherwise keep the already existing package. */ UpdateFinder::Private::Resolution UpdateFinder::Private::checkPriorityAndVersion( - const UpdateSourceInfo &sourceInfo, const QVariantHash &newPackage) const + const PackageSource &source, const QVariantHash &newPackage) const { const QString name = newPackage.value(QLatin1String("Name")).toString(); if (Update *existingPackage = updates.value(name)) { @@ -431,18 +426,18 @@ UpdateFinder::Private::Resolution UpdateFinder::Private::checkPriorityAndVersion .arg(name, existingPackage->data(QLatin1String("Version")).toString(), QFileInfo(existingPackage->sourceInfoUrl().toLocalFile()).fileName(), name, newPackage.value(QLatin1String("Version")).toString(), - QFileInfo(sourceInfo.url.toLocalFile()).fileName()); + QFileInfo(source.url.toLocalFile()).fileName()); return Resolution::RemoveExisting; } - if ((match == 0) && (sourceInfo.priority > existingPackage->priority())) { + if ((match == 0) && (source.priority > existingPackage->priority())) { // new package version equals but priority is higher, use qDebug() << QString::fromLatin1("Remove Package 'Name: %1, Priority: %2, Source: %3' " "found a package with higher priority 'Name: %4, Priority: %5, Source: %6'") .arg(name, QString::number(existingPackage->priority()), QFileInfo(existingPackage->sourceInfoUrl().toLocalFile()).fileName(), - name, QString::number(sourceInfo.priority), - QFileInfo(sourceInfo.url.toLocalFile()).fileName()); + name, QString::number(source.priority), + QFileInfo(source.url.toLocalFile()).fileName()); return Resolution::RemoveExisting; } return Resolution::KeepExisting; // otherwise keep existing @@ -485,11 +480,11 @@ void UpdateFinder::setPackagesInfo(std::weak_ptr<PackagesInfo> info) } /*! - Sets the update sources information to use when searching for updates. + Sets the package sources information to use when searching for applicable packages. */ -void UpdateFinder::setUpdateSourcesInfo(const UpdateSourcesInfo &sources) +void UpdateFinder::setPackageSources(const QSet<PackageSource> &sources) { - d->m_updateSourcesInfo = sources; + d->packageSources = sources; } /*! diff --git a/src/libs/kdtools/kdupdaterupdatefinder.h b/src/libs/kdtools/kdupdaterupdatefinder.h index f437d2311..329cd54e6 100644 --- a/src/libs/kdtools/kdupdaterupdatefinder.h +++ b/src/libs/kdtools/kdupdaterupdatefinder.h @@ -37,6 +37,7 @@ #define KD_UPDATER_UPDATE_FINDER_H #include "kdupdatertask.h" +#include "packagesource.h" #include <memory> @@ -44,7 +45,6 @@ namespace KDUpdater { class PackagesInfo; class Update; -class UpdateSourcesInfo; class KDTOOLS_EXPORT UpdateFinder : public Task { @@ -58,7 +58,7 @@ public: QList<Update *> updates() const; void setPackagesInfo(std::weak_ptr<PackagesInfo> info); - void setUpdateSourcesInfo(const UpdateSourcesInfo &sources); + void setPackageSources(const QSet<QInstaller::PackageSource> &sources); private: void doRun(); diff --git a/src/libs/kdtools/kdupdaterupdatesourcesinfo.cpp b/src/libs/kdtools/kdupdaterupdatesourcesinfo.cpp deleted file mode 100644 index 6125fc3e5..000000000 --- a/src/libs/kdtools/kdupdaterupdatesourcesinfo.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB) -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "kdupdaterupdatesourcesinfo.h" - -namespace KDUpdater { - -/*! - \inmodule kdupdater - \class KDUpdater::UpdateSourcesInfo - \brief The UpdateSourcesInfo class provides access to information about the update sources set - for the application. - - An update source is a repository that contains updates applicable for the application. - Applications can download updates from the update source and install them locally. - - Each application can have one or more update sources from which it can download updates. - - The class makes the information available through an easy to use API. You can: - - \list - \li Get update sources information via the updateSourceInfoCount() and updateSourceInfo() - methods. - \li Add or remove update source information via the addUpdateSourceInfo() and - removeUpdateSourceInfo() methods. - \endlist -*/ - -/*! - \fn KDUpdater::operator==(const UpdateSourceInfo &lhs, const UpdateSourceInfo &rhs) - - Returns \c true if \a lhs and \a rhs are equal; otherwise returns \c false. -*/ - -/*! - \fn KDUpdater::operator!=(const UpdateSourceInfo &lhs, const UpdateSourceInfo &rhs) - - Returns \c true if \a lhs and \a rhs are different; otherwise returns \c false. -*/ - -struct PriorityHigherThan -{ - bool operator()(const UpdateSourceInfo &lhs, const UpdateSourceInfo &rhs) const - { - return lhs.priority > rhs.priority; - } -}; - -/*! - Returns the number of update source info structures contained in this class. -*/ -int UpdateSourcesInfo::updateSourceInfoCount() const -{ - return m_updateSourceInfoList.count(); -} - -/*! - Returns the update source info structure at \a index. If an invalid index is passed, the - function returns a \l{default-constructed value}. -*/ -UpdateSourceInfo UpdateSourcesInfo::updateSourceInfo(int index) const -{ - return m_updateSourceInfoList.value(index); -} - -/*! - Adds the given update source info \a info to this class. -*/ -void UpdateSourcesInfo::addUpdateSourceInfo(const UpdateSourceInfo &info) -{ - if (m_updateSourceInfoList.contains(info)) - return; - m_updateSourceInfoList.append(info); - std::sort(m_updateSourceInfoList.begin(), m_updateSourceInfoList.end(), PriorityHigherThan()); -} - -/*! - \overload - - Adds a new update source with \a name, \a title, \a description, \a url, and \a priority to - this class. -*/ -void UpdateSourcesInfo::addUpdateSource(const QString &name, const QString &title, - const QString &description, const QUrl &url, int priority) -{ - UpdateSourceInfo info; - info.name = name; - info.title = title; - info.description = description; - info.url = url; - info.priority = priority; - addUpdateSourceInfo(info); -} - -/*! - Removes the given update source info \a info from this class. -*/ -void UpdateSourcesInfo::removeUpdateSourceInfo(const UpdateSourceInfo &info) -{ - m_updateSourceInfoList.removeAll(info); -} - -/*! - Clears the update source information this class holds. -*/ -void UpdateSourcesInfo::clear() -{ - m_updateSourceInfoList.clear(); -} - -/*! - \inmodule kdupdater - \class KDUpdater::UpdateSourceInfo - \brief The UpdateSourceInfo class specifies a single update source. - - An update source is a repository that contains updates applicable for the application. - This structure describes a single update source in terms of name, title, description, - url, and priority. -*/ - -/*! - \fn UpdateSourceInfo::UpdateSourceInfo() - - Constructs an empty update source info object. The object's priority is set to -1. All other - class members are initialized using a \l{default-constructed value}. -*/ - -/*! - \variable UpdateSourceInfo::name - \brief The name of the update source. -*/ - -/*! - \variable UpdateSourceInfo::title - \brief The title of the update source. -*/ - -/*! - \variable UpdateSourceInfo::description - \brief The description of the update source. -*/ - -/*! - \variable UpdateSourceInfo::url - \brief The URL of the update source. -*/ - -/*! - \variable UpdateSourceInfo::priority - \brief The priority of the update source. -*/ - -bool operator== (const UpdateSourceInfo &lhs, const UpdateSourceInfo &rhs) -{ - return lhs.name == rhs.name && lhs.title == rhs.title && lhs.description == rhs.description - && lhs.url == rhs.url; -} - -} // namespace KDUpdater |