runcommand: avoid using cmd to allow better handling of quoted arguments
This commit is contained in:
parent
153bc22788
commit
3b7d51dc80
1 changed files with 4 additions and 7 deletions
|
@ -29,16 +29,9 @@
|
||||||
|
|
||||||
#define PACKET_TYPE_RUNCOMMAND QStringLiteral("kdeconnect.runcommand")
|
#define PACKET_TYPE_RUNCOMMAND QStringLiteral("kdeconnect.runcommand")
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
#define COMMAND "cmd"
|
|
||||||
#define ARGS "/c"
|
|
||||||
|
|
||||||
#else
|
|
||||||
#define COMMAND "/bin/sh"
|
#define COMMAND "/bin/sh"
|
||||||
#define ARGS "-c"
|
#define ARGS "-c"
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
K_PLUGIN_CLASS_WITH_JSON(RunCommandPlugin, "kdeconnect_runcommand.json")
|
K_PLUGIN_CLASS_WITH_JSON(RunCommandPlugin, "kdeconnect_runcommand.json")
|
||||||
|
|
||||||
RunCommandPlugin::RunCommandPlugin(QObject* parent, const QVariantList& args)
|
RunCommandPlugin::RunCommandPlugin(QObject* parent, const QVariantList& args)
|
||||||
|
@ -68,7 +61,11 @@ bool RunCommandPlugin::receivePacket(const NetworkPacket& np)
|
||||||
}
|
}
|
||||||
const QJsonObject commandJson = value.toObject();
|
const QJsonObject commandJson = value.toObject();
|
||||||
qCInfo(KDECONNECT_PLUGIN_RUNCOMMAND) << "Running:" << COMMAND << ARGS << commandJson[QStringLiteral("command")].toString();
|
qCInfo(KDECONNECT_PLUGIN_RUNCOMMAND) << "Running:" << COMMAND << ARGS << commandJson[QStringLiteral("command")].toString();
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
QProcess::startDetached(commandJson[QStringLiteral("command")].toString());
|
||||||
|
#else
|
||||||
QProcess::startDetached(QStringLiteral(COMMAND), QStringList()<< QStringLiteral(ARGS) << commandJson[QStringLiteral("command")].toString());
|
QProcess::startDetached(QStringLiteral(COMMAND), QStringList()<< QStringLiteral(ARGS) << commandJson[QStringLiteral("command")].toString());
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
} else if (np.has(QStringLiteral("setup"))) {
|
} else if (np.has(QStringLiteral("setup"))) {
|
||||||
Daemon::instance()->openConfiguration(device()->id(), QStringLiteral("kdeconnect_runcommand"));
|
Daemon::instance()->openConfiguration(device()->id(), QStringLiteral("kdeconnect_runcommand"));
|
||||||
|
|
Loading…
Reference in a new issue