diff options
author | José Bollo <jose.bollo@iot.bzh> | 2017-03-17 23:43:41 +0100 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2017-03-20 16:07:43 +0100 |
commit | 2c566e2dc9df934fb3884f9d4a9ad7ffc73a4aab (patch) | |
tree | aca751afe6992e95d99ab43accb1f58bacc517d6 /src | |
parent | a069be3d476bbdaa56ce4750c8868b4f0682564a (diff) |
Provide unit in config.xml and documentation
This commit remove urn:AGL:widget:provided-application
in favour of urn:AGL:widget:provided-unit.
In the same time, the feature urn:AGL:widget:provided-api
must be attached to a unit. This will enable to export
more than one API for a unit if needed.
Change-Id: I17ade3651db2cd61402875333d063ee05cf57a10
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src')
-rw-r--r-- | src/tests/test-unit/config.xml | 13 | ||||
-rw-r--r-- | src/wgt-json.c | 63 | ||||
-rw-r--r-- | src/wgt-strings.c | 2 | ||||
-rw-r--r-- | src/wgt-strings.h | 2 |
4 files changed, 38 insertions, 42 deletions
diff --git a/src/tests/test-unit/config.xml b/src/tests/test-unit/config.xml index 48a7e3c..65fa43e 100644 --- a/src/tests/test-unit/config.xml +++ b/src/tests/test-unit/config.xml @@ -23,21 +23,30 @@ <param name="urn:AGL:permission::partner:real-time" value="required" /> <param name="urn:AGL:permission::public:applications:read" value="required" /> <param name="urn:AGL:permission::public:display" value="required" /> + <param name="urn:AGL:permission::system:run-by-default" value="required" /> </feature> - <feature name="urn:AGL:widget:provided-api"> + <feature name="urn:AGL:widget:provided-unit"> <param name="#target" value="geoloc" /> <param name="description" value="binding of name geoloc" /> - <param name="content.src" value="libs/binding-geoloc.so" /> + <param name="content.src" value="index.html" /> <param name="content.type" value="application/vnd.agl.service" /> </feature> + <feature name="urn:AGL:widget:provided-api"> + <param name="#target" value="geoloc" /> + <param name="geoloc" value="auto" /> + <param name="moonloc" value="auto" /> + </feature> <feature name="urn:AGL:widget:required-api"> <param name="#target" value="geoloc" /> <param name="identity" value="auto" /> + <param name="lib/binding-geoloc.so" value="local" /> + <param name="lib/binding-moonloc.so" value="local" /> </feature> <feature name="urn:AGL:widget:required-permission"> <param name="#target" value="geoloc" /> <param name="urn:AGL:permission:real-time" value="required" /> <param name="urn:AGL:permission:syscall:*" value="required" /> + <param name="urn:AGL:permission::system:run-by-default" value="required" /> </feature> <feature name="urn:AGL:widget:defined-permission"> <param name="urn:AGL:permission:geoloc:public:settings" value="public" /> diff --git a/src/wgt-json.c b/src/wgt-json.c index 258f151..e0ff08b 100644 --- a/src/wgt-json.c +++ b/src/wgt-json.c @@ -35,26 +35,6 @@ #include "wgt-strings.h" #include "verbose.h" -/* -{ - permissions: { - dict: { - ID: { name: ID, level: LEVEL, index: INDEX }, - ... - }, - list: [ - { name: ID, level: LEVEL, index: 0 }, - ... - } - }, - targets: [ - { name: ID, level: LEVEL, index: 0 }, - ... - ] - } -} -*/ - struct paramaction { const char *name; @@ -258,12 +238,13 @@ static int add_param_simple(struct json_object *obj, const struct wgt_desc_param static int add_param_array(struct json_object *obj, const struct wgt_desc_param *param, void *closure) { + const char *array_name = closure; struct json_object *array, *value; - if (!closure) + if (!array_name) array = obj; - else if (!json_object_object_get_ex(obj, closure, &array)) { - array = j_add_new_array(obj, closure); + else if (!json_object_object_get_ex(obj, array_name, &array)) { + array = j_add_new_array(obj, array_name); if (!array) return -ENOMEM; } @@ -305,7 +286,7 @@ static int add_targeted_params(struct json_object *targets, const struct wgt_des return rc < 0 ? rc : apply_params(obj, feat->params, actions); } -static int add_provided(struct json_object *targets, const struct wgt_desc_feature *feat) +static int add_provided_unit(struct json_object *targets, const struct wgt_desc_feature *feat) { static struct paramaction actions[] = { { .name = string_sharp_target, .action = NULL, .closure = NULL }, @@ -314,6 +295,15 @@ static int add_provided(struct json_object *targets, const struct wgt_desc_featu return add_targeted_params(targets, feat, actions); } +static int add_provided_api(struct json_object *targets, const struct wgt_desc_feature *feat) +{ + static struct paramaction actions[] = { + { .name = string_sharp_target, .action = NULL, .closure = NULL }, + { .name = NULL, .action = add_param_array, .closure = (void*)string_provided_api } + }; + return add_targeted_params(targets, feat, actions); +} + static int add_required_api(struct json_object *targets, const struct wgt_desc_feature *feat) { static struct paramaction actions[] = { @@ -323,7 +313,6 @@ static int add_required_api(struct json_object *targets, const struct wgt_desc_f return add_targeted_params(targets, feat, actions); } - static int add_required_permission(struct json_object *targets, const struct wgt_desc_feature *feat) { static struct paramaction actions[] = { @@ -370,8 +359,7 @@ static struct json_object *to_json(const struct wgt_desc *desc) rc = -EINVAL; } featname += prefixlen; - if (!strcmp(featname, string_provided_api) - || !strcmp(featname, string_provided_application)) { + if (!strcmp(featname, string_provided_unit)) { rc2 = make_target(targets, feat); if (rc2 < 0 && !rc) rc = rc2; @@ -386,25 +374,24 @@ static struct json_object *to_json(const struct wgt_desc *desc) featname += prefixlen; if (!strcmp(featname, string_defined_permission)) { rc2 = add_defined_permission(permissions, feat); - if (rc2 < 0 && !rc) - rc = rc2; } - else if (!strcmp(featname, string_provided_application) - || !strcmp(featname, string_provided_api)) { - rc2 = add_provided(targets, feat); - if (rc2 < 0 && !rc) - rc = rc2; + else if (!strcmp(featname, string_provided_unit)) { + rc2 = add_provided_unit(targets, feat); + } + else if (!strcmp(featname, string_provided_api)) { + rc2 = add_provided_api(targets, feat); } else if (!strcmp(featname, string_required_api)) { rc2 = add_required_api(targets, feat); - if (rc2 < 0 && !rc) - rc = rc2; } else if (!strcmp(featname, string_required_permission)) { rc2 = add_required_permission(targets, feat); - if (rc2 < 0 && !rc) - rc = rc2; + } else { + /* gently ignore other features */ + rc2 = 0; } + if (rc2 < 0 && !rc) + rc = rc2; } } diff --git a/src/wgt-strings.c b/src/wgt-strings.c index f9fe01e..12e5ba5 100644 --- a/src/wgt-strings.c +++ b/src/wgt-strings.c @@ -56,8 +56,8 @@ const char string_level[] = "level"; const char string_list[] = "list"; const char string_main[] = "main"; const char string_optional[] = "optional"; -const char string_provided_application[] = "provided-application"; const char string_provided_api[] = "provided-api"; +const char string_provided_unit[] = "provided-unit"; const char string_required_api[] = "required-api"; const char string_required_permission[] = "required-permission"; const char string_targets[] = "targets"; diff --git a/src/wgt-strings.h b/src/wgt-strings.h index 504bd16..25bfa02 100644 --- a/src/wgt-strings.h +++ b/src/wgt-strings.h @@ -54,8 +54,8 @@ extern const char string_level[]; extern const char string_list[]; extern const char string_main[]; extern const char string_optional[]; -extern const char string_provided_application[]; extern const char string_provided_api[]; +extern const char string_provided_unit[]; extern const char string_required_api[]; extern const char string_required_permission[]; extern const char string_sharp_target[]; |