File indexing completed on 2024-04-21 04:56:49

0001 /**
0002  * SPDX-FileCopyrightText: 2021 Piyush Aggarwal <piyushaggarwal002@gmail.com>
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 #include <QObject>
0010 
0011 #include <core/kdeconnectplugin.h>
0012 
0013 #define PACKET_TYPE_LOCK QStringLiteral("kdeconnect.lock")
0014 #define PACKET_TYPE_LOCK_REQUEST QStringLiteral("kdeconnect.lock.request")
0015 
0016 class LockDevicePlugin : public KdeConnectPlugin
0017 {
0018     Q_OBJECT
0019     Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.lockdevice")
0020     Q_PROPERTY(bool isLocked READ isLocked WRITE setLocked NOTIFY lockedChanged)
0021 
0022 public:
0023     explicit LockDevicePlugin(QObject *parent, const QVariantList &args);
0024 
0025     bool isLocked() const;
0026     Q_SCRIPTABLE void setLocked(bool);
0027 
0028     QString dbusPath() const override;
0029     void connected() override;
0030     void receivePacket(const NetworkPacket &np) override;
0031 
0032 Q_SIGNALS:
0033     Q_SCRIPTABLE void lockedChanged(bool locked);
0034 
0035 private:
0036     void sendState();
0037 
0038     bool m_remoteLocked = false;
0039     bool m_localLocked = false;
0040 };