annotate src/myVncClient/CuiMyVncClient.java @ 94:1783ca4e4877

update
author e085711
date Tue, 04 Oct 2011 23:51:32 +0900
parents 71bfbb5241bf
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
1 package myVncClient;
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
2
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
3 import java.awt.*;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
4 import java.awt.event.*;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
5 import java.io.*;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
6 import java.net.*;
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
7 import java.nio.ByteBuffer;
67
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
8 import java.util.Random;
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
9
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
10 import myVncClient.AcceptThread;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
11 import myVncClient.OptionsNoFrame;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
12
69
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
13 public class CuiMyVncClient implements InterfaceForViewer {
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
14
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
15
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
16 String[] mainArgs;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
17 String username;
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
18
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
19 // RfbProto rfb;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
20 MyRfbProto rfb;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
21 Thread rfbThread;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
22 Thread accThread;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
23 Thread clientThread;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
24
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
25 Frame vncFrame;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
26 Container vncContainer;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
27 ScrollPane desktopScrollPane;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
28 GridBagLayout gridbag;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
29 ButtonPanel buttonPanel;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
30 Label connStatusLabel;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
31 CuiVncCanvas vc;
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
32 // OptionsFrame options;
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
33 OptionsNoFrame options;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
34 ClipboardFrame clipboard;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
35 RecordingFrame rec;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
36
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
37 // Control session recording.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
38 Object recordingSync;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
39 String sessionFileName;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
40 boolean recordingActive;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
41 boolean recordingStatusChanged;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
42 String cursorUpdatesDef;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
43 String eightBitColorsDef;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
44
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
45 // Variables read from parameter values.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
46 String socketFactory;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
47 String host;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
48 int port;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
49 String passwordParam;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
50 boolean showControls;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
51 boolean offerRelogin;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
52 boolean showOfflineDesktop;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
53 int deferScreenUpdates;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
54 int deferCursorUpdates;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
55 int deferUpdateRequests;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
56 int debugStatsExcludeUpdates;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
57 int debugStatsMeasureUpdates;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
58
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
59 private static final long serialVersionUID = 1L;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
60 boolean inAnApplet = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
61 boolean inSeparateFrame = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
62 Socket clientSocket = null;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
63 String parent, treenum;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
64 private String leaderflag;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
65 boolean runflag = false;
69
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
66 boolean first = true;
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
67
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
68 EchoClient echoValue;
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
69 int echoPort;
80
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
70 String pHost;
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
71
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
72 public static void main(String[] argv) {
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
73 CuiMyVncClient v = new CuiMyVncClient();
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
74 v.echoValue = null;
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
75 v.runClient(argv, v);
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
76
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
77 }
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
78
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
79 private void runClient(String[] argv, CuiMyVncClient v) {
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
80 mainArgs = argv;
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
81
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
82 if (mainArgs.length > 0)
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
83 pHost = mainArgs[0];
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
84 else
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
85 pHost = "cls080.ie.u-ryukyu.ac.jp";
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
86 if (mainArgs.length > 1)
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
87 port = Integer.parseInt(mainArgs[1]);
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
88 else
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
89 port = 5999;
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
90
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
91 v.init();
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
92 v.start_threads();
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
93
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
94 }
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
95
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
96
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
97 void checkArgs(String[] argv) {
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
98 if (argv.length > 3) {
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
99 username = argv[3];
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
100 } else if (argv.length < 2) {
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
101 System.out.println("Please enter argv");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
102 System.out.println("hostname(IPaddress) port password");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
103 System.exit(0);
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
104 } else {
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
105 username = argv[0];
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
106 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
107 }
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
108
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
109 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
110 // init()
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
111 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
112
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
113 public void init() {
70
affdcbdc90ea modify CreateCanva.java. implement ZRLEE.
e085711
parents: 69
diff changeset
114
69
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
115 Random rnd = new Random();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
116 long ran = rnd.nextInt(5000);
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
117 try {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
118 Thread.sleep(ran);
70
affdcbdc90ea modify CreateCanva.java. implement ZRLEE.
e085711
parents: 69
diff changeset
119 } catch (InterruptedException e) {
affdcbdc90ea modify CreateCanva.java. implement ZRLEE.
e085711
parents: 69
diff changeset
120 e.printStackTrace();
69
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
121 }
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
122
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
123 readParameters();
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
124 //readParameters(value);
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
125
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
126 options = new OptionsNoFrame(this);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
127 recordingSync = new Object();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
128
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
129 sessionFileName = null;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
130 recordingActive = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
131 recordingStatusChanged = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
132 cursorUpdatesDef = null;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
133 eightBitColorsDef = null;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
134
67
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
135 /*
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
136 * try { connectAndAuthenticate(); } catch (NoRouteToHostException e) {
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
137 * fatalError("Network error: no route to server: " + host, e); } catch
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
138 * (UnknownHostException e) {
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
139 * fatalError("Network error: server name unknown: " + host, e); } catch
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
140 * (ConnectException e) {
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
141 * fatalError("Network error: could not connect to server: " + host +
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
142 * ":" + port, e); } catch (Exception e) { }
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
143 */
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
144 rfbThread = new Thread(this);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
145
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
146 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
147
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
148 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
149 // run() - executed by the rfbThread to deal with the RFB socket.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
150 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
151
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
152 public void start_threads() {
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
153 rfbThread.start();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
154 }
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
155
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
156 public void run() {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
157
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
158 try {
69
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
159 if (first) {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
160 connectAndAuthenticate();
70
affdcbdc90ea modify CreateCanva.java. implement ZRLEE.
e085711
parents: 69
diff changeset
161 accThread = new Thread(new AcceptThread(rfb, 5999));
affdcbdc90ea modify CreateCanva.java. implement ZRLEE.
e085711
parents: 69
diff changeset
162 accThread.start();
69
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
163 first = false;
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
164 }else {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
165 reConnectAndAuthenticate();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
166 }
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
167 doProtocolInitialisation();
67
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
168
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
169 vc = new CuiVncCanvas(this, 0, 0);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
170 vc.updateFramebufferSize();
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
171
67
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
172 } catch (IOException e) {
70
affdcbdc90ea modify CreateCanva.java. implement ZRLEE.
e085711
parents: 69
diff changeset
173
67
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
174 System.out.println("Socket error");
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
175 // parent no find
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
176 Random rnd = new Random();
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
177 long ran = rnd.nextInt(5000) + 5000;
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
178 System.out.println(ran);
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
179 // 親がいない場合の処理はここに書く!!!!
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
180 /**
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
181 * this while reconnection
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
182 */
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
183
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
184 int counter = 0;
69
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
185
67
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
186 /*
69
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
187 vncFrame.setVisible(false);
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
188 vncFrame.dispose();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
189 */
67
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
190 while (true) {
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
191 /**
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
192 * if my last node case reconnectoion stop
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
193 */
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
194
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
195 echoValue = new EchoClient(echoValue, this);
67
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
196 try {
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
197 Thread.sleep(ran);
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
198 } catch (InterruptedException e1) {
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
199 e1.printStackTrace();
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
200 }
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
201
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
202 if (counter >= 3) {
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
203 echoValue.openport();
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
204 echoValue.notfoundParent();
67
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
205 }
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
206
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
207 echoValue.openport();
67
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
208 // runflag = echo.losthost();
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
209 if (echoValue.losthost()) {
71
f6cb1edc2036 modify EchoClient.java. System.exit(0)
e085711
parents: 70
diff changeset
210 break;
67
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
211 }
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
212 counter++;
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
213 }
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
214 // System.exit(0);
69
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
215 }catch (Exception e) {
67
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
216 System.out.println(e);
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
217 System.exit(0);
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
218 }
69
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
219 try{
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
220
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
221 processNormalProtocol();// main loop
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
222
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
223 } catch (NoRouteToHostException e) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
224 fatalError("Network error: no route to server: " + host, e);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
225 } catch (UnknownHostException e) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
226 fatalError("Network error: server name unknown: " + host, e);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
227 } catch (ConnectException e) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
228 fatalError("Network error: could not connect to server: " + host
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
229 + ":" + port, e);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
230 } catch (EOFException e) {
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
231
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
232 if (leaderflag != null) {
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
233 while (true) {
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
234 echoValue = new EchoClient(echoValue, this);
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
235 echoValue.openport();
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
236 // runflag = echo.losthost();
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
237 if (echoValue.losthost()) {
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
238 break;
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
239 }
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
240 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
241 } else {
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
242 if (showOfflineDesktop) {
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
243 e.printStackTrace();
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
244 System.out
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
245 .println("Network error: remote side closed connection");
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
246 if (vc != null) {
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
247 vc.enableInput(false);
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
248 }
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
249 if (rfb != null && !rfb.closed())
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
250 rfb.close();
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
251 if (showControls && buttonPanel != null) {
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
252 buttonPanel.disableButtonsOnDisconnect();
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
253 }
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
254 } else {
67
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
255 fatalError("Network error: remote side closed connection",
5e7110277cf0 modify CuiMyVncClient
e085711
parents: 65
diff changeset
256 e);
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
257 }
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
258 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
259 } catch (IOException e) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
260 String str = e.getMessage();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
261 if (str != null && str.length() != 0) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
262 fatalError("Network Error: " + str, e);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
263 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
264 fatalError(e.toString(), e);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
265 }
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
266 } catch (Exception e) {
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
267 String str = e.getMessage();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
268 if (str != null && str.length() != 0) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
269 fatalError("Error: " + str, e);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
270 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
271 fatalError(e.toString(), e);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
272 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
273 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
274
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
275 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
276
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
277 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
278 // Process RFB socket messages.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
279 // If the rfbThread is being stopped, ignore any exceptions,
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
280 // otherwise rethrow the exception so it can be handled.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
281 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
282
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
283 void processNormalProtocol() throws Exception {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
284 try {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
285 vc.processNormalProtocol();// main loop
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
286 } catch (Exception e) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
287 if (rfbThread == null) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
288 System.out.println("Ignoring RFB socket exceptions"
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
289 + " because applet is stopping");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
290 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
291 throw e;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
292 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
293 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
294 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
295
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
296 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
297 // Connect to the RFB server and authenticate the user.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
298 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
299
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
300 void connectAndAuthenticate() throws Exception {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
301 showConnectionStatus("Initializing...");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
302
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
303 showConnectionStatus("Connecting to " + host + ", port " + port + "...");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
304
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
305 // rfb = new RfbProto(host, port, this);
93
71bfbb5241bf modify CuiMyVncClient
e085711
parents: 92
diff changeset
306 rfb = new MyRfbProto(pHost, port, this);
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
307
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
308 showConnectionStatus("Connected to server");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
309
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
310 rfb.readVersionMsg();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
311 showConnectionStatus("RFB server supports protocol version "
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
312 + rfb.serverMajor + "." + rfb.serverMinor);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
313
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
314 rfb.writeVersionMsg();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
315 showConnectionStatus("Using RFB protocol version " + rfb.clientMajor
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
316 + "." + rfb.clientMinor);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
317
80
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
318
90
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
319 if (rfb.serverMinor == 855) {
94
e085711
parents: 93
diff changeset
320 /*
e085711
parents: 93
diff changeset
321 * if connect to proxy, userEchoPortFlag is true.
e085711
parents: 93
diff changeset
322 * if connect to client, userEchoPortFlag is false.
e085711
parents: 93
diff changeset
323 */
91
d89e03d99b7f modify readJpegData()
e085711
parents: 90
diff changeset
324 boolean useEchoPortFlag = rfb.readProxyFlag();
94
e085711
parents: 93
diff changeset
325
91
d89e03d99b7f modify readJpegData()
e085711
parents: 90
diff changeset
326 if (useEchoPortFlag) {
90
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
327 byte[] b = new byte[4];
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
328 b = rfb.readEchoPort();
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
329 echoPort = castByteInt(b);
76
70004fedb1d1 modify connectAndAuthenticate
e085711
parents: 75
diff changeset
330
90
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
331 InetAddress addr = InetAddress.getByName(pHost);
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
332 String h = new String(addr.getHostAddress());
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
333
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
334 getParentName();
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
335 if (!(h.equals(host))) {
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
336 rfb.changeParent(host, port);
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
337 rfb.readVersionMsg();
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
338 rfb.writeVersionMsg();
94
e085711
parents: 93
diff changeset
339 boolean flag = rfb.readProxyFlag();
90
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
340 }
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
341 }
90
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
342 }
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
343
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
344 int secType = rfb.negotiateSecurity();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
345 int authType;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
346 if (secType == RfbProto.SecTypeTight) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
347 showConnectionStatus("Enabling TightVNC protocol extensions");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
348 rfb.setupTunneling();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
349 authType = rfb.negotiateAuthenticationTight();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
350 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
351 authType = secType;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
352 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
353
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
354 switch (authType) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
355 case RfbProto.AuthNone:
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
356 showConnectionStatus("No authentication needed");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
357 rfb.authenticateNone();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
358 break;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
359 case RfbProto.AuthVNC:
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
360 showConnectionStatus("Performing standard VNC authentication");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
361 if (passwordParam != null) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
362 rfb.authenticateVNC(passwordParam);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
363 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
364 String pw = askPassword();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
365 rfb.authenticateVNC(pw);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
366 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
367 break;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
368 default:
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
369 throw new Exception("Unknown authentication scheme " + authType);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
370 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
371 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
372
70
affdcbdc90ea modify CreateCanva.java. implement ZRLEE.
e085711
parents: 69
diff changeset
373
affdcbdc90ea modify CreateCanva.java. implement ZRLEE.
e085711
parents: 69
diff changeset
374
69
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
375 void reConnectAndAuthenticate() throws Exception {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
376 showConnectionStatus("Initializing...");
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
377
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
378 showConnectionStatus("Connecting to " + host + ", port " + port + "...");
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
379
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
380 rfb.changeParent(host, port);
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
381
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
382 showConnectionStatus("Connected to server");
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
383
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
384 rfb.readVersionMsg();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
385 showConnectionStatus("RFB server supports protocol version "
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
386 + rfb.serverMajor + "." + rfb.serverMinor);
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
387
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
388 rfb.writeVersionMsg();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
389 showConnectionStatus("Using RFB protocol version " + rfb.clientMajor
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
390 + "." + rfb.clientMinor);
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
391
90
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
392 if (rfb.serverMinor == 855) {
91
d89e03d99b7f modify readJpegData()
e085711
parents: 90
diff changeset
393 boolean useEchoPortFlag = rfb.readProxyFlag();
d89e03d99b7f modify readJpegData()
e085711
parents: 90
diff changeset
394 if (useEchoPortFlag) {
90
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
395 byte[] b = new byte[4];
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
396 b = rfb.readEchoPort();
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
397 echoPort = castByteInt(b);
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
398
90
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
399 InetAddress addr = InetAddress.getByName(pHost);
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
400 String h = new String(addr.getHostAddress());
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
401
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
402 getParentName();
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
403 if (!(h.equals(host))) {
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
404 rfb.changeParent(host, port);
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
405 rfb.readVersionMsg();
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
406 rfb.writeVersionMsg();
94
e085711
parents: 93
diff changeset
407 boolean flag = rfb.readProxyFlag();
90
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
408 }
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
409 }
90
7a1e934144e6 modify RFB Protocol version 3.855.
e085711
parents: 89
diff changeset
410 }
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
411
69
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
412 int secType = rfb.negotiateSecurity();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
413 int authType;
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
414 if (secType == RfbProto.SecTypeTight) {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
415 showConnectionStatus("Enabling TightVNC protocol extensions");
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
416 rfb.setupTunneling();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
417 authType = rfb.negotiateAuthenticationTight();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
418 } else {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
419 authType = secType;
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
420 }
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
421
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
422 switch (authType) {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
423 case RfbProto.AuthNone:
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
424 showConnectionStatus("No authentication needed");
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
425 rfb.authenticateNone();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
426 break;
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
427 case RfbProto.AuthVNC:
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
428 showConnectionStatus("Performing standard VNC authentication");
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
429 if (passwordParam != null) {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
430 rfb.authenticateVNC(passwordParam);
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
431 } else {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
432 String pw = askPassword();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
433 rfb.authenticateVNC(pw);
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
434 }
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
435 break;
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
436 default:
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
437 throw new Exception("Unknown authentication scheme " + authType);
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
438 }
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
439 }
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
440
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
441 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
442 // Show a message describing the connection status.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
443 // To hide the connection status label, use (msg == null).
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
444 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
445
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
446 void showConnectionStatus(String msg) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
447 System.out.println(msg);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
448 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
449
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
450 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
451 // Show an authentication panel.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
452 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
453
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
454 String askPassword() throws Exception {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
455 /*
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
456 * showConnectionStatus(null); AuthPanel authPanel = new
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
457 * AuthPanel(this);
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
458 *
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
459 * GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth =
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
460 * GridBagConstraints.REMAINDER; gbc.anchor =
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
461 * GridBagConstraints.NORTHWEST; gbc.weightx = 1.0; gbc.weighty = 1.0;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
462 * gbc.ipadx = 100; gbc.ipady = 50; gridbag.setConstraints(authPanel,
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
463 * gbc); vncContainer.add(authPanel);
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
464 *
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
465 *
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
466 * authPanel.moveFocusToDefaultField(); vncContainer.remove(authPanel);
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
467 */
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
468 showConnectionStatus("ask password...");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
469 String pw = mainArgs[2];
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
470 return pw;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
471 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
472
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
473 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
474 // Do the rest of the protocol initialisation.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
475 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
476
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
477 void doProtocolInitialisation() throws IOException {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
478 rfb.writeClientInit();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
479 rfb.readServerInit();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
480
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
481 System.out.println("Desktop name is " + rfb.desktopName);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
482 System.out.println("Desktop size is " + rfb.framebufferWidth + " x "
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
483 + rfb.framebufferHeight);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
484
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
485 setEncodings();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
486
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
487 // showConnectionStatus(null);
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
488 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
489
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
490 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
491 // Send current encoding list to the RFB server.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
492 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
493
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
494 int[] encodingsSaved;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
495 int nEncodingsSaved;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
496
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
497 void setEncodings() {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
498 setEncodings(false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
499 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
500
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
501 void autoSelectEncodings() {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
502 setEncodings(true);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
503 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
504
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
505 void setEncodings(boolean autoSelectOnly) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
506 if (options == null || rfb == null || !rfb.inNormalProtocol)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
507 return;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
508
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
509 int preferredEncoding = options.preferredEncoding;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
510 if (preferredEncoding == -1) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
511 long kbitsPerSecond = rfb.kbitsPerSecond();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
512 if (nEncodingsSaved < 1) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
513 // Choose Tight or ZRLE encoding for the very first update.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
514 System.out.println("Using Tight/ZRLE encodings");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
515 preferredEncoding = RfbProto.EncodingTight;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
516 } else if (kbitsPerSecond > 2000
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
517 && encodingsSaved[0] != RfbProto.EncodingHextile) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
518 // Switch to Hextile if the connection speed is above 2Mbps.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
519 System.out.println("Throughput " + kbitsPerSecond
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
520 + " kbit/s - changing to Hextile encoding");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
521 preferredEncoding = RfbProto.EncodingHextile;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
522 } else if (kbitsPerSecond < 1000
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
523 && encodingsSaved[0] != RfbProto.EncodingTight) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
524 // Switch to Tight/ZRLE if the connection speed is below 1Mbps.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
525 System.out.println("Throughput " + kbitsPerSecond
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
526 + " kbit/s - changing to Tight/ZRLE encodings");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
527 preferredEncoding = RfbProto.EncodingTight;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
528 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
529 // Don't change the encoder.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
530 if (autoSelectOnly)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
531 return;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
532 preferredEncoding = encodingsSaved[0];
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
533 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
534 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
535 // Auto encoder selection is not enabled.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
536 if (autoSelectOnly)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
537 return;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
538 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
539
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
540 int[] encodings = new int[20];
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
541 int nEncodings = 0;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
542
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
543 encodings[nEncodings++] = preferredEncoding;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
544 if (options.useCopyRect) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
545 encodings[nEncodings++] = RfbProto.EncodingCopyRect;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
546 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
547 if (preferredEncoding != RfbProto.EncodingTight) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
548 encodings[nEncodings++] = RfbProto.EncodingTight;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
549 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
550 if (preferredEncoding != RfbProto.EncodingZRLE) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
551 encodings[nEncodings++] = RfbProto.EncodingZRLE;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
552 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
553 if (preferredEncoding != RfbProto.EncodingHextile) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
554 encodings[nEncodings++] = RfbProto.EncodingHextile;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
555 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
556 if (preferredEncoding != RfbProto.EncodingZlib) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
557 encodings[nEncodings++] = RfbProto.EncodingZlib;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
558 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
559 /*
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
560 * if (preferredEncoding != RfbProto.EncodingCoRRE) {
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
561 * encodings[nEncodings++] = RfbProto.EncodingCoRRE; } if
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
562 * (preferredEncoding != RfbProto.EncodingRRE) { encodings[nEncodings++]
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
563 * = RfbProto.EncodingRRE; }
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
564 *
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
565 * if (options.compressLevel >= 0 && options.compressLevel <= 9) {
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
566 * encodings[nEncodings++] = RfbProto.EncodingCompressLevel0 +
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
567 * options.compressLevel; } if (options.jpegQuality >= 0 &&
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
568 * options.jpegQuality <= 9) { encodings[nEncodings++] =
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
569 * RfbProto.EncodingQualityLevel0 + options.jpegQuality; } if
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
570 * (options.requestCursorUpdates) { encodings[nEncodings++] =
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
571 * RfbProto.EncodingXCursor; encodings[nEncodings++] =
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
572 * RfbProto.EncodingRichCursor; if (!options.ignoreCursorUpdates)
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
573 * encodings[nEncodings++] = RfbProto.EncodingPointerPos; }
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
574 */
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
575
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
576 encodings[nEncodings++] = RfbProto.EncodingLastRect;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
577 encodings[nEncodings++] = RfbProto.EncodingNewFBSize;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
578
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
579 boolean encodingsWereChanged = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
580 if (nEncodings != nEncodingsSaved) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
581 encodingsWereChanged = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
582 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
583 for (int i = 0; i < nEncodings; i++) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
584 if (encodings[i] != encodingsSaved[i]) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
585 encodingsWereChanged = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
586 break;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
587 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
588 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
589 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
590
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
591 if (encodingsWereChanged) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
592 try {
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
593 // rfb.writeSetEncodings(encodings, nEncodings);
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
594 if (vc != null) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
595 vc.softCursorFree();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
596 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
597 } catch (Exception e) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
598 e.printStackTrace();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
599 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
600 encodingsSaved = encodings;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
601 nEncodingsSaved = nEncodings;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
602 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
603 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
604
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
605 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
606 // setCutText() - send the given cut text to the RFB server.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
607 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
608
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
609 void setCutText(String text) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
610 try {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
611 if (rfb != null && rfb.inNormalProtocol) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
612 rfb.writeClientCutText(text);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
613 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
614 } catch (Exception e) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
615 e.printStackTrace();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
616 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
617 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
618
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
619 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
620 // Order change in session recording status. To stop recording, pass
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
621 // null in place of the fname argument.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
622 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
623
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
624 void setRecordingStatus(String fname) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
625 synchronized (recordingSync) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
626 sessionFileName = fname;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
627 recordingStatusChanged = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
628 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
629 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
630
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
631 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
632 // Start or stop session recording. Returns true if this method call
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
633 // causes recording of a new session.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
634 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
635
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
636 boolean checkRecordingStatus() throws IOException {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
637 synchronized (recordingSync) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
638 if (recordingStatusChanged) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
639 recordingStatusChanged = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
640 if (sessionFileName != null) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
641 startRecording();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
642 return true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
643 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
644 stopRecording();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
645 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
646 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
647 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
648 return false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
649 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
650
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
651 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
652 // Start session recording.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
653 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
654
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
655 protected void startRecording() throws IOException {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
656 synchronized (recordingSync) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
657 if (!recordingActive) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
658 // Save settings to restore them after recording the session.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
659 cursorUpdatesDef = options.choices[options.cursorUpdatesIndex]
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
660 .getSelectedItem();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
661 eightBitColorsDef = options.choices[options.eightBitColorsIndex]
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
662 .getSelectedItem();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
663 // Set options to values suitable for recording.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
664 options.choices[options.cursorUpdatesIndex].select("Disable");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
665 options.choices[options.cursorUpdatesIndex].setEnabled(false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
666 options.setEncodings();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
667 options.choices[options.eightBitColorsIndex].select("No");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
668 options.choices[options.eightBitColorsIndex].setEnabled(false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
669 options.setColorFormat();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
670 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
671 rfb.closeSession();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
672 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
673
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
674 System.out.println("Recording the session in " + sessionFileName);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
675 rfb.startSession(sessionFileName);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
676 recordingActive = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
677 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
678 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
679
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
680 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
681 // Stop session recording.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
682 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
683
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
684 protected void stopRecording() throws IOException {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
685 synchronized (recordingSync) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
686 if (recordingActive) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
687 // Restore options.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
688 options.choices[options.cursorUpdatesIndex]
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
689 .select(cursorUpdatesDef);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
690 options.choices[options.cursorUpdatesIndex].setEnabled(true);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
691 options.setEncodings();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
692 options.choices[options.eightBitColorsIndex]
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
693 .select(eightBitColorsDef);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
694 options.choices[options.eightBitColorsIndex].setEnabled(true);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
695 options.setColorFormat();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
696
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
697 rfb.closeSession();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
698 System.out.println("Session recording stopped.");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
699 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
700 sessionFileName = null;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
701 recordingActive = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
702 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
703 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
704
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
705 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
706 // readParameters() - read parameters from the html source or from the
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
707 // command line. On the command line, the arguments are just a sequence of
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
708 // param_name/param_value pairs where the names and values correspond to
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
709 // those expected in the html applet tag source.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
710 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
711
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
712 void readParameters() {
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
713 /*
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
714 * host = readParameter("HOST", !inAnApplet);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
715 *
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
716 * if (host == null) { host = getCodeBase().getHost(); if
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
717 * (host.equals("")) { fatalError("HOST parameter not specified"); } }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
718 *
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
719 * port = readIntParameter("PORT", 5550);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
720 */
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
721
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
722 // Read "ENCPASSWORD" or "PASSWORD" parameter if specified.
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
723 // readPasswordParameters();
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
724
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
725 String str;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
726 if (inAnApplet) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
727 str = readParameter("Open New Window", false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
728 if (str != null && str.equalsIgnoreCase("Yes"))
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
729 inSeparateFrame = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
730 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
731
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
732 // "Show Controls" set to "No" disables button panel.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
733 showControls = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
734 str = readParameter("Show Controls", false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
735 if (str != null && str.equalsIgnoreCase("No"))
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
736 showControls = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
737
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
738 // "Offer Relogin" set to "No" disables "Login again" and "Close
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
739 // window" buttons under error messages in applet mode.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
740 offerRelogin = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
741 str = readParameter("Offer Relogin", false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
742 if (str != null && str.equalsIgnoreCase("No"))
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
743 offerRelogin = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
744
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
745 // Do we continue showing desktop on remote disconnect?
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
746 showOfflineDesktop = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
747 str = readParameter("Show Offline Desktop", false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
748 if (str != null && str.equalsIgnoreCase("Yes"))
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
749 showOfflineDesktop = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
750
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
751 // Fine tuning options.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
752 deferScreenUpdates = readIntParameter("Defer screen updates", 20);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
753 deferCursorUpdates = readIntParameter("Defer cursor updates", 10);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
754 deferUpdateRequests = readIntParameter("Defer update requests", 0);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
755
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
756 // Debugging options.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
757 debugStatsExcludeUpdates = readIntParameter("DEBUG_XU", 0);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
758 debugStatsMeasureUpdates = readIntParameter("DEBUG_CU", 0);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
759
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
760 // SocketFactory.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
761 socketFactory = readParameter("SocketFactory", false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
762 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
763
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
764 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
765 // Read password parameters. If an "ENCPASSWORD" parameter is set,
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
766 // then decrypt the password into the passwordParam string. Otherwise,
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
767 // try to read the "PASSWORD" parameter directly to passwordParam.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
768 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
769
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
770 private void readPasswordParameters() {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
771 String encPasswordParam = readParameter("ENCPASSWORD", false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
772
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
773 if (encPasswordParam == null) {
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
774 passwordParam = readParameter("PASSWORD", false);
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
775 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
776 // ENCPASSWORD is hexascii-encoded. Decode.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
777 byte[] pw = { 0, 0, 0, 0, 0, 0, 0, 0 };
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
778 int len = encPasswordParam.length() / 2;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
779 if (len > 8)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
780 len = 8;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
781 for (int i = 0; i < len; i++) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
782 String hex = encPasswordParam.substring(i * 2, i * 2 + 2);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
783 Integer x = new Integer(Integer.parseInt(hex, 16));
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
784 pw[i] = x.byteValue();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
785 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
786 // Decrypt the password.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
787 byte[] key = { 23, 82, 107, 6, 35, 78, 88, 7 };
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
788 DesCipher des = new DesCipher(key);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
789 des.decrypt(pw, 0, pw, 0);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
790 passwordParam = new String(pw);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
791
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
792 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
793 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
794
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
795 public String readParameter(String name, boolean required) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
796 for (int i = 0; i < mainArgs.length; i += 2) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
797 if (mainArgs[i].equalsIgnoreCase(name)) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
798 try {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
799 return mainArgs[i + 1];
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
800 } catch (Exception e) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
801 if (required) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
802 fatalError(name + " parameter not specified");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
803 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
804 return null;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
805 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
806 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
807 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
808 if (required) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
809 fatalError(name + " parameter not specified");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
810 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
811 return null;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
812 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
813
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
814 int readIntParameter(String name, int defaultValue) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
815 String str = readParameter(name, false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
816 int result = defaultValue;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
817 if (str != null) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
818 try {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
819 result = Integer.parseInt(str);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
820 } catch (NumberFormatException e) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
821 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
822 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
823 return result;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
824 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
825
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
826 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
827 // disconnect() - close connection to server.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
828 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
829
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
830 synchronized public void disconnect() {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
831 System.out.println("Disconnecting");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
832
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
833 if (vc != null) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
834 double sec = (System.currentTimeMillis() - vc.statStartTime) / 1000.0;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
835 double rate = Math.round(vc.statNumUpdates / sec * 100) / 100.0;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
836 int nRealRects = vc.statNumPixelRects;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
837 int nPseudoRects = vc.statNumTotalRects - vc.statNumPixelRects;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
838 System.out.println("Updates received: " + vc.statNumUpdates + " ("
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
839 + nRealRects + " rectangles + " + nPseudoRects
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
840 + " pseudo), " + rate + " updates/sec");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
841 int numRectsOther = nRealRects - vc.statNumRectsTight
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
842 - vc.statNumRectsZRLE - vc.statNumRectsHextile
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
843 - vc.statNumRectsRaw - vc.statNumRectsCopy;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
844 System.out.println("Rectangles:" + " Tight=" + vc.statNumRectsTight
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
845 + "(JPEG=" + vc.statNumRectsTightJPEG + ") ZRLE="
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
846 + vc.statNumRectsZRLE + " Hextile="
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
847 + vc.statNumRectsHextile + " Raw=" + vc.statNumRectsRaw
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
848 + " CopyRect=" + vc.statNumRectsCopy + " other="
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
849 + numRectsOther);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
850
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
851 int raw = vc.statNumBytesDecoded;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
852 int compressed = vc.statNumBytesEncoded;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
853 if (compressed > 0) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
854 double ratio = Math.round((double) raw / compressed * 1000) / 1000.0;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
855 System.out.println("Pixel data: " + vc.statNumBytesDecoded
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
856 + " bytes, " + vc.statNumBytesEncoded
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
857 + " compressed, ratio " + ratio);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
858 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
859 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
860
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
861 if (rfb != null && !rfb.closed())
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
862 rfb.close();
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
863 // options.dispose();
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
864 clipboard.dispose();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
865 if (rec != null)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
866 rec.dispose();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
867
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
868 System.exit(0);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
869
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
870 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
871
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
872 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
873 // fatalError() - print out a fatal error message.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
874 // FIXME: Do we really need two versions of the fatalError() method?
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
875 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
876
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
877 synchronized public void fatalError(String str) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
878 System.out.println(str);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
879 System.exit(1);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
880 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
881
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
882 synchronized public void fatalError(String str, Exception e) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
883
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
884 if (rfb != null && rfb.closed()) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
885 // Not necessary to show error message if the error was caused
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
886 // by I/O problems after the rfb.close() method call.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
887 System.out.println("RFB thread finished");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
888 return;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
889 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
890
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
891 System.out.println(str);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
892 e.printStackTrace();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
893
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
894 if (rfb != null)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
895 rfb.close();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
896
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
897 System.exit(1);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
898
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
899 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
900
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
901 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
902 // Show message text and optionally "Relogin" and "Close" buttons.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
903 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
904
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
905 void showMessage(String msg) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
906 vncContainer.removeAll();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
907
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
908 Label errLabel = new Label(msg, Label.CENTER);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
909 errLabel.setFont(new Font("Helvetica", Font.PLAIN, 12));
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
910
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
911 if (offerRelogin) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
912 /*
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
913 * Panel gridPanel = new Panel(new GridLayout(0, 1)); Panel
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
914 * outerPanel = new Panel(new FlowLayout(FlowLayout.LEFT));
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
915 * outerPanel.add(gridPanel); vncContainer.setLayout(new
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
916 * FlowLayout(FlowLayout.LEFT, 30, 16));
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
917 * vncContainer.add(outerPanel); Panel textPanel = new Panel(new
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
918 * FlowLayout(FlowLayout.CENTER)); textPanel.add(errLabel);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
919 * gridPanel.add(textPanel); gridPanel.add(new ReloginPanel(this));
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
920 */
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
921 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
922 /*
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
923 * vncContainer.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 30));
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
924 * vncContainer.add(errLabel);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
925 */
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
926 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
927
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
928 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
929
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
930 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
931 // Stop the applet.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
932 // Main applet thread will terminate on first exception
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
933 // after seeing that rfbThread has been set to null.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
934 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
935
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
936 public void stop() {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
937 System.out.println("Stopping applet");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
938 rfbThread = null;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
939 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
940
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
941 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
942 // This method is called before the applet is destroyed.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
943 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
944
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
945 public void destroy() {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
946 System.out.println("Destroying applet");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
947
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
948 vncContainer.removeAll();
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
949 // options.dispose();
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
950 clipboard.dispose();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
951 if (rec != null)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
952 rec.dispose();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
953 if (rfb != null && !rfb.closed())
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
954 rfb.close();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
955 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
956
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
957 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
958 // Start/stop receiving mouse events.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
959 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
960
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
961 public void enableInput(boolean enable) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
962 vc.enableInput(enable);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
963 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
964
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
965 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
966 // Close application properly on window close event.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
967 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
968
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
969 public void windowClosing(WindowEvent evt) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
970 System.out.println("Closing window");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
971 if (rfb != null)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
972 disconnect();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
973
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
974 vncContainer.hide();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
975
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
976 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
977
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
978 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
979 // Ignore window events we're not interested in.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
980 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
981
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
982 public void windowActivated(WindowEvent evt) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
983 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
984
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
985 public void windowDeactivated(WindowEvent evt) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
986 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
987
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
988 public void windowOpened(WindowEvent evt) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
989 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
990
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
991 public void windowClosed(WindowEvent evt) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
992 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
993
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
994 public void windowIconified(WindowEvent evt) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
995 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
996
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
997 public void windowDeiconified(WindowEvent evt) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
998 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
999
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
1000 public void setClientSocket(Socket sock) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
1001 clientSocket = sock;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
1002 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
1003
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
1004 public void start() {
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
1005
61
646e6fc14d62 modify some files. for to use Client with CUI
e085711
parents: 60
diff changeset
1006 }
71
f6cb1edc2036 modify EchoClient.java. System.exit(0)
e085711
parents: 70
diff changeset
1007 public void close() {
f6cb1edc2036 modify EchoClient.java. System.exit(0)
e085711
parents: 70
diff changeset
1008 rfb.close();
f6cb1edc2036 modify EchoClient.java. System.exit(0)
e085711
parents: 70
diff changeset
1009 }
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1010 public void getParentName() {
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1011 if (echoValue == null) {
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
1012
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1013 if (clientSocket == null) {
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1014 String pHost;
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1015 if (mainArgs.length > 0)
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1016 pHost = mainArgs[0];
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1017 else
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1018 pHost = "cls080.ie.u-ryukyu.ac.jp";
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1019 // echo = new EchoClient(pHost, this);
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1020 echoValue = new EchoClient(pHost, this, echoPort);
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1021 echoValue.openport();
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1022
88
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
1023 echoValue = echoValue.requestHostName("1");
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1024 } else {
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1025 echoValue = new EchoClient();
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1026 echoValue = echoValue.Interruption(clientSocket);
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1027 }
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1028 }
78
e085711
parents: 76
diff changeset
1029
e085711
parents: 76
diff changeset
1030 // proxyからの返信で接続先を決定する
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1031 host = echoValue.responseLine;
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1032 parent = echoValue.parent;
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1033 if (echoValue.treenum != null) {
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1034 treenum = echoValue.treenum;
78
e085711
parents: 76
diff changeset
1035 } else {
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1036 treenum = echoValue.treenum;
78
e085711
parents: 76
diff changeset
1037 }
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1038 if (echoValue.leaderflag != null) {
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1039 leaderflag = echoValue.leaderflag;
78
e085711
parents: 76
diff changeset
1040 } else {
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1041 leaderflag = echoValue.leaderflag;
78
e085711
parents: 76
diff changeset
1042 }
e085711
parents: 76
diff changeset
1043 System.out.println("Parent =" + parent);
e085711
parents: 76
diff changeset
1044 System.out.println("mynumber =" + treenum);
e085711
parents: 76
diff changeset
1045 System.out.println("connect host =" + host);
e085711
parents: 76
diff changeset
1046 System.out.println("leaderflag(boolean) = " + leaderflag);
e085711
parents: 76
diff changeset
1047
e085711
parents: 76
diff changeset
1048 // port = 5999;
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1049
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1050 }
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1051 public void setEchoValue(EchoClient value) {
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1052 this.echoValue = value;
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1053 }
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1054
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1055
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1056 int castByteInt(byte[] b) {
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1057 ByteBuffer bb = ByteBuffer.wrap(b);
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1058 int echoValue = bb.getInt();
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1059 return echoValue;
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1060 }
91
d89e03d99b7f modify readJpegData()
e085711
parents: 90
diff changeset
1061 public Image getScreenImage() {
d89e03d99b7f modify readJpegData()
e085711
parents: 90
diff changeset
1062 return vc.rawPixelsImage;
d89e03d99b7f modify readJpegData()
e085711
parents: 90
diff changeset
1063 }
d89e03d99b7f modify readJpegData()
e085711
parents: 90
diff changeset
1064
d89e03d99b7f modify readJpegData()
e085711
parents: 90
diff changeset
1065 public void writeScreenData(byte[] b, String imageFormat) {
d89e03d99b7f modify readJpegData()
e085711
parents: 90
diff changeset
1066 try{
93
71bfbb5241bf modify CuiMyVncClient
e085711
parents: 92
diff changeset
1067 vc.drawBufferedImage(b);
91
d89e03d99b7f modify readJpegData()
e085711
parents: 90
diff changeset
1068 }catch(IOException e){
d89e03d99b7f modify readJpegData()
e085711
parents: 90
diff changeset
1069 e.printStackTrace();
d89e03d99b7f modify readJpegData()
e085711
parents: 90
diff changeset
1070 }
d89e03d99b7f modify readJpegData()
e085711
parents: 90
diff changeset
1071 }
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1072
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
1073 }