1 #Copyright (C) 2008 Codethink Ltd
3 #This library is free software; you can redistribute it and/or
4 #modify it under the terms of the GNU Lesser General Public
5 #License version 2 as published by the Free Software Foundation.
7 #This program is distributed in the hope that it will be useful,
8 #but WITHOUT ANY WARRANTY; without even the implied warranty of
9 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 #GNU General Public License for more details.
11 #You should have received a copy of the GNU Lesser General Public License
12 #along with this program; if not, write to the Free Software
13 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 from interfaces import *
17 from accessible import Accessible
18 from factory import accessible_factory
24 #------------------------------------------------------------------------------
26 class LoginHelper(Accessible):
28 An interface for use by assistive technologies by which they
29 can access system information and services on a 'need to know'
30 basis while the screen is locked, during user authentication,
31 or during other sensitive operations.
32 This interface is intended for use by assistive technologies
33 and related user-enabling services, and by applications and utilities
34 which may wish to restrict access to certain system devices and
35 services during security-sensitive states, e.g. when the screen
36 is locked or during authentication into some secure service.
37 Such 'applications' (for instance, screen lock dialogs and security-enabled
38 web browsers) use the LoginHelper client interfaces, and the
39 bonobo-activation query service, to query for assistive technologies
40 which advertise the LoginHelper service. The client then queries
41 these assistive technologies for their device I/O requirements,
42 via the getDeviceReqs call. The client may then issue the advisory
43 request setSafe (TRUE), which requests that the LoginHelper -implementing
44 service make a best-effort attempt to make itself more secure
45 (for instance, an onscreen keyboard might turn off word prediction,
46 and a screenreader may turn off keyboard echo via speech). The
47 return value of setSafe is an advisory indication of whether
48 this attempt was successful (no specific guarantees are implied).
49 Once the 'security sensitive' state is exited, the client should
51 The return values from getDeviceReqs inform the client of which
52 services the LoginHelper service (e. g. assistive technology)
53 needs in order to do its job. The client may use this information
54 to loosen any restrictions on access which it may currently have
55 in place (for instance, keyboard grabs, etc.). If it does not
56 do so, the likely outcome is that the end-user will experience
57 loss of access to the system.
60 def getDeviceReqs(self, *args, **kwargs):
63 Query a LoginHelper for the types of device I/O it requires,
64 in order to do its job. For instance, a LoginHelper which needs
65 to receive keyboard events will include Accessibility_LoginHelper_CORE_KEYBOARD
67 @return : A sequence of LoginHelper_DeviceReq indicating the
68 device I/O required in order to facilitate end-user access to
71 func = self.get_dbus_method("getDeviceReqs", dbus_interface=ATSPI_LOGIN_HELPER)
72 return func(*args, **kwargs)
74 def getRaiseWindows(self, *args, **kwargs):
77 Get a list of window IDs that need raising on login.
78 @return : a sequence containing window IDS for toplevels which
79 need to be raised/made visible during user authentication, in
80 order for the LoginHelper to facilitate end-user access to the
83 func = self.get_dbus_method("getRaiseWindows", dbus_interface=ATSPI_LOGIN_HELPER)
84 return func(*args, **kwargs)
86 def setSafe(self, *args, **kwargs):
90 TRUE if the client is requesting that 'safe mode' be initiated,
91 FALSE if the client is advising that 'safe mode' may be exited,
92 i.e. normal operation may be resumed.
93 Request a LoginHelper to enter "safe" mode, or inform LoginHelper
94 that "safe" mode may be exited. If safe_mode is TRUE, but the
95 return value is FALSE, the requesting client may wish to deny
96 services to the LoginHelper, for instance avoid raising its toplevels.
97 The return value is purely advisory, and no guarantees are intended
98 about what the implementing LoginHelper will do to improve security
100 @return : whether the LoginHelper is now "safe" or not.
102 func = self.get_dbus_method("setSafe", dbus_interface=ATSPI_LOGIN_HELPER)
103 return func(*args, **kwargs)
105 class DeviceReq(Enum):
120 AUDIO_IN = DeviceReq(6)
121 AUDIO_OUT = DeviceReq(5)
122 CORE_KEYBOARD = DeviceReq(1)
123 CORE_POINTER = DeviceReq(2)
124 EXT_INPUT = DeviceReq(3)
125 GUI_EVENTS = DeviceReq(0)
126 LOCALHOST = DeviceReq(8)
127 NETWORK = DeviceReq(7)
128 POST_WINDOWS = DeviceReq(4)
129 SERIAL_IN = DeviceReq(10)
130 SERIAL_OUT = DeviceReq(9)
132 class WindowInfo(list):
133 def __new__(cls, winID):
134 list.__new__(cls, (winID))
135 def __init__(self, winID):
136 list.__init__(self, (winID))
138 def _get_winID(self):
140 def _set_winID(self, val):
142 winID = property(fget=_get_winID, fset=_set_winID)
144 # Register the accessible class with the factory.
145 accessible_factory.register_accessible_class(ATSPI_LOGIN_HELPER, LoginHelper)
147 #END----------------------------------------------------------------------------