annotate src/myVncClient/CuiMyVncClient.java @ 80:3bfe8845684c

modify MyVncClient
author e085711
date Wed, 31 Aug 2011 15:15:23 +0900
parents c76e43a12796
children d3e806372657 3ea33e683522
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
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
319 if(rfb.serverMinor == 998) {
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();
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
387 echoPort = castByteInt(b);
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
388
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
389 String hs = host;
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
390 InetAddress addr = InetAddress.getByName(host);
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
391 String h = new String(addr.getHostAddress());
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
392
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
393 getParentName();
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
394 if(!(h.equals(host))) {
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
395 rfb.changeParent(host, port);
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
396 rfb.readVersionMsg();
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
397 rfb.writeVersionMsg();
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
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
401
69
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
402 int secType = rfb.negotiateSecurity();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
403 int authType;
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
404 if (secType == RfbProto.SecTypeTight) {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
405 showConnectionStatus("Enabling TightVNC protocol extensions");
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
406 rfb.setupTunneling();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
407 authType = rfb.negotiateAuthenticationTight();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
408 } else {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
409 authType = secType;
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
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
412 switch (authType) {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
413 case RfbProto.AuthNone:
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
414 showConnectionStatus("No authentication needed");
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
415 rfb.authenticateNone();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
416 break;
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
417 case RfbProto.AuthVNC:
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
418 showConnectionStatus("Performing standard VNC authentication");
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
419 if (passwordParam != null) {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
420 rfb.authenticateVNC(passwordParam);
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
421 } else {
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
422 String pw = askPassword();
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
423 rfb.authenticateVNC(pw);
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
424 }
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
425 break;
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
426 default:
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
427 throw new Exception("Unknown authentication scheme " + authType);
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 }
1f05b73b15df modify MyVncClient.java and CuiMyVNcClient.java
e085711
parents: 67
diff changeset
430
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
431 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
432 // Show a message describing the connection status.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
433 // To hide the connection status label, use (msg == null).
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
436 void showConnectionStatus(String msg) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
437 System.out.println(msg);
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
441 // Show an authentication panel.
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
444 String askPassword() throws Exception {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
445 /*
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
446 * showConnectionStatus(null); AuthPanel authPanel = new
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
447 * AuthPanel(this);
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
448 *
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
449 * GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth =
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
450 * GridBagConstraints.REMAINDER; gbc.anchor =
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
451 * GridBagConstraints.NORTHWEST; gbc.weightx = 1.0; gbc.weighty = 1.0;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
452 * gbc.ipadx = 100; gbc.ipady = 50; gridbag.setConstraints(authPanel,
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
453 * gbc); vncContainer.add(authPanel);
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
454 *
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
455 *
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
456 * authPanel.moveFocusToDefaultField(); vncContainer.remove(authPanel);
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
457 */
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
458 showConnectionStatus("ask password...");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
459 String pw = mainArgs[2];
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
460 return pw;
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
464 // Do the rest of the protocol initialisation.
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
467 void doProtocolInitialisation() throws IOException {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
468 rfb.writeClientInit();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
469 rfb.readServerInit();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
470
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
471 System.out.println("Desktop name is " + rfb.desktopName);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
472 System.out.println("Desktop size is " + rfb.framebufferWidth + " x "
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
473 + rfb.framebufferHeight);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
474
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
475 setEncodings();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
476
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
477 // showConnectionStatus(null);
60
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
481 // Send current encoding list to the RFB server.
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
484 int[] encodingsSaved;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
485 int nEncodingsSaved;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
486
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
487 void setEncodings() {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
488 setEncodings(false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
489 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
490
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
491 void autoSelectEncodings() {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
492 setEncodings(true);
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
495 void setEncodings(boolean autoSelectOnly) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
496 if (options == null || rfb == null || !rfb.inNormalProtocol)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
497 return;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
498
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
499 int preferredEncoding = options.preferredEncoding;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
500 if (preferredEncoding == -1) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
501 long kbitsPerSecond = rfb.kbitsPerSecond();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
502 if (nEncodingsSaved < 1) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
503 // Choose Tight or ZRLE encoding for the very first update.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
504 System.out.println("Using Tight/ZRLE encodings");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
505 preferredEncoding = RfbProto.EncodingTight;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
506 } else if (kbitsPerSecond > 2000
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
507 && encodingsSaved[0] != RfbProto.EncodingHextile) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
508 // Switch to Hextile if the connection speed is above 2Mbps.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
509 System.out.println("Throughput " + kbitsPerSecond
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
510 + " kbit/s - changing to Hextile encoding");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
511 preferredEncoding = RfbProto.EncodingHextile;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
512 } else if (kbitsPerSecond < 1000
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
513 && encodingsSaved[0] != RfbProto.EncodingTight) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
514 // 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
515 System.out.println("Throughput " + kbitsPerSecond
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
516 + " kbit/s - changing to Tight/ZRLE encodings");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
517 preferredEncoding = RfbProto.EncodingTight;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
518 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
519 // Don't change the encoder.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
520 if (autoSelectOnly)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
521 return;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
522 preferredEncoding = encodingsSaved[0];
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
523 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
524 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
525 // Auto encoder selection is not enabled.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
526 if (autoSelectOnly)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
527 return;
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
530 int[] encodings = new int[20];
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
531 int nEncodings = 0;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
532
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
533 encodings[nEncodings++] = preferredEncoding;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
534 if (options.useCopyRect) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
535 encodings[nEncodings++] = RfbProto.EncodingCopyRect;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
536 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
537 if (preferredEncoding != RfbProto.EncodingTight) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
538 encodings[nEncodings++] = RfbProto.EncodingTight;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
539 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
540 if (preferredEncoding != RfbProto.EncodingZRLE) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
541 encodings[nEncodings++] = RfbProto.EncodingZRLE;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
542 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
543 if (preferredEncoding != RfbProto.EncodingHextile) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
544 encodings[nEncodings++] = RfbProto.EncodingHextile;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
545 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
546 if (preferredEncoding != RfbProto.EncodingZlib) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
547 encodings[nEncodings++] = RfbProto.EncodingZlib;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
548 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
549 /*
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
550 * if (preferredEncoding != RfbProto.EncodingCoRRE) {
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
551 * encodings[nEncodings++] = RfbProto.EncodingCoRRE; } if
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
552 * (preferredEncoding != RfbProto.EncodingRRE) { encodings[nEncodings++]
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
553 * = RfbProto.EncodingRRE; }
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
554 *
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
555 * if (options.compressLevel >= 0 && options.compressLevel <= 9) {
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
556 * encodings[nEncodings++] = RfbProto.EncodingCompressLevel0 +
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
557 * options.compressLevel; } if (options.jpegQuality >= 0 &&
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
558 * options.jpegQuality <= 9) { encodings[nEncodings++] =
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
559 * RfbProto.EncodingQualityLevel0 + options.jpegQuality; } if
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
560 * (options.requestCursorUpdates) { encodings[nEncodings++] =
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
561 * RfbProto.EncodingXCursor; encodings[nEncodings++] =
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
562 * RfbProto.EncodingRichCursor; if (!options.ignoreCursorUpdates)
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
563 * encodings[nEncodings++] = RfbProto.EncodingPointerPos; }
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
564 */
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
565
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
566 encodings[nEncodings++] = RfbProto.EncodingLastRect;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
567 encodings[nEncodings++] = RfbProto.EncodingNewFBSize;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
568
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
569 boolean encodingsWereChanged = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
570 if (nEncodings != nEncodingsSaved) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
571 encodingsWereChanged = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
572 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
573 for (int i = 0; i < nEncodings; i++) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
574 if (encodings[i] != encodingsSaved[i]) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
575 encodingsWereChanged = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
576 break;
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
581 if (encodingsWereChanged) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
582 try {
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
583 // rfb.writeSetEncodings(encodings, nEncodings);
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
584 if (vc != null) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
585 vc.softCursorFree();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
586 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
587 } catch (Exception e) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
588 e.printStackTrace();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
589 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
590 encodingsSaved = encodings;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
591 nEncodingsSaved = nEncodings;
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
596 // setCutText() - send the given cut text to the RFB server.
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
599 void setCutText(String text) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
600 try {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
601 if (rfb != null && rfb.inNormalProtocol) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
602 rfb.writeClientCutText(text);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
603 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
604 } catch (Exception e) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
605 e.printStackTrace();
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
610 // Order change in session recording status. To stop recording, pass
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
611 // null in place of the fname argument.
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
614 void setRecordingStatus(String fname) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
615 synchronized (recordingSync) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
616 sessionFileName = fname;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
617 recordingStatusChanged = true;
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
622 // 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
623 // causes recording of a new session.
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
626 boolean checkRecordingStatus() throws IOException {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
627 synchronized (recordingSync) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
628 if (recordingStatusChanged) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
629 recordingStatusChanged = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
630 if (sessionFileName != null) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
631 startRecording();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
632 return true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
633 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
634 stopRecording();
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 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
638 return false;
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
642 // Start session recording.
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
645 protected void startRecording() throws IOException {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
646 synchronized (recordingSync) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
647 if (!recordingActive) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
648 // Save settings to restore them after recording the session.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
649 cursorUpdatesDef = options.choices[options.cursorUpdatesIndex]
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
650 .getSelectedItem();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
651 eightBitColorsDef = options.choices[options.eightBitColorsIndex]
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
652 .getSelectedItem();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
653 // Set options to values suitable for recording.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
654 options.choices[options.cursorUpdatesIndex].select("Disable");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
655 options.choices[options.cursorUpdatesIndex].setEnabled(false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
656 options.setEncodings();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
657 options.choices[options.eightBitColorsIndex].select("No");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
658 options.choices[options.eightBitColorsIndex].setEnabled(false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
659 options.setColorFormat();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
660 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
661 rfb.closeSession();
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
664 System.out.println("Recording the session in " + sessionFileName);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
665 rfb.startSession(sessionFileName);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
666 recordingActive = true;
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
671 // Stop session recording.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
672 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
673
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
674 protected void stopRecording() throws IOException {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
675 synchronized (recordingSync) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
676 if (recordingActive) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
677 // Restore options.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
678 options.choices[options.cursorUpdatesIndex]
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
679 .select(cursorUpdatesDef);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
680 options.choices[options.cursorUpdatesIndex].setEnabled(true);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
681 options.setEncodings();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
682 options.choices[options.eightBitColorsIndex]
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
683 .select(eightBitColorsDef);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
684 options.choices[options.eightBitColorsIndex].setEnabled(true);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
685 options.setColorFormat();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
686
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
687 rfb.closeSession();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
688 System.out.println("Session recording stopped.");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
689 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
690 sessionFileName = null;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
691 recordingActive = false;
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
696 // readParameters() - read parameters from the html source or from the
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
697 // 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
698 // 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
699 // those expected in the html applet tag source.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
700 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
701
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
702 void readParameters() {
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
703 /*
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
704 * host = readParameter("HOST", !inAnApplet);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
705 *
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
706 * if (host == null) { host = getCodeBase().getHost(); if
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
707 * (host.equals("")) { fatalError("HOST parameter not specified"); } }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
708 *
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
709 * port = readIntParameter("PORT", 5550);
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
712 // Read "ENCPASSWORD" or "PASSWORD" parameter if specified.
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
713 // readPasswordParameters();
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
714
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
715 String str;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
716 if (inAnApplet) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
717 str = readParameter("Open New Window", false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
718 if (str != null && str.equalsIgnoreCase("Yes"))
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
719 inSeparateFrame = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
720 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
721
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
722 // "Show Controls" set to "No" disables button panel.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
723 showControls = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
724 str = readParameter("Show Controls", false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
725 if (str != null && str.equalsIgnoreCase("No"))
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
726 showControls = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
727
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
728 // "Offer Relogin" set to "No" disables "Login again" and "Close
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
729 // window" buttons under error messages in applet mode.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
730 offerRelogin = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
731 str = readParameter("Offer Relogin", false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
732 if (str != null && str.equalsIgnoreCase("No"))
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
733 offerRelogin = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
734
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
735 // Do we continue showing desktop on remote disconnect?
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
736 showOfflineDesktop = false;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
737 str = readParameter("Show Offline Desktop", false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
738 if (str != null && str.equalsIgnoreCase("Yes"))
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
739 showOfflineDesktop = true;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
740
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
741 // Fine tuning options.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
742 deferScreenUpdates = readIntParameter("Defer screen updates", 20);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
743 deferCursorUpdates = readIntParameter("Defer cursor updates", 10);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
744 deferUpdateRequests = readIntParameter("Defer update requests", 0);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
745
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
746 // Debugging options.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
747 debugStatsExcludeUpdates = readIntParameter("DEBUG_XU", 0);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
748 debugStatsMeasureUpdates = readIntParameter("DEBUG_CU", 0);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
749
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
750 // SocketFactory.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
751 socketFactory = readParameter("SocketFactory", false);
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
755 // Read password parameters. If an "ENCPASSWORD" parameter is set,
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
756 // then decrypt the password into the passwordParam string. Otherwise,
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
757 // try to read the "PASSWORD" parameter directly to passwordParam.
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
760 private void readPasswordParameters() {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
761 String encPasswordParam = readParameter("ENCPASSWORD", false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
762
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
763 if (encPasswordParam == null) {
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
764 passwordParam = readParameter("PASSWORD", false);
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
765 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
766 // ENCPASSWORD is hexascii-encoded. Decode.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
767 byte[] pw = { 0, 0, 0, 0, 0, 0, 0, 0 };
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
768 int len = encPasswordParam.length() / 2;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
769 if (len > 8)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
770 len = 8;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
771 for (int i = 0; i < len; i++) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
772 String hex = encPasswordParam.substring(i * 2, i * 2 + 2);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
773 Integer x = new Integer(Integer.parseInt(hex, 16));
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
774 pw[i] = x.byteValue();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
775 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
776 // Decrypt the password.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
777 byte[] key = { 23, 82, 107, 6, 35, 78, 88, 7 };
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
778 DesCipher des = new DesCipher(key);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
779 des.decrypt(pw, 0, pw, 0);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
780 passwordParam = new String(pw);
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
785 public String readParameter(String name, boolean required) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
786 for (int i = 0; i < mainArgs.length; i += 2) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
787 if (mainArgs[i].equalsIgnoreCase(name)) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
788 try {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
789 return mainArgs[i + 1];
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
790 } catch (Exception e) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
791 if (required) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
792 fatalError(name + " parameter not specified");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
793 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
794 return null;
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 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
798 if (required) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
799 fatalError(name + " parameter not specified");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
800 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
801 return null;
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
804 int readIntParameter(String name, int defaultValue) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
805 String str = readParameter(name, false);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
806 int result = defaultValue;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
807 if (str != null) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
808 try {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
809 result = Integer.parseInt(str);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
810 } catch (NumberFormatException e) {
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 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
813 return result;
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
817 // disconnect() - close connection to server.
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
820 synchronized public void disconnect() {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
821 System.out.println("Disconnecting");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
822
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
823 if (vc != null) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
824 double sec = (System.currentTimeMillis() - vc.statStartTime) / 1000.0;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
825 double rate = Math.round(vc.statNumUpdates / sec * 100) / 100.0;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
826 int nRealRects = vc.statNumPixelRects;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
827 int nPseudoRects = vc.statNumTotalRects - vc.statNumPixelRects;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
828 System.out.println("Updates received: " + vc.statNumUpdates + " ("
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
829 + nRealRects + " rectangles + " + nPseudoRects
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
830 + " pseudo), " + rate + " updates/sec");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
831 int numRectsOther = nRealRects - vc.statNumRectsTight
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
832 - vc.statNumRectsZRLE - vc.statNumRectsHextile
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
833 - vc.statNumRectsRaw - vc.statNumRectsCopy;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
834 System.out.println("Rectangles:" + " Tight=" + vc.statNumRectsTight
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
835 + "(JPEG=" + vc.statNumRectsTightJPEG + ") ZRLE="
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
836 + vc.statNumRectsZRLE + " Hextile="
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
837 + vc.statNumRectsHextile + " Raw=" + vc.statNumRectsRaw
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
838 + " CopyRect=" + vc.statNumRectsCopy + " other="
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
839 + numRectsOther);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
840
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
841 int raw = vc.statNumBytesDecoded;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
842 int compressed = vc.statNumBytesEncoded;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
843 if (compressed > 0) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
844 double ratio = Math.round((double) raw / compressed * 1000) / 1000.0;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
845 System.out.println("Pixel data: " + vc.statNumBytesDecoded
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
846 + " bytes, " + vc.statNumBytesEncoded
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
847 + " compressed, ratio " + ratio);
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
851 if (rfb != null && !rfb.closed())
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
852 rfb.close();
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
853 // options.dispose();
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
854 clipboard.dispose();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
855 if (rec != null)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
856 rec.dispose();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
857
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
858 System.exit(0);
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
863 // fatalError() - print out a fatal error message.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
864 // 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
865 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
866
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
867 synchronized public void fatalError(String str) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
868 System.out.println(str);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
869 System.exit(1);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
870 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
871
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
872 synchronized public void fatalError(String str, Exception e) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
873
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
874 if (rfb != null && rfb.closed()) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
875 // 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
876 // by I/O problems after the rfb.close() method call.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
877 System.out.println("RFB thread finished");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
878 return;
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
881 System.out.println(str);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
882 e.printStackTrace();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
883
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
884 if (rfb != null)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
885 rfb.close();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
886
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
887 System.exit(1);
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
892 // Show message text and optionally "Relogin" and "Close" buttons.
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
895 void showMessage(String msg) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
896 vncContainer.removeAll();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
897
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
898 Label errLabel = new Label(msg, Label.CENTER);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
899 errLabel.setFont(new Font("Helvetica", Font.PLAIN, 12));
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
900
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
901 if (offerRelogin) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
902 /*
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
903 * Panel gridPanel = new Panel(new GridLayout(0, 1)); Panel
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
904 * outerPanel = new Panel(new FlowLayout(FlowLayout.LEFT));
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
905 * outerPanel.add(gridPanel); vncContainer.setLayout(new
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
906 * FlowLayout(FlowLayout.LEFT, 30, 16));
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
907 * vncContainer.add(outerPanel); Panel textPanel = new Panel(new
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
908 * FlowLayout(FlowLayout.CENTER)); textPanel.add(errLabel);
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
909 * gridPanel.add(textPanel); gridPanel.add(new ReloginPanel(this));
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
910 */
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
911 } else {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
912 /*
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
913 * vncContainer.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 30));
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
914 * vncContainer.add(errLabel);
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
921 // Stop the applet.
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
922 // Main applet thread will terminate on first exception
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
923 // after seeing that rfbThread has been set to null.
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
926 public void stop() {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
927 System.out.println("Stopping applet");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
928 rfbThread = null;
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
932 // This method is called before the applet is destroyed.
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
935 public void destroy() {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
936 System.out.println("Destroying applet");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
937
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
938 vncContainer.removeAll();
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
939 // options.dispose();
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
940 clipboard.dispose();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
941 if (rec != null)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
942 rec.dispose();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
943 if (rfb != null && !rfb.closed())
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
944 rfb.close();
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
948 // Start/stop receiving mouse events.
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
951 public void enableInput(boolean enable) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
952 vc.enableInput(enable);
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
956 // Close application properly on window close event.
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
959 public void windowClosing(WindowEvent evt) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
960 System.out.println("Closing window");
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
961 if (rfb != null)
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
962 disconnect();
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
963
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
964 vncContainer.hide();
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 //
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
969 // Ignore window events we're not interested in.
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
972 public void windowActivated(WindowEvent evt) {
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
975 public void windowDeactivated(WindowEvent evt) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
976 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
977
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
978 public void windowOpened(WindowEvent evt) {
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
981 public void windowClosed(WindowEvent evt) {
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
984 public void windowIconified(WindowEvent evt) {
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
987 public void windowDeiconified(WindowEvent evt) {
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
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
990 public void setClientSocket(Socket sock) {
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
991 clientSocket = sock;
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
992 }
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
993
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
994 public void start() {
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
995
61
646e6fc14d62 modify some files. for to use Client with CUI
e085711
parents: 60
diff changeset
996 }
71
f6cb1edc2036 modify EchoClient.java. System.exit(0)
e085711
parents: 70
diff changeset
997 public void close() {
f6cb1edc2036 modify EchoClient.java. System.exit(0)
e085711
parents: 70
diff changeset
998 rfb.close();
f6cb1edc2036 modify EchoClient.java. System.exit(0)
e085711
parents: 70
diff changeset
999 }
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1000 public void getParentName() {
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1001 if (echoValue == null) {
65
4225c2fd3e16 modify CuiMyVncClient.java
e085711
parents: 61
diff changeset
1002
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1003 if (clientSocket == null) {
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1004 String pHost;
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1005 if (mainArgs.length > 0)
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1006 pHost = mainArgs[0];
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1007 else
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1008 pHost = "cls080.ie.u-ryukyu.ac.jp";
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1009 // echo = new EchoClient(pHost, this);
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1010 echoValue = new EchoClient(pHost, this, echoPort);
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1011 echoValue.openport();
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1012
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1013 echoValue = echoValue.hostn("1");
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1014 } else {
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1015 echoValue = new EchoClient();
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1016 echoValue = echoValue.Interruption(clientSocket);
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1017 }
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1018 }
78
e085711
parents: 76
diff changeset
1019
e085711
parents: 76
diff changeset
1020 // proxyからの返信で接続先を決定する
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1021 host = echoValue.responseLine;
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1022 parent = echoValue.parent;
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1023 if (echoValue.treenum != null) {
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1024 treenum = echoValue.treenum;
78
e085711
parents: 76
diff changeset
1025 } else {
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1026 treenum = echoValue.treenum;
78
e085711
parents: 76
diff changeset
1027 }
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1028 if (echoValue.leaderflag != null) {
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1029 leaderflag = echoValue.leaderflag;
78
e085711
parents: 76
diff changeset
1030 } else {
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1031 leaderflag = echoValue.leaderflag;
78
e085711
parents: 76
diff changeset
1032 }
e085711
parents: 76
diff changeset
1033 System.out.println("Parent =" + parent);
e085711
parents: 76
diff changeset
1034 System.out.println("mynumber =" + treenum);
e085711
parents: 76
diff changeset
1035 System.out.println("connect host =" + host);
e085711
parents: 76
diff changeset
1036 System.out.println("leaderflag(boolean) = " + leaderflag);
e085711
parents: 76
diff changeset
1037
e085711
parents: 76
diff changeset
1038 // port = 5999;
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1039
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1040 }
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1041 public void setEchoValue(EchoClient value) {
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1042 this.echoValue = value;
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1043 }
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1044
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1045
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1046 int castByteInt(byte[] b) {
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1047 ByteBuffer bb = ByteBuffer.wrap(b);
79
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1048 int echoValue = bb.getInt();
c76e43a12796 modify MyVncClient
e085711
parents: 78
diff changeset
1049 return echoValue;
74
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1050 }
7d25b08f5835 modify CuiMyVncClient
e085711
parents: 71
diff changeset
1051
60
18a19d8a09f4 add some files. for to use Client with CUI.
e085711
parents:
diff changeset
1052 }