[RFC 06/11] 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 | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/device.c b/src/device.c
index 8661386..1891735 100644
--- a/src/device.c
+++ b/src/device.c
@@ -864,6 +864,15 @@ 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;
+
+	/* TODO: only exists when monitoring is enabled? */
+	return btd_device_is_connected(device) ? TRUE : FALSE;
+}
+
 static void set_trust(GDBusPendingPropertySet id, gboolean value, void *data)
 {
 	struct btd_device *device = data;
@@ -1957,9 +1966,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