1
# Xlib.support.connect -- OS-independent display connection functions
3
# Copyright (C) 2000 Peter Liljenberg <petli@ctrl-c.liu.se>
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
# List the modules which contain the corresponding functions
25
'OpenVMS': 'vms_connect',
28
_default_display_mod = 'unix_connect'
31
'OpenVMS': 'vms_connect'
34
_default_socket_mod = 'unix_connect'
37
'OpenVMS': 'vms_connect'
40
_default_auth_mod = 'unix_connect'
43
# Figure out which OS we're using.
44
# sys.platform is either "OS-ARCH" or just "OS".
46
_parts = string.split(sys.platform, '-')
51
def get_display(display):
52
"""dname, host, dno, screen = get_display(display)
54
Parse DISPLAY into its components. If DISPLAY is None, use
55
the default display. The return values are:
57
DNAME -- the full display name (string)
58
HOST -- the host name (string, possibly empty)
59
DNO -- display number (integer)
60
SCREEN -- default screen number (integer)
63
modname = _display_mods.get(platform, _default_display_mod)
64
mod = __import__(modname, globals())
65
return mod.get_display(display)
68
def get_socket(dname, host, dno):
69
"""socket = get_socket(dname, host, dno)
71
Connect to the display specified by DNAME, HOST and DNO, which
72
are the corresponding values from a previous call to get_display().
74
Return SOCKET, a new socket object connected to the X server.
77
modname = _socket_mods.get(platform, _default_socket_mod)
78
mod = __import__(modname, globals())
79
return mod.get_socket(dname, host, dno)
82
def get_auth(sock, dname, host, dno):
83
"""auth_name, auth_data = get_auth(sock, dname, host, dno)
85
Return authentication data for the display on the other side of
86
SOCK, which was opened with DNAME, HOST and DNO.
88
Return AUTH_NAME and AUTH_DATA, two strings to be used in the
89
connection setup request.
92
modname = _auth_mods.get(platform, _default_auth_mod)
93
mod = __import__(modname, globals())
94
return mod.get_auth(sock, dname, host, dno)