From ecdee3271c495ebf60f39751bdea8366cca71512 Mon Sep 17 00:00:00 2001 From: Pawel Polanski <pawel.3.polanski@nokia.com> Date: Thu, 15 Jul 2010 12:01:07 +0200 Subject: [PATCH] Enabling not silent installation on Symbian OS Reviewed-by: Tobias Hunger --- src/shared/symbianutils/launcher.cpp | 51 +++++++++++++++++++++++++--- src/shared/symbianutils/launcher.h | 13 +++++++ 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/src/shared/symbianutils/launcher.cpp b/src/shared/symbianutils/launcher.cpp index a22c12f9905..930e6d1495c 100644 --- a/src/shared/symbianutils/launcher.cpp +++ b/src/shared/symbianutils/launcher.cpp @@ -102,13 +102,17 @@ struct LauncherPrivate { Launcher::Actions m_startupActions; bool m_closeDevice; CrashReportState m_crashReportState; + Launcher::InstallationMode m_installationMode; + Launcher::InstallationMode m_currentInstallationStep; }; LauncherPrivate::LauncherPrivate(const TrkDevicePtr &d) : m_device(d), m_state(Launcher::Disconnected), m_verbose(0), - m_closeDevice(true) + m_closeDevice(true), + m_installationMode(Launcher::InstallationModeSilentAndUser), + m_currentInstallationStep(Launcher::InstallationModeSilent) { if (m_device.isNull()) m_device = TrkDevicePtr(new TrkDevice); @@ -147,6 +151,11 @@ void Launcher::setState(State s) } } +void Launcher::setInstallationMode(InstallationMode installation) +{ + d->m_installationMode = installation; +} + void Launcher::addStartupActions(trk::Launcher::Actions startupActions) { d->m_startupActions = Actions(d->m_startupActions | startupActions); @@ -204,7 +213,6 @@ bool Launcher::serialFrame() const return d->m_device->serialFrame(); } - bool Launcher::closeDevice() const { return d->m_closeDevice; @@ -215,6 +223,11 @@ void Launcher::setCloseDevice(bool c) d->m_closeDevice = c; } +Launcher::InstallationMode Launcher::installationMode() const +{ + return d->m_installationMode; +} + bool Launcher::startServer(QString *errorMessage) { errorMessage->clear(); @@ -291,7 +304,7 @@ void Launcher::handleConnect(const TrkResult &result) if (d->m_startupActions & ActionCopy) copyFileToRemote(); else if (d->m_startupActions & ActionInstall) - installRemotePackageSilently(); + installRemotePackage(); else if (d->m_startupActions & ActionRun) startInferiorIfNeeded(); else if (d->m_startupActions & ActionDownload) @@ -678,7 +691,7 @@ void Launcher::handleFileCopied(const TrkResult &result) if (result.errorCode()) emit canNotCloseFile(d->m_copyState.destinationFileName, result.errorString()); if (d->m_startupActions & ActionInstall) - installRemotePackageSilently(); + installRemotePackage(); else if (d->m_startupActions & ActionRun) startInferiorIfNeeded(); else if (d->m_startupActions & ActionDownload) @@ -847,15 +860,45 @@ void Launcher::copyFileFromRemote() void Launcher::installRemotePackageSilently() { emit installingStarted(); + d->m_currentInstallationStep = InstallationModeSilent; QByteArray ba; ba.append('C'); appendString(&ba, d->m_installFileName.toLocal8Bit(), TargetByteOrder, false); d->m_device->sendTrkMessage(TrkInstallFile, TrkCallback(this, &Launcher::handleInstallPackageFinished), ba); } +void Launcher::installRemotePackageByUser() +{ + emit installingStarted(); + d->m_currentInstallationStep = InstallationModeUser; + QByteArray ba; + appendString(&ba, d->m_installFileName.toLocal8Bit(), TargetByteOrder, false); + d->m_device->sendTrkMessage(TrkInstallFile2, TrkCallback(this, &Launcher::handleInstallPackageFinished), ba); +} + +void Launcher::installRemotePackage() +{ + switch (installationMode()) { + case InstallationModeSilent: + case InstallationModeSilentAndUser: + installRemotePackageSilently(); + break; + case InstallationModeUser: + installRemotePackageByUser(); + break; + default: + break; + } +} + void Launcher::handleInstallPackageFinished(const TrkResult &result) { if (result.errorCode()) { + if( installationMode() == InstallationModeSilentAndUser + && d->m_currentInstallationStep & InstallationModeSilent ) { + installRemotePackageByUser(); + return; + } emit canNotInstall(d->m_installFileName, result.errorString()); disconnectTrk(); return; diff --git a/src/shared/symbianutils/launcher.h b/src/shared/symbianutils/launcher.h index 7e348e80842..edf2afed94a 100644 --- a/src/shared/symbianutils/launcher.h +++ b/src/shared/symbianutils/launcher.h @@ -51,6 +51,13 @@ class SYMBIANUTILS_EXPORT Launcher : public QObject public: typedef void (Launcher::*TrkCallBack)(const TrkResult &); + enum InstallationMode { + InstallationModeSilent = 0x1, + InstallationModeUser = 0x2, + InstallationModeSilentAndUser = InstallationModeSilent|InstallationModeUser + //first attempt is silent and if it fails then the user installation is launched + }; + enum Actions { ActionPingOnly = 0x0, ActionCopy = 0x1, @@ -87,8 +94,12 @@ public: void setInstallFileName(const QString &name); void setCommandLineArgs(const QStringList &args); bool startServer(QString *errorMessage); + void setInstallationMode(InstallationMode installation); void setVerbose(int v); void setSerialFrame(bool b); + + InstallationMode installationMode() const; + bool serialFrame() const; // Close device or leave it open bool closeDevice() const; @@ -185,6 +196,8 @@ private: void copyFileToRemote(); void copyFileFromRemote(); void installRemotePackageSilently(); + void installRemotePackageByUser(); + void installRemotePackage(); void startInferiorIfNeeded(); void handleFinished(); -- GitLab