summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2008-04-11 19:34:17 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2008-04-11 19:34:17 +0000
commit7ac7ec4e9be4a28d906fa152bfdd1e7e7ceed6f6 (patch)
tree2f09918ac71043ba0e4b3c1434bd631e5b3b44c3 /hcid
parent25f696a6bb2682902ba8d34cea190ef0ebf45aa4 (diff)
Plugin auth cancel: call device's agent when it is available
Diffstat (limited to 'hcid')
-rw-r--r--hcid/plugin.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/hcid/plugin.c b/hcid/plugin.c
index 29f11714..ca43ae72 100644
--- a/hcid/plugin.c
+++ b/hcid/plugin.c
@@ -240,9 +240,26 @@ int plugin_req_auth(bdaddr_t *src, bdaddr_t *dst,
int plugin_cancel_auth(bdaddr_t *src)
{
struct adapter *adapter = ba2adapter(src);
+ struct device *device;
+ struct agent *agent;
+ char address[18];
+
+ if (!adapter)
+ return -EPERM;
- if (!adapter || !adapter->agent)
+ ba2str(src, address);
+ device = adapter_find_device(adapter, address);
+ if (!device)
+ return -EPERM;
+
+ /*
+ * FIXME: Cancel fails if authorization is requested to adapter's
+ * agent and in the meanwhile CreatePairedDevice is called.
+ */
+
+ agent = (device->agent ? : adapter->agent);
+ if (!agent)
return -EPERM;
- return agent_cancel(adapter->agent);
+ return agent_cancel(agent);
}