2002-08-02 19:57:46 +00: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-10 20:18:32 +00:00
|
|
|
#ifndef CSERVERPROXY_H
|
|
|
|
#define CSERVERPROXY_H
|
|
|
|
|
2002-07-10 21:22:28 +00:00
|
|
|
#include "IScreenReceiver.h"
|
2002-07-10 20:18:32 +00:00
|
|
|
#include "CMutex.h"
|
|
|
|
|
|
|
|
class IClient;
|
|
|
|
class IInputStream;
|
|
|
|
class IOutputStream;
|
|
|
|
|
2002-07-30 14:59:36 +00: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.
|
|
|
|
*/
|
2002-07-10 21:22:28 +00:00
|
|
|
class CServerProxy : public IScreenReceiver {
|
2002-07-10 20:18:32 +00:00
|
|
|
public:
|
2002-07-30 14:59:36 +00:00
|
|
|
/*! \c adoptedInput is the stream from the server and
|
|
|
|
\c adoptedOutput is the stream to the server. This object
|
|
|
|
takes ownership of both and destroys them in the d'tor.
|
|
|
|
Messages from the server are converted to calls on \c client.
|
|
|
|
*/
|
2002-07-10 20:18:32 +00:00
|
|
|
CServerProxy(IClient* client,
|
|
|
|
IInputStream* adoptedInput,
|
|
|
|
IOutputStream* adoptedOutput);
|
|
|
|
~CServerProxy();
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! @name manipulators
|
|
|
|
//@{
|
2002-07-10 20:18:32 +00:00
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Run event loop
|
|
|
|
/*!
|
|
|
|
Run the event loop and return when the server disconnects or
|
|
|
|
requests the client to disconnect. Return true iff the server
|
|
|
|
didn't reject our connection.
|
|
|
|
|
|
|
|
(cancellation point)
|
|
|
|
*/
|
2002-07-30 15:17:44 +00:00
|
|
|
bool mainLoop();
|
2002-07-10 20:18:32 +00:00
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//@}
|
|
|
|
//! @name accessors
|
|
|
|
//@{
|
2002-07-10 20:18:32 +00:00
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Get client
|
|
|
|
/*!
|
|
|
|
Returns the client passed to the c'tor.
|
|
|
|
*/
|
2002-07-10 20:18:32 +00:00
|
|
|
IClient* getClient() const;
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Get input stream
|
|
|
|
/*!
|
|
|
|
Return the input stream passed to the c'tor.
|
|
|
|
*/
|
2002-07-10 20:18:32 +00:00
|
|
|
IInputStream* getInputStream() const;
|
2002-07-30 14:59:36 +00:00
|
|
|
|
|
|
|
//! Get output stream
|
|
|
|
/*!
|
|
|
|
Return the output stream passed to the c'tor.
|
|
|
|
*/
|
2002-07-10 20:18:32 +00:00
|
|
|
IOutputStream* getOutputStream() const;
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//@}
|
|
|
|
|
2002-07-10 21:22:28 +00:00
|
|
|
// IScreenReceiver overrides
|
2002-07-16 16:52:26 +00:00
|
|
|
virtual void onError();
|
2002-07-10 21:22:28 +00:00
|
|
|
virtual void onInfoChanged(const CClientInfo&);
|
|
|
|
virtual bool onGrabClipboard(ClipboardID);
|
|
|
|
virtual void onClipboardChanged(ClipboardID, const CString& data);
|
2002-07-10 20:18:32 +00:00
|
|
|
|
|
|
|
private:
|
2002-07-30 14:59:36 +00:00
|
|
|
|
|
|
|
// get the client name (from the client)
|
|
|
|
CString getName() const;
|
|
|
|
|
2002-07-10 20:18:32 +00:00
|
|
|
// if compressing mouse motion then send the last motion now
|
|
|
|
void flushCompressedMouse();
|
|
|
|
|
|
|
|
void sendInfo(const CClientInfo&);
|
|
|
|
|
|
|
|
// message handlers
|
|
|
|
void enter();
|
|
|
|
void leave();
|
|
|
|
void setClipboard();
|
|
|
|
void grabClipboard();
|
|
|
|
void keyDown();
|
|
|
|
void keyRepeat();
|
|
|
|
void keyUp();
|
|
|
|
void mouseDown();
|
|
|
|
void mouseUp();
|
|
|
|
void mouseMove();
|
|
|
|
void mouseWheel();
|
2002-07-13 22:00:38 +00:00
|
|
|
void screensaver();
|
2002-12-23 14:47:44 +00:00
|
|
|
void resetOptions();
|
|
|
|
void setOptions();
|
2002-07-10 20:18:32 +00:00
|
|
|
void queryInfo();
|
|
|
|
void infoAcknowledgment();
|
|
|
|
|
|
|
|
private:
|
|
|
|
CMutex m_mutex;
|
|
|
|
|
|
|
|
IClient* m_client;
|
|
|
|
IInputStream* m_input;
|
|
|
|
IOutputStream* m_output;
|
|
|
|
|
2002-07-10 21:22:28 +00:00
|
|
|
UInt32 m_seqNum;
|
|
|
|
|
2002-07-10 20:18:32 +00:00
|
|
|
bool m_compressMouse;
|
|
|
|
SInt32 m_xMouse, m_yMouse;
|
|
|
|
|
|
|
|
bool m_ignoreMouse;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|