diff options
author | kh1 <karsten.heimrich@digia.com> | 2013-11-25 16:53:04 +0100 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@digia.com> | 2013-11-25 16:53:33 +0100 |
commit | 31a0f80573edce1a08b0532327a15287298d8a2c (patch) | |
tree | 12ead8dafb8b22105251fed2e6dea78a384bccc4 | |
parent | 42255f8756c5c92bc3312dce2d672bb2c4d6f2b7 (diff) |
Adjust ProductKeyCheck API. (in preparation for multiple pages)
Change-Id: I69d0fc9842df7fb564db57067da5f40e002b61de
Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
-rw-r--r-- | src/libs/installer/component.cpp | 2 | ||||
-rw-r--r-- | src/libs/installer/getrepositoriesmetainfojob.cpp | 2 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore.cpp | 4 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore_p.cpp | 10 | ||||
-rw-r--r-- | src/libs/installer/productkeycheck.cpp | 30 | ||||
-rw-r--r-- | src/libs/installer/productkeycheck.h | 13 | ||||
-rw-r--r-- | src/sdk/installerbase.cpp | 3 | ||||
-rw-r--r-- | src/sdk/installerbasecommons.cpp | 11 | ||||
-rw-r--r-- | src/sdk/settingsdialog.cpp | 2 | ||||
-rw-r--r-- | src/sdk/tabcontroller.cpp | 4 |
10 files changed, 26 insertions, 55 deletions
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 QHash<QString, QVar for (it = licenseHash.begin(); it != licenseHash.end(); ++it) { const QString &fileName = it.value().toString(); - if (!ProductKeyCheck::instance(d->m_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<QString, QString> ¶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 <productkeycheck.h> -#include <packagemanagercore.h> - -class ProductKeyCheckPrivate -{ - public: - static QPointer<QInstaller::PackageManagerCore> core; -}; - -QPointer<QInstaller::PackageManagerCore> 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 <QString> -#include <QHash> -#include <QPointer> 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 diff --git a/src/sdk/installerbase.cpp b/src/sdk/installerbase.cpp index 8401dcff7..3bc5ea8cd 100644 --- a/src/sdk/installerbase.cpp +++ b/src/sdk/installerbase.cpp @@ -61,6 +61,8 @@ #include <kdrunoncechecker.h> #include <kdupdaterfiledownloaderfactory.h> +#include <productkeycheck.h> + #include <QDirIterator> #include <QtCore/QTranslator> #include <QMessageBox> @@ -304,6 +306,7 @@ int main(int argc, char *argv[]) // instantiate the installer we are actually going to use QInstaller::PackageManagerCore core(content.magicMarker(), content.performedOperations()); + ProductKeyCheck::instance()->init(&core); QString controlScript; QHash<QString, QString> params; diff --git a/src/sdk/installerbasecommons.cpp b/src/sdk/installerbasecommons.cpp index ab5a745a4..58a811fac 100644 --- a/src/sdk/installerbasecommons.cpp +++ b/src/sdk/installerbasecommons.cpp @@ -503,10 +503,13 @@ bool TargetDirectoryPageImpl::validatePage() InstallerGui::InstallerGui(PackageManagerCore *core) : PackageManagerGui(core, 0) { - ProductKeyCheck *checker = ProductKeyCheck::instance(core); - foreach (const int id, checker->registeredPages()) - setPage(id, PackageManagerPageFactory::instance().create(id, core)); - + ProductKeyCheck *checker = ProductKeyCheck::instance(); + foreach (const int id, checker->registeredPages()) { + PackageManagerPage *page = PackageManagerPageFactory::instance().create(id, core); + Q_ASSERT_X(page, Q_FUNC_INFO, qPrintable(QString::fromLatin1("Page with %1 couldn't be " + "constructed.").arg(id))); + setPage(id, page); + } setPage(PackageManagerCore::Introduction, new IntroductionPageImpl(core)); setPage(PackageManagerCore::TargetDirectory, new TargetDirectoryPageImpl(core)); setPage(PackageManagerCore::ComponentSelection, new ComponentSelectionPage(core)); diff --git a/src/sdk/settingsdialog.cpp b/src/sdk/settingsdialog.cpp index 0f1f3ff6e..305fc051a 100644 --- a/src/sdk/settingsdialog.cpp +++ b/src/sdk/settingsdialog.cpp @@ -450,6 +450,6 @@ void SettingsDialog::insertRepositories(const QSet<Repository> repos, QTreeWidge foreach (const Repository &repo, repos) { RepositoryItem *item = new RepositoryItem(repo); rootItem->addChild(item); - item->setHidden(!ProductKeyCheck::instance(m_core)->isValidRepository(repo)); + item->setHidden(!ProductKeyCheck::instance()->isValidRepository(repo)); } } diff --git a/src/sdk/tabcontroller.cpp b/src/sdk/tabcontroller.cpp index 770ea8007..8d4492ac1 100644 --- a/src/sdk/tabcontroller.cpp +++ b/src/sdk/tabcontroller.cpp @@ -124,10 +124,6 @@ void TabController::setManagerParams(const QHash<QString, QString> ¶ms) int TabController::init() { - if (!ProductKeyCheck::instance()->hasValidKey() && d->m_core->isInstaller()) { - return PackageManagerCore::Failure; - } - if (!d->m_init) { d->m_init = true; // this should called as early as possible, to handle error message boxes for example |