CServerProxy.h

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2002 Chris Schoeneman
00004  * 
00005  * This package is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * found in the file COPYING that should have accompanied this file.
00008  * 
00009  * This package is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
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     // if compressing mouse motion then send the last motion now
00058     void                flushCompressedMouse();
00059 
00060     void                sendInfo(const CClientInfo&);
00061 
00062     void                resetKeepAliveAlarm();
00063     void                setKeepAliveRate(double);
00064 
00065     // modifier key translation
00066     KeyID               translateKey(KeyID) const;
00067     KeyModifierMask     translateModifierMask(KeyModifierMask) const;
00068 
00069     // event handlers
00070     void                handleData(const CEvent&, void*);
00071     void                handleKeepAliveAlarm(const CEvent&, void*);
00072 
00073     // message handlers
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

Generated on Fri Nov 6 00:18:45 2009 for synergy-plus by  doxygen 1.4.7