Mercurial > hg > Applications > TreeVNC
view src/main/java/com/glavsoft/rfb/protocol/TreeTask.java @ 23:6a4312344a5a
remove set rfb TreeTask
author | one |
---|---|
date | Thu, 30 Aug 2012 14:40:32 +0900 |
parents | ea83f4be0cc9 |
children | 1fe39e8ba3e9 |
line wrap: on
line source
package com.glavsoft.rfb.protocol; import jp.ac.u_ryukyu.treevnc.server.*; import com.glavsoft.exceptions.CommonException; import com.glavsoft.exceptions.TransportException; import com.glavsoft.rfb.ClipboardController; import com.glavsoft.rfb.IRepaintController; import com.glavsoft.rfb.client.FramebufferUpdateRequestMessage; import com.glavsoft.rfb.client.SetPixelFormatMessage; import com.glavsoft.rfb.encoding.EncodingType; import com.glavsoft.rfb.encoding.decoder.Decoder; import com.glavsoft.rfb.encoding.decoder.DecodersContainer; import com.glavsoft.rfb.encoding.decoder.FramebufferUpdateRectangle; import com.glavsoft.rfb.encoding.decoder.RichCursorDecoder; import com.glavsoft.transport.Reader; public class TreeTask extends ReceiverTask { final static String versionMsg_3_855 = "RFB 003.855\n"; private MyRfbProtoProxy rfb; public TreeTask(Reader reader, IRepaintController repaintController, ClipboardController clipboardController, DecodersContainer decoders, ProtocolContext context, MyRfbProtoProxy _rfb) { super(reader, repaintController, clipboardController, decoders, context, true); rfb = _rfb; } @Override public void framebufferUpdateMessage() throws CommonException { reader.readByte(); // padding int numberOfRectangles = reader.readUInt16(); // number of rectangles while (numberOfRectangles-- > 0) { FramebufferUpdateRectangle rect = new FramebufferUpdateRectangle(); rect.fill(reader); Decoder decoder = decoders.getDecoderByType(rect.getEncodingType()); logger.finest(rect.toString() + (0 == numberOfRectangles ? "\n---" : "")); if (decoder != null) { /* decoder.decode(reader, renderer, rect); repaintController.repaintBitmap(rect); */ int zrleLength = getZrleLength(rect); reader.reset(); rfb.readSendData(zrleLength, reader); } else if (rect.getEncodingType() == EncodingType.RICH_CURSOR) { RichCursorDecoder.getInstance().decode(reader, renderer, rect); repaintController.repaintCursor(); } else if (rect.getEncodingType() == EncodingType.CURSOR_POS) { renderer.decodeCursorPosition(rect); repaintController.repaintCursor(); } else if (rect.getEncodingType() == EncodingType.DESKTOP_SIZE) { fullscreenFbUpdateIncrementalRequest = new FramebufferUpdateRequestMessage(0, 0, rect.width, rect.height, true); synchronized (renderer) { renderer = repaintController.createRenderer(reader, rect.width, rect.height, context.getPixelFormat()); } context.sendMessage(new FramebufferUpdateRequestMessage(0, 0, rect.width, rect.height, false)); // repaintController.repaintCursor(); } else throw new CommonException("Unprocessed encoding: " + rect.toString()); } synchronized (this) { if (needSendPixelFormat) { needSendPixelFormat = false; context.setPixelFormat(pixelFormat); context.sendMessage(new SetPixelFormatMessage(pixelFormat)); logger.fine("sent: "+pixelFormat); context.sendRefreshMessage(); logger.fine("sent: nonincremental fb update"); } else { context.sendMessage(fullscreenFbUpdateIncrementalRequest); } } } private int getZrleLength(FramebufferUpdateRectangle rect) throws TransportException { int zrleLength = 0; if (rect.getEncodingType() == EncodingType.ZRLE || rect.getEncodingType() == EncodingType.ZRLEE || rect.getEncodingType() == EncodingType.ZLIB) { zrleLength = reader.readInt32(); ; } return zrleLength + 20; } }