16
|
1 package com.glavsoft.rfb.protocol;
|
|
2
|
|
3 import jp.ac.u_ryukyu.treevnc.server.*;
|
|
4
|
|
5 import com.glavsoft.exceptions.CommonException;
|
|
6 import com.glavsoft.exceptions.TransportException;
|
|
7 import com.glavsoft.rfb.ClipboardController;
|
|
8 import com.glavsoft.rfb.IRepaintController;
|
23
|
9 import com.glavsoft.rfb.client.FramebufferUpdateRequestMessage;
|
|
10 import com.glavsoft.rfb.client.SetPixelFormatMessage;
|
16
|
11 import com.glavsoft.rfb.encoding.EncodingType;
|
23
|
12 import com.glavsoft.rfb.encoding.decoder.Decoder;
|
16
|
13 import com.glavsoft.rfb.encoding.decoder.DecodersContainer;
|
|
14 import com.glavsoft.rfb.encoding.decoder.FramebufferUpdateRectangle;
|
23
|
15 import com.glavsoft.rfb.encoding.decoder.RichCursorDecoder;
|
16
|
16 import com.glavsoft.transport.Reader;
|
|
17
|
|
18 public class TreeTask extends ReceiverTask {
|
|
19 final static String versionMsg_3_855 = "RFB 003.855\n";
|
19
|
20 private MyRfbProtoProxy rfb;
|
|
21
|
16
|
22 public TreeTask(Reader reader, IRepaintController repaintController,
|
|
23 ClipboardController clipboardController,
|
23
|
24 DecodersContainer decoders, ProtocolContext context, MyRfbProtoProxy _rfb) {
|
19
|
25 super(reader, repaintController, clipboardController, decoders,
|
|
26 context, true);
|
23
|
27 rfb = _rfb;
|
16
|
28 }
|
19
|
29
|
24
|
30 /*
|
|
31 * (non-Javadoc)
|
|
32 * proxy
|
|
33 * no Repaint
|
|
34 * decoder!=0 ZRLE -> ZRLEE
|
|
35 * readSendData();
|
|
36 * client
|
|
37 * Repaint
|
|
38 * no context.send();
|
|
39 * if necessary ZRLEE -> ZRLE
|
|
40 * readSendData();
|
|
41 */
|
16
|
42 @Override
|
19
|
43 public void framebufferUpdateMessage() throws CommonException {
|
16
|
44 reader.readByte(); // padding
|
19
|
45 int numberOfRectangles = reader.readUInt16(); // number of rectangles
|
23
|
46
|
16
|
47 while (numberOfRectangles-- > 0) {
|
|
48 FramebufferUpdateRectangle rect = new FramebufferUpdateRectangle();
|
|
49 rect.fill(reader);
|
23
|
50
|
|
51 Decoder decoder = decoders.getDecoderByType(rect.getEncodingType());
|
|
52 logger.finest(rect.toString() + (0 == numberOfRectangles ? "\n---" : ""));
|
|
53 if (decoder != null) {
|
|
54 int zrleLength = getZrleLength(rect);
|
|
55 reader.reset();
|
|
56 rfb.readSendData(zrleLength, reader);
|
|
57 } else if (rect.getEncodingType() == EncodingType.RICH_CURSOR) {
|
|
58 } else if (rect.getEncodingType() == EncodingType.CURSOR_POS) {
|
|
59 } else if (rect.getEncodingType() == EncodingType.DESKTOP_SIZE) {
|
|
60 fullscreenFbUpdateIncrementalRequest =
|
|
61 new FramebufferUpdateRequestMessage(0, 0, rect.width, rect.height, true);
|
|
62 context.sendMessage(new FramebufferUpdateRequestMessage(0, 0, rect.width, rect.height, false));
|
|
63 } else
|
|
64 throw new CommonException("Unprocessed encoding: " + rect.toString());
|
|
65 }
|
|
66 synchronized (this) {
|
|
67 if (needSendPixelFormat) {
|
|
68 needSendPixelFormat = false;
|
|
69 context.setPixelFormat(pixelFormat);
|
|
70 context.sendMessage(new SetPixelFormatMessage(pixelFormat));
|
|
71 logger.fine("sent: "+pixelFormat);
|
|
72 context.sendRefreshMessage();
|
|
73 logger.fine("sent: nonincremental fb update");
|
|
74 } else {
|
|
75 context.sendMessage(fullscreenFbUpdateIncrementalRequest);
|
|
76 }
|
16
|
77 }
|
|
78 }
|
|
79
|
19
|
80 private int getZrleLength(FramebufferUpdateRectangle rect)
|
|
81 throws TransportException {
|
|
82 int zrleLength = 0;
|
|
83 if (rect.getEncodingType() == EncodingType.ZRLE
|
|
84 || rect.getEncodingType() == EncodingType.ZRLEE
|
|
85 || rect.getEncodingType() == EncodingType.ZLIB) {
|
|
86 zrleLength = reader.readInt32();
|
|
87 }
|
|
88 return zrleLength + 20;
|
|
89 }
|
16
|
90
|
|
91 }
|