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

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