Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
| 2 | * Copyright 2009-2011 Pierre Ossman <ossman@cendio.se> for Cendio AB |
| 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 | #ifndef __CCONN_H__ |
| 21 | #define __CCONN_H__ |
| 22 | |
| 23 | #include <rfb/CConnection.h> |
| 24 | #include <network/Socket.h> |
| 25 | |
| 26 | #include "DesktopWindow.h" |
| 27 | |
| 28 | class CConn : public rfb::CConnection, |
| 29 | public rdr::FdInStreamBlockCallback |
| 30 | { |
| 31 | public: |
| 32 | CConn(const char* vncServerName); |
| 33 | ~CConn(); |
| 34 | |
Pierre Ossman | d4c61ce | 2011-04-29 11:18:12 +0000 | [diff] [blame] | 35 | void refreshFramebuffer(); |
| 36 | |
Pierre Ossman | 2eb1d11 | 2011-05-16 12:18:08 +0000 | [diff] [blame] | 37 | const char *connectionInfo(); |
| 38 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 39 | // FdInStreamBlockCallback methods |
| 40 | void blockCallback(); |
| 41 | |
| 42 | // Callback when socket is ready (or broken) |
| 43 | static void socketEvent(int fd, void *data); |
| 44 | |
| 45 | // CConnection callback methods |
| 46 | void serverInit(); |
| 47 | |
| 48 | void setDesktopSize(int w, int h); |
| 49 | void setExtendedDesktopSize(int reason, int result, int w, int h, |
| 50 | const rfb::ScreenSet& layout); |
| 51 | |
| 52 | void setName(const char* name); |
| 53 | |
| 54 | void setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs); |
| 55 | |
| 56 | void bell(); |
| 57 | |
| 58 | void serverCutText(const char* str, rdr::U32 len); |
| 59 | |
| 60 | void framebufferUpdateStart(); |
| 61 | void framebufferUpdateEnd(); |
| 62 | |
| 63 | void beginRect(const rfb::Rect& r, int encoding); |
| 64 | void endRect(const rfb::Rect& r, int encoding); |
| 65 | |
| 66 | void fillRect(const rfb::Rect& r, rfb::Pixel p); |
| 67 | void imageRect(const rfb::Rect& r, void* p); |
| 68 | void copyRect(const rfb::Rect& r, int sx, int sy); |
| 69 | |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame] | 70 | rdr::U8* getRawPixelsRW(const rfb::Rect& r, int* stride); |
| 71 | void releaseRawPixels(const rfb::Rect& r); |
| 72 | |
| 73 | const rfb::PixelFormat &getPreferredPF() { return fullColourPF; } |
| 74 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 75 | void setCursor(int width, int height, const rfb::Point& hotspot, |
| 76 | void* data, void* mask); |
| 77 | |
| 78 | private: |
| 79 | |
| 80 | void resizeFramebuffer(); |
| 81 | |
| 82 | void autoSelectFormatAndEncoding(); |
| 83 | void checkEncodings(); |
| 84 | void requestNewUpdate(); |
| 85 | |
Pierre Ossman | f4f3094 | 2011-05-17 09:39:07 +0000 | [diff] [blame] | 86 | static void handleOptions(void *data); |
| 87 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 88 | private: |
| 89 | char* serverHost; |
| 90 | int serverPort; |
| 91 | network::Socket* sock; |
| 92 | |
| 93 | DesktopWindow *desktop; |
| 94 | |
| 95 | rfb::PixelFormat serverPF; |
| 96 | rfb::PixelFormat fullColourPF; |
| 97 | |
| 98 | int currentEncoding, lastServerEncoding; |
| 99 | |
| 100 | bool formatChange; |
| 101 | bool encodingChange; |
| 102 | |
| 103 | bool firstUpdate; |
| 104 | bool pendingUpdate; |
Pierre Ossman | d4c61ce | 2011-04-29 11:18:12 +0000 | [diff] [blame] | 105 | |
| 106 | bool forceNonincremental; |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | #endif |