diff --git a/guacamole-common/pom.xml b/guacamole-common/pom.xml index 9a2c74e7e..0e03c342d 100644 --- a/guacamole-common/pom.xml +++ b/guacamole-common/pom.xml @@ -5,7 +5,7 @@ net.sourceforge.guacamole guacamole-common jar - 0.7.1 + 0.8.0 guacamole-common http://guac-dev.org/ diff --git a/guacamole-common/src/main/java/net/sourceforge/guacamole/io/ReaderGuacamoleReader.java b/guacamole-common/src/main/java/net/sourceforge/guacamole/io/ReaderGuacamoleReader.java index cb57eaaec..ed4ed4580 100644 --- a/guacamole-common/src/main/java/net/sourceforge/guacamole/io/ReaderGuacamoleReader.java +++ b/guacamole-common/src/main/java/net/sourceforge/guacamole/io/ReaderGuacamoleReader.java @@ -43,7 +43,6 @@ import java.util.LinkedList; import net.sourceforge.guacamole.GuacamoleException; import net.sourceforge.guacamole.GuacamoleServerException; import net.sourceforge.guacamole.protocol.GuacamoleInstruction; -import net.sourceforge.guacamole.protocol.GuacamoleInstruction.Operation; /** * A GuacamoleReader which wraps a standard Java Reader, using that Reader as @@ -251,7 +250,7 @@ public class ReaderGuacamoleReader implements GuacamoleReader { // Create instruction GuacamoleInstruction instruction = new GuacamoleInstruction( - Operation.fromOpcode(opcode), + opcode, elements.toArray(new String[elements.size()]) ); diff --git a/guacamole-common/src/main/java/net/sourceforge/guacamole/protocol/ConfiguredGuacamoleSocket.java b/guacamole-common/src/main/java/net/sourceforge/guacamole/protocol/ConfiguredGuacamoleSocket.java index a8bb31bd3..0dd34abe8 100644 --- a/guacamole-common/src/main/java/net/sourceforge/guacamole/protocol/ConfiguredGuacamoleSocket.java +++ b/guacamole-common/src/main/java/net/sourceforge/guacamole/protocol/ConfiguredGuacamoleSocket.java @@ -42,7 +42,6 @@ import net.sourceforge.guacamole.GuacamoleServerException; import net.sourceforge.guacamole.io.GuacamoleReader; import net.sourceforge.guacamole.io.GuacamoleWriter; import net.sourceforge.guacamole.net.GuacamoleSocket; -import net.sourceforge.guacamole.protocol.GuacamoleInstruction.Operation; /** * A GuacamoleSocket which pre-configures the connection based on a given @@ -104,7 +103,7 @@ public class ConfiguredGuacamoleSocket implements GuacamoleSocket { GuacamoleWriter writer = socket.getWriter(); // Send protocol - writer.writeInstruction(new GuacamoleInstruction(Operation.CLIENT_SELECT, config.getProtocol())); + writer.writeInstruction(new GuacamoleInstruction("select", config.getProtocol())); // Wait for server args GuacamoleInstruction instruction; @@ -115,7 +114,7 @@ public class ConfiguredGuacamoleSocket implements GuacamoleSocket { if (instruction == null) throw new GuacamoleServerException("End of stream during initial handshake."); - } while (instruction.getOperation() != Operation.SERVER_ARGS); + } while (!instruction.getOpcode().equals("args")); // Build args list off provided names and config String[] args = new String[instruction.getArgs().length]; @@ -134,7 +133,7 @@ public class ConfiguredGuacamoleSocket implements GuacamoleSocket { // Send size writer.writeInstruction( new GuacamoleInstruction( - Operation.CLIENT_SIZE, + "size", Integer.toString(info.getOptimalScreenWidth()), Integer.toString(info.getOptimalScreenHeight()) ) @@ -143,19 +142,19 @@ public class ConfiguredGuacamoleSocket implements GuacamoleSocket { // Send supported audio formats writer.writeInstruction( new GuacamoleInstruction( - Operation.CLIENT_AUDIO, + "audio", info.getAudioMimetypes().toArray(new String[0]) )); // Send supported video formats writer.writeInstruction( new GuacamoleInstruction( - Operation.CLIENT_VIDEO, + "video", info.getVideoMimetypes().toArray(new String[0]) )); // Send args - writer.writeInstruction(new GuacamoleInstruction(Operation.CLIENT_CONNECT, args)); + writer.writeInstruction(new GuacamoleInstruction("connect", args)); } diff --git a/guacamole-common/src/main/java/net/sourceforge/guacamole/protocol/GuacamoleInstruction.java b/guacamole-common/src/main/java/net/sourceforge/guacamole/protocol/GuacamoleInstruction.java index 028955c28..75032d352 100644 --- a/guacamole-common/src/main/java/net/sourceforge/guacamole/protocol/GuacamoleInstruction.java +++ b/guacamole-common/src/main/java/net/sourceforge/guacamole/protocol/GuacamoleInstruction.java @@ -37,8 +37,6 @@ package net.sourceforge.guacamole.protocol; * * ***** END LICENSE BLOCK ***** */ -import java.util.HashMap; - /** * An abstract representation of a Guacamole instruction, as defined by the * Guacamole protocol. @@ -47,111 +45,28 @@ import java.util.HashMap; */ public class GuacamoleInstruction { - /** - * The operation performed by a particular Guacamole instruction. Each - * Operation is associated with a unique opcode. - */ - public enum Operation { - - - /** - * Message sent from client to server specifying the optimal or - * desired screen size. - */ - CLIENT_SIZE("size"), - - /** - * Message sent from client to server specifying which audio mimetypes - * are supported. - */ - CLIENT_AUDIO("audio"), - - /** - * Message sent from client to server specifying which video mimetypes - * are supported. - */ - CLIENT_VIDEO("video"), - - /** - * Message sent from client to server specifying which protocol is - * to be used. - */ - CLIENT_SELECT("select"), - - /** - * Message sent from client to server specifying which argument - * values correspond to the arguments required by the selected - * protocol. - */ - CLIENT_CONNECT("connect"), - - /** - * Message sent from server to client specifying which arguments - * are required by the selected protocol. - */ - SERVER_ARGS("args"); - - private String opcode; - private Operation(String opcode) { - this.opcode = opcode; - } - - /** - * Returns the unique opcode associated with this Operation. - * @return The unique opcode associated with this Operation. - */ - public String getOpcode() { - return opcode; - } - - /** - * Static hash of all opcodes and their corresponding Operations. - */ - private static final HashMap opcodeToOperation; - static { - - opcodeToOperation = new HashMap(); - - for (Operation operation : Operation.values()) - opcodeToOperation.put(operation.getOpcode(), operation); - - } - - /** - * Returns the corresponding Operation having the given opcode, if any. - * - * @param opcode The unique opcode associated with an Operation. - * @return The Operation associated with the given opcode, or null if - * no such Operation is defined. - */ - public static Operation fromOpcode(String opcode) { - return opcodeToOperation.get(opcode); - } - - } - - private Operation operation; + private String opcode; private String[] args; /** * Creates a new GuacamoleInstruction having the given Operation and * list of arguments values. * - * @param operation The Operation of the instruction to create. + * @param operation The opcode of the instruction to create. * @param args The list of argument values to provide in the new * instruction if any. */ - public GuacamoleInstruction(Operation operation, String... args) { - this.operation = operation; + public GuacamoleInstruction(String opcode, String... args) { + this.opcode = opcode; this.args = args; } /** - * Returns the Operation associated with this GuacamoleInstruction. - * @return The Operation associated with this GuacamoleInstruction. + * Returns the opcode associated with this GuacamoleInstruction. + * @return The opcode associated with this GuacamoleInstruction. */ - public Operation getOperation() { - return operation; + public String getOpcode() { + return opcode; } /** @@ -177,9 +92,9 @@ public class GuacamoleInstruction { StringBuilder buff = new StringBuilder(); - buff.append(operation.getOpcode().length()); + buff.append(opcode.length()); buff.append('.'); - buff.append(operation.getOpcode()); + buff.append(opcode); for (int i=0; i