annotate src/main/java/com/glavsoft/rfb/protocol/Protocol.java @ 55:9fdb8ff88497

change parameter.
author one
date Mon, 02 Dec 2013 14:20:37 +0900
parents 986f16afb753
children 913d0f663e74
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 // Copyright (C) 2010, 2011 GlavSoft LLC.
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;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 private final Logger logger = Logger.getLogger("com.glavsoft.rfb.protocol");
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;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 private String remoteDesctopName;
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;
18
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
69 private byte[] initData;
50
225e3873d75f Modified to be able to specify the region of the screen in the argument.
one
parents: 49
diff changeset
70 private boolean isRetina = false;
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 public Protocol(Reader reader, Writer writer,
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 IPasswordRetriever passwordRetriever, ProtocolSettings settings) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 this.reader = reader;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 this.writer = writer;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 this.passwordRetriever = passwordRetriever;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 this.settings = settings;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 decoders = new DecodersContainer();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 decoders.instantiateDecodersWhenNeeded(settings.encodings);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 state = new HandshakeState(this);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 }
50
225e3873d75f Modified to be able to specify the region of the screen in the argument.
one
parents: 49
diff changeset
82
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 public void changeStateTo(ProtocolState state) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 this.state = state;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 public void handshake() throws UnsupportedProtocolVersionException, UnsupportedSecurityTypeException,
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 AuthenticationFailedException, TransportException, FatalException {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 while (state.next()) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 continue;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 this.messageQueue = new MessageQueue();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 }
18
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
95
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 public PixelFormat getPixelFormat() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 return pixelFormat;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 public void setPixelFormat(PixelFormat pixelFormat) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 this.pixelFormat = pixelFormat;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 if (repaintController != null) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 repaintController.setPixelFormat(pixelFormat);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 public String getRemoteDesktopName() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 return remoteDesctopName;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 public void setRemoteDesktopName(String name) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 remoteDesctopName = name;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 public int getFbWidth() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 return fbWidth;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 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
126 if(!isRetina)
225e3873d75f Modified to be able to specify the region of the screen in the argument.
one
parents: 49
diff changeset
127 this.fbWidth = fbWidth;
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 public int getFbHeight() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 return fbHeight;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134
18
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
135 @Override
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
136 public byte[] getInitData() {
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
137 return initData;
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
138 }
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
139
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
140 @Override
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
141 public void setInitData(byte[] initData) {
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
142 this.initData = initData;
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
143 }
075fb190d5d4 modify protocol.java
one
parents: 16
diff changeset
144
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 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
147 if(!isRetina)
225e3873d75f Modified to be able to specify the region of the screen in the argument.
one
parents: 49
diff changeset
148 this.fbHeight = fbHeight;
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 public IPasswordRetriever getPasswordRetriever() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 return passwordRetriever;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 public ProtocolSettings getSettings() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 return settings;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 public Logger getLogger() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 return logger;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 public Writer getWriter() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 return writer;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 public Reader getReader() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 return reader;
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
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 /**
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 * 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
178 * 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
179 * 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
180 * FramebufferUpdateRequest. From then on the server will send
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 * FramebufferUpdate messages in response to the client's
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 * FramebufferUpdateRequest messages. The client should send
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 * 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
184 * 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
185 * 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
186 * should be regulated to avoid hogging the network.
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 */
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 public void startNormalHandling(IRfbSessionListener rfbSessionListener,
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 IRepaintController repaintController, ClipboardController clipboardController) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 this.rfbSessionListener = rfbSessionListener;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 this.repaintController = repaintController;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 // if (settings.getBitsPerPixel() == 0) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 // settings.setBitsPerPixel(pixelFormat.bitsPerPixel); // the same the server sent when not initialized yet
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 // }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 serverPixelFormat = pixelFormat;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 serverPixelFormat.trueColourFlag = 1; // correct flag - we don't support color maps
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 setPixelFormat(createPixelFormat(settings));
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 sendMessage(new SetPixelFormatMessage(pixelFormat));
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 logger.fine("sent: "+pixelFormat);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 sendSupportedEncodingsMessage(settings);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 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
203 settings.addListener(repaintController);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
204
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 sendRefreshMessage();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 senderTask = new SenderTask(messageQueue, writer, this);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 senderThread = new Thread(senderTask);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 senderThread.start();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 decoders.resetDecoders();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 receiverTask = new ReceiverTask(
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 reader, repaintController,
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 clipboardController,
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 decoders, this);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
214 receiverThread = new Thread(receiverTask);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 receiverThread.start();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
217
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 public void sendMessage(ClientToServerMessage message) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 messageQueue.put(message);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
222
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 private void sendSupportedEncodingsMessage(ProtocolSettings settings) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 decoders.instantiateDecodersWhenNeeded(settings.encodings);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 SetEncodingsMessage encodingsMessage = new SetEncodingsMessage(settings.encodings);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
226 sendMessage(encodingsMessage);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 logger.fine("sent: " + encodingsMessage.toString());
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
229
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 /**
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
231 * create pixel format by bpp
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 */
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 private PixelFormat createPixelFormat(ProtocolSettings settings) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 int serverBigEndianFlag = serverPixelFormat.bigEndianFlag;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 switch (settings.getBitsPerPixel()) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 case ProtocolSettings.BPP_32:
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 return PixelFormat.create32bppPixelFormat(serverBigEndianFlag);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 case ProtocolSettings.BPP_16:
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 return PixelFormat.create16bppPixelFormat(serverBigEndianFlag);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 case ProtocolSettings.BPP_8:
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 return PixelFormat.create8bppBGRPixelFormat(serverBigEndianFlag);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 case ProtocolSettings.BPP_6:
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 return PixelFormat.create6bppPixelFormat(serverBigEndianFlag);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 case ProtocolSettings.BPP_3:
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 return PixelFormat.create3bppPixelFormat(serverBigEndianFlag);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 case ProtocolSettings.BPP_SERVER_SETTINGS:
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 return serverPixelFormat;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 default:
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 // unsupported bpp, use default
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 return PixelFormat.create32bppPixelFormat(serverBigEndianFlag);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
253
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 public void settingsChanged(SettingsChangedEvent e) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 ProtocolSettings settings = (ProtocolSettings) e.getSource();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 if (settings.isChangedEncodings()) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 sendSupportedEncodingsMessage(settings);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 if (settings.changedBitsPerPixel() && receiverTask != null) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 receiverTask.queueUpdatePixelFormat(createPixelFormat(settings));
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 }
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 @Override
55
9fdb8ff88497 change parameter.
one
parents: 52
diff changeset
266 public void sendRefreshMessage() {
52
986f16afb753 update before change host.
one
parents: 50
diff changeset
267 sendMessage(new FramebufferUpdateRequestMessage(0, 0, 1006, 506, true));
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 logger.fine("sent: full FB Refresh");
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
270
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 @Override
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 public void cleanUpSession(String message) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 cleanUpSession();
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 rfbSessionListener.rfbSessionStopped(message);
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 public synchronized void cleanUpSession() {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 if (senderTask != null) { senderTask.stopTask(); }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 if (receiverTask != null) { receiverTask.stopTask(); }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 if (senderTask != null) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 try {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 senderThread.join(1000);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 } catch (InterruptedException e) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 // nop
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 senderTask = null;
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 if (receiverTask != null) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 try {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 receiverThread.join(1000);
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 } catch (InterruptedException e) {
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 // nop
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 receiverTask = null;
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 }
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
297
16
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
298 public void startNormalHandling(VncProxyService vncProxyService,
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
299 Surface surface, ClipboardControllerImpl clipboardController,
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
300 MyRfbProtoProxy rfb)
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
301 {
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
302 this.rfbSessionListener = vncProxyService;
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
303 this.repaintController = surface;
19
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
304 // if (settings.getBitsPerPixel() == 0) {
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
305 // 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
306 // }
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
307 serverPixelFormat = pixelFormat;
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
308 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
309 setPixelFormat(createPixelFormat(settings));
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
310 sendMessage(new SetPixelFormatMessage(pixelFormat));
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
311 logger.fine("sent: "+pixelFormat);
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
312
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
313 sendSupportedEncodingsMessage(settings);
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
314 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
315 settings.addListener(surface);
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
316
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
317 sendRefreshMessage();
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
318 senderTask = new SenderTask(messageQueue, writer, this);
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
319 senderThread = new Thread(senderTask);
ea83f4be0cc9 remove is and os
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
320 senderThread.start();
16
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
321 decoders.resetDecoders();
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
322 receiverTask = new TreeTask(
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
323 reader, repaintController,
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
324 clipboardController,
23
6a4312344a5a remove set rfb TreeTask
one
parents: 19
diff changeset
325 decoders, this, rfb);
16
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
326 receiverThread = new Thread(receiverTask);
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
327 receiverThread.start();
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
328 }
32
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
329
35
1b81deb0abb3 write a little part reconnection.
one
parents: 32
diff changeset
330
32
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
331 public void startTreeClientHandling(IRfbSessionListener rfbSessionListener,
35
1b81deb0abb3 write a little part reconnection.
one
parents: 32
diff changeset
332 IRepaintController repaintController,
1b81deb0abb3 write a little part reconnection.
one
parents: 32
diff changeset
333 ClipboardController clipboardController, MyRfbProto rfb) {
32
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
334 this.rfbSessionListener = rfbSessionListener;
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
335 this.repaintController = repaintController;
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
336 // if (settings.getBitsPerPixel() == 0) {
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
337 // settings.setBitsPerPixel(pixelFormat.bitsPerPixel); // the same the server sent when not initialized yet
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
338 // }
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
339 serverPixelFormat = pixelFormat;
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
340 serverPixelFormat.trueColourFlag = 1; // correct flag - we don't support color maps
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
341 setPixelFormat(createPixelFormat(settings));
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
342 sendMessage(new SetPixelFormatMessage(pixelFormat));
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
343 logger.fine("sent: "+pixelFormat);
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
344
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
345 sendSupportedEncodingsMessage(settings);
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
346 settings.addListener(this); // to support pixel format (color depth), and encodings changes
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
347 settings.addListener(repaintController);
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
348
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
349 sendRefreshMessage();
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
350 senderTask = new SenderTask(messageQueue, writer, this);
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
351 senderThread = new Thread(senderTask);
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
352 senderThread.start();
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
353 decoders.resetDecoders();
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
354 receiverTask = new TreeTask(
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
355 reader, repaintController,
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
356 clipboardController,
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
357 decoders, this, rfb);
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
358 receiverThread = new Thread(receiverTask);
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
359 receiverThread.start();
758d025ee24b add TextBox.java
one
parents: 23
diff changeset
360 }
16
e654b2e4de64 add TreeTask.java
one
parents: 0
diff changeset
361
50
225e3873d75f Modified to be able to specify the region of the screen in the argument.
one
parents: 49
diff changeset
362 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
363 isRetina = true;
225e3873d75f Modified to be able to specify the region of the screen in the argument.
one
parents: 49
diff changeset
364 this.fbWidth = fbWidth;
225e3873d75f Modified to be able to specify the region of the screen in the argument.
one
parents: 49
diff changeset
365 this.fbHeight = fbHeight;
225e3873d75f Modified to be able to specify the region of the screen in the argument.
one
parents: 49
diff changeset
366 }
0
4689cc86d6cb create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
367 }