Coverage for /home/antoine/projects/xpra-git/dist/python3/lib64/python/xpra/client/mixins/stub_client_mixin.py : 83%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# This file is part of Xpra.
2# Copyright (C) 2018 Antoine Martin <antoine@xpra.org>
3# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
4# later version. See the file COPYING for details.
6import sys
7import time
9from xpra.util import typedict
12class StubClientMixin:
14 __signals__ = {}
15 def __init__(self):
16 self.exit_code = None
17 self.start_time = int(time.time())
19 def init(self, _opts, _extra_args=()):
20 """
21 Initialize this instance with the options given.
22 Options are usually obtained by parsing the command line,
23 or using a default configuration object.
24 """
26 def run(self):
27 """
28 run the main loop.
29 """
31 def quit(self, exit_code): # pragma: no cover
32 """
33 Terminate the client with the given exit code.
34 (the exit code is ignored if we already have one)
35 """
36 self.exit_code = exit_code
37 sys.exit(exit_code)
39 def cleanup(self):
40 """
41 Free up any resources.
42 """
44 def send(self, *_args, **_kwargs):
45 """
46 Send a packet to the server, dummy implementation.
47 """
49 def send_now(self, *parts):
50 """
51 Send a packet to the server,
52 this takes precedence over packets sent via send().
53 """
55 def emit(self, *_args, **_kwargs):
56 """
57 Emit a signal, dummy implementation overriden by gobject.
58 """
60 def setup_connection(self, _conn):
61 """
62 Prepare to run using this connection to the server.
63 """
65 def get_caps(self) -> dict:
66 """
67 Return the capabilities provided by this mixin.
68 """
69 return {}
71 def get_info(self) -> dict:
72 """
73 Information contained in this mixin
74 """
75 return {}
77 def parse_server_capabilities(self, c : typedict) -> bool:
78 """
79 Parse server attributes specified in the hello capabilities.
80 This runs in a non-UI thread.
81 """
82 return True
84 def process_ui_capabilities(self, caps : typedict):
85 """
86 Parse server attributes specified in the hello capabilities.
87 This runs in the UI thread.
88 """
90 def compressed_wrapper(self, datatype, data, level=5):
91 """
92 Dummy utility method for compressing data.
93 Actual client implementations will provide compression
94 based on the client and server capabilities (lz4, lzo, zlib).
95 """
96 #sub-classes should override this
97 assert level>=0
98 from xpra.net.compression import Compressed
99 return Compressed("raw %s" % datatype, data, can_inline=True)
101 def init_authenticated_packet_handlers(self):
102 """
103 Register the packet types that this mixin can handle.
104 """
106 def add_packet_handler(self, packet_type : str, handler : callable, main_thread=True): # pragma: no cover
107 raise NotImplementedError()
109 def add_packet_handlers(self, defs, main_thread=True): # pragma: no cover
110 raise NotImplementedError()
112 def show_progress(self, pct, text=""):
113 pass