mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 09:03:21 +00:00 
			
		
		
		
	Expose immutable List rather than array in GuacamoleInstruction. Bump version to 0.8.0.
This commit is contained in:
		
				
					committed by
					
						 Michael Jumper
						Michael Jumper
					
				
			
			
				
	
			
			
			
						parent
						
							1b103f80a8
						
					
				
				
					commit
					fbe1339623
				
			| @@ -37,6 +37,7 @@ package net.sourceforge.guacamole.protocol; | ||||
|  * | ||||
|  * ***** END LICENSE BLOCK ***** */ | ||||
|  | ||||
| import java.util.List; | ||||
| import net.sourceforge.guacamole.GuacamoleException; | ||||
| import net.sourceforge.guacamole.GuacamoleServerException; | ||||
| import net.sourceforge.guacamole.io.GuacamoleReader; | ||||
| @@ -117,16 +118,21 @@ public class ConfiguredGuacamoleSocket implements GuacamoleSocket { | ||||
|         } while (!instruction.getOpcode().equals("args")); | ||||
|  | ||||
|         // Build args list off provided names and config | ||||
|         String[] args = new String[instruction.getArgs().length]; | ||||
|         for (int i=0; i<instruction.getArgs().length; i++) { | ||||
|         List<String> arg_names = instruction.getArgs(); | ||||
|         String[] arg_values = new String[arg_names.size()]; | ||||
|         for (int i=0; i<arg_names.size(); i++) { | ||||
|  | ||||
|             String requiredArg = instruction.getArgs()[i]; | ||||
|             // Retrieve argument name | ||||
|             String arg_name = arg_names.get(i); | ||||
|  | ||||
|             String value = config.getParameter(requiredArg); | ||||
|             if (value != null) | ||||
|                 args[i] = value; | ||||
|             else | ||||
|                 args[i] = ""; | ||||
|             // Get defined value for name | ||||
|             String value = config.getParameter(arg_name); | ||||
|  | ||||
|             // If value defined, set that value | ||||
|             if (value != null) arg_values[i] = value; | ||||
|  | ||||
|             // Otherwise, leave value blank | ||||
|             else arg_values[i] = ""; | ||||
|  | ||||
|         } | ||||
|  | ||||
| @@ -154,7 +160,7 @@ public class ConfiguredGuacamoleSocket implements GuacamoleSocket { | ||||
|                 )); | ||||
|  | ||||
|         // Send args | ||||
|         writer.writeInstruction(new GuacamoleInstruction("connect", args)); | ||||
|         writer.writeInstruction(new GuacamoleInstruction("connect", arg_values)); | ||||
|  | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,10 @@ | ||||
|  | ||||
| package net.sourceforge.guacamole.protocol; | ||||
|  | ||||
| import java.util.Arrays; | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
|  | ||||
| /* ***** BEGIN LICENSE BLOCK ***** | ||||
|  * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | ||||
|  * | ||||
| @@ -45,8 +49,15 @@ package net.sourceforge.guacamole.protocol; | ||||
|  */ | ||||
| public class GuacamoleInstruction { | ||||
|  | ||||
|     /** | ||||
|      * The opcode of this instruction. | ||||
|      */ | ||||
|     private String opcode; | ||||
|     private String[] args; | ||||
|  | ||||
|     /** | ||||
|      * All arguments of this instruction, in order. | ||||
|      */ | ||||
|     private List<String> args; | ||||
|  | ||||
|     /** | ||||
|      * Creates a new GuacamoleInstruction having the given Operation and | ||||
| @@ -58,7 +69,7 @@ public class GuacamoleInstruction { | ||||
|      */ | ||||
|     public GuacamoleInstruction(String opcode, String... args) { | ||||
|         this.opcode = opcode; | ||||
|         this.args = args; | ||||
|         this.args = Collections.unmodifiableList(Arrays.asList(args)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -70,13 +81,14 @@ public class GuacamoleInstruction { | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns an array of all argument values specified for this | ||||
|      * GuacamoleInstruction. | ||||
|      * Returns a List of all argument values specified for this | ||||
|      * GuacamoleInstruction. Note that the List returned is immutable. | ||||
|      * Attempts to modify the list will result in exceptions. | ||||
|      * | ||||
|      * @return An array of all argument values specified for this | ||||
|      * @return A List of all argument values specified for this | ||||
|      *         GuacamoleInstruction. | ||||
|      */ | ||||
|     public String[] getArgs() { | ||||
|     public List<String> getArgs() { | ||||
|         return args; | ||||
|     } | ||||
|  | ||||
| @@ -92,17 +104,20 @@ public class GuacamoleInstruction { | ||||
|  | ||||
|         StringBuilder buff = new StringBuilder(); | ||||
|  | ||||
|         // Write opcode | ||||
|         buff.append(opcode.length()); | ||||
|         buff.append('.'); | ||||
|         buff.append(opcode); | ||||
|  | ||||
|         for (int i=0; i<args.length; i++) { | ||||
|         // Write argument values | ||||
|         for (String value : args) { | ||||
|             buff.append(','); | ||||
|             buff.append(args[i].length()); | ||||
|             buff.append(value.length()); | ||||
|             buff.append('.'); | ||||
|             buff.append(args[i]); | ||||
|             buff.append(value); | ||||
|         } | ||||
|  | ||||
|         // Write terminator | ||||
|         buff.append(';'); | ||||
|  | ||||
|         return buff.toString(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user