2002-08-02 23:57:46 +04:00
|
|
|
/*
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
|
|
|
* Copyright (C) 2002 Chris Schoeneman
|
|
|
|
*
|
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* found in the file COPYING that should have accompanied this file.
|
|
|
|
*
|
|
|
|
* This package is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2002-07-11 00:18:32 +04:00
|
|
|
#ifndef CSERVERPROXY_H
|
|
|
|
#define CSERVERPROXY_H
|
|
|
|
|
2004-02-15 20:32:11 +03:00
|
|
|
#include "ClipboardTypes.h"
|
2003-02-22 18:03:31 +03:00
|
|
|
#include "KeyTypes.h"
|
2004-02-15 20:32:11 +03:00
|
|
|
#include "CEvent.h"
|
2002-07-11 00:18:32 +04:00
|
|
|
|
2004-02-15 20:32:11 +03:00
|
|
|
class CClient;
|
|
|
|
class CClientInfo;
|
|
|
|
class CEventQueueTimer;
|
|
|
|
class IClipboard;
|
|
|
|
class IStream;
|
2002-07-11 00:18:32 +04:00
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Proxy for server
|
|
|
|
/*!
|
|
|
|
This class acts a proxy for the server, converting calls into messages
|
|
|
|
to the server and messages from the server to calls on the client.
|
|
|
|
*/
|
2004-02-15 20:32:11 +03:00
|
|
|
class CServerProxy {
|
2002-07-11 00:18:32 +04:00
|
|
|
public:
|
2004-02-15 20:32:11 +03:00
|
|
|
/*!
|
|
|
|
Process messages from the server on \p stream and forward to
|
|
|
|
\p client.
|
2002-07-30 18:59:36 +04:00
|
|
|
*/
|
2004-02-15 20:32:11 +03:00
|
|
|
CServerProxy(CClient* client, IStream* stream);
|
2002-07-11 00:18:32 +04:00
|
|
|
~CServerProxy();
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! @name manipulators
|
|
|
|
//@{
|
2002-07-11 00:18:32 +04:00
|
|
|
|
2004-02-28 15:19:49 +03:00
|
|
|
void onInfoChanged();
|
|
|
|
bool onGrabClipboard(ClipboardID);
|
|
|
|
void onClipboardChanged(ClipboardID, const IClipboard*);
|
2002-07-11 00:18:32 +04:00
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//@}
|
|
|
|
|
2004-02-28 15:19:49 +03:00
|
|
|
protected:
|
|
|
|
enum EResult { kOkay, kUnknown, kDisconnect };
|
|
|
|
EResult parseHandshakeMessage(const UInt8* code);
|
|
|
|
EResult parseMessage(const UInt8* code);
|
|
|
|
|
2002-07-11 00:18:32 +04:00
|
|
|
private:
|
|
|
|
// if compressing mouse motion then send the last motion now
|
|
|
|
void flushCompressedMouse();
|
|
|
|
|
|
|
|
void sendInfo(const CClientInfo&);
|
|
|
|
|
2004-02-15 20:32:11 +03:00
|
|
|
void installHeartBeat(double);
|
|
|
|
|
2003-02-22 18:03:31 +03:00
|
|
|
// modifier key translation
|
|
|
|
KeyID translateKey(KeyID) const;
|
|
|
|
KeyModifierMask translateModifierMask(KeyModifierMask) const;
|
|
|
|
|
2004-02-15 20:32:11 +03:00
|
|
|
// event handlers
|
2004-02-28 15:19:49 +03:00
|
|
|
void handleData(const CEvent&, void*);
|
2004-02-15 20:32:11 +03:00
|
|
|
void handleHeartBeat(const CEvent&, void*);
|
|
|
|
|
2002-07-11 00:18:32 +04:00
|
|
|
// message handlers
|
|
|
|
void enter();
|
|
|
|
void leave();
|
|
|
|
void setClipboard();
|
|
|
|
void grabClipboard();
|
|
|
|
void keyDown();
|
|
|
|
void keyRepeat();
|
|
|
|
void keyUp();
|
|
|
|
void mouseDown();
|
|
|
|
void mouseUp();
|
|
|
|
void mouseMove();
|
2004-05-02 12:03:49 +04:00
|
|
|
void mouseRelativeMove();
|
2002-07-11 00:18:32 +04:00
|
|
|
void mouseWheel();
|
2002-07-14 02:00:38 +04:00
|
|
|
void screensaver();
|
2002-12-23 17:47:44 +03:00
|
|
|
void resetOptions();
|
|
|
|
void setOptions();
|
2002-07-11 00:18:32 +04:00
|
|
|
void queryInfo();
|
|
|
|
void infoAcknowledgment();
|
|
|
|
|
|
|
|
private:
|
2004-02-28 15:19:49 +03:00
|
|
|
typedef EResult (CServerProxy::*MessageParser)(const UInt8*);
|
|
|
|
|
2004-02-15 20:32:11 +03:00
|
|
|
CClient* m_client;
|
|
|
|
IStream* m_stream;
|
|
|
|
CEventQueueTimer* m_timer;
|
2002-07-11 00:18:32 +04:00
|
|
|
|
2002-07-11 01:22:28 +04:00
|
|
|
UInt32 m_seqNum;
|
|
|
|
|
2002-07-11 00:18:32 +04:00
|
|
|
bool m_compressMouse;
|
2004-05-02 12:03:49 +04:00
|
|
|
bool m_compressMouseRelative;
|
2002-07-11 00:18:32 +04:00
|
|
|
SInt32 m_xMouse, m_yMouse;
|
2004-05-02 12:03:49 +04:00
|
|
|
SInt32 m_dxMouse, m_dyMouse;
|
2002-07-11 00:18:32 +04:00
|
|
|
|
|
|
|
bool m_ignoreMouse;
|
2003-02-22 18:03:31 +03:00
|
|
|
|
|
|
|
KeyModifierID m_modifierTranslationTable[kKeyModifierIDLast];
|
2003-02-22 19:20:23 +03:00
|
|
|
double m_heartRate;
|
2004-02-15 20:32:11 +03:00
|
|
|
|
2004-02-28 15:19:49 +03:00
|
|
|
MessageParser m_parser;
|
2002-07-11 00:18:32 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|