barrier/client/CClient.h

102 lines
2.9 KiB
C
Raw Normal View History

2001-10-06 18:13:28 +04:00
#ifndef CCLIENT_H
#define CCLIENT_H
2002-07-11 01:22:28 +04:00
#include "IScreenReceiver.h"
#include "IClient.h"
#include "IClipboard.h"
#include "CNetworkAddress.h"
#include "CMutex.h"
2001-10-06 18:13:28 +04:00
class CSecondaryScreen;
class CServerProxy;
class CThread;
class IDataSocket;
2002-07-11 01:22:28 +04:00
class IScreenReceiver;
2001-10-06 18:13:28 +04:00
2002-07-11 01:22:28 +04:00
class CClient : public IScreenReceiver, public IClient {
2002-04-29 18:40:01 +04:00
public:
2001-10-06 18:13:28 +04:00
CClient(const CString& clientName);
~CClient();
// manipulators
// turn camping on or off. when camping the client will keep
// trying to connect to the server until it succeeds. this
// is useful if the client may start before the server. do
// not call this while in run().
void camp(bool on);
// set the server's address that the client should connect to
void setAddress(const CNetworkAddress& serverAddress);
2001-10-06 18:13:28 +04:00
2002-06-21 21:55:47 +04:00
// tell client to exit run() gracefully. this must only be called
// after a successful open().
void quit();
2001-10-06 18:13:28 +04:00
// accessors
// returns true if the server rejected us
bool wasRejected() const;
2002-07-11 01:22:28 +04:00
// IScreenReceiver overrides
virtual void onInfoChanged(const CClientInfo&);
virtual bool onGrabClipboard(ClipboardID);
virtual void onClipboardChanged(ClipboardID, const CString&);
// IClient overrides
virtual bool open();
virtual void run();
virtual void close();
2002-07-11 01:22:28 +04:00
// FIXME -- can we avoid passing everything here?
virtual void enter(SInt32 xAbs, SInt32 yAbs,
UInt32 seqNum, KeyModifierMask mask,
bool forScreensaver);
virtual bool leave();
virtual void setClipboard(ClipboardID, const CString&);
virtual void grabClipboard(ClipboardID);
virtual void setClipboardDirty(ClipboardID, bool dirty);
virtual void keyDown(KeyID, KeyModifierMask);
virtual void keyRepeat(KeyID, KeyModifierMask, SInt32 count);
virtual void keyUp(KeyID, KeyModifierMask);
virtual void mouseDown(ButtonID);
virtual void mouseUp(ButtonID);
virtual void mouseMove(SInt32 xAbs, SInt32 yAbs);
virtual void mouseWheel(SInt32 delta);
virtual void screensaver(bool activate);
virtual CString getName() const;
virtual SInt32 getJumpZoneSize() const;
virtual void getShape(SInt32& x, SInt32& y,
SInt32& width, SInt32& height) const;
virtual void getCursorPos(SInt32& x, SInt32& y) const;
virtual void getCursorCenter(SInt32& x, SInt32& y) const;
2001-10-06 18:13:28 +04:00
2002-04-29 18:40:01 +04:00
private:
// open/close the secondary screen
void openSecondaryScreen();
void closeSecondaryScreen();
// send the clipboard to the server
void sendClipboard(ClipboardID);
// handle server messaging
void runSession(void*);
void deleteSession(CThread*);
void runServer();
CServerProxy* handshakeServer(IDataSocket*);
2001-10-06 18:13:28 +04:00
2002-04-29 18:40:01 +04:00
private:
CMutex m_mutex;
2001-10-06 18:13:28 +04:00
CString m_name;
CSecondaryScreen* m_screen;
2002-07-11 01:22:28 +04:00
IScreenReceiver* m_server;
CNetworkAddress m_serverAddress;
bool m_camp;
bool m_active;
bool m_rejected;
bool m_ownClipboard[kClipboardEnd];
IClipboard::Time m_timeClipboard[kClipboardEnd];
CString m_dataClipboard[kClipboardEnd];
2001-10-06 18:13:28 +04:00
};
#endif