Пример #1
0
 def process_packet(self, proto, packet):
     packet_type = str(packet[0])
     if packet_type.startswith("clipboard-"):
         if self.clipboard_enabled:
             self._client_extras.process_clipboard_packet(packet)
     else:
         XpraClientBase.process_packet(self, proto, packet)
Пример #2
0
 def init_packet_handlers(self):
     XpraClientBase.init_packet_handlers(self)
     for k,v in {
         "hello":                self._process_hello,
         "new-window":           self._process_new_window,
         "new-override-redirect":self._process_new_override_redirect,
         "window-resized":       self._process_window_resized,
         "cursor":               self._process_cursor,
         "bell":                 self._process_bell,
         "notify_show":          self._process_notify_show,
         "notify_close":         self._process_notify_close,
         "window-metadata":      self._process_window_metadata,
         "configure-override-redirect":  self._process_configure_override_redirect,
         "lost-window":          self._process_lost_window,
         "desktop_size":         self._process_desktop_size,
         # "clipboard-*" packets are handled by a special case below.
         }.items():
         self._ui_packet_handlers[k] = v
     #these handlers can run directly from the network thread:
     for k,v in {
         "draw":                 self._process_draw,
         "ping":                 self._process_ping,
         "ping_echo":            self._process_ping_echo,
         }.items():
         self._packet_handlers[k] = v
Пример #3
0
 def process_packet(self, proto, packet):
     packet_type = str(packet[0])
     if packet_type.startswith("clipboard-"):
         if self.clipboard_enabled:
             self._client_extras.process_clipboard_packet(packet)
     else:
         XpraClientBase.process_packet(self, proto, packet)
Пример #4
0
 def init_packet_handlers(self):
     XpraClientBase.init_packet_handlers(self)
     for k, v in {
             "hello": self._process_hello,
             "new-window": self._process_new_window,
             "new-override-redirect": self._process_new_override_redirect,
             "window-resized": self._process_window_resized,
             "cursor": self._process_cursor,
             "bell": self._process_bell,
             "notify_show": self._process_notify_show,
             "notify_close": self._process_notify_close,
             "window-metadata": self._process_window_metadata,
             "configure-override-redirect":
             self._process_configure_override_redirect,
             "lost-window": self._process_lost_window,
             "desktop_size": self._process_desktop_size,
             # "clipboard-*" packets are handled by a special case below.
     }.items():
         self._ui_packet_handlers[k] = v
     #these handlers can run directly from the network thread:
     for k, v in {
             "draw": self._process_draw,
             "ping": self._process_ping,
             "ping_echo": self._process_ping_echo,
     }.items():
         self._packet_handlers[k] = v
Пример #5
0
 def parse_server_capabilities(self, capabilities):
     XpraClientBase.parse_server_capabilities(self, capabilities)
     if not self.session_name:
         self.session_name = capabilities.get("session_name", "Xpra")
     try:
         import glib
         glib.set_application_name(self.session_name)
     except ImportError, e:
         log.warn("glib is missing, cannot set the application name, please install glib's python bindings: %s", e)
Пример #6
0
 def parse_server_capabilities(self, capabilities):
     XpraClientBase.parse_server_capabilities(self, capabilities)
     if not self.session_name:
         self.session_name = capabilities.get("session_name", "Xpra")
     try:
         import glib
         glib.set_application_name(self.session_name)
     except ImportError, e:
         log.warn("glib is missing, cannot set the application name, please install glib's python bindings: %s", e)
Пример #7
0
 def make_hello(self, challenge_response=None):
     capabilities = XpraClientBase.make_hello(self, challenge_response)
     for k, v in self.get_keymap_properties().items():
         capabilities[k] = v
     capabilities["xkbmap_layout"] = nn(self.xkbmap_layout)
     capabilities["xkbmap_variant"] = nn(self.xkbmap_variant)
     capabilities["clipboard"] = self.clipboard_enabled
     capabilities["notifications"] = self._client_extras.can_notify()
     capabilities["modifiers"] = self.get_current_modifiers()
     root_w, root_h = gtk.gdk.get_default_root_window().get_size()
     capabilities["desktop_size"] = [root_w, root_h]
     key_repeat = self._client_extras.get_keyboard_repeat()
     if key_repeat:
         delay_ms, interval_ms = key_repeat
         capabilities["key_repeat"] = (delay_ms, interval_ms)
     capabilities["keyboard_sync"] = self.keyboard_sync and (key_repeat
                                                             is not None)
     if self.mmap_file:
         capabilities["mmap_file"] = self.mmap_file
         capabilities["mmap_token"] = self.mmap_token
     #these should be turned into options:
     capabilities["cursors"] = True
     capabilities["bell"] = True
     #this is to keep compatibility with v0.0.7.36 only
     #and will be removed shortly
     capabilities["keyboard_as_properties"] = True
     capabilities["damage_sequence"] = True
     capabilities["rowstride"] = True
     capabilities["ping"] = True
     capabilities["png_window_icons"] = "png" in ENCODINGS
     return capabilities
Пример #8
0
 def make_hello(self, challenge_response=None):
     capabilities = XpraClientBase.make_hello(self, challenge_response)
     for k,v in self.get_keymap_properties().items():
         capabilities[k] = v
     capabilities["xkbmap_layout"] = nn(self.xkbmap_layout)
     capabilities["xkbmap_variant"] = nn(self.xkbmap_variant)
     capabilities["clipboard"] = self.clipboard_enabled
     capabilities["notifications"] = self._client_extras.can_notify()
     capabilities["modifiers"] = self.get_current_modifiers()
     root_w, root_h = get_root_size()
     capabilities["desktop_size"] = [root_w, root_h]
     key_repeat = self._client_extras.get_keyboard_repeat()
     if key_repeat:
         delay_ms,interval_ms = key_repeat
         capabilities["key_repeat"] = (delay_ms,interval_ms)
     capabilities["keyboard_sync"] = self.keyboard_sync and (key_repeat is not None)
     if self.mmap_file:
         capabilities["mmap_file"] = self.mmap_file
         capabilities["mmap_token"] = self.mmap_token
     #these should be turned into options:
     capabilities["cursors"] = True
     capabilities["bell"] = True
     #this is to keep compatibility with v0.0.7.36 only
     #and will be removed shortly
     capabilities["keyboard_as_properties"] = True
     capabilities["damage_sequence"] = True
     capabilities["rowstride"] = True
     capabilities["ping"] = True
     capabilities["png_window_icons"] = "png" in ENCODINGS
     return capabilities
Пример #9
0
 def make_hello(self, challenge_response=None):
     capabilities = XpraClientBase.make_hello(self, challenge_response)
     add_gtk_version_info(capabilities, gtk)
     for k,v in self.get_keymap_properties().items():
         capabilities[k] = v
     if self.readonly:
         #don't bother sending keyboard info, as it won't be used
         capabilities["keyboard"] = False
     else:
         capabilities["xkbmap_layout"] = nn(self.xkbmap_layout)
         capabilities["xkbmap_variant"] = nn(self.xkbmap_variant)
     capabilities["modifiers"] = self.get_current_modifiers()
     root_w, root_h = get_root_size()
     capabilities["desktop_size"] = [root_w, root_h]
     capabilities["screen_sizes"] = self.get_screen_sizes()
     key_repeat = self._client_extras.get_keyboard_repeat()
     if key_repeat:
         delay_ms,interval_ms = key_repeat
         capabilities["key_repeat"] = (delay_ms,interval_ms)
     capabilities["keyboard_sync"] = self.keyboard_sync and (key_repeat is not None)
     if self.mmap_file:
         capabilities["mmap_file"] = self.mmap_file
         capabilities["mmap_token"] = self.mmap_token
     capabilities["randr_notify"] = True
     capabilities["compressible_cursors"] = True
     capabilities["dpi"] = self.dpi
     capabilities["clipboard"] = self.client_supports_clipboard
     capabilities["notifications"] = self.client_supports_notifications
     capabilities["cursors"] = self.client_supports_cursors
     capabilities["bell"] = self.client_supports_bell
     capabilities["encoding_client_options"] = True
     capabilities["share"] = self.client_supports_sharing
     return capabilities
Пример #10
0
 def make_hello(self, challenge_response=None):
     capabilities = XpraClientBase.make_hello(self, challenge_response)
     add_gtk_version_info(capabilities, gtk)
     for k, v in self.get_keymap_properties().items():
         capabilities[k] = v
     if self.readonly:
         #don't bother sending keyboard info, as it won't be used
         capabilities["keyboard"] = False
     else:
         capabilities["xkbmap_layout"] = nn(self.xkbmap_layout)
         capabilities["xkbmap_variant"] = nn(self.xkbmap_variant)
     capabilities["modifiers"] = self.get_current_modifiers()
     root_w, root_h = get_root_size()
     capabilities["desktop_size"] = [root_w, root_h]
     key_repeat = self._client_extras.get_keyboard_repeat()
     if key_repeat:
         delay_ms, interval_ms = key_repeat
         capabilities["key_repeat"] = (delay_ms, interval_ms)
     capabilities["keyboard_sync"] = self.keyboard_sync and (key_repeat
                                                             is not None)
     if self.mmap_file:
         capabilities["mmap_file"] = self.mmap_file
         capabilities["mmap_token"] = self.mmap_token
     capabilities["randr_notify"] = True
     capabilities["compressible_cursors"] = True
     capabilities["dpi"] = self.dpi
     capabilities["clipboard"] = self.client_supports_clipboard
     capabilities["notifications"] = self.client_supports_notifications
     capabilities["cursors"] = self.client_supports_cursors
     capabilities["bell"] = self.client_supports_bell
     capabilities["encoding_client_options"] = True
     return capabilities
Пример #11
0
 def make_hello(self, challenge_response=None):
     capabilities = XpraClientBase.make_hello(self, challenge_response)
     for k,v in self.get_keymap_properties().items():
         capabilities[k] = v
     if self.readonly:
         #don't bother sending keyboard info, as it won't be used
         capabilities["keyboard"] = False
     else:
         capabilities["xkbmap_layout"] = nn(self.xkbmap_layout)
         capabilities["xkbmap_variant"] = nn(self.xkbmap_variant)
     capabilities["clipboard"] = self.clipboard_enabled
     capabilities["notifications"] = self._client_extras.can_notify()
     capabilities["modifiers"] = self.get_current_modifiers()
     root_w, root_h = get_root_size()
     capabilities["desktop_size"] = [root_w, root_h]
     key_repeat = self._client_extras.get_keyboard_repeat()
     if key_repeat:
         delay_ms,interval_ms = key_repeat
         capabilities["key_repeat"] = (delay_ms,interval_ms)
     capabilities["keyboard_sync"] = self.keyboard_sync and (key_repeat is not None)
     if self.mmap_file:
         capabilities["mmap_file"] = self.mmap_file
         capabilities["mmap_token"] = self.mmap_token
     capabilities["randr_notify"] = True
     #these should be turned into options:
     capabilities["cursors"] = True
     capabilities["bell"] = True
     capabilities["png_window_icons"] = "png" in ENCODINGS
     return capabilities
Пример #12
0
 def make_hello(self, challenge_response=None):
     capabilities = XpraClientBase.make_hello(self, challenge_response)
     for k, v in self.get_keymap_properties().items():
         capabilities[k] = v
     if self.readonly:
         #don't bother sending keyboard info, as it won't be used
         capabilities["keyboard"] = False
     else:
         capabilities["xkbmap_layout"] = nn(self.xkbmap_layout)
         capabilities["xkbmap_variant"] = nn(self.xkbmap_variant)
     capabilities["clipboard"] = self.clipboard_enabled
     capabilities["notifications"] = self._client_extras.can_notify()
     capabilities["modifiers"] = self.get_current_modifiers()
     root_w, root_h = get_root_size()
     capabilities["desktop_size"] = [root_w, root_h]
     key_repeat = self._client_extras.get_keyboard_repeat()
     if key_repeat:
         delay_ms, interval_ms = key_repeat
         capabilities["key_repeat"] = (delay_ms, interval_ms)
     capabilities["keyboard_sync"] = self.keyboard_sync and (key_repeat
                                                             is not None)
     if self.mmap_file:
         capabilities["mmap_file"] = self.mmap_file
         capabilities["mmap_token"] = self.mmap_token
     capabilities["randr_notify"] = True
     #these should be turned into options:
     capabilities["cursors"] = True
     capabilities["bell"] = True
     capabilities["png_window_icons"] = "png" in ENCODINGS
     return capabilities
Пример #13
0
 def make_hello(self, challenge_response=None):
     capabilities = XpraClientBase.make_hello(self, challenge_response)
     add_gtk_version_info(capabilities, gtk)
     for k, v in self.get_keymap_properties().items():
         capabilities[k] = v
     if self.readonly:
         #don't bother sending keyboard info, as it won't be used
         capabilities["keyboard"] = False
     else:
         capabilities["xkbmap_layout"] = nn(self.xkbmap_layout)
         capabilities["xkbmap_variant"] = nn(self.xkbmap_variant)
     capabilities["modifiers"] = self.get_current_modifiers()
     root_w, root_h = get_root_size()
     capabilities["desktop_size"] = [root_w, root_h]
     capabilities["screen_sizes"] = self.get_screen_sizes()
     capabilities["client_type"] = "Python/Gtk"
     key_repeat = self._client_extras.get_keyboard_repeat()
     if key_repeat:
         delay_ms, interval_ms = key_repeat
         capabilities["key_repeat"] = (delay_ms, interval_ms)
     capabilities["keyboard_sync"] = self.keyboard_sync and (key_repeat
                                                             is not None)
     if self.mmap_file:
         capabilities["mmap_file"] = self.mmap_file
         capabilities["mmap_token"] = self.mmap_token
     capabilities["randr_notify"] = True
     capabilities["compressible_cursors"] = True
     capabilities["dpi"] = self.dpi
     capabilities["clipboard"] = self.client_supports_clipboard
     capabilities["notifications"] = self.client_supports_notifications
     capabilities["cursors"] = self.client_supports_cursors
     capabilities["bell"] = self.client_supports_bell
     capabilities["encoding_client_options"] = True
     capabilities["rgb24zlib"] = True
     capabilities["share"] = self.client_supports_sharing
     capabilities["auto_refresh_delay"] = int(self.auto_refresh_delay *
                                              1000)
     capabilities["windows"] = self.windows_enabled
     try:
         from wimpiggy.prop import set_xsettings_format
         assert set_xsettings_format
         capabilities["xsettings-tuple"] = True
     except:
         pass
     return capabilities
Пример #14
0
 def make_hello(self, challenge_response=None):
     capabilities = XpraClientBase.make_hello(self, challenge_response)
     add_gtk_version_info(capabilities, gtk)
     for k,v in self.get_keymap_properties().items():
         capabilities[k] = v
     if self.readonly:
         #don't bother sending keyboard info, as it won't be used
         capabilities["keyboard"] = False
     else:
         capabilities["xkbmap_layout"] = nn(self.xkbmap_layout)
         capabilities["xkbmap_variant"] = nn(self.xkbmap_variant)
     capabilities["modifiers"] = self.get_current_modifiers()
     root_w, root_h = get_root_size()
     capabilities["desktop_size"] = [root_w, root_h]
     capabilities["screen_sizes"] = self.get_screen_sizes()
     capabilities["client_type"] = "Python/Gtk"
     key_repeat = self._client_extras.get_keyboard_repeat()
     if key_repeat:
         delay_ms,interval_ms = key_repeat
         capabilities["key_repeat"] = (delay_ms,interval_ms)
     capabilities["keyboard_sync"] = self.keyboard_sync and (key_repeat is not None)
     if self.mmap_file:
         capabilities["mmap_file"] = self.mmap_file
         capabilities["mmap_token"] = self.mmap_token
     capabilities["randr_notify"] = True
     capabilities["compressible_cursors"] = True
     capabilities["dpi"] = self.dpi
     capabilities["clipboard"] = self.client_supports_clipboard
     capabilities["notifications"] = self.client_supports_notifications
     capabilities["cursors"] = self.client_supports_cursors
     capabilities["bell"] = self.client_supports_bell
     capabilities["encoding_client_options"] = True
     capabilities["rgb24zlib"] = True
     capabilities["share"] = self.client_supports_sharing
     capabilities["auto_refresh_delay"] = int(self.auto_refresh_delay*1000)
     capabilities["windows"] = self.windows_enabled
     try:
         from wimpiggy.prop import set_xsettings_format
         assert set_xsettings_format
         capabilities["xsettings-tuple"] = True
     except:
         pass
     return capabilities
Пример #15
0
 def make_hello(self, challenge_response=None):
     capabilities = XpraClientBase.make_hello(self, challenge_response)
     if self.compression_level:
         capabilities["deflate"] = self.compression_level
     if self.xkbmap_layout:
         capabilities["xkbmap_layout"] = self.xkbmap_layout
         if self.xkbmap_variant:
             capabilities["xkbmap_variant"] = self.xkbmap_variant
     for x in ["xkbmap_print", "xkbmap_query", "xmodmap_data",
               "xkbmap_mod_clear", "xkbmap_mod_add", "xkbmap_mod_meanings",
               "xkbmap_mod_managed", "xkbmap_mod_pointermissing", "xkbmap_keycodes"]:
         v = getattr(self, x)
         if v is not None:
             capabilities[x] = v
     #special case: this used to be sent as "keymap" prior to 0.0.7.35:
     if self.xkbmap_print:
         capabilities["keymap"] = self.xkbmap_print
     capabilities["cursors"] = True
     capabilities["bell"] = True
     capabilities["clipboard"] = self.clipboard_enabled
     capabilities["notifications"] = self._client_extras.can_notify()
     (_, _, current_mask) = gtk.gdk.get_default_root_window().get_pointer()
     modifiers = self.mask_to_names(current_mask)
     log.debug("sending modifiers=%s" % str(modifiers))
     capabilities["modifiers"] = modifiers
     root_w, root_h = gtk.gdk.get_default_root_window().get_size()
     capabilities["desktop_size"] = [root_w, root_h]
     capabilities["png_window_icons"] = True
     capabilities["damage_sequence"] = True
     capabilities["rowstride"] = True
     capabilities["ping"] = True
     key_repeat = self._client_extras.get_keyboard_repeat()
     if key_repeat:
         delay_ms,interval_ms = key_repeat
         capabilities["key_repeat"] = (delay_ms,interval_ms)
     capabilities["keyboard_sync"] = self.keyboard_sync and (key_repeat is not None)
     capabilities["keyboard_as_properties"] = True
     if self.mmap_file:
         capabilities["mmap_file"] = self.mmap_file
         capabilities["mmap_token"] = self.mmap_token
     return capabilities
Пример #16
0
 def make_hello(self, challenge_response=None):
     capabilities = XpraClientBase.make_hello(self, challenge_response)
     if self.compression_level:
         capabilities["deflate"] = self.compression_level
     if self.xkbmap_layout:
         capabilities["xkbmap_layout"] = self.xkbmap_layout
         if self.xkbmap_variant:
             capabilities["xkbmap_variant"] = self.xkbmap_variant
     for x in ["xkbmap_print", "xkbmap_query", "xmodmap_data",
               "xkbmap_mod_clear", "xkbmap_mod_add", "xkbmap_mod_meanings",
               "xkbmap_mod_managed", "xkbmap_mod_pointermissing", "xkbmap_keycodes"]:
         v = getattr(self, x)
         if v is not None:
             capabilities[x] = v
     #special case: this used to be sent as "keymap" prior to 0.0.7.35:
     if self.xkbmap_print:
         capabilities["keymap"] = self.xkbmap_print
     capabilities["cursors"] = True
     capabilities["bell"] = True
     capabilities["clipboard"] = self.clipboard_enabled
     capabilities["notifications"] = self._client_extras.can_notify()
     (_, _, current_mask) = gtk.gdk.get_default_root_window().get_pointer()
     modifiers = self.mask_to_names(current_mask)
     log.debug("sending modifiers=%s" % str(modifiers))
     capabilities["modifiers"] = modifiers
     root_w, root_h = gtk.gdk.get_default_root_window().get_size()
     capabilities["desktop_size"] = [root_w, root_h]
     capabilities["png_window_icons"] = True
     capabilities["damage_sequence"] = True
     capabilities["rowstride"] = True
     capabilities["ping"] = True
     key_repeat = self._client_extras.get_keyboard_repeat()
     if key_repeat:
         delay_ms,interval_ms = key_repeat
         capabilities["key_repeat"] = (delay_ms,interval_ms)
     capabilities["keyboard_sync"] = self.keyboard_sync and (key_repeat is not None)
     capabilities["keyboard_as_properties"] = True
     if self.mmap_file:
         capabilities["mmap_file"] = self.mmap_file
         capabilities["mmap_token"] = self.mmap_token
     return capabilities
Пример #17
0
    def __init__(self, conn, opts):
        XpraClientBase.__init__(self, opts)
        self.start_time = time.time()
        self._window_to_id = {}
        self._id_to_window = {}
        self.title = opts.title
        self.readonly = opts.readonly
        self.session_name = opts.session_name
        self.compression_level = opts.compression_level
        self.auto_refresh_delay = opts.auto_refresh_delay
        self.max_bandwidth = opts.max_bandwidth
        if self.max_bandwidth > 0.0 and self.jpegquality == 0:
            """ jpegquality was not set, use a better start value """
            self.jpegquality = 50
        self.dpi = int(opts.dpi)

        #statistics:
        self.server_start_time = -1
        self.server_platform = ""
        self.server_actual_desktop_size = None
        self.server_randr = False
        self.pixel_counter = maxdeque(maxlen=100)
        self.server_latency = maxdeque(maxlen=100)
        self.server_load = None
        self.client_latency = maxdeque(maxlen=100)
        self.last_ping_echoed_time = 0

        #features:
        self.toggle_cursors_bell_notify = False
        self.toggle_keyboard_sync = False
        self.window_configure = False
        self._client_extras = ClientExtras(self, opts)
        self.client_supports_notifications = opts.notifications and self._client_extras.can_notify(
        )
        self.client_supports_clipboard = opts.clipboard and self._client_extras.supports_clipboard(
        ) and not self.readonly
        self.client_supports_cursors = opts.cursors
        self.client_supports_bell = opts.bell
        self.notifications_enabled = self.client_supports_notifications
        self.clipboard_enabled = self.client_supports_clipboard
        self.cursors_enabled = self.client_supports_cursors
        self.bell_enabled = self.client_supports_bell

        #mmap:
        self.mmap_enabled = False
        self.mmap = None
        self.mmap_token = None
        self.mmap_file = None
        self.mmap_size = 0
        self.supports_mmap = opts.mmap and (
            "rgb24" in ENCODINGS) and self._client_extras.supports_mmap()
        if self.supports_mmap:
            self.init_mmap(opts.mmap_group, conn.filename)

        self.init_packet_handlers()
        self.ready(conn)

        #keyboard:
        self.keyboard_sync = opts.keyboard_sync
        self.key_repeat_delay = -1
        self.key_repeat_interval = -1
        self.keys_pressed = {}
        self._remote_version = None
        self._keymap_changing = False
        try:
            self._keymap = gdk.keymap_get_default()
        except:
            self._keymap = None
        self._do_keys_changed()
        self.key_shortcuts = self.parse_shortcuts(opts.key_shortcuts)
        self.send_hello()

        if self._keymap:
            self._keymap.connect("keys-changed", self._keys_changed)

        self._focused = None

        def compute_receive_bandwidth(delay):
            bytecount = self._protocol.input_bytecount
            bw = (
                (bytecount - self.last_input_bytecount) / 1024) * 1000 / delay
            self.last_input_bytecount = bytecount
            log.debug("Bandwidth is ", bw, "kB/s, max ", self.max_bandwidth,
                      "kB/s")
            q = self.jpegquality
            if bw > self.max_bandwidth:
                q -= 10
            elif bw < self.max_bandwidth:
                q += 5
            q = max(10, min(95, q))
            self.send_jpeg_quality(q)
            return True

        if (self.max_bandwidth):
            self.last_input_bytecount = 0
            gobject.timeout_add(2000, compute_receive_bandwidth, 2000)
        if opts.send_pings:
            gobject.timeout_add(1000, self.send_ping)
        else:
            gobject.timeout_add(20 * 1000, self.send_ping)
Пример #18
0
 def cleanup(self):
     if self._client_extras:
         self._client_extras.cleanup()
     XpraClientBase.cleanup(self)
     self.clean_mmap()
Пример #19
0
 def cleanup(self):
     if self._client_extras:
         self._client_extras.exit()
         self._client_extras = None
     XpraClientBase.cleanup(self)
     self.clean_mmap()
Пример #20
0
 def make_hello(self, challenge_response=None):
     capabilities = XpraClientBase.make_hello(self, challenge_response)
     capabilities["waste_of_space"] = "\0" * (32 * 1024)
     return capabilities
Пример #21
0
    def __init__(self, conn, opts):
        XpraClientBase.__init__(self, opts)
        self.start_time = time.time()
        self._window_to_id = {}
        self._id_to_window = {}
        self._ui_events = 0
        self.title = opts.title
        self.readonly = opts.readonly
        self.session_name = opts.session_name
        self.compression_level = opts.compression_level
        self.auto_refresh_delay = opts.auto_refresh_delay
        self.max_bandwidth = opts.max_bandwidth
        if self.max_bandwidth>0.0 and self.jpegquality==0:
            """ jpegquality was not set, use a better start value """
            self.jpegquality = 50
        self.dpi = int(opts.dpi)

        #statistics:
        self.server_start_time = -1
        self.server_platform = ""
        self.server_actual_desktop_size = None
        self.server_randr = False
        self.pixel_counter = maxdeque(maxlen=100)
        self.server_latency = maxdeque(maxlen=100)
        self.server_load = None
        self.client_latency = maxdeque(maxlen=100)
        self.last_ping_echoed_time = 0

        #features:
        self.toggle_cursors_bell_notify = False
        self.toggle_keyboard_sync = False
        self.window_configure = False
        self._client_extras = ClientExtras(self, opts)
        self.client_supports_notifications = opts.notifications and self._client_extras.can_notify()
        self.client_supports_clipboard = opts.clipboard and self._client_extras.supports_clipboard() and not self.readonly
        self.client_supports_cursors = opts.cursors
        self.client_supports_bell = opts.bell
        self.client_supports_sharing = opts.sharing
        self.notifications_enabled = self.client_supports_notifications
        self.clipboard_enabled = self.client_supports_clipboard
        self.cursors_enabled = self.client_supports_cursors
        self.bell_enabled = self.client_supports_bell

        #mmap:
        self.mmap_enabled = False
        self.mmap = None
        self.mmap_token = None
        self.mmap_file = None
        self.mmap_size = 0
        self.supports_mmap = opts.mmap and ("rgb24" in ENCODINGS) and self._client_extras.supports_mmap()
        if self.supports_mmap:
            self.init_mmap(opts.mmap_group, conn.filename)

        self.init_packet_handlers()
        self.ready(conn)

        #keyboard:
        self.keyboard_sync = opts.keyboard_sync
        self.key_repeat_delay = -1
        self.key_repeat_interval = -1
        self.keys_pressed = {}
        self._remote_version = None
        self._keymap_changing = False
        try:
            self._keymap = gdk.keymap_get_default()
        except:
            self._keymap = None
        self._do_keys_changed()
        self.key_shortcuts = self.parse_shortcuts(opts.key_shortcuts)
        log.info("xpra client version %s" % __version__)
        self.send_hello()

        if self._keymap:
            self._keymap.connect("keys-changed", self._keys_changed)

        self._focused = None
        def compute_receive_bandwidth(delay):
            bytecount = self._protocol.input_bytecount
            bw = ((bytecount - self.last_input_bytecount) / 1024) * 1000 / delay
            self.last_input_bytecount = bytecount;
            log.debug("Bandwidth is ", bw, "kB/s, max ", self.max_bandwidth, "kB/s")
            q = self.jpegquality
            if bw > self.max_bandwidth:
                q -= 10
            elif bw < self.max_bandwidth:
                q += 5
            q = max(10, min(95 ,q))
            self.send_jpeg_quality(q)
            return True
        if (self.max_bandwidth):
            self.last_input_bytecount = 0
            gobject.timeout_add(2000, compute_receive_bandwidth, 2000)
        if opts.send_pings:
            gobject.timeout_add(1000, self.send_ping)
        else:
            gobject.timeout_add(20*1000, self.send_ping)
Пример #22
0
    def __init__(self, conn, opts):
        XpraClientBase.__init__(self, opts)
        self.start_time = time.time()
        self._window_to_id = {}
        self._id_to_window = {}
        title = opts.title
        if opts.title_suffix is not None:
            title = "@title@ %s" % opts.title_suffix
        self.title = title
        self.readonly = opts.readonly
        self.session_name = opts.session_name
        self.compression_level = opts.compression_level
        self.auto_refresh_delay = opts.auto_refresh_delay
        self.max_bandwidth = opts.max_bandwidth
        if self.max_bandwidth>0.0 and self.jpegquality==0:
            """ jpegquality was not set, use a better start value """
            self.jpegquality = 50

        self.server_capabilities = {}

        self.can_ping = False
        self.mmap_enabled = False
        self.server_start_time = -1
        self.server_platform = ""
        self.server_actual_desktop_size = None
        self.server_desktop_size = None
        self.server_randr = False
        self.pixel_counter = deque(maxlen=100)
        self.server_latency = deque(maxlen=100)
        self.server_load = None
        self.client_latency = deque(maxlen=100)
        self.bell_enabled = True
        self.notifications_enabled = True
        self.send_damage_sequence = False
        self.clipboard_enabled = False
        self.mmap = None
        self.mmap_token = None
        self.mmap_file = None
        self.mmap_size = 0

        self._client_extras = ClientExtras(self, opts)
        self.clipboard_enabled = not self.readonly and opts.clipboard and self._client_extras.supports_clipboard()
        self.supports_mmap = opts.mmap and self._client_extras.supports_mmap()
        if self.supports_mmap:
            try:
                import mmap
                import tempfile
                import uuid
                import ctypes
                from stat import S_IRUSR,S_IWUSR
                mmap_dir = os.getenv("TMPDIR", "/tmp")
                if not os.path.exists(mmap_dir):
                    raise Exception("TMPDIR %s does not exist!" % mmap_dir)
                temp = tempfile.NamedTemporaryFile(prefix="xpra.", suffix=".mmap", dir=mmap_dir)
                #keep a reference to it so it does not disappear!
                self._mmap_temp_file = temp
                self.mmap_file = temp.name
                #ensure that the permissions are strict:
                os.chmod(self.mmap_file, S_IRUSR|S_IWUSR)
                self.mmap_size = max(4096, mmap.PAGESIZE)*32*1024   #generally 128MB
                fd = temp.file.fileno()
                log("using mmap file %s, fd=%s, size=%s", self.mmap_file, fd, self.mmap_size)
                os.lseek(fd, self.mmap_size-1, os.SEEK_SET)
                assert os.write(fd, '\x00')
                os.lseek(fd, 0, os.SEEK_SET)
                self.mmap = mmap.mmap(fd, length=self.mmap_size)
                #write the 16 byte token one byte at a time - no endianness
                self.mmap_token = uuid.uuid4().int
                log.debug("mmap_token=%s", self.mmap_token)
                v = self.mmap_token
                for i in range(0,16):
                    poke = ctypes.c_ubyte.from_buffer(self.mmap, 512+i)
                    poke.value = v % 256
                    v = v>>8
                assert v==0
            except Exception, e:
                log.error("failed to setup mmap: %s", e)
                self.supports_mmap = False
                self.clean_mmap()
                self.mmap = None
                self.mmap_file = None
                self.mmap_size = 0
Пример #23
0
 def cleanup(self):
     if self._client_extras:
         self._client_extras.exit()
         self._client_extras = None
     XpraClientBase.cleanup(self)
     self.clean_mmap()
Пример #24
0
    def __init__(self, conn, opts):
        XpraClientBase.__init__(self, opts)
        self.start_time = time.time()
        self._window_to_id = {}
        self._id_to_window = {}
        title = opts.title
        if opts.title_suffix is not None:
            title = "@title@ %s" % opts.title_suffix
        self.title = title
        self.readonly = opts.readonly
        self.session_name = opts.session_name
        self.compression_level = opts.compression_level
        self.auto_refresh_delay = opts.auto_refresh_delay
        self.max_bandwidth = opts.max_bandwidth
        if self.max_bandwidth>0.0 and self.jpegquality==0:
            """ jpegquality was not set, use a better start value """
            self.jpegquality = 50

        self.server_capabilities = {}

        self.mmap_enabled = False
        self.server_start_time = -1
        self.server_platform = ""
        self.server_actual_desktop_size = None
        self.server_desktop_size = None
        self.server_randr = False
        self.pixel_counter = maxdeque(maxlen=100)
        self.server_latency = maxdeque(maxlen=100)
        self.server_load = None
        self.client_latency = maxdeque(maxlen=100)
        self.toggle_cursors_bell_notify = False
        self.bell_enabled = True
        self.cursors_enabled = True
        self.notifications_enabled = True
        self.clipboard_enabled = False
        self.mmap = None
        self.mmap_token = None
        self.mmap_file = None
        self.mmap_size = 0

        self._client_extras = ClientExtras(self, opts)
        self.clipboard_enabled = not self.readonly and opts.clipboard and self._client_extras.supports_clipboard()
        self.supports_mmap = opts.mmap and ("rgb24" in ENCODINGS) and self._client_extras.supports_mmap()
        if self.supports_mmap:
            try:
                import mmap
                import tempfile
                import uuid
                from stat import S_IRUSR,S_IWUSR,S_IRGRP,S_IWGRP
                mmap_dir = os.getenv("TMPDIR", "/tmp")
                if not os.path.exists(mmap_dir):
                    raise Exception("TMPDIR %s does not exist!" % mmap_dir)
                #create the mmap file, the mkstemp that is called via NamedTemporaryFile ensures
                #that the file is readable and writable only by the creating user ID
                temp = tempfile.NamedTemporaryFile(prefix="xpra.", suffix=".mmap", dir=mmap_dir)
                #keep a reference to it so it does not disappear!
                self._mmap_temp_file = temp
                self.mmap_file = temp.name
                fd = temp.file.fileno()
                #set the group permissions and gid if the mmap-group option is specified
                if opts.mmap_group and type(conn.target)==str and os.path.exists(conn.target):
                    s = os.stat(conn.target)
                    os.fchown(fd, -1, s.st_gid)
                    os.fchmod(fd, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
                self.mmap_size = max(4096, mmap.PAGESIZE)*32*1024   #generally 128MB
                log("using mmap file %s, fd=%s, size=%s", self.mmap_file, fd, self.mmap_size)
                os.lseek(fd, self.mmap_size-1, os.SEEK_SET)
                assert os.write(fd, '\x00')
                os.lseek(fd, 0, os.SEEK_SET)
                self.mmap = mmap.mmap(fd, length=self.mmap_size)
                #write the 16 byte token one byte at a time - no endianness
                self.mmap_token = uuid.uuid4().int
                log.debug("mmap_token=%s", self.mmap_token)
                v = self.mmap_token
                for i in range(0,16):
                    poke = ctypes.c_ubyte.from_buffer(self.mmap, 512+i)
                    poke.value = v % 256
                    v = v>>8
                assert v==0
            except Exception, e:
                log.error("failed to setup mmap: %s", e)
                self.supports_mmap = False
                self.clean_mmap()
                self.mmap = None
                self.mmap_file = None
                self.mmap_size = 0
Пример #25
0
 def make_hello(self, challenge_response=None):
     capabilities = XpraClientBase.make_hello(self, challenge_response)
     capabilities["waste_of_space"] = "\0" * (32*1024)
     return capabilities
Пример #26
0
    def __init__(self, conn, opts):
        XpraClientBase.__init__(self, opts)
        self.start_time = time.time()
        self._window_to_id = {}
        self._id_to_window = {}
        self.title = opts.title
        self.readonly = opts.readonly
        self.session_name = opts.session_name
        self.compression_level = opts.compression_level
        self.auto_refresh_delay = opts.auto_refresh_delay
        self.max_bandwidth = opts.max_bandwidth
        if self.max_bandwidth > 0.0 and self.jpegquality == 0:
            """ jpegquality was not set, use a better start value """
            self.jpegquality = 50

        self.mmap_enabled = False
        self.server_start_time = -1
        self.server_platform = ""
        self.server_actual_desktop_size = None
        self.server_randr = False
        self.pixel_counter = maxdeque(maxlen=100)
        self.server_latency = maxdeque(maxlen=100)
        self.server_load = None
        self.client_latency = maxdeque(maxlen=100)
        self.toggle_cursors_bell_notify = False
        self.toggle_keyboard_sync = False
        self.bell_enabled = True
        self.cursors_enabled = True
        self.notifications_enabled = True
        self.clipboard_enabled = False
        self.window_configure = False
        self.mmap = None
        self.mmap_token = None
        self.mmap_file = None
        self.mmap_size = 0
        self.last_ping_echoed_time = 0

        self._client_extras = ClientExtras(self, opts)
        self.clipboard_enabled = not self.readonly and opts.clipboard and self._client_extras.supports_clipboard(
        )
        self.supports_mmap = opts.mmap and (
            "rgb24" in ENCODINGS) and self._client_extras.supports_mmap()
        if self.supports_mmap:
            try:
                import mmap
                import tempfile
                import uuid
                from stat import S_IRUSR, S_IWUSR, S_IRGRP, S_IWGRP
                mmap_dir = os.getenv("TMPDIR", "/tmp")
                if not os.path.exists(mmap_dir):
                    raise Exception("TMPDIR %s does not exist!" % mmap_dir)
                #create the mmap file, the mkstemp that is called via NamedTemporaryFile ensures
                #that the file is readable and writable only by the creating user ID
                temp = tempfile.NamedTemporaryFile(prefix="xpra.",
                                                   suffix=".mmap",
                                                   dir=mmap_dir)
                #keep a reference to it so it does not disappear!
                self._mmap_temp_file = temp
                self.mmap_file = temp.name
                fd = temp.file.fileno()
                #set the group permissions and gid if the mmap-group option is specified
                if opts.mmap_group and type(
                        conn.target) == str and os.path.exists(conn.target):
                    s = os.stat(conn.target)
                    os.fchown(fd, -1, s.st_gid)
                    os.fchmod(fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)
                self.mmap_size = max(
                    4096, mmap.PAGESIZE) * 32 * 1024  #generally 128MB
                log("using mmap file %s, fd=%s, size=%s", self.mmap_file, fd,
                    self.mmap_size)
                os.lseek(fd, self.mmap_size - 1, os.SEEK_SET)
                assert os.write(fd, '\x00')
                os.lseek(fd, 0, os.SEEK_SET)
                self.mmap = mmap.mmap(fd, length=self.mmap_size)
                #write the 16 byte token one byte at a time - no endianness
                self.mmap_token = uuid.uuid4().int
                log.debug("mmap_token=%s", self.mmap_token)
                v = self.mmap_token
                for i in range(0, 16):
                    poke = ctypes.c_ubyte.from_buffer(self.mmap, 512 + i)
                    poke.value = v % 256
                    v = v >> 8
                assert v == 0
            except Exception, e:
                log.error("failed to setup mmap: %s", e)
                self.supports_mmap = False
                self.clean_mmap()
                self.mmap = None
                self.mmap_file = None
                self.mmap_size = 0
Пример #27
0
 def cleanup(self):
     if self._client_extras:
         self._client_extras.cleanup()
     XpraClientBase.cleanup(self)
     self.clean_mmap()