annotate src/main/java/com/glavsoft/rfb/protocol/Protocol.java @ 59:433c79184c05

merge version2.7.2
author Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
date Tue, 17 Dec 2013 20:16:48 +0900
parents 17b702648079 913d0f663e74
children ac6f9e46566f
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.protocol;
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.core.SettingsChangedEvent;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 import com.glavsoft.exceptions.*;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 import com.glavsoft.rfb.*;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 import com.glavsoft.rfb.client.ClientToServerMessage;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 import com.glavsoft.rfb.client.FramebufferUpdateRequestMessage;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 import com.glavsoft.rfb.client.SetEncodingsMessage;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 import com.glavsoft.rfb.client.SetPixelFormatMessage;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 import com.glavsoft.rfb.encoding.PixelFormat;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 import com.glavsoft.rfb.encoding.decoder.DecodersContainer;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 import com.glavsoft.rfb.protocol.state.HandshakeState;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 import com.glavsoft.rfb.protocol.state.ProtocolState;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 import com.glavsoft.transport.Reader;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 import com.glavsoft.transport.Writer;
16
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
40 import com.glavsoft.viewer.swing.ClipboardControllerImpl;
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
41 import com.glavsoft.viewer.swing.Surface;
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 import java.util.logging.Logger;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
32
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
45 import jp.ac.u_ryukyu.treevnc.MyRfbProto;
16
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
46 import jp.ac.u_ryukyu.treevnc.server.MyRfbProtoProxy;
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
47 import jp.ac.u_ryukyu.treevnc.server.VncProxyService;
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
48
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 public class Protocol implements ProtocolContext, IChangeSettingsListener {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 private ProtocolState state;
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
51 private final Logger logger;
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 private final IPasswordRetriever passwordRetriever;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 private final ProtocolSettings settings;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 private int fbWidth;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 private int fbHeight;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 private PixelFormat pixelFormat;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 private final Reader reader;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 private final Writer writer;
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
59 private String remoteDesktopName;
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 private MessageQueue messageQueue;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 private final DecodersContainer decoders;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 private SenderTask senderTask;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 private ReceiverTask receiverTask;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 private IRfbSessionListener rfbSessionListener;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 private IRepaintController repaintController;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 private PixelFormat serverPixelFormat;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 private Thread senderThread;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 private Thread receiverThread;
59
433c79184c05 merge version2.7.2
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 57 56
diff changeset
69 private boolean isTight;
433c79184c05 merge version2.7.2
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 57 56
diff changeset
70 private String protocolVersion;
18
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
71 private byte[] initData;
50
225e3873d75f Modified to be able to specify the region of the screen in the argument.
one
parents: 49
diff changeset
72 private boolean isRetina = false;
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
74 public Protocol(Reader reader, Writer writer,
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 IPasswordRetriever passwordRetriever, ProtocolSettings settings) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 this.reader = reader;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 this.writer = writer;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 this.passwordRetriever = passwordRetriever;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 this.settings = settings;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 decoders = new DecodersContainer();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 decoders.instantiateDecodersWhenNeeded(settings.encodings);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 state = new HandshakeState(this);
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
83 logger = Logger.getLogger(getClass().getName());
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
84 }
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 public void changeStateTo(ProtocolState state) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 this.state = state;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 public void handshake() throws UnsupportedProtocolVersionException, UnsupportedSecurityTypeException,
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 AuthenticationFailedException, TransportException, FatalException {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 while (state.next()) {
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
94 // continue;
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 this.messageQueue = new MessageQueue();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 }
18
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
98
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 public PixelFormat getPixelFormat() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 return pixelFormat;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 public void setPixelFormat(PixelFormat pixelFormat) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 this.pixelFormat = pixelFormat;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 if (repaintController != null) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 repaintController.setPixelFormat(pixelFormat);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 public String getRemoteDesktopName() {
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
114 return remoteDesktopName;
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 public void setRemoteDesktopName(String name) {
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
119 remoteDesktopName = name;
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 public int getFbWidth() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 return fbWidth;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 public void setFbWidth(int fbWidth) {
50
225e3873d75f Modified to be able to specify the region of the screen in the argument.
one
parents: 49
diff changeset
129 if(!isRetina)
225e3873d75f Modified to be able to specify the region of the screen in the argument.
one
parents: 49
diff changeset
130 this.fbWidth = fbWidth;
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 public int getFbHeight() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 return fbHeight;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137
18
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
138 @Override
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
139 public byte[] getInitData() {
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
140 return initData;
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
141 }
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
142
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
143 @Override
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
144 public void setInitData(byte[] initData) {
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
145 this.initData = initData;
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
146 }
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
147
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 public void setFbHeight(int fbHeight) {
50
225e3873d75f Modified to be able to specify the region of the screen in the argument.
one
parents: 49
diff changeset
150 if(!isRetina)
225e3873d75f Modified to be able to specify the region of the screen in the argument.
one
parents: 49
diff changeset
151 this.fbHeight = fbHeight;
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 public IPasswordRetriever getPasswordRetriever() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 return passwordRetriever;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 public ProtocolSettings getSettings() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 return settings;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
164 @Override
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 public Writer getWriter() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 return writer;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 public Reader getReader() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 return reader;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 /**
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 * Following the server initialisation message it's up to the client to send
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 * whichever protocol messages it wants. Typically it will send a
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 * SetPixelFormat message and a SetEncodings message, followed by a
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 * FramebufferUpdateRequest. From then on the server will send
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 * FramebufferUpdate messages in response to the client's
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 * FramebufferUpdateRequest messages. The client should send
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 * FramebufferUpdateRequest messages with incremental set to true when it has
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 * finished processing one FramebufferUpdate and is ready to process another.
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 * With a fast client, the rate at which FramebufferUpdateRequests are sent
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 * should be regulated to avoid hogging the network.
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 */
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 public void startNormalHandling(IRfbSessionListener rfbSessionListener,
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 IRepaintController repaintController, ClipboardController clipboardController) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 this.rfbSessionListener = rfbSessionListener;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 this.repaintController = repaintController;
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
190 // if (settings.getColorDepth() == 0) {
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
191 // settings.setColorDepth(pixelFormat.depth); // the same the server sent when not initialized yet
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 // }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 serverPixelFormat = pixelFormat;
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
194 correctServerPixelFormat();
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 setPixelFormat(createPixelFormat(settings));
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 sendMessage(new SetPixelFormatMessage(pixelFormat));
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
197 logger.fine("sent: " + pixelFormat);
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 sendSupportedEncodingsMessage(settings);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 settings.addListener(this); // to support pixel format (color depth), and encodings changes
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 settings.addListener(repaintController);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 sendRefreshMessage();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 senderTask = new SenderTask(messageQueue, writer, this);
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
204 senderThread = new Thread(senderTask, "RfbSenderTask");
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 senderThread.start();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 decoders.resetDecoders();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 receiverTask = new ReceiverTask(
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 reader, repaintController,
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 clipboardController,
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 decoders, this);
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
211 receiverThread = new Thread(receiverTask, "RfbReceiverTask");
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 receiverThread.start();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
214
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
215 private void correctServerPixelFormat() {
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
216 // correct true color flag - we don't support color maps, so always set it up
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
217 serverPixelFormat.trueColourFlag = 1;
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
218 // correct .depth to use actual depth 24 instead of incorrect 32, used by ex. UltraVNC server, that cause
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
219 // protocol incompatibility in ZRLE encoding
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
220 final long significant = serverPixelFormat.redMax << serverPixelFormat.redShift |
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
221 serverPixelFormat.greenMax << serverPixelFormat.greenShift |
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
222 serverPixelFormat.blueMax << serverPixelFormat.blueShift;
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
223 if (32 == serverPixelFormat.bitsPerPixel &&
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
224 ((significant & 0x00ff000000L) == 0 || (significant & 0x000000ffL) == 0) &&
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
225 32 == serverPixelFormat.depth) {
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
226 serverPixelFormat.depth = 24;
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
227 }
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
228 }
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
229
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
230 @Override
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
231 public void sendMessage(ClientToServerMessage message) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 messageQueue.put(message);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
234
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 private void sendSupportedEncodingsMessage(ProtocolSettings settings) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 decoders.instantiateDecodersWhenNeeded(settings.encodings);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 SetEncodingsMessage encodingsMessage = new SetEncodingsMessage(settings.encodings);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 sendMessage(encodingsMessage);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 logger.fine("sent: " + encodingsMessage.toString());
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
241
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 /**
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 * create pixel format by bpp
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 */
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 private PixelFormat createPixelFormat(ProtocolSettings settings) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 int serverBigEndianFlag = serverPixelFormat.bigEndianFlag;
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
247 switch (settings.getColorDepth()) {
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
248 case ProtocolSettings.COLOR_DEPTH_24:
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
249 return PixelFormat.create24bitColorDepthPixelFormat(serverBigEndianFlag);
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
250 case ProtocolSettings.COLOR_DEPTH_16:
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
251 return PixelFormat.create16bitColorDepthPixelFormat(serverBigEndianFlag);
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
252 case ProtocolSettings.COLOR_DEPTH_8:
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
253 return PixelFormat.create8bitColorDepthBGRPixelFormat(serverBigEndianFlag);
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
254 case ProtocolSettings.COLOR_DEPTH_6:
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
255 return PixelFormat.create6bitColorDepthPixelFormat(serverBigEndianFlag);
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
256 case ProtocolSettings.COLOR_DEPTH_3:
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 return PixelFormat.create3bppPixelFormat(serverBigEndianFlag);
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
258 case ProtocolSettings.COLOR_DEPTH_SERVER_SETTINGS:
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 return serverPixelFormat;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 default:
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 // unsupported bpp, use default
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
262 return PixelFormat.create24bitColorDepthPixelFormat(serverBigEndianFlag);
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
265
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
266 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 public void settingsChanged(SettingsChangedEvent e) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 ProtocolSettings settings = (ProtocolSettings) e.getSource();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 if (settings.isChangedEncodings()) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 sendSupportedEncodingsMessage(settings);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 }
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
272 if (settings.isChangedColorDepth() && receiverTask != null) {
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 receiverTask.queueUpdatePixelFormat(createPixelFormat(settings));
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
275 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
276
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
277 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 public void sendRefreshMessage() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 sendMessage(new FramebufferUpdateRequestMessage(0, 0, fbWidth, fbHeight, false));
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 logger.fine("sent: full FB Refresh");
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 public void cleanUpSession(String message) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 cleanUpSession();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 rfbSessionListener.rfbSessionStopped(message);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
288
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 public synchronized void cleanUpSession() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 if (senderTask != null) { senderTask.stopTask(); }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 if (receiverTask != null) { receiverTask.stopTask(); }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 if (senderTask != null) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 try {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 senderThread.join(1000);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 } catch (InterruptedException e) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 // nop
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 senderTask = null;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 if (receiverTask != null) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
301 try {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 receiverThread.join(1000);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 } catch (InterruptedException e) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 // nop
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
306 receiverTask = null;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
307 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
308 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
309
57
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
310 @Override
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
311 public void setTight(boolean isTight) {
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
312 this.isTight = isTight;
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
313 }
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
314
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
315 @Override
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
316 public boolean isTight() {
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
317 return isTight;
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
318 }
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
319
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
320 @Override
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
321 public void setProtocolVersion(String protocolVersion) {
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
322 this.protocolVersion = protocolVersion;
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
323 }
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
324
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
325 @Override
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
326 public String getProtocolVersion() {
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
327 return protocolVersion;
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
328 }
17b702648079 version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
329
16
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
330 public void startNormalHandling(VncProxyService vncProxyService,
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
331 Surface surface, ClipboardControllerImpl clipboardController,
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
332 MyRfbProtoProxy rfb)
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
333 {
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
334 this.rfbSessionListener = vncProxyService;
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
335 this.repaintController = surface;
19
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
336 // if (settings.getBitsPerPixel() == 0) {
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
337 // settings.setBitsPerPixel(pixelFormat.bitsPerPixel); // the same the server sent when not initialized yet
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
338 // }
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
339 serverPixelFormat = pixelFormat;
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
340 serverPixelFormat.trueColourFlag = 1; // correct flag - we don't support color maps
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
341 setPixelFormat(createPixelFormat(settings));
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
342 sendMessage(new SetPixelFormatMessage(pixelFormat));
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
343 logger.fine("sent: "+pixelFormat);
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
344
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
345 sendSupportedEncodingsMessage(settings);
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
346 settings.addListener(this); // to support pixel format (color depth), and encodings changes
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
347 settings.addListener(surface);
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
348 sendRefreshMessage();
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
349 senderTask = new SenderTask(messageQueue, writer, this);
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
350 senderThread = new Thread(senderTask);
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
351 senderThread.start();
16
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
352 decoders.resetDecoders();
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
353 receiverTask = new TreeTask(
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
354 reader, repaintController,
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
355 clipboardController,
23
6a4312344a5a remove set rfb TreeTask
one
parents: 19
diff changeset
356 decoders, this, rfb);
16
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
357 receiverThread = new Thread(receiverTask);
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
358 receiverThread.start();
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
359 }
32
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
360
35
1b81deb0abb3 write a little part reconnection.
one
parents: 32
diff changeset
361
32
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
362 public void startTreeClientHandling(IRfbSessionListener rfbSessionListener,
35
1b81deb0abb3 write a little part reconnection.
one
parents: 32
diff changeset
363 IRepaintController repaintController,
1b81deb0abb3 write a little part reconnection.
one
parents: 32
diff changeset
364 ClipboardController clipboardController, MyRfbProto rfb) {
32
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
365 this.rfbSessionListener = rfbSessionListener;
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
366 this.repaintController = repaintController;
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
367 // if (settings.getBitsPerPixel() == 0) {
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
368 // settings.setBitsPerPixel(pixelFormat.bitsPerPixel); // the same the server sent when not initialized yet
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
369 // }
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
370 serverPixelFormat = pixelFormat;
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
371 serverPixelFormat.trueColourFlag = 1; // correct flag - we don't support color maps
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
372 setPixelFormat(createPixelFormat(settings));
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
373 sendMessage(new SetPixelFormatMessage(pixelFormat));
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
374 logger.fine("sent: "+pixelFormat);
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
375
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
376 sendSupportedEncodingsMessage(settings);
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
377 settings.addListener(this); // to support pixel format (color depth), and encodings changes
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
378 settings.addListener(repaintController);
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
379
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
380 sendRefreshMessage();
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
381 senderTask = new SenderTask(messageQueue, writer, this);
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
382 senderThread = new Thread(senderTask);
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
383 senderThread.start();
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
384 decoders.resetDecoders();
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
385 receiverTask = new TreeTask(
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
386 reader, repaintController,
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
387 clipboardController,
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
388 decoders, this, rfb);
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
389 receiverThread = new Thread(receiverTask);
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
390 receiverThread.start();
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
391 }
16
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
392
50
225e3873d75f Modified to be able to specify the region of the screen in the argument.
one
parents: 49
diff changeset
393 public void setScreenSizeRetina(int fbWidth, int fbHeight) {
225e3873d75f Modified to be able to specify the region of the screen in the argument.
one
parents: 49
diff changeset
394 isRetina = true;
225e3873d75f Modified to be able to specify the region of the screen in the argument.
one
parents: 49
diff changeset
395 this.fbWidth = fbWidth;
225e3873d75f Modified to be able to specify the region of the screen in the argument.
one
parents: 49
diff changeset
396 this.fbHeight = fbHeight;
225e3873d75f Modified to be able to specify the region of the screen in the argument.
one
parents: 49
diff changeset
397 }
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
398 }