Mercurial > hg > Applications > TreeVNC
diff src/viewer_swing/java/com/glavsoft/viewer/Viewer.java @ 59:433c79184c05
merge version2.7.2
author | Taninari YU <you@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 17 Dec 2013 20:16:48 +0900 |
parents | 17b702648079 9fdb8ff88497 |
children | ac6f9e46566f |
line wrap: on
line diff
--- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Mon Dec 16 17:06:19 2013 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Tue Dec 17 20:16:48 2013 +0900 @@ -39,10 +39,15 @@ import java.awt.event.WindowListener; import java.io.IOException; import java.io.InputStream; +import java.net.Socket; import java.util.jar.Attributes; import java.util.jar.Manifest; import java.util.logging.*; +import jp.ac.u_ryukyu.treevnc.client.GetDataClient; +import jp.ac.u_ryukyu.treevnc.client.GetHostClient; +import jp.ac.u_ryukyu.treevnc.client.MyRfbProtoClient; + @SuppressWarnings("serial") public class Viewer extends JApplet implements Runnable, WindowListener { @@ -50,12 +55,12 @@ private int paramsMask; private boolean allowAppletInteractiveConnections; - private final ConnectionParams connectionParams; - private String passwordFromParams; + protected final ConnectionParams connectionParams; + protected String passwordFromParams; boolean isSeparateFrame = true; - boolean isApplet = true; + protected boolean isApplet = true; private final ProtocolSettings settings; - private final UiSettings uiSettings; + protected UiSettings uiSettings; private volatile boolean isAppletStopped = false; private ConnectionPresenter connectionPresenter; @@ -73,12 +78,12 @@ } public static void printUsage(String additional) { - System.out.println("Usage: java -jar (progfilename) [hostname [port_number]] [Options]\n" + - " or\n"+ - " java -jar (progfilename) [Options]\n" + - " or\n java -jar (progfilename) -help\n to view this help\n\n" + - "Where Options are:\n" + additional + - "\nOptions format: -optionName=optionValue. Ex. -host=localhost -port=5900 -viewonly=yes\n" + + System.out.println("Usage: java -jar (progfilename) [hostname [port_number]] [Options]¥n" + + " or¥n"+ + " java -jar (progfilename) [Options]¥n" + + " or¥n java -jar (progfilename) -help¥n to view this help¥n¥n" + + "Where Options are:¥n" + additional + + "¥nOptions format: -optionName=optionValue. Ex. -host=localhost -port=5900 -viewonly=yes¥n" + "Both option name and option value are case insensitive."); } @@ -201,7 +206,6 @@ @Override public void run() { - final boolean hasJsch = checkJsch(); final boolean allowInteractive = allowAppletInteractiveConnections || ! isApplet; connectionPresenter = new ConnectionPresenter(hasJsch, allowInteractive); @@ -261,4 +265,134 @@ } } + public void setType(TreeConnectionManager treeConnectionManager, + MyRfbProtoClient myRfbProtoClient) { + // must write + } + + public void setSocket(Socket soc) { + // TODO Auto-generated method stub + + } + + public void setOpenPort(int parseInt) { + // TODO Auto-generated method stub + + } + + public void setTeminationType(boolean b) { + // TODO Auto-generated method stub + } + + public void startViewer(String[] args) { + GetHostClient bCast = new GetHostClient("who"); + bCast.getHost(); + GetDataClient getBcast = new GetDataClient(); + Thread runBcast = new Thread(getBcast); + runBcast.start(); + connectionParams.hostName = getBcast.textAddress(); + getBcast.interrupt(); + Viewer viewer = new Viewer(); + SwingUtilities.invokeLater(viewer); + } + } + + + /* + @Override + public void run() { + + final boolean hasJsch = checkJsch(); + final boolean allowInteractive = allowAppletInteractiveConnections || ! isApplet; + connectionPresenter = new ConnectionPresenter(hasJsch, allowInteractive); + connectionPresenter.addModel("ConnectionParamsModel", connectionParams); + final ConnectionView connectionView = new ConnectionView( + Viewer.this, // appWindowListener + connectionPresenter, hasJsch); + connectionPresenter.addView(ConnectionPresenter.CONNECTION_VIEW, connectionView); + if (isApplet) { + connectionPresenter.addView("AppletStatusStringView", new View() { + @Override + public void showView() { / } + @Override + public void closeView() { } + @SuppressWarnings("UnusedDeclaration") + public void setMessage(String message) { + Viewer.this.getAppletContext().showStatus(message); + } + }); + } + if (forceReconnection) { + System.out.println("error10#####################"); + connectionManager.showReconnectDialog("Connection lost", reconnectionReason); + forceReconnection = false; + } + + + tryAgain = true; + while (tryAgain) { + if(workingSocket==null) + workingSocket = connectionManager.connectToHost(connectionParams, settings, rfb); + if (null == workingSocket) { + closeApp(); + break; + } + logger.info("Connected"); + System.out.println("connection-----------" + workingSocket.getInetAddress()); + try { + workingSocket.setTcpNoDelay(true); // disable Nagle algorithm + Reader reader = new Reader(workingSocket.getInputStream()); + Writer writer = new Writer(workingSocket.getOutputStream()); + + workingProtocol = new Protocol(reader, writer, + new PasswordChooser(passwordFromParams, connectionParams, containerFrame, this), + settings); + workingProtocol.handshake(); + + ClipboardControllerImpl clipboardController = + new ClipboardControllerImpl(workingProtocol, settings.getRemoteCharsetName()); + clipboardController.setEnabled(settings.isAllowClipboardTransfer()); + settings.addListener(clipboardController); + + surface = new Surface(workingProtocol, this, uiSettings.getScaleFactor()); + settings.addListener(this); + uiSettings.addListener(surface); + containerFrame = createContainer(); + connectionManager.setContainerFrame(containerFrame); + updateFrameTitle(); + if(rfb != null) { + rfb.setViewer(this); + runAcceptThread(); + rfb.setProtocolContext(workingProtocol); + rfb.notProxy(); + workingProtocol.startTreeClientHandling(this,surface, clipboardController,rfb); + } else { + workingProtocol.startNormalHandling(this, surface, clipboardController); + } + tryAgain = false; + } catch (UnsupportedProtocolVersionException e) { + connectionManager.showReconnectDialog("Unsupported Protocol Version", e.getMessage()); + logger.severe(e.getMessage()); + } catch (UnsupportedSecurityTypeException e) { + connectionManager.showReconnectDialog("Unsupported Security Type", e.getMessage()); + logger.severe(e.getMessage()); + } catch (AuthenticationFailedException e) { + passwordFromParams = null; + connectionManager.showReconnectDialog("Authentication Failed", e.getMessage()); + logger.severe(e.getMessage()); + } catch (TransportException e) { + connectionManager.showReconnectDialog("Connection Error", "Connection Error" + ": " + e.getMessage()); + logger.severe(e.getMessage()); + } catch (IOException e) { + connectionManager.showReconnectDialog("Connection Error", "Connection Error" + ": " + e.getMessage()); + logger.severe(e.getMessage()); + } catch (FatalException e) { + connectionManager.showReconnectDialog("Connection Error", "Connection Error" + ": " + e.getMessage()); + logger.severe(e.getMessage()); + } + } + } + */ + +