def do_open_URL(url): app.__osx_open_signal = True app.update_options_from_URL(url) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) app.update_gui_from_config() glib.idle_add(app.do_connect)
def do_open_file(filename): app.update_options_from_file(filename) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) app.update_gui_from_config() if app.config.autoconnect: app.__osx_open_signal = True glib.idle_add(app.do_connect)
def do_open_file(filename): app.__osx_open_file = True app.update_options_from_file(filename) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) app.update_gui_from_config() if app.config.autoconnect: glib.idle_add(app.do_connect)
def open_file(filename): log("open_file(%s)", filename) app.update_options_from_file(filename) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) app.update_gui_from_config() if app.config.autoconnect: app.__osx_open_signal = True glib.idle_add(app.do_connect) else: show_with_focus_workaround(app.show)
def do_main(): from xpra.os_util import SIGNAMES from xpra.scripts.main import InitExit, InitInfo from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() from xpra.platform.gui import ready as gui_ready gui_init() try: from xpra.scripts.main import parse_cmdline, fixup_debug_option options, args = parse_cmdline(sys.argv) debug = fixup_debug_option(options.debug) if debug: for x in debug.split(","): enable_debug_for(x) except InitInfo as e: print(str(e)) return 0 except InitExit as e: return e.status except Exception: exception_dialog("Error parsing command line") return 1 #allow config to be debugged: from xpra.scripts import config config.debug = log.debug try: app = ApplicationWindow() def app_signal(signum, _frame): print("") log("got signal %s" % SIGNAMES.get(signum, signum)) def show_signal(): app.show() app.client.cleanup() glib.timeout_add(1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) glib.timeout_add(1000, app.set_info_color, True) #call from UI thread: glib.idle_add(show_signal) if sys.version_info[0]<3: #breaks GTK3.. signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) has_file = len(args) == 1 if has_file: app.update_options_from_file(args[0]) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) debug = fixup_debug_option(app.config.debug) if debug: for x in debug.split(","): enable_debug_for(x) #suspend tray workaround for our window widgets: try: set_use_tray_workaround(False) app.create_window() finally: set_use_tray_workaround(True) app.update_gui_from_config() except Exception: exception_dialog("Error creating launcher form") return 1 try: if app.config.autoconnect: #file says we should connect, #do that only (not showing UI unless something goes wrong): glib.idle_add(app.do_connect) if not has_file: app.reset_errors() gui_ready() if not app.config.autoconnect or app.config.debug: #FIXME: this is ugly as hell #We have to wait for the main loop to be running #to get the NSApplicationOpneFile signal, #so we end up duplicating some of the logic from just above #maybe we should always run this code from the main loop instead if OSX: def force_show(): from xpra.platform.darwin.gui import enable_focus_workaround, disable_focus_workaround enable_focus_workaround() app.show() glib.timeout_add(500, disable_focus_workaround) #wait a little bit for the "openFile" signal app.__osx_open_signal = False def do_open_file(filename): log.info("do_open_file(%s)", filename) app.update_options_from_file(filename) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) app.update_gui_from_config() if app.config.autoconnect: app.__osx_open_signal = True glib.idle_add(app.do_connect) else: force_show() def open_file(_, filename): log.info("open_file(%s)", filename) glib.idle_add(do_open_file, filename) def do_open_URL(url): log.info("do_open_URL(%s)", url) app.__osx_open_signal = True app.update_options_from_URL(url) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) app.update_gui_from_config() glib.idle_add(app.do_connect) def open_URL(url): log.info("open_URL(%s)", url) glib.idle_add(do_open_URL, url) from xpra.platform.darwin.gui import get_OSXApplication, register_URL_handler register_URL_handler(open_URL) try: get_OSXApplication().connect("NSApplicationOpenFile", open_file) except Exception as e: log.error("Error: cannot handle file associations:") log.error(" %s", e) def may_show(): log("may_show() osx open signal=%s", app.__osx_open_signal) if not app.__osx_open_signal: force_show() glib.timeout_add(500, may_show) else: app.show() app.run() except KeyboardInterrupt: pass return 0
def main(): from xpra.os_util import SIGNAMES from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() from xpra.platform import program_context from xpra.platform.gui import ready as gui_ready from xpra.log import enable_color with program_context("Xpra-Launcher", "Xpra Connection Launcher"): enable_color() gui_init() try: from xpra.scripts.main import parse_cmdline, fixup_debug_option options, args = parse_cmdline(sys.argv) debug = fixup_debug_option(options.debug) if debug: for x in debug.split(","): enable_debug_for(x) except Exception: exception_dialog("Error parsing command line") return 1 try: app = ApplicationWindow() def app_signal(signum, frame): print("") log("got signal %s" % SIGNAMES.get(signum, signum)) def show_signal(): app.show() app.client.cleanup() glib.timeout_add(1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) glib.timeout_add(1000, app.set_info_color, True) #call from UI thread: glib.idle_add(show_signal) if sys.version_info[0]<3: #breaks GTK3.. signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) has_file = len(args) == 1 if has_file: app.update_options_from_file(args[0]) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) debug = fixup_debug_option(app.config.debug) if debug: for x in debug.split(","): enable_debug_for(x) #suspend tray workaround for our window widgets: try: set_use_tray_workaround(False) app.create_window() finally: set_use_tray_workaround(True) app.update_gui_from_config() except Exception: exception_dialog("Error creating launcher form") return 1 try: if app.config.autoconnect: #file says we should connect, #do that only (not showing UI unless something goes wrong): glib.idle_add(app.do_connect) if not has_file: app.reset_errors() gui_ready() if not app.config.autoconnect or app.config.debug: #FIXME: this is ugly as hell #We have to wait for the main loop to be running #to get the NSApplicationOpneFile signal, #so we end up duplicating some of the logic from just above #maybe we should always run this code from the main loop instead if sys.platform.startswith("darwin"): #wait a little bit for the "openFile" signal app.__osx_open_file = False def do_open_file(filename): app.__osx_open_file = True app.update_options_from_file(filename) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) app.update_gui_from_config() if app.config.autoconnect: glib.idle_add(app.do_connect) def open_file(_, filename): log("open_file(%s)", filename) glib.idle_add(do_open_file, filename) from xpra.platform.darwin.gui import get_OSXApplication get_OSXApplication().connect("NSApplicationOpenFile", open_file) def may_show(): log("may_show() osx open file=%s", app.__osx_open_file) if not app.__osx_open_file: app.show() glib.timeout_add(500, may_show) else: app.show() app.run() except KeyboardInterrupt: pass return 0
def connect_builtin(self): #cooked vars used by connect_to username = self.config.username params = { "type": self.config.mode, "username": username, } if self.config.mode == MODE_SSH or self.config.mode == MODE_NESTED_SSH: if self.config.socket_dir: params["socket_dir"] = self.config.socket_dir params["remote_xpra"] = self.config.remote_xpra params["proxy_command"] = ["_proxy"] if self.config.port and self.config.port > 0: params["display"] = ":%s" % self.config.port params["display_as_args"] = [params["display"]] else: params["display"] = "auto" params["display_as_args"] = [] params["ssh"] = self.config.ssh params["is_putty"] = self.is_putty params["is_paramiko"] = self.is_paramiko password = self.config.password host = self.config.host upos = host.find("@") if upos >= 0: #found at sign: username@host username = host[:upos] host = host[upos + 1:] ppos = username.find(":") if ppos >= 0: #found separator: username:password@host password = username[ppos + 1:] username = username[:ppos] if self.config.ssh_port and self.config.ssh_port != 22: params["ssh-port"] = self.config.ssh_port ssh_cmd = parse_ssh_string(self.config.ssh) ssh_cmd_0 = ssh_cmd[0].strip().lower() self.is_putty = ssh_cmd_0.endswith("plink") or ssh_cmd_0.endswith( "plink.exe") self.is_paramiko = ssh_cmd_0 == "paramiko" full_ssh = ssh_cmd[:] full_ssh += add_ssh_args(username, password, host, self.config.ssh_port, None, self.is_putty, self.is_paramiko) if username: params["username"] = username if self.nostrict_host_check.get_active(): full_ssh += ["-o", "StrictHostKeyChecking=no"] if params["type"] == MODE_NESTED_SSH: params["type"] = "ssh" params["proxy_host"] = self.config.proxy_host params["proxy_port"] = self.config.proxy_port params["proxy_username"] = self.config.proxy_username params["proxy_password"] = self.config.proxy_password full_ssh += add_ssh_proxy_args(self.config.proxy_username, self.config.proxy_password, self.config.proxy_host, self.config.proxy_port, self.config.proxy_key, ssh_cmd, self.is_putty, self.is_paramiko) params["host"] = host params["local"] = is_local(self.config.host) params["full_ssh"] = full_ssh params["password"] = password params["display_name"] = "ssh:%s:%s" % (self.config.host, self.config.port) elif self.config.mode == "unix-domain": params["display"] = ":%s" % self.config.port params["display_name"] = "unix-domain:%s" % self.config.port else: assert self.config.mode in ( MODE_TCP, MODE_SSL, MODE_WS, MODE_WSS), "invalid / unsupported mode %s" % self.config.mode params["host"] = self.config.host params["local"] = is_local(self.config.host) params["port"] = int(self.config.port) params["display_name"] = "%s:%s:%s" % ( self.config.mode, self.config.host, self.config.port) if self.config.mode in ( MODE_SSL, MODE_WSS) and self.nostrict_host_check.get_active(): params["strict-host-check"] = False #print("connect_to(%s)" % params) #UGLY warning: the username may have been updated during display parsing, #or the config file may contain a username which is different from the default one #which is used for initializing the client during init, #so update the client now: configure_env(self.config.env) configure_logging(self.config, "attach") configure_network(self.config) self.start_client(params)
def do_main(argv): from xpra.os_util import SIGNAMES from xpra.scripts.main import InitExit, InitInfo from xpra.platform.gui import init as gui_init, ready as gui_ready if POSIX and not OSX: from xpra.x11.gtk_x11.gdk_display_source import init_gdk_display_source init_gdk_display_source() gui_init() try: from xpra.scripts.parsing import parse_cmdline, fixup_debug_option options, args = parse_cmdline(argv) debug = fixup_debug_option(options.debug) if debug: for x in debug.split(","): enable_debug_for(x) except InitInfo as e: print(str(e)) return 0 except InitExit as e: return e.status except Exception: exception_dialog("Error parsing command line") return 1 #allow config to be debugged: from xpra.scripts import config config.debug = log.debug try: app = ApplicationWindow() def handle_signal(signum): app.show() client = app.client if client: client.cleanup() else: Gtk.main_quit() GLib.timeout_add(1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) GLib.timeout_add(1000, app.set_info_color, True) register_os_signals(handle_signal, "Client Launcher") has_file = len(args) == 1 if has_file: app.update_options_from_file(args[0]) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) debug = fixup_debug_option(app.config.debug) if debug: for x in debug.split(","): enable_debug_for(x) app.create_window_with_config() except Exception: exception_dialog("Error creating launcher form") return 1 try: if app.config.autoconnect: #file says we should connect, #do that only (not showing UI unless something goes wrong): GLib.idle_add(app.do_connect) if not has_file: app.reset_errors() if not app.config.autoconnect or app.config.debug: if OSX: from xpra.platform.darwin.gui import wait_for_open_handlers, force_focus if has_file: force_focus() app.show() else: def open_file(filename): log("open_file(%s)", filename) app.update_options_from_file(filename) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) app.update_gui_from_config() if app.config.autoconnect: app.__osx_open_signal = True GLib.idle_add(app.do_connect) else: force_focus() app.show() def open_URL(url): log("open_URL(%s)", url) app.__osx_open_signal = True app.update_options_from_URL(url) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) app.update_gui_from_config() GLib.idle_add(app.do_connect) wait_for_open_handlers(app.show, open_file, open_URL) else: app.show() gui_ready() app.run() except KeyboardInterrupt: pass return 0
def do_main(argv): from xpra.os_util import SIGNAMES from xpra.scripts.main import InitExit, InitInfo from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() from xpra.platform.gui import ready as gui_ready gui_init() try: from xpra.scripts.parsing import parse_cmdline, fixup_debug_option options, args = parse_cmdline(argv) debug = fixup_debug_option(options.debug) if debug: for x in debug.split(","): enable_debug_for(x) except InitInfo as e: print(str(e)) return 0 except InitExit as e: return e.status except Exception: exception_dialog("Error parsing command line") return 1 #allow config to be debugged: from xpra.scripts import config config.debug = log.debug try: app = ApplicationWindow() def app_signal(signum, _frame): print("") log("got signal %s" % SIGNAMES.get(signum, signum)) def show_signal(): app.show() app.client.cleanup() glib.timeout_add( 1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) glib.timeout_add(1000, app.set_info_color, True) #call from UI thread: glib.idle_add(show_signal) if sys.version_info[0] < 3: #breaks GTK3.. signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) has_file = len(args) == 1 if has_file: app.update_options_from_file(args[0]) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) debug = fixup_debug_option(app.config.debug) if debug: for x in debug.split(","): enable_debug_for(x) app.create_window_with_config() except Exception: exception_dialog("Error creating launcher form") return 1 try: if app.config.autoconnect: #file says we should connect, #do that only (not showing UI unless something goes wrong): glib.idle_add(app.do_connect) if not has_file: app.reset_errors() if not app.config.autoconnect or app.config.debug: if OSX and not has_file: from xpra.platform.darwin.gui import wait_for_open_handlers, show_with_focus_workaround def open_file(filename): log("open_file(%s)", filename) app.update_options_from_file(filename) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) app.update_gui_from_config() if app.config.autoconnect: app.__osx_open_signal = True glib.idle_add(app.do_connect) else: show_with_focus_workaround(app.show) def open_URL(url): log("open_URL(%s)", url) app.__osx_open_signal = True app.update_options_from_URL(url) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) app.update_gui_from_config() glib.idle_add(app.do_connect) wait_for_open_handlers(app.show, open_file, open_URL) else: app.show() gui_ready() app.run() except KeyboardInterrupt: pass return 0
def connect_builtin(self): #cooked vars used by connect_to params = {"type": self.config.mode} self.config.sharing = self.sharing.get_active() username = self.config.username if self.config.mode == "ssh" or self.config.mode == "ssh -> ssh": if self.config.socket_dir: params["socket_dir"] = self.config.socket_dir params["remote_xpra"] = self.config.remote_xpra params["proxy_command"] = ["_proxy"] if self.config.port and self.config.port > 0: params["display"] = ":%s" % self.config.port params["display_as_args"] = [params["display"]] else: params["display"] = "auto" params["display_as_args"] = [] params["ssh"] = self.config.ssh params["is_putty"] = self.is_putty params["is_paramiko"] = self.is_paramiko password = self.config.password host = self.config.host upos = host.find("@") if upos >= 0: #found at sign: username@host username = host[:upos] host = host[upos + 1:] ppos = username.find(":") if ppos >= 0: #found separator: username:password@host password = username[ppos + 1:] username = username[:ppos] if self.config.ssh_port and self.config.ssh_port != 22: params["ssh-port"] = self.config.ssh_port ssh_cmd = parse_ssh_string(self.config.ssh) ssh_cmd_0 = ssh_cmd[0].strip().lower() self.is_putty = ssh_cmd_0.endswith("plink") or ssh_cmd_0.endswith( "plink.exe") self.is_paramiko = ssh_cmd_0 == "paramiko" full_ssh = ssh_cmd[:] full_ssh += add_ssh_args(username, password, host, self.config.ssh_port, None, self.is_putty, self.is_paramiko) if username: params["username"] = username if self.nostrict_host_check.get_active(): full_ssh += ["-o", "StrictHostKeyChecking=no"] if params["type"] == "ssh -> ssh": params["type"] = "ssh" params["proxy_host"] = self.config.proxy_host params["proxy_port"] = self.config.proxy_port params["proxy_username"] = self.config.proxy_username params["proxy_password"] = self.config.proxy_password full_ssh += add_ssh_proxy_args(self.config.proxy_username, self.config.proxy_password, self.config.proxy_host, self.config.proxy_port, self.config.proxy_key, ssh_cmd, self.is_putty, self.is_paramiko) params["host"] = host params["local"] = is_local(self.config.host) params["full_ssh"] = full_ssh params["password"] = password params["display_name"] = "ssh:%s:%s" % (self.config.host, self.config.port) elif self.config.mode == "unix-domain": params["display"] = ":%s" % self.config.port params["display_name"] = "unix-domain:%s" % self.config.port else: assert self.config.mode in ( "tcp", "ssl", "ws", "wss"), "invalid / unsupported mode %s" % self.config.mode params["host"] = self.config.host params["local"] = is_local(self.config.host) params["port"] = int(self.config.port) params["display_name"] = "%s:%s:%s" % ( self.config.mode, self.config.host, self.config.port) if self.config.mode in ( "ssl", "wss") and self.nostrict_host_check.get_active(): params["strict-host-check"] = False #print("connect_to(%s)" % params) #UGLY warning: the username may have been updated during display parsing, #or the config file may contain a username which is different from the default one #which is used for initializing the client during init, #so update the client now: def raise_exception(*args): raise Exception(*args) configure_env(self.config.env) configure_logging(self.config, "attach") configure_network(self.config) self.client = make_client(raise_exception, self.config) self.client.show_progress(30, "client configuration") self.client.init(self.config) self.client.show_progress(40, "loading user interface") self.client.init_ui(self.config) self.client.username = username def handshake_complete(*_args): self.client.show_progress(100, "connection established") self.client.after_handshake(handshake_complete) self.set_info_text("Connecting...") start_thread(self.do_connect_builtin, "connect", daemon=True, args=(params, ))
def main(): from xpra.os_util import SIGNAMES from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() from xpra.platform import init as platform_init, clean as platform_clean from xpra.platform.gui import ready as gui_ready from xpra.log import enable_color try: platform_init("Xpra-Launcher", "Xpra Connection Launcher") enable_color() gui_init() try: from xpra.scripts.main import parse_cmdline, fixup_debug_option options, args = parse_cmdline(sys.argv) debug = fixup_debug_option(options.debug) if debug: for x in debug.split(","): enable_debug_for(x) except Exception: exception_dialog("Error parsing command line") return 1 try: app = ApplicationWindow() def app_signal(signum, frame): print("") log("got signal %s" % SIGNAMES.get(signum, signum)) def show_signal(): app.show() app.client.cleanup() glib.timeout_add(1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) glib.timeout_add(1000, app.set_info_color, True) #call from UI thread: glib.idle_add(show_signal) if sys.version_info[0]<3: #breaks GTK3.. signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) has_file = len(args) == 1 if has_file: app.update_options_from_file(args[0]) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) debug = fixup_debug_option(app.config.debug) if debug: for x in debug.split(","): enable_debug_for(x) #suspend tray workaround for our window widgets: try: set_use_tray_workaround(False) app.create_window() finally: set_use_tray_workaround(True) app.update_gui_from_config() except Exception: exception_dialog("Error creating launcher form") return 1 try: if app.config.autoconnect: #file says we should connect, #do that only (not showing UI unless something goes wrong): glib.idle_add(app.do_connect) if not has_file: app.reset_errors() gui_ready() if not app.config.autoconnect or app.config.debug: app.show() app.run() except KeyboardInterrupt: pass return 0 finally: platform_clean()