1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 """\
21 Default variables and values for Python X2Go.
22
23 """
24 __NAME__ = 'x2godefaults-pylib'
25
26 import os
27 import paramiko
28 import platform
29
30
31
32
33
34 X2GOCLIENT_OS = platform.system()
35
36 if X2GOCLIENT_OS != 'Windows':
37 import Xlib.display
38 import Xlib.error
39
40
41 try:
42 X_DISPLAY = Xlib.display.Display()
43 except Xlib.error.DisplayNameError:
44 X_DISPLAY = None
45 except Xlib.error.DisplayConnectionError:
46 X_DISPLAY = None
47
48 LOCAL_HOME = os.path.normpath(os.path.expanduser('~'))
49 X2GO_SESSIONS_ROOTDIR = '.x2go'
50 X2GO_CLIENT_ROOTDIR = '.x2goclient'
51 X2GO_SSH_ROOTDIR = os.path.join('.x2go','.ssh')
52
53
54 if X2GOCLIENT_OS == "Windows":
55
56
57 ROOT_DIR = os.path.abspath(os.path.curdir)
58 ETC_DIR = os.path.join(ROOT_DIR, 'etc')
59 import win32api
60 CURRENT_LOCAL_USER = win32api.GetUserName()
61 X2GO_SSH_ROOTDIR = '.ssh'
62 SUPPORTED_SOUND = True
63 SUPPORTED_PRINTING = True
64 SUPPORTED_FOLDERSHARING = True
65 SUPPORTED_MIMEBOX = True
66 SUPPORTED_TELEKINESIS = False
67
68 elif X2GOCLIENT_OS == "Linux":
69 ROOT_DIR = '/'
70 ETC_DIR = os.path.join(ROOT_DIR, 'etc', 'x2goclient')
71 import getpass
72 CURRENT_LOCAL_USER = getpass.getuser()
73 X2GO_SSH_ROOTDIR = '.ssh'
74 SUPPORTED_SOUND = True
75 SUPPORTED_PRINTING = True
76 SUPPORTED_FOLDERSHARING = True
77 SUPPORTED_MIMEBOX = True
78 SUPPORTED_TELEKINESIS = True
79
80 elif X2GOCLIENT_OS == "Mac":
81 ROOT_DIR = '/'
82 ETC_DIR = os.path.join(ROOT_DIR, 'etc', 'x2goclient')
83 import getpass
84 CURRENT_LOCAL_USER = getpass.getuser()
85 X2GO_SSH_ROOTDIR = '.ssh'
86 SUPPORTED_SOUND = True
87 SUPPORTED_PRINTING = True
88 SUPPORTED_FOLDERSHARING = True
89 SUPPORTED_MIMEBOX = True
90 SUPPORTED_TELEKINESIS = False
91
92 else:
93 import exceptions
95 raise OSNotSupportedException('Platform %s is not supported' % platform.system())
96
97
98
99
100
101 BACKENDS = {
102 'X2GoControlSession': {
103 'default': 'PLAIN',
104 'PLAIN': 'x2go.backends.control.plain',
105 },
106 'X2GoTerminalSession': {
107 'default': 'PLAIN',
108 'PLAIN': 'x2go.backends.terminal.plain',
109 },
110 'X2GoServerSessionInfo': {
111 'default': 'PLAIN',
112 'PLAIN': 'x2go.backends.info.plain',
113 },
114 'X2GoServerSessionList': {
115 'default': 'PLAIN',
116 'PLAIN': 'x2go.backends.info.plain',
117 },
118 'X2GoProxy': {
119 'default': 'NX3',
120 'NX3': 'x2go.backends.proxy.nx3',
121 },
122 'X2GoSessionProfiles': {
123 'default': 'FILE',
124 'FILE': 'x2go.backends.profiles.file',
125 'GCONF': 'x2go.backends.profiles.gconf',
126 'HTTPBROKER': 'x2go.backends.profiles.httpbroker',
127 'SSHBROKER': 'x2go.backends.profiles.sshbroker',
128 'WINREG': 'x2go.backends.profiles.winreg',
129 },
130 'X2GoClientSettings': {
131 'default': 'FILE',
132 'FILE': 'x2go.backends.settings.file',
133 'GCONF': 'x2go.backends.settings.gconf',
134 'WINREG': 'x2go.backends.settings.winreg',
135 },
136 'X2GoClientPrinting': {
137 'default': 'FILE',
138 'FILE': 'x2go.backends.printing.file',
139 'GCONF': 'x2go.backends.printing.gconf',
140 'WINREG': 'x2go.backends.printing.winreg',
141 }
142 }
143
144
145
146
147
148 X2GO_SETTINGS_FILENAME = 'settings'
149 X2GO_SETTINGS_CONFIGFILES = [
150 os.path.normpath(os.path.join(LOCAL_HOME, X2GO_CLIENT_ROOTDIR, 'settings')),
151 os.path.normpath(os.path.join(ETC_DIR,X2GO_SETTINGS_FILENAME)),
152 ]
153 X2GO_PRINTING_FILENAME = 'printing'
154 X2GO_PRINTING_CONFIGFILES = [
155 os.path.normpath(os.path.join(LOCAL_HOME, X2GO_CLIENT_ROOTDIR, 'printing')),
156 os.path.normpath(os.path.join(ETC_DIR,X2GO_PRINTING_FILENAME)),
157 ]
158 X2GO_SESSIONPROFILES_FILENAME = 'sessions'
159 X2GO_SESSIONPROFILES_CONFIGFILES = [
160 os.path.normpath(os.path.join(LOCAL_HOME, X2GO_CLIENT_ROOTDIR, 'sessions')),
161 os.path.normpath(os.path.join(ETC_DIR,X2GO_SESSIONPROFILES_FILENAME)),
162 ]
163 X2GO_XCONFIG_FILENAME = 'xconfig'
164 X2GO_XCONFIG_CONFIGFILES = [
165 os.path.normpath(os.path.join(LOCAL_HOME, X2GO_CLIENT_ROOTDIR, 'xconfig')),
166 os.path.normpath(os.path.join(ETC_DIR,X2GO_XCONFIG_FILENAME)),
167 ]
168
169 X2GO_CLIENTSETTINGS_DEFAULTS = {
170 'LDAP': {
171 'useldap': False,
172 'port': 389,
173 'server': 'localhost',
174 'port1': 0,
175 'port2': 0,
176 },
177 'General': {
178
179 'clientport': 22,
180 'autoresume': True,
181 },
182 'Authorization': {
183 'newprofile': True,
184 'suspend': True,
185 'editprofile': True,
186 'resume': True
187 },
188 'trayicon': {
189 'enabled': True,
190 'mintotray': True,
191 'noclose': True,
192 'mincon': True,
193 'maxdiscon': True,
194 },
195 }
196 X2GO_CLIENTPRINTING_DEFAULTS = {
197 'General': {
198
199 'showdialog': False,
200
201 'pdfview': True,
202 },
203 'print': {
204
205 'startcmd': False,
206
207 'command': 'lpr',
208
209 'stdin': False,
210
211 'ps': False,
212 },
213 'save': {
214
215 'folder': 'PDF',
216 },
217 'view': {
218
219
220
221 'open': True,
222
223 'command': 'xdg-open',
224 },
225 'CUPS': {
226
227
228 'defaultprinter': 'PDF',
229 },
230 }
231 if X2GOCLIENT_OS == 'Windows':
232 X2GO_CLIENTPRINTING_DEFAULTS['print'].update({'gsprint': os.path.join(os.environ['ProgramFiles'], 'GhostGum', 'gsview', 'gsprint.exe'), })
233
234
235 if X2GOCLIENT_OS == 'Windows':
236 X2GO_CLIENTXCONFIG_DEFAULTS = {
237 'XServers': {
238 'known_xservers': ['VcXsrv_development', 'VcXsrv_shipped', 'VcXsrv', 'Xming', 'Cygwin-X', ],
239 },
240 'Cygwin-X': {
241 'display': 'localhost:40',
242 'last_display': 'localhost:40',
243 'process_name': 'XWin.exe',
244 'test_installed': os.path.join(os.environ['SystemDrive'], '\\', 'cygwin', 'bin', 'XWin.exe'),
245 'run_command': os.path.join(os.environ['SystemDrive'], '\\', 'cygwin', 'bin', 'XWin.exe'),
246 'parameters': [':40', '-clipboard', '-multiwindow', '-notrayicon', '-nowinkill', '-nounixkill', '-swcursor', ],
247 },
248 'VcXsrv': {
249 'display': 'localhost:40',
250 'last_display': 'localhost:40',
251 'process_name': 'vcxsrv.exe',
252 'test_installed': os.path.join(os.environ['ProgramFiles'], 'VcXsrv', 'vcxsrv.exe'),
253 'run_command': os.path.join(os.environ['ProgramFiles'], 'VcXsrv', 'vcxsrv.exe'),
254 'parameters': [':40', '-clipboard', '-multiwindow', '-notrayicon', '-nowinkill', '-nounixkill', '-swcursor', ],
255 },
256 'VcXsrv_shipped': {
257 'display': 'localhost:40',
258 'last_display': 'localhost:40',
259 'process_name': 'vcxsrv.exe',
260 'test_installed': os.path.join(os.getcwd(), 'VcXsrv', 'vcxsrv.exe'),
261 'run_command': os.path.join(os.getcwd(), 'VcXsrv', 'vcxsrv.exe'),
262 'parameters': [':40', '-clipboard', '-multiwindow', '-notrayicon', '-nowinkill', '-nounixkill', '-swcursor', ],
263 },
264 'VcXsrv_development': {
265 'display': 'localhost:40',
266 'last_display': 'localhost:40',
267 'process_name': 'vcxsrv.exe',
268 'test_installed': os.path.join(os.getcwd(), '..', 'pyhoca-contrib', 'mswin', 'vcxsrv-mswin', 'VcXsrv-1.15.2.1-xp+vc2013+x2go1', 'vcxsrv.exe'),
269 'run_command': os.path.join(os.getcwd(), '..', 'pyhoca-contrib', 'mswin', 'vcxsrv-mswin', 'VcXsrv-1.15.2.1-xp+vc2013+x2go1', 'vcxsrv.exe'),
270 'parameters': [':40', '-clipboard', '-multiwindow', '-notrayicon', '-nowinkill', '-nounixkill', '-swcursor', ],
271 },
272 'Xming': {
273 'display': 'localhost:40',
274 'last_display': 'localhost:40',
275 'process_name': 'Xming.exe',
276 'test_installed': os.path.join(os.environ['ProgramFiles'], 'Xming', 'Xming.exe'),
277 'run_command': os.path.join(os.environ['ProgramFiles'], 'Xming', 'Xming.exe'),
278 'parameters': [':40', '-clipboard', '-multiwindow', '-notrayicon', '-nowinkill', '-nounixkill', '-swcursor', ],
279 },
280 }
281 else:
282
283 X2GO_CLIENTXCONFIG_DEFAULTS = {}
284
285 X2GO_GENERIC_APPLICATIONS = [ 'WWWBROWSER', 'MAILCLIENT', 'OFFICE', 'TERMINAL', ]
286 """X2Go's generic applications."""
287
288 X2GO_SESSIONPROFILE_DEFAULTS = {
289 'autologin': True, 'autoconnect': False, 'autostart': False, 'setsessiontitle': False, 'sessiontitle': "",
290 'speed': 2, 'pack': '16m-jpeg', 'quality': 9,
291 'iconvto': 'UTF-8', 'iconvfrom': 'UTF-8', 'useiconv': False,
292 'usesshproxy': False, 'sshproxyhost': 'proxyhost.mydomain', 'sshproxyport': 22, 'sshproxyuser': '', 'sshproxykeyfile': '',
293 'sshproxytype': 'SSH', 'sshproxysameuser': False, 'sshproxysamepass': False, 'sshproxyautologin': True,
294 'uniquehostkeyaliases': False,
295 'useexports': True, 'restoreexports': False, 'fstunnel': True, 'export': {},
296 'usemimebox': False, 'mimeboxextensions': '', 'mimeboxaction': 'OPEN',
297 'fullscreen': False, 'clipboard': 'both',
298 'width': 800,'height': 600, 'maxdim': False, 'dpi': 96, 'setdpi': False, 'xinerama': False, 'multidisp': False, 'display': 1,
299 'usekbd': True, 'layout': 'us', 'type': 'pc105/us', 'variant': '',
300 'sound': False, 'soundsystem': 'pulse', 'startsoundsystem': False, 'soundtunnel':True, 'defsndport':True, 'sndport':4713,
301 'name': 'NEW_PROFILE', 'icon': ':icons/128x128/x2gosession.png',
302 'host': ['server.mydomain'], 'user': CURRENT_LOCAL_USER, 'key': '', 'sshport': 22, 'krblogin': False, 'forwardsshagent': False,
303 'rootless': True, 'applications': X2GO_GENERIC_APPLICATIONS, 'command':'TERMINAL', 'published': False,
304 'directrdp': False, 'directrdpsettings': '', 'rdpclient': 'rdesktop', 'rdpport': 3389,
305 'rdpoptions': '-u X2GO_USER -p X2GO_PASSWORD', 'rdpserver': '',
306 'print': False,
307 'xdmcpserver': 'localhost',
308 }
309 """L{X2GoSessionProfiles} default values to fill a new session profile with."""
310
311
312
313
314
315
316
317 pack_methods_nx3_noqual = ['nopack','8','64','256','512','4k','32k','64k','256k','2m','16m',
318 '256-rdp','256-rdp-compressed','32k-rdp','32k-rdp-compressed','64k-rdp',
319 '64k-rdp-compressed','16m-rdp','16m-rdp-compressed',
320 'rfb-hextile','rfb-tight','rfb-tight-compressed',
321 '8-tight','64-tight','256-tight','512-tight','4k-tight','32k-tight',
322 '64k-tight','256k-tight','2m-tight','16m-tight',
323 '8-jpeg-%','64-jpeg','256-jpeg','512-jpeg','4k-jpeg','32k-jpeg',
324 '64k-jpeg','256k-jpeg','2m-jpeg','16m-jpeg-%',
325 '8-png-jpeg-%','64-png-jpeg','256-png-jpeg','512-png-jpeg','4k-png-jpeg',
326 '32k-png-jpeg','64k-png-jpeg','256k-png-jpeg','2m-png-jpeg','16m-png-jpeg-%',
327 '8-png-%','64-png','256-png','512-png','4k-png',
328 '32k-png','64k-png','256k-png','2m-png','16m-png-%',
329 '16m-rgb-%','16m-rle-%',]
330 """Available NX3 compression methods."""
331
332
333 pack_methods_nx3_formatted="""
334 \'%s\'
335 \'%s\'
336 \'%s\'
337 \'%s\'
338 \'%s\'
339 \'%s\'
340 \'%s\'
341 \'%s\'
342 \'%s\'
343 \'%s\'
344 \'%s\'
345 \'%s\'
346 \'%s\'
347 """ % ('\', \''.join(pack_methods_nx3_noqual[0:11]), \
348 '\', \''.join(pack_methods_nx3_noqual[11:16]), \
349 '\', \''.join(pack_methods_nx3_noqual[16:19]), \
350 '\', \''.join(pack_methods_nx3_noqual[19:22]), \
351 '\', \''.join(pack_methods_nx3_noqual[22:28]), \
352 '\', \''.join(pack_methods_nx3_noqual[28:32]), \
353 '\', \''.join(pack_methods_nx3_noqual[32:38]), \
354 '\', \''.join(pack_methods_nx3_noqual[38:42]), \
355 '\', \''.join(pack_methods_nx3_noqual[42:47]), \
356 '\', \''.join(pack_methods_nx3_noqual[47:52]), \
357 '\', \''.join(pack_methods_nx3_noqual[52:57]), \
358 '\', \''.join(pack_methods_nx3_noqual[57:62]), \
359 '\', \''.join(pack_methods_nx3_noqual[62:]))
360
361
362
363 pack_methods_nx3 = [ m for m in pack_methods_nx3_noqual if "%" not in m ]
364 for meth in [ m for m in pack_methods_nx3_noqual if "%" in m ]:
365 pack_methods_nx3 += [ meth.replace('%','%s' % str(i)) for i in range(0,10) ]
366 pack_methods_nx3.sort()
367
368
369
370
371 X2GO_DESKTOPSESSIONS={
372 'CINNAMON': 'cinnamon',
373 'KDE': 'startkde',
374 'GNOME': 'gnome-session',
375 'MATE': 'mate-session',
376 'XFCE': 'xfce4-session',
377 'LXDE': 'startlxde',
378 'TRINITY': 'starttrinity',
379 'UNITY': 'unity',
380 }
381 """A dictionary with meta-commands for X2Go's window manager sessions."""
382
383
384
385
386
387 RSAKEY_STRENGTH = 1024
388 RSAHostKey = paramiko.RSAKey.generate(RSAKEY_STRENGTH)
389 """\
390 An RSA host key for this client session. Python X2Go does not use the
391 system's host key but generates its own host key for each running
392 application instance.
393
394 """
395
396 X2GO_PRINT_ACTIONS = {
397 'PDFVIEW': 'X2GoPrintActionPDFVIEW',
398 'PDFSAVE': 'X2GoPrintActionPDFSAVE',
399 'PRINT': 'X2GoPrintActionPRINT',
400 'PRINTCMD': 'X2GoPrintActionPRINTCMD',
401 'DIALOG': 'X2GoPrintActionDIALOG',
402 }
403 """Relating print action names and classes."""
404
405 DEFAULT_PDFVIEW_CMD = 'xdg-open'
406 """Default PDF viewer command for Linux systems (PDFVIEW print action)."""
407 DEFAULT_PDFSAVE_LOCATION = 'PDF'
408 """Default location for saving PDF files (PDFSAVE print action)."""
409 DEFAULT_PRINTCMD_CMD = 'lpr'
410 """Default command for the PRINTCMD print action."""
411
412 X2GO_MIMEBOX_ACTIONS = {
413 'OPEN': 'X2GoMIMEboxActionOPEN',
414 'OPENWITH': 'X2GoMIMEboxActionOPENWITH',
415 'SAVEAS': 'X2GoMIMEboxActionSAVEAS',
416 }
417 """Relating MIME box action names and classes."""
418
419 X2GO_MIMEBOX_EXTENSIONS_BLACKLIST = [
420 'LOCK', 'SYS', 'SWP',
421 'EXE', 'COM', 'CMD', 'PS1', 'PS2', 'BAT',
422 'JS', 'PY', 'PL', 'SH',
423 ]
424 """Black-listed MIME box file extenstions."""
425
426
427 X2GO_SHARE_VIEWONLY=0
428 """Constant representing read-only access to shared desktops."""
429 X2GO_SHARE_FULLACCESS=1
430 """Constant representing read-write (full) access to shared desktops."""
431
432 PUBAPP_MAX_NO_SUBMENUS=10
433 """Less than ten applications will not get rendered into submenus."""
434