tdebluez
tdebluezNode.cpp
Go to the documentation of this file.
1// File autogenerated
2
3// declaration include
4#include "tdebluezNode.h"
5
6// TQt includes
7#include <tqdom.h>
8#include <tqmap.h>
9#include <tqstringlist.h>
10
11// TQt D-Bus includes
12#include <tqdbusconnection.h>
13#include <tqdbusmessage.h>
14
15
16// interface classes includes
18#include "agent1Interface.h"
19
20namespace org
21{
22namespace trinitydesktop
23{
24
45
46tdebluezNode::tdebluezNode() : TQT_DBusObjectBase(),
47 m_private(new Private())
48{
49}
50
57
59{
60 if (path.isEmpty()) return false;
61
62 if (!m_private->objectPath.isEmpty()) unregisterObject();
63
64 m_private->connection = connection;
66
67 if (!m_private->connection.registerObject(path, this))
68 {
71
72 return false;
73 }
74
75 if (m_private->interfaces.isEmpty())
76 {
77 TQString name = "org.freedesktop.DBus.Introspectable";
78 TQT_DBusObjectBase* interface = m_private;
80
81 name = "org.bluez.Agent1";
82 interface = createInterface(name);
83 Q_ASSERT(interface != 0);
84 m_private->interfaces.insert(name, interface);
85 }
86
87 return true;
88}
89
94
96{
97 if (m_private->objectPath.isEmpty()) return;
98
99 m_private->connection.unregisterObject(m_private->objectPath);
100
103}
104
112
114{
117 for (; it != endIt; ++it)
118 {
119 TQT_DBusObjectBase* interface = it.data();
120 if (interface != this)
121 delete interface;
122 }
123 interfaces.clear();
124}
125
127{
129 if (introspectionData.isEmpty()) cacheIntrospectionData();
130
131 data = introspectionData;
132
133 return true;
134}
135
137{
138 connection.send(reply);
139}
140
142{
145 TQDomElement nodeElement = doc.createElement("node");
146 if (!objectPath.isEmpty() && objectPath.compare("/") != 0)
147 {
148 nodeElement.setAttribute ( "name", objectPath );
149 }
150 // Introspectable is added by default. Show it only if there is interface
151 if (interfaces.count()>1) {
152 interfaceElement = doc.createElement("interface");
154 nodeElement.appendChild(interfaceElement);
155 }
156
157 interfaceElement = doc.createElement("interface");
159 nodeElement.appendChild(interfaceElement);
160
161 if (!childrenNodes.isEmpty()) {
162 for (TQStringList::Iterator it = childrenNodes.begin(); it != childrenNodes.end(); ++it ) {
163 TQDomElement nodeElement1 = doc.createElement("node");
164 nodeElement1.setAttribute ( "name", *it );
165 nodeElement.appendChild(nodeElement1);
166 }
167 }
168
169 doc.appendChild(nodeElement);
170
171 introspectionData = "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n";
172 introspectionData += doc.toString();
173}
174
175}; // namespace trinitydesktop
176
177}; // namespace org
178
179// End of File
180
static void buildIntrospectionData(TQDomElement &interfaceElement)
virtual bool Introspect(TQString &data, TQT_DBusError &error)
virtual void handleMethodReply(const TQT_DBusMessage &reply)
TQMap< TQString, TQT_DBusObjectBase * > interfaces
virtual bool handleMethodCall(const TQT_DBusMessage &message)
bool registerObject(const TQT_DBusConnection &connection, const TQString &path)
void addChildNode(const TQString &child)