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. |
Pierre Ossman | 0ff2655 | 2016-02-05 10:26:56 +0100 | [diff] [blame] | 3 | * Copyright 2014-2019 Pierre Ossman for Cendio AB |
Pierre Ossman | b14a6bc | 2018-06-18 15:44:26 +0200 | [diff] [blame] | 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 | b03512c | 2018-06-20 16:03:23 +0200 | [diff] [blame] | 28 | supportsQEMUKeyEvent(false), |
Pierre Ossman | b14a6bc | 2018-06-18 15:44:26 +0200 | [diff] [blame] | 29 | supportsSetDesktopSize(false), supportsFence(false), |
| 30 | supportsContinuousUpdates(false), |
Pierre Ossman | b14a6bc | 2018-06-18 15:44:26 +0200 | [diff] [blame] | 31 | width_(0), height_(0), name_(0), |
| 32 | ledState_(ledUnknown) |
| 33 | { |
| 34 | setName(""); |
Pierre Ossman | 0ff2655 | 2016-02-05 10:26:56 +0100 | [diff] [blame] | 35 | |
Pierre Ossman | b14a6bc | 2018-06-18 15:44:26 +0200 | [diff] [blame] | 36 | cursor_ = new Cursor(0, 0, Point(), NULL); |
Pierre Ossman | 0ff2655 | 2016-02-05 10:26:56 +0100 | [diff] [blame] | 37 | |
| 38 | clipFlags = 0; |
| 39 | memset(clipSizes, 0, sizeof(clipSizes)); |
Pierre Ossman | b14a6bc | 2018-06-18 15:44:26 +0200 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | ServerParams::~ServerParams() |
| 43 | { |
| 44 | delete [] name_; |
| 45 | delete cursor_; |
| 46 | } |
| 47 | |
| 48 | void ServerParams::setDimensions(int width, int height) |
| 49 | { |
| 50 | ScreenSet layout; |
| 51 | layout.add_screen(rfb::Screen(0, 0, 0, width, height, 0)); |
| 52 | setDimensions(width, height, layout); |
| 53 | } |
| 54 | |
| 55 | void ServerParams::setDimensions(int width, int height, const ScreenSet& layout) |
| 56 | { |
| 57 | if (!layout.validate(width, height)) |
| 58 | throw Exception("Attempted to configure an invalid screen layout"); |
| 59 | |
| 60 | width_ = width; |
| 61 | height_ = height; |
| 62 | screenLayout_ = layout; |
| 63 | } |
| 64 | |
| 65 | void ServerParams::setPF(const PixelFormat& pf) |
| 66 | { |
| 67 | pf_ = pf; |
| 68 | |
| 69 | if (pf.bpp != 8 && pf.bpp != 16 && pf.bpp != 32) |
| 70 | throw Exception("setPF: not 8, 16 or 32 bpp?"); |
| 71 | } |
| 72 | |
| 73 | void ServerParams::setName(const char* name) |
| 74 | { |
| 75 | delete [] name_; |
| 76 | name_ = strDup(name); |
| 77 | } |
| 78 | |
| 79 | void ServerParams::setCursor(const Cursor& other) |
| 80 | { |
| 81 | delete cursor_; |
| 82 | cursor_ = new Cursor(other); |
| 83 | } |
| 84 | |
| 85 | void ServerParams::setLEDState(unsigned int state) |
| 86 | { |
| 87 | ledState_ = state; |
| 88 | } |
Pierre Ossman | 0ff2655 | 2016-02-05 10:26:56 +0100 | [diff] [blame] | 89 | |
| 90 | void ServerParams::setClipboardCaps(rdr::U32 flags, const rdr::U32* lengths) |
| 91 | { |
| 92 | int i, num; |
| 93 | |
| 94 | clipFlags = flags; |
| 95 | |
| 96 | num = 0; |
| 97 | for (i = 0;i < 16;i++) { |
| 98 | if (!(flags & (1 << i))) |
| 99 | continue; |
| 100 | clipSizes[i] = lengths[num++]; |
| 101 | } |
| 102 | } |