aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hs-apprecover.cpp3
-rw-r--r--src/hs-clientmanager.cpp90
-rw-r--r--src/hs-clientmanager.h10
-rw-r--r--src/hs-vuiadapter.cpp13
4 files changed, 24 insertions, 92 deletions
diff --git a/src/hs-apprecover.cpp b/src/hs-apprecover.cpp
index adc8a3a..e3a84c6 100644
--- a/src/hs-apprecover.cpp
+++ b/src/hs-apprecover.cpp
@@ -90,7 +90,6 @@ int HS_AppRecover::init(afb_api_t api)
*/
void HS_AppRecover::startRecovery(afb_api_t api)
{
- this->addListenAppId(_listen_all);
HS_ClientManager::instance()->addListener(this);
for(auto &key : HS_Config::keys_recover_type) {
@@ -142,6 +141,7 @@ void HS_AppRecover::notify(afb_api_t api, std::string appid)
AFB_INFO("recover appid=[%s].", appid.c_str());
auto it = m_recovering_set.find(appid);
if(it != m_recovering_set.end()) {
+ this->removeListenAppId(appid);
m_recovering_set.erase(appid);
auto ip = m_recover_apps_list.find(appid);
if(ip != m_recover_apps_list.end()
@@ -216,6 +216,7 @@ void HS_AppRecover::screenUpdated(struct json_object *obj)
*/
void HS_AppRecover::startApplication(afb_api_t api, const std::string &appid)
{
+ this->addListenAppId(appid);
HS_AfmMainProxy afm_proxy;
afm_proxy.start(api, HS_AppInfo::instance()->getAppProperty(appid, _keyId));
}
diff --git a/src/hs-clientmanager.cpp b/src/hs-clientmanager.cpp
index a1472b8..913e9b6 100644
--- a/src/hs-clientmanager.cpp
+++ b/src/hs-clientmanager.cpp
@@ -22,7 +22,6 @@
static const char _homescreen[] = "homescreen";
static const char _area[] = "area";
static const char _parameter[] = "parameter";
-const std::string _listen_all("all");
HS_ClientManager* HS_ClientManager::me = nullptr;
@@ -76,8 +75,6 @@ HS_ClientManager* HS_ClientManager::instance(void)
int HS_ClientManager::init(void)
{
listener_list.clear();
- std::list<listener_interface*> interface_list;
- listener_list[_listen_all] = std::move(interface_list);
}
/**
@@ -247,40 +244,6 @@ int HS_ClientManager::pushEvent(const char *event, struct json_object *param, st
}
/**
- * check register application
- *
- * #### Parameters
- * - api : the api
- * - appid : register application's id
- *
- * #### Return
- * true : checked
- * false : not checked
- *
- */
-bool HS_ClientManager::checkRegisterApp(afb_api_t api, const std::string &appid)
-{
- bool ret = true;
- auto &ip = listener_list[_listen_all];
- if(!ip.empty()) {
- for(auto &it : ip) {
- it->notify(api, appid);
- }
- }
- else if(startup_appid == appid) {
- startup_appid.clear();
- struct json_object* json_param = json_object_new_object();
- json_object_object_add(json_param, _area, json_object_new_string(startup_area.c_str()));
- pushEvent("showWindow", json_param, appid);
- startup_area.clear();
- }
- else {
- ret = false;
- }
- return ret;
-}
-
-/**
* check whether application was started
*
* #### Parameters
@@ -309,17 +272,7 @@ bool HS_ClientManager::isAppStarted(const std::string &appid)
*/
void HS_ClientManager::addListener(listener_interface* listener)
{
- for (auto &it : listener->listenAppSet()) {
- auto ip = listener_list.find(it);
- if(ip != listener_list.end()) {
- ip->second.push_back(listener);
- }
- else {
- std::list<listener_interface*> lst;
- lst.push_back(listener);
- listener_list[it] = std::move(lst);
- }
- }
+ listener_list[listener->myUid()] = listener;
}
/**
@@ -334,21 +287,7 @@ void HS_ClientManager::addListener(listener_interface* listener)
*/
void HS_ClientManager::removeListener(listener_interface* listener)
{
- for (auto &iter : listener->listenAppSet()) {
- auto it = listener_list.find(iter);
- if(it != listener_list.end()) {
- auto ip = it->second.begin();
- for(; ip != it->second.end(); ++ip) {
- if(listener->myUid() == (*ip)->myUid()) {
- break;
- }
- }
- it->second.erase(ip);
- if(it->second.empty()) {
- listener_list.erase(it->first);
- }
- }
- }
+ listener_list.erase(listener->myUid());
}
/**
@@ -364,25 +303,18 @@ void HS_ClientManager::removeListener(listener_interface* listener)
*/
void HS_ClientManager::notifyListener(afb_api_t api, const std::string &appid)
{
- if (checkRegisterApp(api, appid)) {
- return;
- }
-
AFB_INFO("listen %s, notified", appid.c_str());
- std::list<listener_interface*> interface_list;
- auto ip = listener_list.find(appid);
- if(ip != listener_list.end()) {
- if(!ip->second.empty()) {
- interface_list = ip->second;
- }
- else {
- AFB_WARNING("listener is null.");
- return;
+ for(auto &it : listener_list) {
+ if(it.second->isListenAppId(appid)) {
+ it.second->notify(api, appid);
}
}
- for(auto &it : interface_list) {
- it->notify(api, appid);
+ if(startup_appid == appid) {
+ struct json_object* json_param = json_object_new_object();
+ json_object_object_add(json_param, _area, json_object_new_string(startup_area.c_str()));
+ startup_area.clear();
+ startup_appid.clear();
+ pushEvent("showWindow", json_param, appid);
}
-
} \ No newline at end of file
diff --git a/src/hs-clientmanager.h b/src/hs-clientmanager.h
index 4cb1fad..9e58e64 100644
--- a/src/hs-clientmanager.h
+++ b/src/hs-clientmanager.h
@@ -26,7 +26,6 @@
#include "hs-helper.h"
#include "hs-client.h"
-extern const std::string _listen_all;
class listener_interface {
public:
@@ -34,9 +33,9 @@ public:
virtual ~listener_interface() {}
virtual void notify(afb_api_t api, std::string appid = "") = 0;
std::string myUid(void) {return m_uid;}
- std::set<std::string> listenAppSet(void) {return m_listen_appid;}
- void addListenAppId(std::string appid) {m_listen_appid.insert(appid);}
- bool isListenAppId(std::string &appid) {
+ void addListenAppId(const std::string &appid) {m_listen_appid.insert(appid);}
+ void removeListenAppId(const std::string &appid) {m_listen_appid.erase(appid);}
+ bool isListenAppId(const std::string &appid) {
auto it = m_listen_appid.find(appid);
return it != m_listen_appid.end() ? true : false;
}
@@ -80,12 +79,11 @@ private:
HS_ClientCtxt* createClientCtxt(afb_req_t req, std::string appid);
HS_Client* addClient(afb_req_t req, std::string appid);
void removeClient(std::string appid);
- bool checkRegisterApp(afb_api_t api, const std::string &appid);
void notifyListener(afb_api_t api, const std::string &appid);
private:
static HS_ClientManager* me;
- std::unordered_map<std::string, std::list<listener_interface*>> listener_list;
+ std::unordered_map<std::string, listener_interface*> listener_list;
std::unordered_map<std::string, HS_Client*> client_list;
std::unordered_map<std::string, HS_ClientCtxt*> appid2ctxt;
std::mutex mtx;
diff --git a/src/hs-vuiadapter.cpp b/src/hs-vuiadapter.cpp
index cbcc8e0..9b04569 100644
--- a/src/hs-vuiadapter.cpp
+++ b/src/hs-vuiadapter.cpp
@@ -188,10 +188,11 @@ void Vui_Navigation::cancel_navigation(afb_api_t api, struct json_object *object
*/
void Vui_Navigation::notify(afb_api_t api, std::string appid)
{
+ AFB_INFO("recover appid=[%s].", appid.c_str());
if(isListenAppId(appid)) {
if (appid == _poi) {
m_start_flg.first = true;
- sleep(1);
+ // sleep(1);
set_destination2poi(api);
}
else if(appid == _navigation) {
@@ -204,8 +205,8 @@ void Vui_Navigation::notify(afb_api_t api, std::string appid)
}
}
if(m_start_flg.first && m_start_flg.second) {
+ clearListenAppSet();this->removeListenAppId(appid);
HS_ClientManager::instance()->removeListener(this);
- clearListenAppSet();
}
}
@@ -277,10 +278,10 @@ HS_VuiAdapter* HS_VuiAdapter::instance(void)
*/
void HS_VuiAdapter::init(afb_api_t api)
{
- if(afb_api_require_api(api, _vshl_capabilities, 0)) {
- AFB_INFO("%s api isn't existing.", _vshl_capabilities);
- return;
- }
+ // if(afb_api_require_api(api, _vshl_capabilities, 0)) {
+ // AFB_INFO("%s api isn't existing.", _vshl_capabilities);
+ // return;
+ // }
std::string uid = std::string(_vui_prefixe) + std::string("-") + _navigation;
module_list[uid] = new Vui_Navigation(uid);