blob: 85d067d123cb90e646bc874d3accfe7de82d8c80 [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 Kaplinsky72e47ef2008-04-18 17:48:16 +0000183 if (e.getMessage() != null && e.getMessage().equals("[REWIND]")) {
184 // A special type of EOFException allowing us to seek backwards.
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000185 newTimeOffset = fbs.getSeekOffset();
186 autoPlay = !fbs.isPaused();
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000187 } else {
188 // Return to the beginning after the playback is finished.
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000189 newTimeOffset = 0;
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000190 autoPlay = false;
191 }
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000192 fbs.close();
Constantin Kaplinsky2859fdc2008-06-19 16:07:52 +0000193 fbs = conn.connect(newTimeOffset);
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000194 rfb.newSession(fbs);
Constantin Kaplinsky282aaa12002-09-22 11:33:22 +0000195 vc.updateFramebufferSize();
wimba.com30ff9ed2004-11-01 20:54:08 +0000196 } catch (NullPointerException e) {
197 // catching this causes a hang with 1.4.1 JVM's under Win32 IE
198 throw e;
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000199 }
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000200 }
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000201
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000202 } catch (FileNotFoundException e) {
203 fatalError(e.toString());
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000204 } catch (Exception e) {
205 e.printStackTrace();
206 fatalError(e.toString());
207 }
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000208
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000209 }
210
wimba.comb5a90342007-04-02 18:54:41 +0000211 public void setPausedInt(String paused) {
212 // default to true (pause)
213 int pause = 1;
214
215 try {
216 pause = Integer.parseInt(paused);
217 } catch (NumberFormatException e) {
218 }
219
220 if (pause == 0) {
221 setPaused(false);
222 } else {
223 setPaused(true);
224 }
225 }
226
Constantin Kaplinskyac6420d2002-05-29 17:05:39 +0000227 public void setPaused(boolean paused) {
Constantin Kaplinsky972c2572002-05-30 14:19:02 +0000228 if (showControls)
229 buttonPanel.setPaused(paused);
Constantin Kaplinsky37cc43e2002-05-30 17:30:11 +0000230 if (paused) {
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000231 fbs.pausePlayback();
Constantin Kaplinsky37cc43e2002-05-30 17:30:11 +0000232 } else {
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000233 fbs.resumePlayback();
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000234 }
235 }
236
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +0000237 public double getSpeed() {
238 return playbackSpeed;
239 }
240
Constantin Kaplinskyce39d3b2002-05-30 15:54:56 +0000241 public void setSpeed(double speed) {
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +0000242 playbackSpeed = speed;
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000243 fbs.setSpeed(speed);
Constantin Kaplinskyce39d3b2002-05-30 15:54:56 +0000244 }
245
wimba.comc23aeb02004-09-16 00:00:00 +0000246 public void jumpTo(long pos) {
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000247 long diff = Math.abs(pos - fbs.getTimeOffset());
wimba.comc23aeb02004-09-16 00:00:00 +0000248
249 // Current threshold is 5 seconds
250 if (diff > 5000) {
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000251 fbs.pausePlayback();
wimba.comc23aeb02004-09-16 00:00:00 +0000252 setPos(pos);
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000253 fbs.resumePlayback();
wimba.comc23aeb02004-09-16 00:00:00 +0000254 }
255 }
256
Constantin Kaplinskyc833e012002-05-30 17:59:22 +0000257 public void setPos(long pos) {
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000258 fbs.setTimeOffset(pos);
Constantin Kaplinsky30f786a2002-05-29 10:59:52 +0000259 }
260
Constantin Kaplinskyfe079832002-05-29 00:52:32 +0000261 public void updatePos() {
Constantin Kaplinskyaa7b5612008-06-17 09:27:52 +0000262 if (showControls && buttonPanel != null)
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000263 buttonPanel.setPos(fbs.getTimeOffset());
Constantin Kaplinskyfe079832002-05-29 00:52:32 +0000264 }
265
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000266 //
267 // readParameters() - read parameters from the html source or from the
268 // command line. On the command line, the arguments are just a sequence of
269 // param_name/param_value pairs where the names and values correspond to
270 // those expected in the html applet tag source.
271 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000272 public void readParameters() {
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000273
Constantin Kaplinsky5d99c952002-05-25 09:49:23 +0000274 sessionURL = readParameter("URL", true);
Constantin Kaplinsky5f1f8862008-06-20 05:17:39 +0000275 idxPrefix = readParameter("Index", false);
Constantin Kaplinsky5a7133a2002-07-24 17:02:04 +0000276
Constantin Kaplinsky972c2572002-05-30 14:19:02 +0000277 initialTimeOffset = readLongParameter("Position", 0);
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +0000278 if (initialTimeOffset < 0)
279 initialTimeOffset = 0;
Constantin Kaplinsky5a7133a2002-07-24 17:02:04 +0000280
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +0000281 playbackSpeed = readDoubleParameter("Speed", 1.0);
282 if (playbackSpeed <= 0.0)
283 playbackSpeed = 1.0;
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000284
Constantin Kaplinsky5a7133a2002-07-24 17:02:04 +0000285 autoPlay = false;
286 String str = readParameter("Autoplay", false);
287 if (str != null && str.equalsIgnoreCase("Yes"))
288 autoPlay = true;
289
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000290 showControls = true;
wimba.com9bd9c5c2005-09-14 18:42:46 +0000291 str = readParameter("Show_Controls", false);
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000292 if (str != null && str.equalsIgnoreCase("No"))
293 showControls = false;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000294
295 if (inAnApplet) {
wimba.com9bd9c5c2005-09-14 18:42:46 +0000296 str = readParameter("Open_New_Window", false);
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000297 if (str != null && str.equalsIgnoreCase("Yes"))
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000298 inSeparateFrame = true;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000299 }
300
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000301 // Fine tuning options.
wimba.com9bd9c5c2005-09-14 18:42:46 +0000302 deferScreenUpdates = (int)readLongParameter("Defer_screen_updates", 20);
Constantin Kaplinsky972c2572002-05-30 14:19:02 +0000303 if (deferScreenUpdates < 0)
304 deferScreenUpdates = 0; // Just in case.
wimba.com252eb3b2004-09-21 21:27:54 +0000305
306 // Display width and height.
307 dispW = readIntParameter("DISPLAY_WIDTH", dispW);
308 dispH = readIntParameter("DISPLAY_HEIGHT", dispH);
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000309 }
310
311 public String readParameter(String name, boolean required) {
312 if (inAnApplet) {
313 String s = getParameter(name);
314 if ((s == null) && required) {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000315 fatalError(name + " parameter not specified");
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000316 }
317 return s;
318 }
319
320 for (int i = 0; i < mainArgs.length; i += 2) {
321 if (mainArgs[i].equalsIgnoreCase(name)) {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000322 try {
323 return mainArgs[i + 1];
324 } catch (Exception e) {
325 if (required) {
326 fatalError(name + " parameter not specified");
327 }
328 return null;
329 }
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000330 }
331 }
332 if (required) {
333 fatalError(name + " parameter not specified");
334 }
335 return null;
336 }
337
Constantin Kaplinsky972c2572002-05-30 14:19:02 +0000338 long readLongParameter(String name, long defaultValue) {
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000339 String str = readParameter(name, false);
Constantin Kaplinsky972c2572002-05-30 14:19:02 +0000340 long result = defaultValue;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000341 if (str != null) {
342 try {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000343 result = Long.parseLong(str);
344 } catch (NumberFormatException e) {
345 }
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000346 }
347 return result;
348 }
349
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +0000350 double readDoubleParameter(String name, double defaultValue) {
351 String str = readParameter(name, false);
352 double result = defaultValue;
353 if (str != null) {
354 try {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000355 result = Double.valueOf(str).doubleValue();
356 } catch (NumberFormatException e) {
357 }
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +0000358 }
359 return result;
360 }
361
wimba.com252eb3b2004-09-21 21:27:54 +0000362 int readIntParameter(String name, int defaultValue) {
363 String str = readParameter(name, false);
364 int result = defaultValue;
365 if (str != null) {
366 try {
367 result = Integer.parseInt(str);
368 } catch (NumberFormatException e) {
369 }
370 }
371 return result;
372 }
373
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000374 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000375 // fatalError() - print out a fatal error message.
376 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000377 public void fatalError(String str) {
Constantin Kaplinsky64446a82008-06-20 06:51:32 +0000378 System.err.println(str);
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000379
380 if (inAnApplet) {
381 vncContainer.removeAll();
382 if (rfb != null) {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000383 rfb = null;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000384 }
385 Label errLabel = new Label(str);
386 errLabel.setFont(new Font("Helvetica", Font.PLAIN, 12));
387 vncContainer.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 30));
388 vncContainer.add(errLabel);
389 if (inSeparateFrame) {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000390 vncFrame.pack();
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000391 } else {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000392 validate();
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000393 }
394 Thread.currentThread().stop();
395 } else {
396 System.exit(1);
397 }
398 }
399
400
401 //
402 // This method is called before the applet is destroyed.
403 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000404 public void destroy() {
wimba.comd1f56df2004-11-01 16:18:54 +0000405 isQuitting = true;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000406 vncContainer.removeAll();
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000407 if (fbs != null) {
408 fbs.quit();
409 try {
410 fbs.close();
411 } catch (IOException e) {
412 }
wimba.comd1f56df2004-11-01 16:18:54 +0000413 }
414 try {
415 rfbThread.join();
416 } catch (InterruptedException e) {
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000417 }
418 if (inSeparateFrame) {
wimba.com30ff9ed2004-11-01 20:54:08 +0000419 vncFrame.removeWindowListener(this);
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000420 vncFrame.dispose();
421 }
422 }
423
wimba.com252eb3b2004-09-21 21:27:54 +0000424 //
425 // Set the new width and height of the applet. Call when browser is resized to
426 // resize the viewer.
427 //
428 public void displaySize(int width, int height) {
429 dispW = width;
430 dispH = height;
431 if (!inSeparateFrame) {
432 vc.resizeEmbeddedApplet();
433 }
434 }
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000435
436 //
437 // Close application properly on window close event.
438 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000439 public void windowClosing(WindowEvent evt) {
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000440 vncContainer.removeAll();
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000441 if (rfb != null)
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000442 rfb = null;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000443
444 vncFrame.dispose();
445 if (!inAnApplet) {
446 System.exit(0);
447 }
448 }
449
450 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000451 // Ignore window events we're not interested in.
452 //
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000453 public void windowActivated(WindowEvent evt) {
454 }
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000455
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000456 public void windowDeactivated(WindowEvent evt) {
457 }
458
459 public void windowOpened(WindowEvent evt) {
460 }
461
462 public void windowClosed(WindowEvent evt) {
463 }
464
465 public void windowIconified(WindowEvent evt) {
466 }
467
468 public void windowDeiconified(WindowEvent evt) {
469 }
470
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000471}