Changeset View
Changeset View
Standalone View
Standalone View
plugins/clipboard/clipboardplugin.h
Show All 21 Lines | |||||
22 | #define CLIPBOARDPLUGIN_H | 22 | #define CLIPBOARDPLUGIN_H | ||
23 | 23 | | |||
24 | #include <QObject> | 24 | #include <QObject> | ||
25 | #include <QClipboard> | 25 | #include <QClipboard> | ||
26 | #include <QLoggingCategory> | 26 | #include <QLoggingCategory> | ||
27 | #include <core/kdeconnectplugin.h> | 27 | #include <core/kdeconnectplugin.h> | ||
28 | 28 | | |||
29 | Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_PLUGIN_CLIPBOARD) | 29 | Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_PLUGIN_CLIPBOARD) | ||
30 | | ||||
31 | /** | ||||
32 | * Packet containing just clipboard contents, sent when a device updates its clipboard. | ||||
33 | * <p> | ||||
34 | * The body should look like so: | ||||
35 | * { | ||||
36 | * "content": "password" | ||||
37 | * } | ||||
38 | */ | ||||
30 | #define PACKET_TYPE_CLIPBOARD QStringLiteral("kdeconnect.clipboard") | 39 | #define PACKET_TYPE_CLIPBOARD QStringLiteral("kdeconnect.clipboard") | ||
31 | 40 | | |||
41 | /** | ||||
42 | * Packet containing clipboard contents and a timestamp that the contents were last updated, sent | ||||
43 | * on first connection | ||||
44 | * <p> | ||||
45 | * The timestamp is milliseconds since epoch. It can be 0, which indicates that the clipboard | ||||
46 | * update time is currently unknown. | ||||
47 | * <p> | ||||
48 | * The body should look like so: | ||||
49 | * { | ||||
50 | * "timestamp": 542904563213, | ||||
51 | * "content": "password" | ||||
52 | * } | ||||
53 | */ | ||||
54 | #define PACKET_TYPE_CLIPBOARD_CONNECT QStringLiteral("kdeconnect.clipboard.connect") | ||||
55 | | ||||
32 | class ClipboardPlugin | 56 | class ClipboardPlugin | ||
33 | : public KdeConnectPlugin | 57 | : public KdeConnectPlugin | ||
34 | { | 58 | { | ||
35 | Q_OBJECT | 59 | Q_OBJECT | ||
36 | 60 | | |||
37 | public: | 61 | public: | ||
38 | explicit ClipboardPlugin(QObject* parent, const QVariantList& args); | 62 | explicit ClipboardPlugin(QObject* parent, const QVariantList& args); | ||
39 | 63 | | |||
40 | bool receivePacket(const NetworkPacket& np) override; | 64 | bool receivePacket(const NetworkPacket& np) override; | ||
41 | void connected() override { } | 65 | void connected() override; | ||
42 | | ||||
43 | private Q_SLOTS: | 66 | private Q_SLOTS: | ||
44 | void propagateClipboard(const QString& content); | 67 | void propagateClipboard(const QString& content); | ||
68 | void sendConnectPacket(); | ||||
45 | 69 | | |||
46 | }; | 70 | }; | ||
47 | 71 | | |||
48 | #endif | 72 | #endif |