From 31a0f80573edce1a08b0532327a15287298d8a2c Mon Sep 17 00:00:00 2001 From: kh1 Date: Mon, 25 Nov 2013 16:53:04 +0100 Subject: Adjust ProductKeyCheck API. (in preparation for multiple pages) Change-Id: I69d0fc9842df7fb564db57067da5f40e002b61de Reviewed-by: Karsten Heimrich --- src/libs/installer/component.cpp | 2 +- src/libs/installer/getrepositoriesmetainfojob.cpp | 2 +- src/libs/installer/packagemanagercore.cpp | 4 +-- src/libs/installer/packagemanagercore_p.cpp | 10 -------- src/libs/installer/productkeycheck.cpp | 30 +++++------------------ src/libs/installer/productkeycheck.h | 13 ++++------ 6 files changed, 15 insertions(+), 46 deletions(-) (limited to 'src/libs') diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index b7c4dfe3b..1b37cc12c 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -589,7 +589,7 @@ void Component::loadLicenses(const QString &directory, const QHashm_core)->isValidLicenseTextFile(fileName)) + if (!ProductKeyCheck::instance()->isValidLicenseTextFile(fileName)) continue; QFileInfo fileInfo(fileName); diff --git a/src/libs/installer/getrepositoriesmetainfojob.cpp b/src/libs/installer/getrepositoriesmetainfojob.cpp index c4564e781..cde872064 100644 --- a/src/libs/installer/getrepositoriesmetainfojob.cpp +++ b/src/libs/installer/getrepositoriesmetainfojob.cpp @@ -121,7 +121,7 @@ void GetRepositoriesMetaInfoJob::doStart() { if ((m_core->isInstaller() && !m_core->isOfflineOnly()) || (m_core->isUpdater() || m_core->isPackageManager())) { - const ProductKeyCheck *const productKeyCheck = ProductKeyCheck::instance(m_core); + const ProductKeyCheck *const productKeyCheck = ProductKeyCheck::instance(); foreach (const Repository &repo, m_core->settings().repositories()) { if (repo.isEnabled() && productKeyCheck->isValidRepository(repo)) m_repositories += repo; diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index 1eddb8c1b..09e1a5094 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -900,8 +900,8 @@ bool PackageManagerCore::fetchRemotePackagesTree() return false; } - if (!ProductKeyCheck::instance(this)->hasValidKey()) { - d->setStatus(Failure, ProductKeyCheck::instance(this)->lastErrorString()); + if (!ProductKeyCheck::instance()->hasValidKey()) { + d->setStatus(Failure, ProductKeyCheck::instance()->lastErrorString()); return false; } diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index 884bc849d..5416bc9f2 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -601,16 +601,6 @@ QString PackageManagerCorePrivate::installReason(Component *component) void PackageManagerCorePrivate::initialize(const QHash ¶ms) { - if (!ProductKeyCheck::instance(m_core)->hasValidKey()) { - if (m_core->isInstaller()) { - setStatus(PackageManagerCore::Failure, ProductKeyCheck::instance(m_core)->lastErrorString()); - } else { - MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(), - QLatin1String("ProductKeyCheckError"), ProductKeyCheck::instance(m_core)->lastErrorString(), - ProductKeyCheck::instance(m_core)->maintainanceToolDetailErrorNotice(), QMessageBox::Ok); - } - } - m_coreCheckedHash.clear(); m_data = PackageManagerCoreData(params); m_componentsToInstallCalculated = false; diff --git a/src/libs/installer/productkeycheck.cpp b/src/libs/installer/productkeycheck.cpp index 9a9010d60..6b5699361 100644 --- a/src/libs/installer/productkeycheck.cpp +++ b/src/libs/installer/productkeycheck.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (c) 2012 Digia Plc and/or its subsidiary(-ies). +** Copyright (c) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Installer Framework @@ -27,42 +27,24 @@ ** **************************************************************************/ -#include -#include - -class ProductKeyCheckPrivate -{ - public: - static QPointer core; -}; - -QPointer ProductKeyCheckPrivate::core = 0; - +#include "productkeycheck.h" +#include "packagemanagercore.h" ProductKeyCheck::ProductKeyCheck() - : d(new ProductKeyCheckPrivate()) { } -ProductKeyCheck::~ProductKeyCheck() -{ - delete d; -} - -ProductKeyCheck *ProductKeyCheck::instance(QInstaller::PackageManagerCore *core) +ProductKeyCheck *ProductKeyCheck::instance() { static ProductKeyCheck instance; - if (core) - instance.setPackageManagerCore(core); return &instance; } -void ProductKeyCheck::setPackageManagerCore(QInstaller::PackageManagerCore *core) +void ProductKeyCheck::init(QInstaller::PackageManagerCore *core) { - ProductKeyCheckPrivate::core = core; + Q_UNUSED(core) } - bool ProductKeyCheck::hasValidKey() { return true; diff --git a/src/libs/installer/productkeycheck.h b/src/libs/installer/productkeycheck.h index d5772629a..d714e2d3d 100644 --- a/src/libs/installer/productkeycheck.h +++ b/src/libs/installer/productkeycheck.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (c) 2012 Digia Plc and/or its subsidiary(-ies). +** Copyright (c) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Installer Framework @@ -30,11 +30,9 @@ #ifndef PRODUCTKEYCHECK_H #define PRODUCTKEYCHECK_H -#include "qinstallerglobal.h" +#include "installer_global.h" #include -#include -#include namespace QInstaller{ class PackageManagerCore; @@ -46,9 +44,8 @@ class ProductKeyCheckPrivate; class INSTALLER_EXPORT ProductKeyCheck { public: - ~ProductKeyCheck(); - static ProductKeyCheck *instance(QInstaller::PackageManagerCore *core = 0); - static void setPackageManagerCore(QInstaller::PackageManagerCore *core); + static ProductKeyCheck *instance(); + void init(QInstaller::PackageManagerCore *core); // was validLicense bool hasValidKey(); @@ -68,7 +65,7 @@ public: private: ProductKeyCheck(); - ProductKeyCheckPrivate *const d; + Q_DISABLE_COPY(ProductKeyCheck) }; #endif // PRODUCTKEYCHECK_H -- cgit v1.2.3