X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fhs-clientmanager.cpp;h=ba293262681285ed8ad5dd185772166ed189653c;hb=7a123d6d802fe76a6d2eb32adacb2215d5bb873a;hp=15897b7c91bf099e7c48203bc0aa804daec1b1cc;hpb=c6035c02992d874c1422cb279423017ca4c05eec;p=apps%2Fagl-service-homescreen.git diff --git a/src/hs-clientmanager.cpp b/src/hs-clientmanager.cpp index 15897b7..ba29326 100644 --- a/src/hs-clientmanager.cpp +++ b/src/hs-clientmanager.cpp @@ -17,6 +17,8 @@ #include "hs-clientmanager.h" #include "hmi-debug.h" +static const char _homescreen[] = "homescreen"; + HS_ClientManager* HS_ClientManager::me = nullptr; static void cbRemoveClientCtxt(void *data) @@ -309,3 +311,147 @@ int HS_ClientManager::unsubscribe(afb_req_t request) } return ret; } + +/** + * showWindow event + * + * #### Parameters + * - request : the request + * + * #### Return + * 0 : success + * others : fail + * + */ +int HS_ClientManager::showWindow(afb_req_t request) +{ + int ret = 0; + const char* value = afb_req_value(request, _application_id); + if (value) { + HMI_NOTICE("homescreen-service","request params = %s.", value); + std::lock_guard lock(this->mtx); + auto ip = client_list.find(std::string(value)); + if(ip != client_list.end()) { + ret = ip->second->showWindow(request, value); + } + } + else { + HMI_NOTICE("homescreen-service","Please input application_id"); + ret = AFB_EVENT_BAD_REQUEST; + } + return ret; +} + +/** + * hideWindow event + * + * #### Parameters + * - request : the request + * + * #### Return + * 0 : success + * others : fail + * + */ +int HS_ClientManager::hideWindow(afb_req_t request) +{ + int ret = 0; + const char* value = afb_req_value(request, _application_id); + if (value) { + HMI_NOTICE("homescreen-service","request params = %s.", value); + std::lock_guard lock(this->mtx); + auto ip = client_list.find(std::string(value)); + if(ip != client_list.end()) { + ret = ip->second->hideWindow(request); + } + } + else { + HMI_NOTICE("homescreen-service","Please input application_id"); + ret = AFB_EVENT_BAD_REQUEST; + } + return ret; +} + +/** + * replyShowWindow event + * + * #### Parameters + * - request : the request + * + * #### Return + * 0 : success + * others : fail + * + */ +int HS_ClientManager::replyShowWindow(afb_req_t request) +{ + int ret = 0; + const char* value = afb_req_value(request, _application_id); + if (value) { + HMI_NOTICE("homescreen-service","request params = %s.", value); + std::lock_guard lock(this->mtx); + auto ip = client_list.find(std::string(value)); + if(ip != client_list.end()) { + ret = ip->second->replyShowWindow(request, value); + } + } + else { + HMI_NOTICE("homescreen-service","Please input application_id"); + ret = AFB_EVENT_BAD_REQUEST; + } + return ret; +} + +/** + * showNotification event + * + * #### Parameters + * - request : the request + * + * #### Return + * 0 : success + * others : fail + * + */ +int HS_ClientManager::showNotification(afb_req_t request) +{ + int ret = 0; + std::lock_guard lock(this->mtx); + auto ip = client_list.find(_homescreen); + if(ip != client_list.end()) { + ret = ip->second->showNotification(request); + } + else { + HMI_NOTICE("homescreen-service","not exist sessiion with homescreen"); + ret = AFB_REQ_SHOWNOTIFICATION_ERROR; + } + + return ret; +} + +/** + * showInformation event + * + * #### Parameters + * - request : the request + * + * #### Return + * 0 : success + * others : fail + * + */ +int HS_ClientManager::showInformation(afb_req_t request) +{ + int ret = 0; + std::lock_guard lock(this->mtx); + auto ip = client_list.find(_homescreen); + if(ip != client_list.end()) { + ret = ip->second->showInformation(request); + } + else { + HMI_NOTICE("homescreen-service","not exist sessiion with homescreen"); + ret = AFB_REQ_SHOWINFORMATION_ERROR; + } + + return ret; +}