diff options
author | Alok Barsode <alok.barsode@azingo.com> | 2008-07-09 12:57:13 +0530 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@indt.org.br> | 2008-07-28 10:34:17 -0300 |
commit | 46fd7beaa5b27f74e64d77449247e5459d7a3084 (patch) | |
tree | 1b9d312654022718b0e9368774bdbd919557736d | |
parent | aec749f0732638f182c4b50fb59d6c905a80d42d (diff) |
Adding device_get_path.
Signed-off-by: Alok Barsode <alok.barsode@azingo.com>
-rw-r--r-- | hcid/adapter.c | 22 | ||||
-rw-r--r-- | hcid/agent.c | 12 | ||||
-rw-r--r-- | hcid/dbus-hci.c | 31 | ||||
-rw-r--r-- | hcid/dbus-service.c | 5 | ||||
-rw-r--r-- | hcid/device.c | 8 | ||||
-rw-r--r-- | hcid/device.h | 1 |
6 files changed, 62 insertions, 17 deletions
diff --git a/hcid/adapter.c b/hcid/adapter.c index 45791734..e70f31c2 100644 --- a/hcid/adapter.c +++ b/hcid/adapter.c @@ -721,7 +721,10 @@ static DBusMessage *remove_bonding(DBusConnection *conn, DBusMessage *msg, if (paired) { gboolean paired = FALSE; - dbus_connection_emit_property_changed(conn, device->path, + + const gchar *dev_path = device_get_path(device); + + dbus_connection_emit_property_changed(conn, dev_path, DEVICE_INTERFACE, "Paired", DBUS_TYPE_BOOLEAN, &paired); } @@ -742,6 +745,7 @@ void adapter_remove_device(DBusConnection *conn, struct adapter *adapter, { bdaddr_t src; const gchar *destination = device_get_address(device); + const gchar *dev_path = device_get_path(device); str2ba(adapter->address, &src); delete_entry(&src, "profiles", destination); @@ -752,7 +756,7 @@ void adapter_remove_device(DBusConnection *conn, struct adapter *adapter, g_dbus_emit_signal(conn, adapter->path, ADAPTER_INTERFACE, "DeviceRemoved", - DBUS_TYPE_OBJECT_PATH, &device->path, + DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_INVALID); } @@ -1534,6 +1538,7 @@ static DBusMessage *list_devices(DBusConnection *conn, GSList *l; DBusMessageIter iter; DBusMessageIter array_iter; + const gchar *dev_path; if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING)) return invalid_args(msg); @@ -1552,8 +1557,10 @@ static DBusMessage *list_devices(DBusConnection *conn, if (device->temporary) continue; + dev_path = device_get_path(device); + dbus_message_iter_append_basic(&array_iter, - DBUS_TYPE_OBJECT_PATH, &device->path); + DBUS_TYPE_OBJECT_PATH, &dev_path); } dbus_message_iter_close_container(&iter, &array_iter); @@ -1634,7 +1641,9 @@ static DBusMessage *create_paired_device(DBusConnection *conn, static gint device_path_cmp(struct device *device, const gchar *path) { - return strcasecmp(device->path, path); + const gchar *dev_path = device_get_path(device); + + return strcasecmp(dev_path, path); } static DBusMessage *remove_device(DBusConnection *conn, @@ -1675,6 +1684,7 @@ static DBusMessage *find_device(DBusConnection *conn, DBusMessage *reply; const gchar *address; GSList *l; + const gchar *dev_path; if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address, DBUS_TYPE_INVALID)) @@ -1698,8 +1708,10 @@ static DBusMessage *find_device(DBusConnection *conn, if (!reply) return NULL; + dev_path = device_get_path(device); + dbus_message_append_args(reply, - DBUS_TYPE_OBJECT_PATH, &device->path, + DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_INVALID); return reply; diff --git a/hcid/agent.c b/hcid/agent.c index ab326789..a2b04be2 100644 --- a/hcid/agent.c +++ b/hcid/agent.c @@ -441,13 +441,14 @@ int agent_request_pincode(struct agent *agent, struct device *device, agent_pincode_cb cb, void *user_data) { struct agent_request *req; + const gchar *dev_path = device_get_path(device); if (agent->request) return -EBUSY; req = agent_request_new(agent, AGENT_REQUEST_PINCODE, cb, user_data); - req->call = pincode_request_new(agent, device->path, FALSE); + req->call = pincode_request_new(agent, dev_path, FALSE); if (!req->call) goto failed; @@ -593,6 +594,7 @@ int agent_request_passkey(struct agent *agent, struct device *device, agent_passkey_cb cb, void *user_data) { struct agent_request *req; + const gchar *dev_path = device_get_path(device); if (agent->request) return -EBUSY; @@ -602,7 +604,7 @@ int agent_request_passkey(struct agent *agent, struct device *device, req = agent_request_new(agent, AGENT_REQUEST_PASSKEY, cb, user_data); - req->call = passkey_request_new(agent, device->path); + req->call = passkey_request_new(agent, dev_path); if (!req->call) goto failed; @@ -653,6 +655,7 @@ int agent_request_confirmation(struct agent *agent, struct device *device, void *user_data) { struct agent_request *req; + const gchar *dev_path = device_get_path(device); if (agent->request) return -EBUSY; @@ -663,7 +666,7 @@ int agent_request_confirmation(struct agent *agent, struct device *device, req = agent_request_new(agent, AGENT_REQUEST_CONFIRMATION, cb, user_data); - req->call = confirmation_request_new(agent, device->path, passkey); + req->call = confirmation_request_new(agent, dev_path, passkey); if (!req->call) goto failed; @@ -682,6 +685,7 @@ int agent_display_passkey(struct agent *agent, struct device *device, uint32_t passkey) { DBusMessage *message; + const gchar *dev_path = device_get_path(device); message = dbus_message_new_method_call(agent->name, agent->path, "org.bluez.Agent", "DisplayPasskey"); @@ -691,7 +695,7 @@ int agent_display_passkey(struct agent *agent, struct device *device, } dbus_message_append_args(message, - DBUS_TYPE_OBJECT_PATH, &device->path, + DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_UINT32, &passkey, DBUS_TYPE_INVALID); diff --git a/hcid/dbus-hci.c b/hcid/dbus-hci.c index 583d2ed7..c4dd3fa5 100644 --- a/hcid/dbus-hci.c +++ b/hcid/dbus-hci.c @@ -1094,6 +1094,7 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer, struct bonding_request_info *bonding; gboolean paired = TRUE; struct pending_auth_info *auth; + const gchar *dev_path; debug("hcid_dbus_bonding_process_complete: status=%02x", status); @@ -1129,13 +1130,14 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer, debug("hcid_dbus_bonding_process_complete: removing temporary flag"); device->temporary = FALSE; + dev_path = device_get_path(device); g_dbus_emit_signal(connection, adapter->path, ADAPTER_INTERFACE, "DeviceCreated", - DBUS_TYPE_OBJECT_PATH, &device->path, + DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_INVALID); - dbus_connection_emit_property_changed(connection, device->path, + dbus_connection_emit_property_changed(connection, dev_path, DEVICE_INTERFACE, "Paired", DBUS_TYPE_BOOLEAN, &paired); } @@ -1658,6 +1660,7 @@ void hcid_dbus_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t class) struct adapter *adapter; GSList *l; struct device *device; + const gchar *dev_path; read_remote_class(local, peer, &old_class); @@ -1678,7 +1681,10 @@ void hcid_dbus_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t class) return; device = l->data; - dbus_connection_emit_property_changed(connection, device->path, + + dev_path = device_get_path(device); + + dbus_connection_emit_property_changed(connection, dev_path, DEVICE_INTERFACE, "Class", DBUS_TYPE_UINT32, &class); } @@ -1689,6 +1695,7 @@ void hcid_dbus_remote_name(bdaddr_t *local, bdaddr_t *peer, uint8_t status, struct adapter *adapter; char peer_addr[18]; const char *paddr = peer_addr; + const gchar *dev_path; adapter = manager_find_adapter(local); if (!adapter) { @@ -1703,8 +1710,11 @@ void hcid_dbus_remote_name(bdaddr_t *local, bdaddr_t *peer, uint8_t status, device = adapter_find_device(adapter, paddr); if (device) { + + dev_path = device_get_path(device); + dbus_connection_emit_property_changed(connection, - device->path, DEVICE_INTERFACE, + dev_path, DEVICE_INTERFACE, "Name", DBUS_TYPE_STRING, &name); } } @@ -1759,6 +1769,7 @@ void hcid_dbus_conn_complete(bdaddr_t *local, uint8_t status, uint16_t handle, char peer_addr[18]; const char *paddr = peer_addr; struct adapter *adapter; + const gchar *dev_path; adapter = manager_find_adapter(local); if (!adapter) { @@ -1785,8 +1796,11 @@ void hcid_dbus_conn_complete(bdaddr_t *local, uint8_t status, uint16_t handle, device = adapter_find_device(adapter, paddr); if (device) { - dbus_connection_emit_property_changed(connection, - device->path, DEVICE_INTERFACE, + + dev_path = device_get_path(device); + + dbus_connection_emit_property_changed(connection, + dev_path, DEVICE_INTERFACE, "Connected", DBUS_TYPE_BOOLEAN, &connected); } @@ -1809,6 +1823,7 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status, gboolean connected = FALSE; struct pending_auth_info *auth; const gchar *destination; + const gchar *dev_path; if (status) { error("Disconnection failed: 0x%02x", status); @@ -1871,8 +1886,10 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status, device = adapter_find_device(adapter, paddr); if (device) { destination = device_get_address(device); + dev_path = device_get_path(device); + dbus_connection_emit_property_changed(connection, - device->path, DEVICE_INTERFACE, + dev_path, DEVICE_INTERFACE, "Connected", DBUS_TYPE_BOOLEAN, &connected); if (device->temporary) { diff --git a/hcid/dbus-service.c b/hcid/dbus-service.c index f6946052..edb3ab0c 100644 --- a/hcid/dbus-service.c +++ b/hcid/dbus-service.c @@ -79,6 +79,7 @@ int service_req_auth(const bdaddr_t *src, const bdaddr_t *dst, struct agent *agent; char address[18]; gboolean trusted; + const gchar *dev_path; adapter = manager_find_adapter(src); if (!adapter) @@ -112,7 +113,9 @@ int service_req_auth(const bdaddr_t *src, const bdaddr_t *dst, auth->cb = cb; auth->user_data = user_data; - return agent_authorize(agent, device->path, uuid, agent_auth_cb, auth); + dev_path = device_get_path(device); + + return agent_authorize(agent, dev_path, uuid, agent_auth_cb, auth); } int service_cancel_auth(const bdaddr_t *src, const bdaddr_t *dst) diff --git a/hcid/device.c b/hcid/device.c index dffbdcde..008afa7e 100644 --- a/hcid/device.c +++ b/hcid/device.c @@ -944,6 +944,14 @@ const gchar *device_get_address(struct device *device) return device->address; } +const gchar *device_get_path(struct device *device) +{ + if (!device) + return NULL; + + return device->path; +} + int btd_register_device_driver(struct btd_device_driver *driver) { const char **uuid; diff --git a/hcid/device.h b/hcid/device.h index f83308dc..be8aee7c 100644 --- a/hcid/device.h +++ b/hcid/device.h @@ -58,6 +58,7 @@ int device_browse(struct device *device, DBusConnection *conn, void device_probe_drivers(struct device *device, GSList *uuids); struct adapter *device_get_adapter(struct device *device); const gchar *device_get_address(struct device *device); +const gchar *device_get_path(struct device *device); #define BTD_UUIDS(args...) ((const char *[]) { args, NULL } ) |