annotate src/treeVnc/VncProxyService.java @ 15:578ea14c95e9

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