Diff between 76041ebc6b7b6a9cb95040ec6a824c2fea75b2f1 and a3396702362776ca21bbf06686626c7f0bb39d28

Changed Files

File Additions Deletions Status
audio/manager.c +25 -13 modified
profiles/deviceinfo/manager.c +5 -2 modified
profiles/gatt/manager.c +4 -2 modified
profiles/health/hdp_manager.c +7 -4 modified
profiles/input/hog_manager.c +3 -2 modified
profiles/input/manager.c +6 -4 modified
profiles/network/manager.c +7 -4 modified
profiles/proximity/immalert.c +1 -0 modified
profiles/proximity/linkloss.c +1 -0 modified
profiles/proximity/manager.c +4 -2 modified
profiles/proximity/reporter.c +4 -2 modified
profiles/proximity/reporter.h +3 -2 modified
profiles/sap/manager.c +3 -2 modified
profiles/thermometer/manager.c +5 -2 modified
profiles/time/manager.c +1 -1 modified
profiles/time/server.c +7 -2 modified
profiles/time/server.h +2 -2 modified
src/adapter.c +2 -2 modified
src/device.c +3 -3 modified
src/profile.h +8 -4 modified

Full Patch

diff --git a/audio/manager.c b/audio/manager.c
index fbfe00f..9fc19cc 100644
--- a/audio/manager.c
+++ b/audio/manager.c
@@ -665,7 +665,7 @@ static struct audio_device *get_audio_dev(struct btd_device *device)
 	return manager_get_device(&src, &dst, TRUE);
 }
 
-static void audio_remove(struct btd_device *device)
+static void audio_remove(struct btd_profile *p, struct btd_device *device)
 {
 	struct audio_device *dev;
 
@@ -677,7 +677,8 @@ static void audio_remove(struct btd_device *device)
 	audio_device_unregister(dev);
 }
 
-static int hs_probe(struct btd_device *device, GSList *uuids)
+static int hs_probe(struct btd_profile *p, struct btd_device *device,
+								GSList *uuids)
 {
 	struct audio_device *audio_dev;
 
@@ -696,7 +697,8 @@ static int hs_probe(struct btd_device *device, GSList *uuids)
 	return 0;
 }
 
-static int ag_probe(struct btd_device *device, GSList *uuids)
+static int ag_probe(struct btd_profile *p, struct btd_device *device,
+								GSList *uuids)
 {
 	struct audio_device *audio_dev;
 
@@ -714,7 +716,8 @@ static int ag_probe(struct btd_device *device, GSList *uuids)
 	return 0;
 }
 
-static int a2dp_probe(struct btd_device *device, GSList *uuids)
+static int a2dp_probe(struct btd_profile *p, struct btd_device *device,
+								GSList *uuids)
 {
 	struct audio_device *audio_dev;
 
@@ -735,7 +738,8 @@ static int a2dp_probe(struct btd_device *device, GSList *uuids)
 	return 0;
 }
 
-static int avrcp_probe(struct btd_device *device, GSList *uuids)
+static int avrcp_probe(struct btd_profile *p, struct btd_device *device,
+								GSList *uuids)
 {
 	struct audio_device *audio_dev;
 
@@ -846,7 +850,8 @@ static void state_changed(struct btd_adapter *adapter, gboolean powered)
 	telephony = FALSE;
 }
 
-static int headset_server_probe(struct btd_adapter *adapter)
+static int headset_server_probe(struct btd_profile *p,
+						struct btd_adapter *adapter)
 {
 	struct audio_adapter *adp;
 	const gchar *path = adapter_get_path(adapter);
@@ -869,7 +874,8 @@ static int headset_server_probe(struct btd_adapter *adapter)
 	return 0;
 }
 
-static void headset_server_remove(struct btd_adapter *adapter)
+static void headset_server_remove(struct btd_profile *p,
+						struct btd_adapter *adapter)
 {
 	struct audio_adapter *adp;
 	const gchar *path = adapter_get_path(adapter);
@@ -907,7 +913,8 @@ static void headset_server_remove(struct btd_adapter *adapter)
 	audio_adapter_unref(adp);
 }
 
-static int gateway_server_probe(struct btd_adapter *adapter)
+static int gateway_server_probe(struct btd_profile *p,
+						struct btd_adapter *adapter)
 {
 	struct audio_adapter *adp;
 	int err;
@@ -923,7 +930,8 @@ static int gateway_server_probe(struct btd_adapter *adapter)
 	return err;
 }
 
-static void gateway_server_remove(struct btd_adapter *adapter)
+static void gateway_server_remove(struct btd_profile *p,
+						struct btd_adapter *adapter)
 {
 	struct audio_adapter *adp;
 	const gchar *path = adapter_get_path(adapter);
@@ -948,7 +956,8 @@ static void gateway_server_remove(struct btd_adapter *adapter)
 	audio_adapter_unref(adp);
 }
 
-static int a2dp_server_probe(struct btd_adapter *adapter)
+static int a2dp_server_probe(struct btd_profile *p,
+						struct btd_adapter *adapter)
 {
 	struct audio_adapter *adp;
 	const gchar *path = adapter_get_path(adapter);
@@ -970,7 +979,8 @@ static int a2dp_server_probe(struct btd_adapter *adapter)
 	return err;
 }
 
-static void a2dp_server_remove(struct btd_adapter *adapter)
+static void a2dp_server_remove(struct btd_profile *p,
+						struct btd_adapter *adapter)
 {
 	struct audio_adapter *adp;
 	const gchar *path = adapter_get_path(adapter);
@@ -987,7 +997,8 @@ static void a2dp_server_remove(struct btd_adapter *adapter)
 	audio_adapter_unref(adp);
 }
 
-static int avrcp_server_probe(struct btd_adapter *adapter)
+static int avrcp_server_probe(struct btd_profile *p,
+						struct btd_adapter *adapter)
 {
 	struct audio_adapter *adp;
 	const gchar *path = adapter_get_path(adapter);
@@ -1009,7 +1020,8 @@ static int avrcp_server_probe(struct btd_adapter *adapter)
 	return err;
 }
 
-static void avrcp_server_remove(struct btd_adapter *adapter)
+static void avrcp_server_remove(struct btd_profile *p,
+						struct btd_adapter *adapter)
 {
 	struct audio_adapter *adp;
 	const gchar *path = adapter_get_path(adapter);
diff --git a/profiles/deviceinfo/manager.c b/profiles/deviceinfo/manager.c
index 982135e..3217283 100644
--- a/profiles/deviceinfo/manager.c
+++ b/profiles/deviceinfo/manager.c
@@ -42,7 +42,9 @@ static gint primary_uuid_cmp(gconstpointer a, gconstpointer b)
 	return g_strcmp0(prim->uuid, uuid);
 }
 
-static int deviceinfo_driver_probe(struct btd_device *device, GSList *uuids)
+static int deviceinfo_driver_probe(struct btd_profile *p,
+					struct btd_device *device,
+					GSList *uuids)
 {
 	struct gatt_primary *prim;
 	GSList *primaries, *l;
@@ -59,7 +61,8 @@ static int deviceinfo_driver_probe(struct btd_device *device, GSList *uuids)
 	return deviceinfo_register(device, prim);
 }
 
-static void deviceinfo_driver_remove(struct btd_device *device)
+static void deviceinfo_driver_remove(struct btd_profile *p,
+						struct btd_device *device)
 {
 	deviceinfo_unregister(device);
 }
diff --git a/profiles/gatt/manager.c b/profiles/gatt/manager.c
index 6a520b3..747760b 100644
--- a/profiles/gatt/manager.c
+++ b/profiles/gatt/manager.c
@@ -43,7 +43,8 @@ static gint primary_uuid_cmp(gconstpointer a, gconstpointer b)
 	return g_strcmp0(prim->uuid, uuid);
 }
 
-static int gatt_driver_probe(struct btd_device *device, GSList *uuids)
+static int gatt_driver_probe(struct btd_profile *p, struct btd_device *device,
+								GSList *uuids)
 {
 	GSList *primaries, *l;
 	struct gatt_primary *gap = NULL, *gatt = NULL;
@@ -66,7 +67,8 @@ static int gatt_driver_probe(struct btd_device *device, GSList *uuids)
 	return gas_register(device, &gap->range, &gatt->range);
 }
 
-static void gatt_driver_remove(struct btd_device *device)
+static void gatt_driver_remove(struct btd_profile *p,
+						struct btd_device *device)
 {
 	gas_unregister(device);
 }
diff --git a/profiles/health/hdp_manager.c b/profiles/health/hdp_manager.c
index 740fe3a..7b799f4 100644
--- a/profiles/health/hdp_manager.c
+++ b/profiles/health/hdp_manager.c
@@ -42,22 +42,25 @@
 #include "hdp_manager.h"
 #include "hdp.h"
 
-static int hdp_adapter_probe(struct btd_adapter *adapter)
+static int hdp_adapter_probe(struct btd_profile *p,
+						struct btd_adapter *adapter)
 {
 	return hdp_adapter_register(adapter);
 }
 
-static void hdp_adapter_remove(struct btd_adapter *adapter)
+static void hdp_adapter_remove(struct btd_profile *p,
+						struct btd_adapter *adapter)
 {
 	hdp_adapter_unregister(adapter);
 }
 
-static int hdp_driver_probe(struct btd_device *device, GSList *uuids)
+static int hdp_driver_probe(struct btd_profile *p, struct btd_device *device,
+								GSList *uuids)
 {
 	return hdp_device_register(device);
 }
 
-static void hdp_driver_remove(struct btd_device *device)
+static void hdp_driver_remove(struct btd_profile *p, struct btd_device *device)
 {
 	hdp_device_unregister(device);
 }
diff --git a/profiles/input/hog_manager.c b/profiles/input/hog_manager.c
index 8272640..612c12a 100644
--- a/profiles/input/hog_manager.c
+++ b/profiles/input/hog_manager.c
@@ -39,7 +39,8 @@
 #include "device.h"
 #include "hog_device.h"
 
-static int hog_device_probe(struct btd_device *device, GSList *uuids)
+static int hog_device_probe(struct btd_profile *p, struct btd_device *device,
+								GSList *uuids)
 {
 	const char *path = device_get_path(device);
 
@@ -48,7 +49,7 @@ static int hog_device_probe(struct btd_device *device, GSList *uuids)
 	return hog_device_register(device, path);
 }
 
-static void hog_device_remove(struct btd_device *device)
+static void hog_device_remove(struct btd_profile *p, struct btd_device *device)
 {
 	const gchar *path = device_get_path(device);
 
diff --git a/profiles/input/manager.c b/profiles/input/manager.c
index e9a9f99..4e8cf8e 100644
--- a/profiles/input/manager.c
+++ b/profiles/input/manager.c
@@ -56,7 +56,8 @@ static void input_remove(struct btd_device *device, const char *uuid)
 	input_device_unregister(path, uuid);
 }
 
-static int hid_device_probe(struct btd_device *device, GSList *uuids)
+static int hid_device_probe(struct btd_profile *p, struct btd_device *device,
+								GSList *uuids)
 {
 	const gchar *path = device_get_path(device);
 	const sdp_record_t *rec = btd_device_get_record(device, uuids->data);
@@ -70,12 +71,12 @@ static int hid_device_probe(struct btd_device *device, GSList *uuids)
 							idle_timeout * 60);
 }
 
-static void hid_device_remove(struct btd_device *device)
+static void hid_device_remove(struct btd_profile *p, struct btd_device *device)
 {
 	input_remove(device, HID_UUID);
 }
 
-static int hid_server_probe(struct btd_adapter *adapter)
+static int hid_server_probe(struct btd_profile *p, struct btd_adapter *adapter)
 {
 	bdaddr_t src;
 	int ret;
@@ -91,7 +92,8 @@ static int hid_server_probe(struct btd_adapter *adapter)
 	return 0;
 }
 
-static void hid_server_remove(struct btd_adapter *adapter)
+static void hid_server_remove(struct btd_profile *p,
+						struct btd_adapter *adapter)
 {
 	bdaddr_t src;
 
diff --git a/profiles/network/manager.c b/profiles/network/manager.c
index a0506d3..e1f4164 100644
--- a/profiles/network/manager.c
+++ b/profiles/network/manager.c
@@ -73,7 +73,8 @@ done:
 				conf_security ? "true" : "false");
 }
 
-static int network_probe(struct btd_device *device, GSList *uuids)
+static int network_probe(struct btd_profile *p, struct btd_device *device,
+								GSList *uuids)
 {
 	struct btd_adapter *adapter = device_get_adapter(device);
 	const gchar *path = device_get_path(device);
@@ -94,7 +95,7 @@ static int network_probe(struct btd_device *device, GSList *uuids)
 	return 0;
 }
 
-static void network_remove(struct btd_device *device)
+static void network_remove(struct btd_profile *p, struct btd_device *device)
 {
 	const gchar *path = device_get_path(device);
 
@@ -103,7 +104,8 @@ static void network_remove(struct btd_device *device)
 	connection_unregister(path);
 }
 
-static int network_server_probe(struct btd_adapter *adapter)
+static int network_server_probe(struct btd_profile *p,
+						struct btd_adapter *adapter)
 {
 	const gchar *path = adapter_get_path(adapter);
 
@@ -112,7 +114,8 @@ static int network_server_probe(struct btd_adapter *adapter)
 	return server_register(adapter);
 }
 
-static void network_server_remove(struct btd_adapter *adapter)
+static void network_server_remove(struct btd_profile *p,
+						struct btd_adapter *adapter)
 {
 	const gchar *path = adapter_get_path(adapter);
 
diff --git a/profiles/proximity/immalert.c b/profiles/proximity/immalert.c
index 59e4f12..77b4966 100644
--- a/profiles/proximity/immalert.c
+++ b/profiles/proximity/immalert.c
@@ -41,6 +41,7 @@
 #include "gatt-service.h"
 #include "attrib-server.h"
 #include "device.h"
+#include "profile.h"
 #include "attio.h"
 #include "dbus-common.h"
 #include "reporter.h"
diff --git a/profiles/proximity/linkloss.c b/profiles/proximity/linkloss.c
index 659eaa8..40510d8 100644
--- a/profiles/proximity/linkloss.c
+++ b/profiles/proximity/linkloss.c
@@ -41,6 +41,7 @@
 #include "gatt-service.h"
 #include "attrib-server.h"
 #include "device.h"
+#include "profile.h"
 #include "attio.h"
 #include "dbus-common.h"
 #include "reporter.h"
diff --git a/profiles/proximity/manager.c b/profiles/proximity/manager.c
index 39c2bfe..6b6fdad 100644
--- a/profiles/proximity/manager.c
+++ b/profiles/proximity/manager.c
@@ -56,7 +56,8 @@ static gint primary_uuid_cmp(gconstpointer a, gconstpointer b)
 	return g_strcmp0(prim->uuid, uuid);
 }
 
-static int attio_device_probe(struct btd_device *device, GSList *uuids)
+static int attio_device_probe(struct btd_profile *p, struct btd_device *device,
+								GSList *uuids)
 {
 	struct gatt_primary *linkloss, *txpower, *immediate;
 	GSList *l, *primaries;
@@ -78,7 +79,8 @@ static int attio_device_probe(struct btd_device *device, GSList *uuids)
 	return monitor_register(device, linkloss, txpower, immediate, &enabled);
 }
 
-static void attio_device_remove(struct btd_device *device)
+static void attio_device_remove(struct btd_profile *p,
+						struct btd_device *device)
 {
 	monitor_unregister(device);
 	reporter_device_remove(device);
diff --git a/profiles/proximity/reporter.c b/profiles/proximity/reporter.c
index a425d53..1fc42c4 100644
--- a/profiles/proximity/reporter.c
+++ b/profiles/proximity/reporter.c
@@ -41,6 +41,7 @@
 #include "dbus-common.h"
 #include "error.h"
 #include "device.h"
+#include "profile.h"
 #include "hcid.h"
 #include "gattrib.h"
 #include "att.h"
@@ -248,7 +249,7 @@ void reporter_device_remove(struct btd_device *device)
 	unregister_reporter_device(device, radapter);
 }
 
-int reporter_adapter_probe(struct btd_adapter *adapter)
+int reporter_adapter_probe(struct btd_profile *p, struct btd_adapter *adapter)
 {
 	struct reporter_adapter *radapter;
 
@@ -265,7 +266,8 @@ int reporter_adapter_probe(struct btd_adapter *adapter)
 	return 0;
 }
 
-void reporter_adapter_remove(struct btd_adapter *adapter)
+void reporter_adapter_remove(struct btd_profile *p,
+						struct btd_adapter *adapter)
 {
 	struct reporter_adapter *radapter = find_reporter_adapter(adapter);
 	if (!radapter)
diff --git a/profiles/proximity/reporter.h b/profiles/proximity/reporter.h
index d038c0e..95a12c0 100644
--- a/profiles/proximity/reporter.h
+++ b/profiles/proximity/reporter.h
@@ -39,7 +39,8 @@ enum {
 void reporter_device_remove(struct btd_device *device);
 int reporter_device_probe(struct btd_device *device);
 
-int reporter_adapter_probe(struct btd_adapter *adapter);
-void reporter_adapter_remove(struct btd_adapter *adapter);
+int reporter_adapter_probe(struct btd_profile *p, struct btd_adapter *adapter);
+void reporter_adapter_remove(struct btd_profile *p,
+						struct btd_adapter *adapter);
 
 const char *get_alert_level_string(uint8_t level);
diff --git a/profiles/sap/manager.c b/profiles/sap/manager.c
index ebfe266..cb47b93 100644
--- a/profiles/sap/manager.c
+++ b/profiles/sap/manager.c
@@ -32,7 +32,7 @@
 #include "manager.h"
 #include "server.h"
 
-static int sap_server_probe(struct btd_adapter *adapter)
+static int sap_server_probe(struct btd_profile *p, struct btd_adapter *adapter)
 {
 	const char *path = adapter_get_path(adapter);
 	bdaddr_t src;
@@ -44,7 +44,8 @@ static int sap_server_probe(struct btd_adapter *adapter)
 	return sap_server_register(path, &src);
 }
 
-static void sap_server_remove(struct btd_adapter *adapter)
+static void sap_server_remove(struct btd_profile *p,
+						struct btd_adapter *adapter)
 {
 	const char *path = adapter_get_path(adapter);
 
diff --git a/profiles/thermometer/manager.c b/profiles/thermometer/manager.c
index 1b5173e..d965976 100644
--- a/profiles/thermometer/manager.c
+++ b/profiles/thermometer/manager.c
@@ -41,7 +41,9 @@ static gint primary_uuid_cmp(gconstpointer a, gconstpointer b)
 	return g_strcmp0(prim->uuid, uuid);
 }
 
-static int thermometer_driver_probe(struct btd_device *device, GSList *uuids)
+static int thermometer_driver_probe(struct btd_profile *p,
+					struct btd_device *device,
+					GSList *uuids)
 {
 	struct gatt_primary *tattr;
 	GSList *primaries, *l;
@@ -58,7 +60,8 @@ static int thermometer_driver_probe(struct btd_device *device, GSList *uuids)
 	return thermometer_register(device, tattr);
 }
 
-static void thermometer_driver_remove(struct btd_device *device)
+static void thermometer_driver_remove(struct btd_profile *p,
+						struct btd_device *device)
 {
 	thermometer_unregister(device);
 }
diff --git a/profiles/time/manager.c b/profiles/time/manager.c
index 8dab12f..608a807 100644
--- a/profiles/time/manager.c
+++ b/profiles/time/manager.c
@@ -35,7 +35,7 @@
 #include "server.h"
 
 struct btd_profile time_profile = {
-	.name 		= "gatt-time-server",
+	.name		= "gatt-time-server",
 	.adapter_probe	= time_server_init,
 	.adapter_remove	= time_server_exit,
 };
diff --git a/profiles/time/server.c b/profiles/time/server.c
index db97056..bd75037 100644
--- a/profiles/time/server.c
+++ b/profiles/time/server.c
@@ -29,8 +29,13 @@
 #include <glib.h>
 #include <time.h>
 #include <errno.h>
+#include <stdbool.h>
+
 #include <bluetooth/uuid.h>
+
 #include <adapter.h>
+#include <device.h>
+#include <profile.h>
 
 #include "gattrib.h"
 #include "att.h"
@@ -207,7 +212,7 @@ static gboolean register_ref_time_update_service(struct btd_adapter *adapter)
 				GATT_OPT_INVALID);
 }
 
-int time_server_init(struct btd_adapter *adapter)
+int time_server_init(struct btd_profile *p, struct btd_adapter *adapter)
 {
 	const char *path = adapter_get_path(adapter);
 
@@ -226,7 +231,7 @@ int time_server_init(struct btd_adapter *adapter)
 	return 0;
 }
 
-void time_server_exit(struct btd_adapter *adapter)
+void time_server_exit(struct btd_profile *p, struct btd_adapter *adapter)
 {
 	const char *path = adapter_get_path(adapter);
 
diff --git a/profiles/time/server.h b/profiles/time/server.h
index c7b997d..44e2f61 100644
--- a/profiles/time/server.h
+++ b/profiles/time/server.h
@@ -41,5 +41,5 @@ enum {
 	CANCEL_REFERENCE_UPDATE = 2,
 };
 
-int time_server_init(struct btd_adapter *adapter);
-void time_server_exit(struct btd_adapter *adapter);
+int time_server_init(struct btd_profile *p, struct btd_adapter *adapter);
+void time_server_exit(struct btd_profile *p, struct btd_adapter *adapter);
diff --git a/src/adapter.c b/src/adapter.c
index f9acbd5..e154c69 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2042,7 +2042,7 @@ static void probe_profile(struct btd_profile *profile, void *data)
 	if (profile->adapter_probe == NULL)
 		return;
 
-	err = profile->adapter_probe(adapter);
+	err = profile->adapter_probe(profile, adapter);
 	if (err < 0) {
 		error("%s: %s (%d)", profile->name, strerror(-err), -err);
 		return;
@@ -2276,7 +2276,7 @@ static void remove_profile(gpointer data, gpointer user_data)
 	struct btd_adapter *adapter = user_data;
 
 	if (profile->adapter_remove)
-		profile->adapter_remove(adapter);
+		profile->adapter_remove(profile, adapter);
 }
 
 static void unload_drivers(struct btd_adapter *adapter)
diff --git a/src/device.c b/src/device.c
index 1258109..57fdf00 100644
--- a/src/device.c
+++ b/src/device.c
@@ -497,7 +497,7 @@ static DBusMessage *set_trust(DBusMessage *msg, gboolean value, void *data)
 static void profile_remove(struct btd_profile *profile,
 						struct btd_device *device)
 {
-	profile->device_remove(device);
+	profile->device_remove(profile, device);
 
 	device->profiles = g_slist_remove(device->profiles, profile);
 }
@@ -1361,7 +1361,7 @@ static void dev_probe(struct btd_profile *p, void *user_data)
 	if (!probe_uuids)
 		return;
 
-	err = p->device_probe(d->dev, probe_uuids);
+	err = p->device_probe(p, d->dev, probe_uuids);
 	if (err < 0) {
 		error("%s profile probe failed for %s", p->name, d->addr);
 		g_slist_free(probe_uuids);
@@ -1447,7 +1447,7 @@ static void device_remove_profiles(struct btd_device *device, GSList *uuids)
 			continue;
 		}
 
-		profile->device_remove(device);
+		profile->device_remove(profile, device);
 		device->profiles = g_slist_remove(device->profiles, profile);
 	}
 }
diff --git a/src/profile.h b/src/profile.h
index 178e7bf..12d2b3e 100644
--- a/src/profile.h
+++ b/src/profile.h
@@ -36,15 +36,19 @@ struct btd_profile {
 
 	bool auto_connect;
 
-	int (*device_probe) (struct btd_device *device, GSList *uuids);
-	void (*device_remove) (struct btd_device *device);
+	int (*device_probe) (struct btd_profile *p, struct btd_device *device,
+								GSList *uuids);
+	void (*device_remove) (struct btd_profile *p,
+						struct btd_device *device);
 
 	int (*connect) (struct btd_device *device, struct btd_profile *profile,
 							btd_profile_cb cb);
 	int (*disconnect) (struct btd_device *device, btd_profile_cb cb);
 
-	int (*adapter_probe) (struct btd_adapter *adapter);
-	void (*adapter_remove) (struct btd_adapter *adapter);
+	int (*adapter_probe) (struct btd_profile *p,
+						struct btd_adapter *adapter);
+	void (*adapter_remove) (struct btd_profile *p,
+						struct btd_adapter *adapter);
 };
 
 void btd_profile_foreach(void (*func)(struct btd_profile *p, void *data),