From ee5cd21864fa355653ad078febb9be069d646754 Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Thu, 15 Aug 2013 11:56:47 -0300 Subject: [PATCH] bluetooth: Use the same DeviceMap as BlueZ 5 As we want to keep track of changes in org.bluez.Device's objects, it is very convenient that we keep GDBusProxies for each device. And the plan is to have the key of the map to be the object path of the device, so when an signal is emitted it can be immediately recognized which device has changed. --- bluetooth/bluetooth_context.h | 4 ---- bluetooth/bluetooth_context_bluez4.cc | 15 ++++----------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/bluetooth/bluetooth_context.h b/bluetooth/bluetooth_context.h index 389e622..f75abea 100644 --- a/bluetooth/bluetooth_context.h +++ b/bluetooth/bluetooth_context.h @@ -31,11 +31,7 @@ \ void METHOD(std::string, ARG0); -#if defined(BLUEZ_5) typedef std::map DeviceMap; -#elif defined(BLUEZ_4) -typedef std::map DeviceMap; -#endif namespace picojson { class value; diff --git a/bluetooth/bluetooth_context_bluez4.cc b/bluetooth/bluetooth_context_bluez4.cc index 8fed905..fcc972a 100644 --- a/bluetooth/bluetooth_context_bluez4.cc +++ b/bluetooth/bluetooth_context_bluez4.cc @@ -220,7 +220,7 @@ BluetoothContext::~BluetoothContext() { DeviceMap::iterator it; for (it = known_devices_.begin(); it != known_devices_.end(); ++it) - g_variant_iter_free(it->second); + g_object_unref(it->second); #if defined(TIZEN_MOBILE) bt_deinitialize(); @@ -290,21 +290,14 @@ void BluetoothContext::DeviceFound(std::string address, GVariantIter* properties if (it == known_devices_.end()) { // Found on discovery. o["cmd"] = picojson::value("DeviceFound"); o["found_on_discovery"] = picojson::value(true); - - while (g_variant_iter_loop(properties, "{sv}", &key, &value)) - getPropertyValue(key, value, o); - - known_devices_[address] = properties; } else { // Updated during discovery. o["cmd"] = picojson::value("DeviceUpdated"); o["found_on_discovery"] = picojson::value(false); - - while (g_variant_iter_loop(properties, "{sv}", &key, &value)) - getPropertyValue(key, value, o); - - known_devices_[address] = properties; } + while (g_variant_iter_loop(properties, "{sv}", &key, &value)) + getPropertyValue(key, value, o); + picojson::value v(o); PostMessage(v); } -- 2.7.4