mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-10-27 07:03:07 +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
parent
1b103f80a8
commit
fbe1339623
@@ -37,6 +37,7 @@ package net.sourceforge.guacamole.protocol;
|
|||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import net.sourceforge.guacamole.GuacamoleException;
|
import net.sourceforge.guacamole.GuacamoleException;
|
||||||
import net.sourceforge.guacamole.GuacamoleServerException;
|
import net.sourceforge.guacamole.GuacamoleServerException;
|
||||||
import net.sourceforge.guacamole.io.GuacamoleReader;
|
import net.sourceforge.guacamole.io.GuacamoleReader;
|
||||||
@@ -117,16 +118,21 @@ public class ConfiguredGuacamoleSocket implements GuacamoleSocket {
|
|||||||
} while (!instruction.getOpcode().equals("args"));
|
} while (!instruction.getOpcode().equals("args"));
|
||||||
|
|
||||||
// Build args list off provided names and config
|
// Build args list off provided names and config
|
||||||
String[] args = new String[instruction.getArgs().length];
|
List<String> arg_names = instruction.getArgs();
|
||||||
for (int i=0; i<instruction.getArgs().length; i++) {
|
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);
|
// Get defined value for name
|
||||||
if (value != null)
|
String value = config.getParameter(arg_name);
|
||||||
args[i] = value;
|
|
||||||
else
|
// If value defined, set that value
|
||||||
args[i] = "";
|
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
|
// Send args
|
||||||
writer.writeInstruction(new GuacamoleInstruction("connect", args));
|
writer.writeInstruction(new GuacamoleInstruction("connect", arg_values));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
|
|
||||||
package net.sourceforge.guacamole.protocol;
|
package net.sourceforge.guacamole.protocol;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
@@ -45,8 +49,15 @@ package net.sourceforge.guacamole.protocol;
|
|||||||
*/
|
*/
|
||||||
public class GuacamoleInstruction {
|
public class GuacamoleInstruction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The opcode of this instruction.
|
||||||
|
*/
|
||||||
private String opcode;
|
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
|
* Creates a new GuacamoleInstruction having the given Operation and
|
||||||
@@ -58,7 +69,7 @@ public class GuacamoleInstruction {
|
|||||||
*/
|
*/
|
||||||
public GuacamoleInstruction(String opcode, String... args) {
|
public GuacamoleInstruction(String opcode, String... args) {
|
||||||
this.opcode = opcode;
|
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
|
* Returns a List of all argument values specified for this
|
||||||
* GuacamoleInstruction.
|
* 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.
|
* GuacamoleInstruction.
|
||||||
*/
|
*/
|
||||||
public String[] getArgs() {
|
public List<String> getArgs() {
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,17 +104,20 @@ public class GuacamoleInstruction {
|
|||||||
|
|
||||||
StringBuilder buff = new StringBuilder();
|
StringBuilder buff = new StringBuilder();
|
||||||
|
|
||||||
|
// Write opcode
|
||||||
buff.append(opcode.length());
|
buff.append(opcode.length());
|
||||||
buff.append('.');
|
buff.append('.');
|
||||||
buff.append(opcode);
|
buff.append(opcode);
|
||||||
|
|
||||||
for (int i=0; i<args.length; i++) {
|
// Write argument values
|
||||||
|
for (String value : args) {
|
||||||
buff.append(',');
|
buff.append(',');
|
||||||
buff.append(args[i].length());
|
buff.append(value.length());
|
||||||
buff.append('.');
|
buff.append('.');
|
||||||
buff.append(args[i]);
|
buff.append(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write terminator
|
||||||
buff.append(';');
|
buff.append(';');
|
||||||
|
|
||||||
return buff.toString();
|
return buff.toString();
|
||||||
|
|||||||
Reference in New Issue
Block a user