[runcommand] Add windows support
Summary: Added windows support to the runcommand plugin Completes T10001 Test Plan: 1. Run a command 2. Run the command Reviewers: #kde_connect, nicolasfella, albertvaka Reviewed By: #kde_connect, albertvaka Subscribers: albertvaka, shivanshukantprasad, apol, nicolasfella, kdeconnect, #kde_connect Tags: #kde_connect, #windows Differential Revision: https://phabricator.kde.org/D16746
This commit is contained in:
parent
7bfebd581f
commit
f0486e16c9
2 changed files with 13 additions and 3 deletions
|
@ -20,8 +20,8 @@ if(NOT SAILFISHOS)
|
|||
add_subdirectory(telephony)
|
||||
add_subdirectory(mousepad)
|
||||
add_subdirectory(sms)
|
||||
add_subdirectory(runcommand)
|
||||
if(NOT WIN32)
|
||||
add_subdirectory(runcommand)
|
||||
add_subdirectory(pausemusic)
|
||||
add_subdirectory(screensaver-inhibit)
|
||||
add_subdirectory(sftp)
|
||||
|
|
|
@ -36,6 +36,16 @@
|
|||
|
||||
#define PACKET_TYPE_RUNCOMMAND QStringLiteral("kdeconnect.runcommand")
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#define COMMAND "cmd"
|
||||
#define ARGS "/c"
|
||||
|
||||
#else
|
||||
#define COMMAND "/bin/sh"
|
||||
#define ARGS "-c"
|
||||
|
||||
#endif
|
||||
|
||||
K_PLUGIN_FACTORY_WITH_JSON( KdeConnectPluginFactory, "kdeconnect_runcommand.json", registerPlugin< RunCommandPlugin >(); )
|
||||
|
||||
Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_RUNCOMMAND, "kdeconnect.plugin.runcommand")
|
||||
|
@ -66,8 +76,8 @@ bool RunCommandPlugin::receivePacket(const NetworkPacket& np)
|
|||
qCWarning(KDECONNECT_PLUGIN_RUNCOMMAND) << key << "is not a configured command";
|
||||
}
|
||||
const QJsonObject commandJson = value.toObject();
|
||||
qCInfo(KDECONNECT_PLUGIN_RUNCOMMAND) << "Running:" << "/bin/sh" << "-c" << commandJson[QStringLiteral("command")].toString();
|
||||
QProcess::startDetached(QStringLiteral("/bin/sh"), QStringList()<< QStringLiteral("-c") << commandJson[QStringLiteral("command")].toString());
|
||||
qCInfo(KDECONNECT_PLUGIN_RUNCOMMAND) << "Running:" << COMMAND << ARGS << commandJson[QStringLiteral("command")].toString();
|
||||
QProcess::startDetached(QStringLiteral(COMMAND), QStringList()<< QStringLiteral(ARGS) << commandJson[QStringLiteral("command")].toString());
|
||||
return true;
|
||||
} else if (np.has("setup")) {
|
||||
QProcess::startDetached(QStringLiteral("kcmshell5"), {QStringLiteral("kdeconnect"), QStringLiteral("--args"), QString(device()->id() + QStringLiteral(":kdeconnect_runcommand")) });
|
||||
|
|
Loading…
Reference in a new issue