diff --git a/src/tools/dbusxml2qt3/classgen.cpp b/src/tools/dbusxml2qt3/classgen.cpp index 0954e7c..e117387 100644 --- a/src/tools/dbusxml2qt3/classgen.cpp +++ b/src/tools/dbusxml2qt3/classgen.cpp @@ -347,6 +347,7 @@ static void writeSourceIncludes(const Class& classData, Class::Role role, case Class::Node: includes["TQt"].insertString(""); includes["TQt"].insertString(""); + includes["TQt"].insertString(""); includes["tqdbus"].insertString(""); includes["tqdbus"].insertString(""); break; @@ -440,6 +441,7 @@ static void openClassDeclaration(const Class& classData, stream << endl; stream << " bool registerObject(const TQT_DBusConnection& connection, " << "const TQString& path);" << endl; + stream << " void addChildNode(const TQString& child);" << endl; stream << endl; stream << " void unregisterObject();" << endl; stream << endl; diff --git a/src/tools/dbusxml2qt3/main.cpp b/src/tools/dbusxml2qt3/main.cpp index 747af9e..018bc5d 100644 --- a/src/tools/dbusxml2qt3/main.cpp +++ b/src/tools/dbusxml2qt3/main.cpp @@ -119,7 +119,10 @@ int main(int argc, char** argv) { hasIntrospectable = true; } - interfaces << classData; + else + { + interfaces << classData; + } } } } @@ -398,6 +401,34 @@ int main(int argc, char** argv) headerStream, sourceStream); ClassGenerator::finishStreams(baseName, headerStream, sourceStream); + + // create dummy node to handle the path hierarchy + if ( nameParts.size() > 1 ) { + TQTextStream headerStreamDBusBaseNode; + TQTextStream sourceStreamDBusBaseNode; + + TQString baseName = "DBusBase"; + Class classDataDBusBaseNode; + classDataDBusBaseNode.name = baseName + "Node"; + TQValueList interfacesDBusBase = TQValueList(); + + TQString baseNameDBusBaseNode = baseName.lower() + "Node"; + + if (!ClassGenerator::initStreams(baseNameDBusBaseNode, headerStreamDBusBaseNode, sourceStreamDBusBaseNode)) + { + std::cerr << "dbusxml2qt3: interface files, using base name '" + << baseNameDBusBaseNode.local8Bit().data() + << "', could not be opened for writing" + << std::endl; + exit(4); + } + + ClassGenerator::generateNode(classDataDBusBaseNode, + interfacesDBusBase, baseNameDBusBaseNode, + headerStreamDBusBaseNode, sourceStreamDBusBaseNode); + + ClassGenerator::finishStreams(baseNameDBusBaseNode, headerStreamDBusBaseNode, sourceStreamDBusBaseNode); + } } return 0; diff --git a/src/tools/dbusxml2qt3/methodgen.cpp b/src/tools/dbusxml2qt3/methodgen.cpp index a7e3427..f86f762 100644 --- a/src/tools/dbusxml2qt3/methodgen.cpp +++ b/src/tools/dbusxml2qt3/methodgen.cpp @@ -152,7 +152,7 @@ static bool parseDBusSignature(const TQString& signature, Argument& argument) if (!parseDBusSignature(dictSignature.left(1), key)) return false; Argument value; - if (parseDBusSignature(dictSignature.mid(1), value)) + if (parseDBusSignature(dictSignature.mid(1), value) && !dictSignature.startsWith("oa")) { if (!value.subAccessor.isEmpty()) { @@ -535,6 +535,14 @@ static void writeNodeInitialization(const Class& classData, stream << " return true;" << endl; stream << "}" << endl; stream << endl; + + stream << "void " << classData.name + << "::addChildNode(const TQString& child)" << endl; + stream << "{" << endl; + stream << " m_private->childrenNodes.append(child);" << endl; + stream << "}" << endl; + stream << endl; + } static void writeNodeIntrospection(const Class& classData, @@ -550,11 +558,14 @@ static void writeNodeIntrospection(const Class& classData, stream << " {" << endl; stream << " nodeElement.setAttribute ( \"name\", objectPath );" << endl; stream << " }" << endl; - stream << " TQDomElement interfaceElement = doc.createElement(\"interface\");" + stream << " // Introspectable is added by default. Show it only if there is interface" << endl; + stream << " if (interfaces.count()>1) {" << endl; + stream << " TQDomElement interfaceElement = doc.createElement(\"interface\");" << endl; - stream << " org::freedesktop::DBus::IntrospectableInterface" + stream << " org::freedesktop::DBus::IntrospectableInterface" << "::buildIntrospectionData(interfaceElement);" << endl; - stream << " nodeElement.appendChild(interfaceElement);" << endl; + stream << " nodeElement.appendChild(interfaceElement);" << endl; + stream << " }" << endl; TQValueList::const_iterator it = interfaces.begin(); TQValueList::const_iterator endIt = interfaces.end(); @@ -563,13 +574,22 @@ static void writeNodeIntrospection(const Class& classData, if ((*it).dbusName == "org.freedesktop.DBus.Introspectable") continue; stream << endl; - stream << " interfaceElement = doc.createElement(\"interface\");" + stream << " TQDomElement interfaceElement = doc.createElement(\"interface\");" << endl; stream << " " << (*it).namespaces.join("::") + "::" + (*it).name << "Interface::buildIntrospectionData(interfaceElement);" << endl; stream << " nodeElement.appendChild(interfaceElement);" << endl; } + stream << endl; + stream << " if (!childrenNodes.isEmpty()) {" << endl; + stream << " for (TQStringList::Iterator it = childrenNodes.begin(); it != childrenNodes.end(); ++it ) {" << endl; + stream << " TQDomElement nodeElement1 = doc.createElement(\"node\");" << endl; + stream << " nodeElement1.setAttribute ( \"name\", *it );" << endl; + stream << " nodeElement.appendChild(nodeElement1);" << endl; + stream << " }" << endl; + stream << " }" << endl; + stream << endl; stream << " doc.appendChild(nodeElement);" << endl; stream << endl; @@ -1763,6 +1783,7 @@ void MethodGenerator::writeNodePrivate(const Class& classData, TQTextStream& str stream << endl; stream << " TQT_DBusConnection connection;" << endl; stream << " TQString objectPath;" << endl; + stream << " TQStringList childrenNodes;" << endl; stream << endl; stream << "protected:" << endl;