diff options
| author | Alok Barsode <alok.barsode@azingo.com> | 2008-07-09 13:19:43 +0530 | 
|---|---|---|
| committer | Luiz Augusto von Dentz <luiz.dentz@indt.org.br> | 2008-07-28 10:34:42 -0300 | 
| commit | a2335a65bb61313b3e46be861c90ca8bdb786eb8 (patch) | |
| tree | 0b3a6bc85393de6d4608013b6cb3eb2b1ba9d361 | |
| parent | 46fd7beaa5b27f74e64d77449247e5459d7a3084 (diff) | |
Adding device_get_agent.
Signed-off-by: Alok Barsode <alok.barsode@azingo.com>
| -rw-r--r-- | hcid/adapter.c | 7 | ||||
| -rw-r--r-- | hcid/dbus-hci.c | 46 | ||||
| -rw-r--r-- | hcid/dbus-service.c | 12 | ||||
| -rw-r--r-- | hcid/device.c | 8 | ||||
| -rw-r--r-- | hcid/device.h | 1 | 
5 files changed, 54 insertions, 20 deletions
diff --git a/hcid/adapter.c b/hcid/adapter.c index e70f31c2..753a1c47 100644 --- a/hcid/adapter.c +++ b/hcid/adapter.c @@ -746,6 +746,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); +	struct agent *agent;  	str2ba(adapter->address, &src);  	delete_entry(&src, "profiles", destination); @@ -760,8 +761,10 @@ void adapter_remove_device(DBusConnection *conn, struct adapter *adapter,  				DBUS_TYPE_INVALID);  	} -	if (device->agent) { -		agent_destroy(device->agent, FALSE); +	agent = device_get_agent(device); + +	if (agent) { +		agent_destroy(agent, FALSE);  		device->agent = NULL;  	} diff --git a/hcid/dbus-hci.c b/hcid/dbus-hci.c index c4dd3fa5..3af3f046 100644 --- a/hcid/dbus-hci.c +++ b/hcid/dbus-hci.c @@ -62,6 +62,7 @@ void bonding_request_free(struct bonding_request_info *bonding)  {  	struct device *device;  	char address[18]; +	struct agent *agent;  	if (!bonding)  		return; @@ -78,8 +79,10 @@ void bonding_request_free(struct bonding_request_info *bonding)  	ba2str(&bonding->bdaddr, address);  	device = adapter_find_device(bonding->adapter, address); -	if (device && device->agent) { -		agent_destroy(device->agent, FALSE); +	agent = device_get_agent(device); + +	if (device && agent) { +		agent_destroy(agent, FALSE);  		device->agent = NULL;  	} @@ -785,7 +788,13 @@ int hcid_dbus_request_pin(int dev, bdaddr_t *sba, struct hci_conn_info *ci)  	ba2str(&ci->bdaddr, addr);  	device = adapter_find_device(adapter, addr); -	agent = device && device->agent ? device->agent : adapter->agent; + +	if (device) +		agent = device_get_agent(device); + +	if (!agent) +		agent = adapter->agent; +  	if (!agent)  		return -EPERM; @@ -985,9 +994,9 @@ int hcid_dbus_user_confirm(bdaddr_t *sba, bdaddr_t *dba, uint32_t passkey)  		return 0;  	} -	if (device->agent) -		agent = device->agent; -	else +	agent = device_get_agent(device); + +	if (!agent)  		agent = adapter->agent;  	if (!agent) { @@ -1024,9 +1033,11 @@ int hcid_dbus_user_passkey(bdaddr_t *sba, bdaddr_t *dba)  	ba2str(dba, addr);  	device = adapter_get_device(connection, adapter, addr); -	if (device && device->agent) -		agent = device->agent; -	else + +	if (device) +		agent = device_get_agent(device); + +	if (!agent)  		agent = adapter->agent;  	if (!agent) { @@ -1062,9 +1073,10 @@ int hcid_dbus_user_notify(bdaddr_t *sba, bdaddr_t *dba, uint32_t passkey)  	ba2str(dba, addr);  	device = adapter_get_device(connection, adapter, addr); -	if (device && device->agent) -		agent = device->agent; -	else +	if (device) +		agent = device_get_agent(device); + +	if (!agent)  		agent = adapter->agent;  	if (!agent) { @@ -2188,10 +2200,12 @@ int hcid_dbus_get_io_cap(bdaddr_t *local, bdaddr_t *remote,  	ba2str(remote, addr);  	device = adapter_find_device(adapter, addr); -	if (device && device->agent) { -		agent = device->agent; -		*auth = 0x03; -	} else +	if (device) { +		agent = device_get_agent(device); +		if (agent) +			*auth = 0x03; +	} +	if (!agent)  		agent = adapter->agent;  	if (!agent) { diff --git a/hcid/dbus-service.c b/hcid/dbus-service.c index edb3ab0c..66575d33 100644 --- a/hcid/dbus-service.c +++ b/hcid/dbus-service.c @@ -102,7 +102,11 @@ int service_req_auth(const bdaddr_t *src, const bdaddr_t *dst,  	if (!device)  		return -EPERM; -	agent = (device->agent ? : adapter->agent); +	agent = device_get_agent(device); + +	if (!agent) +		agent =  adapter->agent; +  	if (!agent)  		return -EPERM; @@ -138,7 +142,11 @@ int service_cancel_auth(const bdaddr_t *src, const bdaddr_t *dst)  	 * agent and in the meanwhile CreatePairedDevice is called.  	 */ -	agent = (device->agent ? : adapter->agent); +	agent = device_get_agent(device); + +	if (!agent) +		agent =  adapter->agent; +  	if (!agent)  		return -EPERM; diff --git a/hcid/device.c b/hcid/device.c index 008afa7e..87f9d80c 100644 --- a/hcid/device.c +++ b/hcid/device.c @@ -952,6 +952,14 @@ const gchar *device_get_path(struct device *device)  	return device->path;  } +struct agent *device_get_agent(struct device *device) +{ +	if (!device) +		return NULL; + +	return  device->agent; +} +  int btd_register_device_driver(struct btd_device_driver *driver)  {  	const char **uuid; diff --git a/hcid/device.h b/hcid/device.h index be8aee7c..611b8140 100644 --- a/hcid/device.h +++ b/hcid/device.h @@ -59,6 +59,7 @@ 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); +struct agent *device_get_agent(struct device *device);  #define BTD_UUIDS(args...) ((const char *[]) { args, NULL } )  | 
