# HG changeset patch # User Yu Taninari # Date 1334744057 -32400 # Node ID 32b266967c2c778906c04e3ecc8bd8ce07ff8049 # Parent 74195a7722bede8ac3249da7d5f10cb5d00eb269 delete notfound window diff -r 74195a7722be -r 32b266967c2c src/test/BlockingUpdateRectangle.java --- a/src/test/BlockingUpdateRectangle.java Thu Apr 05 19:23:35 2012 +0900 +++ b/src/test/BlockingUpdateRectangle.java Wed Apr 18 19:14:17 2012 +0900 @@ -1,14 +1,123 @@ package test; -import static org.junit.Assert.*; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.LinkedList; +import java.util.zip.Deflater; import org.junit.Test; +import treeVnc.RfbProto; public class BlockingUpdateRectangle { - + + int INFLATE_BUFSIZE = 1024*100; + + @Test public void test() { + ByteBuffer input = ByteBuffer.allocate(4096); + createUpdateRectangle(input); + RfbProto rfb = new RfbProto(); + LinkedList output = rfb.BlockingUpdateRectangle(input); + + fail("Not yet implemented"); } + private void createUpdateRectangle(ByteBuffer input) { + int x = 512; + int y = 512; + int count = 1; + int bytePixel = 3; + int mode = 0; + byte[] palette = new byte[count*bytePixel]; + input.put((byte)mode); + for(byte b: palette) + input.put(b); + int[] pixel = new int[x*y*bytePixel]; + for(int i = 0 ; i < x*y ; i+=bytePixel) { + } + + int[] dst = new int[x*y*bytePixel]; + for(int i = 0 ; i < x*y ; i++) { + dst[i] = ((pixel[i * 3 + 2] & 0xFF) << 16 + | (pixel[i * 3 + 1] & 0xFF) << 8 | (pixel[i * 3] & 0xFF)); + } + } + + private LinkedList splitBuffer(LinkedList input) { + LinkedList output = new LinkedList(); + int high = rectH / 4; + //System.out.println(INFLATE_BUFSIZE * (input.size() - 1)+ input.getLast().limit()); + int dataLen = 64*64; + int temp = 0; + int tempDataLen = 0; + ByteBuffer buf1 = ByteBuffer.allocate(INFLATE_BUFSIZE); + ByteBuffer buf2 = ByteBuffer.allocate(INFLATE_BUFSIZE); + buf2 = input.poll(); + + for (int ty = rectY; ty < rectY + rectH; ty += 64) { + + int th = Math.min(rectY + rectH - ty, 64); + + for (int tx = rectX; tx < rectX + rectW; tx += 64) { + + int tw = Math.min(rectX + rectW - tx, 64); + + if(buf2.limit()-buf2.position() >= dataLen) { + buf2.get(buf1.array(),0,dataLen); + temp += dataLen; + buf2.position(temp); + } else { + buf2.get(buf1.array(),0,buf2.remaining()); + temp = th*tw - buf2.remaining(); + buf2 = input.poll(); + buf2.get(buf1.array(), 0, temp); + buf2.position(temp); + } + } + } + return output; + } + + private void splitData(LinkedList input, ByteBuffer header) + throws IOException { + +// System.out.println(test++); + LinkedList bufs = new LinkedList(); + LinkedList buf = splitBuffer(input); + for (int i = 1; i < 5; i++) { + LinkedList tempBuf = new LinkedList(); + while (buf.peek() != null) { + tempBuf.addLast(buf.poll()); + } + Deflater nDeflater = deflater; + int len2 = zip(nDeflater, tempBuf, 0, bufs); + ByteBuffer blen = ByteBuffer.allocate(4); + blen.putInt(len2); + blen.flip(); + bufs.addFirst(blen); + // ByteBuffer tempheader = createHeader(header,i); + // bufs.addFirst(tempheader); + bufs.addFirst(header); + multicastqueue.put(bufs); + buf.remove(); + } + } + + private ByteBuffer createHeader(ByteBuffer header, int count) { + ByteBuffer tempheader = header; + int h = tempheader.getShort(10); + int y = tempheader.getShort(6); + int high = h / 4; + if (count != 4) + y = y + high * count; + else + y = y + high * count + (h % 4); + tempheader.put(10, (byte) high); + tempheader.put(6, (byte) y); + return tempheader; + } + + } diff -r 74195a7722be -r 32b266967c2c src/treeVnc/CreateThread.java --- a/src/treeVnc/CreateThread.java Thu Apr 05 19:23:35 2012 +0900 +++ b/src/treeVnc/CreateThread.java Wed Apr 18 19:14:17 2012 +0900 @@ -30,7 +30,6 @@ public void run() { // AcceptClient acceptClient = new AcceptClient(); // acceptClient new - System.out.println("Threadつくります"); acceptClient.transferParentAddrerss(is,os); } }; @@ -69,7 +68,6 @@ BufferedReader is = new BufferedReader(new InputStreamReader( clientSocket.getInputStream())); PrintStream os = new PrintStream(clientSocket.getOutputStream()); - System.out.println("accしたよ"); newEchoClient(is,os); // acceptClient.transferParentAddrerss(is, os); } catch (IOException e) { diff -r 74195a7722be -r 32b266967c2c src/treeVnc/GetBroadCastProxy.java --- a/src/treeVnc/GetBroadCastProxy.java Thu Apr 05 19:23:35 2012 +0900 +++ b/src/treeVnc/GetBroadCastProxy.java Wed Apr 18 19:14:17 2012 +0900 @@ -78,7 +78,7 @@ String recover = new String(a); recover = recover.replace("¥n", ""); recover = recover.trim(); - System.out.println(recover); +// System.out.println(recover); return recover; } diff -r 74195a7722be -r 32b266967c2c src/treeVnc/MyVncClient.java --- a/src/treeVnc/MyVncClient.java Thu Apr 05 19:23:35 2012 +0900 +++ b/src/treeVnc/MyVncClient.java Wed Apr 18 19:14:17 2012 +0900 @@ -58,6 +58,10 @@ getHost = new TextBoxClient(); getHost.ipRegister(); pHost = getHost.getAddressOption(); + if(pHost=="notFound"){ + + } + port = Integer.parseInt(getHost.getPortOption()); } } else { @@ -89,7 +93,14 @@ runBcast.start(); getBcast.setStopFlag(true); pHost = getBcast.text.getAddress(); - port = Integer.parseInt(getBcast.text.getPort()); + if("notFound".equals(pHost)) { + getHost = new TextBoxClient(); + getHost.ipRegister(); + pHost = getHost.getAddressOption(); + port = Integer.parseInt(getHost.getPortOption()); + } else { + port = Integer.parseInt(getBcast.text.getPort()); + } } // getBcast.text.checkBox(getNamePort()); diff -r 74195a7722be -r 32b266967c2c src/treeVnc/TextBoxClient.java --- a/src/treeVnc/TextBoxClient.java Thu Apr 05 19:23:35 2012 +0900 +++ b/src/treeVnc/TextBoxClient.java Wed Apr 18 19:14:17 2012 +0900 @@ -119,9 +119,12 @@ int i = 0; while (!(flag)) { if (i >= 50) { + /* reportWindow(); visible(); break; + */ + return "notFound"; } try { Thread.sleep(500);