diff options
author | José Bollo <jose.bollo@iot.bzh> | 2019-03-19 23:21:35 +0100 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2019-03-22 16:54:46 +0100 |
commit | 598f374d2948a76c381eab0a3dfb5334d6d62379 (patch) | |
tree | 1a45d9bdc4d9e2cfad3c259a6a39f26f578e8258 /src/afm-binding.c | |
parent | d07c7f7169788ffbe5cc70506daaf9fe0add88c2 (diff) |
Add ability to manage all widget/applicationsguppy_7.0.1guppy/7.0.17.0.1
For system uses -like automatic testing-, it is
needed to include tha ability to list ALL installed
widgets and ALL running instance of installed
widgets.
This change adds the option -a or --all to the
commands 'list' and 'runners' for the purpose
of listing any installed widgets, even those
requiring to be hidden.
Example: afm-util ps -a
Bug-AGL: SPEC-2272
Bug-AGL: SPEC-1850
Change-Id: I216ec9c63efea1b3af58e1d2d7723d986e04551e
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afm-binding.c')
-rw-r--r-- | src/afm-binding.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/afm-binding.c b/src/afm-binding.c index f4bba8a..34880fc 100644 --- a/src/afm-binding.c +++ b/src/afm-binding.c @@ -41,6 +41,7 @@ * constant strings */ static const char _added_[] = "added"; +static const char _all_[] = "all"; static const char _a_l_c_[] = "application-list-changed"; static const char _bad_request_[] = "bad-request"; static const char _cannot_start_[] = "cannot-start"; @@ -226,6 +227,18 @@ static const char *get_lang(afb_req_t req) return lang; } +/* + * Retrieve whether all is required from 'req'. + */ +static int get_all(afb_req_t req) +{ + struct json_object *val; + + /* get the optional language */ + return json_object_object_get_ex(afb_req_json(req), _all_, &val) + && json_object_get_boolean(val); +} + /* * retrieves the 'appid' in parameters received with the @@ -328,14 +341,18 @@ static void reply_status(afb_req_t req, int status) */ static void runnables(afb_req_t req) { + int all; const char *lang; struct json_object *resp; /* get the language */ lang = get_lang(req); + /* get the all */ + all = get_all(req); + /* get the details */ - resp = afm_udb_applications_public(afudb, afb_req_get_uid(req), lang); + resp = afm_udb_applications_public(afudb, all, afb_req_get_uid(req), lang); afb_req_success(req, resp, NULL); } @@ -473,8 +490,10 @@ static void terminate(afb_req_t req) */ static void runners(afb_req_t req) { + int all; struct json_object *resp; - resp = afm_urun_list(afudb, afb_req_get_uid(req)); + all = get_all(req); + resp = afm_urun_list(afudb, all, afb_req_get_uid(req)); afb_req_success(req, resp, NULL); } @@ -585,7 +604,7 @@ static int init(afb_api_t api) json_true = json_object_new_boolean(1); /* init database */ - afudb = afm_udb_create(1, 0, "afm-appli-"); + afudb = afm_udb_create(1, 0, "afm-"); if (!afudb) { ERROR("afm_udb_create failed"); return -1; |