• Main Page
  • Classes
  • Files
  • File List

CServerProxy.h

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2012 Bolton Software Ltd.
00004  * Copyright (C) 2002 Chris Schoeneman
00005  * 
00006  * This package is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * found in the file COPYING that should have accompanied this file.
00009  * 
00010  * This package is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
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     // if compressing mouse motion then send the last motion now
00070     void                flushCompressedMouse();
00071 
00072     void                sendInfo(const CClientInfo&);
00073 
00074     void                resetKeepAliveAlarm();
00075     void                setKeepAliveRate(double);
00076 
00077     // modifier key translation
00078     KeyID               translateKey(KeyID) const;
00079     KeyModifierMask         translateModifierMask(KeyModifierMask) const;
00080 
00081     // event handlers
00082     void                handleData(const CEvent&, void*);
00083     void                handleKeepAliveAlarm(const CEvent&, void*);
00084 
00085     // message handlers
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

Generated on Fri May 24 2013 00:00:04 for Synergy by  doxygen 1.7.1