def send_hello(self, server_capabilities): capabilities = server_capabilities.copy() for bc in CC_BASES: log("%s.get_caps()", bc) merge_dicts(capabilities, bc.get_caps(self)) self.send("hello", capabilities) self.hello_sent = True
def make_hello(self, source): capabilities = ServerCore.make_hello(self, source) for c in SERVER_BASES: if c != ServerCore: merge_dicts(capabilities, c.get_caps(self, source)) capabilities["server_type"] = "base" if source.wants_display: capabilities.update({ "max_desktop_size": self.get_max_screen_size(), }) if source.wants_features: capabilities.update({ "client-shutdown": self.client_shutdown, "sharing": self.sharing is not False, "sharing-toggle": self.sharing is None, "lock": self.lock is not False, "lock-toggle": self.lock is None, "windows": server_features.windows, "keyboard": server_features.input_devices, "pointer": server_features.input_devices, }) capabilities.update(flatten_dict(self.get_server_features(source))) #this is a feature, but we would need the hello request #to know if it is really needed.. so always include it: capabilities["exit_server"] = True return capabilities
def get_info(self): info = { "protocol" : "xpra", "connection_time" : int(self.connection_time), "elapsed_time" : int(monotonic_time()-self.connection_time), "counter" : self.counter, "hello-sent" : self.hello_sent, "jitter" : self.jitter, "bandwidth-limit" : { "detection" : self.bandwidth_detection, "actual" : self.soft_bandwidth_limit or 0, } } p = self.protocol if p: info.update({ "connection" : p.get_info(), }) info.update(self.get_features_info()) for bc in CC_BASES: try: merge_dicts(info, bc.get_info(self)) except Exception as e: log("merge_dicts on %s", bc, exc_info=True) log.error("Error: cannot add information from %s:", bc) log.error(" %s", e) return info
def make_hello(self, source): capabilities = ServerCore.make_hello(self, source) for c in ServerBase.__bases__: if c!=ServerCore: merge_dicts(capabilities, c.get_caps(self)) capabilities["server_type"] = "base" if source.wants_display: capabilities.update({ "max_desktop_size" : self.get_max_screen_size(), }) if source.wants_features: capabilities.update({ "bell" : self.bell, "cursors" : self.cursors, "av-sync.enabled" : self.av_sync, "client-shutdown" : self.client_shutdown, "sharing" : self.sharing is not False, "sharing-toggle" : self.sharing is None, "lock" : self.lock is not False, "lock-toggle" : self.lock is None, }) capabilities.update(flatten_dict(self.get_server_features(source))) #this is a feature, but we would need the hello request #to know if it is really needed.. so always include it: capabilities["exit_server"] = True return capabilities
def get_info(self, proto, *_args): info = X11ServerCore.get_info(self, proto) merge_dicts(info, ShadowServerBase.get_info(self, proto)) info.setdefault("features", {})["shadow"] = True info.setdefault( "server", {})["type"] = "Python/gtk%i/x11-shadow" % (2 + is_gtk3()) return info
def make_hello(self, source): capabilities = super().make_hello(source) for c in SERVER_BASES: if c != ServerCore: merge_dicts(capabilities, c.get_caps(self, source)) capabilities["server_type"] = "base" if source.wants_display: capabilities.update({ "max_desktop_size": self.get_max_screen_size(), "display": os.environ.get("DISPLAY", "Main"), }) if source.wants_features: capabilities.update({ "client-shutdown": self.client_shutdown, "sharing": self.sharing is not False, "sharing-toggle": self.sharing is None, "lock": self.lock is not False, "lock-toggle": self.lock is None, "windows": server_features.windows, "keyboard": server_features.input_devices, "pointer": server_features.input_devices, }) capabilities.update(flatten_dict(self.get_server_features(source))) capabilities[ "configure.pointer"] = True #v4 clients assume this is enabled return capabilities
def in_thread(*args): start = time.time() #this runs in a non-UI thread try: info = self.get_info(proto, *args) merge_dicts(ui_info, info) except Exception as e: log.error("error during info collection: %s", e, exc_info=True) end = time.time() log("get_all_info: non ui info collected in %ims", (end-start)*1000) callback(proto, ui_info)
def get_ui_info(self, proto, client_uuids=None, *args): """ info that must be collected from the UI thread (ie: things that query the display) """ info = {"server" : {"max_desktop_size" : self.get_max_screen_size()}} for c in SERVER_BASES: try: merge_dicts(info, c.get_ui_info(self, proto, client_uuids, *args)) except Exception: log.error("Error gathering UI info on %s", c, exc_info=True) return info
def get_server_features(self, server_source=None): #these are flags that have been added over time with new versions #to expose new server features: f = { "toggle_keyboard_sync": True, #v4.0 clients assume this is always available } for c in SERVER_BASES: if c != ServerCore: merge_dicts(f, c.get_server_features(self, server_source)) return f
def in_thread(*args): start = time.time() #this runs in a non-UI thread try: info = self.get_info(proto, *args) merge_dicts(ui_info, info) except Exception as e: log.error("error during info collection: %s", e, exc_info=True) end = time.time() log("get_all_info: non ui info collected in %ims", (end - start) * 1000) callback(proto, ui_info)
def do_get_info(self, proto, server_sources=None, window_ids=None): start = monotonic_time() info = {} def up(prefix, d): merge_dicts(info, {prefix: d}) for c in ServerBase.__bases__: try: merge_dicts(info, c.get_info(self, proto)) except Exception as e: log("do_get_info%s", (proto, server_sources, window_ids), exc_info=True) log.error("Error collecting information from %s: %s", c, e) up("features", self.get_features_info()) up( "network", { "sharing": self.sharing is not False, "sharing-toggle": self.sharing is None, "lock": self.lock is not False, "lock-toggle": self.lock is None, }) # other clients: info["clients"] = { "": len([p for p in self._server_sources.keys() if p != proto]), "unauthenticated": len([ p for p in self._potential_protocols if ((p is not proto) and (p not in self._server_sources.keys()) ) ]) } #find the server source to report on: n = len(server_sources or []) if n == 1: ss = server_sources[0] up("client", ss.get_info()) info.update(ss.get_window_info(window_ids)) elif n > 1: cinfo = {} for i, ss in enumerate(server_sources): sinfo = ss.get_info() sinfo["ui-driver"] = self.ui_driver == ss.uuid sinfo.update(ss.get_window_info(window_ids)) cinfo[i] = sinfo up("client", cinfo) log("ServerBase.do_get_info took %ims", (monotonic_time() - start) * 1000) return info
def do_get_info(self, proto, server_sources=None) -> dict: log("ServerBase.do_get_info%s", (proto, server_sources)) start = monotonic() info = {} def up(prefix, d): merge_dicts(info, {prefix: d}) for c in SERVER_BASES: try: cstart = monotonic() merge_dicts(info, c.get_info(self, proto)) cend = monotonic() log("%s.get_info(%s) took %ims", c, proto, int(1000 * (cend - cstart))) except Exception: log.error("Error collecting information from %s", c, exc_info=True) up("features", self.get_features_info()) up( "network", { "sharing": self.sharing is not False, "sharing-toggle": self.sharing is None, "lock": self.lock is not False, "lock-toggle": self.lock is None, }) # other clients: info["clients"] = { "": sum(1 for p in self._server_sources if p != proto), "unauthenticated": sum(1 for p in self._potential_protocols if ((p is not proto) and (p not in self._server_sources))), } #find the server source to report on: n = len(server_sources or []) if n == 1: ss = server_sources[0] up("client", ss.get_info()) elif n > 1: cinfo = {} for i, ss in enumerate(server_sources): sinfo = ss.get_info() sinfo["ui-driver"] = self.ui_driver == ss.uuid cinfo[i] = sinfo up("client", cinfo) log("ServerBase.do_get_info took %ims", (monotonic() - start) * 1000) return info
def get_info(self) -> dict: def module_name(m): name = str(m.__name__.split(".")[-1]) return name.replace("Mixin", "").replace("Connection", "").rstrip("_") info = { "modules" : tuple(module_name(x) for x in CC_BASES), } for bc in CC_BASES: log("%s.get_info()", bc) try: merge_dicts(info, bc.get_info(self)) except Exception as e: log("merge_dicts on %s", bc, exc_info=True) log.error("Error: cannot add information from %s:", bc) log.error(" %s", e) return info
def get_server_features(self, server_source=None): #these are flags that have been added over time with new versions #to expose new server features: f = dict((k, True) for k in ( #all these flags are assumed enabled in 0.17 (they are present in 0.14.x onwards): "toggle_cursors_bell_notify", "toggle_keyboard_sync", "xsettings-tuple", "event_request", "notify-startup-complete", "server-events", )) for c in SERVER_BASES: if c != ServerCore: merge_dicts(f, c.get_server_features(self, server_source)) return f
def get_info(self): info = {} for c in CLIENT_BASES: try: i = c.get_info(self) info = merge_dicts(info, i) except Exception: log.error("Error collection information from %s", c, exc_info=True) return info
def get_info(self): info = { "pid" : os.getpid(), "threads" : get_frame_info(), "env" : get_info_env(), "sys" : get_sys_info(), "network" : get_net_info(), "logging" : get_log_info(), } if SYSCONFIG: info["sysconfig"] = get_sysconfig_info() for c in CLIENT_BASES: try: i = c.get_info(self) info = merge_dicts(info, i) except Exception: log.error("Error collection information from %s", c, exc_info=True) return info
def get_info(self): info = { "protocol": "xpra", "connection_time": int(self.connection_time), "elapsed_time": int(monotonic_time() - self.connection_time), "counter": self.counter, "hello-sent": self.hello_sent, "bandwidth-limit": { "setting": self.bandwidth_limit or 0, "actual": self.soft_bandwidth_limit or 0, } } p = self.protocol if p: info.update({ "connection": p.get_info(), }) info.update(self.get_features_info()) merge_dicts(info, FilePrintMixin.get_info(self)) merge_dicts(info, AudioMixin.get_info(self)) merge_dicts(info, MMAP_Connection.get_info(self)) merge_dicts(info, NetworkStateMixin.get_info(self)) merge_dicts(info, ClientInfoMixin.get_info(self)) merge_dicts(info, WindowsMixin.get_info(self)) merge_dicts(info, EncodingsMixin.get_info(self)) merge_dicts(info, AVSyncMixin.get_info(self)) merge_dicts(info, ClientDisplayMixin.get_info(self)) merge_dicts(info, IdleMixin.get_info(self)) merge_dicts(info, ClipboardConnection.get_info(self)) return info
def send_hello(self, server_capabilities): capabilities = server_capabilities.copy() merge_dicts(capabilities, AudioMixin.get_caps(self)) merge_dicts(capabilities, MMAP_Connection.get_caps(self)) merge_dicts(capabilities, WindowsMixin.get_caps(self)) merge_dicts(capabilities, EncodingsMixin.get_caps(self)) merge_dicts(capabilities, InputMixin.get_caps(self)) merge_dicts(capabilities, AVSyncMixin.get_caps(self)) merge_dicts(capabilities, ClientDisplayMixin.get_caps(self)) self.send("hello", capabilities) self.hello_sent = True
def up(prefix, d): merge_dicts(info, {prefix: d})