annotate src/myVncProxy/VncProxyService.java @ 130:cb00150c223e

implement sendEchoPort
author e085711
date Tue, 30 Aug 2011 05:39:12 +0900
parents e3dddee7b934
children acd88e63854b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
87b29d6039a6 add package myVncProxy
e085711
parents: 23
diff changeset
1 package myVncProxy;
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
2 import java.awt.*;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
3 import java.awt.event.*;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
4 import java.io.*;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
5 import java.net.*;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
6
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
7 public class VncProxyService implements java.lang.Runnable {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
8
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
9 public static void main(String[] argv) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
10 VncProxyService v = new VncProxyService();
30
a0e1fc94d344 print out html file's text
e085711
parents: 27
diff changeset
11
a0e1fc94d344 print out html file's text
e085711
parents: 27
diff changeset
12 v.checkArgs(argv);
a0e1fc94d344 print out html file's text
e085711
parents: 27
diff changeset
13
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
14 v.mainArgs = argv;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
15
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
16 v.init();
50
458a231f060d modify VncProxyService.java
e085711
parents: 48
diff changeset
17 v.start_threads();
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
18 }
15
89e1c5f84407 faile ZRLE encode. success raw encode.
e085711
parents: 13
diff changeset
19
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
20 String[] mainArgs;
31
cb0e4fd2d982 upload CreateHtmlFile.java
e085711
parents: 30
diff changeset
21 String username;
cb0e4fd2d982 upload CreateHtmlFile.java
e085711
parents: 30
diff changeset
22
cb0e4fd2d982 upload CreateHtmlFile.java
e085711
parents: 30
diff changeset
23 CreateHtmlFile htmlFile;
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
24
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
25 // RfbProto rfb;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
26 MyRfbProto rfb;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
27 Thread rfbThread;
27
13d4d3118cb8 create rfb.cliListTmp
e085711
parents: 26
diff changeset
28 Thread accThread;
63
4864a7d1df00 add CreateThread.java modify acceptClient.java and VncProxyService.java
Yu Taninari <e085734@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
29 Thread clientThread;
4864a7d1df00 add CreateThread.java modify acceptClient.java and VncProxyService.java
Yu Taninari <e085734@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
30 CreateThread geth;
73
6fc4272db7e2 change class name
Yu Taninari <e085734@ie.u-ryukyu.ac.jp>
parents: 64
diff changeset
31 AcceptClient acc;
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
32
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
33 Frame vncFrame;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
34 Container vncContainer;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
35 ScrollPane desktopScrollPane;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
36 GridBagLayout gridbag;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
37 ButtonPanel buttonPanel;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
38 Label connStatusLabel;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
39 ProxyVncCanvas vc;
67
f695bc56eb4f add OptionNoFrame.java. add setEncodings.
e085711
parents: 66
diff changeset
40 // OptionsFrame options;
f695bc56eb4f add OptionNoFrame.java. add setEncodings.
e085711
parents: 66
diff changeset
41 OptionsNoFrame options;
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
42 ClipboardFrame clipboard;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
43 RecordingFrame rec;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
44
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
45 // Control session recording.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
46 Object recordingSync;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
47 String sessionFileName;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
48 boolean recordingActive;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
49 boolean recordingStatusChanged;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
50 String cursorUpdatesDef;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
51 String eightBitColorsDef;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
52
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
53 // Variables read from parameter values.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
54 String socketFactory;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
55 String host;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
56 int port;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
57 String passwordParam;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
58 boolean showControls;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
59 boolean offerRelogin;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
60 boolean showOfflineDesktop;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
61 int deferScreenUpdates;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
62 int deferCursorUpdates;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
63 int deferUpdateRequests;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
64 int debugStatsExcludeUpdates;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
65 int debugStatsMeasureUpdates;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
66
130
cb00150c223e implement sendEchoPort
e085711
parents: 125
diff changeset
67 int echoPort = 9999;
cb00150c223e implement sendEchoPort
e085711
parents: 125
diff changeset
68
cb00150c223e implement sendEchoPort
e085711
parents: 125
diff changeset
69
30
a0e1fc94d344 print out html file's text
e085711
parents: 27
diff changeset
70
a0e1fc94d344 print out html file's text
e085711
parents: 27
diff changeset
71 void checkArgs(String[] argv){
31
cb0e4fd2d982 upload CreateHtmlFile.java
e085711
parents: 30
diff changeset
72 if(argv.length > 3){
cb0e4fd2d982 upload CreateHtmlFile.java
e085711
parents: 30
diff changeset
73 username = argv[3];
cb0e4fd2d982 upload CreateHtmlFile.java
e085711
parents: 30
diff changeset
74 }else if(argv.length < 2){
30
a0e1fc94d344 print out html file's text
e085711
parents: 27
diff changeset
75 System.out.println("Please enter argv");
a0e1fc94d344 print out html file's text
e085711
parents: 27
diff changeset
76 System.out.println("hostname(IPaddress) port password");
a0e1fc94d344 print out html file's text
e085711
parents: 27
diff changeset
77 System.exit(0);
31
cb0e4fd2d982 upload CreateHtmlFile.java
e085711
parents: 30
diff changeset
78 }else{
cb0e4fd2d982 upload CreateHtmlFile.java
e085711
parents: 30
diff changeset
79 username = argv[0];
30
a0e1fc94d344 print out html file's text
e085711
parents: 27
diff changeset
80 }
a0e1fc94d344 print out html file's text
e085711
parents: 27
diff changeset
81 }
a0e1fc94d344 print out html file's text
e085711
parents: 27
diff changeset
82
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
83 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
84 // init()
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
85 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
86
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
87 public void init() {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
88
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
89 readParameters();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
90
67
f695bc56eb4f add OptionNoFrame.java. add setEncodings.
e085711
parents: 66
diff changeset
91 options = new OptionsNoFrame(this);
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
92 recordingSync = new Object();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
93
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
94 sessionFileName = null;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
95 recordingActive = false;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
96 recordingStatusChanged = false;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
97 cursorUpdatesDef = null;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
98 eightBitColorsDef = null;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
99
25
cded9fd297ab create png data
e085711
parents: 24
diff changeset
100 try{
cded9fd297ab create png data
e085711
parents: 24
diff changeset
101 connectAndAuthenticate();
cded9fd297ab create png data
e085711
parents: 24
diff changeset
102 }catch (NoRouteToHostException e) {
cded9fd297ab create png data
e085711
parents: 24
diff changeset
103 fatalError("Network error: no route to server: " + host, e);
cded9fd297ab create png data
e085711
parents: 24
diff changeset
104 } catch (UnknownHostException e) {
cded9fd297ab create png data
e085711
parents: 24
diff changeset
105 fatalError("Network error: server name unknown: " + host, e);
cded9fd297ab create png data
e085711
parents: 24
diff changeset
106 } catch (ConnectException e) {
cded9fd297ab create png data
e085711
parents: 24
diff changeset
107 fatalError("Network error: could not connect to server: " + host
cded9fd297ab create png data
e085711
parents: 24
diff changeset
108 + ":" + port, e);
cded9fd297ab create png data
e085711
parents: 24
diff changeset
109 }catch(Exception e){}
51
089bd4510538 add MultiThreadTee.java
e085711
parents: 50
diff changeset
110
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
111 rfbThread = new Thread(this);
80
712a047908df recompress output
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 78
diff changeset
112 accThread = new Thread(new AcceptThread(rfb, 5999));
50
458a231f060d modify VncProxyService.java
e085711
parents: 48
diff changeset
113
458a231f060d modify VncProxyService.java
e085711
parents: 48
diff changeset
114 }
458a231f060d modify VncProxyService.java
e085711
parents: 48
diff changeset
115
458a231f060d modify VncProxyService.java
e085711
parents: 48
diff changeset
116 public void start_threads(){
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
117 rfbThread.start();
27
13d4d3118cb8 create rfb.cliListTmp
e085711
parents: 26
diff changeset
118 accThread.start();
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
119 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
120
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
121 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
122 // run() - executed by the rfbThread to deal with the RFB socket.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
123 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
124
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
125 public void run() {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
126
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
127 try {
25
cded9fd297ab create png data
e085711
parents: 24
diff changeset
128 // connectAndAuthenticate();
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
129 doProtocolInitialisation();
45
b16072ddc911 modify MyRfbProto.java acceptThread.java
e085711
parents: 31
diff changeset
130 /*
31
cb0e4fd2d982 upload CreateHtmlFile.java
e085711
parents: 30
diff changeset
131 htmlFile = new CreateHtmlFile(rfb, host, username);
cb0e4fd2d982 upload CreateHtmlFile.java
e085711
parents: 30
diff changeset
132 htmlFile.createHtml();
45
b16072ddc911 modify MyRfbProto.java acceptThread.java
e085711
parents: 31
diff changeset
133 */
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
134 vc = new ProxyVncCanvas(this, 0, 0);
25
cded9fd297ab create png data
e085711
parents: 24
diff changeset
135 vc.updateFramebufferSize();
cded9fd297ab create png data
e085711
parents: 24
diff changeset
136
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
137 processNormalProtocol();// main loop
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
138
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
139 } catch (NoRouteToHostException e) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
140 fatalError("Network error: no route to server: " + host, e);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
141 } catch (UnknownHostException e) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
142 fatalError("Network error: server name unknown: " + host, e);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
143 } catch (ConnectException e) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
144 fatalError("Network error: could not connect to server: " + host
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
145 + ":" + port, e);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
146 } catch (EOFException e) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
147 if (showOfflineDesktop) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
148 e.printStackTrace();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
149 System.out
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
150 .println("Network error: remote side closed connection");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
151 if (vc != null) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
152 vc.enableInput(false);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
153 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
154 if (rfb != null && !rfb.closed())
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
155 rfb.close();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
156 if (showControls && buttonPanel != null) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
157 buttonPanel.disableButtonsOnDisconnect();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
158 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
159 } else {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
160 fatalError("Network error: remote side closed connection", e);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
161 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
162 } catch (IOException e) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
163 String str = e.getMessage();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
164 if (str != null && str.length() != 0) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
165 fatalError("Network Error: " + str, e);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
166 } else {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
167 fatalError(e.toString(), e);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
168 }
26
0aa0e0bd742c succeed drawFirstImage()!!
e085711
parents: 25
diff changeset
169 } catch (Exception e) {
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
170 String str = e.getMessage();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
171 if (str != null && str.length() != 0) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
172 fatalError("Error: " + str, e);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
173 } else {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
174 fatalError(e.toString(), e);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
175 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
176 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
177
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
178 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
179
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
180 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
181 // Process RFB socket messages.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
182 // If the rfbThread is being stopped, ignore any exceptions,
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
183 // otherwise rethrow the exception so it can be handled.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
184 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
185
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
186 void processNormalProtocol() throws Exception {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
187 try {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
188 vc.processNormalProtocol();// main loop
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
189 } catch (Exception e) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
190 if (rfbThread == null) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
191 System.out.println("Ignoring RFB socket exceptions"
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
192 + " because applet is stopping");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
193 } else {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
194 throw e;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
195 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
196 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
197 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
198
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
199 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
200 // Connect to the RFB server and authenticate the user.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
201 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
202
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
203 void connectAndAuthenticate() throws Exception {
73
6fc4272db7e2 change class name
Yu Taninari <e085734@ie.u-ryukyu.ac.jp>
parents: 64
diff changeset
204 acc = new AcceptClient(mainArgs[0]);
130
cb00150c223e implement sendEchoPort
e085711
parents: 125
diff changeset
205 geth = new CreateThread(acc , echoPort);
64
3ec4c9e94462 update myVncProxy
one
parents: 63
diff changeset
206 Thread thread = new Thread(geth);
3ec4c9e94462 update myVncProxy
one
parents: 63
diff changeset
207 thread.start();
48
1ad24c0af09e add acceptClient.java. modify VncProxyService
e085711
parents: 45
diff changeset
208
1ad24c0af09e add acceptClient.java. modify VncProxyService
e085711
parents: 45
diff changeset
209
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
210 showConnectionStatus("Initializing...");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
211
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
212 showConnectionStatus("Connecting to " + host + ", port " + port + "...");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
213
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
214 // rfb = new RfbProto(host, port, this);
130
cb00150c223e implement sendEchoPort
e085711
parents: 125
diff changeset
215 // rfb = new MyRfbProto(host, port);
cb00150c223e implement sendEchoPort
e085711
parents: 125
diff changeset
216 rfb = new MyRfbProto(host, port, geth);
cb00150c223e implement sendEchoPort
e085711
parents: 125
diff changeset
217
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
218 showConnectionStatus("Connected to server");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
219
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
220 rfb.readVersionMsg();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
221 showConnectionStatus("RFB server supports protocol version "
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
222 + rfb.serverMajor + "." + rfb.serverMinor);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
223
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
224 rfb.writeVersionMsg();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
225 showConnectionStatus("Using RFB protocol version " + rfb.clientMajor
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
226 + "." + rfb.clientMinor);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
227
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
228 int secType = rfb.negotiateSecurity();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
229 int authType;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
230 if (secType == RfbProto.SecTypeTight) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
231 showConnectionStatus("Enabling TightVNC protocol extensions");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
232 rfb.setupTunneling();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
233 authType = rfb.negotiateAuthenticationTight();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
234 } else {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
235 authType = secType;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
236 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
237
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
238 switch (authType) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
239 case RfbProto.AuthNone:
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
240 showConnectionStatus("No authentication needed");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
241 rfb.authenticateNone();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
242 break;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
243 case RfbProto.AuthVNC:
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
244 showConnectionStatus("Performing standard VNC authentication");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
245 if (passwordParam != null) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
246 rfb.authenticateVNC(passwordParam);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
247 } else {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
248 String pw = askPassword();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
249 rfb.authenticateVNC(pw);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
250 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
251 break;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
252 default:
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
253 throw new Exception("Unknown authentication scheme " + authType);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
254 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
255 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
256
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
257 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
258 // Show a message describing the connection status.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
259 // To hide the connection status label, use (msg == null).
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
260 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
261
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
262 void showConnectionStatus(String msg) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
263 System.out.println(msg);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
264 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
265
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
266 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
267 // Show an authentication panel.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
268 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
269
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
270 String askPassword() throws Exception {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
271 /*
30
a0e1fc94d344 print out html file's text
e085711
parents: 27
diff changeset
272 * showConnectionStatus(null);
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
273 * AuthPanel authPanel = new AuthPanel(this);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
274 *
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
275 * GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth =
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
276 * GridBagConstraints.REMAINDER; gbc.anchor =
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
277 * GridBagConstraints.NORTHWEST; gbc.weightx = 1.0; gbc.weighty = 1.0;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
278 * gbc.ipadx = 100; gbc.ipady = 50; gridbag.setConstraints(authPanel,
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
279 * gbc); vncContainer.add(authPanel);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
280
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
281
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
282 authPanel.moveFocusToDefaultField();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
283 vncContainer.remove(authPanel);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
284 */
30
a0e1fc94d344 print out html file's text
e085711
parents: 27
diff changeset
285 showConnectionStatus("ask password...");
31
cb0e4fd2d982 upload CreateHtmlFile.java
e085711
parents: 30
diff changeset
286 String pw = mainArgs[2];
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
287 return pw;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
288 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
289
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
290 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
291 // Do the rest of the protocol initialisation.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
292 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
293
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
294 void doProtocolInitialisation() throws IOException {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
295 rfb.writeClientInit();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
296 rfb.readServerInit();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
297
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
298
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
299 System.out.println("Desktop name is " + rfb.desktopName);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
300 System.out.println("Desktop size is " + rfb.framebufferWidth + " x "
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
301 + rfb.framebufferHeight);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
302
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
303 setEncodings();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
304
30
a0e1fc94d344 print out html file's text
e085711
parents: 27
diff changeset
305 //showConnectionStatus(null);
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
306 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
307
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
308 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
309 // Send current encoding list to the RFB server.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
310 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
311
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
312 int[] encodingsSaved;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
313 int nEncodingsSaved;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
314
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
315 void setEncodings() {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
316 setEncodings(false);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
317 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
318
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
319 void autoSelectEncodings() {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
320 setEncodings(true);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
321 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
322
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
323 void setEncodings(boolean autoSelectOnly) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
324 if (options == null || rfb == null || !rfb.inNormalProtocol)
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
325 return;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
326
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
327 int preferredEncoding = options.preferredEncoding;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
328 if (preferredEncoding == -1) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
329 long kbitsPerSecond = rfb.kbitsPerSecond();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
330 if (nEncodingsSaved < 1) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
331 // Choose Tight or ZRLE encoding for the very first update.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
332 System.out.println("Using Tight/ZRLE encodings");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
333 preferredEncoding = RfbProto.EncodingTight;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
334 } else if (kbitsPerSecond > 2000
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
335 && encodingsSaved[0] != RfbProto.EncodingHextile) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
336 // Switch to Hextile if the connection speed is above 2Mbps.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
337 System.out.println("Throughput " + kbitsPerSecond
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
338 + " kbit/s - changing to Hextile encoding");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
339 preferredEncoding = RfbProto.EncodingHextile;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
340 } else if (kbitsPerSecond < 1000
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
341 && encodingsSaved[0] != RfbProto.EncodingTight) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
342 // Switch to Tight/ZRLE if the connection speed is below 1Mbps.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
343 System.out.println("Throughput " + kbitsPerSecond
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
344 + " kbit/s - changing to Tight/ZRLE encodings");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
345 preferredEncoding = RfbProto.EncodingTight;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
346 } else {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
347 // Don't change the encoder.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
348 if (autoSelectOnly)
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
349 return;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
350 preferredEncoding = encodingsSaved[0];
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
351 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
352 } else {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
353 // Auto encoder selection is not enabled.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
354 if (autoSelectOnly)
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
355 return;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
356 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
357
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
358 int[] encodings = new int[20];
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
359 int nEncodings = 0;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
360
80
712a047908df recompress output
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 78
diff changeset
361
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
362 encodings[nEncodings++] = preferredEncoding;
130
cb00150c223e implement sendEchoPort
e085711
parents: 125
diff changeset
363
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
364 if (options.useCopyRect) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
365 encodings[nEncodings++] = RfbProto.EncodingCopyRect;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
366 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
367 if (preferredEncoding != RfbProto.EncodingTight) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
368 encodings[nEncodings++] = RfbProto.EncodingTight;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
369 }
130
cb00150c223e implement sendEchoPort
e085711
parents: 125
diff changeset
370
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
371 if (preferredEncoding != RfbProto.EncodingZRLE) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
372 encodings[nEncodings++] = RfbProto.EncodingZRLE;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
373 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
374 if (preferredEncoding != RfbProto.EncodingHextile) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
375 encodings[nEncodings++] = RfbProto.EncodingHextile;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
376 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
377 if (preferredEncoding != RfbProto.EncodingZlib) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
378 encodings[nEncodings++] = RfbProto.EncodingZlib;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
379 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
380 if (preferredEncoding != RfbProto.EncodingCoRRE) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
381 encodings[nEncodings++] = RfbProto.EncodingCoRRE;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
382 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
383 if (preferredEncoding != RfbProto.EncodingRRE) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
384 encodings[nEncodings++] = RfbProto.EncodingRRE;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
385 }
122
2ff8d5a226c9 modify VncProxyService.java
e085711
parents: 117
diff changeset
386 /*
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
387 if (options.compressLevel >= 0 && options.compressLevel <= 9) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
388 encodings[nEncodings++] = RfbProto.EncodingCompressLevel0
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
389 + options.compressLevel;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
390 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
391 if (options.jpegQuality >= 0 && options.jpegQuality <= 9) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
392 encodings[nEncodings++] = RfbProto.EncodingQualityLevel0
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
393 + options.jpegQuality;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
394 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
395 if (options.requestCursorUpdates) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
396 encodings[nEncodings++] = RfbProto.EncodingXCursor;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
397 encodings[nEncodings++] = RfbProto.EncodingRichCursor;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
398 if (!options.ignoreCursorUpdates)
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
399 encodings[nEncodings++] = RfbProto.EncodingPointerPos;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
400 }
78
5970410efee7 modify VncProxyService. EncodingRAW -> EncodingZlib
e085711
parents: 76
diff changeset
401 */
5970410efee7 modify VncProxyService. EncodingRAW -> EncodingZlib
e085711
parents: 76
diff changeset
402
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
403 encodings[nEncodings++] = RfbProto.EncodingLastRect;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
404 encodings[nEncodings++] = RfbProto.EncodingNewFBSize;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
405
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
406 boolean encodingsWereChanged = false;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
407 if (nEncodings != nEncodingsSaved) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
408 encodingsWereChanged = true;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
409 } else {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
410 for (int i = 0; i < nEncodings; i++) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
411 if (encodings[i] != encodingsSaved[i]) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
412 encodingsWereChanged = true;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
413 break;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
414 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
415 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
416 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
417
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
418 if (encodingsWereChanged) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
419 try {
122
2ff8d5a226c9 modify VncProxyService.java
e085711
parents: 117
diff changeset
420 rfb.writeSetEncodings(encodings, nEncodings);
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
421 if (vc != null) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
422 vc.softCursorFree();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
423 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
424 } catch (Exception e) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
425 e.printStackTrace();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
426 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
427 encodingsSaved = encodings;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
428 nEncodingsSaved = nEncodings;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
429 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
430 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
431
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
432 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
433 // setCutText() - send the given cut text to the RFB server.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
434 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
435
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
436 void setCutText(String text) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
437 try {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
438 if (rfb != null && rfb.inNormalProtocol) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
439 rfb.writeClientCutText(text);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
440 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
441 } catch (Exception e) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
442 e.printStackTrace();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
443 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
444 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
445
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
446 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
447 // Order change in session recording status. To stop recording, pass
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
448 // null in place of the fname argument.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
449 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
450
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
451 void setRecordingStatus(String fname) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
452 synchronized (recordingSync) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
453 sessionFileName = fname;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
454 recordingStatusChanged = true;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
455 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
456 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
457
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
458 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
459 // Start or stop session recording. Returns true if this method call
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
460 // causes recording of a new session.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
461 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
462
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
463 boolean checkRecordingStatus() throws IOException {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
464 synchronized (recordingSync) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
465 if (recordingStatusChanged) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
466 recordingStatusChanged = false;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
467 if (sessionFileName != null) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
468 startRecording();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
469 return true;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
470 } else {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
471 stopRecording();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
472 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
473 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
474 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
475 return false;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
476 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
477
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
478 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
479 // Start session recording.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
480 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
481
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
482 protected void startRecording() throws IOException {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
483 synchronized (recordingSync) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
484 if (!recordingActive) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
485 // Save settings to restore them after recording the session.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
486 cursorUpdatesDef = options.choices[options.cursorUpdatesIndex]
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
487 .getSelectedItem();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
488 eightBitColorsDef = options.choices[options.eightBitColorsIndex]
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
489 .getSelectedItem();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
490 // Set options to values suitable for recording.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
491 options.choices[options.cursorUpdatesIndex].select("Disable");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
492 options.choices[options.cursorUpdatesIndex].setEnabled(false);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
493 options.setEncodings();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
494 options.choices[options.eightBitColorsIndex].select("No");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
495 options.choices[options.eightBitColorsIndex].setEnabled(false);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
496 options.setColorFormat();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
497 } else {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
498 rfb.closeSession();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
499 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
500
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
501 System.out.println("Recording the session in " + sessionFileName);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
502 rfb.startSession(sessionFileName);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
503 recordingActive = true;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
504 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
505 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
506
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
507 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
508 // Stop session recording.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
509 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
510
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
511 protected void stopRecording() throws IOException {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
512 synchronized (recordingSync) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
513 if (recordingActive) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
514 // Restore options.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
515 options.choices[options.cursorUpdatesIndex]
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
516 .select(cursorUpdatesDef);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
517 options.choices[options.cursorUpdatesIndex].setEnabled(true);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
518 options.setEncodings();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
519 options.choices[options.eightBitColorsIndex]
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
520 .select(eightBitColorsDef);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
521 options.choices[options.eightBitColorsIndex].setEnabled(true);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
522 options.setColorFormat();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
523
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
524 rfb.closeSession();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
525 System.out.println("Session recording stopped.");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
526 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
527 sessionFileName = null;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
528 recordingActive = false;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
529 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
530 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
531
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
532 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
533 // readParameters() - read parameters from the html source or from the
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
534 // command line. On the command line, the arguments are just a sequence of
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
535 // param_name/param_value pairs where the names and values correspond to
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
536 // those expected in the html applet tag source.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
537 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
538
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
539 void readParameters() {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
540
30
a0e1fc94d344 print out html file's text
e085711
parents: 27
diff changeset
541 host = mainArgs[0];
31
cb0e4fd2d982 upload CreateHtmlFile.java
e085711
parents: 30
diff changeset
542 if(mainArgs.length < 2){
30
a0e1fc94d344 print out html file's text
e085711
parents: 27
diff changeset
543 port = 5900;
a0e1fc94d344 print out html file's text
e085711
parents: 27
diff changeset
544 }else{
31
cb0e4fd2d982 upload CreateHtmlFile.java
e085711
parents: 30
diff changeset
545 port = Integer.parseInt(mainArgs[1]);
30
a0e1fc94d344 print out html file's text
e085711
parents: 27
diff changeset
546 }
a0e1fc94d344 print out html file's text
e085711
parents: 27
diff changeset
547
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
548
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
549 // Read "ENCPASSWORD" or "PASSWORD" parameter if specified.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
550 // readPasswordParameters();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
551
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
552 String str;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
553
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
554 // "Show Controls" set to "No" disables button panel.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
555 showControls = true;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
556 str = readParameter("Show Controls", false);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
557 if (str != null && str.equalsIgnoreCase("No"))
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
558 showControls = false;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
559
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
560 // "Offer Relogin" set to "No" disables "Login again" and "Close
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
561 // window" buttons under error messages in applet mode.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
562 offerRelogin = true;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
563 str = readParameter("Offer Relogin", false);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
564 if (str != null && str.equalsIgnoreCase("No"))
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
565 offerRelogin = false;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
566
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
567 // Do we continue showing desktop on remote disconnect?
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
568 showOfflineDesktop = false;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
569 str = readParameter("Show Offline Desktop", false);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
570 if (str != null && str.equalsIgnoreCase("Yes"))
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
571 showOfflineDesktop = true;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
572
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
573 // Fine tuning options.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
574 deferScreenUpdates = readIntParameter("Defer screen updates", 20);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
575 deferCursorUpdates = readIntParameter("Defer cursor updates", 10);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
576 deferUpdateRequests = readIntParameter("Defer update requests", 0);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
577
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
578 // Debugging options.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
579 debugStatsExcludeUpdates = readIntParameter("DEBUG_XU", 0);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
580 debugStatsMeasureUpdates = readIntParameter("DEBUG_CU", 0);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
581
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
582 // SocketFactory.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
583 socketFactory = readParameter("SocketFactory", false);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
584 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
585
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
586 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
587 // Read password parameters. If an "ENCPASSWORD" parameter is set,
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
588 // then decrypt the password into the passwordParam string. Otherwise,
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
589 // try to read the "PASSWORD" parameter directly to passwordParam.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
590 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
591
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
592 private void readPasswordParameters() {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
593 // String encPasswordParam = readParameter("ENCPASSWORD", false);
31
cb0e4fd2d982 upload CreateHtmlFile.java
e085711
parents: 30
diff changeset
594 String encPasswordParam = mainArgs[2];
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
595
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
596 if (encPasswordParam == null) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
597 // passwordParam = readParameter("PASSWORD", false);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
598
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
599 } else {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
600 // ENCPASSWORD is hexascii-encoded. Decode.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
601 byte[] pw = { 0, 0, 0, 0, 0, 0, 0, 0 };
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
602 int len = encPasswordParam.length() / 2;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
603 if (len > 8)
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
604 len = 8;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
605 for (int i = 0; i < len; i++) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
606 String hex = encPasswordParam.substring(i * 2, i * 2 + 2);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
607 Integer x = new Integer(Integer.parseInt(hex, 16));
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
608 pw[i] = x.byteValue();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
609 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
610 // Decrypt the password.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
611 byte[] key = { 23, 82, 107, 6, 35, 78, 88, 7 };
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
612 DesCipher des = new DesCipher(key);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
613 des.decrypt(pw, 0, pw, 0);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
614 passwordParam = new String(pw);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
615
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
616 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
617 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
618
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
619 public String readParameter(String name, boolean required) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
620 for (int i = 0; i < mainArgs.length; i += 2) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
621 if (mainArgs[i].equalsIgnoreCase(name)) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
622 try {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
623 return mainArgs[i + 1];
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
624 } catch (Exception e) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
625 if (required) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
626 fatalError(name + " parameter not specified");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
627 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
628 return null;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
629 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
630 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
631 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
632 if (required) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
633 fatalError(name + " parameter not specified");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
634 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
635 return null;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
636 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
637
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
638 int readIntParameter(String name, int defaultValue) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
639 String str = readParameter(name, false);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
640 int result = defaultValue;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
641 if (str != null) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
642 try {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
643 result = Integer.parseInt(str);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
644 } catch (NumberFormatException e) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
645 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
646 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
647 return result;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
648 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
649
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
650 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
651 // disconnect() - close connection to server.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
652 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
653
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
654 synchronized public void disconnect() {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
655 System.out.println("Disconnecting");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
656
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
657 if (vc != null) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
658 double sec = (System.currentTimeMillis() - vc.statStartTime) / 1000.0;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
659 double rate = Math.round(vc.statNumUpdates / sec * 100) / 100.0;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
660 int nRealRects = vc.statNumPixelRects;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
661 int nPseudoRects = vc.statNumTotalRects - vc.statNumPixelRects;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
662 System.out.println("Updates received: " + vc.statNumUpdates + " ("
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
663 + nRealRects + " rectangles + " + nPseudoRects
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
664 + " pseudo), " + rate + " updates/sec");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
665 int numRectsOther = nRealRects - vc.statNumRectsTight
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
666 - vc.statNumRectsZRLE - vc.statNumRectsHextile
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
667 - vc.statNumRectsRaw - vc.statNumRectsCopy;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
668 System.out.println("Rectangles:" + " Tight=" + vc.statNumRectsTight
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
669 + "(JPEG=" + vc.statNumRectsTightJPEG + ") ZRLE="
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
670 + vc.statNumRectsZRLE + " Hextile="
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
671 + vc.statNumRectsHextile + " Raw=" + vc.statNumRectsRaw
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
672 + " CopyRect=" + vc.statNumRectsCopy + " other="
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
673 + numRectsOther);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
674
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
675 int raw = vc.statNumBytesDecoded;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
676 int compressed = vc.statNumBytesEncoded;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
677 if (compressed > 0) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
678 double ratio = Math.round((double) raw / compressed * 1000) / 1000.0;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
679 System.out.println("Pixel data: " + vc.statNumBytesDecoded
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
680 + " bytes, " + vc.statNumBytesEncoded
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
681 + " compressed, ratio " + ratio);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
682 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
683 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
684
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
685 if (rfb != null && !rfb.closed())
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
686 rfb.close();
67
f695bc56eb4f add OptionNoFrame.java. add setEncodings.
e085711
parents: 66
diff changeset
687 // options.dispose();
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
688 clipboard.dispose();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
689 if (rec != null)
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
690 rec.dispose();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
691
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
692 System.exit(0);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
693
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
694 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
695
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
696 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
697 // fatalError() - print out a fatal error message.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
698 // FIXME: Do we really need two versions of the fatalError() method?
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
699 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
700
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
701 synchronized public void fatalError(String str) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
702 System.out.println(str);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
703 System.exit(1);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
704 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
705
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
706 synchronized public void fatalError(String str, Exception e) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
707
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
708 if (rfb != null && rfb.closed()) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
709 // Not necessary to show error message if the error was caused
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
710 // by I/O problems after the rfb.close() method call.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
711 System.out.println("RFB thread finished");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
712 return;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
713 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
714
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
715 System.out.println(str);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
716 e.printStackTrace();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
717
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
718 if (rfb != null)
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
719 rfb.close();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
720
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
721 System.exit(1);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
722
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
723 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
724
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
725 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
726 // Show message text and optionally "Relogin" and "Close" buttons.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
727 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
728
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
729 void showMessage(String msg) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
730 vncContainer.removeAll();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
731
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
732 Label errLabel = new Label(msg, Label.CENTER);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
733 errLabel.setFont(new Font("Helvetica", Font.PLAIN, 12));
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
734
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
735 if (offerRelogin) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
736 /*
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
737 * Panel gridPanel = new Panel(new GridLayout(0, 1)); Panel
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
738 * outerPanel = new Panel(new FlowLayout(FlowLayout.LEFT));
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
739 * outerPanel.add(gridPanel); vncContainer.setLayout(new
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
740 * FlowLayout(FlowLayout.LEFT, 30, 16));
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
741 * vncContainer.add(outerPanel); Panel textPanel = new Panel(new
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
742 * FlowLayout(FlowLayout.CENTER)); textPanel.add(errLabel);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
743 * gridPanel.add(textPanel); gridPanel.add(new ReloginPanel(this));
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
744 */
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
745 } else {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
746 /*
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
747 * vncContainer.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 30));
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
748 * vncContainer.add(errLabel);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
749 */
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
750 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
751
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
752 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
753
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
754 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
755 // Stop the applet.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
756 // Main applet thread will terminate on first exception
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
757 // after seeing that rfbThread has been set to null.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
758 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
759
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
760 public void stop() {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
761 System.out.println("Stopping applet");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
762 rfbThread = null;
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
763 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
764
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
765 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
766 // This method is called before the applet is destroyed.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
767 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
768
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
769 public void destroy() {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
770 System.out.println("Destroying applet");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
771
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
772 vncContainer.removeAll();
67
f695bc56eb4f add OptionNoFrame.java. add setEncodings.
e085711
parents: 66
diff changeset
773 // options.dispose();
13
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
774 clipboard.dispose();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
775 if (rec != null)
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
776 rec.dispose();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
777 if (rfb != null && !rfb.closed())
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
778 rfb.close();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
779 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
780
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
781 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
782 // Start/stop receiving mouse events.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
783 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
784
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
785 public void enableInput(boolean enable) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
786 vc.enableInput(enable);
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
787 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
788
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
789 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
790 // Close application properly on window close event.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
791 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
792
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
793 public void windowClosing(WindowEvent evt) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
794 System.out.println("Closing window");
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
795 if (rfb != null)
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
796 disconnect();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
797
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
798 vncContainer.hide();
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
799
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
800 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
801
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
802 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
803 // Ignore window events we're not interested in.
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
804 //
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
805
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
806 public void windowActivated(WindowEvent evt) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
807 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
808
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
809 public void windowDeactivated(WindowEvent evt) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
810 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
811
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
812 public void windowOpened(WindowEvent evt) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
813 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
814
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
815 public void windowClosed(WindowEvent evt) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
816 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
817
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
818 public void windowIconified(WindowEvent evt) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
819 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
820
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
821 public void windowDeiconified(WindowEvent evt) {
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
822 }
a5d73cafc8fe add ProxyVncCanvas and VncProxyService
e085711
parents:
diff changeset
823 }