Changeset View
Changeset View
Standalone View
Standalone View
plugins/runcommand/runcommandplugin.cpp
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 59 | if (np.has(QStringLiteral("key"))) { | |||
---|---|---|---|---|---|
63 | QJsonValue value = commands[key]; | 63 | QJsonValue value = commands[key]; | ||
64 | if (value == QJsonValue::Undefined) { | 64 | if (value == QJsonValue::Undefined) { | ||
65 | qCWarning(KDECONNECT_PLUGIN_RUNCOMMAND) << key << "is not a configured command"; | 65 | qCWarning(KDECONNECT_PLUGIN_RUNCOMMAND) << key << "is not a configured command"; | ||
66 | } | 66 | } | ||
67 | const QJsonObject commandJson = value.toObject(); | 67 | const QJsonObject commandJson = value.toObject(); | ||
68 | qCInfo(KDECONNECT_PLUGIN_RUNCOMMAND) << "Running:" << "/bin/sh" << "-c" << commandJson[QStringLiteral("command")].toString(); | 68 | qCInfo(KDECONNECT_PLUGIN_RUNCOMMAND) << "Running:" << "/bin/sh" << "-c" << commandJson[QStringLiteral("command")].toString(); | ||
69 | QProcess::startDetached(QStringLiteral("/bin/sh"), QStringList()<< QStringLiteral("-c") << commandJson[QStringLiteral("command")].toString()); | 69 | QProcess::startDetached(QStringLiteral("/bin/sh"), QStringList()<< QStringLiteral("-c") << commandJson[QStringLiteral("command")].toString()); | ||
70 | return true; | 70 | return true; | ||
71 | } else if (np.has("setup")) { | ||||
72 | QProcess::startDetached(QStringLiteral("kcmshell5"), {QStringLiteral("kdeconnect"), QStringLiteral("--args"), QString(device()->id() + QStringLiteral(":kdeconnect_runcommand")) }); | ||||
nicolasfella: Why not separate by space instead of ':'? Would simplify the logic above | |||||
apol: How would it be simpler? Look closer :p | |||||
Sorry, what I actually meant was passing them in two args instead of one. In bash that would be separating them by space, hence my confusing statement nicolasfella: Sorry, what I actually meant was passing them in two args instead of one. In bash that would be… | |||||
Ah, we are only getting one string from the --args kcmshell argument, there's not a whole lot we can do there. apol: Ah, we are only getting one string from the --args kcmshell argument, there's not a whole lot… | |||||
71 | } | 73 | } | ||
72 | 74 | | |||
73 | return false; | 75 | return false; | ||
74 | } | 76 | } | ||
75 | 77 | | |||
76 | void RunCommandPlugin::connected() | 78 | void RunCommandPlugin::connected() | ||
77 | { | 79 | { | ||
78 | 80 | | |||
79 | sendConfig(); | 81 | sendConfig(); | ||
80 | } | 82 | } | ||
81 | 83 | | |||
82 | void RunCommandPlugin::sendConfig() | 84 | void RunCommandPlugin::sendConfig() | ||
83 | { | 85 | { | ||
84 | QString commands = config()->get<QString>(QStringLiteral("commands"),QStringLiteral("{}")); | 86 | QString commands = config()->get<QString>(QStringLiteral("commands"),QStringLiteral("{}")); | ||
85 | NetworkPacket np(PACKET_TYPE_RUNCOMMAND, {{"commandList", commands}}); | 87 | NetworkPacket np(PACKET_TYPE_RUNCOMMAND, {{"commandList", commands}}); | ||
88 | np.set<bool>(QStringLiteral("canAddCommand"), true); | ||||
86 | sendPacket(np); | 89 | sendPacket(np); | ||
87 | } | 90 | } | ||
88 | 91 | | |||
89 | void RunCommandPlugin::configChanged() { | 92 | void RunCommandPlugin::configChanged() { | ||
90 | sendConfig(); | 93 | sendConfig(); | ||
91 | } | 94 | } | ||
92 | 95 | | |||
93 | #include "runcommandplugin.moc" | 96 | #include "runcommandplugin.moc" |
Why not separate by space instead of ':'? Would simplify the logic above