annotate src/myVncClient/CuiMyVncClient.java @ 67:5e7110277cf0

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