bug fix: TIVI-1997, TIVI-2161, An action is inaccurate when the menu of HomeScreen...
[profile/ivi/ico-uxf-homescreen.git] / src / homescreen / CicoHSAppHistoryExt.h
1 /*
2  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
3  *
4  * This program is licensed under the terms and conditions of the
5  * Apache License, version 2.0.  The full text of the Apache License is at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  */
9 /**
10  * @brief   Homescreen application history sequence manager
11  *
12  * @date    Sep-16-2013
13  */
14 #ifndef CICOHSAPPHISTORYEXT_H
15 #define CICOHSAPPHISTORYEXT_H
16
17 #include <string>
18 #include <vector>
19 #include <list>
20 #include <utility>
21 #include "CicoHSAppHistory.h"
22
23 /**
24  * ecore timer void data typedef
25  */
26 typedef struct t_CHSAHE_data {
27     int   id;
28     void* pObj;
29 } CHSAHE_data_t;
30
31 /**
32  * pid appid convert data item
33  */
34 typedef std::pair<int, std::string> pairPidAppid;
35
36 /**
37  * order of the start-up window
38  */
39 typedef std::pair<bool, pairPidAppid> pairBoolPidAppid;
40
41 class CicoHSAppHistoryExt :public CicoHSAppHistory
42 {
43 public:
44     CicoHSAppHistoryExt();
45     CicoHSAppHistoryExt(const char* user, const char* path, const char* pathD,
46                         const char* flagpath);
47     CicoHSAppHistoryExt(const std::string& user, const std::string& path,
48                         const std::string& pathD, const std::string& flagpath);
49     virtual ~CicoHSAppHistoryExt();
50     void setWaitTime(double msec);
51
52     // operate
53     virtual bool addAppHistory(const std::string& app);
54     virtual bool delAppHistory(const std::string& app);
55     virtual bool moveHistoryHead(const std::string& app);
56     const std::string& getNearHistory();
57
58     // AUL I/F
59     int appLaunch(int pid, const char* appid, int aulstt);
60     int appDead(int pid);
61
62     // pid to appid converter
63     bool getAppid(int pid, std::string& appid);
64
65     // swipe operation I/F
66     void selectApp(int pid);
67     void selectApp(const std::string& appid);
68     void selectApp(const char* appid);
69     const std::string& getSelectApp() const;
70     void clearSelectApp();
71
72     // time out selected app
73     void determined(CHSAHE_data_t* data);
74
75     // touch operation I/F
76     void activeApp(int pid);
77     void activeApp(const std::string& appid);
78     void activeApp(const char* appid);
79
80     // swipe operate
81     const std::string& prevSwipe();
82     const std::string& nextSwipe();
83     const std::string& getSwipeCurrentAppid();
84     const std::string& homeSwipe();
85
86     void update_appid(int pid, std::string& appid, int& aulstt);
87     bool update_pairPidAppid(std::string& appid);
88     void update_appid();
89
90     // order of the start-up window
91     void startupCheckAdd(int pid, const std::string& appid, bool d = false);
92     bool isStartupChecking() const;
93     void startupEntryFinish(int pid);
94     void startupEntryFinish(const std::string& appid);
95     bool isFinish();
96     void stopStartupCheck();
97     const std::string& getLastStartupAppid() const;
98     const std::string& getSubDispAppid() const;
99
100     bool chgChk();
101 protected:
102     enum {
103         COUNTER_START = 1,
104         COUNTER_MAX = 30000
105     };
106     virtual void setHandler();
107     int resetCounter();
108     int getCounter();
109     int nextCounter();
110
111 protected:
112     std::vector<pairPidAppid> m_vppa;
113     std::vector<int> m_aulstt;
114     int   m_cnt;
115     std::string m_waitSelApp;
116     std::list<CHSAHE_data_t*> m_lCdt;
117     double   m_waitTimer;    // ex.) 1sec = 1.0
118     std::string m_bkTmp;
119     std::vector<pairBoolPidAppid> m_vpbpa;
120     std::string m_lastStartupApp;
121     std::string m_subDispApp;
122     std::string m_empty;
123 };
124
125 /**
126  * @brief counter reset
127  * @ret reset counter value
128  */
129 inline int CicoHSAppHistoryExt::resetCounter()
130 {
131     m_cnt = COUNTER_START;
132     return m_cnt;
133 }
134
135 /**
136  * @brief get counter value
137  * @ret  counter value
138  */
139 inline int CicoHSAppHistoryExt::getCounter()
140 {
141     return m_cnt;
142 }
143
144 /**
145  * @brief next counter value
146  * @ret next counter value
147  */
148 inline int CicoHSAppHistoryExt::nextCounter()
149 {
150     m_cnt++;
151     if (COUNTER_MAX < m_cnt) {
152         resetCounter();
153     }
154     return m_cnt;
155 }
156
157 /**
158  * @brief set wait timer val
159  * @param sec wait time ex.) 1.0 == 1sec
160  */
161 inline void CicoHSAppHistoryExt::setWaitTime(double sec)
162 {
163     m_waitTimer = sec;
164 }
165
166 /**
167  * @brief get start-up checking state
168  * @ret  bool
169  * @retval true cheking
170  * @retval false no checking
171  */
172 inline bool CicoHSAppHistoryExt::isStartupChecking() const
173 {
174     if (0 == m_vpbpa.size()) {
175         return  false;
176     }
177     return true;
178 }
179
180 /**
181  * @brief get last start-up appid
182  * @retuen appid Valid only application startup
183  * @retval empty is application startup finish or no have history
184 */
185
186 inline const std::string& CicoHSAppHistoryExt::getLastStartupAppid() const
187 {
188     return m_lastStartupApp;
189 }
190
191 /**
192  * @brief get history sub display appid
193  * @return appid 
194  * @retval empty is no have history sub display
195  */
196 inline const std::string& CicoHSAppHistoryExt::getSubDispAppid() const
197 {
198     return m_subDispApp;
199 }
200
201 /**
202  * @brief get select App entry appid
203  * @ret appid
204  * @retval empty is time out or none select
205  */
206 inline const std::string& CicoHSAppHistoryExt::getSelectApp() const
207 {
208     return m_waitSelApp;
209 }
210
211 /**
212  * @brief select appid clear
213  */
214 inline void CicoHSAppHistoryExt::clearSelectApp()
215 {
216     m_waitSelApp.clear();
217 }
218
219 #endif // CICOHSAPPHISTORYEXT_H
220 // vim: set expandtab ts=4 sw=4: