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 * @brief homescreen application main
18 #include <Ecore_Evas.h>
19 #include <Ecore_Wayland.h>
21 #include <Elementary.h>
25 #include <libwebsockets.h>
29 #include "ico_uxf_conf.h"
30 #include "ico_syc_apc.h"
31 #include "ico_uxf_conf_ecore.h"
33 #include "home_screen_lib.h"
34 #include "home_screen_res.h"
35 #include "home_screen_conf.h"
36 #include "home_screen_parser.h"
38 /*============================================================================*/
40 /*============================================================================*/
41 #define ICO_HS_WINDOW_TYPE_BG (1)
42 #define ICO_HS_WINDOW_TYPE_TOUCH (2)
43 #define ICO_HS_TOUCH_TIME_OUT (1.0) /* Long press for timer */
44 typedef struct _hs_tile_info hs_tile_info_t;
45 typedef struct _hs_tile_hide hs_tile_hide_t;
47 struct _hs_tile_hide {
48 hs_tile_hide_t *next; /* next hide app on the same tile */
49 char appid[ICO_UXF_MAX_PROCESS_NAME];
52 struct _hs_tile_info {
54 int idx; /* index: 0 to ... */
55 int valid; /* 0: invalid, 1:valid */ /* dont't touch now */
56 char appid[ICO_UXF_MAX_PROCESS_NAME]; /* active app id */
57 int type; /* 11:small, 21:h-wide, 12:v-wide, 22:large, 0:others */
58 int l_press; /* 1: long press */
66 #define HS_DISPLAY_HOMESCREEN 0 /* HomeScreen target display Id */
67 #define NUM_ONSCREEN_WINDOWS 10 /* max number of windows in OnScreen*/
69 #define HS_LAYER_BACKGROUND 0 /* layer of BackGround */
70 #define HS_LAYER_HOMESCREEN 1 /* layer of HomeScreen menu */
71 #define HS_LAYER_APPLICATION 2 /* layer of Application */
72 #define HS_LAYER_SOFTKEYBOARD 3 /* layer of Software Keyboard */
73 #define HS_LAYER_INTERRUPTAPP 4 /* layer of Interrupted Application */
74 #define HS_LAYER_TOUCH 5 /* layer of TouchPanel */
75 #define HS_LAYER_ONSCREEN 6 /* layer of OnScreen */
77 /*============================================================================*/
78 /* static(internal) functions prototype */
79 /*============================================================================*/
80 static int hs_is_special_app(const char *appid);
81 static int hs_is_noicon_app(const char *appid);
82 static void hs_set_invisible_all(void);
83 static void hs_set_appscreen(const char *appid);
84 static void hs_tile_start_apps(void);
85 static int hs_tile_init_info(void);
86 static void hs_convert_tile_config(char *in, int *out, int cnt, int val);
87 static Eina_Bool hs_ecore_uxf_eventfd(void *data, Ecore_Fd_Handler *handler);
88 static void hs_uxf_event(int ev, Ico_Uxf_EventDetail dd, int arg);
89 static int hs_get_process_window(const char *appid);
90 static void hs_display_control(const Ico_Uxf_conf_application *conf, const int show);
91 static void hs_sound_control(const Ico_Uxf_conf_application *conf, const int adjust);
92 static void hs_input_control(const Ico_Uxf_conf_application *conf, const int inputsw);
93 static void *hs_create_window(int type);
94 static void hs_touch_up_api_list(void *data, Evas *evas, Evas_Object *obj,
96 static void hs_touch_down_api_list(void *data, Evas *evas, Evas_Object *obj,
98 static Eina_Bool hs_ecore_timer_event(void *data);
99 static void hs_touch_up_tile(void *data, Evas *evas, Evas_Object *obj, void *event_info);
100 static void hs_touch_down_tile(void *data, Evas *evas, Evas_Object *obj, void *event_info);
101 static void hs_add_touch_listener(Evas *canvas_fg);
102 static void hs_add_bg_image(Evas *canvas_bg);
103 static void hs_terminate_all_app(void);
104 static void hs_regulation_listener(const int appcategory,
105 const ico_apc_reguration_control_t control,
108 /*============================================================================*/
109 /* variables and tables */
110 /*============================================================================*/
111 char hs_kill_appid[ICO_UXF_MAX_PROCESS_NAME];
112 /* set kill 'app id' in touch layer */
113 char hs_active_onscreen[ICO_UXF_MAX_PROCESS_NAME];
114 /* stack 'app id' at active onscreen */
115 hs_window_data_t hs_command_tile_req[ICO_HS_APP_NUM_MAX];
116 hs_window_data_t hs_app_screen_window[ICO_HS_APP_NUM_MAX];
117 char hs_name_homescreen[ICO_UXF_MAX_PROCESS_NAME + 1];
118 static char gStatusbarName[ICO_UXF_MAX_PROCESS_NAME + 1];
119 static char gOnscreenName[ICO_UXF_MAX_PROCESS_NAME + 1];
120 static hs_tile_info_t *hs_tile_info;
121 static int hs_tile_cnt = 0;
122 static int hs_notile_cnt = 0;
123 static int hs_regulation_category = 0;
124 static int hs_regulation_visible = 1;
126 /*============================================================================*/
128 /*============================================================================*/
129 /*--------------------------------------------------------------------------*/
131 * @brief hs_uxf_event
132 * callback function called by UXF.
134 * @param[in] ev event kinds
135 * @param[in] dd event detail structure
136 * @param[in] arg user data
139 /*--------------------------------------------------------------------------*/
141 hs_uxf_event(int ev, Ico_Uxf_EventDetail dd, int arg)
143 const Ico_Uxf_conf_application *appConf;
145 uifw_trace("... Event=%08x Arg=%d", ev, arg);
147 Ico_Uxf_WindowAttr winAttr;
152 if (ev == ICO_UXF_EVENT_NEWWINDOW) {
153 uifw_trace(" D(Window) ev=%08x disp=%d win=%x x/y=%d/%d w/h=%d/%d v/r/a=%d/%d/%d",
154 dd.event, dd.window.display, dd.window.window,
155 dd.window.x, dd.window.y, dd.window.w, dd.window.h,
156 dd.window.visible, dd.window.raise, dd.window.active);
157 ret = ico_uxf_window_attribute_get(dd.window.window, &winAttr);
158 if (ret == ICO_UXF_EOK) {
159 uifw_trace(" D(Window) appid=%s sub=%d", winAttr.process,
161 if (strncmp(winAttr.process, hs_name_homescreen,
162 ICO_UXF_MAX_PROCESS_NAME) == 0) {
163 ico_uxf_window_screen_size_get(&dispW, &dispH);
164 /* HomeScreen APP: BG or TOUCH */
165 ico_uxf_window_resize(dd.window.window, dispW, dispH
166 - ICO_HS_SIZE_SB_HEIGHT);
167 ico_uxf_window_move(dd.window.window, 0, ICO_HS_SIZE_SB_HEIGHT);
168 ico_uxf_window_show(dd.window.window);
169 if (winAttr.subwindow > 0) {
170 /* set layer of HomeScreen TouchPanel window */
171 ico_uxf_window_layer(dd.window.window, HS_LAYER_TOUCH);
172 hs_tile_show_screen();
175 /* set layer of HomeScreen BackGround window */
176 ico_uxf_window_layer(dd.window.window, HS_LAYER_BACKGROUND);
179 else if (strncmp(winAttr.process, gStatusbarName,
180 ICO_UXF_MAX_PROCESS_NAME) == 0) {
181 /* set layer of StatusBar window */
182 ico_uxf_window_layer(dd.window.window, HS_LAYER_ONSCREEN);
183 /* show status bar */
184 ico_uxf_window_show(dd.window.window);
185 ico_uxf_window_move(dd.window.window, 0, 0);
186 ico_uxf_window_screen_size_get(&dispW, &dispH);
187 ico_uxf_window_resize(dd.window.window, dispW, ICO_HS_SIZE_SB_HEIGHT);
189 else if (strncmp(winAttr.process, gOnscreenName,
190 ICO_UXF_MAX_PROCESS_NAME) == 0) {
191 /* set layer of OnScreen window */
192 ico_uxf_window_layer(dd.window.window, HS_LAYER_BACKGROUND);
193 ico_uxf_window_visible_raise(dd.window.window, 1, 0);
196 /* other normal application */
197 if (hs_is_special_app(winAttr.process) == FALSE) {
198 if (hs_is_noicon_app(winAttr.process) != FALSE) {
199 hs_set_appscreen(winAttr.process);
200 if (hs_stat_touch == ICO_HS_TOUCH_IN_SHOW) {
201 hs_tile_show_screen();
204 else if (hs_stat_touch == ICO_HS_TOUCH_IN_SHOW) {
205 /* set layer of Application in HomeScreen menu */
206 ico_uxf_window_layer(dd.window.window, HS_LAYER_HOMESCREEN);
207 hs_tile_show_screen();
209 else if (hs_stat_touch == ICO_HS_TOUCH_IN_HIDE) {
210 hs_set_appscreen(winAttr.process);
216 else if (ev == ICO_UXF_EVENT_TERMPROCESS) {
217 uifw_trace("hs_uxf_event: ICO_UXF_EVENT_TERMPROCESS");
219 if (strlen(dd.process.process) != 0) {
220 idx = hs_tile_get_index_app(dd.process.process);
222 hs_tile_free_app(idx);
225 hs_tile_delete_hide(dd.process.process);
229 else if (ev == ICO_UXF_EVENT_ACTIVEWINDOW) {
230 /* set active window */
231 if (dd.window.active == ICO_UXF_WINDOW_SELECT) {
232 if (ico_uxf_window_attribute_get(dd.window.window, &winAttr) == ICO_UXF_EOK) {
233 if ((strncmp(winAttr.process, hs_name_homescreen, ICO_UXF_MAX_PROCESS_NAME)
235 (strncmp(winAttr.process, gStatusbarName, ICO_UXF_MAX_PROCESS_NAME)
237 (strncmp(winAttr.process, gOnscreenName, ICO_UXF_MAX_PROCESS_NAME)
239 /* if selected application is soft-keyboard, activate only pointer, */
240 /* other case activate pointer and keyboard */
241 appConf = ico_uxf_getAppByAppid(winAttr.process);
242 if ((appConf != NULL) &&
243 (appConf->display[0].layerId == HS_LAYER_SOFTKEYBOARD)) {
244 ico_uxf_window_active(dd.window.window,
245 ICO_UXF_WINDOW_POINTER_ACTIVE);
246 ico_uxf_window_raise(dd.window.window);
249 ico_uxf_window_active(dd.window.window,
250 ICO_UXF_WINDOW_KEYBOARD_ACTIVE);
251 ico_uxf_window_raise(dd.window.window);
252 ico_syc_apc_active(winAttr.process);
260 /*--------------------------------------------------------------------------*/
262 * @brief hs_ecore_uxf_eventfd
263 * callback function of wayland fd event that is used in UXF.
264 * if the fd has event, ecore call this function.
266 * @param[in] data user data
267 * @param[in] handler handler
270 /*--------------------------------------------------------------------------*/
272 hs_ecore_uxf_eventfd(void *data, Ecore_Fd_Handler *handler)
274 ico_uxf_main_loop_iterate();
279 /*--------------------------------------------------------------------------*/
281 * @brief hs_convert_tile_config
282 * for read configuration.
283 * convert configuration string to integer array.
285 * @param[in] in configuration
286 * @param[out] out integer array
287 * @param[in] cnt count
288 * @param[in] val default value
291 /*--------------------------------------------------------------------------*/
293 hs_convert_tile_config(char *in, int *out, int cnt, int val)
299 for (idx = 0; idx < cnt; idx++) {
304 for (idx = 0; idx < cnt; idx++) {
305 out[idx] = atoi(tok);
306 tok = strtok(NULL, s);
314 /*--------------------------------------------------------------------------*/
316 * @brief hs_get_index_appscreendata
317 * get applicaton screen data index.
319 * @param[in] appid application id
321 * @retval >=0 app index
322 * @retval -1 not exist
324 /*--------------------------------------------------------------------------*/
326 hs_get_index_appscreendata(const char *appid)
331 for (ii = 0; ii < ICO_HS_APP_NUM_MAX; ii++) {
332 if (hs_app_screen_window[ii].appid[0] == 0) {
338 if (strncmp(hs_app_screen_window[ii].appid, appid,
339 ICO_UXF_MAX_PROCESS_NAME) == 0) {
345 strncpy(hs_app_screen_window[idx].appid, appid,
346 ICO_UXF_MAX_PROCESS_NAME);
351 /*--------------------------------------------------------------------------*/
353 * @brief hs_set_appscreen
354 * set the application screen's status to the applicaton window,
355 * and visible raise the application window.
357 * @param[in] appid application id
360 /*--------------------------------------------------------------------------*/
362 hs_set_appscreen(const char *appid)
366 Ico_Uxf_ProcessWin window;
367 const Ico_Uxf_conf_application *appConf;
368 const Ico_Uxf_Sys_Config *sysConf;
369 Ico_Uxf_conf_display_zone *zone;
371 idx = hs_get_index_appscreendata(appid);
378 ret = ico_uxf_process_window_get(hs_app_screen_window[idx].appid, &window, 1);
379 if ((ret > 0) || (ret == ICO_UXF_E2BIG)) {
380 uifw_trace("hs_set_appscreen: app[%d]:visible=%d raise=%d %dx%d(%d,%d)",
381 idx, hs_app_screen_window[idx].visible, hs_app_screen_window[idx].raise,
382 hs_app_screen_window[idx].resize_w, hs_app_screen_window[idx].resize_h,
383 hs_app_screen_window[idx].move_x, hs_app_screen_window[idx].move_y);
384 /* move application window to application layer */
385 appConf = ico_uxf_getAppByAppid(hs_app_screen_window[idx].appid);
387 ico_uxf_window_layer(window.window, HS_LAYER_APPLICATION);
388 /* show application layer */
389 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_APPLICATION, 1);
392 ico_uxf_window_layer(window.window, appConf->display[0].layerId);
393 /* show application layer */
394 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, appConf->display[0].layerId, 1);
396 if ((hs_app_screen_window[idx].resize_w <= 0) &&
397 (hs_app_screen_window[idx].resize_h <= 0) &&
398 (hs_app_screen_window[idx].move_x <= 0) &&
399 (hs_app_screen_window[idx].move_y <= 0)) {
400 /* not set size and position, set default(zone size) */
401 sysConf = ico_uxf_getSysConfig();
402 zone = (Ico_Uxf_conf_display_zone *)&sysConf->
403 display[appConf->display[0].displayId].
404 zone[appConf->display[0].zoneId];
405 hs_app_screen_window[idx].resize_w = zone->width;
406 hs_app_screen_window[idx].resize_h = zone->height;
407 hs_app_screen_window[idx].move_x = zone->x;
408 hs_app_screen_window[idx].move_y = zone->y;
409 hs_app_screen_window[idx].visible = 1;
410 hs_app_screen_window[idx].raise = 1;
413 ico_uxf_window_move(window.window, hs_app_screen_window[idx].move_x,
414 hs_app_screen_window[idx].move_y);
415 ico_uxf_window_resize(window.window,
416 hs_app_screen_window[idx].resize_w,
417 hs_app_screen_window[idx].resize_h);
418 ico_uxf_window_visible_raise(window.window,
419 hs_app_screen_window[idx].visible,
420 hs_app_screen_window[idx].raise);
421 /* hide HomeScreen layer */
422 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_HOMESCREEN, 0);
424 ico_uxf_main_loop_iterate();
427 /*--------------------------------------------------------------------------*/
429 * @brief hs_set_invisible_all
430 * set all applicatoin except special applicaion(homescreen
431 * /statusbar/onscreen) in invisible.
436 /*--------------------------------------------------------------------------*/
438 hs_set_invisible_all(void)
440 uifw_trace("hs_set_invisible_all: Enter");
442 /* hide application layer */
443 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_APPLICATION, 0);
444 /* hide HomeScreen layer menu */
445 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_HOMESCREEN, 0);
447 uifw_trace("hs_set_invisible_all: Leave");
450 /*--------------------------------------------------------------------------*/
452 * @brief hs_show_appscreen
453 * show applicaton screen and raise the indicated application.
455 * @param[in] appid application id
458 /*--------------------------------------------------------------------------*/
460 hs_show_appscreen(const char *appid)
462 Ico_Uxf_ProcessWin window;
463 const Ico_Uxf_conf_application *appConf = NULL;
469 uifw_trace("hs_show_appscreen: Enter(appid=%s)", appid ? appid : "(NULL)");
470 /* change to noraml mode for AppsControler */
471 ico_uxf_window_control(NULL, -1, ICO_UXF_APPSCTL_TEMPVISIBLE, 0);
473 /* touch to invisible */
474 sid = hs_get_process_window(ICO_HS_APPID_DEFAULT_TOUCH);
476 ico_uxf_window_hide(sid);
478 /* all apps invisible */
479 hs_set_invisible_all();
481 /* show other apps */
482 for (ii = 0; ii < ICO_HS_APP_NUM_MAX; ii++) {
483 if (hs_app_screen_window[ii].appid[0] == 0)
485 appConf = ico_uxf_getAppByAppid(hs_app_screen_window[ii].appid);
486 if (appConf != NULL) {
487 hs_app_screen_window[ii].category = appConf->categoryId;
489 if (hs_is_special_app(hs_app_screen_window[ii].appid))
491 if ((appid != NULL) && strncmp(hs_app_screen_window[ii].appid, appid,
492 ICO_UXF_MAX_PROCESS_NAME) == 0)
496 ret = ico_uxf_process_window_get(hs_app_screen_window[ii].appid,
498 uifw_trace("hs_show_appscreen: window_get app[%s] = %d(visible=%d)",
499 hs_app_screen_window[ii].appid, ret,
500 hs_app_screen_window[ii].visible);
501 if ((ret > 0) || (ret == ICO_UXF_E2BIG)) {
502 if (hs_app_screen_window[ii].visible == 0) {
505 uifw_trace("hs_show_appscreen: move %d=%dx%d(%d,%d)", ii,
506 hs_app_screen_window[ii].resize_w,
507 hs_app_screen_window[ii].resize_h,
508 hs_app_screen_window[ii].move_x, hs_app_screen_window[ii].move_y);
509 /* move application window to application layer */
510 ico_uxf_window_resize(window.window,
511 hs_app_screen_window[ii].resize_w,
512 hs_app_screen_window[ii].resize_h);
513 ico_uxf_window_move(window.window,
514 hs_app_screen_window[ii].move_x,
515 hs_app_screen_window[ii].move_y);
516 ico_uxf_window_show(window.window);
518 ico_uxf_window_layer(window.window, HS_LAYER_APPLICATION);
519 /* show application layer */
520 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_APPLICATION, 1);
523 ico_uxf_window_layer(window.window, appConf->display[0].layerId);
524 /* show application layer */
525 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN,
526 appConf->display[0].layerId, 1);
531 /* hide HomeScreen layer menu */
532 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_HOMESCREEN, 0);
533 /* hide Touch layer */
534 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_TOUCH, 0);
535 /* hide OnScreen windows */
540 idx = hs_get_index_appscreendata(appid);
541 /* if not set pos, load default */
542 appConf = ico_uxf_getAppByAppid(appid);
543 if (appConf != NULL) {
544 int x, y, width, height;
545 (void)ico_uxf_getAppDisplay(appConf, 0, &x, &y, &width, &height);
547 if ((hs_app_screen_window[idx].resize_w == -1)
548 || (hs_app_screen_window[idx].resize_h == -1)) {
549 hs_app_screen_window[idx].resize_w = width;
550 hs_app_screen_window[idx].resize_h = height;
552 if ((hs_app_screen_window[idx].move_x == -1)
553 || (hs_app_screen_window[idx].move_y == -1)) {
554 hs_app_screen_window[idx].move_x = x;
555 hs_app_screen_window[idx].move_y = y;
557 if ((hs_app_screen_window[idx].resize_w == 0)
558 && (hs_app_screen_window[idx].resize_h == 0)
559 && (hs_app_screen_window[idx].move_x == 0)
560 && (hs_app_screen_window[idx].move_y == 0)) {
561 /* not have manifest, set default */
562 ico_uxf_window_screen_size_get(&dispW, &dispH);
563 hs_app_screen_window[idx].resize_w = dispW;
564 hs_app_screen_window[idx].resize_h = (dispH - ICO_HS_SIZE_SB_HEIGHT) / 2;
565 hs_app_screen_window[idx].move_x = 0;
566 hs_app_screen_window[idx].move_y = ICO_HS_SIZE_SB_HEIGHT;
571 ret = ico_uxf_process_window_get(appid, &window, 1);
572 uifw_trace("hs_show_appscreen: window_get app[%s] = %d", appid, ret);
573 if ((ret > 0) || (ret == ICO_UXF_E2BIG)) {
574 uifw_trace("hs_show_appscreen: move %d=%dx%d(%d,%d)", idx,
575 hs_app_screen_window[idx].resize_w,
576 hs_app_screen_window[idx].resize_h,
577 hs_app_screen_window[idx].move_x,
578 hs_app_screen_window[idx].move_y);
579 /* window hide and resize (for animation) */
580 ico_uxf_window_hide(window.window);
581 /* move application window to application layer */
582 ico_uxf_window_resize(window.window,
583 hs_app_screen_window[idx].resize_w,
584 hs_app_screen_window[idx].resize_h);
585 ico_uxf_window_move(window.window,
586 hs_app_screen_window[idx].move_x,
587 hs_app_screen_window[idx].move_y);
589 ico_uxf_window_layer(window.window, HS_LAYER_APPLICATION);
590 /* show application layer */
591 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_APPLICATION, 1);
594 ico_uxf_window_layer(window.window, appConf->display[0].layerId);
595 /* show application layer */
596 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN,
597 appConf->display[0].layerId, 1);
599 ico_uxf_window_raise(window.window);
600 /* activate application window */
601 if ((appConf != NULL) && (appConf->display[0].layerId == HS_LAYER_SOFTKEYBOARD)) {
602 ico_uxf_window_active(window.window, ICO_UXF_WINDOW_POINTER_ACTIVE);
605 ico_uxf_window_active(window.window,
606 ICO_UXF_WINDOW_KEYBOARD_ACTIVE);
608 ico_syc_apc_active(appid);
610 hs_app_screen_window[idx].visible = 1;
611 /* hide HomeScreen layer */
612 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_HOMESCREEN, 0);
613 /* visible application window with animation */
614 ico_uxf_window_visible_animation(window.window, 1);
617 hs_stat_touch = ICO_HS_TOUCH_IN_HIDE;
618 ico_uxf_main_loop_iterate();
620 uifw_trace("hs_show_appscreen: Leave");
623 /*--------------------------------------------------------------------------*/
625 * @brief hs_tile_start_apps
626 * launch the default application that indicated by configuration
632 /*--------------------------------------------------------------------------*/
634 hs_tile_start_apps(void)
636 char cName[ICO_UXF_MAX_PROCESS_NAME + 1];
640 const Ico_Uxf_App_Config *appConf;
641 hs_tile_info_t *tinfo;
643 /* excute applications in tile menu */
644 for (idx = 0; idx < hs_tile_cnt; idx++) {
645 tinfo = &hs_tile_info[idx];
646 if (tinfo->valid == 0) continue;
647 sprintf(cName, ICO_HS_CONFIG_TILE_APP"%d", idx);
648 appName = hs_conf_get_string(ICO_HS_CONFIG_HOMESCREEN, cName, NULL);
649 if ((appName != NULL) && (strcmp(appName, "none") != 0)) {
650 ret = ico_uxf_process_execute(appName);
652 uifw_trace("hs_tile_start_apps: execute tile[%d]=%s", idx, appName);
653 memset(tinfo->appid, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
654 strncpy(tinfo->appid, appName, ICO_UXF_MAX_PROCESS_NAME);
659 /* excute no menu applications */
660 appConf = ico_uxf_getAppConfig();
662 for (idx1 = 0; idx1 < appConf->applicationNum; idx1++) {
663 if (appConf->application[idx1].autostart == 0) continue;
664 for (idx2 = 0; idx2 < hs_tile_cnt; idx2++) {
665 if (! strcmp(hs_tile_info[idx2].appid, appConf->application[idx1].appid)) break;
667 if (idx2 >= hs_tile_cnt) {
668 ret = ico_uxf_process_execute(appConf->application[idx1].appid);
670 uifw_trace("hs_tile_start_apps: execute no tile[%d]=%s",
671 idx, appConf->application[idx1].appid);
672 memset(hs_tile_info[idx].appid, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
673 strncpy(hs_tile_info[idx].appid,
674 appConf->application[idx1].appid, ICO_UXF_MAX_PROCESS_NAME);
676 if ((idx - hs_tile_cnt) >= ICO_HS_NOTILE_APP_MAX) break;
680 hs_notile_cnt = idx - hs_tile_cnt;
683 /*--------------------------------------------------------------------------*/
685 * @brief hs_tile_init_info
686 * initialize tile information.
690 * @retval ICO_HS_OK success
691 * @retval ICO_HS_ERR err
693 /*--------------------------------------------------------------------------*/
695 hs_tile_init_info(void)
697 int idx, row, column;
705 int colcnt, rowcnt, tilecnt, tilesize;
707 hs_tile_info_t *tinfo;
710 colcnt = hs_conf_get_integer(ICO_HS_CONFIG_HOMESCREEN,
711 ICO_HS_CONFIG_TILE_COLCNT,
712 ICO_HS_CONFIG_TILE_COLCNT_DEFAULT);
713 rowcnt = hs_conf_get_integer(ICO_HS_CONFIG_HOMESCREEN,
714 ICO_HS_CONFIG_TILE_ROWCNT,
715 ICO_HS_CONFIG_TILE_ROWCNT_DEFAULT);
716 tilecnt = colcnt * rowcnt;
718 /* allocate tile info structure */
719 hs_tile_info = malloc(sizeof(hs_tile_info_t) * (tilecnt + ICO_HS_NOTILE_APP_MAX));
720 valid = (int *)malloc(sizeof(int) * (tilecnt + ICO_HS_NOTILE_APP_MAX));
721 type = (int *)malloc(sizeof(int) * (tilecnt + ICO_HS_NOTILE_APP_MAX));
722 if (!hs_tile_info || !valid || !type) {
723 uifw_warn("hs_tile_init_info: Leave(err malloc tile str failed)");
726 memset(hs_tile_info, 0, sizeof(hs_tile_info_t) * (tilecnt + ICO_HS_NOTILE_APP_MAX));
728 /* get screen size */
729 ico_uxf_window_screen_size_get(&dispW, &dispH);
730 while ((dispW < 0) || (dispH < 0)) {
731 ico_uxf_main_loop_iterate();
734 uifw_warn("hs_tile_init_info: Leave(cannot get screen size)");
738 ico_uxf_window_screen_size_get(&dispW, &dispH);
741 height = dispH - ICO_HS_SIZE_SB_HEIGHT;
743 /* determin tile size (interval the tile is 10 percent of the tile width) */
744 if (((float)width / (float)colcnt) > ((float)height / (float)rowcnt)) {
745 /* tile size based height */
746 tilesize = height / (1.0 * rowcnt + 0.1 * (rowcnt + 1));
747 mSide = (width - (tilesize * colcnt + tilesize * 0.1 * (colcnt + 1)))
752 /* tile size based width */
753 tilesize = width / (1.0 * colcnt + 0.1 * (colcnt + 1));
755 mTop = (height - (tilesize * rowcnt + tilesize * 0.1 * (rowcnt + 1)))
758 uifw_trace("hs_tile_init_info: mSide=%d mTop=%d disp(%dx%d)", mSide, mTop,
761 /* get tile config */
762 sValid = (char *)hs_conf_get_string(ICO_HS_CONFIG_HOMESCREEN,
763 ICO_HS_CONFIG_TILE_VALID, NULL);
764 sType = (char *)hs_conf_get_string(ICO_HS_CONFIG_HOMESCREEN,
765 ICO_HS_CONFIG_TILE_TYPE, NULL);
766 hs_convert_tile_config(sValid, valid, tilecnt, 1);
767 hs_convert_tile_config(sType, type, tilecnt, ICO_HS_TILE_SMALL);
769 /* set tile parameter */
770 for (idx = 0; idx < tilecnt; idx++) {
771 tinfo = &hs_tile_info[idx];
773 column = idx % colcnt;
775 memset(tinfo->appid, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
776 tinfo->valid = valid[idx];
777 tinfo->type = type[idx];
778 if (idx == tilecnt - 1) {
779 tinfo->type = ICO_HS_TILE_OTHERS;
784 tinfo->coord_x = mSide + tilesize * 0.1 + (tilesize + tilesize * 0.1)
786 tinfo->coord_y = mTop + ICO_HS_SIZE_SB_HEIGHT + tilesize * 0.1 + (tilesize
787 + tilesize * 0.1) * row;
788 switch (tinfo->type) {
789 case ICO_HS_TILE_SMALL:
790 tinfo->size_x = tilesize;
791 tinfo->size_y = tilesize;
793 case ICO_HS_TILE_HWIDE:
794 tinfo->size_x = tilesize;
795 tinfo->size_y = tilesize * 2.1;
797 case ICO_HS_TILE_VWIDE:
798 tinfo->size_x = tilesize * 2.1;
799 tinfo->size_y = tilesize;
801 case ICO_HS_TILE_LARGE:
802 tinfo->size_x = tilesize * 2.1;
803 tinfo->size_y = tilesize * 2.1;
806 tinfo->size_x = tilesize;
807 tinfo->size_y = tilesize;
811 uifw_trace("TILE_INFO:tile[%d]={%d,%d,%s,%d,%d,%d,(%dx%d),(%d,%d)}",
812 idx, tinfo->idx, tinfo->valid, tinfo->appid, tinfo->type,
813 tinfo->l_press, tinfo->change, tinfo->size_x, tinfo->size_y,
814 tinfo->coord_x, tinfo->coord_y);
817 hs_tile_cnt = tilecnt;
822 /*--------------------------------------------------------------------------*/
824 * @brief hs_tile_delete_hide
825 * delete hide app information.
827 * @param[in] appid application id
830 /*--------------------------------------------------------------------------*/
832 hs_tile_delete_hide(const char *appid)
835 hs_tile_info_t *tinfo;
836 hs_tile_hide_t *hide, *bhide;
838 for (ii = 0; ii < hs_tile_cnt; ii++) {
839 tinfo = &hs_tile_info[ii];
843 if (strcmp(appid, hide->appid) == 0) {
845 tinfo->next = hide->next;
848 bhide->next = hide->next;
861 /*--------------------------------------------------------------------------*/
863 * @brief hs_tile_free_app
864 * delete all information of the indicated tile.
866 * @param[in] idx tile index
869 /*--------------------------------------------------------------------------*/
871 hs_tile_free_app(int idx)
873 hs_tile_info_t *tinfo;
874 hs_tile_hide_t *hide;
877 if ((idx >= 0) && (idx < hs_tile_cnt)) {
878 tinfo = &hs_tile_info[idx];
881 tinfo->next = hide->next;
882 strncpy(tinfo->appid, hide->appid, ICO_UXF_MAX_PROCESS_NAME);
886 memset(tinfo->appid, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
893 if (strlen(hs_active_onscreen) > 0) {
896 if (hs_regulation_visible == 0) {
900 if ((hs_stat_touch == ICO_HS_TOUCH_IN_SHOW)
901 && (strlen(tinfo->appid) > 0)) {
902 win = hs_get_process_window(tinfo->appid);
904 ico_uxf_window_visible_raise(win, 1, 1);
909 /*--------------------------------------------------------------------------*/
911 * @brief hs_tile_show_screen
912 * show tile screen again.
917 /*--------------------------------------------------------------------------*/
919 hs_tile_show_screen(void)
921 Ico_Uxf_ProcessWin window;
924 hs_tile_info_t *tinfo;
926 if (hs_regulation_visible == 0) {
927 uifw_trace("hs_regulation_visible: regulation, no menu display");
931 /* chnage to menu mode for AppsControler */
932 ico_uxf_window_control(NULL, -1, ICO_UXF_APPSCTL_TEMPVISIBLE, 1);
934 /* all apps invisible */
935 /* hide HomeScreen layer menu */
936 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_HOMESCREEN, 0);
938 /* show application tile */
939 for (idx = 0; idx < hs_tile_cnt; idx++) {
940 tinfo = &hs_tile_info[idx];
941 if (tinfo->appid[0] == 0)
944 ret = ico_uxf_process_window_get(tinfo->appid, &window, 1);
945 uifw_trace("hs_tile_show_screen: window_get app[%s] = %d(%08x)",
946 tinfo->appid, ret, window.window);
947 if (((ret > 0) || (ret == ICO_UXF_E2BIG)) && (window.window != 0)) {
948 uifw_trace("hs_tile_show_screen: move %d=%dx%d(%d,%d)", idx,
949 tinfo->size_x, tinfo->size_y, tinfo->coord_x, tinfo->coord_y);
950 /* move application window to HomeScreen layer */
951 ico_uxf_window_layer(window.window, HS_LAYER_HOMESCREEN);
952 ico_uxf_window_resize(window.window, tinfo->size_x, tinfo->size_y);
953 ico_uxf_window_move(window.window, tinfo->coord_x, tinfo->coord_y);
954 ico_uxf_window_visible_raise(window.window, 1, 1);
958 hs_stat_touch = ICO_HS_TOUCH_IN_SHOW;
959 /* visible and raise touch layer */
960 sid = hs_get_process_window(ICO_HS_APPID_DEFAULT_TOUCH);
962 ico_uxf_window_visible_raise(sid, 1, 1);
964 /* show HomeScreen layer menu */
965 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_HOMESCREEN, 1);
966 /* show Touch layer */
967 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_TOUCH, 1);
968 /* hide application layer */
969 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_APPLICATION, 0);
971 ico_uxf_main_loop_iterate();
974 /*--------------------------------------------------------------------------*/
976 * @brief hs_tile_get_index_app
977 * Get tile index that has indicated application id.
979 * @param[in] appid application id
981 * @retval >=0 tile index
982 * @retval -1 not exist
984 /*--------------------------------------------------------------------------*/
986 hs_tile_get_index_app(const char *appid)
989 hs_tile_info_t *tinfo;
991 for (idx = 0; idx < hs_tile_cnt; idx++) {
992 tinfo = &hs_tile_info[idx];
993 if (strncmp(tinfo->appid, appid, ICO_UXF_MAX_PROCESS_NAME) == 0) {
1001 /*--------------------------------------------------------------------------*/
1003 * @brief hs_tile_get_minchange
1004 * Get a application tile index that has no application
1005 * or is changed minimum
1009 * @retval >= success(tile index)
1012 /*--------------------------------------------------------------------------*/
1014 hs_tile_get_minchange(void)
1019 hs_tile_info_t *tinfo;
1021 for (ii = 0; ii < hs_tile_cnt; ii++) {
1022 tinfo = &hs_tile_info[ii];
1023 if ((tinfo->type > ICO_HS_TILE_OTHERS) && ((tinfo->change <= min)
1026 min = tinfo->change;
1028 if ((tinfo->type > ICO_HS_TILE_OTHERS) && (strlen(tinfo->appid) == 0)) {
1036 /*--------------------------------------------------------------------------*/
1038 * @brief hs_tile_kill_app
1039 * terminate the indicated application, and free the tile
1040 * that have the application.
1042 * @param[in] appid application id
1045 /*--------------------------------------------------------------------------*/
1047 hs_tile_kill_app(const char *appid)
1051 idx = hs_tile_get_index_app(appid);
1053 ret = ico_uxf_process_terminate(appid);
1054 if (ret == ICO_UXF_EOK) {
1056 hs_tile_free_app(idx);
1059 hs_tile_delete_hide(appid);
1066 /*--------------------------------------------------------------------------*/
1068 * @brief hs_tile_get_index_pos
1069 * get the tile index of the position.
1071 * @param[in] appid application id
1072 * @return tile index
1073 * @retval >=0 success
1074 * @retval ICO_HS_ERR error
1076 /*--------------------------------------------------------------------------*/
1078 hs_tile_get_index_pos(int x, int y, int w, int h)
1081 hs_tile_info_t *tinfo;
1083 for (idx = 0; idx < hs_tile_cnt; idx++) {
1084 tinfo = &hs_tile_info[idx];
1085 if ((tinfo->coord_x == x) && (tinfo->coord_y == y) && (tinfo->size_x
1086 == w) && (tinfo->size_y == h)) {
1094 /*--------------------------------------------------------------------------*/
1096 * @brief hs_tile_set_app
1097 * set the applicaton to the tile of the indicated index.
1099 * @param[in] idx tile index
1100 * @param[in] appid application id
1103 /*--------------------------------------------------------------------------*/
1105 hs_tile_set_app(int idx, const char *appid)
1107 hs_tile_info_t *tinfo;
1108 hs_tile_hide_t *search, *bsearch, *hide = NULL;
1111 uifw_trace("hs_tile_set_app: Enter(idx=%d appid=%s)", idx, appid);
1113 if ((idx < 0) && (idx >= hs_tile_cnt)) {
1117 /* check whether the app is same as tile one */
1118 tinfo = &hs_tile_info[idx];
1119 if (strcmp(tinfo->appid, appid) == 0) {
1123 /* check whether the app is hide */
1124 for (ii = 0; ii < hs_tile_cnt; ii++) {
1125 tinfo = &hs_tile_info[ii];
1126 if (tinfo->valid == 0) continue;
1127 search = tinfo->next;
1130 if (strcmp(search->appid, appid) == 0) {
1133 tinfo->next = search->next;
1136 bsearch->next = search->next;
1141 search = search->next;
1149 tinfo = &hs_tile_info[idx];
1150 if (tinfo->valid > 0) {
1151 if (strlen(tinfo->appid) != 0) {
1152 int oldwin = hs_get_process_window(tinfo->appid);
1154 (void) ico_uxf_window_hide(oldwin);
1158 hide = malloc(sizeof(hs_tile_hide_t));
1161 uifw_warn("hs_tile_set_app: cannot allocate app table");
1164 memset(hide, 0, sizeof(hs_tile_hide_t));
1165 strncpy(hide->appid, tinfo->appid, ICO_UXF_MAX_PROCESS_NAME);
1167 hide->next = tinfo->next;
1176 strncpy(tinfo->appid, appid, ICO_UXF_MAX_PROCESS_NAME);
1181 /*--------------------------------------------------------------------------*/
1183 * @brief hs_get_process_window
1184 * get window surface from applicatoin id including special id.
1186 * @param[in] appid application id
1188 * @retval >=0 surface
1189 * @retval -1 not exist
1191 /*--------------------------------------------------------------------------*/
1193 hs_get_process_window(const char *appid)
1195 Ico_Uxf_ProcessWin wins[2];
1198 if (strcmp(appid, ICO_HS_APPID_DEFAULT_TOUCH) == 0) {
1199 ret = ico_uxf_process_window_get(hs_name_homescreen, wins, 2);
1200 if ((ret > 1) || (ret == ICO_UXF_E2BIG)) {
1201 return wins[1].window;
1205 ret = ico_uxf_process_window_get(appid, wins, 1);
1206 if ((ret > 0) || (ret == ICO_UXF_E2BIG)) {
1207 return wins[0].window;
1214 /*--------------------------------------------------------------------------*/
1216 * @brief hs_show_onscreen
1217 * set onscreen window to visible.
1222 /*--------------------------------------------------------------------------*/
1224 hs_show_onscreen(void)
1226 Ico_Uxf_ProcessWin window;
1229 ret = ico_uxf_process_window_get(ICO_HS_APPID_DEFAULT_ONS, &window, 1);
1231 if ((ret > 0) || (ret == ICO_UXF_E2BIG)) {
1232 ico_uxf_window_layer(window.window, HS_LAYER_ONSCREEN);
1236 /*--------------------------------------------------------------------------*/
1238 * @brief hs_hide_onscreen
1239 * set onscreen window to invisible.
1244 /*--------------------------------------------------------------------------*/
1246 hs_hide_onscreen(void)
1248 Ico_Uxf_ProcessWin window;
1251 ret = ico_uxf_process_window_get(ICO_HS_APPID_DEFAULT_ONS, &window, 1);
1253 if ((ret > 0) || (ret == ICO_UXF_E2BIG)) {
1254 ico_uxf_window_layer(window.window, HS_LAYER_BACKGROUND);
1255 ico_uxf_window_lower(window.window);
1259 /*--------------------------------------------------------------------------*/
1261 * @brief hs_click_escutcheon
1262 * processing when escutcheon button is clicked.
1267 /*--------------------------------------------------------------------------*/
1269 hs_click_escutcheon(void)
1271 uifw_trace("hs_click_escutcheon: Enter(regulation=%d)", hs_regulation_visible);
1273 if (strlen(hs_active_onscreen) > 0) {
1274 uifw_trace("hs_click_escutcheon: Leave(active=%s)", hs_active_onscreen);
1277 if (hs_regulation_visible == 0) {
1278 uifw_trace("hs_click_escutcheon: Leave(regulation)");
1282 if (hs_stat_touch == ICO_HS_TOUCH_IN_SHOW) {
1283 hs_snd_play(hs_snd_get_filename(ICO_HS_SND_TYPE_DEFAULT));
1284 uifw_trace("hs_click_escutcheon: hs_show_appscreen");
1285 hs_show_appscreen(NULL);
1287 else if (hs_stat_touch == ICO_HS_TOUCH_IN_HIDE) {
1288 hs_snd_play(hs_snd_get_filename(ICO_HS_SND_TYPE_DEFAULT));
1289 uifw_trace("hs_click_escutcheon: hs_tile_show_screen");
1290 hs_tile_show_screen();
1292 uifw_trace("hs_click_escutcheon: Leave");
1296 /*--------------------------------------------------------------------------*/
1298 * @brief hs_click_applist
1299 * processing when application list button is clicked.
1302 * @return regulation
1303 * @retval =0 regulation controlled(no display)
1304 * @retval =1 no regulation
1306 /*--------------------------------------------------------------------------*/
1308 hs_click_applist(void)
1310 uifw_trace("hs_click_applist: Enter(regulation=%d)", hs_regulation_visible);
1312 if (hs_regulation_visible == 0) {
1313 uifw_trace("hs_click_applist: Leave(regulation)");
1317 /* operation sound */
1318 hs_snd_play(hs_snd_get_filename(ICO_HS_SND_TYPE_DEFAULT));
1319 uifw_trace("hs_click_applist: Leave");
1321 /* show Touch layer */
1322 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_TOUCH, 1);
1323 /* show OnScreen windows */
1329 /*--------------------------------------------------------------------------*/
1331 * @brief hs_is_special_app
1332 * return 1 if the application is special one(homescreen)
1333 * /statusbar/onscreen).
1335 * @param[in] appid applicationId
1336 * @return special application
1337 * @retval 1 special application(HomeScreen/StatusBar ... etc)
1338 * @retval 0 normal application
1340 /*--------------------------------------------------------------------------*/
1342 hs_is_special_app(const char *appid)
1344 if ((strncmp(appid, hs_name_homescreen, ICO_UXF_MAX_PROCESS_NAME) == 0)
1345 || (strncmp(appid, gStatusbarName, ICO_UXF_MAX_PROCESS_NAME) == 0)
1346 || (strncmp(appid, gOnscreenName, ICO_UXF_MAX_PROCESS_NAME) == 0)
1347 || (strncmp(appid, ICO_HS_APPID_DEFAULT_TOUCH,
1348 ICO_UXF_MAX_PROCESS_NAME) == 0)) {
1349 uifw_trace("hs_is_special_app: app(%s) is special", appid);
1352 uifw_trace("hs_is_special_app: app(%s) is normal", appid);
1356 /*--------------------------------------------------------------------------*/
1358 * @brief hs_is_noicon_app
1359 * return 1 if the application has no menu icon
1361 * @param[in] appid applicationId
1362 * @return no need menu
1363 * @retval 1 no need menu
1364 * @retval 0 need menu
1366 /*--------------------------------------------------------------------------*/
1368 hs_is_noicon_app(const char *appid)
1370 const Ico_Uxf_conf_application *appConf;
1372 appConf = ico_uxf_getAppByAppid(appid);
1374 uifw_trace("hs_is_noicon_app: appid(%s) dose not exist", appid);
1378 if (appConf->noicon) {
1379 uifw_trace("hs_is_noicon_app: appid(%s) has no icon", appid);
1382 uifw_trace("hs_is_noicon_app: appid(%s) has icon", appid);
1386 /*--------------------------------------------------------------------------*/
1388 * @brief hs_terminate_all_app
1389 * terminate all application that homescreen handled
1394 /*--------------------------------------------------------------------------*/
1396 hs_terminate_all_app(void)
1398 Ico_Uxf_ProcessAttr procs[ICO_HS_APP_NUM_MAX];
1402 cnt = ico_uxf_process_query_processes(procs, ICO_HS_APP_NUM_MAX);
1403 if (cnt == ICO_UXF_E2BIG)
1404 cnt = ICO_HS_APP_NUM_MAX;
1405 uifw_trace("hs_terminate_all_app: ico_uxf_process_query_processes() = %d",
1407 for (ii = 0; ii < cnt; ii++) {
1408 if (hs_is_special_app(procs[ii].process))
1410 uifw_trace("hs_terminate_all_app: terminate(%s)", procs[ii].process);
1411 ico_uxf_process_terminate(procs[ii].process);
1413 ico_uxf_process_terminate(gStatusbarName);
1414 ico_uxf_process_terminate(gOnscreenName);
1417 /*--------------------------------------------------------------------------*/
1419 * @brief hs_req_ctlr_tile
1420 * processing when homescreen received json command from extra
1426 /*--------------------------------------------------------------------------*/
1428 hs_req_ctlr_tile(void)
1433 for (ii = 0; ii < ICO_HS_APP_NUM_MAX; ii++) {
1434 if ((hs_command_tile_req[ii].appid[0] == 0)
1435 || (hs_is_special_app(hs_command_tile_req[ii].appid) == TRUE)) {
1439 idx = hs_tile_get_index_app(hs_command_tile_req[ii].appid);
1442 if (hs_command_tile_req[ii].terminate != IGNORE) {
1443 ret = ico_uxf_process_terminate(hs_command_tile_req[ii].appid);
1444 if (ret == ICO_UXF_EOK) {
1446 hs_tile_free_app(idx);
1452 if (strlen(hs_command_tile_req[ii].exe_name) > 0) {
1453 ico_uxf_process_execute(hs_command_tile_req[ii].exe_name);
1456 hs_tile_show_screen();
1459 /*--------------------------------------------------------------------------*/
1461 * @brief hs_touch_up_api_list
1462 * processing when application list button touch up.
1467 /*--------------------------------------------------------------------------*/
1469 hs_touch_up_api_list(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1471 int idx = *(int *)data;
1472 char buf[ICO_HS_TEMP_BUF_SIZE];
1473 char path[ICO_HS_TEMP_BUF_SIZE];
1474 hs_tile_info_t *tinfo;
1476 tinfo = &hs_tile_info[idx];
1479 hs_get_image_path(path, sizeof(path));
1480 sprintf(buf, "%s"fname_api_all_off, path);
1481 evas_object_image_file_set(obj, buf, NULL);
1482 /* move and resize in the image */
1483 evas_object_move(obj, tinfo->coord_x, tinfo->coord_y - ICO_HS_SIZE_SB_HEIGHT);
1484 evas_object_resize(obj, tinfo->size_x, tinfo->size_y);
1485 /* show the image */
1486 evas_object_show(obj);
1488 uifw_trace("hs_touch_up_api_list: idx=%d", idx);
1489 strncpy(hs_active_onscreen, ICO_UXF_PROC_DEFAULT_HOMESCREEN,
1490 sizeof(hs_active_onscreen));
1491 hs_get_ons_edj_path(path, sizeof(path));
1492 sprintf(buf, "OPEN %s%s %s", path, ICO_HS_ONS_APPLI_LIST_NAME,
1493 ICO_UXF_PROC_DEFAULT_HOMESCREEN);
1494 uifw_trace("send '%s' to onscreen", buf);
1495 if (hs_lib_event_message(ICO_HS_PROTOCOL_TYPE_OS, buf) < 0) {
1496 memset(hs_active_onscreen, 0, sizeof(hs_active_onscreen));
1498 hs_snd_play(hs_snd_get_filename(ICO_HS_SND_TYPE_DEFAULT));
1501 /*--------------------------------------------------------------------------*/
1503 * @brief hs_touch_down_api_list
1504 * processing when application list button touch down.
1509 /*--------------------------------------------------------------------------*/
1511 hs_touch_down_api_list(void *data, Evas *evas, Evas_Object *obj,
1514 int idx = *(int *)data;
1515 char buf[ICO_HS_TEMP_BUF_SIZE];
1516 char path[ICO_HS_TEMP_BUF_SIZE];
1517 hs_tile_info_t *tinfo;
1519 tinfo = &hs_tile_info[idx];
1522 hs_get_image_path(path, sizeof(path));
1523 sprintf(buf, "%s"fname_api_all_off, path);
1524 evas_object_image_file_set(obj, buf, NULL);
1525 /* move and resize in the image */
1526 evas_object_move(obj, tinfo->coord_x, tinfo->coord_y - ICO_HS_SIZE_SB_HEIGHT);
1527 evas_object_resize(obj, tinfo->size_x, tinfo->size_y);
1528 /* show the image */
1529 evas_object_show(obj);
1532 /*--------------------------------------------------------------------------*/
1534 * @brief hs_ecore_timer_event
1535 * handler called when applicaton tile is pushed long term
1536 * to terminate application.
1538 * @param[in] data user data
1540 * @retval ECORE_CALLBACK_CANCEL
1541 * delete this handler
1543 /*--------------------------------------------------------------------------*/
1545 hs_ecore_timer_event(void *data)
1547 int idx = *(int *)data;
1548 char buf[ICO_HS_TEMP_BUF_SIZE];
1549 char tmp[ICO_HS_TEMP_BUF_SIZE];
1550 hs_tile_info_t *tinfo;
1552 tinfo = &hs_tile_info[idx];
1553 if (tinfo->l_press == 1) {
1556 /* set terminate app id for onscrAppliKill */
1557 if (strlen(tinfo->appid) != 0) {
1558 strncpy(hs_kill_appid, tinfo->appid, sizeof(hs_kill_appid));
1559 uifw_trace("hs_ecore_timer_event :hs_kill_appid = %s", hs_kill_appid);
1560 strncpy(hs_active_onscreen, ICO_UXF_PROC_DEFAULT_HOMESCREEN,
1561 sizeof(hs_active_onscreen));
1562 sprintf(buf, "OPEN HomeScreen/src/appli_kill.edj %s",
1563 ICO_UXF_PROC_DEFAULT_HOMESCREEN);
1564 hs_get_ons_edj_path(tmp, sizeof(tmp));
1565 sprintf(buf, "OPEN %s%s %s", tmp, ICO_HS_ONS_APPLI_KILL_NAME,
1566 ICO_UXF_PROC_DEFAULT_HOMESCREEN);
1567 uifw_trace("hs_ecore_timer_event: send %s to onscreen", buf);
1568 hs_lib_event_message(ICO_HS_PROTOCOL_TYPE_OS, buf);
1571 return ECORE_CALLBACK_CANCEL;
1574 /*--------------------------------------------------------------------------*/
1576 * @brief hs_touch_up_tile
1577 * processing when application tile button touch up.
1579 * @param[in] data user data
1580 * @param[in] obj evas object of the button
1581 * @param[in] event_info evas event infomation
1584 /*--------------------------------------------------------------------------*/
1586 hs_touch_up_tile(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1588 int idx = *(int *)data;
1591 hs_tile_info_t *tinfo;
1593 uifw_trace("hs_touch_up_tile: idx=%d", idx);
1595 if (strlen(hs_active_onscreen) != 0) {
1596 uifw_trace("hs_touch_up_tile: active=%s", hs_active_onscreen);
1600 tinfo = &hs_tile_info[idx];
1601 if (tinfo->l_press == 1) {
1604 /* send a message to extra tools */
1605 if (strlen(tinfo->appid) != 0) {
1606 sprintf(buf, "FOCUS %s", tinfo->appid);
1607 uifw_trace("hs_touch_up_tile: send '%s' to extra tools", buf);
1608 ret = hs_lib_event_message(ICO_HS_PROTOCOL_TYPE_CM, buf);
1610 hs_show_appscreen(tinfo->appid);
1612 hs_snd_play(hs_snd_get_filename(ICO_HS_SND_TYPE_DEFAULT));
1618 /*--------------------------------------------------------------------------*/
1620 * @brief hs_touch_down_tile
1621 * processing when application tile button touch down.
1623 * @param[in] data user data
1624 * @param[in] obj evas object of the button
1625 * @param[in] event_info evas event infomation
1628 /*--------------------------------------------------------------------------*/
1630 hs_touch_down_tile(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1632 int idx = *(int *)data;
1633 hs_tile_info_t *tinfo;
1635 uifw_trace("hs_touch_down_tile: idx=%d", idx);
1637 tinfo = &hs_tile_info[idx];
1639 if (strlen(tinfo->appid) != 0) {
1642 if (tinfo->type > ICO_HS_TILE_OTHERS) {
1643 /* add timer to detect long push */
1644 ecore_timer_add(ICO_HS_TOUCH_TIME_OUT, hs_ecore_timer_event, &tinfo->idx);
1648 /*--------------------------------------------------------------------------*/
1650 * @brief hs_add_bg_image
1651 * add image to background. if config does not have image file or
1652 * image file is not exsit, background show default edj.
1654 * @param[in] canvas_bg evas of background
1657 /*--------------------------------------------------------------------------*/
1659 hs_add_bg_image(Evas *canvas_bg)
1661 char img[ICO_HS_TEMP_BUF_SIZE];
1662 char path[ICO_HS_TEMP_BUF_SIZE];
1664 Evas_Object *canvas;
1665 Evas_Load_Error err;
1668 fname = (char *)hs_conf_get_string(ICO_HS_CONFIG_HOMESCREEN,
1669 ICO_HS_CONFIG_BG, NULL);
1671 uifw_trace("hs_add_bg_image: backgound config is not exist");
1674 if (fname[0] == '/') {
1675 snprintf(img, sizeof(img), "%s", fname);
1678 hs_get_image_path(path, sizeof(path));
1679 snprintf(img, sizeof(img), "%s/%s", path, fname);
1682 ico_uxf_window_screen_size_get(&dispW, &dispH);
1684 canvas = evas_object_image_filled_add(canvas_bg);
1685 evas_object_image_file_set(canvas, img, NULL);
1686 err = evas_object_image_load_error_get(canvas);
1687 if (err != EVAS_LOAD_ERROR_NONE) {
1688 uifw_trace("hs_add_bg_image: backgound image is not exist");
1691 evas_object_image_fill_set(canvas, 0, 0, dispW, dispH - ICO_HS_SIZE_SB_HEIGHT);
1692 evas_object_resize(canvas, dispW, dispH - ICO_HS_SIZE_SB_HEIGHT);
1693 evas_object_show(canvas);
1699 /*--------------------------------------------------------------------------*/
1701 * @brief hs_add_touch_listener
1702 * make and add listener to application tile button.
1704 * @param[in] canvas_fg evas of tile screen
1707 /*--------------------------------------------------------------------------*/
1709 hs_add_touch_listener(Evas *canvas_fg)
1712 char img[ICO_HS_TEMP_BUF_SIZE];
1713 char path[ICO_HS_TEMP_BUF_SIZE];
1714 Evas_Object * canvas;
1715 hs_tile_info_t *tinfo;
1717 /* set image path */
1718 hs_get_image_path(path, sizeof(path));
1719 sprintf(img, "%s"fname_api_all_off, path);
1722 for (idx = 0; idx < hs_tile_cnt; idx++) {
1723 tinfo = &hs_tile_info[idx];
1724 if (tinfo->valid == 0)
1726 /* Creates a reclangle */
1727 canvas = evas_object_rectangle_add(canvas_fg);
1728 /* Set a color or image */
1729 evas_object_color_set(canvas, 0, 0, 0, 0);
1730 /* Move and resize the rectangle */
1731 evas_object_move(canvas, tinfo->coord_x, tinfo->coord_y - ICO_HS_SIZE_SB_HEIGHT);
1732 evas_object_resize(canvas, tinfo->size_x, tinfo->size_y);
1733 /* add event the rectangle */
1734 evas_object_event_callback_add(canvas, EVAS_CALLBACK_MOUSE_UP,
1735 hs_touch_up_tile, &tinfo->idx);
1736 evas_object_event_callback_add(canvas, EVAS_CALLBACK_MOUSE_DOWN,
1737 hs_touch_down_tile, &tinfo->idx);
1738 /* show the rectangle */
1739 evas_object_show(canvas);
1741 /* application menu icon */
1742 tinfo = &hs_tile_info[hs_tile_cnt - 1];
1743 if ((tinfo->valid == 0) && (tinfo->type == ICO_HS_TILE_APPLIST)) {
1744 canvas = evas_object_image_filled_add(canvas_fg);
1745 evas_object_image_file_set(canvas, img, NULL);
1746 evas_object_move(canvas, tinfo->coord_x, tinfo->coord_y - ICO_HS_SIZE_SB_HEIGHT);
1747 evas_object_resize(canvas, tinfo->size_x, tinfo->size_y);
1748 evas_object_event_callback_add(canvas, EVAS_CALLBACK_MOUSE_UP,
1749 hs_touch_up_api_list, &tinfo->idx);
1750 evas_object_event_callback_add(canvas, EVAS_CALLBACK_MOUSE_DOWN,
1751 hs_touch_down_api_list, &tinfo->idx);
1752 evas_object_show(canvas);
1756 /*--------------------------------------------------------------------------*/
1758 * @brief hs_create_window
1759 * create background and tile screen window of ecore.
1761 * @param[in] type background or tile screen
1764 /*--------------------------------------------------------------------------*/
1766 hs_create_window(int type)
1769 Ecore_Evas * window;
1773 char path[ICO_HS_TEMP_BUF_SIZE];
1774 char edjfile[ICO_HS_TEMP_BUF_SIZE];
1776 window = ecore_evas_new(NULL, 0, 0, 1, 1, "frame=0");
1778 ecore_main_loop_iterate();
1779 ico_uxf_window_screen_size_get(&dispW, &dispH);
1781 height = dispH - ICO_HS_SIZE_SB_HEIGHT;
1784 uifw_warn("HomeScreen: could not create window.");
1788 canvas = ecore_evas_get(window);
1789 edje = edje_object_add(canvas);
1790 /* NULL is aborted */
1792 uifw_warn("HomeScreen: could not create edje object!");
1796 hs_get_edj_path(path, sizeof(path));
1798 if (type == ICO_HS_WINDOW_TYPE_BG) {
1799 ecore_evas_move(window, 0, 0);
1800 ecore_evas_resize(window, width, height);
1801 ecore_evas_show(window);
1803 int err = edje_object_load_error_get(edje);
1804 const char *errmsg = edje_load_error_str(err);
1805 sprintf(edjfile, "%s/home_screen_bg.edj", path);
1806 if (!edje_object_file_set(edje, edjfile, "home_screen_bg")) {
1808 "HomeScreen: could not load 'home_screen_bg' from %s: %s",
1810 evas_object_del(edje);
1814 evas_object_move(edje, 0, 0);
1815 evas_object_resize(edje, width, height);
1816 evas_object_show(edje);
1818 hs_add_bg_image(canvas);
1821 ecore_evas_move(window, 0, 0);
1822 ecore_evas_resize(window, width, height);
1823 ecore_evas_alpha_set(window, EINA_TRUE);
1824 ecore_evas_show(window);
1826 int err = edje_object_load_error_get(edje);
1827 const char *errmsg = edje_load_error_str(err);
1828 sprintf(edjfile, "%s/home_screen_touch.edj", path);
1829 if (!edje_object_file_set(edje, edjfile, "home_screen_touch")) {
1831 "HomeScreen: could not load 'home_screen_touch' from %s: %s",
1833 evas_object_del(edje);
1837 evas_object_move(edje, 0, 0);
1838 evas_object_resize(edje, width, height);
1839 evas_object_show(edje);
1841 hs_add_touch_listener(canvas);
1847 /*--------------------------------------------------------------------------*/
1849 * @brief hs_display_control
1852 * @param[in] conf configuration
1853 * @param[in] show show
1856 /*--------------------------------------------------------------------------*/
1858 hs_display_control(const Ico_Uxf_conf_application *conf, const int show)
1860 uifw_trace("hs_display_control: app=%s show=%d", conf->appid, show);
1861 /* no need, because all control in AppsController */
1864 /*--------------------------------------------------------------------------*/
1866 * @brief hs_sound_control
1869 * @param[in] conf configuration
1870 * @param[in] adjust adjust
1873 /*--------------------------------------------------------------------------*/
1875 hs_sound_control(const Ico_Uxf_conf_application *conf, const int adjust)
1877 uifw_trace("hs_sound_control: app=%s adjust=%d", conf->appid, adjust);
1878 /* no need, because all control in AppsController */
1881 /*--------------------------------------------------------------------------*/
1883 * @brief hs_input_control
1886 * @param[in] conf configuration
1887 * @param[in] inputsw input switch
1890 /*--------------------------------------------------------------------------*/
1892 hs_input_control(const Ico_Uxf_conf_application *conf, const int inputsw)
1894 uifw_trace("hs_input_control: app=%s inputsw=%d", conf->appid, inputsw);
1895 /* no need, because all control in AppsController */
1898 /*--------------------------------------------------------------------------*/
1900 * @brief hs_regulation_listener: change regulation callback(static function)
1902 * @param[in] appcategory category Id
1903 * @param[in] control control(display/sound/input active/inactive)
1904 * @param[in] user_data user data(unused)
1907 /*--------------------------------------------------------------------------*/
1909 hs_regulation_listener(const int appcategory,
1910 const ico_apc_reguration_control_t control, void *user_data)
1912 if ((appcategory == hs_regulation_category) &&
1913 (control.display != ICO_SYC_APC_REGULATION_NOCHANGE)) {
1914 uifw_trace("hs_regulation_listener: Enter(category=%d disp=%d)",
1915 appcategory, control.display);
1917 if (control.display == ICO_SYC_APC_REGULATION_REGULATION) {
1918 /* Invisible by reguration */
1919 if (hs_regulation_visible) {
1920 hs_regulation_visible = 0;
1921 if (hs_stat_touch == ICO_HS_TOUCH_IN_SHOW) {
1922 uifw_trace("hs_regulation_listener: Change to App screen");
1923 hs_show_appscreen(NULL);
1926 memset(hs_active_onscreen, 0, sizeof(hs_active_onscreen));
1931 uifw_trace("hs_regulation_listener: Change to ALl screen");
1932 hs_regulation_visible = 1;
1937 /*--------------------------------------------------------------------------*/
1940 * homescreen main. initialize UXF, app manager, and ecore.
1942 * @param[in] argc counts of argment
1943 * @param[in] argv argment
1945 * @retval >=0 success
1948 /*--------------------------------------------------------------------------*/
1950 main(int argc, char *argv[])
1958 printf("main: %s: %s", getenv("HOME"), getenv("PKG_NAME"));
1959 pkg = getenv("PKG_NAME");
1960 memset(hs_name_homescreen, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
1962 strncpy(hs_name_homescreen, pkg, ICO_UXF_MAX_PROCESS_NAME);
1965 strncpy(hs_name_homescreen, ICO_UXF_PROC_DEFAULT_HOMESCREEN,
1966 ICO_UXF_MAX_PROCESS_NAME);
1968 strncpy(gStatusbarName,
1969 (char *)hs_conf_get_string(ICO_HS_CONFIG_HOMESCREEN,
1971 ICO_HS_APPID_DEFAULT_SB),
1972 ICO_UXF_MAX_PROCESS_NAME);
1973 strncpy(gOnscreenName,
1974 (char *)hs_conf_get_string(ICO_HS_CONFIG_HOMESCREEN,
1976 ICO_HS_APPID_DEFAULT_ONS),
1977 ICO_UXF_MAX_PROCESS_NAME);
1980 /* init for window mgr */
1981 ret = ico_uxf_init(hs_name_homescreen);
1982 if (ret != ICO_UXF_EOK) {
1983 uifw_error("ico_uxf_init err=%d", ret);
1986 ico_uxf_callback_set(ICO_UXF_EVENT_ALL, hs_uxf_event, 0);
1987 memset(hs_app_screen_window, 0, sizeof(hs_app_screen_window));
1988 for (ii = 0; ii < ICO_HS_APP_NUM_MAX; ii++) {
1989 hs_app_screen_window[ii].resize_w = -1;
1990 hs_app_screen_window[ii].resize_h = -1;
1991 hs_app_screen_window[ii].move_x = -1;
1992 hs_app_screen_window[ii].move_y = -1;
1994 ico_uxf_main_loop_iterate();
1996 /* init tile info */
1997 ret = hs_tile_init_info();
1999 uifw_warn("hs_tile_init_info err=%d", ret);
2002 /* start onscreen & statusbar apps */
2003 ret = ico_uxf_process_execute(gOnscreenName);
2005 uifw_warn("ico_uxf_process_execute(%s) err=%d", gOnscreenName, ret);
2007 ret = ico_uxf_process_execute(gStatusbarName);
2009 uifw_warn("ico_uxf_process_execute(%s) err=%d", gStatusbarName, ret);
2011 ico_uxf_main_loop_iterate();
2017 /* for communicate other process */
2018 port = hs_conf_get_integer(ICO_HS_CONFIG_HOMESCREEN,
2019 ICO_HS_CONFIG_WS_PORT,
2023 /* initialize Application Controller */
2024 ret = ico_syc_apc_init(hs_display_control, hs_sound_control, hs_input_control);
2025 if (ret != ICO_SYC_EOK) {
2026 uifw_error("ico_syc_apc_init err=%d", ret);
2029 /* start default tile apps */
2030 hs_tile_start_apps();
2031 ico_uxf_main_loop_iterate();
2033 /* HomeScreen Menu(background) */
2034 hs_create_window(ICO_HS_WINDOW_TYPE_BG);
2035 /* add callbacks for wayland(wl_window_mgr) */
2036 ecore_main_fd_handler_add(ico_uxf_wl_display_fd(), ECORE_FD_READ,
2037 hs_ecore_uxf_eventfd, NULL, /* data */
2039 ecore_main_loop_iterate();
2040 ico_uxf_main_loop_iterate();
2042 /* HomeScreen Menu(touch) */
2043 hs_create_window(ICO_HS_WINDOW_TYPE_TOUCH);
2045 /* initiailze regulation control */
2046 hs_regulation_category = ico_uxf_getSysCategoryByName("CarSetting");
2047 ico_syc_apc_regulation_listener(hs_regulation_listener, NULL);
2049 if (hs_regulation_visible) {
2050 uifw_trace("main: no regulation");
2051 hs_tile_show_screen();
2054 uifw_trace("main: regulation");
2055 hs_show_appscreen(NULL);
2058 /* add callback to app configuration */
2059 ico_uxf_econf_setAppUpdateCb(NULL);
2062 ecore_main_loop_begin();
2064 /* terminate Application Controller */
2065 (void) ico_syc_apc_term();
2067 /* terminate all known application */
2068 hs_terminate_all_app();
2072 ecore_evas_shutdown();