diff options
Diffstat (limited to 'common/rfb/CConnection.h')
-rw-r--r-- | common/rfb/CConnection.h | 199 |
1 files changed, 108 insertions, 91 deletions
diff --git a/common/rfb/CConnection.h b/common/rfb/CConnection.h index 07e47e39..b28c5aa9 100644 --- a/common/rfb/CConnection.h +++ b/common/rfb/CConnection.h @@ -29,8 +29,14 @@ #include <rfb/CMsgHandler.h> #include <rfb/DecodeManager.h> +#include <rfb/PixelFormat.h> #include <rfb/SecurityClient.h> +namespace rdr { + class InStream; + class OutStream; +} + namespace rfb { class CMsgReader; @@ -99,89 +105,6 @@ namespace rfb { // connection void close(); - - // Methods overridden from CMsgHandler - - // Note: These must be called by any deriving classes - - void setDesktopSize(int w, int h) override; - void setExtendedDesktopSize(unsigned reason, unsigned result, - int w, int h, - const ScreenSet& layout) override; - - void endOfContinuousUpdates() override; - - void serverInit(int width, int height, const PixelFormat& pf, - const char* name) override; - - bool readAndDecodeRect(const Rect& r, int encoding, - ModifiablePixelBuffer* pb) override; - - void framebufferUpdateStart() override; - void framebufferUpdateEnd() override; - bool dataRect(const Rect& r, int encoding) override; - - void serverCutText(const char* str) override; - - void handleClipboardCaps(uint32_t flags, - const uint32_t* lengths) override; - void handleClipboardRequest(uint32_t flags) override; - void handleClipboardPeek() override; - void handleClipboardNotify(uint32_t flags) override; - void handleClipboardProvide(uint32_t flags, const size_t* lengths, - const uint8_t* const* data) override; - - - // Methods to be overridden in a derived class - - // getUserPasswd() gets the username and password. This might - // involve a dialog, getpass(), etc. The user buffer pointer can be - // null, in which case no user name will be retrieved. - virtual void getUserPasswd(bool secure, std::string* user, - std::string* password) = 0; - - // showMsgBox() displays a message box with the specified style and - // contents. The return value is true if the user clicked OK/Yes. - virtual bool showMsgBox(MsgBoxFlags flags, const char *title, - const char *text) = 0; - - // authSuccess() is called when authentication has succeeded. - virtual void authSuccess(); - - // initDone() is called when the connection is fully established - // and standard messages can be sent. This is called before the - // initial FramebufferUpdateRequest giving a derived class the - // chance to modify pixel format and settings. The derived class - // must also make sure it has provided a valid framebuffer before - // returning. - virtual void initDone() = 0; - - // resizeFramebuffer() is called whenever the framebuffer - // dimensions or the screen layout changes. A subclass must make - // sure the pixel buffer has been updated once this call returns. - virtual void resizeFramebuffer(); - - // handleClipboardRequest() is called whenever the server requests - // the client to send over its clipboard data. It will only be - // called after the client has first announced a clipboard change - // via announceClipboard(). - virtual void handleClipboardRequest(); - - // handleClipboardAnnounce() is called to indicate a change in the - // clipboard on the server. Call requestClipboard() to access the - // actual data. - virtual void handleClipboardAnnounce(bool available); - - // handleClipboardData() is called when the server has sent over - // the clipboard data as a result of a previous call to - // requestClipboard(). Note that this function might never be - // called if the clipboard data was no longer available when the - // server received the request. - virtual void handleClipboardData(const char* data); - - - // Other methods - // requestClipboard() will result in a request to the server to // transfer its clipboard data. A call to handleClipboardData() // will be made once the data is available. @@ -221,7 +144,9 @@ namespace rfb { // setCompressLevel()/setQualityLevel() controls the encoding hints // sent to the server void setCompressLevel(int level); + int getCompressLevel(); void setQualityLevel(int level); + int getQualityLevel(); // setPF() controls the pixel format requested from the server. // server.pf() will automatically be adjusted once the new format // is active. @@ -237,7 +162,7 @@ namespace rfb { // Identities, to determine the unique(ish) name of the server. const char* getServerName() const { return serverName.c_str(); } - bool isSecure() const { return csecurity ? csecurity->isSecure() : false; } + bool isSecure() const; enum stateEnum { RFBSTATE_UNINITIALISED, @@ -254,8 +179,107 @@ namespace rfb { stateEnum state() { return state_; } + // Methods used by SSecurity classes + + // getUserPasswd() gets the username and password. This might + // involve a dialog, getpass(), etc. The user buffer pointer can be + // null, in which case no user name will be retrieved. + virtual void getUserPasswd(bool secure, std::string* user, + std::string* password) = 0; + + // showMsgBox() displays a message box with the specified style and + // contents. The return value is true if the user clicked OK/Yes. + virtual bool showMsgBox(MsgBoxFlags flags, const char *title, + const char *text) = 0; + + protected: + + // Methods overridden from CMsgHandler + + // Note: These must be called by any deriving classes + + void setDesktopSize(int w, int h) override; + void setExtendedDesktopSize(unsigned reason, unsigned result, + int w, int h, + const ScreenSet& layout) override; + + void setCursor(int width, int height, const core::Point& hotspot, + const uint8_t* data) override; + void setCursorPos(const core::Point& pos) override; + + void setName(const char* name) override; + + void fence(uint32_t flags, unsigned len, const uint8_t data[]) override; + + void endOfContinuousUpdates() override; + + void supportsQEMUKeyEvent() override; + + void supportsExtendedMouseButtons() override; + + void serverInit(int width, int height, const PixelFormat& pf, + const char* name) override; + + bool readAndDecodeRect(const core::Rect& r, int encoding, + ModifiablePixelBuffer* pb) override; + + void framebufferUpdateStart() override; + void framebufferUpdateEnd() override; + bool dataRect(const core::Rect& r, int encoding) override; + + void setColourMapEntries(int firstColour, int nColours, + uint16_t* rgbs) override; + + void serverCutText(const char* str) override; + + void setLEDState(unsigned int state) override; + + void handleClipboardCaps(uint32_t flags, + const uint32_t* lengths) override; + void handleClipboardRequest(uint32_t flags) override; + void handleClipboardPeek() override; + void handleClipboardNotify(uint32_t flags) override; + void handleClipboardProvide(uint32_t flags, const size_t* lengths, + const uint8_t* const* data) override; + + + // Methods to be overridden in a derived class + + // initDone() is called when the connection is fully established + // and standard messages can be sent. This is called before the + // initial FramebufferUpdateRequest giving a derived class the + // chance to modify pixel format and settings. The derived class + // must also make sure it has provided a valid framebuffer before + // returning. + virtual void initDone() = 0; + + // resizeFramebuffer() is called whenever the framebuffer + // dimensions or the screen layout changes. A subclass must make + // sure the pixel buffer has been updated once this call returns. + virtual void resizeFramebuffer(); + + // handleClipboardRequest() is called whenever the server requests + // the client to send over its clipboard data. It will only be + // called after the client has first announced a clipboard change + // via announceClipboard(). + virtual void handleClipboardRequest(); + + // handleClipboardAnnounce() is called to indicate a change in the + // clipboard on the server. Call requestClipboard() to access the + // actual data. + virtual void handleClipboardAnnounce(bool available); + + // handleClipboardData() is called when the server has sent over + // the clipboard data as a result of a previous call to + // requestClipboard(). Note that this function might never be + // called if the clipboard data was no longer available when the + // server received the request. + virtual void handleClipboardData(const char* data); + + protected: CSecurity *csecurity; SecurityClient security; + protected: void setState(stateEnum s) { state_ = s; } @@ -273,13 +297,6 @@ namespace rfb { bool supportsLEDState; private: - // This is a default implementation of fences that automatically - // responds to requests, stating no support for synchronisation. - // When overriding, call CMsgHandler::fence() directly in order to - // state correct support for fence flags. - void fence(uint32_t flags, unsigned len, const uint8_t data[]) override; - - private: bool processVersionMsg(); bool processSecurityTypesMsg(); bool processSecurityMsg(); |