annotate src/CapsContainer.java @ 0:e04119c40b9b

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