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)");
471 if (hs_stat_touch == ICO_HS_TOUCH_IN_HIDE) {
472 /* if it is the transition from an application screen to */
473 /* an other application screen, perform animation at hide screen*/
474 ico_uxf_window_animation_control(0, 1);
477 /* if it is the transition from menu to an application screen, */
478 /* do not perform animation at hide appllication screen */
479 ico_uxf_window_animation_control(0, 0);
482 /* change to noraml mode for AppsControler */
483 ico_uxf_window_control(NULL, -1, ICO_UXF_APPSCTL_TEMPVISIBLE, 0);
485 /* touch to invisible */
486 sid = hs_get_process_window(ICO_HS_APPID_DEFAULT_TOUCH);
488 ico_uxf_window_hide(sid);
490 /* all apps invisible */
491 hs_set_invisible_all();
493 /* show other apps */
494 for (ii = 0; ii < ICO_HS_APP_NUM_MAX; ii++) {
495 if (hs_app_screen_window[ii].appid[0] == 0)
497 appConf = ico_uxf_getAppByAppid(hs_app_screen_window[ii].appid);
498 if (appConf != NULL) {
499 hs_app_screen_window[ii].category = appConf->categoryId;
501 if (hs_is_special_app(hs_app_screen_window[ii].appid))
503 if ((appid != NULL) && strncmp(hs_app_screen_window[ii].appid, appid,
504 ICO_UXF_MAX_PROCESS_NAME) == 0)
508 ret = ico_uxf_process_window_get(hs_app_screen_window[ii].appid,
510 uifw_trace("hs_show_appscreen: window_get app[%s] = %d(visible=%d)",
511 hs_app_screen_window[ii].appid, ret,
512 hs_app_screen_window[ii].visible);
513 if ((ret > 0) || (ret == ICO_UXF_E2BIG)) {
514 if (hs_app_screen_window[ii].visible == 0) {
517 uifw_trace("hs_show_appscreen: move %d=%dx%d(%d,%d)", ii,
518 hs_app_screen_window[ii].resize_w,
519 hs_app_screen_window[ii].resize_h,
520 hs_app_screen_window[ii].move_x, hs_app_screen_window[ii].move_y);
521 /* move application window to application layer */
522 ico_uxf_window_resize(window.window,
523 hs_app_screen_window[ii].resize_w,
524 hs_app_screen_window[ii].resize_h);
525 ico_uxf_window_move(window.window,
526 hs_app_screen_window[ii].move_x,
527 hs_app_screen_window[ii].move_y);
528 ico_uxf_window_show(window.window);
530 ico_uxf_window_layer(window.window, HS_LAYER_APPLICATION);
531 /* show application layer */
532 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_APPLICATION, 1);
535 ico_uxf_window_layer(window.window, appConf->display[0].layerId);
536 /* show application layer */
537 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN,
538 appConf->display[0].layerId, 1);
543 /* hide HomeScreen layer menu */
544 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_HOMESCREEN, 0);
545 /* hide Touch layer */
546 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_TOUCH, 0);
547 /* hide OnScreen windows */
552 idx = hs_get_index_appscreendata(appid);
553 /* if not set pos, load default */
554 appConf = ico_uxf_getAppByAppid(appid);
555 if (appConf != NULL) {
556 int x, y, width, height;
557 (void)ico_uxf_getAppDisplay(appConf, 0, &x, &y, &width, &height);
559 if ((hs_app_screen_window[idx].resize_w == -1)
560 || (hs_app_screen_window[idx].resize_h == -1)) {
561 hs_app_screen_window[idx].resize_w = width;
562 hs_app_screen_window[idx].resize_h = height;
564 if ((hs_app_screen_window[idx].move_x == -1)
565 || (hs_app_screen_window[idx].move_y == -1)) {
566 hs_app_screen_window[idx].move_x = x;
567 hs_app_screen_window[idx].move_y = y;
569 if ((hs_app_screen_window[idx].resize_w == 0)
570 && (hs_app_screen_window[idx].resize_h == 0)
571 && (hs_app_screen_window[idx].move_x == 0)
572 && (hs_app_screen_window[idx].move_y == 0)) {
573 /* not have manifest, set default */
574 ico_uxf_window_screen_size_get(&dispW, &dispH);
575 hs_app_screen_window[idx].resize_w = dispW;
576 hs_app_screen_window[idx].resize_h = (dispH - ICO_HS_SIZE_SB_HEIGHT) / 2;
577 hs_app_screen_window[idx].move_x = 0;
578 hs_app_screen_window[idx].move_y = ICO_HS_SIZE_SB_HEIGHT;
583 ret = ico_uxf_process_window_get(appid, &window, 1);
584 uifw_trace("hs_show_appscreen: window_get app[%s] = %d", appid, ret);
585 if ((ret > 0) || (ret == ICO_UXF_E2BIG)) {
586 uifw_trace("hs_show_appscreen: move %d=%dx%d(%d,%d)", idx,
587 hs_app_screen_window[idx].resize_w,
588 hs_app_screen_window[idx].resize_h,
589 hs_app_screen_window[idx].move_x,
590 hs_app_screen_window[idx].move_y);
591 /* window hide and resize (for animation) */
592 ico_uxf_window_hide(window.window);
593 /* move application window to application layer */
594 ico_uxf_window_resize(window.window,
595 hs_app_screen_window[idx].resize_w,
596 hs_app_screen_window[idx].resize_h);
597 ico_uxf_window_move(window.window,
598 hs_app_screen_window[idx].move_x,
599 hs_app_screen_window[idx].move_y);
601 ico_uxf_window_layer(window.window, HS_LAYER_APPLICATION);
602 /* show application layer */
603 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_APPLICATION, 1);
606 ico_uxf_window_layer(window.window, appConf->display[0].layerId);
607 /* show application layer */
608 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN,
609 appConf->display[0].layerId, 1);
611 ico_uxf_window_raise(window.window);
612 /* activate application window */
613 if ((appConf != NULL) && (appConf->display[0].layerId == HS_LAYER_SOFTKEYBOARD)) {
614 ico_uxf_window_active(window.window, ICO_UXF_WINDOW_POINTER_ACTIVE);
617 ico_uxf_window_active(window.window,
618 ICO_UXF_WINDOW_KEYBOARD_ACTIVE);
620 ico_syc_apc_active(appid);
622 hs_app_screen_window[idx].visible = 1;
623 /* hide HomeScreen layer */
624 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_HOMESCREEN, 0);
625 /* visible application window with animation */
626 ico_uxf_window_visible_animation(window.window, 1);
629 hs_stat_touch = ICO_HS_TOUCH_IN_HIDE;
630 ico_uxf_window_animation_control(0, 1); /* change hide animation to default */
631 ico_uxf_main_loop_iterate();
633 uifw_trace("hs_show_appscreen: Leave");
636 /*--------------------------------------------------------------------------*/
638 * @brief hs_tile_start_apps
639 * launch the default application that indicated by configuration
645 /*--------------------------------------------------------------------------*/
647 hs_tile_start_apps(void)
649 char cName[ICO_UXF_MAX_PROCESS_NAME + 1];
653 const Ico_Uxf_App_Config *appConf;
654 hs_tile_info_t *tinfo;
656 /* excute applications in tile menu */
657 for (idx = 0; idx < hs_tile_cnt; idx++) {
658 tinfo = &hs_tile_info[idx];
659 if (tinfo->valid == 0) continue;
660 sprintf(cName, ICO_HS_CONFIG_TILE_APP"%d", idx);
661 appName = hs_conf_get_string(ICO_HS_CONFIG_HOMESCREEN, cName, NULL);
662 if ((appName != NULL) && (strcmp(appName, "none") != 0)) {
663 ret = ico_uxf_process_execute(appName);
665 uifw_trace("hs_tile_start_apps: execute tile[%d]=%s", idx, appName);
666 memset(tinfo->appid, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
667 strncpy(tinfo->appid, appName, ICO_UXF_MAX_PROCESS_NAME);
672 /* excute no menu applications */
673 appConf = ico_uxf_getAppConfig();
675 for (idx1 = 0; idx1 < appConf->applicationNum; idx1++) {
676 if (appConf->application[idx1].autostart == 0) continue;
677 for (idx2 = 0; idx2 < hs_tile_cnt; idx2++) {
678 if (! strcmp(hs_tile_info[idx2].appid, appConf->application[idx1].appid)) break;
680 if (idx2 >= hs_tile_cnt) {
681 ret = ico_uxf_process_execute(appConf->application[idx1].appid);
683 uifw_trace("hs_tile_start_apps: execute no tile[%d]=%s",
684 idx, appConf->application[idx1].appid);
685 memset(hs_tile_info[idx].appid, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
686 strncpy(hs_tile_info[idx].appid,
687 appConf->application[idx1].appid, ICO_UXF_MAX_PROCESS_NAME);
689 if ((idx - hs_tile_cnt) >= ICO_HS_NOTILE_APP_MAX) break;
693 hs_notile_cnt = idx - hs_tile_cnt;
696 /*--------------------------------------------------------------------------*/
698 * @brief hs_tile_init_info
699 * initialize tile information.
703 * @retval ICO_HS_OK success
704 * @retval ICO_HS_ERR err
706 /*--------------------------------------------------------------------------*/
708 hs_tile_init_info(void)
710 int idx, row, column;
718 int colcnt, rowcnt, tilecnt, tilesize;
720 hs_tile_info_t *tinfo;
723 colcnt = hs_conf_get_integer(ICO_HS_CONFIG_HOMESCREEN,
724 ICO_HS_CONFIG_TILE_COLCNT,
725 ICO_HS_CONFIG_TILE_COLCNT_DEFAULT);
726 rowcnt = hs_conf_get_integer(ICO_HS_CONFIG_HOMESCREEN,
727 ICO_HS_CONFIG_TILE_ROWCNT,
728 ICO_HS_CONFIG_TILE_ROWCNT_DEFAULT);
729 tilecnt = colcnt * rowcnt;
731 /* allocate tile info structure */
732 hs_tile_info = malloc(sizeof(hs_tile_info_t) * (tilecnt + ICO_HS_NOTILE_APP_MAX));
733 valid = (int *)malloc(sizeof(int) * (tilecnt + ICO_HS_NOTILE_APP_MAX));
734 type = (int *)malloc(sizeof(int) * (tilecnt + ICO_HS_NOTILE_APP_MAX));
735 if (!hs_tile_info || !valid || !type) {
736 uifw_warn("hs_tile_init_info: Leave(err malloc tile str failed)");
739 memset(hs_tile_info, 0, sizeof(hs_tile_info_t) * (tilecnt + ICO_HS_NOTILE_APP_MAX));
741 /* get screen size */
742 ico_uxf_window_screen_size_get(&dispW, &dispH);
743 while ((dispW < 0) || (dispH < 0)) {
744 ico_uxf_main_loop_iterate();
747 uifw_warn("hs_tile_init_info: Leave(cannot get screen size)");
751 ico_uxf_window_screen_size_get(&dispW, &dispH);
754 height = dispH - ICO_HS_SIZE_SB_HEIGHT;
756 /* determin tile size (interval the tile is 10 percent of the tile width) */
757 if (((float)width / (float)colcnt) > ((float)height / (float)rowcnt)) {
758 /* tile size based height */
759 tilesize = height / (1.0 * rowcnt + 0.1 * (rowcnt + 1));
760 mSide = (width - (tilesize * colcnt + tilesize * 0.1 * (colcnt + 1)))
765 /* tile size based width */
766 tilesize = width / (1.0 * colcnt + 0.1 * (colcnt + 1));
768 mTop = (height - (tilesize * rowcnt + tilesize * 0.1 * (rowcnt + 1)))
771 uifw_trace("hs_tile_init_info: mSide=%d mTop=%d disp(%dx%d)", mSide, mTop,
774 /* get tile config */
775 sValid = (char *)hs_conf_get_string(ICO_HS_CONFIG_HOMESCREEN,
776 ICO_HS_CONFIG_TILE_VALID, NULL);
777 sType = (char *)hs_conf_get_string(ICO_HS_CONFIG_HOMESCREEN,
778 ICO_HS_CONFIG_TILE_TYPE, NULL);
779 hs_convert_tile_config(sValid, valid, tilecnt, 1);
780 hs_convert_tile_config(sType, type, tilecnt, ICO_HS_TILE_SMALL);
782 /* set tile parameter */
783 for (idx = 0; idx < tilecnt; idx++) {
784 tinfo = &hs_tile_info[idx];
786 column = idx % colcnt;
788 memset(tinfo->appid, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
789 tinfo->valid = valid[idx];
790 tinfo->type = type[idx];
791 if (idx == tilecnt - 1) {
792 tinfo->type = ICO_HS_TILE_OTHERS;
797 tinfo->coord_x = mSide + tilesize * 0.1 + (tilesize + tilesize * 0.1)
799 tinfo->coord_y = mTop + ICO_HS_SIZE_SB_HEIGHT + tilesize * 0.1 + (tilesize
800 + tilesize * 0.1) * row;
801 switch (tinfo->type) {
802 case ICO_HS_TILE_SMALL:
803 tinfo->size_x = tilesize;
804 tinfo->size_y = tilesize;
806 case ICO_HS_TILE_HWIDE:
807 tinfo->size_x = tilesize;
808 tinfo->size_y = tilesize * 2.1;
810 case ICO_HS_TILE_VWIDE:
811 tinfo->size_x = tilesize * 2.1;
812 tinfo->size_y = tilesize;
814 case ICO_HS_TILE_LARGE:
815 tinfo->size_x = tilesize * 2.1;
816 tinfo->size_y = tilesize * 2.1;
819 tinfo->size_x = tilesize;
820 tinfo->size_y = tilesize;
824 uifw_trace("TILE_INFO:tile[%d]={%d,%d,%s,%d,%d,%d,(%dx%d),(%d,%d)}",
825 idx, tinfo->idx, tinfo->valid, tinfo->appid, tinfo->type,
826 tinfo->l_press, tinfo->change, tinfo->size_x, tinfo->size_y,
827 tinfo->coord_x, tinfo->coord_y);
830 hs_tile_cnt = tilecnt;
835 /*--------------------------------------------------------------------------*/
837 * @brief hs_tile_delete_hide
838 * delete hide app information.
840 * @param[in] appid application id
843 /*--------------------------------------------------------------------------*/
845 hs_tile_delete_hide(const char *appid)
848 hs_tile_info_t *tinfo;
849 hs_tile_hide_t *hide, *bhide;
851 for (ii = 0; ii < hs_tile_cnt; ii++) {
852 tinfo = &hs_tile_info[ii];
856 if (strcmp(appid, hide->appid) == 0) {
858 tinfo->next = hide->next;
861 bhide->next = hide->next;
874 /*--------------------------------------------------------------------------*/
876 * @brief hs_tile_free_app
877 * delete all information of the indicated tile.
879 * @param[in] idx tile index
882 /*--------------------------------------------------------------------------*/
884 hs_tile_free_app(int idx)
886 hs_tile_info_t *tinfo;
887 hs_tile_hide_t *hide;
890 if ((idx >= 0) && (idx < hs_tile_cnt)) {
891 tinfo = &hs_tile_info[idx];
894 tinfo->next = hide->next;
895 strncpy(tinfo->appid, hide->appid, ICO_UXF_MAX_PROCESS_NAME);
899 memset(tinfo->appid, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
906 if (strlen(hs_active_onscreen) > 0) {
909 if (hs_regulation_visible == 0) {
913 if ((hs_stat_touch == ICO_HS_TOUCH_IN_SHOW)
914 && (strlen(tinfo->appid) > 0)) {
915 win = hs_get_process_window(tinfo->appid);
917 ico_uxf_window_visible_raise(win, 1, 1);
922 /*--------------------------------------------------------------------------*/
924 * @brief hs_tile_show_screen
925 * show tile screen again.
930 /*--------------------------------------------------------------------------*/
932 hs_tile_show_screen(void)
934 Ico_Uxf_ProcessWin window;
937 hs_tile_info_t *tinfo;
939 if (hs_regulation_visible == 0) {
940 uifw_trace("hs_regulation_visible: regulation, no menu display");
944 /* chnage to menu mode for AppsControler */
945 ico_uxf_window_control(NULL, -1, ICO_UXF_APPSCTL_TEMPVISIBLE, 1);
947 /* all apps invisible */
948 /* hide HomeScreen layer menu */
949 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_HOMESCREEN, 0);
951 /* show application tile */
952 for (idx = 0; idx < hs_tile_cnt; idx++) {
953 tinfo = &hs_tile_info[idx];
954 if (tinfo->appid[0] == 0)
957 ret = ico_uxf_process_window_get(tinfo->appid, &window, 1);
958 uifw_trace("hs_tile_show_screen: window_get app[%s] = %d(%08x)",
959 tinfo->appid, ret, window.window);
960 if (((ret > 0) || (ret == ICO_UXF_E2BIG)) && (window.window != 0)) {
961 uifw_trace("hs_tile_show_screen: move %d=%dx%d(%d,%d)", idx,
962 tinfo->size_x, tinfo->size_y, tinfo->coord_x, tinfo->coord_y);
963 /* move application window to HomeScreen layer */
964 ico_uxf_window_layer(window.window, HS_LAYER_HOMESCREEN);
965 ico_uxf_window_resize(window.window, tinfo->size_x, tinfo->size_y);
966 ico_uxf_window_move(window.window, tinfo->coord_x, tinfo->coord_y);
967 ico_uxf_window_visible_raise(window.window, 1, 1);
971 hs_stat_touch = ICO_HS_TOUCH_IN_SHOW;
972 /* visible and raise touch layer */
973 sid = hs_get_process_window(ICO_HS_APPID_DEFAULT_TOUCH);
975 ico_uxf_window_visible_raise(sid, 1, 1);
977 /* show HomeScreen layer menu */
978 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_HOMESCREEN, 1);
979 /* show Touch layer */
980 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_TOUCH, 1);
981 /* hide application layer */
982 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_APPLICATION, 0);
984 ico_uxf_main_loop_iterate();
987 /*--------------------------------------------------------------------------*/
989 * @brief hs_tile_get_index_app
990 * Get tile index that has indicated application id.
992 * @param[in] appid application id
994 * @retval >=0 tile index
995 * @retval -1 not exist
997 /*--------------------------------------------------------------------------*/
999 hs_tile_get_index_app(const char *appid)
1002 hs_tile_info_t *tinfo;
1004 for (idx = 0; idx < hs_tile_cnt; idx++) {
1005 tinfo = &hs_tile_info[idx];
1006 if (strncmp(tinfo->appid, appid, ICO_UXF_MAX_PROCESS_NAME) == 0) {
1014 /*--------------------------------------------------------------------------*/
1016 * @brief hs_tile_get_minchange
1017 * Get a application tile index that has no application
1018 * or is changed minimum
1022 * @retval >= success(tile index)
1025 /*--------------------------------------------------------------------------*/
1027 hs_tile_get_minchange(void)
1032 hs_tile_info_t *tinfo;
1034 for (ii = 0; ii < hs_tile_cnt; ii++) {
1035 tinfo = &hs_tile_info[ii];
1036 if ((tinfo->type > ICO_HS_TILE_OTHERS) && ((tinfo->change <= min)
1039 min = tinfo->change;
1041 if ((tinfo->type > ICO_HS_TILE_OTHERS) && (strlen(tinfo->appid) == 0)) {
1049 /*--------------------------------------------------------------------------*/
1051 * @brief hs_tile_kill_app
1052 * terminate the indicated application, and free the tile
1053 * that have the application.
1055 * @param[in] appid application id
1058 /*--------------------------------------------------------------------------*/
1060 hs_tile_kill_app(const char *appid)
1064 idx = hs_tile_get_index_app(appid);
1066 ret = ico_uxf_process_terminate(appid);
1067 if (ret == ICO_UXF_EOK) {
1069 hs_tile_free_app(idx);
1072 hs_tile_delete_hide(appid);
1079 /*--------------------------------------------------------------------------*/
1081 * @brief hs_tile_get_index_pos
1082 * get the tile index of the position.
1084 * @param[in] appid application id
1085 * @return tile index
1086 * @retval >=0 success
1087 * @retval ICO_HS_ERR error
1089 /*--------------------------------------------------------------------------*/
1091 hs_tile_get_index_pos(int x, int y, int w, int h)
1094 hs_tile_info_t *tinfo;
1096 for (idx = 0; idx < hs_tile_cnt; idx++) {
1097 tinfo = &hs_tile_info[idx];
1098 if ((tinfo->coord_x == x) && (tinfo->coord_y == y) && (tinfo->size_x
1099 == w) && (tinfo->size_y == h)) {
1107 /*--------------------------------------------------------------------------*/
1109 * @brief hs_tile_set_app
1110 * set the applicaton to the tile of the indicated index.
1112 * @param[in] idx tile index
1113 * @param[in] appid application id
1116 /*--------------------------------------------------------------------------*/
1118 hs_tile_set_app(int idx, const char *appid)
1120 hs_tile_info_t *tinfo;
1121 hs_tile_hide_t *search, *bsearch, *hide = NULL;
1124 uifw_trace("hs_tile_set_app: Enter(idx=%d appid=%s)", idx, appid);
1126 if ((idx < 0) && (idx >= hs_tile_cnt)) {
1130 /* check whether the app is same as tile one */
1131 tinfo = &hs_tile_info[idx];
1132 if (strcmp(tinfo->appid, appid) == 0) {
1136 /* check whether the app is hide */
1137 for (ii = 0; ii < hs_tile_cnt; ii++) {
1138 tinfo = &hs_tile_info[ii];
1139 if (tinfo->valid == 0) continue;
1140 search = tinfo->next;
1143 if (strcmp(search->appid, appid) == 0) {
1146 tinfo->next = search->next;
1149 bsearch->next = search->next;
1154 search = search->next;
1162 tinfo = &hs_tile_info[idx];
1163 if (tinfo->valid > 0) {
1164 if (strlen(tinfo->appid) != 0) {
1165 int oldwin = hs_get_process_window(tinfo->appid);
1167 (void) ico_uxf_window_hide(oldwin);
1171 hide = malloc(sizeof(hs_tile_hide_t));
1174 uifw_warn("hs_tile_set_app: cannot allocate app table");
1177 memset(hide, 0, sizeof(hs_tile_hide_t));
1178 strncpy(hide->appid, tinfo->appid, ICO_UXF_MAX_PROCESS_NAME);
1180 hide->next = tinfo->next;
1189 strncpy(tinfo->appid, appid, ICO_UXF_MAX_PROCESS_NAME);
1194 /*--------------------------------------------------------------------------*/
1196 * @brief hs_get_process_window
1197 * get window surface from applicatoin id including special id.
1199 * @param[in] appid application id
1201 * @retval >=0 surface
1202 * @retval -1 not exist
1204 /*--------------------------------------------------------------------------*/
1206 hs_get_process_window(const char *appid)
1208 Ico_Uxf_ProcessWin wins[2];
1211 if (strcmp(appid, ICO_HS_APPID_DEFAULT_TOUCH) == 0) {
1212 ret = ico_uxf_process_window_get(hs_name_homescreen, wins, 2);
1213 if ((ret > 1) || (ret == ICO_UXF_E2BIG)) {
1214 return wins[1].window;
1218 ret = ico_uxf_process_window_get(appid, wins, 1);
1219 if ((ret > 0) || (ret == ICO_UXF_E2BIG)) {
1220 return wins[0].window;
1227 /*--------------------------------------------------------------------------*/
1229 * @brief hs_show_onscreen
1230 * set onscreen window to visible.
1235 /*--------------------------------------------------------------------------*/
1237 hs_show_onscreen(void)
1239 Ico_Uxf_ProcessWin window;
1242 ret = ico_uxf_process_window_get(ICO_HS_APPID_DEFAULT_ONS, &window, 1);
1244 if ((ret > 0) || (ret == ICO_UXF_E2BIG)) {
1245 ico_uxf_window_layer(window.window, HS_LAYER_ONSCREEN);
1249 /*--------------------------------------------------------------------------*/
1251 * @brief hs_hide_onscreen
1252 * set onscreen window to invisible.
1257 /*--------------------------------------------------------------------------*/
1259 hs_hide_onscreen(void)
1261 Ico_Uxf_ProcessWin window;
1264 ret = ico_uxf_process_window_get(ICO_HS_APPID_DEFAULT_ONS, &window, 1);
1266 if ((ret > 0) || (ret == ICO_UXF_E2BIG)) {
1267 ico_uxf_window_layer(window.window, HS_LAYER_BACKGROUND);
1268 ico_uxf_window_lower(window.window);
1272 /*--------------------------------------------------------------------------*/
1274 * @brief hs_click_escutcheon
1275 * processing when escutcheon button is clicked.
1280 /*--------------------------------------------------------------------------*/
1282 hs_click_escutcheon(void)
1284 uifw_trace("hs_click_escutcheon: Enter(regulation=%d)", hs_regulation_visible);
1286 if (strlen(hs_active_onscreen) > 0) {
1287 uifw_trace("hs_click_escutcheon: Leave(active=%s)", hs_active_onscreen);
1290 if (hs_regulation_visible == 0) {
1291 uifw_trace("hs_click_escutcheon: Leave(regulation)");
1295 if (hs_stat_touch == ICO_HS_TOUCH_IN_SHOW) {
1296 hs_snd_play(hs_snd_get_filename(ICO_HS_SND_TYPE_DEFAULT));
1297 uifw_trace("hs_click_escutcheon: hs_show_appscreen");
1298 hs_show_appscreen(NULL);
1300 else if (hs_stat_touch == ICO_HS_TOUCH_IN_HIDE) {
1301 hs_snd_play(hs_snd_get_filename(ICO_HS_SND_TYPE_DEFAULT));
1302 uifw_trace("hs_click_escutcheon: hs_tile_show_screen");
1303 hs_tile_show_screen();
1305 uifw_trace("hs_click_escutcheon: Leave");
1309 /*--------------------------------------------------------------------------*/
1311 * @brief hs_click_applist
1312 * processing when application list button is clicked.
1315 * @return regulation
1316 * @retval =0 regulation controlled(no display)
1317 * @retval =1 no regulation
1319 /*--------------------------------------------------------------------------*/
1321 hs_click_applist(void)
1323 uifw_trace("hs_click_applist: Enter(regulation=%d)", hs_regulation_visible);
1325 if (hs_regulation_visible == 0) {
1326 uifw_trace("hs_click_applist: Leave(regulation)");
1330 /* operation sound */
1331 hs_snd_play(hs_snd_get_filename(ICO_HS_SND_TYPE_DEFAULT));
1332 uifw_trace("hs_click_applist: Leave");
1334 /* show Touch layer */
1335 ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_TOUCH, 1);
1336 /* show OnScreen windows */
1342 /*--------------------------------------------------------------------------*/
1344 * @brief hs_is_special_app
1345 * return 1 if the application is special one(homescreen)
1346 * /statusbar/onscreen).
1348 * @param[in] appid applicationId
1349 * @return special application
1350 * @retval 1 special application(HomeScreen/StatusBar ... etc)
1351 * @retval 0 normal application
1353 /*--------------------------------------------------------------------------*/
1355 hs_is_special_app(const char *appid)
1357 if ((strncmp(appid, hs_name_homescreen, ICO_UXF_MAX_PROCESS_NAME) == 0)
1358 || (strncmp(appid, gStatusbarName, ICO_UXF_MAX_PROCESS_NAME) == 0)
1359 || (strncmp(appid, gOnscreenName, ICO_UXF_MAX_PROCESS_NAME) == 0)
1360 || (strncmp(appid, ICO_HS_APPID_DEFAULT_TOUCH,
1361 ICO_UXF_MAX_PROCESS_NAME) == 0)) {
1362 uifw_trace("hs_is_special_app: app(%s) is special", appid);
1365 uifw_trace("hs_is_special_app: app(%s) is normal", appid);
1369 /*--------------------------------------------------------------------------*/
1371 * @brief hs_is_noicon_app
1372 * return 1 if the application has no menu icon
1374 * @param[in] appid applicationId
1375 * @return no need menu
1376 * @retval 1 no need menu
1377 * @retval 0 need menu
1379 /*--------------------------------------------------------------------------*/
1381 hs_is_noicon_app(const char *appid)
1383 const Ico_Uxf_conf_application *appConf;
1385 appConf = ico_uxf_getAppByAppid(appid);
1387 uifw_trace("hs_is_noicon_app: appid(%s) dose not exist", appid);
1391 if (appConf->noicon) {
1392 uifw_trace("hs_is_noicon_app: appid(%s) has no icon", appid);
1395 uifw_trace("hs_is_noicon_app: appid(%s) has icon", appid);
1399 /*--------------------------------------------------------------------------*/
1401 * @brief hs_terminate_all_app
1402 * terminate all application that homescreen handled
1407 /*--------------------------------------------------------------------------*/
1409 hs_terminate_all_app(void)
1411 Ico_Uxf_ProcessAttr procs[ICO_HS_APP_NUM_MAX];
1415 cnt = ico_uxf_process_query_processes(procs, ICO_HS_APP_NUM_MAX);
1416 if (cnt == ICO_UXF_E2BIG)
1417 cnt = ICO_HS_APP_NUM_MAX;
1418 uifw_trace("hs_terminate_all_app: ico_uxf_process_query_processes() = %d",
1420 for (ii = 0; ii < cnt; ii++) {
1421 if (hs_is_special_app(procs[ii].process))
1423 uifw_trace("hs_terminate_all_app: terminate(%s)", procs[ii].process);
1424 ico_uxf_process_terminate(procs[ii].process);
1426 ico_uxf_process_terminate(gStatusbarName);
1427 ico_uxf_process_terminate(gOnscreenName);
1430 /*--------------------------------------------------------------------------*/
1432 * @brief hs_req_ctlr_tile
1433 * processing when homescreen received json command from extra
1439 /*--------------------------------------------------------------------------*/
1441 hs_req_ctlr_tile(void)
1446 for (ii = 0; ii < ICO_HS_APP_NUM_MAX; ii++) {
1447 if ((hs_command_tile_req[ii].appid[0] == 0)
1448 || (hs_is_special_app(hs_command_tile_req[ii].appid) == TRUE)) {
1452 idx = hs_tile_get_index_app(hs_command_tile_req[ii].appid);
1455 if (hs_command_tile_req[ii].terminate != IGNORE) {
1456 ret = ico_uxf_process_terminate(hs_command_tile_req[ii].appid);
1457 if (ret == ICO_UXF_EOK) {
1459 hs_tile_free_app(idx);
1465 if (strlen(hs_command_tile_req[ii].exe_name) > 0) {
1466 ico_uxf_process_execute(hs_command_tile_req[ii].exe_name);
1469 hs_tile_show_screen();
1472 /*--------------------------------------------------------------------------*/
1474 * @brief hs_touch_up_api_list
1475 * processing when application list button touch up.
1480 /*--------------------------------------------------------------------------*/
1482 hs_touch_up_api_list(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1484 int idx = *(int *)data;
1485 char buf[ICO_HS_TEMP_BUF_SIZE];
1486 char path[ICO_HS_TEMP_BUF_SIZE];
1487 hs_tile_info_t *tinfo;
1489 tinfo = &hs_tile_info[idx];
1492 hs_get_image_path(path, sizeof(path));
1493 sprintf(buf, "%s"fname_api_all_off, path);
1494 evas_object_image_file_set(obj, buf, NULL);
1495 /* move and resize in the image */
1496 evas_object_move(obj, tinfo->coord_x, tinfo->coord_y - ICO_HS_SIZE_SB_HEIGHT);
1497 evas_object_resize(obj, tinfo->size_x, tinfo->size_y);
1498 /* show the image */
1499 evas_object_show(obj);
1501 uifw_trace("hs_touch_up_api_list: idx=%d", idx);
1502 strncpy(hs_active_onscreen, ICO_UXF_PROC_DEFAULT_HOMESCREEN,
1503 sizeof(hs_active_onscreen));
1504 hs_get_ons_edj_path(path, sizeof(path));
1505 sprintf(buf, "OPEN %s%s %s", path, ICO_HS_ONS_APPLI_LIST_NAME,
1506 ICO_UXF_PROC_DEFAULT_HOMESCREEN);
1507 uifw_trace("send '%s' to onscreen", buf);
1508 if (hs_lib_event_message(ICO_HS_PROTOCOL_TYPE_OS, buf) < 0) {
1509 memset(hs_active_onscreen, 0, sizeof(hs_active_onscreen));
1511 hs_snd_play(hs_snd_get_filename(ICO_HS_SND_TYPE_DEFAULT));
1514 /*--------------------------------------------------------------------------*/
1516 * @brief hs_touch_down_api_list
1517 * processing when application list button touch down.
1522 /*--------------------------------------------------------------------------*/
1524 hs_touch_down_api_list(void *data, Evas *evas, Evas_Object *obj,
1527 int idx = *(int *)data;
1528 char buf[ICO_HS_TEMP_BUF_SIZE];
1529 char path[ICO_HS_TEMP_BUF_SIZE];
1530 hs_tile_info_t *tinfo;
1532 tinfo = &hs_tile_info[idx];
1535 hs_get_image_path(path, sizeof(path));
1536 sprintf(buf, "%s"fname_api_all_off, path);
1537 evas_object_image_file_set(obj, buf, NULL);
1538 /* move and resize in the image */
1539 evas_object_move(obj, tinfo->coord_x, tinfo->coord_y - ICO_HS_SIZE_SB_HEIGHT);
1540 evas_object_resize(obj, tinfo->size_x, tinfo->size_y);
1541 /* show the image */
1542 evas_object_show(obj);
1545 /*--------------------------------------------------------------------------*/
1547 * @brief hs_ecore_timer_event
1548 * handler called when applicaton tile is pushed long term
1549 * to terminate application.
1551 * @param[in] data user data
1553 * @retval ECORE_CALLBACK_CANCEL
1554 * delete this handler
1556 /*--------------------------------------------------------------------------*/
1558 hs_ecore_timer_event(void *data)
1560 int idx = *(int *)data;
1561 char buf[ICO_HS_TEMP_BUF_SIZE];
1562 char tmp[ICO_HS_TEMP_BUF_SIZE];
1563 hs_tile_info_t *tinfo;
1565 tinfo = &hs_tile_info[idx];
1566 if (tinfo->l_press == 1) {
1569 /* set terminate app id for onscrAppliKill */
1570 if (strlen(tinfo->appid) != 0) {
1571 strncpy(hs_kill_appid, tinfo->appid, sizeof(hs_kill_appid));
1572 uifw_trace("hs_ecore_timer_event :hs_kill_appid = %s", hs_kill_appid);
1573 strncpy(hs_active_onscreen, ICO_UXF_PROC_DEFAULT_HOMESCREEN,
1574 sizeof(hs_active_onscreen));
1575 sprintf(buf, "OPEN HomeScreen/src/appli_kill.edj %s",
1576 ICO_UXF_PROC_DEFAULT_HOMESCREEN);
1577 hs_get_ons_edj_path(tmp, sizeof(tmp));
1578 sprintf(buf, "OPEN %s%s %s", tmp, ICO_HS_ONS_APPLI_KILL_NAME,
1579 ICO_UXF_PROC_DEFAULT_HOMESCREEN);
1580 uifw_trace("hs_ecore_timer_event: send %s to onscreen", buf);
1581 hs_lib_event_message(ICO_HS_PROTOCOL_TYPE_OS, buf);
1584 return ECORE_CALLBACK_CANCEL;
1587 /*--------------------------------------------------------------------------*/
1589 * @brief hs_touch_up_tile
1590 * processing when application tile button touch up.
1592 * @param[in] data user data
1593 * @param[in] obj evas object of the button
1594 * @param[in] event_info evas event infomation
1597 /*--------------------------------------------------------------------------*/
1599 hs_touch_up_tile(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1601 int idx = *(int *)data;
1604 hs_tile_info_t *tinfo;
1606 uifw_trace("hs_touch_up_tile: idx=%d", idx);
1608 if (strlen(hs_active_onscreen) != 0) {
1609 uifw_trace("hs_touch_up_tile: active=%s", hs_active_onscreen);
1613 tinfo = &hs_tile_info[idx];
1614 if (tinfo->l_press == 1) {
1617 /* send a message to extra tools */
1618 if (strlen(tinfo->appid) != 0) {
1619 sprintf(buf, "FOCUS %s", tinfo->appid);
1620 uifw_trace("hs_touch_up_tile: send '%s' to extra tools", buf);
1621 ret = hs_lib_event_message(ICO_HS_PROTOCOL_TYPE_CM, buf);
1623 hs_show_appscreen(tinfo->appid);
1625 hs_snd_play(hs_snd_get_filename(ICO_HS_SND_TYPE_DEFAULT));
1631 /*--------------------------------------------------------------------------*/
1633 * @brief hs_touch_down_tile
1634 * processing when application tile button touch down.
1636 * @param[in] data user data
1637 * @param[in] obj evas object of the button
1638 * @param[in] event_info evas event infomation
1641 /*--------------------------------------------------------------------------*/
1643 hs_touch_down_tile(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1645 int idx = *(int *)data;
1646 hs_tile_info_t *tinfo;
1648 uifw_trace("hs_touch_down_tile: idx=%d", idx);
1650 tinfo = &hs_tile_info[idx];
1652 if (strlen(tinfo->appid) != 0) {
1655 if (tinfo->type > ICO_HS_TILE_OTHERS) {
1656 /* add timer to detect long push */
1657 ecore_timer_add(ICO_HS_TOUCH_TIME_OUT, hs_ecore_timer_event, &tinfo->idx);
1661 /*--------------------------------------------------------------------------*/
1663 * @brief hs_add_bg_image
1664 * add image to background. if config does not have image file or
1665 * image file is not exsit, background show default edj.
1667 * @param[in] canvas_bg evas of background
1670 /*--------------------------------------------------------------------------*/
1672 hs_add_bg_image(Evas *canvas_bg)
1674 char img[ICO_HS_TEMP_BUF_SIZE];
1675 char path[ICO_HS_TEMP_BUF_SIZE];
1677 Evas_Object *canvas;
1678 Evas_Load_Error err;
1681 fname = (char *)hs_conf_get_string(ICO_HS_CONFIG_HOMESCREEN,
1682 ICO_HS_CONFIG_BG, NULL);
1684 uifw_trace("hs_add_bg_image: backgound config is not exist");
1687 if (fname[0] == '/') {
1688 snprintf(img, sizeof(img), "%s", fname);
1691 hs_get_image_path(path, sizeof(path));
1692 snprintf(img, sizeof(img), "%s/%s", path, fname);
1695 ico_uxf_window_screen_size_get(&dispW, &dispH);
1697 canvas = evas_object_image_filled_add(canvas_bg);
1698 evas_object_image_file_set(canvas, img, NULL);
1699 err = evas_object_image_load_error_get(canvas);
1700 if (err != EVAS_LOAD_ERROR_NONE) {
1701 uifw_trace("hs_add_bg_image: backgound image is not exist");
1704 evas_object_image_fill_set(canvas, 0, 0, dispW, dispH - ICO_HS_SIZE_SB_HEIGHT);
1705 evas_object_resize(canvas, dispW, dispH - ICO_HS_SIZE_SB_HEIGHT);
1706 evas_object_show(canvas);
1712 /*--------------------------------------------------------------------------*/
1714 * @brief hs_add_touch_listener
1715 * make and add listener to application tile button.
1717 * @param[in] canvas_fg evas of tile screen
1720 /*--------------------------------------------------------------------------*/
1722 hs_add_touch_listener(Evas *canvas_fg)
1725 char img[ICO_HS_TEMP_BUF_SIZE];
1726 char path[ICO_HS_TEMP_BUF_SIZE];
1727 Evas_Object * canvas;
1728 hs_tile_info_t *tinfo;
1730 /* set image path */
1731 hs_get_image_path(path, sizeof(path));
1732 sprintf(img, "%s"fname_api_all_off, path);
1735 for (idx = 0; idx < hs_tile_cnt; idx++) {
1736 tinfo = &hs_tile_info[idx];
1737 if (tinfo->valid == 0)
1739 /* Creates a reclangle */
1740 canvas = evas_object_rectangle_add(canvas_fg);
1741 /* Set a color or image */
1742 evas_object_color_set(canvas, 0, 0, 0, 0);
1743 /* Move and resize the rectangle */
1744 evas_object_move(canvas, tinfo->coord_x, tinfo->coord_y - ICO_HS_SIZE_SB_HEIGHT);
1745 evas_object_resize(canvas, tinfo->size_x, tinfo->size_y);
1746 /* add event the rectangle */
1747 evas_object_event_callback_add(canvas, EVAS_CALLBACK_MOUSE_UP,
1748 hs_touch_up_tile, &tinfo->idx);
1749 evas_object_event_callback_add(canvas, EVAS_CALLBACK_MOUSE_DOWN,
1750 hs_touch_down_tile, &tinfo->idx);
1751 /* show the rectangle */
1752 evas_object_show(canvas);
1754 /* application menu icon */
1755 tinfo = &hs_tile_info[hs_tile_cnt - 1];
1756 if ((tinfo->valid == 0) && (tinfo->type == ICO_HS_TILE_APPLIST)) {
1757 canvas = evas_object_image_filled_add(canvas_fg);
1758 evas_object_image_file_set(canvas, img, NULL);
1759 evas_object_move(canvas, tinfo->coord_x, tinfo->coord_y - ICO_HS_SIZE_SB_HEIGHT);
1760 evas_object_resize(canvas, tinfo->size_x, tinfo->size_y);
1761 evas_object_event_callback_add(canvas, EVAS_CALLBACK_MOUSE_UP,
1762 hs_touch_up_api_list, &tinfo->idx);
1763 evas_object_event_callback_add(canvas, EVAS_CALLBACK_MOUSE_DOWN,
1764 hs_touch_down_api_list, &tinfo->idx);
1765 evas_object_show(canvas);
1769 /*--------------------------------------------------------------------------*/
1771 * @brief hs_create_window
1772 * create background and tile screen window of ecore.
1774 * @param[in] type background or tile screen
1777 /*--------------------------------------------------------------------------*/
1779 hs_create_window(int type)
1782 Ecore_Evas * window;
1786 char path[ICO_HS_TEMP_BUF_SIZE];
1787 char edjfile[ICO_HS_TEMP_BUF_SIZE];
1789 window = ecore_evas_new(NULL, 0, 0, 1, 1, "frame=0");
1791 ecore_main_loop_iterate();
1792 ico_uxf_window_screen_size_get(&dispW, &dispH);
1794 height = dispH - ICO_HS_SIZE_SB_HEIGHT;
1797 uifw_warn("HomeScreen: could not create window.");
1801 canvas = ecore_evas_get(window);
1802 edje = edje_object_add(canvas);
1803 /* NULL is aborted */
1805 uifw_warn("HomeScreen: could not create edje object!");
1809 hs_get_edj_path(path, sizeof(path));
1811 if (type == ICO_HS_WINDOW_TYPE_BG) {
1812 ecore_evas_move(window, 0, 0);
1813 ecore_evas_resize(window, width, height);
1814 ecore_evas_show(window);
1816 int err = edje_object_load_error_get(edje);
1817 const char *errmsg = edje_load_error_str(err);
1818 sprintf(edjfile, "%s/home_screen_bg.edj", path);
1819 if (!edje_object_file_set(edje, edjfile, "home_screen_bg")) {
1821 "HomeScreen: could not load 'home_screen_bg' from %s: %s",
1823 evas_object_del(edje);
1827 evas_object_move(edje, 0, 0);
1828 evas_object_resize(edje, width, height);
1829 evas_object_show(edje);
1831 hs_add_bg_image(canvas);
1834 ecore_evas_move(window, 0, 0);
1835 ecore_evas_resize(window, width, height);
1836 ecore_evas_alpha_set(window, EINA_TRUE);
1837 ecore_evas_show(window);
1839 int err = edje_object_load_error_get(edje);
1840 const char *errmsg = edje_load_error_str(err);
1841 sprintf(edjfile, "%s/home_screen_touch.edj", path);
1842 if (!edje_object_file_set(edje, edjfile, "home_screen_touch")) {
1844 "HomeScreen: could not load 'home_screen_touch' from %s: %s",
1846 evas_object_del(edje);
1850 evas_object_move(edje, 0, 0);
1851 evas_object_resize(edje, width, height);
1852 evas_object_show(edje);
1854 hs_add_touch_listener(canvas);
1860 /*--------------------------------------------------------------------------*/
1862 * @brief hs_display_control
1865 * @param[in] conf configuration
1866 * @param[in] show show
1869 /*--------------------------------------------------------------------------*/
1871 hs_display_control(const Ico_Uxf_conf_application *conf, const int show)
1873 uifw_trace("hs_display_control: app=%s show=%d", conf->appid, show);
1874 /* no need, because all control in AppsController */
1877 /*--------------------------------------------------------------------------*/
1879 * @brief hs_sound_control
1882 * @param[in] conf configuration
1883 * @param[in] adjust adjust
1886 /*--------------------------------------------------------------------------*/
1888 hs_sound_control(const Ico_Uxf_conf_application *conf, const int adjust)
1890 uifw_trace("hs_sound_control: app=%s adjust=%d", conf->appid, adjust);
1891 /* no need, because all control in AppsController */
1894 /*--------------------------------------------------------------------------*/
1896 * @brief hs_input_control
1899 * @param[in] conf configuration
1900 * @param[in] inputsw input switch
1903 /*--------------------------------------------------------------------------*/
1905 hs_input_control(const Ico_Uxf_conf_application *conf, const int inputsw)
1907 uifw_trace("hs_input_control: app=%s inputsw=%d", conf->appid, inputsw);
1908 /* no need, because all control in AppsController */
1911 /*--------------------------------------------------------------------------*/
1913 * @brief hs_regulation_listener: change regulation callback(static function)
1915 * @param[in] appcategory category Id
1916 * @param[in] control control(display/sound/input active/inactive)
1917 * @param[in] user_data user data(unused)
1920 /*--------------------------------------------------------------------------*/
1922 hs_regulation_listener(const int appcategory,
1923 const ico_apc_reguration_control_t control, void *user_data)
1925 if ((appcategory == hs_regulation_category) &&
1926 (control.display != ICO_SYC_APC_REGULATION_NOCHANGE)) {
1927 uifw_trace("hs_regulation_listener: Enter(category=%d disp=%d)",
1928 appcategory, control.display);
1930 if (control.display == ICO_SYC_APC_REGULATION_REGULATION) {
1931 /* Invisible by reguration */
1932 if (hs_regulation_visible) {
1933 hs_regulation_visible = 0;
1934 if (hs_stat_touch == ICO_HS_TOUCH_IN_SHOW) {
1935 uifw_trace("hs_regulation_listener: Change to App screen");
1936 hs_show_appscreen(NULL);
1939 memset(hs_active_onscreen, 0, sizeof(hs_active_onscreen));
1944 uifw_trace("hs_regulation_listener: Change to ALl screen");
1945 hs_regulation_visible = 1;
1950 /*--------------------------------------------------------------------------*/
1953 * homescreen main. initialize UXF, app manager, and ecore.
1955 * @param[in] argc counts of argment
1956 * @param[in] argv argment
1958 * @retval >=0 success
1961 /*--------------------------------------------------------------------------*/
1963 main(int argc, char *argv[])
1971 printf("main: %s: %s", getenv("HOME"), getenv("PKG_NAME"));
1972 pkg = getenv("PKG_NAME");
1973 memset(hs_name_homescreen, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
1975 strncpy(hs_name_homescreen, pkg, ICO_UXF_MAX_PROCESS_NAME);
1978 strncpy(hs_name_homescreen, ICO_UXF_PROC_DEFAULT_HOMESCREEN,
1979 ICO_UXF_MAX_PROCESS_NAME);
1981 strncpy(gStatusbarName,
1982 (char *)hs_conf_get_string(ICO_HS_CONFIG_HOMESCREEN,
1984 ICO_HS_APPID_DEFAULT_SB),
1985 ICO_UXF_MAX_PROCESS_NAME);
1986 strncpy(gOnscreenName,
1987 (char *)hs_conf_get_string(ICO_HS_CONFIG_HOMESCREEN,
1989 ICO_HS_APPID_DEFAULT_ONS),
1990 ICO_UXF_MAX_PROCESS_NAME);
1993 /* init for window mgr */
1994 ret = ico_uxf_init(hs_name_homescreen);
1995 if (ret != ICO_UXF_EOK) {
1996 uifw_error("ico_uxf_init err=%d", ret);
1999 ico_uxf_callback_set(ICO_UXF_EVENT_ALL, hs_uxf_event, 0);
2000 memset(hs_app_screen_window, 0, sizeof(hs_app_screen_window));
2001 for (ii = 0; ii < ICO_HS_APP_NUM_MAX; ii++) {
2002 hs_app_screen_window[ii].resize_w = -1;
2003 hs_app_screen_window[ii].resize_h = -1;
2004 hs_app_screen_window[ii].move_x = -1;
2005 hs_app_screen_window[ii].move_y = -1;
2007 ico_uxf_main_loop_iterate();
2009 /* init tile info */
2010 ret = hs_tile_init_info();
2012 uifw_warn("hs_tile_init_info err=%d", ret);
2015 /* start onscreen & statusbar apps */
2016 ret = ico_uxf_process_execute(gOnscreenName);
2018 uifw_warn("ico_uxf_process_execute(%s) err=%d", gOnscreenName, ret);
2020 ret = ico_uxf_process_execute(gStatusbarName);
2022 uifw_warn("ico_uxf_process_execute(%s) err=%d", gStatusbarName, ret);
2024 ico_uxf_main_loop_iterate();
2030 /* for communicate other process */
2031 port = hs_conf_get_integer(ICO_HS_CONFIG_HOMESCREEN,
2032 ICO_HS_CONFIG_WS_PORT,
2036 /* initialize Application Controller */
2037 ret = ico_syc_apc_init(hs_display_control, hs_sound_control, hs_input_control);
2038 if (ret != ICO_SYC_EOK) {
2039 uifw_error("ico_syc_apc_init err=%d", ret);
2042 /* start default tile apps */
2043 hs_tile_start_apps();
2044 ico_uxf_main_loop_iterate();
2046 /* HomeScreen Menu(background) */
2047 hs_create_window(ICO_HS_WINDOW_TYPE_BG);
2048 /* add callbacks for wayland(wl_window_mgr) */
2049 ecore_main_fd_handler_add(ico_uxf_wl_display_fd(), ECORE_FD_READ,
2050 hs_ecore_uxf_eventfd, NULL, /* data */
2052 ecore_main_loop_iterate();
2053 ico_uxf_main_loop_iterate();
2055 /* HomeScreen Menu(touch) */
2056 hs_create_window(ICO_HS_WINDOW_TYPE_TOUCH);
2058 /* initiailze regulation control */
2059 hs_regulation_category = ico_uxf_getSysCategoryByName("CarSetting");
2060 ico_syc_apc_regulation_listener(hs_regulation_listener, NULL);
2062 if (hs_regulation_visible) {
2063 uifw_trace("main: no regulation");
2064 hs_tile_show_screen();
2067 uifw_trace("main: regulation");
2068 hs_show_appscreen(NULL);
2071 /* add callback to app configuration */
2072 ico_uxf_econf_setAppUpdateCb(NULL);
2075 ecore_main_loop_begin();
2077 /* terminate Application Controller */
2078 (void) ico_syc_apc_term();
2080 /* terminate all known application */
2081 hs_terminate_all_app();
2085 ecore_evas_shutdown();