Deskflow 1.26.0.314
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 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"
16
17class Client;
18class ClientInfo;
19class EventQueueTimer;
20class IClipboard;
21namespace deskflow {
22class IStream;
23}
24class IEventQueue;
25
27
32{
33public:
38 ServerProxy(Client *client, deskflow::IStream *stream, IEventQueue *events);
39 ServerProxy(ServerProxy const &) = delete;
42
43 ServerProxy &operator=(ServerProxy const &) = delete;
45
47
48
49 void onInfoChanged();
52
54
55protected:
62 ConnectionResult parseHandshakeMessage(const uint8_t *code);
63 ConnectionResult parseMessage(const uint8_t *code);
64
65private:
66 // if compressing mouse motion then send the last motion now
67 void flushCompressedMouse();
68
69 void sendInfo(const ClientInfo &);
70
71 void resetKeepAliveAlarm();
72 void setKeepAliveRate(double);
73
74 // modifier key translation
75 KeyID translateKey(KeyID) const;
76 KeyModifierMask translateModifierMask(KeyModifierMask) const;
77
78 // event handlers
79 void handleData();
80 void handleKeepAliveAlarm();
81 void requestDisconnect(const char *message);
82 void requestRefuseConnection(deskflow::core::ConnectionRefusal reason, const char *message);
83
84 // message handlers
85 void enter();
86 void leave();
87 void setClipboard();
88 void grabClipboard();
89 void keyDown(uint16_t id, uint16_t mask, uint16_t button, const std::string &lang);
90 void keyRepeat();
91 void keyUp();
92 void mouseDown();
93 void mouseUp();
94 void mouseMove();
95 void mouseRelativeMove();
96 void mouseWheel();
97 void screensaver();
98 void resetOptions();
99 void setOptions();
100 void queryInfo();
101 void infoAcknowledgment();
102 void secureInputNotification();
103 void setServerLanguages();
104 void setActiveServerLanguage(const std::string_view &language);
105
106private:
107 using MessageParser = ConnectionResult (ServerProxy::*)(const uint8_t *);
108
109 Client *m_client = nullptr;
110 deskflow::IStream *m_stream = nullptr;
111
112 uint32_t m_seqNum = 0;
113
114 bool m_compressMouse = false;
115 bool m_compressMouseRelative = false;
116 int32_t m_xMouse = 0;
117 int32_t m_yMouse = 0;
118 int32_t m_dxMouse = 0;
119 int32_t m_dyMouse = 0;
120
121 bool m_ignoreMouse = false;
122
123 KeyModifierID m_modifierTranslationTable[kKeyModifierIDLast];
124
125 double m_keepAliveAlarm = 0.0;
126 EventQueueTimer *m_keepAliveAlarmTimer = nullptr;
127
128 MessageParser m_parser = &ServerProxy::parseHandshakeMessage;
129 IEventQueue *m_events = nullptr;
130 std::string m_serverLayout = "";
131 std::string m_clipboardDataCached;
132 ClipboardChunkAssemblyState m_clipboardChunkState;
133 bool m_isUserNotifiedAboutLayoutSyncError = false;
134 deskflow::KeyboardLayoutManager m_layoutManager;
135};
uint8_t ClipboardID
Clipboard ID.
Definition ClipboardTypes.h:16
uint32_t KeyID
Key ID.
Definition KeyTypes.h:21
static const KeyModifierID kKeyModifierIDLast
Definition KeyTypes.h:96
uint32_t KeyModifierID
Modifier key ID.
Definition KeyTypes.h:54
uint32_t KeyModifierMask
Modifier key mask.
Definition KeyTypes.h:44
Client screen information structure.
Definition ProtocolTypes.h:1304
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.
Definition ServerProxy.h:32
ConnectionResult parseMessage(const uint8_t *code)
Definition ServerProxy.cpp:208
ConnectionResult
Definition ServerProxy.h:57
@ Okay
Definition ServerProxy.h:58
@ Disconnect
Definition ServerProxy.h:60
@ Unknown
Definition ServerProxy.h:59
void onClipboardChanged(ClipboardID, const IClipboard *)
Definition ServerProxy.cpp:375
ServerProxy(ServerProxy const &)=delete
ServerProxy(ServerProxy &&)=delete
bool onGrabClipboard(ClipboardID)
Definition ServerProxy.cpp:368
ServerProxy(Client *client, deskflow::IStream *stream, IEventQueue *events)
Definition ServerProxy.cpp:30
ServerProxy & operator=(ServerProxy const &)=delete
ServerProxy & operator=(ServerProxy &&)=delete
ConnectionResult parseHandshakeMessage(const uint8_t *code)
Definition ServerProxy.cpp:126
~ServerProxy()
Definition ServerProxy.cpp:54
void onInfoChanged()
Definition ServerProxy.cpp:358
Bidirectional stream interface.
Definition IStream.h:22
Definition KeyboardLayoutManager.h:15
ConnectionRefusal
Definition Enums.h:48
Definition DaemonApp.h:18
Definition ClipboardChunk.h:23