Mercurial > hg > Members > riono > TreeVNC_ja_comment
changeset 306:5e55cc34f789
change public to private
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/protocol/Protocol.java Wed Jan 21 11:53:35 2015 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/Protocol.java Wed Jan 21 19:05:21 2015 +0900 @@ -66,9 +66,10 @@ private String protocolVersion; private byte[] initData; private boolean isRetina = false; + private TreeRFBProto rfb; public Protocol(Reader reader, Writer writer, - IPasswordRetriever passwordRetriever, ProtocolSettings settings) { + IPasswordRetriever passwordRetriever, ProtocolSettings settings, TreeRFBProto myRfb) { this.reader = reader; this.writer = writer; this.passwordRetriever = passwordRetriever; @@ -77,6 +78,7 @@ decoders.instantiateDecodersWhenNeeded(settings.encodings); state = new HandshakeState(this); logger = Logger.getLogger(getClass().getName()); + this.rfb = myRfb; } @@ -327,6 +329,11 @@ } @Override + public TreeRFBProto getRfb() { + return rfb; + } + + @Override public void setTight(boolean isTight) { this.isTight = isTight; }
--- a/src/main/java/com/glavsoft/rfb/protocol/ProtocolContext.java Wed Jan 21 11:53:35 2015 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ProtocolContext.java Wed Jan 21 19:05:21 2015 +0900 @@ -30,6 +30,7 @@ import com.glavsoft.rfb.protocol.state.ProtocolState; import com.glavsoft.transport.Reader; import com.glavsoft.transport.Writer; +import jp.ac.u_ryukyu.treevnc.TreeRFBProto; public interface ProtocolContext { @@ -77,6 +78,8 @@ int getNumberOfRectangle(); + TreeRFBProto getRfb(); + /** * TreeVNC expension command (server to client) * 0 : command byte
--- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Wed Jan 21 11:53:35 2015 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Wed Jan 21 19:05:21 2015 +0900 @@ -91,6 +91,7 @@ renderer = repaintController.createRenderer(reader, context.getFbWidth(), context.getFbHeight(),context.getPixelFormat()); fullscreenFbUpdateIncrementalRequest = new FramebufferUpdateRequestMessage(0, 0, context.getFbWidth(), context.getFbHeight(), true); if(rfb.isTreeManager()) { + // これを定期的にフルサイズのframebufferUpdateを送信するThreadにしよう! fullscreenFbUpdateIncrementalRequest.sendFullScreenRequest(); connectionFinished(); } @@ -232,10 +233,11 @@ while (numberOfRectangles-- > 0) { FramebufferUpdateRectangle rect = new FramebufferUpdateRectangle(); rect.fill(reader); + int singleWidth = rfb.getSingleWidth(); if(rfb.filterSingleDisplay && firstTime) { - if (rfb.singleWidth == 0) { - rfb.singleWidth = rect.width; + if (singleWidth == 0) { + rfb.setSingleDisplaySize(rect.width, rect.height); } this.firstTime = false; } @@ -250,7 +252,7 @@ decoder.decode(reader, renderer, rect); // TreeVNC processing here if(!(rfb.getCuiVersion())) { if (rfb.filterSingleDisplay) { - if (rect.x < rfb.singleWidth) { + if (rect.x < singleWidth) { repaintController.repaintBitmap(rect); } } else { @@ -298,8 +300,7 @@ String address = rfb.getMyAddress(); sendCheckDelayReply(rect.time, port, address); } else if (rect.getEncodingType() == EncodingType.SEND_SINGLE_DISPLAY_SIZE) { - rfb.singleWidth = rect.width; - rfb.singleHeight = rect.height; + rfb.setSingleDisplaySize(rect.width, rect.height); // 下に送る } else if (rect.getEncodingType() == EncodingType.SOUND) { // SOUNDを受信した時の処理を
--- a/src/main/java/com/glavsoft/rfb/protocol/state/InitState.java Wed Jan 21 11:53:35 2015 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/state/InitState.java Wed Jan 21 19:05:21 2015 +0900 @@ -32,6 +32,7 @@ import com.glavsoft.rfb.encoding.ServerInitMessage; import com.glavsoft.rfb.protocol.ProtocolContext; import com.glavsoft.rfb.protocol.ProtocolSettings; +import jp.ac.u_ryukyu.treevnc.TreeRFBProto; /** * ClientInit @@ -56,37 +57,41 @@ */ public class InitState extends ProtocolState { - public InitState(ProtocolContext context) { - super(context); - } + private int singleWidth; + private int singleHeight; + private byte[] originalInitData; - @Override - public boolean next() throws UnsupportedProtocolVersionException, TransportException, - UnsupportedSecurityTypeException, AuthenticationFailedException, FatalException { - clientAndServerInit(); - return false; - } + public InitState(ProtocolContext context) { + super(context); + } + + @Override + public boolean next() throws UnsupportedProtocolVersionException, TransportException, + UnsupportedSecurityTypeException, AuthenticationFailedException, FatalException { + clientAndServerInit(); + return false; + } - protected void clientAndServerInit() throws TransportException { - ServerInitMessage serverInitMessage = getServerInitMessage(); - ProtocolSettings settings = context.getSettings(); - settings.enableAllEncodingCaps(); - completeContextData(serverInitMessage); - } + protected void clientAndServerInit() throws TransportException { + ServerInitMessage serverInitMessage = getServerInitMessage(); + ProtocolSettings settings = context.getSettings(); + settings.enableAllEncodingCaps(); + completeContextData(serverInitMessage); + } - public void completeContextData(ServerInitMessage serverInitMessage) { - context.setPixelFormat(serverInitMessage.getPixelFormat()); - context.setFbWidth(serverInitMessage.getFrameBufferWidth()); - context.setFbHeight(serverInitMessage.getFrameBufferHeight()); - context.setRemoteDesktopName(serverInitMessage.getName()); - context.setInitData(serverInitMessage.getInitData()); - } + public void completeContextData(ServerInitMessage serverInitMessage) { + context.setPixelFormat(serverInitMessage.getPixelFormat()); + context.setFbWidth(serverInitMessage.getFrameBufferWidth()); + context.setFbHeight(serverInitMessage.getFrameBufferHeight()); + context.setRemoteDesktopName(serverInitMessage.getName()); + context.setInitData(serverInitMessage.getInitData()); + } - protected ServerInitMessage getServerInitMessage() throws TransportException { - writer.write(context.getSettings().getSharedFlag()); - ServerInitMessage serverInitMessage = new ServerInitMessage(reader); - return serverInitMessage; - } + protected ServerInitMessage getServerInitMessage() throws TransportException { + writer.write(context.getSettings().getSharedFlag()); + ServerInitMessage serverInitMessage = new ServerInitMessage(reader); + return serverInitMessage; + } }
--- a/src/main/java/com/glavsoft/rfb/protocol/state/ProtocolState.java Wed Jan 21 11:53:35 2015 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/state/ProtocolState.java Wed Jan 21 19:05:21 2015 +0900 @@ -28,16 +28,19 @@ import com.glavsoft.rfb.protocol.ProtocolContext; import com.glavsoft.transport.Reader; import com.glavsoft.transport.Writer; +import jp.ac.u_ryukyu.treevnc.TreeRFBProto; abstract public class ProtocolState { protected ProtocolContext context; protected Reader reader; protected Writer writer; + protected TreeRFBProto rfb; public ProtocolState(ProtocolContext context) { this.context = context; this.reader = context.getReader(); this.writer = context.getWriter(); + this.rfb = context.getRfb(); } /**
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Wed Jan 21 11:53:35 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Wed Jan 21 19:05:21 2015 +0900 @@ -72,11 +72,13 @@ public int fixingSizeWidth; public int fixingSizeHeight; - public int singleWidth = 0; - public int singleHeight = 0; + private int singleWidth = 0; + private int singleHeight = 0; private DatagramSocket socket = null; + private byte[] originalInitData = null; + public TreeRFBProto(boolean isTreeManager) { rThread = new RequestScreenThread(this); nets.setMyRfb(this); @@ -483,11 +485,8 @@ byte[] initData = null; if (filterSingleDisplay) { - width = singleWidth; - height = singleHeight; - TreeVncCommandChannelListener treeVncCommandChannelListener = new TreeVncCommandChannelListener(this, acceptPort); - initData = treeVncCommandChannelListener.createOriginalInitData(width, height, context.getRemoteDesktopName()); - desktopSize.add(new ChengeDesktopSize(singleWidth, singleHeight, EncodingType.INIT_DATA, initData, id).getMessage()); + this.originalInitData = createOriginalInitData(singleWidth, singleHeight, context.getRemoteDesktopName()); + desktopSize.add(new ChengeDesktopSize(singleWidth, singleHeight, EncodingType.INIT_DATA, originalInitData, id).getMessage()); } else { desktopSize.add(new ChengeDesktopSize(width, height, EncodingType.INIT_DATA, context.getInitData(), id).getMessage()); } @@ -495,6 +494,21 @@ multicastqueue.put(desktopSize); } + public byte[] createOriginalInitData(int singleWidth, int singleHeight, String remoteDesktopName) { + TreeVncCommandChannelListener treeVncCommandChannelListener = new TreeVncCommandChannelListener(this, acceptPort); + byte[] originalInitData = treeVncCommandChannelListener.createOriginalInitData(singleWidth, singleHeight, remoteDesktopName); + return originalInitData; + } + + public void setOriginalInitData(int singleWidth, int singleHeight, String remoteDesktopName) { + TreeVncCommandChannelListener treeVncCommandChannelListener = new TreeVncCommandChannelListener(this, acceptPort); + originalInitData = treeVncCommandChannelListener.createOriginalInitData(singleWidth, singleHeight, remoteDesktopName); + } + + public byte[] getOriginalInitData() { + return originalInitData; + } + public void addSerialNumber(LinkedList<ByteBuffer> bufs) { ByteBuffer serialNum = multicastqueue.allocate(4+8); // addSerialNum flag + SerialNum @@ -879,4 +893,17 @@ } return socket; } + + public void setSingleDisplaySize(int singleWidth, int singleHeight) { + this.singleWidth = singleWidth; + this.singleHeight = singleHeight; + } + + public int getSingleWidth() { + return singleWidth; + } + + public int getSingleHeight() { + return singleHeight; + } } \ No newline at end of file
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRootFinderListener.java Wed Jan 21 11:53:35 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRootFinderListener.java Wed Jan 21 19:05:21 2015 +0900 @@ -57,7 +57,9 @@ port = port * 256 + reply[11]; TreeVncProtocol t = new TreeVncProtocol(hostname, port); - t.setSingleSize(vps.getRfb().singleWidth, vps.getRfb().singleHeight); + int singleWidth = vps.getRfb().getSingleWidth(); + int singleHeight = vps.getRfb().getSingleHeight(); + t.setSingleSize(singleWidth, singleHeight); try { t.findRootReply(vps.getRfb().getAcceptPort()); } catch (IOException e) {
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommandChannelListener.java Wed Jan 21 11:53:35 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommandChannelListener.java Wed Jan 21 19:05:21 2015 +0900 @@ -222,8 +222,8 @@ void sendInitData(Writer os) throws TransportException { ProtocolContext context = rfb.context; if (context != null && rfb.filterSingleDisplay) { - int width = rfb.singleWidth; - int height = rfb.singleHeight; + int width = rfb.getSingleWidth(); + int height = rfb.getSingleHeight(); byte[] initData = createOriginalInitData(width, height, context.getRemoteDesktopName()); os.write(initData); } else if (context != null) {
--- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Wed Jan 21 11:53:35 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Wed Jan 21 19:05:21 2015 +0900 @@ -401,8 +401,9 @@ ArrayList<Rectangle> rectangles = getScreenRectangles(); int leftScreenNumber = 0; - getRfb().singleWidth = (int) rectangles.get(leftScreenNumber).getWidth(); - getRfb().singleHeight = (int) rectangles.get(leftScreenNumber).getHeight(); + int singleWidth = (int) rectangles.get(leftScreenNumber).getWidth(); + int singleHeight = (int) rectangles.get(leftScreenNumber).getHeight(); + getRfb().setSingleDisplaySize(singleWidth, singleHeight); run(); }
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingRfbConnectionWorker.java Wed Jan 21 11:53:35 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingRfbConnectionWorker.java Wed Jan 21 19:05:21 2015 +0900 @@ -75,7 +75,7 @@ workingProtocol = new Protocol(reader, writer, new PasswordChooser(connectionString, parentWindow, this), - rfbSettings); + rfbSettings, myRfb); String message = "Handshaking with remote host"; logger.info(message); publish(message);
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Wed Jan 21 11:53:35 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Wed Jan 21 19:05:21 2015 +0900 @@ -856,8 +856,7 @@ int rightScreenNumber = 1; int singleWidth = (int) rectangles.get(leftScreenNumber).getWidth(); int singleHeight = (int) rectangles.get(leftScreenNumber).getHeight(); - viewer.getRfb().singleWidth = singleWidth; - viewer.getRfb().singleHeight = singleHeight; + viewer.getRfb().setSingleDisplaySize(singleWidth, singleHeight); /* // show share sound dialog. boolean setShareSound = presenter.showShareSoundDialog(); @@ -895,14 +894,16 @@ @Override public void actionPerformed(ActionEvent e) { // adjustHdSizeButton.setSelected(false); + int singleWidth = viewer.getRfb().getSingleWidth(); + int singleHeight = viewer.getRfb().getSingleHeight(); if (viewer.getRfb().isTreeManager()) { - System.out.println(viewer.getRfb().singleWidth); - uiSettings.adjustHdSize(viewer.getRfb().singleWidth); + System.out.println(singleWidth); + uiSettings.adjustHdSize(singleWidth); return; } context.sendMessage(new RequestSingleDisplayWidth()); - System.out.println(viewer.getRfb().singleWidth); - uiSettings.adjustHdSize(viewer.getRfb().singleWidth); + System.out.println(singleWidth); + uiSettings.adjustHdSize(singleWidth); } }); kbdButtons.add(adjustHdSizeButton);