Advertisement
puneet

GetManagedObjects

Jul 19th, 2012
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. ManagedObjectMap ObjectManager::getManagedObjects()
  2. {
  3. kDebug()<<"Get Managed Objects";
  4. ManagedObjectMap object_map;
  5. org::freedesktop::DBus::Introspectable *introspectable_iface = new org::freedesktop::DBus::Introspectable("", "/", m_conn, this);
  6.  
  7. //create an xml document of the introspect
  8. QDomDocument doc("dbus connection");
  9. kDebug() << introspectable_iface->Introspect();
  10. if (!doc.setContent(introspectable_iface->Introspect())) {
  11. kDebug()<<"Error in setting the content of introspectable interface";
  12. }
  13.  
  14. QDomElement docElem = doc.documentElement();
  15. QString rootTag = docElem.tagName();
  16. kDebug()<<"Root Name" << rootTag;
  17.  
  18. //Parse the above xml document for all the object paths registered on the dbus
  19. QDomNodeList nodeList = docElem.elementsByTagName("node");
  20. for(int ii = 0;ii < nodeList.count(); ii++)
  21. {
  22. kDebug()<<"inside";
  23. QDomElement el = nodeList.at(ii).toElement();
  24. kDebug()<<el.tagName();
  25. QString object_name = el.attribute("name");
  26. kDebug() << "Object Name" << object_name;
  27. org::freedesktop::DBus::Introspectable *introspectable_iface1 = new org::freedesktop::DBus::Introspectable("", "/"+object_name, m_conn, this);
  28. QDomDocument doc1("single object");
  29. kDebug() << introspectable_iface1->Introspect();
  30.  
  31. //Create the xml document for intefaces available at each object path
  32. if (!doc1.setContent(introspectable_iface1->Introspect())) {
  33. kDebug()<<"Error in setting the content of introspectable interface";
  34. }
  35. QDomElement docElem1 = doc1.documentElement();
  36. QString rootTag1 = docElem1.tagName();
  37. kDebug()<<"Interface Root Name" << rootTag1;
  38. QDomNodeList nodeList1 = docElem1.elementsByTagName("interface");
  39. ManagedInterfaceMap interface_map;
  40. kDebug()<<"Just testing";
  41.  
  42. //Parse Each interface to get the properties
  43. for(int jj = 0;jj < nodeList1.count(); jj++)
  44. {
  45. QDomElement el1 = nodeList1.at(jj).toElement();
  46. kDebug()<<"Inside the Inteface Loop";
  47. QString interface_name = el1.attribute("name");
  48. org::freedesktop::DBus::Properties *prop_iface = new org::freedesktop::DBus::Properties("","/"+object_name, m_conn, this);
  49. kDebug()<<"Fetching Properties for interface"<<interface_name;
  50. QVariantMap properties = prop_iface->GetAll(interface_name);
  51. kDebug()<<"Fetching Properties Done!";
  52. if(properties.isEmpty()) {
  53. kDebug()<<"No Properties";
  54. } else {
  55. QMapIterator<QString, QVariant> i(properties);
  56. while (i.hasNext()) {
  57. i.next();
  58. kDebug() << i.key() << ": " << i.value() << endl;
  59. }
  60. }
  61. interface_map.insert(interface_name,properties);
  62. }
  63. object_map.insert(object_name,interface_map);
  64. }
  65. kDebug() << "Returning the value now";
  66. // qDebug()<<object_map;
  67. return object_map;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement