summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2014-02-08 14:37:20 +0200
committerMikko Ylinen <mikko.ylinen@intel.com>2014-09-23 21:29:22 +0300
commite83a97da1e9b4fca87915a287564b63fd63fc1d1 (patch)
tree695c1b5f88e684d6b2ee9c33d4ad56162bd27580
parentf13f13a7525eee970d176efe82e292926e25a3e3 (diff)
downloadbluez-e83a97da1e9b4fca87915a287564b63fd63fc1d1.tar.gz
bluez-e83a97da1e9b4fca87915a287564b63fd63fc1d1.tar.bz2
bluez-e83a97da1e9b4fca87915a287564b63fd63fc1d1.zip
core/device: Add device_is_service_blocked
This adds device_is_service_blocked which can be used to check if a service is currently blocked.
-rw-r--r--src/device.c28
-rw-r--r--src/device.h1
2 files changed, 29 insertions, 0 deletions
diff --git a/src/device.c b/src/device.c
index 738128f2..a4b5e936 100644
--- a/src/device.c
+++ b/src/device.c
@@ -576,6 +576,34 @@ gboolean device_is_trusted(struct btd_device *device)
return device->trusted;
}
+bool device_is_service_blocked(struct btd_device *device, const char *uuid)
+{
+ GSList *l;
+ bool block = false;
+
+ for (l = device->services; l; l = g_slist_next(l)) {
+ struct btd_service *service = l->data;
+ struct btd_profile *p = btd_service_get_profile(service);
+ const char *p_uuid;
+
+ p_uuid = p->auth_uuid ? p->auth_uuid : p->local_uuid;
+ if (!p_uuid)
+ continue;
+
+ if (strcasecmp(uuid, p_uuid))
+ continue;
+
+ if (!btd_service_is_blocked(service))
+ return false;
+
+ block = true;
+ }
+
+ /* Every service matching is blocked
+ */
+ return block;
+}
+
static gboolean dev_property_get_address(const GDBusPropertyTable *property,
DBusMessageIter *iter, void *data)
{
diff --git a/src/device.h b/src/device.h
index 51ee29f6..0b13a2f2 100644
--- a/src/device.h
+++ b/src/device.h
@@ -83,6 +83,7 @@ bool device_is_bonded(struct btd_device *device, uint8_t bdaddr_type);
gboolean device_is_trusted(struct btd_device *device);
void device_set_paired(struct btd_device *dev, uint8_t bdaddr_type);
void device_set_unpaired(struct btd_device *dev, uint8_t bdaddr_type);
+bool device_is_service_blocked(struct btd_device *device, const char *uuid);
void btd_device_set_temporary(struct btd_device *device, gboolean temporary);
void btd_device_set_trusted(struct btd_device *device, gboolean trusted);
void device_set_bonded(struct btd_device *device, uint8_t bdaddr_type);