summaryrefslogtreecommitdiffstats
path: root/src/libs/installer
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/installer
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/installer')
-rw-r--r--src/libs/installer/component.cpp1
-rw-r--r--src/libs/installer/installer.pro6
-rw-r--r--src/libs/installer/packagemanagercore_p.cpp24
-rw-r--r--src/libs/installer/packagemanagercore_p.h4
-rw-r--r--src/libs/installer/packagesource.cpp91
-rw-r--r--src/libs/installer/packagesource.h63
6 files changed, 168 insertions, 21 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> &params
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/installer/packagesource.h b/src/libs/installer/packagesource.h
new file mode 100644
index 000000000..6bc565c15
--- /dev/null
+++ b/src/libs/installer/packagesource.h
@@ -0,0 +1,63 @@
+/**************************************************************************
+**
+** 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 PACKAGESOURCE_H
+#define PACKAGESOURCE_H
+
+#include "installer_global.h"
+
+#include <QUrl>
+
+namespace QInstaller {
+
+struct INSTALLER_EXPORT PackageSource
+{
+ PackageSource()
+ : priority(-1)
+ {}
+ PackageSource(const QUrl &u, int p)
+ : url(u)
+ , priority(p)
+ {}
+
+ QUrl url;
+ int priority;
+};
+
+INSTALLER_EXPORT uint qHash(const PackageSource &key, uint seed);
+INSTALLER_EXPORT bool operator==(const PackageSource &lhs, const PackageSource &rhs);
+
+} // namespace QInstaller
+
+#endif // PACKAGESOURCE_H