blob: a267e933abe8b16cec53e2e02548ca26b78f319b [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 Kaplinsky4140d912006-09-12 14:10:14 +000051 // Does the list include nothing more than one particular capability?
52 bool includesOnly(rdr::U32 code) {
53 return (numEnabled() == 1 && getByOrder(0) == code);
54 }
55
Constantin Kaplinsky99637aa2006-09-12 05:46:34 +000056 // Add capability ("standard" vendor).
Constantin Kaplinskyce0907d2006-09-08 12:55:37 +000057 void addStandard(rdr::U32 code, const char *name);
Constantin Kaplinsky99637aa2006-09-12 05:46:34 +000058 // Add capability (TightVNC vendor).
Constantin Kaplinskyce0907d2006-09-08 12:55:37 +000059 void addTightExt(rdr::U32 code, const char *name);
Constantin Kaplinsky99637aa2006-09-12 05:46:34 +000060 // Add capability (any other vendor).
Constantin Kaplinskyce0907d2006-09-08 12:55:37 +000061 void add3rdParty(rdr::U32 code, const char *name, const char *vendor);
62
Constantin Kaplinsky99637aa2006-09-12 05:46:34 +000063 // Send the list of capabilities (not including the counter).
Constantin Kaplinskyce0907d2006-09-08 12:55:37 +000064 void write(rdr::OutStream* os) const;
65
66 protected:
Constantin Kaplinsky99637aa2006-09-12 05:46:34 +000067
68 // Pre-defined signatures for known vendors.
Constantin Kaplinskyce0907d2006-09-08 12:55:37 +000069 static const char *const VENDOR_STD;
70 static const char *const VENDOR_TIGHT;
71 };
72
73}
74
75#endif // __RFB_CAPSLIST_H__