1 | /*
|
---|
2 | * synergy -- mouse and keyboard sharing utility
|
---|
3 | * Copyright (C) 2002 Chris Schoeneman
|
---|
4 | *
|
---|
5 | * This package is free software; you can redistribute it and/or
|
---|
6 | * modify it under the terms of the GNU General Public License
|
---|
7 | * found in the file COPYING that should have accompanied this file.
|
---|
8 | *
|
---|
9 | * This package is distributed in the hope that it will be useful,
|
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | * GNU General Public License for more details.
|
---|
13 | */
|
---|
14 |
|
---|
15 | #ifndef CSERVERPROXY_H
|
---|
16 | #define CSERVERPROXY_H
|
---|
17 |
|
---|
18 | #include "ClipboardTypes.h"
|
---|
19 | #include "KeyTypes.h"
|
---|
20 | #include "CEvent.h"
|
---|
21 |
|
---|
22 | class CClient;
|
---|
23 | class CClientInfo;
|
---|
24 | class CEventQueueTimer;
|
---|
25 | class IClipboard;
|
---|
26 | class IStream;
|
---|
27 |
|
---|
28 | //! Proxy for server
|
---|
29 | /*!
|
---|
30 | This class acts a proxy for the server, converting calls into messages
|
---|
31 | to the server and messages from the server to calls on the client.
|
---|
32 | */
|
---|
33 | class CServerProxy {
|
---|
34 | public:
|
---|
35 | /*!
|
---|
36 | Process messages from the server on \p stream and forward to
|
---|
37 | \p client.
|
---|
38 | */
|
---|
39 | CServerProxy(CClient* client, IStream* stream);
|
---|
40 | ~CServerProxy();
|
---|
41 |
|
---|
42 | //! @name manipulators
|
---|
43 | //@{
|
---|
44 |
|
---|
45 | void onInfoChanged();
|
---|
46 | bool onGrabClipboard(ClipboardID);
|
---|
47 | void onClipboardChanged(ClipboardID, const IClipboard*);
|
---|
48 |
|
---|
49 | //@}
|
---|
50 |
|
---|
51 | protected:
|
---|
52 | enum EResult { kOkay, kUnknown, kDisconnect };
|
---|
53 | EResult parseHandshakeMessage(const UInt8* code);
|
---|
54 | EResult parseMessage(const UInt8* code);
|
---|
55 |
|
---|
56 | private:
|
---|
57 | // if compressing mouse motion then send the last motion now
|
---|
58 | void flushCompressedMouse();
|
---|
59 |
|
---|
60 | void sendInfo(const CClientInfo&);
|
---|
61 |
|
---|
62 | void resetKeepAliveAlarm();
|
---|
63 | void setKeepAliveRate(double);
|
---|
64 |
|
---|
65 | // modifier key translation
|
---|
66 | KeyID translateKey(KeyID) const;
|
---|
67 | KeyModifierMask translateModifierMask(KeyModifierMask) const;
|
---|
68 |
|
---|
69 | // event handlers
|
---|
70 | void handleData(const CEvent&, void*);
|
---|
71 | void handleKeepAliveAlarm(const CEvent&, void*);
|
---|
72 |
|
---|
73 | // message handlers
|
---|
74 | void enter();
|
---|
75 | void leave();
|
---|
76 | void setClipboard();
|
---|
77 | void grabClipboard();
|
---|
78 | void keyDown();
|
---|
79 | void keyRepeat();
|
---|
80 | void keyUp();
|
---|
81 | void mouseDown();
|
---|
82 | void mouseUp();
|
---|
83 | void mouseMove();
|
---|
84 | void mouseRelativeMove();
|
---|
85 | void mouseWheel();
|
---|
86 | void screensaver();
|
---|
87 | void resetOptions();
|
---|
88 | void setOptions();
|
---|
89 | void queryInfo();
|
---|
90 | void infoAcknowledgment();
|
---|
91 |
|
---|
92 | private:
|
---|
93 | typedef EResult (CServerProxy::*MessageParser)(const UInt8*);
|
---|
94 |
|
---|
95 | CClient* m_client;
|
---|
96 | IStream* m_stream;
|
---|
97 |
|
---|
98 | UInt32 m_seqNum;
|
---|
99 |
|
---|
100 | bool m_compressMouse;
|
---|
101 | bool m_compressMouseRelative;
|
---|
102 | SInt32 m_xMouse, m_yMouse;
|
---|
103 | SInt32 m_dxMouse, m_dyMouse;
|
---|
104 |
|
---|
105 | bool m_ignoreMouse;
|
---|
106 |
|
---|
107 | KeyModifierID m_modifierTranslationTable[kKeyModifierIDLast];
|
---|
108 |
|
---|
109 | double m_keepAliveAlarm;
|
---|
110 | CEventQueueTimer* m_keepAliveAlarmTimer;
|
---|
111 |
|
---|
112 | MessageParser m_parser;
|
---|
113 | };
|
---|
114 |
|
---|
115 | #endif
|
---|