qtmobility/src/systeminfo/qsysteminfo_maemo.cpp
changeset 5 453da2cfceef
parent 4 90517678cc4f
child 8 71781823f776
--- a/qtmobility/src/systeminfo/qsysteminfo_maemo.cpp	Mon May 03 13:18:40 2010 +0300
+++ b/qtmobility/src/systeminfo/qsysteminfo_maemo.cpp	Fri May 14 16:41:33 2010 +0300
@@ -442,6 +442,7 @@
 void QSystemNetworkInfoPrivate::setupNetworkInfo()
 {
     currentCellNetworkStatus = QSystemNetworkInfo::UndefinedStatus;
+    currentBluetoothNetworkStatus = networkStatus(QSystemNetworkInfo::BluetoothMode);
     currentEthernetState = "down";
     currentEthernetSignalStrength = networkSignalStrength(QSystemNetworkInfo::EthernetMode);
     currentWlanSignalStrength = networkSignalStrength(QSystemNetworkInfo::WlanMode);
@@ -564,6 +565,20 @@
                               this, SLOT(usbCableAction())) ) {
         qWarning() << "unable to connect to usbCableAction (disconnect)";
     }
+    if(!systemDbusConnection.connect("org.freedesktop.Hal",
+                              "/org/freedesktop/Hal/Manager",
+                              "org.freedesktop.Hal.Manager",
+                              QLatin1String("DeviceAdded"),
+                              this, SLOT(bluetoothNetworkStatusCheck())) ) {
+        qWarning() << "unable to connect to bluetoothNetworkStatusCheck (1)";
+    }
+    if(!systemDbusConnection.connect("org.freedesktop.Hal",
+                              "/org/freedesktop/Hal/Manager",
+                              "org.freedesktop.Hal.Manager",
+                              QLatin1String("DeviceRemoved"),
+                              this, SLOT(bluetoothNetworkStatusCheck())) ) {
+        qWarning() << "unable to connect to bluetoothNetworkStatusCheck (2)";
+    }
 #endif
 }
 
@@ -690,6 +705,15 @@
     }
 }
 
+void QSystemNetworkInfoPrivate::bluetoothNetworkStatusCheck()
+{
+    if (currentBluetoothNetworkStatus != networkStatus(QSystemNetworkInfo::BluetoothMode)) {
+        currentBluetoothNetworkStatus = networkStatus(QSystemNetworkInfo::BluetoothMode);
+        emit networkStatusChanged(QSystemNetworkInfo::BluetoothMode, currentBluetoothNetworkStatus);
+    }
+}
+
+
 void QSystemNetworkInfoPrivate::setWlanSignalStrengthCheckEnabled(bool enabled)
 {
     if (enabled) {