Mercurial > hg > Applications > TreeVNC
comparison src/main/java/com/glavsoft/rfb/protocol/state/InitState.java @ 0:4689cc86d6cb
create TreeViewer2 Repository
author | Yu Taninari <you@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 03 Jul 2012 13:20:49 +0900 |
parents | |
children | 075fb190d5d4 17b702648079 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4689cc86d6cb |
---|---|
1 // Copyright (C) 2010, 2011 GlavSoft LLC. | |
2 // All rights reserved. | |
3 // | |
4 //------------------------------------------------------------------------- | |
5 // This file is part of the TightVNC software. Please visit our Web site: | |
6 // | |
7 // http://www.tightvnc.com/ | |
8 // | |
9 // This program is free software; you can redistribute it and/or modify | |
10 // it under the terms of the GNU General Public License as published by | |
11 // the Free Software Foundation; either version 2 of the License, or | |
12 // (at your option) any later version. | |
13 // | |
14 // This program is distributed in the hope that it will be useful, | |
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 // GNU General Public License for more details. | |
18 // | |
19 // You should have received a copy of the GNU General Public License along | |
20 // with this program; if not, write to the Free Software Foundation, Inc., | |
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
22 //------------------------------------------------------------------------- | |
23 // | |
24 | |
25 package com.glavsoft.rfb.protocol.state; | |
26 | |
27 import com.glavsoft.exceptions.AuthenticationFailedException; | |
28 import com.glavsoft.exceptions.FatalException; | |
29 import com.glavsoft.exceptions.TransportException; | |
30 import com.glavsoft.exceptions.UnsupportedProtocolVersionException; | |
31 import com.glavsoft.exceptions.UnsupportedSecurityTypeException; | |
32 import com.glavsoft.rfb.encoding.ServerInitMessage; | |
33 import com.glavsoft.rfb.protocol.ProtocolContext; | |
34 import com.glavsoft.rfb.protocol.ProtocolSettings; | |
35 | |
36 /** | |
37 * ClientInit | |
38 * | |
39 * Once the client and server are sure that they're happy to talk to one | |
40 * another, the client sends an initialisation message. At present this | |
41 * message onl@!,@!,y consists of a boolean indicating whether the server should try | |
42 * to share the desktop by leaving other clients connected, or give exclusive | |
43 * access to this client by disconnecting all other clients. | |
44 * | |
45 * 1 - U8 - shared-flag | |
46 * | |
47 * Shared-flag is non-zero (true) if the server should try to share the desktop by leaving | |
48 * other clients connected, zero (false) if it should give exclusive access to this client by | |
49 * disconnecting all other clients. | |
50 * | |
51 * ServerInit | |
52 * | |
53 * After receiving the ClientInit message, the server sends a ServerInit message. This | |
54 * tells the client the width and height of the server’s framebuffer, its pixel format and the | |
55 * name associated with the desktop. | |
56 */ | |
57 public class InitState extends ProtocolState { | |
58 | |
59 public InitState(ProtocolContext context) { | |
60 super(context); | |
61 } | |
62 | |
63 @Override | |
64 public boolean next() throws UnsupportedProtocolVersionException, TransportException, | |
65 UnsupportedSecurityTypeException, AuthenticationFailedException, FatalException { | |
66 clientAndServerInit(); | |
67 return false; | |
68 } | |
69 | |
70 protected void clientAndServerInit() throws TransportException { | |
71 ServerInitMessage serverInitMessage = getServerInitMessage(); | |
72 ProtocolSettings settings = context.getSettings(); | |
73 settings.enableAllEncodingCaps(); | |
74 completeContextData(serverInitMessage); | |
75 } | |
76 | |
77 protected void completeContextData(ServerInitMessage serverInitMessage) { | |
78 context.setPixelFormat(serverInitMessage.getPixelFormat()); | |
79 context.setFbWidth(serverInitMessage.getFrameBufferWidth()); | |
80 context.setFbHeight(serverInitMessage.getFrameBufferHeight()); | |
81 context.setRemoteDesktopName(serverInitMessage.getName()); | |
82 logger.fine(serverInitMessage.toString()); | |
83 } | |
84 | |
85 protected ServerInitMessage getServerInitMessage() throws TransportException { | |
86 writer.write(context.getSettings().getSharedFlag()); | |
87 ServerInitMessage serverInitMessage = new ServerInitMessage(reader); | |
88 return serverInitMessage; | |
89 } | |
90 | |
91 | |
92 } |