Revert "Corresponding to TizenIVI3.0 M14.3, GENIVI-LayerManagement was used instead...
[profile/ivi/ico-uxf-homescreen.git] / src / syscond / CicoSysConDaemon.cpp
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 //==========================================================================
11 /**
12  *  @file   CicoSysConDaemon.cpp
13  *
14  *  @brief  This file is implimention of CicoSysConDaemon class
15  */
16 //==========================================================================
17
18 #include <exception>
19 #include <iostream>
20 #include <string>
21
22 #include "CicoSysConDaemon.h"
23 #include "ico_syc_error.h"
24 #include "CicoLog.h"
25 #include "CicoSystemConfig.h"
26 #include "CicoSCServer.h"
27 #include "CicoSCWayland.h"
28 #include "CicoSCWindowController.h"
29 #include "CicoSCInputController.h"
30 #include "CicoSCLifeCycleController.h"
31 #include "CicoSCUser.h"
32 #include "CicoSCUserManager.h"
33 #include "CicoSCResourceManager.h"
34 #include "Cico_aul_listen_app.h"
35 #include "CicoSCVInfoManager.h"
36
37 //--------------------------------------------------------------------------
38 /**
39  *  @brief  default constructor
40  */
41 //--------------------------------------------------------------------------
42 CicoSysConDaemon::CicoSysConDaemon()
43     : m_winctrl(NULL), m_inputctrl(NULL), m_resourcemgr(NULL)
44 {
45 //    ICO_TRA("CicoSysConDaemon::CicoSysConDaemon Enter");
46 //    ICO_TRA("CicoSysConDaemon::CicoSysConDaemon Leave");
47 }
48
49 //--------------------------------------------------------------------------
50 /**
51  *  @brief  callback function on create
52  *
53  *  @param [in] user_data   The user data passed from the callback
54  *                          registration function
55  *
56  *  @return true on success, false on error
57  */
58 //--------------------------------------------------------------------------
59 CicoSysConDaemon::~CicoSysConDaemon()
60 {
61 //    ICO_TRA("CicoSysConDaemon::~CicoSysConDaemon Enter");
62 //    ICO_TRA("CicoSysConDaemon::~CicoSysConDaemon Leave");
63 }
64
65 //--------------------------------------------------------------------------
66 /**
67  *  @brief  callback function on terminate
68  *
69  *  @param [in] user_data   The user data passed from the callback
70  *                          registration function
71  */
72 //--------------------------------------------------------------------------
73 bool
74 CicoSysConDaemon::onCreate(void *user_data)
75 {
76     ICO_TRA("CicoSysConDaemon::onCreate Enter");
77
78     try {
79         int ret = ICO_SYC_EOK;
80         CicoSystemConfig::getInstance()->load("/usr/apps/org.tizen.ico.system-controller/res/config/system.xml");
81
82         initAulListenXSignal();
83
84         CicoSCVInfoManager::getInstance()->startup();
85
86         CicoSCLifeCycleController *lifecycle =
87             CicoSCLifeCycleController::getInstance();
88         m_winctrl     = new CicoSCWindowController();
89         m_inputctrl   = new CicoSCInputController();
90
91         m_resourcemgr = new CicoSCResourceManager();
92         m_resourcemgr->setWindowController(m_winctrl);
93         m_resourcemgr->setInputController(m_inputctrl);
94         ret = m_resourcemgr->initialize();
95         if (ICO_SYC_EOK != ret) {
96             return false;
97         }
98
99         m_winctrl->setResourceManager(m_resourcemgr);
100
101         CicoSCUserManager *usermgr = CicoSCUserManager::getInstance();
102         usermgr->load("/usr/apps/org.tizen.ico.system-controller/res/config/user.xml");
103
104         CicoSCServer *server = CicoSCServer::getInstance();
105         server->setWindowCtrl(m_winctrl);
106         server->setInputCtrl(m_inputctrl);
107         server->setUserMgr(usermgr);
108         server->setResourceMgr(m_resourcemgr);
109         server->setPolicyMgr(m_resourcemgr->getPolicyManager());
110
111         server->startup(18081, (const char*)"ico_syc_protocol");
112         ret = CicoSCWayland::getInstance()->initialize();
113         if (ICO_SYC_EOK != ret) {
114             return false;
115         }
116         CicoSCWayland::getInstance()->addEcoreMainWlFdHandler();
117
118         usermgr->initialize();
119         if (true == lifecycle->isAppResource()) {
120             const CicoSCUser* user = usermgr->getLoginUser();
121             if (NULL != user) {
122                 if (false == lifecycle->startAppResource(user->name)) {
123                     lifecycle->createAppResourceFile(user->name);
124                 }
125             }
126         }
127     }
128     catch (const std::exception& e) {
129         std::cerr << e.what() << std::endl;
130         ICO_ERR("catch exception %s", e.what());
131         ICO_DBG("CicoSysConDaemon::onCreate Leave(false)");
132         return false;
133     }
134     catch (const std::string& str) {
135         std::cerr << str << std::endl;
136         ICO_ERR("catch exception %s", str.c_str());
137         ICO_DBG("CicoSysConDaemon::onCreate Leave(false)");
138         return false;
139     }
140     catch (...) {
141         ICO_ERR("catch exception unknown");
142         ICO_DBG("CicoSysConDaemon::onCreate Leave(false)");
143         return false;
144     }
145
146     ICO_TRA("CicoSysConDaemon::onCreate Leave(true)");
147     ICO_PRF("SYS_STARTED Initialization is complete");
148
149     return true;
150 }
151
152 //--------------------------------------------------------------------------
153 /**
154  *  @brief  callback function on terminate
155  *
156  *  @param [in] user_data   The user data passed from the callback
157  *                          registration function
158  */
159 //--------------------------------------------------------------------------
160 void
161 CicoSysConDaemon::onTerminate(void *user_data)
162 {
163     ICO_TRA("CicoSysConDaemon::onTerminate Enter");
164     CicoSCUserManager *usermgr = CicoSCUserManager::getInstance();
165     usermgr->cloaseUser();
166     stop();
167     CicoSCServer::getInstance()->teardown();
168     CicoSCVInfoManager::getInstance()->teardown();
169     ICO_TRA("CicoSysConDaemon::onTerminate Leave");
170 }
171
172 //--------------------------------------------------------------------------
173 /**
174  *  @brief  callback function on pause
175  *
176  *  @param [in] user_data   The user data passed from the callback
177  *                          registration function
178  */
179 //--------------------------------------------------------------------------
180 void
181 CicoSysConDaemon::onPause(void *user_data)
182 {
183     ICO_TRA("CicoSysConDaemon::onPause Enter");
184     ICO_TRA("CicoSysConDaemon::onPause Leave");
185 }
186
187 //--------------------------------------------------------------------------
188 /**
189  *  @brief  callback function on resume
190  *
191  *  @param [in] user_data   The user data passed from the callback
192  *                          registration function
193  */
194 //--------------------------------------------------------------------------
195 void
196 CicoSysConDaemon::onResume(void *user_data)
197 {
198     ICO_TRA("CicoSysConDaemon::onResume Enter");
199     ICO_TRA("CicoSysConDaemon::onResume Leave");
200 }
201
202 //--------------------------------------------------------------------------
203 /**
204  *  @brief  callback function on service
205  *
206  *  @param [in] service     The handle to the service
207  *  @param [in] user_data   The user data passed from the callback
208  *                          registration function
209  */
210 //--------------------------------------------------------------------------
211 void
212 CicoSysConDaemon::onService(service_h service, void *user_data)
213 {
214     ICO_TRA("CicoSysConDaemon::onService Enter");
215     ICO_TRA("CicoSysConDaemon::onService Leave");
216 }
217 // vim: set expandtab ts=4 sw=4: