Pierre Ossman | b14a6bc | 2018-06-18 15:44:26 +0200 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
| 2 | * Copyright (C) 2011 D. R. Commander. All Rights Reserved. |
| 3 | * Copyright 2014-2018 Pierre Ossman for Cendio AB |
| 4 | * |
| 5 | * This is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This software is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this software; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 18 | * USA. |
| 19 | */ |
| 20 | #include <rfb/Exception.h> |
| 21 | #include <rfb/ledStates.h> |
| 22 | #include <rfb/ServerParams.h> |
| 23 | |
| 24 | using namespace rfb; |
| 25 | |
| 26 | ServerParams::ServerParams() |
| 27 | : majorVersion(0), minorVersion(0), |
Pierre Ossman | 5588f4f | 2018-06-20 11:48:17 +0200 | [diff] [blame] | 28 | supportsLocalCursor(false), |
Pierre Ossman | 6ea58ba | 2018-06-20 15:47:49 +0200 | [diff] [blame^] | 29 | supportsDesktopResize(false), |
Pierre Ossman | b14a6bc | 2018-06-18 15:44:26 +0200 | [diff] [blame] | 30 | supportsLEDState(false), supportsQEMUKeyEvent(false), |
| 31 | supportsSetDesktopSize(false), supportsFence(false), |
| 32 | supportsContinuousUpdates(false), |
| 33 | compressLevel(2), qualityLevel(-1), |
| 34 | width_(0), height_(0), name_(0), |
| 35 | ledState_(ledUnknown) |
| 36 | { |
| 37 | setName(""); |
| 38 | cursor_ = new Cursor(0, 0, Point(), NULL); |
| 39 | } |
| 40 | |
| 41 | ServerParams::~ServerParams() |
| 42 | { |
| 43 | delete [] name_; |
| 44 | delete cursor_; |
| 45 | } |
| 46 | |
| 47 | void ServerParams::setDimensions(int width, int height) |
| 48 | { |
| 49 | ScreenSet layout; |
| 50 | layout.add_screen(rfb::Screen(0, 0, 0, width, height, 0)); |
| 51 | setDimensions(width, height, layout); |
| 52 | } |
| 53 | |
| 54 | void ServerParams::setDimensions(int width, int height, const ScreenSet& layout) |
| 55 | { |
| 56 | if (!layout.validate(width, height)) |
| 57 | throw Exception("Attempted to configure an invalid screen layout"); |
| 58 | |
| 59 | width_ = width; |
| 60 | height_ = height; |
| 61 | screenLayout_ = layout; |
| 62 | } |
| 63 | |
| 64 | void ServerParams::setPF(const PixelFormat& pf) |
| 65 | { |
| 66 | pf_ = pf; |
| 67 | |
| 68 | if (pf.bpp != 8 && pf.bpp != 16 && pf.bpp != 32) |
| 69 | throw Exception("setPF: not 8, 16 or 32 bpp?"); |
| 70 | } |
| 71 | |
| 72 | void ServerParams::setName(const char* name) |
| 73 | { |
| 74 | delete [] name_; |
| 75 | name_ = strDup(name); |
| 76 | } |
| 77 | |
| 78 | void ServerParams::setCursor(const Cursor& other) |
| 79 | { |
| 80 | delete cursor_; |
| 81 | cursor_ = new Cursor(other); |
| 82 | } |
| 83 | |
| 84 | void ServerParams::setLEDState(unsigned int state) |
| 85 | { |
| 86 | ledState_ = state; |
| 87 | } |