From 2523a39df6a3fbb081c7f4f2522f5f8a0da57f41 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 4 Sep 2010 23:20:29 -0700 Subject: [PATCH] Removed VNC client, generalized description of Guac in copyright. --- .../src/net/sourceforge/guacamole/Client.java | 2 +- .../guacamole/GuacamoleException.java | 2 +- .../sourceforge/guacamole/event/Event.java | 2 +- .../guacamole/event/EventHandler.java | 2 +- .../guacamole/event/EventQueue.java | 2 +- .../sourceforge/guacamole/event/KeyEvent.java | 2 +- .../guacamole/event/PointerEvent.java | 2 +- .../instruction/ClipboardInstruction.java | 2 +- .../instruction/ErrorInstruction.java | 2 +- .../guacamole/instruction/Instruction.java | 2 +- .../instruction/NameInstruction.java | 2 +- .../instruction/SizeInstruction.java | 2 +- .../framebuffer/CopyRectInstruction.java | 2 +- .../framebuffer/CursorInstruction.java | 2 +- .../framebuffer/DrawRectInstruction.java | 2 +- .../instruction/framebuffer/PNGImage.java | 2 +- .../framebuffer/PNGInstruction.java | 2 +- .../net/sourceforge/guacamole/net/Base64.java | 2 +- .../guacamole/net/Configuration.java | 2 +- .../guacamole/net/GuacamoleConfiguration.java | 8 +- .../guacamole/net/GuacamoleServlet.java | 2 +- .../guacamole/net/GuacamoleSession.java | 37 +- .../guacamole/net/XMLGuacamoleServlet.java | 2 +- .../guacamole/net/control/Connect.java | 2 +- .../guacamole/net/control/Disconnect.java | 4 +- .../guacamole/net/input/Clipboard.java | 5 +- .../sourceforge/guacamole/net/input/Key.java | 5 +- .../guacamole/net/input/Pointer.java | 3 +- .../net/output/InstructionStream.java | 4 +- .../guacamole/vnc/InputOutputStream.java | 63 - .../sourceforge/guacamole/vnc/VNCClient.java | 1113 ----------------- .../guacamole/vnc/VNCConfiguration.java | 60 - .../guacamole/vnc/VNCException.java | 32 - .../vnc/VNCFullColorImageReader.java | 239 ---- .../guacamole/vnc/VNCImageReader.java | 64 - .../guacamole/vnc/VNCIndexedImageReader.java | 104 -- 36 files changed, 36 insertions(+), 1749 deletions(-) delete mode 100644 guacamole/client/src/net/sourceforge/guacamole/vnc/InputOutputStream.java delete mode 100644 guacamole/client/src/net/sourceforge/guacamole/vnc/VNCClient.java delete mode 100644 guacamole/client/src/net/sourceforge/guacamole/vnc/VNCConfiguration.java delete mode 100644 guacamole/client/src/net/sourceforge/guacamole/vnc/VNCException.java delete mode 100644 guacamole/client/src/net/sourceforge/guacamole/vnc/VNCFullColorImageReader.java delete mode 100644 guacamole/client/src/net/sourceforge/guacamole/vnc/VNCImageReader.java delete mode 100644 guacamole/client/src/net/sourceforge/guacamole/vnc/VNCIndexedImageReader.java diff --git a/guacamole/client/src/net/sourceforge/guacamole/Client.java b/guacamole/client/src/net/sourceforge/guacamole/Client.java index e5da483cf..5be1b9704 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/Client.java +++ b/guacamole/client/src/net/sourceforge/guacamole/Client.java @@ -2,7 +2,7 @@ package net.sourceforge.guacamole; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/GuacamoleException.java b/guacamole/client/src/net/sourceforge/guacamole/GuacamoleException.java index 566cf862a..3a09c5ac7 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/GuacamoleException.java +++ b/guacamole/client/src/net/sourceforge/guacamole/GuacamoleException.java @@ -2,7 +2,7 @@ package net.sourceforge.guacamole; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/event/Event.java b/guacamole/client/src/net/sourceforge/guacamole/event/Event.java index 88e8ed433..8fa047f1b 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/event/Event.java +++ b/guacamole/client/src/net/sourceforge/guacamole/event/Event.java @@ -2,7 +2,7 @@ package net.sourceforge.guacamole.event; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/event/EventHandler.java b/guacamole/client/src/net/sourceforge/guacamole/event/EventHandler.java index 12d363c36..bae027a2e 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/event/EventHandler.java +++ b/guacamole/client/src/net/sourceforge/guacamole/event/EventHandler.java @@ -2,7 +2,7 @@ package net.sourceforge.guacamole.event; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/event/EventQueue.java b/guacamole/client/src/net/sourceforge/guacamole/event/EventQueue.java index 65622a2d9..a1d7a5246 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/event/EventQueue.java +++ b/guacamole/client/src/net/sourceforge/guacamole/event/EventQueue.java @@ -2,7 +2,7 @@ package net.sourceforge.guacamole.event; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/event/KeyEvent.java b/guacamole/client/src/net/sourceforge/guacamole/event/KeyEvent.java index 5f2f69270..a287dd448 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/event/KeyEvent.java +++ b/guacamole/client/src/net/sourceforge/guacamole/event/KeyEvent.java @@ -1,7 +1,7 @@ package net.sourceforge.guacamole.event; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/event/PointerEvent.java b/guacamole/client/src/net/sourceforge/guacamole/event/PointerEvent.java index 9a5401adc..05692ada1 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/event/PointerEvent.java +++ b/guacamole/client/src/net/sourceforge/guacamole/event/PointerEvent.java @@ -1,7 +1,7 @@ package net.sourceforge.guacamole.event; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/instruction/ClipboardInstruction.java b/guacamole/client/src/net/sourceforge/guacamole/instruction/ClipboardInstruction.java index f5e62d1ab..5eb29737b 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/instruction/ClipboardInstruction.java +++ b/guacamole/client/src/net/sourceforge/guacamole/instruction/ClipboardInstruction.java @@ -2,7 +2,7 @@ package net.sourceforge.guacamole.instruction; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/instruction/ErrorInstruction.java b/guacamole/client/src/net/sourceforge/guacamole/instruction/ErrorInstruction.java index 36c337784..acc550777 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/instruction/ErrorInstruction.java +++ b/guacamole/client/src/net/sourceforge/guacamole/instruction/ErrorInstruction.java @@ -2,7 +2,7 @@ package net.sourceforge.guacamole.instruction; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/instruction/Instruction.java b/guacamole/client/src/net/sourceforge/guacamole/instruction/Instruction.java index b7ed3553f..07f7e92d5 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/instruction/Instruction.java +++ b/guacamole/client/src/net/sourceforge/guacamole/instruction/Instruction.java @@ -2,7 +2,7 @@ package net.sourceforge.guacamole.instruction; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/instruction/NameInstruction.java b/guacamole/client/src/net/sourceforge/guacamole/instruction/NameInstruction.java index 806c13793..92606aec7 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/instruction/NameInstruction.java +++ b/guacamole/client/src/net/sourceforge/guacamole/instruction/NameInstruction.java @@ -2,7 +2,7 @@ package net.sourceforge.guacamole.instruction; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/instruction/SizeInstruction.java b/guacamole/client/src/net/sourceforge/guacamole/instruction/SizeInstruction.java index 4d4ece13c..e21364469 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/instruction/SizeInstruction.java +++ b/guacamole/client/src/net/sourceforge/guacamole/instruction/SizeInstruction.java @@ -2,7 +2,7 @@ package net.sourceforge.guacamole.instruction; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/CopyRectInstruction.java b/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/CopyRectInstruction.java index 42cc3b930..1b23f7777 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/CopyRectInstruction.java +++ b/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/CopyRectInstruction.java @@ -2,7 +2,7 @@ package net.sourceforge.guacamole.instruction.framebuffer; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/CursorInstruction.java b/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/CursorInstruction.java index 9122f6f6b..b5cbe656f 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/CursorInstruction.java +++ b/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/CursorInstruction.java @@ -3,7 +3,7 @@ package net.sourceforge.guacamole.instruction.framebuffer; import net.sourceforge.guacamole.net.Base64; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/DrawRectInstruction.java b/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/DrawRectInstruction.java index 5da8ac271..544aed334 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/DrawRectInstruction.java +++ b/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/DrawRectInstruction.java @@ -2,7 +2,7 @@ package net.sourceforge.guacamole.instruction.framebuffer; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/PNGImage.java b/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/PNGImage.java index 4a74d4a5e..79489dfd3 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/PNGImage.java +++ b/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/PNGImage.java @@ -1,7 +1,7 @@ package net.sourceforge.guacamole.instruction.framebuffer; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/PNGInstruction.java b/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/PNGInstruction.java index b7f113489..4d5e26962 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/PNGInstruction.java +++ b/guacamole/client/src/net/sourceforge/guacamole/instruction/framebuffer/PNGInstruction.java @@ -1,7 +1,7 @@ package net.sourceforge.guacamole.instruction.framebuffer; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/net/Base64.java b/guacamole/client/src/net/sourceforge/guacamole/net/Base64.java index a126bb6bd..1fa0676e0 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/net/Base64.java +++ b/guacamole/client/src/net/sourceforge/guacamole/net/Base64.java @@ -1,7 +1,7 @@ package net.sourceforge.guacamole.net; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/net/Configuration.java b/guacamole/client/src/net/sourceforge/guacamole/net/Configuration.java index c1dead926..b8bc8d057 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/net/Configuration.java +++ b/guacamole/client/src/net/sourceforge/guacamole/net/Configuration.java @@ -2,7 +2,7 @@ package net.sourceforge.guacamole.net; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/net/GuacamoleConfiguration.java b/guacamole/client/src/net/sourceforge/guacamole/net/GuacamoleConfiguration.java index 190ec8d35..02b588f10 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/net/GuacamoleConfiguration.java +++ b/guacamole/client/src/net/sourceforge/guacamole/net/GuacamoleConfiguration.java @@ -2,7 +2,7 @@ package net.sourceforge.guacamole.net; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify @@ -27,7 +27,6 @@ public class GuacamoleConfiguration extends Configuration { private String password; private int outputBPP; private boolean compressStream; - private String protocol; private boolean swapRedAndBlue; public GuacamoleConfiguration(ServletContext context) throws GuacamoleException { @@ -37,7 +36,6 @@ public class GuacamoleConfiguration extends Configuration { password = context.getInitParameter("password"); outputBPP = readIntParameter("output-bpp", 8, 8, 24); compressStream = readBooleanParameter("compress-stream", false); - protocol = readParameter("protocol", "vnc", "vnc"); swapRedAndBlue = readBooleanParameter("swap-red-blue", false); } @@ -54,10 +52,6 @@ public class GuacamoleConfiguration extends Configuration { return compressStream; } - public String getProtocol() { - return protocol; - } - public boolean getSwapRedAndBlue() { return swapRedAndBlue; } diff --git a/guacamole/client/src/net/sourceforge/guacamole/net/GuacamoleServlet.java b/guacamole/client/src/net/sourceforge/guacamole/net/GuacamoleServlet.java index e64c104b1..5c0a55dd9 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/net/GuacamoleServlet.java +++ b/guacamole/client/src/net/sourceforge/guacamole/net/GuacamoleServlet.java @@ -2,7 +2,7 @@ package net.sourceforge.guacamole.net; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/net/GuacamoleSession.java b/guacamole/client/src/net/sourceforge/guacamole/net/GuacamoleSession.java index d7dfe373e..197b7358c 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/net/GuacamoleSession.java +++ b/guacamole/client/src/net/sourceforge/guacamole/net/GuacamoleSession.java @@ -2,7 +2,7 @@ package net.sourceforge.guacamole.net; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify @@ -29,9 +29,6 @@ import net.sourceforge.guacamole.GuacamoleException; import net.sourceforge.guacamole.instruction.Instruction; import net.sourceforge.guacamole.event.KeyEvent; import net.sourceforge.guacamole.event.PointerEvent; -import net.sourceforge.guacamole.vnc.VNCClient; -import net.sourceforge.guacamole.vnc.VNCConfiguration; -import net.sourceforge.guacamole.vnc.VNCException; public class GuacamoleSession { @@ -107,35 +104,9 @@ public class GuacamoleSession { client.disconnect(); - String protocol = config.getProtocol(); - if (protocol.equals("vnc")) { - - // Connect to VNC server - try { - - // Read VNC-specific parameters - ServletContext context = session.getServletContext(); - VNCConfiguration vncconfig = new VNCConfiguration(context); - - client = new SessionClient( - new VNCClient( - vncconfig.getHostname(), - vncconfig.getPort(), - vncconfig.getPassword(), - vncconfig.getBPP(), - config.getOutputBPP(), - config.getSwapRedAndBlue() - ) - ); - - } - catch (VNCException e) { - throw new GuacamoleException(e); - } - - } - else - throw new GuacamoleException("Unsupported protocol: " + protocol); + client = new SessionClient( + null /* CLIENT GOES HERE */ + ); session.setAttribute("CLIENT", client); diff --git a/guacamole/client/src/net/sourceforge/guacamole/net/XMLGuacamoleServlet.java b/guacamole/client/src/net/sourceforge/guacamole/net/XMLGuacamoleServlet.java index fafe745fd..2fef0c647 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/net/XMLGuacamoleServlet.java +++ b/guacamole/client/src/net/sourceforge/guacamole/net/XMLGuacamoleServlet.java @@ -2,7 +2,7 @@ package net.sourceforge.guacamole.net; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/net/control/Connect.java b/guacamole/client/src/net/sourceforge/guacamole/net/control/Connect.java index a102d224b..cdbc20f5d 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/net/control/Connect.java +++ b/guacamole/client/src/net/sourceforge/guacamole/net/control/Connect.java @@ -1,7 +1,7 @@ package net.sourceforge.guacamole.net.control; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify diff --git a/guacamole/client/src/net/sourceforge/guacamole/net/control/Disconnect.java b/guacamole/client/src/net/sourceforge/guacamole/net/control/Disconnect.java index c061284b1..35ab2b565 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/net/control/Disconnect.java +++ b/guacamole/client/src/net/sourceforge/guacamole/net/control/Disconnect.java @@ -1,7 +1,7 @@ package net.sourceforge.guacamole.net.control; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify @@ -35,7 +35,7 @@ public class Disconnect extends XMLGuacamoleServlet { session.disconnect(); // Disconnect client. } catch (GuacamoleException e) { - throw new GuacamoleException("Error disconnecting from VNC server: " + e.getMessage(), e); + throw new GuacamoleException("Error disconnecting from server: " + e.getMessage(), e); } } diff --git a/guacamole/client/src/net/sourceforge/guacamole/net/input/Clipboard.java b/guacamole/client/src/net/sourceforge/guacamole/net/input/Clipboard.java index 959b604ea..ec299061a 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/net/input/Clipboard.java +++ b/guacamole/client/src/net/sourceforge/guacamole/net/input/Clipboard.java @@ -2,7 +2,7 @@ package net.sourceforge.guacamole.net.input; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify @@ -25,13 +25,12 @@ import org.w3c.dom.Element; import net.sourceforge.guacamole.net.GuacamoleSession; import net.sourceforge.guacamole.net.XMLGuacamoleServlet; -import net.sourceforge.guacamole.vnc.VNCException; import java.io.IOException; import java.io.Reader; /** - * Servlet which sets the VNC clipboard data. + * Servlet which sets the clipboard data. * * This servlet takes one parameter: * data: The data to set the clipboard to. diff --git a/guacamole/client/src/net/sourceforge/guacamole/net/input/Key.java b/guacamole/client/src/net/sourceforge/guacamole/net/input/Key.java index 5ad547a85..9e5b80fdb 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/net/input/Key.java +++ b/guacamole/client/src/net/sourceforge/guacamole/net/input/Key.java @@ -2,7 +2,7 @@ package net.sourceforge.guacamole.net.input; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify @@ -26,11 +26,10 @@ import net.sourceforge.guacamole.event.KeyEvent; import net.sourceforge.guacamole.net.GuacamoleSession; import net.sourceforge.guacamole.net.XMLGuacamoleServlet; -import net.sourceforge.guacamole.vnc.VNCException; /** * Servlet which accepts keyboard input events, forwards these events to the - * VNC client associated with the session, and returns the result (if any) + * client associated with the session, and returns the result (if any) * to the HTTP client via XML. * * This servlet takes three parameters: diff --git a/guacamole/client/src/net/sourceforge/guacamole/net/input/Pointer.java b/guacamole/client/src/net/sourceforge/guacamole/net/input/Pointer.java index efb8c67d1..52ccaacb6 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/net/input/Pointer.java +++ b/guacamole/client/src/net/sourceforge/guacamole/net/input/Pointer.java @@ -1,7 +1,7 @@ package net.sourceforge.guacamole.net.input; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify @@ -25,7 +25,6 @@ import net.sourceforge.guacamole.event.PointerEvent; import net.sourceforge.guacamole.net.GuacamoleSession; import net.sourceforge.guacamole.net.XMLGuacamoleServlet; -import net.sourceforge.guacamole.vnc.VNCException; public class Pointer extends XMLGuacamoleServlet { diff --git a/guacamole/client/src/net/sourceforge/guacamole/net/output/InstructionStream.java b/guacamole/client/src/net/sourceforge/guacamole/net/output/InstructionStream.java index 4fc930c7a..6a66c2c7d 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/net/output/InstructionStream.java +++ b/guacamole/client/src/net/sourceforge/guacamole/net/output/InstructionStream.java @@ -1,7 +1,7 @@ package net.sourceforge.guacamole.net.output; /* - * Guacamole - Pure JavaScript/HTML VNC Client + * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify @@ -79,7 +79,7 @@ public class InstructionStream extends GuacamoleServlet { try { - // Query new update from VNC server + // Query new update from server Client client = session.getClient(); // For all messages, until another stream is ready (we send at least one message) diff --git a/guacamole/client/src/net/sourceforge/guacamole/vnc/InputOutputStream.java b/guacamole/client/src/net/sourceforge/guacamole/vnc/InputOutputStream.java deleted file mode 100644 index a796522e9..000000000 --- a/guacamole/client/src/net/sourceforge/guacamole/vnc/InputOutputStream.java +++ /dev/null @@ -1,63 +0,0 @@ - -package net.sourceforge.guacamole.vnc; - -import java.io.IOException; -import java.io.InputStream; -import java.util.LinkedList; - -public class InputOutputStream extends InputStream { - - private int pos = 0; - private byte[] current = null; - private LinkedList buffer = new LinkedList(); - - public void write(byte[] data) { - - if (data.length == 0) - return; - - if (current == null) - current = data; - else - buffer.addLast(data); - } - - @Override - public int read() throws IOException { - - if (pos >= current.length) { - if (buffer.size() == 0) - throw new IOException("Buffer underrun."); - - current = buffer.removeFirst(); - pos = 0; - } - - return 0xFF & current[pos++]; - - } - - @Override - public int read(byte[] data) throws IOException { - return read(data, 0, data.length); - } - - @Override - public int read(byte[] data, int off, int len) throws IOException { - - if (pos >= current.length) { - if (buffer.size() == 0) - throw new IOException("Buffer underrun."); - - current = buffer.removeFirst(); - pos = 0; - } - - int amountRead = Math.min(current.length - pos, len); - System.arraycopy(current, pos, data, off, amountRead); - pos += amountRead; - - return amountRead; - } - -} diff --git a/guacamole/client/src/net/sourceforge/guacamole/vnc/VNCClient.java b/guacamole/client/src/net/sourceforge/guacamole/vnc/VNCClient.java deleted file mode 100644 index 3ac453b72..000000000 --- a/guacamole/client/src/net/sourceforge/guacamole/vnc/VNCClient.java +++ /dev/null @@ -1,1113 +0,0 @@ -package net.sourceforge.guacamole.vnc; - -/* - * Guacamole - Pure JavaScript/HTML VNC Client - * Copyright (C) 2010 Michael Jumper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import java.awt.image.WritableRaster; -import net.sourceforge.guacamole.instruction.framebuffer.PNGInstruction; -import net.sourceforge.guacamole.instruction.framebuffer.CursorInstruction; -import net.sourceforge.guacamole.instruction.framebuffer.CopyRectInstruction; -import net.sourceforge.guacamole.event.PointerEvent; -import net.sourceforge.guacamole.event.EventQueue; -import net.sourceforge.guacamole.event.KeyEvent; -import net.sourceforge.guacamole.event.EventHandler; -import java.awt.image.BufferedImage; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.UnsupportedEncodingException; - -import java.net.Socket; -import java.net.InetSocketAddress; -import java.net.SocketTimeoutException; -import java.net.UnknownHostException; -import java.util.LinkedList; - -import javax.crypto.Cipher; -import javax.crypto.spec.DESKeySpec; -import javax.crypto.SecretKeyFactory; -import javax.crypto.BadPaddingException; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.IllegalBlockSizeException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.spec.InvalidKeySpecException; -import java.util.zip.InflaterInputStream; -import java.util.zip.Inflater; -import net.sourceforge.guacamole.Client; - -import net.sourceforge.guacamole.instruction.ClipboardInstruction; -import net.sourceforge.guacamole.instruction.Instruction; -import net.sourceforge.guacamole.instruction.NameInstruction; -import net.sourceforge.guacamole.instruction.SizeInstruction; -import net.sourceforge.guacamole.instruction.framebuffer.PNGImage; -import net.sourceforge.guacamole.GuacamoleException; - -public class VNCClient extends Client { - - private static final int SECURITY_TYPE_INVALID = 0; - private static final int SECURITY_TYPE_NONE = 1; - private static final int SECURITY_TYPE_VNC_AUTHENTICATION = 2; - - private static final int SECURITY_RESULT_OK = 0; - private static final int SECURITY_RESULT_FAILED = 1; - - private static final int MESSAGE_SET_PIXEL_FORMAT = 0; - private static final int MESSAGE_SET_ENCODINGS = 2; - private static final int MESSAGE_FRAMEBUFFER_UPDATE_REQUEST = 3; - private static final int MESSAGE_KEY_EVENT = 4; - private static final int MESSAGE_POINTER_EVENT = 5; - private static final int MESSAGE_CLIENT_CUT_TEXT = 6; - - private static final int MESSAGE_FRAMEBUFFER_UPDATE = 0; - private static final int MESSAGE_SET_COLORMAP_ENTRIES = 1; - private static final int MESSAGE_BELL = 2; - private static final int MESSAGE_SERVER_CUT_TEXT = 3; - - private static final int HEXTILE_FLAG_RAW = 1; - private static final int HEXTILE_FLAG_BACKGROUND_SPECIFIED = 2; - private static final int HEXTILE_FLAG_FOREGROUND_SPECIFIED = 4; - private static final int HEXTILE_FLAG_ANY_SUBRECTS = 8; - private static final int HEXTILE_FLAG_SUBRECTS_COLORED = 16; - - private static final int ENCODING_RAW = 0; - private static final int ENCODING_COPYRECT = 1; - private static final int ENCODING_RRE = 2; - private static final int ENCODING_HEXTILE = 5; - private static final int ENCODING_ZRLE = 16; - private static final int ENCODING_CURSOR = -239; - - private final Socket sock; - private final DataInputStream input; - private final DataOutputStream output; - - private int frameBufferWidth; - private int frameBufferHeight; - private String name; - - private boolean needRefresh = true; - private VNCImageReader rawReader = null; - - private InputOutputStream toZlib; - private DataInputStream fromZlib; - - public int getFrameBufferHeight() { - return frameBufferHeight; - } - - public int getFrameBufferWidth() { - return frameBufferWidth; - } - - public String getName() { - return name; - } - - public byte reverse(byte b) { - - int input = b & 0xFF; - int output = 0; - - for (int i=0; i<8; i++) { - - output <<= 1; - - if ((input & 0x01) != 0) - output |= 0x01; - - input >>= 1; - - } - - return (byte) output; - } - - // Generates VNC key from string - private byte[] generateVNCAuthKey(String password) throws VNCException { - - try { - // Get password bytes - byte[] passwordBytes = password.getBytes("iso-8859-1"); - if (passwordBytes.length > 8) - throw new VNCException("Password must be 8 characters (bytes) or less."); - - // Reverse bit order of all bytes in array - for (int i=0; i 0 && height > 0) { - BufferedImage image = rawReader.readImage(input, width, height); - - // Construct FramebufferUpdate - PNGInstruction update = new PNGInstruction(dstX, dstY, new PNGImage(image)); - instructions.addLast(update); - - // If full-screen refresh, reset refresh flag. - if (dstX == 0 && dstY == 0 && width == frameBufferWidth && height == frameBufferHeight) - needRefresh = false; - } - } - else if (type == ENCODING_COPYRECT) { - - // Read CopyRect encoding - int srcX = input.readUnsignedShort(); - int srcY = input.readUnsignedShort(); - - // Construct FramebufferUpdate - - if (width > 0 && height > 0) { - CopyRectInstruction update = new CopyRectInstruction(dstX, dstY, width, height, srcX, srcY); - instructions.addLast(update); - } - } - else if (type == ENCODING_RRE) { - - int numSubRects = input.readInt(); - int background = rawReader.readPixel(input); - - BufferedImage image = null; - - if (width > 0 && height > 0) { - image = rawReader.generateBlankImage(width, height); - } - - //instructions.addLast(new DrawRectInstruction(dstX, dstY, width, height, background)); - if (image != null) { - fillRect(image, 0, 0, width, height, background); - } - - for (int j=0; j 0 && height > 0) { - BufferedImage image = rawReader.generateBlankImage(width, height); - WritableRaster raster = image.getWritableTile(0, 0); - - int backgroundColor = 0; - int foregroundColor = 0; - - // For all 16x16 tiles in left-to-right, top-to-bottom order - for (int tileOffsetY = 0; tileOffsetY < height; tileOffsetY += 16) { - - int tileHeight = Math.min(16, height - tileOffsetY); - - for (int tileOffsetX = 0; tileOffsetX < width; tileOffsetX += 16) { - - int tileWidth = Math.min(16, width - tileOffsetX); - - int flags = input.read(); - - // If RAW flag is set, other flags are irrelevant. - if ((flags & HEXTILE_FLAG_RAW) != 0) { - - // Read and draw raw tile - BufferedImage tile = rawReader.readImage(input, tileWidth, tileHeight); - raster.setRect(tileOffsetX, tileOffsetY, tile.getData()); - - } - - // RAW = 0 - else { - - // If background specified, read pixel value - if ((flags & HEXTILE_FLAG_BACKGROUND_SPECIFIED) != 0) - backgroundColor = rawReader.readPixel(input); - - // Draw background - fillRect(image, tileOffsetX, tileOffsetY, tileWidth, tileHeight, backgroundColor); - - // If foreground specified, read pixel value - if ((flags & HEXTILE_FLAG_FOREGROUND_SPECIFIED) != 0) - foregroundColor = rawReader.readPixel(input); - - // If subrects present, read subrects - if ((flags & HEXTILE_FLAG_ANY_SUBRECTS) != 0) { - - // Read number of subrects, determine whether they are colored - int numSubRects = input.read(); - boolean colored = (flags & HEXTILE_FLAG_SUBRECTS_COLORED) != 0; - - int color = foregroundColor; - for (int j=0; j> 4; - int y = position & 0x0F; - - // Read dimensions - int dimensions = input.read(); - int w = (dimensions >> 4) + 1; - int h = (dimensions & 0x0F) + 1; - - fillRect(image, tileOffsetX+x, tileOffsetY+y, w, h, color); - } - - } - - } // end if not raw - - } - } - - // Send as png instruction (rects are too inefficient) - PNGInstruction update = new PNGInstruction(dstX, dstY, new PNGImage(image)); - instructions.addLast(update); - - // If full-screen refresh, reset refresh flag. - if (dstX == 0 && dstY == 0 && width == frameBufferWidth && height == frameBufferHeight) - needRefresh = false; - } - - } - else if (type == ENCODING_ZRLE) { - - // Read ZLIB data - int length = input.readInt(); - byte[] zlibData = new byte[length]; - input.readFully(zlibData); - - // Write data to ZLIB stream - toZlib.write(zlibData); - - - if (width > 0 && height > 0) { - BufferedImage image = rawReader.generateBlankImage(width, height); - WritableRaster raster = image.getWritableTile(0, 0); - - // For all 64x64 tiles in left-to-right, top-to-bottom order - for (int tileOffsetY = 0; tileOffsetY < height; tileOffsetY += 64) { - - int tileHeight = Math.min(64, height - tileOffsetY); - - for (int tileOffsetX = 0; tileOffsetX < width; tileOffsetX += 64) { - - int tileWidth = Math.min(64, width - tileOffsetX); - - // Get subencoding type (RLE flag + palette size) - int subencodingType = fromZlib.read(); - - // If RAW, just read raw image - if (subencodingType == 0) { - - // Read and draw raw tile - if (image != null) { - BufferedImage tile = rawReader.readCImage(fromZlib, tileWidth, tileHeight); - raster.setRect(tileOffsetX, tileOffsetY, tile.getData()); - } - - } - - // If single color... - else if (subencodingType == 1) { - - // Read color - int color = rawReader.readCPixel(fromZlib); - - // Draw solid rectangle - if (image != null) { - fillRect(image, tileOffsetX, tileOffsetY, tileWidth, tileHeight, color); - } - - } - - // Packed palette - else if (subencodingType >= 2 && subencodingType <= 16) { - - int paletteSize = subencodingType; - int[] palette = new int[paletteSize]; - - // Read palette - for (int j=0; j> (8 - indexBits); - buffer <<= indexBits; - bitsAvailable -= indexBits; - - // Write pixel to image - image.setRGB(tileOffsetX+x, tileOffsetY+y, 0xFF000000 | palette[index]); - - } - } - - } - - // Plain RLE - else if (subencodingType == 128) { - - int color = -1; - int runRemaining= 0; - - for (int y=0; y= 130 && subencodingType <= 255) { - - int paletteSize = subencodingType - 128; - int[] palette = new int[paletteSize]; - - // Read palette - for (int j=0; j 0 && height > 0) { - BufferedImage image = rawReader.readImage(input, width, height); - - // Read cursor mask - for (int y=0; y> 8; - int green = input.readUnsignedShort() >> 8; - int blue = input.readUnsignedShort() >> 8; - - reds[i] = (byte) red; - greens[i] = (byte) green; - blues[i] = (byte) blue; - alphas[i] = (byte) 0xFF; - } - - // Set reader - rawReader = new VNCIndexedImageReader(reds, greens, blues); - } - - private void handleBell() { - // Do nothing, currently - // This message has no data, so no need to dummy-read. - log("BELL!"); - } - - private void handleServerCutText() throws IOException { - - byte[] padding = new byte[3]; - input.readFully(padding); - - int length = input.readInt(); - byte[] textBytes = new byte[length]; - input.readFully(textBytes); - - String clipboard = new String(textBytes, "UTF-8"); - instructions.addLast(new ClipboardInstruction(clipboard)); - } - - private void setPixelFormat(int bitsPerPixel, int depth, - boolean bigEndian, boolean trueColor, - int redMax, int greenMax, int blueMax, - int redShift, int greenShift, int blueShift) - throws IOException { - - synchronized (output) { - output.writeByte(MESSAGE_SET_PIXEL_FORMAT); - output.writeBytes(" "); // Padding - output.writeByte(bitsPerPixel); - output.writeByte(depth); - output.writeBoolean(bigEndian); - output.writeBoolean(trueColor); - output.writeShort(redMax); - output.writeShort(greenMax); - output.writeShort(blueMax); - output.writeByte(redShift); - output.writeByte(greenShift); - output.writeByte(blueShift); - output.writeBytes(" "); // Padding - output.flush(); - } - - } - - // Last is most recent message. - private final Object instructionLock = new Object(); - private LinkedList instructions = new LinkedList(); - - @Override - public void setClipboard(String clipboard) throws GuacamoleException { - try { - sendClipboard(clipboard); - } - catch (IOException e) { - throw new GuacamoleException("Could not send clipboard data to VNC server (network error).", e); - } - } - - @Override - public void send(KeyEvent event) throws GuacamoleException { - try { - // Add to queue - keyEvents.add(event); - } - catch (IOException e) { - throw new GuacamoleException("Could not send keyboard event to VNC server (network error).", e); - } - } - - @Override - public void send(PointerEvent event) throws GuacamoleException { - try { - // Add to queue - pointerEvents.add(event); - } - catch (IOException e) { - throw new GuacamoleException("Could not send pointer event to VNC server (network error).", e); - } - } - - private static final int EVENT_DEADLINE = 500; - - private EventQueue keyEvents = new EventQueue(new EventHandler() { - - public void handle(KeyEvent e) throws IOException { - sendKeyEvent(e.getPressed(), e.getKeySym()); - } - - }, EVENT_DEADLINE); - - private EventQueue pointerEvents = new EventQueue(new EventHandler() { - - public void handle(PointerEvent e) throws IOException { - sendPointerEvent( - e.isLeftButtonPressed(), - e.isMiddleButtonPressed(), - e.isRightButtonPressed(), - e.isUpButtonPressed(), - e.isDownButtonPressed(), - e.getX(), - e.getY() - ); - } - - }, EVENT_DEADLINE); - - private void sendClipboard(String clipboard) throws IOException { - - synchronized (output) { - output.writeByte(MESSAGE_CLIENT_CUT_TEXT); - output.writeBytes(" "); // Padding - - byte[] encodedString = clipboard.getBytes("UTF-8"); - - output.writeInt(encodedString.length); - output.write(encodedString); - output.flush(); - } - - } - - private void sendKeyEvent(boolean pressed, int keysym) throws IOException { - - synchronized (output) { - output.writeByte(MESSAGE_KEY_EVENT); - output.writeBoolean(pressed); - output.writeBytes(" "); // Padding - output.writeInt(keysym); - output.flush(); - } - - //log("Sent key event."); - } - - private void sendPointerEvent(boolean left, boolean middle, boolean right, boolean up, boolean down, int x, int y) throws IOException { - - int buttonMask = 0; - if (left) buttonMask |= 1; - if (middle) buttonMask |= 2; - if (right) buttonMask |= 4; - if (up) buttonMask |= 8; - if (down) buttonMask |= 16; - - synchronized (output) { - output.writeByte(MESSAGE_POINTER_EVENT); - output.writeByte(buttonMask); - output.writeShort(x); - output.writeShort(y); - output.flush(); - } - - //log("Sent pointer event."); - } - - private void sendEncodings(int... encodings) throws IOException { - - synchronized (output) { - output.writeByte(MESSAGE_SET_ENCODINGS); - output.writeBytes(" "); // padding - output.writeShort(encodings.length); - - for (int encoding : encodings) - output.writeInt(encoding); - } - - } - - @Override - public Instruction nextInstruction(boolean blocking) - throws GuacamoleException { - - synchronized (instructionLock) { - if (instructions.size() == 0) { - - if (blocking) { - try { - // Send framebuffer update request - synchronized (output) { - output.writeByte(MESSAGE_FRAMEBUFFER_UPDATE_REQUEST); - output.writeBoolean(!needRefresh); // Incremental - output.writeShort(0); // x - output.writeShort(0); // y - output.writeShort(frameBufferWidth); // width - output.writeShort(frameBufferHeight); // height - output.flush(); - } - } - catch (IOException e) { - throw new GuacamoleException("Could not send framebuffer update request to VNC server (network error).", e); - } - } - - // Handle incoming messages, blocking until one message exists - try { - handleMessages(blocking); - } - catch (IOException e) { - throw new GuacamoleException("Could not read messages from VNC server (network error).", e); - } - catch (VNCException e) { - throw new GuacamoleException(e); - } - - } - - // If no messages, return null. - if (instructions.size() == 0) - return null; - - // Send messages, oldest first - return instructions.removeFirst(); - } - - } - - private void log(String str) { - System.err.println(str); - } - - @Override - public void disconnect() throws GuacamoleException { - try { - - // Close event queues - keyEvents.close(); - pointerEvents.close(); - - // Close socket - sock.close(); - } - catch (IOException e) { - throw new GuacamoleException("Network error while closing socket.", e); - } - } -} - diff --git a/guacamole/client/src/net/sourceforge/guacamole/vnc/VNCConfiguration.java b/guacamole/client/src/net/sourceforge/guacamole/vnc/VNCConfiguration.java deleted file mode 100644 index a0a68ad3a..000000000 --- a/guacamole/client/src/net/sourceforge/guacamole/vnc/VNCConfiguration.java +++ /dev/null @@ -1,60 +0,0 @@ - -package net.sourceforge.guacamole.vnc; - -/* - * Guacamole - Pure JavaScript/HTML VNC Client - * Copyright (C) 2010 Michael Jumper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import net.sourceforge.guacamole.net.Configuration; -import net.sourceforge.guacamole.GuacamoleException; -import javax.servlet.ServletContext; - -public class VNCConfiguration extends Configuration { - - private String hostname; - private int port; - private String password; - private int bpp; - - public VNCConfiguration(ServletContext context) throws GuacamoleException { - - super(context); - - hostname = readParameter("host", null); - port = readIntParameter("port", null); - password = context.getInitParameter("password"); - bpp = readIntParameter("bpp", 24, 8, 16, 24); - - } - - public int getBPP() { - return bpp; - } - - public String getPassword() { - return password; - } - - public String getHostname() { - return hostname; - } - - public int getPort() { - return port; - } - -} diff --git a/guacamole/client/src/net/sourceforge/guacamole/vnc/VNCException.java b/guacamole/client/src/net/sourceforge/guacamole/vnc/VNCException.java deleted file mode 100644 index ae14c65bd..000000000 --- a/guacamole/client/src/net/sourceforge/guacamole/vnc/VNCException.java +++ /dev/null @@ -1,32 +0,0 @@ - -package net.sourceforge.guacamole.vnc; - -/* - * Guacamole - Pure JavaScript/HTML VNC Client - * Copyright (C) 2010 Michael Jumper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -public class VNCException extends Exception { - - public VNCException(String message, Throwable cause) { - super(message, cause); - } - - public VNCException(String message) { - super(message); - } - -} diff --git a/guacamole/client/src/net/sourceforge/guacamole/vnc/VNCFullColorImageReader.java b/guacamole/client/src/net/sourceforge/guacamole/vnc/VNCFullColorImageReader.java deleted file mode 100644 index 9509d4204..000000000 --- a/guacamole/client/src/net/sourceforge/guacamole/vnc/VNCFullColorImageReader.java +++ /dev/null @@ -1,239 +0,0 @@ -package net.sourceforge.guacamole.vnc; - -/* - * Guacamole - Pure JavaScript/HTML VNC Client - * Copyright (C) 2010 Michael Jumper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import java.awt.image.BufferedImage; -import java.awt.image.IndexColorModel; -import java.io.DataInputStream; -import java.io.IOException; - - -public class VNCFullColorImageReader extends VNCImageReader { - - private int bpp; - private int depth; - - private int redBits; - private int greenBits; - private int blueBits; - - private int redMax; - private int greenMax; - private int blueMax; - - private int redShift; - private int greenShift; - private int blueShift; - - private boolean readAsIndexed; - private boolean bigEndian; - - private boolean swapRedAndBlue; - - public boolean isBigEndian() { - return bigEndian; - } - - public int getBitsPerPixel() { - return bpp; - } - - public int getDepth() { - return depth; - } - - public int getRedMax() { - return redMax; - } - - public int getGreenMax() { - return greenMax; - } - - public int getBlueMax() { - return blueMax; - } - - public int getRedShift() { - return redShift; - } - - public int getGreenShift() { - return greenShift; - } - - public int getBlueShift() { - return blueShift; - } - - // Set up BGR reader - public VNCFullColorImageReader(boolean bigEndian, int redBits, int greenBits, int blueBits, int outputBPP, boolean swapRedAndBlue) throws VNCException { - - this.swapRedAndBlue = swapRedAndBlue; - - depth = redBits + greenBits + blueBits; - - if (depth > 0 && depth <= 8) - bpp = 8; - else if (depth <= 16) - bpp = 16; - else if (depth <= 32) - bpp = 32; - else - throw new VNCException("Illegal bit depth for VNC images: " + bpp); - - this.redBits = redBits; - this.greenBits = greenBits; - this.blueBits = blueBits; - - blueMax = (1 << blueBits) - 1; - greenMax = (1 << greenBits) - 1; - redMax = (1 << redBits) - 1; - - redShift = greenBits + blueBits; - greenShift = blueBits; - blueShift = 0; - - if (outputBPP == 8) - this.readAsIndexed = true; - else if (outputBPP == 24) - this.readAsIndexed = false; - else - throw new VNCException("Only 8-bit or 24-bit output is supported."); - - } - - @Override - public int readCPixel(DataInputStream input) throws IOException { - - if (redBits != 8 || greenBits != 8 || blueBits != 8) - return readPixel(input); - - int red; - int green; - int blue; - - if (bigEndian) { - red = input.read(); - green = input.read(); - blue = input.read(); - } - else { - blue = input.read(); - green = input.read(); - red = input.read(); - } - - if (swapRedAndBlue) - return (blue << 16) | (green << 8) | red; - else - return (red << 16) | (green << 8) | blue; - } - - @Override - public int readPixel(DataInputStream input) throws IOException { - int value; - switch (bpp) { - case 8: - value = input.read(); - break; - case 16: - - short inputShort = input.readShort(); - if (!bigEndian) inputShort = Short.reverseBytes(inputShort); - - value = inputShort; - break; - case 32: - - int inputInt = input.readInt(); - if (!bigEndian) inputInt = Integer.reverseBytes(inputInt); - - value = inputInt; - break; - default: - throw new IOException("Invalid BPP."); - } - - int red = (value >> redShift) & redMax; - int green = (value >> greenShift) & greenMax; - int blue = (value >> blueShift) & blueMax; - - red <<= 8 - redBits; - green <<= 8 - greenBits; - blue <<= 8 - blueBits; - - if (swapRedAndBlue) - return (blue << 16) | (green << 8) | red; - else - return (red << 16) | (green << 8) | blue; - } - - @Override - public BufferedImage generateBlankImage(int width, int height) { - if (readAsIndexed) - return new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED, COLOR_MODEL); - return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - } - - // Load color model - public static final IndexColorModel COLOR_MODEL; - static { - // Construct color model - byte[] colorShade = {0, (byte) 51, (byte) 104, (byte) 153, (byte) 204, (byte) 255}; - byte[] greyShade = new byte[39]; - for (int i=1; i<40; i++) - greyShade[i-1] = (byte) (6*i); - - byte[] red = new byte[colorShade.length*colorShade.length*colorShade.length+greyShade.length+1]; - byte[] green = new byte[colorShade.length*colorShade.length*colorShade.length+greyShade.length+1]; - byte[] blue = new byte[colorShade.length*colorShade.length*colorShade.length+greyShade.length+1]; - byte[] alpha = new byte[colorShade.length*colorShade.length*colorShade.length+greyShade.length+1]; - - int color = 0; - for (int r=0; r. - */ - -import java.awt.image.BufferedImage; -import java.io.DataInputStream; -import java.io.IOException; - -public abstract class VNCImageReader { - - public BufferedImage readCImage(DataInputStream input, int width, int height) throws IOException { - - BufferedImage image = generateBlankImage(width, height); - // Read image - - for (int pixelY=0; pixelY. - */ - -import java.awt.image.BufferedImage; -import java.awt.image.IndexColorModel; -import java.io.DataInputStream; -import java.io.IOException; - - -public class VNCIndexedImageReader extends VNCImageReader { - - private IndexColorModel palette; - private byte[] red; - private byte[] green; - private byte[] blue; - - // Set up BGR reader - public VNCIndexedImageReader(byte[] red, byte[] green, byte[] blue) throws VNCException { - - this.red = red; - this.green = green; - this.blue = blue; - - palette = new IndexColorModel(8, 256, red, green, blue); - if (palette.getMapSize() != 256) - throw new VNCException("Currently, only 256-color maps are supported."); - - } - - @Override - public int readPixel(DataInputStream input) throws IOException { - int value = input.read(); - int color = (red[value] << 16) | (green[value] << 8) | blue[value]; - return color; - } - - @Override - public BufferedImage generateBlankImage(int width, int height) { - BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED, palette); - return image; - } - - // Load color model - public static final IndexColorModel COLOR_MODEL; - static { - // Construct color model - byte[] colorShade = {0, (byte) 51, (byte) 104, (byte) 153, (byte) 204, (byte) 255}; - byte[] greyShade = new byte[39]; - for (int i=1; i<40; i++) - greyShade[i-1] = (byte) (6*i); - - byte[] red = new byte[colorShade.length*colorShade.length*colorShade.length+greyShade.length+1]; - byte[] green = new byte[colorShade.length*colorShade.length*colorShade.length+greyShade.length+1]; - byte[] blue = new byte[colorShade.length*colorShade.length*colorShade.length+greyShade.length+1]; - byte[] alpha = new byte[colorShade.length*colorShade.length*colorShade.length+greyShade.length+1]; - - int color = 0; - for (int r=0; r