tdebluez
obexNode.cpp
Go to the documentation of this file.
1// File autogenerated
2
3// declaration include
4#include "obexNode.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
19#include "client1Interface.h"
22#include "session1Interface.h"
23#include "transfer1Interface.h"
26#include "propertiesInterface.h"
27
28namespace org
29{
30namespace bluez
31{
32
53
54obexNode::obexNode() : TQT_DBusObjectBase(),
55 m_private(new Private())
56{
57}
58
60{
62
63 delete m_private;
64}
65
67{
68 if (path.isEmpty()) return false;
69
70 if (!m_private->objectPath.isEmpty()) unregisterObject();
71
72 m_private->connection = connection;
74
75 if (!m_private->connection.registerObject(path, this))
76 {
79
80 return false;
81 }
82
83 if (m_private->interfaces.isEmpty())
84 {
85 TQString name = "org.freedesktop.DBus.Introspectable";
86 TQT_DBusObjectBase* interface = m_private;
88
89 name = "org.bluez.obex.AgentManager1";
90 interface = createInterface(name);
91 Q_ASSERT(interface != 0);
92 m_private->interfaces.insert(name, interface);
93
94 name = "org.bluez.obex.Client1";
95 interface = createInterface(name);
96 Q_ASSERT(interface != 0);
97 m_private->interfaces.insert(name, interface);
98
99 name = "org.bluez.obex.FileTransfer1";
100 interface = createInterface(name);
101 Q_ASSERT(interface != 0);
102 m_private->interfaces.insert(name, interface);
103
104 name = "org.bluez.obex.ObjectPush1";
105 interface = createInterface(name);
106 Q_ASSERT(interface != 0);
107 m_private->interfaces.insert(name, interface);
108
109 name = "org.bluez.obex.Session1";
110 interface = createInterface(name);
111 Q_ASSERT(interface != 0);
112 m_private->interfaces.insert(name, interface);
113
114 name = "org.bluez.obex.Transfer1";
115 interface = createInterface(name);
116 Q_ASSERT(interface != 0);
117 m_private->interfaces.insert(name, interface);
118
119 name = "org.bluez.obex.Synchronization1";
120 interface = createInterface(name);
121 Q_ASSERT(interface != 0);
122 m_private->interfaces.insert(name, interface);
123
124 name = "org.bluez.obex.PhonebookAccess1";
125 interface = createInterface(name);
126 Q_ASSERT(interface != 0);
127 m_private->interfaces.insert(name, interface);
128
129 name = "org.freedesktop.DBus.Properties";
130 interface = createInterface(name);
131 Q_ASSERT(interface != 0);
132 m_private->interfaces.insert(name, interface);
133 }
134
135 return true;
136}
137
138void obexNode::addChildNode(const TQString& child)
139{
140 m_private->childrenNodes.append(child);
141}
142
143void obexNode::unregisterObject()
144{
145 if (m_private->objectPath.isEmpty()) return;
146
147 m_private->connection.unregisterObject(m_private->objectPath);
148
149 m_private->connection = TQT_DBusConnection();
150 m_private->objectPath = TQString();
151}
152
153bool obexNode::handleMethodCall(const TQT_DBusMessage& message)
154{
155 TQMap<TQString, TQT_DBusObjectBase*>::iterator findIt = m_private->interfaces.find(message.interface());
156 if (findIt == m_private->interfaces.end()) return false;
157
158 return delegateMethodCall(message, findIt.data());
159}
160
161obexNode::Private::~Private()
162{
165 for (; it != endIt; ++it)
166 {
167 TQT_DBusObjectBase* interface = it.data();
168 if (interface != this)
169 delete interface;
170 }
171 interfaces.clear();
172}
173
174bool obexNode::Private::Introspect(TQString& data, TQT_DBusError& error)
175{
177 if (introspectionData.isEmpty()) cacheIntrospectionData();
178
179 data = introspectionData;
180
181 return true;
182}
183
184void obexNode::Private::handleMethodReply(const TQT_DBusMessage& reply)
185{
186 connection.send(reply);
187}
188
189void obexNode::Private::cacheIntrospectionData()
190{
193 TQDomElement nodeElement = doc.createElement("node");
194 if (!objectPath.isEmpty() && objectPath.compare("/") != 0)
195 {
196 nodeElement.setAttribute ( "name", objectPath );
197 }
198 // Introspectable is added by default. Show it only if there is interface
199 if (interfaces.count()>1) {
200 interfaceElement = doc.createElement("interface");
202 nodeElement.appendChild(interfaceElement);
203 }
204
205 interfaceElement = doc.createElement("interface");
207 nodeElement.appendChild(interfaceElement);
208
209 interfaceElement = doc.createElement("interface");
211 nodeElement.appendChild(interfaceElement);
212
213 interfaceElement = doc.createElement("interface");
215 nodeElement.appendChild(interfaceElement);
216
217 interfaceElement = doc.createElement("interface");
219 nodeElement.appendChild(interfaceElement);
220
221 interfaceElement = doc.createElement("interface");
223 nodeElement.appendChild(interfaceElement);
224
225 interfaceElement = doc.createElement("interface");
227 nodeElement.appendChild(interfaceElement);
228
229 interfaceElement = doc.createElement("interface");
231 nodeElement.appendChild(interfaceElement);
232
233 interfaceElement = doc.createElement("interface");
235 nodeElement.appendChild(interfaceElement);
236
237 interfaceElement = doc.createElement("interface");
239 nodeElement.appendChild(interfaceElement);
240
241 if (!childrenNodes.isEmpty()) {
242 for (TQStringList::Iterator it = childrenNodes.begin(); it != childrenNodes.end(); ++it ) {
243 TQDomElement nodeElement1 = doc.createElement("node");
244 nodeElement1.setAttribute ( "name", *it );
245 nodeElement.appendChild(nodeElement1);
246 }
247 }
248
249 doc.appendChild(nodeElement);
250
251 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";
252 introspectionData += doc.toString();
253}
254
255}; // namespace bluez
256
257}; // namespace org
258
259// End of File
260
virtual void handleMethodReply(const TQT_DBusMessage &reply)
Definition obexNode.cpp:184
TQT_DBusConnection connection
Definition obexNode.cpp:42
TQMap< TQString, TQT_DBusObjectBase * > interfaces
Definition obexNode.cpp:39
virtual bool Introspect(TQString &data, TQT_DBusError &error)
Definition obexNode.cpp:174
bool registerObject(const TQT_DBusConnection &connection, const TQString &path)
Definition obexNode.cpp:66
Private * m_private
Definition obexNode.h:39
static void buildIntrospectionData(TQDomElement &interfaceElement)
static void buildIntrospectionData(TQDomElement &interfaceElement)
static void buildIntrospectionData(TQDomElement &interfaceElement)
static void buildIntrospectionData(TQDomElement &interfaceElement)
static void buildIntrospectionData(TQDomElement &interfaceElement)
static void buildIntrospectionData(TQDomElement &interfaceElement)
static void buildIntrospectionData(TQDomElement &interfaceElement)
static void buildIntrospectionData(TQDomElement &interfaceElement)