aboutsummaryrefslogtreecommitdiffstats
path: root/src/hs-apprecover.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hs-apprecover.cpp')
-rw-r--r--src/hs-apprecover.cpp46
1 files changed, 42 insertions, 4 deletions
diff --git a/src/hs-apprecover.cpp b/src/hs-apprecover.cpp
index c2464b1..025b6fb 100644
--- a/src/hs-apprecover.cpp
+++ b/src/hs-apprecover.cpp
@@ -90,22 +90,34 @@ int HS_AppRecover::init(afb_api_t api)
*/
void HS_AppRecover::startRecovery(afb_api_t api, recover_map &map)
{
- HS_AfmMainProxy afm_proxy;
for(auto &key : HS_Config::keys_recover_type) {
for(auto &m : map[key]){
struct app_recover_info recover_info;
recover_info.recover_type = key;
recover_info.visibility = m.visibility;
+ recover_info.after = m.after;
m_recover_apps_list[m.appid] = std::move(recover_info);
if(key == HS_Config::keys_recover_type[1]) {
m_lastmode_list.insert(m.appid);
}
-
// recover application
auto it = m_recovering_set.find(m.appid);
if(it == m_recovering_set.end()) {
m_recovering_set.insert(m.appid);
- afm_proxy.start(api, HS_AppInfo::instance()->getAppProperty(m.appid, _keyId));
+ std::string &after = m_recover_apps_list[m.appid].after;
+ if(!after.empty()) {
+ auto w = m_wait_recover_set.find(m_recover_apps_list[m.appid].after);
+ if(w != m_wait_recover_set.end()) {
+ m_wait_recover_set[after].insert(m.appid);
+ }
+ else {
+ std::set<std::string> new_set;
+ new_set.insert(m.appid);
+ m_wait_recover_set[after] = std::move(new_set);
+ }
+ continue; // don't immediately start application, wait until after applicaiton started.
+ }
+ startApplication(api, m.appid);
}
}
}
@@ -122,7 +134,7 @@ void HS_AppRecover::startRecovery(afb_api_t api, recover_map &map)
* true : recover app
*
*/
-bool HS_AppRecover::registerRecoveredApp(const std::string &appid)
+bool HS_AppRecover::registerRecoveredApp(afb_api_t api, const std::string &appid)
{
bool ret = false;
if(m_recovering_set.empty()) {
@@ -140,6 +152,15 @@ bool HS_AppRecover::registerRecoveredApp(const std::string &appid)
}
ret = true;
}
+
+ // check wait recover application
+ auto w = m_wait_recover_set.find(appid);
+ if(w != m_wait_recover_set.end()) {
+ for(auto &ref : m_wait_recover_set[appid]) {
+ startApplication(api, ref);
+ }
+ m_wait_recover_set.erase(appid);
+ }
return ret;
}
@@ -178,6 +199,23 @@ void HS_AppRecover::screenUpdated(struct json_object *obj)
}
/**
+ * start application
+ *
+ * #### Parameters
+ * - api : the api
+ * - appid : application id liked "dashboard"
+ *
+ * #### Return
+ * None
+ *
+ */
+void HS_AppRecover::startApplication(afb_api_t api, const std::string &appid)
+{
+ HS_AfmMainProxy afm_proxy;
+ afm_proxy.start(api, HS_AppInfo::instance()->getAppProperty(appid, _keyId));
+}
+
+/**
* update lastmode file
*
* #### Parameters