diff options
Diffstat (limited to 'tools/runonphone')
-rw-r--r-- | tools/runonphone/main.cpp | 3 | ||||
-rw-r--r-- | tools/runonphone/trk/launcher.cpp | 47 | ||||
-rw-r--r-- | tools/runonphone/trk/launcher.h | 5 |
3 files changed, 33 insertions, 22 deletions
diff --git a/tools/runonphone/main.cpp b/tools/runonphone/main.cpp index c7fc43f..77bd809 100644 --- a/tools/runonphone/main.cpp +++ b/tools/runonphone/main.cpp @@ -72,7 +72,7 @@ int main(int argc, char *argv[]) QString serialPortFriendlyName; QString sisFile; QString exeFile; - QString cmdLine; + QStringList cmdLine; QStringList args = QCoreApplication::arguments(); QTextStream outstream(stdout); QTextStream errstream(stderr); @@ -124,7 +124,6 @@ int main(int argc, char *argv[]) i++; for(;i<args.size();i++) { cmdLine.append(args.at(i)); - if(i + 1 < args.size()) cmdLine.append(' '); } } } diff --git a/tools/runonphone/trk/launcher.cpp b/tools/runonphone/trk/launcher.cpp index 8f150c6..1655aaf 100644 --- a/tools/runonphone/trk/launcher.cpp +++ b/tools/runonphone/trk/launcher.cpp @@ -76,7 +76,7 @@ struct LauncherPrivate { CopyState m_copyState; QString m_fileName; - QString m_commandLineArgs; + QStringList m_commandLineArgs; QString m_installFileName; int m_verbose; Launcher::Actions m_startupActions; @@ -159,7 +159,7 @@ void Launcher::setInstallFileName(const QString &name) d->m_installFileName = name; } -void Launcher::setCommandLineArgs(const QString &args) +void Launcher::setCommandLineArgs(const QStringList &args) { d->m_commandLineArgs = args; } @@ -189,8 +189,10 @@ bool Launcher::startServer(QString *errorMessage) { errorMessage->clear(); if (d->m_verbose) { - const QString msg = QString::fromLatin1("Port=%1 Executable=%2 Package=%3 Remote Package=%4 Install file=%5") - .arg(d->m_trkServerName, d->m_fileName, d->m_copyState.sourceFileName, d->m_copyState.destinationFileName, d->m_installFileName); + const QString msg = QString::fromLatin1("Port=%1 Executable=%2 Arguments=%3 Package=%4 Remote Package=%5 Install file=%6") + .arg(d->m_trkServerName, d->m_fileName, + d->m_commandLineArgs.join(QString(QLatin1Char(' '))), + d->m_copyState.sourceFileName, d->m_copyState.destinationFileName, d->m_installFileName); logMessage(msg); } if (d->m_startupActions & ActionCopy) { @@ -681,28 +683,35 @@ void Launcher::handleInstallPackageFinished(const TrkResult &result) } } -void Launcher::startInferiorIfNeeded() +QByteArray Launcher::startProcessMessage(const QString &executable, + const QStringList &arguments) { - emit startingApplication(); - if (d->m_session.pid != 0) { - logMessage("Process already 'started'"); - return; - } // It's not started yet QByteArray ba; appendShort(&ba, 0, TargetByteOrder); // create new process appendByte(&ba, 0); // options - currently unused + if(arguments.isEmpty()) { + appendString(&ba, executable.toLocal8Bit(), TargetByteOrder); + return ba; + } + // Append full command line as one string (leading length information). + QByteArray commandLineBa; + commandLineBa.append(executable.toLocal8Bit()); + commandLineBa.append('\0'); + commandLineBa.append(arguments.join(QString(QLatin1Char(' '))).toLocal8Bit()); + appendString(&ba, commandLineBa, TargetByteOrder); + return ba; +} - if(d->m_commandLineArgs.isEmpty()) { - appendString(&ba, d->m_fileName.toLocal8Bit(), TargetByteOrder); - } else { - QByteArray ba2; - ba2.append(d->m_fileName.toLocal8Bit()); - ba2.append('\0'); - ba2.append(d->m_commandLineArgs.toLocal8Bit()); - appendString(&ba, ba2, TargetByteOrder); +void Launcher::startInferiorIfNeeded() +{ + emit startingApplication(); + if (d->m_session.pid != 0) { + logMessage("Process already 'started'"); + return; } - d->m_device->sendTrkMessage(TrkCreateItem, TrkCallback(this, &Launcher::handleCreateProcess), ba); // Create Item + d->m_device->sendTrkMessage(TrkCreateItem, TrkCallback(this, &Launcher::handleCreateProcess), + startProcessMessage(d->m_fileName, d->m_commandLineArgs)); // Create Item } void Launcher::resume(uint pid, uint tid) diff --git a/tools/runonphone/trk/launcher.h b/tools/runonphone/trk/launcher.h index 5dded53..472f234 100644 --- a/tools/runonphone/trk/launcher.h +++ b/tools/runonphone/trk/launcher.h @@ -95,7 +95,7 @@ public: void setFileName(const QString &name); void setCopyFileName(const QString &srcName, const QString &dstName); void setInstallFileName(const QString &name); - void setCommandLineArgs(const QString &args); + void setCommandLineArgs(const QStringList &args); bool startServer(QString *errorMessage); void setVerbose(int v); void setSerialFrame(bool b); @@ -109,6 +109,9 @@ public: // becomes valid after successful execution of ActionPingOnly QString deviceDescription(unsigned verbose = 0u) const; + static QByteArray startProcessMessage(const QString &executable, + const QStringList &arguments); + signals: void copyingStarted(); void canNotConnect(const QString &errorMessage); |