summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Collignon <loic.collignon@iot.bzh>2018-06-14 11:04:43 +0200
committerStéphane Desneux <stephane.desneux@iot.bzh>2018-06-14 12:30:26 +0000
commit6cc7b3b79beab5d1f0a6a1cd23d565803b3c9b52 (patch)
treec70c89824135156e4e15585fd3bdd3816f84cc8e
parent44bb35713cb6adcbed82b2d08e794c5269070b2d (diff)
Add special permission to the mixer
Mixer will make use of the high level api to control volume, but it has to have special permission to be allowed to control volume without opening the stream. Change-Id: Iabf76e3df329de3706f24ef21b6df35b5f5aab60 Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
-rw-r--r--ahl-binding/role.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/ahl-binding/role.cpp b/ahl-binding/role.cpp
index b6a9c1f..2be3dc5 100644
--- a/ahl-binding/role.cpp
+++ b/ahl-binding/role.cpp
@@ -229,16 +229,23 @@ void role_t::close(afb_request* r, json_object* o)
void role_t::volume(afb_request* r, json_object* o)
{
- if (!opened_)
+ if(!afb_request_has_permission(r, "urn:AGL:permission::public:4a-audio-mixer"))
{
- afb_request_fail(r, "You have to open the stream first!", nullptr);
- return;
- }
+ if (!opened_)
+ {
+ afb_request_fail(r, "You have to open the stream first!", nullptr);
+ return;
+ }
- if(!afb_request_context_get(r))
+ if(!afb_request_context_get(r))
+ {
+ afb_request_fail(r, "Stream is opened by another client!", nullptr);
+ return;
+ }
+ }
+ else
{
- afb_request_fail(r, "Stream is opened by another client!", nullptr);
- return;
+ AFB_DYNAPI_NOTICE(ahl_binding_t::instance().handle(), "Granted special audio-mixer permission to change volume");
}
json_object* value = json_object_object_get(o, "value");
@@ -249,7 +256,7 @@ void role_t::volume(afb_request* r, json_object* o)
}
json_object_get(value);
-
+
json_object* a = json_object_new_object();
json_object_object_add(a, "volume", value);
@@ -262,7 +269,7 @@ void role_t::volume(afb_request* r, json_object* o)
{
AFB_DYNAPI_DEBUG(handle, "Got the following answer: %s", json_object_to_json_string(result));
afb_request* r = (afb_request*)closure;
-
+
json_object_get(result);
if (status) afb_request_fail(r, json_object_to_json_string(result), nullptr);
else afb_request_success(r, result, nullptr);