blob: b8fb8e8564896d2452e6d28d573d08c4ae767c10 [file] [log] [blame]
Constantin Kaplinskyce0907d2006-09-08 12:55:37 +00001/* 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 Kaplinsky99637aa2006-09-12 05:46:34 +000020// 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 Kaplinskyce0907d2006-09-08 12:55:37 +000022//
23
24#ifndef __RFB_CAPSLIST_H__
25#define __RFB_CAPSLIST_H__
26
27#include <rfb/CapsContainer.h>
28
29namespace rdr { class OutStream; }
30
31namespace 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 Kaplinsky99637aa2006-09-12 05:46:34 +000035 // use its well-tested code instead of writing new class from the
36 // scratch.
Constantin Kaplinskyce0907d2006-09-08 12:55:37 +000037
Constantin Kaplinsky99637aa2006-09-12 05:46:34 +000038 class CapsList : private CapsContainer
39 {
Constantin Kaplinskyce0907d2006-09-08 12:55:37 +000040 public:
Constantin Kaplinsky99637aa2006-09-12 05:46:34 +000041
42 // Constructor.
43 // The maxCaps value is the maximum number of capabilities in the list.
Constantin Kaplinskyce0907d2006-09-08 12:55:37 +000044 CapsList(int maxCaps = 64);
Constantin Kaplinsky99637aa2006-09-12 05:46:34 +000045
Constantin Kaplinskyce0907d2006-09-08 12:55:37 +000046 virtual ~CapsList();
47
Constantin Kaplinsky99637aa2006-09-12 05:46:34 +000048 // Current number of capabilities in the list.
Constantin Kaplinskyce0907d2006-09-08 12:55:37 +000049 int getSize() const { return numEnabled(); }
50
Constantin Kaplinsky99637aa2006-09-12 05:46:34 +000051 // Add capability ("standard" vendor).
Constantin Kaplinskyce0907d2006-09-08 12:55:37 +000052 void addStandard(rdr::U32 code, const char *name);
Constantin Kaplinsky99637aa2006-09-12 05:46:34 +000053 // Add capability (TightVNC vendor).
Constantin Kaplinskyce0907d2006-09-08 12:55:37 +000054 void addTightExt(rdr::U32 code, const char *name);
Constantin Kaplinsky99637aa2006-09-12 05:46:34 +000055 // Add capability (any other vendor).
Constantin Kaplinskyce0907d2006-09-08 12:55:37 +000056 void add3rdParty(rdr::U32 code, const char *name, const char *vendor);
57
Constantin Kaplinsky99637aa2006-09-12 05:46:34 +000058 // Send the list of capabilities (not including the counter).
Constantin Kaplinskyce0907d2006-09-08 12:55:37 +000059 void write(rdr::OutStream* os) const;
60
61 protected:
Constantin Kaplinsky99637aa2006-09-12 05:46:34 +000062
63 // Pre-defined signatures for known vendors.
Constantin Kaplinskyce0907d2006-09-08 12:55:37 +000064 static const char *const VENDOR_STD;
65 static const char *const VENDOR_TIGHT;
66 };
67
68}
69
70#endif // __RFB_CAPSLIST_H__