1 /**
2  * SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com>
3  *
4  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
5  */
6 
7 #ifndef KDECONNECTPLUGIN_H
8 #define KDECONNECTPLUGIN_H
9 
10 #include <QObject>
11 #include <QVariantList>
12 #include <kcoreaddons_version.h>
13 
14 #include "kdeconnectcore_export.h"
15 #include "kdeconnectpluginconfig.h"
16 #include "networkpacket.h"
17 #include "device.h"
18 
19 #if KCOREADDONS_VERSION < QT_VERSION_CHECK(5,44,0)
20 #define K_PLUGIN_CLASS_WITH_JSON(classname,jsonFile) K_PLUGIN_FACTORY_WITH_JSON(classname ## Factory, jsonFile, registerPlugin<classname >();)
21 #endif
22 
23 struct KdeConnectPluginPrivate;
24 
25 class KDECONNECTCORE_EXPORT KdeConnectPlugin
26     : public QObject
27 {
28     Q_OBJECT
29 
30 public:
31     KdeConnectPlugin(QObject* parent, const QVariantList& args);
32     ~KdeConnectPlugin() override;
33 
34     const Device* device();
35     Device const* device() const;
36 
37     bool sendPacket(NetworkPacket& np) const;
38 
39     KdeConnectPluginConfig* config() const;
40 
41     virtual QString dbusPath() const;
42 
43     QString iconName() const;
44 
45 public Q_SLOTS:
46     /**
47      * Returns true if it has handled the packet in some way
48      * device.sendPacket can be used to send an answer back to the device
49      */
50     virtual bool receivePacket(const NetworkPacket& np) = 0;
51 
52     /**
53      * This method will be called when a device is connected to this computer.
54      * The plugin could be loaded already, but there is no guarantee we will be able to reach the device until this is called.
55      */
56     virtual void connected() = 0;
57 
58 private:
59     QScopedPointer<KdeConnectPluginPrivate> d;
60 
61 };
62 
63 #endif
64