Coverage for /home/antoine/projects/xpra-git/dist/python3/lib64/python/xpra/server/mixins/stub_server_mixin.py : 98%
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-2020 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 os
7import shlex
9from xpra.util import typedict
10from xpra.os_util import WIN32
13class StubServerMixin:
14 """
15 Base class for server mixins.
16 Defines the default interface methods that each mixin may override.
17 """
19 def init(self, _opts):
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 init_state(self):
27 """
28 Initialize state attributes.
29 """
32 def reset_focus(self):
33 """
34 Called when we reset the focus.
35 """
37 def last_client_exited(self):
38 """
39 Called when the last client has exited,
40 so we can reset things to their original state.
41 """
43 def cleanup(self):
44 """
45 Free up any resources.
46 """
48 def setup(self):
49 """
50 After initialization, prepare to run.
51 """
53 def threaded_setup(self):
54 """
55 Prepare to run, this method runs in parallel to start faster.
56 """
58 def init_sockets(self, _sockets):
59 """
60 Prepare to handle connections from the given sockets.
61 """
63 def get_caps(self, _source) -> dict:
64 """
65 Capabilities provided by this mixin.
66 """
67 return {}
69 def get_server_features(self, _source) -> dict:
70 """
71 Features provided by this mixin.
72 (the difference with capabilities is that those will only
73 be returned if the client requests 'features')
74 """
75 return {}
77 def set_session_driver(self, _source):
78 """
79 When the user in control of the session changes,
80 this method will be called.
81 """
83 def get_info(self, _proto) -> dict:
84 """
85 Runtime information on this mixin, includes state and settings.
86 Somewhat overlaps with the capabilities and features,
87 but the data is returned in a structured format. (ie: nested dictionaries)
88 """
89 return {}
91 def get_ui_info(self, proto, client_uuids=None, *args) -> dict:
92 """
93 Runtime information on this mixin,
94 unlike get_info() this method will be called
95 from the UI thread.
96 """
97 return {}
99 def init_packet_handlers(self):
100 """
101 Register the packet types that this mixin can handle.
102 """
104 def parse_hello(self, ss, caps : typedict, send_ui):
105 """
106 Parse capabilities from a new connection.
107 """
109 def add_new_client(self, ss, c, send_ui, share_count : int):
110 """
111 A new client is being handled, take any action needed.
112 """
114 def send_initial_data(self, ss, caps, send_ui, share_count : int):
115 """
116 A new connection has been accepted, send initial data.
117 """
119 def cleanup_protocol(self, protocol):
120 """
121 Cleanup method for a specific connection.
122 (to cleanup / free up resources associated with a specific client or connection)
123 """
126 def get_child_env(self):
127 return os.environ.copy()
130 def get_full_child_command(self, cmd, use_wrapper : bool=True) -> list:
131 #make sure we have it as a list:
132 if isinstance(cmd, (list, tuple)):
133 return cmd
134 if WIN32: #pragma: no cover
135 return [cmd]
136 return shlex.split(str(cmd))
139 def get_http_scripts(self) -> dict:
140 return {}
143 def add_packet_handler(self, packet_type, handler, main_thread=True):
144 pass
146 def add_packet_handlers(self, defs, main_thread=True):
147 pass
149 def get_server_source(self, proto):
150 return None