Mercurial > hg > Applications > TreeVNC
view src/viewer_swing/java/com/glavsoft/viewer/TreeViewer.java @ 78:fc984746f958
use real ip address for TreeVNC root selection
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 30 Apr 2014 10:34:07 +0900 |
parents | cdf7bbe45885 |
children | 015321785ddf |
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 int width; private int height; private String hostName = null; public static void main(String[] args) { new TreeViewer().vncStart(args); } private void vncStart(String[] args) { modeSelect(args); if (treeProxy) { VncProxyService vps = new VncProxyService(); vps.proxyStart(args,width,height); } if(hostName!=null) { CuiViewer v = new CuiViewer(); v.startViewer(hostName,true); } else if (viewer) { Viewer v = new Viewer(); 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. treeProxy = true; viewer = 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. treeProxy = true; 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; } } }