<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -88,6 +88,7 @@ class testsuite_dist(partial_dist):
                                   'viewdiff/api-compare.js', 
                                   'viewdiff/api-compare.xsl'])],
         packages=['tests', 'treediff'],
+        py_modules=['speclenium_client'],
         scripts=['run_tests.py', 'quick_diff.py'])
 
 try:
@@ -171,6 +172,7 @@ setup(name=__doc__.split('\n')[0],
       classifiers=classifiers,
       version=specular.__version__,
       packages=[&quot;specular&quot;, &quot;speclenium&quot;, &quot;tests&quot;],
+      py_modules=[&quot;speclenium_client&quot;],
       scripts=[&quot;speclenium.py&quot;, &quot;run_tests.py&quot;], 
       data_files=[('', ['LICENSE', 
                         'README', </diff>
      <filename>setup.py</filename>
    </modified>
    <modified>
      <diff>@@ -30,7 +30,7 @@
 # the provisions above, a recipient may use your version of this file under
 # the terms of any one of the MPL, the GPL or the LGPL.
 
-__version__   = &quot;0.0.1&quot;
+__version__   = &quot;0.0.3&quot;
 __copyright__ = &quot;Copyright (c) 2008 Eitan Isaacson&quot;
 __license__   = &quot;MPL 1.1/GPL 2.0/LGPL 2.1&quot;
 </diff>
      <filename>speclenium/__init__.py</filename>
    </modified>
    <modified>
      <diff>@@ -35,7 +35,7 @@ from xml.dom.minidom import parseString
 from specular.specular_accessible import \
     specular_accessible_from_accessible, specular_accessible_from_string
 from specular.specular_event import \
-    specular_event_from_event, specular_event_from_string
+    specular_event_from_event, specular_event_from_string, events_map
 
 class SpecleniumBase(xmlrpc.XMLRPC):
     AGENTS = ['Mozilla', 'Internet Explorer', 'Webkit', 'Opera', 'Unknown']
@@ -71,6 +71,10 @@ class SpecleniumBase(xmlrpc.XMLRPC):
         
     def xmlrpc_get_accessible_event_match(self, event, start_at):
         spec_event = specular_event_from_string(event)
+        if events_map[spec_event.type] == 'not supported on platform':
+            spec_event.documentElement.setAttribute(
+                'supportedOnPlatform', 'false')
+            return spec_event.toxml()
 
         i = start_at
         if start_at != 0:</diff>
      <filename>speclenium/speclenium_base.py</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,8 @@
 from selenium import selenium
 from xmlrpclib import ServerProxy
+import time
+from xml.dom.minidom import parseString
+
 class SpecleniumClient(selenium):
     SPECLENIUM_PORT = 4117
     def start(self):
@@ -22,3 +25,19 @@ class SpecleniumClient(selenium):
         return self._speclenium_server.get_accessible_event_match(
             match_criteria, index)
 
+    def wait_accessible_events(self, events, timeout=3000):
+        returned_events = []
+        index = 0
+        cumulative_time = 0
+        for event in events:
+            while cumulative_time &lt; timeout:
+                e = parseString(self.get_accessible_event_match(event, index))
+                if e.documentElement.tagName == 'event':
+                    index = \
+                        int(e.documentElement.getAttribute('index') or 0) + 1
+                    returned_events.append(e.toxml())
+                    break
+                cumulative_time += 500
+                time.sleep(0.5)
+
+        return returned_events</diff>
      <filename>speclenium_client.py</filename>
    </modified>
    <modified>
      <diff>@@ -30,7 +30,7 @@
 # the provisions above, a recipient may use your version of this file under
 # the terms of any one of the MPL, the GPL or the LGPL.
 
-__version__   = &quot;0.0.2&quot;
+__version__   = &quot;0.0.3&quot;
 __copyright__ = &quot;Copyright (c) 2008 Eitan Isaacson&quot;
 __license__   = &quot;MPL 1.1/GPL 2.0/LGPL 2.1&quot;
 </diff>
      <filename>specular/__init__.py</filename>
    </modified>
    <modified>
      <diff>@@ -65,7 +65,7 @@ def specular_accessible_from_dom(dom):
 
 
 if platform == 'win32':
-    def _populate_accessible_node(doc, element, acc):
+    def _populate_accessible_node(doc, element, acc, descendants=True):
         element.setAttribute('role', acc.accRoleName() or '')
         element.setAttribute('name', acc.accName(0) or '')
 
@@ -82,13 +82,14 @@ if platform == 'win32':
 
         element.setAttribute('state', '|'.join(acc.accStateSet()))
         
-        for child in acc:
-            if child:
-                e = doc.createElement('accessible')
-                element.appendChild(e)
-                _populate_accessible_node(doc, e, child)
+        if descendants:
+            for child in acc:
+                if child:
+                    e = doc.createElement('accessible')
+                    element.appendChild(e)
+                    _populate_accessible_node(doc, e, child)
 else:
-    def _populate_accessible_node(doc, element, acc):
+    def _populate_accessible_node(doc, element, acc, descendants=True):
         element.setAttribute('role', acc.getRoleName())
         element.setAttribute('name', acc.name)
 
@@ -97,17 +98,18 @@ else:
         sset = [repr(a)[6:].lower() for a in acc.getState().getStates()]
         
         element.setAttribute('state', '|'.join(sset))
-        for child in acc:
-            if child:
-                e = doc.createElement('accessible')
-                try:
-                    _populate_accessible_node(doc, e, child)
-                except LookupError:
-                    pass
-                else:
-                    element.appendChild(e)
+        if descendants:
+            for child in acc:
+                if child:
+                    e = doc.createElement('accessible')
+                    try:
+                        _populate_accessible_node(doc, e, child)
+                    except LookupError:
+                        pass
+                    else:
+                        element.appendChild(e)
 
-def specular_accessible_from_accessible(acc):    
+def specular_accessible_from_accessible(acc, descendants=True):    
     doc = getDOMImplementation().createDocument(None, &quot;accessible&quot;, None)
-    _populate_accessible_node(doc, doc.documentElement, acc)
+    _populate_accessible_node(doc, doc.documentElement, acc, descendants)
     return specular_accessible_from_dom(doc.documentElement)</diff>
      <filename>specular/specular_accessible.py</filename>
    </modified>
    <modified>
      <diff>@@ -41,14 +41,23 @@ from specular_accessible import \
 
 if platform == 'win32':
     import pyia
-    events_map = {'object-state-changed-checked':pyia.EVENT_OBJECT_STATECHANGE}
+    events_map = \
+        {'object-state-changed-checked' : pyia.EVENT_OBJECT_STATECHANGE,
+         'object-destroy' : pyia.EVENT_OBJECT_HIDE,
+         'object-add' : pyia.EVENT_OBJECT_SHOW,
+         'object-focus' : pyia.EVENT_OBJECT_FOCUS,
+         'system-alert' : pyia.EVENT_SYSTEM_ALERT}
     def get_specular_type(native_type):
         for key, value in events_map.iteritems():
             if value == native_type:
                 return key
 else:
     events_map = \
-        {'object-state-changed-checked':'object:state-changed:checked'}
+        {'object-state-changed-checked':'object:state-changed:checked',
+         'object-destroy' : 'object:children-changed:remove',
+         'object-add' : 'object:children-changed:add',
+         'object-focus' : 'focus',
+         'system-alert' : 'not supported on platform'}
     def get_specular_type(native_type):
         for key, value in events_map.iteritems():
             if native_type.startswith(value):
@@ -93,9 +102,20 @@ def specular_event_from_event(event):
     doc = Document()
     doc.appendChild(doc.createElement('event'))
     doc.documentElement.setAttribute('type', get_specular_type(event.type))
-    if event.source:
-        acc_dom = specular_accessible_from_accessible(event.source)
+    if type(event.type) != int and \
+            event.type.startswith('object:children-changed') and \
+            getattr(event, 'any_data', None):
+        acc_dom = specular_accessible_from_accessible(event.any_data, False)
         source = doc.createElement('source')
         doc.documentElement.appendChild(source)
         source.appendChild(acc_dom.documentElement)
+    else:
+        try:
+            acc_dom = specular_accessible_from_accessible(event.source, False)
+        except:
+            pass
+        else:
+            source = doc.createElement('source')
+            doc.documentElement.appendChild(source)
+            source.appendChild(acc_dom.documentElement)
     return specular_event_from_dom(doc.documentElement)</diff>
      <filename>specular/specular_event.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>16bc857fb79a5e003b5198b26d9a91f749c28ea5</id>
    </parent>
    <parent>
      <id>ba5358381f847ce8dcafc68519128bffc61b3f74</id>
    </parent>
  </parents>
  <author>
    <name>Eitan Isaacson</name>
    <email>eitan@sparky.(none)</email>
  </author>
  <url>http://github.com/eeejay/specular/commit/5db81bd577c43539a12bac354ea1b9179c59ddda</url>
  <id>5db81bd577c43539a12bac354ea1b9179c59ddda</id>
  <committed-date>2008-10-17T10:00:16-07:00</committed-date>
  <authored-date>2008-10-17T10:00:16-07:00</authored-date>
  <message>Merge branch 'master' into codetalks_suite

Conflicts:

	specular/specular_event.py</message>
  <tree>6523443ea365b973992e9eab69076111b3aa9d51</tree>
  <committer>
    <name>Eitan Isaacson</name>
    <email>eitan@sparky.(none)</email>
  </committer>
</commit>
