Simplify KDEConnectPlugin::recievePacket

- We do not need the return type. If a plugin declares it can handle the
  packet it should do so. We don't have any fallback logic in place and
  the packet types are namespaced with the plugin IDs anyway.

- Provide a default implementation with a warning, not all plugins need
  to overwrite this
This commit is contained in:
Alexander Lohnau
2023-07-31 09:25:45 +02:00
parent 2edc139522
commit 1631ada5b3
77 changed files with 106 additions and 206 deletions

View File

@@ -37,11 +37,11 @@ RunCommandPlugin::RunCommandPlugin(QObject *parent, const QVariantList &args)
connect(config(), &KdeConnectPluginConfig::configChanged, this, &RunCommandPlugin::sendConfig);
}
bool RunCommandPlugin::receivePacket(const NetworkPacket &np)
void RunCommandPlugin::receivePacket(const NetworkPacket &np)
{
if (np.get<bool>(QStringLiteral("requestCommandList"), false)) {
sendConfig();
return true;
return;
}
if (np.has(QStringLiteral("key"))) {
@@ -59,13 +59,10 @@ bool RunCommandPlugin::receivePacket(const NetworkPacket &np)
#else
QProcess::startDetached(QStringLiteral(COMMAND), QStringList{QStringLiteral(ARGS), commandJson[QStringLiteral("command")].toString()});
#endif
return true;
} else if (np.has(QStringLiteral("setup"))) {
OpenConfig oc;
oc.openConfiguration(device()->id(), QStringLiteral("kdeconnect_runcommand"));
}
return false;
}
void RunCommandPlugin::connected()