diff --git a/src/unittests/unit/client/mixins_test.py b/src/unittests/unit/client/mixins_test.py index 7abeb56b9e..f5cca47bcd 100755 --- a/src/unittests/unit/client/mixins_test.py +++ b/src/unittests/unit/client/mixins_test.py @@ -10,6 +10,7 @@ from xpra.os_util import monotonic_time from xpra.client.mixins.network_state import NetworkState from xpra.client.mixins.mmap_client import MmapClient +from xpra.client.mixins.remote_logging import RemoteLogging class MixinsTest(unittest.TestCase): @@ -46,6 +47,34 @@ def test_mmap(self): }) x.parse_server_capabilities() + def test_remotelogging(self): + x = RemoteLogging() + opts = AdHocStruct() + opts.remote_logging = "yes" + x.init(opts) + assert x.get_caps() is not None + x.server_capabilities = typedict({ + "remote-logging" : True, + }) + x.parse_server_capabilities() + packets = [] + def send(*args): + packets.append(args) + x.send = send + from xpra.log import Logger + log = Logger("util") + message = "hello" + log.info(message) + assert len(packets)==1 + packet = packets[0] + assert packet[0]=="logging" + assert packet[1]==20 #info + assert packet[2].data==message + #after cleanup, log messages should not be intercepted: + x.cleanup() + log.info("foo") + assert len(packets)==1 + def main(): unittest.main() diff --git a/src/xpra/client/mixins/audio_client.py b/src/xpra/client/mixins/audio_client.py index 0545088c61..96e30b7812 100644 --- a/src/xpra/client/mixins/audio_client.py +++ b/src/xpra/client/mixins/audio_client.py @@ -25,6 +25,7 @@ class AudioClient(StubClientMixin): __signals__ = ["speaker-changed", "microphone-changed"] def __init__(self): + StubClientMixin.__init__(self) self.sound_source_plugin = None self.speaker_allowed = False self.speaker_enabled = False diff --git a/src/xpra/client/mixins/clipboard_client.py b/src/xpra/client/mixins/clipboard_client.py index 9c0f53ecfb..ba6b4ee11e 100644 --- a/src/xpra/client/mixins/clipboard_client.py +++ b/src/xpra/client/mixins/clipboard_client.py @@ -25,6 +25,7 @@ class ClipboardClient(StubClientMixin): __signals__ = ["clipboard-toggled"] def __init__(self): + StubClientMixin.__init__(self) self.client_clipboard_type = "" self.client_clipboard_direction = "both" self.client_supports_clipboard = False diff --git a/src/xpra/client/mixins/display_client.py b/src/xpra/client/mixins/display_client.py index 27cc52c2e6..9c2712e860 100644 --- a/src/xpra/client/mixins/display_client.py +++ b/src/xpra/client/mixins/display_client.py @@ -45,6 +45,7 @@ class DisplayClient(StubClientMixin): __signals__ = ["scaling-changed"] def __init__(self): + StubClientMixin.__init__(self) self.dpi = 0 self.initial_scaling = 1, 1 self.xscale, self.yscale = self.initial_scaling diff --git a/src/xpra/client/mixins/encodings.py b/src/xpra/client/mixins/encodings.py index bd265b94ba..2392996c0f 100644 --- a/src/xpra/client/mixins/encodings.py +++ b/src/xpra/client/mixins/encodings.py @@ -35,7 +35,9 @@ Mixin for adding encodings to a client """ class Encodings(StubClientMixin): + def __init__(self): + StubClientMixin.__init__(self) self.allowed_encodings = [] self.core_encodings = None self.encoding = None diff --git a/src/xpra/client/mixins/mmap_client.py b/src/xpra/client/mixins/mmap_client.py index 62763e8e62..21effaaadc 100644 --- a/src/xpra/client/mixins/mmap_client.py +++ b/src/xpra/client/mixins/mmap_client.py @@ -19,7 +19,9 @@ Mixin for adding mmap support to a client """ class MmapClient(StubClientMixin): + def __init__(self): + StubClientMixin.__init__(self) self.mmap_enabled = False self.mmap = None self.mmap_token = None diff --git a/src/xpra/client/mixins/network_state.py b/src/xpra/client/mixins/network_state.py index f80ff1f5fa..56c22c41e3 100644 --- a/src/xpra/client/mixins/network_state.py +++ b/src/xpra/client/mixins/network_state.py @@ -31,7 +31,7 @@ class NetworkState(StubClientMixin): def __init__(self): - self.start_time = int(monotonic_time()) + StubClientMixin.__init__(self) self.uuid = get_user_uuid() self.server_start_time = -1 diff --git a/src/xpra/client/mixins/notification_client.py b/src/xpra/client/mixins/notification_client.py index 8b18ec57e8..ba19688b87 100644 --- a/src/xpra/client/mixins/notification_client.py +++ b/src/xpra/client/mixins/notification_client.py @@ -23,6 +23,7 @@ class NotificationClient(StubClientMixin): def __init__(self): + StubClientMixin.__init__(self) self.client_supports_notifications = False self.notifications_enabled = False self.notifier = None diff --git a/src/xpra/client/mixins/remote_logging.py b/src/xpra/client/mixins/remote_logging.py index 8ef3b9a357..2ebcc37e86 100644 --- a/src/xpra/client/mixins/remote_logging.py +++ b/src/xpra/client/mixins/remote_logging.py @@ -22,6 +22,7 @@ class RemoteLogging(StubClientMixin): def __init__(self): + StubClientMixin.__init__(self) self.client_supports_remote_logging = False self.in_remote_logging = False self.local_logging = None diff --git a/src/xpra/client/mixins/rpc_client.py b/src/xpra/client/mixins/rpc_client.py index 73e8822b3f..2ffe69b5b7 100644 --- a/src/xpra/client/mixins/rpc_client.py +++ b/src/xpra/client/mixins/rpc_client.py @@ -20,6 +20,7 @@ class RPCClient(StubClientMixin): def __init__(self): + StubClientMixin.__init__(self) #rpc / dbus: self.rpc_counter = AtomicInteger() self.rpc_pending_requests = {} diff --git a/src/xpra/client/mixins/stub_client_mixin.py b/src/xpra/client/mixins/stub_client_mixin.py index 0e6852fb4f..299fd38203 100644 --- a/src/xpra/client/mixins/stub_client_mixin.py +++ b/src/xpra/client/mixins/stub_client_mixin.py @@ -5,17 +5,24 @@ import sys +from xpra.os_util import monotonic_time + + class StubClientMixin(object): __signals__ = {} + def __init__(self): + self.exit_code = None + self.start_time = int(monotonic_time()) - def init(self, opts): + def init(self, _opts): pass def run(self): pass def quit(self, exit_code): + self.exit_code = exit_code sys.exit(exit_code) def cleanup(self): @@ -39,6 +46,12 @@ def parse_server_capabilities(self): def process_ui_capabilities(self): pass + def compressed_wrapper(self, datatype, data, level=5): + #sub-classes should override this + assert level>=0 + from xpra.net.compression import Compressed + return Compressed("raw %s" % datatype, data, can_inline=True) + def init_authenticated_packet_handlers(self): pass diff --git a/src/xpra/client/mixins/tray_client.py b/src/xpra/client/mixins/tray_client.py index 26cd27ae4f..bd08d99821 100644 --- a/src/xpra/client/mixins/tray_client.py +++ b/src/xpra/client/mixins/tray_client.py @@ -20,7 +20,9 @@ (not forwarding other application's trays - that's handled in WindowClient) """ class TrayClient(StubClientMixin): + def __init__(self): + StubClientMixin.__init__(self) #settings: self.tray_enabled = False self.delay_tray = False diff --git a/src/xpra/client/mixins/webcam_forwarder.py b/src/xpra/client/mixins/webcam_forwarder.py index c0b94e9cc4..6e67a9758f 100644 --- a/src/xpra/client/mixins/webcam_forwarder.py +++ b/src/xpra/client/mixins/webcam_forwarder.py @@ -27,6 +27,7 @@ class WebcamForwarder(StubClientMixin): __signals__ = ["webcam-changed"] def __init__(self): + StubClientMixin.__init__(self) #webcam: self.webcam_option = "" self.webcam_forwarding = False diff --git a/src/xpra/client/mixins/window_client.py b/src/xpra/client/mixins/window_client.py index ee59dcf878..36e75e2df9 100644 --- a/src/xpra/client/mixins/window_client.py +++ b/src/xpra/client/mixins/window_client.py @@ -67,6 +67,7 @@ class WindowClient(StubClientMixin): def __init__(self): + StubClientMixin.__init__(self) self._window_to_id = {} self._id_to_window = {}