[PATCH 5/9] core: Make connection properties exist only when connected

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds common 'exists' function for Connection* properties
on org.bluez.Device1 interface. It will make properties to exist only
when device is connected since they do not make sense otherwise.
---
 src/device.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/src/device.c b/src/device.c
index 8661386..a66f397 100644
--- a/src/device.c
+++ b/src/device.c
@@ -864,6 +864,22 @@ static gboolean dev_property_get_conn_max_txpower(
 	return TRUE;
 }
 
+static gboolean dev_property_exists_conn(const GDBusPropertyTable *property,
+								void *data)
+{
+	struct btd_device *device = data;
+
+	/* Properties do not exist on disconnected device */
+	if (!btd_device_is_connected(device))
+		return FALSE;
+
+	/* Properties do not exist if no one requested monitoring */
+	if (!queue_length(device->monitor_list))
+		return FALSE;
+
+	return TRUE;
+}
+
 static void set_trust(GDBusPendingPropertySet id, gboolean value, void *data)
 {
 	struct btd_device *device = data;
@@ -1957,9 +1973,12 @@ static const GDBusPropertyTable device_properties[] = {
 	{ "Modalias", "s", dev_property_get_modalias, NULL,
 						dev_property_exists_modalias },
 	{ "Adapter", "o", dev_property_get_adapter },
-	{ "ConnectionRSSI", "n", dev_property_get_conn_rssi },
-	{ "ConnectionTXPower", "n", dev_property_get_conn_txpower },
-	{ "ConnectionTXPowerMax", "n", dev_property_get_conn_max_txpower },
+	{ "ConnectionRSSI", "n", dev_property_get_conn_rssi, NULL,
+						dev_property_exists_conn },
+	{ "ConnectionTXPower", "n", dev_property_get_conn_txpower, NULL,
+						dev_property_exists_conn },
+	{ "ConnectionTXPowerMax", "n", dev_property_get_conn_max_txpower, NULL,
+						dev_property_exists_conn },
 	{ }
 };
 
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux