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# -*- coding: utf-8 -*- 

2# This file is part of Xpra. 

3# Copyright (C) 2010-2020 Antoine Martin <antoine@xpra.org> 

4# Xpra is released under the terms of the GNU GPL v2, or, at your option, any 

5# later version. See the file COPYING for details. 

6 

7from xpra.util import std, typedict 

8from xpra.server.source.stub_source_mixin import StubSourceMixin 

9from xpra.os_util import platform_name 

10from xpra.log import Logger 

11 

12log = Logger("server") 

13 

14 

15""" 

16Store information about the client. 

17""" 

18class ClientInfoMixin(StubSourceMixin): 

19 

20 def cleanup(self): 

21 self.init_state() 

22 

23 def init_state(self): 

24 self.uuid = "" 

25 self.session_id = "" 

26 self.machine_id = "" 

27 self.hostname = "" 

28 self.username = "" 

29 self.name = "" 

30 self.argv = () 

31 self.sharing = False 

32 # client capabilities/options: 

33 self.client_setting_change = False 

34 self.client_type = None 

35 self.client_version = None 

36 self.client_revision= None 

37 self.client_bits = 0 

38 self.client_platform = None 

39 self.client_machine = None 

40 self.client_processor = None 

41 self.client_release = None 

42 self.client_linux_distribution = None 

43 self.client_proxy = False 

44 self.client_wm_name = None 

45 self.client_session_type = None 

46 self.client_session_type_full = None 

47 self.client_connection_data = {} 

48 self.client_opengl = {} 

49 self.proxy_hostname = None 

50 self.proxy_platform = None 

51 self.proxy_release = None 

52 self.proxy_version = None 

53 self.proxy_version = None 

54 

55 def parse_client_caps(self, c : typedict): 

56 self.uuid = c.strget("uuid") 

57 self.session_id = c.strget("session-id") 

58 self.machine_id = c.strget("machine_id") 

59 self.hostname = c.strget("hostname") 

60 self.username = c.strget("username") 

61 self.name = c.strget("name") 

62 self.argv = c.strtupleget("argv") 

63 self.sharing = c.boolget("share") 

64 self.client_type = c.strget("client_type", "PyGTK") 

65 self.client_platform = c.strget("platform") 

66 self.client_machine = c.strget("platform.machine") 

67 self.client_processor = c.strget("platform.processor") 

68 self.client_release = c.strget("platform.sysrelease") 

69 self.client_linux_distribution = c.strtupleget("platform.linux_distribution") 

70 self.client_version = c.strget("version") 

71 self.client_revision = c.strget("build.revision") 

72 self.client_bits = c.intget("python.bits") 

73 self.client_proxy = c.boolget("proxy") 

74 self.client_wm_name = c.strget("wm_name") 

75 self.client_session_type = c.strget("session-type") 

76 self.client_session_type_full = c.strget("session-type.full", "") 

77 self.client_setting_change = c.boolget("setting-change") 

78 self.client_opengl = typedict(c.dictget("opengl") or {}) 

79 self.proxy_hostname = c.strget("proxy.hostname") 

80 self.proxy_platform = c.strget("proxy.platform") 

81 self.proxy_release = c.strget("proxy.platform.sysrelease") 

82 self.proxy_version = c.strget("proxy.version") 

83 self.proxy_version = c.strget("proxy.build.version", self.proxy_version) 

84 log("client uuid %s", self.uuid) 

85 

86 def get_connect_info(self) -> list: 

87 cinfo = [] 

88 #client platform / version info: 

89 pinfo = "" 

90 if self.client_platform: 

91 pinfo = " %s" % platform_name(self.client_platform, self.client_linux_distribution or self.client_release) 

92 if self.client_session_type: 

93 pinfo += " %s" % self.client_session_type 

94 revinfo = "" 

95 if self.client_revision: 

96 revinfo="-r%s" % self.client_revision 

97 bitsstr = "" 

98 if self.client_bits: 

99 bitsstr = " %i-bit" % self.client_bits 

100 cinfo.append("%s%s client version %s%s%s" % ( 

101 std(self.client_type), pinfo, std(self.client_version), std(revinfo), bitsstr) 

102 ) 

103 #opengl info: 

104 if self.client_opengl: 

105 msg = "OpenGL is " 

106 if not self.client_opengl.boolget("enabled"): 

107 msg += "disabled" 

108 else: 

109 msg += "enabled" 

110 driver_info = self.client_opengl.strget("renderer") or self.client_opengl.strget("vendor") 

111 if driver_info: 

112 msg += " with %s" % driver_info 

113 cinfo.append(msg) 

114 #connection info: 

115 msg = "" 

116 if self.hostname: 

117 msg += "connected from '%s'" % std(self.hostname) 

118 if self.username: 

119 msg += " as '%s'" % std(self.username) 

120 if self.name and self.name!=self.username: 

121 msg += " - '%s'" % std(self.name) 

122 if msg: 

123 cinfo.append(msg) 

124 #proxy info 

125 if self.client_proxy: 

126 msg = "via %s proxy version %s" % ( 

127 platform_name(self.proxy_platform, self.proxy_release), 

128 std(self.proxy_version or "unknown") 

129 ) 

130 if self.proxy_hostname: 

131 msg += " on '%s'" % std(self.proxy_hostname) 

132 cinfo.append(msg) 

133 return cinfo 

134 

135 

136 def get_info(self) -> dict: 

137 info = { 

138 "version" : self.client_version or "unknown", 

139 "revision" : self.client_revision or "unknown", 

140 "platform_name" : platform_name(self.client_platform, self.client_release), 

141 "session-type" : self.client_session_type or "", 

142 "session-type.full" : self.client_session_type_full or "", 

143 "session-id" : self.session_id or "", 

144 "uuid" : self.uuid or "", 

145 "hostname" : self.hostname or "", 

146 "argv" : self.argv or (), 

147 "sharing" : bool(self.sharing), 

148 } 

149 

150 def addattr(k, name): 

151 v = getattr(self, name) 

152 if v is not None: 

153 info[k] = v 

154 for x in ("type", "platform", "release", "machine", "processor", "proxy", "wm_name", "session_type"): 

155 addattr(x, "client_"+x) 

156 return info