2 * Copyright (c) 2013, 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
10 //==========================================================================
14 * @brief This file is implimention of CicoHSAppInfo class
16 //==========================================================================
18 #include "CicoHSAppInfo.h"
19 #include "CicoSystemConfig.h"
21 #include "CicoHSLifeCycleController.h"
23 //==========================================================================
25 //==========================================================================
26 //--------------------------------------------------------------------------
30 * @param [in] appid application id
32 //--------------------------------------------------------------------------
33 CicoHSAppInfo::CicoHSAppInfo(const char *appid)
34 : m_appid(appid), m_category(0), m_window_num(0), m_last_surface(0)
36 memset(m_window_info_i, 0, sizeof(m_window_info_i));
37 m_life_cycle_controller = CicoHSLifeCycleController::getInstance();
40 //--------------------------------------------------------------------------
44 //--------------------------------------------------------------------------
45 CicoHSAppInfo::~CicoHSAppInfo(void)
49 //--------------------------------------------------------------------------
51 * @brief set window information
53 * @param [in] wininfo window information
56 //--------------------------------------------------------------------------
58 CicoHSAppInfo::AddWindowInfo(ico_syc_win_info_t *wininfo)
61 if (NULL == wininfo) {
62 ICO_ERR("wininfo is null.");
66 ICO_TRA("CicoHSAppInfo::AddWindowInfo Enter(appid=%s surface=%x",
67 wininfo->appid, wininfo->surface);
69 // if exist window information, update current window information
70 std::vector<ico_hs_window_info*>::iterator itr;
71 itr = this->m_window_info.begin();
72 for (; itr != this->m_window_info.end(); ++itr) {
73 if (wininfo->surface == (*itr)->surface) {
75 SetWindowInfo(*itr, wininfo);
76 ICO_TRA("CicoHSAppInfo::AddWindowInfo Leave(OK)");
81 // if not exit window information, create window information
82 ico_hs_window_info *tmp_win_info = GetFreeWindowInfoBuffer();
83 if (tmp_win_info == NULL) {
84 ICO_ERR("CicoHSAppInfo::AddWindowInfo Leave(ERR)");
87 SetWindowInfo(tmp_win_info, wininfo);
88 this->m_window_info.push_back(tmp_win_info);
91 ICO_TRA("CicoHSAppInfo::AddWindowInfo Leave(OK)");
95 //--------------------------------------------------------------------------
97 * @brief set window attribute
99 * @param [in] winattr window attribute
100 * @return OK or ERROR
102 //--------------------------------------------------------------------------
104 CicoHSAppInfo::AddWindowAttr(ico_syc_win_attr_t *winattr)
106 if (NULL == winattr) {
107 ICO_ERR("winattr is null.");
111 ICO_TRA("CicoHSAppInfo::AddWindowAttr Enter(appid=%s surface=%x",
112 winattr->appid, winattr->surface);
114 // if exist window information, update current window information
115 std::vector<ico_hs_window_info*>::iterator itr;
116 itr = m_window_info.begin();
117 for (; itr != m_window_info.end(); itr++){
118 if (winattr->surface == (*itr)->surface) {
120 SetWindowAttr(*itr, winattr);
121 ICO_TRA("CicoHSAppInfo::AddWindowAttr Leave(OK)");
126 // if not exit window information, create window information
127 ico_hs_window_info *tmp_win_info = GetFreeWindowInfoBuffer();
128 if (tmp_win_info == NULL){
129 ICO_TRA("CicoHSAppInfo::AddWindowAttr Leave(ERR)");
133 SetWindowAttr(tmp_win_info, winattr);
134 m_window_info.push_back(tmp_win_info);
137 ICO_TRA("CicoHSAppInfo::AddWindowAttr Leave(OK)");
141 //--------------------------------------------------------------------------
143 * @brief free window information
145 * @param [in] name window name
147 //--------------------------------------------------------------------------
149 CicoHSAppInfo::FreeWindowInfo(const char *name)
151 std::vector<ico_hs_window_info*>::iterator itr;
152 itr = m_window_info.begin();
153 for (; itr != m_window_info.end(); ++itr) {
154 if ((0 == strncmp(name,(*itr)->name, ICO_HS_MAX_WINDOW_NAME)) &&
156 ICO_DBG("CicoHSAppInfo::FreeWindowInfo(name=%s)", name ? name : "(NULL)");
157 if ((*itr)->surface == m_last_surface) {
160 (*itr)->valid = false;
161 m_window_info.erase(itr);
168 //--------------------------------------------------------------------------
170 * @brief free window information
172 * @param [in] surface surface id
174 //--------------------------------------------------------------------------
176 CicoHSAppInfo::FreeWindowInfo(int surface)
178 std::vector<ico_hs_window_info*>::iterator itr;
179 itr = m_window_info.begin();
180 for (; itr != m_window_info.end(); ++itr) {
181 if (((*itr)->surface == surface) && ((*itr)->valid)) {
182 ICO_DBG("CicoHSAppInfo::FreeWindowInfo(surface=%08x)", surface);
183 if ((*itr)->surface == m_last_surface) {
186 (*itr)->valid = false;
187 m_window_info.erase(itr);
194 //--------------------------------------------------------------------------
196 * @brief get application id
198 * @return application id
200 //--------------------------------------------------------------------------
202 CicoHSAppInfo::GetAppId(void)
204 return m_appid.c_str();
207 //--------------------------------------------------------------------------
209 * @brief get number of window
211 * @return number of window
213 //--------------------------------------------------------------------------
215 CicoHSAppInfo::GetWindowNum(void)
220 //--------------------------------------------------------------------------
222 * @brief get window information
224 * @param[in] name window name
225 * @return window information
227 //--------------------------------------------------------------------------
229 CicoHSAppInfo::GetWindowInfo(const char* name)
231 std::vector<ico_hs_window_info*>::iterator itr;
232 itr = m_window_info.begin();
233 for (; itr != m_window_info.end(); ++itr) {
234 if((0 == strncmp(name,(*itr)->name, ICO_HS_MAX_WINDOW_NAME)) &&
242 /*--------------------------------------------------------------------------*/
244 * @brief CicoHSAppInfo::GetWindowInfo
245 * get window information
247 * @param[in] idx index(0-n)
248 * @return window information
250 /*--------------------------------------------------------------------------*/
252 CicoHSAppInfo::GetWindowInfo(int idx)
256 for (std::vector<ico_hs_window_info*>::iterator it_window_info
257 = m_window_info.begin();
258 it_window_info != m_window_info.end();
260 if (! (*it_window_info)->valid) continue;
262 return *it_window_info;
269 //--------------------------------------------------------------------------
271 * @brief get window information
273 * @param[in] surface surface id
274 * @return window information
276 //--------------------------------------------------------------------------
278 CicoHSAppInfo::GetWindowInfobySurface(int surface)
280 std::vector<ico_hs_window_info*>::iterator itr;
281 itr = m_window_info.begin();
282 for (; itr != m_window_info.end(); ++itr) {
283 if (((*itr)->surface == surface) &&
291 //--------------------------------------------------------------------------
293 * @brief launch application
295 * @return 0 on success, other on error
297 //--------------------------------------------------------------------------
299 CicoHSAppInfo::Execute(void)
302 int ret = m_life_cycle_controller->launch(m_appid);
309 //--------------------------------------------------------------------------
311 * @brief terminate application
313 * @return 0 on success, other on error
315 //--------------------------------------------------------------------------
317 CicoHSAppInfo::Terminate(void)
319 // call terminate api
320 int ret = m_life_cycle_controller->terminate(m_appid);
327 //--------------------------------------------------------------------------
331 * @return application running status
332 * @retval true running
333 * @retval false not running
335 //--------------------------------------------------------------------------
337 CicoHSAppInfo::GetStatus(void)
339 return m_life_cycle_controller->isRunning(m_appid);
342 //--------------------------------------------------------------------------
344 * @brief set last surface id
346 * @param [in] last surface id
348 //--------------------------------------------------------------------------
350 CicoHSAppInfo::SetLastSurface(int last_surface)
352 m_last_surface = last_surface;
355 //--------------------------------------------------------------------------
357 * @brief get last surface id
361 //--------------------------------------------------------------------------
363 CicoHSAppInfo::GetLastSurface(void)
365 return m_last_surface;
368 //--------------------------------------------------------------------------
370 * @brief get default zone name
374 //--------------------------------------------------------------------------
376 CicoHSAppInfo::GetDefaultZone(void)
378 m_life_cycle_controller = CicoHSLifeCycleController::getInstance();
379 const CicoAilItems* ailItem = m_life_cycle_controller->findAIL(m_appid);
381 CicoSystemConfig *sysConf = CicoSystemConfig::getInstance();
382 const CicoSCDisplayZoneConf *zoneConf = NULL;
383 if (NULL != ailItem) {
384 zoneConf = sysConf->findDisplayZoneConfbyId(ailItem->m_displayZone);
387 const CicoSCDefaultConf* defConf = sysConf->getDefaultConf();
388 zoneConf = sysConf->findDisplayZoneConfbyId(defConf->displayzone);
391 if (NULL == zoneConf) {
394 return zoneConf->fullname.c_str();
397 //==========================================================================
399 //==========================================================================
400 //--------------------------------------------------------------------------
402 * @brief set window information
404 * @param [in] hs_wininfo window information
405 * @param [in] wininfo window information from system-controller
407 //--------------------------------------------------------------------------
409 CicoHSAppInfo::SetWindowInfo(ico_hs_window_info *hs_wininfo,
410 ico_syc_win_info_t *wininfo)
412 ICO_TRA("CicoHSAppInfo::SetWindowInfo Enter"
413 "(winifo=%p appid=%s winname=%s surface=%x)",
415 wininfo->appid, wininfo->name, wininfo->surface);
417 // set application id
418 if(wininfo->appid != NULL){
419 strncpy(hs_wininfo->appid, wininfo->appid, ICO_HS_MAX_PROCESS_NAME);
422 // set window name(window title)
423 if(wininfo->name != NULL){
424 strncpy(hs_wininfo->name, wininfo->name, ICO_HS_MAX_WINDOW_NAME);
427 hs_wininfo->surface = wininfo->surface;
429 ICO_TRA("CicoHSAppInfo::SetWindowInfo Leave");
432 //--------------------------------------------------------------------------
434 * @brief set window attribute
436 * @param [in] hs_wininfo window information
437 * @param [in] winattr window attribute
439 //--------------------------------------------------------------------------
441 CicoHSAppInfo::SetWindowAttr(ico_hs_window_info *hs_wininfo,
442 ico_syc_win_attr_t *winattr)
444 ICO_TRA("CicoHSAppInfo::SetWindowAttr Enter"
446 "appid=%s winname=%s zone=%s surface=%x nodeid=%d layer=%d "
447 "x/y=%d/%d w/h=%d/%d raise=%d visible=%d active=%d)",
449 winattr->appid, winattr->name, winattr->zone,
450 winattr->surface, winattr->nodeid, winattr->layer,
451 winattr->pos_x, winattr->pos_y, winattr->width, winattr->height,
452 winattr->raise, winattr->visible, winattr->active);
454 if (winattr->appid != NULL) {
455 strncpy(hs_wininfo->appid, winattr->appid, ICO_HS_MAX_PROCESS_NAME);
458 if (winattr->name != NULL) {
459 strncpy(hs_wininfo->name, winattr->name, ICO_HS_MAX_WINDOW_NAME);
462 if (winattr->zone != NULL) {
463 strncpy(hs_wininfo->zone, winattr->zone, ICO_HS_MAX_ZONE_NAME);
466 hs_wininfo->surface = winattr->surface;
467 hs_wininfo->nodeid = winattr->nodeid;
468 hs_wininfo->layer = winattr->layer;
469 hs_wininfo->pos_x = winattr->pos_x;
470 hs_wininfo->pos_y = winattr->pos_y;
471 hs_wininfo->width = winattr->width;
472 hs_wininfo->height = winattr->height;
473 hs_wininfo->raise = winattr->raise;
474 hs_wininfo->visible = winattr->visible;
475 hs_wininfo->active = winattr->active;
477 ICO_TRA("CicoHSAppInfo::SetWindowAttr Leave");
480 //--------------------------------------------------------------------------
482 * @brief CicoHSAppInfo::GetFreeWindowInfoBuffer
483 * get internal window info buffer
488 //--------------------------------------------------------------------------
490 CicoHSAppInfo::GetFreeWindowInfoBuffer(void)
492 ico_hs_window_info *tmp_win_info;
493 for (int ii = 0; ii < ICO_HS_APP_MAX_WINDOW_NUM; ii++) {
494 if (m_window_info_i[ii].valid == false) {
495 tmp_win_info = &m_window_info_i[ii];
496 tmp_win_info->valid = true;
502 // vim: set expandtab ts=4 sw=4: