Adding child node/objects parsing into introspection
authorAlexander Fell <alex@alexfell.com>
Thu, 25 Jul 2013 11:01:05 +0000 (12:01 +0100)
committerAlexander Fell <alex@alexfell.com>
Thu, 25 Jul 2013 11:01:05 +0000 (12:01 +0100)
From the introspection dtd document, the returned xml
from introspection can return a list of interface or node elements:
http://standards.freedesktop.org/dbus/1.0/introspect.dtd

This is useful to get the names of the child objects that
can be found on the bus path

cloudeebus/cloudeebus.js

index 2684da8..7a888a3 100644 (file)
@@ -767,6 +767,15 @@ cloudeebus.ProxyObject.prototype._introspect = function(successCB, errorCB) {
        function introspectSuccessCB(str) {
                var parser = new DOMParser();
                var xmlDoc = parser.parseFromString(str, "text/xml");
+               var nodes = xmlDoc.getElementsByTagName("node");
+               self.childNodeNames = [];
+               var l = nodes.length;
+               //there will always be 1 node, the parent/head node
+               if(l > 1){
+                       for(var i = 1; i < l; i++){
+                               self.childNodeNames.push(nodes[i].getAttribute("name"));
+                       }
+               }
                var interfaces = xmlDoc.getElementsByTagName("interface");
                self.propInterfaces = [];
                var supportDBusProperties = false;