summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEmanoil Kotsev <deloptes@gmail.com>2020-03-11 18:11:28 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2020-03-11 18:11:28 +0900
commit7d4929217698d7ed663732d08540420ee835bf08 (patch)
tree378d516207349eb243c846e8ba9eecba700f2736 /src
parente9bf60b236c3a449b7c507646898945178cb8957 (diff)
downloaddbus-1-tqt-7d4929217698d7ed663732d08540420ee835bf08.tar.gz
dbus-1-tqt-7d4929217698d7ed663732d08540420ee835bf08.zip
Generate DBusBaseNode class to handle the empty nodes.
- Prevent showing Introspection in empty nodes - fix method generation for objectpath array in signature like a{oa{sa{sv}}} - Hide Introspectable interface if there is no interface in the node - Add support for multiple nodes introspection - addChildNode function to support multiple nodes Signed-off-by: Emanoil Kotsev <deloptes@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/tools/dbusxml2qt3/classgen.cpp2
-rw-r--r--src/tools/dbusxml2qt3/main.cpp33
-rw-r--r--src/tools/dbusxml2qt3/methodgen.cpp31
3 files changed, 60 insertions, 6 deletions
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("<tqdom.h>");
includes["TQt"].insertString("<tqmap.h>");
+ includes["TQt"].insertString("<tqstringlist.h>");
includes["tqdbus"].insertString("<tqdbusconnection.h>");
includes["tqdbus"].insertString("<tqdbusmessage.h>");
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<Class> interfacesDBusBase = TQValueList<Class>();
+
+ 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<Class>::const_iterator it = interfaces.begin();
TQValueList<Class>::const_iterator endIt = interfaces.end();
@@ -563,7 +574,7 @@ 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;
@@ -571,6 +582,15 @@ static void writeNodeIntrospection(const Class& classData,
}
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;