From e83a97da1e9b4fca87915a287564b63fd63fc1d1 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Sat, 8 Feb 2014 14:37:20 +0200 Subject: 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. --- src/device.c | 28 ++++++++++++++++++++++++++++ src/device.h | 1 + 2 files changed, 29 insertions(+) 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); -- cgit v1.2.3