00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CSERVERPROXY_H
00016 #define CSERVERPROXY_H
00017
00018 #include "ClipboardTypes.h"
00019 #include "KeyTypes.h"
00020 #include "CEvent.h"
00021
00022 class CClient;
00023 class CClientInfo;
00024 class CEventQueueTimer;
00025 class IClipboard;
00026 class IStream;
00027
00029
00033 class CServerProxy {
00034 public:
00039 CServerProxy(CClient* client, IStream* stream);
00040 ~CServerProxy();
00041
00043
00044
00045 void onInfoChanged();
00046 bool onGrabClipboard(ClipboardID);
00047 void onClipboardChanged(ClipboardID, const IClipboard*);
00048
00050
00051 protected:
00052 enum EResult { kOkay, kUnknown, kDisconnect };
00053 EResult parseHandshakeMessage(const UInt8* code);
00054 EResult parseMessage(const UInt8* code);
00055
00056 private:
00057
00058 void flushCompressedMouse();
00059
00060 void sendInfo(const CClientInfo&);
00061
00062 void resetKeepAliveAlarm();
00063 void setKeepAliveRate(double);
00064
00065
00066 KeyID translateKey(KeyID) const;
00067 KeyModifierMask translateModifierMask(KeyModifierMask) const;
00068
00069
00070 void handleData(const CEvent&, void*);
00071 void handleKeepAliveAlarm(const CEvent&, void*);
00072
00073
00074 void enter();
00075 void leave();
00076 void setClipboard();
00077 void grabClipboard();
00078 void keyDown();
00079 void keyRepeat();
00080 void keyUp();
00081 void mouseDown();
00082 void mouseUp();
00083 void mouseMove();
00084 void mouseRelativeMove();
00085 void mouseWheel();
00086 void screensaver();
00087 void resetOptions();
00088 void setOptions();
00089 void queryInfo();
00090 void infoAcknowledgment();
00091
00092 private:
00093 typedef EResult (CServerProxy::*MessageParser)(const UInt8*);
00094
00095 CClient* m_client;
00096 IStream* m_stream;
00097
00098 UInt32 m_seqNum;
00099
00100 bool m_compressMouse;
00101 bool m_compressMouseRelative;
00102 SInt32 m_xMouse, m_yMouse;
00103 SInt32 m_dxMouse, m_dyMouse;
00104
00105 bool m_ignoreMouse;
00106
00107 KeyModifierID m_modifierTranslationTable[kKeyModifierIDLast];
00108
00109 double m_keepAliveAlarm;
00110 CEventQueueTimer* m_keepAliveAlarmTimer;
00111
00112 MessageParser m_parser;
00113 };
00114
00115 #endif