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