Deskflow 1.27.0.5
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
ServerProxy.h
Go to the documentation of this file.
1/*
2 * Deskflow -- mouse and keyboard sharing utility
3 * SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
4 * SPDX-FileCopyrightText: (C) 2012 - 2016, 2026 Synergy App Ltd
5 * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
6 * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
7 */
8
9#pragma once
10
11#include "common/Enums.h"
14#include "deskflow/KeyTypes.h"
15
16class Client;
17class ClientInfo;
18class EventQueueTimer;
19class IClipboard;
20namespace deskflow {
21class IStream;
22}
23class IEventQueue;
24
26
33{
34public:
39 ServerProxy(Client *client, deskflow::IStream *stream, IEventQueue *events);
40 ServerProxy(ServerProxy const &) = delete;
42 virtual ~ServerProxy();
43
44 ServerProxy &operator=(ServerProxy const &) = delete;
46
48
49
50 void onInfoChanged();
53
55
56protected:
58 {
59 Okay,
60 Unknown,
61 Disconnect
62 };
63
64 virtual ConnectionResult parseHandshakeMessage(const uint8_t *code);
65 virtual ConnectionResult parseMessage(const uint8_t *code);
66 void keyDown(uint16_t id, uint16_t mask, uint16_t button, const std::string &lang);
67 void keyRepeat(uint16_t id, uint16_t mask, uint16_t count, uint16_t button, const std::string &lang);
68
70 {
71 return m_stream;
72 }
73
74private:
75 // if compressing mouse motion then send the last motion now
76 void flushCompressedMouse();
77
78 void sendInfo(const ClientInfo &);
79
80 void resetKeepAliveAlarm();
81 void setKeepAliveRate(double);
82
83 // modifier key translation
84 KeyID translateKey(KeyID) const;
85 KeyModifierMask translateModifierMask(KeyModifierMask) const;
86
87 // event handlers
88 void handleData();
89 ConnectionResult handleMessage(const uint8_t *code);
90 void handleKeepAliveAlarm();
91 void requestDisconnect(const char *message);
92 void requestRefuseConnection(deskflow::core::ConnectionRefusal reason, const char *message);
93
94 // message handlers
95 void enter();
96 void leave();
97 void setClipboard();
98 void grabClipboard();
99 void keyUp();
100 void mouseDown();
101 void mouseUp();
102 void mouseMove();
103 void mouseRelativeMove();
104 void mouseWheel();
105 void screensaver();
106 void resetOptions();
107 void setOptions();
108 void queryInfo();
109 void infoAcknowledgment();
110
111private:
112 using MessageParser = ConnectionResult (ServerProxy::*)(const uint8_t *);
113
114 Client *m_client = nullptr;
115 deskflow::IStream *m_stream = nullptr;
116
117 uint32_t m_seqNum = 0;
118
119 bool m_compressMouse = false;
120 bool m_compressMouseRelative = false;
121 int32_t m_xMouse = 0;
122 int32_t m_yMouse = 0;
123 int32_t m_dxMouse = 0;
124 int32_t m_dyMouse = 0;
125
126 bool m_ignoreMouse = false;
127
128 KeyModifierID m_modifierTranslationTable[kKeyModifierIDLast];
129
130 double m_keepAliveAlarm = 0.0;
131 EventQueueTimer *m_keepAliveAlarmTimer = nullptr;
132
133 MessageParser m_parser = &ServerProxy::parseHandshakeMessage;
134 IEventQueue *m_events = nullptr;
135 std::string m_clipboardDataCached;
136 ClipboardChunkAssemblyState m_clipboardChunkState;
137};
uint8_t ClipboardID
Clipboard ID.
Definition ClipboardTypes.h:16
uint32_t KeyModifierID
Modifier key ID.
Definition KeyModifierID.h:20
uint32_t KeyID
Key ID.
Definition KeyTypes.h:22
uint32_t KeyModifierMask
Modifier key mask.
Definition KeyTypes.h:45
Client computer information structure.
Definition ProtocolTypes.h:1340
Deskflow client.
Definition Client.h:42
Definition EventQueueTimer.h:12
Clipboard interface.
Definition IClipboard.h:19
Event queue interface.
Definition IEventQueue.h:29
Proxy for server implementing protocol version 1.6.
Definition ServerProxy.h:33
virtual ConnectionResult parseMessage(const uint8_t *code)
Definition ServerProxy.cpp:216
ConnectionResult
Definition ServerProxy.h:58
void onClipboardChanged(ClipboardID, const IClipboard *)
Definition ServerProxy.cpp:365
ServerProxy(ServerProxy const &)=delete
ServerProxy(ServerProxy &&)=delete
bool onGrabClipboard(ClipboardID)
Definition ServerProxy.cpp:358
void keyDown(uint16_t id, uint16_t mask, uint16_t button, const std::string &lang)
Definition ServerProxy.cpp:577
ServerProxy(Client *client, deskflow::IStream *stream, IEventQueue *events)
Definition ServerProxy.cpp:29
ServerProxy & operator=(ServerProxy const &)=delete
void keyRepeat(uint16_t id, uint16_t mask, uint16_t count, uint16_t button, const std::string &lang)
Definition ServerProxy.cpp:589
ServerProxy & operator=(ServerProxy &&)=delete
virtual ConnectionResult parseHandshakeMessage(const uint8_t *code)
Definition ServerProxy.cpp:125
void onInfoChanged()
Definition ServerProxy.cpp:348
deskflow::IStream * getStream() const
Definition ServerProxy.h:69
Bidirectional stream interface.
Definition IStream.h:22
ConnectionRefusal
Definition Enums.h:48
Definition DaemonApp.h:18
Definition ClipboardChunk.h:23