# HG changeset patch # User Tatsuki IHA # Date 1439580093 -32400 # Node ID b60780e1fafc7265850b03411d52ce6aaaea65a2 # Parent 0e3af3c8b7719f7a661a0cd26d8271c59e7716d8 Add ServerChangeThread to inhelitClients method Add startVNCConnectionMethod to ConnectionPresenter class diff -r 0e3af3c8b771 -r b60780e1fafc .idea/misc.xml --- a/.idea/misc.xml Fri Aug 14 16:26:04 2015 +0900 +++ b/.idea/misc.xml Sat Aug 15 04:21:33 2015 +0900 @@ -1,50 +1,8 @@ - - - - - - - - - - - - @@ -86,131 +44,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - localhost - 5050 - - - - - - - diff -r 0e3af3c8b771 -r b60780e1fafc .idea/workspace.xml --- a/.idea/workspace.xml Fri Aug 14 16:26:04 2015 +0900 +++ b/.idea/workspace.xml Sat Aug 15 04:21:33 2015 +0900 @@ -2,7 +2,10 @@ - + + + + @@ -19,9 +22,6 @@ - - - @@ -33,9 +33,16 @@ - + - + + + + + + + + @@ -43,11 +50,47 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -56,9 +99,14 @@ - + - + + + + + + @@ -66,63 +114,100 @@ - + - - - - - - - - - - - + - - + + - + - - + + - + - - + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + @@ -130,37 +215,113 @@ - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + - - + + + + + + + + + + + + @@ -169,9 +330,14 @@ - + - + + + + + + @@ -179,8 +345,8 @@ - - + + @@ -461,20 +627,23 @@ + + + - @@ -499,8 +668,7 @@ - - + @@ -763,6 +931,8 @@ + + @@ -782,6 +952,8 @@ + + @@ -818,6 +990,26 @@ + + + - - - + - + - + + - - - - + + + + - - + + - + - - + @@ -1055,9 +1223,9 @@ - + - + @@ -1076,9 +1244,6 @@ - @@ -1093,17 +1258,23 @@ @@ -1112,17 +1283,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + - + @@ -1130,32 +1411,47 @@ - + - + + + + + + + + - + + - - - - - - - + + + + + + + + + + + + + + - + @@ -1163,363 +1459,533 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + - - - - - - - - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - - - - - - - - - - + + - + - - - - - - - - - - - - - - - - - - - + + + - - + + + - - - - - - - + + + + + + + + + + + + + + - + - - + + diff -r 0e3af3c8b771 -r b60780e1fafc src/viewer_swing/java/com/glavsoft/viewer/ConnectionPresenter.java --- a/src/viewer_swing/java/com/glavsoft/viewer/ConnectionPresenter.java Fri Aug 14 16:26:04 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/ConnectionPresenter.java Sat Aug 15 04:21:33 2015 +0900 @@ -27,10 +27,8 @@ import com.glavsoft.rfb.protocol.ProtocolSettings; import com.glavsoft.utils.Strings; import com.glavsoft.viewer.mvp.Presenter; -import com.glavsoft.viewer.swing.ConnectionParams; -import com.glavsoft.viewer.swing.SwingNetworkConnectionWorker; -import com.glavsoft.viewer.swing.SwingViewerWindow; -import com.glavsoft.viewer.swing.WrongParameterException; +import com.glavsoft.viewer.mvp.View; +import com.glavsoft.viewer.swing.*; import com.glavsoft.viewer.swing.gui.ConnectionView; import com.glavsoft.viewer.swing.gui.ConnectionsHistory; @@ -331,4 +329,28 @@ public Socket getSocket() { return rfbConnectionWorker.getSocket(); } + + public void startVNCConnection(Viewer viewer) { + final boolean hasJsch = viewer.checkJsch(); + ConnectionView connectionView = new ConnectionView( + viewer, // appWindowListener + this, hasJsch); + addView(CONNECTION_VIEW, connectionView); + if (viewer.isApplet) { + addView("AppletStatusStringView", new View() { + @Override + public void showView() { /*nop*/ } + + @Override + public void closeView() { /*nop*/ } + }); + } + + SwingViewerWindowFactory viewerWindowFactory = new SwingViewerWindowFactory(viewer.isSeparateFrame, viewer.isApplet, viewer, viewer.width, viewer.height); + + setConnectionWorkerFactory( + new SwingConnectionWorkerFactory(connectionView.getFrame(), viewer.passwordFromParams, this, viewerWindowFactory, viewer.myRfb)); + setNeedReconnection(!viewer.noConnection); + startConnection(viewer.settings, viewer.uiSettings, viewer.paramsMask); + } } diff -r 0e3af3c8b771 -r b60780e1fafc src/viewer_swing/java/com/glavsoft/viewer/Viewer.java --- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Fri Aug 14 16:26:04 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Sat Aug 15 04:21:33 2015 +0900 @@ -26,13 +26,7 @@ import com.glavsoft.rfb.protocol.ProtocolSettings; import com.glavsoft.viewer.cli.Parser; -import com.glavsoft.viewer.mvp.View; -import com.glavsoft.viewer.swing.ConnectionParams; -import com.glavsoft.viewer.swing.ParametersHandler; -import com.glavsoft.viewer.swing.SwingConnectionWorkerFactory; -import com.glavsoft.viewer.swing.SwingViewerWindow; -import com.glavsoft.viewer.swing.SwingViewerWindowFactory; -import com.glavsoft.viewer.swing.gui.ConnectionView; +import com.glavsoft.viewer.swing.*; import javax.swing.*; @@ -54,20 +48,20 @@ public class Viewer extends JApplet implements Runnable, WindowListener , ViewerInterface { private Logger logger; - private int paramsMask; - private boolean allowAppletInteractiveConnections; + public int paramsMask; + public boolean allowAppletInteractiveConnections; public final ConnectionParams connectionParams; - protected String passwordFromParams; - boolean isSeparateFrame = true; - protected boolean isApplet = true; - private final ProtocolSettings settings; - protected UiSettings uiSettings; + public String passwordFromParams; + public boolean isSeparateFrame = true; + public boolean isApplet = true; + public final ProtocolSettings settings; + public UiSettings uiSettings; private volatile boolean isAppletStopped = false; private ConnectionPresenter connectionPresenter; boolean isTreeVNC = false; - protected TreeRFBProto myRfb; - private boolean noConnection; + public TreeRFBProto myRfb; + public boolean noConnection; public int vncport = ConnectionParams.DEFAULT_RFB_PORT; private int fbWidth; private boolean showTree = false; @@ -91,7 +85,7 @@ public static void printUsage(String additional) { System.out.println("Usage: java -jar (progfilename) [hostname [port_number]] [Options]¥n" + - " or¥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 + @@ -207,7 +201,7 @@ super.start(); } - private boolean checkJsch() { + public boolean checkJsch() { try { Class.forName("com.jcraft.jsch.JSch"); return true; @@ -224,28 +218,10 @@ public void run() { final boolean hasJsch = checkJsch(); final boolean allowInteractive = allowAppletInteractiveConnections || ! isApplet; - ConnectionPresenter connectionPresenter = new ConnectionPresenter(hasJsch, allowInteractive); + connectionPresenter = new ConnectionPresenter(hasJsch, allowInteractive); connectionPresenter.setNoConnection(noConnection); connectionPresenter.addModel("ConnectionParamsModel", connectionParams); - 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() { /*nop*/ } - @Override - public void closeView() { /*nop*/ } - }); - } - - SwingViewerWindowFactory viewerWindowFactory = new SwingViewerWindowFactory(isSeparateFrame, isApplet, this, width, height); - - connectionPresenter.setConnectionWorkerFactory( - new SwingConnectionWorkerFactory(connectionView.getFrame(), passwordFromParams, connectionPresenter, viewerWindowFactory, myRfb)); - connectionPresenter.setNeedReconnection(!noConnection); - connectionPresenter.startConnection(settings, uiSettings, paramsMask); + connectionPresenter.startVNCConnection(this); } @Override @@ -333,10 +309,22 @@ @Override public void inhelitClients(ViewerInterface vs, String hostName) { myRfb.vncConnected(false); + final boolean hasJsch = checkJsch(); + final boolean allowInteractive = allowAppletInteractiveConnections || ! isApplet; + final ConnectionPresenter connectionPresenter = new ConnectionPresenter(hasJsch, allowInteractive); + connectionPresenter.setNoConnection(noConnection); + ConnectionParams connectionParams = new ConnectionParams(); connectionParams.setConnectionParam(hostName, vncport); + connectionPresenter.addModel("ConnectionParamsModel", connectionParams); isApplet = true; this.setNoConnection(false); - run(); + final Viewer v = this; + new Thread(new Runnable() { + @Override + public void run() { + connectionPresenter.startVNCConnection(v); + } + }, "ServerChangeThread").start(); } /**