annotate src/VncViewer.java @ 0:e04119c40b9b

upload all file of tighVNCClient
author e085711
date Tue, 12 Apr 2011 12:57:33 +0900
parents
children dc1d008d987b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
2 // Copyright (C) 2001-2004 HorizonLive.com, Inc. All Rights Reserved.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
3 // Copyright (C) 2002 Constantin Kaplinsky. All Rights Reserved.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
4 // Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
5 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
6 // This is free software; you can redistribute it and/or modify
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
7 // it under the terms of the GNU General Public License as published by
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
8 // the Free Software Foundation; either version 2 of the License, or
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
9 // (at your option) any later version.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
10 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
11 // This software is distributed in the hope that it will be useful,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
14 // GNU General Public License for more details.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
15 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
16 // You should have received a copy of the GNU General Public License
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
17 // along with this software; if not, write to the Free Software
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
19 // USA.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
20 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
21
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
22 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
23 // VncViewer.java - the VNC viewer applet. This class mainly just sets up the
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
24 // user interface, leaving it to the VncCanvas to do the actual rendering of
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
25 // a VNC desktop.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
26 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
27
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
28 import java.awt.*;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
29 import java.awt.event.*;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
30 import java.io.*;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
31 import java.net.*;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
32
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
33 public class VncViewer extends java.applet.Applet
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
34 implements java.lang.Runnable, WindowListener {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
35
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
36 boolean inAnApplet = true;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
37 boolean inSeparateFrame = false;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
38
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
39 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
40 // main() is called when run as a java program from the command line.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
41 // It simply runs the applet inside a newly-created frame.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
42 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
43
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
44 public static void main(String[] argv) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
45 VncViewer v = new VncViewer();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
46 v.mainArgs = argv;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
47 v.inAnApplet = false;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
48 v.inSeparateFrame = true;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
49 /*
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
50 if(argv.length > 1){
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
51 v.host = argv[0];
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
52 v.port = Integer.parseInt(argv[1]);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
53 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
54 */
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
55 v.init();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
56 v.start();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
57 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
58
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
59 String[] mainArgs;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
60
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
61 RfbProto rfb;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
62 Thread rfbThread;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
63
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
64 Frame vncFrame;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
65 Container vncContainer;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
66 ScrollPane desktopScrollPane;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
67 GridBagLayout gridbag;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
68 ButtonPanel buttonPanel;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
69 Label connStatusLabel;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
70 VncCanvas vc;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
71 OptionsFrame options;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
72 ClipboardFrame clipboard;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
73 RecordingFrame rec;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
74
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
75 // Control session recording.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
76 Object recordingSync;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
77 String sessionFileName;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
78 boolean recordingActive;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
79 boolean recordingStatusChanged;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
80 String cursorUpdatesDef;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
81 String eightBitColorsDef;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
82
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
83 // Variables read from parameter values.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
84 String socketFactory;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
85 String host;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
86 int port;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
87 String passwordParam;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
88 boolean showControls;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
89 boolean offerRelogin;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
90 boolean showOfflineDesktop;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
91 int deferScreenUpdates;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
92 int deferCursorUpdates;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
93 int deferUpdateRequests;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
94 int debugStatsExcludeUpdates;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
95 int debugStatsMeasureUpdates;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
96
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
97
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
98 // Reference to this applet for inter-applet communication.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
99 public static java.applet.Applet refApplet;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
100
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
101 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
102 // init()
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
103 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
104
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
105 public void init() {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
106
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
107 readParameters();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
108
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
109 refApplet = this;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
110
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
111 if (inSeparateFrame) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
112 vncFrame = new Frame("TightVNC");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
113 if (!inAnApplet) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
114 vncFrame.add("Center", this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
115 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
116 vncContainer = vncFrame;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
117 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
118 vncContainer = this;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
119 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
120
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
121 recordingSync = new Object();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
122
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
123 options = new OptionsFrame(this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
124 clipboard = new ClipboardFrame(this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
125 if (RecordingFrame.checkSecurity())
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
126 rec = new RecordingFrame(this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
127
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
128 sessionFileName = null;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
129 recordingActive = false;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
130 recordingStatusChanged = false;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
131 cursorUpdatesDef = null;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
132 eightBitColorsDef = null;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
133
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
134 if (inSeparateFrame)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
135 vncFrame.addWindowListener(this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
136
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
137 rfbThread = new Thread(this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
138 rfbThread.start();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
139 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
140
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
141 public void update(Graphics g) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
142 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
143
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
144 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
145 // run() - executed by the rfbThread to deal with the RFB socket.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
146 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
147
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
148 public void run() {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
149
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
150 gridbag = new GridBagLayout();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
151 vncContainer.setLayout(gridbag);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
152
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
153 GridBagConstraints gbc = new GridBagConstraints();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
154 gbc.gridwidth = GridBagConstraints.REMAINDER;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
155 gbc.anchor = GridBagConstraints.NORTHWEST;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
156
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
157 if (showControls) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
158 buttonPanel = new ButtonPanel(this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
159 gridbag.setConstraints(buttonPanel, gbc);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
160 vncContainer.add(buttonPanel);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
161 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
162
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
163
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
164
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
165
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
166
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
167 /*****************************************************************************/
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
168 // /*
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
169 vncFrame.pack();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
170 vncFrame.show();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
171 try{
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
172 rfb = new RfbProto(host, port, this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
173 try {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
174 rfb.readVersionMsg();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
175 rfb.writeVersionMsg();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
176 int secType = rfb.negotiateSecurity();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
177 }catch(Exception e){}
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
178 ServerSocket serverSocket = new ServerSocket(5550);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
179 Socket socket = serverSocket.accept();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
180 rfb.chsock(socket);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
181
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
182 rfb.framebufferWidth = 1680;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
183 rfb.framebufferHeight = 1050;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
184 rfb.bitsPerPixel = 32;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
185 rfb.depth = 32;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
186 rfb.bigEndian = false;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
187 rfb.trueColour = true;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
188 rfb.redMax = 255;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
189 rfb.greenMax = 255;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
190 rfb.blueMax = 255;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
191 rfb.redShift = 16;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
192 rfb.greenShift = 8;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
193 rfb.blueShift = 0;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
194 rfb.inNormalProtocol = true;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
195
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
196 createCanvas(0, 0);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
197 }catch(IOException e) {}
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
198
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
199 gbc.weightx = 1.0;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
200 gbc.weighty = 1.0;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
201
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
202 if (inSeparateFrame) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
203
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
204 // Create a panel which itself is resizeable and can hold
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
205 // non-resizeable VncCanvas component at the top left corner.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
206 Panel canvasPanel = new Panel();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
207 canvasPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
208 canvasPanel.add(vc);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
209
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
210 // Create a ScrollPane which will hold a panel with VncCanvas
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
211 // inside.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
212 desktopScrollPane = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
213 gbc.fill = GridBagConstraints.BOTH;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
214 gridbag.setConstraints(desktopScrollPane, gbc);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
215 desktopScrollPane.add(canvasPanel);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
216
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
217 // Finally, add our ScrollPane to the Frame window.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
218 vncFrame.add(desktopScrollPane);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
219 vncFrame.setTitle(rfb.desktopName);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
220 vncFrame.pack();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
221 vc.resizeDesktopFrame();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
222
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
223 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
224
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
225 // Just add the VncCanvas component to the Applet.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
226 gridbag.setConstraints(vc, gbc);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
227 add(vc);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
228 validate();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
229
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
230 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
231 //*/
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
232 /*****************************************************************************/
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
233
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
234 /*
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
235
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
236 try {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
237 connectAndAuthenticate();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
238 doProtocolInitialisation();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
239
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
240 // FIXME: Use auto-scaling not only in a separate frame.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
241 if (options.autoScale && inSeparateFrame) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
242 Dimension screenSize;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
243 try {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
244 screenSize = vncContainer.getToolkit().getScreenSize();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
245 } catch (Exception e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
246 screenSize = new Dimension(0, 0);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
247 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
248 createCanvas(screenSize.width - 32, screenSize.height - 32);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
249 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
250 createCanvas(0, 0);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
251 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
252
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
253 gbc.weightx = 1.0;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
254 gbc.weighty = 1.0;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
255
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
256 if (inSeparateFrame) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
257
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
258 // Create a panel which itself is resizeable and can hold
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
259 // non-resizeable VncCanvas component at the top left corner.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
260 Panel canvasPanel = new Panel();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
261 canvasPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
262 canvasPanel.add(vc);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
263
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
264 // Create a ScrollPane which will hold a panel with VncCanvas
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
265 // inside.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
266 desktopScrollPane = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
267 gbc.fill = GridBagConstraints.BOTH;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
268 gridbag.setConstraints(desktopScrollPane, gbc);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
269 desktopScrollPane.add(canvasPanel);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
270
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
271 // Finally, add our ScrollPane to the Frame window.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
272 vncFrame.add(desktopScrollPane);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
273 vncFrame.setTitle(rfb.desktopName);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
274 vncFrame.pack();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
275 vc.resizeDesktopFrame();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
276
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
277 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
278
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
279 // Just add the VncCanvas component to the Applet.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
280 gridbag.setConstraints(vc, gbc);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
281 add(vc);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
282 validate();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
283
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
284 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
285 */
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
286
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
287 try{
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
288
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
289 if (showControls)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
290 buttonPanel.enableButtons();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
291
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
292 moveFocusToDesktop();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
293 processNormalProtocol();//main loop
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
294
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
295 } catch (NoRouteToHostException e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
296 fatalError("Network error: no route to server: " + host, e);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
297 } catch (UnknownHostException e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
298 fatalError("Network error: server name unknown: " + host, e);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
299 } catch (ConnectException e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
300 fatalError("Network error: could not connect to server: " +
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
301 host + ":" + port, e);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
302 } catch (EOFException e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
303 if (showOfflineDesktop) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
304 e.printStackTrace();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
305 System.out.println("Network error: remote side closed connection");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
306 if (vc != null) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
307 vc.enableInput(false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
308 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
309 if (inSeparateFrame) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
310 vncFrame.setTitle(rfb.desktopName + " [disconnected]");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
311 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
312 if (rfb != null && !rfb.closed())
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
313 rfb.close();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
314 if (showControls && buttonPanel != null) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
315 buttonPanel.disableButtonsOnDisconnect();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
316 if (inSeparateFrame) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
317 vncFrame.pack();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
318 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
319 validate();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
320 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
321 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
322 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
323 fatalError("Network error: remote side closed connection", e);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
324 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
325 } catch (IOException e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
326 String str = e.getMessage();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
327 if (str != null && str.length() != 0) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
328 fatalError("Network Error: " + str, e);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
329 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
330 fatalError(e.toString(), e);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
331 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
332 } catch (Exception e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
333 String str = e.getMessage();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
334 if (str != null && str.length() != 0) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
335 fatalError("Error: " + str, e);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
336 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
337 fatalError(e.toString(), e);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
338 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
339 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
340
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
341 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
342
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
343 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
344 // Create a VncCanvas instance.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
345 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
346
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
347 void createCanvas(int maxWidth, int maxHeight) throws IOException {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
348 // Determine if Java 2D API is available and use a special
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
349 // version of VncCanvas if it is present.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
350 vc = null;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
351 try {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
352 // This throws ClassNotFoundException if there is no Java 2D API.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
353 Class cl = Class.forName("java.awt.Graphics2D");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
354 // If we could load Graphics2D class, then we can use VncCanvas2D.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
355 cl = Class.forName("VncCanvas2");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
356 Class[] argClasses = { this.getClass(), Integer.TYPE, Integer.TYPE };
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
357 java.lang.reflect.Constructor cstr = cl.getConstructor(argClasses);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
358 Object[] argObjects =
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
359 { this, new Integer(maxWidth), new Integer(maxHeight) };
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
360 vc = (VncCanvas)cstr.newInstance(argObjects);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
361 } catch (Exception e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
362 System.out.println("Warning: Java 2D API is not available");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
363 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
364
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
365 // If we failed to create VncCanvas2D, use old VncCanvas.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
366 if (vc == null)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
367 vc = new VncCanvas(this, maxWidth, maxHeight);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
368 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
369
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
370
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
371 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
372 // Process RFB socket messages.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
373 // If the rfbThread is being stopped, ignore any exceptions,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
374 // otherwise rethrow the exception so it can be handled.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
375 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
376
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
377 void processNormalProtocol() throws Exception {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
378 try {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
379 vc.processNormalProtocol();//main loop
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
380 } catch (Exception e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
381 if (rfbThread == null) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
382 System.out.println("Ignoring RFB socket exceptions" +
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
383 " because applet is stopping");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
384 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
385 throw e;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
386 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
387 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
388 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
389
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
390
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
391 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
392 // Connect to the RFB server and authenticate the user.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
393 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
394
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
395 void connectAndAuthenticate() throws Exception
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
396 {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
397 showConnectionStatus("Initializing...");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
398 if (inSeparateFrame) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
399 vncFrame.pack();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
400 vncFrame.show();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
401 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
402 validate();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
403 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
404
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
405 showConnectionStatus("Connecting to " + host + ", port " + port + "...");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
406
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
407 rfb = new RfbProto(host, port, this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
408 showConnectionStatus("Connected to server");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
409
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
410 rfb.readVersionMsg();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
411 showConnectionStatus("RFB server supports protocol version " +
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
412 rfb.serverMajor + "." + rfb.serverMinor);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
413
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
414 rfb.writeVersionMsg();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
415 showConnectionStatus("Using RFB protocol version " +
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
416 rfb.clientMajor + "." + rfb.clientMinor);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
417
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
418 int secType = rfb.negotiateSecurity();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
419 int authType;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
420 if (secType == RfbProto.SecTypeTight) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
421 showConnectionStatus("Enabling TightVNC protocol extensions");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
422 rfb.setupTunneling();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
423 authType = rfb.negotiateAuthenticationTight();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
424 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
425 authType = secType;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
426 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
427
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
428 switch (authType) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
429 case RfbProto.AuthNone:
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
430 showConnectionStatus("No authentication needed");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
431 rfb.authenticateNone();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
432 break;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
433 case RfbProto.AuthVNC:
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
434 showConnectionStatus("Performing standard VNC authentication");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
435 if (passwordParam != null) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
436 rfb.authenticateVNC(passwordParam);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
437 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
438 String pw = askPassword();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
439 rfb.authenticateVNC(pw);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
440 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
441 break;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
442 default:
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
443 throw new Exception("Unknown authentication scheme " + authType);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
444 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
445 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
446
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
447
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
448 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
449 // Show a message describing the connection status.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
450 // To hide the connection status label, use (msg == null).
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
451 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
452
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
453 void showConnectionStatus(String msg)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
454 {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
455 if (msg == null) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
456 if (vncContainer.isAncestorOf(connStatusLabel)) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
457 vncContainer.remove(connStatusLabel);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
458 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
459 return;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
460 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
461
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
462 System.out.println(msg);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
463
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
464 if (connStatusLabel == null) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
465 connStatusLabel = new Label("Status: " + msg);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
466 connStatusLabel.setFont(new Font("Helvetica", Font.PLAIN, 12));
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
467 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
468 connStatusLabel.setText("Status: " + msg);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
469 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
470
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
471 if (!vncContainer.isAncestorOf(connStatusLabel)) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
472 GridBagConstraints gbc = new GridBagConstraints();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
473 gbc.gridwidth = GridBagConstraints.REMAINDER;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
474 gbc.fill = GridBagConstraints.HORIZONTAL;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
475 gbc.anchor = GridBagConstraints.NORTHWEST;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
476 gbc.weightx = 1.0;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
477 gbc.weighty = 1.0;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
478 gbc.insets = new Insets(20, 30, 20, 30);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
479 gridbag.setConstraints(connStatusLabel, gbc);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
480 vncContainer.add(connStatusLabel);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
481 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
482
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
483 if (inSeparateFrame) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
484 vncFrame.pack();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
485 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
486 validate();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
487 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
488 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
489
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
490
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
491 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
492 // Show an authentication panel.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
493 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
494
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
495 String askPassword() throws Exception
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
496 {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
497 showConnectionStatus(null);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
498
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
499 AuthPanel authPanel = new AuthPanel(this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
500
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
501 GridBagConstraints gbc = new GridBagConstraints();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
502 gbc.gridwidth = GridBagConstraints.REMAINDER;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
503 gbc.anchor = GridBagConstraints.NORTHWEST;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
504 gbc.weightx = 1.0;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
505 gbc.weighty = 1.0;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
506 gbc.ipadx = 100;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
507 gbc.ipady = 50;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
508 gridbag.setConstraints(authPanel, gbc);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
509 vncContainer.add(authPanel);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
510
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
511 if (inSeparateFrame) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
512 vncFrame.pack();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
513 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
514 validate();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
515 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
516
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
517 authPanel.moveFocusToDefaultField();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
518 String pw = authPanel.getPassword();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
519 vncContainer.remove(authPanel);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
520
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
521 return pw;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
522 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
523
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
524
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
525 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
526 // Do the rest of the protocol initialisation.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
527 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
528
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
529 void doProtocolInitialisation() throws IOException
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
530 {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
531 rfb.writeClientInit();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
532 rfb.readServerInit();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
533
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
534 System.out.println("Desktop name is " + rfb.desktopName);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
535 System.out.println("Desktop size is " + rfb.framebufferWidth + " x " +
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
536 rfb.framebufferHeight);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
537
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
538 setEncodings();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
539
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
540 showConnectionStatus(null);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
541 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
542
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
543
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
544 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
545 // Send current encoding list to the RFB server.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
546 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
547
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
548 int[] encodingsSaved;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
549 int nEncodingsSaved;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
550
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
551 void setEncodings() { setEncodings(false); }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
552 void autoSelectEncodings() { setEncodings(true); }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
553
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
554 void setEncodings(boolean autoSelectOnly) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
555 if (options == null || rfb == null || !rfb.inNormalProtocol)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
556 return;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
557
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
558 int preferredEncoding = options.preferredEncoding;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
559 if (preferredEncoding == -1) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
560 long kbitsPerSecond = rfb.kbitsPerSecond();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
561 if (nEncodingsSaved < 1) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
562 // Choose Tight or ZRLE encoding for the very first update.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
563 System.out.println("Using Tight/ZRLE encodings");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
564 preferredEncoding = RfbProto.EncodingTight;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
565 } else if (kbitsPerSecond > 2000 &&
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
566 encodingsSaved[0] != RfbProto.EncodingHextile) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
567 // Switch to Hextile if the connection speed is above 2Mbps.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
568 System.out.println("Throughput " + kbitsPerSecond +
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
569 " kbit/s - changing to Hextile encoding");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
570 preferredEncoding = RfbProto.EncodingHextile;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
571 } else if (kbitsPerSecond < 1000 &&
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
572 encodingsSaved[0] != RfbProto.EncodingTight) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
573 // Switch to Tight/ZRLE if the connection speed is below 1Mbps.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
574 System.out.println("Throughput " + kbitsPerSecond +
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
575 " kbit/s - changing to Tight/ZRLE encodings");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
576 preferredEncoding = RfbProto.EncodingTight;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
577 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
578 // Don't change the encoder.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
579 if (autoSelectOnly)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
580 return;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
581 preferredEncoding = encodingsSaved[0];
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
582 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
583 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
584 // Auto encoder selection is not enabled.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
585 if (autoSelectOnly)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
586 return;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
587 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
588
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
589 int[] encodings = new int[20];
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
590 int nEncodings = 0;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
591
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
592 encodings[nEncodings++] = preferredEncoding;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
593 if (options.useCopyRect) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
594 encodings[nEncodings++] = RfbProto.EncodingCopyRect;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
595 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
596
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
597 if (preferredEncoding != RfbProto.EncodingTight) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
598 encodings[nEncodings++] = RfbProto.EncodingTight;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
599 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
600 if (preferredEncoding != RfbProto.EncodingZRLE) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
601 encodings[nEncodings++] = RfbProto.EncodingZRLE;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
602 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
603 if (preferredEncoding != RfbProto.EncodingHextile) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
604 encodings[nEncodings++] = RfbProto.EncodingHextile;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
605 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
606 if (preferredEncoding != RfbProto.EncodingZlib) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
607 encodings[nEncodings++] = RfbProto.EncodingZlib;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
608 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
609 if (preferredEncoding != RfbProto.EncodingCoRRE) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
610 encodings[nEncodings++] = RfbProto.EncodingCoRRE;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
611 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
612 if (preferredEncoding != RfbProto.EncodingRRE) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
613 encodings[nEncodings++] = RfbProto.EncodingRRE;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
614 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
615
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
616 if (options.compressLevel >= 0 && options.compressLevel <= 9) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
617 encodings[nEncodings++] =
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
618 RfbProto.EncodingCompressLevel0 + options.compressLevel;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
619 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
620 if (options.jpegQuality >= 0 && options.jpegQuality <= 9) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
621 encodings[nEncodings++] =
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
622 RfbProto.EncodingQualityLevel0 + options.jpegQuality;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
623 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
624
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
625 if (options.requestCursorUpdates) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
626 encodings[nEncodings++] = RfbProto.EncodingXCursor;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
627 encodings[nEncodings++] = RfbProto.EncodingRichCursor;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
628 if (!options.ignoreCursorUpdates)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
629 encodings[nEncodings++] = RfbProto.EncodingPointerPos;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
630 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
631
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
632 encodings[nEncodings++] = RfbProto.EncodingLastRect;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
633 encodings[nEncodings++] = RfbProto.EncodingNewFBSize;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
634
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
635 boolean encodingsWereChanged = false;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
636 if (nEncodings != nEncodingsSaved) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
637 encodingsWereChanged = true;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
638 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
639 for (int i = 0; i < nEncodings; i++) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
640 if (encodings[i] != encodingsSaved[i]) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
641 encodingsWereChanged = true;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
642 break;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
643 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
644 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
645 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
646
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
647 if (encodingsWereChanged) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
648 try {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
649 rfb.writeSetEncodings(encodings, nEncodings);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
650 if (vc != null) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
651 vc.softCursorFree();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
652 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
653 } catch (Exception e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
654 e.printStackTrace();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
655 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
656 encodingsSaved = encodings;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
657 nEncodingsSaved = nEncodings;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
658 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
659 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
660
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
661
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
662 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
663 // setCutText() - send the given cut text to the RFB server.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
664 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
665
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
666 void setCutText(String text) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
667 try {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
668 if (rfb != null && rfb.inNormalProtocol) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
669 rfb.writeClientCutText(text);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
670 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
671 } catch (Exception e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
672 e.printStackTrace();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
673 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
674 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
675
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
676
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
677 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
678 // Order change in session recording status. To stop recording, pass
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
679 // null in place of the fname argument.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
680 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
681
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
682 void setRecordingStatus(String fname) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
683 synchronized(recordingSync) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
684 sessionFileName = fname;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
685 recordingStatusChanged = true;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
686 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
687 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
688
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
689 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
690 // Start or stop session recording. Returns true if this method call
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
691 // causes recording of a new session.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
692 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
693
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
694 boolean checkRecordingStatus() throws IOException {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
695 synchronized(recordingSync) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
696 if (recordingStatusChanged) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
697 recordingStatusChanged = false;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
698 if (sessionFileName != null) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
699 startRecording();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
700 return true;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
701 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
702 stopRecording();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
703 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
704 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
705 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
706 return false;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
707 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
708
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
709 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
710 // Start session recording.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
711 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
712
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
713 protected void startRecording() throws IOException {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
714 synchronized(recordingSync) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
715 if (!recordingActive) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
716 // Save settings to restore them after recording the session.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
717 cursorUpdatesDef =
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
718 options.choices[options.cursorUpdatesIndex].getSelectedItem();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
719 eightBitColorsDef =
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
720 options.choices[options.eightBitColorsIndex].getSelectedItem();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
721 // Set options to values suitable for recording.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
722 options.choices[options.cursorUpdatesIndex].select("Disable");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
723 options.choices[options.cursorUpdatesIndex].setEnabled(false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
724 options.setEncodings();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
725 options.choices[options.eightBitColorsIndex].select("No");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
726 options.choices[options.eightBitColorsIndex].setEnabled(false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
727 options.setColorFormat();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
728 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
729 rfb.closeSession();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
730 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
731
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
732 System.out.println("Recording the session in " + sessionFileName);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
733 rfb.startSession(sessionFileName);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
734 recordingActive = true;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
735 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
736 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
737
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
738 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
739 // Stop session recording.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
740 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
741
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
742 protected void stopRecording() throws IOException {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
743 synchronized(recordingSync) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
744 if (recordingActive) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
745 // Restore options.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
746 options.choices[options.cursorUpdatesIndex].select(cursorUpdatesDef);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
747 options.choices[options.cursorUpdatesIndex].setEnabled(true);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
748 options.setEncodings();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
749 options.choices[options.eightBitColorsIndex].select(eightBitColorsDef);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
750 options.choices[options.eightBitColorsIndex].setEnabled(true);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
751 options.setColorFormat();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
752
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
753 rfb.closeSession();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
754 System.out.println("Session recording stopped.");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
755 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
756 sessionFileName = null;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
757 recordingActive = false;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
758 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
759 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
760
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
761
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
762 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
763 // readParameters() - read parameters from the html source or from the
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
764 // command line. On the command line, the arguments are just a sequence of
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
765 // param_name/param_value pairs where the names and values correspond to
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
766 // those expected in the html applet tag source.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
767 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
768
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
769 void readParameters() {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
770 // host = readParameter("HOST", !inAnApplet);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
771 if(mainArgs.length > 0) host = mainArgs[0];
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
772 else host = "hades.cr.ie.u-ryukyu.ac.jp";
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
773 /*
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
774 if (host == null) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
775 host = getCodeBase().getHost();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
776 if (host.equals("")) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
777 fatalError("HOST parameter not specified");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
778 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
779 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
780 */
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
781
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
782 // port = readIntParameter("PORT", 5900);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
783 if(mainArgs.length > 1) port = Integer.parseInt(mainArgs[1]);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
784 else port = 5901;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
785 // Read "ENCPASSWORD" or "PASSWORD" parameter if specified.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
786 readPasswordParameters();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
787
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
788 String str;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
789 if (inAnApplet) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
790 str = readParameter("Open New Window", false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
791 if (str != null && str.equalsIgnoreCase("Yes"))
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
792 inSeparateFrame = true;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
793 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
794
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
795 // "Show Controls" set to "No" disables button panel.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
796 showControls = true;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
797 str = readParameter("Show Controls", false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
798 if (str != null && str.equalsIgnoreCase("No"))
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
799 showControls = false;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
800
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
801 // "Offer Relogin" set to "No" disables "Login again" and "Close
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
802 // window" buttons under error messages in applet mode.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
803 offerRelogin = true;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
804 str = readParameter("Offer Relogin", false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
805 if (str != null && str.equalsIgnoreCase("No"))
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
806 offerRelogin = false;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
807
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
808 // Do we continue showing desktop on remote disconnect?
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
809 showOfflineDesktop = false;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
810 str = readParameter("Show Offline Desktop", false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
811 if (str != null && str.equalsIgnoreCase("Yes"))
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
812 showOfflineDesktop = true;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
813
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
814 // Fine tuning options.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
815 deferScreenUpdates = readIntParameter("Defer screen updates", 20);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
816 deferCursorUpdates = readIntParameter("Defer cursor updates", 10);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
817 deferUpdateRequests = readIntParameter("Defer update requests", 0);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
818
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
819 // Debugging options.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
820 debugStatsExcludeUpdates = readIntParameter("DEBUG_XU", 0);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
821 debugStatsMeasureUpdates = readIntParameter("DEBUG_CU", 0);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
822
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
823 // SocketFactory.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
824 socketFactory = readParameter("SocketFactory", false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
825 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
826
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
827 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
828 // Read password parameters. If an "ENCPASSWORD" parameter is set,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
829 // then decrypt the password into the passwordParam string. Otherwise,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
830 // try to read the "PASSWORD" parameter directly to passwordParam.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
831 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
832
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
833 private void readPasswordParameters() {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
834 String encPasswordParam = readParameter("ENCPASSWORD", false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
835 if (encPasswordParam == null) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
836 passwordParam = readParameter("PASSWORD", false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
837
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
838 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
839 // ENCPASSWORD is hexascii-encoded. Decode.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
840 byte[] pw = {0, 0, 0, 0, 0, 0, 0, 0};
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
841 int len = encPasswordParam.length() / 2;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
842 if (len > 8)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
843 len = 8;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
844 for (int i = 0; i < len; i++) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
845 String hex = encPasswordParam.substring(i*2, i*2+2);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
846 Integer x = new Integer(Integer.parseInt(hex, 16));
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
847 pw[i] = x.byteValue();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
848 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
849 // Decrypt the password.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
850 byte[] key = {23, 82, 107, 6, 35, 78, 88, 7};
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
851 DesCipher des = new DesCipher(key);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
852 des.decrypt(pw, 0, pw, 0);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
853 passwordParam = new String(pw);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
854
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
855 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
856 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
857
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
858 public String readParameter(String name, boolean required) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
859 if (inAnApplet) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
860 String s = getParameter(name);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
861 if ((s == null) && required) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
862 fatalError(name + " parameter not specified");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
863 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
864 return s;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
865 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
866
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
867 for (int i = 0; i < mainArgs.length; i += 2) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
868 if (mainArgs[i].equalsIgnoreCase(name)) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
869 try {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
870 return mainArgs[i+1];
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
871 } catch (Exception e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
872 if (required) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
873 fatalError(name + " parameter not specified");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
874 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
875 return null;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
876 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
877 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
878 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
879 if (required) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
880 fatalError(name + " parameter not specified");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
881 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
882 return null;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
883 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
884
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
885 int readIntParameter(String name, int defaultValue) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
886 String str = readParameter(name, false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
887 int result = defaultValue;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
888 if (str != null) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
889 try {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
890 result = Integer.parseInt(str);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
891 } catch (NumberFormatException e) { }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
892 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
893 return result;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
894 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
895
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
896 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
897 // moveFocusToDesktop() - move keyboard focus either to VncCanvas.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
898 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
899
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
900 void moveFocusToDesktop() {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
901 if (vncContainer != null) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
902 if (vc != null && vncContainer.isAncestorOf(vc))
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
903 vc.requestFocus();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
904 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
905 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
906
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
907 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
908 // disconnect() - close connection to server.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
909 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
910
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
911 synchronized public void disconnect() {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
912 System.out.println("Disconnecting");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
913
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
914 if (vc != null) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
915 double sec = (System.currentTimeMillis() - vc.statStartTime) / 1000.0;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
916 double rate = Math.round(vc.statNumUpdates / sec * 100) / 100.0;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
917 int nRealRects = vc.statNumPixelRects;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
918 int nPseudoRects = vc.statNumTotalRects - vc.statNumPixelRects;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
919 System.out.println("Updates received: " + vc.statNumUpdates + " (" +
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
920 nRealRects + " rectangles + " + nPseudoRects +
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
921 " pseudo), " + rate + " updates/sec");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
922 int numRectsOther = nRealRects - vc.statNumRectsTight
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
923 - vc.statNumRectsZRLE - vc.statNumRectsHextile
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
924 - vc.statNumRectsRaw - vc.statNumRectsCopy;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
925 System.out.println("Rectangles:" +
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
926 " Tight=" + vc.statNumRectsTight +
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
927 "(JPEG=" + vc.statNumRectsTightJPEG +
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
928 ") ZRLE=" + vc.statNumRectsZRLE +
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
929 " Hextile=" + vc.statNumRectsHextile +
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
930 " Raw=" + vc.statNumRectsRaw +
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
931 " CopyRect=" + vc.statNumRectsCopy +
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
932 " other=" + numRectsOther);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
933
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
934 int raw = vc.statNumBytesDecoded;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
935 int compressed = vc.statNumBytesEncoded;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
936 if (compressed > 0) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
937 double ratio = Math.round((double)raw / compressed * 1000) / 1000.0;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
938 System.out.println("Pixel data: " + vc.statNumBytesDecoded +
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
939 " bytes, " + vc.statNumBytesEncoded +
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
940 " compressed, ratio " + ratio);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
941 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
942 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
943
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
944 if (rfb != null && !rfb.closed())
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
945 rfb.close();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
946 options.dispose();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
947 clipboard.dispose();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
948 if (rec != null)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
949 rec.dispose();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
950
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
951 if (inAnApplet) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
952 showMessage("Disconnected");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
953 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
954 System.exit(0);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
955 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
956 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
957
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
958 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
959 // fatalError() - print out a fatal error message.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
960 // FIXME: Do we really need two versions of the fatalError() method?
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
961 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
962
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
963 synchronized public void fatalError(String str) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
964 System.out.println(str);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
965
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
966 if (inAnApplet) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
967 // vncContainer null, applet not inited,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
968 // can not present the error to the user.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
969 Thread.currentThread().stop();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
970 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
971 System.exit(1);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
972 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
973 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
974
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
975 synchronized public void fatalError(String str, Exception e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
976
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
977 if (rfb != null && rfb.closed()) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
978 // Not necessary to show error message if the error was caused
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
979 // by I/O problems after the rfb.close() method call.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
980 System.out.println("RFB thread finished");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
981 return;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
982 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
983
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
984 System.out.println(str);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
985 e.printStackTrace();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
986
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
987 if (rfb != null)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
988 rfb.close();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
989
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
990 if (inAnApplet) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
991 showMessage(str);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
992 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
993 System.exit(1);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
994 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
995 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
996
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
997 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
998 // Show message text and optionally "Relogin" and "Close" buttons.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
999 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1000
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1001 void showMessage(String msg) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1002 vncContainer.removeAll();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1003
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1004 Label errLabel = new Label(msg, Label.CENTER);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1005 errLabel.setFont(new Font("Helvetica", Font.PLAIN, 12));
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1006
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1007 if (offerRelogin) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1008
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1009 Panel gridPanel = new Panel(new GridLayout(0, 1));
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1010 Panel outerPanel = new Panel(new FlowLayout(FlowLayout.LEFT));
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1011 outerPanel.add(gridPanel);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1012 vncContainer.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 16));
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1013 vncContainer.add(outerPanel);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1014 Panel textPanel = new Panel(new FlowLayout(FlowLayout.CENTER));
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1015 textPanel.add(errLabel);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1016 gridPanel.add(textPanel);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1017 gridPanel.add(new ReloginPanel(this));
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1018
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1019 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1020
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1021 vncContainer.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 30));
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1022 vncContainer.add(errLabel);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1023
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1024 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1025
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1026 if (inSeparateFrame) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1027 vncFrame.pack();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1028 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1029 validate();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1030 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1031 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1032
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1033 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1034 // Stop the applet.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1035 // Main applet thread will terminate on first exception
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1036 // after seeing that rfbThread has been set to null.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1037 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1038
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1039 public void stop() {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1040 System.out.println("Stopping applet");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1041 rfbThread = null;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1042 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1043
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1044 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1045 // This method is called before the applet is destroyed.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1046 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1047
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1048 public void destroy() {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1049 System.out.println("Destroying applet");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1050
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1051 vncContainer.removeAll();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1052 options.dispose();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1053 clipboard.dispose();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1054 if (rec != null)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1055 rec.dispose();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1056 if (rfb != null && !rfb.closed())
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1057 rfb.close();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1058 if (inSeparateFrame)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1059 vncFrame.dispose();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1060 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1061
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1062 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1063 // Start/stop receiving mouse events.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1064 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1065
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1066 public void enableInput(boolean enable) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1067 vc.enableInput(enable);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1068 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1069
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1070 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1071 // Close application properly on window close event.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1072 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1073
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1074 public void windowClosing(WindowEvent evt) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1075 System.out.println("Closing window");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1076 if (rfb != null)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1077 disconnect();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1078
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1079 vncContainer.hide();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1080
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1081 if (!inAnApplet) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1082 System.exit(0);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1083 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1084 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1085
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1086 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1087 // Ignore window events we're not interested in.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1088 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1089
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1090 public void windowActivated(WindowEvent evt) {}
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1091 public void windowDeactivated (WindowEvent evt) {}
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1092 public void windowOpened(WindowEvent evt) {}
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1093 public void windowClosed(WindowEvent evt) {}
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1094 public void windowIconified(WindowEvent evt) {}
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1095 public void windowDeiconified(WindowEvent evt) {}
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1096 }