Mercurial > hg > Applications > TreeVNC
changeset 153:e68dfd1972ac
fix bad names.
line wrap: on
line diff
--- a/Todo.txt Fri Jun 13 17:27:41 2014 +0900 +++ b/Todo.txt Fri Jun 13 18:04:42 2014 +0900 @@ -1,3 +1,8 @@ +Fri Jun 13 17:29:02 JST 2014 + + AcceptThreadをMultiThread化する。(deadlockを防ぐため) + TreeNodeが死んだときに、最後のNodeをそこに置き換える。 + Sat Jun 7 11:47:56 JST 2014 Multicast で root を探す (FIND_ROOT)
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/AcceptThread.java Fri Jun 13 17:27:41 2014 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -package jp.ac.u_ryukyu.treevnc; -import java.net.Socket; -import java.io.InputStream; -import java.io.OutputStream; - -import com.glavsoft.transport.Reader; -import com.glavsoft.transport.Writer; - -public class AcceptThread implements Runnable { - public MyRfbProto rfb = null; - byte[] imageBytes; - int port; - - public AcceptThread(MyRfbProto _rfb, int p) { - rfb = _rfb; - port = p; - } - - public void changeRfb(MyRfbProto _rfb) { - rfb = _rfb; - } - - public void run() { - while (true) { - try { - Socket newCli = rfb.accept(); - OutputStream os = newCli.getOutputStream(); - InputStream is = newCli.getInputStream(); - rfb.newClient(this, newCli, new Writer(os), new Reader(is)); - } catch (Exception e) { - System.out.println("failed to connect incoming client" + e.getMessage()); - } - } - } -}
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java Fri Jun 13 17:27:41 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java Fri Jun 13 18:04:42 2014 +0900 @@ -2,7 +2,7 @@ import java.io.IOException; -import com.glavsoft.viewer.ViewerImpl; +import com.glavsoft.viewer.ViewerInterface; import com.glavsoft.viewer.swing.ConnectionParams; import jp.ac.u_ryukyu.treevnc.client.FindRoot; @@ -32,7 +32,7 @@ * Incoming CONNECT_TO message is handled in MyRFBProto * @param v */ - public void createConnectionParam(ViewerImpl v) { + public void createConnectionParam(ViewerInterface v) { TreeVncProtocol echo = new TreeVncProtocol(hostName,portNumber); rfb.setEcho(echo); try { @@ -42,10 +42,10 @@ } } - public void runAcceptThread() { + public void runTreeVncCommandListener() { rfb.selectPort(ConnectionParams.DEFAULT_VNC_ROOT); - AcceptThread acceptThread = new AcceptThread(rfb, rfb.getAcceptPort()); - accThread = new Thread(acceptThread); + TreeVncCommandCannelListener acceptThread = new TreeVncCommandCannelListener(rfb, rfb.getAcceptPort()); + accThread = new Thread(acceptThread, "tree-vnc-command-listener"); accThread.start(); }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/InterfaceForViewer.java Fri Jun 13 17:27:41 2014 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -package jp.ac.u_ryukyu.treevnc; - -import java.awt.Image; -import java.net.Socket; - -import jp.ac.u_ryukyu.treevnc.client.*; - -public interface InterfaceForViewer extends java.lang.Runnable{ - - public void setEchoValue(TreeVncProtocol value); - public String readParameter(String name, boolean required); - - public void getParentName(); - // synchronized - public void disconnect(); - public void fatalError(String str); - public void fatalError(String str, Exception e); - - - public void destroy(); - - public void enableInput(boolean enable); - - - public void setClientSocket(Socket sock); - public void close(); - public Image getScreenImage(); - public void writeScreenData(byte[] b, String imageFormat); - -}
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Fri Jun 13 17:27:41 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Fri Jun 13 18:04:42 2014 +0900 @@ -1,7 +1,6 @@ package jp.ac.u_ryukyu.treevnc; import java.io.IOException; -import java.io.OutputStream; import java.net.BindException; import java.net.ServerSocket; import java.net.Socket; @@ -25,19 +24,18 @@ import com.glavsoft.rfb.protocol.state.HandshakeState; import com.glavsoft.transport.Reader; import com.glavsoft.transport.Writer; -import com.glavsoft.viewer.ViewerImpl; +import com.glavsoft.viewer.ViewerInterface; public abstract class MyRfbProto { final static int FramebufferUpdateRequest = 3; final static int CheckDelay = 11; protected final static int FramebufferUpdate = 0; - private ProtocolContext context; + protected ProtocolContext context; protected final static String versionMsg_3_856 = "RFB 003.856\n"; - private int clients; + private int clients = 0; public MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new MulticastQueue<LinkedList<ByteBuffer>>(); private RequestScreenThread rThread; - private boolean proxyFlag = true; public int acceptPort = 0; protected boolean readyReconnect = false; private boolean cuiVersion; @@ -95,7 +93,7 @@ * @throws IOException * @throws TransportException */ - public void newClient(AcceptThread acceptThread, final Socket newCli,final Writer os, final Reader is) { + public void newClient(TreeVncCommandCannelListener acceptThread, final Socket newCli,final Writer os, final Reader is) { try { if (initialConnection(os, is, newCli)) { @@ -308,35 +306,15 @@ } int rfbMajor = (b[4] - '0') * 100 + (b[5] - '0') * 10 + (b[6] - '0'); - int rfbMinor = (b[8] - '0') * 100 + (b[9] - '0') * 10 + (b[10] - '0'); +// int rfbMinor = (b[8] - '0') * 100 + (b[9] - '0') * 10 + (b[10] - '0'); if (rfbMajor < 3) { throw new IOException( "RFB server does not support protocol version 3"); } - if (rfbMinor == 855) { - sendProxyFlag(writer); - if (proxyFlag) - sendPortNumber(writer); - } return null; } - - - private void sendProxyFlag(Writer writer) throws TransportException { - if (proxyFlag) - writer.writeInt(1); - else - writer.writeInt(0); - } - - private void sendPortNumber(Writer writer) throws TransportException { - ByteBuffer b = ByteBuffer.allocate(4); - b.order(ByteOrder.BIG_ENDIAN); - b.putInt(9999); - writer.write(b.array()); - } private void readSecType(Reader reader) throws TransportException { @@ -426,20 +404,16 @@ // os.write(b); } - public void notProxy() { - proxyFlag = false; - } - public void setEcho(TreeVncProtocol _echo) { treeProtocol = _echo; treeVncCommand.setVncProtocol(_echo); } - public void setViewer(ViewerImpl v) { + public void setViewer(ViewerInterface v) { treeProtocol.setViewer(v); } - public ViewerImpl getViewer() { + public ViewerInterface getViewer() { return treeProtocol.getViewer(); } @@ -456,13 +430,6 @@ return true; } - void sendProxyFlag(OutputStream os) throws IOException { - if (proxyFlag) - os.write(1); - else - os.write(0); - } - public void close() { // none }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommand.java Fri Jun 13 17:27:41 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommand.java Fri Jun 13 18:04:42 2014 +0900 @@ -94,7 +94,7 @@ * @param myHostName */ void handleWhereToConnect(int port, String hostname, String myHostName) { - viewer.replyCreateTree(hostname,port,myHostName); + viewer.decideWhereToConnect(hostname,port,myHostName); } /**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommandCannelListener.java Fri Jun 13 18:04:42 2014 +0900 @@ -0,0 +1,35 @@ +package jp.ac.u_ryukyu.treevnc; +import java.net.Socket; +import java.io.InputStream; +import java.io.OutputStream; + +import com.glavsoft.transport.Reader; +import com.glavsoft.transport.Writer; + +public class TreeVncCommandCannelListener implements Runnable { + public MyRfbProto rfb = null; + byte[] imageBytes; + int port; + + public TreeVncCommandCannelListener(MyRfbProto _rfb, int p) { + rfb = _rfb; + port = p; + } + + public void changeRfb(MyRfbProto _rfb) { + rfb = _rfb; + } + + public void run() { + while (true) { + try { + Socket newCli = rfb.accept(); + OutputStream os = newCli.getOutputStream(); + InputStream is = newCli.getInputStream(); + rfb.newClient(this, newCli, new Writer(os), new Reader(is)); + } catch (Exception e) { + System.out.println("failed to connect incoming client" + e.getMessage()); + } + } + } +}
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/MyRfbProtoClient.java Fri Jun 13 17:27:41 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/MyRfbProtoClient.java Fri Jun 13 18:04:42 2014 +0900 @@ -11,21 +11,11 @@ import com.glavsoft.transport.Reader; public class MyRfbProtoClient extends MyRfbProto { - private Reader reader; - private ProtocolContext context; - boolean proxyFlag = false; - int serverMajor, serverMinor; - int clientMajor, clientMinor; private boolean normalTermination; private TreeVncRootSelectionPanel rootSelectionPanel; public MyRfbProtoClient() { - - } - - public MyRfbProtoClient(Reader reader, String host, String port) { - this.reader = reader; } @Override
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/TreeVncProtocol.java Fri Jun 13 17:27:41 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/TreeVncProtocol.java Fri Jun 13 18:04:42 2014 +0900 @@ -8,14 +8,14 @@ import javax.swing.SwingUtilities; import com.glavsoft.rfb.protocol.ProtocolContext; -import com.glavsoft.viewer.ViewerImpl; +import com.glavsoft.viewer.ViewerInterface; public class TreeVncProtocol { private BufferedReader is = null; private DataOutputStream os = null; private Socket echoSocket = null; private int echoPort; - public ViewerImpl client; + public ViewerInterface client; private String parentAddress; public boolean leaderFlag; private String myAddress; @@ -95,11 +95,11 @@ echoSocket.close(); } - public void setViewer(ViewerImpl v) { + public void setViewer(ViewerInterface v) { client = v; } - public ViewerImpl getViewer() { + public ViewerInterface getViewer() { return client; }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/AcceptClient.java Fri Jun 13 17:27:41 2014 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,155 +0,0 @@ -package jp.ac.u_ryukyu.treevnc.server; - -import java.net.UnknownHostException; -import java.io.*; -import java.net.*; -import java.util.*; - -import jp.ac.u_ryukyu.treevnc.MyRfbProto; -import jp.ac.u_ryukyu.treevnc.client.TreeVncProtocol; - -public class AcceptClient { - private LinkedList<TreeVNCNode> nodeList = new LinkedList<TreeVNCNode>(); - boolean runflag = false; - private final int treebranch = 2; - // private final int intv_time = 100; avoid too frequent reconnection - private MyRfbProto rfb; - - public AcceptClient(String hostName, int vncport, MyRfbProto myRfb) { - TreeVNCNode me = new TreeVNCNode(hostName, vncport,"localhost"); - me.setTreeNum(0); - nodeList.add(me); - rfb = myRfb; - } - -// -// private boolean checkAddress(String line) { -// String test[] = line.split("\\."); -// int a = Integer.parseInt(test[0]); -// int b = Integer.parseInt(test[1]); -// if ((192 == a && b == 168) || (172 == a && (b > 15 || b < 32)) -// || 10 == a) { -// return true; -// } else { -// return false; -// } -// } - - - /** - * a parent is lost, remove from the list and move last one into here - * @param nodeNum - * parent value - */ - private void moveLastNodeToLostNodePosition(int nodeNum) { - nodeList.remove(nodeNum); - TreeVNCNode node = nodeList.removeLast(); - node.setTreeNum(nodeNum); - nodeList.add(nodeNum, node) ; - } - - private void checkParameter(int parent, int counter, int leaderflag2) { - System.out.println("number p =" + parent); - System.out.println("number i =" + counter); - System.out.println("leaderflag=" + leaderflag2 + "\n"); - } - - String getMyAddress() { - InetAddress addr = null; - try { - addr = InetAddress.getLocalHost(); - } catch (UnknownHostException e) { - e.printStackTrace(); - } - return addr.getHostAddress(); - } - - private TreeVNCNode getParentNode(int nodeNum) { - int parentnum = (nodeNum - 1) / treebranch; - return nodeList.get(parentnum); - } - - /** - * A parent is lost, move last node which has no child to the position - * @param hostname - * @param port - */ - public void fixLostParent(String hostname, int port) { - TreeVNCNode lostParentNode = lookup(nodeList,hostname,port); - if (lostParentNode == null ) return; // some thing wrong - int treeNumber = lostParentNode.getTreeNum(); - TreeVNCNode newparent = getParentNode(treeNumber); - moveLastNodeToLostNodePosition(treeNumber); - if(nodeList.size() > treeNumber +1) - lostNodeConnection(newparent); - // if lostParentNode is the last one, we don't need reconnection - // Thread.sleep(intv_time); - } - - /** - * send reconnect to all children - * @param newparent - */ - private void lostNodeConnection(TreeVNCNode newparent) { - for(int i=1; i < treebranch; i++ ) { - if (newparent.getTreeNum() + i <=nodeList.size() ) { - TreeVNCNode n = nodeList.get(newparent.getTreeNum()+i) ; - TreeVncProtocol vc = new TreeVncProtocol(n.getHostname(),n.getPort()); - try { - vc.connectTo(newparent.getHostname(), newparent.getPort(), isLeader(newparent)); - } catch (IOException e) { - // log - } - } - } - } - - private int isLeader(TreeVNCNode n) { - return ( n.getTreeNum() % treebranch == 1) ? 1 : 0; - } - - private TreeVNCNode lookup(LinkedList<TreeVNCNode> list, String hostname, int port) { - for (TreeVNCNode r : list) { - if (r.getHostname().equals(hostname) && r.getPort() == port ) - return r; - } - return null; - } - - /** - * Determine tree topology and send CONNECT_TO command - * @param hostname - * @param port - */ - public void replyCreateTree(String hostname, int port, String localhostname) { - TreeVNCNode node = new TreeVNCNode(hostname,port,localhostname); - node.setTreeNum(nodeList.size()); - nodeList.add(node); - TreeVncProtocol treeProtocol = new TreeVncProtocol(hostname,port); - try { - if (nodeList.size() >= treebranch + 1) { - TreeVNCNode parent = getParentNode(node.getTreeNum()); - checkParameter(parent.getTreeNum(), nodeList.size(), isLeader(node)); - treeProtocol.connectTo(parent.getHostname(),parent.getPort(),isLeader(node)); - } else { - // connect to me - treeProtocol.connectTo(localhostname,rfb.getAcceptPort(),isLeader(node)); - } - } catch (IOException e) { - // log - } - } - - public LinkedList<TreeVNCNode> getList() { - return nodeList; - } - - public void setList(LinkedList<TreeVNCNode> _ls) { - nodeList = _ls; - } - - public int getTreeBranch() { - return treebranch; - } - -} \ No newline at end of file
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/MyRfbProtoProxy.java Fri Jun 13 17:27:41 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/MyRfbProtoProxy.java Fri Jun 13 18:04:42 2014 +0900 @@ -7,11 +7,7 @@ import java.net.Socket; import java.nio.ByteBuffer; import java.util.LinkedList; - import com.glavsoft.transport.Writer; - -import java.util.concurrent.ExecutorService; - import jp.ac.u_ryukyu.treevnc.MyRfbProto; public class MyRfbProtoProxy extends MyRfbProto { @@ -29,20 +25,14 @@ boolean printStatusFlag = false; long startCheckTime; - private LinkedList<Socket> cliListTmp; private LinkedList<Socket> cliList; - boolean createBimgFlag; - boolean proxyFlag = true; - ExecutorService executor; - - byte[] pngBytes; public RequestScreenThread rThread; private Thread requestThread; public MyRfbProtoProxy() { rThread = new RequestScreenThread(this); - requestThread = new Thread(rThread); + requestThread = new Thread(rThread, "full-screen-request-timer"); } @Override @@ -74,10 +64,6 @@ cliList.add(sock); } - void addSockTmp(Socket sock) { - System.out.println("connected " + sock.getInetAddress()); - cliListTmp.add(sock); - } void requestThreadStart() { requestThread.start();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/TreeManagement.java Fri Jun 13 18:04:42 2014 +0900 @@ -0,0 +1,144 @@ +package jp.ac.u_ryukyu.treevnc.server; + + +import java.io.IOException; +import java.util.LinkedList; + +import jp.ac.u_ryukyu.treevnc.MyRfbProto; +import jp.ac.u_ryukyu.treevnc.client.TreeVncProtocol; + +public class TreeManagement { + private LinkedList<TreeVNCNode> nodeList = new LinkedList<TreeVNCNode>(); + boolean runflag = false; + private final int treebranch = 2; + // private final int intv_time = 100; avoid too frequent reconnection + private MyRfbProto rfb; + + public TreeManagement(String hostName, int vncport, MyRfbProto myRfb) { + TreeVNCNode me = new TreeVNCNode(hostName, vncport,"localhost"); + me.setTreeNum(0); + nodeList.add(me); + rfb = myRfb; + } + +// +// private boolean checkAddress(String line) { +// String test[] = line.split("\\."); +// int a = Integer.parseInt(test[0]); +// int b = Integer.parseInt(test[1]); +// if ((192 == a && b == 168) || (172 == a && (b > 15 || b < 32)) +// || 10 == a) { +// return true; +// } else { +// return false; +// } +// } + + + /** + * a parent is lost, remove from the list and move last one into here + * @param nodeNum + * parent value + */ + private void moveLastNodeToLostNodePosition(int nodeNum) { + nodeList.remove(nodeNum); + TreeVNCNode node = nodeList.removeLast(); + node.setTreeNum(nodeNum); + nodeList.add(nodeNum, node) ; + } + + private void checkParameter(int parent, int counter, int leaderflag2) { + System.out.println("number p =" + parent); + System.out.println("number i =" + counter); + System.out.println("leaderflag=" + leaderflag2 + "\n"); + } + + private TreeVNCNode getParentNode(int nodeNum) { + int parentnum = (nodeNum - 1) / treebranch; + return nodeList.get(parentnum); + } + + /** + * A parent is lost, move last node which has no child to the position + * @param hostname + * @param port + */ + public void fixLostParent(String hostname, int port) { + TreeVNCNode lostParentNode = lookup(nodeList,hostname,port); + if (lostParentNode == null ) return; // some thing wrong + int treeNumber = lostParentNode.getTreeNum(); + TreeVNCNode newparent = getParentNode(treeNumber); + moveLastNodeToLostNodePosition(treeNumber); + if(nodeList.size() > treeNumber +1) + lostNodeConnection(newparent); + // if lostParentNode is the last one, we don't need reconnection + // Thread.sleep(intv_time); + } + + /** + * send reconnect to all children + * @param newparent + */ + private void lostNodeConnection(TreeVNCNode newparent) { + for(int i=1; i < treebranch; i++ ) { + if (newparent.getTreeNum() + i <=nodeList.size() ) { + TreeVNCNode n = nodeList.get(newparent.getTreeNum()+i) ; + TreeVncProtocol vc = new TreeVncProtocol(n.getHostname(),n.getPort()); + try { + vc.connectTo(newparent.getHostname(), newparent.getPort(), isLeader(newparent)); + } catch (IOException e) { + // log + } + } + } + } + + private int isLeader(TreeVNCNode n) { + return ( n.getTreeNum() % treebranch == 1) ? 1 : 0; + } + + private TreeVNCNode lookup(LinkedList<TreeVNCNode> list, String hostname, int port) { + for (TreeVNCNode r : list) { + if (r.getHostname().equals(hostname) && r.getPort() == port ) + return r; + } + return null; + } + + /** + * Determine tree topology and send CONNECT_TO command + * @param hostname + * @param port + */ + public void decideWhereToConnect(String hostname, int port, String localhostname) { + TreeVNCNode node = new TreeVNCNode(hostname,port,localhostname); + node.setTreeNum(nodeList.size()); + nodeList.add(node); + TreeVncProtocol treeProtocol = new TreeVncProtocol(hostname,port); + try { + if (nodeList.size() >= treebranch + 1) { + TreeVNCNode parent = getParentNode(node.getTreeNum()); + checkParameter(parent.getTreeNum(), nodeList.size(), isLeader(node)); + treeProtocol.connectTo(parent.getHostname(),parent.getPort(),isLeader(node)); + } else { + // connect to me + treeProtocol.connectTo(localhostname,rfb.getAcceptPort(),isLeader(node)); + } + } catch (IOException e) { + // log + } + } + + public LinkedList<TreeVNCNode> getList() { + return nodeList; + } + + public void setList(LinkedList<TreeVNCNode> _ls) { + nodeList = _ls; + } + + public int getTreeBranch() { + return treebranch; + } + +} \ No newline at end of file
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java Fri Jun 13 17:27:41 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java Fri Jun 13 18:04:42 2014 +0900 @@ -6,7 +6,7 @@ import java.util.LinkedList; import java.util.logging.Logger; -import jp.ac.u_ryukyu.treevnc.AcceptThread; +import jp.ac.u_ryukyu.treevnc.TreeVncCommandCannelListener; import com.glavsoft.core.SettingsChangedEvent; import com.glavsoft.rfb.IChangeSettingsListener; import com.glavsoft.rfb.IRfbSessionListener; @@ -27,9 +27,9 @@ public static Logger logger = Logger.getLogger("com.glavsoft"); private boolean forceReconnection; private String reconnectionReason; - private AcceptThread acceptThread; + private TreeVncCommandCannelListener acceptThread; private TreeRootFinderListener getCast; - private AcceptClient clients; + private TreeManagement clients; static VncProxyService currentVps; private int fbWidth = 0; private boolean firstTime = true; @@ -72,7 +72,7 @@ private void initProxy1(String hostName) { myRfb = new MyRfbProtoProxy(); myRfb.setVncProxy(this); - clients = new AcceptClient(hostName, vncport,myRfb); + clients = new TreeManagement(hostName, vncport,myRfb); isApplet = false; setIsTreeVNC(true); setConnectionParam(hostName,vncport); @@ -103,12 +103,12 @@ */ public void createConnectionAndStart() { myRfb.selectPort(ConnectionParams.DEFAULT_VNC_ROOT); - acceptThread = new AcceptThread(myRfb, myRfb.getAcceptPort()); + acceptThread = new TreeVncCommandCannelListener(myRfb, myRfb.getAcceptPort()); Thread thread = new Thread(acceptThread, "TreeVNC-accept"); thread.start(); if(firstTime) { getCast = new TreeRootFinderListener(this); - thread = new Thread(getCast); + thread = new Thread(getCast, "tree-root-find-listener"); thread.start(); } } @@ -192,8 +192,8 @@ return clients.getList(); } - public void replyCreateTree(String hostname, int port,String localhostname) { - clients.replyCreateTree(hostname,port,localhostname); + public void decideWhereToConnect(String hostname, int port,String localhostname) { + clients.decideWhereToConnect(hostname,port,localhostname); } public void fixLostParent(String hostname, int port) {
--- a/src/viewer_swing/java/com/glavsoft/viewer/CuiViewer.java Fri Jun 13 17:27:41 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/CuiViewer.java Fri Jun 13 18:04:42 2014 +0900 @@ -22,7 +22,7 @@ import jp.ac.u_ryukyu.treevnc.MyRfbProto; import jp.ac.u_ryukyu.treevnc.client.MyRfbProtoClient; -public class CuiViewer implements Runnable, WindowListener, ViewerImpl { +public class CuiViewer implements Runnable, WindowListener, ViewerInterface { private Logger logger; private int paramsMask; @@ -214,7 +214,7 @@ CuiViewer viewer = new CuiViewer(); MyRfbProtoClient rfb = new MyRfbProtoClient(); CreateConnectionParam cp = new CreateConnectionParam(rfb); - cp.runAcceptThread(); + cp.runTreeVncCommandListener(); try { cp.findTreeVncRoot(); } catch (InterruptedException e) { @@ -231,7 +231,7 @@ MyRfbProtoClient rfb = new MyRfbProtoClient(); CreateConnectionParam cp = new CreateConnectionParam(rfb); cp.setHostName(hostName); - cp.runAcceptThread(); + cp.runTreeVncCommandListener(); cp.createConnectionParam(viewer); rfb.setViewer(viewer); rfb.setCuiVersion(true);
--- a/src/viewer_swing/java/com/glavsoft/viewer/TreeViewer.java Fri Jun 13 17:27:41 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/TreeViewer.java Fri Jun 13 18:04:42 2014 +0900 @@ -24,7 +24,7 @@ vps.proxyStart(args,width,height); if (!permitChangeScreen ) vps.getRfb().setPermitChangeScreen(false); } - ViewerImpl v; + ViewerInterface v; if (viewer) { v = cui ? new CuiViewer() : new Viewer(); if(hostName!=null) {
--- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Fri Jun 13 17:27:41 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Fri Jun 13 18:04:42 2014 +0900 @@ -50,7 +50,7 @@ import jp.ac.u_ryukyu.treevnc.client.MyRfbProtoClient; @SuppressWarnings("serial") -public class Viewer extends JApplet implements Runnable, WindowListener , ViewerImpl{ +public class Viewer extends JApplet implements Runnable, WindowListener , ViewerInterface{ private Logger logger; private int paramsMask; @@ -288,7 +288,7 @@ public void startTreeViewer() { MyRfbProtoClient rfb = new MyRfbProtoClient(); CreateConnectionParam cp = new CreateConnectionParam(rfb); - cp.runAcceptThread(); + cp.runTreeVncCommandListener(); try { cp.findTreeVncRoot(); } catch (InterruptedException e) { @@ -314,7 +314,7 @@ rfb.setCuiVersion(cui); CreateConnectionParam cp = new CreateConnectionParam(rfb); cp.setHostName(hostName); - cp.runAcceptThread(); + cp.runTreeVncCommandListener(); cp.createConnectionParam(this); isTreeVNC = true; rfb.setViewer(this);
--- a/src/viewer_swing/java/com/glavsoft/viewer/ViewerImpl.java Fri Jun 13 17:27:41 2014 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -package com.glavsoft.viewer; - -import java.net.Socket; - -import jp.ac.u_ryukyu.treevnc.MyRfbProto; - -public interface ViewerImpl extends Runnable { - - public boolean getCuiVersion(); - - public MyRfbProto getRfb(); - - public void closeApp(); - - public void setConnectionParam(String parentsAddress, int portNumber); - - public void setSocket(Socket soc); - - public void run(); - - public void setOpenPort(int parseInt); - - public void setTeminationType(boolean b); - - public void setCuiVersion(boolean flag); - - public void startTreeViewer(String hostName, boolean b); - - public void startTreeViewer(); - - public void createRootSelectionPanel(); -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/viewer_swing/java/com/glavsoft/viewer/ViewerInterface.java Fri Jun 13 18:04:42 2014 +0900 @@ -0,0 +1,32 @@ +package com.glavsoft.viewer; + +import java.net.Socket; + +import jp.ac.u_ryukyu.treevnc.MyRfbProto; + +public interface ViewerInterface extends Runnable { + + public boolean getCuiVersion(); + + public MyRfbProto getRfb(); + + public void closeApp(); + + public void setConnectionParam(String parentsAddress, int portNumber); + + public void setSocket(Socket soc); + + public void run(); + + public void setOpenPort(int parseInt); + + public void setTeminationType(boolean b); + + public void setCuiVersion(boolean flag); + + public void startTreeViewer(String hostName, boolean b); + + public void startTreeViewer(); + + public void createRootSelectionPanel(); +}
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/ClipboardControllerImpl.java Fri Jun 13 17:27:41 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/ClipboardControllerImpl.java Fri Jun 13 18:04:42 2014 +0900 @@ -127,7 +127,7 @@ isRunning = false; } if (enable && ! isEnabled) { - new Thread(this).start(); + new Thread(this, "clipboard-listener").start(); } isEnabled = enable; }
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Fri Jun 13 17:27:41 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Fri Jun 13 18:04:42 2014 +0900 @@ -35,7 +35,7 @@ import com.glavsoft.viewer.ConnectionPresenter; import com.glavsoft.viewer.UiSettings; import com.glavsoft.viewer.Viewer; -import com.glavsoft.viewer.ViewerImpl; +import com.glavsoft.viewer.ViewerInterface; import com.glavsoft.viewer.swing.gui.OptionsDialog; import javax.swing.*; @@ -70,7 +70,7 @@ private Surface surface; private boolean isSeparateFrame; private final boolean isApplet; - private ViewerImpl viewer; + private ViewerInterface viewer; private String connectionString; private ConnectionPresenter presenter; private Rectangle oldContainerBounds; @@ -87,7 +87,7 @@ private List<JComponent> kbdButtons; public SwingViewerWindow(Protocol workingProtocol, ProtocolSettings rfbSettings, UiSettings uiSettings, Surface surface, - boolean isSeparateFrame, boolean isApplet, ViewerImpl viewer, String connectionString, + boolean isSeparateFrame, boolean isApplet, ViewerInterface viewer, String connectionString, ConnectionPresenter presenter) { this.workingProtocol = workingProtocol; this.rfbSettings = rfbSettings;
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindowFactory.java Fri Jun 13 17:27:41 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindowFactory.java Fri Jun 13 18:04:42 2014 +0900 @@ -4,7 +4,7 @@ import com.glavsoft.rfb.protocol.ProtocolSettings; import com.glavsoft.viewer.ConnectionPresenter; import com.glavsoft.viewer.UiSettings; -import com.glavsoft.viewer.ViewerImpl; +import com.glavsoft.viewer.ViewerInterface; /** * @author dime at tightvnc.com @@ -13,9 +13,9 @@ private final boolean isSeparateFrame; private final boolean isApplet; - private final ViewerImpl viewer; + private final ViewerInterface viewer; - public SwingViewerWindowFactory(boolean isSeparateFrame, boolean isApplet, ViewerImpl viewer) { + public SwingViewerWindowFactory(boolean isSeparateFrame, boolean isApplet, ViewerInterface viewer) { this.isSeparateFrame = isSeparateFrame; this.isApplet = isApplet; this.viewer = viewer;