Mercurial > hg > Applications > TightVNC_orginal
changeset 3:e7ce2b2ffed8
add and modify files
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/ac/ryukyu/treevnc/MostRecentMultiCast.java Tue Jul 24 15:46:36 2012 +0900 @@ -0,0 +1,27 @@ +package ac.ryukyu.treevnc; + +import java.util.LinkedList; + + +public class MostRecentMultiCast<T> extends MulticastQueue<T> { + + LinkedList<Node<T>> alive; + int count = 0; + MostRecentMultiCast(int limit) { + count = limit; + this.alive = new LinkedList<Node<T>>(); + } + + @Override + public synchronized void put(T item) + { + Node<T> next = new Node<T>(item); + tail.set(next); + tail = next; + alive.addLast(next); + if (alive.size()>count) { + Node<T> old = alive.getFirst(); + old.clear(); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/ac/ryukyu/treevnc/MulticastQueue.java Tue Jul 24 15:46:36 2012 +0900 @@ -0,0 +1,87 @@ +package ac.ryukyu.treevnc; + +import java.util.concurrent.CountDownLatch; + +public class MulticastQueue<T> +{ + + Node<T> tail; + + public MulticastQueue() + { + tail = new Node<T>(null); + } + + public synchronized void put(T item) + { + Node<T> next = new Node<T>(item); + tail.set(next); + tail = next; + } + + public Client<T> newClient() + { + return new Client<T>(tail); + } + + static class Client<T> + { + Node<T> node; + + Client(Node<T> tail) + { + node = tail; + } + + synchronized public T poll() + { + Node<T> next = null; + T item = null; + do { + try { + next = node.next(); + }catch(InterruptedException _e){ + continue; + } +// item = node.getItem(); + item = next.getItem(); + node = next; + } while ( item == null); + return item; + } + } + + static class Node<T> + { + private T item; + private Node<T> next; + private CountDownLatch latch; + + public Node(T item) + { + this.item = item; + this.next = null; + latch = new CountDownLatch(1); + } + + synchronized public T getItem() { + return item; + } + + public void set(Node<T> next) + { + this.next = next; + latch.countDown(); + } + + public Node<T> next() throws InterruptedException + { + latch.await(); + return next; + } + + synchronized public void clear() { + item = null; + } + } +}
--- a/src/main/java/ac/ryukyu/treevnc/client/EchoClient.java Mon Jul 09 18:47:33 2012 +0900 +++ b/src/main/java/ac/ryukyu/treevnc/client/EchoClient.java Tue Jul 24 15:46:36 2012 +0900 @@ -47,6 +47,11 @@ this.name = name; } + public EchoClient(String name, int echoPort) { + this.echoPort = echoPort; + this.name = name; + } + public EchoClient(String name, MyVncClient client, int echoPort) { this.client = (InterfaceForViewer) client; this.name = name;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/ac/ryukyu/treevnc/client/MyRfbProtoClient.java Tue Jul 24 15:46:36 2012 +0900 @@ -0,0 +1,98 @@ +package ac.ryukyu.treevnc.client; + +import java.io.BufferedInputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.InetAddress; +import java.net.Socket; +import java.nio.ByteBuffer; + + + +import com.glavsoft.exceptions.TransportException; +import com.glavsoft.transport.Reader; +import com.glavsoft.viewer.ContainerManager; +import com.glavsoft.viewer.swing.ParametersHandler.ConnectionParams; + +public class MyRfbProtoClient { + private Reader reader; + private EchoClient echoValue = new EchoClient(); + private String host,treenum,parent,pHost,leaderflag; + private int echoPort,port; + Socket clientSocket,sock; + DataInputStream is; + OutputStream os; + private ContainerManager containerManager; + + + + public MyRfbProtoClient(Reader reader,String host,String port) { + this.reader = reader; + } + + public void setParam(ConnectionParams connectionParams) { + pHost = connectionParams.hostName; + echoPort = connectionParams.portNumber; + } + + public boolean readProxyFlag() throws TransportException { + int flag = reader.readUInt8(); + if(flag == 1) + return true; + else + return false; + } + + public byte[] readEchoPort() throws Exception { + byte[] b = new byte[4]; + reader.readBytes(b, 0, b.length); + //readFully(b); + return b; + } + + public void getParentName() { + if (echoValue == null) { + + if (clientSocket == null) { + + // echo = new EchoClient(pHost, this); + echoValue = new EchoClient(pHost, echoPort); + echoValue.openport(); + + echoValue = echoValue.requestHostName("1"); + } else { + echoValue = new EchoClient(); + echoValue = echoValue.Interruption(clientSocket); + } + } + // proxyからの返信で接続先を決定する + host = echoValue.responseLine; + parent = echoValue.parent; + if (echoValue.treenum != null) { + treenum = echoValue.treenum; + } else { + treenum = echoValue.treenum; + } + + if (echoValue.leaderflag != null) { + leaderflag = echoValue.leaderflag; + } else { + leaderflag = echoValue.leaderflag; + } + } + + int castByteInt(byte[] b) { + ByteBuffer bb = ByteBuffer.wrap(b); + int value = bb.getInt(); + return value; + } + + Socket changeParent(String host, int port) throws IOException { + sock = new Socket(host, port); + return sock; + } + +}
--- a/src/main/java/ac/ryukyu/treevnc/client/MyVncClient.java Mon Jul 09 18:47:33 2012 +0900 +++ b/src/main/java/ac/ryukyu/treevnc/client/MyVncClient.java Tue Jul 24 15:46:36 2012 +0900 @@ -1,6 +1,5 @@ package ac.ryukyu.treevnc.client; -import java.awt.Image; import java.awt.Insets; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; @@ -31,7 +30,6 @@ import com.glavsoft.viewer.swing.UiSettings; import com.glavsoft.viewer.swing.ParametersHandler.ConnectionParams; -import ac.ryukyu.treevnc.InterfaceForViewer; public class MyVncClient extends Viewer implements Runnable, IRfbSessionListener, WindowListener, IChangeSettingsListener { @@ -70,7 +68,7 @@ public MyVncClient() { connectionParams = new ParametersHandler.ConnectionParams(); settings = ProtocolSettings.getDefaultSettings(); - uiSettings = new UiSettings(); + uiSettings = super.uiSettings; } public MyVncClient(Parser parser) { @@ -115,27 +113,6 @@ th.start(); } - private void getHostData() { - bCast = new GetHostClient("who"); - bCast.createSocket(); - bCast.sendData(); - getBcast = new GetDataClient(); - runBcast = new Thread(getBcast); - runBcast.start(); - getBcast.setStopFlag(true); - connectionParams.hostName = getBcast.textAddress(); - if("notFound".equals(pHost)) { - getHost = new TextBoxClient(); - getHost.ipRegister(); - connectionParams.hostName = getHost.getAddressOption(); - //connectionParams.portNumber = Integer.parseInt(getHost.getPortOption()); - connectionParams.portNumber = 5900; - } else { - //connectionParams.portNumber = Integer.parseInt(getBcast.textPort()); - connectionParams.portNumber = 5900; - } - } - @Override public void run() { // getHostData(); @@ -147,7 +124,7 @@ tryAgain = true; while (tryAgain) { // workingSocket = connectionManager.connectToTreeHost(connectionParams, settings); - workingSocket = connectionManager.connectToHost(connectionParams, settings); + workingSocket = connectionManager.connectToTreeHost(connectionParams, settings); if (null == workingSocket) { closeApp(); break; @@ -158,12 +135,13 @@ 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(); - + // input into change parents ClipboardControllerImpl clipboardController = new ClipboardControllerImpl(workingProtocol, settings.getRemoteCharsetName()); clipboardController.setEnabled(settings.isAllowClipboardTransfer()); @@ -212,6 +190,8 @@ } + + @Override public void windowClosing(WindowEvent e) { if (e != null && e.getComponent() != null) {
--- a/src/main/java/com/glavsoft/rfb/encoding/EncodingType.java Mon Jul 09 18:47:33 2012 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/EncodingType.java Tue Jul 24 15:46:36 2012 +0900 @@ -60,6 +60,11 @@ ZRLE(16, "ZRLE"), /** + * ZRLEE Encoding is extends ZRLE. ZRLEE have flush(). + */ + ZRLEE(15, "ZRLEE"), + + /** * Rich Cursor pseudo encoding which allows to transfer cursor shape * with transparency */ @@ -116,6 +121,7 @@ ordinaryEncodings.add(TIGHT); ordinaryEncodings.add(HEXTILE); ordinaryEncodings.add(ZRLE); + ordinaryEncodings.add(ZRLEE); ordinaryEncodings.add(ZLIB); ordinaryEncodings.add(RRE); ordinaryEncodings.add(COPY_RECT);
--- a/src/main/java/com/glavsoft/rfb/encoding/decoder/DecodersContainer.java Mon Jul 09 18:47:33 2012 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/DecodersContainer.java Tue Jul 24 15:46:36 2012 +0900 @@ -45,6 +45,7 @@ knownDecoders.put(EncodingType.ZLIB, ZlibDecoder.class); knownDecoders.put(EncodingType.RRE, RREDecoder.class); knownDecoders.put(EncodingType.COPY_RECT, CopyRectDecoder.class); + knownDecoders.put(EncodingType.ZRLEE, ZRLEDecoder.class); // knownDecoders.put(EncodingType.RAW_ENCODING, RawDecoder.class); } private final Map<EncodingType, Decoder> decoders =
--- a/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEDecoder.java Mon Jul 09 18:47:33 2012 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEDecoder.java Tue Jul 24 15:46:36 2012 +0900 @@ -37,7 +37,7 @@ int zippedLength = (int) reader.readUInt32(); if (0 == zippedLength) return; int length = rect.width * rect.height * renderer.getBytesPerPixel(); - byte[] bytes = unzip(reader, zippedLength, length); + byte[] bytes = unzip(reader, zippedLength, length, rect.getEncodingType()); int offset = zippedLength; int maxX = rect.x + rect.width; int maxY = rect.y + rect.height;
--- a/src/main/java/com/glavsoft/rfb/encoding/decoder/ZlibDecoder.java Mon Jul 09 18:47:33 2012 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/ZlibDecoder.java Tue Jul 24 15:46:36 2012 +0900 @@ -26,6 +26,7 @@ import com.glavsoft.drawing.Renderer; import com.glavsoft.exceptions.TransportException; +import com.glavsoft.rfb.encoding.EncodingType; import com.glavsoft.transport.Reader; import java.io.ByteArrayInputStream; @@ -41,20 +42,21 @@ int zippedLength = (int) reader.readUInt32(); if (0 == zippedLength) return; int length = rect.width * rect.height * renderer.getBytesPerPixel(); - byte[] bytes = unzip(reader, zippedLength, length); + byte[] bytes = unzip(reader, zippedLength, length, rect.getEncodingType()); Reader unzippedReader = new Reader( new ByteArrayInputStream(bytes, zippedLength, length)); RawDecoder.getInstance().decode(unzippedReader, renderer, rect); } - protected byte[] unzip(Reader reader, int zippedLength, int length) + protected byte[] unzip(Reader reader, int zippedLength, int length,EncodingType encodingType) throws TransportException { byte [] bytes = ByteBuffer.getInstance().getBuffer(zippedLength + length); reader.readBytes(bytes, 0, zippedLength); - if (null == decoder) { + if (null == decoder || encodingType == EncodingType.ZRLEE) { + //if (null == decoder) { decoder = new Inflater(); - } + } decoder.setInput(bytes, 0, zippedLength); try { decoder.inflate(bytes, zippedLength, length);
--- a/src/main/java/com/glavsoft/rfb/protocol/state/HandshakeState.java Mon Jul 09 18:47:33 2012 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/state/HandshakeState.java Tue Jul 24 15:46:36 2012 +0900 @@ -73,7 +73,7 @@ major = MAX_SUPPORTED_VERSION_MAJOR; minor = MAX_SUPPORTED_VERSION_MINOR; } - + if (minor >= MIN_SUPPORTED_VERSION_MINOR && minor < 7) { changeStateTo(new SecurityType33State(context)); context.getSettings().setProtocolVersion(PROTOCOL_VERSION_3_3);
--- a/src/main/java/com/glavsoft/transport/Reader.java Mon Jul 09 18:47:33 2012 +0900 +++ b/src/main/java/com/glavsoft/transport/Reader.java Tue Jul 24 15:46:36 2012 +0900 @@ -128,4 +128,5 @@ throw new TransportException("Cannot read " + length + " bytes array", e); } } + } \ No newline at end of file
--- a/src/viewer_swing/java/com/glavsoft/viewer/ConnectionManager.java Mon Jul 09 18:47:33 2012 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/ConnectionManager.java Tue Jul 24 15:46:36 2012 +0900 @@ -93,11 +93,11 @@ if("notFound".equals(connectionParams.hostName)) { getBcast.text.ipRegister(); connectionParams.hostName = getBcast.textAddress(); - //connectionParams.portNumber = Integer.parseInt(getHost.getPortOption()); - connectionParams.portNumber = 5900; + connectionParams.portNumber = Integer.parseInt(getBcast.textPort()); + //connectionParams.portNumber = 5900; } else { - //connectionParams.portNumber = Integer.parseInt(getBcast.textPort()); - connectionParams.portNumber = 5900; + connectionParams.portNumber = Integer.parseInt(getBcast.textPort()); + //connectionParams.portNumber = 5900; } Viewer.logger.info("Connecting to host " + connectionParams.hostName + ":" + connectionParams.portNumber); try {
--- a/src/viewer_swing/java/com/glavsoft/viewer/ContainerManager.java Mon Jul 09 18:47:33 2012 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/ContainerManager.java Tue Jul 24 15:46:36 2012 +0900 @@ -24,6 +24,8 @@ package com.glavsoft.viewer; +import ac.ryukyu.treevnc.client.MyVncClient; + import com.glavsoft.viewer.swing.Surface; import com.glavsoft.viewer.swing.UiSettings; import com.glavsoft.viewer.swing.Utils; @@ -50,7 +52,7 @@ public ContainerManager(Viewer viewer) { this.viewer = viewer; } - + public Container createContainer(final Surface surface, boolean isSeparateFrame, boolean isApplet) { outerPanel = System.getProperty("os.name").toLowerCase().startsWith("windows") ? new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)) { @@ -188,7 +190,7 @@ return screenBounds; } - void addZoomButtons(JPanel buttonBar, Insets margin) { + public void addZoomButtons(JPanel buttonBar, Insets margin) { this.buttonBar = buttonBar; buttonBar.add(Box.createHorizontalStrut(10)); @@ -257,7 +259,7 @@ viewer.getWorkingProtocol().getFbWidth(), viewer.getWorkingProtocol().getFbHeight()); } - void registerResizeListener(Container container) { + public void registerResizeListener(Container container) { container.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { @@ -271,7 +273,7 @@ }); } - void updateZoomButtonsState() { + public void updateZoomButtonsState() { zoomOutButton.setEnabled(viewer.getUiSettings().getScalePercent() > UiSettings.MIN_SCALE_PERCENT); zoomInButton.setEnabled(viewer.getUiSettings().getScalePercent() < UiSettings.MAX_SCALE_PERCENT); zoomAsIsButton.setEnabled(viewer.getUiSettings().getScalePercent() != 100);