mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2025-01-26 22:33:29 +08:00
Redefining device_get_address to take bdaddr_t as parameter.
This commit is contained in:
parent
2a8fb41c4c
commit
19ce4933f3
@ -673,14 +673,11 @@ static int audio_probe(struct btd_device *device, GSList *records)
|
||||
{
|
||||
struct btd_adapter *adapter = device_get_adapter(device);
|
||||
const gchar *path = device_get_path(device);
|
||||
const char *destination;
|
||||
bdaddr_t src, dst;
|
||||
struct audio_device *dev;
|
||||
|
||||
adapter_get_address(adapter, &src);
|
||||
destination = device_get_address(device);
|
||||
|
||||
str2ba(destination, &dst);
|
||||
device_get_address(device, &dst);
|
||||
|
||||
dev = manager_find_device(&dst, NULL, FALSE);
|
||||
if (!dev) {
|
||||
@ -698,12 +695,11 @@ static int audio_probe(struct btd_device *device, GSList *records)
|
||||
static void audio_remove(struct btd_device *device)
|
||||
{
|
||||
struct audio_device *dev;
|
||||
const char *destination = device_get_address(device);
|
||||
bdaddr_t dst;
|
||||
bdaddr_t bdaddr;
|
||||
|
||||
str2ba(destination, &dst);
|
||||
device_get_address(device, &bdaddr);
|
||||
|
||||
dev = manager_find_device(&dst, NULL, FALSE);
|
||||
dev = manager_find_device(&bdaddr, NULL, FALSE);
|
||||
if (!dev)
|
||||
return;
|
||||
|
||||
|
@ -170,7 +170,6 @@ static int hid_device_probe(struct btd_device *device, GSList *records)
|
||||
{
|
||||
struct btd_adapter *adapter = device_get_adapter(device);
|
||||
const gchar *path = device_get_path(device);
|
||||
const char *destination;
|
||||
struct hidp_connadd_req hidp;
|
||||
bdaddr_t src, dst;
|
||||
|
||||
@ -179,9 +178,7 @@ static int hid_device_probe(struct btd_device *device, GSList *records)
|
||||
memset(&hidp, 0, sizeof(hidp));
|
||||
|
||||
adapter_get_address(adapter, &src);
|
||||
destination = device_get_address(device);
|
||||
|
||||
str2ba(destination, &dst);
|
||||
device_get_address(device, &dst);
|
||||
|
||||
if (load_stored(&src, &dst, &hidp) == 0)
|
||||
goto done;
|
||||
@ -212,7 +209,6 @@ static int headset_probe(struct btd_device *device, GSList *records)
|
||||
sdp_record_t *record = records->data;
|
||||
sdp_list_t *protos;
|
||||
uint8_t ch;
|
||||
const char *destination;
|
||||
bdaddr_t src, dst;
|
||||
|
||||
DBG("path %s", path);
|
||||
@ -232,9 +228,7 @@ static int headset_probe(struct btd_device *device, GSList *records)
|
||||
}
|
||||
|
||||
adapter_get_address(adapter, &src);
|
||||
destination = device_get_address(device);
|
||||
|
||||
str2ba(destination, &dst);
|
||||
device_get_address(device, &dst);
|
||||
|
||||
return fake_input_register(connection, path, &src, &dst,
|
||||
HSP_HS_UUID, ch);
|
||||
|
@ -196,15 +196,12 @@ static int network_probe(struct btd_device *device, GSList *records,
|
||||
{
|
||||
struct btd_adapter *adapter = device_get_adapter(device);
|
||||
const gchar *path = device_get_path(device);
|
||||
const char *destination;
|
||||
bdaddr_t src, dst;
|
||||
|
||||
DBG("path %s", path);
|
||||
|
||||
adapter_get_address(adapter, &src);
|
||||
destination = device_get_address(device);
|
||||
|
||||
str2ba(destination, &dst);
|
||||
device_get_address(device, &dst);
|
||||
|
||||
return connection_register(path, &src, &dst, id);
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ static int serial_probe(struct btd_device *device, sdp_record_t *rec,
|
||||
}
|
||||
|
||||
adapter_get_address(adapter, &src);
|
||||
str2ba(device_get_address(device), &dst);
|
||||
device_get_address(device, &dst);
|
||||
|
||||
return port_register(connection, path, &src, &dst, name,
|
||||
uuid, ch);
|
||||
|
@ -412,8 +412,9 @@ static struct bonding_request_info *bonding_request_new(DBusConnection *conn,
|
||||
struct bonding_request_info *bonding;
|
||||
struct btd_device *device;
|
||||
const char *name = dbus_message_get_sender(msg);
|
||||
const gchar *destination;
|
||||
struct agent *agent;
|
||||
char addr[18];
|
||||
bdaddr_t bdaddr;
|
||||
|
||||
debug("bonding_request_new(%s)", address);
|
||||
|
||||
@ -421,7 +422,9 @@ static struct bonding_request_info *bonding_request_new(DBusConnection *conn,
|
||||
if (!device)
|
||||
return NULL;
|
||||
|
||||
destination = device_get_address(device);
|
||||
device_get_address(device, &bdaddr);
|
||||
ba2str(&bdaddr, addr);
|
||||
|
||||
agent = agent_create(adapter, name, agent_path,
|
||||
capability,
|
||||
device_agent_removed,
|
||||
@ -430,7 +433,7 @@ static struct bonding_request_info *bonding_request_new(DBusConnection *conn,
|
||||
device_set_agent(device, agent);
|
||||
|
||||
debug("Temporary agent registered for hci%d/%s at %s:%s",
|
||||
adapter->dev_id, destination, name,
|
||||
adapter->dev_id, addr, name,
|
||||
agent_path);
|
||||
|
||||
bonding = g_new0(struct bonding_request_info, 1);
|
||||
@ -987,16 +990,19 @@ done:
|
||||
void adapter_remove_device(DBusConnection *conn, struct btd_adapter *adapter,
|
||||
struct btd_device *device)
|
||||
{
|
||||
bdaddr_t src;
|
||||
const gchar *destination = device_get_address(device);
|
||||
bdaddr_t src, dst;
|
||||
const gchar *dev_path = device_get_path(device);
|
||||
struct agent *agent;
|
||||
char dst_addr[18];
|
||||
|
||||
device_get_address(device, &dst);
|
||||
ba2str(&dst, dst_addr);
|
||||
|
||||
str2ba(adapter->address, &src);
|
||||
delete_entry(&src, "profiles", destination);
|
||||
delete_entry(&src, "profiles", dst_addr);
|
||||
|
||||
if (!device_is_temporary(device)) {
|
||||
remove_bonding(conn, NULL, destination, adapter);
|
||||
remove_bonding(conn, NULL, dst_addr, adapter);
|
||||
|
||||
g_dbus_emit_signal(conn, adapter->path,
|
||||
ADAPTER_INTERFACE,
|
||||
@ -2176,6 +2182,8 @@ static void create_stored_device_from_profiles(char *key, char *value,
|
||||
struct btd_device *device;
|
||||
const gchar *src;
|
||||
struct record_list rec_list;
|
||||
bdaddr_t dst;
|
||||
char dst_addr[18];
|
||||
|
||||
if (g_slist_find_custom(adapter->devices,
|
||||
key, (GCompareFunc) device_address_cmp))
|
||||
@ -2188,8 +2196,11 @@ static void create_stored_device_from_profiles(char *key, char *value,
|
||||
device_set_temporary(device, FALSE);
|
||||
adapter->devices = g_slist_append(adapter->devices, device);
|
||||
|
||||
device_get_address(device, &dst);
|
||||
ba2str(&dst, dst_addr);
|
||||
|
||||
src = adapter->address;
|
||||
rec_list.addr = device_get_address(device);
|
||||
rec_list.addr = dst_addr;
|
||||
rec_list.recs = NULL;
|
||||
|
||||
create_name(filename, PATH_MAX, STORAGEDIR, src, "sdp");
|
||||
|
@ -124,7 +124,6 @@ static void pincode_cb(struct agent *agent, DBusError *err, const char *pincode,
|
||||
size_t len;
|
||||
int dev;
|
||||
struct pending_auth_info *auth;
|
||||
const gchar *destination = device_get_address(device);
|
||||
uint16_t dev_id = adapter_get_dev_id(adapter);
|
||||
struct bonding_request_info *bonding = adapter_get_bonding_info(adapter);
|
||||
|
||||
@ -140,7 +139,7 @@ static void pincode_cb(struct agent *agent, DBusError *err, const char *pincode,
|
||||
}
|
||||
|
||||
adapter_get_address(adapter, &sba);
|
||||
str2ba(destination, &dba);
|
||||
device_get_address(device, &dba);
|
||||
|
||||
auth = adapter_find_auth_request(adapter, &dba);
|
||||
|
||||
@ -221,7 +220,6 @@ static void confirm_cb(struct agent *agent, DBusError *err, void *user_data)
|
||||
user_confirm_reply_cp cp;
|
||||
int dd;
|
||||
struct pending_auth_info *auth;
|
||||
const gchar *destination = device_get_address(device);
|
||||
uint16_t dev_id = adapter_get_dev_id(adapter);
|
||||
struct bonding_request_info *bonding = adapter_get_bonding_info(adapter);
|
||||
|
||||
@ -236,7 +234,7 @@ static void confirm_cb(struct agent *agent, DBusError *err, void *user_data)
|
||||
}
|
||||
|
||||
memset(&cp, 0, sizeof(cp));
|
||||
str2ba(destination, &cp.bdaddr);
|
||||
device_get_address(device, &cp.bdaddr);
|
||||
|
||||
auth = adapter_find_auth_request(adapter, &cp.bdaddr);
|
||||
|
||||
@ -264,7 +262,6 @@ static void passkey_cb(struct agent *agent, DBusError *err, uint32_t passkey,
|
||||
bdaddr_t dba;
|
||||
int dd;
|
||||
struct pending_auth_info *auth;
|
||||
const gchar *destination = device_get_address(device);
|
||||
uint16_t dev_id = adapter_get_dev_id(adapter);
|
||||
struct bonding_request_info *bonding = adapter_get_bonding_info(adapter);
|
||||
|
||||
@ -278,7 +275,7 @@ static void passkey_cb(struct agent *agent, DBusError *err, uint32_t passkey,
|
||||
return;
|
||||
}
|
||||
|
||||
str2ba(destination, &dba);
|
||||
device_get_address(device, &dba);
|
||||
|
||||
memset(&cp, 0, sizeof(cp));
|
||||
bacpy(&cp.bdaddr, &dba);
|
||||
@ -1086,10 +1083,11 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status,
|
||||
struct active_conn_info *dev;
|
||||
gboolean connected = FALSE;
|
||||
struct pending_auth_info *auth;
|
||||
const gchar *destination;
|
||||
const gchar *dev_path;
|
||||
uint16_t dev_id;
|
||||
struct bonding_request_info *bonding;
|
||||
bdaddr_t bdaddr;
|
||||
char addr[18];
|
||||
|
||||
if (status) {
|
||||
error("Disconnection failed: 0x%02x", status);
|
||||
@ -1143,7 +1141,9 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status,
|
||||
|
||||
device = adapter_find_device(adapter, paddr);
|
||||
if (device) {
|
||||
destination = device_get_address(device);
|
||||
device_get_address(device, &bdaddr);
|
||||
ba2str(&bdaddr, addr);
|
||||
|
||||
dev_path = device_get_path(device);
|
||||
|
||||
dbus_connection_emit_property_changed(connection,
|
||||
@ -1151,7 +1151,7 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status,
|
||||
"Connected", DBUS_TYPE_BOOLEAN,
|
||||
&connected);
|
||||
if (device_is_temporary(device)) {
|
||||
debug("Removing temporary device %s", destination);
|
||||
debug("Removing temporary device %s", addr);
|
||||
adapter_remove_device(connection, adapter, device);
|
||||
}
|
||||
}
|
||||
|
13
src/device.c
13
src/device.c
@ -633,7 +633,6 @@ void device_probe_drivers(struct btd_device *device, GSList *uuids, sdp_list_t *
|
||||
void device_remove_drivers(struct btd_device *device, GSList *uuids, sdp_list_t *recs)
|
||||
{
|
||||
struct btd_adapter *adapter = device_get_adapter(device);
|
||||
const gchar *dst = device_get_address(device);
|
||||
GSList *list;
|
||||
char src_addr[18];
|
||||
bdaddr_t src;
|
||||
@ -665,7 +664,7 @@ void device_remove_drivers(struct btd_device *device, GSList *uuids, sdp_list_t
|
||||
if (!rec)
|
||||
continue;
|
||||
|
||||
delete_record(src_addr, dst, rec->handle);
|
||||
delete_record(src_addr, device->address, rec->handle);
|
||||
}
|
||||
}
|
||||
|
||||
@ -795,7 +794,6 @@ static void update_services(struct browse_req *req, sdp_list_t *recs)
|
||||
{
|
||||
struct btd_device *device = req->device;
|
||||
struct btd_adapter *adapter = device_get_adapter(device);
|
||||
const gchar *dst = device_get_address(device);
|
||||
sdp_list_t *seq;
|
||||
char src_addr[18];
|
||||
bdaddr_t src;
|
||||
@ -825,7 +823,7 @@ static void update_services(struct browse_req *req, sdp_list_t *recs)
|
||||
if (sdp_list_find(req->records, rec, rec_cmp))
|
||||
continue;
|
||||
|
||||
store_record(src_addr, dst, rec);
|
||||
store_record(src_addr, device->address, rec);
|
||||
|
||||
/* Copy record */
|
||||
if (sdp_gen_record_pdu(rec, &pdu) == 0) {
|
||||
@ -1015,12 +1013,9 @@ struct btd_adapter *device_get_adapter(struct btd_device *device)
|
||||
return device->adapter;
|
||||
}
|
||||
|
||||
const gchar *device_get_address(struct btd_device *device)
|
||||
void device_get_address(struct btd_device *device, bdaddr_t *bdaddr)
|
||||
{
|
||||
if (!device)
|
||||
return NULL;
|
||||
|
||||
return device->address;
|
||||
str2ba(device->address, bdaddr);
|
||||
}
|
||||
|
||||
const gchar *device_get_path(struct btd_device *device)
|
||||
|
@ -32,7 +32,7 @@ int device_browse(struct btd_device *device, DBusConnection *conn,
|
||||
DBusMessage *msg, uuid_t *search);
|
||||
void device_probe_drivers(struct btd_device *device, GSList *uuids, sdp_list_t *recs);
|
||||
struct btd_adapter *device_get_adapter(struct btd_device *device);
|
||||
const gchar *device_get_address(struct btd_device *device);
|
||||
void device_get_address(struct btd_device *adapter, bdaddr_t *bdaddr);
|
||||
const gchar *device_get_path(struct btd_device *device);
|
||||
struct agent *device_get_agent(struct btd_device *device);
|
||||
void device_set_agent(struct btd_device *device, struct agent *agent);
|
||||
|
Loading…
Reference in New Issue
Block a user