示例#1
0
 def do_process_control_packet(self, proto, packet):
     log("process_control_packet(%s, %s)", proto, packet)
     packet_type = packet[0]
     if packet_type==Protocol.CONNECTION_LOST:
         log.info("Connection lost")
         if proto in self.potential_protocols:
             self.potential_protocols.remove(proto)
         return
     if packet_type=="hello":
         caps = typedict(packet[1])
         if caps.boolget("challenge"):
             self.send_disconnect(proto, AUTHENTICATION_ERROR, "this socket does not use authentication")
             return
         generic_request = caps.strget("request")
         def is_req(mode):
             return generic_request==mode or caps.boolget("%s_request" % mode)
         if is_req("info"):
             proto.send_now(("hello", self.get_proxy_info(proto)))
             self.timeout_add(5*1000, self.send_disconnect, proto, CLIENT_EXIT_TIMEOUT, "info sent")
             return
         elif is_req("stop"):
             self.stop("socket request", None)
             return
         elif is_req("version"):
             version = XPRA_VERSION
             if caps.boolget("full-version-request"):
                 version = full_version_str()
             proto.send_now(("hello", {"version" : version}))
             self.timeout_add(5*1000, self.send_disconnect, proto, CLIENT_EXIT_TIMEOUT, "version sent")
             return
     self.send_disconnect(proto, CONTROL_COMMAND_ERROR, "this socket only handles 'info', 'version' and 'stop' requests")
示例#2
0
    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 = {}
示例#3
0
 def do_process_control_packet(self, proto, packet):
     log("process_control_packet(%s, %s)", proto, packet)
     packet_type = bytestostr(packet[0])
     if packet_type==CONNECTION_LOST:
         log.info("Connection lost")
         if proto in self.potential_protocols:
             self.potential_protocols.remove(proto)
         return
     if packet_type=="hello":
         caps = typedict(packet[1])
         if caps.boolget("challenge"):
             self.send_disconnect(proto, AUTHENTICATION_ERROR, "this socket does not use authentication")
             return
         generic_request = caps.strget("request")
         def is_req(mode):
             return generic_request==mode or caps.boolget("%s_request" % mode)
         if is_req("info"):
             info = self.get_proxy_info(proto)
             info.setdefault("connection", {}).update(self.get_connection_info())
             proto.send_now(("hello", info))
             self.timeout_add(5*1000, self.send_disconnect, proto, CLIENT_EXIT_TIMEOUT, "info sent")
             return
         if is_req("stop"):
             self.stop(None, "socket request")
             return
         if is_req("version"):
             version = XPRA_VERSION
             if caps.boolget("full-version-request"):
                 version = full_version_str()
             proto.send_now(("hello", {"version" : version}))
             self.timeout_add(5*1000, self.send_disconnect, proto, CLIENT_EXIT_TIMEOUT, "version sent")
             return
         log.warn("Warning: invalid hello packet,")
         log.warn(" not a supported control channel request")
     else:
         log.warn("Warning: invalid packet type for control channel")
         log.warn(" '%s' is not supported, only 'hello' is", packet_type)
     self.send_disconnect(proto, CONTROL_COMMAND_ERROR,
                          "this socket only handles 'info', 'version' and 'stop' requests")
示例#4
0
def get_title():
    from xpra.version_util import full_version_str
    return "Xpra top %s" % full_version_str()
示例#5
0
    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 = {}
示例#6
0
def get_title():
    return "Xpra top %s" % full_version_str()
示例#7
0
    def process_network_packet(self, proto, packet):
        log("process_network_packet: %s", packet)
        packet_type = bytestostr(packet[0])

        def close():
            t = self._close_timers.pop(proto, None)
            if t:
                proto.close()
            try:
                self._potential_protocols.remove(proto)
            except ValueError:
                pass

        def hello_reply(data):
            proto.send_now(["hello", data])

        if packet_type == "hello":
            caps = typedict(packet[1])
            proto.parse_remote_caps(caps)
            proto.enable_compressor_from_caps(caps)
            proto.enable_encoder_from_caps(caps)
            request = caps.strget("request")
            if request == "info":

                def send_info():
                    info = self.get_info()
                    info["network"] = get_network_caps()
                    hello_reply(info)

                #run in UI thread:
                self.idle_add(send_info)
            elif request == "id":
                hello_reply(self.get_id_info())
            elif request == "detach":

                def protocol_closed():
                    self.disconnect_and_quit(EXIT_OK, "network request")

                proto.send_disconnect([DETACH_REQUEST],
                                      done_callback=protocol_closed)
                return
            elif request == "version":
                hello_reply({"version": full_version_str()})
            elif request in ("show-menu", "show-about", "show-session-info"):
                fn = getattr(self, request.replace("-", "_"), None)
                log.info("fn=%s", fn)
                if not fn:
                    hello_reply({"error": "%s not found" % request})
                else:
                    from gi.repository import GLib
                    GLib.idle_add(fn)
                    hello_reply({})
            elif request == "show-session-info":
                self.show_session_info()
                hello_reply({})
            elif request == "connect_test":
                hello_reply({})
            elif request == "command":
                command = caps.strtupleget("command_request")
                log("command request: %s", command)

                def process_control():
                    try:
                        self._process_control(["control"] + list(command))
                        code = EXIT_OK
                        response = "done"
                    except Exception as e:
                        code = EXIT_FAILURE
                        response = str(e)
                    hello_reply({"command_response": (code, response)})

                self.idle_add(process_control)
            else:
                log.info("request '%s' is not handled by this client", request)
                proto.send_disconnect([PROTOCOL_ERROR])
        elif packet_type in (CONNECTION_LOST, GIBBERISH):
            close()
            return
        else:
            log.info("packet '%s' is not handled by this client", packet_type)
            proto.send_disconnect([PROTOCOL_ERROR])
        #make sure the connection is closed:
        tid = self.timeout_add(REQUEST_TIMEOUT * 1000, close)
        self._close_timers[proto] = tid