summaryrefslogtreecommitdiffstats
path: root/ahl-binding
diff options
context:
space:
mode:
authorLoïc Collignon <loic.collignon@iot.bzh>2018-08-31 08:43:26 +0200
committerLoïc Collignon <loic.collignon@iot.bzh>2018-08-31 08:43:26 +0200
commit274e7ed3510164c036ae67651f11410911e14f8a (patch)
tree041f4ab10788200e6f4ff8a5679aa92255bacd3c /ahl-binding
parent9a2509a3830c6ca481c56c626a2d016750bb1c0f (diff)
Do not list audio roles not bound to a device
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>
Diffstat (limited to 'ahl-binding')
-rw-r--r--ahl-binding/ahl-binding.cpp14
1 files changed, 13 insertions, 1 deletions
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);
}