def __init__(self): log("ProxyServer.__init__()") ServerCore.__init__(self) self._max_connections = MAX_CONCURRENT_CONNECTIONS self._start_sessions = False self.main_loop = None #proxy servers may have to connect to remote servers, #or even start them, so allow more time before timing out: self._accept_timeout += 10 #keep track of the proxy process instances #the display they're on and the message queue we can # use to communicate with them self.processes = {} #connections used exclusively for requests: self._requests = set() self.idle_add = glib.idle_add self.timeout_add = glib.timeout_add self.source_remove = glib.source_remove self._socket_timeout = PROXY_SOCKET_TIMEOUT self._ws_timeout = PROXY_WS_TIMEOUT self.control_commands["stop"] = ArgsControlCommand( "stop", "stops the proxy instance on the given display", self.handle_stop_command, min_args=1, max_args=1)
def init_control_commands(self): ServerCore.init_control_commands(self) self.control_commands["stop"] = ArgsControlCommand( "stop", "stops the proxy instance on the given display", self.handle_stop_command, min_args=1, max_args=1)
def __init__(self): log("ProxyServer.__init__()") ServerCore.__init__(self) self._max_connections = MAX_CONCURRENT_CONNECTIONS self.main_loop = None #keep track of the proxy process instances #the display they're on and the message queue we can # use to communicate with them self.processes = {} self.idle_add = glib.idle_add self.timeout_add = glib.timeout_add self.source_remove = glib.source_remove self._socket_timeout = PROXY_SOCKET_TIMEOUT self.control_commands["stop"] = ArgsControlCommand( "stop", "stops the proxy instance on the given display", self.handle_stop_command, min_args=1, max_args=1)
def __init__(self): log("ProxyServer.__init__()") ServerCore.__init__(self) self._max_connections = MAX_CONCURRENT_CONNECTIONS self.main_loop = None #keep track of the proxy process instances #the display they're on and the message queue we can # use to communicate with them self.processes = {} self.idle_add = glib.idle_add self.timeout_add = glib.timeout_add self.source_remove = glib.source_remove self._socket_timeout = PROXY_SOCKET_TIMEOUT self.control_commands["stop"] = ArgsControlCommand("stop", "stops the proxy instance on the given display", self.handle_stop_command, min_args=1, max_args=1) #ensure we cache the platform info before intercepting SIGCHLD #as this will cause a fork and SIGCHLD to be emitted: from xpra.version_util import get_platform_info get_platform_info() signal.signal(signal.SIGCHLD, self.sigchld)
def add_control_commands(self): def parse_boolean_value(v): if str(v).lower() in TRUE_OPTIONS: return True if str(v).lower() in FALSE_OPTIONS: return False raise ControlError("a boolean is required, not %s" % v) def parse_4intlist(v): if not v: return [] l = [] #ie: v = " (0,10,100,20), (200,300,20,20)" while v: v = v.strip().strip(",").strip() #ie: "(0,10,100,20)" lp = v.find("(") assert lp==0, "invalid leading characters: %s" % v[:lp] rp = v.find(")") assert (lp+1)<rp item = v[lp+1:rp].strip() #"0,10,100,20" items = [int(x) for x in item] # 0,10,100,20 assert len(items)==4, "expected 4 numbers but got %i" % len(items) l.append(items) return l for cmd in ( ArgsControlCommand("focus", "give focus to the window id", validation=[int]), #window source: ArgsControlCommand("suspend", "suspend screen updates", max_args=0), ArgsControlCommand("resume", "resume screen updates", max_args=0), ArgsControlCommand("ungrab", "cancels any grabs", max_args=0), #server globals: ArgsControlCommand("idle-timeout", "set the idle tiemout", validation=[int]), ArgsControlCommand("server-idle-timeout", "set the server idle timeout", validation=[int]), ArgsControlCommand("start", "executes the command arguments in the server context", min_args=1), ArgsControlCommand("start-child", "executes the command arguments in the server context, as a 'child' (honouring exit-with-children)", min_args=1), ArgsControlCommand("toggle-feature", "toggle a server feature on or off, one of: %s" % csv(TOGGLE_FEATURES), min_args=1, max_args=2, validation=[str, parse_boolean_value]), #network and transfers: ArgsControlCommand("print", "sends the file to the client(s) for printing", min_args=1), ArgsControlCommand("open-url", "open the URL on the client(s)", min_args=1, max_args=2), ArgsControlCommand("send-file", "sends the file to the client(s)", min_args=1, max_args=4), ArgsControlCommand("send-notification", "sends a notification to the client(s)", min_args=4, max_args=5, validation=[int]), ArgsControlCommand("close-notification", "send the request to close an existing notification to the client(s)", min_args=1, max_args=2, validation=[int]), ArgsControlCommand("compression", "sets the packet compressor", min_args=1, max_args=1), ArgsControlCommand("encoder", "sets the packet encoder", min_args=1, max_args=1), ArgsControlCommand("clipboard-direction", "restrict clipboard transfers", min_args=1, max_args=1), ArgsControlCommand("clipboard-limits", "restrict clipboard transfers size", min_args=2, max_args=2, validation=[int, int]), ArgsControlCommand("set-lock", "modify the lock attribute", min_args=1, max_args=1), ArgsControlCommand("set-sharing", "modify the sharing attribute", min_args=1, max_args=1), ArgsControlCommand("set-ui-driver", "set the client connection driving the session", min_args=1, max_args=1), #session and clients: ArgsControlCommand("client", "forwards a control command to the client(s)", min_args=1), ArgsControlCommand("client-property", "set a client property", min_args=4, max_args=5, validation=[int]), ArgsControlCommand("name", "set the session name", min_args=1, max_args=1), ArgsControlCommand("key", "press or unpress a key", min_args=1, max_args=2), ArgsControlCommand("sound-output", "control sound forwarding", min_args=1, max_args=2), #windows: ArgsControlCommand("workspace", "move a window to a different workspace", min_args=2, max_args=2, validation=[int, int]), ArgsControlCommand("scaling-control", "set the scaling-control aggressiveness (from 0 to 100)", min_args=1, validation=[from0to100]), ArgsControlCommand("scaling", "set a specific scaling value", min_args=1, validation=[parse_scaling_value]), ArgsControlCommand("auto-refresh", "set a specific auto-refresh value", min_args=1, validation=[float]), ArgsControlCommand("refresh", "refresh some or all windows", min_args=0), ArgsControlCommand("encoding", "picture encoding", min_args=1, max_args=1), ArgsControlCommand("video-region-enabled", "enable video region", min_args=2, max_args=2, validation=[int, parse_boolean_value]), ArgsControlCommand("video-region-detection","enable video detection", min_args=2, max_args=2, validation=[int, parse_boolean_value]), ArgsControlCommand("video-region-exclusion-zones","set window regions to exclude from video regions: 'WID,(x,y,w,h),(x,y,w,h),..', ie: '1 (0,10,100,20),(200,300,20,20)'", min_args=2, max_args=2, validation=[int, parse_4intlist]), ArgsControlCommand("video-region", "set the video region", min_args=5, max_args=5, validation=[int, int, int, int, int]), ArgsControlCommand("reset-video-region", "reset video region heuristics", min_args=1, max_args=1, validation=[int]), ArgsControlCommand("lock-batch-delay", "set a specific batch delay for a window", min_args=2, max_args=2, validation=[int, int]), ArgsControlCommand("unlock-batch-delay", "let the heuristics calculate the batch delay again for a window (following a 'lock-batch-delay')", min_args=1, max_args=1, validation=[int]), ArgsControlCommand("remove-window-filters", "remove all window filters", min_args=0, max_args=1), ArgsControlCommand("add-window-filter", "add a window filter", min_args=4, max_args=5), ): cmd.do_run = getattr(self, "control_command_%s" % cmd.name.replace("-", "_")) self.control_commands[cmd.name] = cmd #encoding bits: for name in ("quality", "min-quality", "speed", "min-speed"): fn = getattr(self, "control_command_%s" % name.replace("-", "_")) self.control_commands[name] = ArgsControlCommand(name, "set encoding %s (from 0 to 100)" % name, run=fn, min_args=1, validation=[from0to100])