00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CSERVERPROXY_H
00020 #define CSERVERPROXY_H
00021
00022 #include "ClipboardTypes.h"
00023 #include "KeyTypes.h"
00024 #include "CEvent.h"
00025 #include "GameDeviceTypes.h"
00026
00027 class CClient;
00028 class CClientInfo;
00029 class CEventQueueTimer;
00030 class IClipboard;
00031 namespace synergy { class IStream; }
00032 class IEventQueue;
00033
00035
00039 class CServerProxy {
00040 public:
00045 CServerProxy(CClient* client, synergy::IStream* stream, IEventQueue* eventQueue);
00046 ~CServerProxy();
00047
00049
00050
00051 void onInfoChanged();
00052 bool onGrabClipboard(ClipboardID);
00053 void onClipboardChanged(ClipboardID, const IClipboard*);
00054 void onGameDeviceTimingResp(UInt16 freq);
00055 void onGameDeviceFeedback(GameDeviceID id, UInt16 m1, UInt16 m2);
00056
00058
00059 #ifdef TEST_ENV
00060 void handleDataForTest() { handleData(CEvent(), NULL); }
00061 #endif
00062
00063 protected:
00064 enum EResult { kOkay, kUnknown, kDisconnect };
00065 EResult parseHandshakeMessage(const UInt8* code);
00066 EResult parseMessage(const UInt8* code);
00067
00068 private:
00069
00070 void flushCompressedMouse();
00071
00072 void sendInfo(const CClientInfo&);
00073
00074 void resetKeepAliveAlarm();
00075 void setKeepAliveRate(double);
00076
00077
00078 KeyID translateKey(KeyID) const;
00079 KeyModifierMask translateModifierMask(KeyModifierMask) const;
00080
00081
00082 void handleData(const CEvent&, void*);
00083 void handleKeepAliveAlarm(const CEvent&, void*);
00084
00085
00086 void enter();
00087 void leave();
00088 void setClipboard();
00089 void grabClipboard();
00090 void keyDown();
00091 void keyRepeat();
00092 void keyUp();
00093 void mouseDown();
00094 void mouseUp();
00095 void mouseMove();
00096 void mouseRelativeMove();
00097 void mouseWheel();
00098 void gameDeviceButtons();
00099 void gameDeviceSticks();
00100 void gameDeviceTriggers();
00101 void gameDeviceTimingReq();
00102 void cryptoIv();
00103 void screensaver();
00104 void resetOptions();
00105 void setOptions();
00106 void queryInfo();
00107 void infoAcknowledgment();
00108
00109 private:
00110 typedef EResult (CServerProxy::*MessageParser)(const UInt8*);
00111
00112 CClient* m_client;
00113 synergy::IStream* m_stream;
00114
00115 UInt32 m_seqNum;
00116
00117 bool m_compressMouse;
00118 bool m_compressMouseRelative;
00119 SInt32 m_xMouse, m_yMouse;
00120 SInt32 m_dxMouse, m_dyMouse;
00121
00122 bool m_ignoreMouse;
00123
00124 KeyModifierID m_modifierTranslationTable[kKeyModifierIDLast];
00125
00126 double m_keepAliveAlarm;
00127 CEventQueueTimer* m_keepAliveAlarmTimer;
00128
00129 MessageParser m_parser;
00130 IEventQueue* m_eventQueue;
00131 };
00132
00133 #endif