diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp index ef435734827a562625dfe51d34595692976f77a0..5b1a314c7a6d7a79eda2b7dfe94ad4d4809ec46e 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp @@ -624,7 +624,7 @@ void S60DeviceRunControlBase::signsisProcessFinished() emit finished(); return; } - m_launcher = new trk::Launcher; + m_launcher = new trk::Launcher(trk::Launcher::ActionCopyInstallRun); connect(m_launcher, SIGNAL(finished()), this, SLOT(launcherFinished())); connect(m_launcher, SIGNAL(copyingStarted()), this, SLOT(printCopyingNotice())); connect(m_launcher, SIGNAL(canNotCreateFile(QString,QString)), this, SLOT(printCreateFileFailed(QString,QString))); diff --git a/src/shared/trk/launcher.cpp b/src/shared/trk/launcher.cpp index 0c6a76deb341a2abf025c6d8a1b0aff00e1432be..e6cf4d9a7aa3980d855fd15f1b79dbbce36ac3be 100644 --- a/src/shared/trk/launcher.cpp +++ b/src/shared/trk/launcher.cpp @@ -63,6 +63,7 @@ struct LauncherPrivate { QString m_fileName; QString m_installFileName; int m_verbose; + Launcher::Actions m_startupActions; }; LauncherPrivate::LauncherPrivate() : @@ -70,9 +71,10 @@ LauncherPrivate::LauncherPrivate() : { } -Launcher::Launcher() : +Launcher::Launcher(Actions startupActions) : d(new LauncherPrivate) { + d->m_startupActions = startupActions; connect(&d->m_device, SIGNAL(messageReceived(trk::TrkResult)), this, SLOT(handleResult(trk::TrkResult))); } @@ -82,6 +84,11 @@ Launcher::~Launcher() delete d; } +void Launcher::addStartupActions(trk::Launcher::Actions startupActions) +{ + d->m_startupActions = Actions(d->m_startupActions | startupActions); +} + void Launcher::setTrkServerName(const QString &name) { d->m_trkServerName = name; @@ -120,6 +127,23 @@ bool Launcher::startServer(QString *errorMessage) .arg(d->m_trkServerName, d->m_fileName, d->m_copyState.sourceFileName, d->m_copyState.destinationFileName, d->m_installFileName); logMessage(msg); } + if (d->m_startupActions & ActionCopy) { + if (d->m_copyState.sourceFileName.isEmpty()) { + qWarning("No local filename given for copying package."); + return false; + } else if (d->m_copyState.destinationFileName.isEmpty()) { + qWarning("No remote filename given for copying package."); + return false; + } + } + if (d->m_startupActions & ActionInstall && d->m_installFileName.isEmpty()) { + qWarning("No package name given for installing."); + return false; + } + if (d->m_startupActions & ActionRun && d->m_fileName.isEmpty()) { + qWarning("No remote executable given for running."); + return false; + } if (!d->m_device.open(d->m_trkServerName, errorMessage)) return false; d->m_device.sendTrkInitialPing(); @@ -127,10 +151,13 @@ bool Launcher::startServer(QString *errorMessage) d->m_device.sendTrkMessage(TrkSupported, TrkCallback(this, &Launcher::handleSupportMask)); d->m_device.sendTrkMessage(TrkCpuType, TrkCallback(this, &Launcher::handleCpuType)); d->m_device.sendTrkMessage(TrkVersions, TrkCallback(this, &Launcher::handleTrkVersion)); - if (d->m_copyState.sourceFileName.isEmpty() || d->m_copyState.destinationFileName.isEmpty()) - installAndRun(); - else + + if (d->m_startupActions & ActionCopy) copyFileToRemote(); + else if (d->m_startupActions & ActionInstall) + installRemotePackageSilently(d->m_installFileName); + else if (d->m_startupActions & ActionRun) + startInferiorIfNeeded(); return true; } @@ -140,14 +167,6 @@ void Launcher::setVerbose(int v) d->m_device.setVerbose(v); } -void Launcher::installAndRun() -{ - if (d->m_installFileName.isEmpty()) - startInferiorIfNeeded(); - else - installRemotePackageSilently(d->m_installFileName); -} - void Launcher::logMessage(const QString &msg) { if (d->m_verbose) @@ -285,7 +304,7 @@ void Launcher::handleTrkVersion(const TrkResult &result) const int protocolMajor = result.data.at(3); const int protocolMinor = result.data.at(4); // Ping mode: Log & Terminate - if (d->m_fileName.isEmpty()) { + if (d->m_startupActions == ActionPingOnly) { QString msg; QTextStream(&msg) << "CPU: " << d->m_session.cpuMajor << '.' << d->m_session.cpuMinor << ' ' << (d->m_session.bigEndian ? "big endian" : "little endian") @@ -293,6 +312,7 @@ void Launcher::handleTrkVersion(const TrkResult &result) << " float size: " << d->m_session.fpTypeSize << " Trk: v" << trkMajor << '.' << trkMinor << " Protocol: " << protocolMajor << '.' << protocolMinor; qWarning("%s", qPrintable(msg)); + emit finished(); } } @@ -358,7 +378,12 @@ void Launcher::closeRemoteFile(bool failed) void Launcher::handleFileCopied(const TrkResult &result) { Q_UNUSED(result) - installAndRun(); + if (d->m_startupActions & ActionInstall) + installRemotePackageSilently(d->m_installFileName); + else if (d->m_startupActions & ActionRun) + startInferiorIfNeeded(); + else + emit finished(); } void Launcher::handleCpuType(const TrkResult &result) @@ -504,18 +529,14 @@ void Launcher::installRemotePackageSilently(const QString &fileName) void Launcher::handleInstallPackageFinished(const TrkResult &) { - if (d->m_fileName.isEmpty()) - emit finished(); - else + if (d->m_startupActions & ActionRun) startInferiorIfNeeded(); + else + emit finished(); } void Launcher::startInferiorIfNeeded() { - if (d->m_fileName.isEmpty()) { - d->m_device.sendTrkMessage(TrkPing, TrkCallback(this, &Launcher::waitForTrkFinished)); - return; - } emit startingApplication(); if (d->m_session.pid != 0) { logMessage("Process already 'started'"); diff --git a/src/shared/trk/launcher.h b/src/shared/trk/launcher.h index 9a33a57dbf7593122b0cbfa86652e46d2254b3fb..0af92a81e80af4ce855ad7ea27561141f5b556c1 100644 --- a/src/shared/trk/launcher.h +++ b/src/shared/trk/launcher.h @@ -44,8 +44,20 @@ class Launcher : public QObject public: typedef void (Launcher::*TrkCallBack)(const TrkResult &); - Launcher(); + enum Actions { + ActionPingOnly = 0x0, + ActionCopy = 0x1, + ActionInstall = 0x2, + ActionCopyInstall = ActionCopy | ActionInstall, + ActionRun = 0x4, + ActionCopyRun = ActionCopy | ActionRun, + ActionInstallRun = ActionInstall | ActionRun, + ActionCopyInstallRun = ActionCopy | ActionInstall | ActionRun + }; + + Launcher(trk::Launcher::Actions startupActions = trk::Launcher::ActionPingOnly); ~Launcher(); + void addStartupActions(trk::Launcher::Actions startupActions); void setTrkServerName(const QString &name); void setFileName(const QString &name); void setCopyFileName(const QString &srcName, const QString &dstName); @@ -93,7 +105,6 @@ private: void copyFileToRemote(); void installRemotePackageSilently(const QString &filename); - void installAndRun(); void startInferiorIfNeeded(); void logMessage(const QString &msg); diff --git a/tests/manual/trklauncher/main.cpp b/tests/manual/trklauncher/main.cpp index b888e6bf25fc0029e8a29ae43fb5eff6bdc87e7b..65031e7cc5aab100945db92aa3708553f0f11a6f 100644 --- a/tests/manual/trklauncher/main.cpp +++ b/tests/manual/trklauncher/main.cpp @@ -50,9 +50,11 @@ static bool parseArguments(const QStringList &arguments, trk::Launcher &launcher break;verbosity++; case 'i': install = true; + launcher.addStartupActions(trk::Launcher::ActionInstall); break; case 'I': customInstall = true; + launcher.addStartupActions(trk::Launcher::ActionCopyInstall); break; default: return false; @@ -68,23 +70,28 @@ static bool parseArguments(const QStringList &arguments, trk::Launcher &launcher } if (remainingArgsCount == 2 && !install && !customInstall) { // remote exec - launcher.setTrkServerName(arguments.at(a)); // ping + launcher.addStartupActions(trk::Launcher::ActionRun); + launcher.setTrkServerName(arguments.at(a)); launcher.setFileName(arguments.at(a + 1)); return true; } if ((remainingArgsCount == 3 || remainingArgsCount == 2) && install && !customInstall) { launcher.setTrkServerName(arguments.at(a)); // ping launcher.setInstallFileName(arguments.at(a + 1)); - if (remainingArgsCount == 3) + if (remainingArgsCount == 3) { + launcher.addStartupActions(trk::Launcher::ActionRun); launcher.setFileName(arguments.at(a + 2)); + } return true; } if ((remainingArgsCount == 4 || remainingArgsCount == 3) && !install && customInstall) { launcher.setTrkServerName(arguments.at(a)); // ping launcher.setCopyFileName(arguments.at(a + 1), arguments.at(a + 2)); launcher.setInstallFileName(arguments.at(a + 2)); - if (remainingArgsCount == 4) + if (remainingArgsCount == 4) { + launcher.addStartupActions(trk::Launcher::ActionRun); launcher.setFileName(arguments.at(a + 3)); + } return true; } return false;