Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

CClient.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 CCLIENT_H
00016 #define CCLIENT_H
00017 
00018 #include "IClient.h"
00019 #include "IClipboard.h"
00020 #include "CNetworkAddress.h"
00021 
00022 class CEventQueueTimer;
00023 class CScreen;
00024 class CServerProxy;
00025 class IDataSocket;
00026 class ISocketFactory;
00027 class IStream;
00028 class IStreamFilterFactory;
00029 
00031 
00034 class CClient : public IClient {
00035 public:
00036     class CFailInfo {
00037     public:
00038         bool            m_retry;
00039         char            m_what[1];
00040     };
00041 
00047     CClient(const CString& name, const CNetworkAddress& address,
00048                             ISocketFactory* socketFactory,
00049                             IStreamFilterFactory* streamFilterFactory,
00050                             CScreen* screen);
00051     ~CClient();
00052 
00054 
00055 
00057 
00061     void                connect();
00062 
00064 
00067     void                disconnect(const char* msg);
00068 
00070 
00073     void                handshakeComplete();
00074 
00076 
00077 
00078 
00080 
00083     bool                isConnected() const;
00084 
00086 
00090     bool                isConnecting() const;
00091 
00093 
00097     CNetworkAddress     getServerAddress() const;
00098 
00100 
00104     static CEvent::Type getConnectedEvent();
00105 
00107 
00111     static CEvent::Type getConnectionFailedEvent();
00112 
00114 
00119     static CEvent::Type getDisconnectedEvent();
00120 
00122 
00123     // IScreen overrides
00124     virtual void*       getEventTarget() const;
00125     virtual bool        getClipboard(ClipboardID id, IClipboard*) const;
00126     virtual void        getShape(SInt32& x, SInt32& y,
00127                             SInt32& width, SInt32& height) const;
00128     virtual void        getCursorPos(SInt32& x, SInt32& y) const;
00129 
00130     // IClient overrides
00131     virtual void        enter(SInt32 xAbs, SInt32 yAbs,
00132                             UInt32 seqNum, KeyModifierMask mask,
00133                             bool forScreensaver);
00134     virtual bool        leave();
00135     virtual void        setClipboard(ClipboardID, const IClipboard*);
00136     virtual void        grabClipboard(ClipboardID);
00137     virtual void        setClipboardDirty(ClipboardID, bool);
00138     virtual void        keyDown(KeyID, KeyModifierMask, KeyButton);
00139     virtual void        keyRepeat(KeyID, KeyModifierMask,
00140                             SInt32 count, KeyButton);
00141     virtual void        keyUp(KeyID, KeyModifierMask, KeyButton);
00142     virtual void        mouseDown(ButtonID);
00143     virtual void        mouseUp(ButtonID);
00144     virtual void        mouseMove(SInt32 xAbs, SInt32 yAbs);
00145     virtual void        mouseRelativeMove(SInt32 xRel, SInt32 yRel);
00146     virtual void        mouseWheel(SInt32 xDelta, SInt32 yDelta);
00147     virtual void        screensaver(bool activate);
00148     virtual void        resetOptions();
00149     virtual void        setOptions(const COptionsList& options);
00150     virtual CString     getName() const;
00151 
00152 private:
00153     void                sendClipboard(ClipboardID);
00154     void                sendEvent(CEvent::Type, void*);
00155     void                sendConnectionFailedEvent(const char* msg);
00156     void                setupConnecting();
00157     void                setupConnection();
00158     void                setupScreen();
00159     void                setupTimer();
00160     void                cleanupConnecting();
00161     void                cleanupConnection();
00162     void                cleanupScreen();
00163     void                cleanupTimer();
00164     void                handleConnected(const CEvent&, void*);
00165     void                handleConnectionFailed(const CEvent&, void*);
00166     void                handleConnectTimeout(const CEvent&, void*);
00167     void                handleOutputError(const CEvent&, void*);
00168     void                handleDisconnected(const CEvent&, void*);
00169     void                handleShapeChanged(const CEvent&, void*);
00170     void                handleClipboardGrabbed(const CEvent&, void*);
00171     void                handleHello(const CEvent&, void*);
00172     void                handleSuspend(const CEvent& event, void*);
00173     void                handleResume(const CEvent& event, void*);
00174     
00175 private:
00176     CString                 m_name;
00177     CNetworkAddress         m_serverAddress;
00178     ISocketFactory*         m_socketFactory;
00179     IStreamFilterFactory*   m_streamFilterFactory;
00180     CScreen*                m_screen;
00181     IStream*                m_stream;
00182     CEventQueueTimer*       m_timer;
00183     CServerProxy*           m_server;
00184     bool                    m_ready;
00185     bool                    m_active;
00186     bool                    m_suspended;
00187     bool                    m_connectOnResume;
00188     bool                m_ownClipboard[kClipboardEnd];
00189     bool                m_sentClipboard[kClipboardEnd];
00190     IClipboard::Time    m_timeClipboard[kClipboardEnd];
00191     CString             m_dataClipboard[kClipboardEnd];
00192 
00193     static CEvent::Type s_connectedEvent;
00194     static CEvent::Type s_connectionFailedEvent;
00195     static CEvent::Type s_disconnectedEvent;
00196 };
00197 
00198 #endif

Generated on Fri Nov 6 00:21:13 2009 for synergy-plus by  doxygen 1.3.9.1