X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fhs-periphery.cpp;fp=src%2Fhs-periphery.cpp;h=783b01ac842d58f08bd3d081acc2276cd45b77dd;hb=676baef9a7b9ad2868b8e10a7f4d10e54f4b36f1;hp=06e95eada2a342ed679d8cf2cf36fc1f6c0508b1;hpb=d6140dad95f7884f8a7a666a125c1b24065d2c60;p=apps%2Fagl-service-homescreen.git 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); } }