summaryrefslogtreecommitdiffstats
path: root/ahl-binding
diff options
context:
space:
mode:
Diffstat (limited to 'ahl-binding')
-rw-r--r--ahl-binding/ahl-binding.c26
-rw-r--r--ahl-binding/ahl-deviceenum.c4
-rw-r--r--ahl-binding/ahl-json.c2
3 files changed, 26 insertions, 6 deletions
diff --git a/ahl-binding/ahl-binding.c b/ahl-binding/ahl-binding.c
index c205c8e..0b2348a 100644
--- a/ahl-binding/ahl-binding.c
+++ b/ahl-binding/ahl-binding.c
@@ -867,12 +867,19 @@ PUBLIC void audiohlapi_volume(struct afb_req req)
json_object *paramJ= json_object_new_string(volumeStr);
json_object_object_add(pPolicyEndpointJ, "arg_volume", paramJ);
- int policyAllowed = Policy_SetVolume(pPolicyEndpointJ);
+ json_object * pPolicyVolumeReply = NULL;
+ int policyAllowed = Policy_SetVolume(pPolicyEndpointJ,&pPolicyVolumeReply);
if (!policyAllowed)
{
afb_req_fail(req, "Audio policy violation", "Set volume not allowed in current context");
return;
}
+
+ err = wrap_json_unpack(pPolicyVolumeReply,"{s:i}","volume",&pEndpointInfo->iVolume);
+ if (err) {
+ afb_req_fail_f(req, "Invalid policy reply", "Policy volume change reply not a valid json object=%s", json_object_get_string(pPolicyVolumeReply));
+ return;
+ }
#else
// Simulate that policy returns target state (accepted)
pEndpointInfo->iVolume = atoi(volumeStr);
@@ -951,15 +958,28 @@ PUBLIC void audiohlapi_property(struct afb_req req)
json_object_object_add(pPolicyEndpointJ, "arg_property_value", propValueJ);
// Call policy to allow custom policy actions in current context
- int policyAllowed = Policy_SetProperty(pPolicyEndpointJ);
+ json_object * pPropertyReply = NULL;
+ int policyAllowed = Policy_SetProperty(pPolicyEndpointJ,&pPropertyReply);
if (!policyAllowed)
{
afb_req_fail(req, "Audio policy violation", "Set endpoint property not allowed in current context");
return;
}
+
+ json_object * pPropReplyValue = NULL;
+ err = wrap_json_unpack(pPropertyReply,"{s:o}","value",&pPropReplyValue);
+ if (err) {
+ afb_req_fail_f(req, "Invalid policy reply", "Policy property change reply not a valid json object=%s", json_object_get_string(pPropertyReply));
+ return;
+ }
+ if (pEndpointInfo->pPropTable && pPropReplyValue) {
+ json_object_get(pPropReplyValue);
+ g_hash_table_insert(pEndpointInfo->pPropTable, propertyName, pPropReplyValue);
+ }
#else
// Simulate that policy returns target state (accepted)
- if (pEndpointInfo->pPropTable)
+ if (pEndpointInfo->pPropTable && propValueJ)
+ json_object_get(propValueJ);
g_hash_table_insert(pEndpointInfo->pPropTable, propertyName, propValueJ);
#endif
}
diff --git a/ahl-binding/ahl-deviceenum.c b/ahl-binding/ahl-deviceenum.c
index 763b2ca..f672417 100644
--- a/ahl-binding/ahl-deviceenum.c
+++ b/ahl-binding/ahl-deviceenum.c
@@ -43,14 +43,14 @@ static int SeparateDomainFromDeviceURI( char * in_pDeviceURI, char ** out_pDomai
if (*out_pDomain == NULL)
{
AFB_ERROR("Error tokenizing device URI -> %s",in_pDeviceURI);
- return 1;
+ return AHL_FAIL;
}
// TODO: Validate domain is known string (e.g. ALSA,Pulse,GStreamer)
*out_pDevice = strtok(NULL, ".");
if (*out_pDevice == NULL)
{
AFB_ERROR("Error tokenizing device URI -> %s",in_pDeviceURI);
- return 1;
+ return AHL_FAIL;
}
return AHL_SUCCESS;
}
diff --git a/ahl-binding/ahl-json.c b/ahl-binding/ahl-json.c
index 5e8bf97..b711b43 100644
--- a/ahl-binding/ahl-json.c
+++ b/ahl-binding/ahl-json.c
@@ -279,7 +279,7 @@ void JSONPublicPackageEndpoint(EndpointInfoT * pEndpointInfo,json_object **endpo
json_object *pPropTableJ = NULL;
EndpointPropTableToJSON(pEndpointInfo->pPropTable,&pPropTableJ);
- json_object_object_add(*endpointInfoJ,"properties",pPropTableJ);
+ json_object_object_add(*endpointInfoJ,"property_table",pPropTableJ);
}
// Package only information that can useful to application clients when opening a stream