From 6e48c0e9e2724f393d3e87e50d200c5705b838ee Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Fri, 17 May 2013 10:55:28 +0200 Subject: forward packagemanager core to ProductKeyCheck class - with this the outsourced product key check code can enable, disable or even add repositories Change-Id: I390251b7f3bfa29a6f39a9ac44aa55ec15f780a2 Reviewed-by: Iikka Eklund Reviewed-by: Karsten Heimrich --- src/libs/installer/component.cpp | 2 +- src/libs/installer/packagemanagercore.cpp | 4 ++-- src/libs/installer/packagemanagercore_p.cpp | 8 ++++---- src/libs/installer/productkeycheck.cpp | 16 ++++++++++++++-- src/libs/installer/productkeycheck.h | 8 +++++++- 5 files changed, 28 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index 36e1df7fe..a4a16eb44 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -576,7 +576,7 @@ void Component::loadLicenses(const QString &directory, const QHashisValidLicense(fileName)) + if (!ProductKeyCheck::instance(d->m_core)->isValidLicense(fileName)) continue; QFileInfo fileInfo(fileName); diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index d854b018a..1ab7d0909 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -869,8 +869,8 @@ bool PackageManagerCore::fetchRemotePackagesTree() return false; } - if (!ProductKeyCheck::instance()->hasValidKey()) { - d->setStatus(Failure, ProductKeyCheck::instance()->lastErrorString()); + if (!ProductKeyCheck::instance(this)->hasValidKey()) { + d->setStatus(Failure, ProductKeyCheck::instance(this)->lastErrorString()); return false; } diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index d703bbd97..9722a9200 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -569,13 +569,13 @@ QString PackageManagerCorePrivate::installReason(Component *component) void PackageManagerCorePrivate::initialize(const QHash ¶ms) { - if (!ProductKeyCheck::instance()->hasValidKey()) { + if (!ProductKeyCheck::instance(m_core)->hasValidKey()) { if (m_core->isInstaller()) { - setStatus(PackageManagerCore::Failure, ProductKeyCheck::instance()->lastErrorString()); + setStatus(PackageManagerCore::Failure, ProductKeyCheck::instance(m_core)->lastErrorString()); } else { MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(), - QLatin1String("ProductKeyCheckError"), ProductKeyCheck::instance()->lastErrorString(), - ProductKeyCheck::instance()->maintainanceToolDetailErrorNotice(), QMessageBox::Ok); + QLatin1String("ProductKeyCheckError"), ProductKeyCheck::instance(m_core)->lastErrorString(), + ProductKeyCheck::instance(m_core)->maintainanceToolDetailErrorNotice(), QMessageBox::Ok); } } diff --git a/src/libs/installer/productkeycheck.cpp b/src/libs/installer/productkeycheck.cpp index 120014dad..e2aac1813 100644 --- a/src/libs/installer/productkeycheck.cpp +++ b/src/libs/installer/productkeycheck.cpp @@ -28,12 +28,16 @@ **************************************************************************/ #include - +#include class ProductKeyCheckPrivate { + public: + static QPointer core; }; +QPointer ProductKeyCheckPrivate::core = 0; + ProductKeyCheck::ProductKeyCheck() : d(new ProductKeyCheckPrivate()) @@ -45,12 +49,20 @@ ProductKeyCheck::~ProductKeyCheck() delete d; } -ProductKeyCheck *ProductKeyCheck::instance() +ProductKeyCheck *ProductKeyCheck::instance(QInstaller::PackageManagerCore *core) { static ProductKeyCheck instance; + if (core) + instance.setPackageManagerCore(core); return &instance; } +void ProductKeyCheck::setPackageManagerCore(QInstaller::PackageManagerCore *core) +{ + ProductKeyCheckPrivate::core = core; +} + + bool ProductKeyCheck::hasValidKey() { return true; diff --git a/src/libs/installer/productkeycheck.h b/src/libs/installer/productkeycheck.h index 1ecffc3d2..382986e30 100644 --- a/src/libs/installer/productkeycheck.h +++ b/src/libs/installer/productkeycheck.h @@ -34,6 +34,11 @@ #include #include +#include + +namespace QInstaller{ + class PackageManagerCore; +} class ProductKeyCheckPrivate; @@ -41,7 +46,8 @@ class INSTALLER_EXPORT ProductKeyCheck { public: ~ProductKeyCheck(); - static ProductKeyCheck *instance(); + static ProductKeyCheck *instance(QInstaller::PackageManagerCore *core = 0); + static void setPackageManagerCore(QInstaller::PackageManagerCore *core); // was validLicense bool hasValidKey(); -- cgit v1.2.3