annotate src/myVncProxy/VncProxyService.java @ 125:e3dddee7b934

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