added debug message for device removal
authorKevron Rees <kevron_m_rees@linux.intel.com>
Tue, 15 Feb 2011 16:41:01 +0000 (08:41 -0800)
committerKevron Rees <kevron_m_rees@linux.intel.com>
Tue, 15 Feb 2011 16:41:01 +0000 (08:41 -0800)
bluetoothdevicemodel.cpp
bluetoothdevicemodel.h
nearbydevicesmodel.cpp
nearbydevicesmodel.h

index b2e6215..f8a1056 100644 (file)
@@ -100,6 +100,26 @@ bool BluetoothDevicesModel::discoverable()
        return false;
 }
 
+int BluetoothDevicesModel::discoverableTimeout()
+{
+       if(adapter)
+       {
+               QVariantMap props = adapter->GetProperties();
+               return props["DiscoverableTimeout"].toInt();
+       }
+
+       return -1;
+}
+
+void BluetoothDevicesModel::setDiscoverableTimeout(int timeout)
+{
+       if(adapter)
+       {
+               bool success = adapter->setProperty("DiscoverableTimeout", timeout);
+               qDebug()<<"Setting discoverable timeout to "<<timeout<<": "<<success;
+       }
+}
+
 void BluetoothDevicesModel::adapterAdded(QDBusObjectPath path)
 {
        if(adapter && adapter->path() == path.path()) return;
@@ -215,4 +235,8 @@ void BluetoothDevicesModel::adapterPropertyChanged(QString name, QDBusVariant va
        {
                discoverableChanged(value.variant().toBool());
        }
+       else if(name == "DiscoverableTimeout")
+       {
+               discoverableTimeoutChanged(value.variant().toInt());
+       }
 }
index 28a8c05..cd8ae9a 100644 (file)
@@ -10,6 +10,7 @@ class BluetoothDevicesModel : public QAbstractListModel
 {
     Q_OBJECT
        Q_PROPERTY(bool discoverable READ discoverable WRITE makeDiscoverable NOTIFY discoverableChanged);
+       Q_PROPERTY(int discoverableTimeout READ discoverableTimeout WRITE setDiscoverableTimeout NOTIFY discoverableTimeoutChanged)
        Q_PROPERTY(bool adapterPresent READ adapterPresent NOTIFY adapterChanged)
 public:
        explicit BluetoothDevicesModel(QObject *parent = 0);
@@ -29,6 +30,8 @@ public slots:
        BluetoothDevice* device(QString path);
        void makeDiscoverable(bool isDiscoverable);
        bool discoverable();
+       int discoverableTimeout();
+       void setDiscoverableTimeout(int timeout);
 
 private slots:
        void adapterAdded(QDBusObjectPath);
@@ -40,6 +43,7 @@ private slots:
        void adapterPropertyChanged(QString name, QDBusVariant value);
 
 signals:
+       void discoverableTimeoutChanged(int timeout);
        void devicePaired(BluetoothDevice* device);
        void discoverableChanged(bool discoverable);
        void adapterChanged(bool adapterPresent);
index 3171860..57d0341 100644 (file)
@@ -145,8 +145,8 @@ void NearbyDevicesModel::deviceRemoved(QString hwaddy)
        {
                if(device->address() == hwaddy)
                {
+                       qDebug()<<"device "<<device->name()<<" has disappeared";
                        int i=devices.indexOf(device);
-                       //if(i == -1) continue;
                        beginRemoveRows(QModelIndex(),i,i);
                        devices.removeAt(i);
                        emit nearbyDeviceRemoved(i);
index 1c3f87e..f029b1b 100644 (file)
@@ -52,7 +52,6 @@ class NearbyDevicesModel : public QAbstractListModel
 {
        Q_OBJECT
        Q_PROPERTY(BluetoothDevice* pairingDevice READ pairingDevice)
-
 public:
        NearbyDevicesModel(QObject *parent = 0);