diff options
author | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2018-07-23 15:43:51 +0900 |
---|---|---|
committer | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2018-07-23 15:43:51 +0900 |
commit | 1480fffc5303c22dc42081b91c130b705a5d5bd3 (patch) | |
tree | 40f0b0bbd14af0a51150263e8c7d71f302023c20 | |
parent | 57c5390f096f1f8cec3e73330b0e70a806eea92d (diff) |
using char table instead of jsonsandbox/zheng_wenlong/add_role_check
-rw-r--r-- | src/homescreen.c | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/src/homescreen.c b/src/homescreen.c index d781d9b..aa8592e 100644 --- a/src/homescreen.c +++ b/src/homescreen.c @@ -52,21 +52,25 @@ static const char _application_role[] = "application_role"; static const char _display_message[] = "display_message"; static const char _reply_message[] = "reply_message"; -static const char *str_name_role = "{ \ - \"HomeScreen\": \"homescreen\", \ - \"MediaPlayer\": \"music\", \ - \"VideoPlayer\": \"video\", \ - \"WebBrowser\": \"web_browser\", \ - \"Radio\": \"radio\", \ - \"Phone\": \"phone\", \ - \"Navigation\": \"map\", \ - \"HVAC\": \"hvac\", \ - \"Settings\": \"settings\", \ - \"Dashboard\": \"dashboard\", \ - \"POI\": \"poi\", \ - \"launcher\": \"launcher\", \ - \"Mixer\": \"mixer\" \ - }"; +#define APP_COUNT 13 +#define INDEX_APP_NAME 0 +#define INDEX_APP_ROLE 1 + +static const char *str_name_role[APP_COUNT][2] = { + "HomeScreen", "homescreen", + "MediaPlayer", "music", + "VideoPlayer", "video", + "WebBrowser", "web_browser", + "Radio", "radio", + "Phone", "phone", + "Navigation", "map", + "HVAC", "hvac", + "Settings", "settings", + "Dashboard", "dashboard", + "POI", "poi", + "launcher", "launcher", + "Mixer", "mixer" + }; /* ********** Method of HomeScreen Service (API) ********** @@ -95,8 +99,9 @@ static void pingSample(struct afb_req request) const char* get_AppRole (const char* name) { HMI_NOTICE("homescreen-service","called."); - struct json_object *jo_app_role; const char* role = ""; +/* + struct json_object *jo_app_role; const json_object *new_obj = json_tokener_parse(str_name_role); char *allstr = json_object_get_string(new_obj); HMI_NOTICE("homescreen-service","allstr = %s.", allstr); @@ -108,7 +113,16 @@ const char* get_AppRole (const char* name) } else { HMI_WARNING("homescreen-service","unknow application role for %s.", name); } - //json_object_put(new_obj); +*/ + int ret = 0; + for( int idx=0; idx < APP_COUNT; idx++) + { + if(!strcmp(str_name_role[idx][INDEX_APP_NAME], name)) + { + role = str_name_role[idx][INDEX_APP_ROLE]; + break; + } + } return role; } |