core/device: Add device_is_service_blocked
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Sat, 8 Feb 2014 12:37:20 +0000 (14:37 +0200)
committerMikko Ylinen <mikko.ylinen@intel.com>
Tue, 23 Sep 2014 18:29:22 +0000 (21:29 +0300)
This adds device_is_service_blocked which can be used to check if a
service is currently blocked.

src/device.c
src/device.h

index 738128f..a4b5e93 100644 (file)
@@ -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)
 {
index 51ee29f..0b13a2f 100644 (file)
@@ -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);