annotate src/CapsContainer.java @ 0:30bb7074acb1

upload all file of tighVNCProxy
author e085711
date Tue, 12 Apr 2011 12:58:05 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
1 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
2 // Copyright (C) 2003 Constantin Kaplinsky. All Rights Reserved.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
3 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
4 // This is free software; you can redistribute it and/or modify
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
5 // it under the terms of the GNU General Public License as published by
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
6 // the Free Software Foundation; either version 2 of the License, or
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
7 // (at your option) any later version.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
8 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
9 // This software is distributed in the hope that it will be useful,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
12 // GNU General Public License for more details.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
13 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
14 // You should have received a copy of the GNU General Public License
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
15 // along with this software; if not, write to the Free Software
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
17 // USA.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
18 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
19
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
20 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
21 // CapsContainer.java - A container of capabilities as used in the RFB
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
22 // protocol 3.130
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
23 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
24
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
25 import java.util.Vector;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
26 import java.util.Hashtable;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
27
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
28 class CapsContainer {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
29
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
30 // Public methods
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
31
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
32 public CapsContainer() {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
33 infoMap = new Hashtable(64, (float)0.25);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
34 orderedList = new Vector(32, 8);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
35 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
36
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
37 public void add(CapabilityInfo capinfo) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
38 Integer key = new Integer(capinfo.getCode());
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
39 infoMap.put(key, capinfo);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
40 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
41
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
42 public void add(int code, String vendor, String name, String desc) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
43 Integer key = new Integer(code);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
44 infoMap.put(key, new CapabilityInfo(code, vendor, name, desc));
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
45 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
46
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
47 public boolean isKnown(int code) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
48 return infoMap.containsKey(new Integer(code));
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
49 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
50
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
51 public CapabilityInfo getInfo(int code) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
52 return (CapabilityInfo)infoMap.get(new Integer(code));
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
53 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
54
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
55 public String getDescription(int code) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
56 CapabilityInfo capinfo = (CapabilityInfo)infoMap.get(new Integer(code));
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
57 if (capinfo == null)
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
58 return null;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
59
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
60 return capinfo.getDescription();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
61 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
62
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
63 public boolean enable(CapabilityInfo other) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
64 Integer key = new Integer(other.getCode());
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
65 CapabilityInfo capinfo = (CapabilityInfo)infoMap.get(key);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
66 if (capinfo == null)
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
67 return false;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
68
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
69 boolean enabled = capinfo.enableIfEquals(other);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
70 if (enabled)
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
71 orderedList.addElement(key);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
72
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
73 return enabled;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
74 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
75
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
76 public boolean isEnabled(int code) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
77 CapabilityInfo capinfo = (CapabilityInfo)infoMap.get(new Integer(code));
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
78 if (capinfo == null)
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
79 return false;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
80
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
81 return capinfo.isEnabled();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
82 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
83
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
84 public int numEnabled() {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
85 return orderedList.size();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
86 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
87
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
88 public int getByOrder(int idx) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
89 int code;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
90 try {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
91 code = ((Integer)orderedList.elementAt(idx)).intValue();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
92 } catch (ArrayIndexOutOfBoundsException e) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
93 code = 0;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
94 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
95 return code;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
96 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
97
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
98 // Protected data
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
99
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
100 protected Hashtable infoMap;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
101 protected Vector orderedList;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
102 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
103