void listAllInterfaces(const QString &service, const QString &path) { QDBusInterfacePtr iface(*connection, service, path, "org.freedesktop.DBus.Introspectable"); if (!iface->isValid()) { QDBusError err(iface->lastError()); fprintf(stderr, "Cannot introspect object %s at %s:\n%s (%s)\n", qPrintable(path), qPrintable(service), qPrintable(err.name()), qPrintable(err.message())); exit(1); } QDBusReply<QString> xml = iface->call("Introspect"); if (xml.isError()) return; // silently QDomDocument doc; doc.setContent(xml); QDomElement node = doc.documentElement(); QDomElement child = node.firstChildElement(); while (!child.isNull()) { if (child.tagName() == QLatin1String("interface")) { QString ifaceName = child.attribute("name"); if (QDBusUtil::isValidInterfaceName(ifaceName)) listInterface(service, path, ifaceName); else { qWarning("Invalid D-BUS interface name '%s' found while parsing introspection", qPrintable(ifaceName)); } } child = child.nextSiblingElement(); } }
void listContents(const CORBA::ContainedSeq& repoContents) { // // List the contents of each element. // for(unsigned int i = 0; i < repoContents.length(); ++i) { CORBA::Contained::Description_var desc = repoContents[i]->describe(); switch(desc->kind) { case CORBA::dk_Constant: ACE_DEBUG((LM_INFO, ACE_TEXT("%s: element[%d] is a constant definition.\n"), programLabel, i + 1 )); break; case CORBA::dk_Typedef: ACE_DEBUG((LM_INFO, ACE_TEXT("%s: element[%d] is a typedef definition.\n"), programLabel, i + 1 )); break; case CORBA::dk_Exception: ACE_DEBUG((LM_INFO, ACE_TEXT("%s: element[%d] is an exception definition.\n"), programLabel, i + 1 )); break; case CORBA::dk_Interface: { ACE_DEBUG((LM_INFO, ACE_TEXT("%s: element[%d] is an interface definition.\n") ACE_TEXT("%s: listing element[%d]...\n"), programLabel, i + 1, programLabel, i + 1 )); CORBA::InterfaceDef_var interfaceDef = CORBA::InterfaceDef::_narrow(repoContents[i]); listInterface(interfaceDef.in()); break; } case CORBA::dk_Module: { ACE_DEBUG((LM_INFO, ACE_TEXT("%s: element[%d] is a module definition.\n"), programLabel, i + 1 )); CORBA::ModuleDef_var moduleDef = CORBA::ModuleDef::_narrow(repoContents[i]); CORBA::ContainedSeq_var moduleContents = moduleDef->contents(CORBA::dk_all,1); CORBA::String_var moduleId = moduleDef->id(); CORBA::String_var moduleName = moduleDef->name(); ACE_DEBUG((LM_INFO, ACE_TEXT("%s:\n// %s\nmodule %s\n{\n") ACE_TEXT("%s: the module contains %d elements.\n"), programLabel, moduleId.in(), moduleName.in(), programLabel, moduleContents->length() )); listContents(moduleContents.in()); ACE_DEBUG((LM_INFO, ACE_TEXT("}\n"))); break; } default: break; } } }