diff options
author | kh <karsten.heimrich@theqtcompany.com> | 2014-11-25 16:18:26 +0100 |
---|---|---|
committer | Kai Koehne <kai.koehne@theqtcompany.com> | 2014-12-10 08:54:18 +0100 |
commit | 4853be33e29654304af4209b38137541068c1662 (patch) | |
tree | 71ea26e92db160ecdffc0bcc8b8c621bab9a4cf4 | |
parent | 7c2d08ca09875224ee7dca480d91a07bcc7719a6 (diff) |
Add possibility to specify a control script.
Right now we support control scripts just as command line argument,
but now we can also bundle it in the binary as well. This helps e.g.
with running scripts during uninstallation, enables the possibility
to modify the introduction page or enables headless installer builds.
Task-number: QTIFW-495
Task-number: QTIFW-166
Change-Id: I6fee6a55db78ed28b1eeb8257a4febaa2703c04e
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
-rw-r--r-- | doc/installerfw.qdoc | 4 | ||||
-rw-r--r-- | src/libs/installer/packagemanagergui.cpp | 14 | ||||
-rw-r--r-- | src/libs/installer/packagemanagergui.h | 7 | ||||
-rw-r--r-- | src/libs/installer/settings.cpp | 9 | ||||
-rw-r--r-- | src/libs/installer/settings.h | 2 | ||||
-rw-r--r-- | src/sdk/installerbase.cpp | 3 | ||||
-rw-r--r-- | src/sdk/installerbasecommons.cpp | 6 | ||||
-rw-r--r-- | src/sdk/installerbasecommons.h | 4 | ||||
-rw-r--r-- | src/sdk/tabcontroller.cpp | 3 | ||||
-rw-r--r-- | tests/auto/installer/settings/data/full_config.xml | 2 | ||||
-rw-r--r-- | tests/auto/installer/settings/tst_settings.cpp | 1 |
11 files changed, 25 insertions, 30 deletions
diff --git a/doc/installerfw.qdoc b/doc/installerfw.qdoc index bf8475c11..24c0a8afd 100644 --- a/doc/installerfw.qdoc +++ b/doc/installerfw.qdoc @@ -290,7 +290,9 @@ \li UrlQueryString \li This string needs to be in the form "key=value" and will be appended to archive download requests. This can be used to transmit information to the webserver hosting the repository. - + \row + \li ControlScript + \li Filename for a custom installer control script. See \l{Controller Scripting}. \endtable */ diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp index 35a509f22..4653c7ff6 100644 --- a/src/libs/installer/packagemanagergui.cpp +++ b/src/libs/installer/packagemanagergui.cpp @@ -504,7 +504,7 @@ void PackageManagerGui::wizardPageInsertionRequested(QWidget *widget, void PackageManagerGui::wizardPageRemovalRequested(QWidget *widget) { foreach (int pageId, pageIds()) { - DynamicInstallerPage *const dynamicPage = dynamic_cast<DynamicInstallerPage*>(page(pageId)); + DynamicInstallerPage *const dynamicPage = qobject_cast<DynamicInstallerPage*>(page(pageId)); if (dynamicPage == 0) continue; if (dynamicPage->widget() != widget) @@ -1007,8 +1007,6 @@ bool IntroductionPage::validatePage() setErrorMessage(core->error()); } - callControlScript(QLatin1String("UpdaterSelectedCallback")); - if (m_updatesFetched) { if (core->components(QInstaller::PackageManagerCore::ComponentType::Root).count() <= 0) setErrorMessage(QString::fromLatin1("<b>%1</b>").arg(tr("No updates available."))); @@ -1038,8 +1036,6 @@ bool IntroductionPage::validatePage() } } - callControlScript(QLatin1String("PackageManagerSelectedCallback")); - if (m_allPackagesFetched || localPackagesTreeFetched) setComplete(true); } @@ -1121,14 +1117,6 @@ void IntroductionPage::setErrorMessage(const QString &error) #endif } -void IntroductionPage::callControlScript(const QString &callback) -{ - // Initialize the gui. Needs to be done after check repositories as only then the ui can handle - // hide of pages depending on the components. - gui()->init(); - gui()->callControlScriptMethod(callback); -} - bool IntroductionPage::validRepositoriesAvailable() const { const PackageManagerCore *const core = packageManagerCore(); diff --git a/src/libs/installer/packagemanagergui.h b/src/libs/installer/packagemanagergui.h index 6c3c56fc9..2830b1b3d 100644 --- a/src/libs/installer/packagemanagergui.h +++ b/src/libs/installer/packagemanagergui.h @@ -72,8 +72,7 @@ class INSTALLER_EXPORT PackageManagerGui : public QWizard public: explicit PackageManagerGui(PackageManagerCore *core, QWidget *parent = 0); - virtual ~PackageManagerGui(); - virtual void init() = 0; + virtual ~PackageManagerGui() = 0; void loadControlScript(const QString& scriptPath); void callControlScriptMethod(const QString& methodName); @@ -219,7 +218,7 @@ public: void showMaintenanceTools(); void setMaintenanceToolsEnabled(bool enable); - public Q_SLOTS: +public Q_SLOTS: void onCoreNetworkSettingsChanged(); void setMessage(const QString &msg); void onProgressChanged(int progress); @@ -238,8 +237,6 @@ private: void leaving(); void showWidgets(bool show); - void callControlScript(const QString &callback); - bool validRepositoriesAvailable() const; private: diff --git a/src/libs/installer/settings.cpp b/src/libs/installer/settings.cpp index c00cfd794..a225d4262 100644 --- a/src/libs/installer/settings.cpp +++ b/src/libs/installer/settings.cpp @@ -66,6 +66,8 @@ static const QLatin1String scFtpProxy("FtpProxy"); static const QLatin1String scHttpProxy("HttpProxy"); static const QLatin1String scProxyType("ProxyType"); +const char scControlScript[] = "ControlScript"; + template <typename T> static QSet<T> variantListToSet(const QVariantList &list) { @@ -253,7 +255,7 @@ Settings Settings::fromFileAndPrefix(const QString &path, const QString &prefix, << scAllowSpaceInPath << scAllowNonAsciiCharacters << scWizardStyle << scTitleColor << scWizardDefaultWidth << scWizardDefaultHeight << scRepositorySettingsPageVisible << scTargetConfigurationFile - << scRemoteRepositories << scTranslations; + << scRemoteRepositories << scTranslations << QLatin1String(scControlScript); Settings s; s.d->m_data.insert(scPrefix, prefix); @@ -683,3 +685,8 @@ void Settings::setTranslations(const QStringList &translations) { d->m_data.insert(scTranslations, translations); } + +QString Settings::controlScript() const +{ + return d->m_data.value(QLatin1String(scControlScript)).toString(); +} diff --git a/src/libs/installer/settings.h b/src/libs/installer/settings.h index 33f6c0ae1..a9cf08d85 100644 --- a/src/libs/installer/settings.h +++ b/src/libs/installer/settings.h @@ -151,6 +151,8 @@ public: QStringList translations() const; void setTranslations(const QStringList &translations); + QString controlScript() const; + private: class Private; QSharedDataPointer<Private> d; diff --git a/src/sdk/installerbase.cpp b/src/sdk/installerbase.cpp index 6253f3e25..7eb816a1a 100644 --- a/src/sdk/installerbase.cpp +++ b/src/sdk/installerbase.cpp @@ -141,6 +141,9 @@ int InstallerBase::run() controlScript = parser.value(QLatin1String(CommandLineOptions::Script)); if (!QFileInfo(controlScript).exists()) throw QInstaller::Error(QLatin1String("Script file does not exist.")); + } else if (!m_core->settings().controlScript().isEmpty()) { + controlScript = QLatin1String(":/metadata/installer-config/") + + m_core->settings().controlScript(); } if (parser.isSet(QLatin1String(CommandLineOptions::Proxy))) { diff --git a/src/sdk/installerbasecommons.cpp b/src/sdk/installerbasecommons.cpp index efdd58b75..8b7953eda 100644 --- a/src/sdk/installerbasecommons.cpp +++ b/src/sdk/installerbasecommons.cpp @@ -64,10 +64,7 @@ InstallerGui::InstallerGui(PackageManagerCore *core) setPage(PackageManagerCore::ReadyForInstallation, new ReadyForInstallationPage(core)); setPage(PackageManagerCore::PerformInstallation, new PerformInstallationPage(core)); setPage(PackageManagerCore::InstallationFinished, new FinishedPage(core)); -} -void InstallerGui::init() -{ foreach (const int id, pageIds()) { packageManagerCore()->controlScriptEngine()->addQObjectChildren(page(id)); packageManagerCore()->componentScriptEngine()->addQObjectChildren(page(id)); @@ -104,10 +101,7 @@ MaintenanceGui::MaintenanceGui(PackageManagerCore *core) if (core->isUninstaller()) wizardPageVisibilityChangeRequested(false, PackageManagerCore::InstallationFinished + 1); -} -void MaintenanceGui::init() -{ foreach (const int id, pageIds()) { packageManagerCore()->controlScriptEngine()->addQObjectChildren(page(id)); packageManagerCore()->componentScriptEngine()->addQObjectChildren(page(id)); diff --git a/src/sdk/installerbasecommons.h b/src/sdk/installerbasecommons.h index b3ba68c35..f6bde1fd0 100644 --- a/src/sdk/installerbasecommons.h +++ b/src/sdk/installerbasecommons.h @@ -46,7 +46,7 @@ class InstallerGui : public QInstaller::PackageManagerGui public: explicit InstallerGui(QInstaller::PackageManagerCore *core); - virtual void init(); + ~InstallerGui() {} }; @@ -58,7 +58,7 @@ class MaintenanceGui : public QInstaller::PackageManagerGui public: explicit MaintenanceGui(QInstaller::PackageManagerCore *core); - virtual void init(); + ~MaintenanceGui() {} private Q_SLOTS: void updateRestartPage(); diff --git a/src/sdk/tabcontroller.cpp b/src/sdk/tabcontroller.cpp index 035622dfb..4cdb23d50 100644 --- a/src/sdk/tabcontroller.cpp +++ b/src/sdk/tabcontroller.cpp @@ -121,9 +121,8 @@ int TabController::init() d->m_init = true; // this should called as early as possible, to handle error message boxes for example if (!d->m_controlScript.isEmpty()) { - qDebug() << "Non-interactive installation using script:" << d->m_controlScript; - d->m_gui->loadControlScript(d->m_controlScript); + qDebug() << "Using control script:" << d->m_controlScript; } connect(d->m_gui, SIGNAL(currentIdChanged(int)), this, SLOT(onCurrentIdChanged(int))); diff --git a/tests/auto/installer/settings/data/full_config.xml b/tests/auto/installer/settings/data/full_config.xml index 52e18c904..e2cae369e 100644 --- a/tests/auto/installer/settings/data/full_config.xml +++ b/tests/auto/installer/settings/data/full_config.xml @@ -53,4 +53,6 @@ File should contain all elements we allow in a config.xml <Translation>de_de</Translation> <Translation>qt_de</Translation> </Translations> + + <ControlScript>controlscript.js</ControlScript> </Installer> diff --git a/tests/auto/installer/settings/tst_settings.cpp b/tests/auto/installer/settings/tst_settings.cpp index 24095c966..626acfab1 100644 --- a/tests/auto/installer/settings/tst_settings.cpp +++ b/tests/auto/installer/settings/tst_settings.cpp @@ -84,6 +84,7 @@ void tst_Settings::loadTutorialConfig() QCOMPARE(settings.httpProxy(), QNetworkProxy()); QCOMPARE(settings.translations(), QStringList()); + QCOMPARE(settings.controlScript(), QString()); } void tst_Settings::loadFullConfig() |