def get_connect_info(self): cinfo = [] pinfo = "" if self.client_platform: pinfo = " %s" % platform_name( self.client_platform, self.client_linux_distribution or self.client_release) if self.client_session_type: pinfo += " %s" % self.client_session_type revinfo = "" if self.client_revision: revinfo = "-r%s" % self.client_revision bitsstr = "" if self.client_bits: bitsstr = " %i-bit" % self.client_bits cinfo.append("%s%s client version %s%s%s" % (std(self.client_type), pinfo, std( self.client_version), std(revinfo), bitsstr)) msg = "" if self.hostname: msg += "connected from '%s'" % std(self.hostname) if self.username: msg += " as '%s'" % std(self.username) if self.name and self.name != self.username: msg += " - '%s'" % std(self.name) if msg: cinfo.append(msg) if self.client_proxy: msg = "via %s proxy version %s" % (platform_name( self.proxy_platform, self.proxy_release), std(self.proxy_version or "unknown")) if self.proxy_hostname: msg += " on '%s'" % std(self.proxy_hostname) cinfo.append(msg) return cinfo
def parse_server_capabilities(self): for c in CLIENT_BASES: if not c.parse_server_capabilities(self): log.info("failed to parse server capabilities in %s", c) return False c = self.server_capabilities self.server_session_name = strtobytes(c.rawget("session_name", b"")).decode("utf-8") set_name("Xpra", self.session_name or self.server_session_name or "Xpra") self.server_platform = c.strget("platform") self.server_sharing = c.boolget("sharing") self.server_sharing_toggle = c.boolget("sharing-toggle") self.server_lock = c.boolget("lock") self.server_lock_toggle = c.boolget("lock-toggle") self.server_keyboard = c.boolget("keyboard", True) self.server_toggle_keyboard_sync = self.server_keyboard and c.boolget("toggle_keyboard_sync", True) self.server_pointer = c.boolget("pointer", True) self.server_start_new_commands = c.boolget("start-new-commands") if self.server_start_new_commands: self.xdg_menu = c.dictget("xdg-menu") if self.start_new_commands or self.start_child_new_commands: if self.server_start_new_commands: self.after_handshake(self.send_start_new_commands) else: log.warn("Warning: cannot start new commands") log.warn(" the feature is currently disabled on the server") self.server_commands_info = c.boolget("server-commands-info") self.server_commands_signals = c.strlistget("server-commands-signals") self.server_readonly = c.boolget("readonly") if self.server_readonly and not self.readonly: log.info("server is read only") self.readonly = True if not self.server_keyboard and self.keyboard_helper: #swallow packets: def nosend(*args): pass self.keyboard_helper.send = nosend i = platform_name(self._remote_platform, c.strlistget("platform.linux_distribution") or c.strget("platform.release", "")) r = self._remote_version if self._remote_revision: r += "-r%s" % self._remote_revision mode = c.strget("server.mode", "server") bits = c.intget("python.bits", 32) log.info("Xpra %s server version %s %i-bit", mode, std(r), bits) if i: log.info(" running on %s", std(i)) if c.boolget("proxy"): proxy_hostname = c.strget("proxy.hostname") proxy_platform = c.strget("proxy.platform") proxy_release = c.strget("proxy.platform.release") proxy_version = c.strget("proxy.version") proxy_version = c.strget("proxy.build.version", proxy_version) proxy_distro = c.strget("linux_distribution") msg = "via: %s proxy version %s" % (platform_name(proxy_platform, proxy_distro or proxy_release), std(proxy_version or "unknown")) if proxy_hostname: msg += " on '%s'" % std(proxy_hostname) log.info(msg) return True
def get_connect_info(self) -> list: cinfo = [] #client platform / version info: pinfo = "" if self.client_platform: pinfo = " %s" % platform_name( self.client_platform, self.client_linux_distribution or self.client_release) if self.client_session_type: pinfo += " %s" % self.client_session_type revinfo = "" if self.client_revision: revinfo = "-r%s" % self.client_revision bitsstr = "" if self.client_bits: bitsstr = " %i-bit" % self.client_bits cinfo.append("%s%s client version %s%s%s" % (std(self.client_type), pinfo, std( self.client_version), std(revinfo), bitsstr)) #opengl info: if self.client_opengl: msg = "OpenGL is " if not self.client_opengl.boolget("enabled"): msg += "disabled" else: msg += "enabled" driver_info = self.client_opengl.strget( "renderer") or self.client_opengl.strget("vendor") if driver_info: msg += " with %s" % driver_info cinfo.append(msg) #connection info: msg = "" if self.hostname: msg += "connected from '%s'" % std(self.hostname) if self.username: msg += " as '%s'" % std(self.username) if self.name and self.name != self.username: msg += " - '%s'" % std(self.name) if msg: cinfo.append(msg) #proxy info if self.client_proxy: msg = "via %s proxy version %s" % (platform_name( self.proxy_platform, self.proxy_release), std(self.proxy_version or "unknown")) if self.proxy_hostname: msg += " on '%s'" % std(self.proxy_hostname) cinfo.append(msg) return cinfo
def parse_server_capabilities(self): for c in UIXpraClient.__bases__: if not c.parse_server_capabilities(self): log.info("failed to parse server capabilities in %s", c) return False c = self.server_capabilities self.server_session_name = strtobytes(c.rawget("session_name", b"")).decode("utf-8") set_name("Xpra", self.session_name or self.server_session_name or "Xpra") self.server_platform = c.strget("platform") self.server_sharing = c.boolget("sharing") self.server_sharing_toggle = c.boolget("sharing-toggle") self.server_lock = c.boolget("lock") self.server_lock_toggle = c.boolget("lock-toggle") self.server_start_new_commands = c.boolget("start-new-commands") self.server_commands_info = c.boolget("server-commands-info") self.server_commands_signals = c.strlistget("server-commands-signals") self.server_readonly = c.boolget("readonly") if self.server_readonly and not self.readonly: log.info("server is read only") self.readonly = True i = platform_name( self._remote_platform, c.strlistget("platform.linux_distribution") or c.strget("platform.release", "")) r = self._remote_version if self._remote_revision: r += "-r%s" % self._remote_revision mode = c.strget("server.mode", "server") bits = c.intget("python.bits", 32) log.info("Xpra %s server version %s %i-bit", mode, std(r), bits) if i: log.info(" running on %s", std(i)) if c.boolget("proxy"): proxy_hostname = c.strget("proxy.hostname") proxy_platform = c.strget("proxy.platform") proxy_release = c.strget("proxy.platform.release") proxy_version = c.strget("proxy.version") proxy_version = c.strget("proxy.build.version", proxy_version) proxy_distro = c.strget("linux_distribution") msg = "via: %s proxy version %s" % (platform_name( proxy_platform, proxy_distro or proxy_release), std(proxy_version or "unknown")) if proxy_hostname: msg += " on '%s'" % std(proxy_hostname) log.info(msg) return True
def get_info(self) -> dict: info = { "version": self.client_version or "unknown", "revision": self.client_revision or "unknown", "platform_name": platform_name(self.client_platform, self.client_release), "session-type": self.client_session_type or "", "session-type.full": self.client_session_type_full or "", "sharing": bool(self.sharing), } def addattr(k, name=None): v = getattr(self, (name or k).replace("-", "_")) #skip empty values: if v is not None: info[k] = v for k in ("session-id", "uuid", "user", "name", "argv"): addattr(k) for x in ("type", "platform", "release", "machine", "processor", "proxy", "wm_name", "session_type"): addattr(x, "client_" + x) return info
def get_info(self): info = { "version": self.client_version or "unknown", "revision": self.client_revision or "unknown", "platform_name": platform_name(self.client_platform, self.client_release), "session-type": self.client_session_type, "session-type.full": self.client_session_type_full, "uuid": self.uuid, "hostname": self.hostname or "", "argv": self.argv, } def addattr(k, name): v = getattr(self, name) if v is not None: info[k] = v for x in ("type", "platform", "release", "machine", "processor", "proxy", "wm_name", "session_type"): addattr(x, "client_" + x) return info
def make_os_str(sys_platform, platform_release, platform_platform, platform_linux_distribution): s = platform_name(sys_platform, platform_release) if platform_linux_distribution and len( platform_linux_distribution) == 3 and len( platform_linux_distribution[0]) > 0: s += "\n%s" % (" ".join(platform_linux_distribution)) elif platform_platform: s += "\n%s" % platform_platform return s
def __init__(self): log.info("Xpra %s client version %s %i-bit", self.client_toolkit(), full_version_str(), BITS) for c in UIXpraClient.__bases__: c.__init__(self) try: pinfo = get_platform_info() osinfo = "%s" % platform_name( sys.platform, pinfo.get("linux_distribution") or pinfo.get("sysrelease", "")) log.info(" running on %s", osinfo) except: log("platform name error:", exc_info=True) wm = get_wm_name() if wm: log.info(" window manager is '%s'", wm) self._ui_events = 0 self.title = "" self.session_name = u"" self.server_platform = "" self.server_session_name = None #features: self.opengl_enabled = False self.opengl_props = {} self.readonly = False self.xsettings_enabled = False self.server_start_new_commands = False #in WindowClient - should it be? #self.server_is_desktop = False self.server_sharing = False self.server_sharing_toggle = False self.server_lock = False self.server_lock_toggle = False self.server_window_filters = False self.client_supports_opengl = False self.client_supports_sharing = False self.client_lock = False #helpers and associated flags: self.client_extras = None self.keyboard_helper_class = KeyboardHelper self.keyboard_helper = None self.keyboard_grabbed = False self.pointer_grabbed = False self.kh_warning = False self.menu_helper = None #state: self._on_handshake = [] self._on_server_setting_changed = {}
def make_os_str(sys_platform, platform_release, platform_platform, platform_linux_distribution): s = platform_name(sys_platform, platform_release) if ( platform_linux_distribution and len(platform_linux_distribution) == 3 and len(platform_linux_distribution[0]) > 0 ): s += "\n%s" % (" ".join(platform_linux_distribution)) elif platform_platform: s += "\n%s" % platform_platform return s
def do_get_platform_info(): from xpra.os_util import platform_name info = { "" : sys.platform, "name" : platform_name(sys.platform, python_platform.release()), "release" : python_platform.release(), "platform" : python_platform.platform(), "machine" : python_platform.machine(), "processor" : python_platform.processor(), } if sys.platform.startswith("linux") and hasattr(python_platform, "linux_distribution"): info["linux_distribution"] = python_platform.linux_distribution() return info
def print_run_info(self): try: from xpra.src_info import REVISION rev_info = "-r%s" % REVISION except: rev_info = "" log.info("xpra %s version %s%s", self.get_server_mode(), local_version, rev_info) try: pinfo = get_platform_info() osinfo = " on %s" % platform_name(sys.platform, pinfo.get("linux_distribution") or pinfo.get("release", "")) except: log("platform name error:", exc_info=True) osinfo = "" log.info(" running with pid %s%s", os.getpid(), osinfo)
def do_get_platform_info(): from xpra.scripts.config import python_platform from xpra.os_util import platform_name info = { "platform" : sys.platform, "platform.name" : platform_name(sys.platform, python_platform.release()), "platform.release" : python_platform.release(), "platform.platform" : python_platform.platform(), "platform.machine" : python_platform.machine(), "platform.processor" : python_platform.processor(), } if sys.platform.startswith("linux"): info["platform.linux_distribution"] = python_platform.linux_distribution() return info
def do_get_platform_info(): from xpra.os_util import platform_name, platform_release pp = sys.modules.get("platform", python_platform) def get_processor_name(): if pp.system() == "Windows": return pp.processor() elif pp.system() == "Darwin": os.environ['PATH'] = os.environ['PATH'] + os.pathsep + '/usr/sbin' command = "sysctl -n machdep.cpu.brand_string" import subprocess return subprocess.check_output(command).strip() elif pp.system() == "Linux": with open("/proc/cpuinfo") as f: data = f.read() import re for line in data.split("\n"): if "model name" in line: return re.sub(".*model name.*:", "", line, 1).strip() assert False info = {} ld = get_linux_distribution() if ld: info["linux_distribution"] = ld release = platform_release(pp.release()) info.update({ "": sys.platform, "name": platform_name(sys.platform, info.get("linux_distribution") or release), "release": pp.release(), "sysrelease": release, "platform": pp.platform(), "machine": pp.machine(), "processor": pp.processor(), "architecture": pp.architecture(), }) try: info["processor"] = get_processor_name() except: info["processor"] = pp.processor() return info
def do_get_platform_info(): from xpra.os_util import platform_name info = { "": sys.platform, "name": platform_name(sys.platform, python_platform.release()), "release": python_platform.release(), "platform": python_platform.platform(), "machine": python_platform.machine(), "processor": python_platform.processor(), } if sys.platform.startswith("linux") and hasattr(python_platform, "linux_distribution"): info["linux_distribution"] = python_platform.linux_distribution() return info
def populate_form(self): btn = link_btn("https://github.com/Xpra-org/xpra/blob/master/docs/Features/Webcam.md", label="Open Webcam Documentation", icon_name=None) self.vbox.pack_start(btn, expand=True, fill=False, padding=20) tb = self.table() cb = self.bool_cb(tb, "Webcam", "webcam") if OSX or WIN32: cb.set_sensitive(False) cb.set_active(False) tb.inc() tb.attach(Gtk.Label(""), 0, 2) tb.inc() tb.attach(Gtk.Label("Webcam forwarding is not supported on %s" % platform_name()), 0, 2) self.vbox.show_all()
def print_run_info(self): try: from xpra.src_info import REVISION rev_info = "-r%s" % REVISION except: rev_info = "" log.info("xpra %s version %s%s", self.get_server_mode(), local_version, rev_info) try: pinfo = get_platform_info() osinfo = " on %s" % platform_name( sys.platform, pinfo.get("linux_distribution") or pinfo.get("release", "")) except: log("platform name error:", exc_info=True) osinfo = "" log.info(" running with pid %s%s", os.getpid(), osinfo)
def session_toggled(self, *args): localhost = self.localhost_btn.get_active() log("session_toggled(%s) localhost=%s", args, localhost) shadow = self.shadow_btn.get_active() local_shadow_only = WIN32 or OSX if shadow: self.exit_with_client_cb.set_active(True) elif local_shadow_only and localhost: #can only do shadow on localhost, so switch to remote: self.remote_btn.set_active(True) can_use_localhost = shadow or not local_shadow_only self.localhost_btn.set_sensitive(can_use_localhost) self.localhost_btn.set_tooltip_text( "Start sessions on the local system" if can_use_localhost else "Cannot start local desktop or seamless sessions on %s" % platform_name()) self.display_changed() self.populate_menus() self.entry_changed()
def do_get_platform_info(): from xpra.os_util import platform_name def get_processor_name(): if pp.system() == "Windows": return pp.processor() elif pp.system() == "Darwin": os.environ["PATH"] = os.environ["PATH"] + os.pathsep + "/usr/sbin" command = "sysctl -n machdep.cpu.brand_string" import subprocess return subprocess.check_output(command).strip() elif pp.system() == "Linux": with open("/proc/cpuinfo") as f: data = f.read() import re for line in data.split("\n"): if "model name" in line: return re.sub(".*model name.*:", "", line, 1).strip() assert False info = {} if sys.platform.startswith("linux") and hasattr(pp, "linux_distribution"): info["linux_distribution"] = pp.linux_distribution() info.update( { "": sys.platform, "name": platform_name(sys.platform, info.get("linux_distribution") or pp.release()), "release": pp.release(), "platform": pp.platform(), "machine": pp.machine(), "processor": pp.processor(), "architecture": pp.architecture(), } ) try: info["processor"] = get_processor_name() except: info["processor"] = pp.processor() return info
def get_info(self) -> dict: info = { "version": self.client_version or "unknown", "revision": self.client_revision or "unknown", "platform_name": platform_name(self.client_platform, self.client_release), "session-type": self.client_session_type or "", "session-type.full": self.client_session_type_full or "", "session-id": self.session_id or "", "uuid": self.uuid or "", "hostname": self.hostname or "", "user": self.user, "name": self.name, "argv": self.argv or (), "sharing": bool(self.sharing), } def addattr(k, name): v = getattr(self, name) if v is not None: info[k] = v for x in ("type", "platform", "release", "machine", "processor", "proxy", "wm_name", "session_type"): addattr(x, "client_" + x) return info
def __init__(self, title="Xpra"): self.exit_code = 0 self.start_session = None gtk.Window.__init__(self) self.set_title(title) self.set_border_width(10) self.set_resizable(True) self.set_decorated(True) self.set_position(WIN_POS_CENTER) icon = get_pixbuf("xpra") if icon: self.set_icon(icon) add_close_accel(self, self.quit) add_window_accel(self, 'F1', self.show_about) self.connect("delete_event", self.quit) self.vbox = gtk.VBox(False, 10) self.add(self.vbox) #with most window managers, #the window's title bar already shows "Xpra" #title_label = gtk.Label(title) #title_label.modify_font(pango.FontDescription("sans 14")) #self.vbox.add(title_label) self.widgets = [] label_font = pango.FontDescription("sans 16") if has_client: icon = get_pixbuf("browse.png") self.browse_button = imagebutton( "Browse", icon, "Browse and connect to local sessions", clicked_callback=self.browse, icon_size=48, label_font=label_font) self.widgets.append(self.browse_button) icon = get_pixbuf("connect.png") self.connect_button = imagebutton( "Connect", icon, "Connect to a session", clicked_callback=self.show_launcher, icon_size=48, label_font=label_font) self.widgets.append(self.connect_button) if has_server: icon = get_pixbuf("server-connected.png") self.shadow_button = imagebutton( "Shadow", icon, "Start a shadow server", clicked_callback=self.start_shadow, icon_size=48, label_font=label_font) if not has_shadow: set_tooltip_text( self.shadow_button, "This build of Xpra does not support starting sessions") self.shadow_button.set_sensitive(False) self.widgets.append(self.shadow_button) icon = get_pixbuf("windows.png") self.start_button = imagebutton("Start", icon, "Start a session", clicked_callback=self.start, icon_size=48, label_font=label_font) #not all builds and platforms can start sessions: if OSX or WIN32: set_tooltip_text( self.start_button, "Starting sessions is not supported on %s" % platform_name(sys.platform)) self.start_button.set_sensitive(False) elif not has_server: set_tooltip_text( self.start_button, "This build of Xpra does not support starting sessions") self.start_button.set_sensitive(False) self.widgets.append(self.start_button) assert len(self.widgets) % 2 == 0 table = gtk.Table(len(self.widgets) // 2, 2, True) for i, widget in enumerate(self.widgets): table.attach(widget, i % 2, i % 2 + 1, i // 2, i // 2 + 1, xpadding=10, ypadding=10) self.vbox.add(table) self.vbox.show_all() self.set_size_request(640, 100 + 100 * len(self.widgets) // 2) def focus_in(window, event): log("focus_in(%s, %s)", window, event) def focus_out(window, event): log("focus_out(%s, %s)", window, event) self.reset_cursors() self.connect("focus-in-event", focus_in) self.connect("focus-out-event", focus_out)
def do_update_screen(self): self.log("do_update_screen()") #c = self.stdscr.getch() #if c==curses.KEY_RESIZE: height, width = self.stdscr.getmaxyx() #log.info("update_screen() %ix%i", height, width) title = get_title() sli = self.server_last_info def _addstr(pad, y, x, s, *args): if len(s) + x >= width - pad: s = s[:max(0, width - x - 2 - pad)] + ".." self.stdscr.addstr(y, x, s, *args) def addstr_main(y, x, s, *args): _addstr(0, y, x, s, *args) def addstr_box(y, x, s, *args): _addstr(2, y, x, s, *args) try: x = max(0, width // 2 - len(title) // 2) addstr_main(0, x, title, curses.A_BOLD) if height <= 1: return server_info = self.slidictget("server") build = self.slidictget("server", "build") vstr = caps_to_version(build) mode = server_info.strget("mode", "server") python_info = typedict(server_info.dictget("python", {})) bits = python_info.intget("bits", 32) server_str = "Xpra %s server version %s %i-bit" % (mode, vstr, bits) proxy_info = self.slidictget("proxy") if proxy_info: proxy_platform_info = typedict( proxy_info.dictget("platform", {})) proxy_platform = proxy_platform_info.strget("") proxy_release = proxy_platform_info.strget("release") proxy_build_info = typedict(proxy_info.dictget("build", {})) proxy_version = proxy_build_info.strget("version") proxy_distro = proxy_info.strget("linux_distribution") server_str += " via: %s proxy version %s" % (platform_name( proxy_platform, proxy_distro or proxy_release), std(proxy_version or "unknown")) addstr_main(1, 0, server_str) if height <= 2: return #load and uptime: now = datetime.now() uptime = "" elapsed_time = server_info.intget("elapsed_time") if elapsed_time: td = timedelta(seconds=elapsed_time) uptime = " up %s" % str(td).lstrip("0:") clients_info = self.slidictget("clients") nclients = clients_info.intget("") load_average = "" load = sli.inttupleget("load") if load and len(load) == 3: float_load = tuple(v / 1000.0 for v in load) load_average = ", load average: %1.2f, %1.2f, %1.2f" % float_load addstr_main( 2, 0, "xpra top - %s%s, %2i users%s" % (now.strftime("%H:%M:%S"), uptime, nclients, load_average)) if height <= 3: return thread_info = self.slidictget("threads") rinfo = "%i threads" % thread_info.intget("count") server_pid = server_info.intget("pid", 0) if server_pid: rinfo += ", pid %i" % server_pid machine_id = server_info.get("machine-id") if machine_id is None or machine_id == get_machine_id(): try: process = self.psprocess.get(server_pid) if not process: import psutil process = psutil.Process(server_pid) self.psprocess[server_pid] = process else: cpu = process.cpu_percent() rinfo += ", %i%% CPU" % (cpu) except Exception: pass cpuinfo = self.slidictget("cpuinfo") if cpuinfo: rinfo += ", %s" % cpuinfo.strget("hz_actual") elapsed = monotonic_time() - self.server_last_info_time color = WHITE if self.server_last_info_time == 0: rinfo += " - no server data" elif elapsed > 2: rinfo += " - last updated %i seconds ago" % elapsed color = RED addstr_main(3, 0, rinfo, curses.color_pair(color)) if height <= 4: return #display: dinfo = [] server = self.slidictget("server") rws = server.intpair("root_window_size", None) if rws: sinfo = "%ix%i display" % (rws[0], rws[1]) mds = server.intpair("max_desktop_size") if mds: sinfo += " (max %ix%i)" % (mds[0], mds[1]) dinfo.append(sinfo) cursor_info = self.slidictget("cursor") if cursor_info: cx, cy = cursor_info.inttupleget("position", (0, 0)) dinfo.append("cursor at %ix%i" % (cx, cy)) display_info = self.slidictget("display") pid = display_info.intget("pid") if pid: dinfo.append("pid %i" % pid) addstr_main(4, 0, csv(dinfo)) if height <= 5: return hpos = 5 gl_info = self.get_gl_info(display_info.dictget("opengl")) if gl_info: addstr_main(5, 0, gl_info) hpos += 1 if hpos < height - 3: hpos += 1 if nclients == 0: addstr_main(hpos, 0, "no clients connected") else: addstr_main( hpos, 0, "%i client%s connected:" % (nclients, engs(nclients))) hpos += 1 client_info = self.slidictget("client") client_no = 0 while True: ci = client_info.dictget(client_no) if not ci: break client_no += 1 ci = typedict(ci) session_id = ci.strget("session-id") if session_id: #don't show ourselves: if session_id == self.session_id: continue elif not ci.boolget("windows", True): #for older servers, hide any client that doesn't display windows: continue ci = self.get_client_info(ci) l = len(ci) if hpos + 2 + l > height: if hpos < height: more = nclients - client_no addstr_box( hpos, 0, "%i client%s not shown" % (more, engs(more)), curses.A_BOLD) break self.box(1, hpos, width - 2, 2 + l) for i, info in enumerate(ci): info_text, color = info cpair = curses.color_pair(color) addstr_box(hpos + i + 1, 2, info_text, cpair) hpos += 2 + l windows = self.slidictget("windows") if hpos < height - 3: hpos += 1 addstr_main(hpos, 0, "%i window%s:" % (len(windows), engs(windows))) hpos += 1 wins = tuple(windows.values()) nwindows = len(wins) for win_no, win in enumerate(wins): wi = self.get_window_info(typedict(win)) l = len(wi) if hpos + 2 + l > height: if hpos < height: more = nwindows - win_no addstr_main(hpos, 0, "terminal window is too small: %i window%s not shown" % \ (more, engs(more)), curses.A_BOLD) break self.box(1, hpos, width - 2, 2 + l) for i, info in enumerate(wi): info_text, color = info cpair = curses.color_pair(color) addstr_box(hpos + i + 1, 2, info_text, cpair) hpos += 2 + l except Exception as e: self.err(e)
def __init__(self): log.info("Xpra %s client version %s %i-bit", self.client_toolkit(), full_version_str(), BITS) #mmap_enabled belongs in the MmapClient mixin, #but it is used outside it, so make sure we define it: self.mmap_enabled = False #same for tray: self.tray = None for c in CLIENT_BASES: log("calling %s.__init__()", c) c.__init__(self) try: pinfo = get_platform_info() osinfo = "%s" % platform_name(sys.platform, pinfo.get("linux_distribution") or pinfo.get("sysrelease", "")) log.info(" running on %s", osinfo) except Exception: log("platform name error:", exc_info=True) wm = get_wm_name() #pylint: disable=assignment-from-none if wm: log.info(" window manager is '%s'", wm) self._ui_events = 0 self.title = "" self.session_name = u"" self.server_platform = "" self.server_session_name = None #features: self.opengl_enabled = False self.opengl_props = {} self.readonly = False self.xsettings_enabled = False self.server_start_new_commands = False self.server_xdg_menu = None self.start_new_commands = [] self.start_child_new_commands = [] #in WindowClient - should it be? #self.server_is_desktop = False self.server_sharing = False self.server_sharing_toggle = False self.server_lock = False self.server_lock_toggle = False self.server_window_filters = False self.server_keyboard = True self.server_toggle_keyboard_sync = False self.server_pointer = True self.client_supports_opengl = False self.client_supports_sharing = False self.client_lock = False #helpers and associated flags: self.client_extras = None self.keyboard_helper_class = KeyboardHelper self.keyboard_helper = None self.keyboard_grabbed = False self.keyboard_sync = False self.pointer_grabbed = False self.kh_warning = False self.menu_helper = None #state: self._on_handshake = [] self._on_server_setting_changed = {}
def do_update_screen(self): #c = self.stdscr.getch() #if c==curses.KEY_RESIZE: height, width = self.stdscr.getmaxyx() #log.info("update_screen() %ix%i", height, width) title = "Xpra top %s" % __version__ try: from xpra.src_info import REVISION, LOCAL_MODIFICATIONS title += "-r%s" % REVISION if LOCAL_MODIFICATIONS: title += "M" except ImportError: pass x = max(0, width // 2 - len(title) // 2) sli = self.server_last_info try: self.stdscr.addstr(0, x, title, curses.A_BOLD) if height <= 1: return server_info = self.dictget("server") build = self.dictget("build") v = build.strget("version") revision = build.strget("revision") if v and revision: v = " version %s-r%s" % (v, revision) mode = server_info.strget("mode", "server") python_info = typedict(server_info.dictget("python", {})) bits = python_info.intget("bits", 32) server_str = "Xpra %s server%s %i-bit" % (mode, std(v), bits) proxy_info = self.dictget("proxy") if proxy_info: proxy_platform_info = typedict( proxy_info.dictget("platform", {})) proxy_platform = proxy_platform_info.strget("") proxy_release = proxy_platform_info.strget("release") proxy_build_info = typedict(proxy_info.dictget("build", {})) proxy_version = proxy_build_info.strget("version") proxy_distro = proxy_info.strget("linux_distribution") server_str += " via: %s proxy version %s" % (platform_name( proxy_platform, proxy_distro or proxy_release), std(proxy_version or "unknown")) self.stdscr.addstr(1, 0, server_str) if height <= 2: return #load and uptime: now = datetime.now() uptime = "" elapsed_time = server_info.intget("elapsed_time") if elapsed_time: td = timedelta(seconds=elapsed_time) uptime = " up %s" % str(td).lstrip("0:") clients_info = self.dictget("clients") nclients = clients_info.intget("") load_average = "" load = sli.intlistget("load") if load and len(load) == 3: float_load = tuple(v / 1000.0 for v in load) load_average = ", load average: %1.2f, %1.2f, %1.2f" % float_load self.stdscr.addstr( 2, 0, "xpra top - %s%s, %2i users%s" % (now.strftime("%H:%M:%S"), uptime, nclients, load_average)) if height <= 3: return thread_info = self.dictget("threads") self.stdscr.addstr(3, 0, "%i threads" % thread_info.intget("count")) if height <= 4: return #cursor: cursor_info = self.dictget("cursor") cx, cy = cursor_info.intlistget("position", (0, 0)) self.stdscr.addstr(4, 0, "cursor at %ix%i" % (cx, cy)) if height <= 5: return hpos = 6 client_info = self.dictget("client") client_no = 0 while True: ci = client_info.dictget(client_no) if not ci: break client_no += 1 ci = typedict(ci) if not ci.boolget("windows", True): continue ci = self.get_client_info(ci) l = len(ci) if hpos + 2 + l > height: if hpos < height: more = nclients - client_no self.stdscr.addstr( hpos, 0, "%i client%s not shown" % (more, engs(more)), curses.A_BOLD) break self.box(self.stdscr, 1, hpos, width - 2, 2 + l) for i, info in enumerate(ci): info_text, color = info cpair = curses.color_pair(color) self.stdscr.addstr(hpos + i + 1, 2, info_text, cpair) hpos += 2 + l windows = self.dictget("windows") if hpos < height - 3: hpos += 1 self.stdscr.addstr(hpos, 0, "%i windows" % len(windows)) hpos += 1 wins = tuple(windows.values()) nwindows = len(wins) for win_no, win in enumerate(wins): wi = self.get_window_info(typedict(win)) l = len(wi) if hpos + 2 + l > height: if hpos < height: more = nwindows - win_no self.stdscr.addstr( hpos, 0, "terminal window is too small: %i window%s not shown" % (more, engs(more)), curses.A_BOLD) break self.box(self.stdscr, 1, hpos, width - 2, 2 + l) for i, info in enumerate(wi): info_text, color = info cpair = curses.color_pair(color) self.stdscr.addstr(hpos + i + 1, 2, info_text, cpair) hpos += 2 + l except Exception as e: import traceback self.stdscr.addstr(0, 0, str(e)) self.stdscr.addstr(0, 1, traceback.format_exc())
def parse_server_capabilities(self, c : typedict) -> bool: for cb in CLIENT_BASES: if not cb.parse_server_capabilities(self, c): log.info("failed to parse server capabilities in %s", cb) return False self.server_session_name = c.uget("session_name") set_name("Xpra", self.session_name or self.server_session_name or "Xpra") self.server_platform = c.strget("platform") self.server_sharing = c.boolget("sharing") self.server_sharing_toggle = c.boolget("sharing-toggle") self.server_lock = c.boolget("lock") self.server_lock_toggle = c.boolget("lock-toggle") self.server_keyboard = c.boolget("keyboard", True) self.server_pointer = c.boolget("pointer", True) self.server_start_new_commands = c.boolget("start-new-commands") if self.server_start_new_commands: self.server_xdg_menu = c.dictget("xdg-menu", None) if self.start_new_commands or self.start_child_new_commands: if self.server_start_new_commands: self.after_handshake(self.send_start_new_commands) else: log.warn("Warning: cannot start new commands") log.warn(" the feature is currently disabled on the server") self.server_commands_info = c.boolget("server-commands-info") self.server_commands_signals = c.strtupleget("server-commands-signals") self.server_readonly = c.boolget("readonly") if self.server_readonly and not self.readonly: log.info("server is read only") self.readonly = True if not self.server_keyboard and self.keyboard_helper: #swallow packets: def nosend(*_args): pass self.keyboard_helper.send = nosend i = platform_name(self._remote_platform, c.strtupleget("platform.linux_distribution") or c.strget("platform.release", "")) r = self._remote_version if self._remote_revision: r += "-r%s" % self._remote_revision mode = c.strget("server.mode", "server") bits = c.intget("python.bits", 32) log.info("Xpra %s server version %s %i-bit", mode, std(r), bits) if i: log.info(" running on %s", std(i)) if c.boolget("desktop") or c.boolget("shadow"): v = c.intpair("actual_desktop_size") if v: w, h = v ss = c.tupleget("screen_sizes") if ss: log.info(" remote desktop size is %sx%s with %s screen%s:", w, h, len(ss), engs(ss)) log_screen_sizes(w, h, ss) else: log.info(" remote desktop size is %sx%s", w, h) if c.boolget("proxy"): proxy_hostname = c.strget("proxy.hostname") proxy_platform = c.strget("proxy.platform") proxy_release = c.strget("proxy.platform.release") proxy_version = c.strget("proxy.version") proxy_version = c.strget("proxy.build.version", proxy_version) proxy_distro = c.strget("proxy.linux_distribution") msg = "via: %s proxy version %s" % ( platform_name(proxy_platform, proxy_distro or proxy_release), std(proxy_version or "unknown") ) if proxy_hostname: msg += " on '%s'" % std(proxy_hostname) log.info(msg) return True
def __init__(self, title="Xpra"): self.exit_code = 0 self.start_session = None Gtk.Window.__init__(self) hb = Gtk.HeaderBar() hb.set_show_close_button(True) hb.props.title = "Xpra" self.set_titlebar(hb) hb.add(self.button("About", "help-about", about)) try: from xpra.client.gtk_base.toolbox import ToolboxGUI except ImportError: pass else: def show(): w = None def hide(*_args): w.hide() ToolboxGUI.quit = hide w = ToolboxGUI() w.show() hb.add(self.button("Toolbox", "applications-utilities", show)) hb.show_all() self.set_title(title) self.set_border_width(10) self.set_resizable(True) self.set_decorated(True) self.set_position(Gtk.WindowPosition.CENTER) icon = get_icon_pixbuf("xpra.png") if icon: self.set_icon(icon) add_close_accel(self, self.quit) add_window_accel(self, 'F1', self.show_about) self.connect("delete_event", self.quit) self.set_wmclass("xpra-gui", "Xpra-GUI") self.vbox = Gtk.VBox(False, 10) self.add(self.vbox) #with most window managers, #the window's title bar already shows "Xpra" #title_label = Gtk.Label(title) #title_label.modify_font(pango.FontDescription("sans 14")) #self.vbox.add(title_label) self.widgets = [] label_font = Pango.FontDescription("sans 16") if has_client: icon = get_icon_pixbuf("browse.png") self.browse_button = imagebutton( "Browse", icon, "Browse and connect to local sessions", clicked_callback=self.browse, icon_size=48, label_font=label_font) self.widgets.append(self.browse_button) icon = get_icon_pixbuf("connect.png") self.connect_button = imagebutton( "Connect", icon, "Connect to a session", clicked_callback=self.show_launcher, icon_size=48, label_font=label_font) self.widgets.append(self.connect_button) if has_server: icon = get_icon_pixbuf("server-connected.png") self.shadow_button = imagebutton( "Shadow", icon, "Start a shadow server", clicked_callback=self.start_shadow, icon_size=48, label_font=label_font) if not has_shadow: self.shadow_button.set_tooltip_text( "This build of Xpra does not support starting sessions") self.shadow_button.set_sensitive(False) self.widgets.append(self.shadow_button) icon = get_icon_pixbuf("windows.png") self.start_button = imagebutton("Start", icon, "Start a session", clicked_callback=self.start, icon_size=48, label_font=label_font) #not all builds and platforms can start sessions: if OSX or WIN32: self.start_button.set_tooltip_text( "Starting sessions is not supported on %s" % platform_name(sys.platform)) self.start_button.set_sensitive(False) elif not has_server: self.start_button.set_tooltip_text( "This build of Xpra does not support starting sessions") self.start_button.set_sensitive(False) self.widgets.append(self.start_button) assert len(self.widgets) % 2 == 0 table = Gtk.Table(len(self.widgets) // 2, 2, True) for i, widget in enumerate(self.widgets): table.attach(widget, i % 2, i % 2 + 1, i // 2, i // 2 + 1, xpadding=10, ypadding=10) self.vbox.add(table) self.vbox.show_all() self.set_size_request(640, 100 + 100 * len(self.widgets) // 2) def focus_in(window, event): log("focus_in(%s, %s)", window, event) def focus_out(window, event): log("focus_out(%s, %s)", window, event) self.reset_cursors() self.connect("focus-in-event", focus_in) self.connect("focus-out-event", focus_out)