summaryrefslogtreecommitdiff
path: root/src/agent.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2011-09-21 00:21:16 +0900
committerJohan Hedberg <johan.hedberg@intel.com>2011-09-21 00:21:16 +0900
commitd4a6604e8d07671ad628a734d6a04d54c08041f0 (patch)
tree479dc585776a6d3f8d9fd3670d51c4ead3c3a46d /src/agent.c
parentbd48d4b7dd772366c86a13141cf49a9ae8ecb6df (diff)
downloadbluez-d4a6604e8d07671ad628a734d6a04d54c08041f0.tar.gz
Fix agent fall-back mechanism
We can't change the agent for a request internally within agent.c since externally code may depend on a specific agent being used so that agent_cancel work properly. This patch exports the fall-back behavior from agent.c into device.c.
Diffstat (limited to 'src/agent.c')
-rw-r--r--src/agent.c67
1 files changed, 3 insertions, 64 deletions
diff --git a/src/agent.c b/src/agent.c
index 607d8c299..9b942e883 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -79,9 +79,6 @@ struct agent_request {
static DBusConnection *connection = NULL;
-static int request_fallback(struct agent_request *req,
- DBusPendingCallNotifyFunction function);
-
static void agent_release(struct agent *agent)
{
DBusMessage *message;
@@ -258,13 +255,6 @@ static void simple_agent_reply(DBusPendingCall *call, void *user_data)
dbus_error_init(&err);
if (dbus_set_error_from_message(&err, message)) {
- if ((g_str_equal(DBUS_ERROR_UNKNOWN_METHOD, err.name) ||
- g_str_equal(DBUS_ERROR_NO_REPLY, err.name)) &&
- request_fallback(req, simple_agent_reply) == 0) {
- dbus_error_free(&err);
- return;
- }
-
error("Agent replied with an error: %s, %s",
err.name, err.message);
@@ -374,15 +364,8 @@ static void pincode_reply(DBusPendingCall *call, void *user_data)
dbus_error_init(&err);
if (dbus_set_error_from_message(&err, message)) {
- if ((g_str_equal(DBUS_ERROR_UNKNOWN_METHOD, err.name) ||
- g_str_equal(DBUS_ERROR_NO_REPLY, err.name)) &&
- request_fallback(req, pincode_reply) == 0) {
- dbus_error_free(&err);
- return;
- }
-
- error("Agent replied with an error: %s, %s",
- err.name, err.message);
+ error("Agent %s replied with an error: %s, %s",
+ agent->path, err.name, err.message);
cb(agent, &err, NULL, req->user_data);
dbus_error_free(&err);
@@ -547,15 +530,8 @@ static void passkey_reply(DBusPendingCall *call, void *user_data)
dbus_error_init(&err);
if (dbus_set_error_from_message(&err, message)) {
- if ((g_str_equal(DBUS_ERROR_UNKNOWN_METHOD, err.name) ||
- g_str_equal(DBUS_ERROR_NO_REPLY, err.name)) &&
- request_fallback(req, passkey_reply) == 0) {
- dbus_error_free(&err);
- return;
- }
-
error("Agent replied with an error: %s, %s",
- err.name, err.message);
+ err.name, err.message);
cb(agent, &err, 0, req->user_data);
dbus_error_free(&err);
goto done;
@@ -696,43 +672,6 @@ failed:
return err;
}
-static int request_fallback(struct agent_request *req,
- DBusPendingCallNotifyFunction function)
-{
- struct btd_adapter *adapter = req->agent->adapter;
- struct agent *adapter_agent = adapter_get_agent(adapter);
- DBusMessage *msg;
-
- if (req->agent == adapter_agent || adapter_agent == NULL)
- return -EINVAL;
-
- dbus_pending_call_cancel(req->call);
- dbus_pending_call_unref(req->call);
-
- msg = dbus_message_copy(req->msg);
-
- dbus_message_set_destination(msg, adapter_agent->name);
- dbus_message_set_path(msg, adapter_agent->path);
-
- if (dbus_connection_send_with_reply(connection, msg,
- &req->call, REQUEST_TIMEOUT) == FALSE) {
- error("D-Bus send failed");
- dbus_message_unref(msg);
- return -EIO;
- }
-
- req->agent->request = NULL;
- req->agent = adapter_agent;
- req->agent->request = req;
-
- dbus_message_unref(req->msg);
- req->msg = msg;
-
- dbus_pending_call_set_notify(req->call, function, req, NULL);
-
- return 0;
-}
-
int agent_display_passkey(struct agent *agent, struct btd_device *device,
uint32_t passkey)
{