2 * Copyright (c) 2014, TOYOTA MOTOR CORPORATION.
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
14 #include "CicoOnScreen.h"
15 #include "CicoOSPopWindow.h"
17 #include <Ecore_Wayland.h>
21 //==========================================================================
23 //==========================================================================
24 CicoOnScreen * CicoOnScreen::os_instance=NULL;
26 //==========================================================================
28 //==========================================================================
30 //--------------------------------------------------------------------------
32 * @brief CicoOnScreen::CicoOnScreen
38 //--------------------------------------------------------------------------
39 CicoOnScreen::CicoOnScreen(void)
41 ICO_TRA("CicoOnScreen::CicoOnScreen Enter");
45 ICO_TRA("CicoOnScreen::CicoOnScreen Leave");
48 //--------------------------------------------------------------------------
50 * @brief CicoOnScreen::~CicoOnScreen
56 //--------------------------------------------------------------------------
57 CicoOnScreen::~CicoOnScreen(void)
59 // ICO_TRA("CicoOnScreen::~CicoOnScreen Enter");
60 list<CicoOSPopWindow*>::iterator p = m_mngWin.begin();
61 while (p != m_mngWin.end()) {
62 CicoOSPopWindow* pt = *p;
66 p = m_waitMngWin.begin();
67 while (p != m_waitMngWin.end()) {
68 CicoOSPopWindow* pt = *p;
73 if (NULL != m_request) {
77 // ICO_TRA("CicoOnScreen::~CicoOnScreen Leave");
80 //--------------------------------------------------------------------------
82 * @brief CicoOnScreen::StartOnScreen
87 * @return true on success, false on error
89 //--------------------------------------------------------------------------
91 CicoOnScreen::StartOnScreen(void)
95 ico_syc_connect(EventCallBack, NULL);
97 // save instance pointer
103 if (NULL == m_reserve) {
104 m_reserve = new CicoOSPopWindow(NOTIFICATION_TYPE_NONE);
105 m_reserve->createMainWindow();
108 // set notification callback function
109 notiservice_.SetCallback(NotificationCallback, this);
111 ICO_TRA("Leave(true)");
115 bool CicoOnScreen::insertNoti(notification_h noti_h)
118 CicoOSPopWindow* w = new CicoOSPopWindow(noti_h);
120 ICO_ERR("FAIL new class");
121 ICO_TRA("Leave (false)");
125 if (NOTIFICATION_TYPE_NOTI == w->GetType()) {
126 m_waitMngWin.push_back(w);
133 ICO_TRA("Leave (false)");
136 ICO_TRA("Leave (true)");
139 bool CicoOnScreen::deleteNoti(int priv_id)
142 list<CicoOSPopWindow*>::iterator p = m_mngWin.begin();
143 for (; p != m_mngWin.end(); ++p) {
144 CicoOSPopWindow* w = *p;
145 if (priv_id == w->GetPrivId()) {
149 list<CicoOSPopWindow*> tmp;
150 p = m_waitMngWin.begin();
151 for (; p != m_waitMngWin.end(); ++p) {
152 CicoOSPopWindow* w = *p;
153 if (priv_id == w->GetPrivId()) {
158 for (; p != tmp.end(); ++p) {
159 CicoOSPopWindow* w = *p;
160 m_waitMngWin.remove(w);
163 if (NULL != m_request) {
164 if (priv_id == m_request->GetPrivId()) {
168 ICO_TRA("Leave (true)");
172 //--------------------------------------------------------------------------
174 * @brief CicoOnScreen::NotificationCallback
175 * Notification callback function
177 * @param[in] data The user data passed from the callback
178 * registration function
179 * @param[in] type The type of notification
182 //--------------------------------------------------------------------------
184 CicoOnScreen::NotificationCallback(void *data, notification_type_e type,
185 notification_op *op_list, int num_op)
188 bool bInsFlag = false;
189 for (int i = 0; i < num_op; i++) {
190 notification_op_type_e op_type = op_list[i].type;
191 int priv_id = op_list[i].priv_id;
192 notification_h noti_h = op_list[i].noti;
193 ICO_DBG("RECV notification op_type=%d priv_id=%d noti=0x%08x",
194 op_type, priv_id, noti_h);
197 case NOTIFICATION_OP_INSERT :
199 ICO_DBG("NOTIFICATION_OP_INSERT");
200 if (true == os_instance->insertNoti(noti_h)) {
203 break; // break of switch op_type
205 case NOTIFICATION_OP_UPDATE :
206 ICO_DBG("NOTIFICATION_OP_UPDATE");
207 break; // break of switch op_type
208 case NOTIFICATION_OP_DELETE:
210 ICO_DBG("NOTIFICATION_OP_DELETE");
211 os_instance->deleteNoti(priv_id);
212 break; // break of switch op_type
214 case NOTIFICATION_OP_DELETE_ALL:
215 ICO_DBG("NOTIFICATION_OP_DELETE_ALL");
216 break; // break of switch op_type
217 case NOTIFICATION_OP_REFRESH:
218 ICO_DBG("NOTIFICATION_OP_REFRESH");
219 break; // break of switch op_type
220 case NOTIFICATION_OP_SERVICE_READY:
221 ICO_DBG("NOTIFICATION_OP_SERVICE_READY");
222 break; // break of switch op_type
224 ICO_DBG("UNKOWN OP_TYPE(%d)", (int)op_type);
225 break; // break of switch op_type
229 if (true == bInsFlag) {
230 os_instance->requestShowSC();
236 bool CicoOnScreen::requestShowSC()
239 if (NULL != m_request) {
240 ICO_TRA("Leave false(request now)");
243 if (m_waitMngWin.empty()) {
244 ICO_TRA("Leave false(nothing window)");
248 list<CicoOSPopWindow*>::iterator p = m_waitMngWin.begin();
251 m_waitMngWin.remove(m_request);
252 bool r = m_request->showPopup();
253 while (false == r) { // fail showPop request
254 ICO_ERR("_____ Fail SHOW POP REQUEST(%d)",
255 m_request->GetPrivId());
258 if (m_waitMngWin.empty()) {
261 p = m_waitMngWin.begin();
264 m_waitMngWin.remove(m_request);
265 r = m_request->showPopup();
267 ICO_TRA("Leave %s", r? "true": "false");
271 //--------------------------------------------------------------------------
273 * @brief callback for system controller
275 * @param [in] event kind of event
276 * @param [in] detail detail
277 * @param [in] user_data user data
279 //--------------------------------------------------------------------------
281 CicoOnScreen::EventCallBack(const ico_syc_ev_e event,
282 const void *detail, void *user_data)
284 ICO_TRA("Enter(event %d, %x, %x)", (int)event, detail, user_data);
285 ico_syc_res_info_t *ri = (ico_syc_res_info_t*) detail;
287 ICO_ERR("____ CALLBACK NG PARAM");
291 case ICO_SYC_EV_RES_ACQUIRE:
292 ICO_TRA("_____ ICO_SYC_EV_RES_ACQUIRE");
293 break; // break of switch event
294 case ICO_SYC_EV_RES_DEPRIVE:
295 ICO_TRA("_____ ICO_SYC_EV_RES_DEPRIVE");
296 break; // break of switch event
297 case ICO_SYC_EV_RES_WAITING:
298 ICO_TRA("_____ ICO_SYC_EV_RES_WAITING");
299 break; // break of switch event
300 case ICO_SYC_EV_RES_REVERT:
301 ICO_TRA("_____ ICO_SYC_EV_RES_REVERT");
302 break; // break of switch event
303 case ICO_SYC_EV_RES_RELEASE:
305 ICO_TRA("_____ ICO_SYC_EV_RES_RELEASE");
306 if (NULL == ri->window) {
307 ICO_TRA("_____ no WINDOW");
308 break; // break of switch event
310 os_instance->releaseWindow(ri->window->resourceId);
311 break; // break of switch event
313 case ICO_SYC_EV_RES_WINDOW_ID:
315 ICO_TRA("_____ ICO_SYC_EV_RES_WINDOW_ID");
316 if (NULL == ri->window) {
317 ICO_TRA("_____ no WINDOW");
318 break; // break of switch event
320 os_instance->entryWindowId(ri->window->resourceId);
321 break; // break of switch event
324 ICO_TRA("_____ UNKNOWN event(%d)", (int)event);
325 break; // break of switch event
332 CicoOnScreen::releaseWindow(uint32_t resourceId)
334 ICO_TRA("Enter(%d)", resourceId);
336 list<CicoOSPopWindow*> tmp;
338 list<CicoOSPopWindow*>::iterator p = m_mngWin.begin();
339 for (; p != m_mngWin.end(); ++p) {
340 CicoOSPopWindow* w = *p;
341 if (resourceId == w->m_resourceId) {
346 for (; p != tmp.end(); ++p) {
347 CicoOSPopWindow* w = *p;
354 ICO_TRA("Leave %s", bR? "true": "false");
359 CicoOnScreen::entryWindowId(uint32_t resourceId)
361 ICO_TRA("Enter(%d)", resourceId);
363 if (NULL != m_request) {
364 m_request->m_resourceId = resourceId;
365 if (true == m_request->acquireRes()) {
366 m_mngWin.push_back(m_request);
368 ICO_TRA("____ HIDE REQUEST");
369 m_request->hidePopup();
377 bR = requestShowSC();
379 ICO_TRA("Leave %s", bR? "true": "false");
382 // vim: set expandtab ts=4 sw=4: