blob: 6cdd386f584e2d8b36a9a3d0911fa45b666b4358 [file] [log] [blame]
Constantin Kaplinsky1215b992008-04-18 09:51:44 +00001//
2// Copyright (C) 2001,2002 HorizonLive.com, Inc. All Rights Reserved.
3// Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
4//
5// This is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This software is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this software; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18// USA.
19//
20
Constantin Kaplinskycf689b32008-04-30 12:50:34 +000021package com.tightvnc.rfbplayer;
wimba.comc23aeb02004-09-16 00:00:00 +000022
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000023import java.awt.*;
24import java.awt.event.*;
25import java.io.*;
26
Constantin Kaplinsky903009e2002-05-20 10:55:47 +000027public class RfbPlayer extends java.applet.Applet
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +000028 implements java.lang.Runnable, WindowListener {
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000029
30 boolean inAnApplet = true;
31 boolean inSeparateFrame = false;
32
wimba.com252eb3b2004-09-21 21:27:54 +000033 /** current applet width */
34 int dispW = 300;
35 /** current applet height */
36 int dispH = 200;
37
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000038 //
39 // main() is called when run as a java program from the command line.
40 // It simply runs the applet inside a newly-created frame.
41 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000042 public static void main(String[] argv) {
Constantin Kaplinsky903009e2002-05-20 10:55:47 +000043 RfbPlayer p = new RfbPlayer();
44 p.mainArgs = argv;
45 p.inAnApplet = false;
46 p.inSeparateFrame = true;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000047
Constantin Kaplinsky903009e2002-05-20 10:55:47 +000048 p.init();
49 p.start();
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000050 }
51
52 String[] mainArgs;
53
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +000054 FbsInputStream fbs;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000055 RfbProto rfb;
56 Thread rfbThread;
57
58 Frame vncFrame;
59 Container vncContainer;
wimba.come8e19102005-02-08 17:15:23 +000060 //ScrollPane desktopScrollPane;
61 LWScrollPane desktopScrollPane;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000062 GridBagLayout gridbag;
63 ButtonPanel buttonPanel;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000064 VncCanvas vc;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000065
Constantin Kaplinsky5d99c952002-05-25 09:49:23 +000066 String sessionURL;
Constantin Kaplinsky5f1f8862008-06-20 05:17:39 +000067 String idxPrefix;
Constantin Kaplinsky972c2572002-05-30 14:19:02 +000068 long initialTimeOffset;
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +000069 double playbackSpeed;
Constantin Kaplinsky5a7133a2002-07-24 17:02:04 +000070 boolean autoPlay;
Constantin Kaplinsky903009e2002-05-20 10:55:47 +000071 boolean showControls;
wimba.comd1f56df2004-11-01 16:18:54 +000072 boolean isQuitting = false;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000073 int deferScreenUpdates;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000074
75 //
76 // init()
77 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000078 public void init() {
79
wimba.comc23aeb02004-09-16 00:00:00 +000080 // LiveConnect work-a-round
81 RfbSharedStatic.refApplet = this;
82
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000083 readParameters();
84
85 if (inSeparateFrame) {
Constantin Kaplinsky903009e2002-05-20 10:55:47 +000086 vncFrame = new Frame("RFB Session Player");
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000087 if (!inAnApplet) {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +000088 vncFrame.add("Center", this);
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000089 }
90 vncContainer = vncFrame;
91 } else {
92 vncContainer = this;
93 }
94
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000095 if (inSeparateFrame)
96 vncFrame.addWindowListener(this);
97
wimba.comd1f56df2004-11-01 16:18:54 +000098 rfbThread = new Thread(this, "RfbThread");
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000099 rfbThread.start();
100 }
101
102 public void update(Graphics g) {
103 }
104
105 //
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000106 // run() - executed by the rfbThread to read RFB data.
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000107 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000108 public void run() {
109
110 gridbag = new GridBagLayout();
111 vncContainer.setLayout(gridbag);
112
113 GridBagConstraints gbc = new GridBagConstraints();
114 gbc.gridwidth = GridBagConstraints.REMAINDER;
115 gbc.anchor = GridBagConstraints.NORTHWEST;
116
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000117 if (showControls) {
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000118 buttonPanel = new ButtonPanel(this);
119 buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
120 gridbag.setConstraints(buttonPanel, gbc);
121 vncContainer.add(buttonPanel);
122 }
123
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000124 if (inSeparateFrame) {
125 vncFrame.pack();
Constantin Kaplinskyaa7b5612008-06-17 09:27:52 +0000126 vncFrame.setVisible(true);
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000127 } else {
128 validate();
129 }
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000130
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000131 try {
Constantin Kaplinsky2859fdc2008-06-19 16:07:52 +0000132 java.applet.Applet applet = (inAnApplet) ? this : null;
Constantin Kaplinsky5f1f8862008-06-20 05:17:39 +0000133 FbsConnection conn = new FbsConnection(sessionURL, idxPrefix, applet);
Constantin Kaplinsky2859fdc2008-06-19 16:07:52 +0000134 fbs = conn.connect(initialTimeOffset);
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000135 rfb = new RfbProto(fbs);
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000136
137 vc = new VncCanvas(this);
138 gbc.weightx = 1.0;
139 gbc.weighty = 1.0;
140
wimba.com252eb3b2004-09-21 21:27:54 +0000141 // Create a panel which itself is resizeable and can hold
142 // non-resizeable VncCanvas component at the top left corner.
wimba.come8e19102005-02-08 17:15:23 +0000143 //Panel canvasPanel = new Panel();
144 //canvasPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
145 //canvasPanel.add(vc);
wimba.com252eb3b2004-09-21 21:27:54 +0000146
147 // Create a ScrollPane which will hold a panel with VncCanvas
148 // inside.
wimba.come8e19102005-02-08 17:15:23 +0000149 //desktopScrollPane = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
150 desktopScrollPane = new LWScrollPane();
wimba.com252eb3b2004-09-21 21:27:54 +0000151 gbc.fill = GridBagConstraints.BOTH;
wimba.come8e19102005-02-08 17:15:23 +0000152 gridbag.setConstraints(vc, gbc);
153 //gridbag.setConstraints(canvasPanel, gbc);
154 desktopScrollPane.addComp(vc);
155 desktopScrollPane.setSize(dispW, dispH);
156 //desktopScrollPane.add(canvasPanel);
wimba.com252eb3b2004-09-21 21:27:54 +0000157
158 // Now add the scroll bar to the container.
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000159 if (inSeparateFrame) {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000160 gridbag.setConstraints(desktopScrollPane, gbc);
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000161 vncFrame.add(desktopScrollPane);
162 vncFrame.setTitle(rfb.desktopName);
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000163 vc.resizeDesktopFrame();
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000164 } else {
wimba.com252eb3b2004-09-21 21:27:54 +0000165 // Size the scroll pane to display size.
166 desktopScrollPane.setSize(dispW, dispH);
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000167
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000168 // Just add the VncCanvas component to the Applet.
wimba.com252eb3b2004-09-21 21:27:54 +0000169 gbc.fill = GridBagConstraints.NONE;
170 gridbag.setConstraints(desktopScrollPane, gbc);
171 add(desktopScrollPane);
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000172 validate();
wimba.com252eb3b2004-09-21 21:27:54 +0000173 vc.resizeEmbeddedApplet();
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000174 }
175
wimba.comd1f56df2004-11-01 16:18:54 +0000176 while (!isQuitting) {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000177 try {
178 setPaused(!autoPlay);
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000179 fbs.setSpeed(playbackSpeed);
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000180 vc.processNormalProtocol();
181 } catch (EOFException e) {
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000182 long newTimeOffset;
Constantin Kaplinsky2c0d2d12008-06-23 13:34:36 +0000183 if (e.getMessage() != null && e.getMessage().equals("[JUMP]")) {
184 // A special type of EOFException allowing us to close FBS stream
185 // and then re-open it for jumping to a different time offset.
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000186 newTimeOffset = fbs.getSeekOffset();
187 autoPlay = !fbs.isPaused();
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000188 } else {
189 // Return to the beginning after the playback is finished.
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000190 newTimeOffset = 0;
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000191 autoPlay = false;
192 }
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000193 fbs.close();
Constantin Kaplinsky2859fdc2008-06-19 16:07:52 +0000194 fbs = conn.connect(newTimeOffset);
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000195 rfb.newSession(fbs);
Constantin Kaplinsky282aaa12002-09-22 11:33:22 +0000196 vc.updateFramebufferSize();
wimba.com30ff9ed2004-11-01 20:54:08 +0000197 } catch (NullPointerException e) {
198 // catching this causes a hang with 1.4.1 JVM's under Win32 IE
199 throw e;
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000200 }
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000201 }
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000202
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000203 } catch (FileNotFoundException e) {
204 fatalError(e.toString());
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000205 } catch (Exception e) {
206 e.printStackTrace();
207 fatalError(e.toString());
208 }
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000209
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000210 }
211
wimba.comb5a90342007-04-02 18:54:41 +0000212 public void setPausedInt(String paused) {
213 // default to true (pause)
214 int pause = 1;
215
216 try {
217 pause = Integer.parseInt(paused);
218 } catch (NumberFormatException e) {
219 }
220
221 if (pause == 0) {
222 setPaused(false);
223 } else {
224 setPaused(true);
225 }
226 }
227
Constantin Kaplinskyac6420d2002-05-29 17:05:39 +0000228 public void setPaused(boolean paused) {
Constantin Kaplinsky972c2572002-05-30 14:19:02 +0000229 if (showControls)
230 buttonPanel.setPaused(paused);
Constantin Kaplinsky37cc43e2002-05-30 17:30:11 +0000231 if (paused) {
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000232 fbs.pausePlayback();
Constantin Kaplinsky37cc43e2002-05-30 17:30:11 +0000233 } else {
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000234 fbs.resumePlayback();
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000235 }
236 }
237
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +0000238 public double getSpeed() {
239 return playbackSpeed;
240 }
241
Constantin Kaplinskyce39d3b2002-05-30 15:54:56 +0000242 public void setSpeed(double speed) {
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +0000243 playbackSpeed = speed;
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000244 fbs.setSpeed(speed);
Constantin Kaplinskyce39d3b2002-05-30 15:54:56 +0000245 }
246
wimba.comc23aeb02004-09-16 00:00:00 +0000247 public void jumpTo(long pos) {
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000248 long diff = Math.abs(pos - fbs.getTimeOffset());
wimba.comc23aeb02004-09-16 00:00:00 +0000249
250 // Current threshold is 5 seconds
251 if (diff > 5000) {
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000252 fbs.pausePlayback();
wimba.comc23aeb02004-09-16 00:00:00 +0000253 setPos(pos);
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000254 fbs.resumePlayback();
wimba.comc23aeb02004-09-16 00:00:00 +0000255 }
256 }
257
Constantin Kaplinskyc833e012002-05-30 17:59:22 +0000258 public void setPos(long pos) {
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000259 fbs.setTimeOffset(pos);
Constantin Kaplinsky30f786a2002-05-29 10:59:52 +0000260 }
261
Constantin Kaplinskyfe079832002-05-29 00:52:32 +0000262 public void updatePos() {
Constantin Kaplinskyaa7b5612008-06-17 09:27:52 +0000263 if (showControls && buttonPanel != null)
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000264 buttonPanel.setPos(fbs.getTimeOffset());
Constantin Kaplinskyfe079832002-05-29 00:52:32 +0000265 }
266
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000267 //
268 // readParameters() - read parameters from the html source or from the
269 // command line. On the command line, the arguments are just a sequence of
270 // param_name/param_value pairs where the names and values correspond to
271 // those expected in the html applet tag source.
272 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000273 public void readParameters() {
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000274
Constantin Kaplinsky5d99c952002-05-25 09:49:23 +0000275 sessionURL = readParameter("URL", true);
Constantin Kaplinsky5f1f8862008-06-20 05:17:39 +0000276 idxPrefix = readParameter("Index", false);
Constantin Kaplinsky5a7133a2002-07-24 17:02:04 +0000277
Constantin Kaplinsky972c2572002-05-30 14:19:02 +0000278 initialTimeOffset = readLongParameter("Position", 0);
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +0000279 if (initialTimeOffset < 0)
280 initialTimeOffset = 0;
Constantin Kaplinsky5a7133a2002-07-24 17:02:04 +0000281
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +0000282 playbackSpeed = readDoubleParameter("Speed", 1.0);
283 if (playbackSpeed <= 0.0)
284 playbackSpeed = 1.0;
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000285
Constantin Kaplinsky5a7133a2002-07-24 17:02:04 +0000286 autoPlay = false;
287 String str = readParameter("Autoplay", false);
288 if (str != null && str.equalsIgnoreCase("Yes"))
289 autoPlay = true;
290
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000291 showControls = true;
wimba.com9bd9c5c2005-09-14 18:42:46 +0000292 str = readParameter("Show_Controls", false);
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000293 if (str != null && str.equalsIgnoreCase("No"))
294 showControls = false;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000295
296 if (inAnApplet) {
wimba.com9bd9c5c2005-09-14 18:42:46 +0000297 str = readParameter("Open_New_Window", false);
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000298 if (str != null && str.equalsIgnoreCase("Yes"))
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000299 inSeparateFrame = true;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000300 }
301
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000302 // Fine tuning options.
wimba.com9bd9c5c2005-09-14 18:42:46 +0000303 deferScreenUpdates = (int)readLongParameter("Defer_screen_updates", 20);
Constantin Kaplinsky972c2572002-05-30 14:19:02 +0000304 if (deferScreenUpdates < 0)
305 deferScreenUpdates = 0; // Just in case.
wimba.com252eb3b2004-09-21 21:27:54 +0000306
307 // Display width and height.
308 dispW = readIntParameter("DISPLAY_WIDTH", dispW);
309 dispH = readIntParameter("DISPLAY_HEIGHT", dispH);
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000310 }
311
312 public String readParameter(String name, boolean required) {
313 if (inAnApplet) {
314 String s = getParameter(name);
315 if ((s == null) && required) {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000316 fatalError(name + " parameter not specified");
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000317 }
318 return s;
319 }
320
321 for (int i = 0; i < mainArgs.length; i += 2) {
322 if (mainArgs[i].equalsIgnoreCase(name)) {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000323 try {
324 return mainArgs[i + 1];
325 } catch (Exception e) {
326 if (required) {
327 fatalError(name + " parameter not specified");
328 }
329 return null;
330 }
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000331 }
332 }
333 if (required) {
334 fatalError(name + " parameter not specified");
335 }
336 return null;
337 }
338
Constantin Kaplinsky972c2572002-05-30 14:19:02 +0000339 long readLongParameter(String name, long defaultValue) {
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000340 String str = readParameter(name, false);
Constantin Kaplinsky972c2572002-05-30 14:19:02 +0000341 long result = defaultValue;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000342 if (str != null) {
343 try {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000344 result = Long.parseLong(str);
345 } catch (NumberFormatException e) {
346 }
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000347 }
348 return result;
349 }
350
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +0000351 double readDoubleParameter(String name, double defaultValue) {
352 String str = readParameter(name, false);
353 double result = defaultValue;
354 if (str != null) {
355 try {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000356 result = Double.valueOf(str).doubleValue();
357 } catch (NumberFormatException e) {
358 }
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +0000359 }
360 return result;
361 }
362
wimba.com252eb3b2004-09-21 21:27:54 +0000363 int readIntParameter(String name, int defaultValue) {
364 String str = readParameter(name, false);
365 int result = defaultValue;
366 if (str != null) {
367 try {
368 result = Integer.parseInt(str);
369 } catch (NumberFormatException e) {
370 }
371 }
372 return result;
373 }
374
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000375 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000376 // fatalError() - print out a fatal error message.
377 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000378 public void fatalError(String str) {
Constantin Kaplinsky64446a82008-06-20 06:51:32 +0000379 System.err.println(str);
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000380
381 if (inAnApplet) {
382 vncContainer.removeAll();
383 if (rfb != null) {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000384 rfb = null;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000385 }
386 Label errLabel = new Label(str);
387 errLabel.setFont(new Font("Helvetica", Font.PLAIN, 12));
388 vncContainer.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 30));
389 vncContainer.add(errLabel);
390 if (inSeparateFrame) {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000391 vncFrame.pack();
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000392 } else {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000393 validate();
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000394 }
395 Thread.currentThread().stop();
396 } else {
397 System.exit(1);
398 }
399 }
400
401
402 //
403 // This method is called before the applet is destroyed.
404 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000405 public void destroy() {
wimba.comd1f56df2004-11-01 16:18:54 +0000406 isQuitting = true;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000407 vncContainer.removeAll();
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000408 if (fbs != null) {
409 fbs.quit();
410 try {
411 fbs.close();
412 } catch (IOException e) {
413 }
wimba.comd1f56df2004-11-01 16:18:54 +0000414 }
415 try {
416 rfbThread.join();
417 } catch (InterruptedException e) {
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000418 }
419 if (inSeparateFrame) {
wimba.com30ff9ed2004-11-01 20:54:08 +0000420 vncFrame.removeWindowListener(this);
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000421 vncFrame.dispose();
422 }
423 }
424
wimba.com252eb3b2004-09-21 21:27:54 +0000425 //
426 // Set the new width and height of the applet. Call when browser is resized to
427 // resize the viewer.
428 //
429 public void displaySize(int width, int height) {
430 dispW = width;
431 dispH = height;
432 if (!inSeparateFrame) {
433 vc.resizeEmbeddedApplet();
434 }
435 }
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000436
437 //
438 // Close application properly on window close event.
439 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000440 public void windowClosing(WindowEvent evt) {
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000441 vncContainer.removeAll();
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000442 if (rfb != null)
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000443 rfb = null;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000444
445 vncFrame.dispose();
446 if (!inAnApplet) {
447 System.exit(0);
448 }
449 }
450
451 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000452 // Ignore window events we're not interested in.
453 //
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000454 public void windowActivated(WindowEvent evt) {
455 }
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000456
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000457 public void windowDeactivated(WindowEvent evt) {
458 }
459
460 public void windowOpened(WindowEvent evt) {
461 }
462
463 public void windowClosed(WindowEvent evt) {
464 }
465
466 public void windowIconified(WindowEvent evt) {
467 }
468
469 public void windowDeiconified(WindowEvent evt) {
470 }
471
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000472}