summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStéphane Desneux <stephane.desneux@iot.bzh>2019-10-17 13:41:13 +0000
committerGerrit Code Review <gerrit@automotivelinux.org>2019-10-17 13:41:13 +0000
commit43be16676a6d76fc7fd980f5523af10fa19aeebc (patch)
tree57f11d05fe25b1a5640cadd5a81e7fbfc9c3e92e
parent797569a16f183929b317fde86b4c09d03745fc4d (diff)
parentaab7f562b05bc8383b61ce40d8e198c85ea35786 (diff)
Merge "Improve json dependency list generation function"
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-data.c58
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-data.h4
2 files changed, 62 insertions, 0 deletions
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.c b/lib/4a-hal-utilities/4a-hal-utilities-data.c
index 888516f..865bebb 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-data.c
+++ b/lib/4a-hal-utilities/4a-hal-utilities-data.c
@@ -792,6 +792,64 @@ json_object *HalUtlGetJsonArrayForAllDependencies(afb_api_t apiHandle,
return requestedDependenciesInfoJ;
}
+json_object *HalUtlGetJsonArrayForAllDependenciesInfoWithHandledDependency(afb_api_t apiHandle,
+ struct cds_list_head *probedDevicesListHead,
+ enum DependencyInfoJsonFormat jsonFormat,
+ char *handledProbedDeviceUid)
+{
+ int err;
+ size_t idx, dependencyNb;
+ char *currentDependencyObjectUidString = NULL;
+
+ json_object *requestedDependenciesInfoJ, *currentDependencyObject;
+
+ if(! apiHandle) {
+ AFB_API_ERROR(apiHandle, "Api handle is not valid");
+ return NULL;
+ }
+
+ if(! probedDevicesListHead) {
+ AFB_API_ERROR(apiHandle, "Probed device list is not valid");
+ return NULL;
+ }
+
+ if(cds_list_empty(probedDevicesListHead)) {
+ AFB_API_INFO(apiHandle, "Probed device list is empty");
+ return NULL;
+ }
+
+ if(! handledProbedDeviceUid) {
+ AFB_API_ERROR(apiHandle, "Probed device uid is not valid");
+ return NULL;
+ }
+
+ requestedDependenciesInfoJ = HalUtlGetJsonArrayForAllDependencies(apiHandle,
+ probedDevicesListHead,
+ jsonFormat);
+ if(! requestedDependenciesInfoJ) {
+ AFB_API_ERROR(apiHandle, "Didn't succeed get all devices (dependencies) info");
+ return NULL;
+ }
+
+ dependencyNb = json_object_array_length(requestedDependenciesInfoJ);
+ for(idx = 0; idx < dependencyNb; idx++) {
+ currentDependencyObject = json_object_array_get_idx(requestedDependenciesInfoJ, idx);
+
+ err = wrap_json_unpack(currentDependencyObject, "{s:s}", "uid", &currentDependencyObjectUidString);
+ if(err) {
+ AFB_API_ERROR(apiHandle, "Dependency object is malformed (no uid key)");
+ return NULL;
+ }
+
+ if(! strcmp(handledProbedDeviceUid, currentDependencyObjectUidString))
+ json_object_object_add(currentDependencyObject, "handled", json_object_new_boolean(1));
+ else
+ json_object_object_add(currentDependencyObject, "handled", json_object_new_boolean(0));
+ }
+
+ return requestedDependenciesInfoJ;
+}
+
/*******************************************************************************
* Internal Hal - Streams data handling functions *
******************************************************************************/
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.h b/lib/4a-hal-utilities/4a-hal-utilities-data.h
index 8e94078..e57bd85 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-data.h
+++ b/lib/4a-hal-utilities/4a-hal-utilities-data.h
@@ -177,6 +177,10 @@ json_object *HalUtlGetJsonArrayForAvailableDependencies(afb_api_t apiHandle,
json_object *HalUtlGetJsonArrayForAllDependencies(afb_api_t apiHandle,
struct cds_list_head *probedDevicesListHead,
enum DependencyInfoJsonFormat jsonFormat);
+json_object *HalUtlGetJsonArrayForAllDependenciesInfoWithHandledDependency(afb_api_t apiHandle,
+ struct cds_list_head *probedDevicesListHead,
+ enum DependencyInfoJsonFormat jsonFormat,
+ char *handledProbedDeviceUid);
// Internal Hal - Streams data handling functions
struct InternalHalMixerData *HalUtlAddMixerDataToMixerDataList(struct cds_list_head *mixerDataListHead);