don't use area info
[apps/agl-service-homescreen.git] / src / hs-apprecover.cpp
1 /*
2  * Copyright (c) 2019 TOYOTA MOTOR CORPORATION
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "hs-apprecover.h"
18 #include "hs-appinfo.h"
19 #include "hs-proxy.h"
20 #include "hs-clientmanager.h"
21
22 const char _keyArea[] = "area";
23
24 /**
25  * starting recover applications
26  *
27  * #### Parameters
28  *  - api : the api
29  *  - map : recover app map
30  *
31  * #### Return
32  * None
33  *
34  */
35 void HS_AppRecover::startRecovery(afb_api_t api, recover_map &map)
36 {
37     HS_AfmMainProxy afm_proxy;
38     for(auto &key : HS_Config::keys_recover_type) {
39         for(auto &m : map[key]){
40             struct app_recover_info recover_info;
41             recover_info.recover_type = key;
42             recover_info.visibility = m.visibility;
43             m_recover_apps_list[m.appid] = std::move(recover_info);
44
45             // recover application
46             m_recovering_set.insert(m.appid);
47             afm_proxy.start(api,  HS_AppInfo::instance()->getAppProperty(m.appid, _keyId));
48         }
49     }
50 }
51
52 /**
53  * register started applications
54  *
55  * #### Parameters
56  *  - appid : application id liked "dashboard"
57  *
58  * #### Return
59  * false : not all application recovered
60  * true : all applications recovered
61  */
62 bool HS_AppRecover::registerRecoveredApp(std::string &appid)
63 {
64     auto it = m_recovering_set.find(appid);
65     if(it != m_recovering_set.end()) {
66         m_recovering_set.erase(appid);
67         auto ip = m_recover_apps_list.find(appid);
68         if(ip != m_recover_apps_list.end()
69         && ip->second.visibility) {
70             HS_ClientManager::instance()->pushEvent("showWindow", nullptr, appid);
71         }
72     }
73
74     return m_recovering_set.empty() ? true : false;
75 }