Commit 670647b8 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

trk: Add support for command line arguments in trk::Launcher.


Initial-patch-by: default avatarShane Kearns <shane.kearns@sosco.com>
parent e10a07d8
......@@ -64,6 +64,7 @@ struct LauncherPrivate {
CopyState m_copyState;
QString m_fileName;
QStringList m_commandLineArgs;
QString m_installFileName;
int m_verbose;
Launcher::Actions m_startupActions;
......@@ -146,6 +147,11 @@ void Launcher::setInstallFileName(const QString &name)
d->m_installFileName = name;
}
void Launcher::setCommandLineArgs(const QStringList &args)
{
d->m_commandLineArgs = args;
}
void Launcher::setSerialFrame(bool b)
{
d->m_device->setSerialFrame(b);
......@@ -171,8 +177,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) {
......@@ -647,6 +655,26 @@ void Launcher::handleInstallPackageFinished(const TrkResult &result)
}
}
QByteArray Launcher::startProcessMessage(const QString &executable,
const QStringList &arguments)
{
// 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;
}
void Launcher::startInferiorIfNeeded()
{
emit startingApplication();
......@@ -654,12 +682,7 @@ void Launcher::startInferiorIfNeeded()
logMessage("Process already 'started'");
return;
}
// It's not started yet
QByteArray ba;
appendByte(&ba, 0); // ?
appendByte(&ba, 0); // create new process
appendByte(&ba, 0); // ?
appendString(&ba, d->m_fileName.toLocal8Bit(), TargetByteOrder);
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
}
} // namespace trk
......@@ -82,6 +82,7 @@ public:
void setFileName(const QString &name);
void setCopyFileName(const QString &srcName, const QString &dstName);
void setInstallFileName(const QString &name);
void setCommandLineArgs(const QStringList &args);
bool startServer(QString *errorMessage);
void setVerbose(int v);
void setSerialFrame(bool b);
......@@ -95,6 +96,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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment