changeset 34:32b266967c2c

delete notfound window
author Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
date Wed, 18 Apr 2012 19:14:17 +0900
parents 74195a7722be
children cca2a548ed95
files src/test/BlockingUpdateRectangle.java src/treeVnc/CreateThread.java src/treeVnc/GetBroadCastProxy.java src/treeVnc/MyVncClient.java src/treeVnc/TextBoxClient.java
diffstat 5 files changed, 127 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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<ByteBuffer> 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<ByteBuffer> splitBuffer(LinkedList<ByteBuffer> input) {
+		LinkedList<ByteBuffer> output = new LinkedList<ByteBuffer>();
+		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<ByteBuffer> input, ByteBuffer header)
+			throws IOException {
+
+//		System.out.println(test++);
+		LinkedList<ByteBuffer> bufs = new LinkedList<ByteBuffer>();
+		LinkedList<ByteBuffer> buf = splitBuffer(input);
+		for (int i = 1; i < 5; i++) {
+			LinkedList<ByteBuffer> tempBuf = new LinkedList<ByteBuffer>();
+			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;
+	}
+
+
 }
--- 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) {
--- 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;
 	}
 	
--- 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());
--- 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);