annotate src/main/java/com/glavsoft/rfb/encoding/ServerInitMessage.java @ 166:26bc52699cf3

send initData to lower node.
author oc
date Thu, 19 Jun 2014 17:19:59 +0900
parents 433c79184c05
children 2aa4fcbc5ba2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1 // Copyright (C) 2010, 2011, 2012, 2013 GlavSoft LLC.
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 // All rights reserved.
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 //
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 //-------------------------------------------------------------------------
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 // This file is part of the TightVNC software. Please visit our Web site:
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 //
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 // http://www.tightvnc.com/
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 //
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 // This program is free software; you can redistribute it and/or modify
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 // it under the terms of the GNU General Public License as published by
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 // the Free Software Foundation; either version 2 of the License, or
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 // (at your option) any later version.
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 //
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 // This program is distributed in the hope that it will be useful,
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 // GNU General Public License for more details.
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 //
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 // You should have received a copy of the GNU General Public License along
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 // with this program; if not, write to the Free Software Foundation, Inc.,
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 //-------------------------------------------------------------------------
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 //
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 package com.glavsoft.rfb.encoding;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 import com.glavsoft.exceptions.TransportException;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 import com.glavsoft.transport.Reader;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 /**
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 * Struct filled from the ServerInit message
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 * 2 - U16 - framebuffer-width
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 * 2 - U16 - framebuffer-height
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 * 16 - PixelFormat - server-pixel-format
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 * 4 - U32 - name-length
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 * name-length - U8 array - name-string
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 */
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 public class ServerInitMessage {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 protected int frameBufferWidth;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 protected int frameBufferHeight;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 protected PixelFormat pixelFormat;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 protected String name;
17
718cdde720d4 add setInitData()
one
parents: 0
diff changeset
43 protected byte[] initData;
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 public ServerInitMessage(Reader reader) throws TransportException {
17
718cdde720d4 add setInitData()
one
parents: 0
diff changeset
46 readServerInit(reader);
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 frameBufferWidth = reader.readUInt16();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 frameBufferHeight = reader.readUInt16();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 pixelFormat = new PixelFormat();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 pixelFormat.fill(reader);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 name = reader.readString();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 protected ServerInitMessage() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 // empty
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 public int getFrameBufferWidth() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 return frameBufferWidth;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 public int getFrameBufferHeight() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 return frameBufferHeight;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 public PixelFormat getPixelFormat() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 return pixelFormat;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 }
18
075fb190d5d4 modify protocol.java
one
parents: 17
diff changeset
69
075fb190d5d4 modify protocol.java
one
parents: 17
diff changeset
70 public byte[] getInitData() {
075fb190d5d4 modify protocol.java
one
parents: 17
diff changeset
71 return initData;
075fb190d5d4 modify protocol.java
one
parents: 17
diff changeset
72 }
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 public String getName() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 return name;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 public String toString() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 return "ServerInitMessage: [name: "+ name +
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 ", framebuffer-width: " + String.valueOf(frameBufferWidth) +
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 ", framebuffer-height: " + String.valueOf(frameBufferHeight) +
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 ", server-pixel-format: " + pixelFormat +
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 "]";
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 }
17
718cdde720d4 add setInitData()
one
parents: 0
diff changeset
86
718cdde720d4 add setInitData()
one
parents: 0
diff changeset
87 public void readServerInit(Reader reader) throws TransportException {
718cdde720d4 add setInitData()
one
parents: 0
diff changeset
88 reader.mark(255);
718cdde720d4 add setInitData()
one
parents: 0
diff changeset
89 reader.skypBytes(20);
718cdde720d4 add setInitData()
one
parents: 0
diff changeset
90 int nlen = reader.readInt32();
718cdde720d4 add setInitData()
one
parents: 0
diff changeset
91 int blen = 20 + 4 + nlen;
718cdde720d4 add setInitData()
one
parents: 0
diff changeset
92 initData = new byte[blen];
718cdde720d4 add setInitData()
one
parents: 0
diff changeset
93 reader.reset();
718cdde720d4 add setInitData()
one
parents: 0
diff changeset
94
718cdde720d4 add setInitData()
one
parents: 0
diff changeset
95 reader.mark(blen);
718cdde720d4 add setInitData()
one
parents: 0
diff changeset
96 reader.readBytes(initData);
718cdde720d4 add setInitData()
one
parents: 0
diff changeset
97 reader.reset();
718cdde720d4 add setInitData()
one
parents: 0
diff changeset
98 }
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 }