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