*/
static int pmqos_parse_scenario(json_object *obj, struct scenario *scenario)
{
- const char *name;
+ char name[BUFF_MAX] = {};
int max_duration_ms;
int support;
+ int ret = 0;
/* Get property values */
- name = get_string_from_object(obj, "name");
- max_duration_ms = get_int_from_object(obj, "max_duration_ms");
- support = get_boolean_from_object(obj, "support");
-
- /* Check the mandatory property values are valid or not */
- if (!name) {
- _E("Failed to get 'name' property of scenario section\n");
+ ret += get_property(obj, "name", DATA_TYPE_STRING, true,
+ (void *)name);
+ ret += get_property(obj, "support", DATA_TYPE_BOOLEAN, false,
+ (void *)&support);
+ ret += get_property(obj, "max_duration_ms", DATA_TYPE_INT, false,
+ (void *)&max_duration_ms);
+
+ /* Check whether the mandatory properties are included or not */
+ if (ret < 0) {
+ _E("Failed to get the mandatory properties in pmqos scenario\n");
return -EINVAL;
}
int num_scenarios = 0, ret, i;
/* Get property values */
- pmqos_support = get_boolean_from_object(obj, "pmqos_support");
+ ret = get_property(obj, "pmqos_support", DATA_TYPE_BOOLEAN, false,
+ (void *)&pmqos_support);
if (json_object_object_get_ex(obj, "pmqos_scenario_list",
&pmqos_scenario_list))
num_scenarios = json_object_array_length(pmqos_scenario_list);
- /* Check the mandatory property values are valid or not */
+ /* Check whether the mandatory properties are included or not */
+ if (ret < 0) {
+ _E("Failed to get the mandatory properties in pmqos config\n");
+ return -EINVAL;
+ }
+
+ /* Check the validation of property value */
if (pmqos_support <= 0 || num_scenarios <= 0) {
_I("Disable PMQOS module\n");
return 0;