summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz-von@nokia.com>2010-06-30 18:22:35 +0300
committerJohan Hedberg <johan.hedberg@nokia.com>2010-07-01 12:37:46 +0300
commitb5d5bf263f4034ed9e7d40500ad8815b8e45cc8c (patch)
tree7a73fd50c607a2e28e7447c2ff60b9c0e4c5e656
parent90608519f3701763ca00b27d6ae133d6bbb07bad (diff)
downloadbluez-b5d5bf263f4034ed9e7d40500ad8815b8e45cc8c.tar.gz
core: fix emitting pairable when there could still occur an error
An error could be generate by set_mode which then will make application to assume that we were unable to change the property, which wasn't the case.
-rw-r--r--src/adapter.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/adapter.c b/src/adapter.c
index 5d90b4612..d1fae55f5 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -521,6 +521,19 @@ static DBusMessage *set_pairable(DBusConnection *conn, DBusMessage *msg,
if (pairable == adapter->pairable)
goto done;
+ if (!(adapter->scan_mode & SCAN_INQUIRY))
+ goto store;
+
+ mode = (pairable && adapter->discov_timeout > 0 &&
+ adapter->discov_timeout <= 60) ?
+ MODE_LIMITED : MODE_DISCOVERABLE;
+
+ err = set_mode(adapter, mode);
+ if (err < 0 && msg)
+ return failed_strerror(msg, -err);
+
+store:
+
adapter->pairable = pairable;
write_device_pairable(&adapter->bdaddr, pairable);
@@ -533,17 +546,6 @@ static DBusMessage *set_pairable(DBusConnection *conn, DBusMessage *msg,
adapter_set_pairable_timeout(adapter,
adapter->pairable_timeout);
- if (!(adapter->scan_mode & SCAN_INQUIRY))
- goto done;
-
- mode = (pairable && adapter->discov_timeout > 0 &&
- adapter->discov_timeout <= 60) ?
- MODE_LIMITED : MODE_DISCOVERABLE;
-
- err = set_mode(adapter, mode);
- if (err < 0 && msg)
- return failed_strerror(msg, -err);
-
done:
return msg ? dbus_message_new_method_return(msg) : NULL;
}