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 onscreen application
19 #include <Ecore_Wayland.h>
20 #include <Ecore_Evas.h>
24 #include "ico_uxf_conf.h"
25 #include "ico_uxf_conf_ecore.h"
27 #include "home_screen.h"
28 #include "home_screen_res.h"
29 #include "home_screen_conf.h"
31 #include <libwebsockets.h>
33 /*============================================================================*/
34 /* Define data types */
35 /*============================================================================*/
36 #define ICO_ONS_WS_TIMEOUT 0.1
37 #define ICO_ONS_WS_ADDRESS "127.0.0.1"
38 #define ICO_ONS_WS_PROTOCOL_NAME ICO_HS_PROTOCOL_OS
39 #define ICO_ONS_BUF_SIZE (1024)
40 #define ICO_ONS_APPLI_NUM (15) /* only for applist */
42 #define ICO_ONS_VERTICAL (1)
43 #define ICO_ONS_HORIZONTAL (2)
45 #define ICO_ONS_CMD_WAIT (1)
46 #define ICO_ONS_NO_WAIT (2)
48 typedef struct _ons_msg ons_msg_t;
55 /*============================================================================*/
56 /* static(internal) functions prototype */
57 /*============================================================================*/
58 static int ons_loadinons_edje_file(const char *edje_file);
59 static void ons_event_message(char *format, ...);
60 static ons_msg_t *ons_alloc_seendmsg(char *data, int len);
61 static ons_msg_t *ons_get_sendmsg(void);
62 static int ons_put_sendmsg(ons_msg_t *send);
63 static char *ons_edje_parse_str(void *in, int arg_num);
64 static int ons_callback_http(
65 struct libwebsocket_context *context, struct libwebsocket *wsi,
66 enum libwebsocket_callback_reasons reason, void *user, void *in,
68 static int ons_callback_onscreen(
69 struct libwebsocket_context *context,
70 struct libwebsocket *wsi,
71 enum libwebsocket_callback_reasons reason, void *user,
72 void *in, size_t len);
73 static void ons_create_context(void);
74 static Eina_Bool ons_ecore_event(void *data);
75 static void ons_on_destroy(Ecore_Evas *ee);
76 static void ons_touch_up_edje(void *data, Evas *evas,
77 Evas_Object *obj, void *event_info);
78 static void ons_touch_up_next(void *data, Evas *evas, Evas_Object *obj,
80 static const char *ons_get_fname(const char *filepath);
81 static int ons_get_appindex(int idx);
82 static void ons_set_appicon(Evas *evas, Evas_Object *edje, Evas_Object* part,
83 const char *partname);
84 static void ons_load_config(void);
85 static void ons_config_event(const char *appid, int type);
87 /*============================================================================*/
89 /*============================================================================*/
90 static int ons_ws_port = ICO_HS_WS_PORT;
91 static int ons_ws_connected = 0;
92 static struct libwebsocket_context *ons_ws_context = NULL;
93 static struct libwebsocket *ons_wsi_mirror = NULL;
94 static char ons_edje_str[ICO_ONS_BUF_SIZE];
96 static Ecore_Evas *ons_window; /* ecore-evas object */
97 static Evas *ons_evas = NULL; /* evas object */
98 static Evas_Object *ons_edje = NULL; /* loaded edje objects */
99 static Eina_List *ons_img_list = NULL;
100 static int ons_width, ons_height;
101 static int ons_applist_idx = 0; /* only for applist, it's index */
102 static int ons_app_cnt = 0; /* only for applist. a number of app to listed */
104 static ons_msg_t *ons_free_msg = NULL;
105 static ons_msg_t *ons_send_msg = NULL;
107 static int ons_command_wait = ICO_ONS_NO_WAIT;
109 static struct libwebsocket_protocols ws_protocols[] = {
117 ons_callback_onscreen,
128 /*============================================================================*/
130 /*============================================================================*/
131 /*--------------------------------------------------------------------------*/
133 * @brief ons_event_message
136 * @param[in] wsi libwebsockets management table to send
137 * @param[in] fromat message to send
140 /*--------------------------------------------------------------------------*/
142 ons_event_message(char *format, ...)
145 char message[ICO_HS_TEMP_BUF_SIZE];
148 va_start(list, format);
149 vsnprintf(message, sizeof(message), format, list);
152 uifw_trace("OnScreen: ons_event_message %s", message);
154 send = ons_alloc_seendmsg(message, strlen(message));
156 uifw_warn("ons_event_message: ERROR(allocate send msg)");
159 ons_put_sendmsg(send);
165 /*--------------------------------------------------------------------------*/
167 * @brief ons_get_sendmsg
168 * get the send message from the send buffer.
171 * @return send buffer address
172 * @retval > 0 success
175 /*--------------------------------------------------------------------------*/
177 ons_get_sendmsg(void)
183 ons_send_msg = msg->next;
190 /*--------------------------------------------------------------------------*/
192 * @brief ons_put_sendmsg
193 * put the send message to the send queue end.
195 * @param[in] data send message
197 * @retval ICO_HS_OK success
198 * @retval ICO_HS_ERR error
200 /*--------------------------------------------------------------------------*/
202 ons_put_sendmsg(ons_msg_t *send)
206 uifw_trace("ons_put_sendmsg: Enter");
222 if (ons_ws_context && ons_wsi_mirror) {
223 uifw_trace("ons_put_sendmsg: libwebsocket_callback_on_writable"
224 "(wsi_ctx=%x, wsi=%x", ons_ws_context, ons_wsi_mirror);
225 libwebsocket_callback_on_writable(ons_ws_context, ons_wsi_mirror);
228 uifw_trace("ons_put_sendmsg: Leave(do not have wsi)");
232 uifw_trace("ons_put_sendmsg: Leave");
237 /*--------------------------------------------------------------------------*/
239 * @brief ons_alloc_seendmsg
240 * Allocate a send message buffer.
242 * @param[in] data data
243 * @param[in] len data length
245 * @retval > 0 success
248 /*--------------------------------------------------------------------------*/
250 ons_alloc_seendmsg(char *data, int len)
255 msg = malloc(sizeof(ons_msg_t));
262 ons_free_msg = ons_free_msg->next;
264 memset(msg, 0, sizeof(ons_msg_t));
267 msg->data = strdup(data);
277 ons_edje_parse_str(void *in, int arg_num)
282 uifw_trace("ons_edje_parse_str %s, arg = %d", in, arg_num);
283 data = strtok(in, " ");
284 /* arg_num : 0 to n */
285 for (i = 0; i < arg_num; i++) {
286 data = strtok(NULL, " ");
288 uifw_trace("ons_edje_parse_str data: %s", data);
292 /*--------------------------------------------------------------------------*/
294 * @brief ons_callback_http
295 * Connection status is notified from libwebsockets.
297 * @param[in] context libwebsockets context
298 * @param[in] wsi libwebsockets management table
299 * @param[in] reason event type
300 * @param[in] user intact
301 * @param[in] in receive message
302 * @param[in] len message size[BYTE]
307 /*--------------------------------------------------------------------------*/
309 ons_callback_http(struct libwebsocket_context *context, struct libwebsocket *wsi,
310 enum libwebsocket_callback_reasons reason, void *user, void *in,
313 uifw_trace("ons_callback_http %p", context);
314 uifw_trace("OS-REASON %d", reason);
318 /*--------------------------------------------------------------------------*/
320 * @brief ons_callback_onscreen
321 * this callback function is notified from libwebsockets
324 * @param[in] context libwebsockets context
325 * @param[in] wsi libwebsockets management table
326 * @param[in] reason event type
327 * @param[in] user intact
328 * @param[in] in receive message
329 * @param[in] len message size[BYTE]
334 /*--------------------------------------------------------------------------*/
336 ons_callback_onscreen(struct libwebsocket_context *context,
337 struct libwebsocket *wsi,
338 enum libwebsocket_callback_reasons reason, void *user,
339 void *in, size_t len)
342 unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 512
343 + LWS_SEND_BUFFER_POST_PADDING];
344 unsigned char *p = &buf[LWS_SEND_BUFFER_PRE_PADDING];
347 uifw_trace("ons_callback_onscreen %p", context);
350 case LWS_CALLBACK_CLIENT_ESTABLISHED:
351 uifw_trace("OS-ESTABLISHED %x", wsi);
352 ons_wsi_mirror = wsi;
353 ons_event_message("ANS HELLO");
356 case LWS_CALLBACK_CLIENT_RECEIVE:
357 uifw_trace("OS-RECEIVE[%d] %s", len, in);
361 ons_command_wait = ICO_ONS_NO_WAIT;
362 /* onscreen activate request */
363 if (strncmp("OPEN", in, 4) == 0) {
364 uifw_trace("%s", in);
365 strncpy(ons_edje_str, ons_edje_parse_str(in, 1), sizeof(ons_edje_str));
366 uifw_trace("ons_loadinons_edje_file: %s", &ons_edje_str[0]);
367 if (ons_loadinons_edje_file(&ons_edje_str[0]) == 0) {
368 ons_event_message("RESULT SUCCESS");
371 ons_event_message("RESULT FAILED");
376 case LWS_CALLBACK_CLOSED:
377 uifw_trace("OS-CLOSE");
378 ons_wsi_mirror = NULL;
381 case LWS_CALLBACK_CLIENT_WRITEABLE:
382 uifw_trace("LWS_CALLBACK_CLIENT_WRITEABLE:(wsi=%x)", wsi);
384 msg = ons_get_sendmsg();
386 strcpy((char *)p, msg->data);
387 n = libwebsocket_write(wsi, p, strlen((char *)p), LWS_WRITE_TEXT);
389 uifw_warn("ons_callback_onscreen: ERROR(fail to write ws)");
393 libwebsocket_callback_on_writable(context, wsi);
400 uifw_trace("OS-REASON %d", reason);
404 uifw_trace("ons_callback_onscreen: Leave");
409 /*--------------------------------------------------------------------------*/
411 * @brief ons_create_context
412 * connect to the homescreen using websocket.
417 /*--------------------------------------------------------------------------*/
419 ons_create_context(void)
422 = libwebsocket_create_context(CONTEXT_PORT_NO_LISTEN, NULL,
424 libwebsocket_internal_extensions,
425 NULL, NULL, -1, -1, 0);
426 uifw_trace("OnScreen: ons_create_context ctx = %p", ons_ws_context);
428 ons_ws_connected = 0;
429 if (ons_ws_context == NULL) {
430 uifw_trace("OnScreen: libwebsocket_create_context failed.");
433 ons_wsi_mirror = libwebsocket_client_connect(ons_ws_context,
434 ICO_ONS_WS_ADDRESS, ons_ws_port, 0, "/",
435 ICO_ONS_WS_ADDRESS, NULL,
436 ICO_ONS_WS_PROTOCOL_NAME, -1);
437 uifw_trace("OnScreen: ons_create_context wsi = %p", ons_wsi_mirror);
438 if (ons_wsi_mirror != NULL) {
439 ons_ws_connected = 1;
444 /*--------------------------------------------------------------------------*/
446 * @brief ons_ecore_event
447 * timer handler called by Ecore.
449 * @param[in] data user data
450 * @return call back setting
451 * @retval ECORE_CALLBACK_RENEW set callback
453 /*--------------------------------------------------------------------------*/
455 ons_ecore_event(void *data)
457 if (ons_ws_connected) {
458 libwebsocket_service(ons_ws_context, 0);
461 if (ons_ws_context != NULL) {
462 libwebsocket_context_destroy(ons_ws_context);
465 = libwebsocket_create_context(CONTEXT_PORT_NO_LISTEN, NULL,
467 libwebsocket_internal_extensions,
468 NULL, NULL, -1, -1, 0);
469 if (ons_ws_context == NULL) {
470 uifw_trace("OnScreen: libwebsocket_create_context failed.");
473 ons_wsi_mirror = libwebsocket_client_connect(ons_ws_context,
474 ICO_ONS_WS_ADDRESS, ons_ws_port, 0,
475 "/", ICO_ONS_WS_ADDRESS, NULL,
476 ICO_ONS_WS_PROTOCOL_NAME, -1);
477 if (ons_wsi_mirror != NULL) {
478 ons_ws_connected = 1;
483 return ECORE_CALLBACK_RENEW;
486 /*--------------------------------------------------------------------------*/
488 * @brief ons_on_destroy
489 * callback function called by EFL when ecore destroyed.
490 * exit ecore main loop.
492 * @param[in] ee ecore evas object
495 /*--------------------------------------------------------------------------*/
497 ons_on_destroy(Ecore_Evas *ee)
499 uifw_trace("ons_on_destroy: Enter");
501 ecore_main_loop_quit();
502 libwebsocket_context_destroy(ons_ws_context);
507 ons_touch_up_edje(void *data, Evas *evas, Evas_Object *obj, void *event_info)
509 if (ons_command_wait == ICO_ONS_CMD_WAIT) return;
510 ons_command_wait = ICO_ONS_CMD_WAIT;
512 /* get name from userdata */
514 uifw_trace("OnScreen: user data is %s", (const char *)data);
517 uifw_trace("OnScreen: user data is NULL");
519 ons_event_message("TOUCH %s %s", ons_edje_str, data);
521 /* operation sound */
522 hs_snd_play(hs_snd_get_filename(ICO_HS_SND_TYPE_DEFAULT));
525 /*--------------------------------------------------------------------------*/
527 * @brief ons_touch_up_next
528 * processing when next button touch up.
530 * @param[in] data user data
531 * @param[in] obj evas object of the button
532 * @param[in] event_info evas event infomation
535 /*--------------------------------------------------------------------------*/
537 ons_touch_up_next(void *data, Evas *evas, Evas_Object *obj, void *event_info)
541 if (ons_command_wait == ICO_ONS_CMD_WAIT) return;
542 ons_command_wait = ICO_ONS_CMD_WAIT;
544 if (ons_app_cnt > 0) {
545 listcnt = ((ons_app_cnt - 1) / ICO_ONS_APPLI_NUM) + 1;
550 ons_applist_idx += 1;
551 if (ons_applist_idx >= listcnt) {
555 /* get name from userdata */
557 uifw_trace("OnScreen: user data is %s", (const char *)data);
560 uifw_trace("OnScreen: user data is NULL");
562 ons_event_message("TOUCH %s %s", ons_edje_str, data);
564 /* operation sound */
565 hs_snd_play(hs_snd_get_filename(ICO_HS_SND_TYPE_DEFAULT));
568 /*--------------------------------------------------------------------------*/
570 * @brief ons_get_fname
571 * get filename from the full path
573 * @param[in] filepath file path
576 /*--------------------------------------------------------------------------*/
578 ons_get_fname(const char *filepath)
581 const char *name = filepath;
583 for (ii = 0; ii < ICO_ONS_BUF_SIZE - 1; ii++) {
584 if (filepath[ii] == 0)
586 if (filepath[ii] == '/')
587 name = &filepath[ii + 1];
593 /*--------------------------------------------------------------------------*/
595 * @brief ons_get_appindex
596 * return a application index that to be set indicated index.
598 * @param[in] filepath file path
601 /*--------------------------------------------------------------------------*/
603 ons_get_appindex(int idx)
606 int appidx = idx + ons_applist_idx * ICO_ONS_APPLI_NUM + 1;
608 Ico_Uxf_App_Config *appconf = (Ico_Uxf_App_Config *)ico_uxf_getAppConfig();
610 uifw_trace("ons_get_appindex: idx=%d appidx=%d appcnt=%d", idx, appidx, ons_app_cnt);
612 for (ii = 0; ii < appconf->applicationNum; ii++) {
613 if ((! appconf->application[ii].noicon) &&
614 (strcmp(appconf->application[ii].type, ICO_HS_GROUP_SPECIAL) != 0)) {
625 /* set App Icon on rect */
627 ons_set_appicon(Evas *evas, Evas_Object *edje, Evas_Object* part,
628 const char *partname)
631 int idx; /* rect index */
632 int appidx; /* appli index */
633 char imgfile[ICO_ONS_BUF_SIZE];
634 Ico_Uxf_App_Config *appconf;
635 Evas_Object *img = NULL;
637 memset(imgfile, 0, sizeof(imgfile));
638 /* check name, if part is rect/next_bt/cancel_bt */
639 if (strncmp(partname, ICO_HS_ONS_PART_RECT_NAME,
640 sizeof(ICO_HS_ONS_PART_RECT_NAME) - 1) == 0) {
641 img = evas_object_image_filled_add(ons_evas);
642 /* get rect index from partname(rect_01, rect_02, ...) */
643 sscanf(partname, ICO_HS_ONS_PART_RECT_NAME"%d", &idx);
646 appconf = (Ico_Uxf_App_Config *)ico_uxf_getAppConfig();
648 appidx = ons_get_appindex(idx);
649 uifw_trace("ons_set_appicon: idx=%d appidx=%d", idx, appidx);
650 if ((appidx < 0) || (appidx > appconf->applicationNum)) {
651 evas_object_del(img);
655 /* set icon file name */
656 snprintf(imgfile, ICO_ONS_BUF_SIZE, "%s",
657 appconf->application[appidx].icon_key_name);
658 uifw_trace("ons_set_appicon: set image = %s(%d/%d), app=%s, group=%s",
659 imgfile, appidx, ons_app_cnt,
660 appconf->application[appidx].appid,
661 appconf->application[appidx].group);
662 /* set mouse call back function */
663 evas_object_event_callback_add(img, EVAS_CALLBACK_MOUSE_UP,
665 appconf->application[appidx].appid);
667 else if (strcmp(partname, ICO_HS_ONS_PART_NEXT_NAME) == 0) {
668 evas_object_event_callback_add(part, EVAS_CALLBACK_MOUSE_UP,
669 ons_touch_up_next, partname);
671 else if (strcmp(partname, ICO_HS_ONS_PART_CANCEL_NAME) == 0) {
672 evas_object_event_callback_add(part, EVAS_CALLBACK_MOUSE_UP,
673 ons_touch_up_edje, partname);
679 if (strlen(imgfile) > 0) {
680 /* calculation icon pos */
681 edje_object_part_geometry_get(ons_edje, partname, &x, &y, &w, &h);
682 x += (ons_width - ICO_HS_SIZE_LAYOUT_WIDTH) / 2;
683 y += (ons_height - ICO_HS_SIZE_LAYOUT_HEIGHT) / 2;
685 evas_object_image_file_set(img, imgfile, NULL);
686 evas_object_move(img, x, y);
687 evas_object_resize(img, w, h);
688 evas_object_show(img);
691 ons_img_list = eina_list_append(ons_img_list, img);
695 ons_loadinons_edje_file(const char *edje_file)
697 Evas_Object *part; /* part handle */
698 Eina_List *group; /* edje group list */
699 Eina_List *list; /* part list in edje */
700 int group_count = 0; /* group counter */
701 int name_count = 0; /* name counter */
702 int moveX, moveY; /* move list to center */
703 Eina_List *l, *l_next;
708 ons_evas = ecore_evas_get(ons_window);
710 uifw_trace("OnScreen: could not create evas.");
714 canvas = evas_object_rectangle_add(ons_evas);
715 evas_object_color_set(canvas, 0, 0, 0, 191);
716 evas_object_move(canvas, 0, 0);
717 evas_object_resize(canvas, ons_width, ons_height);
718 evas_object_show(canvas);
721 /* delete pre image */
722 uifw_trace("OnScreen: img list is %08x", ons_img_list);
723 EINA_LIST_FOREACH_SAFE(ons_img_list, l, l_next, data) {
724 uifw_trace("OnScreen: del data is %08x", data);
725 evas_object_del(data);
726 ons_img_list = eina_list_remove_list(ons_img_list, l);
731 evas_object_del(ons_edje);
734 /* create and add object in canvas from edje */
735 ons_edje = edje_object_add(ons_evas);
737 uifw_trace("OnScreen: could not create edje object!");
741 uifw_trace("OnScreen: w=%d h=%d", ons_width, ons_height);
744 moveX = (ons_width - ICO_HS_SIZE_LAYOUT_WIDTH) / 2;
745 moveY = (ons_height - ICO_HS_SIZE_LAYOUT_HEIGHT) / 2;
747 /* Put in the image */
748 evas_object_move(ons_edje, moveX, moveY);
749 /* Resize the image */
750 evas_object_resize(ons_edje, ons_width, ons_height);
752 evas_object_show(ons_edje);
755 group = edje_file_collection_list(edje_file);
756 while (group != NULL) {
757 /* Set the edj file */
758 if (!edje_object_file_set(ons_edje, edje_file, (const char *)group->data)) {
759 int err = edje_object_load_error_get(ons_edje);
760 const char *errmsg = edje_load_error_str(err);
761 uifw_trace("OnScreen: could not load %s: %s", edje_file, errmsg);
763 edje_file_collection_list_free(group);
764 evas_object_del(ons_edje);
767 uifw_trace("OnScreen: group[%d] data : %s", group_count,
768 (const char *)group->data);
771 list = edje_object_access_part_list_get(ons_edje);
772 while (list != NULL) {
773 uifw_trace("OnScreen: list[%d] data : %s", name_count,
774 (const char *)list->data);
776 /* set callback for part name */
777 part = (Evas_Object *)edje_object_part_object_get(ons_edje,
778 (const char *)list->data);
780 uifw_trace("OnScreen: list[%d] name : %s", name_count,
781 (const char *)list->data);
784 if (strncmp(ons_get_fname(edje_file), ICO_HS_ONS_APPLI_LIST_NAME,
785 sizeof(ICO_HS_ONS_APPLI_LIST_NAME) - 1) != 0) {
786 evas_object_event_callback_add(part,
787 EVAS_CALLBACK_MOUSE_UP,
788 ons_touch_up_edje, list->data);
792 ons_set_appicon(ons_evas, ons_edje, part, (const char *)list->data);
796 uifw_trace("OnScreen: list[%d] is NULL", name_count);
806 uifw_trace("OnScreen: group num is %d", group_count);
807 uifw_trace("OnScreen: name num is %d", name_count);
812 /*--------------------------------------------------------------------------*/
814 * @brief ons_load_config
815 * load/reload configuration.
820 /*--------------------------------------------------------------------------*/
822 ons_load_config(void)
824 Ico_Uxf_App_Config *appconf;
826 int appidx, idx, cnt;
828 uifw_trace("ons_load_config: Enter");
830 appconf = (Ico_Uxf_App_Config *)ico_uxf_getAppConfig();
831 appcnt = appconf->applicationNum;
832 for (appidx = 0; appidx < appconf->applicationNum; appidx++) {
833 if ((appconf->application[appidx].noicon) ||
834 (strcmp(appconf->application[appidx].type, ICO_HS_GROUP_SPECIAL) == 0)) {
836 uifw_trace("ons_load_config: No Need appid=%s noicon=%d type=%s",
837 appconf->application[appidx].appid,
838 appconf->application[appidx].noicon,
839 appconf->application[appidx].type);
843 for (idx = 0; idx < appcnt; idx++) {
844 appidx = ons_get_appindex(idx);
846 uifw_trace("ons_load_config: appid=%s seat=%d idx=%d seatcnt=%d",
847 appconf->application[appidx].appid, cnt
848 / ICO_ONS_APPLI_NUM, idx - ICO_ONS_APPLI_NUM
849 * (cnt / ICO_ONS_APPLI_NUM), ((appcnt - 1)
850 / ICO_ONS_APPLI_NUM) + 1);
855 ons_app_cnt = appcnt;
858 uifw_trace("ons_load_config: Leave(appcnt=%d)", appcnt);
863 /*--------------------------------------------------------------------------*/
865 * @brief ons_config_event
866 * This is a callback function called when the configurations
869 * @param[in] appid application id
870 * @param[in] type event type(install/uninstall)
873 /*--------------------------------------------------------------------------*/
875 ons_config_event(const char *appid, int type)
877 uifw_trace("ons_config_event: Enter(appid=%s, type=%d)", appid, type);
881 uifw_trace("ons_config_event: Leave");
886 /*--------------------------------------------------------------------------*/
888 * @brief onscreen application
891 * @param main() finction's standard parameter (argc,argv)
896 /*--------------------------------------------------------------------------*/
898 main(int argc, char *argv[])
901 int orientation = ICO_ONS_HORIZONTAL;
906 if (getenv("PKG_NAME")) {
907 ico_uxf_log_open(getenv("PKG_NAME"));
910 ico_uxf_log_open(ICO_HS_APPID_DEFAULT_ONS);
914 for (ii = 1; ii < argc; ii++) {
915 if (argv[ii][0] != '-')
917 if (strncasecmp(argv[ii], "-orientaion=", strlen("-orientaion=")) == 0) {
918 if (strcmp(&argv[ii][strlen("-orientaion=")], "vertical") == 0) {
919 orientation = ICO_ONS_VERTICAL;
921 else if (strcmp(&argv[ii][strlen("-orientaion=")], "horizontal")
923 orientation = ICO_ONS_HORIZONTAL;
928 /* load configuration */
929 ret = initHomeScreenConfig(ICO_ONSCREEN_CONFIG_FILE);
930 if (ret == ICO_HS_OK) {
931 ons_ws_port = hs_conf_get_integer(ICO_HS_CONFIG_ONSCREEN,
932 ICO_HS_CONFIG_WS_PORT,
934 orientation = hs_conf_get_integer(ICO_HS_CONFIG_ONSCREEN,
935 ICO_HS_CONFIG_ORIENTAION,
941 /* Reset a ecore_evas */
944 /* Initialize a edje */
947 /* Make a new ecore_evas */
948 ons_window = ecore_evas_new(NULL, 0, 0, 1, 1, "frame=0");
950 /* if not for a window, return NULL */
952 EINA_LOG_CRIT("OnScreen: could not create ons_window.");
955 ecore_evas_callback_destroy_set(ons_window, ons_on_destroy);
958 ecore_main_loop_iterate();
959 ecore_wl_screen_size_get(&width, &height);
960 if (orientation == ICO_ONS_VERTICAL) {
961 ons_width = width > height ? height : width;
962 ons_height = width > height ? width : height;
965 ons_width = width < height ? height : width;
966 ons_height = width < height ? width : height;
968 ecore_evas_resize(ons_window, ons_width, ons_height);
970 /* Show the window */
971 /* evas_output_framespace_set(ecore_evas_get(ons_window), 0, 0, 0, 0); */
972 ecore_evas_alpha_set(ons_window, EINA_TRUE);
973 ecore_evas_show(ons_window);
975 /* Init websockets */
976 ons_create_context();
977 ecore_timer_add(ICO_ONS_WS_TIMEOUT, ons_ecore_event, NULL);
979 /* add callback to app configuration */
980 ico_uxf_econf_setAppUpdateCb(ons_config_event);
982 /* Start main loop */
983 ecore_main_loop_begin();
985 /* end the ecore_evas */
986 ecore_evas_shutdown();