annotate src/viewer_swing/java/com/glavsoft/viewer/CuiViewer.java @ 202:22676ca0dd97

get VNC Socket.
author oc
date Fri, 27 Jun 2014 19:21:18 +0900
parents aa00e4b2fc27
children d9d234715853
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
65
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 package com.glavsoft.viewer;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 import com.glavsoft.rfb.protocol.ProtocolSettings;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 import com.glavsoft.viewer.cli.Parser;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 import com.glavsoft.viewer.swing.ConnectionParams;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 import com.glavsoft.viewer.swing.ParametersHandler;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 import com.glavsoft.viewer.swing.SwingConnectionWorkerFactory;
130
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
8
65
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 import javax.swing.*;
130
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
10
65
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 import java.awt.*;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 import java.awt.event.WindowEvent;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 import java.awt.event.WindowListener;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 import java.io.IOException;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 import java.io.InputStream;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 import java.net.Socket;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 import java.util.jar.Attributes;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 import java.util.jar.Manifest;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 import java.util.logging.*;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 import jp.ac.u_ryukyu.treevnc.CreateConnectionParam;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 import jp.ac.u_ryukyu.treevnc.MyRfbProto;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 import jp.ac.u_ryukyu.treevnc.client.MyRfbProtoClient;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
153
e68dfd1972ac fix bad names.
oc
parents: 148
diff changeset
25 public class CuiViewer implements Runnable, WindowListener, ViewerInterface {
65
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 private Logger logger;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 private int paramsMask;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 private boolean allowAppletInteractiveConnections;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 public final ConnectionParams connectionParams;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 protected String passwordFromParams;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 boolean isSeparateFrame = true;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 protected boolean isApplet = true;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 private final ProtocolSettings settings;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 protected UiSettings uiSettings;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 private ConnectionPresenter connectionPresenter;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 protected MyRfbProto myRfb;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 private boolean cuiVersion;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 public static void main(String[] args) {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 Parser parser = new Parser();
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 ParametersHandler.completeParserOptions(parser);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 parser.parse(args);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 if (parser.isSet(ParametersHandler.ARG_HELP)) {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 printUsage(parser.optionsUsage());
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 System.exit(0);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 CuiViewer viewer = new CuiViewer(parser);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 SwingUtilities.invokeLater(viewer);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 public static void printUsage(String additional) {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 System.out
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 .println("Usage: java -jar (progfilename) [hostname [port_number]] [Options]?n"
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 + " or?n"
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 + " java -jar (progfilename) [Options]?n"
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 + " or?n java -jar (progfilename) -help?n to view this help?n?n"
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 + "Where Options are:?n"
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 + additional
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 + "?nOptions format: -optionName=optionValue. Ex. -host=localhost -port=5900 -viewonly=yes?n"
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 + "Both option name and option value are case insensitive.");
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 public CuiViewer() {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 logger = Logger.getLogger(getClass().getName());
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 connectionParams = new ConnectionParams();
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 settings = ProtocolSettings.getDefaultSettings();
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 uiSettings = new UiSettings();
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 private CuiViewer(Parser parser) {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 this();
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 setLoggingLevel(parser.isSet(ParametersHandler.ARG_VERBOSE) ? Level.FINE
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 : parser.isSet(ParametersHandler.ARG_VERBOSE_MORE) ? Level.FINER
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 : Level.INFO);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 paramsMask = ParametersHandler.completeSettingsFromCLI(parser,
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 connectionParams, settings, uiSettings);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 passwordFromParams = parser.getValueFor(ParametersHandler.ARG_PASSWORD);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 logger.info("TightVNC Viewer version " + ver());
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 isApplet = false;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 private void setLoggingLevel(Level levelToSet) {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 final Logger appLogger = Logger.getLogger("com.glavsoft");
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 appLogger.setLevel(levelToSet);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 ConsoleHandler ch = null;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 for (Handler h : appLogger.getHandlers()) {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 if (h instanceof ConsoleHandler) {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 ch = (ConsoleHandler) h;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 break;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 if (null == ch) {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 ch = new ConsoleHandler();
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 appLogger.addHandler(ch);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 // ch.setFormatter(new SimpleFormatter());
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 ch.setLevel(levelToSet);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 @Override
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 public void windowClosing(WindowEvent e) {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 if (e != null && e.getComponent() != null) {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 final Window w = e.getWindow();
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 if (w != null) {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 w.setVisible(false);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 w.dispose();
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 closeApp();
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 /**
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 * Closes App(lication) or stops App(let).
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 */
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 public void closeApp() {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 /* nop */
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 private boolean checkJsch() {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 try {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 Class.forName("com.jcraft.jsch.JSch");
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 return true;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 } catch (ClassNotFoundException e) {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 return false;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 @Override
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 public void run() {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 final boolean hasJsch = checkJsch();
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 final boolean allowInteractive = allowAppletInteractiveConnections
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 || !isApplet;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 connectionPresenter = new ConnectionPresenter(hasJsch, allowInteractive);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 connectionPresenter.addModel("ConnectionParamsModel", connectionParams);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 /*
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 * SwingViewerWindowFactory viewerWindowFactory = new
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 * SwingViewerWindowFactory( isSeparateFrame, isApplet, this);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 *
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 * connectionPresenter.setConnectionWorkerFactory(new
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 * SwingConnectionWorkerFactory( connectionView.getFrame(),
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 * passwordFromParams, connectionPresenter, viewerWindowFactory,
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 * myRfb));
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 */
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 connectionPresenter.setConnectionWorkerFactory(
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 new SwingConnectionWorkerFactory(null, passwordFromParams, connectionPresenter, null, myRfb));
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 connectionPresenter.setCuiVersion(true);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 connectionPresenter.startConnection(settings, uiSettings, paramsMask);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 @Override
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 public void windowOpened(WindowEvent e) { /* nop */
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 @Override
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 public void windowClosed(WindowEvent e) { /* nop */
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 @Override
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 public void windowIconified(WindowEvent e) { /* nop */
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 @Override
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 public void windowDeiconified(WindowEvent e) { /* nop */
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 @Override
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 public void windowActivated(WindowEvent e) { /* nop */
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
177
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 @Override
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 public void windowDeactivated(WindowEvent e) { /* nop */
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 public static String ver() {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 final InputStream mfStream = Viewer.class.getClassLoader()
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 .getResourceAsStream("META-INF/MANIFEST.MF");
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 if (null == mfStream) {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 System.out.println("No Manifest file found.");
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 return "-1";
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 try {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 Manifest mf = new Manifest();
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 mf.read(mfStream);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 Attributes atts = mf.getMainAttributes();
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 return atts.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 } catch (IOException e) {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 return "-2";
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 public void setSocket(Socket soc) {
179
c1b91dd27a13 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
200 connectionParams.setConnectionParam(soc.getInetAddress().getHostAddress(), soc.getPort());
65
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
202
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 public void setOpenPort(int parseInt) {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
205
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 public void setTeminationType(boolean b) {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 myRfb.setTerminationType(b);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
209
148
8d01028906c4 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
210 public void startTreeViewer(String hostName, boolean cui) {
65
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 CuiViewer viewer = new CuiViewer();
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 viewer.cuiVersion = cui;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 MyRfbProtoClient rfb = new MyRfbProtoClient();
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
214 CreateConnectionParam cp = new CreateConnectionParam(rfb);
177
8019a393875a proxy reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
215 if (hostName==null) {
8019a393875a proxy reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
216 try {
8019a393875a proxy reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
217 cp.findTreeVncRoot();
8019a393875a proxy reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
218 } catch (InterruptedException e) {
8019a393875a proxy reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
219 }
8019a393875a proxy reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
220 } else {
8019a393875a proxy reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
221 cp.setHostName(hostName);
8019a393875a proxy reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
222 }
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
223 rfb.createConnectionAndStart(this);
177
8019a393875a proxy reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
224 cp.sendWhereToConnect(viewer);
65
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 rfb.setViewer(viewer);
177
8019a393875a proxy reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
226 rfb.setCuiVersion(cui);
65
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 viewer.myRfb = rfb;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 SwingUtilities.invokeLater(viewer);
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
230
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
231 public void setIsTreeVNC(boolean flag) {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
233
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 public MyRfbProto getRfb() {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 return myRfb;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 }
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 public boolean getCuiVersion() {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 return cuiVersion;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 }
68
e6550afe663b delete video feedback.
one
parents: 65
diff changeset
241
e6550afe663b delete video feedback.
one
parents: 65
diff changeset
242 public void setCuiVersion(boolean flag) {
e6550afe663b delete video feedback.
one
parents: 65
diff changeset
243 // nop
e6550afe663b delete video feedback.
one
parents: 65
diff changeset
244 }
130
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
245
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
246 @Override
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
247 public void connectToParenet(int port, String hostname) throws IOException {
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
248 setTeminationType(false);
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
249 closeApp();
179
c1b91dd27a13 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
250 connectionParams.setConnectionParam(hostname, port);
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
251 run();
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
252 }
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
253
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
254 @Override
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
255 public void inhelitClients(ViewerInterface vncProxyService, String hostName) {
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
256
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
257 }
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
258
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
259 @Override
188
f176bffcdc4a add showTreeNode option.
oc
parents: 179
diff changeset
260 public void proxyStart(String[] args, int width, int height, boolean showTree) {
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
261
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
262 }
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
263
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
264 @Override
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
265 public void setNoConnection(boolean noConnection) {
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
266
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
267 }
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
268
192
aa00e4b2fc27 fix root viewer.
oc
parents: 188
diff changeset
269 @Override
aa00e4b2fc27 fix root viewer.
oc
parents: 188
diff changeset
270 public void setVisible(boolean b) {
aa00e4b2fc27 fix root viewer.
oc
parents: 188
diff changeset
271 }
aa00e4b2fc27 fix root viewer.
oc
parents: 188
diff changeset
272
202
22676ca0dd97 get VNC Socket.
oc
parents: 192
diff changeset
273 @Override
22676ca0dd97 get VNC Socket.
oc
parents: 192
diff changeset
274 public Socket getVNCSocket() {
22676ca0dd97 get VNC Socket.
oc
parents: 192
diff changeset
275 return connectionPresenter.getSocket();
22676ca0dd97 get VNC Socket.
oc
parents: 192
diff changeset
276 }
22676ca0dd97 get VNC Socket.
oc
parents: 192
diff changeset
277
65
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 }