annotate src/myVncClient/CuiMyVncClient.java @ 89:3ea33e683522

modify RFB Protocol Version. From 3.998 to 3.855
author e085711
date Tue, 20 Sep 2011 05:56:11 +0900
parents 3bfe8845684c
children 7a1e934144e6
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);
80
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
306 rfb = new MyRfbProto(pHost, port);
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
89
3ea33e683522 modify RFB Protocol Version. From 3.998 to 3.855
e085711
parents: 80
diff changeset
319 if(rfb.serverMinor == 855) {
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
320 byte[] b = new byte[4];
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
321 b = rfb.readEchoPort();
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
322 echoPort = castByteInt(b);
76
70004fedb1d1 modify connectAndAuthenticate
e085711
parents: 75
diff changeset
323
80
3bfe8845684c modify MyVncClient
e085711
parents: 79
diff changeset
324 InetAddress addr = InetAddress.getByName(pHost);
76
70004fedb1d1 modify connectAndAuthenticate
e085711
parents: 75
diff changeset
325 String h = new String(addr.getHostAddress());
70004fedb1d1 modify connectAndAuthenticate
e085711
parents: 75
diff changeset
326
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
327 getParentName();
76
70004fedb1d1 modify connectAndAuthenticate
e085711
parents: 75
diff changeset
328 if(!(h.equals(host))) {
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
329 rfb.changeParent(host, port);
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
330 rfb.readVersionMsg();
76
70004fedb1d1 modify connectAndAuthenticate
e085711
parents: 75
diff changeset
331 rfb.writeVersionMsg();
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
332 }
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
333 }
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
334
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
335
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
336 int secType = rfb.negotiateSecurity();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
337 int authType;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
338 if (secType == RfbProto.SecTypeTight) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
339 showConnectionStatus("Enabling TightVNC protocol extensions");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
340 rfb.setupTunneling();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
341 authType = rfb.negotiateAuthenticationTight();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
342 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
343 authType = secType;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
344 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
345
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
346 switch (authType) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
347 case RfbProto.AuthNone:
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
348 showConnectionStatus("No authentication needed");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
349 rfb.authenticateNone();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
350 break;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
351 case RfbProto.AuthVNC:
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
352 showConnectionStatus("Performing standard VNC authentication");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
353 if (passwordParam != null) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
354 rfb.authenticateVNC(passwordParam);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
355 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
356 String pw = askPassword();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
357 rfb.authenticateVNC(pw);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
358 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
359 break;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
360 default:
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
361 throw new Exception("Unknown authentication scheme " + authType);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
362 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
363 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
364
70
affdcbdc90ea modify CreateCanva.java. implement ZRLEE.
e085711
parents: 69
diff changeset
365
affdcbdc90ea modify CreateCanva.java. implement ZRLEE.
e085711
parents: 69
diff changeset
366
69
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
367 void reConnectAndAuthenticate() throws Exception {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
368 showConnectionStatus("Initializing...");
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
369
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
370 showConnectionStatus("Connecting to " + host + ", port " + port + "...");
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
371
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
372 rfb.changeParent(host, port);
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
373
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
374 showConnectionStatus("Connected to server");
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
375
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
376 rfb.readVersionMsg();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
377 showConnectionStatus("RFB server supports protocol version "
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
378 + rfb.serverMajor + "." + rfb.serverMinor);
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.writeVersionMsg();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
381 showConnectionStatus("Using RFB protocol version " + rfb.clientMajor
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
382 + "." + rfb.clientMinor);
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
383
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
384 if(rfb.serverMinor == 998) {
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
385 byte[] b = new byte[4];
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
386 b = rfb.readEchoPort();
89
3ea33e683522 modify RFB Protocol Version. From 3.998 to 3.855
e085711
parents: 80
diff changeset
387 int echoPort = castByteInt(b);
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
388
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
389 InetAddress addr = InetAddress.getByName(host);
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
390 String h = new String(addr.getHostAddress());
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
391
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
392 getParentName();
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
393 if(!(h.equals(host))) {
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
394 rfb.changeParent(host, port);
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
395 rfb.readVersionMsg();
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
396 rfb.writeVersionMsg();
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
397 }
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
398 }
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
399
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
400
69
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
401 int secType = rfb.negotiateSecurity();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
402 int authType;
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
403 if (secType == RfbProto.SecTypeTight) {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
404 showConnectionStatus("Enabling TightVNC protocol extensions");
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
405 rfb.setupTunneling();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
406 authType = rfb.negotiateAuthenticationTight();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
407 } else {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
408 authType = secType;
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
409 }
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
410
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
411 switch (authType) {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
412 case RfbProto.AuthNone:
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
413 showConnectionStatus("No authentication needed");
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
414 rfb.authenticateNone();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
415 break;
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
416 case RfbProto.AuthVNC:
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
417 showConnectionStatus("Performing standard VNC authentication");
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
418 if (passwordParam != null) {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
419 rfb.authenticateVNC(passwordParam);
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
420 } else {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
421 String pw = askPassword();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
422 rfb.authenticateVNC(pw);
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
423 }
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
424 break;
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
425 default:
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
426 throw new Exception("Unknown authentication scheme " + authType);
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
427 }
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
428 }
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
429
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
430 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
431 // Show a message describing the connection status.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
432 // To hide the connection status label, use (msg == null).
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
433 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
434
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
435 void showConnectionStatus(String msg) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
436 System.out.println(msg);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
437 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
438
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
439 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
440 // Show an authentication panel.
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
443 String askPassword() throws Exception {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
444 /*
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
445 * showConnectionStatus(null); AuthPanel authPanel = new
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
446 * AuthPanel(this);
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
447 *
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
448 * GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth =
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
449 * GridBagConstraints.REMAINDER; gbc.anchor =
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
450 * GridBagConstraints.NORTHWEST; gbc.weightx = 1.0; gbc.weighty = 1.0;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
451 * gbc.ipadx = 100; gbc.ipady = 50; gridbag.setConstraints(authPanel,
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
452 * gbc); vncContainer.add(authPanel);
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
453 *
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
454 *
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
455 * authPanel.moveFocusToDefaultField(); vncContainer.remove(authPanel);
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
456 */
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
457 showConnectionStatus("ask password...");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
458 String pw = mainArgs[2];
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
459 return pw;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
460 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
461
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
462 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
463 // Do the rest of the protocol initialisation.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
464 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
465
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
466 void doProtocolInitialisation() throws IOException {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
467 rfb.writeClientInit();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
468 rfb.readServerInit();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
469
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
470 System.out.println("Desktop name is " + rfb.desktopName);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
471 System.out.println("Desktop size is " + rfb.framebufferWidth + " x "
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
472 + rfb.framebufferHeight);
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 setEncodings();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
475
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
476 // showConnectionStatus(null);
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
477 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
478
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
479 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
480 // Send current encoding list to the RFB server.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
481 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
482
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
483 int[] encodingsSaved;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
484 int nEncodingsSaved;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
485
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
486 void setEncodings() {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
487 setEncodings(false);
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 void autoSelectEncodings() {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
491 setEncodings(true);
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 void setEncodings(boolean autoSelectOnly) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
495 if (options == null || rfb == null || !rfb.inNormalProtocol)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
496 return;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
497
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
498 int preferredEncoding = options.preferredEncoding;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
499 if (preferredEncoding == -1) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
500 long kbitsPerSecond = rfb.kbitsPerSecond();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
501 if (nEncodingsSaved < 1) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
502 // Choose Tight or ZRLE encoding for the very first update.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
503 System.out.println("Using Tight/ZRLE encodings");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
504 preferredEncoding = RfbProto.EncodingTight;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
505 } else if (kbitsPerSecond > 2000
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
506 && encodingsSaved[0] != RfbProto.EncodingHextile) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
507 // Switch to Hextile if the connection speed is above 2Mbps.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
508 System.out.println("Throughput " + kbitsPerSecond
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
509 + " kbit/s - changing to Hextile encoding");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
510 preferredEncoding = RfbProto.EncodingHextile;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
511 } else if (kbitsPerSecond < 1000
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
512 && encodingsSaved[0] != RfbProto.EncodingTight) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
513 // 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
514 System.out.println("Throughput " + kbitsPerSecond
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
515 + " kbit/s - changing to Tight/ZRLE encodings");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
516 preferredEncoding = RfbProto.EncodingTight;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
517 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
518 // Don't change the encoder.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
519 if (autoSelectOnly)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
520 return;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
521 preferredEncoding = encodingsSaved[0];
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
522 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
523 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
524 // Auto encoder selection is not enabled.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
525 if (autoSelectOnly)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
526 return;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
527 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
528
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
529 int[] encodings = new int[20];
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
530 int nEncodings = 0;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
531
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
532 encodings[nEncodings++] = preferredEncoding;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
533 if (options.useCopyRect) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
534 encodings[nEncodings++] = RfbProto.EncodingCopyRect;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
535 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
536 if (preferredEncoding != RfbProto.EncodingTight) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
537 encodings[nEncodings++] = RfbProto.EncodingTight;
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 if (preferredEncoding != RfbProto.EncodingZRLE) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
540 encodings[nEncodings++] = RfbProto.EncodingZRLE;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
541 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
542 if (preferredEncoding != RfbProto.EncodingHextile) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
543 encodings[nEncodings++] = RfbProto.EncodingHextile;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
544 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
545 if (preferredEncoding != RfbProto.EncodingZlib) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
546 encodings[nEncodings++] = RfbProto.EncodingZlib;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
547 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
548 /*
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
549 * if (preferredEncoding != RfbProto.EncodingCoRRE) {
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
550 * encodings[nEncodings++] = RfbProto.EncodingCoRRE; } if
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
551 * (preferredEncoding != RfbProto.EncodingRRE) { encodings[nEncodings++]
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
552 * = RfbProto.EncodingRRE; }
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
553 *
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
554 * if (options.compressLevel >= 0 && options.compressLevel <= 9) {
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
555 * encodings[nEncodings++] = RfbProto.EncodingCompressLevel0 +
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
556 * options.compressLevel; } if (options.jpegQuality >= 0 &&
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
557 * options.jpegQuality <= 9) { encodings[nEncodings++] =
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
558 * RfbProto.EncodingQualityLevel0 + options.jpegQuality; } if
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
559 * (options.requestCursorUpdates) { encodings[nEncodings++] =
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
560 * RfbProto.EncodingXCursor; encodings[nEncodings++] =
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
561 * RfbProto.EncodingRichCursor; if (!options.ignoreCursorUpdates)
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
562 * encodings[nEncodings++] = RfbProto.EncodingPointerPos; }
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
563 */
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
564
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
565 encodings[nEncodings++] = RfbProto.EncodingLastRect;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
566 encodings[nEncodings++] = RfbProto.EncodingNewFBSize;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
567
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
568 boolean encodingsWereChanged = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
569 if (nEncodings != nEncodingsSaved) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
570 encodingsWereChanged = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
571 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
572 for (int i = 0; i < nEncodings; i++) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
573 if (encodings[i] != encodingsSaved[i]) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
574 encodingsWereChanged = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
575 break;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
576 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
577 }
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
580 if (encodingsWereChanged) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
581 try {
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
582 // rfb.writeSetEncodings(encodings, nEncodings);
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
583 if (vc != null) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
584 vc.softCursorFree();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
585 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
586 } catch (Exception e) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
587 e.printStackTrace();
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 encodingsSaved = encodings;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
590 nEncodingsSaved = nEncodings;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
591 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
592 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
593
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
594 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
595 // setCutText() - send the given cut text to the RFB server.
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
598 void setCutText(String text) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
599 try {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
600 if (rfb != null && rfb.inNormalProtocol) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
601 rfb.writeClientCutText(text);
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 } catch (Exception e) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
604 e.printStackTrace();
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 }
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 // Order change in session recording status. To stop recording, pass
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
610 // null in place of the fname argument.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
611 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
612
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
613 void setRecordingStatus(String fname) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
614 synchronized (recordingSync) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
615 sessionFileName = fname;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
616 recordingStatusChanged = true;
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
621 // 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
622 // causes recording of a new session.
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
625 boolean checkRecordingStatus() throws IOException {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
626 synchronized (recordingSync) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
627 if (recordingStatusChanged) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
628 recordingStatusChanged = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
629 if (sessionFileName != null) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
630 startRecording();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
631 return true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
632 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
633 stopRecording();
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 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
637 return false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
638 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
639
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
640 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
641 // Start session recording.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
642 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
643
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
644 protected void startRecording() throws IOException {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
645 synchronized (recordingSync) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
646 if (!recordingActive) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
647 // Save settings to restore them after recording the session.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
648 cursorUpdatesDef = options.choices[options.cursorUpdatesIndex]
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
649 .getSelectedItem();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
650 eightBitColorsDef = options.choices[options.eightBitColorsIndex]
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
651 .getSelectedItem();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
652 // Set options to values suitable for recording.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
653 options.choices[options.cursorUpdatesIndex].select("Disable");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
654 options.choices[options.cursorUpdatesIndex].setEnabled(false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
655 options.setEncodings();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
656 options.choices[options.eightBitColorsIndex].select("No");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
657 options.choices[options.eightBitColorsIndex].setEnabled(false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
658 options.setColorFormat();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
659 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
660 rfb.closeSession();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
661 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
662
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
663 System.out.println("Recording the session in " + sessionFileName);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
664 rfb.startSession(sessionFileName);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
665 recordingActive = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
666 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
667 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
668
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
669 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
670 // Stop session recording.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
671 //
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 protected void stopRecording() throws IOException {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
674 synchronized (recordingSync) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
675 if (recordingActive) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
676 // Restore options.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
677 options.choices[options.cursorUpdatesIndex]
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
678 .select(cursorUpdatesDef);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
679 options.choices[options.cursorUpdatesIndex].setEnabled(true);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
680 options.setEncodings();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
681 options.choices[options.eightBitColorsIndex]
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
682 .select(eightBitColorsDef);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
683 options.choices[options.eightBitColorsIndex].setEnabled(true);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
684 options.setColorFormat();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
685
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
686 rfb.closeSession();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
687 System.out.println("Session recording stopped.");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
688 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
689 sessionFileName = null;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
690 recordingActive = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
691 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
692 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
693
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
694 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
695 // readParameters() - read parameters from the html source or from the
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
696 // 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
697 // 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
698 // those expected in the html applet tag source.
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
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
701 void readParameters() {
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
702 /*
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
703 * host = readParameter("HOST", !inAnApplet);
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 * if (host == null) { host = getCodeBase().getHost(); if
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
706 * (host.equals("")) { fatalError("HOST parameter not specified"); } }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
707 *
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
708 * port = readIntParameter("PORT", 5550);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
709 */
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 // Read "ENCPASSWORD" or "PASSWORD" parameter if specified.
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
712 // readPasswordParameters();
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
713
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
714 String str;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
715 if (inAnApplet) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
716 str = readParameter("Open New Window", false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
717 if (str != null && str.equalsIgnoreCase("Yes"))
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
718 inSeparateFrame = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
719 }
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 // "Show Controls" set to "No" disables button panel.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
722 showControls = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
723 str = readParameter("Show Controls", false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
724 if (str != null && str.equalsIgnoreCase("No"))
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
725 showControls = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
726
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
727 // "Offer Relogin" set to "No" disables "Login again" and "Close
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
728 // window" buttons under error messages in applet mode.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
729 offerRelogin = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
730 str = readParameter("Offer Relogin", false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
731 if (str != null && str.equalsIgnoreCase("No"))
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
732 offerRelogin = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
733
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
734 // Do we continue showing desktop on remote disconnect?
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
735 showOfflineDesktop = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
736 str = readParameter("Show Offline Desktop", false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
737 if (str != null && str.equalsIgnoreCase("Yes"))
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
738 showOfflineDesktop = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
739
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
740 // Fine tuning options.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
741 deferScreenUpdates = readIntParameter("Defer screen updates", 20);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
742 deferCursorUpdates = readIntParameter("Defer cursor updates", 10);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
743 deferUpdateRequests = readIntParameter("Defer update requests", 0);
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 // Debugging options.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
746 debugStatsExcludeUpdates = readIntParameter("DEBUG_XU", 0);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
747 debugStatsMeasureUpdates = readIntParameter("DEBUG_CU", 0);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
748
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
749 // SocketFactory.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
750 socketFactory = readParameter("SocketFactory", false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
751 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
752
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
753 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
754 // Read password parameters. If an "ENCPASSWORD" parameter is set,
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
755 // then decrypt the password into the passwordParam string. Otherwise,
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
756 // try to read the "PASSWORD" parameter directly to passwordParam.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
757 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
758
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
759 private void readPasswordParameters() {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
760 String encPasswordParam = readParameter("ENCPASSWORD", false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
761
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
762 if (encPasswordParam == null) {
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
763 passwordParam = readParameter("PASSWORD", false);
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
764 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
765 // ENCPASSWORD is hexascii-encoded. Decode.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
766 byte[] pw = { 0, 0, 0, 0, 0, 0, 0, 0 };
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
767 int len = encPasswordParam.length() / 2;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
768 if (len > 8)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
769 len = 8;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
770 for (int i = 0; i < len; i++) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
771 String hex = encPasswordParam.substring(i * 2, i * 2 + 2);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
772 Integer x = new Integer(Integer.parseInt(hex, 16));
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
773 pw[i] = x.byteValue();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
774 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
775 // Decrypt the password.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
776 byte[] key = { 23, 82, 107, 6, 35, 78, 88, 7 };
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
777 DesCipher des = new DesCipher(key);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
778 des.decrypt(pw, 0, pw, 0);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
779 passwordParam = new String(pw);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
780
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
781 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
782 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
783
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
784 public String readParameter(String name, boolean required) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
785 for (int i = 0; i < mainArgs.length; i += 2) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
786 if (mainArgs[i].equalsIgnoreCase(name)) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
787 try {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
788 return mainArgs[i + 1];
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
789 } catch (Exception e) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
790 if (required) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
791 fatalError(name + " parameter not specified");
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 return null;
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 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
796 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
797 if (required) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
798 fatalError(name + " parameter not specified");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
799 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
800 return null;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
801 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
802
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
803 int readIntParameter(String name, int defaultValue) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
804 String str = readParameter(name, false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
805 int result = defaultValue;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
806 if (str != null) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
807 try {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
808 result = Integer.parseInt(str);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
809 } catch (NumberFormatException e) {
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 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
812 return result;
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
815 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
816 // disconnect() - close connection to server.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
817 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
818
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
819 synchronized public void disconnect() {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
820 System.out.println("Disconnecting");
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 if (vc != null) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
823 double sec = (System.currentTimeMillis() - vc.statStartTime) / 1000.0;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
824 double rate = Math.round(vc.statNumUpdates / sec * 100) / 100.0;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
825 int nRealRects = vc.statNumPixelRects;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
826 int nPseudoRects = vc.statNumTotalRects - vc.statNumPixelRects;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
827 System.out.println("Updates received: " + vc.statNumUpdates + " ("
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
828 + nRealRects + " rectangles + " + nPseudoRects
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
829 + " pseudo), " + rate + " updates/sec");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
830 int numRectsOther = nRealRects - vc.statNumRectsTight
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
831 - vc.statNumRectsZRLE - vc.statNumRectsHextile
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
832 - vc.statNumRectsRaw - vc.statNumRectsCopy;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
833 System.out.println("Rectangles:" + " Tight=" + vc.statNumRectsTight
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
834 + "(JPEG=" + vc.statNumRectsTightJPEG + ") ZRLE="
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
835 + vc.statNumRectsZRLE + " Hextile="
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
836 + vc.statNumRectsHextile + " Raw=" + vc.statNumRectsRaw
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
837 + " CopyRect=" + vc.statNumRectsCopy + " other="
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
838 + numRectsOther);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
839
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
840 int raw = vc.statNumBytesDecoded;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
841 int compressed = vc.statNumBytesEncoded;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
842 if (compressed > 0) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
843 double ratio = Math.round((double) raw / compressed * 1000) / 1000.0;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
844 System.out.println("Pixel data: " + vc.statNumBytesDecoded
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
845 + " bytes, " + vc.statNumBytesEncoded
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
846 + " compressed, ratio " + ratio);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
847 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
848 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
849
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
850 if (rfb != null && !rfb.closed())
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
851 rfb.close();
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
852 // options.dispose();
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
853 clipboard.dispose();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
854 if (rec != null)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
855 rec.dispose();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
856
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
857 System.exit(0);
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
862 // fatalError() - print out a fatal error message.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
863 // 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
864 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
865
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
866 synchronized public void fatalError(String str) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
867 System.out.println(str);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
868 System.exit(1);
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 synchronized public void fatalError(String str, Exception e) {
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 if (rfb != null && rfb.closed()) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
874 // 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
875 // by I/O problems after the rfb.close() method call.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
876 System.out.println("RFB thread finished");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
877 return;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
878 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
879
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
880 System.out.println(str);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
881 e.printStackTrace();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
882
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
883 if (rfb != null)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
884 rfb.close();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
885
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
886 System.exit(1);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
887
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
888 }
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 // Show message text and optionally "Relogin" and "Close" buttons.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
892 //
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 void showMessage(String msg) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
895 vncContainer.removeAll();
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 Label errLabel = new Label(msg, Label.CENTER);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
898 errLabel.setFont(new Font("Helvetica", Font.PLAIN, 12));
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 if (offerRelogin) {
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 * Panel gridPanel = new Panel(new GridLayout(0, 1)); Panel
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
903 * outerPanel = new Panel(new FlowLayout(FlowLayout.LEFT));
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
904 * outerPanel.add(gridPanel); vncContainer.setLayout(new
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
905 * FlowLayout(FlowLayout.LEFT, 30, 16));
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
906 * vncContainer.add(outerPanel); Panel textPanel = new Panel(new
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
907 * FlowLayout(FlowLayout.CENTER)); textPanel.add(errLabel);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
908 * gridPanel.add(textPanel); gridPanel.add(new ReloginPanel(this));
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
909 */
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
910 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
911 /*
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
912 * vncContainer.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 30));
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
913 * vncContainer.add(errLabel);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
914 */
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
915 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
916
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
917 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
918
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
919 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
920 // Stop the applet.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
921 // Main applet thread will terminate on first exception
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
922 // after seeing that rfbThread has been set to null.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
923 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
924
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
925 public void stop() {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
926 System.out.println("Stopping applet");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
927 rfbThread = null;
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 // This method is called before the applet is destroyed.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
932 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
933
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
934 public void destroy() {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
935 System.out.println("Destroying applet");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
936
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
937 vncContainer.removeAll();
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
938 // options.dispose();
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
939 clipboard.dispose();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
940 if (rec != null)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
941 rec.dispose();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
942 if (rfb != null && !rfb.closed())
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
943 rfb.close();
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
946 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
947 // Start/stop receiving mouse events.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
948 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
949
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
950 public void enableInput(boolean enable) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
951 vc.enableInput(enable);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
952 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
953
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
954 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
955 // Close application properly on window close event.
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 public void windowClosing(WindowEvent evt) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
959 System.out.println("Closing window");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
960 if (rfb != null)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
961 disconnect();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
962
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
963 vncContainer.hide();
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
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 // Ignore window events we're not interested in.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
969 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
970
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
971 public void windowActivated(WindowEvent evt) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
972 }
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 public void windowDeactivated(WindowEvent evt) {
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 public void windowOpened(WindowEvent evt) {
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
980 public void windowClosed(WindowEvent evt) {
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
983 public void windowIconified(WindowEvent evt) {
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
986 public void windowDeiconified(WindowEvent evt) {
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
989 public void setClientSocket(Socket sock) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
990 clientSocket = sock;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
991 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
992
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
993 public void start() {
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
994
61
646e6fc14d62 modify some files. for to use Client with CUI
e085711
parents: 60
diff changeset
995 }
71
f6cb1edc2036 modify EchoClient.java. System.exit(0)
e085711
parents: 70
diff changeset
996 public void close() {
f6cb1edc2036 modify EchoClient.java. System.exit(0)
e085711
parents: 70
diff changeset
997 rfb.close();
f6cb1edc2036 modify EchoClient.java. System.exit(0)
e085711
parents: 70
diff changeset
998 }
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
999 public void getParentName() {
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1000 if (echoValue == null) {
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
1001
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1002 if (clientSocket == null) {
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1003 String pHost;
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1004 if (mainArgs.length > 0)
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1005 pHost = mainArgs[0];
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1006 else
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1007 pHost = "cls080.ie.u-ryukyu.ac.jp";
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1008 // echo = new EchoClient(pHost, this);
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1009 echoValue = new EchoClient(pHost, this, echoPort);
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1010 echoValue.openport();
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1011
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1012 echoValue = echoValue.hostn("1");
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1013 } else {
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1014 echoValue = new EchoClient();
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1015 echoValue = echoValue.Interruption(clientSocket);
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1016 }
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1017 }
78
e085711
parents: 76
diff changeset
1018
e085711
parents: 76
diff changeset
1019 // proxyからの返信で接続先を決定する
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1020 host = echoValue.responseLine;
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1021 parent = echoValue.parent;
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1022 if (echoValue.treenum != null) {
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1023 treenum = echoValue.treenum;
78
e085711
parents: 76
diff changeset
1024 } else {
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1025 treenum = echoValue.treenum;
78
e085711
parents: 76
diff changeset
1026 }
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1027 if (echoValue.leaderflag != null) {
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1028 leaderflag = echoValue.leaderflag;
78
e085711
parents: 76
diff changeset
1029 } else {
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1030 leaderflag = echoValue.leaderflag;
78
e085711
parents: 76
diff changeset
1031 }
e085711
parents: 76
diff changeset
1032 System.out.println("Parent =" + parent);
e085711
parents: 76
diff changeset
1033 System.out.println("mynumber =" + treenum);
e085711
parents: 76
diff changeset
1034 System.out.println("connect host =" + host);
e085711
parents: 76
diff changeset
1035 System.out.println("leaderflag(boolean) = " + leaderflag);
e085711
parents: 76
diff changeset
1036
e085711
parents: 76
diff changeset
1037 // port = 5999;
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1038
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1039 }
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1040 public void setEchoValue(EchoClient value) {
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1041 this.echoValue = value;
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1042 }
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1043
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1044
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1045 int castByteInt(byte[] b) {
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1046 ByteBuffer bb = ByteBuffer.wrap(b);
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1047 int echoValue = bb.getInt();
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1048 return echoValue;
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1049 }
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1050
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
1051 }