File solid-bluetooth.diff of Package kdebase4-workspace
Index: solid_bluez.desktop
===================================================================
--- solid_bluez.desktop (.../branches/KDE/4.1/kdebase/workspace/solid/bluez) (revision 912128)
+++ solid/bluez/solid_bluez.desktop (.../trunk/KDE/kdebase/workspace/solid/bluez) (revision 912128)
@@ -5,20 +5,21 @@
InitialPreference=100
Icon=preferences-system-bluetooth
Name=BlueZ
-Name[ar]=اضافات
Name[hi]=ब्लूज़
+Name[kn]=ಬ್ಲೂಜ಼್
Name[ne]=ब्लुZ
Name[sr]=БлуЗ
Name[x-test]=xxBlueZxx
Comment=Bluetooth management using the BlueZ stack
-Comment[ar]=ادارة بلوتوث باستخدام كومة الاضافات
+Comment[ar]=إدارة بلوتوث باستخدام كومة BlueZ
Comment[be]=Кіраванне Bluetooth пры дапамозе стэка BlueZ
+Comment[be@latin]=Kiravańnie pryładami „Bluetooth” praz systemu „BlueZ”.
Comment[ca]=Gestió del Bluetooth usant la pila BlueZ
Comment[da]=Bluetooth-håndtering med brug af BlueZ-stakken
Comment[de]=Bluetooth-Verwaltung mit Hilfe von Bluez
Comment[el]=Διαχείριση bluetooth με χρήση της στοίβας BlueZ
Comment[eo]=Bluetooth-administrado uzante la BlueZ-stakon
-Comment[es]=Administrar Bluetooth mediante la pila BlueZ
+Comment[es]=Gestión de Bluetooth mediante la pila BlueZ
Comment[et]=Bluetoothi haldamine BlueZi pinuga
Comment[eu]=Bluetooth kudeaketa BlueZ pila erabiliz
Comment[fa]=مدیریت بلوتوث با استفاده از پشته BlueZ
@@ -29,12 +30,14 @@
Comment[gl]=Xestión de Bluetooth usando a pila BlueZ
Comment[gu]=BlueZ સ્ટેકનો ઉપયોગ કરીને બ્લ્યુટુથ સંચાલન
Comment[he]=ניהול Bluetooth באמצעות מחסנית BlueZ
+Comment[hi]=ब्लूएज स्टैक के प्रयोग से ब्लूटूथ प्रबंधन
Comment[hu]=Bluetooth-kezelő (a BlueZ keretrendszerre épül)
Comment[is]=Umsýsla með Blátönn um BlueZ kerfið
Comment[it]=Gestione Bluetooth che usa lo stack BlueZ
Comment[ja]=BlueZ スタックによる Bluetooth 管理
Comment[kk]=BlueZ стегі көмегімен Bluetooth-ды басқару
Comment[km]=ការគ្រប់គ្រងប៊្លូធូសដោយប្រើជង់ BlueZ
+Comment[kn]=ಬ್ಲೂಜ಼್ ಅಡುಕು (ಸ್ಟಾಕ್) ಬಳಸಿ ಬ್ಲೂಟೂತ್ ವ್ಯವಸ್ಥಾಪನೆ
Comment[ko]=BlueZ 스택을 사용하는 블루투스 관리
Comment[ku]=Gerînendetiya Bluetoothê BlueZ stack bi kar tîne
Comment[lv]=Bluetooth pārvaldība lietojot BlueZ
@@ -45,6 +48,7 @@
Comment[ne]=ब्लुZ थाक प्रयोग गरिएको ब्लुटुथ व्यवस्थापन
Comment[nl]=Bluetooth-beheer via de BlueZ Stack
Comment[nn]=Bluetooth-handtering med BlueZ
+Comment[or]=BlueZ ଥାକ ବ୍ୟବହାର କରି ବ୍ଲୁଟୁଥ ପରିଚାଳନା
Comment[pa]=BlueZ ਸਟੈਕ ਨਾਲ ਬਲਿਊਟੁੱਥ ਮੈਨਿਜਮੈਂਟ
Comment[pl]=Zarządzanie interfejsami Bluetooth za pomocą stosu BlueZ
Comment[pt]=Gestão do Bluetooth com a plataforma BlueZ
@@ -52,10 +56,12 @@
Comment[ro]=Gestiune bluetooth folosind stiva BlueZ
Comment[ru]=Управление протоколм Bluetooth на основе стека BlueZ
Comment[se]=Gieđahala Bluetooth BlueZain
+Comment[sk]=Správa bluetooth pomocou aplikácie BlueZ
Comment[sl]=Upravljanje z Bluetooth z uporabo sklada BlueZ
Comment[sr]=Управљање блутутом механизмима БлуЗ‑а
Comment[sr@latin]=Upravljanje Bluetoothom mehanizmima BlueZ‑a
Comment[sv]=Blåtandshantering som använder BlueZ
+Comment[te]=BlueZ స్టాక్ ఉపయోగిస్తూ బ్లూటూత్ నిర్వహణ
Comment[th]=จัดการระบบบลูทูธโดยใช้ชั้นข้อมูลของ BlueZ
Comment[tr]=BlueZ kullanan Bluetooth yönetimi
Comment[uk]=Керування Bluetooth через стос BlueZ
Index: bluez-bluetoothinterface.cpp
===================================================================
--- bluez-bluetoothinterface.cpp (.../branches/KDE/4.1/kdebase/workspace/solid/bluez) (revision 912128)
+++ solid/bluez/bluez-bluetoothinterface.cpp (.../trunk/KDE/kdebase/workspace/solid/bluez) (revision 912128)
@@ -1,6 +1,7 @@
/* This file is part of the KDE project
Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
Copyright (C) 2007 Daniel Gollub <dgollub@suse.de>
+ Copyright (C) 2008 Tom Patzig <tpatzig@suse.de>
This library is free software; you can redistribute it and/or
@@ -21,14 +22,14 @@
#include "bluez-bluetoothinterface.h"
-#include <QtDBus>
-
#include <solid/control/bluetoothinterface.h>
#include "bluez-bluetoothremotedevice.h"
+#include "bluez-bluetoothinputdevice.h"
#include <KDebug>
+
class BluezBluetoothInterfacePrivate
{
public:
@@ -43,8 +44,11 @@
QString objectPath;
QMap<QString, BluezBluetoothRemoteDevice *> devices;
+ QMap<QString, BluezBluetoothInputDevice *> inputDevices;
};
+
+
BluezBluetoothInterface::BluezBluetoothInterface(const QString & objectPath)
: BluetoothInterface(0), d(new BluezBluetoothInterfacePrivate(objectPath))
{
@@ -55,21 +59,13 @@
"org.bluez.Adapter", \
signal, this, SLOT(slot));
- connectInterfaceToThis("ModeChanged", slotModeChanged(const QString &));
- connectInterfaceToThis("DiscoverableTimeoutChanged", slotDiscoverableTimeoutChanged(int));
- connectInterfaceToThis("MinorClassChanged", slotMinorClassChanged(const QString &));
- connectInterfaceToThis("NameChanged", slotNameChanged(const QString &));
- connectInterfaceToThis("DiscoveryStarted", slotDiscoveryStarted());
- connectInterfaceToThis("DiscoveryCompleted", slotDiscoveryCompleted());
- connectInterfaceToThis("RemoteDeviceDisappeared", slotRemoteDeviceDisappeared(const QString &));
- connectInterfaceToThis("RemoteDeviceFound", slotRemoteDeviceFound(const QString &, uint, short));
- connectInterfaceToThis("RemoteNameUpdated", slotRemoteNameUpdated(const QString &, const QString &));
- connectInterfaceToThis("RemoteDeviceConnected", slotRemoteDeviceConnected(const QString &));
- connectInterfaceToThis("RemoteDeviceDisconnected", slotRemoteDeviceDisconnected(const QString &));
- connectInterfaceToThis("TrustAdded", slotTrustAdded(const QString &));
- connectInterfaceToThis("TrustRemoved", slotTrustRemoved(const QString &));
- connectInterfaceToThis("BondingCreated", slotBondingCreated(const QString &));
- connectInterfaceToThis("BondingRemoved", slotBondingRemoved(const QString &));
+ connectInterfaceToThis("PropertyChanged", slotPropertyChanged(const QString &, const QVariant &));
+ connectInterfaceToThis("DeviceCreated", slotDeviceCreated(const QDBusObjectPath &));
+ connectInterfaceToThis("DeviceRemoved", slotDeviceRemoved(const QDBusObjectPath &));
+ connectInterfaceToThis("DeviceDisappeared", slotDeviceDisappeared(const QString &));
+ connectInterfaceToThis("DeviceFound", slotDeviceFound(const QString &, const QMap< QString,QVariant > &));
+
+
}
BluezBluetoothInterface::~BluezBluetoothInterface()
@@ -82,287 +78,132 @@
return d->objectPath;
}
-QString BluezBluetoothInterface::address() const
+void BluezBluetoothInterface::cancelDeviceCreation(const QString &addr)
{
- return stringReply("GetAddress");
+ d->iface.call("CancelDeviceCreation",addr);
}
-QString BluezBluetoothInterface::version() const
+void BluezBluetoothInterface::createDevice(const QString &addr) const
{
- return stringReply("GetVersion");
+ d->iface.call("CreateDevice",addr);
}
-QString BluezBluetoothInterface::revision() const
+void BluezBluetoothInterface::createPairedDevice(const QString &addr, const QString &agentUBI, const QString &capab) const
{
- return stringReply("GetRevision");
+ d->iface.call("CreatePairedDevice",addr,qVariantFromValue(QDBusObjectPath(agentUBI)),capab);
}
-QString BluezBluetoothInterface::manufacturer() const
+QString BluezBluetoothInterface::findDevice(const QString &addr) const
{
- return stringReply("GetManufacturer");
+ QDBusObjectPath path = objectReply("FindDevice",addr);
+ return path.path();
}
-QString BluezBluetoothInterface::company() const
-{
- return stringReply("GetCompany");
-}
-Solid::Control::BluetoothInterface::Mode BluezBluetoothInterface::mode() const
+QMap<QString, QVariant> BluezBluetoothInterface::getProperties() const
{
- QString theMode = stringReply("GetMode");
- Solid::Control::BluetoothInterface::Mode modeEnum;
- if (theMode == "connectable")
- {
- modeEnum = Solid::Control::BluetoothInterface::Connectable;
+ QDBusReply< QMap<QString,QVariant> > prop = d->iface.call("GetProperties");
+ if (!prop.isValid()) {
+ return QMap< QString,QVariant >();
}
- else if (theMode == "discoverable")
- {
- modeEnum = Solid::Control::BluetoothInterface::Discoverable;
- } else {
- Q_ASSERT(theMode == "off");
- modeEnum = Solid::Control::BluetoothInterface::Off;
- }
- return modeEnum;
+ return prop.value();
}
-int BluezBluetoothInterface::discoverableTimeout() const
+QStringList BluezBluetoothInterface::listDevices() const
{
- QDBusReply< uint > timeout = d->iface.call("GetDiscoverableTimeout");
- if (timeout.isValid()) {
- return timeout.value();
- }
+ QStringList deviceList;
- return -1;
-}
-
-bool BluezBluetoothInterface::isDiscoverable() const
-{
- return boolReply("IsDiscoverable");
-}
-
-QStringList BluezBluetoothInterface::listConnections() const
-{
- QStringList list = listReply("ListConnections");
- for (int i = 0; i < list.size(); i++) {
- list[i] = ubi() + '/' + list[i];
+ QDBusReply< QList<QDBusObjectPath> > devices = d->iface.call("ListDevices");
+ if(!devices.isValid()) {
+ return QStringList();
}
- return list;
+ foreach(QDBusObjectPath path, devices.value()) {
+ deviceList.append(path.path());
+ }
+ return deviceList;
}
-QString BluezBluetoothInterface::majorClass() const
+void BluezBluetoothInterface::registerAgent(const QString &agentUBI, const QString &capab)
{
- return stringReply("GetMajorClass");
+ d->iface.call("RegisterAgent",qVariantFromValue(QDBusObjectPath(agentUBI)),capab);
}
-QStringList BluezBluetoothInterface::listAvailableMinorClasses() const
+void BluezBluetoothInterface::releaseSession()
{
- return listReply("ListAvailableMinorClasses");
+ d->iface.call("ReleaseSession");
}
-QString BluezBluetoothInterface::minorClass() const
+void BluezBluetoothInterface::removeDevice(const QString &deviceUBI )
{
- return stringReply("GetMinorClass");
+ d->iface.call("RemoveDevice",qVariantFromValue(QDBusObjectPath(deviceUBI)));
}
-QStringList BluezBluetoothInterface::serviceClasses() const
+void BluezBluetoothInterface::requestSession()
{
- return listReply("GetServiceClasses");
+ d->iface.call("RequestSession");
}
-QString BluezBluetoothInterface::name() const
+void BluezBluetoothInterface::setProperty(const QString &property, const QVariant &value)
{
- return stringReply("GetName");
+ d->iface.call("SetProperty",property, qVariantFromValue(QDBusVariant(value)));
}
-QString BluezBluetoothInterface::getRemoteName(const QString &mac)
-{
- return stringReply("GetRemoteName",mac);
-}
-bool BluezBluetoothInterface::isTrusted(const QString &mac)
+void BluezBluetoothInterface::startDiscovery()
{
- return boolReply("IsTrusted",mac);
+ d->iface.call("StartDiscovery");
}
-QStringList BluezBluetoothInterface::listBondings() const
+void BluezBluetoothInterface::stopDiscovery()
{
- return listReply("ListBondings");
+ d->iface.call("StopDiscovery");
}
-bool BluezBluetoothInterface::isPeriodicDiscoveryActive() const
+void BluezBluetoothInterface::unregisterAgent(const QString &agentUBI)
{
- return boolReply("IsPeriodicDiscovery");
+ d->iface.call("UnregisterAgent",qVariantFromValue(QDBusObjectPath(agentUBI)));
}
-bool BluezBluetoothInterface::isPeriodicDiscoveryNameResolvingActive() const
-{
- return boolReply("IsPeriodicDiscoveryNameResolving");
-}
-QStringList BluezBluetoothInterface::listRemoteDevices() const
-{
- QStringList list = listReply("ListRemoteDevices");
- for (int i = 0; i < list.size(); i++) {
- list[i] = ubi() + '/' + list[i];
- }
- return list;
-}
-QStringList BluezBluetoothInterface::listRecentRemoteDevices(const QDateTime &) const
+void BluezBluetoothInterface::slotDeviceCreated(const QDBusObjectPath &path)
{
- return listReply("ListRecentRemoteDevices");
-}
+ kDebug() << "device created";
-void BluezBluetoothInterface::setMode(const Solid::Control::BluetoothInterface::Mode mode)
-{
- QString modeString;
- switch(mode)
- {
- case Solid::Control::BluetoothInterface::Off:
- modeString = "off";
- break;
- case Solid::Control::BluetoothInterface::Discoverable:
- modeString = "discoverable";
- break;
- case Solid::Control::BluetoothInterface::Connectable:
- modeString = "connectable";
- break;
+ if (!d->devices.contains(path.path())) {
+ BluezBluetoothRemoteDevice* bluetoothRemoteDev = new BluezBluetoothRemoteDevice(path.path());
+ d->devices.insert(path.path(), bluetoothRemoteDev);
}
- d->iface.call("SetMode", modeString);
-}
-void BluezBluetoothInterface::setDiscoverableTimeout(int timeout)
-{
- d->iface.call("SetDiscoverableTimeout", (uint)timeout);
+ emit deviceCreated(path.path());
}
-void BluezBluetoothInterface::setMinorClass(const QString &minorClass)
+void BluezBluetoothInterface::slotDeviceDisappeared(const QString &address)
{
- d->iface.call("SetMinorClass", minorClass);
+ kDebug() << "device disappeared";
+ emit deviceDisappeared(address);
}
-void BluezBluetoothInterface::setName(const QString &name)
+void BluezBluetoothInterface::slotDeviceFound(const QString &address, const QMap< QString, QVariant > &properties)
{
- d->iface.call("SetName", name);
+ kDebug() << "device found " << address << " " << properties["Name"];
+ emit deviceFound(address,properties);
}
-void BluezBluetoothInterface::discoverDevices()
+void BluezBluetoothInterface::slotDeviceRemoved(const QDBusObjectPath &path)
{
- d->iface.call("DiscoverDevices");
+ kDebug() << "device removed";
+ emit deviceRemoved(path.path());
}
-void BluezBluetoothInterface::discoverDevicesWithoutNameResolving()
+void BluezBluetoothInterface::slotPropertyChanged(const QString & property, const QVariant &value)
{
- d->iface.call("DiscoverDevicesWithoutNameResolving");
+ kDebug() << "Property " << property << " changed to " << value;
+ emit propertyChanged(property,value);
}
-void BluezBluetoothInterface::cancelDiscovery()
-{
- d->iface.call("CancelDiscovery");
-}
-void BluezBluetoothInterface::startPeriodicDiscovery()
-{
- d->iface.call("StartPeriodicDiscovery");
-}
-void BluezBluetoothInterface::stopPeriodicDiscovery()
-{
- d->iface.call("StopPeriodicDiscovery");
-}
-
-void BluezBluetoothInterface::setPeriodicDiscoveryNameResolving(bool nameResolving)
-{
- d->iface.call("SetPeriodicDiscoveryNameResolving", nameResolving);
-}
-
-void BluezBluetoothInterface::setTrusted(const QString& mac)
-{
- d->iface.call("SetTrusted", mac);
-}
-
-void BluezBluetoothInterface::removeTrust(const QString& mac)
-{
- d->iface.call("RemoveTrust", mac);
-}
-
-void BluezBluetoothInterface::slotModeChanged(const Solid::Control::BluetoothInterface::Mode mode)
-{
- emit modeChanged(mode);
-}
-
-void BluezBluetoothInterface::slotDiscoverableTimeoutChanged(int timeout)
-{
- emit discoverableTimeoutChanged(timeout);
-}
-
-void BluezBluetoothInterface::slotMinorClassChanged(const QString &minorClass)
-{
- emit minorClassChanged(minorClass);
-}
-
-void BluezBluetoothInterface::slotNameChanged(const QString &name)
-{
- emit nameChanged(name);
-}
-
-void BluezBluetoothInterface::slotDiscoveryStarted()
-{
- emit discoveryStarted();
-}
-
-void BluezBluetoothInterface::slotDiscoveryCompleted()
-{
- emit discoveryCompleted();
-}
-
-void BluezBluetoothInterface::slotRemoteDeviceFound(const QString &address, uint deviceClass, short rssi)
-{
- QString remoteubi = QString("%1/%2").arg(ubi()).arg(address);
- emit remoteDeviceFound(remoteubi, deviceClass, rssi);
-}
-
-void BluezBluetoothInterface::slotRemoteDeviceDisappeared(const QString &address)
-{
- QString remoteubi = QString("%1/%2").arg(ubi()).arg(address);
- emit remoteDeviceDisappeared(remoteubi);
-}
-
-void BluezBluetoothInterface::slotRemoteNameUpdated(const QString &address, const QString& name)
-{
- emit remoteNameUpdated(address,name);
-}
-
-void BluezBluetoothInterface::slotRemoteDeviceConnected(const QString &address)
-{
- emit remoteDeviceConnected(address);
-}
-
-void BluezBluetoothInterface::slotRemoteDeviceDisconnected(const QString &address)
-{
- emit remoteDeviceDisconnected(address);
-}
-
-void BluezBluetoothInterface::slotTrustAdded(const QString &address)
-{
- emit trustAdded(address);
-}
-
-void BluezBluetoothInterface::slotTrustRemoved(const QString &address)
-{
- emit trustRemoved(address);
-}
-
-void BluezBluetoothInterface::slotBondingCreated(const QString &address)
-{
- emit bondingCreated(address);
-}
-
-void BluezBluetoothInterface::slotBondingRemoved(const QString &address)
-{
- emit bondingRemoved(address);
-}
-
QObject *BluezBluetoothInterface::createBluetoothRemoteDevice(const QString &ubi)
{
BluezBluetoothRemoteDevice *bluetoothInterface;
@@ -375,8 +216,22 @@
return bluetoothInterface;
}
-/*******************************/
+QObject *BluezBluetoothInterface::createBluetoothInputDevice(const QString &ubi)
+{
+ BluezBluetoothInputDevice *bluetoothInputDev;
+ if (d->inputDevices.contains(ubi)) {
+ bluetoothInputDev = d->inputDevices[ubi];
+ } else {
+ bluetoothInputDev = new BluezBluetoothInputDevice(ubi);
+ d->inputDevices.insert(ubi, bluetoothInputDev);
+ }
+ return bluetoothInputDev;
+}
+
+
+/******************* DBus Calls *******************************/
+
QStringList BluezBluetoothInterface::listReply(const QString &method) const
{
QDBusReply< QStringList > list = d->iface.call(method);
@@ -419,4 +274,23 @@
return false;
}
+QDBusObjectPath BluezBluetoothInterface::objectReply(const QString &method, const QString ¶m) const
+{
+ QDBusReply< QDBusObjectPath > reply;
+
+ if (param.isEmpty())
+ reply = d->iface.call(method);
+ else {
+ qDebug() << "ObjectReply calling: " << method << " " << param;
+ reply = d->iface.call(method, param);
+ }
+
+ if (reply.isValid()) {
+ qDebug() << "ObjectReply Valid? "<< reply.value().path();
+ return reply.value();
+ }
+
+ return QDBusObjectPath();
+}
+
#include "bluez-bluetoothinterface.moc"
Index: bluez-bluetoothinterface.h
===================================================================
--- bluez-bluetoothinterface.h (.../branches/KDE/4.1/kdebase/workspace/solid/bluez) (revision 912128)
+++ solid/bluez/bluez-bluetoothinterface.h (.../trunk/KDE/kdebase/workspace/solid/bluez) (revision 912128)
@@ -1,6 +1,7 @@
/* This file is part of the KDE project
Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
Copyright (C) 2007 Daniel Gollub <dgollub@suse.de>
+ Copyright (C) 2008 Tom Patzig <tpatzig@suse.de>
This library is free software; you can redistribute it and/or
@@ -23,79 +24,62 @@
#define BLUEZ_BLUETOOTHINTERFACE_H
#include <kdemacros.h>
+#include <QtDBus>
+#include <QDBusVariant>
+#include <QDBusObjectPath>
+#include <QString>
#include <solid/control/ifaces/bluetoothinterface.h>
class BluezBluetoothInterfacePrivate;
+
class KDE_EXPORT BluezBluetoothInterface : public Solid::Control::Ifaces::BluetoothInterface
{
Q_OBJECT
Q_INTERFACES(Solid::Control::Ifaces::BluetoothInterface)
+
public:
BluezBluetoothInterface(const QString & objectPath);
virtual ~BluezBluetoothInterface();
QString ubi() const;
- QString address() const;
- QString version() const;
- QString revision() const;
- QString manufacturer() const;
- QString company() const;
- Solid::Control::BluetoothInterface::Mode mode() const;
- int discoverableTimeout() const;
- bool isDiscoverable() const;
- QStringList listConnections() const;
- QString majorClass() const;
- QStringList listAvailableMinorClasses() const;
- QString minorClass() const;
- QStringList serviceClasses() const;
- QString name() const;
- QStringList listBondings() const;
- bool isPeriodicDiscoveryActive() const;
- bool isPeriodicDiscoveryNameResolvingActive() const;
- QStringList listRemoteDevices() const;
- QStringList listRecentRemoteDevices(const QDateTime &) const;
- QString getRemoteName(const QString &);
- bool isTrusted(const QString &);
-
+
QObject *createBluetoothRemoteDevice(const QString &);
+ QObject *createBluetoothInputDevice(const QString &);
+ void createDevice(const QString &) const;
+ void createPairedDevice(const QString &,const QString &,const QString &) const;
+ QString findDevice(const QString &) const;
+ QMap< QString, QVariant > getProperties() const;
+ QStringList listDevices() const;
+
public Q_SLOTS:
- void setMode(const Solid::Control::BluetoothInterface::Mode);
- void setDiscoverableTimeout(int);
- void setMinorClass(const QString &);
- void setName(const QString &);
- void discoverDevices();
- void discoverDevicesWithoutNameResolving();
- void cancelDiscovery();
- void startPeriodicDiscovery();
- void stopPeriodicDiscovery();
- void setPeriodicDiscoveryNameResolving(bool);
- void setTrusted(const QString &);
- void removeTrust(const QString &);
- void slotModeChanged(const Solid::Control::BluetoothInterface::Mode mode);
- void slotDiscoverableTimeoutChanged(int timeout);
- void slotMinorClassChanged(const QString &minor);
- void slotNameChanged(const QString &name);
- void slotDiscoveryStarted();
- void slotDiscoveryCompleted();
- void slotRemoteDeviceFound(const QString &ubi, uint deviceClass, short rssi);
- void slotRemoteDeviceDisappeared(const QString &ubi);
- void slotRemoteNameUpdated(const QString &, const QString &);
- void slotRemoteDeviceConnected(const QString&);
- void slotRemoteDeviceDisconnected(const QString&);
- void slotTrustAdded(const QString&);
- void slotTrustRemoved(const QString&);
- void slotBondingCreated(const QString&);
- void slotBondingRemoved(const QString&);
+ void cancelDeviceCreation(const QString &);
+ void registerAgent(const QString &,const QString &);
+ void releaseSession();
+ void removeDevice(const QString &);
+ void requestSession();
+ void setProperty(const QString &,const QVariant&);
+ void startDiscovery();
+ void stopDiscovery();
+ void unregisterAgent(const QString &);
+ void slotDeviceCreated(const QDBusObjectPath &);
+ void slotDeviceDisappeared(const QString &);
+ void slotDeviceFound(const QString &, const QMap< QString, QVariant > &);
+ void slotDeviceRemoved(const QDBusObjectPath &);
+ void slotPropertyChanged(const QString &,const QVariant &);
+
private:
BluezBluetoothInterfacePrivate * d;
QStringList listReply(const QString &method) const;
QString stringReply(const QString &method, const QString ¶m = "") const;
bool boolReply(const QString &method, const QString ¶m = "") const;
+ QDBusObjectPath objectReply(const QString &method, const QString ¶m = "" ) const;
+
+
};
#endif
Index: bluez-bluetoothmanager.cpp
===================================================================
--- bluez-bluetoothmanager.cpp (.../branches/KDE/4.1/kdebase/workspace/solid/bluez) (revision 912128)
+++ solid/bluez/bluez-bluetoothmanager.cpp (.../trunk/KDE/kdebase/workspace/solid/bluez) (revision 912128)
@@ -1,6 +1,7 @@
/* This file is part of the KDE project
Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
Copyright (C) 2007 Daniel Gollub <dgollub@suse.de>
+ Copyright (C) 2008 Tom Patzig <tpatzig@suse.de>
This library is free software; you can redistribute it and/or
@@ -36,14 +37,14 @@
public:
- BluezBluetoothManagerPrivate() : manager("org.bluez", "/org/bluez", "org.bluez.Manager", QDBusConnection::systemBus())
+ BluezBluetoothManagerPrivate() : manager("org.bluez", "/", "org.bluez.Manager", QDBusConnection::systemBus())
{}
QDBusInterface manager;
- QDBusInterface *inputManager;
+// QDBusInterface *inputManager;
QMap<QString, BluezBluetoothInterface *> interfaces;
- QMap<QString, BluezBluetoothInputDevice *> inputDevices;
+// QMap<QString, BluezBluetoothInputDevice *> inputDevices;
};
@@ -52,19 +53,21 @@
{
#define connectManagerToThis(signal, slot) \
d->manager.connection().connect("org.bluez", \
- "/org/bluez", \
+ "/", \
"org.bluez.Manager", \
signal, this, SLOT(slot));
- connectManagerToThis("AdapterAdded", slotDeviceAdded(const QString &));
- connectManagerToThis("AdapterRemoved", slotDeviceRemoved(const QString &));
- connectManagerToThis("DefaultAdapterChanged", slotDefaultDeviceChanged(const QString &));
+ connectManagerToThis("AdapterAdded", slotDeviceAdded(const QDBusObjectPath &));
+ connectManagerToThis("AdapterRemoved", slotDeviceRemoved(const QDBusObjectPath &));
+ connectManagerToThis("DefaultAdapterChanged", slotDefaultDeviceChanged(const QDBusObjectPath &));
+// in bluez4 no input Manager needed
- QDBusReply< QString > busId = d->manager.call("ActivateService", "input");
+/* QDBusReply< QString > busId = d->manager.call("ActivateService", "input");
if (busId.isValid()) {
m_inputManagerDest = busId.value();
}
+
d->inputManager = new QDBusInterface(m_inputManagerDest, "/org/bluez/input",
"org.bluez.input.Manager", QDBusConnection::systemBus());
@@ -76,11 +79,12 @@
connectInputManagerToThis("DeviceCreated", inputDeviceCreated(const QString &));
connectInputManagerToThis("DeviceRemoved", inputDeviceRemoved(const QString &));
+*/
}
BluezBluetoothManager::~BluezBluetoothManager()
{
- delete d->inputManager;
+// delete d->inputManager;
delete d;
}
@@ -88,11 +92,11 @@
{
QStringList bluetoothInterfaces;
- QDBusReply< QStringList > deviceList = d->manager.call("ListAdapters");
+ QDBusReply< QList<QDBusObjectPath> > deviceList = d->manager.call("ListAdapters");
if (deviceList.isValid()) {
- QStringList devices = deviceList.value();
- foreach (QString path, devices) {
- bluetoothInterfaces.append(path);
+ QList<QDBusObjectPath> devices = deviceList.value();
+ foreach (const QDBusObjectPath& path, devices) {
+ bluetoothInterfaces.append(path.path());
}
}
return bluetoothInterfaces;
@@ -100,13 +104,23 @@
QString BluezBluetoothManager::defaultInterface() const
{
- QDBusReply< QString > path = d->manager.call("DefaultAdapter");
+ kDebug() << "Calling Backend Default Interface";
+ QDBusReply< QDBusObjectPath > path = d->manager.call("DefaultAdapter");
if (!path.isValid())
return QString();
- return path.value();
+ return path.value().path();
}
+QString BluezBluetoothManager::findInterface(const QString &adapterName) const
+{
+ QDBusReply< QDBusObjectPath > devicePath = d->manager.call("FindAdapter",adapterName);
+ if (!devicePath.isValid())
+ return QString();
+
+ return devicePath.value().path();
+}
+
QObject * BluezBluetoothManager::createInterface(const QString & ubi)
{
BluezBluetoothInterface * bluetoothInterface;
@@ -119,6 +133,17 @@
return bluetoothInterface;
}
+void BluezBluetoothManager::removeInterface(const QString& ubi)
+{
+
+ if (d->interfaces.contains(ubi)) {
+ kDebug() << "Removing Interface" << ubi;
+ BluezBluetoothInterface * bluetoothInterface = d->interfaces.take(ubi);
+ bluetoothInterface = 0;
+ }
+}
+
+/*
KJob *BluezBluetoothManager::setupInputDevice(const QString &ubi)
{
QString address = ubi.right(17);
@@ -129,7 +154,9 @@
return new BluezCallJob(QDBusConnection::systemBus(), m_inputManagerDest, "/org/bluez/input", "org.bluez.input.Manager",
"CreateDevice", params);
}
+*/
+/*
QStringList BluezBluetoothManager::bluetoothInputDevices() const
{
QStringList bluetoothInputDevices;
@@ -137,7 +164,7 @@
QDBusReply< QStringList > deviceList = d->inputManager->call("ListDevices");
if (deviceList.isValid()) {
QStringList devices = deviceList.value();
- foreach (QString path, devices) {
+ foreach (const QString& path, devices) {
bluetoothInputDevices.append(path);
}
}
@@ -160,23 +187,28 @@
}
return bluetoothInputDevice;
}
+*/
-void BluezBluetoothManager::slotDeviceAdded(const QString &adapter)
+void BluezBluetoothManager::slotDeviceAdded(const QDBusObjectPath &adapter)
{
// TODO free the adapter device...
- emit interfaceAdded(adapter);
+ kDebug() << "interfaceAdded " << adapter.path();
+ emit interfaceAdded(adapter.path());
}
-void BluezBluetoothManager::slotDeviceRemoved(const QString &adapter)
+void BluezBluetoothManager::slotDeviceRemoved(const QDBusObjectPath &adapter)
{
- emit interfaceRemoved(adapter);
+ kDebug() << "interfaceRemoved " << adapter.path();
+ emit interfaceRemoved(adapter.path());
}
-void BluezBluetoothManager::slotDefaultDeviceChanged(const QString &adapter)
+void BluezBluetoothManager::slotDefaultDeviceChanged(const QDBusObjectPath &adapter)
{
- emit defaultInterfaceChanged(adapter);
+ kDebug() << "defaultDeviceChanged " << adapter.path();
+ emit defaultInterfaceChanged(adapter.path());
}
+/*
void BluezBluetoothManager::slotInputDeviceCreated(const QString &path)
{
emit inputDeviceCreated(path);
@@ -187,7 +219,9 @@
// TODO free the input device...
emit inputDeviceRemoved(path);
}
+*/
+/*
Solid::Control::Ifaces::BluetoothSecurity *BluezBluetoothManager::security(const QString &interface)
{
BluezBluetoothSecurity *out;
@@ -200,7 +234,7 @@
new BluezBluetoothSecurityAuthorizationAgentAdaptor(out);
return out;
}
-
+*/
#include "bluez-bluetoothmanager.moc"
Index: bluez-bluetoothremotedevice.cpp
===================================================================
--- bluez-bluetoothremotedevice.cpp (.../branches/KDE/4.1/kdebase/workspace/solid/bluez) (revision 912128)
+++ solid/bluez/bluez-bluetoothremotedevice.cpp (.../trunk/KDE/kdebase/workspace/solid/bluez) (revision 912128)
@@ -1,6 +1,7 @@
/* This file is part of the KDE project
Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
Copyright (C) 2007 Daniel Gollub <dgollub@suse.de>
+ Copyright (C) 2008 Tom Patzig <tpatzig@suse.de>
This library is free software; you can redistribute it and/or
@@ -37,28 +38,25 @@
{
// size("/FF:FF:FF:FF:FF:FF") == 18
- Q_ASSERT(objectPath.startsWith('/'));
+ //Q_ASSERT(objectPath.startsWith('/'));
m_adapter = m_objectPath.left(objectPath.size() - 18);
m_address = m_objectPath.right(17);
+ kdDebug() << "Connecting to ObjectPath: " << objectPath;
- device = new QDBusInterface("org.bluez", m_adapter,
- "org.bluez.Adapter", QDBusConnection::systemBus());
- #define connectAdapterToThis(signal, slot) \
+ device = new QDBusInterface("org.bluez", objectPath,
+ "org.bluez.Device", QDBusConnection::systemBus());
+ #define connectDeviceToThis(signal, slot) \
device->connection().connect("org.bluez", \
- m_adapter, \
- "org.bluez.Adapter", \
+ objectPath, \
+ "org.bluez.Device", \
signal, this, SLOT(slot))
- connectAdapterToThis("RemoteClassUpdated",slotClassChanged(const QString&, uint));
- connectAdapterToThis("RemoteNameUpdated",slotNameUpdated(const QString &,const QString &));
- connectAdapterToThis("RemoteNameFailed",slotNameResolvingFailed(const QString &));
- connectAdapterToThis("RemoteAliasChanged",slotAliasChanged(const QString &,const QString &));
- connectAdapterToThis("RemoteAliasCleared",slotAliasCleared(const QString &));
- connectAdapterToThis("RemoteDeviceConnected",slotConnected(const QString &));
- connectAdapterToThis("RemoteDeviceDisconnectRequested",slotRequestDisconnection(const QString &));
- connectAdapterToThis("RemoteDeviceDisconnected",slotDisconnected(const QString &));
- connectAdapterToThis("BondingCreated",slotBonded(const QString &));
- connectAdapterToThis("BondingRemoved",slotUnbonded(const QString &));
+ connectDeviceToThis("PropertyChanged",slotPropertyChanged(const QString &,const QDBusVariant &));
+ connectDeviceToThis("DisconnectRequested",slotDisconnectRequested());
+ connectDeviceToThis("NodeCreated",slotNodeCreated(const QDBusObjectPath &));
+ connectDeviceToThis("NodeRemoved",slotNodeRemoved(const QDBusObjectPath &));
+
+
}
BluezBluetoothRemoteDevice::~BluezBluetoothRemoteDevice()
@@ -68,98 +66,60 @@
QString BluezBluetoothRemoteDevice::ubi() const
{
- return m_objectPath;
+ return device->path();
}
-QString BluezBluetoothRemoteDevice::address() const
+QMap<QString,QVariant> BluezBluetoothRemoteDevice::getProperties() const
{
- return m_address;
-}
+ QDBusReply< QMap<QString,QVariant> > path = device->call("GetProperties");
+ if (!path.isValid())
+ return QMap<QString,QVariant>();
-bool BluezBluetoothRemoteDevice::isConnected() const
-{
- return boolReply("IsConnected");
+ return path.value();
}
-QString BluezBluetoothRemoteDevice::name() const
+void BluezBluetoothRemoteDevice::setProperty(const QString &name, const QVariant &value)
{
- return stringReply("GetRemoteName");
+ device->call("SetProperty",name,qVariantFromValue(QDBusVariant(value)));
}
-QString BluezBluetoothRemoteDevice::version() const
+void BluezBluetoothRemoteDevice::discoverServices(const QString& pattern) const
{
- return stringReply("GetRemoteVersion");
+ QList<QVariant> args;
+ args << pattern;
+ device->callWithCallback("DiscoverServices",
+ args,
+ (QObject*)this,
+ SLOT(slotServiceDiscover(const QMap<uint,QString> &)),
+ SLOT(dbusErrorServiceDiscover(const QDBusError &)));
+
}
-QString BluezBluetoothRemoteDevice::revision() const
+void BluezBluetoothRemoteDevice::cancelDiscovery()
{
- return stringReply("GetRemoteRevision");
+ device->call("CancelDiscovery");
}
-QString BluezBluetoothRemoteDevice::manufacturer() const
+void BluezBluetoothRemoteDevice::disconnect()
{
- return stringReply("GetRemoteManufacturer");
+ device->call("Disconnect");
}
-QString BluezBluetoothRemoteDevice::company() const
+QStringList BluezBluetoothRemoteDevice::listNodes() const
{
- return stringReply("GetRemoteCompany");
-}
+ QStringList list;
+ QDBusReply< QList<QDBusObjectPath> > path = device->call("ListNodes");
+ if (path.isValid()) {
+ foreach(QDBusObjectPath objectPath, path.value()) {
+ list.append(objectPath.path());
+ }
+ return list;
+ }
-QString BluezBluetoothRemoteDevice::majorClass() const
-{
- return stringReply("GetRemoteMajorClass");
+ return QStringList();
}
-QString BluezBluetoothRemoteDevice::minorClass() const
-{
- return stringReply("GetRemoteMinorClass");
-}
-
-QStringList BluezBluetoothRemoteDevice::serviceClasses() const
-{
- return listReply("GetRemoteServiceClasses");
-}
-
-QString BluezBluetoothRemoteDevice::alias() const
-{
- return stringReply("GetRemoteAlias");
-}
-
-QString BluezBluetoothRemoteDevice::lastSeen() const
-{
- return stringReply("LastSeen");
-}
-
-QString BluezBluetoothRemoteDevice::lastUsed() const
-{
- return stringReply("LastUsed");
-}
-
-bool BluezBluetoothRemoteDevice::hasBonding() const
-{
-
- return boolReply("HasBonding");
-}
-
-int BluezBluetoothRemoteDevice::pinCodeLength() const
-{
- QDBusReply< int > path = device->call("PinCodeLength", m_address);
- if (!path.isValid())
- return false;
-
- return path.value();
-}
-
-int BluezBluetoothRemoteDevice::encryptionKeySize() const
-{
- QDBusReply< int > path = device->call("EncryptionKeySize", m_address);
- if (!path.isValid())
- return false;
-
- return path.value();
-}
-
+/*
KJob *BluezBluetoothRemoteDevice::createBonding()
{
QList<QVariant> params;
@@ -169,31 +129,7 @@
"org.bluez.Adapter", "CreateBonding", params);
}
-void BluezBluetoothRemoteDevice::setAlias(const QString &alias)
-{
- device->call("SetRemoteAlias",m_address,alias);
-}
-void BluezBluetoothRemoteDevice::clearAlias()
-{
- device->call("ClearRemoteAlias", m_address);
-}
-
-void BluezBluetoothRemoteDevice::disconnect()
-{
- device->call("DisconnectRemoteDevice", m_address);
-}
-
-void BluezBluetoothRemoteDevice::cancelBondingProcess()
-{
- device->call("CancelBondingProcess", m_address);
-}
-
-void BluezBluetoothRemoteDevice::removeBonding()
-{
- device->call("RemoveBonding", m_address);
-}
-
void BluezBluetoothRemoteDevice::serviceHandles(const QString &filter) const
{
QList<QVariant> args;
@@ -216,15 +152,18 @@
SLOT(slotServiceRecordAsXml(const QString &)),
SLOT(dbusErrorRecordAsXml(const QDBusError &)));
}
-void BluezBluetoothRemoteDevice::slotServiceHandles(const QList< uint > & handles)
-{
- emit serviceHandlesAvailable(ubi(),handles);
-}
void BluezBluetoothRemoteDevice::slotServiceRecordAsXml(const QString & record)
{
emit serviceRecordXmlAvailable(ubi(),record);
}
+*/
+void BluezBluetoothRemoteDevice::slotServiceDiscover(const QMap< uint,QString > & handles)
+{
+ emit serviceDiscoverAvailable("success",handles);
+}
+
+
/******************************/
QStringList BluezBluetoothRemoteDevice::listReply(const QString &method) const
@@ -254,86 +193,31 @@
return reply.value();
}
-void BluezBluetoothRemoteDevice::dbusErrorHandles(const QDBusError &error)
+void BluezBluetoothRemoteDevice::dbusErrorServiceDiscover(const QDBusError &error)
{
- kDebug() << "Error on dbus call for handles: " << error.message();
- emit serviceHandlesAvailable("failed",QList<uint>());
+ kDebug() << "Error on dbus call for DiscoverServices: " << error.message();
+ emit serviceDiscoverAvailable("failed",QMap<uint,QString>());
}
-void BluezBluetoothRemoteDevice::dbusErrorRecordAsXml(const QDBusError & error)
+void BluezBluetoothRemoteDevice::slotPropertyChanged(const QString &prop, const QDBusVariant &value)
{
- kDebug() << "Error on dbus call for record as xml: " << error.message();
- emit serviceRecordXmlAvailable("failed","");
+ emit propertyChanged(prop, value.variant());
}
-void BluezBluetoothRemoteDevice::slotClassChanged(const QString & address, uint newClass)
+void BluezBluetoothRemoteDevice::slotDisconnectRequested()
{
- if (address == this->address()) {
- emit classChanged(newClass);
- }
+ emit disconnectRequested();
}
-void BluezBluetoothRemoteDevice::slotNameResolvingFailed(const QString & address)
+void BluezBluetoothRemoteDevice::slotNodeCreated(const QDBusObjectPath &path)
{
- if (address == this->address()) {
- emit nameResolvingFailed();
- }
+ emit nodeCreated(path.path());
}
-void BluezBluetoothRemoteDevice::slotNameUpdated(const QString & address, const QString & newName)
+void BluezBluetoothRemoteDevice::slotNodeRemoved(const QDBusObjectPath &path)
{
- if (address == this->address()) {
- emit nameChanged(newName);
- }
+ emit nodeRemoved(path.path());
}
-void BluezBluetoothRemoteDevice::slotAliasChanged(const QString & address, const QString & newAlias)
-{
- if (address == this->address()) {
- emit aliasChanged(newAlias);
- }
-}
-void BluezBluetoothRemoteDevice::slotAliasCleared(const QString & address)
-{
- if (address == this->address()) {
- emit aliasCleared();
- }
-}
-
-void BluezBluetoothRemoteDevice::slotConnected(const QString & address)
-{
- if (address == this->address()) {
- emit connected();
- }
-}
-
-void BluezBluetoothRemoteDevice::slotRequestDisconnection(const QString & address)
-{
- if (address == this->address()) {
- emit requestDisconnection();
- }
-}
-
-void BluezBluetoothRemoteDevice::slotDisconnected(const QString & address)
-{
- if (address == this->address()) {
- emit disconnected();
- }
-}
-
-void BluezBluetoothRemoteDevice::slotBonded(const QString & address)
-{
- if (address == this->address()) {
- emit bondingCreated();
- }
-}
-
-void BluezBluetoothRemoteDevice::slotUnbonded(const QString & address)
-{
- if (address == this->address()) {
- emit bondingRemoved();
- }
-}
-
#include "bluez-bluetoothremotedevice.moc"
Index: tests/blueztest.cpp
===================================================================
--- tests/blueztest.cpp (.../branches/KDE/4.1/kdebase/workspace/solid/bluez) (revision 912128)
+++ solid/bluez/tests/blueztest.cpp (.../trunk/KDE/kdebase/workspace/solid/bluez) (revision 912128)
@@ -4,7 +4,7 @@
#include "bluez-bluetoothmanager.h"
#include "bluez-bluetoothinterface.h"
-#include "bluez-bluetoothremotedevice.h"
+//#include "bluez-bluetoothremotedevice.h"
int main(int argc, char **argv)
{
@@ -14,15 +14,24 @@
kDebug() << "Interfaces: " << mgr.bluetoothInterfaces();
kDebug() << "Default Interface: " << mgr.defaultInterface();
+ kDebug() << "Finding Interface hci0: " << mgr.findInterface("hci0");
- kDebug() << "Bluetooth Input Devices: " << mgr.bluetoothInputDevices();
+// kDebug() << "Bluetooth Input Devices: " << mgr.bluetoothInputDevices();
+
BluezBluetoothInterface iface(mgr.defaultInterface());
-// iface.discoverDevices();
+ iface.setProperty("Name","testNAME");
- iface.startPeriodicDiscovery();
+ QMap<QString, QVariant> props = iface.getProperties();
+ foreach(QString key, props.keys()) {
+ kDebug() << "Interface Property: " << key << " : " << props[key];
+ }
+
+
+ iface.startDiscovery();
+
#if 0
BluezBluetoothRemoteDevice remote("/org/bluez/hci0/00:16:BC:15:A3:FF");
Index: bluez-bluetoothmanager.h
===================================================================
--- bluez-bluetoothmanager.h (.../branches/KDE/4.1/kdebase/workspace/solid/bluez) (revision 912128)
+++ solid/bluez/bluez-bluetoothmanager.h (.../trunk/KDE/kdebase/workspace/solid/bluez) (revision 912128)
@@ -1,6 +1,7 @@
/* This file is part of the KDE project
Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
Copyright (C) 2007 Daniel Gollub <dgollub@suse.de>
+ Copyright (C) 2008 Tom Patzig <tpatzig@suse.de>
This library is free software; you can redistribute it and/or
@@ -31,7 +32,7 @@
#include <solid/control/ifaces/bluetoothmanager.h>
-class BluezBluetoothSecurity;
+//class BluezBluetoothSecurity;
class BluezBluetoothManagerPrivate;
class KDE_EXPORT BluezBluetoothManager : public Solid::Control::Ifaces::BluetoothManager
{
@@ -42,27 +43,29 @@
virtual ~BluezBluetoothManager();
QStringList bluetoothInterfaces() const;
QObject * createInterface(const QString &);
- QStringList bluetoothInputDevices() const;
+ void removeInterface(const QString& ubi);
+// QStringList bluetoothInputDevices() const;
QString defaultInterface() const;
+ QString findInterface(const QString &) const;
- QObject * createBluetoothInputDevice(const QString &);
- KJob *setupInputDevice(const QString &);
- Solid::Control::Ifaces::BluetoothSecurity* security(const QString &interface);
+// QObject * createBluetoothInputDevice(const QString &);
+// KJob *setupInputDevice(const QString &);
+// Solid::Control::Ifaces::BluetoothSecurity* security(const QString &interface);
public Q_SLOTS:
- void removeInputDevice(const QString &);
+// void removeInputDevice(const QString &);
protected Q_SLOTS:
- void slotDeviceAdded(const QString &);
- void slotDeviceRemoved(const QString &);
- void slotDefaultDeviceChanged(const QString &);
+ void slotDeviceAdded(const QDBusObjectPath &);
+ void slotDeviceRemoved(const QDBusObjectPath &);
+ void slotDefaultDeviceChanged(const QDBusObjectPath &);
- void slotInputDeviceCreated(const QString &);
- void slotInputDeviceRemoved(const QString &);
+// void slotInputDeviceCreated(const QString &);
+// void slotInputDeviceRemoved(const QString &);
private:
BluezBluetoothManagerPrivate * d;
- QString m_inputManagerDest;
+// QString m_inputManagerDest;
};
#endif
Index: bluez-bluetoothinputdevice.cpp
===================================================================
--- bluez-bluetoothinputdevice.cpp (.../branches/KDE/4.1/kdebase/workspace/solid/bluez) (revision 912128)
+++ solid/bluez/bluez-bluetoothinputdevice.cpp (.../trunk/KDE/kdebase/workspace/solid/bluez) (revision 912128)
@@ -1,6 +1,7 @@
/* This file is part of the KDE project
Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
Copyright (C) 2007 Daniel Gollub <dgollub@suse.de>
+ Copyright (C) 2008 Tom Patzig <tpatzig@suse.de>
This library is free software; you can redistribute it and/or
@@ -25,11 +26,16 @@
#include <kdebug.h>
-BluezBluetoothInputDevice::BluezBluetoothInputDevice(const QString &objectPath,
- const QString &dest) : BluetoothInputDevice(0), m_objectPath(objectPath)
+BluezBluetoothInputDevice::BluezBluetoothInputDevice(const QString &objectPath) : BluetoothInputDevice(0), m_objectPath(objectPath)
{
- device = new QDBusInterface(dest, m_objectPath,
- "org.bluez.input.Device", QDBusConnection::systemBus());
+ device = new QDBusInterface("org.bluez", m_objectPath,
+ "org.bluez.Input", QDBusConnection::systemBus());
+ #define connectInputDeviceToThis(signal, slot) \
+ device->connection().connect("org.bluez", \
+ objectPath, \
+ "org.bluez.Input", \
+ signal, this, SLOT(slot))
+ connectInputDeviceToThis("PropertyChanged",slotPropertyChanged(const QString &,const QDBusVariant &));
}
@@ -43,40 +49,25 @@
return m_objectPath;
}
-QString BluezBluetoothInputDevice::address() const
+QMap<QString,QVariant> BluezBluetoothInputDevice::getProperties() const
{
- return stringReply("GetAddress");
-}
+ QDBusReply< QMap<QString,QVariant> > path = device->call("GetProperties");
+ if (!path.isValid())
+ return QMap<QString,QVariant>();
-bool BluezBluetoothInputDevice::isConnected() const
-{
- return boolReply("IsConnected");
+ return path.value();
}
-QString BluezBluetoothInputDevice::name() const
+void BluezBluetoothInputDevice::disconnect()
{
- return stringReply("GetName");
+ device->call("Disconnect");
}
-QString BluezBluetoothInputDevice::productID() const
+void BluezBluetoothInputDevice::connect()
{
- return stringReply("GetProductID");
-}
-
-QString BluezBluetoothInputDevice::vendorID() const
-{
- return stringReply("GetVendorID");
-}
-
-void BluezBluetoothInputDevice::slotConnect()
-{
device->call("Connect");
}
-void BluezBluetoothInputDevice::slotDisconnect()
-{
- device->call("Disconnect");
-}
/******************************/
@@ -98,4 +89,11 @@
return reply.value();
}
+/******************************/
+
+void BluezBluetoothInputDevice::slotPropertyChanged(const QString & name, const QDBusVariant& value)
+{
+ emit propertyChanged(name,value.variant());
+}
+
#include "bluez-bluetoothinputdevice.moc"
Index: bluez-bluetoothremotedevice.h
===================================================================
--- bluez-bluetoothremotedevice.h (.../branches/KDE/4.1/kdebase/workspace/solid/bluez) (revision 912128)
+++ solid/bluez/bluez-bluetoothremotedevice.h (.../trunk/KDE/kdebase/workspace/solid/bluez) (revision 912128)
@@ -1,6 +1,7 @@
/* This file is part of the KDE project
Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
Copyright (C) 2007 Daniel Gollub <dgollub@suse.de>
+ Copyright (C) 2008 Tom Patzig <tpatzig@suse.de>
This library is free software; you can redistribute it and/or
@@ -35,64 +36,36 @@
public:
BluezBluetoothRemoteDevice(const QString &objectPath);
virtual ~BluezBluetoothRemoteDevice();
+
QString ubi() const;
- QString address() const;
- bool isConnected() const;
- QString version() const;
- QString revision() const;
- QString manufacturer() const;
- QString company() const;
- QString majorClass() const;
- QString minorClass() const;
- QStringList serviceClasses() const;
- QString name() const;
- QString alias() const;
- QString lastSeen() const;
- QString lastUsed() const;
- bool hasBonding() const;
- int pinCodeLength() const;
- int encryptionKeySize() const;
+ QMap<QString,QVariant> getProperties() const;
+ void discoverServices(const QString &pattern) const;
+ QStringList listNodes() const;
- KJob *createBonding();
private Q_SLOTS:
- void slotClassChanged(const QString &address, uint newClass);
- void slotNameUpdated(const QString &address,const QString &newName);
- void slotNameResolvingFailed(const QString &address);
- void slotAliasChanged(const QString &address,const QString &newAlias);
- void slotAliasCleared(const QString &address);
- void slotConnected(const QString &address);
- void slotRequestDisconnection(const QString &address);
- void slotDisconnected(const QString &address);
- void slotBonded(const QString &address);
- void slotUnbonded(const QString &address);
-
- void slotServiceHandles(const QList<uint> &handles);
- void dbusErrorHandles(const QDBusError &error);
- void slotServiceRecordAsXml(const QString &record);
- void dbusErrorRecordAsXml(const QDBusError &error);
+ void slotPropertyChanged(const QString &, const QDBusVariant &);
+ void slotDisconnectRequested();
+ void slotNodeCreated(const QDBusObjectPath &);
+ void slotNodeRemoved(const QDBusObjectPath &);
+
+ void slotServiceDiscover(const QMap<uint,QString> &handles);
+ void dbusErrorServiceDiscover(const QDBusError &error);
+
public Q_SLOTS:
- void setAlias(const QString &alias);
- void clearAlias();
+
+ void setProperty(const QString &, const QVariant &);
+ void cancelDiscovery();
void disconnect();
- void cancelBondingProcess();
- void removeBonding();
- void serviceHandles(const QString &filter ="") const;
- void serviceRecordAsXml(uint handle) const;
+
Q_SIGNALS:
- void classChanged(uint deviceClass);
- void nameChanged(const QString &name);
- void nameResolvingFailed();
- void aliasChanged(const QString &alias);
- void aliasCleared();
- void connected();
- void requestDisconnection();
- void disconnected();
- void bondingCreated();
- void bondingRemoved();
- void serviceRecordXmlAvailable(const QString &ubi, const QString &record);
- void serviceHandlesAvailable(const QString &ubi, const QList<uint> &handles);
+ void serviceDiscoverAvailable(const QString &state, const QMap<uint,QString> &handles);
+ void propertyChanged(const QString &, const QVariant &);
+ void disconnectRequested();
+ void nodeCreated(const QString &);
+ void nodeRemoved(const QString &);
+
private:
QString m_objectPath;
QDBusInterface *device;
Index: bluez-bluetoothinputdevice.h
===================================================================
--- bluez-bluetoothinputdevice.h (.../branches/KDE/4.1/kdebase/workspace/solid/bluez) (revision 912128)
+++ solid/bluez/bluez-bluetoothinputdevice.h (.../trunk/KDE/kdebase/workspace/solid/bluez) (revision 912128)
@@ -1,6 +1,7 @@
/* This file is part of the KDE project
Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
Copyright (C) 2007 Daniel Gollub <dgollub@suse.de>
+ Copyright (C) 2008 Tom Patzig <tpatzig@suse.de>
This library is free software; you can redistribute it and/or
@@ -23,6 +24,8 @@
#define BLUEZ_BLUETOOTHINPUTDEVICE_H
#include <kdemacros.h>
+#include <QMap>
+#include <QtDBus>
#include <solid/control/ifaces/bluetoothinputdevice.h>
@@ -33,23 +36,23 @@
Q_OBJECT
Q_INTERFACES(Solid::Control::Ifaces::BluetoothInputDevice)
public:
- BluezBluetoothInputDevice(const QString &objectPath, const QString &dest);
+ BluezBluetoothInputDevice(const QString &objectPath);
virtual ~BluezBluetoothInputDevice();
QString ubi() const;
- QString address() const;
- bool isConnected() const;
- QString name() const;
- QString productID() const;
- QString vendorID() const;
+ QMap<QString,QVariant> getProperties() const;
+private Q_SLOTS:
+ void slotPropertyChanged(const QString &, const QDBusVariant &);
+
+
public Q_SLOTS:
- void slotConnect();
- void slotDisconnect();
+ void disconnect();
+ void connect();
Q_SIGNALS:
- void connected();
- void disconnected();
+ void propertyChanged(const QString &, const QVariant &);
+
private:
QString m_objectPath;
QDBusInterface *device;
diff -Nur -x '[^b][^l]*' -x .svn 4_1libsControl/bluetoothinputdevice.cpp kdebase/workspace/libs/solid/control/bluetoothinputdevice.cpp
--- 4_1libsControl/bluetoothinputdevice.cpp 2009-01-16 17:04:06.000000000 +0100
+++ libs/solid/control/bluetoothinputdevice.cpp 2009-01-14 21:06:47.000000000 +0100
@@ -19,7 +19,6 @@
*/
-#include <QMap>
#include <QStringList>
#include "ifaces/bluetoothinputdevice.h"
@@ -72,39 +71,19 @@
return_SOLID_CALL(Ifaces::BluetoothInputDevice *, d->backendObject(), QString(), ubi());
}
-bool Solid::Control::BluetoothInputDevice::isConnected() const
+QMap<QString,QVariant> Solid::Control::BluetoothInputDevice::getProperties() const
{
- return_SOLID_CALL(Ifaces::BluetoothInputDevice *, d->backendObject(), false, isConnected());
+ return_SOLID_CALL(Ifaces::BluetoothInputDevice *, d->backendObject(), (QMap< QString,QVariant >()), getProperties());
}
-QString Solid::Control::BluetoothInputDevice::name() const
+void Solid::Control::BluetoothInputDevice::connect()
{
- return_SOLID_CALL(Ifaces::BluetoothInputDevice *, d->backendObject(), QString(), name());
+ SOLID_CALL(Ifaces::BluetoothInputDevice *, d->backendObject(), connect());
}
-QString Solid::Control::BluetoothInputDevice::address() const
+void Solid::Control::BluetoothInputDevice::disconnect()
{
- return_SOLID_CALL(Ifaces::BluetoothInputDevice *, d->backendObject(), QString(), address());
-}
-
-QString Solid::Control::BluetoothInputDevice::productID() const
-{
- return_SOLID_CALL(Ifaces::BluetoothInputDevice *, d->backendObject(), QString(), productID());
-}
-
-QString Solid::Control::BluetoothInputDevice::vendorID() const
-{
- return_SOLID_CALL(Ifaces::BluetoothInputDevice *, d->backendObject(), QString(), vendorID());
-}
-
-void Solid::Control::BluetoothInputDevice::slotConnect()
-{
- SOLID_CALL(Ifaces::BluetoothInputDevice *, d->backendObject(), slotConnect());
-}
-
-void Solid::Control::BluetoothInputDevice::slotDisconnect()
-{
- SOLID_CALL(Ifaces::BluetoothInputDevice *, d->backendObject(), slotDisconnect());
+ SOLID_CALL(Ifaces::BluetoothInputDevice *, d->backendObject(), disconnect());
}
void Solid::Control::BluetoothInputDevicePrivate::setBackendObject(QObject *object)
@@ -112,10 +91,8 @@
FrontendObjectPrivate::setBackendObject(object);
if (object) {
- QObject::connect(object, SIGNAL(connected()),
- parent(), SIGNAL(connected()));
- QObject::connect(object, SIGNAL(disconnected()),
- parent(), SIGNAL(disconnected()));
+ QObject::connect(object, SIGNAL(propertyChanged(const QString&,const QVariant&)),
+ parent(), SIGNAL(propertyChanged(const QString,const QVariant&)));
}
}
diff -Nur -x '[^b][^l]*' -x .svn 4_1libsControl/bluetoothinputdevice.h kdebase/workspace/libs/solid/control/bluetoothinputdevice.h
--- 4_1libsControl/bluetoothinputdevice.h 2009-01-16 17:04:06.000000000 +0100
+++ libs/solid/control/bluetoothinputdevice.h 2008-10-25 18:36:03.000000000 +0200
@@ -1,6 +1,7 @@
/* This file is part of the KDE project
Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
Copyright (C) 2007 Daniel Gollub <dgollub@suse.de>
+ Copyright (C) 2008 Tom Patzig <tpatzig@suse.de>
This library is free software; you can redistribute it and/or
@@ -23,6 +24,8 @@
#define SOLID_CONTROL_BLUETOOTHINPUTDEVICE_H
#include <QtCore/QObject>
+#include <QtCore/QMap>
+#include <QtCore/QVariant>
#include "solid_control_export.h"
@@ -74,65 +77,36 @@
* @returns the Universal Network Identifier of the current bluetooth remote device
*/
QString ubi() const;
-
- /**
- * Retrieves connection status of bluetooth input device.
- *
- * @returns true if bluetooth input device is connected
- */
- bool isConnected() const;
-
- /**
- * Retrieves MAC address of bluetooth input device.
- *
- * @returns MAC address of bluetooth input device
- */
- QString address() const;
-
- /**
- * Retrievies Name of bluetooth input device.
- *
- * @returns Name of bluetooth input device
- */
- QString name() const;
-
/**
- * Retrieves Product ID of bluetooth input device.
+ * Retrieve all properties from the input device.
*
- * @returns Product ID of bluetooth input device
+ * @returns a hash of named properties
*/
- QString productID() const;
+ QMap<QString,QVariant> getProperties() const;
- /**
- * Retrieves Vendor ID of bluetooth input device.
- *
- * @returns Vendor ID of bluetooth input device
- */
- QString vendorID() const;
public Q_SLOTS:
/**
* Connect bluetooth input device.
*/
- void slotConnect();
+ void connect();
/**
* Disconnect bluetooth input device.
*/
- void slotDisconnect();
+ void disconnect();
Q_SIGNALS:
- /**
- * This signal is emitted when the bluetooth input device is connected.
+ /**
+ * A Property for the input device has changed.
+ *
+ * @param name the name of the changed property
+ * @param value the new value
*/
- void connected();
+ void propertyChanged(const QString &name, const QVariant &value);
- /**
- * This signal is emitted when the bluetooth input device is not available anymore.
- */
- void disconnected();
private:
Q_PRIVATE_SLOT(d, void _k_destroyed(QObject *))
diff -Nur -x '[^b][^l]*' -x .svn 4_1libsControl/bluetoothinterface.cpp kdebase/workspace/libs/solid/control/bluetoothinterface.cpp
--- 4_1libsControl/bluetoothinterface.cpp 2009-01-16 17:04:06.000000000 +0100
+++ libs/solid/control/bluetoothinterface.cpp 2009-01-16 12:11:03.000000000 +0100
@@ -1,6 +1,7 @@
/* This file is part of the KDE project
Copyright (C) 2006 Will Stephenson <wstephenson@kde.org>
Copyright (C) 2007 Daniel Gollub <dgollub@suse.de>
+ Copyright (C) 2008 Tom Patzig <tpatzig@suse.de>
This library is free software; you can redistribute it and/or
@@ -22,8 +23,9 @@
#include <QMap>
#include <QPair>
#include <QStringList>
+#include <QVariant>
-#include <kdebug.h>
+#include <KDebug>
#include "ifaces/bluetoothinterface.h"
@@ -47,9 +49,12 @@
void setBackendObject(QObject *object);
QPair<BluetoothRemoteDevice *, Ifaces::BluetoothRemoteDevice *> findRegisteredBluetoothRemoteDevice(const QString &ubi) const;
+ QPair<BluetoothInputDevice *, Ifaces::BluetoothInputDevice *> findRegisteredBluetoothInputDevice(const QString &ubi) const;
mutable QMap<QString, QPair<BluetoothRemoteDevice *, Ifaces::BluetoothRemoteDevice *> > remoteDeviceMap;
+ mutable QMap<QString, QPair<BluetoothInputDevice *, Ifaces::BluetoothInputDevice *> > inputDeviceMap;
mutable BluetoothRemoteDevice invalidDevice;
+ mutable BluetoothInputDevice invalidInputDevice;
};
}
}
@@ -63,30 +68,39 @@
{
const BluetoothInterface &device = BluetoothManager::self().findBluetoothInterface(ubi);
d->setBackendObject(device.d->backendObject());
+ QObject::connect(d->backendObject(), SIGNAL(deviceCreated(const QString &)),this, SLOT(slotDeviceCreated(const QString &)));
}
Solid::Control::BluetoothInterface::BluetoothInterface(QObject *backendObject)
: QObject(), d(new BluetoothInterfacePrivate(this))
{
d->setBackendObject(backendObject);
+ QObject::connect(d->backendObject(), SIGNAL(deviceCreated(const QString &)),this, SLOT(slotDeviceCreated(const QString &)));
}
Solid::Control::BluetoothInterface::BluetoothInterface(const BluetoothInterface &device)
: QObject(), d(new BluetoothInterfacePrivate(this))
{
d->setBackendObject(device.d->backendObject());
+ QObject::connect(d->backendObject(), SIGNAL(deviceCreated(const QString &)),this, SLOT(slotDeviceCreated(const QString &)));
}
Solid::Control::BluetoothInterface::~BluetoothInterface()
{
// Delete all the interfaces, they are now outdated
typedef QPair<BluetoothRemoteDevice *, Ifaces::BluetoothRemoteDevice *> BluetoothRemoteDeviceIfacePair;
+ typedef QPair<BluetoothInputDevice *, Ifaces::BluetoothInputDevice *> BluetoothInputDeviceIfacePair;
// Delete all the devices, they are now outdated
foreach (const BluetoothRemoteDeviceIfacePair &pair, d->remoteDeviceMap.values()) {
delete pair.first;
delete pair.second;
}
+ foreach (const BluetoothInputDeviceIfacePair &pair, d->inputDeviceMap.values()) {
+ delete pair.first;
+ delete pair.second;
+ }
+
}
Solid::Control::BluetoothInterface &Solid::Control::BluetoothInterface::operator=(const Solid::Control::BluetoothInterface & dev)
@@ -101,8 +115,98 @@
return_SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), QString(), ubi());
}
-Solid::Control::BluetoothRemoteDevice Solid::Control::BluetoothInterface::findBluetoothRemoteDevice(const QString &ubi) const
+void Solid::Control::BluetoothInterface::cancelDeviceCreation(const QString &address) const
+{
+ SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), cancelDeviceCreation(address));
+}
+
+void Solid::Control::BluetoothInterface::createPairedDevice(const QString &address,const QString &adapterPath, const QString &capab) const
+{
+ Ifaces::BluetoothInterface *backend = qobject_cast<Ifaces::BluetoothInterface *>(d->backendObject());
+ if (backend == 0)
+ return;
+ backend->createPairedDevice(address,adapterPath,capab);
+}
+
+QMap<QString, QVariant> Solid::Control::BluetoothInterface::getProperties() const
+{
+ return_SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), (QMap<QString,QVariant>()), getProperties());
+}
+
+QVariant Solid::Control::BluetoothInterface::getProperty(const QString &key) const
+{
+ QMap<QString, QVariant> props = getProperties();
+ if (props.contains(key))
+ return props[key];
+ else
+ return QVariant();
+}
+
+Solid::Control::BluetoothRemoteDeviceList Solid::Control::BluetoothInterface::listDevices() const
+{
+ Ifaces::BluetoothInterface *backend = qobject_cast<Ifaces::BluetoothInterface *>(d->backendObject());
+ if (backend == 0)
+ return Solid::Control::BluetoothRemoteDeviceList();
+
+ QStringList ubis = backend->listDevices();
+
+ Solid::Control::BluetoothRemoteDeviceList list;
+ foreach (const QString& ubi,ubis) {
+ BluetoothRemoteDevice* remoteDevice = findBluetoothRemoteDeviceUBI(ubi);
+ list.append(remoteDevice);
+ }
+ return list;
+}
+
+void Solid::Control::BluetoothInterface::registerAgent(const QString &path, const QString &capab) const
+{
+ SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), registerAgent(path,capab));
+}
+
+void Solid::Control::BluetoothInterface::releaseSession() const
+{
+ SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), releaseSession());
+}
+
+void Solid::Control::BluetoothInterface::requestSession() const
{
+ SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), requestSession());
+}
+
+void Solid::Control::BluetoothInterface::removeDevice(const QString &path) const
+{
+ SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), removeDevice(path));
+}
+
+void Solid::Control::BluetoothInterface::setProperty(const QString &property, const QVariant &value) const
+{
+ SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), setProperty(property,value));
+}
+
+void Solid::Control::BluetoothInterface::startDiscovery() const
+{
+ SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), startDiscovery());
+}
+
+void Solid::Control::BluetoothInterface::stopDiscovery() const
+{
+ SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), stopDiscovery());
+}
+
+void Solid::Control::BluetoothInterface::unregisterAgent(const QString &path) const
+{
+ SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), unregisterAgent(path));
+}
+
+
+Solid::Control::BluetoothRemoteDevice Solid::Control::BluetoothInterface::findBluetoothRemoteDeviceAddr(const QString &address) const
+{
+ Ifaces::BluetoothInterface *backend = qobject_cast<Ifaces::BluetoothInterface *>(d->backendObject());
+ if (backend == 0)
+ return d->invalidDevice;
+
+ const QString ubi = getBluetoothRemoteDeviceUBI(address);
+
QPair<BluetoothRemoteDevice *, Ifaces::BluetoothRemoteDevice *> pair = d->findRegisteredBluetoothRemoteDevice(ubi);
if (pair.first != 0) {
@@ -112,24 +216,70 @@
}
}
-Solid::Control::BluetoothRemoteDevice * Solid::Control::BluetoothInterface::createBluetoothRemoteDevice(const QString &address)
+
+const QString Solid::Control::BluetoothInterface::getBluetoothRemoteDeviceUBI(const QString &address) const
+{
+ Ifaces::BluetoothInterface *backend = qobject_cast<Ifaces::BluetoothInterface *>(d->backendObject());
+ if (backend == 0)
+ return "";
+
+ const QString ubi = backend->findDevice(address);
+ return ubi;
+}
+
+
+void Solid::Control::BluetoothInterface::createBluetoothRemoteDevice(const QString &address)
+{
+ Ifaces::BluetoothInterface *backend = qobject_cast<Ifaces::BluetoothInterface *>(d->backendObject());
+ if (backend == 0)
+ return;
+ backend->createDevice(address);
+}
+
+
+Solid::Control::BluetoothRemoteDevice* Solid::Control::BluetoothInterface::findBluetoothRemoteDeviceUBI(const QString &ubi) const
{
- QString ubi;
- if (address.startsWith("/org/bluez"))
- ubi = address;
- else
- ubi = this->ubi() + "/" + address;
-
- kDebug() << "UBI iam using: " << ubi;
QPair<BluetoothRemoteDevice *, Ifaces::BluetoothRemoteDevice *> pair = d->findRegisteredBluetoothRemoteDevice(ubi);
return pair.first;
+}
+
+Solid::Control::BluetoothInputDevice* Solid::Control::BluetoothInterface::findBluetoothInputDeviceUBI(const QString &ubi) const
+{
+ QPair<BluetoothInputDevice *, Ifaces::BluetoothInputDevice *> pair = d->findRegisteredBluetoothInputDevice(ubi);
+ return pair.first;
+}
+
+void Solid::Control::BluetoothInterface::slotDeviceCreated(const QString& ubi)
+{
+
+ Ifaces::BluetoothInterface *backend = qobject_cast<Ifaces::BluetoothInterface *>(d->backendObject());
+ Ifaces::BluetoothRemoteDevice *iface = 0;
+
+ if (backend != 0) {
+ iface = qobject_cast<Ifaces::BluetoothRemoteDevice *>(backend->createBluetoothRemoteDevice(ubi));
+ }
+
+ if (iface != 0) {
+ BluetoothRemoteDevice *device = new BluetoothRemoteDevice(iface);
+ QPair<BluetoothRemoteDevice *, Ifaces::BluetoothRemoteDevice *> pair(device, iface);
+ d->remoteDeviceMap[ubi] = pair;
+ }
}
+
QString Solid::Control::BluetoothInterface::address() const
{
- return_SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), QString(), address());
+ QVariant var = getProperty("Address");
+
+ if (var.isValid())
+ return var.value<QString>();
+ else
+ return QString();
+
+// return_SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), QString(), address());
}
+/*
QString Solid::Control::BluetoothInterface::version() const
{
return_SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), QString(), version());
@@ -149,22 +299,44 @@
{
return_SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), QString(), company());
}
+*/
-Solid::Control::BluetoothInterface::Mode Solid::Control::BluetoothInterface::mode() const
-{
- return_SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), Solid::Control::BluetoothInterface::Off, mode());
-}
int Solid::Control::BluetoothInterface::discoverableTimeout() const
{
- return_SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), 0, discoverableTimeout());
+ QVariant var = getProperty("DiscoverableTimeout");
+
+ if (var.isValid())
+ return var.value<int>();
+ else
+ return 0;
+
+// return_SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), 0, discoverableTimeout());
}
bool Solid::Control::BluetoothInterface::isDiscoverable() const
{
- return_SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), false, isDiscoverable());
+ QVariant var = getProperty("Discoverable");
+
+ if (var.isValid())
+ return var.value<bool>();
+ else
+ return false;
+
+// return_SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), false, isDiscoverable());
+}
+
+bool Solid::Control::BluetoothInterface::isDiscovering() const
+{
+ QVariant var = getProperty("Discovering");
+
+ if (var.isValid())
+ return var.value<bool>();
+ else
+ return false;
}
+/*
Solid::Control::BluetoothRemoteDeviceList Solid::Control::BluetoothInterface::listConnections() const
{
BluetoothRemoteDeviceList list;
@@ -201,12 +373,21 @@
{
return_SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), QStringList(), serviceClasses());
}
+*/
QString Solid::Control::BluetoothInterface::name() const
{
- return_SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), QString(), name());
+ QVariant var = getProperty("Name");
+
+ if (var.isValid())
+ return var.value<QString>();
+ else
+ return QString();
+
+// return_SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), QString(), name());
}
+/*
QString Solid::Control::BluetoothInterface::getRemoteName(const QString &mac)
{
return_SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), QString(), getRemoteName(mac));
@@ -247,28 +428,34 @@
listRecentRemoteDevices(date));
}
+*/
+
/***************************************************************/
-void Solid::Control::BluetoothInterface::setMode(const Solid::Control::BluetoothInterface::Mode mode)
+void Solid::Control::BluetoothInterface::setDiscoverable(bool status)
{
- SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), setMode(mode));
+ QVariant var(status);
+ setProperty("Discoverable",var);
}
void Solid::Control::BluetoothInterface::setDiscoverableTimeout(int timeout)
{
- SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), setDiscoverableTimeout(timeout));
+ QVariant var(timeout);
+ setProperty("DiscoverableTimeout",var);
}
+/*
void Solid::Control::BluetoothInterface::setMinorClass(const QString &minor)
{
SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), setMinorClass(minor));
}
-
+*/
void Solid::Control::BluetoothInterface::setName(const QString &name)
{
- SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), setName(name));
+ QVariant var(name);
+ setProperty("Name",var);
}
-
+/*
void Solid::Control::BluetoothInterface::discoverDevices()
{
SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), discoverDevices());
@@ -309,11 +496,14 @@
SOLID_CALL(Ifaces::BluetoothInterface *, d->backendObject(), removeTrust(address));
}
+*/
+
void Solid::Control::BluetoothInterfacePrivate::setBackendObject(QObject *object)
{
FrontendObjectPrivate::setBackendObject(object);
if (object) {
+/*
QObject::connect(object, SIGNAL(modeChanged(Solid::Control::BluetoothInterface::Mode)),parent(), SIGNAL(modeChanged(Solid::Control::BluetoothInterface::Mode)));
QObject::connect(object, SIGNAL(discoverableTimeoutChanged(int)),
parent(), SIGNAL(discoverableTimeoutChanged(int)));
@@ -343,6 +533,17 @@
parent(), SIGNAL(bondingCreated(const QString &)));
QObject::connect(object, SIGNAL(bondingRemoved(const QString &)),
parent(), SIGNAL(bondingRemoved(const QString &)));
+*/
+ QObject::connect(object, SIGNAL(deviceCreated(const QString &)),
+ parent(), SIGNAL(deviceCreated(const QString &)));
+ QObject::connect(object, SIGNAL(deviceDisappeared(const QString &)),
+ parent(), SIGNAL(deviceDisappeared(const QString &)));
+ QObject::connect(object, SIGNAL(deviceFound(const QString &, const QMap<QString,QVariant> &)),
+ parent(), SIGNAL(deviceFound(const QString &, const QMap<QString,QVariant> &)));
+ QObject::connect(object, SIGNAL(deviceRemoved(const QString &)),
+ parent(), SIGNAL(deviceRemoved(const QString &)));
+ QObject::connect(object, SIGNAL(propertyChanged(const QString &,const QVariant &)),
+ parent(), SIGNAL(propertyChanged(const QString &, const QVariant &)));
}
}
@@ -371,6 +572,32 @@
}
}
+}
+
+QPair<Solid::Control::BluetoothInputDevice *, Solid::Control::Ifaces::BluetoothInputDevice *> Solid::Control::BluetoothInterfacePrivate::findRegisteredBluetoothInputDevice(const QString &ubi) const
+{
+ if (inputDeviceMap.contains(ubi)) {
+ return inputDeviceMap[ubi];
+ } else {
+ Ifaces::BluetoothInterface *backend = qobject_cast<Ifaces::BluetoothInterface *>(backendObject());
+ Ifaces::BluetoothInputDevice *iface = 0;
+
+ if (backend != 0) {
+ iface = qobject_cast<Ifaces::BluetoothInputDevice *>(backend->createBluetoothInputDevice(ubi));
+ }
+
+ if (iface != 0) {
+ BluetoothInputDevice *device = new BluetoothInputDevice(iface);
+
+ QPair<BluetoothInputDevice *, Ifaces::BluetoothInputDevice *> pair(device, iface);
+ inputDeviceMap[ubi] = pair;
+
+ return pair;
+ } else {
+ return QPair<BluetoothInputDevice *, Ifaces::BluetoothInputDevice *>(0, 0);
+ }
+
+ }
}
#include "bluetoothinterface.moc"
diff -Nur -x '[^b][^l]*' -x .svn 4_1libsControl/bluetoothinterface.h kdebase/workspace/libs/solid/control/bluetoothinterface.h
--- 4_1libsControl/bluetoothinterface.h 2009-01-16 17:04:06.000000000 +0100
+++ libs/solid/control/bluetoothinterface.h 2009-01-14 14:17:14.000000000 +0100
@@ -25,9 +25,12 @@
#include <QtCore/QDateTime>
#include <QtCore/QPair>
#include <QtCore/QObject>
+#include <QtCore/QMap>
#include "bluetoothremotedevice.h"
+#include "bluetoothinputdevice.h"
#include "ifaces/bluetoothremotedevice.h"
+#include "ifaces/bluetoothinputdevice.h"
@@ -36,7 +39,7 @@
namespace Control
{
class BluetoothRemoteDevice;
-typedef QList<BluetoothRemoteDevice> BluetoothRemoteDeviceList;
+typedef QList<BluetoothRemoteDevice*> BluetoothRemoteDeviceList;
class BluetoothInterfacePrivate;
/**
@@ -46,6 +49,7 @@
{
Q_OBJECT
+
public:
/**
* Describes the operating mode of a bluetooth interface
@@ -54,12 +58,16 @@
* - Discoverable : The interface may be discovered by other devices and connected to
* - Connectable : The interface may only be connected to but not discovered
*/
- enum Mode { Off, Discoverable, Connectable };
+ //enum Mode { Off, Discoverable, Connectable };
+
+
/**
* Constructs an invalid bluetooth interface
*/
BluetoothInterface();
+
+
/**
* Constructs a bluetooth interface for a given Unique Bluetooth Identifier (UBI).
* This object will be auto deleted, DON'T delete it.
@@ -109,7 +117,8 @@
* @param ubi the identifier of the bluetooth device to instantiate
* @returns a bluetooth object, if a bluetooth device having the given UBI, for this interface exists, 0 otherwise
*/
- BluetoothRemoteDevice *createBluetoothRemoteDevice(const QString &address);
+ //Solid::Control::BluetoothRemoteDevice* createBluetoothRemoteDevice(const QString &address);
+ void createBluetoothRemoteDevice(const QString &address);
/**
* Finds a BluetoothRemoteDevice object given its UBI.
@@ -117,7 +126,13 @@
* @param ubi the identifier of the bluetooth remote device to find from this bluetooth interface
* @returns a valid BluetoothRemoteDevice object if a remote device having the given UBI for this interface exists, an invalid BluetoothRemoteDevice object otherwise.
*/
- BluetoothRemoteDevice findBluetoothRemoteDevice(const QString &ubi) const;
+ const QString getBluetoothRemoteDeviceUBI(const QString &address) const;
+
+ Solid::Control::BluetoothRemoteDevice findBluetoothRemoteDeviceAddr(const QString &addr) const;
+
+ Solid::Control::BluetoothRemoteDevice* findBluetoothRemoteDeviceUBI(const QString &ubi) const;
+
+ Solid::Control::BluetoothInputDevice* findBluetoothInputDeviceUBI(const QString &ubi) const;
/**
* Retrieves the MAC address of the bluetooth interface/adapter.
@@ -132,7 +147,7 @@
*
* @returns bluetooth chip version
*/
- QString version() const;
+ //QString version() const;
/**
* Retrieves the revision of the chip of the bluetooth interface/adapter.
@@ -140,7 +155,7 @@
*
* @returns bluetooth chip revision
*/
- QString revision() const;
+ //QString revision() const;
/**
* Retrieves the name of the bluetooth chip manufacturer.
@@ -148,7 +163,7 @@
*
* @returns manufacturer string of bluetooth interface/adapter
*/
- QString manufacturer() const;
+ //QString manufacturer() const;
/**
* Retrieves the name of the manufacturer of the bluetooth interface,
@@ -157,14 +172,7 @@
*
* @returns company string of bluetooth interface/adapter
*/
- QString company() const;
-
- /**
- * Retrieves the current mode of the bluetooth interface/adapter.
- *
- * @returns the current mode of bluetooth interface/adapter
- */
- Mode mode() const;
+ //QString company() const;
/**
* Retrieves the discoverable timeout of the bluetooth interface/adapter.
@@ -182,19 +190,27 @@
bool isDiscoverable() const;
/**
+ * Retrieves the current status of a discovering session for the adapter.
+ *
+ * @returns true if a discovering session is running for the adapter
+ */
+ bool isDiscovering() const;
+
+
+ /**
* List all UBIs of connected remote bluetooth devices of this handled bluetooth
* interface/adapter.
*
* @returns list UBIs of connected bluetooth remote devices
*/
- BluetoothRemoteDeviceList listConnections() const;
+ //BluetoothRemoteDeviceList listConnections() const;
/**
* Retrieves major class of the bluetooth interface/adapter.
* @todo enum
* @returns current major class of the bluetooth interface/adapter
*/
- QString majorClass() const;
+ //QString majorClass() const;
/**
* List supported minor classes of the bluetooth interface/adapter.
@@ -202,7 +218,7 @@
*
* @returns list of supported minor classes by bluetooth interface/adapter
*/
- QStringList listAvailableMinorClasses() const;
+ //QStringList listAvailableMinorClasses() const;
/**
* Retrieves minor class of the bluetooth interface/adapter.
@@ -211,7 +227,7 @@
*
* @returns minor class of the bluetooth interface/adapter.
*/
- QString minorClass() const;
+ //QString minorClass() const;
/**
* List services class of the bluetooth interface/adapter.
@@ -219,7 +235,7 @@
*
* @returns list of service classes or empty list if no services registered
*/
- QStringList serviceClasses() const;
+ //QStringList serviceClasses() const;
/**
* Retrieves name of bluetooth interface/adapter.
@@ -234,7 +250,7 @@
*
* @return the name of the remote device
*/
- QString getRemoteName(const QString & mac);
+ //QString getRemoteName(const QString & mac);
/**
* List UBIs of bonded/paired remote bluetooth devices with this bluetooth
@@ -242,14 +258,14 @@
*
* @returns UBIs of bonded/paired bluetooth remote devices
*/
- QStringList listBondings() const;
+ //QStringList listBondings() const;
/**
* Periodic discovery status of this bluetooth interface/adapter.
*
* @returns true if periodic discovery is already active otherwise false
*/
- bool isPeriodicDiscoveryActive() const;
+ // bool isPeriodicDiscoveryActive() const;
/**
* Name resolving status of periodic discovery routing.
@@ -257,7 +273,7 @@
* @returns true if name got resolved while periodic discovery of this bluetooth
* interface/adapter
*/
- bool isPeriodicDiscoveryNameResolvingActive() const;
+ //bool isPeriodicDiscoveryNameResolvingActive() const;
/**
* List the Unique Bluetooth Identifier (UBI) of all known remote devices,
@@ -267,7 +283,7 @@
*
* @returns a QStringList of UBIs of all known remote bluetooth devices
*/
- QStringList listRemoteDevices() const;
+ //QStringList listRemoteDevices() const;
/**
* List the Unique Bluetooth Identifier (UBI) of all known remote devices since a specific
@@ -279,24 +295,32 @@
* @param date the datestamp of the beginning of recent used devices
* @returns a QStringList of UBIs of all known remote bluetooth devices
*/
- QStringList listRecentRemoteDevices(const QDateTime &date) const;
+ // QStringList listRecentRemoteDevices(const QDateTime &date) const;
/**
* Returns true if the remote bluetooth device is trusted otherwise false.
*
* @param mac the address of the remote device
*/
- bool isTrusted(const QString &);
+// bool isTrusted(const QString &);
+
+
+ void createPairedDevice(const QString &, const QString &, const QString &) const;
+
+ QMap< QString, QVariant > getProperties() const;
+
+ BluetoothRemoteDeviceList listDevices() const;
+
+
public Q_SLOTS:
/**
- * Set mode of bluetooth interface/adapter.
- * Valid modes, see mode()
+ * Set the discoverable state of the interface/adapter.
*
- * @param mode the mode of the bluetooth interface/adapter
+ * @param status the discoverable state of the bluetooth interface/adapter
*/
- void setMode(const Mode mode);
+ void setDiscoverable(bool status);
/**
* Set discoverable timeout of bluetooth interface/adapter.
@@ -310,7 +334,7 @@
*
* @param minor set minor class. Valid mode see listAvaliableMinorClasses()
*/
- void setMinorClass(const QString &minor);
+ //void setMinorClass(const QString &minor);
/**
* Set name of bluetooth interface/adapter.
@@ -322,47 +346,65 @@
/**
* Start discovery of remote bluetooth devices with device name resolving.
*/
- void discoverDevices();
+ //void discoverDevices();
/**
* Start discovery of remote bluetooth devices without device name resolving.
*/
- void discoverDevicesWithoutNameResolving();
+ //void discoverDevicesWithoutNameResolving();
/**
* Cancel discovery of remote bluetooth devices.
*/
- void cancelDiscovery();
+ //void cancelDiscovery();
/**
* Start periodic discovery of remote bluetooth devices.
* See stopPeriodicDiscovery()
*/
- void startPeriodicDiscovery();
+ //void startPeriodicDiscovery();
/**
* Stop periodic discovery of remote bluetooth devices.
*/
- void stopPeriodicDiscovery();
+ //void stopPeriodicDiscovery();
/**
* Enable/Disable name resolving of remote bluetooth devices in periodic discovery.
*
* @param resolveName true to enable name resolving otherwise false
*/
- void setPeriodicDiscoveryNameResolving(bool resolveNames);
+ //void setPeriodicDiscoveryNameResolving(bool resolveNames);
/**
* Marks the device as trusted.
*
* @param mac the address of the remote device
*/
- void setTrusted(const QString &);
+ //void setTrusted(const QString &);
/**
* Marks the device as not trusted.
*
* @param mac the address of the remote device
*/
- void removeTrust(const QString &);
+ //void removeTrust(const QString &);
+
+ void registerAgent(const QString &,const QString &) const;
+
+ void releaseSession() const;
+
+ void removeDevice(const QString &) const;
+
+ void requestSession() const;
+
+ void setProperty(const QString &, const QVariant &) const;
+
+ void startDiscovery() const;
+
+ void stopDiscovery() const;
+
+ void unregisterAgent(const QString &) const;
+
+ void cancelDeviceCreation(const QString &) const;
Q_SIGNALS:
@@ -373,7 +415,7 @@
*
* @param mode the changed mode
*/
- void modeChanged(Solid::Control::BluetoothInterface::Mode);
+ //void modeChanged(Solid::Control::BluetoothInterface::Mode);
/**
* The signal is emitted if the discoverable timeout of the bluetooth interface/adapter
@@ -381,31 +423,31 @@
*
* @param timeout the changed timeout in seconds
*/
- void discoverableTimeoutChanged(int timeout);
+ //void discoverableTimeoutChanged(int timeout);
/**
* The signal is emitted if the minor class of the bluetooth interface/adapter has changed.
*
* @param minor the new minor class
*/
- void minorClassChanged(const QString &minor);
+ //void minorClassChanged(const QString &minor);
/**
* The signal is emitted if the name of the bluetooth interface/adapter has changed.
*
* @param name the new name of the device
*/
- void nameChanged(const QString &name);
+ //void nameChanged(const QString &name);
/**
* This signal is emitted if a discovery has started.
*/
- void discoveryStarted();
+ //void discoveryStarted();
/**
* This signal is emitted if a discovery has completed.
*/
- void discoveryCompleted();
+ //void discoveryCompleted();
/**
* This signal is emitted if the bluetooth interface/adapter detects a new remote bluetooth device.
@@ -416,7 +458,7 @@
* @param deviceClass the device class of the remote device
* @param rssi the Received Signal Strength Information (RSSI) of the remote device
*/
- void remoteDeviceFound(const QString &ubi, int deviceClass, int rssi);
+ //void remoteDeviceFound(const QString &ubi, int deviceClass, int rssi);
/**
* This signal is emitted if the bluetooth interface/adapter detectes a bluetooth device
@@ -424,7 +466,7 @@
*
* @param ubi the ubi of the disappering bluetooth remote device
*/
- void remoteDeviceDisappeared(const QString &ubi);
+ //void remoteDeviceDisappeared(const QString &ubi);
/**
* This signal is emitted if the bluetooth interface/adapter detectes a new name for a
@@ -433,58 +475,105 @@
* @param address the address of the bluetooth remote device
* @param name the name of the bluetooth remote device
*/
- void remoteNameUpdated(const QString &address, const QString &name);
+ //void remoteNameUpdated(const QString &address, const QString &name);
/**
* This signal is emitted if a bluetooth connection has been created.
*
* @param address the address of the connected bluetooth remote device
*/
- void remoteDeviceConnected(const QString &address);
+ //void remoteDeviceConnected(const QString &address);
/**
* This signal is emitted if a bluetooth connection has been terminated.
*
* @param address the address of the disconnected bluetooth remote device
*/
- void remoteDeviceDisconnected(const QString &address);
+ //void remoteDeviceDisconnected(const QString &address);
/**
* This signal is emitted if a bluetooth device was set trusted.
*
* @param address the address of the trusted bluetooth remote device
*/
- void trustAdded(const QString &address);
+ //void trustAdded(const QString &address);
/**
* This signal is emitted if the trust to the bluetooth device was removed.
*
* @param address the address of the bluetooth remote device
*/
- void trustRemoved(const QString &address);
+ //void trustRemoved(const QString &address);
/**
* This signal is emitted if a successful bonding has been created.
*
* @param address the address of the bluetooth remote device
*/
- void bondingCreated(const QString &address);
+ //void bondingCreated(const QString &address);
/**
* This signal is emitted if the bonding to a bluetooth device has been removed.
*
* @param address the address of the bluetooth remote device
*/
- void bondingRemoved(const QString &address);
+ //void bondingRemoved(const QString &address);
+/**
+ * This signal is emitted when a remote device is created.
+ *
+ * @param ubi the object path of the device on the system bus
+ */
+ void deviceCreated(const QString &ubi);
+
+ /**
+ * This signal is emitted when an inquiry session for a periodic discovery finishes and previously found
+ * devices are no longer in range or visible.
+ *
+ * @param address the address of the remote device
+ */
+ void deviceDisappeared(const QString &address);
+
+ /**
+ * This signal will be emitted every time an inquiry result has been found by the service daemon.
+ * In general they only appear during a device discovery.
+ *
+ * @param address the address of the remote device
+ * @param properties the properties of the remote device
+ */
+ void deviceFound(const QString &address, const QMap< QString, QVariant > &properties);
+
+ /**
+ * This signal is emitted when a remote device is removed from the system bus.
+ *
+ * @param ubi the object path on the system bus from the remote device
+ */
+ void deviceRemoved(const QString &ubi);
+
+ /**
+ * This signal is emitted when a property of the adapter is set to a new value.
+ *
+ * @param property the named property of the adapter
+ * @value the new value for the property
+ */
+ void propertyChanged(const QString &property, const QVariant &value);
+
+
+
private:
Q_PRIVATE_SLOT(d, void _k_destroyed(QObject *))
+ QVariant getProperty(const QString&) const;
BluetoothInterfacePrivate * const d;
+
+private slots:
+ void slotDeviceCreated(const QString& ubi);
+
};
} //Control
} //Solid
+
#endif
diff -Nur -x '[^b][^l]*' -x .svn 4_1libsControl/bluetoothmanager.cpp kdebase/workspace/libs/solid/control/bluetoothmanager.cpp
--- 4_1libsControl/bluetoothmanager.cpp 2009-01-16 17:04:06.000000000 +0100
+++ libs/solid/control/bluetoothmanager.cpp 2009-01-16 13:17:33.000000000 +0100
@@ -2,6 +2,7 @@
Copyright (C) 2006 Will Stephenson <wstephenson@kde.org>
Copyright (C) 2006 Kévin Ottens <ervin@kde.org>
Copyright (C) 2007 Daniel Gollub <dgollub@suse.de>
+ Copyright (C) 2008 Tom Patzig <tpatzig@suse.de>
This library is free software; you can redistribute it and/or
@@ -57,11 +58,13 @@
void _k_interfaceAdded(const QString &ubi);
void _k_interfaceRemoved(const QString &ubi);
+ void _k_defaultInterfaceChanged(const QString &ubi);
void _k_interfaceDestroyed(QObject *object);
-
+/*
void _k_inputDeviceCreated(const QString &ubi);
void _k_inputDeviceRemoved(const QString &ubi);
void _k_inputDeviceDestroyed(QObject *object);
+*/
mutable QMap<QString, QPair<BluetoothInterface *, Ifaces::BluetoothInterface *> > bluetoothInterfaceMap;
mutable QMap<QString, QPair<BluetoothInputDevice *, Ifaces::BluetoothInputDevice *> > bluetoothInputDeviceMap;
@@ -108,6 +111,8 @@
if (backend == 0) return list;
+ kDebug() << "UBI List " << ubiList;
+
foreach (const QString &ubi, ubiList) {
QPair<BluetoothInterface *, Ifaces::BluetoothInterface *> pair = d->findRegisteredBluetoothInterface(ubi);
@@ -119,6 +124,7 @@
return list;
}
+
Solid::Control::BluetoothInterfaceList Solid::Control::BluetoothManager::bluetoothInterfaces() const
{
Ifaces::BluetoothManager *backend = qobject_cast<Ifaces::BluetoothManager *>(d->managerBackend());
@@ -129,7 +135,12 @@
return BluetoothInterfaceList();
}
}
-
+/*
+QStringList Solid::Control::BluetoothManager::bluetoothInterfaces() const
+{
+ return_SOLID_CALL(Ifaces::BluetoothManager *, d->managerBackend(), QStringList(), bluetoothInterfaces());
+}
+*/
QString Solid::Control::BluetoothManager::defaultInterface() const
{
return_SOLID_CALL(Ifaces::BluetoothManager *, d->managerBackend(), QString(), defaultInterface());
@@ -150,6 +161,12 @@
}
}
+QString Solid::Control::BluetoothManager::findInterface(const QString &dev) const
+{
+ return_SOLID_CALL(Ifaces::BluetoothManager *, d->managerBackend(), QString(), findInterface(dev));
+}
+
+/*
Solid::Control::BluetoothInputDevice Solid::Control::BluetoothManager::findBluetoothInputDevice(const QString &ubi) const
{
Ifaces::BluetoothManager *backend = qobject_cast<Ifaces::BluetoothManager *>(d->managerBackend());
@@ -164,7 +181,9 @@
return d->invalidInputDevice;
}
}
+*/
+/*
Solid::Control::BluetoothInputDevice* Solid::Control::BluetoothManager::createBluetoothInputDevice(const QString &ubi)
{
Ifaces::BluetoothManager *backend = qobject_cast<Ifaces::BluetoothManager *>(d->managerBackend());
@@ -220,10 +239,12 @@
{
SOLID_CALL(Ifaces::BluetoothManager *, d->managerBackend(), removeInputDevice(ubi));
}
-
+*/
void Solid::Control::BluetoothManagerPrivate::_k_interfaceAdded(const QString &ubi)
{
- QPair<BluetoothInterface *, Ifaces::BluetoothInterface *> pair = bluetoothInterfaceMap.take(ubi);
+ kDebug() << "Size of InterfaceList " << bluetoothInterfaceMap.size();
+ QPair<BluetoothInterface *, Ifaces::BluetoothInterface *> pair = findRegisteredBluetoothInterface(ubi);
+/* QPair<BluetoothInterface *, Ifaces::BluetoothInterface *> pair = bluetoothInterfaceMap.take(ubi);
if (pair.first != 0) {
// Oops, I'm not sure it should happen...
@@ -231,7 +252,7 @@
delete pair.first;
delete pair.second;
- }
+ }*/
emit q->interfaceAdded(ubi);
}
@@ -245,11 +266,19 @@
delete pair.second;
}
+ Ifaces::BluetoothManager *backend = qobject_cast<Ifaces::BluetoothManager *>(managerBackend());
+ backend->removeInterface(ubi);
emit q->interfaceRemoved(ubi);
}
+void Solid::Control::BluetoothManagerPrivate::_k_defaultInterfaceChanged(const QString &ubi)
+{
+ emit q->defaultInterfaceChanged(ubi);
+}
+
void Solid::Control::BluetoothManagerPrivate::_k_interfaceDestroyed(QObject *object)
{
+ kDebug() << "Interface detroyed";
Ifaces::BluetoothInterface *device = qobject_cast<Ifaces::BluetoothInterface *>(object);
if (device != 0) {
@@ -259,6 +288,7 @@
}
}
+/*
void Solid::Control::BluetoothManagerPrivate::_k_inputDeviceCreated(const QString &ubi)
{
QPair<BluetoothInputDevice *, Ifaces::BluetoothInputDevice *> pair = bluetoothInputDeviceMap.take(ubi);
@@ -296,7 +326,7 @@
delete pair.first;
}
}
-
+*/
/***************************************************************************/
@@ -306,27 +336,36 @@
q, SLOT(_k_interfaceAdded(const QString &)));
QObject::connect(newBackend, SIGNAL(interfaceRemoved(const QString &)),
q, SLOT(_k_interfaceRemoved(const QString &)));
+ QObject::connect(newBackend, SIGNAL(defaultInterfaceChanged(const QString &)),
+ q, SLOT(_k_defaultInterfaceChanged(const QString &)));
+/*
QObject::connect(newBackend, SIGNAL(inputDeviceCreated(const QString &)),
q, SLOT(_k_inputDeviceCreated(const QString &)));
QObject::connect(newBackend, SIGNAL(inputDeviceRemoved(const QString &)),
q, SLOT(_k_inputDeviceRemoved(const QString &)));
+*/
}
QPair<Solid::Control::BluetoothInterface *, Solid::Control::Ifaces::BluetoothInterface *> Solid::Control::BluetoothManagerPrivate::findRegisteredBluetoothInterface(const QString &ubi) const
{
+
+ kDebug() << "findRegisteredBluetoothInterface " << ubi;
if (bluetoothInterfaceMap.contains(ubi)) {
return bluetoothInterfaceMap[ubi];
} else {
+ kDebug() << "Creating New Interface " << ubi;
Ifaces::BluetoothManager *backend = qobject_cast<Ifaces::BluetoothManager *>(managerBackend());
Ifaces::BluetoothInterface *iface = 0;
if (backend != 0) {
+ kDebug() << "Calling Backend to Creating New Interface " << ubi;
iface = qobject_cast<Ifaces::BluetoothInterface *>(backend->createInterface(ubi));
}
if (iface != 0) {
+ kDebug() << "BackendIface created ";
BluetoothInterface *device = new BluetoothInterface(iface);
QPair<BluetoothInterface *, Ifaces::BluetoothInterface *> pair(device, iface);
QObject::connect(iface, SIGNAL(destroyed(QObject *)),
@@ -339,6 +378,7 @@
}
}
+/*
QPair<Solid::Control::BluetoothInputDevice *, Solid::Control::Ifaces::BluetoothInputDevice *> Solid::Control::BluetoothManagerPrivate::findRegisteredBluetoothInputDevice(const QString &ubi) const
{
@@ -364,6 +404,7 @@
}
}
}
+*/
diff -Nur -x '[^b][^l]*' -x .svn 4_1libsControl/bluetoothmanager.h kdebase/workspace/libs/solid/control/bluetoothmanager.h
--- 4_1libsControl/bluetoothmanager.h 2009-01-16 17:04:06.000000000 +0100
+++ libs/solid/control/bluetoothmanager.h 2009-01-16 13:17:33.000000000 +0100
@@ -2,6 +2,7 @@
Copyright (C) 2006 Will Stephenson <wstephenson@kde.org>
Copyright (C) 2006 Kevin Ottens <ervin@kde.org>
Copyright (C) 2007 Daniel Gollub <dgollub@suse.de>
+ Copyright (C) 2008 Tom Patzig <tpatzig@suse.de>
This library is free software; you can redistribute it and/or
@@ -69,6 +70,7 @@
* @return the list of bluetooth interfaces available in this system
*/
BluetoothInterfaceList bluetoothInterfaces() const;
+ //QStringList bluetoothInterfaces() const;
/**
* Retrieves the default bluetooth interface Universal Bluetooth Identifiers (UBIs)
@@ -79,6 +81,15 @@
QString defaultInterface() const;
/**
+ * Returns the UBI of the Bluetooth Interface given its name (e.g. 'hci0'),
+ * if found on the system.
+ *
+ * @return the found UBI of the named bluetooth interface
+ */
+ QString findInterface(const QString & name) const;
+
+
+ /**
* Find a new BluetoothInterface object given its UBI.
*
* @param ubi the identifier of the bluetooth interface to find
@@ -93,7 +104,7 @@
* @param ubi the identifier of the bluetooth input device to find
* @returns a valid BlueoothInputDevice object if there's a device having the given UBI, an invalid one otherwise
*/
- BluetoothInputDevice findBluetoothInputDevice(const QString & ubi) const;
+ // BluetoothInputDevice findBluetoothInputDevice(const QString & ubi) const;
/**
* Retrieves the list of Universal Bluetooth Identifiers (UBIs) of bluetooth input devices
@@ -101,7 +112,7 @@
*
* @return the list of bluetooth input devices configured in this system
*/
- BluetoothInputDeviceList bluetoothInputDevices() const;
+ //BluetoothInputDeviceList bluetoothInputDevices() const;
/**
* Instantiates a new BluetoothInputDevice object from this backend given its UBI.
@@ -109,7 +120,7 @@
* @param ubi the identifier of the bluetooth input device instantiated
* @returns a new BluetoothInputDevice object if there's a device having the given UBI, 0 otherwise
*/
- BluetoothInputDevice *createBluetoothInputDevice(const QString &ubi);
+ //BluetoothInputDevice *createBluetoothInputDevice(const QString &ubi);
/**
* Setup a new bluetooth input device.
@@ -117,12 +128,12 @@
* @param ubi the ubi of the bluetooth input device
* @returns the job handling of the operation.
*/
- KJob *setupInputDevice(const QString &ubi);
+ //KJob *setupInputDevice(const QString &ubi);
/**
* Gets an instance of BluetoothSecurity to handle pairing/authorization requests
*/
- BluetoothSecurity *security(const QString &interface = QString());
+ //BluetoothSecurity *security(const QString &interface = QString());
public Q_SLOTS:
/**
@@ -130,7 +141,7 @@
*
* @param ubi the bluetooth input device identifier
*/
- void removeInputDevice(const QString & ubi);
+// void removeInputDevice(const QString & ubi);
Q_SIGNALS:
/**
@@ -159,14 +170,14 @@
*
* @param ubi the bluetooth input device identifier
*/
- void inputDeviceCreated(const QString & ubi);
+// void inputDeviceCreated(const QString & ubi);
/**
* This signal is emitted when a bluetooth input device configuration is not available anymore.
*
* @param ubi the bluetooth input device identifier
*/
- void inputDeviceRemoved(const QString & ubi);
+// void inputDeviceRemoved(const QString & ubi);
private:
@@ -177,11 +188,13 @@
Q_PRIVATE_SLOT(d, void _k_interfaceAdded(const QString &))
Q_PRIVATE_SLOT(d, void _k_interfaceRemoved(const QString &))
+ Q_PRIVATE_SLOT(d, void _k_defaultInterfaceChanged(const QString &))
Q_PRIVATE_SLOT(d, void _k_interfaceDestroyed(QObject *))
-
+/*
Q_PRIVATE_SLOT(d, void _k_inputDeviceCreated(const QString &))
Q_PRIVATE_SLOT(d, void _k_inputDeviceRemoved(const QString &))
Q_PRIVATE_SLOT(d, void _k_inputDeviceDestroyed(QObject *))
+*/
BluetoothManagerPrivate * const d;
friend class BluetoothManagerPrivate;
diff -Nur -x '[^b][^l]*' -x .svn 4_1libsControl/bluetoothremotedevice.cpp kdebase/workspace/libs/solid/control/bluetoothremotedevice.cpp
--- 4_1libsControl/bluetoothremotedevice.cpp 2009-01-16 17:04:06.000000000 +0100
+++ libs/solid/control/bluetoothremotedevice.cpp 2009-01-13 14:53:39.000000000 +0100
@@ -1,6 +1,7 @@
/* This file is part of the KDE project
Copyright (C) 2006 Will Stephenson <wstephenson@kde.org>
Copyright (C) 2007 Daniel Gollub <dgollub@suse.de>
+ Copyright (C) 2008 Tom Patzig <tpatzig@suse.de>
This library is free software; you can redistribute it and/or
@@ -81,12 +82,105 @@
return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), ubi());
}
-QString Solid::Control::BluetoothRemoteDevice::address() const
+QMap<QString,QVariant> Solid::Control::BluetoothRemoteDevice::getProperties()
{
Q_D(const BluetoothRemoteDevice);
- return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), address());
+ return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), (QMap< QString,QVariant >()), getProperties());
}
+QVariant Solid::Control::BluetoothRemoteDevice::getProperty(const QString &key)
+{
+ QMap<QString, QVariant> props = getProperties();
+ if (props.contains(key))
+ return props[key];
+ else
+ return QVariant();
+}
+
+QStringList Solid::Control::BluetoothRemoteDevice::listNodes()
+{
+ Q_D(const BluetoothRemoteDevice);
+ return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QStringList(), listNodes());
+}
+
+void Solid::Control::BluetoothRemoteDevice::setProperty(const QString &name, const QVariant &value)
+{
+ Q_D(const BluetoothRemoteDevice);
+ SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), setProperty(name,value));
+}
+
+void Solid::Control::BluetoothRemoteDevice::cancelDiscovery()
+{
+ Q_D(const BluetoothRemoteDevice);
+ SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), cancelDiscovery());
+}
+
+void Solid::Control::BluetoothRemoteDevice::disconnect()
+{
+ Q_D(const BluetoothRemoteDevice);
+ SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), disconnect());
+}
+
+
+QString Solid::Control::BluetoothRemoteDevice::address()
+{
+ QVariant var = getProperty("Address");
+
+ if (var.isValid())
+ return var.value<QString>();
+ else
+ return QString();
+
+// Q_D(const BluetoothRemoteDevice);
+// return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), address());
+}
+
+bool Solid::Control::BluetoothRemoteDevice::isTrusted()
+{
+ QVariant var = getProperty("Trusted");
+
+ if (var.isValid())
+ return var.value<bool>();
+ else
+ return false;
+}
+
+void Solid::Control::BluetoothRemoteDevice::setTrusted(bool trust)
+{
+ setProperty("Trusted",QVariant(trust));
+}
+
+QString Solid::Control::BluetoothRemoteDevice::icon()
+{
+ QVariant var = getProperty("Icon");
+
+ if (var.isValid())
+ return var.value<QString>();
+ else
+ return "";
+}
+
+QStringList Solid::Control::BluetoothRemoteDevice::uuids()
+{
+ QVariant var = getProperty("UUIDs");
+
+ if (var.isValid())
+ return var.value<QStringList>();
+ else
+ return QStringList();
+}
+
+bool Solid::Control::BluetoothRemoteDevice::isConnected()
+{
+ QVariant var = getProperty("Connected");
+
+ if (var.isValid())
+ return var.value<bool>();
+ else
+ return false;
+}
+
+/*
bool Solid::Control::BluetoothRemoteDevice::isConnected() const
{
Q_D(const BluetoothRemoteDevice);
@@ -134,12 +228,21 @@
Q_D(const BluetoothRemoteDevice);
return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QStringList(), serviceClasses());
}
-QString Solid::Control::BluetoothRemoteDevice::name() const
+*/
+
+QString Solid::Control::BluetoothRemoteDevice::name()
{
- Q_D(const BluetoothRemoteDevice);
- return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), name());
+ QVariant var = getProperty("Name");
+
+ if (var.isValid())
+ return var.value<QString>();
+ else
+ return QString();
+
+// return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), name());
}
+/*
QString Solid::Control::BluetoothRemoteDevice::alias() const
{
Q_D(const BluetoothRemoteDevice);
@@ -222,12 +325,20 @@
Q_D(const BluetoothRemoteDevice);
SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), serviceRecordAsXml(handle));
}
+*/
+
+void Solid::Control::BluetoothRemoteDevice::discoverServices(const QString &filter)
+{
+ Q_D(const BluetoothRemoteDevice);
+ SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), discoverServices(filter));
+}
void Solid::Control::BluetoothRemoteDevicePrivate::setBackendObject(QObject *object)
{
FrontendObjectPrivate::setBackendObject(object);
if (object) {
+ /*
QObject::connect(object, SIGNAL(classChanged(uint)),
parent(), SIGNAL(classChanged(uint)));
QObject::connect(object, SIGNAL(nameChanged(const QString &)),
@@ -252,6 +363,20 @@
parent(), SIGNAL(serviceHandlesAvailable(const QString &, const QList<uint> &)));
QObject::connect(object, SIGNAL(serviceRecordXmlAvailable(const QString &, const QString &)),
parent(), SIGNAL(serviceRecordXmlAvailable(const QString &, const QString &)));
+ */
+
+ QObject::connect(object, SIGNAL(serviceDiscoverAvailable(const QString &, const QMap< uint,QString> &)),
+ parent(), SIGNAL(serviceDiscoverAvailable(const QString &, const QMap< uint,QString > &)));
+ QObject::connect(object, SIGNAL(propertyChanged(const QString &, const QVariant &)),
+ parent(), SIGNAL(propertyChanged(const QString &, const QVariant &)));
+ QObject::connect(object, SIGNAL(disconnectRequested()),
+ parent(), SIGNAL(disconnectRequested()));
+ QObject::connect(object, SIGNAL(nodeCreated(const QString &)),
+ parent(), SIGNAL(nodeCreated(const QString &)));
+ QObject::connect(object, SIGNAL(nodeRemoved(const QString &)),
+ parent(), SIGNAL(nodeRemoved(const QString &)));
+
+
}
}
diff -Nur -x '[^b][^l]*' -x .svn 4_1libsControl/bluetoothremotedevice.h kdebase/workspace/libs/solid/control/bluetoothremotedevice.h
--- 4_1libsControl/bluetoothremotedevice.h 2009-01-16 17:04:06.000000000 +0100
+++ libs/solid/control/bluetoothremotedevice.h 2009-01-13 14:53:39.000000000 +0100
@@ -1,6 +1,7 @@
/* This file is part of the KDE project
Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
Copyright (C) 2007 Daniel Gollub <dgollub@suse.de>
+ Copyright (C) 2008 Tom Patzig <tpatzig@suse.de>
This library is free software; you can redistribute it and/or
@@ -25,6 +26,7 @@
#include <QtCore/QObject>
#include <QtCore/QStringList>
#include <QtCore/QMap>
+#include <QtCore/QVariant>
#include "bluetoothmanager.h"
#include "bluetoothinterface.h"
@@ -80,261 +82,119 @@
bool operator==(const BluetoothRemoteDevice & other) const;
/**
- * Retrieves the Universal Bluetooth Identifier (UBI) of the remote device.
- * This identifier is unique for each remote device and bluetooth interface in the system.
- *
- * @returns the Universal Bluetooth Identifier of the current remote device.
+ * The UBI of the remote device.
*/
QString ubi() const;
/**
- * Retrieves MAC address of the bluetooth remote device.
- *
- * @returns MAC address of remote device.
- */
- QString address() const;
-
-
- /**
- * Retrieves true if remote device is connected.
- *
- * @returns true if remote bluetooth device is connected otherwise false.
- */
- bool isConnected() const;
-
- /**
- * Retrieves the bluetooth version of the remote device.
- * LMP version (+ EDR support)
- *
- * @returns version of bluetooth chip.
- */
- QString version() const;
-
- /**
- * Retrieves the revision of the bluetooth chip of the remote device.
- *
- * @returns revision of bluetooth chip.
- */
- QString revision() const;
-
- /**
- * Retrieves company name based on the device address.
- *
- * @returns manufacturer string of bluetooth chip.
- */
- QString manufacturer() const;
-
- /**
- * Retrieves the manufacturer of the bluetooth chip of the remote device.
- *
- * @returns company string of the bluetooth chip.
- */
- QString company() const;
-
- /**
- * Retrieves the major class of the remote device.
- * Example: "computer"
- *
- * @returns major class of remote device.
+ * The address of the remote device.
*/
- QString majorClass() const;
+ QString address();
/**
- * Retrieves the minor class of the remote device.
- * Exampe: "laptop"
- *
- * @returns minor class of the remote device.
+ * The name of the remote device.
*/
- QString minorClass() const;
+ QString name();
/**
- * Retrieves a list of service classes of the remote device.
- * Example: ["networking", "object transfer"]
- *
- * @returns list of service classes of the remote device.
+ * The icon of the remote device.
*/
- QStringList serviceClasses() const;
+ QString icon();
/**
- * Retrieves the real name of the remote device. See also alias().
- * Example: "Daniel's mobile"
- *
- * @returns name of remote device.
+ * The Trust state of the remote device.
*/
- QString name() const;
+ bool isTrusted();
/**
- * Retrieves alias of remote device. This is a local alias name for the remote device.
- * If this string is empty the frontend should should use name(). This is handy if
- * someone is using several bluetooth remote device with the same name. alias() should
- * be preferred used by the frontend.
- * Example: "Company mobile"
- *
- * @retuns local alias of remote device.
+ * Set the Trust state of the remote device.
*/
- QString alias() const;
+ void setTrusted(bool);
/**
- * Retrieves the date and time when the remote device has been seen.
- * Example: "2007-03-20 22:14:00 GMT"
- *
- * @returns date and time when the remote device has been seen.
- */
- QString lastSeen() const;
-
- /**
- * Retrieves the date and time when the remote device has been used.
- * Example: "2007-03-20 22:14:00 GMT"
- *
- * @returns date and time when the remote device has been used.
+ * Returns the service uuids of the remote device.
*/
- QString lastUsed() const;
+ QStringList uuids();
/**
- * Retrieves true if remote device has bonding.
- *
- * @returns true if remote device has bonding.
+ * The Connection state of the remote device.
*/
- bool hasBonding() const;
+ bool isConnected();
/**
- * Retrieves PIN code length that was used in the pairing process of remote device.
+ * Retrieve all properties from the remote device.
*
- * @returns PIN code length of pairing.
+ * @returns a hash of named properties
*/
- int pinCodeLength() const;
+ QMap<QString,QVariant> getProperties();
/**
- * Retrieves currently used encryption key size of remote device.
+ * Discover all available Services from the remote Device.
+ * When the call is finished serviceDiscoverAvailable is thrown.
*
- * @returns encryption key size.
+ * @param pattern a service handle pattern to search for
*/
- int encryptionKeySize() const;
+ void discoverServices(const QString &pattern);
/**
- * Create bonding ("pairing") with remote device.
+ * List all defined Nodes.
*
- * @returns the job handling of the operation.
+ * @returns a List of ObjectPaths from all defined Nodes
*/
- KJob *createBonding();
+ QStringList listNodes();
public Q_SLOTS:
+
/**
- * Set alias for remote device.
+ * Set a new Value for a named property.
*
- * @param alias new alias name
+ * @param name the name of the property
+ * @param value the new value to be set
*/
- void setAlias(const QString &alias);
+ void setProperty(const QString &name, const QVariant &value);
/**
- * Clear alias for remote device.
+ * Cancel a started service Discovery.
*/
- void clearAlias();
+ void cancelDiscovery();
/**
- * Disconnect remote device.
+ * Request a disconnect from the remote device.
*/
void disconnect();
- /**
- * Cancel bonding process of remote device.
- */
- void cancelBondingProcess();
-
- /**
- * Remove bonding bonding of remote device.
- */
- void removeBonding();
- /**
- * Obtains a list of unique identifiers to each service provided by this remote device.
- * As this is a slow operation, this method only queues the message
- * in the dbus and returns the list of handles using the serviceHandlesAvailable signal
- *
- * NOTE: Most local adapters won't support more than one search at a time, so serialize your requests
- *
- * @param filter A filter to apply to the search (look at http://wiki.bluez.org/wiki/HOWTO/DiscoveringServices#Searchpatterns)
- */
- void serviceHandles(const QString &filter ="") const;
- /**
- * Requests the service record associated with the given handle.
- * As this is a slow operation, this method only queues the message
- * in the dbus and returns the XML record using the serviceRecordXmlAvailable signal.
- *
- * NOTE: Most local adapters won't support more than one search at a time, so serialize your requests
- *
- * @param handle The handle that uniquely identifies the service record requested.
- */
- void serviceRecordAsXml(uint handle) const;
Q_SIGNALS:
- /**
- * Class has been changed of remote device.
- *
- * @params deviceClass the device class of the remote device
- */
- void classChanged(uint deviceClass);
/**
- * Name has beend changed of remote device.
+ * Search for services is done.
*
- * @params name the name of the remote device
+ * @param status the result of the discovering.
+ * @param services the discovered Services.
*/
- void nameChanged(const QString &name);
+ void serviceDiscoverAvailable(const QString &status, const QMap<uint,QString> &services);
/**
- * Resolving of remote device name failed.
- */
- void nameResolvingFailed();
-
- /**
- * Alias has been changed of remote device.
+ * A Property for the remote device has changed.
*
- * @params alias the alias of the remote device
- */
- void aliasChanged(const QString &alias);
-
- /**
- * Alias got cleared of remote device.
- */
- void aliasCleared();
-
- /**
- * Remote device has been connected.
+ * @param name the name of the changed property
+ * @param value the new value
*/
- void connected();
+ void propertyChanged(const QString &name, const QVariant &value);
/**
- * Disconnection has been requested for remote device.
+ * Disconnect to the remote device requested.
*/
- void requestDisconnection();
+ void disconnectRequested();
- /**
- * Remote device has been disconnected.
- */
- void disconnected();
-
- /**
- * Bonding with remote device has been created.
- */
- void bondingCreated();
- /**
- * Bonding has been removed of remote device.
- */
- void bondingRemoved();
-
- /**
- * Search for service handles is done
- */
- void serviceHandlesAvailable(const QString &ubi, const QList<uint> &handles);
- /**
- * A new service record is available
- */
- void serviceRecordXmlAvailable(const QString &ubi, const QString &record);
protected:
BluetoothRemoteDevicePrivate *d_ptr;
private:
Q_PRIVATE_SLOT(d_func(), void _k_destroyed(QObject *))
+
+
+ QVariant getProperty(const QString &key);
};
} //Control
--- 4_1libsControl/backends/CMakeLists.txt 2009-01-16 17:04:06.000000000 +0100
+++ libs/solid/control/backends/CMakeLists.txt 2008-10-14 21:51:51.000000000 +0200
@@ -1,3 +1,3 @@
add_subdirectory( fakenet )
-add_subdirectory( fakebluetooth )
+#add_subdirectory( fakebluetooth )
diff -Nur -x .svn -x '[^b][^l]*' 4_1libsControl/ifaces//bluetoothinputdevice.h kdebase/workspace/libs/solid/control/ifaces//bluetoothinputdevice.h
--- 4_1libsControl/ifaces//bluetoothinputdevice.h 2009-01-16 17:04:05.000000000 +0100
+++ libs/solid/control/ifaces//bluetoothinputdevice.h 2008-10-25 18:36:03.000000000 +0200
@@ -23,6 +23,9 @@
#define SOLID_IFACES_BLUETOOTHINPUTDEVICE
#include <QtCore/QObject>
+#include <QtCore/QMap>
+#include <QtCore/QVariant>
+
#include "../solid_control_export.h"
namespace Solid
@@ -56,67 +59,34 @@
* @returns ubi of bluetooth input device
*/
virtual QString ubi() const = 0;
-
/**
- * Retrieves connection status of bluetooth input device.
+ * Retrieve all properties from the input device.
*
- * @returns true if bluetooth input device is connected
+ * @returns a hash of named properties
*/
- virtual bool isConnected() const = 0;
+ virtual QMap<QString,QVariant> getProperties() const = 0;
- /**
- * Retrieves MAC address of bluetooth input device.
- *
- * @returns MAC address of bluetooth input device
- */
- virtual QString address() const = 0;
-
- /**
- * Retrievies Name of bluetooth input device.
- *
- * @returns Name of bluetooth input device
- */
- virtual QString name() const = 0;
-
- /**
- * Retrieves Product ID of bluetooth input device.
- *
- * @returns Product ID of bluetooth input device
- */
- virtual QString productID() const = 0;
-
- /**
- * Retrieves Vendor ID of bluetooth input device.
- *
- * @returns Vendor ID of bluetooth input device
- */
- virtual QString vendorID() const = 0;
public Q_SLOTS:
/**
* Connect bluetooth input device.
*/
- virtual void slotConnect() = 0;
+ virtual void connect() = 0;
/**
* Disconnect bluetooth input device.
*/
- virtual void slotDisconnect() = 0;
+ virtual void disconnect() = 0;
Q_SIGNALS:
- /**
- * This signal is emitted when the bluetooth input device is connected.
+ /**
+ * A Property for the input device has changed.
*
- * @param ubi the bluetooth input device identifier
+ * @param name the name of the changed property
+ * @param value the new value
*/
- virtual void connected() = 0;
+ virtual void propertyChanged(const QString &name, const QVariant &value) = 0;
- /**
- * This signal is emitted when the bluetooth input device is not available anymore.
- *
- * @param ubi the bluetooth input device identifier
- */
- virtual void disconnected() = 0;
};
} // Ifaces
diff -Nur -x .svn -x '[^b][^l]*' 4_1libsControl/ifaces//bluetoothinterface.h kdebase/workspace/libs/solid/control/ifaces//bluetoothinterface.h
--- 4_1libsControl/ifaces//bluetoothinterface.h 2009-01-16 17:04:05.000000000 +0100
+++ libs/solid/control/ifaces//bluetoothinterface.h 2009-01-16 17:16:55.000000000 +0100
@@ -68,7 +68,7 @@
*
* @returns MAC address of bluetooth interface
*/
- virtual QString address() const = 0;
+ //virtual QString address() const = 0;
/**
* Retrieves the version of the chip of the bluetooth interface/adapter.
@@ -76,7 +76,7 @@
*
* @returns bluetooth chip version
*/
- virtual QString version() const = 0;
+ //virtual QString version() const = 0;
/**
* Retrieves the revision of the chip of the bluetooth interface/adapter.
@@ -84,7 +84,7 @@
*
* @returns bluetooth chip revision
*/
- virtual QString revision() const = 0;
+ //virtual QString revision() const = 0;
/**
* Retrieves the name of the bluetooth chip manufacturer.
@@ -92,7 +92,7 @@
*
* @returns manufacturer string of bluetooth interface/adapter
*/
- virtual QString manufacturer() const = 0;
+ //virtual QString manufacturer() const = 0;
/**
* Retrieves the name of the bluetooth chip company.
@@ -100,7 +100,7 @@
*
* @returns company string of bluetooth interface/adapter
*/
- virtual QString company() const = 0;
+ //virtual QString company() const = 0;
/**
@@ -112,7 +112,7 @@
*
* @returns current mode of bluetooth interface/adaoter
*/
- virtual Solid::Control::BluetoothInterface::Mode mode() const = 0;
+ //virtual Solid::Control::BluetoothInterface::Mode mode() const = 0;
/**
* Retrieves the discoverable timeout of the bluetooth interface/adapter.
@@ -120,14 +120,14 @@
*
* @returns current discoverable timeout in seconds
*/
- virtual int discoverableTimeout() const = 0;
+ //virtual int discoverableTimeout() const = 0;
/**
* Retrieves the current discoverable staut of the bluetooth interface/adapter.
*
* @returns current discoverable status of bluetooth interface/adapter
*/
- virtual bool isDiscoverable() const = 0;
+ //virtual bool isDiscoverable() const = 0;
/**
@@ -136,7 +136,7 @@
*
* @returns list UBIs of connected bluetooth remote devices
*/
- virtual QStringList listConnections() const = 0;
+ //virtual QStringList listConnections() const = 0;
/**
@@ -144,14 +144,14 @@
*
* @returns current major class of the bluetooth interface/adapter
*/
- virtual QString majorClass() const = 0;
+ //virtual QString majorClass() const = 0;
/**
* List supported minor classes of the bluetooth interface/adapter.
*
* @returns list of supported minor classes by bluetooth interface/adapter
*/
- virtual QStringList listAvailableMinorClasses() const = 0;
+ //virtual QStringList listAvailableMinorClasses() const = 0;
/**
* Retrievies minor class of the bluetooth interface/adapter.
@@ -159,27 +159,27 @@
*
* @returns minor class of the bluetooth interface/adapter.
*/
- virtual QString minorClass() const = 0;
+ //virtual QString minorClass() const = 0;
/**
* List services class of the bluetooth interface/adapter.
*
* @returns list of service classes or empty list if no services registered
*/
- virtual QStringList serviceClasses() const = 0;
+ //virtual QStringList serviceClasses() const = 0;
/**
* Retrieves name of bluetooth interface/adapter.
*
* @returns name of bluetooth interface/adapter
*/
- virtual QString name() const = 0;
+ //virtual QString name() const = 0;
/**
* Returns the name of the remote device, given its mac address (mac).
*
* @return the name of the remote device
*/
- virtual QString getRemoteName(const QString & mac) = 0;
+ //virtual QString getRemoteName(const QString & mac) = 0;
/**
* List UBIs of bonded/paired remote bluetooth devices with this bluetooth
@@ -187,14 +187,14 @@
*
* @returns UBIs of bonded/paired bluetooth remote devices
*/
- virtual QStringList listBondings() const = 0;
+ //virtual QStringList listBondings() const = 0;
/**
* Periodic discovery status of this bluetooth interface/adapter.
*
* @returns true if periodic discovery is already active otherwise false
*/
- virtual bool isPeriodicDiscoveryActive() const = 0;
+ //virtual bool isPeriodicDiscoveryActive() const = 0;
/**
* Name resolving status of periodic discovery routing.
@@ -202,7 +202,7 @@
* @returns true if name got resolved while periodic discovery of this bluetooth
* interface/adapter
*/
- virtual bool isPeriodicDiscoveryNameResolvingActive() const = 0;
+ //virtual bool isPeriodicDiscoveryNameResolvingActive() const = 0;
/**
* List the Universal Bluetooth Identifier (UBI) of all known remote devices, which are
@@ -212,7 +212,7 @@
*
* @returns a QStringList of UBIs of all known remote bluetooth devices
*/
- virtual QStringList listRemoteDevices() const = 0;
+ //virtual QStringList listRemoteDevices() const = 0;
/**
* List the Universal Bluetooth Identifier (UBI) of all known remote devices since a specific
@@ -224,77 +224,96 @@
* @param date the datestamp of the beginning of recent used devices
* @returns a QStringList of UBIs of all known remote bluetooth devices
*/
- virtual QStringList listRecentRemoteDevices(const QDateTime &date) const = 0;
+ // virtual QStringList listRecentRemoteDevices(const QDateTime &date) const = 0;
/**
* Returns true if the remote bluetooth device is trusted otherwise false.
*
* @param mac the address of the remote device
*/
- virtual bool isTrusted(const QString &) = 0;
+// virtual bool isTrusted(const QString &) = 0;
+ /**
+ *
+ *
+ *
+ */
+
+
+ virtual void createPairedDevice(const QString &, const QString &, const QString &) const = 0;
+
+ virtual QMap< QString, QVariant > getProperties() const = 0;
+
+ virtual QStringList listDevices() const = 0;
+
+ virtual QString findDevice(const QString &) const = 0;
+
+ //virtual QString createDevice(const QString &) const = 0;
+ virtual void createDevice(const QString &) const = 0;
-public Q_SLOTS:
+
+
+//public Q_SLOTS:
/**
* Set mode of bluetooth interface/adapter.
* Valid modes, see mode()
*
* @param mode the mode of the bluetooth interface/adapter
*/
- virtual void setMode(const Solid::Control::BluetoothInterface::Mode mode) = 0;
+ //virtual void setMode(const Solid::Control::BluetoothInterface::Mode mode) = 0;
/**
* Set discoverable timeout of bluetooth interface/adapter.
*
* @param timeout timeout in seconds
*/
- virtual void setDiscoverableTimeout(int timeout) = 0;
+ //virtual void setDiscoverableTimeout(int timeout) = 0;
/**
* Set minor class of bluetooth interface/adapter.
*
* @param minor set minor class. Valid mode see listAvaliableMinorClasses()
*/
- virtual void setMinorClass(const QString &minor) = 0;
+ //virtual void setMinorClass(const QString &minor) = 0;
/**
* Set name of bluetooth interface/adapter.
*
* @param name the name of bluetooth interface/adapter
*/
- virtual void setName(const QString &name) = 0;
+ //virtual void setName(const QString &name) = 0;
/**
* Start discovery of remote bluetooth devices with device name resolving.
*/
- virtual void discoverDevices() = 0;
+ //virtual void discoverDevices() = 0;
/**
* Start discovery of remote bluetooth devices without device name resolving.
*/
- virtual void discoverDevicesWithoutNameResolving() = 0;
+ //virtual void discoverDevicesWithoutNameResolving() = 0;
/**
* Cancel discovery of remote bluetooth devices.
*/
- virtual void cancelDiscovery() = 0;
+ //virtual void cancelDiscovery() = 0;
/**
* Start periodic discovery of remote bluetooth devices.
* See stopPeriodicDiscovery()
*/
- virtual void startPeriodicDiscovery() = 0;
+ //virtual void startPeriodicDiscovery() = 0;
/**
* Stop periodic discovery of remote bluetooth devices.
*/
- virtual void stopPeriodicDiscovery() = 0;
+ //virtual void stopPeriodicDiscovery() = 0;
/**
* Enable/Disable name resolving of remote bluetooth devices in periodic discovery.
*
* @param resolveName true to enable name resolving otherwise false
*/
- virtual void setPeriodicDiscoveryNameResolving(bool resolveNames) = 0;
+ //virtual void setPeriodicDiscoveryNameResolving(bool resolveNames) = 0;
/**
* Instantiates a new BluetoothRemoteDevice object from this backend given its address.
@@ -302,21 +321,41 @@
* @param ubi the identifier of the bluetooth remote device instantiated
* @returns a new BluetoothRemoteDevice object if there's a device having the given UBI, 0 otherwise
*/
- virtual QObject *createBluetoothRemoteDevice(const QString &address) = 0;
+ virtual QObject *createBluetoothRemoteDevice(const QString &ubi) = 0;
+
+ virtual QObject *createBluetoothInputDevice(const QString &ubi) = 0;
/**
* Marks the device as trusted.
*
* @param mac the address of the remote device
*/
- virtual void setTrusted(const QString &) = 0;
+ //virtual void setTrusted(const QString &) = 0;
/**
* Marks the device as not trusted.
*
* @param mac the address of the remote device
*/
- virtual void removeTrust(const QString &) = 0;
+ //virtual void removeTrust(const QString &) = 0;
+
+ virtual void registerAgent(const QString &,const QString &) = 0;
+
+ virtual void releaseSession() = 0;
+
+ virtual void removeDevice(const QString &) = 0;
+
+ virtual void requestSession() = 0;
+
+ virtual void setProperty(const QString &, const QVariant &) = 0;
+
+ virtual void startDiscovery() = 0;
+
+ virtual void stopDiscovery() = 0;
+
+ virtual void unregisterAgent(const QString &) = 0;
+
+ virtual void cancelDeviceCreation(const QString &) = 0;
Q_SIGNALS:
@@ -327,7 +366,7 @@
*
* @param mode the changed mode
*/
- void modeChanged(Solid::Control::BluetoothInterface::Mode);
+ //void modeChanged(Solid::Control::BluetoothInterface::Mode);
/**
* The signal is emitted if the discoverable timeout of the bluetooth interface/adapter
@@ -335,31 +374,31 @@
*
* @param timeout the changed timeout in seconds
*/
- void discoverableTimeoutChanged(int timeout);
+ //void discoverableTimeoutChanged(int timeout);
/**
* The signal is emitted if the minor class of the bluetooth interface/adapter has changed.
*
* @param minor the new minor class
*/
- void minorClassChanged(const QString &minor);
+ //void minorClassChanged(const QString &minor);
/**
* The signal is emitted if the name of the bluetooth interface/adapter has changed.
*
* @param name the new name of the device
*/
- void nameChanged(const QString &name);
+ //void nameChanged(const QString &name);
/**
* This signal is emitted if a discovery has started.
*/
- void discoveryStarted();
+ //void discoveryStarted();
/**
* This signal is emitted if a discovery has completed.
*/
- void discoveryCompleted();
+ //void discoveryCompleted();
/**
* This signal is emitted if the bluetooth interface/adapter detects a new remote bluetooth device.
@@ -370,7 +409,7 @@
* @param deviceClass the device Class of the remote device
* @param rssi the RSSI link of the remote device
*/
- void remoteDeviceFound(const QString &ubi, int deviceClass, int rssi);
+ //void remoteDeviceFound(const QString &ubi, int deviceClass, int rssi);
/**
* This signal is emitted if the bluetooth interface/adapter detectes a bluetooth device
@@ -378,7 +417,7 @@
*
* @param ubi the ubi of the disappering bluetooth remote device
*/
- void remoteDeviceDisappeared(const QString &ubi);
+ //void remoteDeviceDisappeared(const QString &ubi);
/**
* This signal is emitted if the bluetooth interface/adapter detectes a new name for a
@@ -387,49 +426,88 @@
* @param address the address of the bluetooth remote device
* @param name the name of the bluetooth remote device
*/
- void remoteNameUpdated(const QString &address, const QString &name);
+ //void remoteNameUpdated(const QString &address, const QString &name);
/**
* This signal is emitted if a bluetooth connection has been created.
*
* @param address the address of the connected bluetooth remote device
*/
- void remoteDeviceConnected(const QString &address);
+ //void remoteDeviceConnected(const QString &address);
/**
* This signal is emitted if a bluetooth connection has been terminated.
*
* @param address the address of the disconnected bluetooth remote device
*/
- void remoteDeviceDisconnected(const QString &address);
+ //void remoteDeviceDisconnected(const QString &address);
/**
* This signal is emitted if a bluetooth device was set trusted.
*
* @param address the address of the trusted bluetooth remote device
*/
- void trustAdded(const QString &address);
+ //void trustAdded(const QString &address);
/**
* This signal is emitted if the trust to the bluetooth device was removed.
*
* @param address the address of the bluetooth remote device
*/
- void trustRemoved(const QString &address);
+ //void trustRemoved(const QString &address);
/**
* This signal is emitted if a successful bonding has been created.
*
* @param address the address of the bluetooth remote device
*/
- void bondingCreated(const QString &address);
+ //void bondingCreated(const QString &address);
/**
* This signal is emitted if the bonding to a bluetooth device has been removed.
*
* @param address the address of the bluetooth remote device
*/
- void bondingRemoved(const QString &address);
+ //void bondingRemoved(const QString &address);
+
+ /**
+ * This signal is emitted when a remote device is created.
+ *
+ * @param ubi the object path of the device on the system bus
+ */
+ void deviceCreated(const QString &ubi);
+
+ /**
+ * This signal is emitted when an inquiry session for a periodic discovery finishes and previously found
+ * devices are no longer in range or visible.
+ *
+ * @param address the address of the remote device
+ */
+ void deviceDisappeared(const QString &address);
+
+ /**
+ * This signal will be emitted every time an inquiry result has been found by the service daemon.
+ * In general they only appear during a device discovery.
+ *
+ * @param address the address of the remote device
+ * @param properties the properties of the remote device
+ */
+ void deviceFound(const QString &address, const QMap< QString,QVariant > &properties);
+
+ /**
+ * This signal is emitted when a remote device is removed from the system bus.
+ *
+ * @param ubi the object path on the system bus from the remote device
+ */
+ void deviceRemoved(const QString &ubi);
+
+ /**
+ * This signal is emitted when a property of the adapter is set to a new value.
+ *
+ * @param property the named property of the adapter
+ * @value the new value for the property
+ */
+ void propertyChanged(const QString &property, const QVariant &value);
};
diff -Nur -x .svn -x '[^b][^l]*' 4_1libsControl/ifaces//bluetoothmanager.h kdebase/workspace/libs/solid/control/ifaces//bluetoothmanager.h
--- 4_1libsControl/ifaces//bluetoothmanager.h 2009-01-16 17:04:05.000000000 +0100
+++ libs/solid/control/ifaces//bluetoothmanager.h 2009-01-16 12:42:32.000000000 +0100
@@ -73,12 +73,27 @@
virtual QString defaultInterface() const = 0;
/**
+ * Returns the UBI of the Bluetooth Interface given its name (e.g. 'hci0'),
+ * if found on the system.
+ *
+ * @return the found UBI of the named bluetooth interface
+ */
+ virtual QString findInterface(const QString &name) const = 0;
+
+ /**
* Instantiates a new BluetoothInterface object from this backend given its UBI.
*
* @param ubi the identifier of the bluetooth interface instantiated
* @returns a new BluetoothInterface object if there's a device having the given UBI, 0 otherwise
*/
- virtual QObject *createInterface(const QString &ubi) = 0;
+ virtual QObject *createInterface(const QString &ubi) = 0;
+
+ /**
+ * Removes a BluetoothInterface object from this backend given its UBI.
+ *
+ * @param ubi the identifier of the bluetooth interface instantiated
+ */
+ virtual void removeInterface(const QString &ubi) = 0;
/**
* Retrieves the list of Universal Bluetooth Identifiers (UBIs) of bluetooth input devices
@@ -86,7 +101,7 @@
*
* @return the list of bluetooth input devices configured in this system
*/
- virtual QStringList bluetoothInputDevices() const = 0;
+// virtual QStringList bluetoothInputDevices() const = 0;
/**
* Instantiates a new BluetoothInputDevice object from this backend given its UBI.
@@ -94,7 +109,7 @@
* @param ubi the identifier of the bluetooth input device instantiated
* @returns a new BluetoothInputDevice object if there's a device having the given UBI, 0 otherwise
*/
- virtual QObject *createBluetoothInputDevice(const QString &ubi) = 0;
+// virtual QObject *createBluetoothInputDevice(const QString &ubi) = 0;
/**
* Setup a new bluetooth input device.
@@ -102,12 +117,12 @@
* @param ubi the ubi of the bluetooth input device
* @returns job handling of the operation.
*/
- virtual KJob *setupInputDevice(const QString &ubi) = 0;
+// virtual KJob *setupInputDevice(const QString &ubi) = 0;
/**
* Gets an instance of BluetoothSecurity to handle pairing/authorization requests
*/
- virtual Solid::Control::Ifaces::BluetoothSecurity* security(const QString &interface) = 0;
+// virtual Solid::Control::Ifaces::BluetoothSecurity* security(const QString &interface) = 0;
public Q_SLOTS:
/**
@@ -115,7 +130,7 @@
*
* @param ubi the bluetooth input device identifier
*/
- virtual void removeInputDevice(const QString & ubi) = 0;
+// virtual void removeInputDevice(const QString & ubi) = 0;
Q_SIGNALS:
/**
@@ -144,14 +159,14 @@
*
* @param ubi the bluetooth input device identifier
*/
- void inputDeviceCreated(const QString & ubi);
+// void inputDeviceCreated(const QString & ubi);
/**
* This signal is emitted when a bluetooth input device configuration is not available anymore.
*
* @param ubi the bluetooth input device identifier
*/
- void inputDeviceRemoved(const QString & ubi);
+// void inputDeviceRemoved(const QString & ubi);
};
diff -Nur -x .svn -x '[^b][^l]*' 4_1libsControl/ifaces//bluetoothremotedevice.h kdebase/workspace/libs/solid/control/ifaces//bluetoothremotedevice.h
--- 4_1libsControl/ifaces//bluetoothremotedevice.h 2009-01-16 17:04:05.000000000 +0100
+++ libs/solid/control/ifaces//bluetoothremotedevice.h 2009-01-09 18:24:32.000000000 +0100
@@ -52,257 +52,72 @@
* Destructs a BluetoothRemoteDevice object.
*/
virtual ~BluetoothRemoteDevice();
-
- /**
- * Retrieves the Universal Bluetooth Identifier (UBI) of the remote device.
- * This identifier is unique for each remote device and bluetooth interface in the system.
- *
- * @returns the Universal Bluetooth Identifier of the current remote device.
- */
- virtual QString ubi() const = 0;
-
- /**
- * Retrieves MAC address of the bluetooth remote device.
- *
- * @returns MAC address of remote device.
- */
- virtual QString address() const = 0;
-
-
- /**
- * Retrieves true if remote device is connected.
- *
- * @returns true if remote bluetooth device is connected otherwise false.
- */
- virtual bool isConnected() const = 0;
-
- /**
- * Retrieves the bluetooth version of the remote device.
- * LMP version (+ EDR support)
- *
- * @returns version of bluetooth chip.
- */
- virtual QString version() const = 0;
-
- /**
- * Retrieves the revision of the bluetooth chip of the remote device.
- *
- * @returns revision of bluetooth chip.
- */
- virtual QString revision() const = 0;
-
- /**
- * Retrieves company name based on the device address.
- *
- * @returns manufacturer string of bluetooth chip.
- */
- virtual QString manufacturer() const = 0;
-
- /**
- * Retrieves the manufacturer of the bluetooth chip of the remote device.
- *
- * @returns company string of the bluetooth chip.
- */
- virtual QString company() const = 0;
-
- /**
- * Retrieves the major class of the remote device.
- * Example: "computer"
- *
- * @returns major class of remote device.
- */
- virtual QString majorClass() const = 0;
-
- /**
- * Retrieves the minor class of the remote device.
- * Exampe: "laptop"
- *
- * @returns minor class of the remote device.
- */
- virtual QString minorClass() const = 0;
-
- /**
- * Retrieves a list of service classes of the remote device.
- * Example: ["networking", "object transfer"]
- *
- * @returns list of service classes of the remote device.
- */
- virtual QStringList serviceClasses() const = 0;
- /**
- * Retrieves the real name of the remote device. See also alias().
- * Example: "Daniel's mobile"
- *
- * @returns name of remote device.
- */
- virtual QString name() const = 0;
-
- /**
- * Retrieves alias of remote device. This is a local alias name for the remote device.
- * If this string is empty the frontend should should use name(). This is handy if
- * someone is using several bluetooth remote device with the same name. alias() should
- * be preferred used by the frontend.
- * Example: "Company mobile"
- *
- * @retuns local alias of remote device.
- */
- virtual QString alias() const = 0;
-
/**
- * Retrieves the date and time when the remote device has been seen.
- * Example: "2007-03-20 22:14:00 GMT"
+ * Retrieve all properties from the remote device.
*
- * @returns date and time when the remote device has been seen.
+ * @returns a hash of named properties
*/
- virtual QString lastSeen() const = 0;
-
+ virtual QMap<QString,QVariant> getProperties() const = 0;
/**
- * Retrieves the date and time when the remote device has been used.
- * Example: "2007-03-20 22:14:00 GMT"
+ * Discover all available Services from the remote Device.
+ * When the call is finished serviceDiscoverAvailable is thrown.
*
- * @returns date and time when the remote device has been used.
+ * @param pattern a service handle pattern to search for
*/
- virtual QString lastUsed() const = 0;
-
+ virtual void discoverServices(const QString &pattern) const = 0;
/**
- * Retrieves true if remote device has bonding.
+ * List all defined Nodes.
*
- * @returns true if remote device has bonding.
+ * @returns a List of ObjectPaths from all defined Nodes
*/
- virtual bool hasBonding() const = 0;
-
+ virtual QStringList listNodes() const = 0;
/**
- * Retrieves PIN code length that was used in the pairing process of remote device.
- *
- * @returns PIN code length of pairing.
- */
- virtual int pinCodeLength() const = 0;
-
- /**
- * Retrieves currently used encryption key size of remote device.
- *
- * @returns encryption key size.
- */
- virtual int encryptionKeySize() const = 0;
-
- /**
- * Create bonding ("pairing") with remote device.
- *
- * @returns the job handling of the operation.
+ * The UBI of the remote device.
*/
- virtual KJob *createBonding() = 0;
+ virtual QString ubi() const = 0;
public Q_SLOTS:
/**
- * Set alias for remote device.
+ * Set a new Value for a named property.
*
- * @param alias new alias name
+ * @param name the name of the property
+ * @param value the new value to be set
*/
- virtual void setAlias(const QString &alias) = 0;
-
+ virtual void setProperty(const QString &name, const QVariant &value) = 0;
/**
- * Clear alias for remote device.
+ * Cancel a started service Discovery.
*/
- virtual void clearAlias() = 0;
-
+ virtual void cancelDiscovery() = 0;
/**
- * Disconnect remote device.
+ * Request a disconnect from the remote device.
*/
virtual void disconnect() = 0;
- /**
- * Cancel bonding process of remote device.
- */
- virtual void cancelBondingProcess() = 0;
- /**
- * Remove bonding bonding of remote device.
- */
- virtual void removeBonding() = 0;
- /**
- * Obtains a list of unique identifiers to each service provided by this remote device.
- * As this is a slow operation, this method only queues the message
- * in the dbus and returns the list of handles using the serviceHandlesAvailable signal
- *
- * NOTE: Most local adapters won't support more than one search at a time, so serialize your requests
- *
- * @param filter A filter to apply to the search (look at http://wiki.bluez.org/wiki/HOWTO/DiscoveringServices#Searchpatterns)
- */
- virtual void serviceHandles(const QString &filter) const = 0;
- /**
- * Requests the service record associated with the given handle.
- * As this is a slow operation, this method only queues the message
- * in the dbus and returns the XML record using the serviceRecordXmlAvailable signal.
- *
- * NOTE: Most local adapters won't support more than one search at a time, so serialize your requests
- *
- * @param handle The handle that uniquely identifies the service record requested.
- */
- virtual void serviceRecordAsXml(uint handle) const = 0;
-Q_SIGNALS:
- /**
- * Class has been changed of remote device.
- *
- * @params deviceClass the device class of the remote device
- */
- virtual void classChanged(uint deviceClass) = 0;
+Q_SIGNALS:
/**
- * Name has beend changed of remote device.
+ * Search for services is done.
*
- * @params name the name of the remote device
- */
- virtual void nameChanged(const QString &name) = 0;
-
- /**
- * Resolving of remote device name failed.
+ * @param status the result of the discovering.
+ * @param services the discovered Services.
*/
- virtual void nameResolvingFailed() = 0;
-
+ virtual void serviceDiscoverAvailable(const QString &status, const QMap<uint,QString> &services) = 0;
/**
- * Alias has been changed of remote device.
+ * A Property for the remote device has changed.
*
- * @params alias the alias of the remote device
- */
- virtual void aliasChanged(const QString &alias) = 0;
-
- /**
- * Alias got cleared of remote device.
- */
- virtual void aliasCleared() = 0;
-
- /**
- * Remote device has been connected.
+ * @param name the name of the changed property
+ * @param value the new value
*/
- virtual void connected() = 0;
-
+ virtual void propertyChanged(const QString &name, const QVariant &value) = 0;
/**
- * Disconnection has been requested for remote device.
+ * Disconnect to the remote device requested.
*/
- virtual void requestDisconnection() = 0;
+ virtual void disconnectRequested() = 0;
- /**
- * Remote device has been disconnected.
- */
- virtual void disconnected() = 0;
- /**
- * Bonding with remote device has been created.
- */
- virtual void bondingCreated() = 0;
- /**
- * Bonding has been removed of remote device.
- */
- virtual void bondingRemoved() = 0;
- /**
- * A new service record is available
- */
- virtual void serviceRecordXmlAvailable(const QString &ubi, const QString &record) = 0;
- /**
- * Search for service handles is done
- */
- virtual void serviceHandlesAvailable(const QString &ubi, const QList<uint> &handles) = 0;
};
} // Ifaces
diff -Nur -x .svn -x '[^b][^l]*' 4_1libsControl/ifaces//bluetoothsecurity.h kdebase/workspace/libs/solid/control/ifaces//bluetoothsecurity.h
--- 4_1libsControl/ifaces//bluetoothsecurity.h 2009-01-16 17:04:05.000000000 +0100
+++ libs/solid/control/ifaces//bluetoothsecurity.h 2008-10-21 11:41:33.000000000 +0200
@@ -25,7 +25,7 @@
#include "../solid_control_export.h"
#include "../bluetoothsecurity.h" // So we know about Solid::Control::BluetoothPassKeyAgent
-#include <QObject>
+#include <QtCore/QObject>
namespace Solid
{
Index: solid-bluetooth.h
===================================================================
--- solid-bluetooth.h (.../branches/KDE/4.1/kdebase/workspace/solid/solidshell/solid-bluetooth.h) (revision 912129)
+++ solid/solidshell/solid-bluetooth.h (.../trunk/KDE/kdebase/workspace/solid/solidshell/solid-bluetooth.h) (revision 912129)
@@ -44,6 +44,10 @@
bool bluetoothListAdapters();
bool bluetoothDefaultAdapter();
+ bool bluetoothCreateDevice(const QString &adapterUbi, const QString &mac);
+ bool bluetoothRemoveDevice(const QString &adapterUbi, const QString &mac);
+ bool bluetoothGetProperties(const QString &adapterUbi);
+#if 0
bool bluetoothGetRemoteName(const QString &adapterUbi, const QString &mac);
bool bluetoothAdapterAddress(const QString &ubi);
bool bluetoothAdapterName(const QString &ubi);
@@ -63,6 +67,7 @@
bool bluetoothRemoteCreateBonding(const QString &adapterUbi, const QString &deviceUbi);
bool bluetoothRemoteRemoveBonding(const QString &adapterUbi, const QString &deviceUbi);
bool bluetoothRemoteHasBonding(const QString &adapterUbi, const QString &deviceUbi);
+#endif
private:
void connectJob(KJob *job);
@@ -71,12 +76,14 @@
int m_error;
QString m_errorString;
private slots:
+#if 0
void slotStorageResult(Solid::ErrorType error, const QVariant &errorData);
void slotResult(KJob *job);
void slotPercent(KJob *job, unsigned long percent);
void slotInfoMessage(KJob *job, const QString &message);
void slotBluetoothDeviceFound(const QString &ubi, int deviceClass, int rssi);
void slotBluetoothDiscoveryCompleted();
+#endif
};
Index: solid-bluetooth.cpp
===================================================================
--- solid-bluetooth.cpp (.../branches/KDE/4.1/kdebase/workspace/solid/solidshell/solid-bluetooth.cpp) (revision 912129)
+++ solid/solidshell/solid-bluetooth.cpp (.../trunk/KDE/kdebase/workspace/solid/solidshell/solid-bluetooth.cpp) (revision 912129)
@@ -70,8 +70,8 @@
QStringList list = value.toStringList();
- QStringList::ConstIterator it = list.begin();
- QStringList::ConstIterator end = list.end();
+ QStringList::ConstIterator it = list.constBegin();
+ QStringList::ConstIterator end = list.constEnd();
for (; it!=end; ++it)
{
@@ -149,7 +149,7 @@
std::ostream &operator<<(std::ostream &out, const QMap<QString,QVariant> &properties)
{
- foreach (QString key, properties.keys())
+ foreach (const QString& key, properties.keys())
{
out << " " << key << " = " << properties[key] << endl;
}
@@ -205,6 +205,17 @@
cout << " solid-bluetooth defaultadapter" << endl;
cout << i18n(" # List bluetooth default adapter/interface\n") << endl;
+ cout << " solid-bluetooth createdevice (interface 'ubi') 'remote-mac'" << endl;
+ cout << i18n(" # Request to create a remote bluetooth device on the bus\n") << endl;
+
+ cout << " solid-bluetooth removedevice (interface 'ubi') 'remote-mac'" << endl;
+ cout << i18n(" # Request to remove the remote bluetooth device from the bus\n") << endl;
+
+ cout << " solid-bluetooth getproperties (interface 'ubi') " << endl;
+ cout << i18n(" # Request the properties from the bluetooth adapter\n") << endl;
+
+
+/*
cout << " solid-bluetooth getremotename (interface 'ubi') 'remote-mac'" << endl;
cout << i18n(" # Query the name from the remote device 'remote-mac' with 'ubi'\n") << endl;
@@ -231,7 +242,7 @@
cout << i18n(" # Create bonding (pairing) with bluetooth remote device.\n"
" # Remove bonding of bluetooth remote device.\n"
" # Check for bonding of bluetooth remote device.\n") << endl;
-
+*/
return 0;
}
@@ -252,11 +263,35 @@
if (command == "listadapters")
{
return shell.bluetoothListAdapters();
- }
+ }
else if (command == "defaultadapter")
{
return shell.bluetoothDefaultAdapter();
}
+ else if (command == "createdevice")
+ {
+ checkArgumentCount(3, 3);
+ QString adapterUbi(args->arg(1));
+ QString mac(args->arg(2));
+ return shell.bluetoothCreateDevice(adapterUbi, mac);
+ }
+ else if (command == "removedevice")
+ {
+ checkArgumentCount(3, 3);
+ QString adapterUbi(args->arg(1));
+ QString remoteUbi(args->arg(2));
+ return shell.bluetoothRemoveDevice(adapterUbi, remoteUbi);
+ }
+ else if (command == "getproperties")
+ {
+ checkArgumentCount(2, 2);
+ QString ubi (args->arg(1));
+ return shell.bluetoothGetProperties(ubi);
+ }
+
+
+
+#if 0
else if (command == "getremotename")
{
checkArgumentCount(3, 3);
@@ -366,6 +401,7 @@
}
}
+#endif
else
{
cerr << i18n("Syntax Error: Unknown command '%1'" , command) << endl;
@@ -378,9 +414,7 @@
{
Solid::Control::BluetoothManager &manager = Solid::Control::BluetoothManager::self();
- const Solid::Control::BluetoothInterfaceList all = manager.bluetoothInterfaces();
-
- foreach (const Solid::Control::BluetoothInterface device, all)
+ foreach (Solid::Control::BluetoothInterface device, manager.bluetoothInterfaces())
{
cout << "UBI = '" << device.ubi() << "'" << endl;
}
@@ -396,6 +430,36 @@
return true;
}
+bool SolidBluetooth::bluetoothCreateDevice(const QString &adapterUbi, const QString &/*mac*/)
+{
+ Solid::Control::BluetoothManager &manager = Solid::Control::BluetoothManager::self();
+ Solid::Control::BluetoothInterface adapter = manager.findBluetoothInterface(adapterUbi);
+// QString remoteDeviceUBI = adapter.createDevice(mac);
+// cout << "Remote Device UBI: " << remoteDeviceUBI << endl;
+ return true;
+}
+
+bool SolidBluetooth::bluetoothRemoveDevice(const QString &adapterUbi, const QString &/*remoteDeviceUbi*/)
+{
+ Solid::Control::BluetoothManager &manager = Solid::Control::BluetoothManager::self();
+ Solid::Control::BluetoothInterface adapter = manager.findBluetoothInterface(adapterUbi);
+// adapter.removeDevice(remoteDeviceUbi);
+ return true;
+}
+
+bool SolidBluetooth::bluetoothGetProperties(const QString &adapterUbi)
+{
+ Solid::Control::BluetoothManager &manager = Solid::Control::BluetoothManager::self();
+ Solid::Control::BluetoothInterface adapter = manager.findBluetoothInterface(adapterUbi);
+ QMap<QString,QVariant> props = adapter.getProperties();
+ foreach (QString valName, props.keys()) {
+ cout << valName << ": " << props[valName] << endl;
+ }
+ return true;
+}
+
+
+#if 0
bool SolidBluetooth::bluetoothGetRemoteName(const QString &adapterUbi, const QString &mac)
{
Solid::Control::BluetoothManager &manager = Solid::Control::BluetoothManager::self();
@@ -685,5 +749,6 @@
}
m_loop.exit();
}
+#endif
#include "solid-bluetooth.moc"