diff options
Diffstat (limited to 'src/hs-periphery.cpp')
-rw-r--r-- | src/hs-periphery.cpp | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/src/hs-periphery.cpp b/src/hs-periphery.cpp index 06e95ea..783b01a 100644 --- a/src/hs-periphery.cpp +++ b/src/hs-periphery.cpp @@ -19,8 +19,6 @@ #include "hmi-debug.h" #include "hs-clientmanager.h" -static const char _restriction_on[] = "RestrictionOn"; -static const char _restriction_off[] = "RestrictionOff"; /* -------------------------------------HS_PeripheryManager------------------------------------------ */ @@ -44,7 +42,7 @@ int HS_PeripheryManager::init(afb_api_t api) HMI_ERROR("homescreen-service","restriction init failed."); } else { - periphery_list[std::string("restriction")] = restriction; + periphery_list[restriction->getAppid()] = restriction; } return ret; } @@ -118,26 +116,10 @@ int HS_Restriction::init(afb_api_t api) */ void HS_Restriction::onEvent(afb_api_t api, const char *event, struct json_object *object) { - if(!isConcernedEvent(event)) - return; - - std::string ev = event; - std::size_t pos = ev.find("/"); - if(pos != std::string::npos) { - ev = ev.substr(pos + 1); - } - else { - HMI_ERROR("homescreen-service","received event is error."); - return; - } - - if(ev == _restriction_on) { - restrictionOn(api, object); - } - else if(ev == _restriction_off) { - restrictionOff(api, object); - } - else { + auto ip = concerned_event_list.find(std::string(event)); + if(ip != concerned_event_list.end()) { + HMI_NOTICE("homescreen-service","[%s] event received.", event); + (this->*(ip->second))(api, object); } } |