Diff between edfd9b47a81208db47ff5f9b8d23eac7400bdffa and 5ca45764738fde7f4efb8c20e154f7c2b8f42a5e

Changed Files

File Additions Deletions Status
src/adapter.c +12 -0 modified
src/adapter.h +1 -0 modified
src/device.c +26 -0 modified
src/device.h +1 -0 modified

Full Patch

diff --git a/src/adapter.c b/src/adapter.c
index e154c69..6731444 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2051,6 +2051,18 @@ static void probe_profile(struct btd_profile *profile, void *data)
 	adapter->profiles = g_slist_prepend(adapter->profiles, profile);
 }
 
+void adapter_add_profile(struct btd_adapter *adapter, gpointer p)
+{
+	struct btd_profile *profile = p;
+
+	if (!adapter->initialized)
+		return;
+
+	probe_profile(profile, adapter);
+
+	g_slist_foreach(adapter->devices, device_probe_profile, profile);
+}
+
 static void load_connections(struct btd_adapter *adapter)
 {
 	GSList *l, *conns;
diff --git a/src/adapter.h b/src/adapter.h
index eece6f5..9f840e8 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -145,6 +145,7 @@ struct btd_adapter_driver {
 
 typedef void (*service_auth_cb) (DBusError *derr, void *user_data);
 
+void adapter_add_profile(struct btd_adapter *adapter, gpointer p);
 int btd_register_adapter_driver(struct btd_adapter_driver *driver);
 void btd_unregister_adapter_driver(struct btd_adapter_driver *driver);
 int btd_request_authorization(const bdaddr_t *src, const bdaddr_t *dst,
diff --git a/src/device.c b/src/device.c
index 57fdf00..cb25606 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1372,6 +1372,32 @@ static void dev_probe(struct btd_profile *p, void *user_data)
 	g_slist_free(probe_uuids);
 }
 
+void device_probe_profile(gpointer a, gpointer b)
+{
+	struct btd_device *device = a;
+	struct btd_profile *profile = b;
+	GSList *probe_uuids;
+	char addr[18];
+	int err;
+
+	if (profile->device_probe == NULL)
+		return;
+
+	probe_uuids = device_match_profile(device, profile, device->uuids);
+	if (!probe_uuids)
+		return;
+
+	ba2str(&device->bdaddr, addr);
+
+	err = profile->device_probe(profile, device, probe_uuids);
+	if (err < 0)
+		error("%s profile probe failed for %s", profile->name, addr);
+	else
+		device->profiles = g_slist_append(device->profiles, profile);
+
+	g_slist_free(probe_uuids);
+}
+
 void device_probe_profiles(struct btd_device *device, GSList *uuids)
 {
 	struct probe_data d = { device, uuids };
diff --git a/src/device.h b/src/device.h
index aee6d13..02c1782 100644
--- a/src/device.h
+++ b/src/device.h
@@ -61,6 +61,7 @@ void device_register_services(struct btd_device *device,
 GSList *device_services_from_record(struct btd_device *device,
 							GSList *profiles);
 void btd_device_add_uuid(struct btd_device *device, const char *uuid);
+void device_probe_profile(gpointer a, gpointer b);
 struct btd_adapter *device_get_adapter(struct btd_device *device);
 void device_get_address(struct btd_device *device, bdaddr_t *bdaddr,
 							uint8_t *bdaddr_type);