Changeset View
Changeset View
Standalone View
Standalone View
plugins/remotecommands/remotecommandsplugin.cpp
Show All 36 Lines | |||||
37 | 37 | | |||
38 | K_PLUGIN_FACTORY_WITH_JSON( KdeConnectPluginFactory, "kdeconnect_remotecommands.json", registerPlugin< RemoteCommandsPlugin >(); ) | 38 | K_PLUGIN_FACTORY_WITH_JSON( KdeConnectPluginFactory, "kdeconnect_remotecommands.json", registerPlugin< RemoteCommandsPlugin >(); ) | ||
39 | 39 | | |||
40 | Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_REMOTECOMMANDS, "kdeconnect.plugin.remotecommands") | 40 | Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_REMOTECOMMANDS, "kdeconnect.plugin.remotecommands") | ||
41 | 41 | | |||
42 | RemoteCommandsPlugin::RemoteCommandsPlugin(QObject* parent, const QVariantList& args) | 42 | RemoteCommandsPlugin::RemoteCommandsPlugin(QObject* parent, const QVariantList& args) | ||
43 | : KdeConnectPlugin(parent, args) | 43 | : KdeConnectPlugin(parent, args) | ||
44 | , m_commands("{}") | 44 | , m_commands("{}") | ||
45 | , m_canAddCommand(false) | ||||
45 | { | 46 | { | ||
46 | } | 47 | } | ||
47 | 48 | | |||
48 | RemoteCommandsPlugin::~RemoteCommandsPlugin() = default; | 49 | RemoteCommandsPlugin::~RemoteCommandsPlugin() = default; | ||
49 | 50 | | |||
50 | bool RemoteCommandsPlugin::receivePacket(const NetworkPacket& np) | 51 | bool RemoteCommandsPlugin::receivePacket(const NetworkPacket& np) | ||
51 | { | 52 | { | ||
52 | if (np.has(QStringLiteral("commandList"))) { | 53 | if (np.has(QStringLiteral("commandList"))) { | ||
54 | m_canAddCommand = np.get<bool>(QStringLiteral("canAddCommand")); | ||||
53 | setCommands(np.get<QByteArray>(QStringLiteral("commandList"))); | 55 | setCommands(np.get<QByteArray>(QStringLiteral("commandList"))); | ||
54 | return true; | 56 | return true; | ||
55 | } | 57 | } | ||
56 | 58 | | |||
57 | return false; | 59 | return false; | ||
58 | } | 60 | } | ||
59 | 61 | | |||
60 | void RemoteCommandsPlugin::connected() | 62 | void RemoteCommandsPlugin::connected() | ||
Show All 16 Lines | |||||
77 | } | 79 | } | ||
78 | 80 | | |||
79 | void RemoteCommandsPlugin::triggerCommand(const QString& key) | 81 | void RemoteCommandsPlugin::triggerCommand(const QString& key) | ||
80 | { | 82 | { | ||
81 | NetworkPacket np(PACKET_TYPE_RUNCOMMAND_REQUEST, {{ "key", key }}); | 83 | NetworkPacket np(PACKET_TYPE_RUNCOMMAND_REQUEST, {{ "key", key }}); | ||
82 | sendPacket(np); | 84 | sendPacket(np); | ||
83 | } | 85 | } | ||
84 | 86 | | |||
87 | void RemoteCommandsPlugin::editCommands() | ||||
88 | { | ||||
89 | NetworkPacket np(PACKET_TYPE_RUNCOMMAND_REQUEST, {{ "setup", true }}); | ||||
90 | sendPacket(np); | ||||
91 | } | ||||
92 | | ||||
85 | #include "remotecommandsplugin.moc" | 93 | #include "remotecommandsplugin.moc" |