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': 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': '', 'sshproxyuser': '', 'sshproxytunnel': '', 'sshproxykeyfile': '',
299 'useexports': True, 'fstunnel': True, 'export': '',
300 'usemimebox': False, 'mimeboxextensions': '', 'mimeboxaction': 'OPEN',
301 'fullscreen': False,
302 'width': 800,'height': 600,'dpi': 96,'setdpi': False, 'xinerama': False, 'multidisp': False,
303 'usekbd': True, 'layout': 'us', 'type': 'pc105/us', 'variant': '',
304 'sound': False, 'soundsystem': 'pulse', 'startsoundsystem': False, 'soundtunnel':True, 'defsndport':True, 'sndport':4713,
305 'name': 'NEW_PROFILE', 'icon': ':icons/128x128/x2gosession.png',
306 'host': '', 'user': CURRENT_LOCAL_USER, 'key': '', 'sshport': 22, 'krblogin': False,
307 'rootless': True, 'applications': X2GO_GENERIC_APPLICATIONS, 'command':'TERMINAL', 'published': False,
308 'rdpoptions': '-u X2GO_USER -p X2GO_PASSWORD', 'rdpserver': '',
309 'print': False,
310 'xdmcpserver': 'localhost',
311 }
312 """L{X2goSessionProfiles} default values to fill a new session profile with."""
313
314
315
316
317
318
319
320 pack_methods_nx3_noqual = ['nopack','8','64','256','512','4k','32k','64k','256k','2m','16m',
321 '256-rdp','256-rdp-compressed','32k-rdp','32k-rdp-compressed','64k-rdp',
322 '64k-rdp-compressed','16m-rdp','16m-rdp-compressed',
323 'rfb-hextile','rfb-tight','rfb-tight-compressed',
324 '8-tight','64-tight','256-tight','512-tight','4k-tight','32k-tight',
325 '64k-tight','256k-tight','2m-tight','16m-tight',
326 '8-jpeg-%','64-jpeg','256-jpeg','512-jpeg','4k-jpeg','32k-jpeg',
327 '64k-jpeg','256k-jpeg','2m-jpeg','16m-jpeg-%',
328 '8-png-jpeg-%','64-png-jpeg','256-png-jpeg','512-png-jpeg','4k-png-jpeg',
329 '32k-png-jpeg','64k-png-jpeg','256k-png-jpeg','2m-png-jpeg','16m-png-jpeg-%',
330 '8-png-%','64-png','256-png','512-png','4k-png',
331 '32k-png','64k-png','256k-png','2m-png','16m-png-%',
332 '16m-rgb-%','16m-rle-%',]
333 """Available NX3 compression methods."""
334
335
336 pack_methods_nx3_formatted="""
337 \'%s\'
338 \'%s\'
339 \'%s\'
340 \'%s\'
341 \'%s\'
342 \'%s\'
343 \'%s\'
344 \'%s\'
345 \'%s\'
346 \'%s\'
347 \'%s\'
348 \'%s\'
349 \'%s\'
350 """ % ('\', \''.join(pack_methods_nx3_noqual[0:11]), \
351 '\', \''.join(pack_methods_nx3_noqual[11:16]), \
352 '\', \''.join(pack_methods_nx3_noqual[16:19]), \
353 '\', \''.join(pack_methods_nx3_noqual[19:22]), \
354 '\', \''.join(pack_methods_nx3_noqual[22:28]), \
355 '\', \''.join(pack_methods_nx3_noqual[28:32]), \
356 '\', \''.join(pack_methods_nx3_noqual[32:38]), \
357 '\', \''.join(pack_methods_nx3_noqual[38:42]), \
358 '\', \''.join(pack_methods_nx3_noqual[42:47]), \
359 '\', \''.join(pack_methods_nx3_noqual[47:52]), \
360 '\', \''.join(pack_methods_nx3_noqual[52:57]), \
361 '\', \''.join(pack_methods_nx3_noqual[57:62]), \
362 '\', \''.join(pack_methods_nx3_noqual[62:]))
363
364
365
366 pack_methods_nx3 = [ m for m in pack_methods_nx3_noqual if "%" not in m ]
367 for meth in [ m for m in pack_methods_nx3_noqual if "%" in m ]:
368 pack_methods_nx3 += [ meth.replace('%','%s' % str(i)) for i in range(0,10) ]
369 pack_methods_nx3.sort()
370
371
372
373
374 X2GO_DESKTOPSESSIONS={
375 'KDE': 'startkde',
376 'GNOME': 'gnome-session',
377 'XFCE4': 'xfce4-session',
378 'LXDE': 'startlxde',
379 'TRINITY': 'starttrinity',
380 'UNITY': 'unity',
381 }
382 """A dictionary with meta-commands for X2go's window manager sessions."""
383
384
385
386
387
388 RSAKEY_STRENGTH = 1024
389 RSAHostKey = paramiko.RSAKey.generate(RSAKEY_STRENGTH)
390 """\
391 An RSA host key for this client session. Python X2Go does not use the
392 system's host key but generates its own host key for each running
393 application instance.
394
395 """
396
397 X2GO_PRINT_ACTIONS = {
398 'PDFVIEW': 'X2goPrintActionPDFVIEW',
399 'PDFSAVE': 'X2goPrintActionPDFSAVE',
400 'PRINT': 'X2goPrintActionPRINT',
401 'PRINTCMD': 'X2goPrintActionPRINTCMD',
402 'DIALOG': 'X2goPrintActionDIALOG',
403 }
404 """Relating print action names and classes."""
405
406 DEFAULT_PDFVIEW_CMD = 'xdg-open'
407 """Default PDF viewer command for Linux systems (PDFVIEW print action)."""
408 DEFAULT_PDFSAVE_LOCATION = 'PDF'
409 """Default location for saving PDF files (PDFSAVE print action)."""
410 DEFAULT_PRINTCMD_CMD = 'lpr'
411 """Default command for the PRINTCMD print action."""
412
413 X2GO_MIMEBOX_ACTIONS = {
414 'OPEN': 'X2goMIMEboxActionOPEN',
415 'OPENWITH': 'X2goMIMEboxActionOPENWITH',
416 'SAVEAS': 'X2goMIMEboxActionSAVEAS',
417 }
418 """Relating MIME box action names and classes."""
419
420 X2GO_MIMEBOX_EXTENSIONS_BLACKLIST = [
421 'LOCK', 'SYS', 'SWP',
422 'EXE', 'COM', 'CMD', 'PS1', 'PS2', 'BAT',
423 'JS', 'PY', 'PL', 'SH',
424 ]
425 """Black-listed MIME box file extenstions."""
426
427
428 X2GO_SHARE_VIEWONLY=0
429 """Constant representing read-only access to shared desktops."""
430 X2GO_SHARE_FULLACCESS=1
431 """Constant representing read-write (full) access to shared desktops."""
432
433 PUBAPP_MAX_NO_SUBMENUS=10
434 """Less than ten applications will not get rendered into submenus."""
435