7
|
1 import java.io.IOException;
|
|
2 import java.net.Socket;
|
8
|
3 import java.nio.ByteBuffer;
|
|
4
|
7
|
5
|
|
6 class MyRfbProto extends RfbProto {
|
8
|
7
|
|
8 private byte initData[];
|
|
9
|
7
|
10 MyRfbProto(String h, int p, VncViewer v) throws IOException {
|
|
11 super(h, p, v);
|
|
12 }
|
|
13
|
|
14 void mark(int len) throws IOException {
|
|
15 is.mark(len);
|
|
16 }
|
|
17
|
|
18 void reset() throws IOException {
|
|
19 is.reset();
|
|
20 }
|
|
21
|
8
|
22 boolean markSupported() {
|
7
|
23 return is.markSupported();
|
|
24 }
|
8
|
25
|
|
26 void readServerInit() throws IOException {
|
|
27
|
|
28 mark(255);
|
|
29 skipBytes(20);
|
|
30 int nlen = readU32();
|
|
31 initData = new byte[20+4+nlen];
|
|
32 readFully(initData);
|
|
33 reset();
|
|
34
|
7
|
35 framebufferWidth = readU16();
|
|
36 framebufferHeight = readU16();
|
|
37 bitsPerPixel = readU8();
|
|
38 depth = readU8();
|
|
39 bigEndian = (readU8() != 0);
|
|
40 trueColour = (readU8() != 0);
|
|
41 redMax = readU16();
|
|
42 greenMax = readU16();
|
|
43 blueMax = readU16();
|
|
44 redShift = readU8();
|
|
45 greenShift = readU8();
|
|
46 blueShift = readU8();
|
8
|
47 byte[] pad = new byte[3];
|
|
48 readFully(pad);
|
|
49 int nameLength = readU32();
|
|
50 byte[] name = new byte[nameLength];
|
|
51 readFully(name);
|
|
52 desktopName = new String(name);
|
7
|
53
|
8
|
54 // Read interaction capabilities (TightVNC protocol extensions)
|
|
55 if (protocolTightVNC) {
|
|
56 int nServerMessageTypes = readU16();
|
|
57 int nClientMessageTypes = readU16();
|
|
58 int nEncodingTypes = readU16();
|
|
59 readU16();
|
|
60 readCapabilityList(serverMsgCaps, nServerMessageTypes);
|
|
61 readCapabilityList(clientMsgCaps, nClientMessageTypes);
|
|
62 readCapabilityList(encodingCaps, nEncodingTypes);
|
|
63 }
|
|
64
|
|
65 inNormalProtocol = true;
|
7
|
66 }
|
|
67
|
9
|
68 void sendInitData(Socket sock) throws IOException{
|
8
|
69 sock.getOutputStream().write(initData);
|
|
70 }
|
7
|
71
|
|
72
|
|
73 }
|