- fixed base agent ignoring pass in object path
authorKevron Rees <kevron_m_rees@linux.intel.com>
Mon, 24 Jan 2011 21:40:02 +0000 (13:40 -0800)
committerKevron Rees <kevron_m_rees@linux.intel.com>
Mon, 24 Jan 2011 21:40:02 +0000 (13:40 -0800)
- fixed adapter being removed added business logic

bluetoothbaseagent.cpp
bluetoothdevicemodel.cpp
bluetoothdevicemodel.h

index a49ef4e..2c8d8bc 100644 (file)
@@ -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: "<<adapter.lastError().message();
 
index d4e70bb..663cb45 100644 (file)
@@ -119,7 +119,10 @@ void BluetoothDevicesModel::adapterAdded(QDBusObjectPath path)
        QDBusObjectPath adapterpath = manager->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<QDBusObjectPath> 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;
        }
 }
index f57b0f4..2dd4aee 100644 (file)
@@ -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;