From 9bbaea4318dd41c9e2fd27fbc1eeec931e372d4f Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 21 Jan 2010 16:05:13 +0100 Subject: Merge from upstream The patch accepted upstream changed a parameter from QString to QStringList. So there is a corresponding change to main.cpp to use the new API. commit b1291ecfd0ab31c41783feb645c98ce42fa87aae Author: Friedemann Kleint Date: Thu Jan 21 12:33:34 2010 +0100 trk: Add support for command line arguments in trk::Launcher. Initial-patch-by: Shane Kearns Task-number: QTBUG-7444 --- tools/runonphone/main.cpp | 3 +-- tools/runonphone/trk/launcher.cpp | 47 +++++++++++++++++++++++---------------- 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(;im_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); -- cgit v0.12