Deskflow 1.24.0.365
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 Symless 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
12#include "deskflow/KeyTypes.h"
14
15class Client;
16class ClientInfo;
17class EventQueueTimer;
18class IClipboard;
19namespace deskflow {
20class IStream;
21}
22class IEventQueue;
23
25
30{
31public:
36 ServerProxy(Client *client, deskflow::IStream *stream, IEventQueue *events);
37 ServerProxy(ServerProxy const &) = delete;
40
41 ServerProxy &operator=(ServerProxy const &) = delete;
43
45
46
47 void onInfoChanged();
50
52
53protected:
60 ConnectionResult parseHandshakeMessage(const uint8_t *code);
61 ConnectionResult parseMessage(const uint8_t *code);
62
63private:
64 // if compressing mouse motion then send the last motion now
65 void flushCompressedMouse();
66
67 void sendInfo(const ClientInfo &);
68
69 void resetKeepAliveAlarm();
70 void setKeepAliveRate(double);
71
72 // modifier key translation
73 KeyID translateKey(KeyID) const;
74 KeyModifierMask translateModifierMask(KeyModifierMask) const;
75
76 // event handlers
77 void handleData();
78 void handleKeepAliveAlarm();
79
80 // message handlers
81 void enter();
82 void leave();
83 void setClipboard();
84 void grabClipboard();
85 void keyDown(uint16_t id, uint16_t mask, uint16_t button, const std::string &lang);
86 void keyRepeat();
87 void keyUp();
88 void mouseDown();
89 void mouseUp();
90 void mouseMove();
91 void mouseRelativeMove();
92 void mouseWheel();
93 void screensaver();
94 void resetOptions();
95 void setOptions();
96 void queryInfo();
97 void infoAcknowledgment();
98 void secureInputNotification();
99 void setServerLanguages();
100 void setActiveServerLanguage(const std::string_view &language);
101 void checkMissedLanguages() const;
102
103private:
104 using MessageParser = ConnectionResult (ServerProxy::*)(const uint8_t *);
105
106 Client *m_client = nullptr;
107 deskflow::IStream *m_stream = nullptr;
108
109 uint32_t m_seqNum = 0;
110
111 bool m_compressMouse = false;
112 bool m_compressMouseRelative = false;
113 int32_t m_xMouse = 0;
114 int32_t m_yMouse = 0;
115 int32_t m_dxMouse = 0;
116 int32_t m_dyMouse = 0;
117
118 bool m_ignoreMouse = false;
119
120 KeyModifierID m_modifierTranslationTable[kKeyModifierIDLast];
121
122 double m_keepAliveAlarm = 0.0;
123 EventQueueTimer *m_keepAliveAlarmTimer = nullptr;
124
125 MessageParser m_parser = &ServerProxy::parseHandshakeMessage;
126 IEventQueue *m_events = nullptr;
127 std::string m_serverLanguage = "";
128 bool m_isUserNotifiedAboutLanguageSyncError = false;
129 deskflow::languages::LanguageManager m_languageManager;
130};
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:1324
Deskflow client.
Definition Client.h:41
Definition EventQueueTimer.h:12
Clipboard interface.
Definition IClipboard.h:19
Event queue interface.
Definition IEventQueue.h:29
Proxy for server.
Definition ServerProxy.h:30
ConnectionResult parseMessage(const uint8_t *code)
Definition ServerProxy.cpp:200
ConnectionResult
Definition ServerProxy.h:55
@ Okay
Definition ServerProxy.h:56
@ Disconnect
Definition ServerProxy.h:58
@ Unknown
Definition ServerProxy.h:57
void onClipboardChanged(ClipboardID, const IClipboard *)
Definition ServerProxy.cpp:352
ServerProxy(ServerProxy const &)=delete
ServerProxy(ServerProxy &&)=delete
bool onGrabClipboard(ClipboardID)
Definition ServerProxy.cpp:345
ServerProxy(Client *client, deskflow::IStream *stream, IEventQueue *events)
Definition ServerProxy.cpp:29
ServerProxy & operator=(ServerProxy const &)=delete
ServerProxy & operator=(ServerProxy &&)=delete
ConnectionResult parseHandshakeMessage(const uint8_t *code)
Definition ServerProxy.cpp:124
~ServerProxy()
Definition ServerProxy.cpp:53
void onInfoChanged()
Definition ServerProxy.cpp:335
Bidirectional stream interface.
Definition IStream.h:22
Definition LanguageManager.h:15
Definition EventTypes.h:11