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)
4 #include <solid/control/bluetoothinterface.h>
6 #include "bluez-bluetoothremotedevice.h"
7 +#include "bluez-bluetoothinputdevice.h"
14 QMap<QString, BluezBluetoothRemoteDevice *> devices;
15 + QMap<QString, BluezBluetoothInputDevice *> inputDevices;
21 "org.bluez.Adapter", \
22 signal, this, SLOT(slot));
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 &));
41 connectInterfaceToThis("PropertyChanged", slotPropertyChanged(const QString &, const QVariant &));
42 connectInterfaceToThis("DeviceCreated", slotDeviceCreated(const QDBusObjectPath &));
44 d->iface.call("CancelDeviceCreation",addr);
47 -QString BluezBluetoothInterface::createDevice(const QString &addr) const
48 +void BluezBluetoothInterface::createDevice(const QString &addr) const
50 - QDBusObjectPath path = objectReply("CreateDevice",addr);
52 + d->iface.call("CreateDevice",addr);
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
58 - QDBusReply< QDBusObjectPath > reply;
59 - reply = d->iface.call("CreatePairedDevice",addr,agentUBI,capab);
61 - if (!reply.isValid()) {
64 - return reply.value().path();
65 + d->iface.call("CreatePairedDevice",addr,qVariantFromValue(QDBusObjectPath(agentUBI)),capab);
68 QString BluezBluetoothInterface::findDevice(const QString &addr) const
71 void BluezBluetoothInterface::registerAgent(const QString &agentUBI, const QString &capab)
73 - d->iface.call("RegisterAgent",agentUBI,capab);
74 + d->iface.call("RegisterAgent",qVariantFromValue(QDBusObjectPath(agentUBI)),capab);
77 void BluezBluetoothInterface::releaseSession()
80 void BluezBluetoothInterface::removeDevice(const QString &deviceUBI )
82 - d->iface.call("RemoveDevice",deviceUBI);
83 + d->iface.call("RemoveDevice",qVariantFromValue(QDBusObjectPath(deviceUBI)));
86 void BluezBluetoothInterface::requestSession()
87 @@ -183,305 +161,20 @@
89 void BluezBluetoothInterface::unregisterAgent(const QString &agentUBI)
91 - d->iface.call("UnregisterAgent",agentUBI);
92 + d->iface.call("UnregisterAgent",qVariantFromValue(QDBusObjectPath(agentUBI)));
99 -QString BluezBluetoothInterface::address() const
100 +void BluezBluetoothInterface::slotDeviceCreated(const QDBusObjectPath &path)
102 - return stringReply("GetAddress");
104 + kDebug() << "device created";
106 -QString BluezBluetoothInterface::version() const
108 - return stringReply("GetVersion");
111 -QString BluezBluetoothInterface::revision() const
113 - return stringReply("GetRevision");
116 -QString BluezBluetoothInterface::manufacturer() const
118 - return stringReply("GetManufacturer");
121 -QString BluezBluetoothInterface::company() const
123 - return stringReply("GetCompany");
126 -Solid::Control::BluetoothInterface::Mode BluezBluetoothInterface::mode() const
128 - QString theMode = stringReply("GetMode");
129 - Solid::Control::BluetoothInterface::Mode modeEnum;
130 - if (theMode == "connectable")
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);
137 - else if (theMode == "discoverable")
139 - modeEnum = Solid::Control::BluetoothInterface::Discoverable;
141 - Q_ASSERT(theMode == "off");
142 - modeEnum = Solid::Control::BluetoothInterface::Off;
147 -int BluezBluetoothInterface::discoverableTimeout() const
149 - QDBusReply< uint > timeout = d->iface.call("GetDiscoverableTimeout");
150 - if (timeout.isValid()) {
151 - return timeout.value();
157 -bool BluezBluetoothInterface::isDiscoverable() const
159 - return boolReply("IsDiscoverable");
162 -QStringList BluezBluetoothInterface::listConnections() const
164 - QStringList list = listReply("ListConnections");
165 - for (int i = 0; i < list.size(); i++) {
166 - list[i] = ubi() + '/' + list[i];
171 -QString BluezBluetoothInterface::majorClass() const
173 - return stringReply("GetMajorClass");
176 -QStringList BluezBluetoothInterface::listAvailableMinorClasses() const
178 - return listReply("ListAvailableMinorClasses");
181 -QString BluezBluetoothInterface::minorClass() const
183 - return stringReply("GetMinorClass");
186 -QStringList BluezBluetoothInterface::serviceClasses() const
188 - return listReply("GetServiceClasses");
191 -QString BluezBluetoothInterface::name() const
193 - return stringReply("GetName");
196 -QString BluezBluetoothInterface::getRemoteName(const QString &mac)
198 - return stringReply("GetRemoteName",mac);
201 -bool BluezBluetoothInterface::isTrusted(const QString &mac)
203 - return boolReply("IsTrusted",mac);
206 -QStringList BluezBluetoothInterface::listBondings() const
208 - return listReply("ListBondings");
211 -bool BluezBluetoothInterface::isPeriodicDiscoveryActive() const
213 - return boolReply("IsPeriodicDiscovery");
216 -bool BluezBluetoothInterface::isPeriodicDiscoveryNameResolvingActive() const
218 - return boolReply("IsPeriodicDiscoveryNameResolving");
221 -QStringList BluezBluetoothInterface::listRemoteDevices() const
223 - QStringList list = listReply("ListRemoteDevices");
224 - for (int i = 0; i < list.size(); i++) {
225 - list[i] = ubi() + '/' + list[i];
230 -QStringList BluezBluetoothInterface::listRecentRemoteDevices(const QDateTime &) const
232 - return listReply("ListRecentRemoteDevices");
235 -void BluezBluetoothInterface::setMode(const Solid::Control::BluetoothInterface::Mode mode)
237 - QString modeString;
240 - case Solid::Control::BluetoothInterface::Off:
241 - modeString = "off";
243 - case Solid::Control::BluetoothInterface::Discoverable:
244 - modeString = "discoverable";
246 - case Solid::Control::BluetoothInterface::Connectable:
247 - modeString = "connectable";
250 - d->iface.call("SetMode", modeString);
253 -void BluezBluetoothInterface::setDiscoverableTimeout(int timeout)
255 - d->iface.call("SetDiscoverableTimeout", (uint)timeout);
258 -void BluezBluetoothInterface::setMinorClass(const QString &minorClass)
260 - d->iface.call("SetMinorClass", minorClass);
263 -void BluezBluetoothInterface::setName(const QString &name)
265 - d->iface.call("SetName", name);
268 -void BluezBluetoothInterface::discoverDevices()
270 - d->iface.call("DiscoverDevices");
273 -void BluezBluetoothInterface::discoverDevicesWithoutNameResolving()
275 - d->iface.call("DiscoverDevicesWithoutNameResolving");
278 -void BluezBluetoothInterface::cancelDiscovery()
280 - d->iface.call("CancelDiscovery");
283 -void BluezBluetoothInterface::startPeriodicDiscovery()
285 - d->iface.call("StartPeriodicDiscovery");
288 -void BluezBluetoothInterface::stopPeriodicDiscovery()
290 - d->iface.call("StopPeriodicDiscovery");
293 -void BluezBluetoothInterface::setPeriodicDiscoveryNameResolving(bool nameResolving)
295 - d->iface.call("SetPeriodicDiscoveryNameResolving", nameResolving);
298 -void BluezBluetoothInterface::setTrusted(const QString& mac)
300 - d->iface.call("SetTrusted", mac);
303 -void BluezBluetoothInterface::removeTrust(const QString& mac)
305 - d->iface.call("RemoveTrust", mac);
314 -void BluezBluetoothInterface::slotModeChanged(const Solid::Control::BluetoothInterface::Mode mode)
316 - emit modeChanged(mode);
319 -void BluezBluetoothInterface::slotDiscoverableTimeoutChanged(int timeout)
321 - emit discoverableTimeoutChanged(timeout);
324 -void BluezBluetoothInterface::slotMinorClassChanged(const QString &minorClass)
326 - emit minorClassChanged(minorClass);
329 -void BluezBluetoothInterface::slotNameChanged(const QString &name)
331 - emit nameChanged(name);
334 -void BluezBluetoothInterface::slotDiscoveryStarted()
336 - emit discoveryStarted();
339 -void BluezBluetoothInterface::slotDiscoveryCompleted()
341 - emit discoveryCompleted();
344 -void BluezBluetoothInterface::slotRemoteDeviceFound(const QString &address, uint deviceClass, short rssi)
346 - QString remoteubi = QString("%1/%2").arg(ubi()).arg(address);
347 - emit remoteDeviceFound(remoteubi, deviceClass, rssi);
350 -void BluezBluetoothInterface::slotRemoteDeviceDisappeared(const QString &address)
352 - QString remoteubi = QString("%1/%2").arg(ubi()).arg(address);
353 - emit remoteDeviceDisappeared(remoteubi);
356 -void BluezBluetoothInterface::slotRemoteNameUpdated(const QString &address, const QString& name)
358 - emit remoteNameUpdated(address,name);
361 -void BluezBluetoothInterface::slotRemoteDeviceConnected(const QString &address)
363 - emit remoteDeviceConnected(address);
366 -void BluezBluetoothInterface::slotRemoteDeviceDisconnected(const QString &address)
368 - emit remoteDeviceDisconnected(address);
371 -void BluezBluetoothInterface::slotTrustAdded(const QString &address)
373 - emit trustAdded(address);
376 -void BluezBluetoothInterface::slotTrustRemoved(const QString &address)
378 - emit trustRemoved(address);
381 -void BluezBluetoothInterface::slotBondingCreated(const QString &address)
383 - emit bondingCreated(address);
386 -void BluezBluetoothInterface::slotBondingRemoved(const QString &address)
388 - emit bondingRemoved(address);
393 -void BluezBluetoothInterface::slotDeviceCreated(const QDBusObjectPath &path)
395 - kDebug() << "device created";
396 emit deviceCreated(path.path());
400 return bluetoothInterface;
403 +QObject *BluezBluetoothInterface::createBluetoothInputDevice(const QString &ubi)
405 + BluezBluetoothInputDevice *bluetoothInputDev;
406 + if (d->inputDevices.contains(ubi)) {
407 + bluetoothInputDev = d->inputDevices[ubi];
409 + bluetoothInputDev = new BluezBluetoothInputDevice(ubi);
410 + d->inputDevices.insert(ubi, bluetoothInputDev);
412 + return bluetoothInputDev;
417 /******************* DBus Calls *******************************/
419 QStringList BluezBluetoothInterface::listReply(const QString &method) const
420 @@ -574,10 +280,13 @@
423 reply = d->iface.call(method);
426 + qDebug() << "ObjectReply calling: " << method << " " << param;
427 reply = d->iface.call(method, param);
430 if (reply.isValid()) {
431 + qDebug() << "ObjectReply Valid? "<< reply.value().path();
432 return reply.value();
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)
441 #include <QDBusVariant>
442 #include <QDBusObjectPath>
445 #include <solid/control/ifaces/bluetoothinterface.h>
448 BluezBluetoothInterface(const QString & objectPath);
449 virtual ~BluezBluetoothInterface();
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 &);
476 QObject *createBluetoothRemoteDevice(const QString &);
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;
487 void stopDiscovery();
488 void unregisterAgent(const QString &);
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 &);
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&);
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)
529 QString BluezBluetoothManager::defaultInterface() const
531 + kDebug() << "Calling Backend Default Interface";
532 QDBusReply< QDBusObjectPath > path = d->manager.call("DefaultAdapter");
536 return bluetoothInterface;
539 +void BluezBluetoothManager::removeInterface(const QString& ubi)
542 + if (d->interfaces.contains(ubi)) {
543 + kDebug() << "Removing Interface" << ubi;
544 + BluezBluetoothInterface * bluetoothInterface = d->interfaces.take(ubi);
545 + bluetoothInterface = 0;
550 KJob *BluezBluetoothManager::setupInputDevice(const QString &ubi)
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)
557 m_adapter = m_objectPath.left(objectPath.size() - 18);
558 m_address = m_objectPath.right(17);
560 + kdDebug() << "Connecting to ObjectPath: " << objectPath;
562 device = new QDBusInterface("org.bluez", objectPath,
563 "org.bluez.Device", QDBusConnection::systemBus());
566 void BluezBluetoothRemoteDevice::setProperty(const QString &name, const QVariant &value)
568 - device->call("SetProperty",name,value);
569 + device->call("SetProperty",name,qVariantFromValue(QDBusVariant(value)));
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)
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
589 FrontendObjectPrivate::setBackendObject(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&)));
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
603 #include <QStringList>
609 #include "ifaces/bluetoothinterface.h"
612 void setBackendObject(QObject *object);
614 QPair<BluetoothRemoteDevice *, Ifaces::BluetoothRemoteDevice *> findRegisteredBluetoothRemoteDevice(const QString &ubi) const;
615 + QPair<BluetoothInputDevice *, Ifaces::BluetoothInputDevice *> findRegisteredBluetoothInputDevice(const QString &ubi) const;
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;
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 &)));
631 Solid::Control::BluetoothInterface::BluetoothInterface(QObject *backendObject)
632 : QObject(), d(new BluetoothInterfacePrivate(this))
634 d->setBackendObject(backendObject);
635 + QObject::connect(d->backendObject(), SIGNAL(deviceCreated(const QString &)),this, SLOT(slotDeviceCreated(const QString &)));
638 Solid::Control::BluetoothInterface::BluetoothInterface(const BluetoothInterface &device)
639 : QObject(), d(new BluetoothInterfacePrivate(this))
641 d->setBackendObject(device.d->backendObject());
642 + QObject::connect(d->backendObject(), SIGNAL(deviceCreated(const QString &)),this, SLOT(slotDeviceCreated(const QString &)));
645 Solid::Control::BluetoothInterface::~BluetoothInterface()
647 // Delete all the interfaces, they are now outdated
648 typedef QPair<BluetoothRemoteDevice *, Ifaces::BluetoothRemoteDevice *> BluetoothRemoteDeviceIfacePair;
649 + typedef QPair<BluetoothInputDevice *, Ifaces::BluetoothInputDevice *> BluetoothInputDeviceIfacePair;
651 // Delete all the devices, they are now outdated
652 - foreach (const BluetoothRemoteDeviceIfacePair &pair, d->remoteDeviceMap) {
653 + foreach (const BluetoothRemoteDeviceIfacePair &pair, d->remoteDeviceMap.values()) {
657 + foreach (const BluetoothInputDeviceIfacePair &pair, d->inputDeviceMap.values()) {
659 + delete pair.second;
664 Solid::Control::BluetoothInterface &Solid::Control::BluetoothInterface::operator=(const Solid::Control::BluetoothInterface & dev)
666 SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), cancelDeviceCreation(address));
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
672 - return_SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), QString(), createPairedDevice(address,adapterPath,capab));
673 + Ifaces::BluetoothInterface *backend = qobject_cast<Ifaces::BluetoothInterface *>(d->backendObject());
676 + backend->createPairedDevice(address,adapterPath,capab);
679 QMap<QString, QVariant> Solid::Control::BluetoothInterface::getProperties() const
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);
689 @@ -184,13 +199,13 @@
693 -Solid::Control::BluetoothRemoteDevice Solid::Control::BluetoothInterface::findBluetoothRemoteDevice(const QString &address) const
694 +Solid::Control::BluetoothRemoteDevice Solid::Control::BluetoothInterface::findBluetoothRemoteDeviceAddr(const QString &address) const
696 Ifaces::BluetoothInterface *backend = qobject_cast<Ifaces::BluetoothInterface *>(d->backendObject());
698 return d->invalidDevice;
700 - const QString ubi = backend->findDevice(address);
701 + const QString ubi = getBluetoothRemoteDeviceUBI(address);
703 QPair<BluetoothRemoteDevice *, Ifaces::BluetoothRemoteDevice *> pair = d->findRegisteredBluetoothRemoteDevice(ubi);
705 @@ -201,18 +216,56 @@
709 -Solid::Control::BluetoothRemoteDevice * Solid::Control::BluetoothInterface::createBluetoothRemoteDevice(const QString &address)
711 +const QString Solid::Control::BluetoothInterface::getBluetoothRemoteDeviceUBI(const QString &address) const
713 Ifaces::BluetoothInterface *backend = qobject_cast<Ifaces::BluetoothInterface *>(d->backendObject());
718 + const QString ubi = backend->findDevice(address);
722 - const QString ubi = backend->createDevice(address);
724 +void Solid::Control::BluetoothInterface::createBluetoothRemoteDevice(const QString &address)
726 + Ifaces::BluetoothInterface *backend = qobject_cast<Ifaces::BluetoothInterface *>(d->backendObject());
729 + backend->createDevice(address);
733 +Solid::Control::BluetoothRemoteDevice* Solid::Control::BluetoothInterface::findBluetoothRemoteDeviceUBI(const QString &ubi) const
735 QPair<BluetoothRemoteDevice *, Ifaces::BluetoothRemoteDevice *> pair = d->findRegisteredBluetoothRemoteDevice(ubi);
739 +Solid::Control::BluetoothInputDevice* Solid::Control::BluetoothInterface::findBluetoothInputDeviceUBI(const QString &ubi) const
741 + QPair<BluetoothInputDevice *, Ifaces::BluetoothInputDevice *> pair = d->findRegisteredBluetoothInputDevice(ubi);
745 +void Solid::Control::BluetoothInterface::slotDeviceCreated(const QString& ubi)
748 + Ifaces::BluetoothInterface *backend = qobject_cast<Ifaces::BluetoothInterface *>(d->backendObject());
749 + Ifaces::BluetoothRemoteDevice *iface = 0;
751 + if (backend != 0) {
752 + iface = qobject_cast<Ifaces::BluetoothRemoteDevice *>(backend->createBluetoothRemoteDevice(ubi));
756 + BluetoothRemoteDevice *device = new BluetoothRemoteDevice(iface);
758 + QPair<BluetoothRemoteDevice *, Ifaces::BluetoothRemoteDevice *> pair(device, iface);
759 + d->remoteDeviceMap[ubi] = pair;
763 QString Solid::Control::BluetoothInterface::address() const
766 QObject::connect(object, SIGNAL(propertyChanged(const QString &,const QVariant &)),
767 parent(), SIGNAL(propertyChanged(const QString &, const QVariant &)));
780 +QPair<Solid::Control::BluetoothInputDevice *, Solid::Control::Ifaces::BluetoothInputDevice *> Solid::Control::BluetoothInterfacePrivate::findRegisteredBluetoothInputDevice(const QString &ubi) const
782 + if (inputDeviceMap.contains(ubi)) {
783 + return inputDeviceMap[ubi];
785 + Ifaces::BluetoothInterface *backend = qobject_cast<Ifaces::BluetoothInterface *>(backendObject());
786 + Ifaces::BluetoothInputDevice *iface = 0;
788 + if (backend != 0) {
789 + iface = qobject_cast<Ifaces::BluetoothInputDevice *>(backend->createBluetoothInputDevice(ubi));
793 + BluetoothInputDevice *device = new BluetoothInputDevice(iface);
795 + QPair<BluetoothInputDevice *, Ifaces::BluetoothInputDevice *> pair(device, iface);
796 + inputDeviceMap[ubi] = pair;
800 + return QPair<BluetoothInputDevice *, Ifaces::BluetoothInputDevice *>(0, 0);
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
811 #include <QtCore/QMap>
813 #include "bluetoothremotedevice.h"
814 +#include "bluetoothinputdevice.h"
815 #include "ifaces/bluetoothremotedevice.h"
816 +#include "ifaces/bluetoothinputdevice.h"
823 class BluetoothRemoteDevice;
824 -typedef QList<BluetoothRemoteDevice> BluetoothRemoteDeviceList;
825 +typedef QList<BluetoothRemoteDevice*> BluetoothRemoteDeviceList;
826 class BluetoothInterfacePrivate;
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
833 - Solid::Control::BluetoothRemoteDevice* createBluetoothRemoteDevice(const QString &address);
834 + //Solid::Control::BluetoothRemoteDevice* createBluetoothRemoteDevice(const QString &address);
835 + void createBluetoothRemoteDevice(const QString &address);
838 * Finds a BluetoothRemoteDevice object given its UBI.
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.
843 - Solid::Control::BluetoothRemoteDevice findBluetoothRemoteDevice(const QString &address) const;
844 + const QString getBluetoothRemoteDeviceUBI(const QString &address) const;
846 + Solid::Control::BluetoothRemoteDevice findBluetoothRemoteDeviceAddr(const QString &addr) const;
848 + Solid::Control::BluetoothRemoteDevice* findBluetoothRemoteDeviceUBI(const QString &ubi) const;
850 + Solid::Control::BluetoothInputDevice* findBluetoothInputDeviceUBI(const QString &ubi) const;
853 * Retrieves the MAC address of the bluetooth interface/adapter.
855 // bool isTrusted(const QString &);
858 - QString createPairedDevice(const QString &, const QString &, const QString &) const;
859 + void createPairedDevice(const QString &, const QString &, const QString &) const;
861 QMap< QString, QVariant > getProperties() const;
864 QVariant getProperty(const QString&) const;
865 BluetoothInterfacePrivate * const d;
868 + void slotDeviceCreated(const QString& ubi);
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
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);
883 void _k_inputDeviceCreated(const QString &ubi);
885 typedef QPair<BluetoothInterface *, Ifaces::BluetoothInterface *> BluetoothInterfaceIfacePair;
887 // Delete all the devices, they are now outdated
888 - foreach (const BluetoothInterfaceIfacePair &pair, d->bluetoothInterfaceMap) {
889 + foreach (const BluetoothInterfaceIfacePair &pair, d->bluetoothInterfaceMap.values()) {
895 if (backend == 0) return list;
897 + kDebug() << "UBI List " << ubiList;
899 foreach (const QString &ubi, ubiList) {
900 QPair<BluetoothInterface *, Ifaces::BluetoothInterface *> pair = d->findRegisteredBluetoothInterface(ubi);
904 void Solid::Control::BluetoothManagerPrivate::_k_interfaceAdded(const QString &ubi)
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);
911 if (pair.first != 0) {
912 // Oops, I'm not sure it should happen...
920 emit q->interfaceAdded(ubi);
922 @@ -261,11 +266,19 @@
926 + Ifaces::BluetoothManager *backend = qobject_cast<Ifaces::BluetoothManager *>(managerBackend());
927 + backend->removeInterface(ubi);
928 emit q->interfaceRemoved(ubi);
931 +void Solid::Control::BluetoothManagerPrivate::_k_defaultInterfaceChanged(const QString &ubi)
933 + emit q->defaultInterfaceChanged(ubi);
936 void Solid::Control::BluetoothManagerPrivate::_k_interfaceDestroyed(QObject *object)
938 + kDebug() << "Interface detroyed";
939 Ifaces::BluetoothInterface *device = qobject_cast<Ifaces::BluetoothInterface *>(object);
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 &)));
950 QObject::connect(newBackend, SIGNAL(inputDeviceCreated(const QString &)),
951 q, SLOT(_k_inputDeviceCreated(const QString &)));
952 @@ -334,17 +350,22 @@
954 QPair<Solid::Control::BluetoothInterface *, Solid::Control::Ifaces::BluetoothInterface *> Solid::Control::BluetoothManagerPrivate::findRegisteredBluetoothInterface(const QString &ubi) const
957 + kDebug() << "findRegisteredBluetoothInterface " << ubi;
958 if (bluetoothInterfaceMap.contains(ubi)) {
959 return bluetoothInterfaceMap[ubi];
961 + kDebug() << "Creating New Interface " << ubi;
962 Ifaces::BluetoothManager *backend = qobject_cast<Ifaces::BluetoothManager *>(managerBackend());
963 Ifaces::BluetoothInterface *iface = 0;
966 + kDebug() << "Calling Backend to Creating New Interface " << ubi;
967 iface = qobject_cast<Ifaces::BluetoothInterface *>(backend->createInterface(ubi));
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
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 *))
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
990 return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), (QMap< QString,QVariant >()), getProperties());
993 +QVariant Solid::Control::BluetoothRemoteDevice::getProperty(const QString &key)
995 + QMap<QString, QVariant> props = getProperties();
996 + if (props.contains(key))
1002 QStringList Solid::Control::BluetoothRemoteDevice::listNodes()
1004 Q_D(const BluetoothRemoteDevice);
1005 @@ -113,14 +122,65 @@
1009 +QString Solid::Control::BluetoothRemoteDevice::address()
1011 + QVariant var = getProperty("Address");
1013 + if (var.isValid())
1014 + return var.value<QString>();
1019 -QString Solid::Control::BluetoothRemoteDevice::address() const
1020 +// Q_D(const BluetoothRemoteDevice);
1021 +// return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), address());
1024 +bool Solid::Control::BluetoothRemoteDevice::isTrusted()
1026 - Q_D(const BluetoothRemoteDevice);
1027 - return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), address());
1028 + QVariant var = getProperty("Trusted");
1030 + if (var.isValid())
1031 + return var.value<bool>();
1036 +void Solid::Control::BluetoothRemoteDevice::setTrusted(bool trust)
1038 + setProperty("Trusted",QVariant(trust));
1041 +QString Solid::Control::BluetoothRemoteDevice::icon()
1043 + QVariant var = getProperty("Icon");
1045 + if (var.isValid())
1046 + return var.value<QString>();
1051 +QStringList Solid::Control::BluetoothRemoteDevice::uuids()
1053 + QVariant var = getProperty("UUIDs");
1055 + if (var.isValid())
1056 + return var.value<QStringList>();
1058 + return QStringList();
1061 +bool Solid::Control::BluetoothRemoteDevice::isConnected()
1063 + QVariant var = getProperty("Connected");
1065 + if (var.isValid())
1066 + return var.value<bool>();
1072 bool Solid::Control::BluetoothRemoteDevice::isConnected() const
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());
1079 -QString Solid::Control::BluetoothRemoteDevice::name() const
1082 +QString Solid::Control::BluetoothRemoteDevice::name()
1084 - Q_D(const BluetoothRemoteDevice);
1085 - return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), name());
1086 + QVariant var = getProperty("Name");
1088 + if (var.isValid())
1089 + return var.value<QString>();
1093 +// return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), name());
1097 QString Solid::Control::BluetoothRemoteDevice::alias() const
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
1104 bool operator==(const BluetoothRemoteDevice & other) const;
1107 - * The UBI of the remote de device.
1108 + * The UBI of the remote device.
1110 QString ubi() const;
1113 + * The address of the remote device.
1115 + QString address();
1118 + * The name of the remote device.
1123 + * The icon of the remote device.
1128 + * The Trust state of the remote device.
1133 + * Set the Trust state of the remote device.
1135 + void setTrusted(bool);
1138 + * Returns the service uuids of the remote device.
1140 + QStringList uuids();
1143 + * The Connection state of the remote device.
1145 + bool isConnected();
1148 * Retrieve all properties from the remote device.
1150 * @returns a hash of named properties
1154 Q_PRIVATE_SLOT(d_func(), void _k_destroyed(QObject *))
1157 + QVariant getProperty(const QString &key);
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
1168 - virtual QString createPairedDevice(const QString &, const QString &, const QString &) const = 0;
1169 + virtual void createPairedDevice(const QString &, const QString &, const QString &) const = 0;
1171 virtual QMap< QString, QVariant > getProperties() const = 0;
1175 virtual QString findDevice(const QString &) const = 0;
1177 - virtual QString createDevice(const QString &) const = 0;
1178 + //virtual QString createDevice(const QString &) const = 0;
1179 + virtual void createDevice(const QString &) const = 0;
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
1187 - virtual QObject *createBluetoothRemoteDevice(const QString &address) = 0;
1188 + virtual QObject *createBluetoothRemoteDevice(const QString &ubi) = 0;
1190 + virtual QObject *createBluetoothInputDevice(const QString &ubi) = 0;
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
1198 virtual QObject *createInterface(const QString &ubi) = 0;
1201 + * Removes a BluetoothInterface object from this backend given its UBI.
1203 + * @param ubi the identifier of the bluetooth interface instantiated
1205 + virtual void removeInterface(const QString &ubi) = 0;
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.