summaryrefslogtreecommitdiffstats
path: root/src/libs/kdtools
diff options
context:
space:
mode:
authorKarsten Heimrich <karsten.heimrich@theqtcompany.com>2015-05-05 11:27:36 +0200
committerKarsten Heimrich <karsten.heimrich@theqtcompany.com>2015-05-06 12:21:10 +0000
commite74530079252ca128be020911f2575caed9f7f28 (patch)
treea116edfb303dcb17be2e5aab844decb6a01f91af /src/libs/kdtools
parentdbdf186ac50e42068c71821ae157a43df3438d55 (diff)
Replace UpdateSourcesInfo and UpdateSourceInfo classes.
Introduce a new struct PackageInfo, which is similar to the removed UpdateSourceInfo struct. The new struct name reflects the actual use better, as we deal with package here (either packages to install or updates to apply) and not updates only. Also remove the container class UpdateSourcesInfo, we can simple reuse a existing Qt container here. Adjust all occurrences that use/ used the classes. Change-Id: I526e24cbf1664f0ab0ad18153f60c2c10b6909d8 Reviewed-by: Jarek Kobus <jaroslaw.kobus@theqtcompany.com>
Diffstat (limited to 'src/libs/kdtools')
-rw-r--r--src/libs/kdtools/kdtools.pri2
-rw-r--r--src/libs/kdtools/kdupdaterupdatefinder.cpp57
-rw-r--r--src/libs/kdtools/kdupdaterupdatefinder.h4
-rw-r--r--src/libs/kdtools/kdupdaterupdatesourcesinfo.cpp191
-rw-r--r--src/libs/kdtools/kdupdaterupdatesourcesinfo.h82
5 files changed, 28 insertions, 308 deletions
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
diff --git a/src/libs/kdtools/kdupdaterupdatesourcesinfo.h b/src/libs/kdtools/kdupdaterupdatesourcesinfo.h
deleted file mode 100644
index cc483a370..000000000
--- a/src/libs/kdtools/kdupdaterupdatesourcesinfo.h
+++ /dev/null
@@ -1,82 +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$
-**
-****************************************************************************/
-
-#ifndef KD_UPDATER_UPDATE_SOURCES_INFO_H
-#define KD_UPDATER_UPDATE_SOURCES_INFO_H
-
-#include "kdtoolsglobal.h"
-
-#include <QUrl>
-
-namespace KDUpdater {
-
-struct KDTOOLS_EXPORT UpdateSourceInfo
-{
- UpdateSourceInfo() : priority(-1) { }
-
- QString name;
- QString title;
- QString description;
- QUrl url;
- int priority;
-};
-
-KDTOOLS_EXPORT bool operator==(const UpdateSourceInfo &lhs, const UpdateSourceInfo &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
-
-#endif // KD_UPDATER_UPDATE_SOURCES_INFO_H