From 44b781c2d0553702ed830006a14d3bf4e3473b4c Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Fri, 14 Mar 2008 22:10:29 +0000 Subject: Fix RequestMode when no agent is registered or the new mode is the same. --- hcid/adapter.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hcid/adapter.c b/hcid/adapter.c index a17ee5eb..3214820e 100644 --- a/hcid/adapter.c +++ b/hcid/adapter.c @@ -3764,7 +3764,7 @@ static DBusHandlerResult request_mode(DBusConnection *conn, return error_invalid_arguments(conn, msg, NULL); /* No need to change mode */ - if (adapter->mode > new_mode) { + if (adapter->mode >= new_mode) { reply = dbus_message_new_method_return(msg); if (!reply) return DBUS_HANDLER_RESULT_NEED_MEMORY; @@ -3772,6 +3772,9 @@ static DBusHandlerResult request_mode(DBusConnection *conn, return send_message_and_unref(conn, reply); } + if (!adapter->agent) + return error_failed(conn, msg, "No agent registered"); + req = g_new0(struct mode_req, 1); req->adapter = adapter; req->conn = dbus_connection_ref(conn); -- cgit