From: Kevron Rees Date: Mon, 24 Jan 2011 21:40:02 +0000 (-0800) Subject: - fixed base agent ignoring pass in object path X-Git-Tag: 0.0.5~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=215593976e552b4e9d60fd000b71eaa71dc04dfc;p=profile%2Fivi%2Fbluetooth-qt.git - fixed base agent ignoring pass in object path - fixed adapter being removed added business logic --- diff --git a/bluetoothbaseagent.cpp b/bluetoothbaseagent.cpp index a49ef4e..2c8d8bc 100644 --- a/bluetoothbaseagent.cpp +++ b/bluetoothbaseagent.cpp @@ -32,7 +32,7 @@ BluetoothBaseAgent::BluetoothBaseAgent(QString path, QObject *parent):QObject(pa adapterpath.path(), QDBusConnection::systemBus()); - adapter.RegisterAgent(QDBusObjectPath("/pairing/agent"),""); + adapter.RegisterAgent(QDBusObjectPath(path),""); qDebug()<<"last error: "<DefaultAdapter(); if(adapterpath.path() == "") + { + ///we actually shouldn't ever get here. return; + } adapter = new OrgBluezAdapterInterface( "org.bluez", @@ -141,6 +144,8 @@ void BluetoothDevicesModel::adapterAdded(QDBusObjectPath path) this, SLOT(deviceCreated(QDBusObjectPath))); + adapterChanged(true); + QList list = adapter->ListDevices(); foreach(QDBusObjectPath item, list) { @@ -157,12 +162,15 @@ void BluetoothDevicesModel::adapterRemoved(QDBusObjectPath) beginRemoveRows(QModelIndex(), 0, m_devices.size()-1); foreach(BluetoothDevice* device, m_devices) { + delete device; } m_devices.clear(); endRemoveRows(); if(adapter) delete adapter; + adapter = NULL; + adapterChanged(false); return; } } diff --git a/bluetoothdevicemodel.h b/bluetoothdevicemodel.h index f57b0f4..2dd4aee 100644 --- a/bluetoothdevicemodel.h +++ b/bluetoothdevicemodel.h @@ -10,7 +10,7 @@ class BluetoothDevicesModel : public QAbstractListModel { Q_OBJECT Q_PROPERTY(bool discoverable READ discoverable WRITE makeDiscoverable NOTIFY discoverableChanged); - + Q_PROPERTY(bool adapterPresent READ adapterPresent NOTIFY adapterChanged) public: explicit BluetoothDevicesModel(QObject *parent = 0); @@ -21,6 +21,8 @@ public: path }; + bool adapterPresent() { return adapter != NULL; } + public slots: int columnCount(const QModelIndex &) const { return 1; } @@ -47,6 +49,7 @@ private slots: signals: void devicePaired(BluetoothDevice* device); void discoverableChanged(bool discoverable); + void adapterChanged(bool adapterPresent); private: OrgBluezManagerInterface *manager;