Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
Pierre Ossman | 615d16b | 2019-05-03 10:53:06 +0200 | [diff] [blame] | 2 | * Copyright 2009-2019 Pierre Ossman for Cendio AB |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 3 | * |
| 4 | * This is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This software is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this software; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 17 | * USA. |
| 18 | */ |
| 19 | // |
| 20 | // VNCServer - abstract interface implemented by the RFB library. The back-end |
| 21 | // code calls the relevant methods as appropriate. |
| 22 | |
| 23 | #ifndef __RFB_VNCSERVER_H__ |
| 24 | #define __RFB_VNCSERVER_H__ |
| 25 | |
Pierre Ossman | cd7931d | 2018-10-05 17:48:58 +0200 | [diff] [blame] | 26 | #include <network/Socket.h> |
| 27 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 28 | #include <rfb/UpdateTracker.h> |
| 29 | #include <rfb/SSecurity.h> |
Pierre Ossman | 04e62db | 2009-03-23 16:57:07 +0000 | [diff] [blame] | 30 | #include <rfb/ScreenSet.h> |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 31 | |
| 32 | namespace rfb { |
| 33 | |
Pierre Ossman | cd7931d | 2018-10-05 17:48:58 +0200 | [diff] [blame] | 34 | class VNCServer : public UpdateTracker, |
| 35 | public network::SocketServer { |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 36 | public: |
Pierre Ossman | 559a2e8 | 2012-01-23 15:54:11 +0000 | [diff] [blame] | 37 | // blockUpdates()/unblockUpdates() tells the server that the pixel buffer |
| 38 | // is currently in flux and may not be accessed. The attributes of the |
| 39 | // pixel buffer may still be accessed, but not the frame buffer itself. |
| 40 | // Note that access must be unblocked the exact same number of times it |
| 41 | // was blocked. |
| 42 | virtual void blockUpdates() = 0; |
| 43 | virtual void unblockUpdates() = 0; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 44 | |
Pierre Ossman | 04e62db | 2009-03-23 16:57:07 +0000 | [diff] [blame] | 45 | // setPixelBuffer() tells the server to use the given pixel buffer (and |
| 46 | // optionally a modified screen layout). If this differs in size from |
| 47 | // the previous pixel buffer, this may result in protocol messages being |
| 48 | // sent, or clients being disconnected. |
| 49 | virtual void setPixelBuffer(PixelBuffer* pb, const ScreenSet& layout) = 0; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 50 | virtual void setPixelBuffer(PixelBuffer* pb) = 0; |
| 51 | |
Pierre Ossman | 04e62db | 2009-03-23 16:57:07 +0000 | [diff] [blame] | 52 | // setScreenLayout() modifies the current screen layout without changing |
| 53 | // the pixelbuffer. Clients will be notified of the new layout. |
| 54 | virtual void setScreenLayout(const ScreenSet& layout) = 0; |
| 55 | |
Constantin Kaplinsky | d7c0a6d | 2007-09-03 04:23:48 +0000 | [diff] [blame] | 56 | // getPixelBuffer() returns a pointer to the PixelBuffer object. |
Pierre Ossman | 6094ced | 2018-10-05 17:24:51 +0200 | [diff] [blame] | 57 | virtual const PixelBuffer* getPixelBuffer() const = 0; |
Constantin Kaplinsky | d7c0a6d | 2007-09-03 04:23:48 +0000 | [diff] [blame] | 58 | |
Pierre Ossman | 615d16b | 2019-05-03 10:53:06 +0200 | [diff] [blame] | 59 | // requestClipboard() will result in a request to a client to |
| 60 | // transfer its clipboard data. A call to |
| 61 | // SDesktop::handleClipboardData() will be made once the data is |
| 62 | // available. |
| 63 | virtual void requestClipboard() = 0; |
| 64 | |
| 65 | // announceClipboard() informs all clients of changes to the |
| 66 | // clipboard on the server. A client may later request the |
| 67 | // clipboard data via SDesktop::handleClipboardRequest(). |
| 68 | virtual void announceClipboard(bool available) = 0; |
| 69 | |
| 70 | // sendClipboardData() transfers the clipboard data to a client |
| 71 | // and should be called whenever a client has requested the |
| 72 | // clipboard via SDesktop::handleClipboardRequest(). |
| 73 | virtual void sendClipboardData(const char* data) = 0; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 74 | |
| 75 | // bell() tells the server that it should make all clients make a bell sound. |
| 76 | virtual void bell() = 0; |
| 77 | |
Pierre Ossman | eef6c9a | 2018-10-05 17:11:25 +0200 | [diff] [blame] | 78 | // approveConnection() is called some time after |
| 79 | // SDesktop::queryConnection() has been called, to accept or reject |
| 80 | // the connection. The accept argument should be true for |
| 81 | // acceptance, or false for rejection, in which case a string |
| 82 | // reason may also be given. |
| 83 | virtual void approveConnection(network::Socket* sock, bool accept, |
| 84 | const char* reason = NULL) = 0; |
| 85 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 86 | // - Close all currently-connected clients, by calling |
| 87 | // their close() method with the supplied reason. |
| 88 | virtual void closeClients(const char* reason) = 0; |
| 89 | |
Pierre Ossman | 7d64b33 | 2018-10-08 15:59:02 +0200 | [diff] [blame] | 90 | // getConnection() gets the SConnection for a particular Socket. If |
| 91 | // the Socket is not recognised then null is returned. |
| 92 | virtual SConnection* getConnection(network::Socket* sock) = 0; |
| 93 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 94 | // setCursor() tells the server that the cursor has changed. The |
Pierre Ossman | 6a1a0d0 | 2017-02-19 15:48:17 +0100 | [diff] [blame] | 95 | // cursorData argument contains width*height rgba quadruplets with |
| 96 | // non-premultiplied alpha. |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 97 | virtual void setCursor(int width, int height, const Point& hotspot, |
Pierre Ossman | 6a1a0d0 | 2017-02-19 15:48:17 +0100 | [diff] [blame] | 98 | const rdr::U8* cursorData) = 0; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 99 | |
| 100 | // setCursorPos() tells the server the current position of the cursor. |
| 101 | virtual void setCursorPos(const Point& p) = 0; |
| 102 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 103 | // setName() tells the server what desktop title to supply to clients |
| 104 | virtual void setName(const char* name) = 0; |
Pierre Ossman | bb305ca | 2016-12-11 12:41:26 +0100 | [diff] [blame] | 105 | |
| 106 | // setLEDState() tells the server what the current lock keys LED |
| 107 | // state is |
| 108 | virtual void setLEDState(unsigned int state) = 0; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 109 | }; |
| 110 | } |
| 111 | #endif |