diff options
author | Katja Marttila <katja.marttila@qt.io> | 2019-10-21 12:31:04 +0300 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2019-11-19 09:37:39 +0000 |
commit | 3bd4e7d632967b1bf77120918700c11f83318166 (patch) | |
tree | c6ad1d18b60ff27e0fb64c507852aca039cdbe97 /src/sdk/installerbase.cpp | |
parent | 9ce679325c244859c7e50ed3cca304c1e0f2b698 (diff) |
Refactor code to functions which command line interface needs
These are needed in multiple places while implementing
CLI so created common functions to avoid code repeat.
Change-Id: I2b30bedf5de838211f48bd1669c59ff3a17f640e
Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
Diffstat (limited to 'src/sdk/installerbase.cpp')
-rw-r--r-- | src/sdk/installerbase.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/sdk/installerbase.cpp b/src/sdk/installerbase.cpp index 5c8478036..918a846fc 100644 --- a/src/sdk/installerbase.cpp +++ b/src/sdk/installerbase.cpp @@ -296,19 +296,14 @@ int InstallerBase::run() if (parser.isSet(QLatin1String(CommandLineOptions::SilentUpdate))) { if (m_core->isInstaller()) throw QInstaller::Error(QLatin1String("Cannot start installer binary as updater.")); - const ProductKeyCheck *const productKeyCheck = ProductKeyCheck::instance(); - if (!productKeyCheck->hasValidLicense()) - throw QInstaller::Error(QLatin1String("Silent update not allowed.")); + checkLicense(); m_core->setUpdater(); m_core->updateComponentsSilently(); } else if (parser.isSet(QLatin1String(CommandLineOptions::ListInstalledPackages))){ if (m_core->isInstaller()) throw QInstaller::Error(QLatin1String("Cannot start installer binary as package manager.")); + checkLicense(); m_core->setPackageManager(); - - const ProductKeyCheck *const productKeyCheck = ProductKeyCheck::instance(); - if (!productKeyCheck->hasValidLicense()) - throw QInstaller::Error(QLatin1String("No valid license found.")); m_core->listInstalledPackages(); } else { //create the wizard GUI @@ -384,3 +379,12 @@ QStringList InstallerBase::repositories(const QString &list) const qDebug().noquote() << "Adding custom repository:" << item; return items; } + +void InstallerBase::checkLicense() +{ + const ProductKeyCheck *const productKeyCheck = ProductKeyCheck::instance(); + if (!productKeyCheck->hasValidLicense()) { + qDebug() << "No valid license found."; + throw QInstaller::Error(QLatin1String("No valid license found.")); + } +} |