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 accessiblecache import AccessibleCache
16 from desktop import Desktop
17 from factory import accessible_factory
23 "TestApplicationCache",
26 #------------------------------------------------------------------------------
28 class TestApplicationCache(object):
30 Test application store, accesses a single application.
32 The store object acts as a central class for creating accessible objects.
33 It interfaces with the ATSPI registry to keep account of all accessible
34 applications. It contains the accessible cache objects from each application.
36 @registry: Each accessible cache object must have a reference to the registry
37 object to send update events.
39 @connection: D-Bus connection used to access applications.
41 @bus_name: The test store only accesses one accessible application, this is its
45 def __init__(self, registry, connection, bus_name):
46 self._connection = connection
48 self.application_list = [bus_name]
49 self.application_cache = {bus_name:AccessibleCache(registry, connection, bus_name)}
51 def get_cache_data(self, app_name, acc_path):
53 Returns the cache tuple for the given application and accessible
54 object path. Throws an IndexError if the cache data is not found.
56 return self.application_cache[app_name][acc_path]
58 def create_application(self, app_name):
60 Creates an accessible object for the root of the application
61 available at the given D-Bus name.
63 cls = accessible_factory.get_accessible_class(interfaces.ATSPI_APPLICATION)
64 return cls(app_name, self.application_cache[app_name].root, self, interfaces.ATSPI_APPLICATION)
66 def create_accessible(self, app_name, acc_path, interface, dbus_object=None):
68 Creates an accessible object.
70 @app_name: D-Bus name of the application where the accessible object resides.
72 @acc_path: D-Bus path of the object within the application.
74 @interface: D-Bus interface of the requested object. A different accessible object
75 class will be created depending on this. Making the function much like
76 an accessible object factory.
78 @dbus_object: If a D-Bus object already exists for the accessible object it can be
79 provided here so that another one is not created.
81 # An acc_path of '/' implies the desktop object, whatever the app_name.
85 cls = accessible_factory.get_accessible_class(interface)
86 return cls(app_name, acc_path, self, interface, dbus_object=dbus_object)
91 D-Bus connection used by the store.
93 return self._connection
95 #END----------------------------------------------------------------------------