diff --git a/audio/manager.c b/audio/manager.c
index fbfe00f..9fc19cc 100644
--- a/audio/manager.c
+++ b/audio/manager.c
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;
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;
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;
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;
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;
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);
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);
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;
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);
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);
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);
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);
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
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;
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
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;
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
#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
#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);
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
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);
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;
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
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);
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);
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);
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
#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
#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
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;
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
#include "dbus-common.h"
#include "error.h"
#include "device.h"
+#include "profile.h"
#include "hcid.h"
#include "gattrib.h"
#include "att.h"
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;
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
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
#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;
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
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;
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
#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
#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"
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);
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
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
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;
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
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);
}
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);
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
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),