File indexing completed on 2024-04-28 08:49:10

0001 /**
0002  * SPDX-FileCopyrightText: 2016 Aleix Pol Gonzalez <aleixpol@kde.org>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #pragma once
0008 
0009 class QObject;
0010 
0011 #include <QString>
0012 #include <core/kdeconnectplugin.h>
0013 
0014 class RemoteCommandsPlugin : public KdeConnectPlugin
0015 {
0016     Q_OBJECT
0017     Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.remotecommands")
0018     Q_PROPERTY(QByteArray commands READ commands NOTIFY commandsChanged)
0019     Q_PROPERTY(QString deviceId READ deviceId CONSTANT)
0020     Q_PROPERTY(bool canAddCommand READ canAddCommand CONSTANT)
0021 
0022 public:
0023     explicit RemoteCommandsPlugin(QObject *parent, const QVariantList &args);
0024 
0025     Q_SCRIPTABLE void triggerCommand(const QString &key);
0026     Q_SCRIPTABLE void editCommands();
0027 
0028     QByteArray commands() const
0029     {
0030         return m_commands;
0031     }
0032     QString deviceId() const
0033     {
0034         return device()->id();
0035     }
0036     bool canAddCommand() const
0037     {
0038         return m_canAddCommand;
0039     }
0040 
0041     void receivePacket(const NetworkPacket &np) override;
0042     void connected() override;
0043     QString dbusPath() const override;
0044 
0045 Q_SIGNALS:
0046     Q_SCRIPTABLE void commandsChanged(const QByteArray &commands);
0047 
0048 private:
0049     void setCommands(const QByteArray &commands);
0050 
0051     QByteArray m_commands;
0052     bool m_canAddCommand;
0053 };