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