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.
16 from base import BaseProxy, Enum
17 from factory import accessible_factory
23 #------------------------------------------------------------------------------
25 class LoginHelper(BaseProxy):
27 An interface for use by assistive technologies by which they
28 can access system information and services on a 'need to know'
29 basis while the screen is locked, during user authentication,
30 or during other sensitive operations.
31 This interface is intended for use by assistive technologies
32 and related user-enabling services, and by applications and utilities
33 which may wish to restrict access to certain system devices and
34 services during security-sensitive states, e.g. when the screen
35 is locked or during authentication into some secure service.
36 Such 'applications' (for instance, screen lock dialogs and security-enabled
37 web browsers) use the LoginHelper client interfaces, and the
38 bonobo-activation query service, to query for assistive technologies
39 which advertise the LoginHelper service. The client then queries
40 these assistive technologies for their device I/O requirements,
41 via the getDeviceReqs call. The client may then issue the advisory
42 request setSafe (TRUE), which requests that the LoginHelper -implementing
43 service make a best-effort attempt to make itself more secure
44 (for instance, an onscreen keyboard might turn off word prediction,
45 and a screenreader may turn off keyboard echo via speech). The
46 return value of setSafe is an advisory indication of whether
47 this attempt was successful (no specific guarantees are implied).
48 Once the 'security sensitive' state is exited, the client should
50 The return values from getDeviceReqs inform the client of which
51 services the LoginHelper service (e. g. assistive technology)
52 needs in order to do its job. The client may use this information
53 to loosen any restrictions on access which it may currently have
54 in place (for instance, keyboard grabs, etc.). If it does not
55 do so, the likely outcome is that the end-user will experience
56 loss of access to the system.
59 def getDeviceReqs(self, *args, **kwargs):
62 Query a LoginHelper for the types of device I/O it requires,
63 in order to do its job. For instance, a LoginHelper which needs
64 to receive keyboard events will include Accessibility_LoginHelper_CORE_KEYBOARD
66 @return : A sequence of LoginHelper_DeviceReq indicating the
67 device I/O required in order to facilitate end-user access to
70 func = self.get_dbus_method("getDeviceReqs")
71 return func(*args, **kwargs)
73 def getRaiseWindows(self, *args, **kwargs):
76 Get a list of window IDs that need raising on login.
77 @return : a sequence containing window IDS for toplevels which
78 need to be raised/made visible during user authentication, in
79 order for the LoginHelper to facilitate end-user access to the
82 func = self.get_dbus_method("getRaiseWindows")
83 return func(*args, **kwargs)
85 def setSafe(self, *args, **kwargs):
89 TRUE if the client is requesting that 'safe mode' be initiated,
90 FALSE if the client is advising that 'safe mode' may be exited,
91 i.e. normal operation may be resumed.
92 Request a LoginHelper to enter "safe" mode, or inform LoginHelper
93 that "safe" mode may be exited. If safe_mode is TRUE, but the
94 return value is FALSE, the requesting client may wish to deny
95 services to the LoginHelper, for instance avoid raising its toplevels.
96 The return value is purely advisory, and no guarantees are intended
97 about what the implementing LoginHelper will do to improve security
99 @return : whether the LoginHelper is now "safe" or not.
101 func = self.get_dbus_method("setSafe")
102 return func(*args, **kwargs)
104 class DeviceReq(Enum):
119 AUDIO_IN = DeviceReq(6)
120 AUDIO_OUT = DeviceReq(5)
121 CORE_KEYBOARD = DeviceReq(1)
122 CORE_POINTER = DeviceReq(2)
123 EXT_INPUT = DeviceReq(3)
124 GUI_EVENTS = DeviceReq(0)
125 LOCALHOST = DeviceReq(8)
126 NETWORK = DeviceReq(7)
127 POST_WINDOWS = DeviceReq(4)
128 SERIAL_IN = DeviceReq(10)
129 SERIAL_OUT = DeviceReq(9)
131 class WindowInfo(list):
132 def __new__(cls, winID):
133 list.__new__(cls, (winID))
134 def __init__(self, winID):
135 list.__init__(self, (winID))
137 def _get_winID(self):
139 def _set_winID(self, val):
141 winID = property(fget=_get_winID, fset=_set_winID)
143 # Register the accessible class with the factory.
144 accessible_factory.register_accessible_class(interfaces.ATSPI_LOGIN_HELPER, LoginHelper)
146 #END----------------------------------------------------------------------------