Constantin Kaplinsky | ce0907d | 2006-09-08 12:55:37 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2006 Constantin Kaplinsky. All Rights Reserved. |
| 2 | * |
| 3 | * This is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This software is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this software; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 16 | * USA. |
| 17 | */ |
| 18 | |
| 19 | // |
Constantin Kaplinsky | 99637aa | 2006-09-12 05:46:34 +0000 | [diff] [blame] | 20 | // CapsList - a list of server-side protocol capabilities. This class makes |
| 21 | // it easy to prepare a capability list and send it via OutStream transport. |
Constantin Kaplinsky | ce0907d | 2006-09-08 12:55:37 +0000 | [diff] [blame] | 22 | // |
| 23 | |
| 24 | #ifndef __RFB_CAPSLIST_H__ |
| 25 | #define __RFB_CAPSLIST_H__ |
| 26 | |
| 27 | #include <rfb/CapsContainer.h> |
| 28 | |
| 29 | namespace rdr { class OutStream; } |
| 30 | |
| 31 | namespace rfb { |
| 32 | |
| 33 | // NOTE: Here we use the CapsContainer class for an off-design purpose. |
| 34 | // However, that class is so good that I believe it's better to |
Constantin Kaplinsky | 99637aa | 2006-09-12 05:46:34 +0000 | [diff] [blame] | 35 | // use its well-tested code instead of writing new class from the |
| 36 | // scratch. |
Constantin Kaplinsky | ce0907d | 2006-09-08 12:55:37 +0000 | [diff] [blame] | 37 | |
Constantin Kaplinsky | 99637aa | 2006-09-12 05:46:34 +0000 | [diff] [blame] | 38 | class CapsList : private CapsContainer |
| 39 | { |
Constantin Kaplinsky | ce0907d | 2006-09-08 12:55:37 +0000 | [diff] [blame] | 40 | public: |
Constantin Kaplinsky | 99637aa | 2006-09-12 05:46:34 +0000 | [diff] [blame] | 41 | |
| 42 | // Constructor. |
| 43 | // The maxCaps value is the maximum number of capabilities in the list. |
Constantin Kaplinsky | ce0907d | 2006-09-08 12:55:37 +0000 | [diff] [blame] | 44 | CapsList(int maxCaps = 64); |
Constantin Kaplinsky | 99637aa | 2006-09-12 05:46:34 +0000 | [diff] [blame] | 45 | |
Constantin Kaplinsky | ce0907d | 2006-09-08 12:55:37 +0000 | [diff] [blame] | 46 | virtual ~CapsList(); |
| 47 | |
Constantin Kaplinsky | 99637aa | 2006-09-12 05:46:34 +0000 | [diff] [blame] | 48 | // Current number of capabilities in the list. |
Constantin Kaplinsky | ce0907d | 2006-09-08 12:55:37 +0000 | [diff] [blame] | 49 | int getSize() const { return numEnabled(); } |
| 50 | |
Constantin Kaplinsky | 99637aa | 2006-09-12 05:46:34 +0000 | [diff] [blame] | 51 | // Add capability ("standard" vendor). |
Constantin Kaplinsky | ce0907d | 2006-09-08 12:55:37 +0000 | [diff] [blame] | 52 | void addStandard(rdr::U32 code, const char *name); |
Constantin Kaplinsky | 99637aa | 2006-09-12 05:46:34 +0000 | [diff] [blame] | 53 | // Add capability (TightVNC vendor). |
Constantin Kaplinsky | ce0907d | 2006-09-08 12:55:37 +0000 | [diff] [blame] | 54 | void addTightExt(rdr::U32 code, const char *name); |
Constantin Kaplinsky | 99637aa | 2006-09-12 05:46:34 +0000 | [diff] [blame] | 55 | // Add capability (any other vendor). |
Constantin Kaplinsky | ce0907d | 2006-09-08 12:55:37 +0000 | [diff] [blame] | 56 | void add3rdParty(rdr::U32 code, const char *name, const char *vendor); |
| 57 | |
Constantin Kaplinsky | 99637aa | 2006-09-12 05:46:34 +0000 | [diff] [blame] | 58 | // Send the list of capabilities (not including the counter). |
Constantin Kaplinsky | ce0907d | 2006-09-08 12:55:37 +0000 | [diff] [blame] | 59 | void write(rdr::OutStream* os) const; |
| 60 | |
| 61 | protected: |
Constantin Kaplinsky | 99637aa | 2006-09-12 05:46:34 +0000 | [diff] [blame] | 62 | |
| 63 | // Pre-defined signatures for known vendors. |
Constantin Kaplinsky | ce0907d | 2006-09-08 12:55:37 +0000 | [diff] [blame] | 64 | static const char *const VENDOR_STD; |
| 65 | static const char *const VENDOR_TIGHT; |
| 66 | }; |
| 67 | |
| 68 | } |
| 69 | |
| 70 | #endif // __RFB_CAPSLIST_H__ |