Mercurial > hg > Applications > TreeVNC
changeset 238:e21ef8f60f7a
fix indent.
author | oc |
---|---|
date | Sat, 11 Oct 2014 14:15:48 +0900 |
parents | 0815ed7f54a7 |
children | d655db005535 |
files | src/main/java/com/glavsoft/rfb/encoding/EncodingType.java src/main/java/com/glavsoft/rfb/protocol/SenderTask.java src/main/java/jp/ac/u_ryukyu/treevnc/CheckDelayReply.java |
diffstat | 3 files changed, 139 insertions(+), 142 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/encoding/EncodingType.java Sat Oct 11 14:13:29 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/EncodingType.java Sat Oct 11 14:15:48 2014 +0900 @@ -30,50 +30,50 @@ * Encoding types */ public enum EncodingType { - /** - * Desktop data representes as raw bytes stream - */ - RAW_ENCODING(0, "Raw"), - /** - * Specfies encodings which allow to copy part of image in client's - * framebuffer from one place to another. - */ - COPY_RECT(1, "CopyRect"), - RRE(2, "RRE"), - /** - * Hextile encoding, uses palettes, filling and raw subencoding - */ + /** + * Desktop data representes as raw bytes stream + */ + RAW_ENCODING(0, "Raw"), + /** + * Specfies encodings which allow to copy part of image in client's + * framebuffer from one place to another. + */ + COPY_RECT(1, "CopyRect"), + RRE(2, "RRE"), + /** + * Hextile encoding, uses palettes, filling and raw subencoding + */ HEXTILE(5, "Hextile"), /** * This encoding is like raw but previously all data compressed with zlib. */ ZLIB(6, "ZLib"), - /** - * Tight Encoding for slow connection. It is uses raw data, palettes, filling - * and jpeg subencodings - */ - TIGHT(7, "Tight"), + /** + * Tight Encoding for slow connection. It is uses raw data, palettes, filling + * and jpeg subencodings + */ + TIGHT(7, "Tight"), //ZlibHex(8), - /** - * ZRLE Encoding is like Hextile but previously all data compressed with zlib. - */ + /** + * ZRLE Encoding is like Hextile but previously all data compressed with zlib. + */ ZRLE(16, "ZRLE"), /** - * ZRLEE Encoding is extends ZRLE. ZRLEE have flush(). - */ + * ZRLEE Encoding is extends ZRLE. ZRLEE have flush(). + */ ZRLEE(15, "ZRLEE"), /** * TreeVNC check delay protocol number. */ CHECK_DELAY(17, "CHECK_DELAY"), - + /** * Transmit initial data of new display */ INIT_DATA(0xFFFFFF10, "InitData"), - + /** * Rich Cursor pseudo encoding which allows to transfer cursor shape * with transparency @@ -88,76 +88,76 @@ * Cusros position encoding allows to transfer remote cursor position to * client side. */ - CURSOR_POS(0xFFFFFF18, "CursorPos"), + CURSOR_POS(0xFFFFFF18, "CursorPos"), - COMPRESS_LEVEL_0(0xFFFFFF00 + 0, "CompressionLevel0"), - COMPRESS_LEVEL_1(0xFFFFFF00 + 1, "CompressionLevel1"), - COMPRESS_LEVEL_2(0xFFFFFF00 + 2, "CompressionLevel2"), - COMPRESS_LEVEL_3(0xFFFFFF00 + 3, "CompressionLevel3"), - COMPRESS_LEVEL_4(0xFFFFFF00 + 4, "CompressionLevel4"), - COMPRESS_LEVEL_5(0xFFFFFF00 + 5, "CompressionLevel5"), - COMPRESS_LEVEL_6(0xFFFFFF00 + 6, "CompressionLevel6"), - COMPRESS_LEVEL_7(0xFFFFFF00 + 7, "CompressionLevel7"), - COMPRESS_LEVEL_8(0xFFFFFF00 + 8, "CompressionLevel8"), - COMPRESS_LEVEL_9(0xFFFFFF00 + 9, "CompressionLevel9"), + COMPRESS_LEVEL_0(0xFFFFFF00 + 0, "CompressionLevel0"), + COMPRESS_LEVEL_1(0xFFFFFF00 + 1, "CompressionLevel1"), + COMPRESS_LEVEL_2(0xFFFFFF00 + 2, "CompressionLevel2"), + COMPRESS_LEVEL_3(0xFFFFFF00 + 3, "CompressionLevel3"), + COMPRESS_LEVEL_4(0xFFFFFF00 + 4, "CompressionLevel4"), + COMPRESS_LEVEL_5(0xFFFFFF00 + 5, "CompressionLevel5"), + COMPRESS_LEVEL_6(0xFFFFFF00 + 6, "CompressionLevel6"), + COMPRESS_LEVEL_7(0xFFFFFF00 + 7, "CompressionLevel7"), + COMPRESS_LEVEL_8(0xFFFFFF00 + 8, "CompressionLevel8"), + COMPRESS_LEVEL_9(0xFFFFFF00 + 9, "CompressionLevel9"), - JPEG_QUALITY_LEVEL_0(0xFFFFFFE0 + 0, "JpegQualityLevel0"), - JPEG_QUALITY_LEVEL_1(0xFFFFFFE0 + 1, "JpegQualityLevel1"), - JPEG_QUALITY_LEVEL_2(0xFFFFFFE0 + 2, "JpegQualityLevel2"), - JPEG_QUALITY_LEVEL_3(0xFFFFFFE0 + 3, "JpegQualityLevel3"), - JPEG_QUALITY_LEVEL_4(0xFFFFFFE0 + 4, "JpegQualityLevel4"), - JPEG_QUALITY_LEVEL_5(0xFFFFFFE0 + 5, "JpegQualityLevel5"), - JPEG_QUALITY_LEVEL_6(0xFFFFFFE0 + 6, "JpegQualityLevel6"), - JPEG_QUALITY_LEVEL_7(0xFFFFFFE0 + 7, "JpegQualityLevel7"), - JPEG_QUALITY_LEVEL_8(0xFFFFFFE0 + 8, "JpegQualityLevel8"), - JPEG_QUALITY_LEVEL_9(0xFFFFFFE0 + 9, "JpegQualityLevel9"); + JPEG_QUALITY_LEVEL_0(0xFFFFFFE0 + 0, "JpegQualityLevel0"), + JPEG_QUALITY_LEVEL_1(0xFFFFFFE0 + 1, "JpegQualityLevel1"), + JPEG_QUALITY_LEVEL_2(0xFFFFFFE0 + 2, "JpegQualityLevel2"), + JPEG_QUALITY_LEVEL_3(0xFFFFFFE0 + 3, "JpegQualityLevel3"), + JPEG_QUALITY_LEVEL_4(0xFFFFFFE0 + 4, "JpegQualityLevel4"), + JPEG_QUALITY_LEVEL_5(0xFFFFFFE0 + 5, "JpegQualityLevel5"), + JPEG_QUALITY_LEVEL_6(0xFFFFFFE0 + 6, "JpegQualityLevel6"), + JPEG_QUALITY_LEVEL_7(0xFFFFFFE0 + 7, "JpegQualityLevel7"), + JPEG_QUALITY_LEVEL_8(0xFFFFFFE0 + 8, "JpegQualityLevel8"), + JPEG_QUALITY_LEVEL_9(0xFFFFFFE0 + 9, "JpegQualityLevel9"); - private int id; - private final String name; - private EncodingType(int id, String name) { - this.id = id; - this.name = name; - } + private int id; + private final String name; + private EncodingType(int id, String name) { + this.id = id; + this.name = name; + } - public int getId() { - return id; - } - public String getName() { - return name; - } + public int getId() { + return id; + } + public String getName() { + return name; + } - public static LinkedHashSet<EncodingType> ordinaryEncodings = new LinkedHashSet<EncodingType>(); - static { - ordinaryEncodings.add(TIGHT); - ordinaryEncodings.add(HEXTILE); - ordinaryEncodings.add(ZRLE); - ordinaryEncodings.add(ZRLEE); - ordinaryEncodings.add(ZLIB); - ordinaryEncodings.add(RRE); - ordinaryEncodings.add(COPY_RECT); -// ordinaryEncodings.add(RAW_ENCODING); - } + public static LinkedHashSet<EncodingType> ordinaryEncodings = new LinkedHashSet<EncodingType>(); + static { + ordinaryEncodings.add(TIGHT); + ordinaryEncodings.add(HEXTILE); + ordinaryEncodings.add(ZRLE); + ordinaryEncodings.add(ZRLEE); + ordinaryEncodings.add(ZLIB); + ordinaryEncodings.add(RRE); + ordinaryEncodings.add(COPY_RECT); + // ordinaryEncodings.add(RAW_ENCODING); + } - public static LinkedHashSet<EncodingType> pseudoEncodings = new LinkedHashSet<EncodingType>(); - static { - pseudoEncodings.add(RICH_CURSOR); - pseudoEncodings.add(CURSOR_POS); - pseudoEncodings.add(DESKTOP_SIZE); - } + public static LinkedHashSet<EncodingType> pseudoEncodings = new LinkedHashSet<EncodingType>(); + static { + pseudoEncodings.add(RICH_CURSOR); + pseudoEncodings.add(CURSOR_POS); + pseudoEncodings.add(DESKTOP_SIZE); + } - public static LinkedHashSet<EncodingType> compressionEncodings = new LinkedHashSet<EncodingType>(); - static { - compressionEncodings.add(COMPRESS_LEVEL_0); - compressionEncodings.add(JPEG_QUALITY_LEVEL_0); - } + public static LinkedHashSet<EncodingType> compressionEncodings = new LinkedHashSet<EncodingType>(); + static { + compressionEncodings.add(COMPRESS_LEVEL_0); + compressionEncodings.add(JPEG_QUALITY_LEVEL_0); + } - public static EncodingType byId(int id) { - // TODO needs to speedup with hash usage? - for (EncodingType type : values()) { - if (type.getId() == id) - return type; - } - throw new IllegalArgumentException("Unsupported encoding id: " + id); - } + public static EncodingType byId(int id) { + // TODO needs to speedup with hash usage? + for (EncodingType type : values()) { + if (type.getId() == id) + return type; + } + throw new IllegalArgumentException("Unsupported encoding id: " + id); + } }
--- a/src/main/java/com/glavsoft/rfb/protocol/SenderTask.java Sat Oct 11 14:13:29 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/SenderTask.java Sat Oct 11 14:15:48 2014 +0900 @@ -34,58 +34,58 @@ public class SenderTask implements Runnable { - private final MessageQueue queue; - private final Writer writer; - private final ProtocolContext protocolContext; - private volatile boolean isRunning = false; + private final MessageQueue queue; + private final Writer writer; + private final ProtocolContext protocolContext; + private volatile boolean isRunning = false; - /** - * Create sender task - * Task runs as thread, receive messages from queue and sends them to writer. - * When no messages appears in queue longer than timeout period, sends FramebufferUpdate - * request - * @param messageQueue queue to poll messages - * @param writer writer to send messages out - * @param protocolContext protocol - */ - public SenderTask(MessageQueue messageQueue, Writer writer, ProtocolContext protocolContext) { - this.queue = messageQueue; - this.writer = writer; - this.protocolContext = protocolContext; - } + /** + * Create sender task + * Task runs as thread, receive messages from queue and sends them to writer. + * When no messages appears in queue longer than timeout period, sends FramebufferUpdate + * request + * @param messageQueue queue to poll messages + * @param writer writer to send messages out + * @param protocolContext protocol + */ + public SenderTask(MessageQueue messageQueue, Writer writer, ProtocolContext protocolContext) { + this.queue = messageQueue; + this.writer = writer; + this.protocolContext = protocolContext; + } - @Override - public void run() { - isRunning = true; - while (isRunning) { - ClientToServerMessage message; - try { - message = queue.get(); - if (message != null) { - message.send(writer); - } - } catch (InterruptedException e) { - // nop - } catch (TransportException e) { - Logger.getLogger(getClass().getName()).severe("Close session: " + e.getMessage()); - if (isRunning) { - protocolContext.cleanUpSession("Connection closed"); - } - stopTask(); - } catch (Throwable te) { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - te.printStackTrace(pw); - if (isRunning) { - protocolContext.cleanUpSession(te.getMessage() + "\n" + sw.toString()); - } - stopTask(); - } - } - } + @Override + public void run() { + isRunning = true; + while (isRunning) { + ClientToServerMessage message; + try { + message = queue.get(); + if (message != null) { + message.send(writer); + } + } catch (InterruptedException e) { + // nop + } catch (TransportException e) { + Logger.getLogger(getClass().getName()).severe("Close session: " + e.getMessage()); + if (isRunning) { + protocolContext.cleanUpSession("Connection closed"); + } + stopTask(); + } catch (Throwable te) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + te.printStackTrace(pw); + if (isRunning) { + protocolContext.cleanUpSession(te.getMessage() + "\n" + sw.toString()); + } + stopTask(); + } + } + } - public void stopTask() { - isRunning = false; - } + public void stopTask() { + isRunning = false; + } }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/CheckDelayReply.java Sat Oct 11 14:13:29 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/CheckDelayReply.java Sat Oct 11 14:15:48 2014 +0900 @@ -22,10 +22,7 @@ this.byteaddress = address.getBytes("UTF-8"); } - public CheckDelayReply() { - // TODO Auto-generated constructor stub - } - + @Override public void send(Writer writer) throws TransportException { ByteBuffer out = ByteBuffer.allocate(18 + addressLength);