diff options
-rw-r--r-- | ahl-binding/role.cpp | 25 |
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); |