6126256c394bc4ba5fd268b9eaaaded2b2046318
[profile/ivi/ico-uxf-homescreen.git] / src / homescreen / CicoHSLifeCycleController.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 #ifndef CICOHSLIFECYCLECONTROLLER_H
10 #define CICOHSLIFECYCLECONTROLLER_H
11 #include <glib.h>
12 #include <vector>
13 #include <map>
14 #include <ail.h>
15 #include <package-manager.h>
16 #include <aul/aul.h>
17
18 #include "CicoAilItems.h"
19 #include "CicoAulItems.h"
20
21
22 #ifndef __CICO_SC_WINDOW_H__
23 class CicoSCWindow;
24 #endif
25
26
27 class CicoHSLifeCycleController {
28 public:
29     CicoHSLifeCycleController();
30     ~CicoHSLifeCycleController();
31
32     static CicoHSLifeCycleController* getInstance(void);
33
34     // Starting application
35     int launch(const char* appid);
36     int launch(const std::string& appid);
37     // Stopping application
38     int terminate(const char* appid);
39     int terminate(const std::string& appid);
40     int terminate(int pid);
41     // suspend application
42     int suspend(const char* appid);
43     int suspend(const std::string& appid);
44     int suspend(int pid);
45     // run application check
46     bool isRunning(const char* appid);
47     bool isRunning(const std::string& appid);
48
49     const std::vector<CicoAilItems>& getAilList() const;
50     const CicoAilItems* findAIL(const char* appid) const;
51     const CicoAilItems* findAIL(const std::string& appid) const;
52     bool isAilRenew() const;
53     void ailRenewFlagOff();
54
55     const std::vector<CicoAulItems>& getAulList();
56 // TODO mk_k Should I think about the multiple return values start
57 /*
58     const CicoAulItems* findAUL(const char* appid) const;
59     const CicoAulItems* findAUL(const std::string& appid) const;
60 */
61     const CicoAulItems* findAUL(int pid);
62     bool getPIDs(const char* appid, std::vector<int>& pids) const;
63     bool getPIDs(std::string& appid, std::vector<int>& pids) const;
64     void enterAUL(const char* appid, int pid, const CicoSCWindow* obj = NULL,
65                   int aulstt = AUL_R_OK);
66
67
68 protected:
69     void initAIL();
70     friend ail_cb_ret_e CSCLCCail_list_appinfo_cbX(const ail_appinfo_h appinfo,
71                                                    CicoHSLifeCycleController* x);
72     bool createAilItems();
73
74     friend 
75         int CSCLCCpkgmgr_handlerX(int req_id, const char *pkg_type,
76                                  const char *pkg_name, const char *key,
77                                  const char *val, const void *pmsg,
78                                  CicoHSLifeCycleController *x);
79     void renewAIL();
80     void ailRenewFlagOn();
81     void initAUL();
82     friend int CSCLCCapp_launch_handlerX(int pid,
83                                          CicoHSLifeCycleController *x);
84     friend int CSCLCCapp_dead_handlerX(int pid, CicoHSLifeCycleController *x);
85
86     int terminateR(int pid);
87     void getCategory(const char* sPkg, const char* sNm, const char* sCtg,
88                      std::string& category);
89     bool addAIL(const char* sPkg, const char* sIco, const char* sNm,
90                 const char* sCtg, const char* sTyp, const char* sExe,
91                 bool bndsp);
92     bool removeAUL(int pid);
93 private:
94     static CicoHSLifeCycleController* ms_myInstance;
95
96 protected:
97     std::vector<CicoAilItems> m_ail;
98     std::vector<CicoAulItems> m_aul;
99     GKeyFile* m_gconf;
100     pkgmgr_client* m_pc;
101     bool m_ailRenew;
102 };
103
104 /**
105  * @brief AIL information list
106  * @return AIL information item list Container
107  */
108 inline
109 const std::vector<CicoAilItems>& CicoHSLifeCycleController::getAilList() const
110 {
111     return m_ail;
112 }
113
114
115 /**
116  * @brief AIL change flag is on?
117  * @ret bool
118  * @retval true change flag on
119  * @retval false change flag off
120  */
121 inline bool CicoHSLifeCycleController::isAilRenew() const
122 {
123     return m_ailRenew;
124 }
125
126 /**
127  * @brief AIL change flag off set
128  */
129 inline void CicoHSLifeCycleController::ailRenewFlagOff()
130 {
131     m_ailRenew = false;
132 }
133
134 /**
135  * @brief AIL change flag on set
136  */
137 inline void CicoHSLifeCycleController::ailRenewFlagOn()
138 {
139     m_ailRenew = true;
140 }
141
142 #endif // CICOHSLIFECYCLECONTROLLER_H
143 // vim: set expandtab ts=4 sw=4: