Changeset View
Changeset View
Standalone View
Standalone View
core/backends/devicelink.h
Show All 18 Lines | |||||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #ifndef DEVICELINK_H | 21 | #ifndef DEVICELINK_H | ||
22 | #define DEVICELINK_H | 22 | #define DEVICELINK_H | ||
23 | 23 | | |||
24 | #include <QObject> | 24 | #include <QObject> | ||
25 | #include <QtCrypto> | 25 | #include <QtCrypto> | ||
26 | 26 | | |||
27 | #include "core/networkpackage.h" | 27 | #include "core/networkpacket.h" | ||
28 | 28 | | |||
29 | class PairingHandler; | 29 | class PairingHandler; | ||
30 | class NetworkPackage; | 30 | class NetworkPacket; | ||
31 | class LinkProvider; | 31 | class LinkProvider; | ||
32 | class Device; | 32 | class Device; | ||
33 | 33 | | |||
34 | class DeviceLink | 34 | class DeviceLink | ||
35 | : public QObject | 35 | : public QObject | ||
36 | { | 36 | { | ||
37 | Q_OBJECT | 37 | Q_OBJECT | ||
38 | 38 | | |||
39 | public: | 39 | public: | ||
40 | enum PairStatus { NotPaired, Paired }; | 40 | enum PairStatus { NotPaired, Paired }; | ||
41 | 41 | | |||
42 | DeviceLink(const QString& deviceId, LinkProvider* parent); | 42 | DeviceLink(const QString& deviceId, LinkProvider* parent); | ||
43 | virtual ~DeviceLink() = default; | 43 | virtual ~DeviceLink() = default; | ||
44 | 44 | | |||
45 | virtual QString name() = 0; | 45 | virtual QString name() = 0; | ||
46 | 46 | | |||
47 | const QString& deviceId() const { return m_deviceId; } | 47 | const QString& deviceId() const { return m_deviceId; } | ||
48 | LinkProvider* provider() { return m_linkProvider; } | 48 | LinkProvider* provider() { return m_linkProvider; } | ||
49 | 49 | | |||
50 | virtual bool sendPackage(NetworkPackage& np) = 0; | 50 | virtual bool sendPacket(NetworkPacket& np) = 0; | ||
51 | 51 | | |||
52 | //user actions | 52 | //user actions | ||
53 | virtual void userRequestsPair() = 0; | 53 | virtual void userRequestsPair() = 0; | ||
54 | virtual void userRequestsUnpair() = 0; | 54 | virtual void userRequestsUnpair() = 0; | ||
55 | 55 | | |||
56 | PairStatus pairStatus() const { return m_pairStatus; } | 56 | PairStatus pairStatus() const { return m_pairStatus; } | ||
57 | virtual void setPairStatus(PairStatus status); | 57 | virtual void setPairStatus(PairStatus status); | ||
58 | 58 | | |||
59 | //The daemon will periodically destroy unpaired links if this returns false | 59 | //The daemon will periodically destroy unpaired links if this returns false | ||
60 | virtual bool linkShouldBeKeptAlive() { return false; } | 60 | virtual bool linkShouldBeKeptAlive() { return false; } | ||
61 | 61 | | |||
62 | Q_SIGNALS: | 62 | Q_SIGNALS: | ||
63 | void pairingRequest(PairingHandler* handler); | 63 | void pairingRequest(PairingHandler* handler); | ||
64 | void pairingRequestExpired(PairingHandler* handler); | 64 | void pairingRequestExpired(PairingHandler* handler); | ||
65 | void pairStatusChanged(DeviceLink::PairStatus status); | 65 | void pairStatusChanged(DeviceLink::PairStatus status); | ||
66 | void pairingError(const QString& error); | 66 | void pairingError(const QString& error); | ||
67 | void receivedPackage(const NetworkPackage& np); | 67 | void receivedPacket(const NetworkPacket& np); | ||
68 | 68 | | |||
69 | protected: | 69 | protected: | ||
70 | QCA::PrivateKey m_privateKey; | 70 | QCA::PrivateKey m_privateKey; | ||
71 | 71 | | |||
72 | private: | 72 | private: | ||
73 | const QString m_deviceId; | 73 | const QString m_deviceId; | ||
74 | LinkProvider* m_linkProvider; | 74 | LinkProvider* m_linkProvider; | ||
75 | PairStatus m_pairStatus; | 75 | PairStatus m_pairStatus; | ||
76 | 76 | | |||
77 | }; | 77 | }; | ||
78 | 78 | | |||
79 | #endif | 79 | #endif |