diff options
author | José Bollo <jose.bollo@iot.bzh> | 2018-02-27 12:02:36 +0100 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2018-02-27 12:02:36 +0100 |
commit | e6fc32e9185b5d6c1ea97714a37f1112b54f64fb (patch) | |
tree | d77e50606e554e5f1f40be8f05a80178f1e69afd /src/afm-binding.c | |
parent | 2db7c770244f97c8674b6e9c78ed50319b38fea3 (diff) |
Provision argument for handling language
The requests 'runnables' and 'detail' accept a parameter
'lang' to -in future- get localized data about apps.
Change-Id: I5f1804870c6b3c0d1aedf1a75cde1e2c09a5a605
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afm-binding.c')
-rw-r--r-- | src/afm-binding.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/src/afm-binding.c b/src/afm-binding.c index 7fe9f3d..e4375a5 100644 --- a/src/afm-binding.c +++ b/src/afm-binding.c @@ -39,6 +39,7 @@ static const char _a_l_c_[] = "application-list-changed"; static const char _detail_[] = "detail"; static const char _id_[] = "id"; static const char _install_[] = "install"; +static const char _lang_[] = "lang"; static const char _not_found_[] = "not-found"; static const char _once_[] = "once"; static const char _pause_[] = "pause"; @@ -90,6 +91,22 @@ static void application_list_changed(const char *operation, const char *data) } /* + * Retrieve the required language from 'req'. + */ +static const char *get_lang(struct afb_req req) +{ + const char *lang; + + /* get the optional language */ + lang = afb_req_value(req, _lang_); + + /* TODO use the req to get the lang of the session (if any) */ + + return lang; +} + + +/* * retrieves the 'appid' in parameters received with the * request 'req' for the 'method'. * @@ -187,9 +204,14 @@ static void reply_status(struct afb_req req, int status, const char *errstr) */ static void runnables(struct afb_req req) { + const char *lang; struct json_object *resp; - INFO("method runnables called"); - resp = afm_udb_applications_public(afudb, afb_req_get_uid(req)); + + /* get the language */ + lang = get_lang(req); + + /* get the details */ + resp = afm_udb_applications_public(afudb, afb_req_get_uid(req), lang); afb_req_success(req, resp, NULL); } @@ -198,6 +220,7 @@ static void runnables(struct afb_req req) */ static void detail(struct afb_req req) { + const char *lang; const char *appid; struct json_object *resp; @@ -205,8 +228,11 @@ static void detail(struct afb_req req) if (!onappid(req, _detail_, &appid)) return; + /* get the language */ + lang = get_lang(req); + /* wants details for appid */ - resp = afm_udb_get_application_public(afudb, appid, afb_req_get_uid(req)); + resp = afm_udb_get_application_public(afudb, appid, afb_req_get_uid(req), lang); if (resp) afb_req_success(req, resp, NULL); else @@ -324,7 +350,6 @@ static void terminate(struct afb_req req) static void runners(struct afb_req req) { struct json_object *resp; - INFO("method runners called"); resp = afm_urun_list(afudb, afb_req_get_uid(req)); afb_req_success(req, resp, NULL); } @@ -342,6 +367,9 @@ static void state(struct afb_req req) } } +/* + * On querying installation of widget(s) + */ static void install(struct afb_req req) { const char *wgtfile; |