Hide keyboard shortcuts

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. 

5 

6import sys 

7import time 

8 

9from xpra.util import typedict 

10 

11 

12class StubClientMixin: 

13 

14 __signals__ = {} 

15 def __init__(self): 

16 self.exit_code = None 

17 self.start_time = int(time.time()) 

18 

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 """ 

25 

26 def run(self): 

27 """ 

28 run the main loop. 

29 """ 

30 

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) 

38 

39 def cleanup(self): 

40 """ 

41 Free up any resources. 

42 """ 

43 

44 def send(self, *_args, **_kwargs): 

45 """ 

46 Send a packet to the server, dummy implementation. 

47 """ 

48 

49 def send_now(self, *parts): 

50 """ 

51 Send a packet to the server, 

52 this takes precedence over packets sent via send(). 

53 """ 

54 

55 def emit(self, *_args, **_kwargs): 

56 """ 

57 Emit a signal, dummy implementation overriden by gobject. 

58 """ 

59 

60 def setup_connection(self, _conn): 

61 """ 

62 Prepare to run using this connection to the server. 

63 """ 

64 

65 def get_caps(self) -> dict: 

66 """ 

67 Return the capabilities provided by this mixin. 

68 """ 

69 return {} 

70 

71 def get_info(self) -> dict: 

72 """ 

73 Information contained in this mixin 

74 """ 

75 return {} 

76 

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 

83 

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 """ 

89 

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) 

100 

101 def init_authenticated_packet_handlers(self): 

102 """ 

103 Register the packet types that this mixin can handle. 

104 """ 

105 

106 def add_packet_handler(self, packet_type : str, handler : callable, main_thread=True): # pragma: no cover 

107 raise NotImplementedError() 

108 

109 def add_packet_handlers(self, defs, main_thread=True): # pragma: no cover 

110 raise NotImplementedError() 

111 

112 def show_progress(self, pct, text=""): 

113 pass