blob: 0abbff0b06d26f0daf9e5258bbe91b7e178b3255 [file] [log] [blame]
Constantin Kaplinsky73fdc8c2006-06-03 13:18:37 +00001/* Copyright (C) 2003-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//
20// CapsContainer and associated structures - dealing with TightVNC-specific
21// protocol capability lists.
22//
23
24#ifndef __RFB_CAPSCONTAINER_H__
25#define __RFB_CAPSCONTAINER_H__
26
27#include <rdr/types.h>
28
29#include <map>
30
31namespace rfb {
32
33 //
34 // Structure used to describe protocol options such as tunneling methods,
35 // authentication schemes and message types (protocol versions 3.7t/3.8t).
36 //
37
38 struct CapabilityInfo {
39 rdr::U32 code; // numeric identifier
40 rdr::U8 vendorSignature[4]; // vendor identification
41 rdr::U8 nameSignature[8]; // abbreviated option name
42 };
43
44
45 //
46 // CapsContainer - a container class to maintain a list of protocol
47 // capabilities.
48 //
49
50 class CapsContainer {
51 public:
52 CapsContainer(int maxCaps = 64);
53 ~CapsContainer();
54
55 void add(const CapabilityInfo *capinfo, const char *desc = 0);
56 void add(rdr::U32 code, const char *vendor, const char *name,
57 const char *desc = 0);
58
59 bool isKnown(rdr::U32 code) const;
60 bool getInfo(rdr::U32 code, CapabilityInfo *capinfo) const;
61 char *getDescription(rdr::U32 code) const;
62
63 bool enable(const CapabilityInfo *capinfo);
64 bool isEnabled(rdr::U32 code) const;
65 int numEnabled() const { return m_listSize; }
66 rdr::U32 getByOrder(int idx) const;
67
68 private:
69 std::map<rdr::U32,CapabilityInfo> m_infoMap;
70 std::map<rdr::U32,char*> m_descMap;
71 std::map<rdr::U32,bool> m_enableMap;
72
73 int m_maxSize;
74 int m_listSize;
75 rdr::U32 *m_plist;
76 };
77
78}
79
80#endif // __RFB_CAPSCONTAINER_H__