changeset 104:b649584c9712

iterator bug
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 04 Aug 2011 16:11:41 +0900
parents d1dc2bb0200d
children e166c3cad2b8
files src/myVncProxy/MyRfbProto.java
diffstat 1 files changed, 16 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/src/myVncProxy/MyRfbProto.java	Thu Aug 04 11:06:10 2011 +0900
+++ b/src/myVncProxy/MyRfbProto.java	Thu Aug 04 16:11:41 2011 +0900
@@ -50,7 +50,7 @@
 	private int rectH;
 	private int encoding;
 	private int zLen;
-	private boolean clicomp;
+	private boolean clicomp = false;
 
 	private ServerSocket servSock;
 	private int acceptPort;
@@ -314,34 +314,7 @@
 		else
 			zLen = 0;
 		is.reset();
-/*
-		int dataLen;
-		switch (encoding) {
-		case RfbProto.EncodingRaw:
-			dataLen = rectW * rectH * 4 + 16;
-			mark(dataLen);
-			break;
-		case RfbProto.EncodingCopyRect:
-			dataLen = 16 + 4;
-			mark(dataLen);
-			break;
-		case RfbProto.EncodingRRE:
-		case RfbProto.EncodingCoRRE:
-		case RfbProto.EncodingHextile:
-			
-		case RfbProto.EncodingZlib:
-		case RfbProto.EncodingTight:
-		case RfbProto.EncodingZRLE:
-			dataLen = zLen + 20;
-			mark(dataLen);
-			break;
-		default:
-			dataLen = 1000000;
-			mark(dataLen);
-		}
-	
-*/	
-	
+
 	}
 
 	int checkAndMark() throws IOException {
@@ -438,12 +411,7 @@
 		BufferedImage bimg = ImageIO.read(new ByteArrayInputStream(pngBytes));
 		return bimg;
 	}
-/*
-	void readPngData() throws IOException {
-		pngBytes = new byte[is.available()];
-		readFully(pngBytes);
-	}
-*/
+
 	void printFramebufferUpdate() {
 
 		System.out.println("messageType=" + messageType);
@@ -746,7 +714,7 @@
 				in.add(ByteBuffer.wrap("test1".getBytes()));
 				in.add(ByteBuffer.wrap("test2".getBytes()));
 				in.add(ByteBuffer.wrap("test3".getBytes()));
-				in.add(ByteBuffer.wrap("test4".getBytes()));
+				in.add(ByteBuffer.wrap("test44".getBytes()));
 			}
 			LinkedList<ByteBuffer> in1 = clone(in);
 
@@ -754,9 +722,10 @@
 			zip(deflater,in,0,out);
 			// LinkedList<ByteBuffer> out3 = clone(out);   zipped result is depend on deflator's state
 			unzip(inflater, out, 0,out2);
-			inflater.reset();
+		    // inflater.reset();
 			equalByteBuffers(in1, out2);
 			LinkedList<ByteBuffer> out4 = new LinkedList<ByteBuffer>();
+			deflater = new Deflater();
 			zip(deflater,out2,0,out4);
 			LinkedList<ByteBuffer> out5 = new LinkedList<ByteBuffer>();
 			unzip(inflater,out4,0, out5);
@@ -793,7 +762,8 @@
 			} else 
 				assertEquals(0,1);
 		}
-		if (o.hasNext()) assertEquals(0,1);
+		if (o.hasNext()) 
+			assertEquals(0,1);
 		// System.out.println();
 		return len;
 	}
@@ -805,12 +775,16 @@
 					int bytes = 0;
 					int buffers = 0;
 					public boolean hasNext() {
-						if (buffers>=in.size()) return false;
-						ByteBuffer b = in.getFirst();
-						return bytes<b.remaining();
+						for(;;) {
+							if (buffers>=in.size()) return false;
+							ByteBuffer b = in.get(buffers);
+							if (! (bytes<b.remaining())) {
+								buffers ++; bytes=0;
+							} else return true;
+						}
 					}
 					public Byte next() {
-						ByteBuffer bf =in.get(buffers);
+						ByteBuffer bf =in.get(buffers); 
 						byte b = bf.get(bytes++); 
 						if (bf.remaining()<=bytes) {
 							buffers++;