[pyatspi2/p2p] Peer-to-peer fixes; may still need work



commit 8cdca57fe872a9f5ef44a867f3e479f651eef498
Author: Mike Gorse <mgorse novell com>
Date:   Mon Aug 30 19:43:41 2010 -0400

    Peer-to-peer fixes; may still need work

 pyatspi/cache.py   |   15 +++++++++++++++
 pyatspi/factory.py |   13 ++++++-------
 2 files changed, 21 insertions(+), 7 deletions(-)
---
diff --git a/pyatspi/cache.py b/pyatspi/cache.py
index b0ce9d1..1715fb8 100644
--- a/pyatspi/cache.py
+++ b/pyatspi/cache.py
@@ -218,6 +218,12 @@ class DesktopCacheManager (object):
                         app = self._application_list[data[0]]
                         app._remove_object(data)
 
+        def getBusAddress(self, bus_name):
+                try:
+                        return self._application_list[bus_name].busAddress
+                except KeyError:
+                        return None
+
 class ApplicationCacheManager (object):
         """
         The application cache manager is responsible for keeping the cache up to date
@@ -238,6 +244,13 @@ class ApplicationCacheManager (object):
                 self._cache = cache
                 self._bus_name = bus_name
 
+                try:
+                        app_obj = bus.get_object (bus_name, ATSPI_ROOT_PATH, introspect=False)
+                        app_itf = dbus.Interface (app_obj, ATSPI_APPLICATION)
+                        self.busAddress = app_itf.GetApplicationBusAddress()
+                except:
+                        self.busAddress = None
+
                 cache_obj = bus.get_object (bus_name, _ATSPI_CACHE_PATH, introspect=False)
                 cache_itf = dbus.Interface (cache_obj, _ATSPI_CACHE_INTERFACE)
                 try:
@@ -328,4 +341,6 @@ class AccessibleCache (dict):
         def __call__ (self, bus_name, object_path):
                 return self[(bus_name, object_path)]
 
+        def getBusAddress(self, bus_name):
+                return self._manager.getBusAddress(bus_name)       
 #END----------------------------------------------------------------------------
diff --git a/pyatspi/factory.py b/pyatspi/factory.py
index e53d153..8181028 100644
--- a/pyatspi/factory.py
+++ b/pyatspi/factory.py
@@ -75,14 +75,13 @@ class AccessibleFactory (object):
 			return None
 
                 if dbus_object == None:
-                        try:
-                                app_obj = bus.get_object (name, ATSPI_ROOT_PATH, introspect=False)
-                                app_itf = dbus.Interface (cache_obj, _ATSPI_APPLICATIONCACHE_INTERFACE)
-                                busAddress = app_itf.GetApplicationBusAddress()
+                        busAddress = self._cache.getBusAddress (name)
+                        if busAddress is not None:
+				busAddress = str(busAddress)
                                 bus = AsyncAccessibilityBus(registry.Registry(), busAddress)
-                                dbus_object = bus.get_object (name, path, introspect=False)
-                        except:
-                                dbus_object = self._connection.get_object (name, path, introspect=False)
+                        else:
+                                bus = self._connection
+                        dbus_object = bus.get_object (name, path, introspect=False)
         
                 return self._interfaces[itf] (self._cache, self, name, path, dbus_object)
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]