Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* add 'is_needed' mixin filtering to AVSync, Audio, Clipboard, Encodings, FilePrint, Webcam and Windows
* fix minor server issues where we assumed that the mixin would be present (windows, clipboard)
* expose which mixins are loaded via 'xpra info'
* don't set the 'clipboard-source' to one that doesn't have the mixin,
* add missing flag to client webcam mixin caps,
* remove av-sync caps from client audio mixin caps

git-svn-id: https://xpra.org/svn/Xpra/trunk@24910 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jan 5, 2020
1 parent 3672b5e commit dda0629
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 29 deletions.
6 changes: 4 additions & 2 deletions src/xpra/client/mixins/audio.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is part of Xpra.
# Copyright (C) 2010-2018 Antoine Martin <[email protected]>
# Copyright (C) 2010-2020 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

Expand Down Expand Up @@ -163,8 +163,10 @@ def get_audio_capabilities(self):
return caps

def get_avsync_capabilities(self):
if not self.av_sync:
return {}
return {
"" : self.av_sync,
"" : True,
"delay.default" : max(0, DEFAULT_AV_SYNC_DELAY + AV_SYNC_DELTA),
}

Expand Down
6 changes: 6 additions & 0 deletions src/xpra/client/mixins/webcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ def init(self, opts):
log("webcam forwarding: %s", self.webcam_forwarding)


def get_caps(self) -> dict:
if not self.webcam_forwarding:
return {}
return {"webcam" : True}


def parse_server_capabilities(self):
c = self.server_capabilities
self.server_webcam = c.boolget("webcam")
Expand Down
14 changes: 6 additions & 8 deletions src/xpra/server/mixins/clipboard_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def init_clipboard(self):

def parse_hello_ui_clipboard(self, ss):
#take the clipboard if no-one else has it yet:
if not ss.clipboard_enabled:
if not getattr(ss, "clipboard_enabled", False):
log("client does not support clipboard")
return
if not self._clipboard_helper:
Expand All @@ -141,6 +141,10 @@ def parse_hello_ui_clipboard(self, ss):
self.set_clipboard_source(ss)

def set_clipboard_source(self, ss):
if not getattr(ss, "clipboard_enabled", False):
#don't use this client as clipboard source!
#(its clipboard is disabled)
return
if self._clipboard_client==ss:
return
self._clipboard_client = ss
Expand All @@ -158,6 +162,7 @@ def set_clipboard_source(self, ss):
ch.enable_selections(ss.clipboard_client_selections)
ch.set_clipboard_contents_slice_fix(ss.clipboard_contents_slice_fix)
ch.set_preferred_targets(ss.clipboard_preferred_targets)
ch.send_tokens(ss.clipboard_client_selections)
else:
ch.enable_selections([])

Expand All @@ -170,13 +175,6 @@ def last_client_exited(self):

def set_session_driver(self, source):
self.set_clipboard_source(source)
ch = self._clipboard_helper
if not source or not ch:
return
log("set_session_driver(%s) clipboard_enabled=%s, clipboard helper=%s", source, source.clipboard_enabled, ch)
if source.clipboard_enabled:
log("selections: %s", source.clipboard_client_selections)
ch.send_tokens(source.clipboard_client_selections)


def _process_clipboard_packet(self, proto, packet):
Expand Down
18 changes: 13 additions & 5 deletions src/xpra/server/mixins/window_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ def add_new_client(self, *_args):
minw, minh = self.window_min_size
maxw, maxh = self.window_max_size
for ss in tuple(self._server_sources.values()):
cminw, cminh = ss.window_min_size
cmaxw, cmaxh = ss.window_max_size
cmin = getattr(ss, "window_min_size", None)
cmax = getattr(ss, "window_max_size", None)
if not cmin or not cmax:
continue
cminw, cminh = cmin
cmaxw, cmaxh = cmax
minw = max(minw, cminw)
minh = max(minh, cminh)
if cmaxw>0:
Expand All @@ -117,9 +121,13 @@ def update_size_constraints(self, minw, minh, maxw, maxh):


def send_initial_data(self, ss, caps, send_ui, share_count):
if send_ui:
self.send_initial_windows(ss, share_count>0)
self.send_initial_cursors(ss, share_count>0)
if not send_ui:
return
if not hasattr(ss, "new_window"):
#no window source mixin
return
self.send_initial_windows(ss, share_count>0)
self.send_initial_cursors(ss, share_count>0)


def is_shown(self, _window):
Expand Down
7 changes: 6 additions & 1 deletion src/xpra/server/source/audio_mixin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# This file is part of Xpra.
# Copyright (C) 2010-2018 Antoine Martin <[email protected]>
# Copyright (C) 2010-2020 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

Expand All @@ -19,6 +19,11 @@

class AudioMixin(StubSourceMixin):

@classmethod
def is_needed(cls, caps):
return caps.boolget("sound.send") or caps.boolget("sound.receive")


def __init__(self):
self.sound_properties = {}
self.sound_source_plugin = ""
Expand Down
10 changes: 9 additions & 1 deletion src/xpra/server/source/avsync_mixin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# This file is part of Xpra.
# Copyright (C) 2010-2019 Antoine Martin <[email protected]>
# Copyright (C) 2010-2020 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

Expand All @@ -16,6 +16,14 @@

class AVSyncMixin(StubSourceMixin):

@classmethod
def is_needed(cls, caps):
if not (caps.boolget("sound.send") or caps.boolget("sound.receive")):
#no audio!
return False
return caps.boolget("av-sync") and caps.boolget("windows")


def __init__(self):
self.av_sync = False

Expand Down
7 changes: 6 additions & 1 deletion src/xpra/server/source/client_connection_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ def send_hello(self, server_capabilities):
self.hello_sent = True

def get_info(self) -> dict:
info = {}
def module_name(m):
name = str(m.__name__.split(".")[-1])
return name.replace("Mixin", "").replace("Connection", "").rstrip("_")
info = {
"modules" : tuple(module_name(x) for x in CC_BASES),
}
for bc in CC_BASES:
log("%s.get_info()", bc)
try:
Expand Down
8 changes: 5 additions & 3 deletions src/xpra/server/source/clipboard_connection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# This file is part of Xpra.
# Copyright (C) 2010-2019 Antoine Martin <[email protected]>
# Copyright (C) 2010-2020 Antoine Martin <[email protected]>
# Copyright (C) 2008 Nathaniel Smith <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.
Expand All @@ -22,8 +22,10 @@

class ClipboardConnection(StubSourceMixin):

def init_from(self, _protocol, _server):
pass
@classmethod
def is_needed(cls, caps):
return caps.boolget("clipboard")


def init_state(self):
self.clipboard_enabled = False
Expand Down
7 changes: 6 additions & 1 deletion src/xpra/server/source/encodings_mixin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# This file is part of Xpra.
# Copyright (C) 2011 Serviware (Arthur Huillet, <[email protected]>)
# Copyright (C) 2010-2019 Antoine Martin <[email protected]>
# Copyright (C) 2010-2020 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

Expand Down Expand Up @@ -33,6 +33,11 @@
"""
class EncodingsMixin(StubSourceMixin):

@classmethod
def is_needed(cls, caps):
return bool(caps.strtupleget("encodings"))


def __init__(self):
self.server_core_encodings = []
self.server_encodings = []
Expand Down
7 changes: 6 additions & 1 deletion src/xpra/server/source/fileprint_mixin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# This file is part of Xpra.
# Copyright (C) 2010-2019 Antoine Martin <[email protected]>
# Copyright (C) 2010-2020 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

Expand All @@ -20,6 +20,11 @@

class FilePrintMixin(FileTransferHandler, StubSourceMixin):

@classmethod
def is_needed(cls, caps):
return bool(caps.boolget("file-transfer") or caps.boolget("printing"))


def init_state(self):
self.printers = {}
self.printers_added = set()
Expand Down
8 changes: 7 additions & 1 deletion src/xpra/server/source/webcam_mixin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# This file is part of Xpra.
# Copyright (C) 2010-2019 Antoine Martin <[email protected]>
# Copyright (C) 2010-2020 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

Expand Down Expand Up @@ -32,6 +32,12 @@ def valid_encodings(args):
"""
class WebcamMixin(StubSourceMixin):

@classmethod
def is_needed(cls, caps):
#the 'webcam' capability was only added in v4,
#so we have to enabled the mixin:
return True

def __init__(self):
self.webcam_enabled = False
self.webcam_device = None
Expand Down
7 changes: 6 additions & 1 deletion src/xpra/server/source/windows_mixin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# This file is part of Xpra.
# Copyright (C) 2010-2019 Antoine Martin <[email protected]>
# Copyright (C) 2010-2020 Antoine Martin <[email protected]>
# Copyright (C) 2008 Nathaniel Smith <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.
Expand Down Expand Up @@ -39,6 +39,11 @@
"""
class WindowsMixin(StubSourceMixin):

@classmethod
def is_needed(cls, caps):
return caps.boolget("windows")


def __init__(self):
self.get_transient_for = None
self.get_focus = None
Expand Down
9 changes: 5 additions & 4 deletions src/xpra/x11/server.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# This file is part of Xpra.
# Copyright (C) 2011 Serviware (Arthur Huillet, <[email protected]>)
# Copyright (C) 2010-2019 Antoine Martin <[email protected]>
# Copyright (C) 2010-2020 Antoine Martin <[email protected]>
# Copyright (C) 2008 Nathaniel Smith <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.
Expand Down Expand Up @@ -471,10 +471,11 @@ def get_transient_for(self, window):


def parse_hello_ui_window_settings(self, ss, _caps):
framelog("parse_hello_ui_window_settings: client window_frame_sizes=%s", ss.window_frame_sizes)
window_frame_sizes = getattr(ss, "window_frame_sizes", None)
framelog("parse_hello_ui_window_settings: client window_frame_sizes=%s", window_frame_sizes)
frame = None
if ss.window_frame_sizes:
frame = ss.window_frame_sizes.inttupleget("frame", (0, 0, 0, 0), 4, 4)
if window_frame_sizes:
frame = window_frame_sizes.inttupleget("frame", (0, 0, 0, 0), 4, 4)
if self._wm:
self._wm.set_default_frame_extents(frame)

Expand Down

0 comments on commit dda0629

Please sign in to comment.