annotate src/myVncProxy/CapsContainer.java @ 61:626cf8cc002c

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