# HG changeset patch # User innparusu # Date 1439627299 -32400 # Node ID 2d01ec1c02d27f078fc1e512b8bbc59545c5d0fb # Parent b60780e1fafc7265850b03411d52ce6aaaea65a2 Fix ReConnectingFlag diff -r b60780e1fafc -r 2d01ec1c02d2 .idea/workspace.xml --- a/.idea/workspace.xml Sat Aug 15 04:21:33 2015 +0900 +++ b/.idea/workspace.xml Sat Aug 15 17:28:19 2015 +0900 @@ -2,9 +2,14 @@ + + + + + - + @@ -22,6 +27,9 @@ + + + @@ -33,15 +41,11 @@ - - + + - - - - - - + + @@ -50,48 +54,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + @@ -99,29 +64,9 @@ - + - - - - - - - - - - - - - - - - - - - - - + @@ -129,35 +74,21 @@ - - + + - - + + - - + + - - - - - - - - - - - - - - - - + + @@ -166,7 +97,7 @@ - + @@ -176,38 +107,33 @@ - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + @@ -215,90 +141,9 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -310,18 +155,21 @@ - - - + + + + + + - + - - + + @@ -330,23 +178,37 @@ - + + + + + + + + + + + - - - - + + + + + + + + - - + + - - + + @@ -625,25 +487,23 @@ - - - + @@ -668,7 +528,7 @@ - + @@ -931,8 +791,8 @@ - + @@ -990,26 +850,6 @@ - + + - + - - + - - + + - - + + + - + - + - @@ -1244,6 +1108,9 @@ + @@ -1260,7 +1127,7 @@ file://$PROJECT_DIR$/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java - 199 + 198 @@ -1283,175 +1150,85 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + - + + + + + + + + + - - - - + + + + + + + + - - - - - - - - - + - + + + + + + + + + + - + - - - - - - + + - + - + - - - - - - - - - - - - - - + - + @@ -1459,534 +1236,349 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - + - + - - + + + - + - - + + + - + - - + + + - + - - + + - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - - - - - - - - - - + + - + - + - - - + + + + + + + + + + + + + + + + + - - + + - + - - - - - - - - - - - - - - + - + - - - + + + + + + + + + + + + diff -r b60780e1fafc -r 2d01ec1c02d2 src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java --- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Sat Aug 15 04:21:33 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Sat Aug 15 17:28:19 2015 +0900 @@ -6,6 +6,7 @@ import java.net.*; import java.nio.ByteBuffer; import java.nio.ByteOrder; +import java.util.Enumeration; import java.util.Iterator; import java.util.LinkedList; import java.util.concurrent.atomic.AtomicInteger; @@ -46,7 +47,6 @@ private TreeVncCommandChannelListener acceptThread; private TreeRootFinderListener getCast; private CreateConnectionParam cp; - private short reconnectingId; // Change Server Request to id's node VNC server private TreeVNCNetwork nets = new TreeVNCNetwork(); private TreeVncRootSelectionPanel rootSelectionPanel; private String vncInterface; @@ -57,7 +57,6 @@ private boolean permitChangeScreen = true; private boolean leader; private boolean hasViewer = false; - private boolean reconnecting; private boolean normalTermination; private boolean isTreeManager; public boolean showTreeNode = false; @@ -481,37 +480,30 @@ public synchronized void vncConnected(boolean ready) { enableChildrenTransmission(); - if (ready && reconnecting) { - printNetworkInterface(); - sendDesktopSizeChange(reconnectingId); - reconnecting = false; - /* - if (reconnectingId == 0) { - viewer.setVisible(false); - } - */ - } - if (reconnectingId!=0) { - readyReconnect = ready; - if (ready) { - notifyAll(); - } + readyReconnect = ready; + if (ready) { + notifyAll(); } } - private void printNetworkInterface() { + public void printNetworkInterface() { Socket vncSocket = viewer.getVNCSocket(); NetworkInterface ni = nets.getInterface(vncSocket); if (ni!=null) { vncInterface = ni.getName(); - System.out.println("VNCNetworkInterface :" + vncInterface); + System.out.print("VNCNetworkInterface :" + vncInterface); + Enumeration addresses = ni.getInetAddresses(); + while(addresses.hasMoreElements()) { + InetAddress adr = addresses.nextElement(); + System.out.print(" "+adr); + } + System.out.println(); } } public synchronized void waitForVNCConnection() { - if (reconnectingId!=0) { - while (!readyReconnect) { + while (!readyReconnect) { try { wait(); } catch (InterruptedException e) { @@ -519,9 +511,6 @@ System.out.println("interrupt wait for vnc connection."); } } - } else { - System.out.println("changeVNCServer : got recconectionId == 0"); - } } @@ -831,13 +820,9 @@ return; } // serverChangeの処理 - reconnectingId = newVNCServerId; - vncProxyService.inhelitClients(vncProxyService, hostName); + vncProxyService.inhelitClients(vncProxyService, hostName, newVNCServerId); // after connecting VNC server, rfb send SEND_INIT_DATA command and wakes me up if necessary - reconnecting = true; // stop reader stop - stopReceiverTask(); - waitForVNCConnection(); } /** @@ -875,14 +860,6 @@ hasViewer = b; } - public void setReconnecting(boolean b) { - reconnecting = b; - } - - public int getReconnectingId() { - return reconnectingId; - } - public void setShowTree(boolean showTree) { this.showTreeNode = showTree; } diff -r b60780e1fafc -r 2d01ec1c02d2 src/viewer_swing/java/com/glavsoft/viewer/ConnectionPresenter.java --- a/src/viewer_swing/java/com/glavsoft/viewer/ConnectionPresenter.java Sat Aug 15 04:21:33 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/ConnectionPresenter.java Sat Aug 15 17:28:19 2015 +0900 @@ -26,11 +26,13 @@ import com.glavsoft.rfb.protocol.ProtocolSettings; import com.glavsoft.utils.Strings; +import com.glavsoft.viewer.mvp.Model; import com.glavsoft.viewer.mvp.Presenter; 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; +import jp.ac.u_ryukyu.treevnc.TreeRFBProto; import java.net.Socket; import java.util.logging.Logger; @@ -64,6 +66,25 @@ private boolean isTreeVNC = false; private boolean cuiVersion; private boolean noConnection = false; + public ViewerInterface viewer; + private ConnectionParams connectionParams; + private short reconnectingId; + + public short getReconnectingId() { + return reconnectingId; + } + + public void setReconnectingId(short reconnectingId) { + this.reconnectingId = reconnectingId; + } + + public ConnectionParams getConnectionParams() { + return connectionParams; + } + + public void setConnectionParams(ConnectionParams connectionParams) { + this.connectionParams = connectionParams; + } public ConnectionPresenter(boolean hasSshSupport, boolean allowInteractive) { this.hasSshSupport = hasSshSupport; @@ -331,6 +352,7 @@ } public void startVNCConnection(Viewer viewer) { + this.viewer = viewer; final boolean hasJsch = viewer.checkJsch(); ConnectionView connectionView = new ConnectionView( viewer, // appWindowListener @@ -353,4 +375,13 @@ setNeedReconnection(!viewer.noConnection); startConnection(viewer.settings, viewer.uiSettings, viewer.paramsMask); } + + public void newVNCConnection() { + TreeRFBProto rfb = viewer.getRfb(); + rfb.stopReceiverTask(); + viewer.getConnectionPresenter().addModel("ConnectionParamsModel", connectionParams); + rfb.enableChildrenTransmission(); + rfb.printNetworkInterface(); + rfb.sendDesktopSizeChange(reconnectingId); + } } diff -r b60780e1fafc -r 2d01ec1c02d2 src/viewer_swing/java/com/glavsoft/viewer/CuiViewer.java --- a/src/viewer_swing/java/com/glavsoft/viewer/CuiViewer.java Sat Aug 15 04:21:33 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/CuiViewer.java Sat Aug 15 17:28:19 2015 +0900 @@ -150,6 +150,11 @@ } @Override + public ConnectionPresenter getConnectionPresenter() { + return connectionPresenter; + } + + @Override public void windowOpened(WindowEvent e) { /* nop */ } @@ -242,7 +247,7 @@ } @Override - public void inhelitClients(ViewerInterface vncProxyService, String hostName) { + public void inhelitClients(ViewerInterface vncProxyService, String hostName, short newVNCServerId) { } diff -r b60780e1fafc -r 2d01ec1c02d2 src/viewer_swing/java/com/glavsoft/viewer/Viewer.java --- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Sat Aug 15 04:21:33 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Sat Aug 15 17:28:19 2015 +0900 @@ -230,6 +230,11 @@ } @Override + public ConnectionPresenter getConnectionPresenter() { + return connectionPresenter; + } + + @Override public void windowOpened(WindowEvent e) { /* nop */ } @Override public void windowClosed(WindowEvent e) { /* nop */ } @@ -305,10 +310,10 @@ * inherited clients * @param vs * @param hostName + * @param newVNCServerId */ @Override - public void inhelitClients(ViewerInterface vs, String hostName) { - myRfb.vncConnected(false); + public void inhelitClients(ViewerInterface vs, String hostName, short newVNCServerId) { final boolean hasJsch = checkJsch(); final boolean allowInteractive = allowAppletInteractiveConnections || ! isApplet; final ConnectionPresenter connectionPresenter = new ConnectionPresenter(hasJsch, allowInteractive); @@ -316,6 +321,8 @@ ConnectionParams connectionParams = new ConnectionParams(); connectionParams.setConnectionParam(hostName, vncport); connectionPresenter.addModel("ConnectionParamsModel", connectionParams); + connectionPresenter.setConnectionParams(connectionParams); + connectionPresenter.setReconnectingId(newVNCServerId); isApplet = true; this.setNoConnection(false); final Viewer v = this; @@ -379,7 +386,6 @@ connectionParams.setConnectionParam(hostname, vncport); isApplet = true; settings.setViewOnly(true); // too avoid unnecessary upward traffic - rfb.setReconnecting(true); ArrayList rectangles = getScreenRectangles(); int leftScreenNumber = 0; @@ -395,7 +401,6 @@ connectionParams.setConnectionParam(hostName, vncport); isApplet = true; myRfbProto.createConnectionAndStart(this); - myRfbProto.setReconnecting(true); run(); } diff -r b60780e1fafc -r 2d01ec1c02d2 src/viewer_swing/java/com/glavsoft/viewer/ViewerInterface.java --- a/src/viewer_swing/java/com/glavsoft/viewer/ViewerInterface.java Sat Aug 15 04:21:33 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/ViewerInterface.java Sat Aug 15 17:28:19 2015 +0900 @@ -5,6 +5,7 @@ import java.net.Socket; import java.util.ArrayList; +import com.glavsoft.viewer.mvp.Presenter; import jp.ac.u_ryukyu.treevnc.TreeRFBProto; public interface ViewerInterface extends Runnable { @@ -29,7 +30,7 @@ public void connectToParenet(int port, String hostname) throws IOException; - public void inhelitClients(ViewerInterface vncProxyService, String hostName); + public void inhelitClients(ViewerInterface vncProxyService, String hostName, short newVNCServerId); public void proxyStart(String[] args, int width, int height, boolean showTree, boolean checkDelay, boolean addSerialNum, boolean fixingSize, boolean filterSingleDisplay); @@ -52,4 +53,6 @@ public ArrayList getScreenRectangles(); void newVNCConnection(ConnectionPresenter presenter); + + ConnectionPresenter getConnectionPresenter(); } diff -r b60780e1fafc -r 2d01ec1c02d2 src/viewer_swing/java/com/glavsoft/viewer/swing/ConnectionParams.java --- a/src/viewer_swing/java/com/glavsoft/viewer/swing/ConnectionParams.java Sat Aug 15 04:21:33 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/ConnectionParams.java Sat Aug 15 17:28:19 2015 +0900 @@ -219,4 +219,5 @@ this.hostName = hostname; this.portNumber = port; } + } diff -r b60780e1fafc -r 2d01ec1c02d2 src/viewer_swing/java/com/glavsoft/viewer/swing/SwingRfbConnectionWorker.java --- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingRfbConnectionWorker.java Sat Aug 15 04:21:33 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingRfbConnectionWorker.java Sat Aug 15 17:28:19 2015 +0900 @@ -108,9 +108,7 @@ try { get(); presenter.showMessage("Handshake established"); - if(myRfb.getViewer() != null) { - myRfb.getViewer().newVNCConnection(presenter); - } + presenter.newVNCConnection(); ClipboardControllerImpl clipboardController; if(!myRfb.getCuiVersion()) clipboardController = new ClipboardControllerImpl(workingProtocol, rfbSettings.getRemoteCharsetName());