Mercurial > hg > Applications > TreeVNC
view src/viewer_swing/java/com/glavsoft/viewer/TreeViewer.java @ 89:1503a373ab73
close client correctly in -d mode.
author | oc |
---|---|
date | Fri, 09 May 2014 19:20:33 +0900 |
parents | 432dac0b9dae |
children | e2416a246c95 |
line wrap: on
line source
package com.glavsoft.viewer; import jp.ac.u_ryukyu.treevnc.server.VncProxyService; public class TreeViewer { private boolean treeProxy; private boolean viewer; private boolean cui = false; private int width; private int height; private String hostName = null; private boolean noConnection = false; public static void main(String[] args) { new TreeViewer().vncStart(args); } private void vncStart(String[] args) { modeSelect(args); if (treeProxy) { VncProxyService vps = new VncProxyService(); vps.setNoConnection(noConnection); vps.proxyStart(args,width,height); } ViewerImpl v; if (viewer) { v = cui ? new CuiViewer() : new Viewer(); if(hostName!=null) { v.startViewer(hostName,true); } else { v.startViewer(); } } } private void modeSelect(String[] args) { viewer = true; // default for (int i = 0; i < args.length; i++) { if ("-p".equals(args[i]) || "-r".equals(args[i])) { // no display. behave as root. // relay rfb update to clients. treeProxy = true; viewer = false; } else if ("-d".equals(args[i])) { // behave as root with display. // use this on main display such as large tv. noConnection = true; treeProxy = true; viewer = true; } else if ("--cui".equals(args[i])) { // use cui viewer cui = true; } else if ("-v".equals(args[i]) || "-c".equals(args[i])) { // behave as client. // open display and connect to some tree node. viewer = true; } else if ("--version".equals(args[i])) { System.out.println("version :" + VncProxyService.ver()); System.exit(0); } else if ("--retina".equals(args[i])) { // retina display too large for TreeVNC. // restrict display size. width = 1280; height = 800; } else if ("--width".equals(args[i])) { width = Integer.parseInt(args[i+1]); i++; } else if ("--height".equals(args[i])) { height = Integer.parseInt(args[i+1]); i++; } else if ("--host".equals(args[i])) { hostName = args[++i]; } else { System.out.println("(default) TreeVNCClient\n" + "-v or -c: View shared screen.\n" + "-p: Share my screen and behave as tree root.\n" + "-d: Show shared screen and behave as tree root.\n" + "-r: Connect to fix to specified host and port.\n" + "--host hostname: Set host name.\n" + "--retina: Limit screen size for very large display.\n" + "--width w: Set display width.\n" + "--height h: Set display height.\n"); } } } public boolean setWidthAndHeight(String[] args, int i) { if(isInteger(args[++i])&&isInteger(args[++i])) { width = Integer.parseInt(args[--i]); height = Integer.parseInt(args[++i]); return true; } else { width = 1920; height = 1080; return false; } } private boolean isInteger(String num) { try { Integer.parseInt(num); return true; } catch (NumberFormatException e) { return false; } } }