1 // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
2 // Jad home page: http://www.kpdus.com/jad.html
3 // Decompiler options: packimports(3) fieldsfirst nonlb space
7 import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
11 import java.util.LinkedList;
12 import java.util.StringTokenizer;
15 // Referenced classes of package mcsClient:
16 // McsTargetSize, McsVersion, LockingKeyStateManager, McsTcpConnection,
17 // LiveVideoPanel, McsKeyAdapter, McsMouseAdapter, McsMouseMotionAdapter,
18 // DatagramReader, McsToolBar, MessageReader, KeepAlive
20 public class McsClient extends JPanel/*Applet*/ {
22 public Container getContentPane() { return this; }
25 private String _userid;
28 public McsClient(String host, String userid, String ac, boolean enc) {
31 this._userid = userid;
35 public String getParameter(String key) {
36 if (key.equals("bluescreen")) return "false";
37 if (key.equals("ac")) return _ac;
38 if (key.equals("userid")) return _userid;
39 if (key.equals("host")) return _host;
40 if (key.equals("enc")) return _enc ? "on" : "off";
41 throw new RuntimeException("unknown key \""+key+"\"");
44 static void go(String host, String user, String password) throws Exception {
45 JFrame jf = new JFrame();
46 McsClient mcs = new McsClient(host, user, password, false);
48 jf.setSize(1200,1000);
51 jf.setSize(1200,1000);
57 // Changes appear above this line //////////////////////////////////////////////////////////////////////////////
59 private static final int FIXED_SIZE = 1;
60 private static final int FULL_SCREEN = 2;
61 private static final int SCROLL_SCREEN = 3;
62 private static final int DEFAULT_REMOTE_PORT = 2000;
63 private static final Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
64 private static final Dimension maxTargetSize = new Dimension(1024, 768);
65 private static int screenWidth;
66 private static int screenHeight;
67 private McsTargetSize mcsTargetSize;
68 private LinkedList datagramList;
69 private McsVersion mcsVersion;
70 private LockingKeyStateManager lockingKeyStateManager;
71 private McsTcpConnection mcsTcpConnection;
72 private McsKeyAdapter mcsKeyAdapter;
73 private LiveVideoPanel liveVideoPanel;
74 private McsMouseAdapter mcsMouseAdapter;
75 private McsMouseMotionAdapter mcsMouseMotionAdapter;
76 private DatagramReader datagramReader;
77 private MessageReader messageReader;
78 private KeepAlive keepAlive;
79 private boolean isStandalone;
80 private ThreadGroup threadGroup;
81 private static final String START = "Show Remote Console";
82 private static final String STOP = "Hide Remote Console";
83 private JButton button;
84 private static final boolean TCP = false;
85 private boolean blueScreenDump;
86 private boolean encryptVideo;
89 mcsTargetSize = new McsTargetSize(1024, 768);
90 datagramList = new LinkedList();
91 mcsVersion = new McsVersion();
92 lockingKeyStateManager = new LockingKeyStateManager();
94 blueScreenDump = false;
100 UIManager.setLookAndFeel(new WindowsLookAndFeel());
102 catch (Exception exception) { }
103 System.out.println("MCS v.3.6 initialized");
104 isStandalone = false;
105 String s = getParameter("host");
108 s = getCodeBase().getHost();
111 String s2 = getParameter("bluescreen");
112 if (s2 != null && s2.equalsIgnoreCase("true"))
113 blueScreenDump = true;
114 String s3 = getParameter("userid");
118 String s5 = getParameter("enc");
119 if (s5 != null && s5.equalsIgnoreCase("on"))
121 String s6 = getParameter("ac");
125 getContentPane().setBackground(Color.WHITE);
126 begin(s1, s4, s7, false);
130 System.out.println("Stopping applet");
131 if (threadGroup != null)
132 threadGroup.interrupt();
133 if (mcsTcpConnection != null) {
134 mcsTcpConnection.close();
135 mcsTcpConnection = null;
139 public void begin(String s, String s1, String s2, boolean flag) {
141 StringTokenizer stringtokenizer = new StringTokenizer(s, ":");
142 String s3 = stringtokenizer.nextToken();
143 if (stringtokenizer.hasMoreTokens())
145 i = Integer.parseInt(stringtokenizer.nextToken());
147 catch (NumberFormatException numberformatexception) {
150 mcsTcpConnection = new McsTcpConnection(s3, i, encryptVideo, s2);
151 if (!mcsTcpConnection.connected()) {
157 sendUsernameToServer(s1, s2);
158 liveVideoPanel = new LiveVideoPanel(mcsTcpConnection, datagramList, mcsTargetSize, lockingKeyStateManager);
159 mcsKeyAdapter = new McsKeyAdapter(mcsTcpConnection, lockingKeyStateManager);
160 mcsMouseAdapter = new McsMouseAdapter(mcsTcpConnection, liveVideoPanel);
161 mcsMouseMotionAdapter = new McsMouseMotionAdapter(mcsTcpConnection, mcsKeyAdapter);
162 if (!blueScreenDump) {
163 liveVideoPanel.addMouseListener(mcsMouseAdapter);
164 liveVideoPanel.addMouseMotionListener(mcsMouseMotionAdapter);
165 liveVideoPanel.addKeyListener(mcsKeyAdapter);
166 liveVideoPanel.addMouseWheelListener(mcsMouseAdapter);
168 liveVideoPanel.setPreferredSize(maxTargetSize);
169 liveVideoPanel.setFocusTraversalKeysEnabled(false);
170 datagramReader = new DatagramReader(mcsTcpConnection, liveVideoPanel, datagramList, s3, i, flag);
171 if (!blueScreenDump) {
172 McsToolBar mcstoolbar = new McsToolBar(mcsKeyAdapter, liveVideoPanel);
173 mcstoolbar.setFloatable(false);
174 mcstoolbar.setVisible(false);
175 McsToolBar mcstoolbar1 = new McsToolBar(s3, mcsKeyAdapter, liveVideoPanel, datagramReader, mcstoolbar);
176 getContentPane().add(mcstoolbar1, "North");
177 getContentPane().add(mcstoolbar, "West");
179 getContentPane().add(liveVideoPanel);
180 liveVideoPanel.requestFocusInWindow();
181 if (!datagramReader.initialized()) {
187 messageReader = new MessageReader(mcsTcpConnection, mcsVersion, lockingKeyStateManager);
188 keepAlive = new KeepAlive(mcsTcpConnection, blueScreenDump);
189 threadGroup = new ThreadGroup("MCS Threads");
190 threadGroup.setDaemon(true);
191 (new Thread(threadGroup, liveVideoPanel, "liveVideoPanel thread")).start();
192 Thread thread = new Thread(threadGroup, datagramReader, "datagramReader thread");
193 thread.setPriority(thread.getPriority() + 2);
195 Thread thread1 = new Thread(threadGroup, messageReader, "messageReader thread");
197 thread1.setPriority(thread1.getPriority() + 2);
199 Thread thread2 = new Thread(threadGroup, keepAlive, "keepAlive thread");
200 thread2.setPriority(thread2.getPriority() + 2);
202 sendVersionToServer();
203 System.out.println("Command KVM Server to start sending images");
204 sendStartSendingToServer(mcsTcpConnection.getDetectedPPP());
207 private void sendUsernameToServer(String s, String s1) {
210 char ac[] = (s + ":" + s1).toCharArray();
211 int ai[] = new int[2 + ac.length];
212 ai[0] = ai.length * 4;
214 for (int i = 0; i < ac.length; i++)
218 mcsTcpConnection.sendMessage(ai);
220 catch (IOException ioexception) {
221 System.err.println("Could not send user name.");
226 private void sendVersionToServer() {
227 int ai[] = new int[4];
228 ai[0] = ai.length * 4;
230 ai[2] = mcsVersion.getClientMajorRev();
231 ai[3] = mcsVersion.getClientMinorRev();
233 mcsTcpConnection.sendMessage(ai);
235 catch (IOException ioexception) {
236 System.err.println("Could not send version.");
241 private void sendStartSendingToServer(boolean flag) {
242 int ai[] = new int[3];
243 ai[0] = ai.length * 4;
253 mcsTcpConnection.sendMessage(ai);
255 catch (IOException ioexception) {
256 System.err.println("Could not send start sending to server.");
261 public boolean isVideoEncrypted() {