Changeset View
Changeset View
Standalone View
Standalone View
core/device.h
Show All 21 Lines | |||||
22 | #define DEVICE_H | 22 | #define DEVICE_H | ||
23 | 23 | | |||
24 | #include <QObject> | 24 | #include <QObject> | ||
25 | #include <QString> | 25 | #include <QString> | ||
26 | #include <QVector> | 26 | #include <QVector> | ||
27 | #include <QSet> | 27 | #include <QSet> | ||
28 | #include <QHostAddress> | 28 | #include <QHostAddress> | ||
29 | 29 | | |||
30 | #include "networkpackage.h" | 30 | #include "networkpacket.h" | ||
31 | #include "backends/devicelink.h" | 31 | #include "backends/devicelink.h" | ||
32 | 32 | | |||
33 | class DeviceLink; | 33 | class DeviceLink; | ||
34 | class KdeConnectPlugin; | 34 | class KdeConnectPlugin; | ||
35 | 35 | | |||
36 | class KDECONNECTCORE_EXPORT Device | 36 | class KDECONNECTCORE_EXPORT Device | ||
37 | : public QObject | 37 | : public QObject | ||
38 | { | 38 | { | ||
Show All 25 Lines | 50 | public: | |||
64 | */ | 64 | */ | ||
65 | Device(QObject* parent, const QString& id); | 65 | Device(QObject* parent, const QString& id); | ||
66 | 66 | | |||
67 | /** | 67 | /** | ||
68 | * Device known via an incoming connection sent to us via a devicelink. | 68 | * Device known via an incoming connection sent to us via a devicelink. | ||
69 | * | 69 | * | ||
70 | * We know everything but we don't trust it yet | 70 | * We know everything but we don't trust it yet | ||
71 | */ | 71 | */ | ||
72 | Device(QObject* parent, const NetworkPackage& np, DeviceLink* dl); | 72 | Device(QObject* parent, const NetworkPacket& np, DeviceLink* dl); | ||
73 | 73 | | |||
74 | ~Device() override; | 74 | ~Device() override; | ||
75 | 75 | | |||
76 | QString id() const { return m_deviceId; } | 76 | QString id() const { return m_deviceId; } | ||
77 | QString name() const { return m_deviceName; } | 77 | QString name() const { return m_deviceName; } | ||
78 | QString dbusPath() const { return "/modules/kdeconnect/devices/"+id(); } | 78 | QString dbusPath() const { return "/modules/kdeconnect/devices/"+id(); } | ||
79 | QString type() const { return type2str(m_deviceType); } | 79 | QString type() const { return type2str(m_deviceType); } | ||
80 | QString iconName() const; | 80 | QString iconName() const; | ||
81 | QString statusIconName() const; | 81 | QString statusIconName() const; | ||
82 | Q_SCRIPTABLE QString encryptionInfo() const; | 82 | Q_SCRIPTABLE QString encryptionInfo() const; | ||
83 | 83 | | |||
84 | //Add and remove links | 84 | //Add and remove links | ||
85 | void addLink(const NetworkPackage& identityPackage, DeviceLink*); | 85 | void addLink(const NetworkPacket& identityPacket, DeviceLink*); | ||
86 | void removeLink(DeviceLink*); | 86 | void removeLink(DeviceLink*); | ||
87 | 87 | | |||
88 | Q_SCRIPTABLE bool isTrusted() const; | 88 | Q_SCRIPTABLE bool isTrusted() const; | ||
89 | 89 | | |||
90 | Q_SCRIPTABLE QStringList availableLinks() const; | 90 | Q_SCRIPTABLE QStringList availableLinks() const; | ||
91 | bool isReachable() const { return !m_deviceLinks.isEmpty(); } | 91 | bool isReachable() const { return !m_deviceLinks.isEmpty(); } | ||
92 | 92 | | |||
93 | Q_SCRIPTABLE QStringList loadedPlugins() const; | 93 | Q_SCRIPTABLE QStringList loadedPlugins() const; | ||
94 | Q_SCRIPTABLE bool hasPlugin(const QString& name) const; | 94 | Q_SCRIPTABLE bool hasPlugin(const QString& name) const; | ||
95 | 95 | | |||
96 | Q_SCRIPTABLE QString pluginsConfigFile() const; | 96 | Q_SCRIPTABLE QString pluginsConfigFile() const; | ||
97 | 97 | | |||
98 | KdeConnectPlugin* plugin(const QString& pluginName) const; | 98 | KdeConnectPlugin* plugin(const QString& pluginName) const; | ||
99 | Q_SCRIPTABLE void setPluginEnabled(const QString& pluginName, bool enabled); | 99 | Q_SCRIPTABLE void setPluginEnabled(const QString& pluginName, bool enabled); | ||
100 | Q_SCRIPTABLE bool isPluginEnabled(const QString& pluginName) const; | 100 | Q_SCRIPTABLE bool isPluginEnabled(const QString& pluginName) const; | ||
101 | 101 | | |||
102 | void cleanUnneededLinks(); | 102 | void cleanUnneededLinks(); | ||
103 | 103 | | |||
104 | int protocolVersion() { return m_protocolVersion; } | 104 | int protocolVersion() { return m_protocolVersion; } | ||
105 | QStringList supportedPlugins() const { return m_supportedPlugins.toList(); } | 105 | QStringList supportedPlugins() const { return m_supportedPlugins.toList(); } | ||
106 | 106 | | |||
107 | QHostAddress getLocalIpAddress() const; | 107 | QHostAddress getLocalIpAddress() const; | ||
108 | 108 | | |||
109 | public Q_SLOTS: | 109 | public Q_SLOTS: | ||
110 | ///sends a @p np package to the device | 110 | ///sends a @p np packet to the device | ||
111 | ///virtual for testing purposes. | 111 | ///virtual for testing purposes. | ||
112 | virtual bool sendPackage(NetworkPackage& np); | 112 | virtual bool sendPacket(NetworkPacket& np); | ||
113 | 113 | | |||
114 | //Dbus operations | 114 | //Dbus operations | ||
115 | public Q_SLOTS: | 115 | public Q_SLOTS: | ||
116 | Q_SCRIPTABLE void requestPair(); //to all links | 116 | Q_SCRIPTABLE void requestPair(); //to all links | ||
117 | Q_SCRIPTABLE void unpair(); //from all links | 117 | Q_SCRIPTABLE void unpair(); //from all links | ||
118 | Q_SCRIPTABLE void reloadPlugins(); //from kconf | 118 | Q_SCRIPTABLE void reloadPlugins(); //from kconf | ||
119 | 119 | | |||
120 | Q_SCRIPTABLE void acceptPairing(); | 120 | Q_SCRIPTABLE void acceptPairing(); | ||
121 | Q_SCRIPTABLE void rejectPairing(); | 121 | Q_SCRIPTABLE void rejectPairing(); | ||
122 | Q_SCRIPTABLE bool hasPairingRequests() const; | 122 | Q_SCRIPTABLE bool hasPairingRequests() const; | ||
123 | 123 | | |||
124 | private Q_SLOTS: | 124 | private Q_SLOTS: | ||
125 | void privateReceivedPackage(const NetworkPackage& np); | 125 | void privateReceivedPacket(const NetworkPacket& np); | ||
126 | void linkDestroyed(QObject* o); | 126 | void linkDestroyed(QObject* o); | ||
127 | void pairStatusChanged(DeviceLink::PairStatus current); | 127 | void pairStatusChanged(DeviceLink::PairStatus current); | ||
128 | void addPairingRequest(PairingHandler* handler); | 128 | void addPairingRequest(PairingHandler* handler); | ||
129 | void removePairingRequest(PairingHandler* handler); | 129 | void removePairingRequest(PairingHandler* handler); | ||
130 | 130 | | |||
131 | Q_SIGNALS: | 131 | Q_SIGNALS: | ||
132 | Q_SCRIPTABLE void pluginsChanged(); | 132 | Q_SCRIPTABLE void pluginsChanged(); | ||
133 | Q_SCRIPTABLE void reachableChanged(bool reachable); | 133 | Q_SCRIPTABLE void reachableChanged(bool reachable); | ||
Show All 31 Lines |