From 274e7ed3510164c036ae67651f11410911e14f8a Mon Sep 17 00:00:00 2001 From: Loïc Collignon <loic.collignon@iot.bzh> Date: Fri, 31 Aug 2018 08:43:26 +0200 Subject: Do not list audio roles not bound to a device MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most of the time if you request an audio role, it's to use it. But you can't use an audio role not bound to a device. Listing not bound audio roles can also lead to confusion. If you want to list all audio roles anyway, you can now pass a verbose parameter. Bug: SPEC-1690, SPEC-1646 Change-Id: Ie216cb58317393c0e7136919bb9c91c259881acd Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh> --- ahl-binding/ahl-binding.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ahl-binding/ahl-binding.cpp b/ahl-binding/ahl-binding.cpp index 79cf7b2..ce31499 100644 --- a/ahl-binding/ahl-binding.cpp +++ b/ahl-binding/ahl-binding.cpp @@ -386,9 +386,21 @@ int ahl_binding_t::create_api_verb(role_t* r) void ahl_binding_t::get_roles(afb_request* req) { + json_bool verbose = FALSE; + json_object* arg = afb_request_json(req); + json_object* jverbose; + if (arg != nullptr) + { + json_bool ret = json_object_object_get_ex(arg, "verbose", &jverbose); + if (ret) verbose = json_object_get_boolean(jverbose); + } + json_object* result = json_object_new_array(); for(const auto& r : roles_) - json_object_array_add(result, json_object_new_string(r.uid().c_str())); + { + if (verbose == TRUE || r.device_uri().size()) + json_object_array_add(result, json_object_new_string(r.uid().c_str())); + } afb_request_success(req, result, nullptr); } -- cgit