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;
9 import java.io.IOException;
10 import java.io.PrintStream;
12 import java.util.LinkedList;
13 import java.util.StringTokenizer;
16 // Referenced classes of package mcsClient:
17 // McsTargetSize, McsVersion, LockingKeyStateManager, McsTcpConnection,
18 // LiveVideoPanel, McsKeyAdapter, McsMouseAdapter, McsMouseMotionAdapter,
19 // DatagramReader, McsToolBar, MessageReader, KeepAlive
21 public class McsClient extends JApplet {
23 private static final int FIXED_SIZE = 1;
24 private static final int FULL_SCREEN = 2;
25 private static final int SCROLL_SCREEN = 3;
26 private static final int DEFAULT_REMOTE_PORT = 2000;
27 private static final Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
28 private static final Dimension maxTargetSize = new Dimension(1024, 768);
29 private static int screenWidth;
30 private static int screenHeight;
31 private McsTargetSize mcsTargetSize;
32 private LinkedList datagramList;
33 private McsVersion mcsVersion;
34 private LockingKeyStateManager lockingKeyStateManager;
35 private McsTcpConnection mcsTcpConnection;
36 private McsKeyAdapter mcsKeyAdapter;
37 private LiveVideoPanel liveVideoPanel;
38 private McsMouseAdapter mcsMouseAdapter;
39 private McsMouseMotionAdapter mcsMouseMotionAdapter;
40 private DatagramReader datagramReader;
41 private MessageReader messageReader;
42 private KeepAlive keepAlive;
43 private boolean isStandalone;
44 private ThreadGroup threadGroup;
45 private static final String START = "Show Remote Console";
46 private static final String STOP = "Hide Remote Console";
47 private JButton button;
48 private static final boolean TCP = false;
49 private boolean blueScreenDump;
50 private boolean encryptVideo;
53 mcsTargetSize = new McsTargetSize(1024, 768);
54 datagramList = new LinkedList();
55 mcsVersion = new McsVersion();
56 lockingKeyStateManager = new LockingKeyStateManager();
58 blueScreenDump = false;
64 UIManager.setLookAndFeel(new WindowsLookAndFeel());
66 catch (Exception exception) { }
67 System.out.println("MCS v.3.6 initialized");
69 String s = getParameter("host");
71 s = getCodeBase().getHost();
73 String s2 = getParameter("bluescreen");
74 if (s2 != null && s2.equalsIgnoreCase("true"))
75 blueScreenDump = true;
76 String s3 = getParameter("userid");
80 String s5 = getParameter("enc");
81 if (s5 != null && s5.equalsIgnoreCase("on"))
83 String s6 = getParameter("ac");
87 getContentPane().setBackground(Color.WHITE);
88 begin(s1, s4, s7, false);
92 System.out.println("Stopping applet");
93 if (threadGroup != null)
94 threadGroup.interrupt();
95 if (mcsTcpConnection != null) {
96 mcsTcpConnection.close();
97 mcsTcpConnection = null;
101 public void begin(String s, String s1, String s2, boolean flag) {
103 StringTokenizer stringtokenizer = new StringTokenizer(s, ":");
104 String s3 = stringtokenizer.nextToken();
105 if (stringtokenizer.hasMoreTokens())
107 i = Integer.parseInt(stringtokenizer.nextToken());
109 catch (NumberFormatException numberformatexception) {
112 mcsTcpConnection = new McsTcpConnection(s3, i, encryptVideo, s2);
113 if (!mcsTcpConnection.connected()) {
119 sendUsernameToServer(s1, s2);
120 liveVideoPanel = new LiveVideoPanel(mcsTcpConnection, datagramList, mcsTargetSize, lockingKeyStateManager);
121 mcsKeyAdapter = new McsKeyAdapter(mcsTcpConnection, lockingKeyStateManager);
122 mcsMouseAdapter = new McsMouseAdapter(mcsTcpConnection, liveVideoPanel);
123 mcsMouseMotionAdapter = new McsMouseMotionAdapter(mcsTcpConnection, mcsKeyAdapter);
124 if (!blueScreenDump) {
125 liveVideoPanel.addMouseListener(mcsMouseAdapter);
126 liveVideoPanel.addMouseMotionListener(mcsMouseMotionAdapter);
127 liveVideoPanel.addKeyListener(mcsKeyAdapter);
128 liveVideoPanel.addMouseWheelListener(mcsMouseAdapter);
130 liveVideoPanel.setPreferredSize(maxTargetSize);
131 liveVideoPanel.setFocusTraversalKeysEnabled(false);
132 datagramReader = new DatagramReader(mcsTcpConnection, liveVideoPanel, datagramList, s3, i, flag);
133 if (!blueScreenDump) {
134 McsToolBar mcstoolbar = new McsToolBar(mcsKeyAdapter, liveVideoPanel);
135 mcstoolbar.setFloatable(false);
136 mcstoolbar.setVisible(false);
137 McsToolBar mcstoolbar1 = new McsToolBar(s3, mcsKeyAdapter, liveVideoPanel, datagramReader, mcstoolbar);
138 getContentPane().add(mcstoolbar1, "North");
139 getContentPane().add(mcstoolbar, "West");
141 getContentPane().add(liveVideoPanel);
142 liveVideoPanel.requestFocusInWindow();
143 if (!datagramReader.initialized()) {
149 messageReader = new MessageReader(mcsTcpConnection, mcsVersion, lockingKeyStateManager);
150 keepAlive = new KeepAlive(mcsTcpConnection, blueScreenDump);
151 threadGroup = new ThreadGroup("MCS Threads");
152 threadGroup.setDaemon(true);
153 (new Thread(threadGroup, liveVideoPanel, "liveVideoPanel thread")).start();
154 Thread thread = new Thread(threadGroup, datagramReader, "datagramReader thread");
155 thread.setPriority(thread.getPriority() + 2);
157 Thread thread1 = new Thread(threadGroup, messageReader, "messageReader thread");
159 thread1.setPriority(thread1.getPriority() + 2);
161 Thread thread2 = new Thread(threadGroup, keepAlive, "keepAlive thread");
162 thread2.setPriority(thread2.getPriority() + 2);
164 sendVersionToServer();
165 System.out.println("Command KVM Server to start sending images");
166 sendStartSendingToServer(mcsTcpConnection.getDetectedPPP());
169 private void sendUsernameToServer(String s, String s1) {
172 char ac[] = (s + ":" + s1).toCharArray();
173 int ai[] = new int[2 + ac.length];
174 ai[0] = ai.length * 4;
176 for (int i = 0; i < ac.length; i++)
180 mcsTcpConnection.sendMessage(ai);
182 catch (IOException ioexception) {
183 System.err.println("Could not send user name.");
188 private void sendVersionToServer() {
189 int ai[] = new int[4];
190 ai[0] = ai.length * 4;
192 ai[2] = mcsVersion.getClientMajorRev();
193 ai[3] = mcsVersion.getClientMinorRev();
195 mcsTcpConnection.sendMessage(ai);
197 catch (IOException ioexception) {
198 System.err.println("Could not send version.");
203 private void sendStartSendingToServer(boolean flag) {
204 int ai[] = new int[3];
205 ai[0] = ai.length * 4;
215 mcsTcpConnection.sendMessage(ai);
217 catch (IOException ioexception) {
218 System.err.println("Could not send start sending to server.");
223 public boolean isVideoEncrypted() {