aboutsummaryrefslogtreecommitdiffstats
path: root/java/com
diff options
context:
space:
mode:
authorMathias Jonsson <math.jonsson@gmail.com>2018-04-22 19:10:30 +0200
committerMathias Jonsson <math.jonsson@gmail.com>2018-05-22 22:48:41 +0200
commit50439d78fae2828356bfde789ec5c4fd0911ae09 (patch)
tree5b7828255715e8073b259cb39e110fb59dfceb4a /java/com
parent105177fc07d07521eafdcf373c1825a59b9c554d (diff)
downloadtigervnc-50439d78fae2828356bfde789ec5c4fd0911ae09.tar.gz
tigervnc-50439d78fae2828356bfde789ec5c4fd0911ae09.zip
Accept a cfg as an argument as an alt way to start the viewer
The user can specify a tigervnc configuration file as an argument to the viewer. Previously the viewer assumed this to be a server, but now we will first check if there is any file matching the given argument. If so, try to load the content of that file, like we normally do. Fixes issue #38.
Diffstat (limited to 'java/com')
-rw-r--r--java/com/tigervnc/vncviewer/VncViewer.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/java/com/tigervnc/vncviewer/VncViewer.java b/java/com/tigervnc/vncviewer/VncViewer.java
index 566169be..93d3f3be 100644
--- a/java/com/tigervnc/vncviewer/VncViewer.java
+++ b/java/com/tigervnc/vncviewer/VncViewer.java
@@ -208,6 +208,8 @@ public class VncViewer extends javax.swing.JApplet
vncServerName.put(argv[i].toCharArray()).flip();
}
+ // Check if the server name in reality is a configuration file
+ potentiallyLoadConfigurationFile(vncServerName);
}
public static void usage() {
@@ -215,6 +217,7 @@ public class VncViewer extends javax.swing.JApplet
"[host:displayNum]\n"+
" vncviewer [options/parameters] -listen [port] "+
"[options/parameters]\n"+
+ " vncviewer [options/parameters] [.tigervnc file]\n"+
"\n"+
"Options:\n"+
" -log <level> configure logging level\n"+
@@ -277,6 +280,27 @@ public class VncViewer extends javax.swing.JApplet
System.exit(1);
}
+ public static void potentiallyLoadConfigurationFile(CharBuffer vncServerName) {
+ String serverName = vncServerName.toString();
+ boolean hasPathSeparator = (serverName.indexOf('/') != -1 ||
+ (serverName.indexOf('\\')) != -1);
+
+ if (hasPathSeparator) {
+ try {
+ serverName = loadViewerParameters(vncServerName.toString());
+ if (serverName == "") {
+ vlog.info("Unable to load the server name from given file");
+ System.exit(1);
+ }
+ vncServerName.clear();
+ vncServerName.put(serverName).flip();
+ } catch (com.tigervnc.rfb.Exception e) {
+ vlog.info(e.getMessage());
+ System.exit(1);
+ }
+ }
+ }
+
public static void newViewer() {
String cmd = "java -jar ";
try {