]>
Commit | Line | Data |
---|---|---|
acac9ffe | 1 | --- bluez-bluetoothinterface.cpp (.../branches/KDE/4.2/kdebase/workspace/solid/bluez) (revision 912529) |
2 | +++ solid/bluez/bluez-bluetoothinterface.cpp (.../trunk/KDE/kdebase/workspace/solid/bluez) (revision 912529) | |
3 | @@ -25,6 +25,7 @@ | |
4 | #include <solid/control/bluetoothinterface.h> | |
5 | ||
6 | #include "bluez-bluetoothremotedevice.h" | |
7 | +#include "bluez-bluetoothinputdevice.h" | |
8 | #include <KDebug> | |
9 | ||
10 | ||
11 | @@ -43,6 +44,7 @@ | |
12 | QString objectPath; | |
13 | ||
14 | QMap<QString, BluezBluetoothRemoteDevice *> devices; | |
15 | + QMap<QString, BluezBluetoothInputDevice *> inputDevices; | |
16 | }; | |
17 | ||
18 | ||
19 | @@ -56,23 +58,6 @@ | |
20 | objectPath, \ | |
21 | "org.bluez.Adapter", \ | |
22 | signal, this, SLOT(slot)); | |
23 | -/* | |
24 | - connectInterfaceToThis("ModeChanged", slotModeChanged(const QString &)); | |
25 | - connectInterfaceToThis("DiscoverableTimeoutChanged", slotDiscoverableTimeoutChanged(int)); | |
26 | - connectInterfaceToThis("MinorClassChanged", slotMinorClassChanged(const QString &)); | |
27 | - connectInterfaceToThis("NameChanged", slotNameChanged(const QString &)); | |
28 | - connectInterfaceToThis("DiscoveryStarted", slotDiscoveryStarted()); | |
29 | - connectInterfaceToThis("DiscoveryCompleted", slotDiscoveryCompleted()); | |
30 | - connectInterfaceToThis("RemoteDeviceDisappeared", slotRemoteDeviceDisappeared(const QString &)); | |
31 | - connectInterfaceToThis("RemoteDeviceFound", slotRemoteDeviceFound(const QString &, uint, short)); | |
32 | - connectInterfaceToThis("RemoteNameUpdated", slotRemoteNameUpdated(const QString &, const QString &)); | |
33 | - connectInterfaceToThis("RemoteDeviceConnected", slotRemoteDeviceConnected(const QString &)); | |
34 | - connectInterfaceToThis("RemoteDeviceDisconnected", slotRemoteDeviceDisconnected(const QString &)); | |
35 | - connectInterfaceToThis("TrustAdded", slotTrustAdded(const QString &)); | |
36 | - connectInterfaceToThis("TrustRemoved", slotTrustRemoved(const QString &)); | |
37 | - connectInterfaceToThis("BondingCreated", slotBondingCreated(const QString &)); | |
38 | - connectInterfaceToThis("BondingRemoved", slotBondingRemoved(const QString &)); | |
39 | -*/ | |
40 | ||
41 | connectInterfaceToThis("PropertyChanged", slotPropertyChanged(const QString &, const QVariant &)); | |
42 | connectInterfaceToThis("DeviceCreated", slotDeviceCreated(const QDBusObjectPath &)); | |
43 | @@ -98,21 +83,14 @@ | |
44 | d->iface.call("CancelDeviceCreation",addr); | |
45 | } | |
46 | ||
47 | -QString BluezBluetoothInterface::createDevice(const QString &addr) const | |
48 | +void BluezBluetoothInterface::createDevice(const QString &addr) const | |
49 | { | |
50 | - QDBusObjectPath path = objectReply("CreateDevice",addr); | |
51 | - return path.path(); | |
52 | + d->iface.call("CreateDevice",addr); | |
53 | } | |
54 | ||
55 | -QString BluezBluetoothInterface::createPairedDevice(const QString &addr, const QString &agentUBI, const QString &capab) const | |
56 | +void BluezBluetoothInterface::createPairedDevice(const QString &addr, const QString &agentUBI, const QString &capab) const | |
57 | { | |
58 | - QDBusReply< QDBusObjectPath > reply; | |
59 | - reply = d->iface.call("CreatePairedDevice",addr,agentUBI,capab); | |
60 | - | |
61 | - if (!reply.isValid()) { | |
62 | - return QString(); | |
63 | - } | |
64 | - return reply.value().path(); | |
65 | + d->iface.call("CreatePairedDevice",addr,qVariantFromValue(QDBusObjectPath(agentUBI)),capab); | |
66 | } | |
67 | ||
68 | QString BluezBluetoothInterface::findDevice(const QString &addr) const | |
69 | @@ -147,7 +125,7 @@ | |
70 | ||
71 | void BluezBluetoothInterface::registerAgent(const QString &agentUBI, const QString &capab) | |
72 | { | |
73 | - d->iface.call("RegisterAgent",agentUBI,capab); | |
74 | + d->iface.call("RegisterAgent",qVariantFromValue(QDBusObjectPath(agentUBI)),capab); | |
75 | } | |
76 | ||
77 | void BluezBluetoothInterface::releaseSession() | |
78 | @@ -157,7 +135,7 @@ | |
79 | ||
80 | void BluezBluetoothInterface::removeDevice(const QString &deviceUBI ) | |
81 | { | |
82 | - d->iface.call("RemoveDevice",deviceUBI); | |
83 | + d->iface.call("RemoveDevice",qVariantFromValue(QDBusObjectPath(deviceUBI))); | |
84 | } | |
85 | ||
86 | void BluezBluetoothInterface::requestSession() | |
87 | @@ -183,305 +161,20 @@ | |
88 | ||
89 | void BluezBluetoothInterface::unregisterAgent(const QString &agentUBI) | |
90 | { | |
91 | - d->iface.call("UnregisterAgent",agentUBI); | |
92 | + d->iface.call("UnregisterAgent",qVariantFromValue(QDBusObjectPath(agentUBI))); | |
93 | } | |
94 | ||
95 | ||
96 | ||
97 | -/* | |
98 | - | |
99 | -QString BluezBluetoothInterface::address() const | |
100 | +void BluezBluetoothInterface::slotDeviceCreated(const QDBusObjectPath &path) | |
101 | { | |
102 | - return stringReply("GetAddress"); | |
103 | -} | |
104 | + kDebug() << "device created"; | |
105 | ||
106 | -QString BluezBluetoothInterface::version() const | |
107 | -{ | |
108 | - return stringReply("GetVersion"); | |
109 | -} | |
110 | - | |
111 | -QString BluezBluetoothInterface::revision() const | |
112 | -{ | |
113 | - return stringReply("GetRevision"); | |
114 | -} | |
115 | - | |
116 | -QString BluezBluetoothInterface::manufacturer() const | |
117 | -{ | |
118 | - return stringReply("GetManufacturer"); | |
119 | -} | |
120 | - | |
121 | -QString BluezBluetoothInterface::company() const | |
122 | -{ | |
123 | - return stringReply("GetCompany"); | |
124 | -} | |
125 | - | |
126 | -Solid::Control::BluetoothInterface::Mode BluezBluetoothInterface::mode() const | |
127 | -{ | |
128 | - QString theMode = stringReply("GetMode"); | |
129 | - Solid::Control::BluetoothInterface::Mode modeEnum; | |
130 | - if (theMode == "connectable") | |
131 | - { | |
132 | - modeEnum = Solid::Control::BluetoothInterface::Connectable; | |
133 | + if (!d->devices.contains(path.path())) { | |
134 | + BluezBluetoothRemoteDevice* bluetoothRemoteDev = new BluezBluetoothRemoteDevice(path.path()); | |
135 | + d->devices.insert(path.path(), bluetoothRemoteDev); | |
136 | } | |
137 | - else if (theMode == "discoverable") | |
138 | - { | |
139 | - modeEnum = Solid::Control::BluetoothInterface::Discoverable; | |
140 | - } else { | |
141 | - Q_ASSERT(theMode == "off"); | |
142 | - modeEnum = Solid::Control::BluetoothInterface::Off; | |
143 | - } | |
144 | - return modeEnum; | |
145 | -} | |
146 | ||
147 | -int BluezBluetoothInterface::discoverableTimeout() const | |
148 | -{ | |
149 | - QDBusReply< uint > timeout = d->iface.call("GetDiscoverableTimeout"); | |
150 | - if (timeout.isValid()) { | |
151 | - return timeout.value(); | |
152 | - } | |
153 | - | |
154 | - return -1; | |
155 | -} | |
156 | - | |
157 | -bool BluezBluetoothInterface::isDiscoverable() const | |
158 | -{ | |
159 | - return boolReply("IsDiscoverable"); | |
160 | -} | |
161 | - | |
162 | -QStringList BluezBluetoothInterface::listConnections() const | |
163 | -{ | |
164 | - QStringList list = listReply("ListConnections"); | |
165 | - for (int i = 0; i < list.size(); i++) { | |
166 | - list[i] = ubi() + '/' + list[i]; | |
167 | - } | |
168 | - return list; | |
169 | -} | |
170 | - | |
171 | -QString BluezBluetoothInterface::majorClass() const | |
172 | -{ | |
173 | - return stringReply("GetMajorClass"); | |
174 | -} | |
175 | - | |
176 | -QStringList BluezBluetoothInterface::listAvailableMinorClasses() const | |
177 | -{ | |
178 | - return listReply("ListAvailableMinorClasses"); | |
179 | -} | |
180 | - | |
181 | -QString BluezBluetoothInterface::minorClass() const | |
182 | -{ | |
183 | - return stringReply("GetMinorClass"); | |
184 | -} | |
185 | - | |
186 | -QStringList BluezBluetoothInterface::serviceClasses() const | |
187 | -{ | |
188 | - return listReply("GetServiceClasses"); | |
189 | -} | |
190 | - | |
191 | -QString BluezBluetoothInterface::name() const | |
192 | -{ | |
193 | - return stringReply("GetName"); | |
194 | -} | |
195 | - | |
196 | -QString BluezBluetoothInterface::getRemoteName(const QString &mac) | |
197 | -{ | |
198 | - return stringReply("GetRemoteName",mac); | |
199 | -} | |
200 | - | |
201 | -bool BluezBluetoothInterface::isTrusted(const QString &mac) | |
202 | -{ | |
203 | - return boolReply("IsTrusted",mac); | |
204 | -} | |
205 | - | |
206 | -QStringList BluezBluetoothInterface::listBondings() const | |
207 | -{ | |
208 | - return listReply("ListBondings"); | |
209 | -} | |
210 | - | |
211 | -bool BluezBluetoothInterface::isPeriodicDiscoveryActive() const | |
212 | -{ | |
213 | - return boolReply("IsPeriodicDiscovery"); | |
214 | -} | |
215 | - | |
216 | -bool BluezBluetoothInterface::isPeriodicDiscoveryNameResolvingActive() const | |
217 | -{ | |
218 | - return boolReply("IsPeriodicDiscoveryNameResolving"); | |
219 | -} | |
220 | - | |
221 | -QStringList BluezBluetoothInterface::listRemoteDevices() const | |
222 | -{ | |
223 | - QStringList list = listReply("ListRemoteDevices"); | |
224 | - for (int i = 0; i < list.size(); i++) { | |
225 | - list[i] = ubi() + '/' + list[i]; | |
226 | - } | |
227 | - return list; | |
228 | -} | |
229 | - | |
230 | -QStringList BluezBluetoothInterface::listRecentRemoteDevices(const QDateTime &) const | |
231 | -{ | |
232 | - return listReply("ListRecentRemoteDevices"); | |
233 | -} | |
234 | - | |
235 | -void BluezBluetoothInterface::setMode(const Solid::Control::BluetoothInterface::Mode mode) | |
236 | -{ | |
237 | - QString modeString; | |
238 | - switch(mode) | |
239 | - { | |
240 | - case Solid::Control::BluetoothInterface::Off: | |
241 | - modeString = "off"; | |
242 | - break; | |
243 | - case Solid::Control::BluetoothInterface::Discoverable: | |
244 | - modeString = "discoverable"; | |
245 | - break; | |
246 | - case Solid::Control::BluetoothInterface::Connectable: | |
247 | - modeString = "connectable"; | |
248 | - break; | |
249 | - } | |
250 | - d->iface.call("SetMode", modeString); | |
251 | -} | |
252 | - | |
253 | -void BluezBluetoothInterface::setDiscoverableTimeout(int timeout) | |
254 | -{ | |
255 | - d->iface.call("SetDiscoverableTimeout", (uint)timeout); | |
256 | -} | |
257 | - | |
258 | -void BluezBluetoothInterface::setMinorClass(const QString &minorClass) | |
259 | -{ | |
260 | - d->iface.call("SetMinorClass", minorClass); | |
261 | -} | |
262 | - | |
263 | -void BluezBluetoothInterface::setName(const QString &name) | |
264 | -{ | |
265 | - d->iface.call("SetName", name); | |
266 | -} | |
267 | - | |
268 | -void BluezBluetoothInterface::discoverDevices() | |
269 | -{ | |
270 | - d->iface.call("DiscoverDevices"); | |
271 | -} | |
272 | - | |
273 | -void BluezBluetoothInterface::discoverDevicesWithoutNameResolving() | |
274 | -{ | |
275 | - d->iface.call("DiscoverDevicesWithoutNameResolving"); | |
276 | -} | |
277 | - | |
278 | -void BluezBluetoothInterface::cancelDiscovery() | |
279 | -{ | |
280 | - d->iface.call("CancelDiscovery"); | |
281 | -} | |
282 | - | |
283 | -void BluezBluetoothInterface::startPeriodicDiscovery() | |
284 | -{ | |
285 | - d->iface.call("StartPeriodicDiscovery"); | |
286 | -} | |
287 | - | |
288 | -void BluezBluetoothInterface::stopPeriodicDiscovery() | |
289 | -{ | |
290 | - d->iface.call("StopPeriodicDiscovery"); | |
291 | -} | |
292 | - | |
293 | -void BluezBluetoothInterface::setPeriodicDiscoveryNameResolving(bool nameResolving) | |
294 | -{ | |
295 | - d->iface.call("SetPeriodicDiscoveryNameResolving", nameResolving); | |
296 | -} | |
297 | - | |
298 | -void BluezBluetoothInterface::setTrusted(const QString& mac) | |
299 | -{ | |
300 | - d->iface.call("SetTrusted", mac); | |
301 | -} | |
302 | - | |
303 | -void BluezBluetoothInterface::removeTrust(const QString& mac) | |
304 | -{ | |
305 | - d->iface.call("RemoveTrust", mac); | |
306 | -} | |
307 | - | |
308 | -*/ | |
309 | - | |
310 | - | |
311 | - | |
312 | -/* | |
313 | - | |
314 | -void BluezBluetoothInterface::slotModeChanged(const Solid::Control::BluetoothInterface::Mode mode) | |
315 | -{ | |
316 | - emit modeChanged(mode); | |
317 | -} | |
318 | - | |
319 | -void BluezBluetoothInterface::slotDiscoverableTimeoutChanged(int timeout) | |
320 | -{ | |
321 | - emit discoverableTimeoutChanged(timeout); | |
322 | -} | |
323 | - | |
324 | -void BluezBluetoothInterface::slotMinorClassChanged(const QString &minorClass) | |
325 | -{ | |
326 | - emit minorClassChanged(minorClass); | |
327 | -} | |
328 | - | |
329 | -void BluezBluetoothInterface::slotNameChanged(const QString &name) | |
330 | -{ | |
331 | - emit nameChanged(name); | |
332 | -} | |
333 | - | |
334 | -void BluezBluetoothInterface::slotDiscoveryStarted() | |
335 | -{ | |
336 | - emit discoveryStarted(); | |
337 | -} | |
338 | - | |
339 | -void BluezBluetoothInterface::slotDiscoveryCompleted() | |
340 | -{ | |
341 | - emit discoveryCompleted(); | |
342 | -} | |
343 | - | |
344 | -void BluezBluetoothInterface::slotRemoteDeviceFound(const QString &address, uint deviceClass, short rssi) | |
345 | -{ | |
346 | - QString remoteubi = QString("%1/%2").arg(ubi()).arg(address); | |
347 | - emit remoteDeviceFound(remoteubi, deviceClass, rssi); | |
348 | -} | |
349 | - | |
350 | -void BluezBluetoothInterface::slotRemoteDeviceDisappeared(const QString &address) | |
351 | -{ | |
352 | - QString remoteubi = QString("%1/%2").arg(ubi()).arg(address); | |
353 | - emit remoteDeviceDisappeared(remoteubi); | |
354 | -} | |
355 | - | |
356 | -void BluezBluetoothInterface::slotRemoteNameUpdated(const QString &address, const QString& name) | |
357 | -{ | |
358 | - emit remoteNameUpdated(address,name); | |
359 | -} | |
360 | - | |
361 | -void BluezBluetoothInterface::slotRemoteDeviceConnected(const QString &address) | |
362 | -{ | |
363 | - emit remoteDeviceConnected(address); | |
364 | -} | |
365 | - | |
366 | -void BluezBluetoothInterface::slotRemoteDeviceDisconnected(const QString &address) | |
367 | -{ | |
368 | - emit remoteDeviceDisconnected(address); | |
369 | -} | |
370 | - | |
371 | -void BluezBluetoothInterface::slotTrustAdded(const QString &address) | |
372 | -{ | |
373 | - emit trustAdded(address); | |
374 | -} | |
375 | - | |
376 | -void BluezBluetoothInterface::slotTrustRemoved(const QString &address) | |
377 | -{ | |
378 | - emit trustRemoved(address); | |
379 | -} | |
380 | - | |
381 | -void BluezBluetoothInterface::slotBondingCreated(const QString &address) | |
382 | -{ | |
383 | - emit bondingCreated(address); | |
384 | -} | |
385 | - | |
386 | -void BluezBluetoothInterface::slotBondingRemoved(const QString &address) | |
387 | -{ | |
388 | - emit bondingRemoved(address); | |
389 | -} | |
390 | - | |
391 | -*/ | |
392 | - | |
393 | -void BluezBluetoothInterface::slotDeviceCreated(const QDBusObjectPath &path) | |
394 | -{ | |
395 | - kDebug() << "device created"; | |
396 | emit deviceCreated(path.path()); | |
397 | } | |
398 | ||
399 | @@ -523,7 +216,20 @@ | |
400 | return bluetoothInterface; | |
401 | } | |
402 | ||
403 | +QObject *BluezBluetoothInterface::createBluetoothInputDevice(const QString &ubi) | |
404 | +{ | |
405 | + BluezBluetoothInputDevice *bluetoothInputDev; | |
406 | + if (d->inputDevices.contains(ubi)) { | |
407 | + bluetoothInputDev = d->inputDevices[ubi]; | |
408 | + } else { | |
409 | + bluetoothInputDev = new BluezBluetoothInputDevice(ubi); | |
410 | + d->inputDevices.insert(ubi, bluetoothInputDev); | |
411 | + } | |
412 | + return bluetoothInputDev; | |
413 | +} | |
414 | ||
415 | + | |
416 | + | |
417 | /******************* DBus Calls *******************************/ | |
418 | ||
419 | QStringList BluezBluetoothInterface::listReply(const QString &method) const | |
420 | @@ -574,10 +280,13 @@ | |
421 | ||
422 | if (param.isEmpty()) | |
423 | reply = d->iface.call(method); | |
424 | - else | |
425 | + else { | |
426 | + qDebug() << "ObjectReply calling: " << method << " " << param; | |
427 | reply = d->iface.call(method, param); | |
428 | + } | |
429 | ||
430 | if (reply.isValid()) { | |
431 | + qDebug() << "ObjectReply Valid? "<< reply.value().path(); | |
432 | return reply.value(); | |
433 | } | |
434 | ||
435 | Index: bluez-bluetoothinterface.h | |
436 | =================================================================== | |
437 | --- bluez-bluetoothinterface.h (.../branches/KDE/4.2/kdebase/workspace/solid/bluez) (revision 912529) | |
438 | +++ solid/bluez/bluez-bluetoothinterface.h (.../trunk/KDE/kdebase/workspace/solid/bluez) (revision 912529) | |
439 | @@ -27,6 +27,7 @@ | |
440 | #include <QtDBus> | |
441 | #include <QDBusVariant> | |
442 | #include <QDBusObjectPath> | |
443 | +#include <QString> | |
444 | ||
445 | #include <solid/control/ifaces/bluetoothinterface.h> | |
446 | ||
447 | @@ -42,34 +43,11 @@ | |
448 | BluezBluetoothInterface(const QString & objectPath); | |
449 | virtual ~BluezBluetoothInterface(); | |
450 | QString ubi() const; | |
451 | -/* | |
452 | - QString address() const; | |
453 | - QString version() const; | |
454 | - QString revision() const; | |
455 | - QString manufacturer() const; | |
456 | - QString company() const; | |
457 | - Solid::Control::BluetoothInterface::Mode mode() const; | |
458 | - int discoverableTimeout() const; | |
459 | - bool isDiscoverable() const; | |
460 | - QStringList listConnections() const; | |
461 | - QString majorClass() const; | |
462 | - QStringList listAvailableMinorClasses() const; | |
463 | - QString minorClass() const; | |
464 | - QStringList serviceClasses() const; | |
465 | - QString name() const; | |
466 | - QStringList listBondings() const; | |
467 | - bool isPeriodicDiscoveryActive() const; | |
468 | - bool isPeriodicDiscoveryNameResolvingActive() const; | |
469 | - QStringList listRemoteDevices() const; | |
470 | - QStringList listRecentRemoteDevices(const QDateTime &) const; | |
471 | - QString getRemoteName(const QString &); | |
472 | - bool isTrusted(const QString &); | |
473 | - | |
474 | -*/ | |
475 | + | |
476 | QObject *createBluetoothRemoteDevice(const QString &); | |
477 | - | |
478 | - QString createDevice(const QString &) const; | |
479 | - QString createPairedDevice(const QString &,const QString &,const QString &) const; | |
480 | + QObject *createBluetoothInputDevice(const QString &); | |
481 | + void createDevice(const QString &) const; | |
482 | + void createPairedDevice(const QString &,const QString &,const QString &) const; | |
483 | QString findDevice(const QString &) const; | |
484 | QMap< QString, QVariant > getProperties() const; | |
485 | QStringList listDevices() const; | |
486 | @@ -87,36 +65,6 @@ | |
487 | void stopDiscovery(); | |
488 | void unregisterAgent(const QString &); | |
489 | ||
490 | -/* | |
491 | - void setMode(const Solid::Control::BluetoothInterface::Mode); | |
492 | - void setDiscoverableTimeout(int); | |
493 | - void setMinorClass(const QString &); | |
494 | - void setName(const QString &); | |
495 | - void discoverDevices(); | |
496 | - void discoverDevicesWithoutNameResolving(); | |
497 | - void cancelDiscovery(); | |
498 | - void startPeriodicDiscovery(); | |
499 | - void stopPeriodicDiscovery(); | |
500 | - void setPeriodicDiscoveryNameResolving(bool); | |
501 | - void setTrusted(const QString &); | |
502 | - void removeTrust(const QString &); | |
503 | - | |
504 | - void slotModeChanged(const Solid::Control::BluetoothInterface::Mode mode); | |
505 | - void slotDiscoverableTimeoutChanged(int timeout); | |
506 | - void slotMinorClassChanged(const QString &minor); | |
507 | - void slotNameChanged(const QString &name); | |
508 | - void slotDiscoveryStarted(); | |
509 | - void slotDiscoveryCompleted(); | |
510 | - void slotRemoteDeviceFound(const QString &ubi, uint deviceClass, short rssi); | |
511 | - void slotRemoteDeviceDisappeared(const QString &ubi); | |
512 | - void slotRemoteNameUpdated(const QString &, const QString &); | |
513 | - void slotRemoteDeviceConnected(const QString&); | |
514 | - void slotRemoteDeviceDisconnected(const QString&); | |
515 | - void slotTrustAdded(const QString&); | |
516 | - void slotTrustRemoved(const QString&); | |
517 | - void slotBondingCreated(const QString&); | |
518 | - void slotBondingRemoved(const QString&); | |
519 | -*/ | |
520 | void slotDeviceCreated(const QDBusObjectPath &); | |
521 | void slotDeviceDisappeared(const QString &); | |
522 | void slotDeviceFound(const QString &, const QMap< QString, QVariant > &); | |
523 | Index: bluez-bluetoothmanager.cpp | |
524 | =================================================================== | |
525 | --- bluez-bluetoothmanager.cpp (.../branches/KDE/4.2/kdebase/workspace/solid/bluez) (revision 912529) | |
526 | +++ solid/bluez/bluez-bluetoothmanager.cpp (.../trunk/KDE/kdebase/workspace/solid/bluez) (revision 912529) | |
527 | @@ -104,6 +104,7 @@ | |
528 | ||
529 | QString BluezBluetoothManager::defaultInterface() const | |
530 | { | |
531 | + kDebug() << "Calling Backend Default Interface"; | |
532 | QDBusReply< QDBusObjectPath > path = d->manager.call("DefaultAdapter"); | |
533 | if (!path.isValid()) | |
534 | return QString(); | |
535 | @@ -132,6 +133,16 @@ | |
536 | return bluetoothInterface; | |
537 | } | |
538 | ||
539 | +void BluezBluetoothManager::removeInterface(const QString& ubi) | |
540 | +{ | |
541 | + | |
542 | + if (d->interfaces.contains(ubi)) { | |
543 | + kDebug() << "Removing Interface" << ubi; | |
544 | + BluezBluetoothInterface * bluetoothInterface = d->interfaces.take(ubi); | |
545 | + bluetoothInterface = 0; | |
546 | + } | |
547 | +} | |
548 | + | |
549 | /* | |
550 | KJob *BluezBluetoothManager::setupInputDevice(const QString &ubi) | |
551 | { | |
552 | Index: bluez-bluetoothremotedevice.cpp | |
553 | =================================================================== | |
554 | --- bluez-bluetoothremotedevice.cpp (.../branches/KDE/4.2/kdebase/workspace/solid/bluez) (revision 912529) | |
555 | +++ solid/bluez/bluez-bluetoothremotedevice.cpp (.../trunk/KDE/kdebase/workspace/solid/bluez) (revision 912529) | |
556 | @@ -42,6 +42,7 @@ | |
557 | m_adapter = m_objectPath.left(objectPath.size() - 18); | |
558 | m_address = m_objectPath.right(17); | |
559 | ||
560 | + kdDebug() << "Connecting to ObjectPath: " << objectPath; | |
561 | ||
562 | device = new QDBusInterface("org.bluez", objectPath, | |
563 | "org.bluez.Device", QDBusConnection::systemBus()); | |
564 | @@ -79,7 +80,7 @@ | |
565 | ||
566 | void BluezBluetoothRemoteDevice::setProperty(const QString &name, const QVariant &value) | |
567 | { | |
568 | - device->call("SetProperty",name,value); | |
569 | + device->call("SetProperty",name,qVariantFromValue(QDBusVariant(value))); | |
570 | } | |
571 | ||
572 | void BluezBluetoothRemoteDevice::discoverServices(const QString& pattern) const | |
573 | Index: bluez-bluetoothmanager.h | |
574 | =================================================================== | |
575 | --- bluez-bluetoothmanager.h (.../branches/KDE/4.2/kdebase/workspace/solid/bluez) (revision 912529) | |
576 | +++ solid/bluez/bluez-bluetoothmanager.h (.../trunk/KDE/kdebase/workspace/solid/bluez) (revision 912529) | |
577 | @@ -43,6 +43,7 @@ | |
578 | virtual ~BluezBluetoothManager(); | |
579 | QStringList bluetoothInterfaces() const; | |
580 | QObject * createInterface(const QString &); | |
581 | + void removeInterface(const QString& ubi); | |
582 | // QStringList bluetoothInputDevices() const; | |
583 | QString defaultInterface() const; | |
584 | QString findInterface(const QString &) const; | |
585 | diff -Nur -x '[^b][^l]*' -x .svn 4_2libsControl/bluetoothinputdevice.cpp kdebase/workspace/libs/solid/control/bluetoothinputdevice.cpp | |
586 | --- 4_2libsControl/bluetoothinputdevice.cpp 2009-01-17 17:51:33.000000000 +0100 | |
587 | +++ libs/solid/control/bluetoothinputdevice.cpp 2009-01-14 21:06:47.000000000 +0100 | |
588 | @@ -91,8 +91,8 @@ | |
589 | FrontendObjectPrivate::setBackendObject(object); | |
590 | ||
591 | if (object) { | |
592 | - QObject::connect(object, SIGNAL(propertyChanged(QString,QVariant)), | |
593 | - parent(), SIGNAL(propertyChanged(QString,QVariant))); | |
594 | + QObject::connect(object, SIGNAL(propertyChanged(const QString&,const QVariant&)), | |
595 | + parent(), SIGNAL(propertyChanged(const QString,const QVariant&))); | |
596 | } | |
597 | } | |
598 | ||
599 | diff -Nur -x '[^b][^l]*' -x .svn 4_2libsControl/bluetoothinterface.cpp kdebase/workspace/libs/solid/control/bluetoothinterface.cpp | |
600 | --- 4_2libsControl/bluetoothinterface.cpp 2009-01-17 17:51:33.000000000 +0100 | |
601 | +++ libs/solid/control/bluetoothinterface.cpp 2009-01-16 12:11:03.000000000 +0100 | |
602 | @@ -25,7 +25,7 @@ | |
603 | #include <QStringList> | |
604 | #include <QVariant> | |
605 | ||
606 | -#include <kdebug.h> | |
607 | +#include <KDebug> | |
608 | ||
609 | #include "ifaces/bluetoothinterface.h" | |
610 | ||
611 | @@ -49,9 +49,12 @@ | |
612 | void setBackendObject(QObject *object); | |
613 | ||
614 | QPair<BluetoothRemoteDevice *, Ifaces::BluetoothRemoteDevice *> findRegisteredBluetoothRemoteDevice(const QString &ubi) const; | |
615 | + QPair<BluetoothInputDevice *, Ifaces::BluetoothInputDevice *> findRegisteredBluetoothInputDevice(const QString &ubi) const; | |
616 | ||
617 | mutable QMap<QString, QPair<BluetoothRemoteDevice *, Ifaces::BluetoothRemoteDevice *> > remoteDeviceMap; | |
618 | + mutable QMap<QString, QPair<BluetoothInputDevice *, Ifaces::BluetoothInputDevice *> > inputDeviceMap; | |
619 | mutable BluetoothRemoteDevice invalidDevice; | |
620 | + mutable BluetoothInputDevice invalidInputDevice; | |
621 | }; | |
622 | } | |
623 | } | |
624 | @@ -65,30 +68,39 @@ | |
625 | { | |
626 | const BluetoothInterface &device = BluetoothManager::self().findBluetoothInterface(ubi); | |
627 | d->setBackendObject(device.d->backendObject()); | |
628 | + QObject::connect(d->backendObject(), SIGNAL(deviceCreated(const QString &)),this, SLOT(slotDeviceCreated(const QString &))); | |
629 | } | |
630 | ||
631 | Solid::Control::BluetoothInterface::BluetoothInterface(QObject *backendObject) | |
632 | : QObject(), d(new BluetoothInterfacePrivate(this)) | |
633 | { | |
634 | d->setBackendObject(backendObject); | |
635 | + QObject::connect(d->backendObject(), SIGNAL(deviceCreated(const QString &)),this, SLOT(slotDeviceCreated(const QString &))); | |
636 | } | |
637 | ||
638 | Solid::Control::BluetoothInterface::BluetoothInterface(const BluetoothInterface &device) | |
639 | : QObject(), d(new BluetoothInterfacePrivate(this)) | |
640 | { | |
641 | d->setBackendObject(device.d->backendObject()); | |
642 | + QObject::connect(d->backendObject(), SIGNAL(deviceCreated(const QString &)),this, SLOT(slotDeviceCreated(const QString &))); | |
643 | } | |
644 | ||
645 | Solid::Control::BluetoothInterface::~BluetoothInterface() | |
646 | { | |
647 | // Delete all the interfaces, they are now outdated | |
648 | typedef QPair<BluetoothRemoteDevice *, Ifaces::BluetoothRemoteDevice *> BluetoothRemoteDeviceIfacePair; | |
649 | + typedef QPair<BluetoothInputDevice *, Ifaces::BluetoothInputDevice *> BluetoothInputDeviceIfacePair; | |
650 | ||
651 | // Delete all the devices, they are now outdated | |
652 | - foreach (const BluetoothRemoteDeviceIfacePair &pair, d->remoteDeviceMap) { | |
653 | + foreach (const BluetoothRemoteDeviceIfacePair &pair, d->remoteDeviceMap.values()) { | |
654 | delete pair.first; | |
655 | delete pair.second; | |
656 | } | |
657 | + foreach (const BluetoothInputDeviceIfacePair &pair, d->inputDeviceMap.values()) { | |
658 | + delete pair.first; | |
659 | + delete pair.second; | |
660 | + } | |
661 | + | |
662 | } | |
663 | ||
664 | Solid::Control::BluetoothInterface &Solid::Control::BluetoothInterface::operator=(const Solid::Control::BluetoothInterface & dev) | |
665 | @@ -108,9 +120,12 @@ | |
666 | SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), cancelDeviceCreation(address)); | |
667 | } | |
668 | ||
669 | -QString Solid::Control::BluetoothInterface::createPairedDevice(const QString &address,const QString &adapterPath, const QString &capab) const | |
670 | +void Solid::Control::BluetoothInterface::createPairedDevice(const QString &address,const QString &adapterPath, const QString &capab) const | |
671 | { | |
672 | - return_SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), QString(), createPairedDevice(address,adapterPath,capab)); | |
673 | + Ifaces::BluetoothInterface *backend = qobject_cast<Ifaces::BluetoothInterface *>(d->backendObject()); | |
674 | + if (backend == 0) | |
675 | + return; | |
676 | + backend->createPairedDevice(address,adapterPath,capab); | |
677 | } | |
678 | ||
679 | QMap<QString, QVariant> Solid::Control::BluetoothInterface::getProperties() const | |
680 | @@ -137,7 +152,7 @@ | |
681 | ||
682 | Solid::Control::BluetoothRemoteDeviceList list; | |
683 | foreach (const QString& ubi,ubis) { | |
684 | - BluetoothRemoteDevice remoteDevice = findBluetoothRemoteDevice(ubi); | |
685 | + BluetoothRemoteDevice* remoteDevice = findBluetoothRemoteDeviceUBI(ubi); | |
686 | list.append(remoteDevice); | |
687 | } | |
688 | return list; | |
689 | @@ -184,13 +199,13 @@ | |
690 | } | |
691 | ||
692 | ||
693 | -Solid::Control::BluetoothRemoteDevice Solid::Control::BluetoothInterface::findBluetoothRemoteDevice(const QString &address) const | |
694 | +Solid::Control::BluetoothRemoteDevice Solid::Control::BluetoothInterface::findBluetoothRemoteDeviceAddr(const QString &address) const | |
695 | { | |
696 | Ifaces::BluetoothInterface *backend = qobject_cast<Ifaces::BluetoothInterface *>(d->backendObject()); | |
697 | if (backend == 0) | |
698 | return d->invalidDevice; | |
699 | ||
700 | - const QString ubi = backend->findDevice(address); | |
701 | + const QString ubi = getBluetoothRemoteDeviceUBI(address); | |
702 | ||
703 | QPair<BluetoothRemoteDevice *, Ifaces::BluetoothRemoteDevice *> pair = d->findRegisteredBluetoothRemoteDevice(ubi); | |
704 | ||
705 | @@ -201,18 +216,56 @@ | |
706 | } | |
707 | } | |
708 | ||
709 | -Solid::Control::BluetoothRemoteDevice * Solid::Control::BluetoothInterface::createBluetoothRemoteDevice(const QString &address) | |
710 | + | |
711 | +const QString Solid::Control::BluetoothInterface::getBluetoothRemoteDeviceUBI(const QString &address) const | |
712 | { | |
713 | Ifaces::BluetoothInterface *backend = qobject_cast<Ifaces::BluetoothInterface *>(d->backendObject()); | |
714 | if (backend == 0) | |
715 | - return 0; | |
716 | + return ""; | |
717 | + | |
718 | + const QString ubi = backend->findDevice(address); | |
719 | + return ubi; | |
720 | +} | |
721 | ||
722 | - const QString ubi = backend->createDevice(address); | |
723 | ||
724 | +void Solid::Control::BluetoothInterface::createBluetoothRemoteDevice(const QString &address) | |
725 | +{ | |
726 | + Ifaces::BluetoothInterface *backend = qobject_cast<Ifaces::BluetoothInterface *>(d->backendObject()); | |
727 | + if (backend == 0) | |
728 | + return; | |
729 | + backend->createDevice(address); | |
730 | +} | |
731 | + | |
732 | + | |
733 | +Solid::Control::BluetoothRemoteDevice* Solid::Control::BluetoothInterface::findBluetoothRemoteDeviceUBI(const QString &ubi) const | |
734 | +{ | |
735 | QPair<BluetoothRemoteDevice *, Ifaces::BluetoothRemoteDevice *> pair = d->findRegisteredBluetoothRemoteDevice(ubi); | |
736 | return pair.first; | |
737 | } | |
738 | ||
739 | +Solid::Control::BluetoothInputDevice* Solid::Control::BluetoothInterface::findBluetoothInputDeviceUBI(const QString &ubi) const | |
740 | +{ | |
741 | + QPair<BluetoothInputDevice *, Ifaces::BluetoothInputDevice *> pair = d->findRegisteredBluetoothInputDevice(ubi); | |
742 | + return pair.first; | |
743 | +} | |
744 | + | |
745 | +void Solid::Control::BluetoothInterface::slotDeviceCreated(const QString& ubi) | |
746 | +{ | |
747 | + | |
748 | + Ifaces::BluetoothInterface *backend = qobject_cast<Ifaces::BluetoothInterface *>(d->backendObject()); | |
749 | + Ifaces::BluetoothRemoteDevice *iface = 0; | |
750 | + | |
751 | + if (backend != 0) { | |
752 | + iface = qobject_cast<Ifaces::BluetoothRemoteDevice *>(backend->createBluetoothRemoteDevice(ubi)); | |
753 | + } | |
754 | + | |
755 | + if (iface != 0) { | |
756 | + BluetoothRemoteDevice *device = new BluetoothRemoteDevice(iface); | |
757 | + | |
758 | + QPair<BluetoothRemoteDevice *, Ifaces::BluetoothRemoteDevice *> pair(device, iface); | |
759 | + d->remoteDeviceMap[ubi] = pair; | |
760 | + } | |
761 | +} | |
762 | ||
763 | QString Solid::Control::BluetoothInterface::address() const | |
764 | { | |
765 | @@ -492,8 +545,6 @@ | |
766 | QObject::connect(object, SIGNAL(propertyChanged(const QString &,const QVariant &)), | |
767 | parent(), SIGNAL(propertyChanged(const QString &, const QVariant &))); | |
768 | ||
769 | - | |
770 | - | |
771 | } | |
772 | } | |
773 | ||
774 | @@ -521,6 +572,32 @@ | |
775 | } | |
776 | ||
777 | } | |
778 | +} | |
779 | + | |
780 | +QPair<Solid::Control::BluetoothInputDevice *, Solid::Control::Ifaces::BluetoothInputDevice *> Solid::Control::BluetoothInterfacePrivate::findRegisteredBluetoothInputDevice(const QString &ubi) const | |
781 | +{ | |
782 | + if (inputDeviceMap.contains(ubi)) { | |
783 | + return inputDeviceMap[ubi]; | |
784 | + } else { | |
785 | + Ifaces::BluetoothInterface *backend = qobject_cast<Ifaces::BluetoothInterface *>(backendObject()); | |
786 | + Ifaces::BluetoothInputDevice *iface = 0; | |
787 | + | |
788 | + if (backend != 0) { | |
789 | + iface = qobject_cast<Ifaces::BluetoothInputDevice *>(backend->createBluetoothInputDevice(ubi)); | |
790 | + } | |
791 | + | |
792 | + if (iface != 0) { | |
793 | + BluetoothInputDevice *device = new BluetoothInputDevice(iface); | |
794 | + | |
795 | + QPair<BluetoothInputDevice *, Ifaces::BluetoothInputDevice *> pair(device, iface); | |
796 | + inputDeviceMap[ubi] = pair; | |
797 | + | |
798 | + return pair; | |
799 | + } else { | |
800 | + return QPair<BluetoothInputDevice *, Ifaces::BluetoothInputDevice *>(0, 0); | |
801 | + } | |
802 | + | |
803 | + } | |
804 | } | |
805 | ||
806 | #include "bluetoothinterface.moc" | |
807 | diff -Nur -x '[^b][^l]*' -x .svn 4_2libsControl/bluetoothinterface.h kdebase/workspace/libs/solid/control/bluetoothinterface.h | |
808 | --- 4_2libsControl/bluetoothinterface.h 2009-01-17 17:51:33.000000000 +0100 | |
809 | +++ libs/solid/control/bluetoothinterface.h 2009-01-14 14:17:14.000000000 +0100 | |
810 | @@ -28,7 +28,9 @@ | |
811 | #include <QtCore/QMap> | |
812 | ||
813 | #include "bluetoothremotedevice.h" | |
814 | +#include "bluetoothinputdevice.h" | |
815 | #include "ifaces/bluetoothremotedevice.h" | |
816 | +#include "ifaces/bluetoothinputdevice.h" | |
817 | ||
818 | ||
819 | ||
820 | @@ -37,7 +39,7 @@ | |
821 | namespace Control | |
822 | { | |
823 | class BluetoothRemoteDevice; | |
824 | -typedef QList<BluetoothRemoteDevice> BluetoothRemoteDeviceList; | |
825 | +typedef QList<BluetoothRemoteDevice*> BluetoothRemoteDeviceList; | |
826 | class BluetoothInterfacePrivate; | |
827 | ||
828 | /** | |
829 | @@ -115,7 +117,8 @@ | |
830 | * @param ubi the identifier of the bluetooth device to instantiate | |
831 | * @returns a bluetooth object, if a bluetooth device having the given UBI, for this interface exists, 0 otherwise | |
832 | */ | |
833 | - Solid::Control::BluetoothRemoteDevice* createBluetoothRemoteDevice(const QString &address); | |
834 | + //Solid::Control::BluetoothRemoteDevice* createBluetoothRemoteDevice(const QString &address); | |
835 | + void createBluetoothRemoteDevice(const QString &address); | |
836 | ||
837 | /** | |
838 | * Finds a BluetoothRemoteDevice object given its UBI. | |
839 | @@ -123,7 +126,13 @@ | |
840 | * @param ubi the identifier of the bluetooth remote device to find from this bluetooth interface | |
841 | * @returns a valid BluetoothRemoteDevice object if a remote device having the given UBI for this interface exists, an invalid BluetoothRemoteDevice object otherwise. | |
842 | */ | |
843 | - Solid::Control::BluetoothRemoteDevice findBluetoothRemoteDevice(const QString &address) const; | |
844 | + const QString getBluetoothRemoteDeviceUBI(const QString &address) const; | |
845 | + | |
846 | + Solid::Control::BluetoothRemoteDevice findBluetoothRemoteDeviceAddr(const QString &addr) const; | |
847 | + | |
848 | + Solid::Control::BluetoothRemoteDevice* findBluetoothRemoteDeviceUBI(const QString &ubi) const; | |
849 | + | |
850 | + Solid::Control::BluetoothInputDevice* findBluetoothInputDeviceUBI(const QString &ubi) const; | |
851 | ||
852 | /** | |
853 | * Retrieves the MAC address of the bluetooth interface/adapter. | |
854 | @@ -296,7 +305,7 @@ | |
855 | // bool isTrusted(const QString &); | |
856 | ||
857 | ||
858 | - QString createPairedDevice(const QString &, const QString &, const QString &) const; | |
859 | + void createPairedDevice(const QString &, const QString &, const QString &) const; | |
860 | ||
861 | QMap< QString, QVariant > getProperties() const; | |
862 | ||
863 | @@ -557,6 +566,9 @@ | |
864 | QVariant getProperty(const QString&) const; | |
865 | BluetoothInterfacePrivate * const d; | |
866 | ||
867 | +private slots: | |
868 | + void slotDeviceCreated(const QString& ubi); | |
869 | + | |
870 | }; | |
871 | ||
872 | } //Control | |
873 | diff -Nur -x '[^b][^l]*' -x .svn 4_2libsControl/bluetoothmanager.cpp kdebase/workspace/libs/solid/control/bluetoothmanager.cpp | |
874 | --- 4_2libsControl/bluetoothmanager.cpp 2009-01-17 17:51:33.000000000 +0100 | |
875 | +++ libs/solid/control/bluetoothmanager.cpp 2009-01-16 13:17:33.000000000 +0100 | |
876 | @@ -58,6 +58,7 @@ | |
877 | ||
878 | void _k_interfaceAdded(const QString &ubi); | |
879 | void _k_interfaceRemoved(const QString &ubi); | |
880 | + void _k_defaultInterfaceChanged(const QString &ubi); | |
881 | void _k_interfaceDestroyed(QObject *object); | |
882 | /* | |
883 | void _k_inputDeviceCreated(const QString &ubi); | |
884 | @@ -95,7 +96,7 @@ | |
885 | typedef QPair<BluetoothInterface *, Ifaces::BluetoothInterface *> BluetoothInterfaceIfacePair; | |
886 | ||
887 | // Delete all the devices, they are now outdated | |
888 | - foreach (const BluetoothInterfaceIfacePair &pair, d->bluetoothInterfaceMap) { | |
889 | + foreach (const BluetoothInterfaceIfacePair &pair, d->bluetoothInterfaceMap.values()) { | |
890 | delete pair.first; | |
891 | delete pair.second; | |
892 | } | |
893 | @@ -110,6 +111,8 @@ | |
894 | ||
895 | if (backend == 0) return list; | |
896 | ||
897 | + kDebug() << "UBI List " << ubiList; | |
898 | + | |
899 | foreach (const QString &ubi, ubiList) { | |
900 | QPair<BluetoothInterface *, Ifaces::BluetoothInterface *> pair = d->findRegisteredBluetoothInterface(ubi); | |
901 | ||
902 | @@ -239,7 +242,9 @@ | |
903 | */ | |
904 | void Solid::Control::BluetoothManagerPrivate::_k_interfaceAdded(const QString &ubi) | |
905 | { | |
906 | - QPair<BluetoothInterface *, Ifaces::BluetoothInterface *> pair = bluetoothInterfaceMap.take(ubi); | |
907 | + kDebug() << "Size of InterfaceList " << bluetoothInterfaceMap.size(); | |
908 | + QPair<BluetoothInterface *, Ifaces::BluetoothInterface *> pair = findRegisteredBluetoothInterface(ubi); | |
909 | +/* QPair<BluetoothInterface *, Ifaces::BluetoothInterface *> pair = bluetoothInterfaceMap.take(ubi); | |
910 | ||
911 | if (pair.first != 0) { | |
912 | // Oops, I'm not sure it should happen... | |
913 | @@ -247,7 +252,7 @@ | |
914 | ||
915 | delete pair.first; | |
916 | delete pair.second; | |
917 | - } | |
918 | + }*/ | |
919 | ||
920 | emit q->interfaceAdded(ubi); | |
921 | } | |
922 | @@ -261,11 +266,19 @@ | |
923 | delete pair.second; | |
924 | } | |
925 | ||
926 | + Ifaces::BluetoothManager *backend = qobject_cast<Ifaces::BluetoothManager *>(managerBackend()); | |
927 | + backend->removeInterface(ubi); | |
928 | emit q->interfaceRemoved(ubi); | |
929 | } | |
930 | ||
931 | +void Solid::Control::BluetoothManagerPrivate::_k_defaultInterfaceChanged(const QString &ubi) | |
932 | +{ | |
933 | + emit q->defaultInterfaceChanged(ubi); | |
934 | +} | |
935 | + | |
936 | void Solid::Control::BluetoothManagerPrivate::_k_interfaceDestroyed(QObject *object) | |
937 | { | |
938 | + kDebug() << "Interface detroyed"; | |
939 | Ifaces::BluetoothInterface *device = qobject_cast<Ifaces::BluetoothInterface *>(object); | |
940 | ||
941 | if (device != 0) { | |
942 | @@ -323,6 +336,9 @@ | |
943 | q, SLOT(_k_interfaceAdded(const QString &))); | |
944 | QObject::connect(newBackend, SIGNAL(interfaceRemoved(const QString &)), | |
945 | q, SLOT(_k_interfaceRemoved(const QString &))); | |
946 | + QObject::connect(newBackend, SIGNAL(defaultInterfaceChanged(const QString &)), | |
947 | + q, SLOT(_k_defaultInterfaceChanged(const QString &))); | |
948 | + | |
949 | /* | |
950 | QObject::connect(newBackend, SIGNAL(inputDeviceCreated(const QString &)), | |
951 | q, SLOT(_k_inputDeviceCreated(const QString &))); | |
952 | @@ -334,17 +350,22 @@ | |
953 | ||
954 | QPair<Solid::Control::BluetoothInterface *, Solid::Control::Ifaces::BluetoothInterface *> Solid::Control::BluetoothManagerPrivate::findRegisteredBluetoothInterface(const QString &ubi) const | |
955 | { | |
956 | + | |
957 | + kDebug() << "findRegisteredBluetoothInterface " << ubi; | |
958 | if (bluetoothInterfaceMap.contains(ubi)) { | |
959 | return bluetoothInterfaceMap[ubi]; | |
960 | } else { | |
961 | + kDebug() << "Creating New Interface " << ubi; | |
962 | Ifaces::BluetoothManager *backend = qobject_cast<Ifaces::BluetoothManager *>(managerBackend()); | |
963 | Ifaces::BluetoothInterface *iface = 0; | |
964 | ||
965 | if (backend != 0) { | |
966 | + kDebug() << "Calling Backend to Creating New Interface " << ubi; | |
967 | iface = qobject_cast<Ifaces::BluetoothInterface *>(backend->createInterface(ubi)); | |
968 | } | |
969 | ||
970 | if (iface != 0) { | |
971 | + kDebug() << "BackendIface created "; | |
972 | BluetoothInterface *device = new BluetoothInterface(iface); | |
973 | QPair<BluetoothInterface *, Ifaces::BluetoothInterface *> pair(device, iface); | |
974 | QObject::connect(iface, SIGNAL(destroyed(QObject *)), | |
975 | diff -Nur -x '[^b][^l]*' -x .svn 4_2libsControl/bluetoothmanager.h kdebase/workspace/libs/solid/control/bluetoothmanager.h | |
976 | --- 4_2libsControl/bluetoothmanager.h 2009-01-17 17:51:33.000000000 +0100 | |
977 | +++ libs/solid/control/bluetoothmanager.h 2009-01-16 13:17:33.000000000 +0100 | |
978 | @@ -188,6 +188,7 @@ | |
979 | ||
980 | Q_PRIVATE_SLOT(d, void _k_interfaceAdded(const QString &)) | |
981 | Q_PRIVATE_SLOT(d, void _k_interfaceRemoved(const QString &)) | |
982 | + Q_PRIVATE_SLOT(d, void _k_defaultInterfaceChanged(const QString &)) | |
983 | Q_PRIVATE_SLOT(d, void _k_interfaceDestroyed(QObject *)) | |
984 | /* | |
985 | Q_PRIVATE_SLOT(d, void _k_inputDeviceCreated(const QString &)) | |
986 | diff -Nur -x '[^b][^l]*' -x .svn 4_2libsControl/bluetoothremotedevice.cpp kdebase/workspace/libs/solid/control/bluetoothremotedevice.cpp | |
987 | --- 4_2libsControl/bluetoothremotedevice.cpp 2009-01-17 17:51:33.000000000 +0100 | |
988 | +++ libs/solid/control/bluetoothremotedevice.cpp 2009-01-13 14:53:39.000000000 +0100 | |
989 | @@ -88,6 +88,15 @@ | |
990 | return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), (QMap< QString,QVariant >()), getProperties()); | |
991 | } | |
992 | ||
993 | +QVariant Solid::Control::BluetoothRemoteDevice::getProperty(const QString &key) | |
994 | +{ | |
995 | + QMap<QString, QVariant> props = getProperties(); | |
996 | + if (props.contains(key)) | |
997 | + return props[key]; | |
998 | + else | |
999 | + return QVariant(); | |
1000 | +} | |
1001 | + | |
1002 | QStringList Solid::Control::BluetoothRemoteDevice::listNodes() | |
1003 | { | |
1004 | Q_D(const BluetoothRemoteDevice); | |
1005 | @@ -113,14 +122,65 @@ | |
1006 | } | |
1007 | ||
1008 | ||
1009 | +QString Solid::Control::BluetoothRemoteDevice::address() | |
1010 | +{ | |
1011 | + QVariant var = getProperty("Address"); | |
1012 | + | |
1013 | + if (var.isValid()) | |
1014 | + return var.value<QString>(); | |
1015 | + else | |
1016 | + return QString(); | |
1017 | ||
1018 | -/* | |
1019 | -QString Solid::Control::BluetoothRemoteDevice::address() const | |
1020 | +// Q_D(const BluetoothRemoteDevice); | |
1021 | +// return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), address()); | |
1022 | +} | |
1023 | + | |
1024 | +bool Solid::Control::BluetoothRemoteDevice::isTrusted() | |
1025 | { | |
1026 | - Q_D(const BluetoothRemoteDevice); | |
1027 | - return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), address()); | |
1028 | + QVariant var = getProperty("Trusted"); | |
1029 | + | |
1030 | + if (var.isValid()) | |
1031 | + return var.value<bool>(); | |
1032 | + else | |
1033 | + return false; | |
1034 | +} | |
1035 | + | |
1036 | +void Solid::Control::BluetoothRemoteDevice::setTrusted(bool trust) | |
1037 | +{ | |
1038 | + setProperty("Trusted",QVariant(trust)); | |
1039 | } | |
1040 | ||
1041 | +QString Solid::Control::BluetoothRemoteDevice::icon() | |
1042 | +{ | |
1043 | + QVariant var = getProperty("Icon"); | |
1044 | + | |
1045 | + if (var.isValid()) | |
1046 | + return var.value<QString>(); | |
1047 | + else | |
1048 | + return ""; | |
1049 | +} | |
1050 | + | |
1051 | +QStringList Solid::Control::BluetoothRemoteDevice::uuids() | |
1052 | +{ | |
1053 | + QVariant var = getProperty("UUIDs"); | |
1054 | + | |
1055 | + if (var.isValid()) | |
1056 | + return var.value<QStringList>(); | |
1057 | + else | |
1058 | + return QStringList(); | |
1059 | +} | |
1060 | + | |
1061 | +bool Solid::Control::BluetoothRemoteDevice::isConnected() | |
1062 | +{ | |
1063 | + QVariant var = getProperty("Connected"); | |
1064 | + | |
1065 | + if (var.isValid()) | |
1066 | + return var.value<bool>(); | |
1067 | + else | |
1068 | + return false; | |
1069 | +} | |
1070 | + | |
1071 | +/* | |
1072 | bool Solid::Control::BluetoothRemoteDevice::isConnected() const | |
1073 | { | |
1074 | Q_D(const BluetoothRemoteDevice); | |
1075 | @@ -168,12 +228,21 @@ | |
1076 | Q_D(const BluetoothRemoteDevice); | |
1077 | return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QStringList(), serviceClasses()); | |
1078 | } | |
1079 | -QString Solid::Control::BluetoothRemoteDevice::name() const | |
1080 | +*/ | |
1081 | + | |
1082 | +QString Solid::Control::BluetoothRemoteDevice::name() | |
1083 | { | |
1084 | - Q_D(const BluetoothRemoteDevice); | |
1085 | - return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), name()); | |
1086 | + QVariant var = getProperty("Name"); | |
1087 | + | |
1088 | + if (var.isValid()) | |
1089 | + return var.value<QString>(); | |
1090 | + else | |
1091 | + return QString(); | |
1092 | + | |
1093 | +// return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), name()); | |
1094 | } | |
1095 | ||
1096 | +/* | |
1097 | QString Solid::Control::BluetoothRemoteDevice::alias() const | |
1098 | { | |
1099 | Q_D(const BluetoothRemoteDevice); | |
1100 | diff -Nur -x '[^b][^l]*' -x .svn 4_2libsControl/bluetoothremotedevice.h kdebase/workspace/libs/solid/control/bluetoothremotedevice.h | |
1101 | --- 4_2libsControl/bluetoothremotedevice.h 2009-01-17 17:51:33.000000000 +0100 | |
1102 | +++ libs/solid/control/bluetoothremotedevice.h 2009-01-13 14:53:39.000000000 +0100 | |
1103 | @@ -82,11 +82,46 @@ | |
1104 | bool operator==(const BluetoothRemoteDevice & other) const; | |
1105 | ||
1106 | /** | |
1107 | - * The UBI of the remote de device. | |
1108 | + * The UBI of the remote device. | |
1109 | */ | |
1110 | QString ubi() const; | |
1111 | ||
1112 | /** | |
1113 | + * The address of the remote device. | |
1114 | + */ | |
1115 | + QString address(); | |
1116 | + | |
1117 | + /** | |
1118 | + * The name of the remote device. | |
1119 | + */ | |
1120 | + QString name(); | |
1121 | + | |
1122 | + /** | |
1123 | + * The icon of the remote device. | |
1124 | + */ | |
1125 | + QString icon(); | |
1126 | + | |
1127 | + /** | |
1128 | + * The Trust state of the remote device. | |
1129 | + */ | |
1130 | + bool isTrusted(); | |
1131 | + | |
1132 | + /** | |
1133 | + * Set the Trust state of the remote device. | |
1134 | + */ | |
1135 | + void setTrusted(bool); | |
1136 | + | |
1137 | + /** | |
1138 | + * Returns the service uuids of the remote device. | |
1139 | + */ | |
1140 | + QStringList uuids(); | |
1141 | + | |
1142 | + /** | |
1143 | + * The Connection state of the remote device. | |
1144 | + */ | |
1145 | + bool isConnected(); | |
1146 | + | |
1147 | + /** | |
1148 | * Retrieve all properties from the remote device. | |
1149 | * | |
1150 | * @returns a hash of named properties | |
1151 | @@ -157,6 +192,9 @@ | |
1152 | ||
1153 | private: | |
1154 | Q_PRIVATE_SLOT(d_func(), void _k_destroyed(QObject *)) | |
1155 | + | |
1156 | + | |
1157 | + QVariant getProperty(const QString &key); | |
1158 | }; | |
1159 | ||
1160 | } //Control | |
1161 | diff -Nur -x '[^b][^l]*' -x .svn 4_2libsControl/ifaces/bluetoothinterface.h kdebase/workspace/libs/solid/control/ifaces/bluetoothinterface.h | |
1162 | --- 4_2libsControl/ifaces/bluetoothinterface.h 2009-01-17 17:51:32.000000000 +0100 | |
1163 | +++ libs/solid/control/ifaces/bluetoothinterface.h 2009-01-16 17:16:55.000000000 +0100 | |
1164 | @@ -240,7 +240,7 @@ | |
1165 | */ | |
1166 | ||
1167 | ||
1168 | - virtual QString createPairedDevice(const QString &, const QString &, const QString &) const = 0; | |
1169 | + virtual void createPairedDevice(const QString &, const QString &, const QString &) const = 0; | |
1170 | ||
1171 | virtual QMap< QString, QVariant > getProperties() const = 0; | |
1172 | ||
1173 | @@ -248,7 +248,8 @@ | |
1174 | ||
1175 | virtual QString findDevice(const QString &) const = 0; | |
1176 | ||
1177 | - virtual QString createDevice(const QString &) const = 0; | |
1178 | + //virtual QString createDevice(const QString &) const = 0; | |
1179 | + virtual void createDevice(const QString &) const = 0; | |
1180 | ||
1181 | ||
1182 | ||
1183 | @@ -320,7 +321,9 @@ | |
1184 | * @param ubi the identifier of the bluetooth remote device instantiated | |
1185 | * @returns a new BluetoothRemoteDevice object if there's a device having the given UBI, 0 otherwise | |
1186 | */ | |
1187 | - virtual QObject *createBluetoothRemoteDevice(const QString &address) = 0; | |
1188 | + virtual QObject *createBluetoothRemoteDevice(const QString &ubi) = 0; | |
1189 | + | |
1190 | + virtual QObject *createBluetoothInputDevice(const QString &ubi) = 0; | |
1191 | ||
1192 | /** | |
1193 | * Marks the device as trusted. | |
1194 | diff -Nur -x '[^b][^l]*' -x .svn 4_2libsControl/ifaces/bluetoothmanager.h kdebase/workspace/libs/solid/control/ifaces/bluetoothmanager.h | |
1195 | --- 4_2libsControl/ifaces/bluetoothmanager.h 2009-01-17 17:51:32.000000000 +0100 | |
1196 | +++ libs/solid/control/ifaces/bluetoothmanager.h 2009-01-16 12:42:32.000000000 +0100 | |
1197 | @@ -89,6 +89,13 @@ | |
1198 | virtual QObject *createInterface(const QString &ubi) = 0; | |
1199 | ||
1200 | /** | |
1201 | + * Removes a BluetoothInterface object from this backend given its UBI. | |
1202 | + * | |
1203 | + * @param ubi the identifier of the bluetooth interface instantiated | |
1204 | + */ | |
1205 | + virtual void removeInterface(const QString &ubi) = 0; | |
1206 | + | |
1207 | + /** | |
1208 | * Retrieves the list of Universal Bluetooth Identifiers (UBIs) of bluetooth input devices | |
1209 | * which are configured in the system. Configured means also not connected devices. | |
1210 | * |