# HG changeset patch # User Yu Taninari # Date 1311843168 -32400 # Node ID 6e703f1000e75b680913234e04fe551130ccc96f # Parent 4423c9c5ab5b732a6aa6ff25a370a6ce4efeae5e# Parent 343e0a107dfc1f780451c16525ff45673f35faa8 merge diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/AuthPanel.class Binary file bin/myVncProxy/AuthPanel.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/ButtonPanel.class Binary file bin/myVncProxy/ButtonPanel.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/CapabilityInfo.class Binary file bin/myVncProxy/CapabilityInfo.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/CapsContainer.class Binary file bin/myVncProxy/CapsContainer.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/ClipboardFrame.class Binary file bin/myVncProxy/ClipboardFrame.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/CreateHtmlFile.class Binary file bin/myVncProxy/CreateHtmlFile.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/CreateThread.class Binary file bin/myVncProxy/CreateThread.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/DesCipher.class Binary file bin/myVncProxy/DesCipher.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/HTTPConnectSocket.class Binary file bin/myVncProxy/HTTPConnectSocket.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/HTTPConnectSocketFactory.class Binary file bin/myVncProxy/HTTPConnectSocketFactory.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/InStream.class Binary file bin/myVncProxy/InStream.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/MemInStream.class Binary file bin/myVncProxy/MemInStream.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/MulticastQueue$Client.class Binary file bin/myVncProxy/MulticastQueue$Client.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/MulticastQueue$Node.class Binary file bin/myVncProxy/MulticastQueue$Node.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/MulticastQueue.class Binary file bin/myVncProxy/MulticastQueue.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/MyRfbProto$1.class Binary file bin/myVncProxy/MyRfbProto$1.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/MyRfbProto$2.class Binary file bin/myVncProxy/MyRfbProto$2.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/MyRfbProto.class Binary file bin/myVncProxy/MyRfbProto.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/OptionsFrame.class Binary file bin/myVncProxy/OptionsFrame.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/OptionsNoFrame.class Binary file bin/myVncProxy/OptionsNoFrame.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/ProxyVncCanvas.class Binary file bin/myVncProxy/ProxyVncCanvas.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/RecordingFrame.class Binary file bin/myVncProxy/RecordingFrame.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/ReloginPanel.class Binary file bin/myVncProxy/ReloginPanel.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/RfbProto.class Binary file bin/myVncProxy/RfbProto.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/SendThread.class Binary file bin/myVncProxy/SendThread.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/SessionRecorder.class Binary file bin/myVncProxy/SessionRecorder.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/SocketFactory.class Binary file bin/myVncProxy/SocketFactory.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/VncCanvas.class Binary file bin/myVncProxy/VncCanvas.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/VncCanvas2.class Binary file bin/myVncProxy/VncCanvas2.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/VncProxyService.class Binary file bin/myVncProxy/VncProxyService.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/VncViewer.class Binary file bin/myVncProxy/VncViewer.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/ZlibInStream.class Binary file bin/myVncProxy/ZlibInStream.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/acceptClient.class Binary file bin/myVncProxy/acceptClient.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/acceptThread.class Binary file bin/myVncProxy/acceptThread.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/child.class Binary file bin/myVncProxy/child.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/myVncProxy/sock.class Binary file bin/myVncProxy/sock.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/test/MultiThreadTee$Client.class Binary file bin/test/MultiThreadTee$Client.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/test/MultiThreadTee$Parent.class Binary file bin/test/MultiThreadTee$Parent.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/test/MultiThreadTee.class Binary file bin/test/MultiThreadTee.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/test/MulticastQueue$1.class Binary file bin/test/MulticastQueue$1.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/test/MulticastQueue$2.class Binary file bin/test/MulticastQueue$2.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/test/MulticastQueue$Client.class Binary file bin/test/MulticastQueue$Client.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/test/MulticastQueue$Node.class Binary file bin/test/MulticastQueue$Node.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 bin/test/MulticastQueue.class Binary file bin/test/MulticastQueue.class has changed diff -r 4423c9c5ab5b -r 6e703f1000e7 src/myVncProxy/MyRfbProto.java --- a/src/myVncProxy/MyRfbProto.java Thu Jul 28 17:50:14 2011 +0900 +++ b/src/myVncProxy/MyRfbProto.java Thu Jul 28 17:52:48 2011 +0900 @@ -24,8 +24,13 @@ import java.io.OutputStream; class MyRfbProto extends RfbProto { - final static String versionMsg_3_998 = "RFB 003.998\n"; + /** + * CheckMillis is one of new msgType for RFB 3.998. + */ + final static int CheckMillis = 4; + boolean printStatusFlag = false; + long startCheckTime; private int messageType; private int rectangles; @@ -320,6 +325,34 @@ if (encoding == 16) zLen = readU32(); reset(); +/* + int dataLen; + switch (encoding) { + case RfbProto.EncodingRaw: + dataLen = rectW * rectH * 4 + 16; + mark(dataLen); + break; + case RfbProto.EncodingCopyRect: + dataLen = 16 + 4; + mark(dataLen); + break; + case RfbProto.EncodingRRE: + case RfbProto.EncodingCoRRE: + case RfbProto.EncodingHextile: + + case RfbProto.EncodingZlib: + case RfbProto.EncodingTight: + case RfbProto.EncodingZRLE: + dataLen = zLen + 20; + mark(dataLen); + break; + default: + dataLen = 1000000; + mark(dataLen); + } + +*/ + } int checkAndMark() throws IOException { @@ -329,6 +362,15 @@ dataLen = rectW * rectH * 4 + 16; mark(dataLen); break; + case RfbProto.EncodingCopyRect: + dataLen = 16 + 4; + mark(dataLen); + break; + case RfbProto.EncodingRRE: + case RfbProto.EncodingCoRRE: + case RfbProto.EncodingHextile: + case RfbProto.EncodingZlib: + case RfbProto.EncodingTight: case RfbProto.EncodingZRLE: dataLen = zLen + 20; mark(dataLen); @@ -339,11 +381,13 @@ } return dataLen; } + void readSendData(int dataLen) throws IOException { byte buffer[] = new byte[dataLen]; readFully(buffer); multicastqueue.put(buffer); reset(); + /* for (Socket cli : cliList) { try { @@ -414,12 +458,12 @@ BufferedImage bimg = ImageIO.read(new ByteArrayInputStream(pngBytes)); return bimg; } - +/* void readPngData() throws IOException { pngBytes = new byte[is.available()]; readFully(pngBytes); } - +*/ void printFramebufferUpdate() { System.out.println("messageType=" + messageType); @@ -433,6 +477,44 @@ default: } } + + void readCheckMillis() throws IOException { + byte[] b = new byte[2]; + readFully(b); + } + + void startCheckMillis() { + byte[] b = new byte[2]; + b[0] = (byte) CheckMillis; + b[1] = (byte) 0; + startCheckTime = System.currentTimeMillis(); + System.out.println("startChckTime = "+ startCheckTime); + multicastqueue.put(b); + } + + void endCheckMills() { + long accTime = System.currentTimeMillis(); + long time = accTime - startCheckTime; + System.out.println("checkMillis: " + time); + } + + void printStatus() { + System.out.println(); + } + + synchronized void changeStatusFlag() { + printStatusFlag = true; + } + + void printMills() { + if(printStatusFlag) { + + changeStatusFlag(); + } else { + changeStatusFlag(); + } + } + void newClient(AcceptThread acceptThread, final Socket newCli, final OutputStream os, final InputStream is) throws IOException { @@ -443,7 +525,9 @@ Runnable sender = new Runnable() { public void run() { try { - // 初期接続確立の部分 + /** + * initial connection of RFB protocol + */ sendRfbVersion(os); readVersionMsg(is); sendSecurityType(os); @@ -457,8 +541,9 @@ os.write(b, 0, b.length); } } catch (IOException e) { - //接続が切れた処理 - //lockしないと駄目 + /** + * if socket closed + */ // cliList.remove(newCli); } @@ -468,4 +553,31 @@ new Thread(sender).start(); } + + void sendCheckMillis() { + + Runnable stdin = new Runnable() { + public void run() { + int c; + try { + while( (c = System.in.read()) != -1 ) { + switch(c) { + case 's': + break; + default: + startCheckMillis(); + break; + } + } + }catch(IOException e){ + System.out.println(e); + } + } + }; + + new Thread(stdin).start(); + } + } + + diff -r 4423c9c5ab5b -r 6e703f1000e7 src/myVncProxy/OptionsNoFrame.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/myVncProxy/OptionsNoFrame.java Thu Jul 28 17:52:48 2011 +0900 @@ -0,0 +1,330 @@ +package myVncProxy; + +import java.awt.*; +import java.awt.event.*; + +class OptionsNoFrame{ + + static String[] names = { + "Encoding", + "Compression level", + "JPEG image quality", + "Cursor shape updates", + "Use CopyRect", + "Restricted colors", + "Mouse buttons 2 and 3", + "View only", + "Scale remote cursor", + "Share desktop", + }; + + static String[][] values = { + { "Auto", "Raw", "RRE", "CoRRE", "Hextile", "Zlib", "Tight", "ZRLE" }, + { "Default", "1", "2", "3", "4", "5", "6", "7", "8", "9" }, + { "JPEG off", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }, + { "Enable", "Ignore", "Disable" }, + { "Yes", "No" }, + { "Yes", "No" }, + { "Normal", "Reversed" }, + { "Yes", "No" }, + { "No", "50%", "75%", "125%", "150%" }, + { "Yes", "No" }, + }; + + final int + encodingIndex = 0, + compressLevelIndex = 1, + jpegQualityIndex = 2, + cursorUpdatesIndex = 3, + useCopyRectIndex = 4, + eightBitColorsIndex = 5, + mouseButtonIndex = 6, + viewOnlyIndex = 7, + scaleCursorIndex = 8, + shareDesktopIndex = 9; + + Label[] labels = new Label[names.length]; + Choice[] choices = new Choice[names.length]; + Button closeButton; + VncProxyService viewer; + + + // + // The actual data which other classes look at: + // + + int preferredEncoding; + int compressLevel; + int jpegQuality; + boolean useCopyRect; + boolean requestCursorUpdates; + boolean ignoreCursorUpdates; + + boolean eightBitColors; + + boolean reverseMouseButtons2And3; + boolean shareDesktop; + boolean viewOnly; + int scaleCursor; + + boolean autoScale; + int scalingFactor; + + // + // Constructor. Set up the labels and choices from the names and values + // arrays. + // + + OptionsNoFrame(VncProxyService v) { + viewer = v; + + for (int i = 0; i < names.length; i++) { + labels[i] = new Label(names[i]); + + choices[i] = new Choice(); + + + for (int j = 0; j < values[i]. length; j++) { + choices[i].addItem(values[i][j]); + } + } + + // Set up defaults + + choices[encodingIndex].select("Auto"); + choices[compressLevelIndex].select("Default"); + choices[jpegQualityIndex].select("6"); + choices[cursorUpdatesIndex].select("Enable"); + choices[useCopyRectIndex].select("Yes"); + choices[eightBitColorsIndex].select("No"); + choices[mouseButtonIndex].select("Normal"); + choices[viewOnlyIndex].select("No"); + choices[scaleCursorIndex].select("No"); + choices[shareDesktopIndex].select("Yes"); + + // But let them be overridden by parameters + + for (int i = 0; i < names.length; i++) { + String s = viewer.readParameter(names[i], false); + if (s != null) { + for (int j = 0; j < values[i].length; j++) { + if (s.equalsIgnoreCase(values[i][j])) { + choices[i].select(j); + } + } + } + } + + // FIXME: Provide some sort of GUI for "Scaling Factor". + + autoScale = false; + scalingFactor = 100; + String s = viewer.readParameter("Scaling Factor", false); + if (s != null) { + if (s.equalsIgnoreCase("Auto")) { + autoScale = true; + } else { + // Remove the '%' char at the end of string if present. + if (s.charAt(s.length() - 1) == '%') { + s = s.substring(0, s.length() - 1); + } + // Convert to an integer. + try { + scalingFactor = Integer.parseInt(s); + } + catch (NumberFormatException e) { + scalingFactor = 100; + } + // Make sure scalingFactor is in the range of [1..1000]. + if (scalingFactor < 1) { + scalingFactor = 1; + } else if (scalingFactor > 1000) { + scalingFactor = 1000; + } + } + } + + // Make the booleans and encodings array correspond to the state of the GUI + + setEncodings(); + setColorFormat(); + setOtherOptions(); + } + + + // + // Disable the shareDesktop option + // + + void disableShareDesktop() { + labels[shareDesktopIndex].setEnabled(false); + choices[shareDesktopIndex].setEnabled(false); + } + + // + // setEncodings looks at the encoding, compression level, JPEG + // quality level, cursor shape updates and copyRect choices and sets + // corresponding variables properly. Then it calls the VncViewer's + // setEncodings method to send a SetEncodings message to the RFB + // server. + // + + void setEncodings() { +// useCopyRect = choices[useCopyRectIndex].getSelectedItem().equals("Yes"); + + preferredEncoding = RfbProto.EncodingRaw; + boolean enableCompressLevel = false; + + if (choices[encodingIndex].getSelectedItem().equals("RRE")) { + preferredEncoding = RfbProto.EncodingRRE; + } else if (choices[encodingIndex].getSelectedItem().equals("CoRRE")) { + preferredEncoding = RfbProto.EncodingCoRRE; + } else if (choices[encodingIndex].getSelectedItem().equals("Hextile")) { + preferredEncoding = RfbProto.EncodingHextile; + } else if (choices[encodingIndex].getSelectedItem().equals("ZRLE")) { + preferredEncoding = RfbProto.EncodingZRLE; + } else if (choices[encodingIndex].getSelectedItem().equals("Zlib")) { + preferredEncoding = RfbProto.EncodingZlib; + enableCompressLevel = true; + } else if (choices[encodingIndex].getSelectedItem().equals("Tight")) { + preferredEncoding = RfbProto.EncodingTight; + enableCompressLevel = true; + } else if (choices[encodingIndex].getSelectedItem().equals("Auto")) { + preferredEncoding = -1; + } + + // Handle compression level setting. + + try { + compressLevel = + Integer.parseInt(choices[compressLevelIndex].getSelectedItem()); + } + catch (NumberFormatException e) { + compressLevel = -1; + } + if (compressLevel < 1 || compressLevel > 9) { + compressLevel = -1; + } + labels[compressLevelIndex].setEnabled(enableCompressLevel); + choices[compressLevelIndex].setEnabled(enableCompressLevel); + + // Handle JPEG quality setting. + + try { + jpegQuality = + Integer.parseInt(choices[jpegQualityIndex].getSelectedItem()); + } + catch (NumberFormatException e) { + jpegQuality = -1; + } + if (jpegQuality < 0 || jpegQuality > 9) { + jpegQuality = -1; + } + + // Request cursor shape updates if necessary. + + requestCursorUpdates = + !choices[cursorUpdatesIndex].getSelectedItem().equals("Disable"); + + if (requestCursorUpdates) { + ignoreCursorUpdates = + choices[cursorUpdatesIndex].getSelectedItem().equals("Ignore"); + } + + viewer.setEncodings(); + } + + // + // setColorFormat sets eightBitColors variable depending on the GUI + // setting, causing switches between 8-bit and 24-bit colors mode if + // necessary. + // + + void setColorFormat() { + + eightBitColors = + choices[eightBitColorsIndex].getSelectedItem().equals("Yes"); + + boolean enableJPEG = !eightBitColors; + + labels[jpegQualityIndex].setEnabled(enableJPEG); + choices[jpegQualityIndex].setEnabled(enableJPEG); + } + + // + // setOtherOptions looks at the "other" choices (ones that do not + // cause sending any protocol messages) and sets the boolean flags + // appropriately. + // + + void setOtherOptions() { + + reverseMouseButtons2And3 + = choices[mouseButtonIndex].getSelectedItem().equals("Reversed"); + + viewOnly + = choices[viewOnlyIndex].getSelectedItem().equals("Yes"); + if (viewer.vc != null) + viewer.vc.enableInput(!viewOnly); + + shareDesktop + = choices[shareDesktopIndex].getSelectedItem().equals("Yes"); + + String scaleString = choices[scaleCursorIndex].getSelectedItem(); + if (scaleString.endsWith("%")) + scaleString = scaleString.substring(0, scaleString.length() - 1); + try { + scaleCursor = Integer.parseInt(scaleString); + } + catch (NumberFormatException e) { + scaleCursor = 0; + } + if (scaleCursor < 10 || scaleCursor > 500) { + scaleCursor = 0; + } + if (requestCursorUpdates && !ignoreCursorUpdates && !viewOnly) { + labels[scaleCursorIndex].setEnabled(true); + choices[scaleCursorIndex].setEnabled(true); + } else { + labels[scaleCursorIndex].setEnabled(false); + choices[scaleCursorIndex].setEnabled(false); + } + if (viewer.vc != null) + viewer.vc.createSoftCursor(); // update cursor scaling + } + + + // + // Respond to actions on Choice controls + // + + public void itemStateChanged(ItemEvent evt) { + Object source = evt.getSource(); + + if (source == choices[encodingIndex] || + source == choices[compressLevelIndex] || + source == choices[jpegQualityIndex] || + source == choices[cursorUpdatesIndex] || + source == choices[useCopyRectIndex]) { + + setEncodings(); + + if (source == choices[cursorUpdatesIndex]) { + setOtherOptions(); // update scaleCursor state + } + + } else if (source == choices[eightBitColorsIndex]) { + + setColorFormat(); + + } else if (source == choices[mouseButtonIndex] || + source == choices[shareDesktopIndex] || + source == choices[viewOnlyIndex] || + source == choices[scaleCursorIndex]) { + + setOtherOptions(); + + } + } + +} diff -r 4423c9c5ab5b -r 6e703f1000e7 src/myVncProxy/ProxyVncCanvas.java --- a/src/myVncProxy/ProxyVncCanvas.java Thu Jul 28 17:50:14 2011 +0900 +++ b/src/myVncProxy/ProxyVncCanvas.java Thu Jul 28 17:52:48 2011 +0900 @@ -359,9 +359,6 @@ // // main dispatch loop // - - - long count = 0; while (true) { @@ -369,9 +366,8 @@ count++; - /* + /** * read Data from parents and send Data to Client. - * */ rfb.sendDataToClient(); @@ -382,6 +378,10 @@ // Process the message depending on its type. switch (msgType) { + case MyRfbProto.CheckMillis: + rfb.readCheckMillis(); + + break; case RfbProto.FramebufferUpdate: if (statNumUpdates == viewer.debugStatsExcludeUpdates @@ -504,7 +504,7 @@ setPixelFormat(); fullUpdateNeeded = true; } -*/ +*/ // Request framebuffer update if needed. int w = rfb.framebufferWidth; diff -r 4423c9c5ab5b -r 6e703f1000e7 src/myVncProxy/RfbProto.java --- a/src/myVncProxy/RfbProto.java Thu Jul 28 17:50:14 2011 +0900 +++ b/src/myVncProxy/RfbProto.java Thu Jul 28 17:52:48 2011 +0900 @@ -561,6 +561,10 @@ /* if (viewer.options.shareDesktop) { */ + + /** + * shared flag + */ os.write(1); // os.write(0); diff -r 4423c9c5ab5b -r 6e703f1000e7 src/myVncProxy/VncProxyService.java --- a/src/myVncProxy/VncProxyService.java Thu Jul 28 17:50:14 2011 +0900 +++ b/src/myVncProxy/VncProxyService.java Thu Jul 28 17:52:48 2011 +0900 @@ -15,7 +15,6 @@ v.init(); v.start_threads(); - } String[] mainArgs; @@ -38,7 +37,8 @@ ButtonPanel buttonPanel; Label connStatusLabel; ProxyVncCanvas vc; - OptionsFrame options; +// OptionsFrame options; + OptionsNoFrame options; ClipboardFrame clipboard; RecordingFrame rec; @@ -85,6 +85,7 @@ readParameters(); + options = new OptionsNoFrame(this); recordingSync = new Object(); sessionFileName = null; @@ -676,7 +677,7 @@ if (rfb != null && !rfb.closed()) rfb.close(); - options.dispose(); +// options.dispose(); clipboard.dispose(); if (rec != null) rec.dispose(); @@ -762,7 +763,7 @@ System.out.println("Destroying applet"); vncContainer.removeAll(); - options.dispose(); +// options.dispose(); clipboard.dispose(); if (rec != null) rec.dispose();