Mercurial > hg > Applications > TightVNC_orginal
comparison src/main/java/ac/ryukyu/treevnc/client/MyVncClient.java @ 2:dca3bd61b830
before change MyVncClient.java
author | Yu Taninari <you@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 09 Jul 2012 18:47:33 +0900 |
parents | 75b54fd9e73a |
children | e7ce2b2ffed8 |
comparison
equal
deleted
inserted
replaced
1:75b54fd9e73a | 2:dca3bd61b830 |
---|---|
13 import com.glavsoft.exceptions.AuthenticationFailedException; | 13 import com.glavsoft.exceptions.AuthenticationFailedException; |
14 import com.glavsoft.exceptions.FatalException; | 14 import com.glavsoft.exceptions.FatalException; |
15 import com.glavsoft.exceptions.TransportException; | 15 import com.glavsoft.exceptions.TransportException; |
16 import com.glavsoft.exceptions.UnsupportedProtocolVersionException; | 16 import com.glavsoft.exceptions.UnsupportedProtocolVersionException; |
17 import com.glavsoft.exceptions.UnsupportedSecurityTypeException; | 17 import com.glavsoft.exceptions.UnsupportedSecurityTypeException; |
18 import com.glavsoft.rfb.IChangeSettingsListener; | |
19 import com.glavsoft.rfb.IRfbSessionListener; | |
18 import com.glavsoft.rfb.protocol.Protocol; | 20 import com.glavsoft.rfb.protocol.Protocol; |
19 import com.glavsoft.rfb.protocol.ProtocolSettings; | 21 import com.glavsoft.rfb.protocol.ProtocolSettings; |
20 import com.glavsoft.transport.Reader; | 22 import com.glavsoft.transport.Reader; |
21 import com.glavsoft.transport.Writer; | 23 import com.glavsoft.transport.Writer; |
22 import com.glavsoft.viewer.ConnectionManager; | 24 import com.glavsoft.viewer.ConnectionManager; |
29 import com.glavsoft.viewer.swing.UiSettings; | 31 import com.glavsoft.viewer.swing.UiSettings; |
30 import com.glavsoft.viewer.swing.ParametersHandler.ConnectionParams; | 32 import com.glavsoft.viewer.swing.ParametersHandler.ConnectionParams; |
31 | 33 |
32 import ac.ryukyu.treevnc.InterfaceForViewer; | 34 import ac.ryukyu.treevnc.InterfaceForViewer; |
33 | 35 |
34 public class MyVncClient extends Viewer implements InterfaceForViewer, | 36 public class MyVncClient extends Viewer implements Runnable, |
35 java.lang.Runnable, WindowListener { | 37 IRfbSessionListener, WindowListener, IChangeSettingsListener { |
36 | 38 |
37 /** | 39 /** |
38 * | 40 * |
39 */ | 41 */ |
40 private static final long serialVersionUID = 1L; | 42 private static final long serialVersionUID = 1L; |
91 System.out.println(mainArgs.length); | 93 System.out.println(mainArgs.length); |
92 // input into arguments Decision | 94 // input into arguments Decision |
93 if (mainArgs.length != 0) { | 95 if (mainArgs.length != 0) { |
94 for (int i = 0; i < argv.length; i++) { | 96 for (int i = 0; i < argv.length; i++) { |
95 if ("-c".equals(argv[i])) { | 97 if ("-c".equals(argv[i])) { |
96 // later write | 98 // write later |
97 } | 99 } |
98 } | 100 } |
99 } else { | 101 } else { |
100 //getHostData(); | 102 //getHostData(); |
101 } | 103 } |
106 if (parser.isSet(ParametersHandler.ARG_HELP)) { | 108 if (parser.isSet(ParametersHandler.ARG_HELP)) { |
107 printUsage(parser.optionsUsage()); | 109 printUsage(parser.optionsUsage()); |
108 System.exit(0); | 110 System.exit(0); |
109 } | 111 } |
110 MyVncClient myClient = new MyVncClient(parser); | 112 MyVncClient myClient = new MyVncClient(parser); |
111 SwingUtilities.invokeLater(myClient); | 113 //SwingUtilities.invokeLater(myClient); |
114 Thread th = new Thread(myClient); | |
115 th.start(); | |
112 } | 116 } |
113 | 117 |
114 private void getHostData() { | 118 private void getHostData() { |
115 bCast = new GetHostClient("who"); | 119 bCast = new GetHostClient("who"); |
116 bCast.createSocket(); | 120 bCast.createSocket(); |
117 bCast.sendData(); | 121 bCast.sendData(); |
118 getBcast = new GetDataClient(); | 122 getBcast = new GetDataClient(); |
119 runBcast = new Thread(getBcast); | 123 runBcast = new Thread(getBcast); |
120 runBcast.start(); | 124 runBcast.start(); |
121 getBcast.setStopFlag(true); | 125 getBcast.setStopFlag(true); |
122 connectionParams.hostName = getBcast.text.getAddress(); | 126 connectionParams.hostName = getBcast.textAddress(); |
123 if("notFound".equals(pHost)) { | 127 if("notFound".equals(pHost)) { |
124 getHost = new TextBoxClient(); | 128 getHost = new TextBoxClient(); |
125 getHost.ipRegister(); | 129 getHost.ipRegister(); |
126 connectionParams.hostName = getHost.getAddressOption(); | 130 connectionParams.hostName = getHost.getAddressOption(); |
127 connectionParams.portNumber = Integer.parseInt(getHost.getPortOption()); | 131 //connectionParams.portNumber = Integer.parseInt(getHost.getPortOption()); |
132 connectionParams.portNumber = 5900; | |
128 } else { | 133 } else { |
129 connectionParams.portNumber = Integer.parseInt(getBcast.text.getPort()); | 134 //connectionParams.portNumber = Integer.parseInt(getBcast.textPort()); |
135 connectionParams.portNumber = 5900; | |
130 } | 136 } |
131 } | 137 } |
132 | 138 |
133 @Override | 139 @Override |
134 public void run() { | 140 public void run() { |
141 // getHostData(); | |
135 ConnectionManager connectionManager = new ConnectionManager(this, isApplet); | 142 ConnectionManager connectionManager = new ConnectionManager(this, isApplet); |
136 if (forceReconnection) { | 143 if (forceReconnection) { |
137 connectionManager.showReconnectDialog("Connection lost", reconnectionReason); | 144 connectionManager.showReconnectDialog("Connection lost", reconnectionReason); |
138 forceReconnection = false; | 145 forceReconnection = false; |
139 } | 146 } |
140 tryAgain = true; | 147 tryAgain = true; |
141 while (tryAgain) { | 148 while (tryAgain) { |
149 // workingSocket = connectionManager.connectToTreeHost(connectionParams, settings); | |
142 workingSocket = connectionManager.connectToHost(connectionParams, settings); | 150 workingSocket = connectionManager.connectToHost(connectionParams, settings); |
143 if (null == workingSocket) { | 151 if (null == workingSocket) { |
144 closeApp(); | 152 closeApp(); |
145 break; | 153 break; |
146 } | 154 } |
194 | 202 |
195 } | 203 } |
196 | 204 |
197 | 205 |
198 | 206 |
199 @Override | 207 |
200 public void setEchoValue(EchoClient value) { | |
201 // TODO Auto-generated method stub | |
202 | |
203 } | |
204 | |
205 @Override | |
206 public String readParameter(String name, boolean required) { | |
207 // TODO Auto-generated method stub | |
208 return null; | |
209 } | |
210 | |
211 @Override | |
212 public void getParentName() { | |
213 // TODO Auto-generated method stub | |
214 | |
215 } | |
216 | |
217 @Override | |
218 public void disconnect() { | |
219 // TODO Auto-generated method stub | |
220 | |
221 } | |
222 | |
223 @Override | |
224 public void fatalError(String str) { | |
225 // TODO Auto-generated method stub | |
226 | |
227 } | |
228 | |
229 @Override | |
230 public void fatalError(String str, Exception e) { | |
231 // TODO Auto-generated method stub | |
232 | |
233 } | |
234 | 208 |
235 @Override | 209 @Override |
236 public void destroy() { | 210 public void destroy() { |
237 // TODO Auto-generated method stub | 211 // TODO Auto-generated method stub |
238 | 212 |
239 } | 213 } |
240 | 214 |
241 @Override | 215 @Override |
242 public void enableInput(boolean enable) { | |
243 // TODO Auto-generated method stub | |
244 | |
245 } | |
246 | |
247 @Override | |
248 public void setClientSocket(Socket sock) { | |
249 // TODO Auto-generated method stub | |
250 | |
251 } | |
252 | |
253 @Override | |
254 public void close() { | |
255 // TODO Auto-generated method stub | |
256 | |
257 } | |
258 | |
259 @Override | |
260 public Image getScreenImage() { | |
261 // TODO Auto-generated method stub | |
262 return null; | |
263 } | |
264 | |
265 @Override | |
266 public void writeScreenData(byte[] b, String imageFormat) { | |
267 // TODO Auto-generated method stub | |
268 | |
269 } | |
270 | |
271 @Override | |
272 public void windowActivated(WindowEvent e) { | |
273 // TODO Auto-generated method stub | |
274 | |
275 } | |
276 | |
277 @Override | |
278 public void windowClosed(WindowEvent e) { | |
279 // TODO Auto-generated method stub | |
280 | |
281 } | |
282 | |
283 @Override | |
284 public void windowClosing(WindowEvent e) { | 216 public void windowClosing(WindowEvent e) { |
285 // TODO Auto-generated method stub | 217 if (e != null && e.getComponent() != null) { |
286 | 218 e.getWindow().setVisible(false); |
287 } | 219 } |
288 | 220 closeApp(); |
289 @Override | 221 } |
290 public void windowDeactivated(WindowEvent e) { | 222 |
291 // TODO Auto-generated method stub | 223 @Override |
292 | 224 public void windowActivated(WindowEvent e) { /*nop*/ } |
293 } | 225 |
294 | 226 @Override |
295 @Override | 227 public void windowClosed(WindowEvent e) { /*nop*/ } |
296 public void windowDeiconified(WindowEvent e) { | 228 |
297 // TODO Auto-generated method stub | 229 @Override |
298 | 230 public void windowDeactivated(WindowEvent e) { /*nop*/ } |
299 } | 231 |
300 | 232 @Override |
301 @Override | 233 public void windowDeiconified(WindowEvent e) { /*nop*/ } |
302 public void windowIconified(WindowEvent e) { | 234 |
303 // TODO Auto-generated method stub | 235 @Override |
304 | 236 public void windowIconified(WindowEvent e) { /*nop*/ } |
305 } | 237 |
306 | 238 @Override |
307 @Override | 239 public void windowOpened(WindowEvent e) { /*nop*/ } |
308 public void windowOpened(WindowEvent e) { | |
309 // TODO Auto-generated method stub | |
310 | |
311 } | |
312 | 240 |
313 } | 241 } |