diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2012-12-04 15:14:13 +0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-12-04 15:14:35 +0200 |
commit | 916791b0348534a72b25fd59a8e0917d0a65eeb5 (patch) | |
tree | 542fb2e5bf41210d95be8d94730c98a26d7ceef8 /src/agent.c | |
parent | 36ac32c5e8efbf0a141b431fe46d7263914ef38b (diff) | |
download | bluez-916791b0348534a72b25fd59a8e0917d0a65eeb5.tar.gz |
core: Add SSP just-works acceptor mapping to Agent.RequestAuthorization
Diffstat (limited to 'src/agent.c')
-rw-r--r-- | src/agent.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/agent.c b/src/agent.c index bb4b61925..3d234c246 100644 --- a/src/agent.c +++ b/src/agent.c @@ -52,6 +52,7 @@ typedef enum { AGENT_REQUEST_PASSKEY, AGENT_REQUEST_CONFIRMATION, + AGENT_REQUEST_AUTHORIZATION, AGENT_REQUEST_PINCODE, AGENT_REQUEST_AUTHORIZE_SERVICE, AGENT_REQUEST_CONFIRM_MODE, @@ -669,6 +670,63 @@ failed: return err; } +static int authorization_request_new(struct agent_request *req, + const char *device_path) +{ + struct agent *agent = req->agent; + + req->msg = dbus_message_new_method_call(agent->name, agent->path, + "org.bluez.Agent", "RequestAuthorization"); + if (req->msg == NULL) { + error("Couldn't allocate D-Bus message"); + return -ENOMEM; + } + + dbus_message_append_args(req->msg, + DBUS_TYPE_OBJECT_PATH, &device_path, + DBUS_TYPE_INVALID); + + if (dbus_connection_send_with_reply(btd_get_dbus_connection(), req->msg, + &req->call, REQUEST_TIMEOUT) == FALSE) { + error("D-Bus send failed"); + return -EIO; + } + + dbus_pending_call_set_notify(req->call, simple_agent_reply, req, NULL); + + return 0; +} + +int agent_request_authorization(struct agent *agent, struct btd_device *device, + agent_cb cb, void *user_data, + GDestroyNotify destroy) +{ + struct agent_request *req; + const gchar *dev_path = device_get_path(device); + int err; + + if (agent->request) + return -EBUSY; + + DBG("Calling Agent.RequestAuthorization: name=%s, path=%s", + agent->name, agent->path); + + req = agent_request_new(agent, AGENT_REQUEST_AUTHORIZATION, cb, + user_data, destroy); + + err = authorization_request_new(req, dev_path); + if (err < 0) + goto failed; + + agent->request = req; + + return 0; + +failed: + agent_request_free(req, FALSE); + return err; +} + int agent_display_passkey(struct agent *agent, struct btd_device *device, uint32_t passkey, uint16_t entered) { |