diff --git a/profiles/audio/manager.c b/profiles/audio/manager.c
index 3498945..689a309 100644
--- a/profiles/audio/manager.c
+++ b/profiles/audio/manager.c
struct profile_req *req = data;
if (req->cb)
- req->cb(req->profile, req->device, err);
+ req->cb(req->device, req->profile, err);
g_free(req);
}
static int a2dp_source_connect(struct btd_device *dev,
- struct btd_profile *profile,
- btd_profile_cb cb)
+ struct btd_profile *profile)
{
const gchar *path = device_get_path(dev);
struct audio_device *audio_dev;
return -1;
}
- req = new_profile_request(dev, profile, cb);
+ req = new_profile_request(dev, profile, device_profile_connected);
err = source_connect(audio_dev, profile_cb, req);
if (err < 0) {
}
static int a2dp_source_disconnect(struct btd_device *dev,
- struct btd_profile *profile,
- btd_profile_cb cb)
+ struct btd_profile *profile)
{
const gchar *path = device_get_path(dev);
struct audio_device *audio_dev;
return -1;
}
- req = new_profile_request(dev, profile, cb);
+ req = new_profile_request(dev, profile, device_profile_disconnected);
err = source_disconnect(audio_dev, FALSE, profile_cb, req);
if (err < 0) {
}
static int a2dp_sink_connect(struct btd_device *dev,
- struct btd_profile *profile,
- btd_profile_cb cb)
+ struct btd_profile *profile)
{
const gchar *path = device_get_path(dev);
struct audio_device *audio_dev;
return -1;
}
- req = new_profile_request(dev, profile, cb);
+ req = new_profile_request(dev, profile, device_profile_connected);
err = sink_connect(audio_dev, profile_cb, req);
if (err < 0) {
}
static int a2dp_sink_disconnect(struct btd_device *dev,
- struct btd_profile *profile,
- btd_profile_cb cb)
+ struct btd_profile *profile)
{
const gchar *path = device_get_path(dev);
struct audio_device *audio_dev;
return -1;
}
- req = new_profile_request(dev, profile, cb);
+ req = new_profile_request(dev, profile, device_profile_disconnected);
err = sink_disconnect(audio_dev, FALSE, profile_cb, req);
if (err < 0) {
}
static int avrcp_control_connect(struct btd_device *dev,
- struct btd_profile *profile,
- btd_profile_cb cb)
+ struct btd_profile *profile)
{
const gchar *path = device_get_path(dev);
struct audio_device *audio_dev;
return -1;
}
- req = new_profile_request(dev, profile, cb);
+ req = new_profile_request(dev, profile, device_profile_connected);
err = control_connect(audio_dev, profile_cb, req);
if (err < 0) {
}
static int avrcp_control_disconnect(struct btd_device *dev,
- struct btd_profile *profile,
- btd_profile_cb cb)
+ struct btd_profile *profile)
{
const gchar *path = device_get_path(dev);
struct audio_device *audio_dev;
return -1;
}
- req = new_profile_request(dev, profile, cb);
+ req = new_profile_request(dev, profile, device_profile_disconnected);
err = control_disconnect(audio_dev, profile_cb, req);
if (err < 0) {
diff --git a/profiles/input/device.c b/profiles/input/device.c
index b22e0a7..aaf1ff8 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
if (err_msg)
error("%s", err_msg);
- pending->cb(pending->profile, idev->device, err);
+ pending->cb(idev->device, pending->profile, err);
g_free(pending);
}
return -EIO;
}
-int input_device_connect(struct btd_device *dev, struct btd_profile *profile,
- btd_profile_cb cb)
+int input_device_connect(struct btd_device *dev, struct btd_profile *profile)
{
struct input_device *idev;
idev->pending = g_new0(struct pending_connect, 1);
idev->pending->profile = profile;
- idev->pending->cb = cb;
+ idev->pending->cb = device_profile_connected;
return dev_connect(idev);
}
-int input_device_disconnect(struct btd_device *dev, struct btd_profile *profile,
- btd_profile_cb cb)
+int input_device_disconnect(struct btd_device *dev, struct btd_profile *profile)
{
struct input_device *idev;
int err;
if (err < 0)
return err;
- if (cb)
- cb(profile, dev, 0);
+ device_profile_disconnected(dev, profile, 0);
return 0;
}
diff --git a/profiles/input/device.h b/profiles/input/device.h
index d68798c..aabc79c 100644
--- a/profiles/input/device.h
+++ b/profiles/input/device.h
GIOChannel *io);
int input_device_close_channels(const bdaddr_t *src, const bdaddr_t *dst);
-int input_device_connect(struct btd_device *dev, struct btd_profile *profile,
- btd_profile_cb cb);
-int input_device_disconnect(struct btd_device *dev, struct btd_profile *profile,
- btd_profile_cb cb);
+int input_device_connect(struct btd_device *dev, struct btd_profile *profile);
+int input_device_disconnect(struct btd_device *dev,
+ struct btd_profile *profile);
diff --git a/profiles/network/manager.c b/profiles/network/manager.c
index e737f6d..1c75e8f 100644
--- a/profiles/network/manager.c
+++ b/profiles/network/manager.c
{
struct connect_req *req = data;
- req->cb(req->profile, device, err);
+ req->cb(device, req->profile, err);
g_free(req);
}
return err;
if (cb)
- cb(profile, dev, 0);
+ cb(dev, profile, 0);
return 0;
}
connection_unregister(device);
}
-static int panu_connect(struct btd_device *dev, struct btd_profile *profile,
- btd_profile_cb cb)
+static int panu_connect(struct btd_device *dev, struct btd_profile *profile)
{
- return connect_profile(dev, profile, BNEP_SVC_PANU, cb);
+ return connect_profile(dev, profile, BNEP_SVC_PANU,
+ device_profile_connected);
}
-static int panu_disconnect(struct btd_device *dev, struct btd_profile *profile,
- btd_profile_cb cb)
+static int panu_disconnect(struct btd_device *dev, struct btd_profile *profile)
{
- return disconnect_profile(dev, profile, BNEP_SVC_PANU, cb);
+ return disconnect_profile(dev, profile, BNEP_SVC_PANU,
+ device_profile_disconnected);
}
static int panu_server_probe(struct btd_profile *p, struct btd_adapter *adapter)
return connection_register(device, BNEP_SVC_GN);
}
-static int gn_connect(struct btd_device *dev, struct btd_profile *profile,
- btd_profile_cb cb)
+static int gn_connect(struct btd_device *dev, struct btd_profile *profile)
{
- return connect_profile(dev, profile, BNEP_SVC_GN, cb);
+ return connect_profile(dev, profile, BNEP_SVC_GN,
+ device_profile_connected);
}
-static int gn_disconnect(struct btd_device *dev, struct btd_profile *profile,
- btd_profile_cb cb)
+static int gn_disconnect(struct btd_device *dev, struct btd_profile *profile)
{
- return disconnect_profile(dev, profile, BNEP_SVC_GN, cb);
+ return disconnect_profile(dev, profile, BNEP_SVC_GN,
+ device_profile_disconnected);
}
static int gn_server_probe(struct btd_profile *p, struct btd_adapter *adapter)
return connection_register(device, BNEP_SVC_NAP);
}
-static int nap_connect(struct btd_device *dev, struct btd_profile *profile,
- btd_profile_cb cb)
+static int nap_connect(struct btd_device *dev, struct btd_profile *profile)
{
- return connect_profile(dev, profile, BNEP_SVC_NAP, cb);
+ return connect_profile(dev, profile, BNEP_SVC_NAP,
+ device_profile_connected);
}
-static int nap_disconnect(struct btd_device *dev, struct btd_profile *profile,
- btd_profile_cb cb)
+static int nap_disconnect(struct btd_device *dev, struct btd_profile *profile)
{
- return disconnect_profile(dev, profile, BNEP_SVC_NAP, cb);
+ return disconnect_profile(dev, profile, BNEP_SVC_NAP,
+ device_profile_disconnected);
}
static int nap_server_probe(struct btd_profile *p, struct btd_adapter *adapter)
diff --git a/src/device.c b/src/device.c
index 419bf9b..e97265b 100644
--- a/src/device.c
+++ b/src/device.c
if (!profile->disconnect)
return;
- profile->disconnect(dev, profile, NULL);
+ profile->disconnect(dev, profile);
}
void device_request_disconnect(struct btd_device *device, DBusMessage *msg)
return NULL;
}
-static int connect_next(struct btd_device *dev, btd_profile_cb cb)
+static int connect_next(struct btd_device *dev)
{
struct btd_profile *profile;
int err = -ENOENT;
profile = dev->pending->data;
- err = profile->connect(dev, profile, cb);
+ err = profile->connect(dev, profile);
if (err == 0)
return 0;
return err;
}
-static void dev_profile_connected(struct btd_profile *profile,
- struct btd_device *dev, int err)
+void device_profile_connected(struct btd_device *dev,
+ struct btd_profile *profile, int err)
{
DBG("%s (%d)", strerror(-err), -err);
dev->pending = g_slist_remove(dev->pending, profile);
if (!err) {
- if (connect_next(dev, dev_profile_connected) == 0)
+ if (connect_next(dev) == 0)
return;
dev->profiles_connected = TRUE;
}
return btd_error_not_available(msg);
start_connect:
- err = connect_next(dev, dev_profile_connected);
+ err = connect_next(dev);
if (err < 0)
return btd_error_failed(msg, strerror(-err));
return reply;
}
-static void profile_disconnected(struct btd_profile *profile,
- struct btd_device *dev, int err)
+void device_profile_disconnected(struct btd_device *dev,
+ struct btd_profile *profile, int err)
{
if (!dev->disconnect)
return;
if (!p->disconnect)
return btd_error_not_supported(msg);
- err = p->disconnect(dev, p, profile_disconnected);
+ err = p->disconnect(dev, p);
if (err < 0)
return btd_error_failed(msg, strerror(-err));
diff --git a/src/device.h b/src/device.h
index 5e173bd..1987a80 100644
--- a/src/device.h
+++ b/src/device.h
uint16_t vendor_id, uint16_t product_id,
uint16_t product_ver);
GIOChannel *device_att_connect(gpointer user_data);
+
+struct btd_profile;
+
+void device_profile_connected(struct btd_device *dev,
+ struct btd_profile *profile, int err);
+void device_profile_disconnected(struct btd_device *dev,
+ struct btd_profile *profile, int err);
diff --git a/src/profile.c b/src/profile.c
index afa487b..da34e25 100644
--- a/src/profile.c
+++ b/src/profile.c
if (!dbus_error_is_set(&err)) {
if (conn->cb) {
- conn->cb(&ext->p, conn->device, 0);
+ conn->cb(conn->device, &ext->p, 0);
conn->cb = NULL;
}
err.name, err.message);
if (conn->cb) {
- conn->cb(&ext->p, conn->device, -ECONNREFUSED);
+ conn->cb(conn->device, &ext->p, -ECONNREFUSED);
conn->cb = NULL;
}
drop:
if (conn->cb) {
- conn->cb(&ext->p, conn->device, err ? -err->code : -EIO);
+ conn->cb(conn->device, &ext->p, err ? -err->code : -EIO);
conn->cb = NULL;
}
if (io_err)
return;
failed:
- conn->cb(&ext->p, conn->device, err);
+ conn->cb(conn->device, &ext->p, err);
ext->conns = g_slist_remove(ext->conns, conn);
ext_io_destroy(conn);
}
return err;
}
-static int ext_connect_dev(struct btd_device *dev, struct btd_profile *profile,
- btd_profile_cb cb)
+static int ext_connect_dev(struct btd_device *dev, struct btd_profile *profile)
{
struct btd_adapter *adapter;
struct ext_io *conn;
conn->adapter = btd_adapter_ref(adapter);
conn->device = btd_device_ref(dev);
- conn->cb = cb;
+ conn->cb = device_profile_connected;
ext->conns = g_slist_append(ext->conns, conn);
}
static int ext_disconnect_dev(struct btd_device *dev,
- struct btd_profile *profile,
- btd_profile_cb cb)
+ struct btd_profile *profile)
{
struct ext_profile *ext;
struct ext_io *conn;
if (err < 0)
return err;
- conn->cb = cb;
+ conn->cb = device_profile_disconnected;
return 0;
}
diff --git a/src/profile.h b/src/profile.h
index 6991041..826d8dd 100644
--- a/src/profile.h
+++ b/src/profile.h
struct btd_profile;
-typedef void (*btd_profile_cb)(struct btd_profile *profile,
- struct btd_device *device, int err);
+typedef void (*btd_profile_cb)(struct btd_device *device,
+ struct btd_profile *profile, int err);
struct btd_profile {
const char *name;
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 (*connect) (struct btd_device *device,
+ struct btd_profile *profile);
int (*disconnect) (struct btd_device *device,
- struct btd_profile *profile,
- btd_profile_cb cb);
+ struct btd_profile *profile);
int (*adapter_probe) (struct btd_profile *p,
struct btd_adapter *adapter);