--- /dev/null
+SUBDIRS=ico-app-framework apps_controller src test
--- /dev/null
+noinst_LIBRARIES = libico_syc-apc.a
+
+includedir = /usr/include/ico-uxf-weston-plugin
+
+libico_syc_apc_a_CFLAGS = -I/usr/include/ico-uxf-weston-plugin -I../include $(EFL_CFLAGS) @DBUS_CFLAGS@ @GLIB_CFLAGS@
+libico_syc_apc_a_SOURCES = \
+ ico_syc_apc_control.c \
+ ico_syc_apc_regulation.c
+
+AM_CFLAGS = $(GCC_CFLAGS)
+AM_CPPFLAGS = $(GCC_CFLAGS) \
+ -DDATADIR='"$(datadir)"' \
+ -DMODULEDIR='"$(moduledir)"' \
+ -DLIBEXECDIR='"$(libexecdir)"'
+
+AM_LDFLAGS = -module -avoid-version -rpath $(libdir) -lwayland-egl -lEGL -lGLESv2
+
+.FORCE :
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief Initialize/Terminate and Control for Apps Controller of System Controller
+ *
+ * @date Feb-28-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdbool.h>
+#include <string.h>
+#include <errno.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <fcntl.h>
+
+#include <wayland-client.h>
+#include <ico_window_mgr-client-protocol.h>
+#include <dbus/dbus.h>
+#include <Ecore.h>
+#include "ico_apf.h"
+#include "ico_uxf.h"
+#include "ico_apf_ecore.h"
+#include "ico_syc_apc.h"
+#include "ico_syc_apc_private.h"
+
+/*==============================================================================*/
+/* static tables */
+/*==============================================================================*/
+/* flag for initiailze */
+static int ico_apps_controller_init = 0;
+
+/* zone management table */
+static ico_apc_dispzone_t *dispzone = NULL;
+static int ndispzone = 0;
+static ico_apc_soundzone_t *soundzone = NULL;
+static int nsoundzone = 0;
+static ico_apc_inputsw_t *inputsw = NULL;
+static int ninputsw = 0;
+
+/* free request save table */
+static ico_apc_request_t *free_request = NULL;
+
+/* user(HomeScreen) control functions */
+static ico_apc_resource_control_t displaycontrol = NULL;
+static ico_apc_resource_control_t soundcontrol = NULL;
+static ico_apc_resource_control_t inputcontrol = NULL;
+
+/* Ecore timer */
+static int timer_count = 0;
+static Ecore_Timer *ecore_timer = NULL;
+
+/* configuration */
+static Ico_Uxf_Sys_Config *confsys = NULL;
+static Ico_Uxf_App_Config *confapp = NULL;
+
+/*==============================================================================*/
+/* define static function prototype */
+/*==============================================================================*/
+static void resource_reqcb(ico_apf_resource_notify_info_t* info, void *user_data);
+static void app_getdisplay(ico_apc_request_t *req, const int addprio);
+static void app_freedisplay(ico_apc_request_t *req, const int send);
+static void change_disprequest(ico_apc_request_t *req, const int active);
+static void recalc_dispzone(const int idx);
+static void app_getsound(ico_apc_request_t *req, const int addprio);
+static void app_freesound(ico_apc_request_t *req, const int send);
+static void change_soundrequest(ico_apc_request_t *req, const int active);
+static void recalc_soundzone(const int idx);
+static void app_getinput(ico_apc_request_t *req, const int addprio);
+static void app_freeinput(ico_apc_request_t *req, const int send);
+static void change_inputrequest(ico_apc_request_t *req, const int active);
+static void recalc_inputsw(const int idx);
+static void regulation_listener(const int appcategory,
+ const ico_apc_reguration_control_t control,
+ void *user_data);
+static Eina_Bool request_timer(void *user_data);
+static void app_display_hook(const char *appid, const int surface, const int object);
+static ico_apc_request_t *get_freereq(void);
+static ico_apc_request_t *search_disprequest(const Ico_Uxf_conf_application *conf,
+ const int resid, const int id);
+static ico_apc_request_t *search_soundrequest(const Ico_Uxf_conf_application *conf,
+ const int resid, const int id,
+ ico_apc_request_t **first_req);
+
+/*==============================================================================*/
+/* define fixed value */
+/*==============================================================================*/
+/* maximum number of request blocks */
+#if ICO_UXF_DISPLAY_ZONE_MAX > ICO_UXF_SOUND_ZONE_MAX
+ #if ICO_UXF_INPUT_SW_MAX > ICO_UXF_DISPLAY_ZONE_MAX
+ #define MAXREQ ICO_UXF_INPUT_SW_MAX
+ #else
+ #define MAXREQ ICO_UXF_DISPLAY_ZONE_MAX
+ #endif
+#else
+ #if ICO_UXF_INPUT_SW_MAX > ICO_UXF_SOUND_ZONE_MAX
+ #define MAXREQ ICO_UXF_INPUT_SW_MAX
+ #else
+ #define MAXREQ ICO_UXF_SOUND_ZONE_MAX
+ #endif
+#endif
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief get_freereq: get free request block(static function)
+ *
+ * @param none
+ * @return result
+ * @retval != NULL success(request block address)
+ * @retval == NULL error(out of memory)
+ */
+/*--------------------------------------------------------------------------*/
+static ico_apc_request_t *
+get_freereq(void)
+{
+ ico_apc_request_t *req;
+ int i;
+
+ if (! free_request) {
+ free_request = malloc(sizeof(ico_apc_request_t)*ICO_UXF_MNG_BLOCK_ALLOCS);
+ if (! free_request) {
+ apfw_error("get_freereq: No Memory");
+ return NULL;
+ }
+ req = free_request;
+ for (i = 0; i < ICO_UXF_MNG_BLOCK_ALLOCS; i++, req++) {
+ if (i < (ICO_UXF_MNG_BLOCK_ALLOCS-1)) {
+ req->next = (req+1);
+ }
+ else {
+ req->next = NULL;
+ }
+ }
+ }
+ req = free_request;
+ memset(req, 0, sizeof(ico_apc_request_t));
+ free_request = free_request->next;
+
+ return req;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief search_disprequest: search client display request(static function)
+ *
+ * @param[in] conf application configuration
+ * @param[in] resid resource type
+ * @param[in] id resource id requested from client
+ * @return result
+ * @retval != NULL success(request block)
+ * @retval == NULL error(request was not found)
+ */
+/*--------------------------------------------------------------------------*/
+static ico_apc_request_t *
+search_disprequest(const Ico_Uxf_conf_application *conf, const int resid, const int id)
+{
+ int i;
+ ico_apc_request_t *p;
+ ico_apc_request_t *sameres = NULL;
+
+ for (i = 0; i < ndispzone; i++) {
+ p = dispzone[i].req;
+ while (p) {
+ if ((p->conf == conf) &&
+ ((int)p->resid == resid)) {
+ if ((id < 0) || (p->id == id)) {
+ return p;
+ }
+ if (! sameres) sameres = p;
+ }
+ p = p->next;
+ }
+ }
+ return sameres;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief search_soundrequest: search client sound request(static function)
+ *
+ * @param[in] conf application configuration
+ * @param[in] resid resource type
+ * @param[in] id resource id requested from client
+ * @param[out] first_req request of top on same sound zone
+ * @return result
+ * @retval != NULL success(request block)
+ * @retval == NULL error(request was not found)
+ */
+/*--------------------------------------------------------------------------*/
+static ico_apc_request_t *
+search_soundrequest(const Ico_Uxf_conf_application *conf, const int resid,
+ const int id, ico_apc_request_t **first_req)
+{
+ int i;
+ ico_apc_request_t *p;
+ ico_apc_request_t *sameres = NULL;
+
+ for (i = 0; i < nsoundzone; i++) {
+ p = soundzone[i].req;
+ while (p) {
+ if ((p->conf == conf) &&
+ ((int)p->resid == resid)) {
+ if ((id < 0) || (p->id == id)) {
+ if (first_req) {
+ *first_req = soundzone[i].req;
+ }
+ return p;
+ }
+ if (! sameres) sameres = p;
+ }
+ p = p->next;
+ }
+ }
+ return sameres;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief resource_reqcb: resource request callback(static function)
+ *
+ * @param[in] info request information
+ * @param[in] user_data user data(unused)
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+resource_reqcb(ico_apf_resource_notify_info_t* info, void *user_data)
+{
+ Ico_Uxf_conf_application *appconf;
+ ico_apc_request_t *req;
+ ico_apc_request_t *p;
+ ico_apc_request_t *freq;
+ int i;
+ int count;
+ ico_apc_request_t *reqsave[MAXREQ];
+
+ apfw_trace("resource_reqcb: Entry(cmd=%d res=%d id=%d bid=%d app=%s[%d])",
+ info->state, info->resid, info->id, info->bid, info->appid, info->pid);
+
+ if (info->state == ICO_APF_RESOURCE_STATE_CONNECTED) {
+ apfw_trace("resource_reqcb: Leave(application connected)");
+ return;
+ }
+
+ if (info->state >= ICO_APF_SOUND_COMMAND_MIN) {
+ /* Multi Sound Manager, data check */
+ if ((int)info->state == (int)ICO_APF_SOUND_REPLY_LIST) {
+ apfw_trace("resource_reqcb: Leave(Sound Reply, no need)");
+ return;
+ }
+ if (info->appid[0] == 0) {
+ apfw_warn("resource_reqcb: Leave(Sound Event, but no appid)");
+ return;
+ }
+ if ((int)info->state == (int)ICO_APF_SOUND_EVENT_FREE) {
+ apfw_trace("resource_reqcb: Leave(Sound Free, no need)");
+ return;
+ }
+ }
+
+ /* check and search application id */
+ appconf = (Ico_Uxf_conf_application *)ico_uxf_getAppByAppid(info->appid);
+ if (! appconf) {
+ /* application id dose not exist, search application name */
+ appconf = (Ico_Uxf_conf_application *)ico_uxf_getAppByName(info->appid);
+ if (! appconf) {
+ apfw_error("resource_reqcb: Leave(appid[%s] dose not exist)",
+ info->appid);
+ return;
+ }
+ }
+ if ((info->state >= ICO_APF_SOUND_COMMAND_MIN) &&
+ ((confsys->kind[appconf->kindId].priv == ICO_UXF_PRIVILEGE_ALMIGHTY) ||
+ (confsys->kind[appconf->kindId].priv == ICO_UXF_PRIVILEGE_SYSTEM))) {
+ /* System Program(ex. HomeScreen) no need resource control */
+ apfw_trace("resource_reqcb: Leave(appid[%s] is system program)",
+ info->appid);
+ return;
+ }
+
+ if (info->state == ICO_APF_RESOURCE_STATE_DISCONNECTED) {
+ apfw_trace("resource_reqcb: DISCONNECTED[%s]", info->appid);
+
+ /* free all screen request from this application */
+ count = 0;
+ for (i = 0; i < ndispzone; i++) {
+ p = dispzone[i].req;
+ while (p) {
+ if (p->conf == appconf) {
+ reqsave[count++] = p;
+ }
+ p = p->next;
+ }
+ }
+ for (i = 0; i < count; i++) {
+ app_freedisplay(reqsave[i], 0);
+ }
+ /* free all sound request from this application */
+ count = 0;
+ for (i = 0; i < nsoundzone; i++) {
+ p = soundzone[i].req;
+ while (p) {
+ if (p->conf == appconf) {
+ reqsave[count++] = p;
+ }
+ p = p->next;
+ }
+ }
+ for (i = 0; i < count; i++) {
+ app_freesound(reqsave[i], 0);
+ }
+ /* free all input switch request from this application*/
+ count = 0;
+ for (i = 0; i < ninputsw; i++) {
+ p = inputsw[i].req;
+ while (p) {
+ if (p->conf == appconf) {
+ reqsave[count++] = p;
+ }
+ p = p->next;
+ }
+ }
+ for (i = 0; i < count; i++) {
+ app_freeinput(reqsave[i], 0);
+ }
+ apfw_trace("resource_reqcb: Leave");
+ return;
+ }
+
+ req = get_freereq();
+ if (! req) {
+ return;
+ }
+ req->conf = appconf;
+ req->resid = info->resid;
+ if (info->device[0]) {
+ strcpy(req->device, info->device);
+ }
+ else {
+ strcpy(req->device, "UnKnown");
+ }
+ req->id = info->id;
+ req->bid = info->bid;
+ req->pid = info->pid;
+ req->reqtype = ICO_APC_REQTYPE_REQUEST;
+
+ switch (info->resid) {
+ case ICO_APF_RESID_BASIC_SCREEN: /* basic screen */
+ switch (info->state) {
+ case ICO_APF_RESOURCE_COMMAND_GET: /* get resource */
+ apfw_trace("resource_reqcb: app(%s) get BasicScreen(%d)",
+ info->appid, info->id);
+ app_getdisplay(req, 0);
+ req = NULL;
+ break;
+ case ICO_APF_RESOURCE_COMMAND_RELEASE: /* release resource */
+ apfw_trace("resource_reqcb: app(%s) release BasicScreen(%d)",
+ info->appid, info->id);
+ app_freedisplay(req, 1);
+ req = NULL;
+ break;
+ case ICO_APF_RESOURCE_REPLY_OK: /* ack reply */
+ case ICO_APF_RESOURCE_REPLY_NG: /* nak reply */
+ apfw_trace("resource_reqcb: app(%s) BasicScreen(%d) reply(%s)", info->appid,
+ info->id, info->state == ICO_APF_RESOURCE_REPLY_OK ? "OK" : "NG");
+ p = search_disprequest(appconf, ICO_APF_RESID_BASIC_SCREEN, info->id);
+ if (p) {
+ if (p->state & ICO_APC_REQSTATE_REPLYACTIVE) {
+ ico_uxf_window_control(appconf->appid, p->id,
+ ICO_UXF_APPSCTL_INVISIBLE, 0);
+ if (displaycontrol) {
+ (*displaycontrol)(appconf, 1);
+ }
+ }
+ p->state &= ~(ICO_APC_REQSTATE_REPLYACTIVE|ICO_APC_REQSTATE_REPLYQUIET);
+ p->timer = 0;
+ }
+ break;
+ default:
+ apfw_error("resource_reqcb: illegal command(%d)", info->state);
+ break;
+ }
+ break;
+ case ICO_APF_RESID_INT_SCREEN: /* interrupt screen */
+ switch (info->state) {
+ case ICO_APF_RESOURCE_COMMAND_GET: /* get resource */
+ apfw_trace("resource_reqcb: app(%s) get IntScreen(%d) on basic screen(%d)",
+ info->appid, info->id, info->bid);
+ app_getdisplay(req, ICO_UXF_PRIO_INTSCREEN);
+ req = NULL;
+ break;
+ case ICO_APF_RESOURCE_COMMAND_RELEASE: /* release resource */
+ apfw_trace("resource_reqcb: app(%s) release IntScreen(%d)",
+ info->appid, info->id);
+ app_freedisplay(req, 1);
+ req = NULL;
+ break;
+ case ICO_APF_RESOURCE_REPLY_OK: /* ack reply */
+ case ICO_APF_RESOURCE_REPLY_NG: /* nak reply */
+ apfw_trace("resource_reqcb: app(%s) IntScreen(%d) reply(%s)", info->appid,
+ info->id, info->state == ICO_APF_RESOURCE_REPLY_OK ? "OK" : "NG");
+ p = search_disprequest(appconf, ICO_APF_RESID_INT_SCREEN, info->id);
+ if (p) {
+ if (p->state & ICO_APC_REQSTATE_REPLYACTIVE) {
+ ico_uxf_window_control(appconf->appid, p->id,
+ ICO_UXF_APPSCTL_INVISIBLE, 0);
+ if (displaycontrol) {
+ (*displaycontrol)(appconf, 1);
+ }
+ }
+ p->state &= ~(ICO_APC_REQSTATE_REPLYACTIVE|ICO_APC_REQSTATE_REPLYQUIET);
+ p->timer = 0;
+ }
+ break;
+ default:
+ apfw_error("resource_reqcb: illegal command(%d)", info->state);
+ break;
+ }
+ break;
+ case ICO_APF_RESID_ON_SCREEN: /* on screen */
+ switch (info->state) {
+ case ICO_APF_RESOURCE_COMMAND_GET: /* get resource */
+ apfw_trace("resource_reqcb: app(%s) get OnScreen(%d)",
+ info->appid, info->id);
+ app_getdisplay(req, ICO_UXF_PRIO_ONSCREEN);
+ req = NULL;
+ break;
+ case ICO_APF_RESOURCE_COMMAND_RELEASE: /* release resource */
+ apfw_trace("resource_reqcb: app(%s) release OnScreen(%d)",
+ info->appid, info->id);
+ app_freedisplay(req, 1);
+ req = NULL;
+ break;
+ case ICO_APF_RESOURCE_REPLY_OK: /* ack reply */
+ case ICO_APF_RESOURCE_REPLY_NG: /* nak reply */
+ apfw_trace("resource_reqcb: app(%s) OnScreen(%d) reply(%s)", info->appid,
+ info->id, info->state == ICO_APF_RESOURCE_REPLY_OK ? "OK" : "NG");
+ p = search_disprequest(appconf, ICO_APF_RESID_ON_SCREEN, info->id);
+ if (p) {
+ if (p->state & ICO_APC_REQSTATE_REPLYACTIVE) {
+ ico_uxf_window_control(appconf->appid, p->id,
+ ICO_UXF_APPSCTL_INVISIBLE, 0);
+ if (displaycontrol) {
+ (*displaycontrol)(appconf, 1);
+ }
+ }
+ p->state &= ~(ICO_APC_REQSTATE_REPLYACTIVE|ICO_APC_REQSTATE_REPLYQUIET);
+ p->timer = 0;
+ }
+ break;
+ default:
+ apfw_error("resource_reqcb: illegal command(%d)", info->state);
+ break;
+ }
+ break;
+ case ICO_APF_RESID_BASIC_SOUND: /* basic sound */
+ switch ((int)info->state) {
+ case ICO_APF_RESOURCE_COMMAND_GET: /* get resource */
+ apfw_trace("resource_reqcb: app(%s) get BasicSound(%d)",
+ info->appid, info->id);
+ app_getsound(req, 0);
+ req = NULL;
+ break;
+ case ICO_APF_RESOURCE_COMMAND_RELEASE: /* release resource */
+ apfw_trace("resource_reqcb: app(%s) release BasicSound(%d)",
+ info->appid, info->id);
+ app_freesound(req, 1);
+ req = NULL;
+ break;
+ case ICO_APF_RESOURCE_REPLY_OK: /* ack reply */
+ case ICO_APF_RESOURCE_REPLY_NG: /* nak reply */
+ apfw_trace("resource_reqcb: app(%s) BasicSound(%d) reply(%s)", info->appid,
+ info->id, info->state == ICO_APF_RESOURCE_REPLY_OK ? "OK" : "NG");
+ p = search_soundrequest(appconf, ICO_APF_RESID_BASIC_SOUND, info->id, NULL);
+ if (p) {
+ if (p->state & ICO_APC_REQSTATE_REPLYACTIVE) {
+ if (ico_apf_resource_send_to_soundctl(ICO_APF_SOUND_COMMAND_MUTEOFF,
+ p->pid)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("resource_reqcb: send MSM Error");
+ }
+ if (soundcontrol) {
+ (*soundcontrol)(p->conf, 1);
+ }
+ }
+ p->state &= ~(ICO_APC_REQSTATE_REPLYACTIVE|ICO_APC_REQSTATE_REPLYQUIET);
+ p->timer = 0;
+ }
+ break;
+ case ICO_APF_SOUND_EVENT_NEW: /* create new sound stream */
+ apfw_trace("resource_reqcb: app(%s) create BasicSound", info->appid);
+ p = search_soundrequest(appconf, ICO_APF_RESID_BASIC_SOUND, -1, &freq);
+ if (p) {
+ apfw_trace("resource_reqcb: app(%s,state=%x,prio=%08x,pid=%d=>%d) "
+ "requested sound, Nop", p->conf->appid, p->state, p->prio,
+ p->pid, info->pid);
+ p->pid = info->pid;
+ if (p->state & ICO_APC_REQSTATE_WAITREQ) {
+ if (ico_apf_resource_send_to_soundctl(ICO_APF_SOUND_COMMAND_MUTEON,
+ p->pid)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("resource_reqcb: send MSM Error");
+ }
+ if (soundcontrol) {
+ (*soundcontrol)(p->conf, 0);
+ }
+ if ((freq->state & ICO_APC_REQSTATE_WAITREQ) == 0) {
+ if (ico_apf_resource_send_to_soundctl(ICO_APF_SOUND_COMMAND_MUTEOFF,
+ freq->pid)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("resource_reqcb: send MSM Error");
+ }
+ if (soundcontrol) {
+ (*soundcontrol)(freq->conf, 1);
+ }
+ }
+ }
+ }
+ else {
+ apfw_trace("resource_reqcb: app(%s) not requested sound", info->appid);
+ req->resid = ICO_APF_RESID_BASIC_SOUND;
+ req->reqtype = ICO_APC_REQTYPE_CREATE;
+ strcpy(req->device,
+ confsys->sound[confsys->misc.default_soundId].
+ zone[confsys->misc.default_soundId].name);
+ app_getsound(req, 0);
+ req = NULL;
+ }
+ break;
+ default:
+ apfw_error("resource_reqcb: illegal command(%d)", info->state);
+ break;
+ }
+ break;
+ case ICO_APF_RESID_INT_SOUND: /* interrupt sound */
+ switch (info->state) {
+ case ICO_APF_RESOURCE_COMMAND_GET: /* get resource */
+ apfw_trace("resource_reqcb: app(%s) get IntSound(%d)",
+ info->appid, info->id);
+ app_getsound(req, ICO_UXF_PRIO_ONSCREEN);
+ req = NULL;
+ break;
+ case ICO_APF_RESOURCE_COMMAND_RELEASE: /* release resource */
+ apfw_trace("resource_reqcb: app(%s) release IntSound(%d)",
+ info->appid, info->id);
+ app_freesound(req, 1);
+ req = NULL;
+ break;
+ case ICO_APF_RESOURCE_REPLY_OK: /* ack reply */
+ case ICO_APF_RESOURCE_REPLY_NG: /* nak reply */
+ apfw_trace("resource_reqcb: app(%s) IntSound(%d) reply(%s)", info->appid,
+ info->id, info->state == ICO_APF_RESOURCE_REPLY_OK ? "OK" : "NG");
+ p = search_soundrequest(appconf, ICO_APF_RESID_INT_SOUND, info->id, NULL);
+ if (p) {
+ if (p->state & ICO_APC_REQSTATE_REPLYACTIVE) {
+ if (ico_apf_resource_send_to_soundctl(ICO_APF_SOUND_COMMAND_MUTEOFF,
+ p->pid)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("resource_reqcb: send MSM Error");
+ }
+ if (soundcontrol) {
+ (*soundcontrol)(p->conf, 1);
+ }
+ }
+ p->state &= ~(ICO_APC_REQSTATE_REPLYACTIVE|ICO_APC_REQSTATE_REPLYQUIET);
+ p->timer = 0;
+ }
+ break;
+ default:
+ apfw_error("resource_reqcb: illegal command(%d)", info->state);
+ break;
+ }
+ break;
+ case ICO_APF_RESID_INPUT_DEV: /* input switch */
+ if ((info->id < 0) || (info->id >= appconf->inputdevNum)) {
+ apfw_error("resource_reqcb: app(%s) cmd=%d InputSW(%d) but no exist",
+ info->appid, info->state, info->id);
+ }
+ else {
+ switch (info->state) {
+ case ICO_APF_RESOURCE_COMMAND_ADD: /* get switch */
+ apfw_trace("resource_reqcb: app(%s) get InputSW(%d)",
+ info->appid, info->id);
+ app_getinput(req, 0);
+ req = NULL;
+ break;
+ case ICO_APF_RESOURCE_COMMAND_CHANGE: /* change switch */
+ apfw_trace("resource_reqcb: app(%s) change InputSW(%d)",
+ info->appid, info->id);
+ app_getinput(req, 0);
+ req = NULL;
+ break;
+ case ICO_APF_RESOURCE_COMMAND_DELETE: /* delete switch */
+ apfw_trace("resource_reqcb: app(%s) delete InputSW(%d)",
+ info->appid, info->id);
+ app_freeinput(req, 1);
+ req = NULL;
+ break;
+ default:
+ apfw_error("resource_reqcb: illegal command(%d)", info->state);
+ break;
+ }
+ }
+ break;
+ default:
+ apfw_error("resource_reqcb: illegal resource(%d)", info->resid);
+ break;
+ }
+ if (req) {
+ req->next = free_request;
+ free_request = req;
+ }
+ apfw_trace("resource_reqcb: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief app_getdisplay: get display zone resource(static function)
+ *
+ * @param[in] req request block
+ * @param[in] addprio a priority to add to the priority of the request
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+app_getdisplay(ico_apc_request_t *req, const int addprio)
+{
+ int prio;
+ int i, j;
+ Ico_Uxf_conf_application *conf = req->conf;
+ Ico_Uxf_conf_display_zone *zone;
+ ico_apc_dispzone_t *czone;
+ ico_apc_request_t *p;
+ ico_apc_request_t *bp;
+
+ /* priority */
+ prio = confsys->category[conf->categoryId].priority * ICO_UXF_PRIO_CATEGORY;
+ prio += addprio;
+ if (ico_syc_apc_regulation_app_visible(conf->categoryId)) {
+ prio |= ICO_UXF_PRIO_REGULATION;
+ }
+ if (ico_uxf_process_is_active(conf->appid)) {
+ for (i = 0; i < ndispzone; i++) {
+ p = dispzone[i].req;
+ while (p) {
+ if (p->prio & ICO_UXF_PRIO_ACTIVEAPP) {
+ p->prio -= ICO_UXF_PRIO_ACTIVECOUNT;
+ }
+ p = p->next;
+ }
+ }
+ prio |= ICO_UXF_PRIO_ACTIVEAPP;
+ }
+
+ /* get display zone from device name */
+ for (i = 0; i < ndispzone; i++) {
+ if (strcasecmp(dispzone[i].conf->name, req->device) == 0) break;
+ }
+ if (i >= ndispzone) {
+ i = confsys->misc.default_dispzoneId;
+ apfw_trace("app_getdisplay: Entry(app=%s zone=%s(%s none) res=%d prio=%x(+%x))",
+ conf->appid, dispzone[i].conf->name, req->resid, req->device,
+ prio, addprio);
+ }
+ else {
+ apfw_trace("app_getdisplay: Entry(app=%s zone=%s res=%d prio=%x(+%x))",
+ conf->appid, dispzone[i].conf->name, req->resid, prio, addprio);
+ }
+ req->zoneidx = i;
+
+ czone = &dispzone[i];
+ zone = czone->conf;
+
+ /* search same request */
+ p = czone->req;
+ bp = NULL;
+ while (p) {
+ if ((p->conf == req->conf) && (p->resid == req->resid) &&
+ (p->zoneidx == req->zoneidx)) {
+ break;
+ }
+ bp = p;
+ p = p->next;
+ }
+ if (p) {
+ if (p->reqtype != ICO_APC_REQTYPE_REQUEST) {
+ apfw_trace("app_getdisplay: Leave(found same request)");
+ return;
+ }
+
+ if (p->prio > prio) {
+ prio = p->prio;
+ }
+ apfw_trace("app_getdisplay: found same request(app=%s zone=%s res=%d prio=%d)",
+ conf->appid, dispzone[i].conf->name, req->resid, prio);
+ if (bp) {
+ bp->next = p->next;
+ }
+ else {
+ czone->req = p->next;
+ }
+ p->next = free_request;
+ free_request = p;
+ }
+
+ /* link request to zone table */
+ req->prio = prio;
+ p = czone->req;
+ bp = NULL;
+ while (p) {
+ if (p->prio <= prio) break;
+ bp = p;
+ p = p->next;
+ }
+ if (bp) {
+ req->next = bp->next;
+ bp->next = req;
+ apfw_trace("app_getdisplay: app(%s) set after(%s) of zone(%s)",
+ conf->appid, bp->conf->appid, req->device);
+ }
+ else {
+ req->next = czone->req;
+ czone->req = req;
+ apfw_trace("app_getdisplay: app(%s) set top of zone(%s) next %s",
+ conf->appid, req->device, req->next ? req->next->conf->appid : "(NULL)");
+ }
+
+ /* check if maximum priority */
+ if (! bp) {
+ j = -1;
+ for (i = 0; i < czone->noverlap; i++) {
+ if (((czone->overlap[i])->req != NULL) &&
+ ((czone->overlap[i])->req->prio > prio)) {
+ j = i;
+ prio = czone->overlap[i]->req->prio;
+ }
+ }
+ }
+ else {
+ j = 9999;
+ }
+ if ((j >= 0) || ((req->prio & ICO_UXF_PRIO_REGULATION) == 0)) {
+ /* lower priority, waitting this application. */
+ /* insert application to zone application list and */
+ /* change zone priority, if request application is top priority */
+ req->state |= ICO_APC_REQSTATE_WAITREQ;
+ if (j >= 0) {
+ /* lower priority */
+ apfw_trace("app_getdisplay: priority low, waitting %s", conf->appid);
+ ico_uxf_window_control(conf->appid, req->id, ICO_UXF_APPSCTL_INVISIBLE, 1);
+ if (displaycontrol) {
+ (*displaycontrol)(conf, 0);
+ }
+ }
+ if ((req->prio & ICO_UXF_PRIO_REGULATION) == 0) {
+ /* regulation control */
+ apfw_trace("app_getdisplay: regulation, waitting %s", conf->appid);
+ ico_uxf_window_control(conf->appid, req->id, ICO_UXF_APPSCTL_REGULATION, 1);
+ if ((j < 0) && (displaycontrol)) {
+ (*displaycontrol)(conf, 0);
+ }
+ }
+ if (req->reqtype == ICO_APC_REQTYPE_REQUEST) {
+ if (ico_apf_resource_send_to_client(
+ conf->appid, ICO_APF_RESOURCE_STATE_WAITTING,
+ req->resid, req->device, req->id) != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("app_getdisplay: Leave(send(%s) Error)", conf->appid);
+ }
+ else {
+ req->state &= ~ICO_APC_REQSTATE_REPLYACTIVE;
+ req->state |= ICO_APC_REQSTATE_REPLYQUIET;
+ req->timer = ICO_APC_REQREPLY_MAXTIME;
+ timer_count ++;
+ }
+ }
+ }
+ else {
+ /* maximum priority, ok */
+ apfw_trace("app_getdisplay: priority heigh");
+ if (req->reqtype == ICO_APC_REQTYPE_REQUEST) {
+ if (ico_apf_resource_send_to_client(
+ conf->appid, ICO_APF_RESOURCE_STATE_ACQUIRED,
+ req->resid, req->device, req->id) != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("app_getdisplay: Leave(send(%s) Error)", conf->appid);
+ ico_uxf_window_control(conf->appid, req->id, ICO_UXF_APPSCTL_INVISIBLE, 0);
+ if (displaycontrol) {
+ (*displaycontrol)(conf, 1);
+ }
+ }
+ else {
+ req->state &= ~ICO_APC_REQSTATE_REPLYQUIET;
+ req->state |= ICO_APC_REQSTATE_REPLYACTIVE;
+ req->timer = ICO_APC_REQREPLY_MAXTIME;
+ timer_count ++;
+ }
+ }
+ else {
+ ico_uxf_window_control(conf->appid, req->id, ICO_UXF_APPSCTL_INVISIBLE, 0);
+ if (displaycontrol) {
+ (*displaycontrol)(conf, 1);
+ }
+ }
+ /* send change event to invisible application */
+ apfw_trace("app_getdisplay: next=%08x %s next_state=%x",
+ req->next, req->next ? req->next->conf->appid : " ",
+ req->next ? req->next->state : 0x9999);
+ if ((req->next) && ((req->next->state & ICO_APC_REQSTATE_WAITREQ) == 0)) {
+ p = req->next;
+ }
+ else {
+ p = NULL;
+ }
+ /* send all waitting applications */
+ i = 0;
+ while (1) {
+ if (p != NULL) {
+ if ((p->state & ICO_APC_REQSTATE_WAITREQ) == 0) {
+ p->state |= ICO_APC_REQSTATE_WAITREQ;
+ apfw_trace("app_getdisplay: overlaped(%s), waitting", p->conf->appid);
+ if (p->reqtype == ICO_APC_REQTYPE_REQUEST) {
+ if (ico_apf_resource_send_to_client(
+ p->conf->appid, ICO_APF_RESOURCE_STATE_DEPRIVED,
+ p->resid, p->device, p->id) != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("app_getdisplay: send(%s) Error)", p->conf->appid);
+ }
+ else {
+ req->state &= ~ICO_APC_REQSTATE_REPLYACTIVE;
+ p->state |= ICO_APC_REQSTATE_REPLYQUIET;
+ p->timer = ICO_APC_REQREPLY_MAXTIME;
+ timer_count ++;
+ }
+ }
+ ico_uxf_window_control(p->conf->appid, -1, ICO_UXF_APPSCTL_INVISIBLE, 1);
+ if (displaycontrol) {
+ (*displaycontrol)(p->conf, 0);
+ }
+ }
+ }
+ if (i >= czone->noverlap) break;
+ p = czone->overlap[i]->req;
+ i ++;
+ }
+ }
+ apfw_trace("app_getdisplay: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief app_freedisplay: free display zone resource(static function)
+ *
+ * @param[in] req request block
+ * @param[in] send send release event to client(1=send/0=no send)
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+app_freedisplay(ico_apc_request_t *req, const int send)
+{
+ int idx;
+ Ico_Uxf_conf_application *conf = req->conf;
+ ico_apc_dispzone_t *czone;
+ ico_apc_request_t *p;
+ ico_apc_request_t *bp;
+
+ apfw_trace("app_freedisplay: Entry(app=%s)", conf->appid);
+
+ czone = &dispzone[req->zoneidx];
+ idx = czone->conf->display->id;
+
+ ico_uxf_window_control(conf->appid, req->id, ICO_UXF_APPSCTL_INVISIBLE, 0);
+ if (displaycontrol) {
+ (*displaycontrol)(conf, 0);
+ }
+ if ((send !=0) && (req->reqtype == ICO_APC_REQTYPE_REQUEST)) {
+ (void) ico_apf_resource_send_to_client(
+ req->conf->appid, ICO_APF_RESOURCE_STATE_RELEASED,
+ req->resid, req->device, req->id);
+ }
+
+ /* find request */
+ p = czone->req;
+ bp = NULL;
+ while (p) {
+ if (p == req) break;
+ bp = p;
+ p = p->next;
+ }
+ if (! p) {
+ apfw_warn("app_freedisplay: Leave(request dose not exist)");
+ return;
+ }
+
+ /* release request table from zone table */
+ if (bp) {
+ bp->next = p->next;
+
+ /* request is waitted, no need other control*/
+ p->next = free_request;
+ free_request = p;
+ apfw_trace("app_freedisplay: Leave(request waited)");
+ return;
+ }
+ czone->req = p->next;
+ p->next = free_request;
+ free_request = p;
+
+ /* recalculate visible zone */
+ recalc_dispzone(idx);
+
+ apfw_trace("app_freedisplay: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief change_disprequest: change display zone resource(static function)
+ *
+ * @param[in] req request block
+ * @param[in] active active(1) or inactive(0)
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+change_disprequest(ico_apc_request_t *req, const int active)
+{
+ apfw_trace("change_disprequest: change to %s(%s)", active ? "active" : "inactive",
+ req->conf->appid);
+
+ req->state &= ~(ICO_APC_REQSTATE_REPLYACTIVE|ICO_APC_REQSTATE_REPLYQUIET);
+
+ if (req->reqtype == ICO_APC_REQTYPE_REQUEST) {
+ if (ico_apf_resource_send_to_client(
+ req->conf->appid,
+ active ? ICO_APF_RESOURCE_STATE_ACQUIRED :
+ ICO_APF_RESOURCE_STATE_DEPRIVED,
+ req->resid, req->device, req->id) != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("change_disprequest: send(%s) Error", req->conf->appid);
+ }
+ else {
+ req->state |= (active ? ICO_APC_REQSTATE_REPLYACTIVE :
+ ICO_APC_REQSTATE_REPLYQUIET);
+ req->timer = ICO_APC_REQREPLY_MAXTIME;
+ timer_count ++;
+ }
+ }
+ if ((req->state & ICO_APC_REQSTATE_REPLYACTIVE) == 0) {
+ ico_uxf_window_control(req->conf->appid, req->id, ICO_UXF_APPSCTL_INVISIBLE,
+ active ? 0 : 1);
+ if (displaycontrol) {
+ (*displaycontrol)(req->conf, active);
+ }
+ }
+ if (active) {
+ req->state &= ~ICO_APC_REQSTATE_WAITREQ;
+ }
+ else {
+ req->state |= ICO_APC_REQSTATE_WAITREQ;
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief recalc_dispzone: calculate all display zone request priority(static function)
+ *
+ * @param[in] idx display index number
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+recalc_dispzone(const int idx)
+{
+ int i;
+ int prio;
+ ico_apc_dispzone_t *czone;
+ ico_apc_dispzone_t *czone2;
+ ico_apc_request_t *p;
+ Ico_Uxf_conf_display *disp = &confsys->display[idx];
+
+ apfw_trace("recalc_dispzone: Enter(disp=%s)", disp->name);
+
+ /* get top of priority of this display */
+ prio = -1;
+ czone2 = NULL;
+ for (i = 0; i < disp->zoneNum; i++) {
+ czone = &dispzone[disp->zone[i].zoneidx];
+ p = czone->req;
+ if (! p) continue;
+ p->state |= ICO_APC_REQSTATE_WAITPROC;
+ if (p->prio > prio) {
+ czone2 = czone;
+ prio = p->prio;
+ }
+ }
+ if (czone2 == NULL) {
+ /* no visible zone, end */
+ apfw_trace("recalc_dispzone: Leave(no request)");
+ return;
+ }
+ if ((czone2->req->state & ICO_APC_REQSTATE_WAITREQ) == 0) {
+ /* not unvisible zone */
+ for (i = 0; i < disp->zoneNum; i++) {
+ czone = &dispzone[disp->zone[i].zoneidx];
+ p = czone->req;
+ if (! p) continue;
+ p->state &= ~ICO_APC_REQSTATE_WAITPROC;
+ }
+ apfw_trace("recalc_dispzone: Leave(%s no need visible control)",
+ czone2->req->conf->appid);
+ return;
+ }
+
+ /* change to show for top priority */
+ p = czone2->req;
+ p->state &= ~ICO_APC_REQSTATE_WAITPROC;
+ change_disprequest(p, 1);
+
+ /* hide overlap zone */
+ for (i = 0; i < czone2->noverlap; i++) {
+ p = czone2->overlap[i]->req;
+ if (p) {
+ if ((p->state & ICO_APC_REQSTATE_WAITREQ) == 0) {
+ p->state &= ~ICO_APC_REQSTATE_WAITPROC;
+ change_disprequest(p, 0);
+ }
+ }
+ }
+
+ /* show not overlap zone */
+ for (i = 0; i < disp->zoneNum; i++) {
+ czone = &dispzone[disp->zone[i].zoneidx];
+ p = czone->req;
+ if ((p == NULL) || ((p->state & ICO_APC_REQSTATE_WAITPROC) == 0)) continue;
+ p->state &= ~ICO_APC_REQSTATE_WAITPROC;
+ change_disprequest(p, 1);
+ }
+ apfw_trace("recalc_dispzone: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief app_getsound: get sound zone resource(static function)
+ *
+ * @param[in] req request block
+ * @param[in] addprio a priority to add to the priority of the request
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+app_getsound(ico_apc_request_t *req, const int addprio)
+{
+ int prio;
+ int i, j;
+ Ico_Uxf_conf_application *conf = req->conf;
+ Ico_Uxf_conf_sound_zone *zone;
+ ico_apc_soundzone_t *czone;
+ ico_apc_request_t *p;
+ ico_apc_request_t *bp;
+
+ /* priority */
+ prio = (confsys->category[conf->categoryId].priority * ICO_UXF_PRIO_CATEGORY);
+ prio += addprio;
+ if (ico_syc_apc_regulation_app_sound(conf->categoryId)) {
+ prio |= ICO_UXF_PRIO_REGULATION;
+ }
+ if (ico_uxf_process_is_active(conf->appid)) {
+ for (i = 0; i < nsoundzone; i++) {
+ p = soundzone[i].req;
+ while (p) {
+ if (p->prio & ICO_UXF_PRIO_ACTIVEAPP) {
+ p->prio -= ICO_UXF_PRIO_ACTIVECOUNT;
+ }
+ p = p->next;
+ }
+ }
+ prio |= ICO_UXF_PRIO_ACTIVEAPP;
+ }
+
+ /* get sound zone from device name */
+ for (i = 0; i < nsoundzone; i++) {
+ if (strcasecmp(soundzone[i].conf->name, req->device) == 0) break;
+ }
+ if (i >= nsoundzone) {
+ i = confsys->misc.default_soundzoneId;
+ apfw_trace("app_getsound: Entry(app=%s zone=%s(%s none) prio=%x(+%x) pid=%d)",
+ conf->appid, soundzone[i].conf->name, req->device, prio, addprio,
+ req->pid);
+ }
+ else {
+ apfw_trace("app_getsound: Entry(app=%s zone=%s prio=%x(+%x) pid=%d)",
+ conf->appid, soundzone[i].conf->name, prio, addprio, req->pid);
+ }
+ req->zoneidx = i;
+
+ czone = &soundzone[i];
+ zone = czone->conf;
+
+ /* search same request */
+ p = czone->req;
+ bp = NULL;
+ while (p) {
+ if ((p->conf == req->conf) && (p->resid == req->resid) &&
+ (p->zoneidx == req->zoneidx)) {
+ break;
+ }
+ bp = p;
+ p = p->next;
+ }
+ if (p) {
+ if (p->reqtype != ICO_APC_REQTYPE_REQUEST) {
+ apfw_trace("app_getsound: Leave(found same request)");
+ return;
+ }
+
+ if (p->prio > prio) {
+ prio = p->prio;
+ }
+ apfw_trace("app_getsound: found same request(app=%s zone=%s res=%d prio=%d)",
+ conf->appid, soundzone[i].conf->name, req->resid, prio);
+ if (bp) {
+ bp->next = p->next;
+ }
+ else {
+ czone->req = p->next;
+ }
+ p->next = free_request;
+ free_request = p;
+ }
+
+ /* link request to zone table */
+ req->prio = prio;
+ p = czone->req;
+ bp = NULL;
+ while (p) {
+ if (p->prio <= prio) break;
+ bp = p;
+ p = p->next;
+ }
+ if (bp) {
+ req->next = bp->next;
+ bp->next = req;
+ }
+ else {
+ req->next = czone->req;
+ czone->req = req;
+ }
+
+ /* check if maximum priority */
+ if (! bp) {
+ j = -1;
+ for (i =0; i < czone->noverlap; i++) {
+ if (((czone->overlap[i])->req != NULL) &&
+ ((czone->overlap[i])->req->prio > prio)) {
+ j = i;
+ prio = czone->overlap[i]->req->prio;
+ }
+ }
+ }
+ else {
+ j = 9999;
+ }
+ if ((j >= 0) || ((req->prio & ICO_UXF_PRIO_REGULATION) == 0)) {
+ /* lower priority, waitting this application. */
+ /* insert application to zone application list and */
+ /* change zone priority, if request application is top priority */
+ req->state |= ICO_APC_REQSTATE_WAITREQ;
+ if (ico_apf_resource_send_to_soundctl(ICO_APF_SOUND_COMMAND_MUTEON, req->pid)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("app_getsound: send MSM Error");
+ }
+ if (soundcontrol) {
+ (*soundcontrol)(conf, 0);
+ }
+ apfw_trace("app_getsound: priority low, waitting %s", conf->appid);
+ if (req->reqtype == ICO_APC_REQTYPE_REQUEST) {
+ if (ico_apf_resource_send_to_client(
+ conf->appid, ICO_APF_RESOURCE_STATE_WAITTING,
+ req->resid, req->device, req->id) != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("app_getsound: Leave(send(%s) Error)", conf->appid);
+ }
+ else {
+ req->state |= ICO_APC_REQSTATE_REPLYQUIET;
+ req->timer = ICO_APC_REQREPLY_MAXTIME;
+ timer_count ++;
+ }
+ }
+ }
+ else {
+ /* maximum priority, ok */
+ apfw_trace("app_getsound: priority heigh(%08x)", req->prio);
+ if (req->reqtype == ICO_APC_REQTYPE_REQUEST) {
+ if (ico_apf_resource_send_to_client(
+ conf->appid, ICO_APF_RESOURCE_STATE_ACQUIRED,
+ req->resid, req->device, req->id) != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("app_getsound: Leave(send(%s) Error)", conf->appid);
+ }
+ }
+ /* send change event to mute application */
+ apfw_trace("app_getsound: next=%08x %s next_state=%x",
+ req->next, req->next ? req->next->conf->appid : " ",
+ req->next ? req->next->state : 0x9999);
+ if ((req->next) && ((req->next->state & ICO_APC_REQSTATE_WAITREQ) == 0)) {
+ p = req->next;
+ }
+ else {
+ p = NULL;
+ }
+ /* send all waitting applications */
+ i = 0;
+ while (1) {
+ if (p != NULL) {
+ if ((p->state & ICO_APC_REQSTATE_WAITREQ) == 0) {
+ p->state |= ICO_APC_REQSTATE_WAITREQ;
+ apfw_trace("app_getsound: overlaped(%s), waitting", p->conf->appid);
+ if (p->reqtype == ICO_APC_REQTYPE_REQUEST) {
+ if (ico_apf_resource_send_to_client(
+ p->conf->appid, ICO_APF_RESOURCE_STATE_DEPRIVED,
+ p->resid, p->device, p->id) != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("app_getsound: send(%s) Error)", p->conf->appid);
+ }
+ else {
+ p->state |= ICO_APC_REQSTATE_REPLYQUIET;
+ p->timer = ICO_APC_REQREPLY_MAXTIME;
+ timer_count ++;
+ }
+ }
+ }
+ if (ico_apf_resource_send_to_soundctl(ICO_APF_SOUND_COMMAND_MUTEON, p->pid)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("app_getsound: send MSM Error");
+ }
+ if (soundcontrol) {
+ (*soundcontrol)(p->conf, 0);
+ }
+ }
+ if (i >= czone->noverlap) break;
+ p = czone->overlap[i]->req;
+ i ++;
+ }
+ }
+ apfw_trace("app_getsound: Leave(req=%08x,state=%x,prio=%08x)",
+ (int)req, req->state, req->prio);
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief app_freesound: free sound zone resource(static function)
+ *
+ * @param[in] req request block
+ * @param[in] send send release event to client(1=send/0=no send)
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+app_freesound(ico_apc_request_t *req, const int send)
+{
+ int idx;
+ Ico_Uxf_conf_application *conf = req->conf;
+ ico_apc_soundzone_t *czone;
+ ico_apc_request_t *p;
+ ico_apc_request_t *bp;
+
+ apfw_trace("app_freesound: Entry(app=%s)", conf->appid);
+
+ czone = &soundzone[req->zoneidx];
+ idx = czone->conf->sound->id;
+
+ if (ico_apf_resource_send_to_soundctl(ICO_APF_SOUND_COMMAND_MUTEON, req->pid)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("app_freesound: send MSM Error");
+ }
+ if (soundcontrol) {
+ (*soundcontrol)(conf, 0);
+ }
+ if ((send !=0) && (req->reqtype == ICO_APC_REQTYPE_REQUEST)) {
+ (void) ico_apf_resource_send_to_client(
+ req->conf->appid, ICO_APF_RESOURCE_STATE_RELEASED,
+ req->resid, req->device, req->id);
+ }
+
+ /* find request */
+ p = czone->req;
+ bp = NULL;
+ while (p) {
+ if (p == req) break;
+ bp = p;
+ p = p->next;
+ }
+ if (! p) {
+ apfw_warn("app_freesound: Leave(request dose not exist)");
+ return;
+ }
+
+ /* release request table from zone table */
+ if (bp) {
+ bp->next = p->next;
+
+ /* request is waitted, no need other control*/
+ p->next = free_request;
+ free_request = p;
+ apfw_trace("app_freesound: Leave(request waited)");
+ return;
+ }
+ czone->req = p->next;
+ p->next = free_request;
+ free_request = p;
+
+ /* recalculate visible zone */
+ recalc_soundzone(idx);
+
+ apfw_trace("app_freesound: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief change_soundrequest: change sound zone resource(static function)
+ *
+ * @param[in] req request block
+ * @param[in] active active(1) or quiet(0)
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+change_soundrequest(ico_apc_request_t *req, const int active)
+{
+ apfw_trace("change_soundrequest: change to %s(%s)", active ? "active" : "quiet",
+ req->conf->appid);
+
+ req->state &= ~(ICO_APC_REQSTATE_REPLYACTIVE|ICO_APC_REQSTATE_REPLYQUIET);
+
+ if (req->reqtype == ICO_APC_REQTYPE_REQUEST) {
+ if (ico_apf_resource_send_to_client(
+ req->conf->appid,
+ active ? ICO_APF_RESOURCE_STATE_ACQUIRED :
+ ICO_APF_RESOURCE_STATE_DEPRIVED,
+ req->resid, req->device, req->id) != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("change_soundrequest: send(%s) Error", req->conf->appid);
+ }
+ else {
+ req->state |= (active ? ICO_APC_REQSTATE_REPLYACTIVE :
+ ICO_APC_REQSTATE_REPLYQUIET);
+ req->timer = ICO_APC_REQREPLY_MAXTIME;
+ timer_count ++;
+ }
+ }
+ if ((req->state & ICO_APC_REQSTATE_REPLYACTIVE) == 0) {
+ if (ico_apf_resource_send_to_soundctl(
+ active ? ICO_APF_SOUND_COMMAND_MUTEOFF : ICO_APF_SOUND_COMMAND_MUTEON,
+ req->pid) != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("change_soundrequest: send MSM Error");
+ }
+ if (soundcontrol) {
+ (*soundcontrol)(req->conf, active);
+ }
+ }
+ if (active) {
+ req->state &= ~ICO_APC_REQSTATE_WAITREQ;
+ }
+ else {
+ req->state |= ICO_APC_REQSTATE_WAITREQ;
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief recalc_soundzone: calculate all sound zone request priority(static function)
+ *
+ * @param[in] idx sound index number
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+recalc_soundzone(const int idx)
+{
+ int i;
+ int prio;
+ ico_apc_soundzone_t *czone;
+ ico_apc_soundzone_t *czone2;
+ ico_apc_request_t *p;
+ Ico_Uxf_conf_sound *sound = &confsys->sound[idx];
+
+ apfw_trace("recalc_soundzone: Enter(sound=%s)", sound->name);
+
+ /* get top of priority of this sound */
+ prio = -1;
+ czone2 = NULL;
+ for (i = 0; i < sound->zoneNum; i++) {
+ czone = &soundzone[sound->zone[i].zoneidx];
+ p = czone->req;
+ if (! p) continue;
+ p->state |= ICO_APC_REQSTATE_WAITPROC;
+ if (p->prio > prio) {
+ czone2 = czone;
+ prio = p->prio;
+ }
+ }
+ if (czone2 == NULL) {
+ /* no active zone, end */
+ apfw_trace("recalc_soundzone: Leave(no request)");
+ return;
+ }
+ if ((czone2->req->state & ICO_APC_REQSTATE_WAITREQ) == 0) {
+ /* not quiet zone */
+ for (i = 0; i < sound->zoneNum; i++) {
+ czone = &soundzone[sound->zone[i].zoneidx];
+ p = czone->req;
+ if (! p) continue;
+ p->state &= ~ICO_APC_REQSTATE_WAITPROC;
+ }
+ apfw_trace("recalc_soundzone: Leave(%s no need sound control)",
+ czone2->req->conf->appid);
+ return;
+ }
+
+ /* change to active for top priority*/
+ p = czone2->req;
+ p->state &= ~ICO_APC_REQSTATE_WAITPROC;
+ if (p->prio & ICO_UXF_PRIO_REGULATION) {
+ apfw_trace("recalc_soundzone: Start %s(prio=%08x and no regulation)",
+ p->conf->appid, p->prio);
+ change_soundrequest(p, 1);
+ }
+
+ /* mute overlap zone */
+ for (i = 0; i < czone2->noverlap; i++) {
+ p = czone2->overlap[i]->req;
+ if (p) {
+ if ((p->state & ICO_APC_REQSTATE_WAITREQ) == 0) {
+ p->state &= ~ICO_APC_REQSTATE_WAITPROC;
+ if (p->prio & ICO_UXF_PRIO_REGULATION) {
+ apfw_trace("recalc_soundzone: Overlap Stop %s(top and no regulation)",
+ p->conf->appid);
+ change_soundrequest(p, 0);
+ }
+ else {
+ p->state |= ICO_APC_REQSTATE_WAITREQ;
+ }
+ }
+ }
+ }
+
+ /* reset mute not overlap zone */
+ for (i = 0; i < sound->zoneNum; i++) {
+ czone = &soundzone[sound->zone[i].zoneidx];
+ p = czone->req;
+ if ((p == NULL) || ((p->state & ICO_APC_REQSTATE_WAITPROC) == 0)) continue;
+ p->state &= ~ICO_APC_REQSTATE_WAITPROC;
+ if (p->state & ICO_APC_REQSTATE_WAITREQ) {
+ if (p->prio & ICO_UXF_PRIO_REGULATION) {
+ apfw_trace("recalc_soundzone: Overlap Start %s(top and no regulation)",
+ p->conf->appid);
+ change_soundrequest(p, 1);
+ }
+ }
+ }
+ apfw_trace("recalc_soundzone: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief app_getinput: get input switch resource(static function)
+ *
+ * @param[in] req request block
+ * @param[in] addprio a priority to add to the priority of the request
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+app_getinput(ico_apc_request_t *req, const int addprio)
+{
+ int prio;
+ int i;
+ Ico_Uxf_conf_application *conf = req->conf;
+ ico_apc_inputsw_t *czone;
+ ico_apc_request_t *p;
+ ico_apc_request_t *bp;
+
+ /* priority */
+ prio = (confsys->category[conf->categoryId].priority * ICO_UXF_PRIO_CATEGORY);
+ prio += addprio;
+ if (ico_syc_apc_regulation_app_input(conf->categoryId)) {
+ prio |= ICO_UXF_PRIO_REGULATION;
+ }
+ if (ico_uxf_process_is_active(conf->appid)) {
+ for (i = 0; i < ninputsw; i++) {
+ p = inputsw[i].req;
+ while (p) {
+ if (p->prio & ICO_UXF_PRIO_ACTIVEAPP) {
+ p->prio -= ICO_UXF_PRIO_ACTIVECOUNT;
+ }
+ p = p->next;
+ }
+ }
+ prio |= ICO_UXF_PRIO_ACTIVEAPP;
+ }
+
+ /* get input switch from device name */
+ for (i = 0; i < ninputsw; i++) {
+ if (strcasecmp(inputsw[i].inputsw->swname, req->device) == 0) break;
+ }
+ if (i >= ninputsw) {
+ i = confsys->misc.default_inputswId;
+ apfw_trace("app_getinput: Entry(app=%s inputsw=%s(%s none) prio=%x(+%x) pid=%d)",
+ conf->appid, inputsw[i].inputsw->swname, req->device, prio, addprio,
+ req->pid);
+ }
+ else {
+ apfw_trace("app_getinput: Entry(app=%s zone=%s prio=%x(+%x) pid=%d)",
+ conf->appid, inputsw[i].inputsw->swname, prio, addprio, req->pid);
+ }
+ req->zoneidx = i;
+
+ czone = &inputsw[i];
+
+ /* search same request */
+ p = czone->req;
+ bp = NULL;
+ while (p) {
+ if ((p->conf == req->conf) && (p->resid == req->resid) &&
+ (p->zoneidx == req->zoneidx)) {
+ break;
+ }
+ bp = p;
+ p = p->next;
+ }
+ if (p) {
+ if (p->reqtype != ICO_APC_REQTYPE_REQUEST) {
+ apfw_trace("app_getinput: Leave(found same request)");
+ return;
+ }
+
+ if (p->prio > prio) {
+ prio = p->prio;
+ }
+ apfw_trace("app_getinput: found same request(app=%s sw=%s res=%d prio=%d)",
+ conf->appid, inputsw[i].inputsw->swname, req->resid, prio);
+ if (bp) {
+ bp->next = p->next;
+ }
+ else {
+ czone->req = p->next;
+ }
+ p->next = free_request;
+ free_request = p;
+ }
+
+ /* link request to zone table */
+ req->prio = prio;
+ p = czone->req;
+ bp = NULL;
+ while (p) {
+ if (p->prio <= prio) break;
+ bp = p;
+ p = p->next;
+ }
+ if (bp) {
+ req->next = bp->next;
+ bp->next = req;
+ }
+ else {
+ req->next = czone->req;
+ czone->req = req;
+ }
+
+ if ((req->prio & ICO_UXF_PRIO_REGULATION) == 0) {
+ /* lower priority, waitting this application. */
+ /* insert application to zone application list and */
+ /* change zone priority, if request application is top priority */
+ req->state |= ICO_APC_REQSTATE_WAITREQ;
+ if (ico_uxf_input_control(0, req->conf->appid, czone->inputdev->device,
+ czone->inputsw->input) != ICO_UXF_EOK) {
+ apfw_warn("app_getinput: send MIM Error");
+ }
+ if (inputcontrol) {
+ (*inputcontrol)(conf, 0);
+ }
+ apfw_trace("app_getinput: priority low, waitting %s", conf->appid);
+ if (req->reqtype == ICO_APC_REQTYPE_REQUEST) {
+ if (ico_apf_resource_send_to_client(
+ conf->appid, ICO_APF_RESOURCE_STATE_WAITTING,
+ req->resid, req->device, req->id) != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("app_getinput: Leave(send(%s) Error)", conf->appid);
+ }
+ else {
+ req->state |= ICO_APC_REQSTATE_REPLYQUIET;
+ req->timer = ICO_APC_REQREPLY_MAXTIME;
+ timer_count ++;
+ }
+ }
+ }
+ else {
+ /* maximum priority, ok */
+ apfw_trace("app_getinput: priority heigh(%08x)", req->prio);
+ if (req->reqtype == ICO_APC_REQTYPE_REQUEST) {
+ if (ico_apf_resource_send_to_client(
+ conf->appid, ICO_APF_RESOURCE_STATE_ACQUIRED,
+ req->resid, req->device, req->id) != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("app_getinput: Leave(send(%s) Error)", conf->appid);
+ }
+ else {
+ req->state |= ICO_APC_REQSTATE_REPLYACTIVE;
+ req->timer = ICO_APC_REQREPLY_MAXTIME;
+ timer_count ++;
+ }
+ }
+ if (ico_uxf_input_control(1, req->conf->appid, czone->inputdev->device,
+ czone->inputsw->input) != ICO_UXF_EOK) {
+ apfw_warn("app_getinput: send MIM Error");
+ }
+ /* change lower priority stateus */
+ if ((req->next) && ((req->next->state & ICO_APC_REQSTATE_WAITREQ) == 0)) {
+ p = req->next;
+ p->state |= ICO_APC_REQSTATE_WAITREQ;
+ apfw_trace("app_getinput: lower priority(%s), waitting", p->conf->appid);
+ if (p->reqtype == ICO_APC_REQTYPE_REQUEST) {
+ if (ico_apf_resource_send_to_client(
+ p->conf->appid, ICO_APF_RESOURCE_STATE_DEPRIVED,
+ p->resid, p->device, p->id) != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("app_getinput: send(%s) Error)", p->conf->appid);
+ }
+ else {
+ p->state |= ICO_APC_REQSTATE_REPLYQUIET;
+ p->timer = ICO_APC_REQREPLY_MAXTIME;
+ timer_count ++;
+ }
+ }
+ }
+ }
+ apfw_trace("app_getinput: Leave(req=%08x,state=%x,prio=%08x)",
+ (int)req, req->state, req->prio);
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief app_freeinput: free input switch resource(static function)
+ *
+ * @param[in] req request block
+ * @param[in] send send release event to client(1=send/0=no send)
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+app_freeinput(ico_apc_request_t *req, const int send)
+{
+ Ico_Uxf_conf_application *conf = req->conf;
+ ico_apc_inputsw_t *czone;
+ ico_apc_request_t *p;
+ ico_apc_request_t *bp;
+
+ apfw_trace("app_freeinput: Entry(app=%s)", conf->appid);
+
+ czone = &inputsw[req->zoneidx];
+
+ if (ico_uxf_input_control(0, conf->appid, czone->inputdev->device,
+ czone->inputsw->input) != ICO_UXF_EOK) {
+ apfw_warn("app_freeinput: send MIM Error");
+ }
+ if (inputcontrol) {
+ (*inputcontrol)(conf, 0);
+ }
+ if ((send !=0) && (req->reqtype == ICO_APC_REQTYPE_REQUEST)) {
+ (void) ico_apf_resource_send_to_client(
+ req->conf->appid, ICO_APF_RESOURCE_STATE_RELEASED,
+ req->resid, req->device, req->id);
+ }
+
+ /* find request */
+ p = czone->req;
+ bp = NULL;
+ while (p) {
+ if (p == req) break;
+ bp = p;
+ p = p->next;
+ }
+ if (! p) {
+ apfw_warn("app_freeinput: Leave(request dose not exist)");
+ return;
+ }
+
+ /* release request table from zone table */
+ if (bp) {
+ bp->next = p->next;
+
+ /* request is waitted, no need other control*/
+ p->next = free_request;
+ free_request = p;
+ apfw_trace("app_freeinput: Leave(request waited)");
+ return;
+ }
+ czone->req = p->next;
+ p->next = free_request;
+ free_request = p;
+
+ /* recalculate visible zone */
+ recalc_inputsw(czone->inputsw->input);
+
+ apfw_trace("app_freeinput: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief change_inputrequest: change input switch resource(static function)
+ *
+ * @param[in] req request block
+ * @param[in] active use(1) or unuse(0)
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+change_inputrequest(ico_apc_request_t *req, const int active)
+{
+ ico_apc_inputsw_t *czone;
+
+ apfw_trace("change_inputrequest: change to %s(%s)", active ? "use" : "unuse",
+ req->conf->appid);
+
+ czone = &inputsw[req->zoneidx];
+
+ if (req->reqtype == ICO_APC_REQTYPE_REQUEST) {
+ if (ico_apf_resource_send_to_client(
+ req->conf->appid,
+ active ? ICO_APF_RESOURCE_STATE_ACQUIRED :
+ ICO_APF_RESOURCE_STATE_DEPRIVED,
+ req->resid, req->device, req->id) != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("change_inputrequest: send(%s) Error", req->conf->appid);
+ }
+ else {
+ req->state |= (active ? ICO_APC_REQSTATE_REPLYACTIVE :
+ ICO_APC_REQSTATE_REPLYQUIET);
+ req->timer = ICO_APC_REQREPLY_MAXTIME;
+ timer_count ++;
+ }
+ }
+ if (ico_uxf_input_control(active, req->conf->appid, czone->inputdev->device,
+ czone->inputsw->input) != ICO_UXF_EOK) {
+ apfw_warn("app_getinput: send MIM Error");
+ }
+ if (inputcontrol) {
+ (*inputcontrol)(req->conf, active);
+ }
+ if (active) {
+ req->state &= ~ICO_APC_REQSTATE_WAITREQ;
+ req->state |= ICO_APC_REQSTATE_REPLYACTIVE;
+ }
+ else {
+ req->state |= (ICO_APC_REQSTATE_WAITREQ | ICO_APC_REQSTATE_REPLYQUIET);
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief recalc_inputsw: calculate all input switch request priority(static function)
+ *
+ * @param[in] idx input switch index number
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+recalc_inputsw(const int idx)
+{
+ ico_apc_inputsw_t *czone = &inputsw[idx];
+ ico_apc_request_t *p;
+
+ apfw_trace("recalc_inputsw: Enter(input=%s)", czone->inputsw->swname);
+
+ /* get top of priority of this input */
+ p = czone->req;
+ if (p == NULL) {
+ /* no active request, end */
+ apfw_trace("recalc_inputsw: Leave(no request)");
+ return;
+ }
+ if ((p->state & ICO_APC_REQSTATE_WAITREQ) == 0) {
+ /* not wait request */
+ apfw_trace("recalc_inputsw: Leave(%s no need input control)", p->conf->appid);
+ return;
+ }
+
+ /* change to active for top priority*/
+ p->state &= ~ICO_APC_REQSTATE_WAITPROC;
+ if (p->prio & ICO_UXF_PRIO_REGULATION) {
+ apfw_trace("recalc_inputsw: Start %s(prio=%08x and no regulation)",
+ p->conf->appid, p->prio);
+ change_inputrequest(p, 1);
+ }
+
+ apfw_trace("recalc_inputsw: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief regulation_listener: change regulation callback(static function)
+ *
+ * @param[in] appcategory category Id
+ * @param[in] control control(display/sound/input active/inactive)
+ * @param[in] user_data user data(unused)
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+regulation_listener(const int appcategory,
+ const ico_apc_reguration_control_t control, void *user_data)
+{
+ int i, j, k;
+ int flag;
+ int disp, sound, input;
+ ico_apc_request_t *p;
+ ico_apc_request_t *bp;
+ ico_apc_request_t *p2;
+ ico_apc_request_t *bp2;
+ unsigned short reqdisp[MAXREQ];
+ unsigned short reqsound[MAXREQ];
+ unsigned short reqinput[MAXREQ];
+
+ disp = 0;
+ sound = 0;
+ input = 0;
+
+ if (control.display != ICO_SYC_APC_REGULATION_NOCHANGE) {
+ /* display regulation control */
+ apfw_trace("regulation_listener: disp category=%d display=%d",
+ appcategory, control.display);
+ for (i = 0; i < confapp->applicationNum; i++) {
+ if (confapp->application[i].categoryId != appcategory) continue;
+ for (k = 0; k < ndispzone; k++) {
+ p = dispzone[k].req;
+ if (!p) continue;
+ bp = NULL;
+ while (p) {
+ if (p->conf == &confapp->application[i]) {
+ flag = 0;
+ if (control.display == ICO_SYC_APC_REGULATION_REGULATION) {
+ if (p->prio & ICO_UXF_PRIO_REGULATION) {
+ p->prio &= ~ICO_UXF_PRIO_REGULATION;
+ flag ++;
+ ico_uxf_window_control(p->conf->appid, p->id,
+ ICO_UXF_APPSCTL_REGULATION, 1);
+ }
+ }
+ else {
+ if ((p->prio & ICO_UXF_PRIO_REGULATION) == 0) {
+ p->prio |= ICO_UXF_PRIO_REGULATION;
+ flag ++;
+ ico_uxf_window_control(p->conf->appid, p->id,
+ ICO_UXF_APPSCTL_REGULATION, 0);
+ }
+ }
+ if (flag) {
+ for (j = 0; j < disp; j++) {
+ if (dispzone[k].conf->display->id == reqdisp[j]) break;
+ }
+ if (j >= disp) {
+ reqdisp[disp++] = dispzone[k].conf->display->id;
+ }
+ apfw_trace("regulation_listener: disp %s %08x",
+ p->conf->appid, p->prio);
+ if (bp) {
+ bp->next = p->next;
+ }
+ else {
+ dispzone[k].req = p->next;
+ }
+ p2 = dispzone[k].req;
+ bp2 = NULL;
+ while (p2) {
+ if (p2->prio < p->prio) {
+ if (bp2) {
+ bp2->next = p;
+ p->next = p2;
+ if ((p->state & ICO_APC_REQSTATE_WAITREQ) == 0) {
+ change_disprequest(p, 0);
+ }
+ }
+ else {
+ p->next = dispzone[k].req;
+ dispzone[k].req = p;
+ if ((p->next != NULL) &&
+ ((p->next->state & ICO_APC_REQSTATE_WAITREQ)
+ == 0)) {
+ change_disprequest(p->next, 0);
+ }
+ }
+ break;
+ }
+ bp2 = p2;
+ p2 = p2->next;
+ }
+ if (! p2) {
+ if (bp2) {
+ bp2->next = p;
+ if ((p->state & ICO_APC_REQSTATE_WAITREQ) == 0) {
+ change_disprequest(p, 0);
+ }
+ }
+ else {
+ dispzone[k].req = p;
+ }
+ p->next = NULL;
+ }
+ break;
+ }
+ }
+ bp = p;
+ p = p->next;
+ }
+ }
+ }
+ }
+
+ if (control.sound != ICO_SYC_APC_REGULATION_NOCHANGE) {
+ /* sound regulation control */
+ apfw_trace("regulation_listener: sound category=%d sound=%d",
+ appcategory, control.sound);
+ for (i = 0; i < confapp->applicationNum; i++) {
+ if (confapp->application[i].categoryId != appcategory) continue;
+ for (k = 0; k < nsoundzone; k++) {
+ p = soundzone[k].req;
+ if (!p) continue;
+ bp = NULL;
+ while (p) {
+ if (p->conf == &confapp->application[i]) {
+ flag = 0;
+ if (control.sound == ICO_SYC_APC_REGULATION_REGULATION) {
+ if (p->prio & ICO_UXF_PRIO_REGULATION) {
+ p->prio &= ~ICO_UXF_PRIO_REGULATION;
+ flag ++;
+ if ((p->state & ICO_APC_REQSTATE_WAITREQ) == 0) {
+ change_soundrequest(p, 0);
+ }
+ }
+ }
+ else {
+ if ((p->prio & ICO_UXF_PRIO_REGULATION) == 0) {
+ p->prio |= ICO_UXF_PRIO_REGULATION;
+ flag ++;
+ }
+ }
+ if (flag) {
+ apfw_trace("regulation_listener: sound change category=%d "
+ "app(%s) sound=%d prio=%08x",
+ appcategory, p->conf->appid, control.sound, p->prio);
+ for (j = 0; j < sound; j++) {
+ if (soundzone[k].conf->sound->id == reqsound[j]) break;
+ }
+ if (j >= sound) {
+ reqsound[sound++] = soundzone[k].conf->sound->id;
+ }
+ apfw_trace("regulation_listener: sound %s %08x %08x",
+ p->conf->appid, p->prio, (int)bp);
+ if (bp) {
+ bp->next = p->next;
+ }
+ else {
+ soundzone[k].req = p->next;
+ }
+ p2 = soundzone[k].req;
+ bp2 = NULL;
+ while (p2) {
+ if (p2->prio < p->prio) {
+ if (bp2) {
+ bp2->next = p;
+ p->next = p2;
+ if ((p->state & ICO_APC_REQSTATE_WAITREQ) == 0) {
+ change_soundrequest(p, 0);
+ }
+ }
+ else {
+ p->next = soundzone[k].req;
+ soundzone[k].req = p;
+ if ((p->next != NULL) &&
+ ((p->next->state & ICO_APC_REQSTATE_WAITREQ)
+ == 0)) {
+ change_soundrequest(p->next, 0);
+ }
+ }
+ break;
+ }
+ bp2 = p2;
+ p2 = p2->next;
+ }
+ if (! p2) {
+ if (bp2) {
+ bp2->next = p;
+ if ((p->state & ICO_APC_REQSTATE_WAITREQ) == 0) {
+ change_soundrequest(p, 0);
+ }
+ }
+ else {
+ soundzone[k].req = p;
+ }
+ p->next = NULL;
+ }
+ break;
+ }
+ }
+ bp = p;
+ p = p->next;
+ }
+ }
+ }
+ }
+
+ if (control.input != ICO_SYC_APC_REGULATION_NOCHANGE) {
+ /* input reguration control */
+ apfw_trace("regulation_listener: input category=%d input=%d",
+ appcategory, control.input);
+ for (i = 0; i < confapp->applicationNum; i++) {
+ if (confapp->application[i].categoryId != appcategory) continue;
+ for (k = 0; k < ninputsw; k++) {
+ p = inputsw[k].req;
+ if (!p) continue;
+ bp = NULL;
+ while (p) {
+ if (p->conf == &confapp->application[i]) {
+ flag = 0;
+ if (control.input == ICO_SYC_APC_REGULATION_REGULATION) {
+ if (p->prio & ICO_UXF_PRIO_REGULATION) {
+ p->prio &= ~ICO_UXF_PRIO_REGULATION;
+ flag ++;
+ if ((p->state & ICO_APC_REQSTATE_WAITREQ) == 0) {
+ change_inputrequest(p, 0);
+ }
+ }
+ }
+ else {
+ if ((p->prio & ICO_UXF_PRIO_REGULATION) == 0) {
+ p->prio |= ICO_UXF_PRIO_REGULATION;
+ flag ++;
+ }
+ }
+ if (flag) {
+ apfw_trace("regulation_listener: input change category=%d "
+ "app(%s) input=%d prio=%08x",
+ appcategory, p->conf->appid, control.input, p->prio);
+ for (j = 0; j < sound; j++) {
+ if (inputsw[k].inputsw->input == reqinput[j]) break;
+ }
+ if (j >= input) {
+ reqinput[input++] = inputsw[k].inputsw->input;
+ }
+ apfw_trace("regulation_listener: input %s %08x %08x",
+ p->conf->appid, p->prio, (int)bp);
+ if (bp) {
+ bp->next = p->next;
+ }
+ else {
+ inputsw[k].req = p->next;
+ }
+ p2 = inputsw[k].req;
+ bp2 = NULL;
+ while (p2) {
+ if (p2->prio < p->prio) {
+ if (bp2) {
+ bp2->next = p;
+ p->next = p2;
+ if ((p->state & ICO_APC_REQSTATE_WAITREQ) == 0) {
+ change_inputrequest(p, 0);
+ }
+ }
+ else {
+ p->next = inputsw[k].req;
+ inputsw[k].req = p;
+ }
+ break;
+ }
+ bp2 = p2;
+ p2 = p2->next;
+ }
+ if (! p2) {
+ if (bp2) {
+ bp2->next = p;
+ if ((p->state & ICO_APC_REQSTATE_WAITREQ) == 0) {
+ change_inputrequest(p, 0);
+ }
+ }
+ else {
+ inputsw[k].req = p;
+ }
+ p->next = NULL;
+ }
+ break;
+ }
+ }
+ bp = p;
+ p = p->next;
+ }
+ }
+ }
+ }
+
+ /* re-calculate display zone, sound zone and inout switch priority */
+ for (i = 0; i < disp; i++) {
+ recalc_dispzone(reqdisp[i]);
+ }
+ for (i = 0; i < sound; i++) {
+ recalc_soundzone(reqsound[i]);
+ }
+ for (i = 0; i < input; i++) {
+ recalc_inputsw(reqinput[i]);
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief request_timer: request timedout timer(static function)
+ *
+ * @param[in] user_data user data(unused)
+ * @return always ECORE_CALLBACK_RENEW(periodic timer)
+ */
+/*--------------------------------------------------------------------------*/
+static Eina_Bool
+request_timer(void *user_data)
+{
+ int i;
+ ico_apc_request_t *p;
+
+ if (timer_count <= 0) {
+ /* no need timedout check */
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ timer_count = 0;
+
+ /* check display request timedout */
+ for (i = 0; i < ndispzone; i++) {
+ p = dispzone[i].req;
+ while (p) {
+ if (p->timer > 0) {
+ p->timer --;
+ if (p->timer == 0) {
+ apfw_trace("request_timer: display timedout(%s %d %d prio=%08x)",
+ p->conf->appid, p->resid, p->id, p->prio);
+ if ((p->state & ICO_APC_REQSTATE_REPLYACTIVE) &&
+ ((p->state & ICO_APC_REQSTATE_WAITREQ) == 0)) {
+ ico_uxf_window_control(p->conf->appid, p->id,
+ ICO_UXF_APPSCTL_INVISIBLE, 0);
+ if (displaycontrol) {
+ (*displaycontrol)(p->conf, 1);
+ }
+ }
+ p->state &= ~(ICO_APC_REQSTATE_REPLYACTIVE|ICO_APC_REQSTATE_REPLYQUIET);
+ }
+ }
+ else {
+ timer_count ++;
+ }
+ p = p->next;
+ }
+ }
+
+ /* check sound request timedout */
+ for (i = 0; i < nsoundzone; i++) {
+ p = soundzone[i].req;
+ while (p) {
+ if (p->timer > 0) {
+ p->timer --;
+ if (p->timer == 0) {
+ apfw_trace("request_timer: sound timedout(%s %d %d prio=%08x)",
+ p->conf->appid, p->resid, p->id, p->prio);
+ if ((p->state & ICO_APC_REQSTATE_REPLYACTIVE) &&
+ ((p->state & ICO_APC_REQSTATE_WAITREQ) == 0)) {
+ if (ico_apf_resource_send_to_soundctl(ICO_APF_SOUND_COMMAND_MUTEOFF,
+ p->pid)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("request_timer: send MSM Error");
+ }
+ if (soundcontrol) {
+ (*soundcontrol)(p->conf, 1);
+ }
+ }
+ p->state &= ~(ICO_APC_REQSTATE_REPLYACTIVE|ICO_APC_REQSTATE_REPLYQUIET);
+ }
+ }
+ else {
+ timer_count ++;
+ }
+ p = p->next;
+ }
+ }
+ return ECORE_CALLBACK_RENEW;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_syc_apc_active: application change to active
+ *
+ * @param[in] appid application Id
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+ico_syc_apc_active(const char *appid)
+{
+ int i, j;
+ int disp, sound, input;
+ int flag;
+ Ico_Uxf_conf_application *appconf;
+ ico_apc_request_t *p;
+ ico_apc_request_t *bp;
+ ico_apc_request_t *p2;
+ ico_apc_request_t *bp2;
+ unsigned short reqdisp[MAXREQ];
+ unsigned short reqsound[MAXREQ];
+ unsigned short reqinput[MAXREQ];
+
+ apfw_trace("ico_syc_apc_active: Enter(%s)", appid ? appid : "(NULL)");
+
+ if ((appid != NULL) && (*appid != 0)) {
+ /* get active application */
+ appconf = (Ico_Uxf_conf_application *)ico_uxf_getAppByAppid(appid);
+ if (! appconf) {
+ apfw_trace("ico_syc_apc_active: appid(%s) dose not exist", appid);
+ }
+ }
+ else {
+ /* chane to no active application */
+ appconf = NULL;
+ }
+
+ /* change all screen request from this application */
+ disp = 0;
+ for (i = 0; i < ndispzone; i++) {
+ p = dispzone[i].req;
+ flag = 0;
+ bp = NULL;
+ while (p) {
+ if (p->conf == appconf) {
+ apfw_trace("ico_syc_apc_active: disp %s prio=%08x is %s",
+ p->conf->appid, p->prio, bp ? "not top" : "top");
+ if ((p->prio & ICO_UXF_PRIO_ACTIVEAPP) != ICO_UXF_PRIO_ACTIVEAPP) {
+ p->prio |= ICO_UXF_PRIO_ACTIVEAPP;
+ apfw_trace("ico_syc_apc_active: cgange active %s prio to %08x",
+ p->conf->appid, p->prio);
+ flag ++;
+
+ if (bp) {
+ bp->next = p->next;
+ p2 = dispzone[i].req;
+ bp2 = NULL;
+ while (p2) {
+ if (p2->prio <= p->prio) {
+ p->next = p2;
+ if (bp2) {
+ apfw_trace("ico_syc_apc_active: %s is not top=%s(%08x)",
+ p->conf->appid, dispzone[i].req->conf->appid,
+ dispzone[i].req->prio);
+ bp2->next = p;
+ }
+ else {
+ if ((p2->conf != appconf) &&
+ ((p2->state & ICO_APC_REQSTATE_WAITREQ) == 0)) {
+ change_disprequest(p2, 0);
+ }
+ dispzone[i].req = p;
+ }
+ break;
+ }
+ bp2 = p2;
+ p2 = p2->next;
+ }
+ if (! p2) {
+ apfw_trace("ico_syc_apc_active: %s is not top=%s(%08x)",
+ p->conf->appid, dispzone[i].req->conf->appid,
+ dispzone[i].req->prio);
+ if (bp2) {
+ bp2->next = p;
+ }
+ else {
+ dispzone[i].req = p;
+ }
+ p->next = NULL;
+ }
+ }
+ else {
+ apfw_trace("ico_syc_apc_active: app %s is top", p->conf->appid);
+ }
+ }
+ }
+ bp = p;
+ p = p->next;
+ }
+ if (flag) {
+ p = dispzone[i].req;
+ while (p) {
+ if (p->prio & ICO_UXF_PRIO_ACTIVEAPP) {
+ p->prio -= ICO_UXF_PRIO_ACTIVECOUNT;
+ }
+ p = p->next;
+ }
+
+ for (j = 0; j < disp; j++) {
+ if (dispzone[i].conf->display->id == reqdisp[j]) break;
+ }
+ if (j >= disp) {
+ reqdisp[disp++] = dispzone[i].conf->display->id;
+ }
+ }
+ }
+
+ /* change all sound request from this application */
+ sound = 0;
+ for (i = 0; i < nsoundzone; i++) {
+ p = soundzone[i].req;
+ flag = 0;
+ bp = NULL;
+ while (p) {
+ if (p->conf == appconf) {
+ apfw_trace("ico_syc_apc_active: sound %s prio=%08x is %s",
+ p->conf->appid, p->prio, bp ? "not top" : "top");
+ if ((p->prio & ICO_UXF_PRIO_ACTIVEAPP) != ICO_UXF_PRIO_ACTIVEAPP) {
+ p->prio |= ICO_UXF_PRIO_ACTIVEAPP;
+ apfw_trace("ico_syc_apc_active: cgange active %s prio to %08x",
+ p->conf->appid, p->prio);
+ flag ++;
+
+ if (bp) {
+ bp->next = p->next;
+ p2 = soundzone[i].req;
+ bp2 = NULL;
+ while (p2) {
+ if (p2->prio <= p->prio) {
+ p->next = p2;
+ if (bp2) {
+ apfw_trace("ico_syc_apc_active: %s is not top=%s(%08x)",
+ p->conf->appid, soundzone[i].req->conf->appid,
+ soundzone[i].req->prio);
+ bp2->next = p;
+ }
+ else {
+ if ((p2->conf != appconf) &&
+ ((p2->state & ICO_APC_REQSTATE_WAITREQ) == 0)) {
+ change_soundrequest(p2, 0);
+ }
+ soundzone[i].req = p;
+ }
+ break;
+ }
+ bp2 = p2;
+ p2 = p2->next;
+ }
+ if (! p2) {
+ apfw_trace("ico_syc_apc_active: %s is not top=%s(%08x)",
+ p->conf->appid, soundzone[i].req->conf->appid,
+ soundzone[i].req->prio);
+ if (bp2) {
+ bp2->next = p;
+ }
+ else {
+ soundzone[i].req = p;
+ }
+ p->next = NULL;
+ }
+ }
+ else {
+ apfw_trace("ico_syc_apc_active: app %s is top", p->conf->appid);
+ }
+ }
+ }
+ bp = p;
+ p = p->next;
+ }
+ if (flag) {
+ p = soundzone[i].req;
+ while (p) {
+ if (p->prio & ICO_UXF_PRIO_ACTIVEAPP) {
+ p->prio -= ICO_UXF_PRIO_ACTIVECOUNT;
+ }
+ p = p->next;
+ }
+
+ for (j = 0; j < sound; j++) {
+ if (soundzone[i].conf->sound->id == reqsound[j]) break;
+ }
+ if (j >= sound) {
+ reqsound[sound++] = soundzone[i].conf->sound->id;
+ }
+ }
+ }
+
+ /* change all inputsw request from this application */
+ input = 0;
+ for (i = 0; i < ninputsw; i++) {
+ p = inputsw[i].req;
+ flag = 0;
+ bp = NULL;
+ while (p) {
+ if (p->conf == appconf) {
+ if ((p->prio & ICO_UXF_PRIO_ACTIVEAPP) != ICO_UXF_PRIO_ACTIVEAPP) {
+ p->prio |= ICO_UXF_PRIO_ACTIVEAPP;
+ apfw_trace("ico_syc_apc_active: cgange active %s prio to %08x",
+ p->conf->appid, p->prio);
+ flag ++;
+
+ if (bp) {
+ bp->next = p->next;
+ p2 = inputsw[i].req;
+ bp2 = NULL;
+ while (p2) {
+ if (p2->prio <= p->prio) {
+ p->next = p2;
+ if (bp2) {
+ apfw_trace("ico_syc_apc_active: %s is not top=%s(%08x)",
+ p->conf->appid, inputsw[i].req->conf->appid,
+ inputsw[i].req->prio);
+ bp2->next = p;
+ }
+ else {
+ if ((p2->conf != appconf) &&
+ ((p2->state & ICO_APC_REQSTATE_WAITREQ) == 0)) {
+ change_inputrequest(p2, 0);
+ }
+ inputsw[i].req = p;
+ }
+ break;
+ }
+ bp2 = p2;
+ p2 = p2->next;
+ }
+ if (! p2) {
+ apfw_trace("ico_syc_apc_active: %s is not top=%s(%08x)",
+ p->conf->appid, inputsw[i].req->conf->appid,
+ inputsw[i].req->prio);
+ if (bp2) {
+ bp2->next = p;
+ }
+ else {
+ inputsw[i].req = p;
+ }
+ p->next = NULL;
+ }
+ }
+ else {
+ apfw_trace("ico_syc_apc_active: app %s is top", p->conf->appid);
+ }
+ }
+ }
+ bp = p;
+ p = p->next;
+ }
+ if (flag) {
+ p = inputsw[i].req;
+ while (p) {
+ if (p->prio & ICO_UXF_PRIO_ACTIVEAPP) {
+ p->prio -= ICO_UXF_PRIO_ACTIVECOUNT;
+ }
+ p = p->next;
+ }
+
+ for (j = 0; j < input; j++) {
+ if (inputsw[i].inputsw->input == reqinput[j]) break;
+ }
+ if (j >= input) {
+ reqinput[input++] = inputsw[i].inputsw->input;
+ }
+ }
+ }
+
+ /* re-calculate display zone, sound zone and inout switch priority */
+ for (i = 0; i < disp; i++) {
+ recalc_dispzone(reqdisp[i]);
+ }
+ for (i = 0; i < sound; i++) {
+ recalc_soundzone(reqsound[i]);
+ }
+ for (i = 0; i < input; i++) {
+ recalc_inputsw(reqinput[i]);
+ }
+ apfw_trace("ico_syc_apc_active: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief app_display_hook: hook function for surface create/destroy(static function)
+ *
+ * @param[in] appid application Id
+ * @param[in] surface surface Id
+ * @param[in] object target surface type and operation
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+app_display_hook(const char *appid, const int surface, const int object)
+{
+ int i;
+ int count;
+ ico_apc_request_t *reqsave[MAXREQ];
+ Ico_Uxf_conf_application *appconf;
+ ico_apc_request_t *req;
+
+ apfw_trace("app_display_hook: Enter(%s,%x,%x)", appid, surface, object);
+
+ appconf = (Ico_Uxf_conf_application *)ico_uxf_getAppByAppid(appid);
+ if (! appconf) {
+ apfw_warn("app_display_hook: Leave(appid[%s] dose not exist)", appid);
+ return;
+ }
+ if ((confsys->kind[appconf->kindId].priv == ICO_UXF_PRIVILEGE_ALMIGHTY) ||
+ (confsys->kind[appconf->kindId].priv == ICO_UXF_PRIVILEGE_SYSTEM)) {
+ /* System Program(ex. HomeScreen) no need resource control */
+ apfw_trace("app_display_hook: Leave(appid[%s] is system program)", appid);
+ return;
+ }
+
+ switch (object) {
+ case ICO_UXF_HOOK_WINDOW_CREATE_MAIN: /* created application main window */
+ /* search display request */
+ for (i = 0; i < ndispzone; i++) {
+ req = dispzone[i].req;
+ while (req) {
+ if ((req->conf == appconf) &&
+ (req->resid == ICO_APF_RESID_BASIC_SCREEN)) break;
+ req = req->next;
+ }
+ if (req) break;
+ }
+ if (i < ndispzone) {
+ apfw_trace("app_display_hook: app(%s) requested display, Nop", appid);
+ }
+ else {
+ apfw_trace("app_display_hook: app(%s) not requested display, set default",
+ appid);
+ req = get_freereq();
+ if (req) {
+ req->conf = appconf;
+ req->resid = ICO_APF_RESID_BASIC_SCREEN;
+ req->reqtype = ICO_APC_REQTYPE_CREATE;
+ strcpy(req->device,
+ confsys->display[confsys->misc.default_displayId].
+ zone[confsys->misc.default_dispzoneId].name);
+ app_getdisplay(req, 0);
+ }
+ }
+ break;
+ case ICO_UXF_HOOK_WINDOW_DESTORY_MAIN: /* destoryed application main window*/
+ /* delete all request from this application */
+ count = 0;
+ for (i = 0; i < ndispzone; i++) {
+ req = dispzone[i].req;
+ while (req) {
+ if (req->conf == appconf) {
+ reqsave[count++] = req;
+ }
+ req = req->next;
+ }
+ }
+ if (count > 0) {
+ apfw_trace("app_display_hook: free app(%s) all display request", appid);
+ for (i = 0; i < count; i++) {
+ app_freedisplay(reqsave[i], 0);
+ }
+ }
+ break;
+ default: /* other, Nop */
+ break;
+ }
+
+ apfw_trace("app_display_hook: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_syc_apc_init: initialize application controller
+ *
+ * @param[in] display callback function for display control
+ * @param[in] sound callback function for sound control
+ * @param[in] input callback function for input control
+ * @return result
+ * @retval ICO_SYC_EOK success
+ * @retval ICO_SYC_ENOSYS error(system error)
+ * @retval ICO_SYC_ENOMEM error(out of memory)
+ */
+/*--------------------------------------------------------------------------*/
+int
+ico_syc_apc_init(ico_apc_resource_control_t display, ico_apc_resource_control_t sound,
+ ico_apc_resource_control_t input)
+{
+ int count;
+ int base_count;
+ int i, j, k;
+ int ret;
+ Ico_Uxf_InputDev *pdev;
+ Ico_Uxf_InputSw *psw;
+
+ apfw_trace("ico_syc_apc_init: Enter");
+
+ if (ico_apps_controller_init) {
+ apfw_trace("ico_syc_apc_init: Leave(OK, initialized)");
+ return ICO_SYC_EOK;
+ }
+
+ /* set callback functions for HomeScreen */
+ displaycontrol = display;
+ soundcontrol = sound;
+ inputcontrol = input;
+
+ ico_apps_controller_init = 1;
+
+ /* get configurations */
+ confsys = (Ico_Uxf_Sys_Config *)ico_uxf_getSysConfig();
+ confapp = (Ico_Uxf_App_Config *)ico_uxf_getAppConfig();
+
+ if ((! confsys) || (! confapp)) {
+ ico_apps_controller_init = 0;
+ apfw_error("ico_syc_apc_init: Leave(can not read configuration)");
+ return ICO_SYC_ENOSYS;
+ }
+
+ /* initialize internal tables */
+ /* display zone table */
+ ndispzone = 0;
+ for (i = 0; i < confsys->displayNum; i++) {
+ ndispzone += confsys->display[i].zoneNum;
+ }
+ dispzone = malloc(sizeof(ico_apc_dispzone_t) * ndispzone);
+ if (! dispzone) {
+ ico_apps_controller_init = 0;
+ apfw_error("ico_syc_apc_init: Leave(No Memory)");
+ return ICO_SYC_ENOMEM;
+ }
+ memset(dispzone, 0, sizeof(ico_apc_dispzone_t) * ndispzone);
+ count = 0;
+ for (i = 0; i < confsys->displayNum; i++) {
+ base_count = count;
+ for (j = 0; j < confsys->display[i].zoneNum; j++) {
+ dispzone[count].conf = &confsys->display[i].zone[j];
+ dispzone[count].noverlap = confsys->display[i].zone[j].overlapNum;
+ for (k = 0; k < dispzone[count].noverlap; k++) {
+ dispzone[count].overlap[k] =
+ &dispzone[base_count + confsys->display[i].zone[j].overlap[k]];
+ }
+ count ++;
+ }
+ }
+
+ /* sound zone table */
+ nsoundzone = 0;
+ for (i = 0; i < confsys->soundNum; i++) {
+ nsoundzone += confsys->sound[i].zoneNum;
+ }
+ soundzone = malloc(sizeof(ico_apc_soundzone_t) * nsoundzone);
+ if (! soundzone) {
+ ico_apps_controller_init = 0;
+ apfw_error("ico_syc_apc_init: Leave(No Memory)");
+ return ICO_SYC_ENOMEM;
+ }
+ memset(soundzone, 0, sizeof(ico_apc_dispzone_t) * nsoundzone);
+ count = 0;
+ for (i = 0; i < confsys->soundNum; i++) {
+ base_count = count;
+ for (j = 0; j < confsys->sound[i].zoneNum; j++) {
+ soundzone[count].conf = &confsys->sound[i].zone[j];
+ soundzone[count].noverlap = confsys->sound[i].zone[j].overlapNum;
+ for (k = 0; k < soundzone[count].noverlap; j++) {
+ soundzone[count].overlap[k] =
+ &soundzone[base_count + confsys->sound[i].zone[j].overlap[k]];
+ }
+ count ++;
+ }
+ }
+ /* input sw table */
+ ninputsw = 0;
+ for (i = 0; ; i++) {
+ pdev = ico_uxf_inputdev_attribute_get(i);
+ if (pdev == NULL) break;
+ apfw_trace("ico_syc_apc_init: input device.%d %s has %d switchs",
+ i, pdev->device, pdev->numInputSw);
+ for (j = 0; j < pdev->numInputSw; j++) {
+ psw = ico_uxf_inputsw_attribute_get(pdev, j);
+ if (psw == NULL) break;
+ if (psw->fix == 0) {
+ ninputsw ++;
+ }
+ }
+ }
+ if (ninputsw > 0) {
+ inputsw = malloc(sizeof(ico_apc_inputsw_t) * ninputsw);
+ if (! inputsw) {
+ ico_apps_controller_init = 0;
+ apfw_error("ico_syc_apc_init: Leave(No Memory)");
+ return ICO_SYC_ENOMEM;
+ }
+ memset(inputsw, 0, sizeof(ico_apc_inputsw_t) * ninputsw);
+ count = 0;
+ for (i = 0; ; i++) {
+ pdev = ico_uxf_inputdev_attribute_get(i);
+ if (pdev == NULL) break;
+ for (j = 0; j < pdev->numInputSw; j++) {
+ psw = ico_uxf_inputsw_attribute_get(pdev, j);
+ if (psw == NULL) break;
+ if (psw->fix) continue;
+ inputsw[count].inputdev = pdev;
+ inputsw[count].inputsw = psw;
+ count ++;
+ }
+ }
+ }
+
+ /* initialize request table */
+ ico_apc_request_t *req = malloc(sizeof(ico_apc_request_t) * 50);
+ ico_apc_request_t *breq;
+ if (! req) {
+ ico_apps_controller_init = 0;
+ apfw_error("ico_syc_apc_init: Leave(No Memory)");
+ return ICO_SYC_ENOMEM;
+ }
+ memset(req, 0, sizeof(ico_apc_request_t) * 50);
+ free_request = req;
+ for (count = 1; count < 50; count++) {
+ breq = req;
+ req ++;
+ breq->next = req;
+ }
+
+ /* initialzie application framework library */
+ ret = ico_apf_ecore_init_server(NULL);
+ if (ret != ICO_APF_E_NONE) {
+ ico_apps_controller_init = 0;
+ apfw_error("ico_syc_apc_init: Leave(ico_apf_ecore_init_server Error<%d>)", ret);
+ return ICO_SYC_ENOSYS;
+ }
+
+ /* regist callback for application resource request */
+ ret = ico_apf_resource_set_event_cb(resource_reqcb, NULL);
+ if (ret != ICO_APF_RESOURCE_E_NONE) {
+ ico_apps_controller_init = 0;
+ apfw_error("ico_syc_apc_init: Leave(ico_apf_resource_set_event_cb Error<%d>)",
+ ret);
+ ico_apf_resource_term_server();
+ return ICO_SYC_ENOSYS;
+ }
+
+ /* initialize regulation controller */
+ ret = ico_syc_apc_regulation_init();
+ if (ret != ICO_SYC_EOK) {
+ ico_apps_controller_init = 0;
+ apfw_error("ico_syc_apc_init: Leave(ico_syc_apc_regulation_init Error<%d>)",
+ ret);
+ ico_apf_resource_term_server();
+ return ICO_SYC_ENOSYS;
+ }
+
+ ico_syc_apc_regulation_listener(regulation_listener, NULL);
+
+ /* set hook for window create/destory */
+ (void) ico_uxf_window_hook(app_display_hook);
+
+ /* create timer */
+ ecore_timer = ecore_timer_add(0.1, request_timer, NULL);
+
+ /* send sound stream list request to Multi Sound manager */
+ ret = ico_apf_resource_send_to_soundctl(ICO_APF_SOUND_COMMAND_GETLIST, 0);
+ if (ret != ICO_APF_RESOURCE_E_NONE) {
+ apfw_error("ico_syc_apc_init: Leave(ico_apf_resource_send_to_soundctl Error<%d>)",
+ ret);
+ return ICO_SYC_ENOSYS;
+ }
+
+ apfw_trace("ico_syc_apc_init: Leave(EOK)");
+ return ICO_SYC_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_syc_apc_term: terminate application controller
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+ico_syc_apc_term(void)
+{
+ apfw_trace("ico_syc_apc_term: Enter");
+ if (ico_apps_controller_init == 0) {
+ apfw_trace("ico_syc_apc_term: Leave(not initialized)");
+ return;
+ }
+ if (ecore_timer) {
+ ecore_timer_del(ecore_timer);
+ ecore_timer = NULL;
+ }
+
+ ico_syc_apc_regulation_term();
+ ico_apf_resource_term_server();
+ ico_apps_controller_init = 0;
+
+ apfw_trace("ico_syc_apc_term: Leave");
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief header file of Apprications Controller internal(private)
+ *
+ * @date Feb-28-2013
+ */
+
+#ifndef _ICO_SYC_APC_PRIVATE_H_
+#define _ICO_SYC_APC_PRIVATE_H_
+
+#include <aul/aul.h>
+#include <ico_input_mgr-client-protocol.h>
+#include "ico_apf_log.h"
+#include "ico_uxf_sysdef.h"
+#include "ico_uxf_conf.h"
+#include "ico_apf_resource_control.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* D-Bus target */
+#define DBUS_SERVICE "org.automotive.message.broker"
+#define DBUS_INTERFACE "org.freedesktop.DBus.Properties"
+#define DBUS_METHOD "Get"
+
+/* define struct */
+/* request information */
+typedef struct _ico_apc_request {
+ struct _ico_apc_request *next; /* requestt list link */
+ Ico_Uxf_conf_application *conf; /* application configuration */
+ ico_apf_resid_e resid; /* resource id */
+ char device[ICO_UXF_MAX_DEVICE_NAME+1];
+ /* request device */
+ int id; /* request object */
+ int bid; /* request base object */
+ int pid; /* request client pid */
+ int prio; /* request priority */
+ unsigned short zoneidx; /* request target zone index */
+ unsigned short timer; /* Reply wait timer */
+ unsigned short state; /* status */
+ unsigned short reqtype; /* Request type */
+} ico_apc_request_t;
+
+#define ICO_APC_REQTYPE_REQUEST 0 /* Request from application */
+#define ICO_APC_REQTYPE_CREATE 1 /* Request automaticaly */
+
+#define ICO_APC_REQREPLY_MAXTIME 500 /* Maximum reply wait (ms) */
+#define ICO_APC_REQSTATE_WAITREQ 0x01 /* Waitting resource */
+#define ICO_APC_REQSTATE_WAITPROC 0x08 /* Priotiry process work flag */
+#define ICO_APC_REQSTATE_MASK 0x0f /* State mask */
+#define ICO_APC_REQSTATE_REPLYACTIVE 0x20 /* Wait reply for active */
+#define ICO_APC_REQSTATE_REPLYQUIET 0x10 /* Wait reply for hide */
+
+/* application request table */
+typedef struct _ico_apc_apprequest {
+} ico_apc_apprequest_t;
+
+/* display zone */
+typedef struct _ico_apc_dispzone {
+ ico_apc_request_t *req; /* request list link */
+ Ico_Uxf_conf_display_zone *conf; /* configuration */
+ short res; /* (unused) */
+ short noverlap; /* number of overlap zone */
+ /* overlap zone */
+ struct _ico_apc_dispzone *overlap[ICO_UXF_DISPLAY_ZONE_MAX];
+} ico_apc_dispzone_t;
+
+/* sound zone */
+typedef struct _ico_apc_soundzone {
+ ico_apc_request_t *req; /* request list link */
+ Ico_Uxf_conf_sound_zone *conf; /* configuration */
+ short res; /* (unused) */
+ short noverlap; /* number of overlap zone */
+ /* overlap zone */
+ struct _ico_apc_soundzone *overlap[ICO_UXF_SOUND_ZONE_MAX];
+} ico_apc_soundzone_t;
+
+/* input sw */
+typedef struct _ico_apc_inputsw {
+ ico_apc_request_t *req; /* request list link */
+ Ico_Uxf_InputDev *inputdev; /* input device attribute */
+ Ico_Uxf_InputSw *inputsw; /* input switch attribute */
+} ico_apc_inputsw_t;
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _ICO_SYC_APC_PRIVATE_H_ */
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief Regulation controller
+ *
+ * @date Feb-28-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdbool.h>
+#include <string.h>
+#include <errno.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <fcntl.h>
+
+#include <wayland-client.h>
+#include <ico_window_mgr-client-protocol.h>
+#include <dbus/dbus.h>
+#include <Ecore.h>
+#include "ico_apf.h"
+#include "ico_syc_apc.h"
+#include "ico_syc_apc_private.h"
+
+/*==============================================================================*/
+/* static tables */
+/*==============================================================================*/
+/* callback function */
+static ico_apc_regulation_cb_t regulation_cb = NULL;
+static void *regulation_cb_user_data = NULL;
+
+/* Ecore/D-Bus static valiables */
+static Ecore_Timer *vehicle_timer = NULL;
+static DBusConnection *dbus_connection = NULL;
+static ico_apc_reguration_control_t control[ICO_UXF_CATEGORY_MAX];
+
+/* vehicle information */
+static const struct _vehicle_info_property {
+ int key; /* Vehicle Information key */
+ char *property; /* D-Bus property name */
+ char *path; /* D-Bus path name */
+ char *interface; /* D-Bus interface name */
+} vehicle_info[] = {
+ { ICO_SYC_VEHICLEINFO_VEHICLE_SPEED, "VehicleSpeed",
+ "/org/automotive/runningstatus/vehicleSpeed", "org.automotive.vehicleSpeed" },
+ { ICO_SYC_VEHICLEINFO_SHIFT_POSITION, "ShiftPosition",
+ "/org/automotive/runningstatus/transmission", "org.automotive.transmission" },
+ { ICO_SYC_VEHICLEINFO_BLINKER, "Blinker",
+ "\0", "\0" },
+ { 0, "\0", "\0", "\0" }
+};
+
+/* Vehicle information data */
+static struct _vehicle_info_data {
+ int key; /* Vehicle Information key */
+ DBusPendingCall *pending;
+ int request;
+ int errcount;
+ double val;
+} vehicle_data[ICO_UXF_REGULATION_VIC_MAX];
+
+/* system configuration */
+static Ico_Uxf_Sys_Config *confsys = NULL;
+static int ncategory;
+static Ico_Uxf_conf_category *category;
+
+/*==============================================================================*/
+/* define static function prototype */
+/*==============================================================================*/
+static int request_vehicle_info(void);
+static int get_vehicle_info(void);
+static Eina_Bool rule_engine_wake(void *user_data);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief request_vehicle_info: request to AMB(static function)
+ *
+ * @param none
+ * @return result
+ * @retval ICO_SYC_EOK success
+ * @retval ICO_SYC_EIO error(D-Bus send error)
+ */
+/*--------------------------------------------------------------------------*/
+static int
+request_vehicle_info(void)
+{
+ DBusMessage *dbus_message = NULL;
+ int idx;
+ int ret = ICO_SYC_EOK;
+
+ for (idx = 0; vehicle_info[idx].key; idx++) {
+
+ /* set vehicle info key */
+ vehicle_data[idx].key = vehicle_info[idx].key;
+
+ if (vehicle_data[idx].pending) {
+ apfw_trace("request_vehicle_info: (%s) not complite",
+ vehicle_info[idx].property);
+ continue;
+ }
+
+ if (vehicle_info[idx].path[0] == 0) {
+ /* currently not support this vehicle information */
+ continue;
+ }
+
+ /* Create send message */
+ dbus_message = dbus_message_new_method_call(DBUS_SERVICE, vehicle_info[idx].path,
+ DBUS_INTERFACE, DBUS_METHOD);
+ if (! dbus_message) {
+ apfw_warn("request_vehicle_info: ERROR dbus_message_new_method_call" );
+ ret = ICO_SYC_EIO;
+ }
+ /* Set parameters into message */
+ else if (! dbus_message_append_args(
+ dbus_message,
+ DBUS_TYPE_STRING, &vehicle_info[idx].interface,
+ DBUS_TYPE_STRING, &vehicle_info[idx].property,
+ DBUS_TYPE_INVALID)) {
+ apfw_warn("request_vehicle_info: ERROR dbus_message_append_args" );
+ ret = ICO_SYC_EIO;
+ }
+ /* Set destination */
+ else if (! dbus_message_set_destination(dbus_message, DBUS_SERVICE)) {
+ apfw_warn("request_vehicle_info: ERROR dbus_message_set_destination" );
+ ret = ICO_SYC_EIO;
+ }
+ /* Send message */
+ else if (! dbus_connection_send_with_reply(
+ dbus_connection, dbus_message,
+ &vehicle_data[idx].pending, 200)) {
+ apfw_warn("request_vehicle_info: ERROR dbus_connection_send" );
+ vehicle_data[idx].pending = NULL;
+ ret = ICO_SYC_EIO;
+ }
+ if (dbus_message) {
+ /* Release message */
+ dbus_message_unref(dbus_message);
+ }
+ }
+
+ /* dispatch if data queue exist */
+ do {
+ dbus_connection_read_write_dispatch(dbus_connection, 0);
+ } while (dbus_connection_get_dispatch_status(dbus_connection)
+ == DBUS_DISPATCH_DATA_REMAINS);
+
+ return(ret);
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief get_vehicle_info: get vercle information from AMB(static function)
+ *
+ * @param none
+ * @return always ICO_SYC_EOK(success)
+ */
+/*--------------------------------------------------------------------------*/
+static int
+get_vehicle_info(void)
+{
+ DBusMessage *dbus_message = NULL;
+ DBusMessageIter iter_head;
+ DBusMessageIter iter;
+ int idx;
+ char type;
+ int32_t i32;
+ int16_t i16;
+ uint32_t u32;
+ uint16_t u16;
+ dbus_bool_t b;
+ uint8_t u8;
+ double d64;
+
+ /* dispatch if data queue exist */
+ do {
+ dbus_connection_read_write_dispatch(dbus_connection, 0);
+ } while (dbus_connection_get_dispatch_status(dbus_connection)
+ == DBUS_DISPATCH_DATA_REMAINS);
+
+ /* analize reply datas */
+ for (idx = 0; vehicle_info[idx].key; idx++) {
+ if (! vehicle_data[idx].pending) {
+ continue;
+ }
+ if (! dbus_pending_call_get_completed(vehicle_data[idx].pending)) {
+ apfw_trace("get_vehicle_info: (%s) NOT complite",
+ vehicle_info[idx].property);
+ continue;
+ }
+
+ dbus_message = dbus_pending_call_steal_reply(vehicle_data[idx].pending);
+ if (! dbus_message) {
+ apfw_trace("get_vehicle_info: (%s) NO reply", vehicle_info[idx].property);
+ continue;
+ }
+
+ if (dbus_message_get_type(dbus_message) == DBUS_MESSAGE_TYPE_ERROR) {
+ dbus_message_unref(dbus_message);
+ dbus_pending_call_cancel(vehicle_data[idx].pending);
+ vehicle_data[idx].pending = NULL;
+ vehicle_data[idx].errcount ++;
+ if (vehicle_data[idx].errcount <= 5) {
+ apfw_warn("get_vehicle_info: (%s) reply error", vehicle_info[idx].property);
+ }
+ continue;
+ }
+
+ dbus_message_iter_init(dbus_message, &iter_head);
+ dbus_message_iter_recurse(&iter_head, &iter);
+
+ type = dbus_message_iter_get_arg_type(&iter);
+ switch (type) {
+ case DBUS_TYPE_INT32:
+ dbus_message_iter_get_basic(&iter, &i32);
+ vehicle_data[idx].val = (double)i32;
+ break;
+ case DBUS_TYPE_INT16:
+ dbus_message_iter_get_basic(&iter, &i16);
+ vehicle_data[idx].val = (double)i16;
+ break;
+ case DBUS_TYPE_UINT32:
+ dbus_message_iter_get_basic(&iter, &u32);
+ vehicle_data[idx].val = (double)u32;
+ break;
+ case DBUS_TYPE_UINT16:
+ dbus_message_iter_get_basic(&iter, &u16);
+ vehicle_data[idx].val = (double)u16;
+ break;
+ case DBUS_TYPE_BOOLEAN:
+ dbus_message_iter_get_basic(&iter, &b);
+ if (b) vehicle_data[idx].val = (double)1.0;
+ else vehicle_data[idx].val = (double)0.0;
+ break;
+ case DBUS_TYPE_BYTE:
+ dbus_message_iter_get_basic(&iter, &u8);
+ vehicle_data[idx].val = (double)u8;
+ break;
+ case DBUS_TYPE_DOUBLE:
+ dbus_message_iter_get_basic(&iter, &d64);
+ vehicle_data[idx].val = (double)d64;
+ break;
+ default:
+ apfw_warn("get_vehicle_info: (%s) illegal data type(0x%02x)",
+ vehicle_info[idx].property, ((int)type) & 0x0ff);
+ break;
+ }
+ /* free message and pending */
+ dbus_message_unref(dbus_message);
+ dbus_pending_call_cancel(vehicle_data[idx].pending);
+ vehicle_data[idx].pending = NULL;
+ };
+ return ICO_SYC_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief rule_engine_wake: judge a run regulation state(static function)
+ *
+ * @param[in] user_data user data(unused)
+ * @return always ECORE_CALLBACK_RENEW(periodic timer)
+ */
+/*--------------------------------------------------------------------------*/
+static Eina_Bool
+rule_engine_wake(void *user_data)
+{
+ int idx;
+ ico_apc_reguration_control_t wkcontrol[ICO_UXF_CATEGORY_MAX];
+ ico_apc_reguration_control_t change;
+ double VehicleSpeed = 0.0;
+ int ShiftPosition = 0;
+ int Blinker = 0;
+
+ memset(wkcontrol, 0, sizeof(ico_apc_reguration_control_t) * ncategory);
+
+ /* get reply (vehicle ifno) */
+ get_vehicle_info();
+
+ /* get vehicle info values */
+ for (idx = 0; vehicle_data[idx].key; idx++) {
+ if (vehicle_data[idx].key == ICO_SYC_VEHICLEINFO_VEHICLE_SPEED) {
+ VehicleSpeed = (double)vehicle_data[idx].val;
+ }
+ else if (vehicle_data[idx].key == ICO_SYC_VEHICLEINFO_SHIFT_POSITION) {
+ ShiftPosition = (int)vehicle_data[idx].val;
+ }
+ else if (vehicle_data[idx].key == ICO_SYC_VEHICLEINFO_BLINKER) {
+ Blinker = (int)vehicle_data[idx].val;
+ }
+ }
+
+ /* Make control code */
+ memcpy(wkcontrol, control, sizeof(ico_apc_reguration_control_t) * ncategory);
+
+ /* Check Vehicle Speed */
+ for (idx = 0; idx < ncategory; idx++) {
+ switch (category[idx].view) {
+ case ICO_UXF_POLICY_ALWAYS:
+ wkcontrol[idx].display = ICO_SYC_APC_REGULATION_NOREGULATION;
+ break;
+ case ICO_UXF_POLICY_RUNNING:
+ if (VehicleSpeed >= ICO_SYC_APC_REGULATION_SPEED_RUNNING)
+ wkcontrol[idx].display = ICO_SYC_APC_REGULATION_NOREGULATION;
+ else
+ wkcontrol[idx].display = ICO_SYC_APC_REGULATION_REGULATION;
+ break;
+ case ICO_UXF_POLICY_PARKED:
+ if (VehicleSpeed >= ICO_SYC_APC_REGULATION_SPEED_RUNNING)
+ wkcontrol[idx].display = ICO_SYC_APC_REGULATION_REGULATION;
+ else
+ wkcontrol[idx].display = ICO_SYC_APC_REGULATION_NOREGULATION;
+ break;
+ case ICO_UXF_POLICY_SHIFT_PARKING:
+ if ((VehicleSpeed < ICO_SYC_APC_REGULATION_SPEED_RUNNING) &&
+ (ShiftPosition == ICO_SYC_APC_REGULATION_SHIFT_PARKING))
+ wkcontrol[idx].display = ICO_SYC_APC_REGULATION_REGULATION;
+ else
+ wkcontrol[idx].display = ICO_SYC_APC_REGULATION_NOREGULATION;
+ break;
+ case ICO_UXF_POLICY_SHIFT_REVERSES:
+ if (ShiftPosition == ICO_SYC_APC_REGULATION_SHIFT_REVERSES)
+ wkcontrol[idx].display = ICO_SYC_APC_REGULATION_NOREGULATION;
+ else
+ wkcontrol[idx].display = ICO_SYC_APC_REGULATION_REGULATION;
+ break;
+ case ICO_UXF_POLICY_BLINKER_LEFT:
+ if ((Blinker != ICO_SYC_APC_REGULATION_BLINKER_LEFT) ||
+ (ShiftPosition == ICO_SYC_APC_REGULATION_SHIFT_PARKING) ||
+ (ShiftPosition == ICO_SYC_APC_REGULATION_SHIFT_REVERSES))
+ wkcontrol[idx].display = ICO_SYC_APC_REGULATION_REGULATION;
+ else
+ wkcontrol[idx].display = ICO_SYC_APC_REGULATION_NOREGULATION;
+ break;
+ case ICO_UXF_POLICY_BLINKER_RIGHT:
+ if ((Blinker != ICO_SYC_APC_REGULATION_BLINKER_RIGHT) ||
+ (ShiftPosition == ICO_SYC_APC_REGULATION_SHIFT_PARKING) ||
+ (ShiftPosition == ICO_SYC_APC_REGULATION_SHIFT_REVERSES))
+ wkcontrol[idx].display = ICO_SYC_APC_REGULATION_REGULATION;
+ else
+ wkcontrol[idx].display = ICO_SYC_APC_REGULATION_NOREGULATION;
+ break;
+ default:
+ apfw_trace("rule_engine_wake: category(%d) has unknown view(%d)",
+ idx, category[idx].view);
+ break;
+ }
+
+ switch (category[idx].sound) {
+ case ICO_UXF_POLICY_ALWAYS:
+ wkcontrol[idx].sound = ICO_SYC_APC_REGULATION_NOREGULATION;
+ break;
+ case ICO_UXF_POLICY_RUNNING:
+ if (VehicleSpeed >= ICO_SYC_APC_REGULATION_SPEED_RUNNING)
+ wkcontrol[idx].sound = ICO_SYC_APC_REGULATION_NOREGULATION;
+ else
+ wkcontrol[idx].sound = ICO_SYC_APC_REGULATION_REGULATION;
+ break;
+ case ICO_UXF_POLICY_PARKED:
+ if (VehicleSpeed >= ICO_SYC_APC_REGULATION_SPEED_RUNNING)
+ wkcontrol[idx].sound = ICO_SYC_APC_REGULATION_REGULATION;
+ else
+ wkcontrol[idx].sound = ICO_SYC_APC_REGULATION_NOREGULATION;
+ break;
+ case ICO_UXF_POLICY_SHIFT_PARKING:
+ if (ShiftPosition == ICO_SYC_APC_REGULATION_SHIFT_PARKING)
+ wkcontrol[idx].sound = ICO_SYC_APC_REGULATION_NOREGULATION;
+ else
+ wkcontrol[idx].sound = ICO_SYC_APC_REGULATION_REGULATION;
+ break;
+ case ICO_UXF_POLICY_SHIFT_REVERSES:
+ if (ShiftPosition == ICO_SYC_APC_REGULATION_SHIFT_REVERSES)
+ wkcontrol[idx].sound = ICO_SYC_APC_REGULATION_NOREGULATION;
+ else
+ wkcontrol[idx].sound = ICO_SYC_APC_REGULATION_REGULATION;
+ break;
+ case ICO_UXF_POLICY_BLINKER_LEFT:
+ if ((Blinker != ICO_SYC_APC_REGULATION_BLINKER_LEFT) ||
+ (ShiftPosition == ICO_SYC_APC_REGULATION_SHIFT_PARKING) ||
+ (ShiftPosition == ICO_SYC_APC_REGULATION_SHIFT_REVERSES))
+ wkcontrol[idx].sound = ICO_SYC_APC_REGULATION_REGULATION;
+ else
+ wkcontrol[idx].sound = ICO_SYC_APC_REGULATION_NOREGULATION;
+ break;
+ case ICO_UXF_POLICY_BLINKER_RIGHT:
+ if ((Blinker != ICO_SYC_APC_REGULATION_BLINKER_RIGHT) ||
+ (ShiftPosition == ICO_SYC_APC_REGULATION_SHIFT_PARKING) ||
+ (ShiftPosition == ICO_SYC_APC_REGULATION_SHIFT_REVERSES))
+ wkcontrol[idx].sound = ICO_SYC_APC_REGULATION_REGULATION;
+ else
+ wkcontrol[idx].sound = ICO_SYC_APC_REGULATION_NOREGULATION;
+ break;
+ default:
+ apfw_trace("rule_engine_wake: category(%d) has unknown sound(%d)",
+ idx, category[idx].sound);
+ break;
+ }
+
+ switch (category[idx].input) {
+ case ICO_UXF_POLICY_ALWAYS:
+ wkcontrol[idx].input = ICO_SYC_APC_REGULATION_NOREGULATION;
+ break;
+ case ICO_UXF_POLICY_RUNNING:
+ if (VehicleSpeed >= ICO_SYC_APC_REGULATION_SPEED_RUNNING)
+ wkcontrol[idx].input = ICO_SYC_APC_REGULATION_NOREGULATION;
+ else
+ wkcontrol[idx].input = ICO_SYC_APC_REGULATION_REGULATION;
+ break;
+ case ICO_UXF_POLICY_PARKED:
+ if (VehicleSpeed >= ICO_SYC_APC_REGULATION_SPEED_RUNNING)
+ wkcontrol[idx].input = ICO_SYC_APC_REGULATION_REGULATION;
+ else
+ wkcontrol[idx].input = ICO_SYC_APC_REGULATION_NOREGULATION;
+ break;
+ case ICO_UXF_POLICY_SHIFT_PARKING:
+ if (ShiftPosition == ICO_SYC_APC_REGULATION_SHIFT_PARKING)
+ wkcontrol[idx].input = ICO_SYC_APC_REGULATION_NOREGULATION;
+ else
+ wkcontrol[idx].input = ICO_SYC_APC_REGULATION_REGULATION;
+ break;
+ case ICO_UXF_POLICY_SHIFT_REVERSES:
+ if (ShiftPosition == ICO_SYC_APC_REGULATION_SHIFT_REVERSES)
+ wkcontrol[idx].input = ICO_SYC_APC_REGULATION_NOREGULATION;
+ else
+ wkcontrol[idx].input = ICO_SYC_APC_REGULATION_REGULATION;
+ break;
+ case ICO_UXF_POLICY_BLINKER_LEFT:
+ if ((Blinker != ICO_SYC_APC_REGULATION_BLINKER_LEFT) ||
+ (ShiftPosition == ICO_SYC_APC_REGULATION_SHIFT_PARKING) ||
+ (ShiftPosition == ICO_SYC_APC_REGULATION_SHIFT_REVERSES))
+ wkcontrol[idx].input = ICO_SYC_APC_REGULATION_REGULATION;
+ else
+ wkcontrol[idx].input = ICO_SYC_APC_REGULATION_NOREGULATION;
+ break;
+ case ICO_UXF_POLICY_BLINKER_RIGHT:
+ if ((Blinker != ICO_SYC_APC_REGULATION_BLINKER_RIGHT) ||
+ (ShiftPosition == ICO_SYC_APC_REGULATION_SHIFT_PARKING) ||
+ (ShiftPosition == ICO_SYC_APC_REGULATION_SHIFT_REVERSES))
+ wkcontrol[idx].input = ICO_SYC_APC_REGULATION_REGULATION;
+ else
+ wkcontrol[idx].input = ICO_SYC_APC_REGULATION_NOREGULATION;
+ break;
+ default:
+ apfw_trace("rule_engine_wake: category(%d) has unknown input(%d)",
+ idx, category[idx].input);
+ break;
+ }
+ }
+
+ for (idx = 0; idx < ncategory; idx++) {
+ if ((control[idx].display != wkcontrol[idx].display) ||
+ (control[idx].sound != wkcontrol[idx].sound) ||
+ (control[idx].input != wkcontrol[idx].input)) {
+ apfw_trace("rule_engine_wake: Category.%d view.%d>%d sound.%d>%d inp.%d>%d",
+ idx, control[idx].display, wkcontrol[idx].display,
+ control[idx].sound, wkcontrol[idx].sound,
+ control[idx].input, wkcontrol[idx].input);
+
+ if (regulation_cb) {
+ if (control[idx].display != wkcontrol[idx].display)
+ change.display = wkcontrol[idx].display;
+ else
+ change.display = ICO_SYC_APC_REGULATION_NOCHANGE;
+ if (control[idx].sound != wkcontrol[idx].sound)
+ change.sound = wkcontrol[idx].sound;
+ else
+ change.sound = ICO_SYC_APC_REGULATION_NOCHANGE;
+ if (control[idx].input != wkcontrol[idx].input)
+ change.input = wkcontrol[idx].input;
+ else
+ change.input = ICO_SYC_APC_REGULATION_NOCHANGE;
+
+ (*regulation_cb)(idx, change, regulation_cb_user_data);
+ }
+ control[idx].display = wkcontrol[idx].display;
+ control[idx].sound = wkcontrol[idx].sound;
+ control[idx].input = wkcontrol[idx].input;
+ }
+ }
+ /* send request to AMB */
+ request_vehicle_info();
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_syc_apc_regulation_init: initialize regulation control
+ *
+ * @param none
+ * @return result
+ * @retval ICO_SYC_EOK success
+ * @retval ICO_SYC_EIO error(D-Bus initialize error)
+ */
+/*--------------------------------------------------------------------------*/
+int
+ico_syc_apc_regulation_init(void)
+{
+ int i;
+ DBusError dbus_error;
+
+ apfw_trace("ico_syc_apc_regulation_init: Enter");
+
+ /* get configurations */
+ confsys = (Ico_Uxf_Sys_Config *)ico_uxf_getSysConfig();
+
+ if (! confsys) {
+ apfw_trace("ico_syc_apc_regulation_init: Leave(can not read configuration)");
+ return ICO_SYC_EIO;
+ }
+ ncategory = confsys->categoryNum;
+ category = confsys->category;
+
+ memset(vehicle_data, 0, sizeof(vehicle_data));
+ memset(control, 0, sizeof(control));
+ for (i = 0; i <ncategory; i++) {
+ control[i].display = ICO_SYC_APC_REGULATION_NOREGULATION;
+ control[i].sound = ICO_SYC_APC_REGULATION_NOREGULATION;
+ control[i].input = ICO_SYC_APC_REGULATION_NOREGULATION;
+ }
+
+ /* Reset D-Bus error */
+ dbus_error_init(&dbus_error);
+
+ /* Get D-Bus connection */
+ dbus_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error);
+ if (! dbus_connection){
+ apfw_warn("ico_syc_apc_regulation_init: Leave(ERROR dbus_bus_get)" );
+ return ICO_SYC_EIO;
+ }
+
+ /* send request to AMB */
+ request_vehicle_info();
+
+ vehicle_timer = ecore_timer_add(0.1, rule_engine_wake, NULL);
+ if (! vehicle_timer) {
+ apfw_error("ico_syc_apc_regulation_init: Leave(Can not create Ecore timer)");
+ }
+
+ apfw_trace("ico_syc_apc_regulation_init: Leave(EOK)");
+
+ return ICO_SYC_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_syc_apc_regulation_term: terminate regulation control
+ *
+ * @param none
+ * @return always ICO_SYC_EOK(success)
+ */
+/*--------------------------------------------------------------------------*/
+int
+ico_syc_apc_regulation_term(void)
+{
+ apfw_trace("ico_syc_apc_regulation_term: Enter");
+
+ if (! confsys) {
+ apfw_trace("ico_syc_apc_regulation_term: Leave(not initialized)");
+ return ICO_SYC_EOK;
+ }
+ ecore_timer_del(vehicle_timer);
+
+ confsys = NULL;
+
+ apfw_trace("ico_syc_apc_regulation_term: Leave(EOK)");
+ return ICO_SYC_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_syc_apc_regulation_listener: set regulation control listener
+ *
+ * @param[in] func listener function
+ * @param[in] user_data user data
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+ico_syc_apc_regulation_listener(ico_apc_regulation_cb_t func, void *user_data)
+{
+ int idx;
+
+ regulation_cb = func;
+ regulation_cb_user_data = user_data;
+
+ if (regulation_cb) {
+ for (idx = 0; idx < ncategory; idx++) {
+ (*regulation_cb)(idx, control[idx], regulation_cb_user_data);
+ }
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_syc_apc_regulation_app_visible: get display regulation status
+ *
+ * @param[in] category category Id
+ * @return result
+ * @retval TRUE The application of this category can use the display
+ * @retval FALSE The application of this category can not use the display
+ */
+/*--------------------------------------------------------------------------*/
+int
+ico_syc_apc_regulation_app_visible(const int category)
+{
+ if ((category < 0) || (category >= ICO_UXF_CATEGORY_MAX)) {
+ apfw_warn("ico_syc_apc_regulation_app_visible: Illegal category(%d)", category);
+ return TRUE;
+ }
+ if (control[category].display == ICO_SYC_APC_REGULATION_NOREGULATION) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_syc_apc_regulation_app_sound: get sound reguration status
+ *
+ * @param[in] category category Id
+ * @return result
+ * @retval TRUE The application of this category can use the sound output
+ * @retval FALSE The application of this category can not use the sound output
+ */
+/*--------------------------------------------------------------------------*/
+int
+ico_syc_apc_regulation_app_sound(const int category)
+{
+ if ((category < 0) || (category >= ICO_UXF_CATEGORY_MAX)) {
+ apfw_warn("ico_syc_apc_regulation_app_sound: Illegal category(%d)", category);
+ return TRUE;
+ }
+ if (control[category].sound == ICO_SYC_APC_REGULATION_NOREGULATION) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_syc_apc_regulation_app_input: get input switch reguration status
+ *
+ * @param[in] category category Id
+ * @return result
+ * @retval TRUE The application of this category is available with an input
+ * @retval FALSE The application of this category is not available with an input
+ */
+/*--------------------------------------------------------------------------*/
+int
+ico_syc_apc_regulation_app_input(const int category)
+{
+ if ((category < 0) || (category >= ICO_UXF_CATEGORY_MAX)) {
+ apfw_warn("ico_syc_apc_regulation_app_input: Illegal category(%d)", category);
+ return TRUE;
+ }
+ if (control[category].input == ICO_SYC_APC_REGULATION_NOREGULATION) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
--- /dev/null
+noinst_LIBRARIES = libico_syc-apc.a
+
+noinst_PROGRAMS = \
+ apc_test
+
+includedir = /usr/include/ico-uxf-weston-plugin
+
+libico_syc_apc_a_CFLAGS = -I/usr/include/ico-uxf-weston-plugin -I../include $(EFL_CFLAGS) @DBUS_CFLAGS@ @GLIB_CFLAGS@
+libico_syc_apc_a_SOURCES = \
+ ico_syc_apc_control.c \
+ ico_syc_apc_regulation.c
+
+AM_CFLAGS = $(GCC_CFLAGS)
+AM_CPPFLAGS = $(GCC_CFLAGS) \
+ -DDATADIR='"$(datadir)"' \
+ -DMODULEDIR='"$(moduledir)"' \
+ -DLIBEXECDIR='"$(libexecdir)"'
+
+check_PROGRAMS = apc_test
+
+AM_LDFLAGS = -module -avoid-version -rpath $(libdir) -lwayland-egl -lEGL -lGLESv2
+
+apc_test_lib = libico_syc-apc.a ../ico-app-framework/.libs/libico-app-fw-efl.so ../ico-app-framework/.libs/libico-app-fw.so -lico-uxf-weston-plugin -lwebsockets $(AUL_LIBS)
+apc_test_dbus = -ldbus-1
+
+apc_test_SOURCE = apc_test.c
+apc_test_CFLAGS = -I/usr/include/ico-uxf-weston-plugin -I../include $(EFL_CFLAGS) @DBUS_CFLAGS@ @GLIB_CFLAGS@
+apc_test_LDADD = $(apc_test_lib) $(apc_test_dbus) -lrt -lm
+
+.FORCE :
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief Applocation Controller Policy library test
+ *
+ * @date Feb-15-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdbool.h>
+#include <string.h>
+#include <errno.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <fcntl.h>
+#include <Ecore.h>
+
+#include "ico_syc_apc.h"
+#include "ico_syc_apc_private.h"
+
+static Ecore_Task_Cb ecore_timer = NULL;
+static void *ecore_user_data = NULL;
+static int time_ms = 100;
+
+/* Ecore dummy routine */
+Ecore_Fd_Handler *
+ecore_main_fd_handler_add(int fd, Ecore_Fd_Handler_Flags flags, Ecore_Fd_Cb func,
+ const void *data, Ecore_Fd_Cb buf_func, const void *buf_data)
+{
+ apfw_trace("TEST: dummyy ecore_main_fd_handler_add(%d,%d,%08x,%08x,%08x,%08x)",
+ fd, (int)flags, (int)func, (int)data, (int)buf_func, (int)buf_data);
+ return (Ecore_Fd_Handler *)0x12345678;
+}
+
+Eina_Bool
+ecore_main_fd_handler_active_get(Ecore_Fd_Handler *fd_handler,
+ Ecore_Fd_Handler_Flags flags)
+{
+ apfw_trace("TEST: dummyy ecore_main_fd_handler_active_get(%08x,%d)",
+ (int)fd_handler, (int)flags);
+ return EINA_FALSE;
+}
+
+void
+ecore_main_fd_handler_active_set(Ecore_Fd_Handler *fd_handler,
+ Ecore_Fd_Handler_Flags flags)
+{
+ apfw_trace("TEST: dummyy ecore_main_fd_handler_active_set(%08x,%d)",
+ (int)fd_handler, (int)flags);
+}
+
+void *
+ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler)
+{
+ apfw_trace("TEST: dummyy ecore_main_fd_handler_del(%08x)", (int)fd_handler);
+ return NULL;
+}
+
+Ecore_Timer *
+ecore_timer_add(double dtime, Ecore_Task_Cb func, const void *user_data)
+{
+ ecore_timer = func;
+ ecore_user_data = (void *)user_data;
+ time_ms = (int)(dtime * 1000);
+ if (time_ms < 10) time_ms = 10;
+ if (time_ms >= 1000) time_ms = 990;
+
+ return (Ecore_Timer *)ecore_timer;
+}
+
+static void displaycontrol(const Ico_Uxf_conf_application *conf, const int control)
+{
+ apfw_trace("TEST: displaycontrol(%s, %d)", conf->appid, control);
+}
+
+static void soundcontrol(const Ico_Uxf_conf_application *conf, const int control)
+{
+ apfw_trace("TEST: soundcontrol(%s, %d)", conf->appid, control);
+}
+
+static void inputcontrol(const Ico_Uxf_conf_application *conf, const int control)
+{
+ apfw_trace("TEST: inputcontrol(%s, %d)", conf->appid, control);
+}
+
+int main(int argc, char *argv[])
+{
+ int ret;
+ Eina_Bool bret;
+
+ ret = ico_syc_apc_init(displaycontrol, soundcontrol, inputcontrol);
+ apfw_trace("TEST: ico_syc_apc_init() = %d", ret);
+
+ while (1) {
+ usleep(time_ms * 1000);
+
+ if (ecore_timer) {
+ apfw_trace("TEST: call ecore_timer");
+ bret = (*ecore_timer)(ecore_user_data);
+ apfw_trace("TEST: ret ecore_timer(%d)", (int)bret);
+ }
+ else {
+ apfw_trace("TEST: NO ecore_timer");
+ break;
+ }
+ }
+
+ exit(0);
+}
+
--- /dev/null
+#!/bin/sh
+
+export LD_LIBRARY_PATH=../ico-app-framework/.libs:$LD_LIBRARY_PATH
+gdb ./apc_test
+
--- /dev/null
+#! /bin/sh
+
+test -n "$srcdir" || srcdir=`dirname "$0"`
+test -n "$srcdir" || srcdir=.
+(
+ cd "$srcdir" &&
+ autoreconf --force -v --install
+) || exit
+test -n "$NOCONFIGURE" || "$srcdir/configure" "$@"
--- /dev/null
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.68])
+AC_INIT([org.tizen.ico.homescreen], [0.0.1], [])
+AM_INIT_AUTOMAKE([foreign 1.11])
+AC_CONFIG_SRCDIR([configure.ac])
+AC_CONFIG_HEADERS([config.h])
+
+# Checks for programs.
+AC_PROG_CC
+
+# Initialize libtool
+LT_PREREQ([2.2])
+LT_INIT([disable-static])
+
+# Checks for libraries.
+PKG_PROG_PKG_CONFIG()
+
+AC_CHECK_LIB([aul], [aul_app_get_appid_bypid], AUL_LIBS="-laul")
+AC_SUBST(AUL_LIBS)
+
+PKG_CHECK_MODULES([EINA], [eina])
+PKG_CHECK_MODULES([EVAS], [evas])
+PKG_CHECK_MODULES([ECORE], [ecore])
+PKG_CHECK_MODULES([EDJE], [edje])
+PKG_CHECK_MODULES([ELEM], [elementary])
+PKG_CHECK_MODULES([ECOREWAYLAND], [ecore-wayland])
+PKG_CHECK_MODULES([ECOREX], [ecore-x])
+EFL_CFLAGS="$EINA_CFLAGS $EVAS_CFLAGS $ECORE_CFLAGS $EDJE_CFLAGS $ELEM_CFLAGS $ECOREWAYLAND_CFLAGS"
+EFL_LIBS="$EINA_LIBS $EVAS_LIBS $ECORE_LIBS $EDJE_LIBS $ELEM_LIBS $ECOREWAYLAND_LIBS $ECOREX_LIBS"
+AC_SUBST(EFL_CFLAGS)
+AC_SUBST(EFL_LIBS)
+
+PKG_CHECK_MODULES([GLIB], [glib-2.0])
+PKG_CHECK_MODULES([DBUS], [dbus-1])
+PKG_CHECK_MODULES([JSONGLIB], [json-glib-1.0])
+OPT_CFLAGS="$GLIB_CFLAGS $JSONGLIB_CFLAGS"
+OPT_LIBS="$GLIB_LIBS $JSONGLIB_LIBS"
+AC_SUBST(OPT_CFLAGS)
+AC_SUBST(OPT_LIBS)
+
+PKG_CHECK_MODULES([AUL], [aul])
+PKG_CHECK_MODULES([BUNDLE], [bundle])
+PKG_CHECK_MODULES([AIL], [ail])
+AUL_CFLAGS="$AUL_CFLAGS $AIL_CFLAGS $BUNDLE_CFLAGS"
+AUL_LIBS="$AUL_LIBS $AIL_LIBS $BUNDLE_LIBS"
+AC_SUBST(AUL_CFLAGS)
+AC_SUBST(AUL_LIBS)
+
+PKG_CHECK_MODULES([WAYLANDCLIENT], [wayland-client])
+PKG_CHECK_MODULES([WAYLANDCURSOR], [wayland-cursor])
+WL_CFLAGS="$WAYLANDCLIENT_CFLAGS $WAYLANDCURSOR_CFLAGS"
+WL_LIBS="$WAYLANDCLIENT_LIBS $WAYLANDCURSOR_LIBS"
+AC_SUBST(WL_CFLAGS)
+AC_SUBST(WL_LIBS)
+
+if test "x$GCC" = "xyes"; then
+ my_common_gcc_flags="-Wall -Wextra -Wno-unused-parameter \
+ -Wno-missing-field-initializers -g -fvisibility=hidden"
+ GCC_CFLAGS="$my_common_gcc_flags \
+ -Wstrict-prototypes -Wmissing-prototypes"
+ GCC_CXXFLAGS="$my_common_gcc_flags"
+fi
+AC_SUBST(GCC_CFLAGS)
+AC_SUBST(GCC_CXXFLAGS)
+
+# Checks for header files.
+AC_CHECK_HEADERS([fcntl.h stdlib.h string.h strings.h sys/file.h sys/ioctl.h sys/time.h unistd.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_TYPE_INT32_T
+AC_TYPE_SIZE_T
+AC_TYPE_UINT32_T
+
+# Checks for library functions.
+AC_FUNC_MALLOC
+AC_CHECK_FUNCS([gethostname gettimeofday memset setenv strcasecmp strdup strncasecmp strtol tzset])
+
+AC_CONFIG_FILES([Makefile
+ ico-app-framework/Makefile
+ src/Makefile
+ apps_controller/Makefile
+ test/Makefile])
+AC_PROG_RANLIB([ranlib])
+AC_OUTPUT
--- /dev/null
+Name=HomeScreen
+Type=menu
+Exec=/opt/apps/org.tizen.ico.homescreen/bin/HomeScreen
+Icon=org.tizen.ico.homescreen.png
+Nodisplay=True
+Version=0.1.0
+Comment=home screen app
+Categories=Menu;HomeScreen;run=Center;noauto
--- /dev/null
+Name=OnScreen
+Type=menu
+Exec=/opt/apps/org.tizen.ico.onscreen/bin/OnScreen
+Icon=org.tizen.ico.onscreen.png
+Nodisplay=True
+Version=0.1.0
+Comment=onscreen app
+Categories=Menu;HomeScreen;run=Center;auto
--- /dev/null
+Name=sampleAlignment
+Type=Application
+Exec=/opt/apps/org.tizen.ico.sample.alignment/bin/DummyApp -number=6
+Icon=org.tizen.ico.sample.alignment.png
+NoDisplay=false
+Version=0.1.0
+Comment=Dummy
--- /dev/null
+Name=sampleBrowser
+Type=Application
+Exec=/opt/apps/org.tizen.ico.sample.browser/bin/DummyApp -number=4
+Icon=org.tizen.ico.sample.browser.png
+NoDisplay=false
+Version=0.1.0
+Comment=Dummy
--- /dev/null
+Name=sampleEnginestatus
+Type=Application
+Exec=/opt/apps/org.tizen.ico.sample.enginestatus/bin/DummyApp -number=19
+Icon=org.tizen.ico.sample.enginestatus.png
+NoDisplay=false
+Version=0.1.0
+Comment=Dummy
--- /dev/null
+Name=sampleMail
+Type=Application
+Exec=/opt/apps/org.tizen.ico.sample.mail/bin/DummyApp -number=2
+Icon=org.tizen.ico.sample.mail.png
+NoDisplay=false
+Version=0.1.0
+Comment=Dummy
--- /dev/null
+Name=sampleMeter
+Type=Application
+Exec=/opt/apps/org.tizen.ico.sample.meter/bin/DummyApp -number=17
+Icon=org.tizen.ico.sample.meter.png
+NoDisplay=false
+Version=0.1.0
+Comment=Dummy
--- /dev/null
+Name=sampleMusic
+Type=Application
+Exec=/opt/apps/org.tizen.ico.sample.music/bin/DummyApp -number=1
+Icon=org.tizen.ico.sample.music.png
+NoDisplay=false
+Version=0.1.0
+Comment=Dummy
--- /dev/null
+Name=sampleSeatarrange
+Type=Application
+Exec=/opt/apps/org.tizen.ico.sample.seatarrange/bin/DummyApp -number=5
+Icon=org.tizen.ico.sample.seatarrange.png
+NoDisplay=false
+Version=0.1.0
+Comment=Dummy
--- /dev/null
+Name=sampleSetup
+Type=Application
+Exec=/opt/apps/org.tizen.ico.sample.setup/bin/DummyApp -number=12
+Icon=org.tizen.ico.sample.setup.png
+Version=0.1.0
+NoDisplay=false
+Comment=Dummy
--- /dev/null
+Name=sampleWeather
+Type=Application
+Exec=/opt/apps/org.tizen.ico.sample.weather/bin/DummyApp -number=3
+Icon=org.tizen.ico.sample.weather.png
+NoDisplay=false
+Version=0.1.0
+Comment=Dummy
--- /dev/null
+Name=StatusBar
+Type=menu
+Exec=/opt/apps/org.tizen.ico.statusbar/bin/StatusBar
+Icon=org.tizen.ico.statusbar.png
+Nodisplay=True
+Version=0.1.0
+Comment=status bar app
+Categories=Menu;HomeScreen;run=Center;auto
--- /dev/null
+lib_LTLIBRARIES = libico-app-fw.la \
+ libico-app-fw-efl.la
+
+#include_HEADERS = \
+# ico_apf.h \
+# ico_apf_error.h \
+# ico_apf_resource_control.h \
+# ico_apf_ecore.h
+
+libico_app_fw_la_CFLAGS = -I../include -I/usr/include/ico-uxf-weston-plugin $(AUL_CFLAGS) @GLIB_CFLAGS@
+libico_app_fw_la_LDFLAGS = -version-info 0:5:0
+libico_app_fw_la_SOURCES = \
+ ico_uxf_conf_common.c \
+ ico_uxf_conf_sys.c \
+ ico_uxf_conf_app.c \
+ ico_uxf_init.c \
+ ico_uxf_launcher.c \
+ ico_uxf_window.c \
+ ico_uxf_inputdev.c \
+ ico_apf_log.c \
+ ico_apf_communication.c \
+ ico_apf_resource_control.c \
+ ico_apf_appmgr.c
+
+libico_app_fw_efl_la_CFLAGS = -I../include $(EFL_CFLAGS) @GLIB_CFLAGS@
+libico_app_fw_efl_la_LDFLAGS = -version-info 0:5:0
+libico_app_fw_efl_la_SOURCES = \
+ ico_apf_ecore.c
+
+AM_CFLAGS = $(GCC_CFLAGS)
+AM_CPPFLAGS = $(GCC_CFLAGS) \
+ -DDATADIR='"$(datadir)"' \
+ -DMODULEDIR='"$(moduledir)"' \
+ -DLIBEXECDIR='"$(libexecdir)"'
+AM_LDFLAGS = -module -avoid-version -rpath $(libdir) -lwayland-egl -lEGL -lGLESv2
+
+.FORCE :
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief header file of AppsController interface(API) macros
+ *
+ * @date Feb-28-2013
+ */
+
+#ifndef __ICO_APF_APIMACRO_H__
+#define __ICO_APF_APIMACRO_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Macros */
+#if defined(__GNUC__) && __GNUC__ >= 4
+#define ICO_APF_API __attribute__ ((visibility("default")))
+#else
+#define ICO_APF_API
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /*__ICO_APF_APIMACRO_H__*/
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief header file of Apprication Framework (Application Manager)
+ *
+ * @date Feb-28-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <aul/aul.h>
+
+#include "ico_apf_private.h"
+#include "ico_uxf_conf.h"
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_get_app_id: Get application id(in AppCore) from application process id
+ *
+ * @param[in] pid application process id
+ * @param[out] appid application id
+ * @return result
+ * @retval ICO_APP_CTL_E_NONE success
+ * @retval ICO_APP_CTL_E_INVALID_PARAM error(pid dose not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_get_app_id(const int pid, char *appid)
+{
+ int fd;
+ int ppid = pid;
+ int i, j;
+ int size;
+ char procpath[240];
+
+ memset(appid, 0, ICO_UXF_MAX_PROCESS_NAME+1);
+
+ if (ppid == 0) {
+ ppid = getpid();
+ }
+
+ /* Get applicationId from AppCore(AUL) */
+ if (aul_app_get_appid_bypid(ppid, appid, ICO_UXF_MAX_PROCESS_NAME)
+ != AUL_R_OK) {
+ snprintf(procpath, sizeof(procpath)-1, "/proc/%d/cmdline", ppid);
+ fd = open(procpath, O_RDONLY);
+ if (fd >= 0) {
+ size = read(fd, procpath, sizeof(procpath));
+ for (; size > 0; size--) {
+ if (procpath[size-1]) break;
+ }
+ if (size > 0) {
+ /* Get program base name */
+ i = 0;
+ for (j = 0; j < size; j++) {
+ if (procpath[j] == 0) break;
+ if (procpath[j] == '/') i = j + 1;
+ }
+ j = 0;
+ for (; i < size; i++) {
+ appid[j] = procpath[i];
+ if ((appid[j] == 0) ||
+ (j >= ICO_UXF_MAX_PROCESS_NAME)) break;
+ j++;
+ }
+ /* Search application number */
+ if ((appid[j] == 0) && (j < (ICO_UXF_MAX_PROCESS_NAME-1))) {
+ for (; i < size; i++) {
+ if ((procpath[i] == 0) &&
+ (procpath[i+1] == '@')) {
+ strncpy(&appid[j], &procpath[i+1],
+ ICO_UXF_MAX_PROCESS_NAME - j - 1);
+ }
+ }
+ }
+ }
+ close(fd);
+ }
+ if (appid[0] == 0) {
+ apfw_trace("ico_apf_get_app_id: LEAVE(pid=%d dose not exist)", ppid);
+ sprintf(appid, "?%d?", ppid);
+ return ICO_APP_CTL_E_INVALID_PARAM;
+ }
+ }
+ return ICO_APP_CTL_E_NONE;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief client library for communicate to AppsController in HomeScreen
+ *
+ * @date Feb-28-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <string.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+#include <libwebsockets.h>
+#include "ico_apf_private.h"
+#include "ico_uxf_conf.h"
+
+/*==============================================================================*/
+/* define static function prototype */
+/*==============================================================================*/
+static ico_apf_com_handle_t *ico_apf_alloc_handle(void);
+static int ico_apf_com_connect(ico_apf_com_handle_t *handle);
+static int ico_apf_com_realsend(ico_apf_com_handle_t *handle,
+ ico_apf_com_buffer_t *msg);
+static int ico_apf_callback_http(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason,
+ void *user, void *in, size_t len);
+static int ico_apf_callback_websock(struct libwebsocket_context *this,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason,
+ void *user, void *in, size_t len);
+static void ico_apf_put_recvmsg(const int cmd, const int res, const int pid,
+ const char *appid, char *msg, const int len,
+ ico_apf_com_handle_t *handle);
+static int ico_apf_poll_fd_add(const int fd, const int flag);
+static void ico_apf_poll_fd_del(const int fd);
+static void ico_apf_poll_write_event(ico_apf_com_handle_t *handle, const int write);
+
+/*==============================================================================*/
+/* variable & table */
+/*==============================================================================*/
+/* variable that control program name in Linux */
+extern const char *program_invocation_name;
+
+/* application framework control handle */
+static struct libwebsocket_context *global_lwscontext = NULL;
+static ico_apf_com_handle_t *handles = NULL;
+static ico_apf_com_handle_t *freehandles = NULL;
+
+/* file descriptor controll table */
+static ico_apf_com_poll_t *com_polls = NULL;
+static ico_apf_com_poll_t *freecom_polls = NULL;
+static ico_apf_com_pollfd_cb ico_apf_pollfd_func = NULL;
+
+/* global user listener */
+static ico_apf_com_eventlistener global_listener = NULL;
+static void *global_user_data = NULL;
+
+/* flag for callback from libwebsockets */
+static int lws_callbacked = 0;
+
+/* libwebsockets's protocol number */
+enum appsctl_protocols {
+ PROTOCOL_HTTP, /* HTTP handshake(Certainly required) */
+ PROTOCOL_APPSCONTROLLER, /* AppsController protocol */
+ PROTOCOL_APPSEND /* everytime means final */
+};
+enum soundmgr_protocols {
+ PROTOCOL_SOUNDMGR, /* Multi Sound Manager protocol */
+ PROTOCOL_SOUNDEND /* everytime means final */
+};
+
+/* list of libwebsockets protocol for AppsController */
+static struct libwebsocket_protocols apps_protocols[] = {
+ /* HTTP handshake(Certainly required) */
+ { "http_only", ico_apf_callback_http, 0 },
+ /* callback from websocket to appscontroller*/
+ { ICO_PROTOCOL_APPSCONTROLLER, ico_apf_callback_websock, sizeof(void *) },
+ { NULL, NULL, 0 } /* everytime means final */
+};
+
+/* list of libwebsockets protocol for pulse-audio plugin */
+static struct libwebsocket_protocols sound_protocols[] = {
+ /* callback from websocket to soundmanager*/
+ { ICO_PROTOCOL_MULTISOUNDMANAGER, ico_apf_callback_websock, sizeof(void *) },
+ { NULL, NULL, 0 } /* everytime means final */
+};
+
+/* command/event string */
+const char *ico_apf_cmd_table[] = {
+ ICO_APF_SRESOURCE_STATE_ACQUIRED, /* acquired */
+ ICO_APF_SRESOURCE_STATE_DEPRIVED, /* deprived */
+ ICO_APF_SRESOURCE_STATE_WAITTING, /* waitting */
+ ICO_APF_SRESOURCE_STATE_RELEASED, /* released */
+
+ ICO_APF_SRESOURCE_COMMAND_GET, /* get command */
+ ICO_APF_SRESOURCE_COMMAND_RELEASE, /* release command */
+ ICO_APF_SRESOURCE_COMMAND_ADD, /* add command */
+ ICO_APF_SRESOURCE_COMMAND_CHANGE, /* change command */
+ ICO_APF_SRESOURCE_COMMAND_DELETE, /* delete command */
+
+ ICO_APF_SRESOURCE_REPLY_OK, /* OK reply */
+ ICO_APF_SRESOURCE_REPLY_NG, /* NG reply */
+ ICO_APF_SRESOURCE_STATE_CONNECTED, /* connected */
+ ICO_APF_SRESOURCE_STATE_DISCONNECTED /* disconnected */
+};
+const char *ico_apf_res_table[] = {
+ ICO_APF_SRESID_BASIC_SCREEN, /* basic screen */
+ ICO_APF_SRESID_INT_SCREEN, /* interrupt screen */
+ ICO_APF_SRESID_ON_SCREEN, /* onscreeen */
+ ICO_APF_SRESID_BASIC_SOUND, /* basic sound */
+ ICO_APF_SRESID_INT_SOUND, /* interrupt sound */
+ ICO_APF_SRESID_INPUT_DEV /* input device */
+};
+const char *ico_apf_sound_table[] = {
+ ICO_APF_SSOUND_COMMAND_MUTEON, /* mute on */
+ ICO_APF_SSOUND_COMMAND_MUTEOFF, /* mute off */
+ ICO_APF_SSOUND_COMMAND_CANCEL, /* cancel */
+ ICO_APF_SSOUND_COMMAND_GETLIST, /* get stream list */
+ ICO_APF_SSOUND_COMMAND_FRESH, /* fresh */
+ ICO_APF_SSOUND_COMMAND_ALLMUTEON, /* mute set all stream*/
+ ICO_APF_SSOUND_COMMAND_ALLMUTEOFF, /* mute reset all stream*/
+ ICO_APF_SSOUND_EVENT_NEW, /* created new stream*/
+ ICO_APF_SSOUND_EVENT_FREE, /* destoryed stream */
+ ICO_APF_SSOUND_REPLY_LIST /* reply of stream list*/
+};
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_com_init_client
+ * This function connects to AppsController in HomeScreen.
+ * If you use AppsController's function, you must call this function.
+ *
+ * @param[in] uri connection URI, NULL is host myself
+ * @param[in] type connection type
+ * @return handle address
+ * @retval handle address success
+ * @retval NULL error(failed connect AppsController)
+ */
+/*--------------------------------------------------------------------------*/
+ico_apf_com_handle_t *
+ico_apf_com_init_client(const char *uri, const int type)
+{
+ int i;
+ int port;
+ char* address;
+ ico_apf_com_poll_t *p;
+ ico_apf_com_handle_t *handle;
+ Ico_Uxf_Sys_Config *sysconf;
+ Ico_Uxf_Sys_Config *ifsysconf = (Ico_Uxf_Sys_Config *)0xffffffff;
+ char *port_env;
+ char *host_env;
+
+ apfw_trace("ico_apf_com_init_client: Enter(%s,%d)",
+ uri ? uri : "(NULL)", type);
+
+ ifsysconf = (Ico_Uxf_Sys_Config *)ico_uxf_ifGetSysConfig();
+
+ if (ifsysconf) {
+ /* Another module already reads config file */
+ /* In this case, you don't release sysconf at finished this function. */
+ sysconf = (Ico_Uxf_Sys_Config *)ifsysconf;
+ }
+ else {
+ /* never read a system config */
+ sysconf = (Ico_Uxf_Sys_Config *)ico_uxf_getSysConfig();
+ }
+ if (!sysconf) {
+ apfw_error("ico_apf_com_init_client: Leave(can not read configuration files)");
+ return NULL;
+ }
+
+ /* If URI is host name, find address from config. */
+ /* If node is a null character string, it regards NULL. */
+ Ico_Uxf_conf_host *phost =
+ (Ico_Uxf_conf_host *) ico_uxf_getSysHostById(ico_uxf_getSysHostByName(uri));
+ if (phost) {
+ address = phost->address;
+ }
+ else {
+ /* If don't find host name from config, regards ipaddress is set as node.*/
+ address = (char *)uri;
+ }
+
+ /* environment variable for port & host */
+ if (type == ICO_APF_COM_TYPE_APPSCTL) {
+ port = sysconf->misc.appscontrollerport;
+ port_env = getenv("ICO_APF_APPSCTL_PORT");
+ host_env = getenv("ICO_APF_APPSCTL_HOST");
+ }
+ else {
+ port = sysconf->misc.soundpluginport;
+ port_env = getenv("ICO_APF_SOUNDMGR_PORT");
+ host_env = getenv("ICO_APF_SOUNDMGR_HOST");
+ }
+ if (port_env) {
+ i = atoi(port_env);
+ if (i > 0) port = i;
+ }
+ if (host_env) {
+ address = host_env;
+ }
+
+ /* get a port number from system configuration(system/system.conf) */
+ apfw_trace("ico_apf_com_init_client: connect Host=%s Port=%d", address, port);
+
+ handle = handles;
+ while (handle) {
+ if ((strcmp(handle->ip, address) == 0) &&
+ (handle->port == port) && (handle->type == type)) {
+ break;
+ }
+ handle = handle->next;
+ }
+
+ if (handle) {
+ apfw_trace("ico_apf_com_init_client: Leave(Connected)");
+ return handle;
+ }
+
+ handle = ico_apf_alloc_handle();
+ if (! handle) {
+ apfw_trace("ico_apf_com_init_client: Leave(No Memory)");
+ return NULL;
+ }
+
+ handle->type = type;
+ handle->port = port;
+ strncpy(handle->ip, address, ICO_APF_RESOURCE_IP_LEN-1);
+ handle->ip[ICO_APF_RESOURCE_IP_LEN-1] = 0;
+
+ /* connect to AppsController */
+ i = ico_apf_com_connect(handle);
+
+ if (! ifsysconf) {
+ ico_uxf_closeSysConfig();
+ }
+
+ if (i != ICO_APF_RESOURCE_E_NONE) {
+ apfw_error("ico_apf_com_init_client: Leave(RESOURCE_E_INIT_COM_FAILD)");
+ (void) ico_apf_com_term_client(handle);
+ return NULL;
+ }
+
+ /* Try to connection */
+ ico_apf_com_dispatch(handle, 0);
+ handle->fd = libwebsocket_get_socket_fd(handle->wsi_connection);
+
+ /* add poll callback if fd is exist */
+ if (handle->fd > 0) {
+ handle->service_on = 1;
+ (void)ico_apf_poll_fd_add(handle->fd, POLLIN);
+ }
+
+ p = com_polls;
+ while (p) {
+ if (p->fd == handle->fd) {
+ p->apf_fd_control = (void *)handle;
+ handle->poll = p;
+ }
+ p = p->next;
+ }
+ apfw_trace("ico_apf_com_init_client: Leave(OK,fd=%d)", handle->fd);
+ return handle;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_com_init_server
+ * This function connects to aplicationto in AppsController.
+ *
+ * @param[in] uri my URI, NULL is host myself
+ * @param[in] type connection type
+ * @return handle address
+ * @retval handle address success
+ * @retval NULL error(failed connect AppsController)
+ */
+/*--------------------------------------------------------------------------*/
+ico_apf_com_handle_t *
+ico_apf_com_init_server(const char *uri, const int type)
+{
+ int i;
+ int port;
+ int svrtype;
+ char* address;
+ ico_apf_com_handle_t *handle;
+ Ico_Uxf_Sys_Config *sysconf;
+ Ico_Uxf_Sys_Config *ifsysconf = (Ico_Uxf_Sys_Config *)0xffffffff;
+ char *port_env;
+
+ apfw_trace("ico_apf_com_init_server: Enter(%s,%d)",
+ uri ? uri : "(NULL)", type);
+
+ ifsysconf = (Ico_Uxf_Sys_Config *)ico_uxf_ifGetSysConfig();
+
+ if (ifsysconf) {
+ /* Another module already reads config file */
+ /* In this case, you don't release sysconf at finished this function. */
+ sysconf = (Ico_Uxf_Sys_Config *)ifsysconf;
+ }
+ else {
+ /* never read a system config */
+ sysconf = (Ico_Uxf_Sys_Config *)ico_uxf_getSysConfig();
+ }
+ if (!sysconf) {
+ apfw_error("ico_apf_com_init_server: Leave(can not read configuration files)");
+ return NULL;
+ }
+
+ /* currently server support only Application Controler */
+ svrtype = ICO_APF_COM_TYPE_SVR_APPSCTL;
+
+ /* If URI is host name, find address from config. */
+ /* If node is a null character string, it regards NULL. */
+ Ico_Uxf_conf_host *phost =
+ (Ico_Uxf_conf_host *) ico_uxf_getSysHostById(ico_uxf_getSysHostByName(uri));
+ if (phost) {
+ address = phost->address;
+ }
+ else {
+ /* If don't find host name from config, regards ipaddress is set as node.*/
+ address = (char *)uri;
+ }
+
+ /* get a port number from system configuration(system/system.conf) */
+ port = sysconf->misc.appscontrollerport;
+ apfw_trace("ico_apf_com_init_server: Config, Host=%s Port=%d", address, port);
+
+ /* environment variable for port */
+ port = sysconf->misc.appscontrollerport;
+ port_env = getenv("ICO_APF_APPSCTL_PORT");
+ if (port_env) {
+ i = atoi(port_env);
+ if (i > 0) port = i;
+ }
+
+ handle = handles;
+ while (handle) {
+ if ((strcmp(address, handle->ip) == 0) &&
+ (handle->port == port) && (handle->type == svrtype)) break;
+ handle = handle->next;
+ }
+
+ if (handle) {
+ apfw_trace("ico_apf_com_init_server: Leave(Created)");
+ return handle;
+ }
+
+ handle = ico_apf_alloc_handle();
+ if (! handle) {
+ apfw_error("ico_apf_com_init_server: Leave(No Memory)");
+ return NULL;
+ }
+
+ handle->type = svrtype;
+ handle->port = port;
+ strncpy(handle->ip, address, ICO_APF_RESOURCE_IP_LEN-1);
+ handle->ip[ICO_APF_RESOURCE_IP_LEN-1] = 0;
+
+ /* connect to AppsController */
+ handle->wsi_context = libwebsocket_create_context(port, NULL, apps_protocols,
+ libwebsocket_internal_extensions,
+ NULL, NULL, -1, -1, 0);
+ if (! handle->wsi_context) {
+ apfw_error("ico_apf_com_init_server: Leave(libwebsockets create Error)");
+ (void) ico_apf_com_term_server(handle);
+ return NULL;
+ }
+ apfw_trace("ico_apf_com_init_server: create server context 0x%08x",
+ (int)handle->wsi_context);
+
+ global_lwscontext = handle->wsi_context;
+
+ ico_apf_com_dispatch(handle, 0);
+
+ apfw_trace("ico_apf_com_init_server: Leave(OK)");
+ return handle;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_alloc_handle
+ * Allocate ccommunication handle.
+ *
+ * @param none
+ * @return handle address
+ * @retval addres success, return handle address
+ * @retval NULL error(no memory)
+ */
+/*--------------------------------------------------------------------------*/
+static ico_apf_com_handle_t *
+ico_apf_alloc_handle(void)
+{
+ ico_apf_com_handle_t *handle;
+ int i;
+
+ if (! freehandles) {
+
+ handle = malloc(sizeof(ico_apf_com_handle_t));
+ if (! handle) {
+ return NULL;
+ }
+ memset(handle, 0, sizeof(ico_apf_com_handle_t));
+
+ /* Queue buffers initialize. */
+ for (i = 0; i < ICO_APF_RESOURCE_WSOCK_BUFR; i++) {
+ handle->rbuf[i] = calloc(sizeof(ico_apf_com_buffer_t), 1);
+ if (! handle->rbuf[i]) {
+ return NULL;
+ }
+ }
+ for (i = 0; i < ICO_APF_RESOURCE_WSOCK_BUFS; i++) {
+ handle->sbuf[i] = calloc(sizeof(ico_apf_com_buffer_t), 1);
+ if (! handle->sbuf[i]) {
+ return NULL;
+ }
+ }
+ }
+ else {
+ handle = freehandles;
+ freehandles = freehandles->next;
+ handle->next = NULL;
+ handle->fd = 0;
+ handle->pid = 0;
+ handle->wsi_context = NULL;
+ handle->wsi_connection = NULL;
+ handle->service_on = 0;
+ handle->retry = 0;
+ handle->stoprecv = 0;
+ handle->shead = 0;
+ handle->stail = 0;
+ handle->rhead = 0;
+ handle->rtail = 0;
+ handle->listener = NULL;
+ handle->user_data = NULL;
+ handle->type = 0;
+ }
+
+ if (handles) {
+ handle->next = handles;
+ }
+ handles = handle;
+
+ return handle;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_com_connect
+ * This function connects to AppsController.
+ *
+ * @param[in] handle Communication handle
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_INIT_COM_FAILD error(connect failed)
+ */
+/*--------------------------------------------------------------------------*/
+static int
+ico_apf_com_connect(ico_apf_com_handle_t *handle)
+{
+ int rep;
+
+ apfw_trace("ico_apf_com_connect: Enter(type=%d)", handle->type);
+
+ int ietf_version = -1; /* latest */
+ char origin[1024];
+ sprintf(origin,"%d %s",getpid(),program_invocation_name);
+
+ apfw_trace("ico_apf_com_connect: libwebsocket_create_context");
+ handle->wsi_context = libwebsocket_create_context(
+ CONTEXT_PORT_NO_LISTEN, NULL,
+ (handle->type & ICO_APF_COM_TYPE_CONNECTION)
+ == ICO_APF_COM_TYPE_SOUNDMGR ?
+ sound_protocols : apps_protocols,
+ libwebsocket_internal_extensions,
+ NULL, NULL, -1, -1, 0);
+ if (handle->wsi_context == NULL) {
+ apfw_error("ico_apf_com_connect: Leave(RESOURCE_E_INIT_COM_FAILD)");
+ return ICO_APF_RESOURCE_E_INIT_COM_FAILD;
+ }
+ apfw_trace("ico_apf_com_connect: create client context 0x%08x",
+ (int)handle->wsi_context);
+
+ /* connect to Application Manager by WebSocket */
+ apfw_trace("ico_apf_com_connect: libwebsocket_client_connect %s:%d",
+ handle->ip, handle->port);
+ for (rep = 0; rep < (1000/50); rep++) {
+ handle->wsi_connection = libwebsocket_client_connect(
+ handle->wsi_context,
+ handle->ip, handle->port, 0,
+ "/", handle->ip, origin,
+ (handle->type == ICO_APF_COM_TYPE_APPSCTL) ?
+ apps_protocols[PROTOCOL_APPSCONTROLLER].name :
+ sound_protocols[PROTOCOL_SOUNDMGR].name,
+ ietf_version);
+ if (handle->wsi_connection) break;
+ usleep(50*1000);
+ }
+ if (handle->wsi_connection == NULL) {
+ apfw_warn("ico_apf_com_connect: Leave(RESOURCE_E_INIT_COM_FAILD)");
+ return ICO_APF_RESOURCE_E_INIT_COM_FAILD;
+ }
+ handle->fd = libwebsocket_get_socket_fd(handle->wsi_connection);
+ if (handle->fd > 0) {
+ (void)ico_apf_poll_fd_add(handle->fd, POLLIN|POLLOUT);
+ }
+ ico_apf_com_dispatch(handle, 0);
+
+ apfw_trace("ico_apf_com_connect: Leave(OK, fd=%d)", handle->fd);
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_com_isconnected
+ * return a connection status with AppsController
+ *
+ * @param[in] handle AppsController's handle
+ * @return connection status
+ * @retval 1 connect
+ * @retval 0 not connetc
+ */
+/*--------------------------------------------------------------------------*/
+int
+ico_apf_com_isconnected(ico_apf_com_handle_t *handle)
+{
+ return((handle != NULL) && (handle->service_on != 0));
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_com_dispatch
+ * The accumulated transmitted and received data is processed.
+ * Connecting AppsController program must call this function.
+ *
+ * @param[in] handle connect handle, if NULL target is all connect
+ * @param[in] timeoutms maximum wait time on miri-sec.
+ * 0 is no wait, -1 is wait forever.
+ * @return non
+ */
+/*--------------------------------------------------------------------------*/
+void
+ico_apf_com_dispatch(ico_apf_com_handle_t *handle, const int timeoutms)
+{
+ int rh;
+ int n;
+ ico_apf_com_handle_t *p;
+
+ if (! handles) {
+ /* If program has not connected, nothing is done. */
+ apfw_warn("ico_apf_com_dispatch: handle dose not exist");
+ return;
+ }
+
+ if (handle) {
+ p = handle;
+ }
+ else {
+ p = handles;
+ }
+
+ while (p) {
+ if (libwebsocket_service(p->wsi_context, timeoutms) < 0) {
+ apfw_warn("ico_apf_com_dispatch: fd=%d is done", p->fd);
+ }
+
+ /* If received data is suspended, it processes. */
+ while (p->rtail != p->rhead) {
+ rh = p->rhead;
+ if (p->rhead >= (ICO_APF_RESOURCE_WSOCK_BUFR-1)) {
+ p->rhead = 0;
+ }
+ else {
+ p->rhead ++;
+ }
+ n = p->rtail - p->rhead;
+ if (n < 0) {
+ n = ICO_APF_RESOURCE_WSOCK_BUFR + n;
+ }
+ if ((p->stoprecv != 0) &&
+ (n < (ICO_APF_RESOURCE_WSOCK_BUFR/2))) {
+ /* If suspending received data is bellow half, request a send process */
+ p->stoprecv = 0;
+ apfw_trace("ico_apf_com_dispatch: Flow Control(Start) %d", n);
+ libwebsocket_rx_flow_control(p->wsi_connection, 1);
+ libwebsocket_service(p->wsi_context, 0);
+ }
+
+ if (p->listener != NULL) {
+ handle->listener(p, p->rbuf[rh]->cmd, p->rbuf[rh]->res, p->rbuf[rh]->pid,
+ p->rbuf[rh]->appid, p->rbuf[rh]->msg, p->user_data);
+ libwebsocket_service(p->wsi_context, 0);
+ }
+ else if (global_listener != NULL) {
+ global_listener(p, p->rbuf[rh]->cmd, p->rbuf[rh]->res, p->rbuf[rh]->pid,
+ p->rbuf[rh]->appid, p->rbuf[rh]->msg, global_user_data);
+ libwebsocket_service(p->wsi_context, 0);
+ }
+ }
+ if (handle) break;
+ p = p->next;
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_com_term_client
+ * finish to connect to AppsController
+ * It recommends call this function before end of program
+ * that used AppsController.
+ *
+ * @param[in] handle AppsController's handle
+ * @return result
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED error(already finished)
+ */
+/*--------------------------------------------------------------------------*/
+int
+ico_apf_com_term_client(ico_apf_com_handle_t *handle)
+{
+ ico_apf_com_handle_t *p;
+
+ apfw_trace("ico_apf_com_term_client: Enter");
+
+ if ((handle == NULL) || (handles == NULL)) {
+ apfw_trace("ico_apf_com_term_client: Leave(RESOURCE_E_NOT_INITIALIZED)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+ handle->service_on = 0;
+
+ if (handle == handles) {
+ handles = handles->next;
+ }
+ else {
+ p = handles;
+ while (p) {
+ if (p->next == handle) break;
+ p = p->next;
+ }
+ if (! p) {
+ apfw_trace("ico_apf_com_term_client: Leave(RESOURCE_E_NOT_INITIALIZED)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+ p->next = handle->next;
+ }
+
+ if (handle->wsi_context) {
+ libwebsocket_context_destroy(handle->wsi_context);
+ }
+ handle->next = freehandles;
+ freehandles = handle;
+
+ apfw_trace("ico_apf_com_term_client: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_com_term_server
+ * finish to connect to application
+ *
+ * @param[in] handle AppsController's handle
+ * @return result
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED error(already finished)
+ */
+/*--------------------------------------------------------------------------*/
+int
+ico_apf_com_term_server(ico_apf_com_handle_t *handle)
+{
+ ico_apf_com_handle_t *p;
+
+ apfw_trace("ico_apf_com_term_server: Enter");
+
+ if ((handle == NULL) || (handles == NULL)) {
+ apfw_trace("ico_apf_com_term_server: Leave(RESOURCE_E_NOT_INITIALIZED)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+ handle->service_on = 0;
+
+ if (handle == handles) {
+ handles = handles->next;
+ }
+ else {
+ p = handles;
+ while (p) {
+ if (p->next == handle) break;
+ p = p->next;
+ }
+ if (! p) {
+ apfw_trace("ico_apf_com_term_server: Leave(RESOURCE_E_NOT_INITIALIZED)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+ p->next = handle->next;
+ }
+
+ if (handle->wsi_context) {
+ libwebsocket_context_destroy(handle->wsi_context);
+ }
+ handle->next = freehandles;
+ freehandles = handle;
+
+ apfw_trace("ico_apf_com_term_server: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_com_send
+ * Accumulates the data send to AppsController/application.
+ *
+ * @param[in] handle AppsController's handle
+ * @param[in] cmd command
+ * @param[in] res resource
+ * @param[in] appid application id
+ * @param[in] msg send message
+ * @return result
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED error(not connect)
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION error(cannot send)
+ * @retval ICO_APF_RESOURCE_E_INVAL error(invalid parameter)
+ */
+/*--------------------------------------------------------------------------*/
+int
+ico_apf_com_send(ico_apf_com_handle_t *handle,
+ const int cmd, const int res, const char *appid, char *msg)
+{
+ int st;
+ int len;
+
+ apfw_trace("ico_apf_com_send: Enter(%08x, %d, %d)", (int)handle, cmd, res);
+
+ if ((handle == NULL) || (! ico_apf_com_isconnected(handle))) {
+ apfw_warn("ico_apf_com_send: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+ if ((handle->type & ICO_APF_COM_TYPE_CONNECTION) != ICO_APF_COM_TYPE_SOUNDMGR) {
+ /* send to AppsController */
+ if ((cmd < ICO_APF_RESOURCE_COMMAND_MIN) ||
+ (cmd > ICO_APF_RESOURCE_COMMAND_MAX) ||
+ (res < ICO_APF_RESOURCE_RESID_MIN) ||
+ (res > ICO_APF_RESOURCE_RESID_MAX)) {
+ apfw_warn("ico_apf_com_send: Leave(invalid command for resource)");
+ return ICO_APF_RESOURCE_E_INVAL;
+ }
+ }
+ else {
+ /* send to Multi Sound Manager */
+ if ((cmd < ICO_APF_SOUND_COMMAND_MIN) ||
+ (cmd > ICO_APF_SOUND_COMMAND_CMD)) {
+ apfw_warn("ico_apf_com_send: Leave(invalid command for sound control)");
+ return ICO_APF_RESOURCE_E_INVAL;
+ }
+ }
+
+ if (msg) {
+ len = strlen(msg);
+ if (len >= ICO_APF_RESOURCE_MSG_LEN) {
+ apfw_warn("ico_apf_com_send: Leave(invalid message length)");
+ return ICO_APF_RESOURCE_E_INVAL;
+ }
+ }
+ else {
+ len = 0;
+ msg = "(NULL)";
+ }
+
+ st = handle->stail;
+
+ if (st >= (ICO_APF_RESOURCE_WSOCK_BUFS-1)) {
+ st = 0;
+ }
+ else {
+ st ++;
+ }
+ if (st == handle->shead) {
+ /* send buffer is full */
+ ico_apf_poll_write_event(handle, 3);
+
+ apfw_error("ico_apf_com_send: Leave(send buffer overflow)");
+ ico_apf_poll_fd_del(handle->fd);
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ /* accumulate send buffer */
+ if ((! appid) || (*appid == 0)) {
+ handle->sbuf[handle->stail]->pid = getpid();
+ handle->sbuf[handle->stail]->appid[0] = 0;
+ }
+ else {
+ handle->sbuf[handle->stail]->pid = 0;
+ strncpy(handle->sbuf[handle->stail]->appid, appid, ICO_UXF_MAX_PROCESS_NAME);
+ handle->sbuf[handle->stail]->appid[ICO_UXF_MAX_PROCESS_NAME] = 0;
+ }
+ apfw_trace("ico_apf_com_send: Send.%d:%d %d %d(%s) <%s>",
+ handle->stail, cmd, res, handle->sbuf[handle->stail]->pid,
+ handle->sbuf[handle->stail]->appid, msg);
+ handle->sbuf[handle->stail]->cmd = cmd;
+ handle->sbuf[handle->stail]->res = res;
+ memcpy(handle->sbuf[handle->stail]->msg, msg, len);
+ handle->sbuf[handle->stail]->msg[len] = 0;
+ handle->stail = st;
+
+ libwebsocket_callback_on_writable(handle->wsi_context, handle->wsi_connection);
+
+ if (lws_callbacked) {
+ /* send call from libwensockets callback, delayed send */
+ ico_apf_poll_write_event(handle, 1);
+ }
+ else {
+ /* not call from callback, direct send */
+ ico_apf_com_dispatch(handle, 0); /* try to service */
+ }
+ apfw_trace("ico_apf_com_send: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_com_realsend
+ * send messege to AppsController
+ *
+ * @param[in] handle AppsController's handle
+ * @param[in] msg Send message
+ * @return result
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED error(not connect)
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION error(cannot send)
+ * @retval ICO_APF_RESOURCE_E_INVAL error(invalid parameter)
+ */
+/*--------------------------------------------------------------------------*/
+static int
+ico_apf_com_realsend(ico_apf_com_handle_t *handle, ico_apf_com_buffer_t *msg)
+{
+ unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 512 +
+ LWS_SEND_BUFFER_POST_PADDING];
+ unsigned char *pt = &buf[LWS_SEND_BUFFER_PRE_PADDING];
+ int n;
+
+ apfw_trace("ico_apf_com_realsend: Enter");
+ if ((handle == NULL) || (! ico_apf_com_isconnected(handle))) {
+ apfw_warn("ico_apf_com_realsend: Leave(Not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ if ((handle->type & ICO_APF_COM_TYPE_CONNECTION) == ICO_APF_COM_TYPE_SOUNDMGR) {
+ /* send to Multi Sound Manager */
+ if (msg->res) {
+ sprintf((char *)pt, "%s %d",
+ ico_apf_sound_table[msg->cmd-ICO_APF_SOUND_COMMAND_MIN], msg->res);
+ }
+ else {
+ strcpy((char *)pt, ico_apf_sound_table[msg->cmd-ICO_APF_SOUND_COMMAND_MIN]);
+ }
+ }
+ else {
+ /* send tp AppsController */
+ if (msg->appid[0]) {
+ sprintf((char *)pt, "%s %s %s %s",
+ ico_apf_cmd_table[msg->cmd-ICO_APF_RESOURCE_COMMAND_MIN],
+ ico_apf_res_table[msg->res-ICO_APF_RESOURCE_RESID_MIN],
+ msg->appid, msg->msg);
+ }
+ else {
+ sprintf((char *)pt, "%s %s %d %s",
+ ico_apf_cmd_table[msg->cmd-ICO_APF_RESOURCE_COMMAND_MIN],
+ ico_apf_res_table[msg->res-ICO_APF_RESOURCE_RESID_MIN],
+ msg->pid, msg->msg);
+ }
+ }
+
+ apfw_trace("ico_apf_com_realsend: libwebsocket_write[%s]", pt);
+ n = libwebsocket_write(handle->wsi_connection,
+ pt, strlen((char *)pt), LWS_WRITE_TEXT);
+ if (n < 0) {
+ apfw_error("ico_apf_com_realsend: write error[%d]", n);
+ ico_apf_poll_fd_del(handle->fd);
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+ usleep(200); /* According to libwebsockets's sample, this is required */
+ apfw_trace("ico_apf_com_realsend: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_com_addeventlistener
+ * register a callback function called receive message from AppsController
+ *
+ * @param[in] handle AppsComtroller's handle
+ * @param[in] listener callback function
+ * @param[in] user_data Arbitrary data
+ * @return result
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED error(not connect)
+ * @retval ICO_APF_RESOURCE_E_INVAL error(already registed)
+ */
+/*--------------------------------------------------------------------------*/
+int
+ico_apf_com_addeventlistener(ico_apf_com_handle_t *handle,
+ ico_apf_com_eventlistener listener, void* user_data)
+{
+ if (handle == NULL) {
+ if (global_listener) {
+ return ICO_APF_RESOURCE_E_INVAL;
+ }
+ global_listener = listener;
+ global_user_data = user_data;
+ return ICO_APF_RESOURCE_E_NONE;
+ }
+
+ if (handle->listener) {
+ return ICO_APF_RESOURCE_E_INVAL;
+ }
+ handle->user_data = user_data;
+ handle->listener = listener;
+
+ if (! global_listener) {
+ /* save listener */
+ global_listener = listener;
+ }
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_com_removeeventlistener
+ * unregister a callback function called receive message
+ *
+ * @param[in] handle AppsComtroller's handle
+ * @return result
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED error(not connect)
+ * @retval ICO_APF_RESOURCE_E_INVAL error(do not registed)
+ */
+/*--------------------------------------------------------------------------*/
+int
+ico_apf_com_removeeventlistener(ico_apf_com_handle_t *handle)
+{
+ if (handle == NULL) {
+ if (! global_listener) {
+ return ICO_APF_RESOURCE_E_INVAL;
+ }
+ global_listener = NULL;
+ global_user_data = NULL;
+ return ICO_APF_RESOURCE_E_NONE;
+ }
+
+ if (! handle->listener) {
+ return ICO_APF_RESOURCE_E_INVAL;
+ }
+ handle->listener = NULL;
+ handle->user_data = NULL;
+
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_callback_http
+ * Connection status is notified from libwebsockets.
+ *
+ * @param[in] context libwebsockets context
+ * @param[in] wsi libwebsockets management table
+ * @param[in] reason event type
+ * @param[in] user intact
+ * @param[in] in receive message
+ * @param[in] len message size[BYTE]
+ * @return result
+ * @retval =0 success
+ * @retval =1 error
+ */
+/*--------------------------------------------------------------------------*/
+static int
+ico_apf_callback_http(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason,
+ void *user, void *in, size_t len)
+{
+ int fd;
+
+ fd = libwebsocket_get_socket_fd(wsi);
+ lws_callbacked ++;
+
+ switch (reason) {
+ case LWS_CALLBACK_FILTER_NETWORK_CONNECTION:
+ /* a connection demand is received */
+ apfw_trace("ico_apf_callback_http: LWS_CALLBACK_FILTER_NETWORK_CONNECTION fd=%d", fd);
+
+ /* If connection is refused, it will return with values other than zero.*/
+ /* At present, since access control is not introduced, */
+ /* connection is always permitted. */
+ break;
+
+ case LWS_CALLBACK_ADD_POLL_FD: /* add connection socket */
+ apfw_trace("ico_apf_callback_http: LWS_CALLBACK_ADD_POLL_FD(%d) %d,%x", fd,
+ (int)user, len);
+ (void)ico_apf_poll_fd_add((int)user, (int)len);
+ break;
+
+ case LWS_CALLBACK_DEL_POLL_FD: /* delete connection socket */
+ apfw_trace("ico_apf_callback_http: LWS_CALLBACK_DEL_POLL_FD(%d) %d,%x", fd,
+ (int)user, len);
+ ico_apf_poll_fd_del((int)user);
+ break;
+
+ case LWS_CALLBACK_SET_MODE_POLL_FD: /* set status */
+ apfw_trace("ico_apf_callback_http: LWS_CALLBACK_SET_MODE_POLL_FD(%d) %d,%x", fd,
+ (int)user, len);
+ (void)ico_apf_poll_fd_add((int)user, (int)len);
+ break;
+
+ case LWS_CALLBACK_CLEAR_MODE_POLL_FD: /* clear status */
+ apfw_trace("ico_apf_callback_http: LWS_CALLBACK_CLEAR_MODE_POLL_FD(%d) %d,%x", fd,
+ (int)user, len);
+ (void)ico_apf_poll_fd_add((int)user, -((int)len));
+ break;
+
+ default:
+ apfw_trace("ico_apf_callback_http: Unknown reason(%d, fd=%d)", reason, fd);
+ break;
+ }
+ lws_callbacked --;
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_callback_websock
+ * this callback function notified from libwebsockets.
+ *
+ * @param[in] context libwebsockets context
+ * @param[in] wsi libwebsockets management table
+ * @param[in] reason event type
+ * @param[in] user intact
+ * @param[in] in receive message
+ * @param[in] len message size[BYTE]
+ * @return result
+ * @retval =0 success
+ * @retval =1 error
+ */
+/*--------------------------------------------------------------------------*/
+static int
+ico_apf_callback_websock(struct libwebsocket_context * this,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason,
+ void *user, void *in, size_t len)
+{
+ int wsifd;
+ int st;
+ int cmd;
+ int res;
+ int pid;
+ int i;
+ int strlen;
+ char *msg;
+ ico_apf_com_poll_t *p;
+ ico_apf_com_handle_t *handle;
+ struct sockaddr_in sin;
+ unsigned int sin_len;
+ char appid[ICO_UXF_MAX_PROCESS_NAME+1];
+ char strname[ICO_UXF_MAX_STREAM_NAME+1];
+ int nparam;
+ struct {
+ short start;
+ short end;
+ } param[10];
+
+ wsifd = libwebsocket_get_socket_fd(wsi);
+
+ lws_callbacked ++;
+
+ if (reason == LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION) {
+ apfw_trace("ico_apf_callback_websock: server side connected from client");
+
+ /* connect from client */
+ handle = handles;
+ while (handle) {
+ if (handle->fd == wsifd) break;
+ handle = handle->next;
+ }
+ if (! handle) {
+ handle = ico_apf_alloc_handle();
+ if (! handle) {
+ lws_callbacked --;
+ apfw_error("ico_apf_callback_websock: No Memory");
+ return 1;
+ }
+ }
+ handle->type = ICO_APF_COM_TYPE_APPSCTL;
+ handle->wsi_context = global_lwscontext;
+ handle->wsi_connection = wsi;
+ handle->fd = wsifd;
+ handle->service_on = 0;
+ handle->stoprecv = 0;
+
+ sin_len = sizeof(sin);
+ if (getpeername(wsifd, (struct sockaddr *) &sin, &sin_len) >= 0) {
+ sprintf(handle->ip, "%u.%u.%u.%u",
+ (sin.sin_addr.s_addr) & 0x0ff,
+ (sin.sin_addr.s_addr >> 8) & 0x0ff,
+ (sin.sin_addr.s_addr >> 16) & 0x0ff,
+ (sin.sin_addr.s_addr >> 24) & 0x0ff);
+ }
+ else {
+ strcpy(handle->ip, "127.0.0.1");
+ }
+
+ p = com_polls;
+ while (p) {
+ if (p->fd == handle->fd) {
+ p->apf_fd_control = (void *)handle;
+ handle->poll = p;
+ }
+ p = p->next;
+ }
+ lws_callbacked --;
+ apfw_trace("ico_apf_callback_websock: server side connected");
+ return 0;
+ }
+
+ handle = handles;
+ while (handle) {
+ if (handle->wsi_connection == wsi) break;
+ handle = handle->next;
+ }
+
+ if (! handle) {
+ lws_callbacked --;
+ apfw_trace("ico_apf_callback_websock: Handle not exist");
+ return 0;
+ }
+
+ switch (reason) {
+ case LWS_CALLBACK_CLIENT_ESTABLISHED:
+ case LWS_CALLBACK_ESTABLISHED:
+ apfw_trace("ico_apf_callback_websock: LWS_CALLBACK_ESTABLISHED");
+ handle->service_on = 1;
+ handle->stoprecv = 0;
+
+ /* save receive message to receive buffer */
+ ico_apf_put_recvmsg(ICO_APF_RESOURCE_STATE_CONNECTED, 0,
+ handle->pid, "\0", NULL, 0, handle);
+ break;
+
+ case LWS_CALLBACK_ADD_POLL_FD: /* add connection socket */
+ (void)ico_apf_poll_fd_add((int)user, (int)len);
+ break;
+
+ case LWS_CALLBACK_DEL_POLL_FD: /* delete connection socket */
+ ico_apf_poll_fd_del((int)user);
+ break;
+
+ case LWS_CALLBACK_SET_MODE_POLL_FD: /* set status */
+ (void)ico_apf_poll_fd_add((int)user, (int)len);
+ break;
+
+ case LWS_CALLBACK_CLEAR_MODE_POLL_FD: /* clear status */
+ (void)ico_apf_poll_fd_add((int)user, -((int)len));
+ break;
+
+ case LWS_CALLBACK_CLOSED:
+ apfw_trace("ico_apf_callback_websock: LWS_CALLBACK_CLOSED");
+ handle->service_on = 0;
+
+ /* save receive message to receive buffer */
+ ico_apf_put_recvmsg(ICO_APF_RESOURCE_STATE_DISCONNECTED, 0,
+ handle->pid, "\0", NULL, 0, handle);
+ break;
+
+ case LWS_CALLBACK_CLIENT_WRITEABLE:
+ case LWS_CALLBACK_SERVER_WRITEABLE:
+ if (handle->stail != handle->shead) {
+ st = handle->shead;
+ if (handle->shead >= (ICO_APF_RESOURCE_WSOCK_BUFS-1)) {
+ handle->shead = 0;
+ }
+ else {
+ handle->shead ++;
+ }
+ if (ico_apf_com_realsend(handle, handle->sbuf[st])
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("ico_apf_callback_websock: ico_apf_com_realsend Error");
+ handle->shead = st;
+ }
+ if (handle->stail != handle->shead) {
+ libwebsocket_callback_on_writable(handle->wsi_context,
+ handle->wsi_connection);
+ }
+ }
+ break;
+
+ case LWS_CALLBACK_CLIENT_RECEIVE:
+ case LWS_CALLBACK_RECEIVE:
+ msg = (char *)in;
+ msg[len] = 0;
+ if ((len <= 9) || (len >= (ICO_APF_RESOURCE_MSG_LEN+9))) {
+ lws_callbacked --;
+ apfw_warn("ico_apf_callback_websock: Receive Length Error, Len=%d", len);
+ return 0;
+ }
+ apfw_trace("ico_apf_callback_websock: LWS_CALLBACK_RECEIVE[%s]", msg);
+
+ /* analize event code */
+ if ((handle->type & ICO_APF_COM_TYPE_CONNECTION)
+ == ICO_APF_COM_TYPE_SOUNDMGR) {
+ /* Multi Sound Manager */
+ i = 0;
+ for (nparam = 0; nparam < 10; nparam++) {
+ for (; msg[i]; i++) {
+ if (msg[i] != ' ') break;
+ }
+ if (msg[i] == 0) break;
+ param[nparam].start = i;
+ for (; msg[i]; i++) {
+ if (msg[i] == ' ') break;
+ }
+ param[nparam].end = i;
+ }
+ if (nparam <= 0) {
+ lws_callbacked --;
+ apfw_warn("ico_apf_callback_websock: Illegal Message Format(no param)");
+ return 0;
+ }
+ for (cmd = ICO_APF_SOUND_COMMAND_CMD+1;
+ cmd <= ICO_APF_SOUND_COMMAND_MAX; cmd++) {
+ if (memcmp(&msg[param[0].start],
+ ico_apf_sound_table[cmd-ICO_APF_SOUND_COMMAND_MIN],
+ param[0].end - param[0].start) == 0) break;
+ }
+ if (cmd > ICO_APF_SOUND_COMMAND_MAX) {
+ lws_callbacked --;
+ apfw_warn("ico_apf_callback_websock: Receive Event Error(cmd=%d)", cmd);
+ return 0;
+ }
+ res = ICO_APF_RESID_BASIC_SOUND;
+ pid = 0;
+ appid[0] = 0;
+ strname[0] = 0;
+ strlen = 0;
+ for (i = 1; i < nparam; i++) {
+ if (memcmp(&msg[param[i].start],
+ "#pid#", param[i].end - param[i].start) == 0) {
+ i ++;
+ if (i < nparam) {
+ pid = strtol(&msg[param[i].start], (char **)0, 0);
+ if (ico_apf_get_app_id(pid, appid) != ICO_APP_CTL_E_NONE) {
+ lws_callbacked --;
+ apfw_trace("ico_apf_callback_websock: Unknown pid=%d", pid);
+ return 0;
+ }
+ }
+ }
+ else if (memcmp(&msg[param[i].start],
+ "#stream_name#", param[i].end - param[i].start) == 0) {
+ i ++;
+ /* no need stream name */
+ }
+ else if (memcmp(&msg[param[i].start],
+ "#app_name#", param[i].end - param[i].start) == 0) {
+ i ++;
+ if (i < nparam) {
+ strlen = param[i].end - param[i].start;
+ if (strlen >= ((int)sizeof(strname)))
+ strlen = sizeof(strname) - 1;
+ strncpy(strname, &msg[param[i].start], strlen);
+ strname[strlen] = 0;
+ }
+ }
+ else if (memcmp(&msg[param[i].start],
+ "#stream_state#", param[i].end - param[i].start) == 0) {
+ i ++;
+ /* no need stream_state */
+ }
+ }
+ apfw_trace("ico_apf_callback_websock: SoundMgr evt=%d res=%d(%s.%d) str=%s",
+ cmd, res, appid, pid, strname);
+ /* save receive message to receive buffer */
+ ico_apf_put_recvmsg(cmd, res, pid, appid, strname, strlen, handle);
+ }
+ else {
+ /* AppsController */
+ for (cmd = ICO_APF_RESOURCE_COMMAND_MIN;
+ cmd <= ICO_APF_RESOURCE_COMMAND_MAX; cmd++) {
+ if (memcmp(msg,
+ ico_apf_cmd_table[cmd-ICO_APF_RESOURCE_COMMAND_MIN], 3)
+ == 0) break;
+ }
+ if (cmd > ICO_APF_RESOURCE_COMMAND_MAX) {
+ lws_callbacked --;
+ apfw_warn("ico_apf_callback_appsctl: Receive Event Error(cmd=%d)", cmd);
+ return 0;
+ }
+ for (res = ICO_APF_RESOURCE_RESID_MIN;
+ res <= ICO_APF_RESOURCE_RESID_MAX; res++) {
+ if (memcmp(&msg[4],
+ ico_apf_res_table[res-ICO_APF_RESOURCE_RESID_MIN], 4) == 0) break;
+ }
+ if (res > ICO_APF_RESOURCE_RESID_MAX) {
+ lws_callbacked --;
+ apfw_warn("ico_apf_callback_websock: Receive Resource Error(resid=%d)",
+ res);
+ return 0;
+ }
+
+ pid = 0;
+ for (st = 9; msg[st]; st++) {
+ if (msg[st] == ' ') break;
+ if (pid >= 0) {
+ if ((msg[st] >= '0') && (msg[st] <= '9')) {
+ pid = pid * 10 + msg[st] - '0';
+ }
+ else {
+ pid = -1;
+ }
+ }
+ }
+ if (pid >= 0) {
+ appid[0] = 0;
+ }
+ else {
+ pid = st - 9;
+ if (pid > ICO_UXF_MAX_PROCESS_NAME )
+ pid = ICO_UXF_MAX_PROCESS_NAME;
+ strncpy(appid, &msg[9], pid);
+ appid[pid] = 0;
+ pid = 0;
+ }
+ if (msg[st] == ' ') st++;
+ apfw_trace("ico_apf_callback_websock: AppsCtl evt=%d res=%d pid=%d(%s) msg=%s",
+ cmd, res, pid, appid, &msg[st]);
+ /* save receive message to receive buffer */
+ ico_apf_put_recvmsg(cmd, res, pid, appid, &msg[st], len-st, handle);
+ }
+ break;
+ default:
+ apfw_trace("ico_apf_callback_websock: UnKnown reason=%d", reason);
+ break;
+ }
+ lws_callbacked --;
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_put_recvmsg
+ * put receive message into receive buffer
+ *
+ * @param[in] cmd receive commnad or event
+ * @param[in] res receive resource
+ * @param[in] pid request pid
+ * @param[in] appid application id (for Web Application)
+ * @param[in] msg receive message
+ * @param[in] len receive message length
+ * @param[out] handle connection handle
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ico_apf_put_recvmsg(const int cmd, const int res, const int pid, const char *appid,
+ char *msg, const int len, ico_apf_com_handle_t *handle)
+{
+ int i;
+ int nexttail;
+
+ /* check receive buffer overflow */
+ if (handle->rtail >= (ICO_APF_RESOURCE_WSOCK_BUFR-1)) {
+ nexttail = 0;
+ }
+ else {
+ nexttail = handle->rtail + 1;
+ }
+ if (handle->rhead == nexttail) {
+ /* receive buffer overflow, drops all message */
+ apfw_warn("ico_apf_put_recvmsg: receive buffer overflow");
+ handle->rhead = 0;
+ handle->rtail = 0;
+ nexttail = 1;
+ }
+
+ /* receive message is put into queue. */
+ handle->rbuf[handle->rtail]->cmd = cmd;
+ handle->rbuf[handle->rtail]->res = res;
+ handle->rbuf[handle->rtail]->pid = pid;
+ strncpy(handle->rbuf[handle->rtail]->appid, appid, ICO_UXF_MAX_PROCESS_NAME);
+ handle->rbuf[handle->rtail]->appid[ICO_UXF_MAX_PROCESS_NAME] = 0;
+ if (msg) {
+ memcpy(handle->rbuf[handle->rtail]->msg, msg, len);
+ handle->rbuf[handle->rtail]->msg[len] = 0;
+ }
+ else {
+ handle->rbuf[handle->rtail]->msg[0] = 0;
+ }
+ handle->rtail = nexttail;
+ i = handle->rtail - handle->rhead;
+ if (i <= 0) {
+ i = ICO_APF_RESOURCE_WSOCK_BUFR + i;
+ }
+ if ((handle->stoprecv == 0) &&
+ (i > ((ICO_APF_RESOURCE_WSOCK_BUFR * 3) / 4))) {
+ /* request to stop sending if an opening is less than 25%. */
+ handle->stoprecv = 1;
+ apfw_trace("ico_apf_put_recvmsg: Flow Control(Stop) %d", i);
+ libwebsocket_rx_flow_control(handle->wsi_connection, 0);
+ }
+ ico_apf_poll_write_event(handle, 1);
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief apf_com_poll_fd_add: add file descriptor for poll
+ *
+ * @param[in] fd file descriptor
+ * @param[in] flag POLL flag(POLLIN,POLLOUT)
+ * negative means reset
+ * @return result
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_INVAL error(out of memory)
+ */
+/*--------------------------------------------------------------------------*/
+static int
+ico_apf_poll_fd_add(const int fd, const int flag)
+{
+ ico_apf_com_poll_t *p;
+ ico_apf_com_poll_t *fds[1];
+ ico_apf_com_handle_t *handle;
+
+ p = com_polls;
+ while (p) {
+ if (p->fd == fd) {
+ break;
+ }
+ p = p->next;
+ }
+
+ if (! p) {
+ /* new file descriptor */
+ if (freecom_polls) {
+ p = freecom_polls;
+ freecom_polls = p->next;
+ p->apf_fd_control = NULL;
+ p->user_data = NULL;
+ }
+ else {
+ p = calloc(sizeof(ico_apf_com_poll_t), 1);
+ if (! p) {
+ /* out of memory */
+ apfw_error("ico_apf_poll_fd_add: can not allocate fd control table"
+ "(No Memory)");
+ return ICO_APF_RESOURCE_E_INVAL;
+ }
+ }
+
+ p->fd = fd;
+ p->next = com_polls;
+ com_polls = p;
+ }
+ p->flags |= ICO_APF_COM_POLL_ERROR;
+ if (flag >= 0) {
+ if (flag & (POLLIN|POLLPRI)) {
+ p->flags |= ICO_APF_COM_POLL_READ;
+ }
+ if (flag & POLLOUT) {
+ p->flags |= ICO_APF_COM_POLL_WRITE;
+ }
+ }
+ else {
+ if ((-flag) & (POLLIN|POLLPRI)) {
+ p->flags &= ~ICO_APF_COM_POLL_READ;
+ }
+ if ((-flag) & POLLOUT) {
+ p->flags &= ~ICO_APF_COM_POLL_WRITE;
+ }
+ }
+
+ handle = handles;
+ while (handle) {
+ if (handle->fd == fd) break;
+ handle = handle->next;
+ }
+ if (handle) {
+ p->apf_fd_control = (void *)handle;
+ handle->poll = p;
+ }
+ else {
+ apfw_trace("ico_apf_poll_fd_add: fd=%d dose not exist in handles", fd);
+ p->apf_fd_control = NULL;
+ }
+
+ /* regist callback function */
+ if (ico_apf_pollfd_func) {
+ fds[0] = p;
+
+ (*ico_apf_pollfd_func)(fds, 1);
+ }
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief apf_com_poll_fd_del: delete file descriptor for poll
+ *
+ * @param[in] fd file descriptor
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ico_apf_poll_fd_del(const int fd)
+{
+ ico_apf_com_poll_t *p;
+ ico_apf_com_poll_t *bp;
+ ico_apf_com_poll_t *fds[1];
+
+ /* search file descriptor */
+ p = com_polls;
+ bp = NULL;
+ while (p) {
+ if (p->fd == fd) {
+ if (bp) {
+ bp->next = p->next;
+ }
+ else {
+ com_polls = p->next;
+ }
+
+ if (p->apf_fd_control) {
+ ((ico_apf_com_handle_t *)(p->apf_fd_control))->poll = NULL;
+ }
+
+ /* call callback function */
+ if (ico_apf_pollfd_func) {
+ p->flags = 0;
+ fds[0] = p;
+
+ (*ico_apf_pollfd_func)(fds, 1);
+ }
+ p->next = freecom_polls;
+ freecom_polls = p;
+ break;
+ }
+ p = p->next;
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_com_poll_fd_control: Set or Unset callback of file descriptors
+ *
+ * @param[in] poll_fd_cb The callback function.
+ * @return result
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_com_poll_fd_control(ico_apf_com_pollfd_cb poll_fd_cb)
+{
+ ico_apf_com_poll_t *p;
+ ico_apf_com_poll_t **fds;
+ int nfds;
+ int count;
+
+ /* regist callback function */
+ ico_apf_pollfd_func = poll_fd_cb;
+
+ if (ico_apf_pollfd_func) {
+ /* if regist, call callback for all file descriptors */
+
+ /* count number of file descriptors */
+ p = com_polls;
+ count = 0;
+ while (p) {
+ count ++;
+ p = p->next;
+ }
+ if (count > 0) {
+ fds = malloc(sizeof(ico_apf_com_poll_t *) * count);
+ }
+ else {
+ fds = NULL;
+ }
+
+ p = com_polls;
+ nfds = 0;
+ while (fds && p) {
+ fds[nfds++] = p;
+ p = p->next;
+ }
+
+ apfw_trace("ico_apf_com_poll_fd_control: nfds=%d", nfds);
+ if (nfds > 0) {
+ (*ico_apf_pollfd_func)(fds, nfds);
+ }
+ if (fds) free(fds);
+ }
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_com_poll_fd_event: Notify the changes of file descriptor's state
+ *
+ * @param[in] fd_ctl The structure of file descriptor's controller
+ * @param[in] flags The user data to be passed to the callback function
+ * @return result
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_com_poll_fd_event(ico_apf_com_poll_t *fd_ctl, int flags)
+{
+ int st;
+ ico_apf_com_handle_t *handle = (ico_apf_com_handle_t *)fd_ctl->apf_fd_control;
+
+ if (handle) {
+ ico_apf_com_dispatch(handle, 0); /* try to service */
+ }
+ else {
+ ico_apf_com_dispatch(NULL, 0); /* try to service for server*/
+ }
+
+ if (handle) {
+ /* send if send data exist */
+ if ((handle->stail != handle->shead) &&
+ (handle->wsi_context != NULL) &&
+ (handle->wsi_connection != NULL)) {
+ st = handle->shead;
+ if (handle->shead >= (ICO_APF_RESOURCE_WSOCK_BUFS-1)) {
+ handle->shead = 0;
+ }
+ else {
+ handle->shead ++;
+ }
+ if (ico_apf_com_realsend(handle, handle->sbuf[st])
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("ico_apf_com_poll_fd_event: ico_apf_com_realsend Error");
+ handle->shead = st;
+ ico_apf_com_dispatch(handle, 10); /* try to service */
+ }
+ if (handle->stail != handle->shead) {
+ libwebsocket_callback_on_writable(handle->wsi_context,
+ handle->wsi_connection);
+ }
+ }
+
+ /* start/stop writable event */
+ if ((handle->stail == handle->shead) ||
+ (handle->wsi_context == NULL) ||
+ (handle->wsi_connection == NULL)) {
+ ico_apf_poll_write_event(handle, 0);
+ }
+ else {
+ libwebsocket_callback_on_writable(handle->wsi_context,
+ handle->wsi_connection);
+ ico_apf_poll_write_event(handle, 1);
+ }
+ }
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_poll_write_event: Write event control for poll
+ *
+ * @param[in] handle AppsController's handle
+ * @param[in] write set/reset write event
+ * = 0 : reset if not reset
+ * = 1 : set if not set
+ * = 2 : force reset
+ * = 3 : force set
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ico_apf_poll_write_event(ico_apf_com_handle_t *handle, const int write)
+{
+ ico_apf_com_poll_t *fds[1];
+
+ if (handle->poll) {
+ if ((write == 3) || (write == 1)) {
+ /* set write poll */
+ handle->poll->flags |= ICO_APF_COM_POLL_WRITE;
+ if (ico_apf_pollfd_func) {
+ fds[0] = handle->poll;
+ (*ico_apf_pollfd_func)(fds, 1);
+ }
+ }
+ else if ((write == 2) || (write == 0)) {
+ /* reset write poll */
+ handle->poll->flags &= ~ICO_APF_COM_POLL_WRITE;
+ if (ico_apf_pollfd_func) {
+ fds[0] = handle->poll;
+ (*ico_apf_pollfd_func)(fds, 1);
+ }
+ }
+ }
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief client library for Ecore(EFL) application
+ *
+ * @date Feb-28-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <string.h>
+#include <sys/time.h>
+#include <Ecore.h>
+
+#include <libwebsockets.h>
+#include "ico_apf_private.h"
+#include "ico_apf_ecore.h"
+
+/* define static function prototype */
+static Eina_Bool ico_apf_ecore_fdevent(void *data, Ecore_Fd_Handler *handler);
+static void ico_apf_ecore_fdcontrol(ico_apf_com_poll_t *fd_ctl[], const int num_fds);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_ecore_init
+ * This function connects to AppsController for Ecore application.
+ * If you use AppsController's function, you must call this function.
+ *
+ * @param[in] uri server URI
+ * @return result status
+ * @retval ICO_APF_E_NONE success
+ * @retval ICO_APF_E_IO_ERROR error(failed)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_ecore_init(const char *uri)
+{
+ apfw_trace("ico_apf_ecore_init: Enter(uri=%s)", uri ? uri : "(NULL)");
+
+ /* initialize resource controller */
+ if (ico_apf_resource_init_client(uri) != ICO_APF_RESOURCE_E_NONE) {
+ apfw_error("ico_apf_ecore_init: Leave(Resource initialize Error)");
+ return ICO_APF_E_IO_ERROR;
+ }
+
+ /* set file descriptor to Ecore main loop */
+ ico_apf_com_poll_fd_control(ico_apf_ecore_fdcontrol);
+
+ apfw_trace("ico_apf_ecore_init: Leave(OK)");
+ return ICO_APF_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_ecore_term
+ * This function connects to AppsController for Ecore application.
+ * If you use AppsController's function, you must call this function.
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API void
+ico_apf_ecore_term(void)
+{
+ apfw_trace("ico_apf_ecore_term: Enter");
+
+ /* terminate resource controller */
+ ico_apf_resource_term_client();
+
+ apfw_trace("ico_apf_ecore_term: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_ecore_init_server
+ * This function connects to AppsController for Ecore application.
+ * If you use AppsController's function, you must call this function.
+ *
+ * @param[in] appid id of application
+ * @return result status
+ * @retval ICO_APF_E_NONE success
+ * @retval ICO_APF_E_IO_ERROR error(failed)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_ecore_init_server(const char *uri)
+{
+ apfw_trace("ico_apf_ecore_init_server: Enter(uri=%s)", uri ? uri : "(NULL)");
+
+ /* initialize resource controller */
+ if (ico_apf_resource_init_server(uri) != ICO_APF_RESOURCE_E_NONE) {
+ apfw_error("ico_apf_ecore_init_server: Leave(Resource initialize Error)");
+ return ICO_APF_E_IO_ERROR;
+ }
+
+ /* set file descriptor to Ecore main loop */
+ ico_apf_com_poll_fd_control(ico_apf_ecore_fdcontrol);
+
+ apfw_trace("ico_apf_ecore_init_server: Leave(OK)");
+ return ICO_APF_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_ecore_term_server
+ * This function connects to AppsController for Ecore application.
+ * If you use AppsController's function, you must call this function.
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API void
+ico_apf_ecore_term_server(void)
+{
+ apfw_trace("ico_apf_ecore_term_server: Enter");
+
+ /* terminate resource controller */
+ ico_apf_resource_term_server();
+
+ apfw_trace("ico_apf_ecore_term_server: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_comm_connect
+ * callback function called by Ecore when a file descriptor had a change
+ *
+ * @param[in] data user data(ico_apf_com_poll_t)
+ * @param[in] handler Ecore file descriptor handler
+ * @return call back setting
+ * @retval ECORE_CALLBACK_RENEW set callback
+ */
+/*--------------------------------------------------------------------------*/
+static Eina_Bool
+ico_apf_ecore_fdevent(void *data, Ecore_Fd_Handler *handler)
+{
+ int flags;
+
+ flags = (ecore_main_fd_handler_active_get(handler, ECORE_FD_READ))
+ ? ICO_APF_COM_POLL_READ : 0;
+ if (ecore_main_fd_handler_active_get(handler, ECORE_FD_WRITE))
+ flags |= ICO_APF_COM_POLL_WRITE;
+ if (ecore_main_fd_handler_active_get(handler, ECORE_FD_ERROR))
+ flags |= ICO_APF_COM_POLL_ERROR;
+
+ ico_apf_com_poll_fd_event((ico_apf_com_poll_t *)data, flags);
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_ecore_fdcontrol
+ * This function connects to AppsController.
+ *
+ * @param[in] fd_ctl file descriptors
+ * @param[in] num_fds number of file descriptors
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ico_apf_ecore_fdcontrol(ico_apf_com_poll_t *fd_ctl[], const int num_fds)
+{
+ Ecore_Fd_Handler_Flags flags;
+ int i;
+
+ for (i = 0; i < num_fds; i++) {
+ if (fd_ctl[i]->flags) {
+ flags = (fd_ctl[i]->flags & ICO_APF_COM_POLL_READ) ? ECORE_FD_READ : 0;
+
+ if (fd_ctl[i]->flags & ICO_APF_COM_POLL_WRITE) flags |= ECORE_FD_WRITE;
+ if (fd_ctl[i]->flags & ICO_APF_COM_POLL_ERROR) flags |= ECORE_FD_ERROR;
+ if (! fd_ctl[i]->user_data) {
+ /* add file descriptor */
+ fd_ctl[i]->user_data = (void *)
+ ecore_main_fd_handler_add(fd_ctl[i]->fd, flags,
+ ico_apf_ecore_fdevent,
+ (void *)fd_ctl[i], NULL, NULL);
+ }
+ else {
+ /* change event */
+ ecore_main_fd_handler_active_set((Ecore_Fd_Handler *)fd_ctl[i]->user_data,
+ flags);
+ }
+ }
+ else {
+ /* remove file descriptor */
+ ecore_main_fd_handler_del((Ecore_Fd_Handler *)fd_ctl[i]->user_data);
+ }
+ }
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief Application Framework debug log function
+ *
+ * @date Feb-28-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <time.h>
+#include "ico_apf_log.h"
+#include "ico_apf_apimacro.h"
+
+/* variabe & table */
+/* output level debug log */
+ICO_APF_API int ico_apf_log_level = 0x7fffffff;
+static int ico_apf_log_flushmode = 1;
+static int ico_apf_log_initialized = 0;
+
+/* file descriptor of output debug log */
+static FILE *sDbgFd = (FILE *)0;
+
+/* name of output source module */
+static char sDbgProg[32];
+
+/* local time difference(sec) */
+static int sTimeZone = (99*60*60);
+
+/* output lines */
+static int sDbgLines = 0;
+
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_log_print: printout log message
+ *
+ * @param[in] fmt message format(same as printf)
+ * @param[in] ... arguments if need
+ * @return nothing
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API void
+ico_apf_log_print(const char *fmt, ...)
+{
+ va_list list;
+
+ if (! sDbgFd) {
+ ico_apf_log_open(NULL);
+ }
+#if ICO_APF_LOG_STDOUT == 0
+ else if (sDbgLines >= (ICO_APF_LOG_MAXLINES-2)) {
+ if (sDbgLines >= ICO_APF_LOG_MAXLINES) {
+ ico_apf_log_close();
+ ico_apf_log_open(sDbgProg);
+ }
+ else {
+ fflush(sDbgFd);
+ }
+ }
+#endif /*ICO_APF_LOG_STDOUT*/
+ if (sDbgFd) {
+ va_start(list, fmt);
+ vfprintf(sDbgFd, fmt, list);
+ va_end(list);
+ if (ico_apf_log_flushmode) {
+ fflush(sDbgFd);
+ }
+ }
+ if (sDbgFd != stdout) {
+ sDbgLines ++;
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_log_open: open log file
+ *
+ * @param[in] prog program name
+ * @return nothing
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API void
+ico_apf_log_open(const char *prog)
+{
+#if ICO_APF_LOG_STDOUT == 0
+ int idx;
+ char sPath[128];
+ char sPath2[128];
+#endif /*ICO_APF_LOG_STDOUT*/
+
+ if (sDbgFd) {
+ fflush(sDbgFd);
+ if (sDbgFd != stdout) {
+ fclose(sDbgFd);
+ }
+ }
+
+ sDbgLines = 0;
+
+ if ((! prog) || (*prog == 0)) {
+ sDbgFd = stdout;
+ sDbgProg[0] = 0;
+ return;
+ }
+ else {
+ strncpy(sDbgProg, prog, sizeof(sDbgProg)-1);
+ sDbgProg[sizeof(sDbgProg)-1] = 0;
+ }
+#if ICO_APF_LOG_STDOUT > 0
+ sDbgFd = stdout;
+#else /*ICO_APF_LOG_STDOUT*/
+ snprintf(sPath, sizeof(sPath)-1, "%s/%s.log%d",
+ ICO_APF_LOG_DIR, sDbgProg, ICO_APF_LOG_MAXFILES-1);
+ (void) remove(sPath);
+
+ for (idx = (ICO_APF_LOG_MAXFILES-1); idx > 0; idx--) {
+ strcpy(sPath2, sPath);
+ if (idx > 1) {
+ snprintf(sPath, sizeof(sPath)-1, "%s/%s.log%d",
+ ICO_APF_LOG_DIR, sDbgProg, idx-1);
+ }
+ else {
+ snprintf(sPath, sizeof(sPath)-1, "%s/%s.log",
+ ICO_APF_LOG_DIR, sDbgProg);
+ }
+ (void) rename(sPath, sPath2);
+ }
+ sDbgFd = fopen(sPath, "w");
+ if (! sDbgFd) {
+ sDbgFd = stdout;
+ }
+ else if ((ico_apf_log_initialized == 0) &&
+ (sDbgFd != stdout) && (sDbgFd != stderr)) {
+ ico_apf_log_initialized = 1;
+ fflush(stdout);
+ fflush(stderr);
+ stdout = sDbgFd;
+ stderr = sDbgFd;
+ }
+#endif /*ICO_APF_LOG_STDOUT*/
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_log_close: close log file
+ *
+ * @param nothing
+ * @return nothing
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API void
+ico_apf_log_close(void)
+{
+#if ICO_APF_LOG_STDOUT == 0
+ if (sDbgFd) {
+ fflush(sDbgFd);
+ if (sDbgFd != stdout) {
+ fclose(sDbgFd);
+ }
+ sDbgFd = (FILE *)0;
+ }
+#endif /*ICO_APF_LOG_STDOUT*/
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_log_flush: flush log file
+ *
+ * @param nothing
+ * @return nothing
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API void
+ico_apf_log_flush(void)
+{
+ if ((sDbgFd != NULL) && (ico_apf_log_flushmode == 0)) {
+ fflush(sDbgFd);
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_log_curtime: create current time string
+ *
+ * @param[in] level log level string(header of log message)
+ * @return current time string
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API char *
+ico_apf_log_curtime(const char *level)
+{
+ struct timeval NowTime;
+ extern long timezone;
+ static char sBuf[28];
+
+ gettimeofday(&NowTime, (struct timezone *)0);
+ if (sTimeZone > (24*60*60)) {
+ tzset();
+ sTimeZone = timezone;
+ }
+ NowTime.tv_sec -= sTimeZone;
+
+ sprintf(sBuf, "%02d:%02d:%02d.%03d[%s]@%d",
+ (int)((NowTime.tv_sec/3600) % 24),
+ (int)((NowTime.tv_sec/60) % 60),
+ (int)(NowTime.tv_sec % 60),
+ (int)NowTime.tv_usec/1000, level, getpid());
+
+ return sBuf;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_apf_log_setlevel: set log output level
+ *
+ * @param[in] loglevel log output level
+ * @return nothing
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API void
+ico_apf_log_setlevel(const int loglevel)
+{
+ ico_apf_log_level = loglevel & (~(ICO_APF_LOG_FLUSH|ICO_APF_LOG_NOFLUSH));
+
+ if (loglevel & (ICO_APF_LOG_FLUSH|ICO_APF_LOG_NOFLUSH)) {
+ if (loglevel & ICO_APF_LOG_FLUSH) {
+ ico_apf_log_flushmode = 1;
+ }
+ else {
+ ico_apf_log_flushmode = 0;
+ }
+ }
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief header file of AppsController interface
+ *
+ * @date Feb-28-2013
+ */
+
+#ifndef __ICO_APF_PRIVATEI_H__
+#define __ICO_APF_PRIVATEI_H__
+
+#include "ico_apf_log.h"
+#include "ico_uxf_sysdef.h"
+#include "ico_apf.h"
+#include "ico_apf_apimacro.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * AppsControllerr Protocol(TEXT)
+ *
+ * TEXT ="cmd resource appid device id (base id)"
+ *
+ * command(Client->AppsController)
+ * "GET BSCR appid disp id" ... Get basic screen
+ * "REL BSCR appid disp id" ... Release basic screen
+ * "GET ISCR appid disp id bid" ... Get interrupt screen
+ * "REL ISCR appid disp id bid" ... Release interrupt screen
+ * "GET OSCR appid disp id" ... Get on screen
+ * "REL OSCR appid disp id" ... Release on screen
+ * "GET BSND appid zone id adjust" ... Get basic sound
+ * "REL BSND appid zone id" ... Release basic sound
+ * "GET ISND appid zone id adjust" ... Get interrupt sound
+ * "REL ISND appid zone id" ... Release interrupt sound
+ * "ADD INPT appid device event" ... Add input switch
+ * "CHG INPT appid device event" ... Change input switch
+ * "DEL INPT appid device event" ... Delete input switch
+ * event(AppsController->Client)
+ * "ACQ BSCR appid disp id" ... Acquired basic screen(with surface visible)
+ * "DEP BSCR appid disp id" ... Deprived basic screen(with surface invisible)
+ * "WAI BSCR appid disp id" ... Waitting basic screen(with surface invisible)
+ * "DES BSCR appid disp id" ... Destoryed basic screen(with surface destory)
+ * * ISCR(interrupt screen), BSND(basic sound), ISND(interrupt sound),
+ * INPT(inout switch) are the same, too.
+ * reply(Client->AppsController)
+ * "ACK BSCR appid disp id" ... OK Reply basic screen
+ * "NAK BSCR appid disp id" ... NG Reply basic screen
+ * * ISCR(interrupt screen), BSND(basic sound), ISND(interrupt sound),
+ * INPT(inout switch) are the same, too.
+ */
+/* Multi Sound Manager Protocol(Text)
+ *
+ * TEXT ="#cmd# pid"
+ *
+ * command(Client->Multi Sound Manager)
+ * "#stream_mute_set# pid" ... Mute control on(mute)
+ * "#stream_mute_reset# pid" ... Mute control off((no mute)
+ * "#stream_cancel# pid" ... Cancel
+ * "#get_stream_list#" ... Get stream list
+ * "#fresh#" ... Fresh
+ * "#all_mute_set#" ... Mute on(mute) all streams
+ * "#all_mute_reset#" ... Mute off(no mute) all streams
+ * pid = process Id (decimal)
+ * event(Multi Sound Manager->Client)
+ * "#stream_new# #pid# pid #stream_name# str-name #app_name# app-name #command_end#"
+ * ... Create new sound stream
+ * pid = process Id (decimal)
+ * str-name = stream name
+ * app-name = application name(appid)
+ * "#stream_free# #pid# pid #stream_name# str-name #app_name# app-name #command_end#"
+ * ... End sound stream
+ * reply(Multi Sound Manager->Client)
+ * "#get_stream_list# #stream_state# state #pid# pid
+ * #stream_name# str-name #app_name# app-name #command_end#"
+ * ... reply of #get_stream_list# (multi message)
+ * state = "PA_SINK_INPUT_INIT"
+ * = "PA_SINK_INPUT_DRAINED"
+ * = "PA_SINK_INPUT_RUNNING"
+ * = "PA_SINK_INPUT_CORKED"
+ * = "PA_SINK_INPUT_UNLINKED"
+ * = "INCORRECT_STATUS"
+ * "#get_stream_list# #no_stream# #command_end#"
+ * ... reply of #get_stream_list# (no stream)
+ */
+
+/* Protocol name on libwebsockets for Application Manager */
+#define ICO_PROTOCOL_APPSCONTROLLER "ico_apps_controller"
+
+/* Protocol name on libwebsockets for Pulse-Audio Plugin(Multi Sound Manager)*/
+#define ICO_PROTOCOL_MULTISOUNDMANAGER "ico_soundmgr-protocol"
+
+/* AppsController resource control command and event */
+#define ICO_APF_SRESOURCE_STATE_ACQUIRED "ACQ"
+#define ICO_APF_SRESOURCE_STATE_DEPRIVED "DEP"
+#define ICO_APF_SRESOURCE_STATE_WAITTING "WAI"
+#define ICO_APF_SRESOURCE_STATE_RELEASED "DES"
+
+#define ICO_APF_SRESOURCE_COMMAND_GET "GET"
+#define ICO_APF_SRESOURCE_COMMAND_RELEASE "REL"
+#define ICO_APF_SRESOURCE_COMMAND_ADD "ADD"
+#define ICO_APF_SRESOURCE_COMMAND_CHANGE "CHG"
+#define ICO_APF_SRESOURCE_COMMAND_DELETE "DEL"
+
+#define ICO_APF_SRESOURCE_REPLY_OK "ACK"
+#define ICO_APF_SRESOURCE_REPLY_NG "NAK"
+#define ICO_APF_SRESOURCE_STATE_CONNECTED "CON"
+#define ICO_APF_SRESOURCE_STATE_DISCONNECTED "DCN"
+
+/* AppsController resource control target object */
+#define ICO_APF_SRESID_BASIC_SCREEN "BSCR"
+#define ICO_APF_SRESID_INT_SCREEN "ISCR"
+#define ICO_APF_SRESID_ON_SCREEN "OSCR"
+#define ICO_APF_SRESID_BASIC_SOUND "BSND"
+#define ICO_APF_SRESID_INT_SOUND "ISND"
+#define ICO_APF_SRESID_INPUT_DEV "INPT"
+
+/* Multi Sound Manager sound control command */
+#define ICO_APF_SSOUND_COMMAND_MUTEON "#stream_mute_set#"
+#define ICO_APF_SSOUND_COMMAND_MUTEOFF "#stream_mute_reset#"
+#define ICO_APF_SSOUND_COMMAND_CANCEL "#stream_cancel#"
+#define ICO_APF_SSOUND_COMMAND_GETLIST "#get_stream_list#"
+#define ICO_APF_SSOUND_COMMAND_FRESH "#fresh#"
+#define ICO_APF_SSOUND_COMMAND_ALLMUTEON "#all_mute_set#"
+#define ICO_APF_SSOUND_COMMAND_ALLMUTEOFF "#all_mute_reset#"
+
+#define ICO_APF_SSOUND_EVENT_NEW "#stream_new#"
+#define ICO_APF_SSOUND_EVENT_FREE "#stream_free#"
+
+#define ICO_APF_SSOUND_REPLY_LIST "#get_stream_list#"
+
+/* Maximum number of send/receive items */
+#define ICO_APF_RESOURCE_MSG_LEN 256 /* Maximum length of message */
+#define ICO_APF_RESOURCE_WSOCK_BUFS 128 /* Number of the buffer for send data */
+#define ICO_APF_RESOURCE_WSOCK_BUFR 64 /* Number of the buffer for receive data*/
+#define ICO_APF_RESOURCE_IP_LEN 20 /* IP address length */
+
+/* Define connection type */
+#define ICO_APF_COM_TYPE_SERVER 0xf0 /* server type */
+#define ICO_APF_COM_TYPE_CONNECTION 0x0f /* connection type */
+#define ICO_APF_COM_TYPE_APPSCTL 0x01 /* connect to AppsController */
+#define ICO_APF_COM_TYPE_SOUNDMGR 0x02 /* connect to Multi Sound Manager*/
+#define ICO_APF_COM_TYPE_SVR_APPSCTL 0x11 /* server(listen) for AppsController*/
+#define ICO_APF_COM_TYPE_SVR_SOUNDMGR 0x12 /* server(listen) for Sound Manager*/
+
+/* Defines of Input/Output Event Flags */
+#define ICO_APF_COM_POLL_READ 1 /* input flag */
+#define ICO_APF_COM_POLL_WRITE 2 /* output flag */
+#define ICO_APF_COM_POLL_ERROR 4 /* error flag */
+
+/* Data queue for send/receive */
+typedef struct _ico_apf_com_buffer {
+ short cmd; /* command */
+ short res; /* resource */
+ int pid; /* requeste client pid */
+ char appid[ICO_UXF_MAX_PROCESS_NAME+1];
+ /* application id (for Web application) */
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+ /* message */
+} ico_apf_com_buffer_t;
+
+/* Listener function prototype */
+typedef struct _ico_apf_com_handle ico_apf_com_handle_t;
+typedef void (*ico_apf_com_eventlistener)(ico_apf_com_handle_t *handle, int cmd, int res,
+ int pid, char *appid, char *msg, void* user_data);
+typedef struct _ico_apf_com_poll ico_apf_com_poll_t;
+typedef void (*ico_apf_com_pollfd_cb)(ico_apf_com_poll_t *fd_ctl[], const int num_fds);
+
+/* AppsController Handle */
+struct _ico_apf_com_handle {
+ ico_apf_com_handle_t *next; /* next handle */
+ short hostid; /* Host Id(unused) */
+ char service_on; /* connected(=1)/ not connect(=0) */
+ char type; /* connection type */
+ char ip[ICO_APF_RESOURCE_IP_LEN];/* IP address */
+ int port; /* port number */
+ int fd; /* Socket file descriptor */
+ ico_apf_com_poll_t *poll; /* poll table */
+ int pid; /* client pid (server only) */
+
+ struct libwebsocket_context *wsi_context;
+ /* Context of libwebsockets */
+ struct libwebsocket *wsi_connection;/* WSI of libwebsockets */
+
+ short retry; /* Retry counter */
+ short stoprecv; /* Receive stopped(flow control) */
+ unsigned short shead; /* Head position of send datas */
+ unsigned short stail; /* Tail position of send datas */
+ ico_apf_com_buffer_t *sbuf[ICO_APF_RESOURCE_WSOCK_BUFS];
+ /* Send buffers */
+ unsigned short rhead; /* Head position of receive datas */
+ unsigned short rtail; /* Tail position of receive datas */
+ ico_apf_com_buffer_t *rbuf[ICO_APF_RESOURCE_WSOCK_BUFR];
+ /* Receive buffers */
+ ico_apf_com_eventlistener listener;
+ /* Listener function(if NULL, not regist)*/
+ void *user_data; /* Listener argument */
+};
+
+/* Structure of File Descriptor's Controller */
+struct _ico_apf_com_poll {
+ ico_apf_com_poll_t *next; /* next table */
+ int fd; /* number of changing File Descriptor */
+ int flags; /* input/output/error flag */
+ void *apf_fd_control; /* address of AppFW's controll table */
+ void *user_data; /* user data */
+};
+
+/* API functions prototype */
+ico_apf_com_handle_t *ico_apf_com_init_client(const char *uri, const int type);
+ico_apf_com_handle_t *ico_apf_com_init_server(const char *uri, const int type);
+int ico_apf_com_term_client(ico_apf_com_handle_t *handle);
+int ico_apf_com_term_server(ico_apf_com_handle_t *handle);
+int ico_apf_com_isconnected(ico_apf_com_handle_t *handle);
+int ico_apf_com_send(ico_apf_com_handle_t *handle,
+ const int cmd, const int res, const char *appid, char *msg);
+int ico_apf_com_addeventlistener(ico_apf_com_handle_t *handle,
+ ico_apf_com_eventlistener listener,
+ void *user_data);
+int ico_apf_com_removeeventlistener(ico_apf_com_handle_t *handle);
+void ico_apf_com_dispatch(ico_apf_com_handle_t *handle, const int timeoutms);
+
+/* API for file descriptor poll */
+int ico_apf_com_poll_fd_control(ico_apf_com_pollfd_cb poll_fd_cb);
+int ico_apf_com_poll_fd_event(ico_apf_com_poll_t *fd_ctl, int flags);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /*__ICO_APF_PRIVATEI_H__*/
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief header file of Apprication Framework (Resource Control)
+ *
+ * @date Feb-28-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "ico_apf_private.h"
+#include "ico_uxf_conf.h"
+
+/* type user callback information */
+typedef struct _resmgr_user_cb_info {
+ ico_apf_resource_notify_cb_t callbacks;
+ void *user_data;
+} resmgr_user_cb_info_t;
+
+/* communication handle management table */
+typedef struct _remgr_com_handle {
+ struct _remgr_com_handle *next;
+ ico_apf_com_handle_t *handle; /* communication handle */
+ int pid; /* client process id */
+ char appid[ICO_UXF_MAX_PROCESS_NAME+1];
+ /* client application id */
+} remgr_com_handle_t;
+
+/* private variable */
+static ico_apf_com_handle_t *appsctl_handle = NULL;
+static ico_apf_com_handle_t *soundmgr_handle = NULL;
+static resmgr_user_cb_info_t user_cb_info = {NULL, NULL};
+static int resmgr_initialized = 0;
+static remgr_com_handle_t *handles = NULL;
+static remgr_com_handle_t *freehandles = NULL;
+static Ico_Uxf_Sys_Config *sysconf = NULL;
+static Ico_Uxf_Sys_Config *ifsysconf = NULL;
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Callback at received from AppsController for client
+ *
+ * @param[in] handle communication handle
+ * @param[in] cmd command(event) code
+ * @param[in] res target resource
+ * @param[in] pid request client pid (server only)
+ * @param[in] appid request client application id (server only)
+ * @param[in] msg received message
+ * @param[in] user_data (unused)
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ico_apf_resmgr_client_event(ico_apf_com_handle_t *handle, int cmd, int res,
+ int pid, char *appid, char *msg, void* user_data)
+{
+ int i;
+ ico_apf_resource_notify_info_t info;
+
+ apfw_trace("ico_apf_resmgr_client_event: cmd=%d res=%d pid=%d(%s) msg=<%s>",
+ cmd, res, pid, appid, msg);
+
+ if (user_cb_info.callbacks != NULL) {
+ memset(&info, 0, sizeof(info));
+
+ /* get device and id */
+ for (i = 0; msg[i]; i++) {
+ if( msg[i] == ' ') break;
+ if (i < ICO_UXF_MAX_DEVICE_NAME) {
+ info.device[i] = msg[i];
+ }
+ }
+ if (msg[i] == ' ') {
+ info.id = strtol(&msg[i+1], (char **)0, 0);
+ }
+ info.state = (ico_apf_resource_state_e)cmd;
+ info.resid = res;
+ info.pid = pid;
+ strncpy(info.appid, appid, ICO_UXF_MAX_PROCESS_NAME);
+ user_cb_info.callbacks(&info, user_cb_info.user_data);
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Callback at received from Application for server
+ *
+ * @param[in] handle communication handle
+ * @param[in] cmd command(event) code
+ * @param[in] res target resource
+ * @param[in] pid request client pid (server only)
+ * @param[in] appid request client application id (server only)
+ * @param[in] msg received message
+ * @param[in] user_data (unused)
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ico_apf_resmgr_server_event(ico_apf_com_handle_t *handle, int cmd, int res,
+ int pid, char *appid, char *msg, void* user_data)
+{
+ int i;
+ ico_apf_resource_notify_info_t info;
+ remgr_com_handle_t *p;
+ remgr_com_handle_t *bp;
+
+ apfw_trace("ico_apf_resmgr_server_event: handle=%08x cmd=%d res=%d pid=%d(%s) msg=<%s>",
+ (int)handle, cmd, res, pid, appid, msg);
+
+ /* regist communication handle table */
+ p = handles;
+ while (p) {
+ if (p->handle == handle) break;
+ p = p->next;
+ }
+ if (! p) {
+ apfw_trace("ico_apf_resmgr_server_event: new client");
+ if (freehandles) {
+ p = freehandles;
+ freehandles = p->next;
+ }
+ else {
+ p = malloc(sizeof(remgr_com_handle_t));
+ }
+ if (p) {
+ memset(p, 0, sizeof(remgr_com_handle_t));
+ if (! handles) {
+ handles = p;
+ }
+ else {
+ p->next = handles;
+ handles = p;
+ }
+ p->handle = handle;
+ p->pid = pid;
+ }
+ }
+
+ memset(&info, 0, sizeof(info));
+
+ /* get device and id */
+ for (i = 0; msg[i] ; i++) {
+ if (msg[i] == ' ') break;
+ if (i < ICO_UXF_MAX_DEVICE_NAME) {
+ info.device[i] = msg[i];
+ }
+ }
+ if (msg[i] == ' ') {
+ sscanf(&msg[i+1], "%d %d", &info.id, &info.bid);
+ }
+ info.state = (ico_apf_resource_state_e)cmd;
+ info.resid = res;
+ info.pid = pid;
+ if (appid[0] ) {
+ strncpy(info.appid, appid, ICO_UXF_MAX_PROCESS_NAME);
+ strcpy(p->appid, info.appid);
+ }
+ else if (pid != 0) {
+ info.pid = pid;
+ ico_apf_get_app_id(pid, info.appid);
+ strcpy(p->appid, info.appid);
+ }
+
+ if (info.state == ICO_APF_RESOURCE_STATE_CONNECTED) {
+ /* regist communication handle table */
+ p = handles;
+ while (p) {
+ if (p->handle == handle) break;
+ p = p->next;
+ }
+ if (! p) {
+ if (freehandles) {
+ p = freehandles;
+ freehandles = p->next;
+ }
+ else {
+ p = malloc(sizeof(remgr_com_handle_t));
+ }
+ if (p) {
+ memset(p, 0, sizeof(remgr_com_handle_t));
+ if (! handles) {
+ handles = p;
+ }
+ else {
+ p->next = handles;
+ handles = p;
+ }
+ p->handle = handle;
+ p->pid = pid;
+ strncpy(p->appid, info.appid, ICO_UXF_MAX_PROCESS_NAME);
+ }
+ }
+ }
+ else if (info.state == ICO_APF_RESOURCE_STATE_DISCONNECTED) {
+ /* destory communiction handle table */
+ p = handles;
+ bp = NULL;
+ while (p) {
+ if (p->handle == handle) break;
+ bp = p;
+ p = p->next;
+ }
+ if (p) {
+ if (bp) {
+ bp->next = p->next;
+ }
+ else {
+ handles = p->next;
+ }
+ p->next = freehandles;
+ freehandles = p;
+ }
+ }
+ if (user_cb_info.callbacks != NULL) {
+ user_cb_info.callbacks(&info, user_cb_info.user_data);
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Initialize resouce manager component for client Application
+ *
+ * @param[in] uri server URI
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_INIT_COM_FAILD can not create connection
+ * @retval ICO_APF_RESOURCE_E_INIT_COMMUNICATION initialize communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_init_client(const char *uri)
+{
+ apfw_trace("ico_apf_resource_init_client: Enter(%s)", uri ? uri : "NULL");
+
+ if (resmgr_initialized != 0) {
+ apfw_warn("ico_apf_resource_init_client: Leave(already intialiezed)");
+ return ICO_APF_RESOURCE_E_NONE;
+ }
+
+ /* initialize connection for AppsController */
+ appsctl_handle = ico_apf_com_init_client(uri, ICO_APF_COM_TYPE_APPSCTL);
+
+ if (! appsctl_handle) {
+ apfw_error("ico_apf_resource_init_client: Leave(can not create connection)");
+ return ICO_APF_RESOURCE_E_INIT_COM_FAILD;
+ }
+
+ /* get system configuration */
+ ifsysconf = (Ico_Uxf_Sys_Config *)ico_uxf_ifGetSysConfig();
+ if (ifsysconf) {
+ /* Another module already reads config file */
+ /* In this case, you don't release sysconf at finished this function. */
+ sysconf = (Ico_Uxf_Sys_Config *)ifsysconf;
+ }
+ else {
+ /* never read a system config */
+ sysconf = (Ico_Uxf_Sys_Config *)ico_uxf_getSysConfig();
+ }
+ if (!sysconf) {
+ apfw_error("ico_apf_resource_init_client: Leave(can not read configuration files)");
+ return ICO_APF_RESOURCE_E_INIT_COM_FAILD;
+ }
+
+ if (ico_apf_com_addeventlistener(NULL, ico_apf_resmgr_client_event, NULL)
+ != ICO_APF_E_NONE) {
+ apfw_error("ico_apf_resource_init_client: Leave(can not set callback)");
+ return ICO_APF_RESOURCE_E_INIT_COM_FAILD;
+ }
+
+ /* chanage resmgr_client_intialized flag */
+ resmgr_initialized = 1;
+
+ apfw_trace("ico_apf_resource_init_client: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Terminame resouce manager component
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API void
+ico_apf_resource_term_client(void)
+{
+ apfw_trace("ico_apf_resource_term_client: Enter");
+
+ /* unset callback functions */
+ ico_apf_resource_unset_event_cb();
+
+ /* terminate resourece server communication */
+ (void) ico_apf_com_term_client(appsctl_handle);
+ appsctl_handle = NULL;
+
+ /* close system configuration */
+ if (! ifsysconf) {
+ ico_uxf_closeSysConfig();
+ }
+
+ /* chanage resmgr_client_intialized flag */
+ resmgr_initialized = 0;
+
+ apfw_trace("ico_apf_resource_term_client: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Initialize resouce manager component for server Application
+ *
+ * @param[in] uri my URI
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_INIT_COM_FAILD can not create connection
+ * @retval ICO_APF_RESOURCE_E_INIT_COMMUNICATION initialize communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_init_server(const char *uri)
+{
+ apfw_trace("ico_apf_resource_init_server: Enter(%s)", uri ? uri : "NULL");
+
+ if (resmgr_initialized != 0) {
+ apfw_warn("ico_apf_resource_init_server: Leave(already intialiezed)");
+ return ICO_APF_RESOURCE_E_NONE;
+ }
+
+ /* initialize connection for AppsController */
+ appsctl_handle = ico_apf_com_init_server(uri, ICO_APF_COM_TYPE_APPSCTL);
+ if (! appsctl_handle) {
+ apfw_error("ico_apf_resource_init_server: Leave(can not create connection)");
+ return ICO_APF_RESOURCE_E_INIT_COM_FAILD;
+ }
+
+ /* initialize connection for Multi Input Manager */
+ soundmgr_handle = ico_apf_com_init_client(NULL, ICO_APF_COM_TYPE_SOUNDMGR);
+ if (! soundmgr_handle) {
+ apfw_error("ico_apf_resource_init_server: Leave(can not connect MSM)");
+ return ICO_APF_RESOURCE_E_INIT_COM_FAILD;
+ }
+
+ /* get system configuration */
+ ifsysconf = (Ico_Uxf_Sys_Config *)ico_uxf_ifGetSysConfig();
+ if (ifsysconf) {
+ /* Another module already reads config file */
+ /* In this case, you don't release sysconf at finished this function. */
+ sysconf = (Ico_Uxf_Sys_Config *)ifsysconf;
+ }
+ else {
+ /* never read a system config */
+ sysconf = (Ico_Uxf_Sys_Config *)ico_uxf_getSysConfig();
+ }
+ if (!sysconf) {
+ apfw_error("ico_apf_resource_init_server: Leave(can not read configuration files)");
+ return ICO_APF_RESOURCE_E_INIT_COM_FAILD;
+ }
+
+ if (ico_apf_com_addeventlistener(NULL, ico_apf_resmgr_server_event, NULL)
+ != ICO_APF_E_NONE) {
+ apfw_error("ico_apf_resource_init_server: Leave(can not set callback)");
+ return ICO_APF_RESOURCE_E_INIT_COM_FAILD;
+ }
+
+ /* chanage resmgr_client_intialized flag */
+ resmgr_initialized = 1;
+
+ apfw_trace("ico_apf_resource_init_server: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Terminame resouce manager component
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API void
+ico_apf_resource_term_server(void)
+{
+ apfw_trace("ico_apf_resource_term_server: Enter");
+
+ /* unset callback functions */
+ ico_apf_resource_unset_event_cb();
+
+ /* terminate resourece server communication */
+ (void) ico_apf_com_term_server(appsctl_handle);
+ appsctl_handle = NULL;
+
+ /* terminate Multi Sound Manager client communication */
+ (void) ico_apf_com_term_client(soundmgr_handle);
+ soundmgr_handle = NULL;
+
+ /* close system configuration */
+ if (! ifsysconf) {
+ ico_uxf_closeSysConfig();
+ }
+
+ /* chanage resmgr_client_intialized flag */
+ resmgr_initialized = 0;
+
+ apfw_trace("ico_apf_resource_term_server: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Set event callback function
+ *
+ * @param[in] callbacks callback functions
+ * @param[in] user_data passed data on called callback function
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_INVAL callbacks is null
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_set_event_cb(ico_apf_resource_notify_cb_t callbacks,
+ void *user_data)
+{
+ apfw_trace("ico_apf_resource_set_event_cb: Enter(0x%08x, 0x%08x)",
+ (int)callbacks, (int)user_data);
+
+ if (callbacks == NULL) {
+ apfw_error("ico_apf_resource_set_event_cb: Leave(callbacks is NULL)");
+ return ICO_APF_RESOURCE_E_INVAL;
+ }
+ user_cb_info.callbacks = callbacks;
+ user_cb_info.user_data = user_data;
+
+ apfw_trace("ico_apf_resource_set_event_cb: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Unset event callback function
+ *
+ * @param none
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success(At present, always give back this)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_unset_event_cb(void)
+{
+ apfw_trace("ico_apf_resource_unset_event_cb:");
+
+ user_cb_info.callbacks = NULL;
+ user_cb_info.user_data = NULL;
+
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Get the rights of basic screen
+ *
+ * @param[in] disp_dev display device uri
+ * @param[in] src_id id of basic screen
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_get_screen_mode(const char* disp_dev, int scr_id)
+{
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+
+ apfw_trace("ico_apf_resource_get_screen_mode: Enter(%s,%d)",
+ disp_dev ? disp_dev : "(NULL)", scr_id);
+
+ if ((! resmgr_initialized) || (! appsctl_handle)) {
+ apfw_error("ico_apf_resource_get_screen_mode: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ /* set send message parameter */
+ if (disp_dev) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d", disp_dev, scr_id);
+ }
+ else {
+ /* no display URI, default display */
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d",
+ sysconf->display[sysconf->misc.default_displayId].
+ zone[sysconf->misc.default_dispzoneId].name, scr_id);
+ }
+ if (ico_apf_com_send(appsctl_handle, ICO_APF_RESOURCE_COMMAND_GET,
+ ICO_APF_RESID_BASIC_SCREEN, NULL, msg)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_error("ico_apf_resource_get_screen_mode: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ apfw_trace("ico_apf_resource_get_screen_mode: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Release the rights of basic screen
+ *
+ * @param[in] disp_dev display device uri
+ * @param[in] src_id id of basic screen
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_release_screen_mode(const char* disp_dev, int scr_id)
+{
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+
+ apfw_trace("ico_apf_resource_release_screen_mode: Enter(%s,%d)",
+ disp_dev ? disp_dev : "(NULL)", scr_id);
+
+ if ((! resmgr_initialized) || (! appsctl_handle)) {
+ apfw_error("ico_apf_resource_release_screen_mode: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ /* set send message parameter */
+ if (disp_dev) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d", disp_dev, scr_id);
+ }
+ else {
+ /* no display URI, default display */
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d",
+ sysconf->display[sysconf->misc.default_displayId].
+ zone[sysconf->misc.default_dispzoneId].name, scr_id);
+ }
+ if (ico_apf_com_send(appsctl_handle, ICO_APF_RESOURCE_COMMAND_RELEASE,
+ ICO_APF_RESID_BASIC_SCREEN, NULL, msg)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("ico_apf_resource_release_screen_mode: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ apfw_trace("ico_apf_resource_release_screen_mode: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Reply the rights of basic screen
+ *
+ * @param[in] disp_dev display device uri
+ * @param[in] src_id id of basic screen
+ * @param[in] ok OK(1) or NG(0)
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_reply_screen_mode(const char* disp_dev, int scr_id, const int ok)
+{
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+
+ apfw_trace("ico_apf_resource_reply_screen_mode: Enter(%s,%d,%d)",
+ disp_dev ? disp_dev : "(NULL)", scr_id, ok);
+
+ if ((! resmgr_initialized) || (! appsctl_handle)) {
+ apfw_error("ico_apf_resource_reply_screen_mode: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ /* set send message parameter */
+ if (disp_dev) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d", disp_dev, scr_id);
+ }
+ else {
+ /* no display URI, default display */
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d",
+ sysconf->display[sysconf->misc.default_displayId].
+ zone[sysconf->misc.default_dispzoneId].name, scr_id);
+ }
+ if (ico_apf_com_send(appsctl_handle,
+ (ok != 0) ? ICO_APF_RESOURCE_REPLY_OK
+ : ICO_APF_RESOURCE_REPLY_NG,
+ ICO_APF_RESID_BASIC_SCREEN, NULL, msg)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("ico_apf_resource_reply_screen_mode: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ apfw_trace("ico_apf_resource_reply_screen_mode: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Release the rights of interrupt screen
+ *
+ * @param[in] disp_dev display device uri
+ * @param[in] src_id id of basic screen
+ * @param[in] int_src_id id of interrupt screen
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_get_int_screen_mode(const char* disp_dev,
+ int scr_id, int int_scr_id)
+{
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+
+ apfw_trace("ico_apf_resource_get_int_screen_mode: Enter(%s,%d,%d)",
+ disp_dev ? disp_dev : "(NULL)", scr_id, int_scr_id);
+
+ if ((! resmgr_initialized) || (! appsctl_handle)) {
+ apfw_error("ico_apf_resource_get_int_screen_mode: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ /* set send message parameter */
+ if (disp_dev) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d %d",
+ disp_dev, int_scr_id, scr_id);
+ }
+ else {
+ /* no display URI, default display */
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d %d",
+ sysconf->display[sysconf->misc.default_displayId].
+ zone[sysconf->misc.default_dispzoneId].name,
+ int_scr_id, scr_id);
+ }
+ if (ico_apf_com_send(appsctl_handle, ICO_APF_RESOURCE_COMMAND_GET,
+ ICO_APF_RESID_INT_SCREEN, NULL, msg)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_error("ico_apf_resource_get_int_screen_mode: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ apfw_trace("ico_apf_resource_get_int_screen_mode: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Release the rights of interrupt screen on basic screen
+ *
+ * @param[in] disp_dev display device uri
+ * @param[in] src_id id of basic screen
+ * @param[in] int_scr_id id of interrupt screen
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_release_int_screen_mode(const char* disp_dev,
+ int scr_id, int int_scr_id)
+{
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+
+ apfw_trace("ico_apf_resource_release_int_screen_mode: Enter(%s,%d,%d)",
+ disp_dev ? disp_dev : "(NULL)", scr_id, int_scr_id);
+
+ if ((! resmgr_initialized) || (! appsctl_handle)) {
+ apfw_error("ico_apf_resource_release_int_screen_mode: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ /* set send message parameter */
+ if (disp_dev) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d %d",
+ disp_dev, int_scr_id, scr_id);
+ }
+ else {
+ /* no display URI, default display */
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d %d",
+ sysconf->display[sysconf->misc.default_displayId].
+ zone[sysconf->misc.default_dispzoneId].name,
+ int_scr_id, scr_id);
+ }
+ if (ico_apf_com_send(appsctl_handle, ICO_APF_RESOURCE_COMMAND_RELEASE,
+ ICO_APF_RESID_INT_SCREEN, NULL, msg)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("ico_apf_resource_release_int_screen_mode: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ apfw_trace("ico_apf_resource_release_int_screen_mode: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Reply the rights of interrupt screen on basic screen
+ *
+ * @param[in] disp_dev display device uri
+ * @param[in] src_id id of basic screen
+ * @param[in] int_scr_id id of interrupt screen
+ * @param[in] ok OK(1) or NG(0)
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_reply_int_screen_mode(const char* disp_dev,
+ int scr_id, int int_scr_id, const int ok)
+{
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+
+ apfw_trace("ico_apf_resource_reply_int_screen_mode: Enter(%s,%d,%d,%d)",
+ disp_dev ? disp_dev : "(NULL)", scr_id, int_scr_id, ok);
+
+ if ((! resmgr_initialized) || (! appsctl_handle)) {
+ apfw_error("ico_apf_resource_reply_int_screen_mode: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ /* set send message parameter */
+ if (disp_dev) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d %d",
+ disp_dev, int_scr_id, scr_id);
+ }
+ else {
+ /* no display URI, default display */
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d %d",
+ sysconf->display[sysconf->misc.default_displayId].
+ zone[sysconf->misc.default_dispzoneId].name,
+ int_scr_id, scr_id);
+ }
+ if (ico_apf_com_send(appsctl_handle,
+ (ok != 0) ? ICO_APF_RESOURCE_REPLY_OK
+ : ICO_APF_RESOURCE_REPLY_NG,
+ ICO_APF_RESID_INT_SCREEN, NULL, msg)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("ico_apf_resource_reply_int_screen_mode: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ apfw_trace("ico_apf_resource_reply_int_screen_mode: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Get the rights of interrupt screen on display
+ *
+ * @param[in] disp_dev display device uri
+ * @param[in] int_scr_id id of interrupt screen
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_get_int_screen_mode_disp(const char* disp_dev, int int_scr_id)
+{
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+
+ apfw_trace("ico_apf_resource_get_int_screen_mode_disp: Enter(%s,%d)",
+ disp_dev ? disp_dev : "(NULL)", int_scr_id);
+
+ if ((! resmgr_initialized) || (! appsctl_handle)) {
+ apfw_error("ico_apf_resource_get_int_screen_mode_disp: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ /* set send message parameter */
+ if (disp_dev) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d", disp_dev, int_scr_id);
+ }
+ else {
+ /* no display URI, default display */
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d",
+ sysconf->display[sysconf->misc.default_displayId].
+ zone[sysconf->misc.default_dispzoneId].name, int_scr_id);
+ }
+ if (ico_apf_com_send(appsctl_handle, ICO_APF_RESOURCE_COMMAND_GET,
+ ICO_APF_RESID_ON_SCREEN, NULL, msg)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_error("ico_apf_resource_get_int_screen_mode_disp: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ apfw_trace("ico_apf_resource_get_int_screen_mode_disp: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Release the rights of interrupt screen on display
+ *
+ * @param[in] disp_dev display device uri
+ * @param[in] int_scr_id id of interrupt screen
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_release_int_screen_mode_disp(const char* disp_dev,
+ int int_scr_id)
+{
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+
+ apfw_trace("ico_apf_resource_release_int_screen_mode_disp: Enter(%s,%d)",
+ disp_dev ? disp_dev : "(NULL)", int_scr_id);
+
+ if ((! resmgr_initialized) || (! appsctl_handle)) {
+ apfw_error("ico_apf_resource_release_int_screen_mode_disp: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ /* set send message parameter */
+ if (disp_dev) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d", disp_dev, int_scr_id);
+ }
+ else {
+ /* no display URI, default display */
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d",
+ sysconf->display[sysconf->misc.default_displayId].
+ zone[sysconf->misc.default_dispzoneId].name, int_scr_id);
+ }
+ if (ico_apf_com_send(appsctl_handle, ICO_APF_RESOURCE_COMMAND_RELEASE,
+ ICO_APF_RESID_ON_SCREEN, NULL, msg)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("ico_apf_resource_release_int_screen_mode_disp: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ apfw_trace("ico_apf_resource_release_int_screen_mode_disp: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Reply the rights of interrupt screen on display
+ *
+ * @param[in] disp_dev display device uri
+ * @param[in] int_scr_id id of interrupt screen
+ * @param[in] ok OK(1) or NG(0)
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_reply_int_screen_mode_disp(const char* disp_dev,
+ int int_scr_id, const int ok)
+{
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+
+ apfw_trace("ico_apf_resource_reply_int_screen_mode_disp: Enter(%s,%d,%d)",
+ disp_dev ? disp_dev : "(NULL)", int_scr_id, ok);
+
+ if ((! resmgr_initialized) || (! appsctl_handle)) {
+ apfw_error("ico_apf_resource_reply_int_screen_mode_disp: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ /* set send message parameter */
+ if (disp_dev) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d", disp_dev, int_scr_id);
+ }
+ else {
+ /* no display URI, default display */
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d",
+ sysconf->display[sysconf->misc.default_displayId].
+ zone[sysconf->misc.default_dispzoneId].name, int_scr_id);
+ }
+ if (ico_apf_com_send(appsctl_handle,
+ (ok != 0) ? ICO_APF_RESOURCE_REPLY_OK
+ : ICO_APF_RESOURCE_REPLY_NG,
+ ICO_APF_RESID_ON_SCREEN, NULL, msg)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("ico_apf_resource_reply_int_screen_mode_disp: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ apfw_trace("ico_apf_resource_reply_int_screen_mode_disp: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Get the rights of basic sound on zone
+ *
+ * @param[in] zone sound device uri
+ * @param[in] snd_id id of basic sound
+ * @param[in] adjust adjust acction
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_get_sound_mode(const char* zone, int snd_id, int adjust)
+{
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+
+ apfw_trace("ico_apf_resource_get_sound_mode: Enter(%s,%d,%d)",
+ zone ? zone : "(NULL)", snd_id, adjust);
+
+ if ((! resmgr_initialized) || (! appsctl_handle)) {
+ apfw_error("ico_apf_resource_get_sound_mode: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ /* set send message parameter */
+ if (zone) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d %d", zone, snd_id, adjust);
+ }
+ else {
+ /* no zone, default zone */
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d %d",
+ sysconf->sound[sysconf->misc.default_soundId].
+ zone[sysconf->misc.default_soundzoneId].name,
+ snd_id, adjust);
+ }
+ if (ico_apf_com_send(appsctl_handle, ICO_APF_RESOURCE_COMMAND_GET,
+ ICO_APF_RESID_BASIC_SOUND, NULL, msg)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_error("ico_apf_resource_get_sound_mode: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ apfw_trace("ico_apf_resource_get_sound_mode: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Release the rights of basic sound on zone
+ *
+ * @param[in] zone sound device uri
+ * @param[in] snd_id id of basic sound
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_release_sound_mode(const char* zone, int snd_id)
+{
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+
+ apfw_trace("ico_apf_resource_release_sound_mode: Enter(%s,%d)",
+ zone ? zone : "(NULL)", snd_id);
+
+ if ((! resmgr_initialized) || (! appsctl_handle)) {
+ apfw_error("ico_apf_resource_release_sound_mode: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ /* set send message parameter */
+ if (zone) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d", zone, snd_id);
+ }
+ else {
+ /* no zone, default zone */
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d",
+ sysconf->sound[sysconf->misc.default_soundId].
+ zone[sysconf->misc.default_soundzoneId].name, snd_id);
+ }
+ if (ico_apf_com_send(appsctl_handle, ICO_APF_RESOURCE_COMMAND_RELEASE,
+ ICO_APF_RESID_BASIC_SOUND, NULL, msg)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("ico_apf_resource_release_sound_mode: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ apfw_trace("ico_apf_resource_release_sound_mode: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Reply the rights of basic sound on zone
+ *
+ * @param[in] zone sound device uri
+ * @param[in] snd_id id of basic sound
+ * @param[in] ok OK(1) or NG(0)
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_reply_sound_mode(const char* zone, int snd_id, const int ok)
+{
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+
+ apfw_trace("ico_apf_resource_reply_sound_mode: Enter(%s,%d,%d)",
+ zone ? zone : "(NULL)", snd_id, ok);
+
+ if ((! resmgr_initialized) || (! appsctl_handle)) {
+ apfw_error("ico_apf_resource_reply_sound_mode: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ /* set send message parameter */
+ if (zone) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d", zone, snd_id);
+ }
+ else {
+ /* no zone, default zone */
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d",
+ sysconf->sound[sysconf->misc.default_soundId].
+ zone[sysconf->misc.default_soundzoneId].name, snd_id);
+ }
+ if (ico_apf_com_send(appsctl_handle,
+ (ok != 0) ? ICO_APF_RESOURCE_REPLY_OK
+ : ICO_APF_RESOURCE_REPLY_NG,
+ ICO_APF_RESID_BASIC_SOUND, NULL, msg)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("ico_apf_resource_reply_sound_mode: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ apfw_trace("ico_apf_resource_reply_sound_mode: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Get the rights of interrupt sound on zone
+ *
+ * @param[in] zone sound device uri
+ * @param[in] int_snd_id id of basic sound
+ * @param[in] adjust adjust action
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_get_int_sound_mode(const char* zone,
+ int int_snd_id, int adjust)
+{
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+
+ apfw_trace("ico_apf_resource_get_int_sound_mode: Enter(%s,%d,%d)",
+ zone ? zone : "(NULL)", int_snd_id, adjust);
+
+ if ((! resmgr_initialized) || (! appsctl_handle)) {
+ apfw_error("ico_apf_resource_get_int_sound_mode: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ /* set send message parameter */
+ if (zone) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d %d", zone, int_snd_id, adjust);
+ }
+ else {
+ /* no zone, default zone */
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d %d",
+ sysconf->sound[sysconf->misc.default_soundId].
+ zone[sysconf->misc.default_soundzoneId].name,
+ int_snd_id, adjust);
+ }
+ if (ico_apf_com_send(appsctl_handle, ICO_APF_RESOURCE_COMMAND_GET,
+ ICO_APF_RESID_INT_SOUND, NULL, msg)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_error("ico_apf_resource_get_int_sound_mode: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ apfw_trace("ico_apf_resource_get_int_sound_mode: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Release the rights of interrupt sound on zone
+ *
+ * @param[in] zone sound device uri
+ * @param[in] int_snd_id id of interrupt sound
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_release_int_sound_mode(const char* zone, int int_snd_id)
+{
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+
+ apfw_trace("ico_apf_resource_release_int_sound_mode: Enter(%s,%d)",
+ zone ? zone : "(NULL)", int_snd_id);
+
+ if ((! resmgr_initialized) || (! appsctl_handle)) {
+ apfw_error("ico_apf_resource_release_int_sound_mode: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ /* set send message parameter */
+ if (zone) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d", zone, int_snd_id);
+ }
+ else {
+ /* no zone, default zone */
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d",
+ sysconf->sound[sysconf->misc.default_soundId].
+ zone[sysconf->misc.default_soundzoneId].name, int_snd_id);
+ }
+ if (ico_apf_com_send(appsctl_handle, ICO_APF_RESOURCE_COMMAND_RELEASE,
+ ICO_APF_RESID_INT_SOUND, NULL, msg)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("ico_apf_resource_release_int_sound_mode: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ apfw_trace("ico_apf_resource_release_int_sound_mode: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Reply the rights of interrupt sound on zone
+ *
+ * @param[in] zone sound device uri
+ * @param[in] int_snd_id id of interrupt sound
+ * @param[in] ok OK(1) or NG(0)
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_reply_int_sound_mode(const char* zone, int int_snd_id, const int ok)
+{
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+
+ apfw_trace("ico_apf_resource_reply_int_sound_mode: Enter(%s,%d,%d)",
+ zone ? zone : "(NULL)", int_snd_id, ok);
+
+ if ((! resmgr_initialized) || (! appsctl_handle)) {
+ apfw_error("ico_apf_resource_reply_int_sound_mode: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ /* set send message parameter */
+ if (zone) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d", zone, int_snd_id);
+ }
+ else {
+ /* no zone, default zone */
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d",
+ sysconf->sound[sysconf->misc.default_soundId].
+ zone[sysconf->misc.default_soundzoneId].name, int_snd_id);
+ }
+ if (ico_apf_com_send(appsctl_handle,
+ (ok != 0) ? ICO_APF_RESOURCE_REPLY_OK
+ : ICO_APF_RESOURCE_REPLY_NG,
+ ICO_APF_RESID_INT_SOUND, NULL, msg)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_warn("ico_apf_resource_reply_int_sound_mode: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ apfw_trace("ico_apf_resource_reply_int_sound_mode: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Add the input event notification from input device
+ *
+ * @param[in] input_dev input device uri
+ * @param[in] events notify input events
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_add_input_event(const char* input_dev, int events)
+{
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+
+ apfw_trace("ico_apf_resource_add_input_event: Enter(%s,%d)",
+ input_dev ? input_dev : "(NULL)", events);
+
+ if ((! resmgr_initialized) || (! appsctl_handle)) {
+ apfw_error("ico_apf_resource_add_input_event: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ /* set send message parameter */
+ if (input_dev) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d", input_dev, events);
+ }
+ else {
+ /* no input device, default device */
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d",
+ sysconf->inputdev[sysconf->misc.default_inputdevId].name, events);
+ }
+ if (ico_apf_com_send(appsctl_handle, ICO_APF_RESOURCE_COMMAND_ADD,
+ ICO_APF_RESID_INPUT_DEV, NULL, msg)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_error("ico_apf_resource_add_input_event: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ apfw_trace("ico_apf_resource_add_input_event: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Change the input event notification from input device
+ *
+ * @param[in] input_dev input device uri
+ * @param[in] events notify input events
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_change_input_event(const char* input_dev, int events)
+{
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+
+ apfw_trace("ico_apf_resource_change_input_event: Enter(%s,%d)",
+ input_dev ? input_dev : "(NULL)", events);
+
+ if ((! resmgr_initialized) || (! appsctl_handle)) {
+ apfw_error("ico_apf_resource_change_input_event: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ /* set send message parameter */
+ if (input_dev) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d", input_dev, events);
+ }
+ else {
+ /* no input device, default device */
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d",
+ sysconf->inputdev[sysconf->misc.default_inputdevId].name, events);
+ }
+ if (ico_apf_com_send(appsctl_handle, ICO_APF_RESOURCE_COMMAND_CHANGE,
+ ICO_APF_RESID_INPUT_DEV, NULL, msg)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_error("ico_apf_resource_change_input_event: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ apfw_trace("ico_apf_resource_change_input_event: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Delete the input event notification from input device
+ *
+ * @param[in] input_dev input device uri
+ * @param[in] events notify input events
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_delete_input_event(const char* input_dev, int events)
+{
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+
+ apfw_trace("ico_apf_resource_delete_input_event: Enter(%s,%d)",
+ input_dev ? input_dev : "(NULL)", events);
+
+ if ((! resmgr_initialized) || (! appsctl_handle)) {
+ apfw_error("ico_apf_resource_delete_input_event: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ /* set send message parameter */
+ if (input_dev) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d", input_dev, events);
+ }
+ else {
+ /* no input device, default device */
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d",
+ sysconf->inputdev[sysconf->misc.default_inputdevId].name, events);
+ }
+ if (ico_apf_com_send(appsctl_handle, ICO_APF_RESOURCE_COMMAND_DELETE,
+ ICO_APF_RESID_INPUT_DEV, NULL, msg)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_error("ico_apf_resource_delete_input_event: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ apfw_trace("ico_apf_resource_delete_input_event: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Send responce form server(AppsController) to client application
+ *
+ * @param[in] appid client application id
+ * @param[in] event event
+ * @param[in] resource target resource
+ * @param[in] device display device / sound zone
+ * @param[in] id application defined object id
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ * @retval ICO_APF_RESOURCE_E_INVAL illegal appid or event code
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_send_to_client(const char *appid, const int event,
+ const int resource, const char *device, const int id)
+{
+ remgr_com_handle_t *p;
+ char msg[ICO_APF_RESOURCE_MSG_LEN];
+
+ apfw_trace("ico_apf_resource_send_to_client: Enter(%s,%d,%d,%s,%d)",
+ appid, event, resource, device ? device : "(NULL)", id);
+
+ if ((! resmgr_initialized) || (! appsctl_handle)) {
+ apfw_error("ico_apf_resource_send_to_client: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ /* search client application */
+ p = handles;
+ while (p) {
+ if (strcmp(p->appid, appid) == 0) break;
+ p = p->next;
+ }
+ if (! p) {
+ apfw_error("ico_apf_resource_send_to_client: Leave(appid not exist)");
+ return ICO_APF_RESOURCE_E_INVAL;
+ }
+
+ /* set send message parameter */
+ if (device) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d", device, id);
+ }
+ else {
+ /* no display URI, default display */
+ if ((resource == ICO_APF_RESID_BASIC_SCREEN) ||
+ (resource == ICO_APF_RESID_INT_SCREEN) ||
+ (resource == ICO_APF_RESID_ON_SCREEN)) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d",
+ sysconf->display[sysconf->misc.default_displayId].
+ zone[sysconf->misc.default_dispzoneId].name, id);
+ }
+ else if (resource == ICO_APF_RESID_INPUT_DEV) {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d",
+ sysconf->inputdev[sysconf->misc.default_inputdevId].name, id);
+ }
+ else {
+ snprintf(msg, ICO_APF_RESOURCE_MSG_LEN-1, "%s %d",
+ sysconf->sound[sysconf->misc.default_soundId].
+ zone[sysconf->misc.default_soundzoneId].name, id);
+ }
+ }
+ if (ico_apf_com_send(p->handle, event, resource, appid, msg)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_error("ico_apf_resource_send_to_client: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+
+ apfw_trace("ico_apf_resource_send_to_client: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Send request to Multi Sound Manager
+ *
+ * @param[in] cmd send command
+ * @param[in] pid target pid
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_apf_resource_send_to_soundctl(const ico_apf_sound_state_e cmd, const int pid)
+{
+ apfw_trace("ico_apf_resource_send_to_soundctl: Enter(%s[%d],%d)",
+ cmd == ICO_APF_SOUND_COMMAND_MUTEON ? "Stop" :
+ (cmd == ICO_APF_SOUND_COMMAND_MUTEOFF ? "Start" : "\0"), (int)cmd, pid);
+
+ if ((! resmgr_initialized) || (! soundmgr_handle)) {
+ apfw_error("ico_apf_resource_send_to_soundctl: Leave(not initialized)");
+ return ICO_APF_RESOURCE_E_NOT_INITIALIZED;
+ }
+
+ if (ico_apf_com_send(soundmgr_handle, cmd, pid, NULL, NULL)
+ != ICO_APF_RESOURCE_E_NONE) {
+ apfw_error("ico_apf_resource_send_to_soundctl: Leave(commnad send error)");
+ return ICO_APF_RESOURCE_E_COMMUNICATION;
+ }
+ apfw_trace("ico_apf_resource_send_to_soundctl: Leave(OK)");
+ return ICO_APF_RESOURCE_E_NONE;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief user experiance library(read apprication's configuration file)
+ *
+ * @date Feb-28-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/time.h>
+#include <sys/file.h>
+#include <errno.h>
+#include <ail.h>
+
+#include "ico_apf_log.h"
+#include "ico_apf_apimacro.h"
+#include "ico_uxf_conf_common.h"
+
+#define APP_CONF_AIL_NULL_STR "(null)"
+
+static Ico_Uxf_App_Config *readAilApplist(void);
+static void Ico_Uxf_conf_remakeAppHash(void);
+
+static Ico_Uxf_App_Config *_ico_app_config = NULL;
+static Ico_Uxf_Sys_Config *sys_config = NULL;
+static GKeyFile *skeyfile = NULL;
+
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getAppConfig: get application configurations
+ *
+ * @param none
+ * @return application configuration table
+ * @retval !=NULL success(application configuration table address)
+ * @retval ==NULL error(can not read configuration files)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API const Ico_Uxf_App_Config *
+ico_uxf_getAppConfig(void)
+{
+ if (_ico_app_config) {
+ return _ico_app_config;
+ }
+ _ico_app_config = g_new0(Ico_Uxf_App_Config,1);
+ return readAilApplist();
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief infoAilpkg: callback function for configuration from AppCore(static function)
+ *
+ * @param[in] appinfo AppCore(AIL) application information
+ * @param[in] data user data(application index)
+ * @return result
+ * @retval AIL_CB_RET_CONTINUE success(continue next application)
+ * @retval AIL_CB_RET_CANCEL error(stop all application search)
+ */
+/*--------------------------------------------------------------------------*/
+static ail_cb_ret_e
+infoAilpkg(const ail_appinfo_h appinfo, void *data)
+{
+ int num = (int)data;
+ char *package;
+ char *icon;
+ char *name;
+ char *category;
+ char *type;
+ char *exec;
+ GError *error;
+ char *app_category;
+ char add_category[256];
+ int i;
+ struct stat buff;
+ Ico_Uxf_conf_application *apptbl;
+
+ /* get package name for appid */
+ ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
+ if (strcmp(package, APP_CONF_AIL_NULL_STR) == 0) {
+ package = NULL;
+ }
+ /* get icon path */
+ ail_appinfo_get_str(appinfo, AIL_PROP_ICON_STR, &icon);
+ if (strcmp(icon, APP_CONF_AIL_NULL_STR) == 0) {
+ icon = NULL;
+ }
+ else if (icon != NULL) {
+ /* file check */
+ memset(&buff, 0, sizeof(buff));
+ if (stat(icon, &buff) == 0) {
+ if (S_ISDIR(buff.st_mode)) {
+ /* is directory */
+ icon = NULL;
+ }
+ }
+ else {
+ /* is not exist */
+ icon = NULL;
+ }
+ }
+ /* get name */
+ ail_appinfo_get_str(appinfo, AIL_PROP_NAME_STR, &name);
+ if (strcmp(name, APP_CONF_AIL_NULL_STR) == 0) {
+ name = NULL;
+ }
+ /* get default category of this application */
+ add_category[0] = 0;
+ error = NULL;
+ app_category = g_key_file_get_string(skeyfile, "app-category", package, &error);
+ if (error != NULL) {
+ g_clear_error(&error);
+ error = NULL;
+ app_category = g_key_file_get_string(skeyfile, "app-category", name, &error);
+ }
+ if (error != NULL) {
+ g_clear_error(&error);
+ apfw_trace("infoAilpkg: %s(%s) dose not has app-category", package, name);
+ }
+ else {
+ apfw_trace("infoAilpkg: %s(%s) has app-category=%s", package, name, app_category);
+ strncpy(add_category, app_category, sizeof(add_category)-2);
+ add_category[sizeof(add_category)-2] = 0;
+ i = strlen(add_category);
+ if (i > 0) {
+ if (add_category[i-1] != ';') {
+ strcpy(&add_category[i], ";");
+ }
+ }
+ }
+ g_clear_error(&error);
+
+ /* get category */
+ ail_appinfo_get_str(appinfo, AIL_PROP_CATEGORIES_STR, &category);
+ if (strcmp(category, APP_CONF_AIL_NULL_STR) != 0) {
+ apfw_trace("infoAilpkg: %s + %s", add_category, category);
+ i = strlen(add_category);
+ strncpy(&add_category[i], category, sizeof(add_category)-i-1);
+ add_category[sizeof(add_category)-i-1] = 0;
+ }
+ if (add_category[0]) {
+ category = add_category;
+ }
+ else {
+ category = NULL;
+ }
+
+ /* get type */
+ ail_appinfo_get_str(appinfo, AIL_PROP_TYPE_STR, &type);
+ if (strcmp(type, APP_CONF_AIL_NULL_STR) == 0) {
+ type = NULL;
+ }
+ /* get exec */
+ ail_appinfo_get_str(appinfo, AIL_PROP_EXEC_STR, &exec);
+ if (strcmp(exec, APP_CONF_AIL_NULL_STR) == 0) {
+ exec = NULL;
+ }
+
+ if ((package != NULL) && (icon != NULL) && (*package != 0) && (*icon != 0)) {
+ apptbl = &_ico_app_config->application[_ico_app_config->applicationNum];
+ apptbl->appid = strdup(package);
+ apptbl->icon_key_name = strdup(icon);
+ if ((name != NULL) && (*name != 0)) {
+ apptbl->name = strdup(name);
+ }
+ else {
+ apptbl->name = strdup(package);
+ }
+
+ /* set default values */
+ apptbl->hostId = sys_config->misc.default_hostId;
+ apptbl->kindId = sys_config->misc.default_kindId;
+ apptbl->categoryId = sys_config->misc.default_categoryId;
+
+ /* analize categorys for extended attributes */
+ if (category) {
+ int i, j, k, m, n;
+ int found;
+ int dispidx = sys_config->misc.default_displayId;;
+ int soundidx = sys_config->misc.default_soundId;;
+ int inputidx = sys_config->misc.default_inputdevId;
+ Ico_Uxf_conf_display *display;
+ Ico_Uxf_conf_sound *sound;
+ char work[64];
+
+ apfw_trace("Ail.%d category=%s", _ico_app_config->applicationNum, category);
+
+ j = 0;
+ for (i = 0;; i++) {
+ if ((category[i] == 0) || (category[i] == ';')) {
+ k = i - j;
+ if (k >= ((int)sizeof(work)-1)) k = sizeof(work)-1;
+ memcpy(work, &category[j], k);
+ work[k] = 0;
+ found = 0;
+
+ /* find running host */
+ if (strncasecmp(work, "run=", 4) == 0) {
+ found = 4;
+ }
+ for (k = 0; k < sys_config->hostNum; k++) {
+ if (strcasecmp(&work[found], sys_config->host[k].name) == 0) {
+ apptbl->hostId = sys_config->host[k].id;
+ found = 1;
+ break;
+ }
+ }
+ if (found > 1) {
+ apfw_error("infoAilpkg: [%s] unknown running host", work);
+ }
+ /* find kind */
+ if (found == 0) {
+ if (strncasecmp(work, "kind=", 5) == 0) {
+ found = 5;
+ }
+ for (k = 0; k < sys_config->kindNum; k++) {
+ if (strcasecmp(&work[found],
+ sys_config->kind[k].name) == 0) {
+ apptbl->kindId = sys_config->kind[k].id;
+ found = 1;
+ break;
+ }
+ }
+ }
+ if (found > 1) {
+ apfw_error("infoAilpkg: [%s] unknown kind", work);
+ }
+ /* find category */
+ if (found == 0) {
+ if (strncasecmp(work, "category=", 9) == 0) {
+ found = 9;
+ }
+ for (k = 0; k < sys_config->categoryNum; k++) {
+ if (strcasecmp(&work[found],
+ sys_config->category[k].name) == 0) {
+ apptbl->categoryId = sys_config->category[k].id;
+ found = 1;
+ break;
+ }
+ }
+ }
+ if (found > 1) {
+ apfw_error("infoAilpkg: [%s] unknown category", work);
+ }
+ /* find display */
+ if ((found == 0) &&
+ (strncasecmp(work, "display", 7) == 0)) {
+ if (work[7] == '=') {
+ dispidx = 0;
+ found = 8;
+ }
+ else if ((work[7] == '.') && (work[9] == '=')) {
+ dispidx = work[8] - '0';
+ found = 10;
+ if ((dispidx < 0) || (dispidx >= ICO_UXF_APPDISPLAY_MAX)) {
+ apfw_error("infoAilpkg: [%s] unknown display number", work);
+ dispidx = 0;
+ break;
+ }
+ }
+ else {
+ apfw_error("infoAilpkg: [%s] unknown display number", work);
+ dispidx = 0;
+ break;
+ }
+ if (apptbl->displayzoneNum <= dispidx) {
+ apptbl->display[dispidx].displayId
+ = sys_config->misc.default_displayId;
+ apptbl->display[dispidx].layerId
+ = sys_config->misc.default_layerId;
+ apptbl->display[dispidx].zoneId
+ = sys_config->misc.default_dispzoneId;
+ }
+ for (k = 0; k < sys_config->displayNum; k++) {
+ if (strcasecmp(&work[found],
+ sys_config->display[k].name) == 0) {
+ apptbl->display[dispidx].displayId
+ = sys_config->display[k].id;
+ if (apptbl->displayzoneNum <= dispidx) {
+ apptbl->displayzoneNum = dispidx + 1;
+ }
+ found = 1;
+ break;
+ }
+ }
+ }
+ if (found > 1) {
+ apfw_error("infoAilpkg: [%s] unknown display", work);
+ }
+ /* find display layer */
+ if ((found == 0) &&
+ (strncasecmp(work, "layer", 5) == 0)) {
+ if (work[5] == '=') {
+ dispidx = 0;
+ found = 6;
+ }
+ else if ((work[5] == '.') && (work[7] == '=')) {
+ dispidx = work[6] - '0';
+ found = 8;
+ if ((dispidx < 0) || (dispidx >= ICO_UXF_APPDISPLAY_MAX)) {
+ apfw_error("infoAilpkg: [%s] unknown display number", work);
+ dispidx = 0;
+ break;
+ }
+ }
+ else {
+ apfw_error("infoAilpkg: [%s] unknown display number", work);
+ dispidx = 0;
+ break;
+ }
+ if (apptbl->displayzoneNum <= dispidx) {
+ apptbl->display[dispidx].displayId
+ = sys_config->misc.default_displayId;
+ apptbl->display[dispidx].layerId
+ = sys_config->misc.default_layerId;
+ apptbl->display[dispidx].zoneId
+ = sys_config->misc.default_dispzoneId;
+ }
+ display = &sys_config->display[apptbl->display[dispidx].displayId];
+
+ for (k = 0; k < display->layerNum; k++) {
+ if (strcasecmp(&work[found], display->layer[k].name) == 0) {
+ apptbl->display[dispidx].layerId = display->layer[k].id;
+ if (apptbl->displayzoneNum <= dispidx) {
+ apptbl->displayzoneNum = dispidx + 1;
+ }
+ found = 1;
+ break;
+ }
+ }
+ }
+ if (found > 1) {
+ apfw_error("infoAilpkg: [%s] unknown layer", work);
+ }
+ /* find display zone */
+ if ((found == 0) &&
+ (strncasecmp(work, "dispzone", 8) == 0)) {
+ if (work[8] == '=') {
+ dispidx = 0;
+ found = 9;
+ }
+ else if ((work[8] == '.') && (work[10] == '=')) {
+ dispidx = work[9] - '0';
+ found = 11;
+ if ((dispidx < 0) || (dispidx >= ICO_UXF_APPDISPLAY_MAX)) {
+ apfw_error("infoAilpkg: [%s] unknown display number", work);
+ dispidx = 0;
+ break;
+ }
+ }
+ else {
+ apfw_error("infoAilpkg: [%s] unknown display number", work);
+ dispidx = 0;
+ break;
+ }
+ if (apptbl->displayzoneNum <= dispidx) {
+ apptbl->display[dispidx].displayId
+ = sys_config->misc.default_displayId;
+ apptbl->display[dispidx].layerId
+ = sys_config->misc.default_layerId;
+ apptbl->display[dispidx].zoneId
+ = sys_config->misc.default_dispzoneId;
+ }
+ display = &sys_config->display[apptbl->display[dispidx].displayId];
+
+ for (k = 0; k < display->zoneNum; k++) {
+ if (strcasecmp(&work[found], display->zone[k].name) == 0) {
+ apptbl->display[dispidx].zoneId = display->zone[k].id;
+ if (apptbl->displayzoneNum <= dispidx) {
+ apptbl->displayzoneNum = dispidx + 1;
+ }
+ found = 1;
+ break;
+ }
+ }
+ }
+ if (found > 1) {
+ apfw_error("infoAilpkg: [%s] unknown display zone", work);
+ }
+
+ /* find sound zone */
+ if ((found == 0) &&
+ (strncasecmp(work, "soundzone", 9) == 0)) {
+ if (work[9] == '=') {
+ soundidx = 0;
+ found = 10;
+ }
+ else if ((work[9] == '.') && (work[11] == '=')) {
+ soundidx = work[10] - '0';
+ found = 12;
+ if ((soundidx < 0) || (soundidx >= ICO_UXF_APPSOUND_MAX)) {
+ apfw_error("infoAilpkg: [%s] unknown sound number", work);
+ soundidx = 0;
+ break;
+ }
+ }
+ else {
+ apfw_error("infoAilpkg: [%s] unknown sound number", work);
+ soundidx = 0;
+ break;
+ }
+ if (apptbl->soundzoneNum <= soundidx) {
+ apptbl->sound[soundidx].soundId
+ = sys_config->misc.default_soundId;
+ apptbl->sound[soundidx].zoneId
+ = sys_config->misc.default_soundzoneId;
+ }
+ sound = &sys_config->sound[apptbl->sound[soundidx].soundId];
+
+ for (k = 0; k < sound->zoneNum; k++) {
+ if (strcasecmp(&work[found], sound->zone[k].name) == 0) {
+ apptbl->sound[soundidx].zoneId = sound->zone[k].id;
+ if (apptbl->soundzoneNum <= soundidx) {
+ apptbl->soundzoneNum = soundidx + 1;
+ }
+ found = 1;
+ break;
+ }
+ }
+ }
+ if (found > 1) {
+ apfw_error("infoAilpkg: [%s] unknown sound zone", work);
+ }
+
+ /* find sound */
+ if ((found == 0) &&
+ (strncasecmp(work, "sound", 5) == 0)) {
+ if (work[5] == '=') {
+ soundidx = 0;
+ found = 5;
+ }
+ else if ((work[5] == '.') && (work[7] == '=')) {
+ soundidx = work[6] - '0';
+ found = 8;
+ if ((soundidx < 0) || (soundidx >= ICO_UXF_APPSOUND_MAX)) {
+ apfw_error("infoAilpkg: [%s] unknown sound number", work);
+ soundidx = 0;
+ break;
+ }
+ }
+ else {
+ apfw_error("infoAilpkg: [%s] unknown sound number", work);
+ soundidx = 0;
+ break;
+ }
+ if (apptbl->soundzoneNum <= soundidx) {
+ apptbl->sound[soundidx].soundId
+ = sys_config->misc.default_soundId;
+ apptbl->sound[soundidx].zoneId
+ = sys_config->misc.default_soundzoneId;
+ }
+ for (k = 0; k < sys_config->soundNum; k++) {
+ if (strcasecmp(&work[found], sys_config->sound[k].name) == 0) {
+ apptbl->sound[soundidx].soundId = sys_config->sound[k].id;
+ if (apptbl->soundzoneNum <= soundidx) {
+ apptbl->soundzoneNum = soundidx + 1;
+ }
+ found = 1;
+ break;
+ }
+ }
+ }
+ if (found > 1) {
+ apfw_error("infoAilpkg: [%s] unknown sound", work);
+ }
+
+ /* find input device */
+ if ((found == 0) &&
+ (strncasecmp(work, "input", 5) == 0)) {
+ if (work[5] == '=') {
+ inputidx = 0;
+ found = 6;
+ }
+ else if ((work[5] == '.') && (work[7] == '=')) {
+ inputidx = work[6] - '0';
+ if ((inputidx < 0) || (inputidx >= ICO_UXF_APPINPUT_MAX)) {
+ apfw_error("infoAilpkg: [%s] unknown input number", work);
+ found = 1;
+ break;
+ }
+ found = 8;
+ }
+ else {
+ apfw_error("infoAilpkg: [%s] unknown input number", work);
+ break;
+ }
+ if (apptbl->inputdevNum <= inputidx) {
+ apptbl->input[inputidx].inputdevId
+ = sys_config->misc.default_inputdevId;
+ }
+ for (k = 0; k < sys_config->inputdevNum; k++) {
+ m = strlen(sys_config->inputdev[k].name);
+ if (strncasecmp(&work[found],
+ sys_config->inputdev[k].name, m) == 0) {
+ if (work[found+m] != '.') {
+ apfw_error("infoAilpkg: [%s] unknown input sw", work);
+ break;
+ }
+ apptbl->input[inputidx].inputdevId
+ = sys_config->inputdev[k].id;
+ m += (found + 1);
+ for (n = 0; n < sys_config->inputdev[k].inputswNum; n++) {
+ if (strcasecmp(&work[m],
+ sys_config->inputdev[k].inputsw[n].name)
+ == 9) {
+ apptbl->input[inputidx].inputswId = n;
+ break;
+ }
+ }
+ if (n < sys_config->inputdev[k].inputswNum) {
+ if (apptbl->inputdevNum <= inputidx) {
+ apptbl->inputdevNum = inputidx + 1;
+ }
+ }
+ else {
+ apfw_error("infoAilpkg: [%s] unknown input sw", work);
+ }
+ found = 1;
+ break;
+ }
+ }
+ if (k >= sys_config->inputdevNum) {
+ apfw_error("infoAilpkg: [%s] unknown input device", work);
+ found = 1;
+ break;
+ }
+ }
+ if (found > 1) {
+ apfw_error("infoAilpkg: [%s] unknown input", work);
+ }
+
+ /* start mode */
+ if ((found == 0) && (work[0] != 0)) {
+ if (strcasecmp(work, "auto") == 0) {
+ apptbl->autostart = 1;
+ }
+ else if (strcasecmp(work, "noauto") == 0) {
+ apptbl->autostart = 0;
+ }
+ else {
+ apfw_error("infoAilpkg: [%s] unknown key", work);
+ }
+ }
+ if (category[i] == 0) break;
+ j = i + 1;
+ }
+ }
+ }
+ apptbl->exec = strdup(exec);
+ apptbl->type = strdup(type);
+ if (apptbl->displayzoneNum == 0) {
+ apptbl->displayzoneNum = 1;
+ apptbl->display[0].displayId = sys_config->misc.default_displayId;
+ apptbl->display[0].layerId = sys_config->misc.default_layerId;
+ apptbl->display[0].zoneId = sys_config->misc.default_dispzoneId;
+ }
+ if (apptbl->soundzoneNum == 0) {
+ apptbl->soundzoneNum = 1;
+ apptbl->sound[0].soundId = sys_config->misc.default_soundId;
+ apptbl->sound[0].zoneId = sys_config->misc.default_soundzoneId;
+ }
+ apfw_trace("Ail.%d: appid=%s name=%s icon=%s exec=%s type=%s",
+ _ico_app_config->applicationNum, apptbl->appid, apptbl->name,
+ icon, apptbl->exec, apptbl->type);
+ apfw_trace("Ail.%d: categ=%d kind=%d disp=%d layer=%d zone=%d "
+ "sound=%d zone=%d auto=%d",
+ _ico_app_config->applicationNum, apptbl->categoryId, apptbl->kindId,
+ apptbl->display[0].displayId, apptbl->display[0].layerId,
+ apptbl->display[0].zoneId, apptbl->sound[0].soundId,
+ apptbl->sound[0].zoneId, apptbl->autostart);
+ _ico_app_config->applicationNum++;
+ }
+
+ if (_ico_app_config->applicationNum > num)
+ return AIL_CB_RET_CANCEL;
+
+ return AIL_CB_RET_CONTINUE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief readAilApplist: get all application configuration from AppCore(static function)
+ *
+ * @param none
+ * @return application configuration table
+ * @retval !=NULL success(application configuration table address)
+ * @retval ==NULL error(can not read configuration files)
+ */
+/*--------------------------------------------------------------------------*/
+static Ico_Uxf_App_Config *
+readAilApplist(void)
+{
+ int ret, num, wnum;
+ ail_filter_h filter;
+ GError *error = NULL;
+
+ /* get system configuration */
+ sys_config = (Ico_Uxf_Sys_Config *)ico_uxf_getSysConfig();
+ if (! sys_config) {
+ apfw_error("readAilApplist: can not read system configuration");
+ return NULL;
+ }
+
+ /* read system configuration file for application default category */
+ skeyfile = g_key_file_new();
+
+ GString* filepath = g_string_new("xx");
+ g_string_printf(filepath, "%s/%s", sys_config->misc.confdir, ICO_UXF_CONFIG_SYSTEM);
+
+ if (! g_key_file_load_from_file(skeyfile, filepath->str,
+ G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
+ &error)) {
+ apfw_error("readAilApplist: %s %s", (char *)filepath->str, error->message);
+ g_key_file_free(skeyfile);
+ skeyfile = NULL;
+ }
+ g_string_free(filepath, TRUE);
+
+ /* count packages */
+ ret = ail_filter_count_appinfo(NULL, &num);
+ if (ret != AIL_ERROR_OK) {
+ if( skeyfile) {
+ g_key_file_free(skeyfile);
+ skeyfile = NULL;
+ }
+ return NULL;
+ }
+ apfw_trace("readAilApplist: number of off AIL package = %d", num);
+
+ ail_filter_new(&filter);
+ ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "menu");
+ ail_filter_count_appinfo(filter, &num);
+ apfw_trace("readAilApplist: number of menu AIL package = %d", num);
+ ail_filter_destroy(filter);
+
+ ail_filter_new(&filter);
+ ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "Application");
+ ail_filter_count_appinfo(filter, &wnum);
+ apfw_trace("readAilApplist: number of Application AIL package = %d", wnum);
+ ail_filter_destroy(filter);
+ num += wnum;
+
+ _ico_app_config->application = g_new0(Ico_Uxf_conf_application, num);
+
+ ail_filter_new(&filter);
+ ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "menu");
+ ail_filter_list_appinfo_foreach(filter, infoAilpkg, (void *)num);
+ ail_filter_destroy(filter);
+
+ ail_filter_new(&filter);
+ ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "Application");
+ ail_filter_list_appinfo_foreach(filter, infoAilpkg, (void *)num);
+ ail_filter_destroy(filter);
+
+ /* create Hash Table */
+ Ico_Uxf_conf_remakeAppHash();
+
+ if( skeyfile) {
+ g_key_file_free(skeyfile);
+ }
+
+ return _ico_app_config;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_closeAppConfig: close application configuration table
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API void
+ico_uxf_closeAppConfig(void)
+{
+ if(_ico_app_config != NULL){
+ g_free(_ico_app_config->application);
+ g_free(_ico_app_config);
+ _ico_app_config = NULL;
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Ico_Uxf_conf_remakeAppHash: make application hash table(static function)
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+Ico_Uxf_conf_remakeAppHash(void)
+{
+ int i;
+ int hash;
+ Ico_Uxf_conf_application *app;
+
+ memset(_ico_app_config->hashnametable, 0, sizeof(_ico_app_config->hashnametable));
+
+ for (i = 0; i < _ico_app_config->applicationNum; i++) {
+
+ _ico_app_config->application[i].nextidhash = NULL;
+ hash = ICO_UXF_MISC_HASHBYID(i);
+ app = _ico_app_config->hashidtable[hash];
+ if (! app) {
+ _ico_app_config->hashidtable[hash] = &_ico_app_config->application[i];
+ }
+ else {
+ while (app->nextidhash) {
+ app = app->nextidhash;
+ }
+ app->nextidhash = &_ico_app_config->application[i];
+ }
+
+ _ico_app_config->application[i].nextnamehash = NULL;
+ hash = ICO_UXF_MISC_HASHBYNAME(_ico_app_config->application[i].appid);
+ app = _ico_app_config->hashnametable[hash];
+ if (! app) {
+ _ico_app_config->hashnametable[hash] = &_ico_app_config->application[i];
+ }
+ else {
+ while (app->nextnamehash) {
+ app = app->nextnamehash;
+ }
+ app->nextnamehash = &_ico_app_config->application[i];
+ }
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getAppByAppid: get application configuration by application Id
+ *
+ * @param[in] appid application Id
+ * @return application configuration table
+ * @retval !=NULL success(application configuration table address)
+ * @retval ==NULL error(application dose not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API const Ico_Uxf_conf_application *
+ico_uxf_getAppByAppid(const char *appid)
+{
+ Ico_Uxf_conf_application *app;
+
+ if (!_ico_app_config) {
+ (void)ico_uxf_getAppConfig();
+ }
+ app = _ico_app_config->hashnametable[ICO_UXF_MISC_HASHBYNAME(appid)];
+
+ while (app) {
+ if (strcasecmp(app->appid, appid) == 0) break;
+ app = app->nextnamehash;
+ }
+ if (! app) {
+ apfw_warn("ico_uxf_getAppByAppid: appid(%s) dose not exist", appid);
+ }
+ return app;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getAppByName: get application configuration by application name
+ *
+ * @param[in] name application name
+ * @return application configuration table
+ * @retval !=NULL success(application configuration table address)
+ * @retval ==NULL error(application dose not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API const Ico_Uxf_conf_application *
+ico_uxf_getAppByName(const char *name)
+{
+ int i;
+ Ico_Uxf_conf_application *app = NULL;
+
+ if (!_ico_app_config) {
+ (void)ico_uxf_getAppConfig();
+ }
+
+ for (i = 0; i < _ico_app_config->applicationNum; i++) {
+ if (strcasecmp(_ico_app_config->application[i].name, name) == 0) {
+ app = &_ico_app_config->application[i];
+ break;
+ }
+ }
+ if (! app) {
+ apfw_warn("ico_uxf_getAppByName: name(%s) dose not exist", name);
+ }
+ return app;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getAppDisplay: get application display
+ *
+ * @param[in] app application configuration table
+ * @param[in] idx display zone index
+ * @param[out] x zone X coodinate
+ * @param[out] y zone Y coodinate
+ * @param[out] width zone width
+ * @param[out] height zone height
+ * @return result
+ * @retval ICO_UXF_EOK succes
+ * @retval ICO_UXF_EINVAL error(illegal idx)
+ * @retval ICO_UXF_ENOSYS error(can not read configuration files)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_getAppDisplay(const Ico_Uxf_conf_application *app, const int idx,
+ int *x, int *y, int *width, int *height)
+{
+ Ico_Uxf_conf_display_zone *zone;
+
+ if (! sys_config) {
+ return ICO_UXF_ENOSYS;
+ }
+ if ((! app) || (idx < 0) || (idx >= app->displayzoneNum)) {
+ return ICO_UXF_EINVAL;
+ }
+
+ zone = &sys_config->display[app->display[idx].displayId].zone[app->display[idx].zoneId];
+
+ if (x) *x = zone->x;
+ if (y) *y = zone->y;
+ if (width) *width = zone->width;
+ if (height) *height = zone->height;
+
+ return 0;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief user experiance library(common function in read configuration)
+ *
+ * @date Feb-28-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/time.h>
+#include <sys/file.h>
+#include <errno.h>
+
+#include "ico_apf_log.h"
+#include "ico_apf_apimacro.h"
+#include "ico_uxf_conf_common.h"
+
+/* Number of hash table */
+#define ICO_UXF_MISC_HASHSIZE 64 /* Must be 2's factorial */
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_misc_hashByName: create hash value by name string
+ * there is no distinction of an english capital letter/small
+ *
+ * @param[in] name character string changed into a hash value(NULL termination)
+ *
+ * @return create hash value
+ */
+/*--------------------------------------------------------------------------*/
+int
+ico_uxf_misc_hashByName(const char *name)
+{
+ int hash = 0;
+ int i;
+
+ for (i = 0; name[i]; i++) {
+ hash = (hash << 1) | (name[i] & 0x1f);
+ }
+ return hash & (ICO_UXF_MISC_HASHSIZE-1);
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_conf_getUint: convert value string to value
+ *
+ * @param[in] str string
+ * @return converted value
+ */
+/*--------------------------------------------------------------------------*/
+int
+ico_uxf_conf_getUint(const char* str)
+{
+ int key = -1;
+ if (str != NULL) {
+ if ((strcasecmp(str, "true") == 0) ||
+ (strcasecmp(str, "yes") == 0)) {
+ key = 1;
+ }
+ else if ((strcasecmp(str, "false") == 0) ||
+ (strcasecmp(str, "no") == 0)) {
+ key = 0;
+ }
+ else {
+ char *errpt = (char *)0;
+ key = strtol(str, &errpt, 0);
+ if ((errpt) && (*errpt != 0)) {
+ key = -1;
+ }
+ }
+ }
+ return key;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_conf_countNumericalKey: count numerical keys in configuration file
+ *
+ * @param[in] keyfile configuration file
+ * @param[in] group configuration groupe(ex.[display])
+ * @return configuration list
+ */
+/*--------------------------------------------------------------------------*/
+GList *
+ico_uxf_conf_countNumericalKey(GKeyFile *keyfile, const char* group)
+{
+ GList* list = NULL;
+ char **result;
+ gsize length;
+ int i;
+
+ result = g_key_file_get_keys(keyfile, group, &length,NULL);
+
+ for (i = 0; i < (int)length; i++) {
+ int id = ico_uxf_conf_getUint(result[i]);
+ if (id >= 0) {
+ list=g_list_append(list,g_strdup(result[i]));
+ }
+ }
+ g_strfreev(result);
+ return list;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_conf_appendStr: connect strings
+ *
+ * @param[in] str1 string 1
+ * @param[in] str2 string 2
+ * @return static connected string (str1+str2)
+ */
+/*--------------------------------------------------------------------------*/
+const char *
+ico_uxf_conf_appendStr(const char* str1, const char* str2)
+{
+ static char buf[256];
+ sprintf(buf, "%s%s", str1, str2);
+ return buf;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_conf_checkGerror: output configuration error message
+ *
+ * @param[in] error error information
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+ico_uxf_conf_checkGerror(GError** error)
+{
+ if (*error != NULL) {
+ uifw_warn("%s",(*error)->message);
+ }
+ g_clear_error(error);
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief user experiance library(read configuration file in all system)
+ *
+ * @date Feb-28-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/time.h>
+#include <sys/file.h>
+#include <errno.h>
+
+#include "ico_apf_log.h"
+#include "ico_apf_apimacro.h"
+#include "ico_uxf_conf_common.h"
+
+static Ico_Uxf_Sys_Config *reloadSysConfig(void);
+
+static Ico_Uxf_Sys_Config *_ico_sys_config = NULL;
+
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getSysConfig: get system configurations
+ *
+ * @param none
+ * @return system configuration table
+ * @retval != NULL success(system configuration table address)
+ * @retval == NULL error(can not read configuration file)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API const Ico_Uxf_Sys_Config *
+ico_uxf_getSysConfig(void)
+{
+ if (_ico_sys_config) {
+ return _ico_sys_config;
+ }
+ _ico_sys_config = g_new0(Ico_Uxf_Sys_Config,1);
+ return reloadSysConfig();
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_ifGetSysConfig: get system configurations
+ *
+ * @param none
+ * @return system configuration table
+ * @retval != NULL success(system configuration table address)
+ * @retval == NULL error(the configuration file is not yet read)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API const Ico_Uxf_Sys_Config *
+ico_uxf_ifGetSysConfig(void)
+{
+ return _ico_sys_config;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief pars_dispposition: calculate an expression about display size(static function)
+ *
+ * @param[in] exp expression
+ * @param[in] display display configuration table
+ * @return calculation result
+ */
+/*--------------------------------------------------------------------------*/
+static int
+pars_dispposition(const char *exp, Ico_Uxf_conf_display *display)
+{
+ int val = 0;
+ int wval;
+ int i, j, sign;
+ char word[32];
+
+ j = 0;
+ sign = 0;
+ for (i = 0; ; i++) {
+ if (exp[i] == ' ') continue;
+ if ((exp[i] == 0) || (exp[i] == '+') || (exp[i] == '-') ||
+ (exp[i] == '*') || (exp[i] == '-') || (exp[i] == '/')) {
+ if (j > 0) {
+ word[j] = 0;
+ if ((strcasecmp(word, "dispw") == 0) ||
+ (strcasecmp(word, "width") == 0)) {
+ wval = display->width;
+ }
+ else if ((strcasecmp(word, "disph") == 0) ||
+ (strcasecmp(word, "heigh") == 0)) {
+ wval = display->height;
+ }
+ else {
+ wval = strtol(word, (char **)0, 0);
+ }
+ j = 0;
+ if (sign >= 10) {
+ wval = 0 - wval;
+ }
+ switch (sign % 10) {
+ case 0: /* assign */
+ val = wval;
+ break;
+ case 1: /* '+' */
+ val += wval;
+ break;
+ case 2: /* '-' */
+ val -= wval;
+ break;
+ case 3: /* '*' */
+ val *= wval;
+ break;
+ case 4: /* '/' */
+ val /= wval;
+ break;
+ default:
+ break;
+ }
+ sign = 0;
+ if (exp[i] == '+') sign = 1;
+ else if (exp[i] == '-') sign = 2;
+ else if (exp[i] == '*') sign = 3;
+ else if (exp[i] == '/') sign = 4;
+ else sign = 0;
+ }
+ else {
+ if ((sign > 0) && (exp[i] == '-')) {
+ sign += 10;
+ }
+ else {
+ if (exp[i] == '+') sign = 1;
+ else if (exp[i] == '-') sign = 2;
+ else if (exp[i] == '*') sign = 3;
+ else if (exp[i] == '/') sign = 4;
+ else sign = 0;
+ }
+ }
+ if (exp[i] == 0) break;
+ }
+ else {
+ if (j < ((int)sizeof(word)-1)) {
+ word[j++] = exp[i];
+ }
+ }
+ }
+ return val;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief reloadSysConfig: load system configuration file(static function)
+ *
+ * @param none
+ * @return system configuration table
+ * @retval != NULL success(system configuration table address)
+ * @retval == NULL error(can not read configuration file)
+ */
+/*--------------------------------------------------------------------------*/
+static Ico_Uxf_Sys_Config *
+reloadSysConfig(void)
+{
+ GKeyFile *keyfile;
+ GKeyFileFlags flags;
+ GError *error = NULL;
+ gsize length;
+ int i;
+ int j;
+ int zoneidx;
+ GList* idlist;
+ char* dirp;
+ char* strp;
+
+ apfw_trace("reloadSysConfig: Enter");
+
+ /* decide top directory in all configurations */
+ dirp = getenv(ICO_UXF_TOP_ENV);
+ if (! dirp) {
+ dirp = ICO_UXF_TOP_TOPDIR;
+ }
+ strncpy(_ico_sys_config->misc.topdir, dirp, ICO_UXF_CONF_DIR_MAX);
+
+ /* decide top directory in configuration file's */
+ dirp = getenv(ICO_UXF_CONFIG_ENV);
+ if (dirp) {
+ strncpy(_ico_sys_config->misc.confdir, dirp, ICO_UXF_CONF_DIR_MAX);
+ }
+ else {
+ snprintf(_ico_sys_config->misc.confdir, ICO_UXF_CONF_DIR_MAX,
+ "%s/%s", _ico_sys_config->misc.topdir, ICO_UXF_CONFIG_DIR);
+ dirp = _ico_sys_config->misc.confdir;
+ }
+
+ /* A system-wide definition */
+ keyfile = g_key_file_new();
+ flags = G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS;
+
+ GString* filepath = g_string_new("xx");
+ g_string_printf(filepath, "%s/%s", dirp, ICO_UXF_CONFIG_SYSTEM);
+
+ if (!g_key_file_load_from_file(keyfile, filepath->str, flags, &error)) {
+ fprintf(stderr, "%s: %s\n", (char *)filepath->str, error->message);
+ g_string_free(filepath, TRUE);
+ return NULL;
+ }
+ g_string_free(filepath, TRUE);
+
+ /* log */
+ _ico_sys_config->misc.loglevel
+ = g_key_file_get_integer(keyfile, "log", "loglevel", &error);
+ ico_uxf_conf_checkGerror(&error);
+ _ico_sys_config->misc.logflush =
+ ico_uxf_getSysBoolByName(g_key_file_get_string(keyfile, "log", "logflush", &error));
+ ico_uxf_conf_checkGerror(&error);
+
+ /* log setting */
+ if (getenv("ICO_IVI_NO_LOG")) {
+ ico_uxf_log_setlevel(0);
+ }
+ else {
+ ico_uxf_log_setlevel(_ico_sys_config->misc.loglevel |
+ ((_ico_sys_config->misc.logflush) ?
+ ICO_APF_LOG_FLUSH : ICO_APF_LOG_NOFLUSH));
+ }
+
+ /* [category] application category name and attributes */
+ idlist = ico_uxf_conf_countNumericalKey(keyfile, "category");
+ length = g_list_length(idlist);
+ _ico_sys_config->categoryNum = length;
+ _ico_sys_config->category = g_malloc0(sizeof(Ico_Uxf_conf_category) * length);
+
+ for (i = 0; i < (int)length; i++) {
+ const char* key = (const char*) g_list_nth_data(idlist, i);
+ const char* g = "category";
+ _ico_sys_config->category[i].id = ico_uxf_conf_getUint(key);
+ ico_uxf_conf_checkGerror(&error);
+ _ico_sys_config->category[i].name = g_key_file_get_string(keyfile, g, key, &error);
+ ico_uxf_conf_checkGerror(&error);
+
+ strp = (char *)g_key_file_get_string(keyfile, g,
+ ico_uxf_conf_appendStr(key, ".view"), &error);
+ ico_uxf_conf_checkGerror(&error);
+ if (strncasecmp(strp, "alway", 5) == 0) {
+ _ico_sys_config->category[i].view = ICO_UXF_POLICY_ALWAYS;
+ }
+ else if (strncasecmp(strp, "run", 3) == 0) {
+ _ico_sys_config->category[i].view = ICO_UXF_POLICY_RUNNING;
+ }
+ else if (strncasecmp(strp, "park", 4) == 0) {
+ _ico_sys_config->category[i].view = ICO_UXF_POLICY_PARKED;
+ }
+ else if (strncasecmp(strp, "shift_park", 10) == 0) {
+ _ico_sys_config->category[i].view = ICO_UXF_POLICY_SHIFT_PARKING;
+ }
+ else if ((strncasecmp(strp, "shift_back", 10) == 0) ||
+ (strncasecmp(strp, "shift_rev", 9) == 0)) {
+ _ico_sys_config->category[i].view = ICO_UXF_POLICY_SHIFT_REVERSES;
+ }
+ else if (strcasecmp(strp, "blinker_left") == 0) {
+ _ico_sys_config->category[i].view = ICO_UXF_POLICY_BLINKER_LEFT;
+ }
+ else if (strcasecmp(strp, "blinker_right") == 0) {
+ _ico_sys_config->category[i].view = ICO_UXF_POLICY_BLINKER_RIGHT;
+ }
+ else {
+ fprintf(stderr, "[%s.view: %s] Unknown view mode\n", key, strp);
+ g_list_free_full(idlist,g_free);
+ g_key_file_free(keyfile);
+ return NULL;
+ }
+
+ strp = (char *)g_key_file_get_string(keyfile, g,
+ ico_uxf_conf_appendStr(key, ".sound"), &error);
+ ico_uxf_conf_checkGerror(&error);
+ if (strncasecmp(strp, "alway", 5) == 0) {
+ _ico_sys_config->category[i].sound = ICO_UXF_POLICY_ALWAYS;
+ }
+ else if (strncasecmp(strp, "run", 3) == 0) {
+ _ico_sys_config->category[i].sound = ICO_UXF_POLICY_RUNNING;
+ }
+ else if (strncasecmp(strp, "park", 4) == 0) {
+ _ico_sys_config->category[i].sound = ICO_UXF_POLICY_PARKED;
+ }
+ else if (strncasecmp(strp, "shift_park", 10) == 0) {
+ _ico_sys_config->category[i].sound = ICO_UXF_POLICY_SHIFT_PARKING;
+ }
+ else if ((strncasecmp(strp, "shift_back", 10) == 0) ||
+ (strncasecmp(strp, "shift_rev", 9) == 0)) {
+ _ico_sys_config->category[i].sound = ICO_UXF_POLICY_SHIFT_REVERSES;
+ }
+ else if (strcasecmp(strp, "blinker_left") == 0) {
+ _ico_sys_config->category[i].sound = ICO_UXF_POLICY_BLINKER_LEFT;
+ }
+ else if (strcasecmp(strp, "blinker_right") == 0) {
+ _ico_sys_config->category[i].sound = ICO_UXF_POLICY_BLINKER_RIGHT;
+ }
+ else {
+ fprintf(stderr, "[%s.view: %s] Unknown sound mode\n", key, strp);
+ g_list_free_full(idlist,g_free);
+ g_key_file_free(keyfile);
+ return NULL;
+ }
+
+ strp = (char *)g_key_file_get_string(keyfile, g,
+ ico_uxf_conf_appendStr(key, ".input"), &error);
+ ico_uxf_conf_checkGerror(&error);
+ if (strncasecmp(strp, "alway", 5) == 0) {
+ _ico_sys_config->category[i].input = ICO_UXF_POLICY_ALWAYS;
+ }
+ else if (strncasecmp(strp, "run", 3) == 0) {
+ _ico_sys_config->category[i].input = ICO_UXF_POLICY_RUNNING;
+ }
+ else if (strncasecmp(strp, "park", 4) == 0) {
+ _ico_sys_config->category[i].input = ICO_UXF_POLICY_PARKED;
+ }
+ else if (strncasecmp(strp, "shift_park", 10) == 0) {
+ _ico_sys_config->category[i].input = ICO_UXF_POLICY_SHIFT_PARKING;
+ }
+ else if ((strncasecmp(strp, "shift_back", 10) == 0) ||
+ (strncasecmp(strp, "shift_rev", 9) == 0)) {
+ _ico_sys_config->category[i].input = ICO_UXF_POLICY_SHIFT_REVERSES;
+ }
+ else if (strcasecmp(strp, "blinker_left") == 0) {
+ _ico_sys_config->category[i].input = ICO_UXF_POLICY_BLINKER_LEFT;
+ }
+ else if (strcasecmp(strp, "blinker_right") == 0) {
+ _ico_sys_config->category[i].input = ICO_UXF_POLICY_BLINKER_RIGHT;
+ }
+ else {
+ fprintf(stderr, "[%s.view: %s] Unknown input mode\n", key, strp);
+ g_list_free_full(idlist,g_free);
+ g_key_file_free(keyfile);
+ return NULL;
+ }
+ _ico_sys_config->category[i].priority =
+ g_key_file_get_integer(keyfile, g,
+ ico_uxf_conf_appendStr(key,".priority"), &error);
+ ico_uxf_conf_checkGerror(&error);
+
+ apfw_trace("Categry.%d id = %d name = %s view = %d sound = %d input = %d prio = %d",
+ i, _ico_sys_config->category[i].id, _ico_sys_config->category[i].name,
+ _ico_sys_config->category[i].view, _ico_sys_config->category[i].sound,
+ _ico_sys_config->category[i].input,
+ _ico_sys_config->category[i].priority);
+ }
+ g_list_free_full(idlist,g_free);
+
+ /* [kind] application kind name and attributes */
+ idlist = ico_uxf_conf_countNumericalKey(keyfile, "kind");
+ length = g_list_length(idlist);
+ _ico_sys_config->kindNum = length;
+ _ico_sys_config->kind = g_malloc0(sizeof(Ico_Uxf_conf_kind) * length);
+
+ for (i = 0; i < (int)length; i++) {
+ const char* key = (const char*) g_list_nth_data(idlist, i);
+ const char* g = "kind";
+ _ico_sys_config->kind[i].id = ico_uxf_conf_getUint(key);
+ ico_uxf_conf_checkGerror(&error);
+ _ico_sys_config->kind[i].name = g_key_file_get_string(keyfile, g, key, &error);
+ ico_uxf_conf_checkGerror(&error);
+ strp = (char *)g_key_file_get_string(
+ keyfile, g, ico_uxf_conf_appendStr(key, ".privilege"), &error);
+ ico_uxf_conf_checkGerror(&error);
+ if (strcasecmp(strp, "almighty") == 0) {
+ _ico_sys_config->kind[i].priv = ICO_UXF_PRIVILEGE_ALMIGHTY;
+ }
+ else if (strcasecmp(strp, "system") == 0) {
+ _ico_sys_config->kind[i].priv = ICO_UXF_PRIVILEGE_SYSTEM;
+ }
+ else if (strcasecmp(strp, "maker") == 0) {
+ _ico_sys_config->kind[i].priv = ICO_UXF_PRIVILEGE_MAKER;
+ }
+ else if (strcasecmp(strp, "certificate") == 0) {
+ _ico_sys_config->kind[i].priv = ICO_UXF_PRIVILEGE_CERTIFICATE;
+ }
+ else if (strcasecmp(strp, "none") == 0) {
+ _ico_sys_config->kind[i].priv = ICO_UXF_PRIVILEGE_NONE;
+ }
+ else {
+ fprintf(stderr, "[%s.view: %s] Unknown privilege mode\n", key, strp);
+ g_list_free_full(idlist,g_free);
+ g_key_file_free(keyfile);
+ return NULL;
+ }
+ apfw_trace("Kind.%d id = %d name = %s privilege = %d",
+ i, _ico_sys_config->kind[i].id, _ico_sys_config->kind[i].name,
+ _ico_sys_config->kind[i].priv);
+ }
+ g_list_free_full(idlist,g_free);
+
+ /* [port] port numbers */
+ _ico_sys_config->misc.appscontrollerport
+ = g_key_file_get_integer(keyfile, "port", "appscontrollerport", &error);
+ ico_uxf_conf_checkGerror(&error);
+ _ico_sys_config->misc.soundpluginport
+ = g_key_file_get_integer(keyfile, "port", "soundpluginport", &error);
+ ico_uxf_conf_checkGerror(&error);
+ if (_ico_sys_config->misc.appscontrollerport <= 0)
+ _ico_sys_config->misc.appscontrollerport = 18081;
+ if (_ico_sys_config->misc.soundpluginport <= 0)
+ _ico_sys_config->misc.soundpluginport = 18082;
+
+ /* hosts */
+ idlist = ico_uxf_conf_countNumericalKey(keyfile, "host");
+ length = g_list_length(idlist);
+ _ico_sys_config->hostNum = length;
+ _ico_sys_config->host = g_malloc0(sizeof(Ico_Uxf_conf_host) * length);
+
+ for (i = 0; i < (int)length; i++) {
+ char* key = (char*) g_list_nth_data(idlist, i);
+ const char* g = "host";
+ _ico_sys_config->host[i].id = ico_uxf_conf_getUint(key);
+ _ico_sys_config->host[i].name = g_key_file_get_string(keyfile, g, key, &error);
+ ico_uxf_conf_checkGerror(&error);
+
+ _ico_sys_config->host[i].address
+ = g_key_file_get_string(keyfile, g, ico_uxf_conf_appendStr(key, ".ip"), &error);
+ ico_uxf_conf_checkGerror(&error);
+ if (g_hostname_is_ip_address(_ico_sys_config->host[i].address)!= TRUE){
+ apfw_error("host[%d] = %s is not ip address style",
+ _ico_sys_config->host[i].id, _ico_sys_config->host[i].address);
+ exit(1);
+ }
+
+ _ico_sys_config->host[i].type =
+ ico_uxf_getSysHostTypeByName(
+ g_key_file_get_string(keyfile, g,
+ ico_uxf_conf_appendStr(key, ".type"), &error));
+ ico_uxf_conf_checkGerror(&error);
+
+ _ico_sys_config->host[i].homescreen =
+ g_key_file_get_string(keyfile, g,
+ ico_uxf_conf_appendStr(key, ".homescreen"), &error);
+ ico_uxf_conf_checkGerror(&error);
+ apfw_trace("Host.%d: Id = %d Name = %s Type = %d Ip = %s HomeScreen = %s",
+ i, _ico_sys_config->host[i].id, (char *)_ico_sys_config->host[i].name,
+ _ico_sys_config->host[i].type, (char *)_ico_sys_config->host[i].address,
+ _ico_sys_config->host[i].homescreen);
+ }
+ g_list_free_full(idlist,g_free);
+
+ /* decide myhost */
+ const char *penv = getenv(ICO_UXF_ENV_APPINF);
+ int hostid = -1;
+ int dmy1, dmy2, dmy3;
+ char cdmy4[64];
+ if (penv) {
+ if (sscanf(penv, "%d %d %d %s %d", &dmy1, &dmy2, &dmy3, cdmy4, &hostid) < 5) {
+ hostid = -1;
+ }
+ apfw_trace("reloadSysConfig: Env(%s) = %s, hostId = %d",
+ ICO_UXF_ENV_APPINF, penv, hostid);
+ }
+
+ if (hostid < 0) {
+ if ((gethostname(cdmy4, sizeof(cdmy4)-1) >= 0) &&
+ (strncmp(cdmy4, "localhost", 9) != 0)) {
+ apfw_trace("hostname = %s", cdmy4);
+ for (j = 0; cdmy4[j]; j++) {
+ if ((cdmy4[j] == ' ') || (cdmy4[j] == '(') ||
+ (cdmy4[j] == '@') || (cdmy4[j] == ':')) {
+ cdmy4[j] = 0;
+ break;
+ }
+ }
+ for (j = 0; j < _ico_sys_config->hostNum; j++) {
+ if (strcasecmp(_ico_sys_config->host[j].name, cdmy4) == 0) {
+ hostid = _ico_sys_config->host[j].id;
+ break;
+ }
+ }
+ }
+ }
+
+ if (hostid < 0) {
+ FILE *fp = popen("/sbin/ifconfig", "r");
+ int foundeth = 0;
+ char sBuf[128];
+
+ if (fp) {
+ while (fgets(sBuf, sizeof(sBuf)-1, fp)) {
+ if ((! foundeth) || (sBuf[0] != ' ')) {
+ foundeth = 0;
+ /* skip to "eth" device */
+ if (sBuf[0] == ' ' || sBuf[0] == '\t') continue;
+ if (strncmp(sBuf, "eth", 3) != 0) continue;
+ }
+ foundeth = 1;
+
+ for (j = 0; sBuf[j]; j++) {
+ if (strncmp(&sBuf[j], "inet6", 5) == 0) continue;
+ if (strncmp(&sBuf[j], "inet", 4) == 0) break;
+ }
+ if (sBuf[j]) {
+ /* forget "inet" device */
+ j += 4;
+ for (; sBuf[j]; j++) {
+ if (sBuf[j] == ':') break;
+ }
+ if (sBuf[j] ) {
+ j++;
+ int k;
+ for (k = j +1; sBuf[k]; k++) {
+ if (sBuf[k] == ' ' || sBuf[k] == '\t' ||
+ sBuf[k] == '\n' || sBuf[k] == '\r') {
+ sBuf[k] = 0;
+ break;
+ }
+ }
+ apfw_trace("My Inet Addr = %s", &sBuf[j]);
+ for (k = 0; k < _ico_sys_config->hostNum; k++) {
+ if (strcmp(_ico_sys_config->host[k].address, &sBuf[j]) == 0) {
+ hostid = _ico_sys_config->host[k].id;
+ break;
+ }
+ }
+ }
+ }
+ if (hostid >= 0) break;
+ }
+ fclose(fp);
+ }
+ }
+ if (hostid >= 0) {
+ _ico_sys_config->misc.myhostId = hostid;
+ }
+ else {
+ apfw_trace("Default Host = 0, %s", ico_uxf_get_SysLocation(0));
+ _ico_sys_config->misc.myhostId = _ico_sys_config->host[0].id;
+ }
+
+ /* The validity of MyHost is checked. */
+ Ico_Uxf_conf_host *myhost = (Ico_Uxf_conf_host *)
+ ico_uxf_getSysHostById(_ico_sys_config->misc.myhostId);
+ if (! myhost) {
+ apfw_critical("MyHostId.%d dose not exist, default 0",
+ _ico_sys_config->misc.myhostId);
+ myhost = &_ico_sys_config->host[0];
+ if (! myhost) {
+ apfw_error("HostId.0 dose not exist, GiveUp!");
+ exit(1);
+ }
+ _ico_sys_config->misc.myhostId = myhost->id;
+ }
+
+ _ico_sys_config->misc.myaddress =
+ (char *)ico_uxf_get_SysLocation(_ico_sys_config->misc.myhostId);
+ _ico_sys_config->misc.myhostName = myhost->name;
+
+ _ico_sys_config->misc.homescreen = myhost->homescreen;
+
+ if (myhost->homescreen) {
+ _ico_sys_config->misc.masterhostId = myhost->id;
+ }
+ else {
+ _ico_sys_config->misc.masterhostId = _ico_sys_config->misc.myhostId;
+
+ for (i = 0; i < _ico_sys_config->hostNum; i++) {
+ if (_ico_sys_config->host[i].homescreen) {
+ _ico_sys_config->misc.masterhostId = _ico_sys_config->host[i].id;
+ break;
+ }
+ }
+ }
+ _ico_sys_config->misc.masterhostaddress =
+ (char *)ico_uxf_get_SysLocation(_ico_sys_config->misc.masterhostId);
+
+ apfw_trace("MyHost %d[%s] Master Host %d(%s)", _ico_sys_config->misc.myhostId,
+ _ico_sys_config->misc.myaddress, _ico_sys_config->misc.masterhostId,
+ _ico_sys_config->misc.masterhostaddress);
+
+ _ico_sys_config->misc.default_hostId = ico_uxf_getSysHostByName(
+ g_key_file_get_string(keyfile, "default", "host", &error));
+ ico_uxf_conf_checkGerror(&error);
+
+ /* display */
+ idlist = ico_uxf_conf_countNumericalKey(keyfile, "display");
+ length = g_list_length(idlist);
+ _ico_sys_config->displayNum = length;
+ _ico_sys_config->display = g_malloc0(sizeof(Ico_Uxf_conf_display) * length);
+ zoneidx = 0;
+
+ for (i = 0; i < (int)length; i++) {
+ const char* key = (const char*) g_list_nth_data(idlist, i);
+ const char* g = "display";
+ Ico_Uxf_conf_display *display = &_ico_sys_config->display[i];
+ display->id = ico_uxf_conf_getUint(key);
+ ico_uxf_conf_checkGerror(&error);
+ display->name = g_key_file_get_string(keyfile, g, key, &error);
+ ico_uxf_conf_checkGerror(&error);
+
+ display->hostId =
+ ico_uxf_getSysHostByName(
+ g_key_file_get_string(keyfile, g,
+ ico_uxf_conf_appendStr(key,".host"), &error));
+ ico_uxf_conf_checkGerror(&error);
+ display->displayno =
+ g_key_file_get_integer(keyfile, g,
+ ico_uxf_conf_appendStr(key,".displayno"), &error);
+ if (error) {
+ display->displayno = -1;
+ g_clear_error(&error);
+ }
+ display->wayland =
+ g_key_file_get_string(keyfile, g,
+ ico_uxf_conf_appendStr(key,".wayland"), &error);
+ ico_uxf_conf_checkGerror(&error);
+
+ display->type =
+ ico_uxf_getSysDispTypeByName(g_key_file_get_string(keyfile, g,
+ ico_uxf_conf_appendStr(key,".type"), &error));
+ ico_uxf_conf_checkGerror(&error);
+
+ display->width =
+ g_key_file_get_integer(keyfile, g, ico_uxf_conf_appendStr(key,".width"), &error);
+ ico_uxf_conf_checkGerror(&error);
+ display->height =
+ g_key_file_get_integer(keyfile, g, ico_uxf_conf_appendStr(key,".height"), &error);
+ ico_uxf_conf_checkGerror(&error);
+ display->layerNum =
+ g_key_file_get_integer(keyfile, g, ico_uxf_conf_appendStr(key,".layer"), &error);
+ ico_uxf_conf_checkGerror(&error);
+
+ /* inch */
+ display->inch =
+ g_key_file_get_integer(keyfile,g,ico_uxf_conf_appendStr(key,".inch"),&error);
+ ico_uxf_conf_checkGerror(&error);
+
+ apfw_trace("Display.%d Id = %d Name = %s Host = %d DispNo = %d W/H = %d/%d Wayland = %s inch = %d",
+ i, display->id, (char *)display->name, display->hostId,
+ display->displayno, display->width, display->height,
+ display->wayland, display->inch);
+
+ /* display layer */
+ int displayer_length;
+ GString* layer_key = g_string_new("");
+ for (displayer_length = 0;
+ displayer_length < ICO_UXF_DISPLAY_LAYER_MAX; displayer_length++) {
+ g_string_printf(layer_key,"%s.layer.%d",key,displayer_length);
+ if (g_key_file_has_key(keyfile,g,layer_key->str,NULL) != TRUE) break;
+ }
+ apfw_trace("Display.%d layerNum = %d" ,i, displayer_length);
+ display->layerNum = displayer_length;
+ display->layer = g_malloc0(sizeof(Ico_Uxf_conf_display_layer)*displayer_length);
+
+ for (j = 0; j < displayer_length; j++) {
+ g_string_printf(layer_key,"%s.layer.%d",key,j);
+ display->layer[j].id = j;
+ display->layer[j].name =
+ g_key_file_get_string(keyfile, g, layer_key->str, &error);
+ ico_uxf_conf_checkGerror(&error);
+ apfw_trace("Display.%d Layer.%d id = %d name = %s", i, j,
+ display->layer[j].id, display->layer[j].name);
+ }
+ g_string_free(layer_key,TRUE);
+
+ /* display zone */
+ int dispzone_length;
+ GString* zone_key = g_string_new("");
+ for (dispzone_length = 0;
+ dispzone_length < ICO_UXF_DISPLAY_ZONE_MAX; dispzone_length++) {
+ g_string_printf(zone_key,"%s.zone.%d",key,dispzone_length);
+ if (g_key_file_has_key(keyfile,g,zone_key->str,NULL) != TRUE) break;
+ }
+ apfw_trace("Display.%d zoneNum = %d" ,i, dispzone_length);
+ display->zoneNum = dispzone_length;
+ display->zone = g_malloc0(sizeof(Ico_Uxf_conf_display_zone)*dispzone_length);
+
+ gsize zonesizes[ICO_UXF_DISPLAY_ZONE_MAX];
+ gchar **zonelists[ICO_UXF_DISPLAY_ZONE_MAX];
+ gchar **zonelist;
+ Ico_Uxf_conf_display_zone *zone;
+
+ for (j = 0; j < dispzone_length; j++) {
+ g_string_printf(zone_key,"%s.zone.%d",key,j);
+ zonelists[j] = g_key_file_get_string_list(
+ keyfile,g,zone_key->str,&zonesizes[j],&error);
+ ico_uxf_conf_checkGerror(&error);
+ if ((! zonelists[j]) || (zonesizes[j] <= 0)) {
+ apfw_error("reloadSysConfig: display.%d zone.%d dose not exist",i,j);
+ zonesizes[j] = 0;
+ }
+ }
+ for (j = 0; j < dispzone_length; j++) {
+ zone = &(display->zone[j]);
+ zone->id = j;
+ zone->zoneidx = zoneidx++;
+ zone->display = display;
+
+ if (zonesizes[j] <= 0) continue;
+
+ zonelist = zonelists[j];
+ zone->name = strdup((char*)zonelist[0]);
+ if (zonesizes[j] < 5) {
+ /* default zone is full screen */
+ zone->x = 0;
+ zone->y = 0;
+ zone->width = display->width;
+ zone->height = display->height;
+ }
+ else {
+ zone->x = pars_dispposition((char *)zonelist[1], display);
+ zone->y = pars_dispposition((char *)zonelist[2], display);
+ zone->width = pars_dispposition((char *)zonelist[3], display);
+ zone->height = pars_dispposition((char *)zonelist[4], display);
+ }
+ }
+ for (j = 0; j < dispzone_length; j++) {
+ int k, l, m, n;
+ if (zonesizes[j] <= 5) continue;
+ zonelist = zonelists[j];
+ zone = &(display->zone[j]);
+ m = 0;
+ for (k = 5; (m < ZONE_MAX_OVERLAP) && (k < (int)zonesizes[j]); k++) {
+ for (l = 0; l < dispzone_length; l++) {
+ if (l == j) continue;
+ if (strcasecmp(zonelist[k], display->zone[l].name) == 0) {
+ for (n = 0; n < m; n++) {
+ if (zone->overlap[n] == display->zone[l].id) break;
+ }
+ if (n >= m) {
+ zone->overlap[m++] = display->zone[l].id;
+ }
+ break;
+ }
+ }
+ if (l >= dispzone_length) {
+ apfw_error("reloadSysConfig: disp.%d zone.%d overlap zone(%s) "
+ "dose not exist", i, j, (char *)zonelist[k]);
+ }
+ }
+ zone->overlapNum = m;
+ }
+ for (j = 0; j < dispzone_length; j++) {
+ if (zonelists[j]) g_strfreev(zonelists[j]);
+ zone = &(display->zone[j]);
+ apfw_trace("Disp.%d zone.%d x/y = %d/%d w/h = %d/%d over = %d.%d %d %d %d %d",
+ i, j, zone->x, zone->y, zone->width, zone->height,
+ zone->overlapNum, zone->overlap[0], zone->overlap[1],
+ zone->overlap[2], zone->overlap[3], zone->overlap[4]);
+ }
+ g_string_free(zone_key,TRUE);
+ }
+ g_list_free_full(idlist,g_free);
+
+ /* sound devices */
+ idlist = ico_uxf_conf_countNumericalKey(keyfile, "sound");
+ length = g_list_length(idlist);
+ _ico_sys_config->soundNum = length;
+ _ico_sys_config->sound = g_malloc0(sizeof(Ico_Uxf_conf_sound) * length);
+ zoneidx = 0;
+
+ for (i = 0; i < (int)length; i++) {
+ const char* key = (const char*) g_list_nth_data(idlist, i);
+ const char* g = "sound";
+ Ico_Uxf_conf_sound *sound = &_ico_sys_config->sound[i];
+ sound->id = ico_uxf_conf_getUint(key);
+ ico_uxf_conf_checkGerror(&error);
+ sound->name = g_key_file_get_string(keyfile, g, key, &error);
+ ico_uxf_conf_checkGerror(&error);
+
+ sound->hostId =
+ ico_uxf_getSysHostByName(g_key_file_get_string(
+ keyfile, g, ico_uxf_conf_appendStr(key,".host"), &error));
+ ico_uxf_conf_checkGerror(&error);
+ sound->soundno =
+ g_key_file_get_integer(keyfile, g,
+ ico_uxf_conf_appendStr(key,".soundno"), &error);
+ if (error) {
+ sound->soundno = -1;
+ g_clear_error(&error);
+ }
+
+ apfw_trace("Sound.%d Id = %d Name = %s Host = %d SoundNo = %d",
+ i, sound->id, (char *)sound->name, sound->hostId, sound->soundno);
+
+ /* sound zone */
+ int sound_length;
+ GString* sound_key = g_string_new("");
+ for (sound_length = 0;
+ sound_length < ICO_UXF_SOUND_ZONE_MAX; sound_length++) {
+ g_string_printf(sound_key,"%s.zone.%d", key, sound_length);
+ if (g_key_file_has_key(keyfile,g,sound_key->str,NULL) != TRUE) break;
+ }
+ apfw_trace("Sound.%d zoneNum = %d" ,i, sound_length);
+ sound->zoneNum = sound_length;
+ sound->zone = g_malloc0(sizeof(Ico_Uxf_conf_sound_zone)*sound_length);
+
+ gsize zonesizes[ICO_UXF_SOUND_ZONE_MAX];
+ gchar **zonelists[ICO_UXF_SOUND_ZONE_MAX];
+ gchar **zonelist;
+ Ico_Uxf_conf_sound_zone *zone;
+
+ for (j = 0; j < sound_length; j++) {
+ g_string_printf(sound_key,"%s.zone.%d",key,j);
+ zonelists[j] =
+ g_key_file_get_string_list(keyfile,g,sound_key->str,&zonesizes[j],&error);
+ ico_uxf_conf_checkGerror(&error);
+ if ((! zonelists[j]) || (zonesizes[j] <= 0)) {
+ apfw_error("reloadSysConfig: sound.%d zone.%d dose not exist",i,j);
+ zonesizes[j] = 0;
+ }
+ }
+ for (j = 0; j < sound_length; j++) {
+ zone = &(sound->zone[j]);
+ zone->id = j;
+ zone->zoneidx = zoneidx++;
+ zone->sound = sound;
+ if (zonesizes[j] <= 0) continue;
+
+ zonelist = zonelists[j];
+ zone->name = strdup((char*)zonelist[0]);
+ }
+ for (j = 0; j < sound_length; j++) {
+ int k, l, m, n;
+ if (zonesizes[j] <= 1) continue;
+ zonelist = zonelists[j];
+ zone = &(sound->zone[j]);
+ m = 0;
+ for (k = 1; (m < ZONE_MAX_OVERLAP) && (k < (int)zonesizes[j]); k++) {
+ for (l = 0; l < sound_length; l++) {
+ if (l == j) continue;
+ if (strcasecmp((char*)zonelist[k], sound->zone[l].name) == 0) {
+ for (n = 0; n < m; n++) {
+ if (zone->overlap[n] == sound->zone[l].id) break;
+ }
+ if (n >= m) {
+ zone->overlap[m++] = sound->zone[l].id;
+ }
+ break;
+ }
+ }
+ if (l >= sound_length) {
+ apfw_error("reloadSysConfig: sound.%d zone.%d overlap zone(%s) "
+ "dose not exist", i, j, (char *)zonelist[k]);
+ }
+ }
+ zone->overlapNum = m;
+ }
+ for (j = 0; j < sound_length; j++) {
+ if (zonelists[j]) g_strfreev(zonelists[j]);
+ zone = &(sound->zone[j]);
+ apfw_trace("Sound.%d zone.%d(%s) over = %d.%d %d %d %d %d",
+ i, j, zone->name,
+ zone->overlapNum, zone->overlap[0], zone->overlap[1],
+ zone->overlap[2], zone->overlap[3], zone->overlap[4]);
+ }
+ g_string_free(sound_key,TRUE);
+ }
+ g_list_free_full(idlist,g_free);
+
+ /* input devices */
+ idlist = ico_uxf_conf_countNumericalKey(keyfile, "input");
+ length = g_list_length(idlist);
+ _ico_sys_config->inputdevNum = length;
+ _ico_sys_config->inputdev = g_malloc0(sizeof(Ico_Uxf_conf_inputdev) * length);
+
+ for (i = 0; i < (int)length; i++) {
+ const char* key = (const char*) g_list_nth_data(idlist, i);
+ const char* g = "input";
+ Ico_Uxf_conf_inputdev *inputdev = &_ico_sys_config->inputdev[i];
+ inputdev->id = ico_uxf_conf_getUint(key);
+ ico_uxf_conf_checkGerror(&error);
+ inputdev->name = g_key_file_get_string(keyfile, g, key, &error);
+ ico_uxf_conf_checkGerror(&error);
+
+ /* input sw */
+ int sw_length;
+ GString* sw_key = g_string_new("");
+ for (sw_length = 0;; sw_length++) {
+ g_string_printf(sw_key,"%s.sw.%d",key,sw_length);
+ if (g_key_file_has_key(keyfile,g,sw_key->str,NULL) != TRUE) break;
+ }
+ apfw_trace("Input.%d swNum = %d" ,i, sw_length);
+ inputdev->inputswNum = sw_length;
+ inputdev->inputsw = g_malloc0(sizeof(Ico_Uxf_conf_inputsw)*sw_length);
+
+ /* input sw */
+ gchar **swlist;
+ gsize swsize;
+ for (j = 0; j < sw_length; j++) {
+ g_string_printf(sw_key,"%s.sw.%d",key,j);
+ swlist = g_key_file_get_string_list(keyfile,g,sw_key->str,&swsize,&error);
+ ico_uxf_conf_checkGerror(&error);
+ if ((!swlist) || (swsize <= 0)) {
+ apfw_error("reloadSysConfig: input.%d sw.%d dose not exist",i,j);
+ swsize = 0;
+ }
+ else {
+ inputdev->inputsw[j].inputdev = inputdev;
+ inputdev->inputsw[j].name = strdup((char *)swlist[0]);
+ if (swsize > 1) {
+ inputdev->inputsw[j].appid = strdup((char *)swlist[1]);
+ }
+ }
+ g_strfreev(swlist);
+ uifw_trace("reloadSysConfig: input %s.%s app = %s",
+ inputdev->name,
+ inputdev->inputsw[j].name ? inputdev->inputsw[j].name : " ",
+ inputdev->inputsw[j].appid ? inputdev->inputsw[j].appid : " ");
+ }
+ g_string_free(sw_key,TRUE);
+ }
+ g_list_free_full(idlist,g_free);
+
+ _ico_sys_config->misc.default_kindId = ico_uxf_getSysKindByName(
+ g_key_file_get_string(keyfile, "default", "kind", &error));
+ ico_uxf_conf_checkGerror(&error);
+ _ico_sys_config->misc.default_categoryId = ico_uxf_getSysCategoryByName(
+ g_key_file_get_string(keyfile, "default", "category", &error));
+ ico_uxf_conf_checkGerror(&error);
+ _ico_sys_config->misc.default_displayId = ico_uxf_getSysDisplayByName(
+ g_key_file_get_string(keyfile, "default", "display", &error));
+ ico_uxf_conf_checkGerror(&error);
+ _ico_sys_config->misc.default_layerId = ico_uxf_getSysLayerByName(
+ _ico_sys_config->misc.default_displayId,
+ g_key_file_get_string(keyfile, "default", "layer", &error));
+ ico_uxf_conf_checkGerror(&error);
+ _ico_sys_config->misc.default_dispzoneId = ico_uxf_getSysDispZoneByName(
+ _ico_sys_config->misc.default_displayId,
+ g_key_file_get_string(keyfile, "default", "displayzone", &error));
+ _ico_sys_config->misc.default_soundId = ico_uxf_getSysSoundByName(
+ g_key_file_get_string(keyfile, "default", "sound", &error));
+ _ico_sys_config->misc.default_soundzoneId = ico_uxf_getSysSoundZoneByName(
+ _ico_sys_config->misc.default_soundId,
+ g_key_file_get_string(keyfile, "default", "soundzone", &error));
+ ico_uxf_conf_checkGerror(&error);
+ _ico_sys_config->misc.default_inputdevId = ico_uxf_getSysInputdevByName(
+ g_key_file_get_string(keyfile, "default", "inputdev", &error));
+ _ico_sys_config->misc.default_inputswId = ico_uxf_getSysInputswByName(
+ _ico_sys_config->misc.default_inputdevId,
+ g_key_file_get_string(keyfile, "default", "inputsw", &error));
+ ico_uxf_conf_checkGerror(&error);
+
+ apfw_trace("Default host = %d kind = %d category = %d disp = %d layer = %d dispzone = %d "
+ "sound = %d soundzone = %d input = %d/%d",
+ _ico_sys_config->misc.default_hostId,
+ _ico_sys_config->misc.default_kindId,
+ _ico_sys_config->misc.default_categoryId,
+ _ico_sys_config->misc.default_displayId,
+ _ico_sys_config->misc.default_layerId,
+ _ico_sys_config->misc.default_dispzoneId,
+ _ico_sys_config->misc.default_soundId,
+ _ico_sys_config->misc.default_soundzoneId,
+ _ico_sys_config->misc.default_inputdevId,
+ _ico_sys_config->misc.default_inputswId);
+ g_key_file_free(keyfile);
+
+ apfw_trace("reloadSysConfig: Leave");
+ return _ico_sys_config;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getSysHostById: get host configuration by host Id
+ *
+ * @param[in] hostId host Id
+ * @return host configuration table
+ * @retval != NULL success(host configuration table address)
+ * @retval == NULL error(host Id dose not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API const Ico_Uxf_conf_host *
+ico_uxf_getSysHostById(const int hostId)
+{
+ int i;
+
+ if (!_ico_sys_config) {
+ (void)ico_uxf_getSysConfig();
+ }
+
+ for (i = 0; i < _ico_sys_config->hostNum; i++) {
+ if (_ico_sys_config->host[i].id == hostId) {
+ return &_ico_sys_config->host[i];
+ }
+ }
+ apfw_warn("ico_uxf_getSysHostById(%d) Illegal Host Number", hostId);
+ return NULL;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_get_SysLocation: get host location by host Id
+ *
+ * @param[in] hostId host Id
+ * @return host location name
+ * @retval != NULL success(host location name)
+ * @retval == NULL error(host Id dose not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API const char *
+ico_uxf_get_SysLocation(const int hostId)
+{
+ int i;
+
+ if (!_ico_sys_config) {
+ (void)ico_uxf_getSysConfig();
+ }
+
+ for (i = 0; i < _ico_sys_config->hostNum; i++) {
+ if (_ico_sys_config->host[i].id == hostId) {
+ return _ico_sys_config->host[i].address;
+ }
+ }
+ apfw_warn("Ico_uxf_get_SysLocation(%d) Illegal Host Number", hostId);
+ return "127.0.0.1";
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getSysDisplayById: get display configuration by display Id
+ *
+ * @param[in] displayId display Id
+ * @return display configuration table address
+ * @retval != NULL success(host oy configuration tabel address)
+ * @retval == NULL error(displayd dose not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API const Ico_Uxf_conf_display *
+ico_uxf_getSysDisplayById(const int displayId)
+{
+ int i;
+
+ if (!_ico_sys_config) {
+ (void)ico_uxf_getSysConfig();
+ }
+
+ for (i = 0; i < _ico_sys_config->displayNum; i++) {
+ if (_ico_sys_config->display[i].id == displayId) {
+ return &_ico_sys_config->display[i];
+ }
+ }
+ apfw_warn("ico_uxf_getSysDisplayById(%d) Illegal Display Number", displayId);
+ return NULL;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getSysHostByName: get host Id bu host name
+ *
+ * @param[in] shost host name
+ * @return host Id number
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_getSysHostByName(const char *shost)
+{
+ int i;
+
+ if (!_ico_sys_config) {
+ (void)ico_uxf_getSysConfig();
+ }
+ if (_ico_sys_config->hostNum <= 0) {
+ apfw_critical("ico_uxf_getSysHostByName: can not read configuration file");
+ return _ico_sys_config->misc.default_hostId;
+ }
+
+ if ((! shost) || (*shost == 0)) {
+ return _ico_sys_config->host[0].id;
+ }
+
+ for (i = 0; i < _ico_sys_config->hostNum; i++) {
+ if (strcasecmp(shost, _ico_sys_config->host[i].name) == 0) {
+ return _ico_sys_config->host[i].id;
+ }
+ }
+ apfw_warn("ico_uxf_getSysHostByName(%s) Illegal Host Name", shost);
+ return _ico_sys_config->misc.default_hostId;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getSysHostTypeByName: get host type number by name(internal function)
+ *
+ * @param[in] stype host type name
+ * @return host type number
+ */
+/*--------------------------------------------------------------------------*/
+int
+ico_uxf_getSysHostTypeByName(const char *stype)
+{
+ if ((! stype) || (*stype == 0)) {
+ return ICO_UXF_HOSTTYPE_CENTER;
+ }
+ if (strcasecmp(stype, "center") == 0) {
+ return ICO_UXF_HOSTTYPE_CENTER;
+ }
+ else if (strcasecmp(stype, "meter") == 0) {
+ return ICO_UXF_HOSTTYPE_METER;
+ }
+ else if (strcasecmp(stype, "remote") == 0) {
+ return ICO_UXF_HOSTTYPE_REMOTE;
+ }
+ else if (strcasecmp(stype, "passenger") == 0) {
+ return ICO_UXF_HOSTTYPE_PASSENGER;
+ }
+ else if (strcasecmp(stype, "rear") == 0) {
+ return ICO_UXF_HOSTTYPE_REAR;
+ }
+ else if (strcasecmp(stype, "rearleft") == 0) {
+ return ICO_UXF_HOSTTYPE_REARLEFT;
+ }
+ else if (strcasecmp(stype, "rearright") == 0) {
+ return ICO_UXF_HOSTTYPE_REARRIGHT;
+ }
+ apfw_warn("ico_uxf_getSysHostTypeByName(%s) Illegal HostType Name", stype);
+ return strtol(stype, (char **)0, 0);
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getSysDispTypeByName: get display type number by name(internal function)
+ *
+ * @param[in] stype display type name
+ * @return display type number
+ */
+/*--------------------------------------------------------------------------*/
+int
+ico_uxf_getSysDispTypeByName(const char *stype)
+{
+ if ((! stype) || (*stype == 0)) {
+ apfw_critical("ico_uxf_getSysDispTypeByName(NULL) Illegal HostType Name");
+ return 0;
+ }
+ if (strcasecmp(stype, "center") == 0) {
+ return ICO_UXF_DISPLAYTYPE_CENTER;
+ }
+ else if (strcasecmp(stype, "meter") == 0) {
+ return ICO_UXF_DISPLAYTYPE_METER;
+ }
+ else if (strcasecmp(stype, "remote") == 0) {
+ return ICO_UXF_DISPLAYTYPE_REMOTE;
+ }
+ else if (strcasecmp(stype, "passenger") == 0) {
+ return ICO_UXF_DISPLAYTYPE_PASSENGER;
+ }
+ else if (strcasecmp(stype, "rear") == 0) {
+ return ICO_UXF_DISPLAYTYPE_REAR;
+ }
+ else if (strcasecmp(stype, "rearleft") == 0) {
+ return ICO_UXF_DISPLAYTYPE_REARLEFT;
+ }
+ else if (strcasecmp(stype, "rearright") == 0) {
+ return ICO_UXF_DISPLAYTYPE_REARRIGHT;
+ }
+ apfw_warn("ico_uxf_getSysDispTypeByName(%s) Illegal DisplayType Name", stype);
+ return strtol(stype, (char **)0, 0);
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getSysBoolByName: get boolian value(internal function)
+ *
+ * @param[in] sbool boolian value string
+ * @return boolian value
+ * @retval = 0 false
+ * @retval = 1 true
+ */
+/*--------------------------------------------------------------------------*/
+int
+ico_uxf_getSysBoolByName(const char *sbool)
+{
+ if ((! sbool) || (*sbool == 0)) {
+ return 0;
+ }
+ if ((strcasecmp(sbool, "true") == 0) ||
+ (strcasecmp(sbool, "yes") == 0) ||
+ (strcasecmp(sbool, "1") == 0)) {
+ return 1;
+ }
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getSysDisplayByName: get display Id by display name
+ *
+ * @param[in] sdisplay display name
+ * @return display Id
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_getSysDisplayByName(const char *sdisplay)
+{
+ int i;
+
+ if (!_ico_sys_config) {
+ (void)ico_uxf_getSysConfig();
+ }
+ if ((! sdisplay) || (*sdisplay == 0)) {
+ apfw_trace("ico_uxf_getSysDisplayByName(NULL) Illegal Display Name");
+ return _ico_sys_config->misc.default_displayId;
+ }
+
+ for (i = 0; i < _ico_sys_config->displayNum; i++) {
+ if (strcasecmp(sdisplay, _ico_sys_config->display[i].name) == 0) {
+ return _ico_sys_config->display[i].id;
+ }
+ }
+ apfw_warn("ico_uxf_getSysDisplayByName(%s) Illegal Display Name", sdisplay);
+ return _ico_sys_config->misc.default_displayId;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getSysLayerByName: get layer Id by layer name
+ *
+ * @param[in] display display Id
+ * @param[in] slayer layer name
+ * @return layer Id
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_getSysLayerByName(const int display, const char *slayer)
+{
+ int i;
+ char *errp;
+
+ if (!_ico_sys_config) {
+ (void)ico_uxf_getSysConfig();
+ }
+
+ if ((display < 0) || (display >= _ico_sys_config->displayNum)) {
+ apfw_warn("ico_uxf_getSysLayerByName(%d,%s) Illegal Display Number",
+ display, slayer);
+ return _ico_sys_config->misc.default_layerId;
+ }
+ if ((! slayer) || (*slayer == 0)) {
+ apfw_trace("ico_uxf_getSysLayerByName(NULL) Illegal Layer Name");
+ return _ico_sys_config->misc.default_layerId;
+ }
+
+ for (i = 0; i < _ico_sys_config->display[display].layerNum; i++) {
+ if (strcasecmp(slayer, _ico_sys_config->display[display].layer[i].name) == 0) {
+ return _ico_sys_config->display[display].layer[i].id;
+ }
+ }
+
+ errp = NULL;
+ i = strtol(slayer, &errp, 0);
+ if ((errp) && (*errp != 0)) {
+ apfw_warn("ico_uxf_getSysLayerByName(%d,%s) Illegal Layer Name", display, slayer);
+ i = _ico_sys_config->misc.default_layerId;
+ }
+ return i;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getSysKindByName: get kind Id by kind name
+ *
+ * @param[in] skind kind name
+ * @return kind Id
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_getSysKindByName(const char *skind)
+{
+ int i;
+
+ if (!_ico_sys_config) {
+ (void)ico_uxf_getSysConfig();
+ }
+ if (_ico_sys_config->kindNum <= 0) {
+ apfw_critical("ico_uxf_getSysKindByName: can not read configuration file");
+ return _ico_sys_config->misc.default_kindId;
+ }
+
+ if ((skind) && (*skind != 0)) {
+ for (i = 0; i < _ico_sys_config->kindNum; i++) {
+ if (strcasecmp(skind, _ico_sys_config->kind[i].name) == 0) {
+ return _ico_sys_config->kind[i].id;
+ }
+ }
+ }
+ apfw_warn("ico_uxf_getSysKindByName(%s) Illegal kind name", skind);
+ return _ico_sys_config->misc.default_kindId;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getSysCategoryByName: get category Id by category name
+ *
+ * @param[in] scategory category name
+ * @return category Id
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_getSysCategoryByName(const char *scategory)
+{
+ int i;
+
+ if (!_ico_sys_config) {
+ (void)ico_uxf_getSysConfig();
+ }
+ if (_ico_sys_config->categoryNum <= 0) {
+ apfw_critical("ico_uxf_getSysCategoryByName: can not read configuration file");
+ return _ico_sys_config->misc.default_categoryId;
+ }
+
+ if ((scategory) && (*scategory != 0)) {
+ for (i = 0; i < _ico_sys_config->categoryNum; i++) {
+ if (strcasecmp(scategory, _ico_sys_config->category[i].name) == 0) {
+ return _ico_sys_config->category[i].id;
+ }
+ }
+ }
+ apfw_warn("ico_uxf_getSysCategoryByName(%s) Illegal category name", scategory);
+ return _ico_sys_config->misc.default_categoryId;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getSysDispZoneByName: get display zone Id by display zone name
+ *
+ * @param[in] display display Id
+ * @param[in] sdispzone displahy zone name
+ * @return display zone Id
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_getSysDispZoneByName(const int display, const char *sdispzone)
+{
+ int i;
+
+ if (!_ico_sys_config) {
+ (void)ico_uxf_getSysConfig();
+ }
+ if ((display < 0) || (display >= _ico_sys_config->displayNum) ||
+ (_ico_sys_config->display[display].zoneNum <= 0)) {
+ apfw_critical("ico_uxf_getSysDispZoneByName: can not read configuration file");
+ return _ico_sys_config->misc.default_dispzoneId;
+ }
+
+ if ((sdispzone) && (*sdispzone != 0)) {
+ for (i = 0; i < _ico_sys_config->display[display].zoneNum; i++) {
+ if (strcasecmp(sdispzone, _ico_sys_config->display[display].zone[i].name) == 0) {
+ return _ico_sys_config->display[display].zone[i].id;
+ }
+ }
+ }
+ apfw_warn("ico_uxf_getSysDispZoneByName(%s) Illegal zone name", sdispzone);
+ return _ico_sys_config->misc.default_dispzoneId;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getSysSoundByName: get sound Id by sound name
+ *
+ * @param[in] ssound sound name
+ * @return sound Id
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_getSysSoundByName(const char *ssound)
+{
+ int i;
+
+ if (!_ico_sys_config) {
+ (void)ico_uxf_getSysConfig();
+ }
+ if (_ico_sys_config->soundNum <= 0) {
+ apfw_critical("ico_uxf_getSysSoundByName: can not read configuration file");
+ return _ico_sys_config->misc.default_soundId;
+ }
+
+ if ((ssound) && (*ssound != 0)) {
+ for (i = 0; i < _ico_sys_config->soundNum; i++) {
+ if (strcasecmp(ssound, _ico_sys_config->sound[i].name) == 0) {
+ return _ico_sys_config->sound[i].id;
+ }
+ }
+ }
+ apfw_warn("ico_uxf_getSysSoundByName(%s) Illegal sound name", ssound);
+ return _ico_sys_config->misc.default_soundId;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getSysSoundZoneByName: get sound zone Id by sound zone name
+ *
+ * @param[in] sound sound Id
+ * @param[in] ssoundzone sound zone name
+ * @return sound zone Id
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_getSysSoundZoneByName(const int sound, const char *ssoundzone)
+{
+ int i;
+
+ if (!_ico_sys_config) {
+ (void)ico_uxf_getSysConfig();
+ }
+ if ((sound < 0) || (sound >= _ico_sys_config->soundNum) ||
+ (_ico_sys_config->sound[sound].zoneNum <= 0)) {
+ apfw_critical("ico_uxf_getSysSoundZoneByName: can not read configuration file");
+ return _ico_sys_config->misc.default_soundzoneId;
+ }
+
+ if ((ssoundzone) && (*ssoundzone != 0)) {
+ for (i = 0; i < _ico_sys_config->sound[sound].zoneNum; i++) {
+ if (strcasecmp(ssoundzone, _ico_sys_config->sound[sound].zone[i].name) == 0) {
+ return _ico_sys_config->sound[sound].zone[i].id;
+ }
+ }
+ }
+ apfw_warn("ico_uxf_getSysSoundZoneByName(%s) Illegal zone name", ssoundzone);
+ return _ico_sys_config->misc.default_soundzoneId;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getSysInputdevByName: get input device Id by input device name
+ *
+ * @param[in] sinputdev input device name
+ * @return input device Id
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_getSysInputdevByName(const char *sinputdev)
+{
+ int i;
+
+ if (!_ico_sys_config) {
+ (void)ico_uxf_getSysConfig();
+ }
+ if (_ico_sys_config->inputdevNum <= 0) {
+ apfw_critical("ico_uxf_getSysInputdevByName: can not read configuration file");
+ return _ico_sys_config->misc.default_inputdevId;
+ }
+
+ if ((! sinputdev) || (*sinputdev == 0)) {
+ return _ico_sys_config->misc.default_inputdevId;
+ }
+
+ for (i = 0; i < _ico_sys_config->inputdevNum; i++) {
+ if (strcasecmp(sinputdev, _ico_sys_config->inputdev[i].name) == 0) {
+ return _ico_sys_config->inputdev[i].id;
+ }
+ }
+ apfw_warn("ico_uxf_getSysInputdevByName(%s) Illegal device Name", sinputdev);
+ return _ico_sys_config->misc.default_inputdevId;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_getSysInputswByName: get input switch Id by input switch name
+ *
+ * @param[in] inputdev input device Id
+ * @param[in] sinputsw input switch name
+ * @return input switch Id
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_getSysInputswByName(const int inputdev, const char *sinputsw)
+{
+ int i;
+
+ if (!_ico_sys_config) {
+ (void)ico_uxf_getSysConfig();
+ }
+ if ((inputdev < 0) || (inputdev >= _ico_sys_config->inputdevNum) ||
+ (_ico_sys_config->inputdev[inputdev].inputswNum <= 0)) {
+ apfw_critical("ico_uxf_getSysInputswByName: can not read configuration file");
+ return 0;
+ }
+
+ if ((sinputsw) && (*sinputsw != 0)) {
+ for (i = 0; i < _ico_sys_config->inputdev[inputdev].inputswNum; i++) {
+ if (strcasecmp(sinputsw, _ico_sys_config->inputdev[inputdev].inputsw[i].name)
+ == 0) {
+ return i;
+ }
+ }
+ }
+ apfw_warn("ico_uxf_getSysInputswByName(%s) Illegal sw name",
+ sinputsw ? sinputsw : "(NULL)");
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_closeSysConfig: close and release system configuration table
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API void
+ico_uxf_closeSysConfig(void)
+{
+ if (_ico_sys_config != NULL) {
+ g_free(_ico_sys_config->host);
+ g_free(_ico_sys_config->display);
+ g_free(_ico_sys_config);
+ _ico_sys_config = NULL;
+ }
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief user experiance library(initialize/terminate/event)
+ *
+ * @date Feb-28-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <fcntl.h>
+
+#include "wayland-client.h"
+#include "ico_window_mgr-client-protocol.h"
+#include "ico_uxf.h"
+#include "ico_uxf_conf.h"
+#include "ico_uxf_private.h"
+
+/* static functions */
+/* wayland standard callback functions */
+static void ico_uxf_wayland_globalcb(void *data, struct wl_registry *registry,
+ uint32_t name, const char *interface,
+ uint32_t version);
+static void ico_uxf_output_geometrycb(void *data, struct wl_output *wl_output,
+ int32_t x, int32_t y, int32_t physical_width,
+ int32_t physical_height, int32_t subpixel,
+ const char *make, const char *model,
+ int32_t transform);
+static void ico_uxf_output_modecb(void *data, struct wl_output *wl_output,
+ uint32_t flags, int32_t width, int32_t height,
+ int32_t refresh);
+
+/* ico_window_mgr(Multi Window Manager) callback functions */
+struct ico_window;
+static void ico_uxf_window_createdcb(void *data, struct ico_window_mgr *ico_window_mgr,
+ uint32_t surfaceid, int32_t pid, const char *appid);
+static void ico_uxf_window_destroyedcb(void *data, struct ico_window_mgr *ico_window_mgr,
+ uint32_t surfaceid);
+static void ico_uxf_window_visiblecb(void *data, struct ico_window_mgr *ico_window_mgr,
+ uint32_t surfaceid, int32_t visible, int32_t raise,
+ int32_t hint);
+static void ico_uxf_window_configurecb(void *data, struct ico_window_mgr *ico_window_mgr,
+ uint32_t surfaceid, const char *appid,
+ int32_t layer, int32_t x, int32_t y,
+ int32_t width, int32_t height, int32_t hint);
+static void ico_uxf_window_activecb(void *data,
+ struct ico_window_mgr *ico_window_mgr,
+ uint32_t surfaceid,
+ uint32_t active);
+
+/* ico_input_mgr(Multi Input Manager) callback functions */
+static void ico_uxf_input_capabilitiescb(void *data, struct ico_exinput *ico_exinput,
+ const char *device, int32_t type,
+ const char *swname, int32_t input,
+ const char *codename, int32_t code);
+static void ico_uxf_input_codecb(void *data, struct ico_exinput *ico_exinput,
+ const char *device, int32_t input, const char *codename,
+ int32_t code);
+static void ico_uxf_input_inputcb(void *data, struct ico_exinput *ico_exinput,
+ uint32_t time, const char *device, int32_t input,
+ int32_t code, int32_t state);
+
+/* AppCore(AUL) callback function */
+static int ico_uxf_aul_deadcb(int pid, void *data);
+
+/* Variables & Tables */
+Ico_Uxf_Api_Mng gIco_Uxf_Api_Mng = { 0 };
+
+static pthread_mutex_t sMutex;
+
+/* Wayland Registry Listener */
+static const struct wl_registry_listener ico_uxf_registry_listener = {
+ ico_uxf_wayland_globalcb
+};
+
+/* Window Manger Interface */
+static const struct ico_window_mgr_listener windowlistener = {
+ ico_uxf_window_createdcb,
+ ico_uxf_window_destroyedcb,
+ ico_uxf_window_visiblecb,
+ ico_uxf_window_configurecb,
+ ico_uxf_window_activecb
+};
+
+/* Input Manger Interface */
+static const struct ico_exinput_listener exinputlistener = {
+ ico_uxf_input_capabilitiescb,
+ ico_uxf_input_codecb,
+ ico_uxf_input_inputcb
+};
+
+/* Wayland Output interface */
+static const struct wl_output_listener outputlistener = {
+ ico_uxf_output_geometrycb,
+ ico_uxf_output_modecb
+};
+
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_init: initialize user interface library hor HomeScreen
+ *
+ * @param[in] name application id
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_EBUSY error(cullentry terminating)
+ * @retval ICO_UXF_ESRCH error(configuration error)
+ * @retval ICO_UXF_ENOSYS error(system error)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_init(const char *name)
+{
+ Ico_Uxf_Mng_Display *dsp;
+ Ico_Uxf_Mng_Layer *lay;
+ Ico_Uxf_Mng_Process *prc;
+ pthread_mutexattr_t sMutexAttr;
+ Ico_Uxf_Sys_Config *sysconf;
+ Ico_Uxf_App_Config *appconf;
+ Ico_Uxf_conf_appdisplay *appdsp;
+ Ico_Uxf_Mng_Callback *freecb;
+ Ico_Uxf_Mng_EventQue *freeeq;
+ int dn, tn;
+ int ret;
+
+ ico_uxf_log_open(name);
+
+ if (gIco_Uxf_Api_Mng.Initialized) {
+ if (gIco_Uxf_Api_Mng.Initialized < 0) {
+ uifw_trace("ico_uxf_init: Enter");
+ uifw_warn("ico_uxf_init: Leave(EBUSY)");
+ return ICO_UXF_EBUSY;
+ }
+ uifw_trace("ico_uxf_init: Enter");
+ uifw_trace("ico_uxf_init: Leave(EOK)");
+ return ICO_UXF_EOK;
+ }
+ uifw_trace("ico_uxf_init: Enter");
+
+ gIco_Uxf_Api_Mng.Initialized = -1;
+ memset(gIco_Uxf_Api_Mng.MyProcess, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
+ strncpy(gIco_Uxf_Api_Mng.MyProcess, name, ICO_UXF_MAX_PROCESS_NAME);
+ gIco_Uxf_Api_Mng.EventMask = 0;
+ gIco_Uxf_Api_Mng.WaylandFd = -1;
+ gIco_Uxf_Api_Mng.Wayland_Display = NULL;
+
+ /* read configurations */
+ sysconf = (Ico_Uxf_Sys_Config *)ico_uxf_getSysConfig();
+ appconf = (Ico_Uxf_App_Config *)ico_uxf_getAppConfig();
+ if ((sysconf == NULL) || (appconf == NULL)) {
+ uifw_error("ico_uxf_init: Leave(ESRCH), Configuration Read Error");
+ return ICO_UXF_ESRCH;
+ }
+
+ uifw_trace("ico_uxf_init: set display configurations");
+ /* set display configurations */
+ for (dn = 0; dn < sysconf->displayNum; dn++) {
+ dsp = ico_uxf_mng_display(sysconf->display[dn].id, 1);
+ dsp->attr.type = sysconf->display[dn].type;
+ dsp->attr.num_layers = sysconf->display[dn].layerNum;
+ dsp->attr.hostId = sysconf->display[dn].hostId;
+ dsp->attr.displayNo = sysconf->display[dn].displayno;
+ dsp->attr.w = sysconf->display[dn].width;
+ dsp->attr.h = sysconf->display[dn].height;
+ dsp->attr.pWidth = -1;
+ dsp->attr.pHeight = -1;
+ dsp->attr.orientation = ICO_UXF_ORIENTATION_HORIZONTAL;
+ dsp->attr.inch = sysconf->display[dn].inch;
+ strncpy(dsp->attr.name, sysconf->display[dn].name, ICO_UXF_MAX_WIN_NAME);
+ dsp->attr.name[ICO_UXF_MAX_WIN_NAME] = 0;
+
+ for (tn = 0; tn < sysconf->display[dn].layerNum; tn++) {
+ lay = ico_uxf_mng_layer(sysconf->display[dn].id,
+ sysconf->display[dn].layer[tn].id, 1);
+ lay->attr.display = sysconf->display[dn].id;
+ lay->attr.w = sysconf->display[dn].width;
+ lay->attr.h = sysconf->display[dn].height;
+ lay->mng_display = dsp;
+ }
+ }
+
+ uifw_trace("ico_uxf_init: set application configurations(num=%d)",
+ appconf->applicationNum);
+ /* set application configurations */
+ for(dn = 0; dn < appconf->applicationNum; dn++) {
+ prc = ico_uxf_mng_process(appconf->application[dn].appid, 1);
+ prc->attr.internalid = 0;
+ prc->attr.status = ICO_UXF_PROCSTATUS_STOP;
+ prc->attr.type = appconf->application[dn].categoryId;
+ prc->attr.hostId = appconf->application[dn].hostId;
+ prc->attr.myHost = (prc->attr.hostId == sysconf->misc.myhostId) ? 1 : 0;
+
+ appdsp = &appconf->application[dn].display[0];
+ prc->attr.mainwin.window = 0;
+ prc->attr.mainwin.windowtype = appconf->application[dn].categoryId;
+ prc->attr.mainwin.display = appdsp->displayId;
+ prc->attr.mainwin.layer = appdsp->layerId;
+ prc->attr.mainwin.x =
+ sysconf->display[appdsp->displayId].zone[appdsp->zoneId].x;
+ prc->attr.mainwin.y =
+ sysconf->display[appdsp->displayId].zone[appdsp->zoneId].y;
+ prc->attr.mainwin.w =
+ sysconf->display[appdsp->displayId].zone[appdsp->zoneId].width;
+ prc->attr.mainwin.h =
+ sysconf->display[appdsp->displayId].zone[appdsp->zoneId].height;
+ prc->attr.mainwin.name[ICO_UXF_MAX_WIN_NAME] = 0;
+ prc->attr.numwindows = appconf->application[dn].displayzoneNum;
+ /* get sub windows */
+ if (prc->attr.numwindows > 1) {
+ prc->attr.subwin = malloc(sizeof(Ico_Uxf_ProcessWin) *
+ (prc->attr.numwindows - 1));
+ if (! prc->attr.subwin) {
+ uifw_error("ico_uxf_init: No Memory");
+ appconf->application[dn].displayzoneNum = 1;
+ prc->attr.numwindows = 1;
+ }
+ else {
+ memset(prc->attr.subwin, 0, (prc->attr.numwindows - 1));
+ for (tn = 0; tn < (prc->attr.numwindows - 1); tn++) {
+ appdsp ++;
+ prc->attr.subwin[tn].windowtype = prc->attr.mainwin.windowtype;
+ prc->attr.subwin[tn].display = appdsp->displayId;
+ prc->attr.subwin[tn].layer = appdsp->layerId;
+ prc->attr.subwin[tn].x =
+ sysconf->display[appdsp->displayId].zone[appdsp->zoneId].x;
+ prc->attr.subwin[tn].y =
+ sysconf->display[appdsp->displayId].zone[appdsp->zoneId].y;
+ prc->attr.subwin[tn].w =
+ sysconf->display[appdsp->displayId].zone[appdsp->zoneId].width;
+ prc->attr.subwin[tn].h =
+ sysconf->display[appdsp->displayId].zone[appdsp->zoneId].height;
+ }
+ }
+ }
+ }
+
+ gIco_Uxf_Api_Mng.Mng_MyProcess
+ = ico_uxf_mng_process(gIco_Uxf_Api_Mng.MyProcess, 0);
+ if (!gIco_Uxf_Api_Mng.Mng_MyProcess) {
+ uifw_error("ico_uxf_init: Leave(ESRCH), Unknown Apprication(%s)",
+ gIco_Uxf_Api_Mng.MyProcess);
+ return ICO_UXF_ESRCH;
+ }
+ gIco_Uxf_Api_Mng.Mng_MyProcess->attr.internalid = getpid();
+ gIco_Uxf_Api_Mng.Mng_MyProcess->attr.status = ICO_UXF_PROCSTATUS_RUN;
+
+ dsp = ico_uxf_mng_display(gIco_Uxf_Api_Mng.Mng_MyProcess->attr.mainwin.display, 0);
+
+ uifw_trace("ico_uxf_init: App.%d MainDisplay.%d %08x",
+ gIco_Uxf_Api_Mng.Mng_MyProcess->attr.process,
+ gIco_Uxf_Api_Mng.Mng_MyProcess->attr.mainwin.display, dsp);
+
+ for (ret = 0; ret < (5000/50); ret++) {
+ gIco_Uxf_Api_Mng.Wayland_Display = wl_display_connect(NULL);
+ if (gIco_Uxf_Api_Mng.Wayland_Display) break;
+ usleep(50*1000);
+ }
+
+ gIco_Uxf_Api_Mng.Wayland_Registry
+ = wl_display_get_registry(gIco_Uxf_Api_Mng.Wayland_Display);
+ wl_registry_add_listener(gIco_Uxf_Api_Mng.Wayland_Registry,
+ &ico_uxf_registry_listener, (void *)0);
+
+ for (ret = 0; ret < (500/20); ret++) {
+ if ((gIco_Uxf_Api_Mng.Wayland_WindowMgr != NULL) &&
+ (gIco_Uxf_Api_Mng.Wayland_exInput != NULL) &&
+ (gIco_Uxf_Api_Mng.Wayland_InputMgr != NULL)) break;
+ uifw_trace("ico_uxf_init: call wl_display_dispatch(%08x)",
+ (int)gIco_Uxf_Api_Mng.Wayland_Display);
+ wl_display_dispatch(gIco_Uxf_Api_Mng.Wayland_Display);
+ usleep(20*1000);
+ }
+ wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
+ uifw_trace("ico_uxf_init: Wayland/Weston connect OK");
+
+ gIco_Uxf_Api_Mng.WaylandFd
+ = wl_display_get_fd(gIco_Uxf_Api_Mng.Wayland_Display);
+
+ /* initialize mutex */
+ (void) pthread_mutexattr_init(&sMutexAttr);
+ if (pthread_mutex_init(&sMutex, &sMutexAttr) != 0) {
+ uifw_error("ico_uxf_init: Leave(ENOSYS), Mutex Create Error %d", errno);
+ wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
+ gIco_Uxf_Api_Mng.Wayland_Display = NULL;
+ gIco_Uxf_Api_Mng.Initialized = 0;
+ return ICO_UXF_ENOSYS;
+ }
+
+ /* allocate free control blocks */
+ freecb = ico_uxf_alloc_callback();
+ ico_uxf_free_callback(freecb);
+ freeeq = ico_uxf_alloc_eventque();
+ ico_uxf_free_eventque(freeeq);
+
+ /* flush wayland connection */
+ ico_window_mgr_set_eventcb(gIco_Uxf_Api_Mng.Wayland_WindowMgr, 1);
+ wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
+
+ /* application die callback from AppCore(aul) */
+ aul_listen_app_dead_signal(ico_uxf_aul_deadcb, NULL);
+
+ gIco_Uxf_Api_Mng.Initialized = 1;
+
+ uifw_trace("ico_uxf_init: Leave(EOK)");
+ uifw_logflush();
+
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_wl_display_fd: get wayland file discriptor
+ *
+ * @param none
+ * @return wayland connect socket file descriptor
+ * @retval >=0 success(file descriptor)
+ * @retval < 0 error(wayland not connect)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_wl_display_fd(void)
+{
+ uifw_trace("ico_uxf_wl_display_fd: fd=%d", gIco_Uxf_Api_Mng.WaylandFd);
+
+ return gIco_Uxf_Api_Mng.WaylandFd;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_shutdown: terminate user interface library hor HomeScreen
+ *
+ * @param none
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_EBUSY error(cullentry terminating)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_shutdown(void)
+{
+ uifw_trace("ico_uxf_shutdown: Enter");
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ if (gIco_Uxf_Api_Mng.Initialized < 0) {
+ uifw_warn("ico_uxf_shutdown: Leave(EBUSY)");
+ return ICO_UXF_EBUSY;
+ }
+ uifw_trace("ico_uxf_shutdown: Leave(EOK)");
+ return ICO_UXF_EOK;
+ }
+ gIco_Uxf_Api_Mng.Initialized = -1;
+ gIco_Uxf_Api_Mng.LastEvent = 0;
+
+ (void) pthread_mutex_destroy(&sMutex);
+
+ if (gIco_Uxf_Api_Mng.Wayland_Seat) {
+ wl_seat_destroy(gIco_Uxf_Api_Mng.Wayland_Seat);
+ gIco_Uxf_Api_Mng.Wayland_Seat = NULL;
+ }
+ if (gIco_Uxf_Api_Mng.Wayland_exInput) {
+ ico_exinput_destroy(gIco_Uxf_Api_Mng.Wayland_exInput);
+ gIco_Uxf_Api_Mng.Wayland_exInput = NULL;
+ }
+ if (gIco_Uxf_Api_Mng.Wayland_InputMgr) {
+ ico_input_mgr_control_destroy(gIco_Uxf_Api_Mng.Wayland_InputMgr);
+ gIco_Uxf_Api_Mng.Wayland_InputMgr = NULL;
+ }
+ if (gIco_Uxf_Api_Mng.Wayland_Compositor) {
+ wl_compositor_destroy(gIco_Uxf_Api_Mng.Wayland_Compositor);
+ gIco_Uxf_Api_Mng.Wayland_Compositor = NULL;
+ }
+ if (gIco_Uxf_Api_Mng.Wayland_Display) {
+ wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
+ wl_display_disconnect(gIco_Uxf_Api_Mng.Wayland_Display);
+ gIco_Uxf_Api_Mng.Wayland_Display = NULL;
+ }
+
+ gIco_Uxf_Api_Mng.Initialized = 0;
+
+ uifw_trace("ico_uxf_shutdown: Leave(EOK)");
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_main_loop_iterate: process user interface library events
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API void
+ico_uxf_main_loop_iterate(void)
+{
+ int arg;
+ Ico_Uxf_Mng_EventQue *wkque;
+ Ico_Uxf_Mng_Callback *callback;
+ Ico_Uxf_Event_Cb func;
+
+ wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
+
+ arg = 0;
+ if (ioctl(gIco_Uxf_Api_Mng.WaylandFd, FIONREAD, &arg) < 0) {
+ uifw_warn("ico_uxf_main_loop_iterate: ioclt(FIONREAD,) Error %d", errno);
+ arg = 0;
+ }
+
+ if (arg > 0) {
+ wl_display_dispatch(gIco_Uxf_Api_Mng.Wayland_Display);
+ }
+
+ ico_uxf_enter_critical();
+
+ /* notify event */
+ while (gIco_Uxf_Api_Mng.EventQue) {
+
+ wkque = gIco_Uxf_Api_Mng.EventQue;
+ gIco_Uxf_Api_Mng.EventQue = gIco_Uxf_Api_Mng.EventQue->next;
+
+ gIco_Uxf_Api_Mng.LastEvent = wkque->detail.event;
+ callback = gIco_Uxf_Api_Mng.Callback;
+ while (callback) {
+ if (callback->eventmask & gIco_Uxf_Api_Mng.LastEvent) {
+ func = callback->func;
+ arg = callback->arg;
+ ico_uxf_leave_critical();
+
+ uifw_trace("ico_uxf_main_loop: Call Event Callback(%08x,,%08x)",
+ gIco_Uxf_Api_Mng.LastEvent, arg);
+ (*func)(gIco_Uxf_Api_Mng.LastEvent, wkque->detail, arg);
+
+ ico_uxf_enter_critical();
+ }
+ callback = callback->next;
+ }
+ ico_uxf_free_eventque(wkque);
+ }
+
+ ico_uxf_leave_critical();
+
+ wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_callback_set: set event calback function
+ *
+ * @param[in] mask event mask
+ * @param[in] func callback function
+ * @param[in] arg user argument
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ESRCH error(user interface library not initialized)
+ * @retval ICO_UXF_EINVAL error(illegal event mask)
+ * @retval ICO_UXF_EBUSY error(already set same event)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_callback_set(const unsigned int mask, Ico_Uxf_Event_Cb func, const int arg)
+{
+ Ico_Uxf_Mng_Callback *callback;
+ unsigned int wkmask;
+
+ uifw_trace("ico_uxf_callback_set: Enter(%08x,%08x,%08x)", mask, (int)func, arg);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_callback_set: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ if (mask) {
+ wkmask = mask;
+ }
+ else {
+ wkmask = ICO_UXF_EVENT_ALL;
+ }
+ if ((wkmask & ICO_UXF_EVENT_VALIDALL) == 0) {
+ uifw_warn("ico_uxf_callback_set: Leave(EINVAL)");
+ return ICO_UXF_EINVAL;
+ }
+
+ ico_uxf_enter_critical();
+
+ callback = gIco_Uxf_Api_Mng.Callback;
+ while (callback) {
+ if ((callback->eventmask == wkmask) && (callback->func == func) &&
+ (callback->arg == arg)) {
+
+ ico_uxf_leave_critical();
+ uifw_warn("ico_uxf_callback_set: Leave(EBUSY)");
+ return ICO_UXF_EBUSY;
+ }
+ }
+
+ callback = ico_uxf_alloc_callback();
+
+ callback->eventmask = wkmask;
+ callback->func = func;
+ callback->arg = arg;
+
+ ico_uxf_regist_callback(callback);
+
+ gIco_Uxf_Api_Mng.EventMask |= wkmask;
+
+ ico_uxf_leave_critical();
+
+ uifw_trace("ico_uxf_callback_set: Leave(EOK)");
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_callback_remove: remove event calback function
+ *
+ * @param[in] mask event mask
+ * @param[in] func callback function
+ * @param[in] arg user argument
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ESRCH error(user interface library not initialized)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_callback_remove(const unsigned int mask, Ico_Uxf_Event_Cb func, const int arg)
+{
+ Ico_Uxf_Mng_Callback *callback;
+ unsigned int wkmask;
+
+ uifw_trace("ico_uxf_callback_remove: Enter(%08x,%08x,%08x)", mask, (int)func, arg);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_callback_remove: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ if (mask) {
+ wkmask = mask;
+ }
+ else {
+ wkmask = ICO_UXF_EVENT_ALL;
+ }
+
+ ico_uxf_enter_critical();
+
+ gIco_Uxf_Api_Mng.EventMask = 0;
+
+ callback = gIco_Uxf_Api_Mng.Callback;
+
+ while (callback) {
+ if ((callback->eventmask == wkmask) && (callback->func == func) &&
+ (callback->arg == arg)) {
+ ico_uxf_remove_callback(callback);
+ }
+ else {
+ gIco_Uxf_Api_Mng.EventMask |= callback->eventmask;
+ }
+ callback = callback->next;
+ }
+
+ ico_uxf_leave_critical();
+
+ uifw_trace("ico_uxf_callback_remove: Leave(EOK)");
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_free_procwin: free active window management table(internal function)
+ *
+ * @param[in] prc application management table address
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+ico_uxf_free_procwin(Ico_Uxf_Mng_Process *prc)
+{
+ Ico_Uxf_Mng_Window *p;
+ Ico_Uxf_Mng_Window *pp;
+ Ico_Uxf_Mng_Window *freep;
+ int hash;
+
+ uifw_trace("ico_uxf_free_procwin: Enter(%d)", prc->attr.process);
+
+ for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++) {
+ p = gIco_Uxf_Api_Mng.Hash_WindowId[hash];
+ pp = (Ico_Uxf_Mng_Window *)0;
+ while (p) {
+ if (p->attr.process == prc->attr.process) {
+ freep = p;
+ p = p->nextidhash;
+ if (! pp) {
+ gIco_Uxf_Api_Mng.Hash_WindowId[hash] = p;
+ }
+ else {
+ pp->nextidhash = p;
+ }
+ uifw_trace("ico_uxf_free_procwin: Free Window(%08x)", freep->attr.window);
+ free(freep);
+ }
+ else {
+ pp = p;
+ p = p->nextidhash;
+ }
+ }
+ }
+ uifw_trace("ico_uxf_free_procwin: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_wayland_globalcb: wayland global callback(static function)
+ *
+ * @param[in] data user data(unused)
+ * @param[in] registry wayland registry
+ * @param[in] name wayland display Id(unused)
+ * @param[in] interface wayland interface name
+ * @param[in] version wayland interface version number(unused)
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ico_uxf_wayland_globalcb(void *data, struct wl_registry *registry,
+ uint32_t name, const char *interface, uint32_t version)
+{
+ uifw_trace("ico_uxf_wayland_globalcb: Enter(Event=%s DispId=%08x)", interface, name);
+
+ if (strcmp(interface, "ico_window_mgr") == 0) {
+ gIco_Uxf_Api_Mng.Wayland_WindowMgr = (struct ico_window_mgr *)
+ wl_registry_bind(registry, name, &ico_window_mgr_interface, 1);
+ ico_window_mgr_add_listener(gIco_Uxf_Api_Mng.Wayland_WindowMgr,
+ &windowlistener, NULL);
+ ico_window_mgr_set_user(gIco_Uxf_Api_Mng.Wayland_WindowMgr,
+ getpid(), gIco_Uxf_Api_Mng.MyProcess);
+ }
+ else if (strcmp(interface, "ico_exinput") == 0) {
+ /* regist exinput */
+ gIco_Uxf_Api_Mng.Wayland_exInput = (struct ico_exinput *)
+ wl_registry_bind(registry, name, &ico_exinput_interface, 1);
+ ico_exinput_add_listener(gIco_Uxf_Api_Mng.Wayland_exInput, &exinputlistener, NULL);
+ }
+ else if (strcmp(interface, "ico_input_mgr_control") == 0) {
+ /* regist Multi Input Manager interface */
+ gIco_Uxf_Api_Mng.Wayland_InputMgr = (struct ico_input_mgr_control *)
+ wl_registry_bind(registry, name, &ico_input_mgr_control_interface, 1);
+ }
+ else if (strcmp(interface, "wl_output") == 0) {
+ /* regist wl_output listener to get display info */
+ gIco_Uxf_Api_Mng.Wayland_Output = (struct wl_output *)
+ wl_registry_bind(registry, name, &wl_output_interface, 1);
+ wl_output_add_listener(gIco_Uxf_Api_Mng.Wayland_Output, &outputlistener, NULL);
+ }
+ wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
+ uifw_trace("ico_uxf_wayland_globalcb: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_output_geometrycb: wayland display attribute callback(static function)
+ *
+ * @param[in] data user data(unused)
+ * @param[in] wl_output wayland wl_output interface
+ * @param[in] x display upper-left X coodinate
+ * @param[in] y display upper-left Y coodinate
+ * @param[in] physical_width display physical width
+ * @param[in] physical_height display physical height
+ * @param[in] subpixel display sub pixcel
+ * @param[in] make display maker
+ * @param[in] model diaplay model
+ * @param[in] transform transform
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ico_uxf_output_geometrycb(void *data, struct wl_output *wl_output, int32_t x, int32_t y,
+ int32_t physical_width, int32_t physical_height, int32_t subpixel,
+ const char *make, const char *model, int32_t transform)
+{
+ Ico_Uxf_Mng_Display *dsp;
+
+ uifw_trace("ico_uxf_output_geometrycb: Enter(x/y=%d/%d, pwidth/height=%d/%d, trans=%d)",
+ x, y, physical_width, physical_height, transform);
+
+ dsp = ico_uxf_mng_display(gIco_Uxf_Api_Mng.Mng_MyProcess->attr.mainwin.display, 0);
+
+ if (dsp) {
+ if ((transform == WL_OUTPUT_TRANSFORM_90)
+ || (transform == WL_OUTPUT_TRANSFORM_270)
+ || (transform == WL_OUTPUT_TRANSFORM_FLIPPED_90)
+ || (transform == WL_OUTPUT_TRANSFORM_FLIPPED_270)) {
+ dsp->attr.pWidth = physical_height;
+ dsp->attr.pHeight = physical_width;
+ dsp->attr.orientation = ICO_UXF_ORIENTATION_VERTICAL;
+ }
+ else {
+ dsp->attr.pWidth = physical_width;
+ dsp->attr.pHeight = physical_height;
+ dsp->attr.orientation = ICO_UXF_ORIENTATION_HORIZONTAL;
+ }
+ }
+ uifw_trace("ico_uxf_output_geometrycb: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_output_modecb: wayland display mode callback(static function)
+ *
+ * @param[in] data user data(unused)
+ * @param[in] wl_output wayland wl_output interface
+ * @param[in] flags flags
+ * @param[in] width display width
+ * @param[in] height display height
+ * @param[in] refresh display refresh rate
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ico_uxf_output_modecb(void *data, struct wl_output *wl_output, uint32_t flags,
+ int32_t width, int32_t height, int32_t refresh)
+{
+ Ico_Uxf_Mng_Display *dsp;
+
+ uifw_trace("ico_uxf_output_modecb: Enter(flg=%d, width=%d, height=%d, ref=%d)",
+ flags, width, height, refresh);
+
+ dsp = ico_uxf_mng_display(gIco_Uxf_Api_Mng.Mng_MyProcess->attr.mainwin.display, 0);
+
+ if (dsp && (flags & WL_OUTPUT_MODE_CURRENT)) {
+ if (dsp->attr.orientation == ICO_UXF_ORIENTATION_VERTICAL) {
+ dsp->attr.pWidth = height;
+ dsp->attr.pHeight = width;
+ }
+ else {
+ dsp->attr.pWidth = width;
+ dsp->attr.pHeight = height;
+ }
+ }
+ uifw_trace("ico_uxf_output_modecb: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_createdcb: wayland surface create callback(static function)
+ *
+ * @param[in] data user data(unused)
+ * @param[in] ico_window_mgr wayland ico_window_mgr plugin interface
+ * @param[in] surfaceid ico_window_mgr surface Id
+ * @param[in] pid wayland client process Id
+ * @param[in] appid wayland client application Id
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ico_uxf_window_createdcb(void *data, struct ico_window_mgr *ico_window_mgr,
+ uint32_t surfaceid, int32_t pid, const char *appid)
+{
+ Ico_Uxf_Mng_Process *prc;
+ Ico_Uxf_Mng_ProcWin *ppwin;
+ Ico_Uxf_Mng_ProcWin *ppw;
+
+ uifw_trace("ico_uxf_window_createdcb: Enter(surf=%08x pid=%d appid=%s myapp=%s)",
+ (int)surfaceid, pid, appid, gIco_Uxf_Api_Mng.MyProcess);
+
+ prc = ico_uxf_mng_process(appid, 0);
+
+ if (prc) {
+ if (prc->attr.mainwin.window <= 0) {
+ uifw_trace("ico_uxf_window_createdcb: Set Main Window, Config Data");
+ prc->attr.mainwin.window = surfaceid;
+ ico_uxf_window_configurecb(data, ico_window_mgr, surfaceid, appid,
+ prc->attr.mainwin.layer, prc->attr.mainwin.x,
+ prc->attr.mainwin.y, prc->attr.mainwin.w,
+ prc->attr.mainwin.h, 0);
+ if (gIco_Uxf_Api_Mng.Hook_Window) {
+ (*gIco_Uxf_Api_Mng.Hook_Window)(prc->attr.process, surfaceid,
+ ICO_UXF_HOOK_WINDOW_CREATE_MAIN);
+ }
+ }
+ else {
+ uifw_trace("ico_uxf_window_createdcb: Sub Window, Dummy Data");
+ ico_uxf_window_configurecb(data, ico_window_mgr, surfaceid, appid,
+ prc->attr.mainwin.layer, 16384, 16384, 1, 1, 0);
+ ppwin = (Ico_Uxf_Mng_ProcWin *)malloc(sizeof(Ico_Uxf_Mng_ProcWin));
+ if (ppwin) {
+ memset(ppwin, 0, sizeof(Ico_Uxf_Mng_ProcWin));
+ ppwin->attr.window = surfaceid;
+ ppwin->attr.display = prc->attr.mainwin.display;
+ if (!prc->procwin) {
+ prc->procwin = ppwin;
+ }
+ else {
+ ppw = prc->procwin;
+ while (ppw->next) {
+ ppw = ppw->next;
+ }
+ ppw->next = ppwin;
+ }
+ }
+ if (gIco_Uxf_Api_Mng.Hook_Window) {
+ (*gIco_Uxf_Api_Mng.Hook_Window)(prc->attr.process, surfaceid,
+ ICO_UXF_HOOK_WINDOW_CREATE_SUB);
+ }
+ }
+ }
+ else {
+ uifw_warn("ico_uxf_window_createdcb: Application.%s dose not exist", appid);
+ }
+ uifw_trace("ico_uxf_window_createdcb: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_destroyedcb: wayland surface destroy callback(static function)
+ *
+ * @param[in] data user data(unused)
+ * @param[in] ico_window_mgr wayland ico_window_mgr plugin interface
+ * @param[in] surfaceid ico_window_mgr surface Id
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ico_uxf_window_destroyedcb(void *data, struct ico_window_mgr *ico_window_mgr,
+ uint32_t surfaceid)
+{
+ Ico_Uxf_Mng_Window *p;
+ Ico_Uxf_Mng_Window *pp;
+ Ico_Uxf_Mng_Window *freep;
+ Ico_Uxf_Mng_Process *prc;
+ Ico_Uxf_Mng_EventQue *que;
+ int hash;
+ char wkappid[ICO_UXF_MAX_PROCESS_NAME+1];
+ int wksubwindow;
+
+ uifw_trace("ico_uxf_window_destroyedcb: Enter(surf=%08x)", (int)surfaceid);
+
+ ico_uxf_enter_critical();
+
+ p = ico_uxf_mng_window(surfaceid, 0);
+
+ if (! p) {
+ ico_uxf_leave_critical();
+ uifw_trace("ico_uxf_window_destroyedcb: Leave(Surface=%08x dose not exist)",
+ (int)surfaceid);
+ return;
+ }
+ prc = p->mng_process;
+ if ((prc != NULL) && (prc->attr.mainwin.window == (int)surfaceid)) {
+ prc->attr.mainwin.window = 0;
+ }
+
+ strcpy(wkappid, p->attr.process);
+ wksubwindow = p->attr.subwindow;
+
+ if ((gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_DESTORYWINDOW) &&
+ (p->attr.eventmask & ICO_UXF_EVENT_DESTORYWINDOW)) {
+
+ que = ico_uxf_alloc_eventque();
+ que->detail.event = ICO_UXF_EVENT_DESTORYWINDOW;
+ que->detail.window.display = p->attr.display;
+ que->detail.window.window = surfaceid;
+ que->detail.window.layer = p->attr.layer;
+ que->detail.window.x = p->attr.x;
+ que->detail.window.y = p->attr.y;
+ que->detail.window.w = p->attr.w;
+ que->detail.window.h = p->attr.h;
+ que->detail.window.visible = p->attr.visible;
+ que->detail.window.raise = p->attr.raise;
+ que->detail.window.active = p->attr.active;
+ ico_uxf_regist_eventque(que);
+ }
+
+ for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++) {
+ p = gIco_Uxf_Api_Mng.Hash_WindowId[hash];
+ pp = (Ico_Uxf_Mng_Window *)0;
+ while (p) {
+ if (p->attr.window == (int)surfaceid) {
+ freep = p;
+ p = p->nextidhash;
+ if (! pp) {
+ gIco_Uxf_Api_Mng.Hash_WindowId[hash] = p;
+ }
+ else {
+ pp->nextidhash = p;
+ }
+ uifw_trace("ico_uxf_window_destroyedcb: Free Window.%08x(%08x)",
+ (int)freep, freep->attr.window);
+ free(freep);
+ hash = ICO_UXF_MISC_HASHSIZE;
+ break;
+ }
+ pp = p;
+ p = p->nextidhash;
+ }
+ }
+ ico_uxf_leave_critical();
+
+ if (gIco_Uxf_Api_Mng.Hook_Window) {
+ (*gIco_Uxf_Api_Mng.Hook_Window)(wkappid, surfaceid,
+ wksubwindow ? ICO_UXF_HOOK_WINDOW_DESTORY_SUB :
+ ICO_UXF_HOOK_WINDOW_DESTORY_MAIN);
+ }
+ uifw_trace("ico_uxf_window_destroyedcb: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_visiblecb: wayland surface visible callback(static function)
+ *
+ * @param[in] data user data(unused)
+ * @param[in] ico_window_mgr wayland ico_window_mgr plugin interface
+ * @param[in] surfaceid ico_window_mgr surface Id
+ * @param[in] visibility surface visible(1=visible/0=unvisible/9=nochange)
+ * @param[in] raise surface raise(1=raise/0=lower/9=nochange)
+ * @param[in] hint client request(1=client request(not changed)/0=changed)
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ico_uxf_window_visiblecb(void *data, struct ico_window_mgr *ico_window_mgr,
+ uint32_t surfaceid, int32_t visible, int32_t raise, int32_t hint)
+{
+ Ico_Uxf_Mng_Window *win;
+ Ico_Uxf_Mng_EventQue *que;
+ int ovisible;
+ int oraise;
+
+ uifw_trace("ico_uxf_window_visiblecb: Enter(surf=%08x vis=%d raise=%d hint=%d)",
+ (int)surfaceid, visible, raise, hint);
+
+ ico_uxf_enter_critical();
+
+ win = ico_uxf_mng_window(surfaceid, 0);
+
+ if (!win) {
+ ico_uxf_leave_critical();
+ uifw_trace("ico_uxf_window_visiblecb: Leave(Surface=%08x dose not exist)",
+ (int)surfaceid);
+ return;
+ }
+
+ ovisible = visible;
+ oraise = raise;
+ if (ovisible == 9) {
+ ovisible = win->attr.visible;
+ }
+ if (oraise == 9) {
+ oraise = win->attr.raise;
+ }
+
+ if ((win->attr.visible != ovisible) ||
+ (win->attr.raise != oraise)) {
+
+ if (((hint == 0) && (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_VISIBLE) &&
+ (win->attr.eventmask & ICO_UXF_EVENT_VISIBLE)) ||
+ ((hint != 0) && (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_VISIBLE_REQ) &&
+ (win->attr.eventmask & ICO_UXF_EVENT_VISIBLE_REQ))) {
+
+ que = ico_uxf_alloc_eventque();
+ que->detail.event =
+ (hint == 0) ? ICO_UXF_EVENT_VISIBLE : ICO_UXF_EVENT_VISIBLE_REQ;
+ que->detail.window.display = win->attr.display;
+ que->detail.window.window = win->attr.window;
+ que->detail.window.layer = win->attr.layer;
+ que->detail.window.x = win->attr.x;
+ que->detail.window.y = win->attr.y;
+ que->detail.window.w = win->attr.w;
+ que->detail.window.h = win->attr.h;
+ que->detail.window.visible = ovisible;
+ que->detail.window.raise = oraise;
+ que->detail.window.active = win->attr.active;
+
+ ico_uxf_regist_eventque(que);
+ }
+ }
+ ico_uxf_leave_critical();
+ uifw_trace("ico_uxf_window_visiblecb: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_configurecb: wayland surface configure callback(static function)
+ *
+ * @param[in] data user data(unused)
+ * @param[in] ico_window_mgr wayland ico_window_mgr plugin interface
+ * @param[in] surfaceid ico_window_mgr surface Id
+ * @param[in] appid client application Id
+ * @param[in] x surface upper-left X coodinate
+ * @param[in] y surface upper-left Y coodinate
+ * @param[in] width surface width
+ * @param[in] height surface height
+ * @param[in] hint client request(1=client request(not changed)/0=changed)
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ico_uxf_window_configurecb(void *data, struct ico_window_mgr *ico_window_mgr,
+ uint32_t surfaceid, const char *appid, int32_t layer,
+ int32_t x, int32_t y, int32_t width, int32_t height,
+ int32_t hint)
+{
+ Ico_Uxf_Mng_Window *win;
+ Ico_Uxf_Mng_EventQue *que;
+ int display;
+ Ico_Uxf_Mng_Process *prc;
+
+ uifw_trace("ico_uxf_window_configurecb: Enter(surf=%08x app=%s layer=%d "
+ "x/y=%d/%d w/h=%d/%d hint=%d)",
+ (int)surfaceid, appid, layer, x, y, width, height, hint);
+
+ ico_uxf_enter_critical();
+
+ win = ico_uxf_mng_window(surfaceid, 0);
+
+ if (!win) {
+ win = ico_uxf_mng_window(surfaceid, 1);
+ display = ICO_UXF_GETDISPLAYID(surfaceid);
+ win->mng_display = ico_uxf_mng_display(display, 0);
+ win->mng_layer = ico_uxf_mng_layer(display, layer, 0);
+ win->attr.eventmask = ICO_UXF_EVENT_NEWWINDOW;
+ win->attr.display = display;
+ win->attr.layer = layer;
+ memset(win->attr.process, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
+ strncpy(win->attr.process, appid, ICO_UXF_MAX_PROCESS_NAME);
+ win->attr.x = x;
+ win->attr.y = y;
+ win->attr.w = width;
+ win->attr.h = height;
+ hint = 0;
+
+ prc = ico_uxf_mng_process(appid, 0);
+ if ((prc != NULL) && (prc->attr.mainwin.window != (int)surfaceid)) {
+ /* sub-window */
+ win->attr.subwindow = 1;
+ }
+
+ if (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_NEWWINDOW) {
+
+ que = ico_uxf_alloc_eventque();
+
+ que->detail.event = ICO_UXF_EVENT_NEWWINDOW;
+ que->detail.window.display = display;
+ que->detail.window.window = surfaceid;
+ que->detail.window.layer = layer;
+ que->detail.window.x = win->attr.x;
+ que->detail.window.y = win->attr.y;
+ que->detail.window.w = win->attr.w;
+ que->detail.window.h = win->attr.h;
+ que->detail.window.visible = win->attr.visible;
+ que->detail.window.raise = win->attr.raise;
+ que->detail.window.active = win->attr.active;
+
+ ico_uxf_regist_eventque(que);
+ }
+ }
+ else {
+ if ((win->attr.layer != layer) ||
+ (win->attr.x != x) || (win->attr.y != y) ||
+ (win->attr.w != width) || (win->attr.h != height)) {
+
+ if (((hint == 0) && (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_RESIZE) &&
+ (win->attr.eventmask & ICO_UXF_EVENT_RESIZE)) ||
+ ((hint != 0) && (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_RESIZE_REQ) &&
+ (win->attr.eventmask & ICO_UXF_EVENT_RESIZE_REQ))) {
+
+ que = ico_uxf_alloc_eventque();
+
+ que->detail.event =
+ (hint == 0) ? ICO_UXF_EVENT_RESIZE : ICO_UXF_EVENT_RESIZE_REQ;
+ que->detail.window.display = win->mng_display->attr.display;
+ que->detail.window.window = win->attr.window;
+ que->detail.window.layer = layer;
+ que->detail.window.x = x;
+ que->detail.window.y = y;
+ que->detail.window.w = width;
+ que->detail.window.h = height;
+ que->detail.window.visible = win->attr.visible;
+ que->detail.window.raise = win->attr.raise;
+ que->detail.window.active = win->attr.active;
+
+ ico_uxf_regist_eventque(que);
+ }
+ win->attr.x = x;
+ win->attr.y = y;
+ win->attr.w = width;
+ win->attr.h = height;
+ if (win->attr.layer != layer) {
+ win->attr.layer = layer;
+ win->mng_layer = ico_uxf_mng_layer(win->mng_display->attr.display,
+ layer, 0);
+ }
+ }
+ }
+ ico_uxf_leave_critical();
+ uifw_trace("ico_uxf_window_configurecb: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_activecb: wayland surface active callback(static function)
+ *
+ * @param[in] data user data(unused)
+ * @param[in] ico_window_mgr wayland ico_window_mgr plugin interface
+ * @param[in] surfaceid ico_window_mgr surface Id
+ * @param[in] active surface active(1=active/0=not active)
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ico_uxf_window_activecb(void *data, struct ico_window_mgr *ico_window_mgr,
+ uint32_t surfaceid, uint32_t active)
+{
+ Ico_Uxf_Mng_Window *win;
+ Ico_Uxf_Mng_EventQue *que;
+
+ uifw_trace("ico_uxf_window_activecb: Enter(surf=%08x active=%d)", surfaceid, active);
+
+ ico_uxf_enter_critical();
+
+ win = ico_uxf_mng_window(surfaceid, 0);
+
+ if (win) {
+ if (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_ACTIVEWINDOW) {
+
+ que = ico_uxf_alloc_eventque();
+
+ que->detail.event = ICO_UXF_EVENT_ACTIVEWINDOW;
+ que->detail.window.display = ICO_UXF_GETDISPLAYID(surfaceid);
+ que->detail.window.window = surfaceid;
+ que->detail.window.active = active;
+ win->attr.active = active;
+
+ ico_uxf_regist_eventque(que);
+ }
+ }
+ ico_uxf_leave_critical();
+ uifw_trace("ico_uxf_window_activecb: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_input_capabilitiescb: wayland extended input
+ * input capabilities callback(static function)
+ *
+ * @param[in] data user data(unused)
+ * @param[in] ico_exinput wayland ico_input_mgr plugin interface
+ * @param[in] device input device name
+ * @param[in] type input device type
+ * @param[in] swname input switch name
+ * @param[in] input input switch number
+ * @param[in] codename input code name
+ * @param[in] code input code value
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ico_uxf_input_capabilitiescb(void *data, struct ico_exinput *ico_exinput,
+ const char *device, int32_t type, const char *swname,
+ int32_t input, const char *codename, int32_t code)
+{
+ int i, j;
+ Ico_Uxf_Sys_Config *sysconf = (Ico_Uxf_Sys_Config *)ico_uxf_getSysConfig();
+ Ico_Uxf_InputDev *inputdev;
+ Ico_Uxf_InputDev *bpdev;
+ Ico_Uxf_InputSw *inputsw;
+ Ico_Uxf_InputSw *bpsw;
+
+ uifw_trace("ico_uxf_input_capabilitiescb: "
+ "Enter(device=%s type=%d sw=%s input=%d code=%s[%d])",
+ device, type, swname, input, codename, code);
+
+ if (! sysconf) return;
+
+ /* search and create input device table */
+ bpdev = NULL;
+ inputdev = gIco_Uxf_Api_Mng.InputDev;
+ while (inputdev) {
+ if (strcasecmp(inputdev->device, device) == 0) break;
+ bpdev = inputdev;
+ inputdev = inputdev->next;
+ }
+ if (! inputdev) {
+ inputdev = malloc(sizeof(Ico_Uxf_InputDev));
+ if (! inputdev) {
+ uifw_error("ico_uxf_input_capabilitiescb: Leave(No Memory)");
+ return;
+ }
+ memset(inputdev, 0, sizeof(Ico_Uxf_InputDev));
+
+ if (bpdev) {
+ bpdev->next = inputdev;
+ }
+ else {
+ gIco_Uxf_Api_Mng.InputDev = inputdev;
+ }
+ }
+ strncpy(inputdev->device, device, sizeof(inputdev->device)-1);
+ inputdev->type = type;
+
+ bpsw = NULL;
+ inputsw = inputdev->inputSw;
+ while (inputsw) {
+ if (strcasecmp(inputsw->swname, swname) == 0) break;
+ bpsw = inputsw;
+ inputsw = inputsw->next;
+ }
+ if (! inputsw) {
+ inputsw = malloc(sizeof(Ico_Uxf_InputSw));
+ if (! inputsw) {
+ uifw_error("ico_uxf_input_capabilitiescb: Leave(No Memory)");
+ return;
+ }
+ if (bpsw) {
+ bpsw->next = inputsw;
+ }
+ else {
+ inputdev->inputSw = inputsw;
+ }
+ inputdev->numInputSw ++;
+ }
+ memset(inputsw, 0, sizeof(Ico_Uxf_InputSw));
+ strncpy(inputsw->swname, swname, sizeof(inputsw->swname)-1);
+ inputsw->input = input;
+ inputsw->numCode = 1;
+ inputsw->inputCode[0].code = code;
+ strncpy(inputsw->inputCode[0].codename, codename,
+ sizeof(inputsw->inputCode[0].codename)-1);
+ uifw_trace("ico_uxf_input_capabilitiescb: create new inputsw");
+
+ /* send fixed application if fixed switch */
+ for (i = 0; i < sysconf->inputdevNum; i++) {
+ if (strcasecmp(sysconf->inputdev[i].name, inputdev->device) != 0) continue;
+
+ for (j = 0; j < sysconf->inputdev[i].inputswNum; j++) {
+ if (! sysconf->inputdev[i].inputsw[j].appid) continue;
+ if (strcasecmp(sysconf->inputdev[i].inputsw[j].name,
+ inputsw->swname) != 0) continue;
+
+ uifw_trace("ico_uxf_input_capabilitiescb: input %s.%s = %s",
+ inputdev->device, inputsw->swname,
+ sysconf->inputdev[i].inputsw[j].appid);
+ ico_input_mgr_control_add_input_app(gIco_Uxf_Api_Mng.Wayland_InputMgr,
+ sysconf->inputdev[i].inputsw[j].appid,
+ inputdev->device, inputsw->input, 1);
+ inputsw->fix = 1;
+ break;
+ }
+ }
+ uifw_trace("ico_uxf_input_capabilitiescb: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_input_codecb: wayland extended input
+ * input code callback(static function)
+ *
+ * @param[in] data user data(unused)
+ * @param[in] ico_exinput wayland ico_input_mgr plugin interface
+ * @param[in] device input device name
+ * @param[in] input input switch number
+ * @param[in] codename input code name
+ * @param[in] code input code value
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ico_uxf_input_codecb(void *data, struct ico_exinput *ico_exinput, const char *device,
+ int32_t input, const char *codename, int32_t code)
+{
+ int i;
+ Ico_Uxf_InputDev *inputdev;
+ Ico_Uxf_InputSw *inputsw;
+
+ uifw_trace("ico_uxf_input_codecb: device=%s input=%d code=%s[%d]",
+ device, input, codename, code);
+
+ /* search input device table */
+ inputdev = gIco_Uxf_Api_Mng.InputDev;
+ while (inputdev) {
+ if (strcasecmp(inputdev->device, device) == 0) break;
+ inputdev = inputdev->next;
+ }
+ if (! inputdev) {
+ uifw_error("ico_uxf_input_codecb: device.%s dose not exist", device);
+ return;
+ }
+
+ /* search input switch */
+ inputsw = inputdev->inputSw;
+ while (inputsw) {
+ if (inputsw->input == input) break;
+ inputsw = inputsw->next;
+ }
+ if (! inputsw) {
+ uifw_error("ico_uxf_input_codecb: device.%s input=%d dose not exist",
+ device, input);
+ return;
+ }
+ for (i = 0; i < inputsw->numCode; i++) {
+ if (inputsw->inputCode[i].code == code) break;
+ }
+ if (i >= inputsw->numCode) {
+ if (i >= 8) {
+ uifw_error("ico_uxf_input_codecb: device.%s input=%d number of codes overflow",
+ device, input);
+ return;
+ }
+ inputsw->numCode ++;
+ i = inputsw->numCode - 1;
+ }
+ memset(inputsw->inputCode[i].codename, 0, sizeof(inputsw->inputCode[i].codename));
+ strncpy(inputsw->inputCode[i].codename, codename,
+ sizeof(inputsw->inputCode[i].codename)-1);
+ inputsw->inputCode[i].code = code;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_input_inputcb: wayland extended input
+ * input switch callback(static function)
+ *
+ * @param[in] data user data(unused)
+ * @param[in] ico_exinput wayland ico_input_mgr plugin interface
+ * @param[in] time input time(miri-sec)
+ * @param[in] device input device name
+ * @param[in] input input switch number
+ * @param[in] code input code value
+ * @param[in] state input state(1=switch On/0=switch Off)
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ico_uxf_input_inputcb(void *data, struct ico_exinput *ico_exinput, uint32_t time,
+ const char *device, int32_t input, int32_t code, int32_t state)
+{
+ Ico_Uxf_Mng_EventQue *que;
+ uifw_trace("ico_uxf_input_inputcb: device=%s input=%d code=%d state=%d",
+ device, input, code, state);
+
+ if (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_EXINPUT) {
+
+ ico_uxf_enter_critical();
+ que = ico_uxf_alloc_eventque();
+
+ strncpy(que->detail.exinput.device, device,
+ sizeof(que->detail.exinput.device)-1);
+ que->detail.exinput.input = input;
+ que->detail.exinput.code = code;
+ que->detail.exinput.state = state;
+
+ ico_uxf_regist_eventque(que);
+ ico_uxf_leave_critical();
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_aul_deadcb: AppCore(AUL) application dead callback(static function)
+ *
+ * @param[in] pid dead application process Id
+ * @param[in] data user data(unused)
+ * @return result(always 0, means success)
+ */
+/*--------------------------------------------------------------------------*/
+static int
+ico_uxf_aul_deadcb(int pid, void *data)
+{
+ Ico_Uxf_Mng_Process *proc;
+ int hash;
+ Ico_Uxf_Mng_EventQue *que;
+
+ uifw_trace("ico_uxf_aul_deadcb: Enter(pid=%d)", pid);
+
+ for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++) {
+ proc = gIco_Uxf_Api_Mng.Hash_ProcessId[hash];
+ while (proc) {
+ if (proc->attr.internalid == pid) break;
+ proc = proc->nextidhash;
+ }
+ if (proc) break;
+ }
+ if (! proc) {
+ /* not handle process, */
+ /* or the process is correctly terminated by ico_uxf_process_terminate */
+ uifw_trace("ico_uxf_aul_deadcb: Leave(not find)");
+ return 0;
+ }
+ uifw_trace("ico_uxf_aul_deadcb: find(appid=%s)", proc->attr.process);
+
+ ico_uxf_enter_critical();
+ /* set event */
+ que = ico_uxf_alloc_eventque();
+ que->detail.event = ICO_UXF_EVENT_TERMPROCESS;
+ strncpy(que->detail.process.process, proc->attr.process, ICO_UXF_MAX_PROCESS_NAME);
+ que->detail.process.status = ICO_UXF_PROCSTATUS_STOP;
+
+ /* delete process info */
+ proc->attr.status = ICO_UXF_PROCSTATUS_STOP;
+ proc->attr.internalid = -1;
+ proc->attr.mainwin.window = 0;
+ ico_uxf_free_procwin(proc);
+
+ /* notify event */
+ ico_uxf_regist_eventque(que);
+
+ ico_uxf_leave_critical();
+
+ uifw_trace("ico_uxf_aul_deadcb: Leave");
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_enter_critical: enter critical section(internal function)
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+ico_uxf_enter_critical(void)
+{
+ if (pthread_mutex_lock(&sMutex)) {
+ uifw_error("ico_uxf_enter_critical: Error<%d>", errno);
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_leave_critical: leave critical section(internal function)
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+ico_uxf_leave_critical(void)
+{
+ if (pthread_mutex_unlock(&sMutex)) {
+ uifw_error("ico_uxf_leave_critical: Error<%d>", errno);
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_alloc_callback: allocate callback management table(internal function)
+ *
+ * @param none
+ * @return allocated callback management table address
+ */
+/*--------------------------------------------------------------------------*/
+Ico_Uxf_Mng_Callback *
+ico_uxf_alloc_callback(void)
+{
+ Ico_Uxf_Mng_Callback *p;
+ int idx;
+
+ p = gIco_Uxf_Api_Mng.CallbackFree;
+ if (! p) {
+ p = (Ico_Uxf_Mng_Callback *)malloc(sizeof(Ico_Uxf_Mng_Callback) *
+ ICO_UXF_MNG_BLOCK_ALLOCS);
+ if (! p) {
+ uifw_error("ico_uxf_alloc_callback: NO Memory (malloc Error)");
+ exit(1);
+ }
+ gIco_Uxf_Api_Mng.CallbackFree = p;
+
+ for (idx = 0; idx < ICO_UXF_MNG_BLOCK_ALLOCS; idx++, p++) {
+ if (idx != (ICO_UXF_MNG_BLOCK_ALLOCS-1)) {
+ p->next = (p+1);
+ }
+ else {
+ p->next = (struct _Ico_Uxf_Mng_Callback *)0;
+ }
+ }
+ p = gIco_Uxf_Api_Mng.CallbackFree;
+ }
+ gIco_Uxf_Api_Mng.CallbackFree = p->next;
+ return p;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_free_callback: release callback management table(internal function)
+ *
+ * @param[in] p callback management table address
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+ico_uxf_free_callback(Ico_Uxf_Mng_Callback *p)
+{
+ p->next = gIco_Uxf_Api_Mng.CallbackFree;
+ gIco_Uxf_Api_Mng.CallbackFree = p;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_regist_callback: register a callback management table(internal function)
+ *
+ * @param[in] p callback management table address
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+ico_uxf_regist_callback(Ico_Uxf_Mng_Callback *p)
+{
+ p->next = (struct _Ico_Uxf_Mng_Callback *)0;
+
+ if (gIco_Uxf_Api_Mng.Callback) {
+ gIco_Uxf_Api_Mng.CallbackLast->next = p;
+ gIco_Uxf_Api_Mng.CallbackLast = p;
+ }
+ else {
+ gIco_Uxf_Api_Mng.Callback = p;
+ gIco_Uxf_Api_Mng.CallbackLast = gIco_Uxf_Api_Mng.Callback;
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_remove_callback: remove a callback management table(internal function)
+ *
+ * @param[in] p callback management table address
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+ico_uxf_remove_callback(Ico_Uxf_Mng_Callback *p)
+{
+ Ico_Uxf_Mng_Callback *pp;
+ Ico_Uxf_Mng_Callback *before;
+
+ pp = gIco_Uxf_Api_Mng.Callback;
+ before = (Ico_Uxf_Mng_Callback *)0;
+
+ while (pp) {
+ if (pp == p) break;
+ before = pp;
+ pp = pp->next;
+ }
+ if (pp) {
+ if (before) {
+ before->next = p->next;
+ if (! p->next) {
+ gIco_Uxf_Api_Mng.CallbackLast = before;
+ }
+ }
+ else {
+ gIco_Uxf_Api_Mng.Callback = p->next;
+ }
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_alloc_eventque: allocate event queue block(internal function)
+ *
+ * @param none
+ * @return allocated event queue control block address
+ */
+/*--------------------------------------------------------------------------*/
+Ico_Uxf_Mng_EventQue
+*ico_uxf_alloc_eventque(void)
+{
+ Ico_Uxf_Mng_EventQue *p;
+ int idx;
+
+ p = gIco_Uxf_Api_Mng.EventQueFree;
+ if (! p) {
+ p = (Ico_Uxf_Mng_EventQue *)
+ malloc(sizeof(Ico_Uxf_Mng_EventQue) * ICO_UXF_MNG_BLOCK_ALLOCS);
+ if (! p) {
+ uifw_error("ico_uxf_alloc_eventque: NO Memory (malloc Error)");
+ exit(1);
+ }
+ gIco_Uxf_Api_Mng.EventQueFree = p;
+
+ for (idx = 0; idx < ICO_UXF_MNG_BLOCK_ALLOCS; idx++, p++) {
+ if (idx != (ICO_UXF_MNG_BLOCK_ALLOCS-1)) {
+ p->next = (p+1);
+ }
+ else {
+ p->next = (struct _Ico_Uxf_Mng_EventQue *)0;
+ }
+ }
+ p = gIco_Uxf_Api_Mng.EventQueFree;
+ }
+ gIco_Uxf_Api_Mng.EventQueFree = p->next;
+
+ return p;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_free_eventque: release event queue block(internal function)
+ *
+ * @param[in] p event queue control block address
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+ico_uxf_free_eventque(Ico_Uxf_Mng_EventQue *p)
+{
+ p->next = gIco_Uxf_Api_Mng.EventQueFree;
+ gIco_Uxf_Api_Mng.EventQueFree = p;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_regist_eventque: register a event queue(internal function)
+ *
+ * @param[in] p event queue control block address
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+ico_uxf_regist_eventque(Ico_Uxf_Mng_EventQue *p)
+{
+ p->next = (struct _Ico_Uxf_Mng_EventQue *)0;
+
+ if (gIco_Uxf_Api_Mng.EventQue) {
+ gIco_Uxf_Api_Mng.EventQueLast->next = p;
+ gIco_Uxf_Api_Mng.EventQueLast = p;
+ }
+ else {
+ gIco_Uxf_Api_Mng.EventQue = p;
+ gIco_Uxf_Api_Mng.EventQueLast = gIco_Uxf_Api_Mng.EventQue;
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_mng_display: get display management table(internal function)
+ *
+ * @param[in] display display Id
+ * @param[in] create create flag(1=create tabell if not exist/0=not create)
+ * @return display management table address
+ * @retval !=NULL display management table address
+ * @retval ==NULL display dose not exist(parameter 'create' only 0)
+ */
+/*--------------------------------------------------------------------------*/
+Ico_Uxf_Mng_Display *
+ico_uxf_mng_display(const int display, const int create)
+{
+ Ico_Uxf_Mng_Display *p;
+ Ico_Uxf_Mng_Display *plast;
+
+ p = gIco_Uxf_Api_Mng.Mng_Display;
+ plast = (Ico_Uxf_Mng_Display *)0;
+ while (p) {
+ if (p->attr.display == display) break;
+ plast = p;
+ p = p->next;
+ }
+
+ if ((! p) && (create != 0)) {
+
+ p = (Ico_Uxf_Mng_Display *) malloc(sizeof(Ico_Uxf_Mng_Display));
+ if (! p) {
+ uifw_error("ico_uxf_mng_display: NO Memory (malloc Error)");
+ exit(1);
+ }
+ memset((char *)p, 0, sizeof(Ico_Uxf_Mng_Display));
+ p->attr.display = display;
+ if (plast) {
+ plast->next = p;
+ }
+ else {
+ gIco_Uxf_Api_Mng.Mng_Display = p;
+ }
+ }
+ return p;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_mng_layer: get layer management table(internal function)
+ *
+ * @param[in] display display Id
+ * @param[in] layer layer Id
+ * @param[in] create create flag(1=create tabell if not exist/0=not create)
+ * @return layer management table address
+ * @retval !=NULL layer management table address
+ * @retval ==NULL layer dose not exist(parameter 'create' only 0)
+ */
+/*--------------------------------------------------------------------------*/
+Ico_Uxf_Mng_Layer *
+ico_uxf_mng_layer(const int display, const int layer, const int create)
+{
+ Ico_Uxf_Mng_Layer *p;
+ Ico_Uxf_Mng_Layer *plast;
+
+ p = gIco_Uxf_Api_Mng.Mng_Layer;
+ plast = (Ico_Uxf_Mng_Layer *)0;
+ while (p) {
+ if ((p->attr.display == display) &&
+ (p->attr.layer == layer)) break;
+ plast = p;
+ p = p->next;
+ }
+
+ if ((! p) && (create != 0)) {
+
+ p = (Ico_Uxf_Mng_Layer *) malloc(sizeof(Ico_Uxf_Mng_Layer));
+ if (! p) {
+ uifw_error("ico_uxf_mng_layer: NO Memory (malloc Error)");
+ exit(1);
+ }
+ memset((char *)p, 0, sizeof(Ico_Uxf_Mng_Layer));
+ p->attr.layer = layer;
+ if (plast) {
+ plast->next = p;
+ }
+ else {
+ gIco_Uxf_Api_Mng.Mng_Layer = p;
+ }
+ }
+ return p;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_mng_window: get window management table(internal function)
+ *
+ * @param[in] window window Id(same as ico_window_mgr surface Id)
+ * @param[in] create create flag(1=create tabell if not exist/0=not create)
+ * @return window management table address
+ * @retval !=NULL window management table address
+ * @retval ==NULL window dose not exist(parameter 'create' only 0)
+ */
+/*--------------------------------------------------------------------------*/
+Ico_Uxf_Mng_Window *
+ico_uxf_mng_window(const int window, const int create)
+{
+ Ico_Uxf_Mng_Window *p;
+ Ico_Uxf_Mng_Window *plast = (Ico_Uxf_Mng_Window *)0;
+ int hash;
+
+ hash = ICO_UXF_MISC_HASHBYID(window);
+ p = gIco_Uxf_Api_Mng.Hash_WindowId[hash];
+ while (p) {
+ if (p->attr.window == window) break;
+ plast = p;
+ p = p->nextidhash;
+ }
+
+ if ((! p) && (create != 0)) {
+
+ p = (Ico_Uxf_Mng_Window *) malloc(sizeof(Ico_Uxf_Mng_Window));
+ if (! p) {
+ uifw_error("ico_uxf_mng_window: NO Memory (malloc Error)");
+ exit(1);
+ }
+ memset((char *)p, 0, sizeof(Ico_Uxf_Mng_Window));
+ p->attr.window = window;
+ if (plast) {
+ plast->nextidhash = p;
+ }
+ else {
+ gIco_Uxf_Api_Mng.Hash_WindowId[hash] = p;
+ }
+ uifw_trace("ico_uxf_mng_window: Create New Table=%08x", (int)p);
+ }
+ return p;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_mng_process: get process management table(internal function)
+ *
+ * @param[in] process application Id
+ * @param[in] create create flag(1=create tabell if not exist/0=not create)
+ * @return process management table address
+ * @retval !=NULL process management table address
+ * @retval ==NULL process dose not exist(parameter 'create' only 0)
+ */
+/*--------------------------------------------------------------------------*/
+Ico_Uxf_Mng_Process *
+ico_uxf_mng_process(const char *process, const int create)
+{
+ Ico_Uxf_Mng_Process *p;
+ Ico_Uxf_Mng_Process *plast = (Ico_Uxf_Mng_Process *)0;
+ int hash;
+
+ hash = ICO_UXF_MISC_HASHBYNAME(process);
+ uifw_trace("ico_uxf_mng_process: find(hash=%d)", hash);
+ p = gIco_Uxf_Api_Mng.Hash_ProcessId[hash];
+ while (p) {
+ if(strncmp(p->attr.process, process, ICO_UXF_MAX_PROCESS_NAME) == 0) break;
+ plast = p;
+ p = p->nextidhash;
+ }
+
+ if ((! p) && (create != 0)) {
+
+ p = (Ico_Uxf_Mng_Process *) malloc(sizeof(Ico_Uxf_Mng_Process));
+ if (! p) {
+ uifw_error("ico_uxf_mng_process: NO Memory (malloc Error)");
+ exit(1);
+ }
+ memset((char *)p, 0, sizeof(Ico_Uxf_Mng_Process));
+ strncpy(p->attr.process, process, ICO_UXF_MAX_PROCESS_NAME);
+ uifw_trace("ico_uxf_mng_process: create table(hash=%d, proc=%s)", hash, process);
+ if (plast) {
+ plast->nextidhash = p;
+ }
+ else {
+ gIco_Uxf_Api_Mng.Hash_ProcessId[hash] = p;
+ }
+ }
+ return p;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_screen_size_get: get display physical size
+ *
+ * @param[out] width variable to receive the width of the display
+ * @param[out] height variable to receive the height of the display
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API void
+ico_uxf_window_screen_size_get(int *width, int *height)
+{
+ Ico_Uxf_Mng_Display *dsp;
+ dsp = ico_uxf_mng_display(gIco_Uxf_Api_Mng.Mng_MyProcess->attr.mainwin.display, 0);
+
+ uifw_trace("ico_uxf_window_screen_size_get: Enter(dsp=%d(%d))",
+ dsp, gIco_Uxf_Api_Mng.Mng_MyProcess->attr.mainwin.display);
+
+ if ((dsp != NULL) && (width != NULL) && (height != NULL)) {
+ uifw_trace("ico_uxf_window_screen_size_get: %dx%d",
+ dsp->attr.pWidth, dsp->attr.pHeight);
+ *width = dsp->attr.pWidth;
+ *height = dsp->attr.pHeight;
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_hook: set window create/destroy hook function
+ *
+ * @param[in] func window create/destroy hook function
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API void
+ico_uxf_window_hook(Ico_Uxf_Hook func)
+{
+ uifw_trace("ico_uxf_window_hook: Window Control Hook=%08x", (int)func);
+
+ gIco_Uxf_Api_Mng.Hook_Window = func;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief heade for input device
+ *
+ * @date Feb-28-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include "ico_uxf.h"
+#include "ico_uxf_private.h"
+#include "ico_input_mgr-client-protocol.h"
+
+extern Ico_Uxf_Api_Mng gIco_Uxf_Api_Mng;
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_inputdev_attribute_get: get input device attribute
+ *
+ * @param[in] devidx input device index (0-)
+ * @return result
+ * @retval !=NULL success(input device attribute address)
+ * @retval ==NULL error(device dose not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API Ico_Uxf_InputDev *
+ico_uxf_inputdev_attribute_get(const int devidx)
+{
+ Ico_Uxf_InputDev *pdev;
+ int idx;
+
+ uifw_trace("ico_uxf_inputdev_attribute_get: Enter(%d)", devidx);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_window_layer: Leave(ESRCH)");
+ return NULL;
+ }
+
+ pdev = gIco_Uxf_Api_Mng.InputDev;
+ idx = 0;
+ while ((pdev != NULL) && (idx < devidx)) {
+ idx ++;
+ pdev = pdev->next;
+ }
+
+ if ((pdev == NULL) || (idx != devidx)) {
+ uifw_trace("ico_uxf_inputdev_attribute_get: Leave(ENOENT)");
+ return NULL;
+ }
+
+ uifw_trace("ico_uxf_inputdev_attribute_get: Leave(EOK, device=%s)", pdev->device);
+ return pdev;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_inputsw_attribute_get: get input switch attribute
+ *
+ * @param[in] inputdev input device attribute
+ * @param[in] swidx input switch index (0-)
+ * @return result
+ * @retval !=NULL success(input switch attribute address)
+ * @retval ==NULL error(device dose not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API Ico_Uxf_InputSw *
+ico_uxf_inputsw_attribute_get(Ico_Uxf_InputDev *inputdev, const int swidx)
+{
+ Ico_Uxf_InputSw *psw;
+ int idx;
+
+ uifw_trace("ico_uxf_inputsw_attribute_get: Enter(%s,%d)",
+ inputdev ? inputdev->device : "(NULL)", swidx);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_inputsw_attribute_get: Leave(ESRCH)");
+ return NULL;
+ }
+ if ((inputdev == NULL) || (swidx < 0) || (swidx >= inputdev->numInputSw)) {
+ uifw_warn("ico_uxf_inputsw_attribute_get: Leave(device ENOENT)");
+ return NULL;
+ }
+
+ psw = inputdev->inputSw;
+ idx = 0;
+ while ((psw != NULL) && (idx < swidx)) {
+ idx ++;
+ psw = psw->next;
+ }
+
+ if ((psw == NULL) || (idx != swidx)) {
+ uifw_warn("ico_uxf_inputsw_attribute_get: Leave(switch ENOENT)");
+ return NULL;
+ }
+
+ uifw_trace("ico_uxf_inputsw_attribute_get: Leave(EOK, switch=%s.%s)",
+ inputdev->device, psw->swname);
+ return psw;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Send request to Multi Input Manager
+ *
+ * @param[in] add switch add(=1)/delete(=0)
+ * @param[in] appid target application id
+ * @param[in] device target input device name
+ * @param[in] input target input switch number
+ * @return result status
+ * @retval ICO_UXF_EOK success(cullentry always success)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_input_control(const int add, const char *appid, const char *device, const int input)
+{
+ apfw_trace("ico_uxf_input_control: input switch %s %s %s.%d",
+ add ? "add" : "del", appid ? appid : "all-app",
+ device ? device : "all-device", input);
+
+ if (add) {
+ ico_input_mgr_control_add_input_app(gIco_Uxf_Api_Mng.Wayland_InputMgr, appid,
+ device, input, 0);
+ }
+ else {
+ ico_input_mgr_control_del_input_app(gIco_Uxf_Api_Mng.Wayland_InputMgr, appid,
+ device, input);
+ }
+ return ICO_UXF_EOK;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief user experience library for HomeScreen
+ *
+ * @date Feb-28-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include "wayland-client.h"
+#include "wayland-util.h"
+#include "ico_uxf.h" /* UX-FW open definition header */
+#include "ico_uxf_private.h" /* UX-FW inner definition header */
+#include "ico_uxf_conf.h"
+
+/* valiable & table */
+/* UX-FW API inner management table */
+extern Ico_Uxf_Api_Mng gIco_Uxf_Api_Mng;
+
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_process_execute: launch a program
+ *
+ * @param[in] name program name
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_ENOENT error(does not exist)
+ * @retval ICO_UXF_EBUSY error(already launch)
+ * @retval ICO_UXF_EPERM error(no authority)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_process_execute(const char *name)
+{
+ Ico_Uxf_Mng_Process *proc; /* process management table */
+ int hash;
+ bundle *appBundle = NULL;
+ Ico_Uxf_conf_application *apptbl = NULL;
+
+ uifw_trace("ico_uxf_process_execute: Enter(%s)", name);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_process_execute: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++) {
+ proc = gIco_Uxf_Api_Mng.Hash_ProcessId[hash];
+ while (proc) {
+ uifw_trace("ico_uxf_process_execute: PROC(%s)", proc->attr.process);
+ if (strcasecmp(proc->attr.process, name) == 0) break;
+ proc = proc->nextidhash;
+ }
+ if (proc) break;
+ }
+
+ if (! proc) {
+ uifw_warn("ico_uxf_process_execute: Leave(ENOENT)");
+ return ICO_UXF_ENOENT;
+ }
+
+ ico_uxf_enter_critical(); /* enter critical section */
+
+ if (proc->attr.status != ICO_UXF_PROCSTATUS_STOP) {
+ ico_uxf_leave_critical(); /* leave critical section */
+ uifw_warn("ico_uxf_process_execute: Leave(EBUSY)");
+ return ICO_UXF_EBUSY;
+ }
+
+ /* in order to avoid double execute, status set starting */
+ proc->attr.status = ICO_UXF_PROCSTATUS_INIT;
+ ico_uxf_leave_critical(); /* leave critical section */
+
+ /* setup option */
+ appBundle = bundle_create();
+ apptbl = (Ico_Uxf_conf_application *)ico_uxf_getAppByAppid(name);
+ if ((appBundle != NULL) && (apptbl != NULL)) {
+ char *opt = strdup(apptbl->exec);
+ char *str = strtok(opt, " ");
+ while (str != NULL) {
+ str = strtok(NULL, " ");
+ if (str != NULL) {
+ bundle_add(appBundle, str, "Application");
+ uifw_trace("ico_uxf_process_execute: option(%s)", str);
+ }
+ }
+ free(opt);
+ }
+
+ /* execute program */
+ proc->attr.internalid = aul_launch_app(name ,appBundle);
+ if (proc->attr.internalid < 0) {
+ uifw_error("ico_uxf_process_execute: Leave(ENOSYS), Launch App Error(%d)",
+ proc->attr.internalid);
+ return ICO_UXF_ENOSYS;
+ }
+
+ proc->attr.status = ICO_UXF_PROCSTATUS_RUN;
+
+ uifw_trace("ico_uxf_process_execute: Leave(%s)", proc->attr.process);
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_process_terminate: finish a program
+ *
+ * @param[in] process process id
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_ENOENT error(does not exist)
+ * @retval ICO_UXF_EAGAIN error(already launch)
+ * @retval ICO_UXF_EPERM error(no authority)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_process_terminate(const char *process)
+{
+ Ico_Uxf_Mng_Process *proc; /* process management table */
+ int ret; /* process management table */
+
+ uifw_trace("ico_uxf_process_terminate: Enter(%s)", process);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_process_terminate: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ /* target is other process */
+ proc = ico_uxf_mng_process(process, 0);
+ if (! proc) {
+ uifw_warn("ico_uxf_process_terminate: Leave(ENOENT)");
+ return ICO_UXF_ENOENT;
+ }
+
+ ret = aul_terminate_pid(proc->attr.internalid);
+ if (ret < 0) {
+ uifw_warn("ico_uxf_process_terminate: Leave(ENOSYS) cannot terminate pid=%d",
+ proc->attr.internalid);
+ return ICO_UXF_ENOSYS;
+ }
+
+ proc->attr.status = ICO_UXF_PROCSTATUS_STOP;
+ proc->attr.internalid = -1;
+ proc->attr.mainwin.window = 0;
+ ico_uxf_free_procwin(proc);
+
+ uifw_trace("ico_uxf_process_terminate: Leave(EOK)");
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_process_attribute_get: get a process's current state
+ *
+ * @param[in] process process's identity
+ * @param[out] attr target process's current state
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_ENOENT error(does not exist)
+ * @retval ICO_UXF_EPERM error(no authority)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_process_attribute_get(const char *process, Ico_Uxf_ProcessAttr *attr)
+{
+ Ico_Uxf_Mng_Process *proc; /* process management table */
+
+ uifw_trace("ico_uxf_process_attribute_get: Enter(%s)", process);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_process_attribute_get: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ proc = ico_uxf_mng_process(process, 0);
+ if (! proc) {
+ uifw_warn("ico_uxf_process_attribute_get: Leave(ENOENT)");
+ return ICO_UXF_ENOENT;
+ }
+
+ memcpy((char *)attr, (char *)&(proc->attr), sizeof(Ico_Uxf_ProcessAttr));
+
+ uifw_trace("ico_uxf_process_attribute_get: Leave(EOK)");
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_process_is_active: get application activity
+ *
+ * @param[in] process process's identity
+ * @return result
+ * @retval 1 process is active
+ * @retval 0 process is not active
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_process_is_active(const char *process)
+{
+ Ico_Uxf_Mng_Process *proc; /* process management table */
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_process_is_active: False(ESRCH)");
+ return 0;
+ }
+
+ proc = ico_uxf_mng_process(process, 0);
+ if (! proc) {
+ uifw_warn("ico_uxf_process_is_active: False(ENOENT)");
+ return 0;
+ }
+
+ uifw_trace("ico_uxf_process_is_active: %s is %s",
+ process, proc->attr.active ? "Active" : "Inactive");
+ return proc->attr.active;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_process_window_get: get a window defined by the process
+ *
+ * @param[in] process process identity
+ * @param[out] attr return a window definition
+ * First is main window of the process,
+ * second henceforth is sub window of the process.
+ * At present support only main window.
+ * @param[in] num number of window definition(= array size)
+ * @return result
+ * @retval >= 0 success(number of windows)
+ * @retval ICO_UXF_E2BIG The number of the process has exceeded num
+ * The attribute of the process up to a num piece is returned to attr
+ * @retval ICO_UXF_ENOENT error(does not exist)
+ * @retval ICO_UXF_EINVAL error(num is 0 or less)
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_EPERM error(no authority)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_process_window_get(const char *process, Ico_Uxf_ProcessWin *attr, const int num)
+{
+ Ico_Uxf_Mng_Process *proc; /* process management table */
+ Ico_Uxf_Mng_ProcWin *pwin; /* Process possession window table */
+ int n; /* number of window */
+
+ uifw_trace("ico_uxf_process_window_get: Enter(%s,,%d)", process, num);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_process_window_get: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ if (num <= 0) {
+ uifw_warn("ico_uxf_process_window_get: Leave(EINVAL)");
+ return ICO_UXF_EINVAL;
+ }
+
+ proc = ico_uxf_mng_process(process, 0);
+ if (! proc) {
+ uifw_trace("ico_uxf_process_window_get: Leave(ENOENT)");
+ return ICO_UXF_ENOENT;
+ }
+
+ memcpy((char *)&(attr[0]), (char *)&(proc->attr.mainwin), sizeof(Ico_Uxf_ProcessWin));
+
+ pwin = proc->procwin;
+ for (n = 1; n < num; n++) {
+ if (! pwin) break;
+ memcpy((char *)&(attr[n]), (char *)&(pwin->attr), sizeof(Ico_Uxf_ProcessWin));
+ pwin = pwin->next;
+ }
+
+ if (pwin) {
+ n = ICO_UXF_E2BIG;
+ uifw_trace("ico_uxf_process_window_get: Leave(E2BIG)");
+ }
+ else {
+ uifw_trace("ico_uxf_process_window_get: Leave(%d)", n);
+ }
+ return n;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_process_window_get_one: get a window defined by the process
+ *
+ * @param[in] process process identity(appid)
+ * @param[out] attr return a window definition
+ * @param[in] winidx window index(0 is main window, 1-N is sub window)
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ENOENT error(does not exist)
+ * @retval ICO_UXF_EINVAL error(winidx is negative)
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_EPERM error(no authority)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_process_window_get_one(const char *process,
+ Ico_Uxf_ProcessWin *attr, const int winidx)
+{
+ Ico_Uxf_Mng_Process *proc; /* process management table */
+ Ico_Uxf_Mng_ProcWin *pwin; /* Process possession window table */
+ int n; /* number of window */
+
+ uifw_trace("ico_uxf_process_window_get_one: Enter(%s,,%d)", process, winidx);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_process_window_get_one: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ if (winidx < 0) {
+ uifw_warn("ico_uxf_process_window_get_one: Leave(EINVAL)");
+ return ICO_UXF_EINVAL;
+ }
+
+ proc = ico_uxf_mng_process(process, 0);
+ if (! proc) {
+ uifw_warn("ico_uxf_process_window_get_one: Leave(ENOENT, no appid)");
+ return ICO_UXF_ENOENT;
+ }
+ if (winidx >= proc->attr.numwindows) {
+ uifw_warn("ico_uxf_process_window_get_one: Leave(ENOENT, winidx over)");
+ return ICO_UXF_ENOENT;
+ }
+
+ if (winidx == 0) {
+ memcpy(attr, &proc->attr.mainwin, sizeof(Ico_Uxf_ProcessWin));
+ }
+ else {
+ pwin = proc->procwin;
+ for (n = 1; n < winidx; n++) {
+ if (! pwin) {
+ uifw_warn("ico_uxf_process_window_get_one: Leave(ENOENT, winidx over)");
+ return ICO_UXF_ENOENT;
+ }
+ pwin = pwin->next;
+ }
+ memcpy(attr, &pwin->attr, sizeof(Ico_Uxf_ProcessWin));
+ }
+ uifw_trace("ico_uxf_process_window_get_one: Leave(EOK)");
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_process_query_processes: get all process current status
+ *
+ * @param[out] attr process's current status
+ * @return result
+ * @retval >= 0 success(number of process)
+ * @retval ICO_UXF_E2BIG The number of the process has exceeded num
+ * The attribute of the process up to a num piece is returned to attr
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_EINVAL error(num is 0 or less)
+ * @retval ICO_UXF_EPERM error(no authority)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_process_query_processes(Ico_Uxf_ProcessAttr attr[], const int num)
+{
+ int n; /* number of process */
+ Ico_Uxf_Mng_Process *mng; /* process management table */
+ int hash;
+
+ uifw_trace("ico_uxf_process_query_processes: Enter(,%d)", num);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_process_query_processes: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ if (num <= 0) {
+ uifw_warn("ico_uxf_process_query_processes: Leave(EINVAL)");
+ return ICO_UXF_EINVAL;
+ }
+
+ n = 0;
+ for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++) {
+ mng = gIco_Uxf_Api_Mng.Hash_ProcessId[hash];
+ while (mng) {
+ if (n >= num) break;
+ memcpy((char *)(&attr[n]), (char *)&(mng->attr), sizeof(Ico_Uxf_ProcessAttr));
+ n ++;
+ mng = mng->nextidhash;
+ }
+ if (mng) break;
+ }
+
+ if (mng) {
+ n = ICO_UXF_E2BIG;
+ uifw_trace("ico_uxf_process_query_processes: Leave(E2BIG)");
+ }
+ else {
+ uifw_trace("ico_uxf_process_query_processes: Leave(%d)", n);
+ }
+ return n;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief user experience library internal header
+ *
+ * @date Feb-28-2013
+ */
+
+#ifndef _ICO_UXF_INTERNAL_H_
+#define _ICO_UXF_INTERNAL_H_
+
+#include <wayland-client.h> /* Wayland client library */
+#include <wayland-egl.h> /* Wayland EGL library */
+#include <wayland-util.h> /* Wayland Misc library */
+#include <aul/aul.h> /* AppCore */
+
+#include "ico_uxf_sysdef.h" /* UX-FW System convention value */
+#include "ico_uxf_def.h" /* UX-FW definition value */
+#include "ico_apf_log.h" /* wide use log definition */
+#include "ico_apf_apimacro.h"
+
+#include "ico_input_mgr-client-protocol.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* macro */
+ /* get DisplayId from SurfaceId */
+#define ICO_UXF_GETDISPLAYID(surfaceid) \
+ ((surfaceid >> 20) & 0x0fff)
+
+/* define struct */
+/* struct management callback function */
+typedef struct _Ico_Uxf_Mng_Callback {
+ struct _Ico_Uxf_Mng_Callback *next; /* next callback struct */
+ unsigned int eventmask; /* notify event mask */
+ Ico_Uxf_Event_Cb func; /* callback function address */
+ int arg; /* function's argument */
+} Ico_Uxf_Mng_Callback;
+
+/* struct management event queue */
+typedef struct _Ico_Uxf_Mng_EventQue {
+ struct _Ico_Uxf_Mng_EventQue *next; /* next event queue struct */
+ Ico_Uxf_EventDetail detail; /* event detail */
+} Ico_Uxf_Mng_EventQue;
+
+/* struct management window which proccess owns */
+typedef struct _Ico_Uxf_Mng_ProcWin {
+ struct _Ico_Uxf_Mng_ProcWin *next; /* next window */
+ Ico_Uxf_ProcessWin attr; /* window configuration */
+} Ico_Uxf_Mng_ProcWin;
+
+/* struct management proccess */
+typedef struct _Ico_Uxf_Mng_Process {
+ struct _Ico_Uxf_Mng_Process *nextidhash;/* next process of the same id and hash */
+ Ico_Uxf_Mng_ProcWin *procwin; /* process's subwindow */
+ void *exttable; /* extended table */
+ Ico_Uxf_ProcessAttr attr; /* process configuration */
+} Ico_Uxf_Mng_Process;
+
+/* struct management display */
+typedef struct _Ico_Uxf_Mng_Display {
+ struct _Ico_Uxf_Mng_Display *next; /* next display */
+ Ico_Uxf_DisplayAttr attr; /* display configuration */
+} Ico_Uxf_Mng_Display;
+
+/* struct management layer */
+typedef struct _Ico_Uxf_Mng_Layer {
+ struct _Ico_Uxf_Mng_Layer *next; /* next layer */
+ Ico_Uxf_Mng_Display *mng_display; /* display local cache */
+ Ico_Uxf_LayerAttr attr; /* layer attribute */
+} Ico_Uxf_Mng_Layer;
+
+#define ICO_UXF_RESREQ_CLIENT 1 /* Request from client */
+#define ICO_UXF_RESREQ_AUTO 2 /* Automatic request */
+#define ICO_UXF_RESSTAT_NONE 0 /* Resource status: None */
+#define ICO_UXF_RESSTAT_ACQUIRED 1 /* Resource status: Acruired */
+#define ICO_UXF_RESSTAT_DEPRIVED 2 /* Resource status: Deprived */
+
+typedef struct _Ico_Uxf_Mng_Window {
+ struct _Ico_Uxf_Mng_Window *nextidhash;/* next window of the same id and hash */
+ Ico_Uxf_Mng_Display *mng_display; /* display local cache */
+ Ico_Uxf_Mng_Layer *mng_layer; /* layer local cache */
+ Ico_Uxf_Mng_Process *mng_process; /* process local cache */
+ struct _Ico_Uxf_Mng_Window *mng_parent; /* parent window */
+ short state; /* Window status */
+ unsigned char request; /* Request */
+ unsigned char timecount; /* Time counter */
+ Ico_Uxf_WindowAttr attr; /* window attribute */
+} Ico_Uxf_Mng_Window;
+
+/* struct management listener added by user */
+typedef struct _Ico_Uxf_Mng_EventListener {
+ struct _Ico_Uxf_Mng_EventListener *next;/* next table management listener function*/
+ void (*func)(void *); /* listener function address */
+ void *arg; /* listener function's argument */
+} Ico_Uxf_Mng_EventListener;
+
+/* struct management UX-FW API */
+typedef struct _Ico_Uxf_Api_Mng {
+ /* variable */
+ int Initialized; /* initialized flag */
+ int EventMask; /* receive event */
+ unsigned int LastEvent; /* last receive event(end synchronization)*/
+ int AppsCtlVisible; /* Tempolary visible all windows */
+
+ /* process information myprocess */
+ char MyProcess[ICO_UXF_MAX_PROCESS_NAME+1];
+ /* process id */
+ Ico_Uxf_Mng_Process *Mng_MyProcess; /* process management table */
+ int MyMainWindow; /* main window id */
+
+ /* table management callback function */
+ Ico_Uxf_Mng_Callback *Callback; /* callback management table */
+ Ico_Uxf_Mng_Callback *CallbackLast; /* last at callback management table's */
+ Ico_Uxf_Mng_Callback *CallbackFree; /* free callback management table */
+
+ /* event queue */
+ Ico_Uxf_Mng_EventQue *EventQue; /* event queue list */
+ Ico_Uxf_Mng_EventQue *EventQueLast; /* last at event queue list */
+ Ico_Uxf_Mng_EventQue *EventQueFree; /* opening event queue */
+
+ /* table management resource */
+ Ico_Uxf_Mng_Display *Mng_Display; /* display attribute cache */
+ Ico_Uxf_Mng_Layer *Mng_Layer; /* layer attribute cache */
+ Ico_Uxf_Mng_Process *Hash_ProcessId[ICO_UXF_MISC_HASHSIZE];
+ /* process attribute table's hash */
+ Ico_Uxf_Mng_Window *Hash_WindowId[ICO_UXF_MISC_HASHSIZE];
+ /* window attribute table's hash */
+ Ico_Uxf_InputDev *InputDev; /* Input device table */
+
+ /* Wayland */
+ struct wl_display *Wayland_Display; /* Wayland's display */
+ struct wl_registry *Wayland_Registry; /* Wayland's Registry */
+ struct wl_compositor *Wayland_Compositor;/* Wayland's compositor */
+ struct wl_seat *Wayland_Seat; /* Wayland's device input event */
+ struct ico_window_mgr *Wayland_WindowMgr; /* Wayland's Window Manager PlugIn */
+ struct wl_output *Wayland_Output; /* Wayland's output describes */
+ int WaylandFd; /* Wayland's file descriptor */
+ struct ico_input_mgr_control
+ *Wayland_InputMgr; /* Input Manager PulgIn */
+ struct ico_exinput *Wayland_exInput; /* extra input event */
+
+ /* Hook routines */
+ Ico_Uxf_Hook Hook_Window; /* Window control hook */
+} Ico_Uxf_Api_Mng;
+
+/* define inner misc function */
+void ico_uxf_enter_critical(void); /* Exclusion section start */
+void ico_uxf_leave_critical(void); /* Exclusion section end */
+void ico_uxf_broadcast_signal(void); /* Dissolution of MainLoop's wait */
+Ico_Uxf_Mng_Callback *ico_uxf_alloc_callback(void);
+ /* get a callback management table */
+void ico_uxf_free_callback(Ico_Uxf_Mng_Callback *p);
+ /* free a callback management table */
+void ico_uxf_regist_callback(Ico_Uxf_Mng_Callback *p);
+ /* register callback management table */
+void ico_uxf_remove_callback(Ico_Uxf_Mng_Callback *p);
+ /* deregister callback management table */
+Ico_Uxf_Mng_EventQue *ico_uxf_alloc_eventque(void);
+ /* allocate event queue block */
+void ico_uxf_free_eventque(Ico_Uxf_Mng_EventQue *p);
+ /* free a event queue block */
+void ico_uxf_regist_eventque(Ico_Uxf_Mng_EventQue *p);
+ /* register event queue block */
+Ico_Uxf_Mng_Display *ico_uxf_mng_display(const int display, const int create);
+ /* get a display management table */
+Ico_Uxf_Mng_Layer *ico_uxf_mng_layer(const int display, const int layer,
+ const int create);
+ /* get a layer management table */
+Ico_Uxf_Mng_Window *ico_uxf_mng_window(const int window, const int create);
+ /* get a window management table */
+Ico_Uxf_Mng_Process *ico_uxf_mng_process(const char *process, const int create);
+ /* get a process management table */
+void ico_uxf_free_procwin(Ico_Uxf_Mng_Process *prc);
+ /* release application windows */
+int ico_uxf_gl_create_window(const int display, const int layer, const int x,
+ const int y, const int w, const int h, const int full);
+ /* create window by OpenGL ES/EGL */
+
+/* define log macros */
+#ifndef uifw_trace
+#define uifw_trace ICO_UXF_DEBUG
+#define uifw_critical ICO_UXF_CRITICAL
+#define uifw_info ICO_UXF_INFO
+#define uifw_warn ICO_UXF_WARN
+#define uifw_error ICO_UXF_ERROR
+#define uifw_logflush ico_uxf_log_flush
+#endif /*uifw_trace*/
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _ICO_UXF_INTERNAL_H_ */
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief header file of Window control for HomeScreen
+ *
+ * @date Feb-28-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include "ico_uxf.h"
+#include "ico_uxf_private.h"
+#include "ico_window_mgr-client-protocol.h"
+
+extern Ico_Uxf_Api_Mng gIco_Uxf_Api_Mng;
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_layer: Set window layer
+ *
+ * @param[in] window window Id
+ * @param[in] layer layer Id
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_ENOENT error(window or layer dose not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_window_layer(const int window, const int layer)
+{
+ Ico_Uxf_Mng_Window *winmng;
+ Ico_Uxf_Mng_Layer *layermng;
+
+ uifw_trace("ico_uxf_window_layer: Enter(%08x,%d)", window, layer);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_window_layer: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ winmng = ico_uxf_mng_window(window, 0);
+ if ((! winmng) || (! winmng->mng_display)) {
+ uifw_warn("ico_uxf_window_layer: Leave(ENOENT)");
+ return ICO_UXF_ENOENT;
+ }
+
+ layermng = ico_uxf_mng_layer(winmng->attr.display, layer, 0);
+ if ((! layermng) || (! layermng->mng_display)) {
+ uifw_warn("ico_uxf_window_layer: Leave(ENOENT)");
+ return ICO_UXF_ENOENT;
+ }
+
+ uifw_trace("ico_uxf_window_layer: ico_window_mgr_set_window_layer(%08x,%d)",
+ window, layer);
+ winmng->mng_layer = layermng;
+ ico_window_mgr_set_window_layer(gIco_Uxf_Api_Mng.Wayland_WindowMgr, window, layer);
+ wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
+
+ uifw_trace("ico_uxf_window_layer: Leave(EOK)");
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_layer_visible: Control layer visibility
+ *
+ * @param[in] display display Id
+ * @param[in] layer layer Id
+ * @param[in] visible layer show(1)/hide(0)
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_ENOENT error(layer dose not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_layer_visible(const int display, const int layer, const int visible)
+{
+ Ico_Uxf_Mng_Layer *layermng;
+
+ uifw_trace("ico_uxf_layer_visible: Enter(%d,%d,%d)", display, layer, visible);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_layer_visible: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ layermng = ico_uxf_mng_layer(display, layer, 0);
+ if ((! layermng) || (! layermng->mng_display)) {
+ uifw_warn("ico_uxf_layer_visible: Leave(ENOENT)");
+ return ICO_UXF_ENOENT;
+ }
+
+ uifw_trace("ico_uxf_layer_visible: ico_window_mgr_set_layer_visible(%d,%d)",
+ layer, visible);
+ ico_window_mgr_set_layer_visible(gIco_Uxf_Api_Mng.Wayland_WindowMgr, layer, visible);
+ wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
+
+ uifw_trace("ico_uxf_layer_visible: Leave(EOK)");
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_resize: resize window(surface) size
+ *
+ * @param[in] window window Id(same as ico_window_mgr surface Id)
+ * @param[in] w window width
+ * @param[in] h window height
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_ENOENT error(layer dose not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_window_resize(const int window, const int w, const int h)
+{
+ Ico_Uxf_Mng_Window *winmng;
+
+ uifw_trace("ico_uxf_window_resize: Enter(%08x,%d,%d)", window, w, h);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_window_resize: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ winmng = ico_uxf_mng_window(window, 0);
+ if ((! winmng) || (! winmng->mng_layer)) {
+ uifw_warn("ico_uxf_window_resize: Leave(ENOENT)");
+ return ICO_UXF_ENOENT;
+ }
+
+ uifw_trace("ico_uxf_window_resize: layer(%d,%d)",
+ winmng->mng_layer->attr.w, winmng->mng_layer->attr.h);
+ if ((w <= 0) || (w > winmng->mng_layer->attr.w) ||
+ (h <= 0) || (h > winmng->mng_layer->attr.h)) {
+ uifw_warn("ico_uxf_window_resize: Leave(EINVAL)");
+ return ICO_UXF_EINVAL;
+ }
+
+ if ((w != winmng->attr.w) || (h != winmng->attr.h)) {
+ winmng->attr.w = w;
+ winmng->attr.h = h;
+
+ ico_window_mgr_set_positionsize(gIco_Uxf_Api_Mng.Wayland_WindowMgr, window,
+ winmng->attr.x, winmng->attr.y,
+ winmng->attr.w, winmng->attr.h);
+ wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
+ }
+ uifw_trace("ico_uxf_window_resize: Leave(EOK)");
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_move: move window(surface) geometry
+ *
+ * @param[in] window window Id(same as ico_window_mgr surface Id)
+ * @param[in] x window upper-left X coodinate of display
+ * @param[in] y window upper-left Y coodinate of display
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_ENOENT error(layer dose not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_window_move(const int window, const int x, const int y)
+{
+ Ico_Uxf_Mng_Window *winmng;
+
+ uifw_trace("ico_uxf_window_move: Enter(%08x,%d,%d)", window, x, y);
+
+ if(gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_window_move: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ winmng = ico_uxf_mng_window(window, 0);
+ if ((! winmng) || (! winmng->mng_layer)) {
+ uifw_warn("ico_uxf_window_move: Leave(ENOENT)");
+ return ICO_UXF_ENOENT;
+ }
+
+ winmng->attr.x = x;
+ winmng->attr.y = y;
+
+ ico_window_mgr_set_positionsize(gIco_Uxf_Api_Mng.Wayland_WindowMgr, window,
+ winmng->attr.x, winmng->attr.y,
+ winmng->attr.w, winmng->attr.h);
+ wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
+
+ uifw_trace("ico_uxf_window_move: Leave(EOK)");
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_raise: raise window(surface)
+ *
+ * @param[in] window window Id(same as ico_window_mgr surface Id)
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_ENOENT error(layer dose not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_window_raise(const int window)
+{
+ Ico_Uxf_Mng_Window *winmng;
+
+ uifw_trace("ico_uxf_window_raise: Enter(%08x)", window);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_window_raise: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ winmng = ico_uxf_mng_window(window, 0);
+ if ((! winmng) || (! winmng->mng_display)) {
+ uifw_warn("ico_uxf_window_raise: Leave(ENOENT)");
+ return ICO_UXF_ENOENT;
+ }
+
+ uifw_trace("ico_uxf_window_raise: ico_window_mgr_set_visible(%08x,%d,%d)", window, 9, 1);
+ ico_window_mgr_set_visible(gIco_Uxf_Api_Mng.Wayland_WindowMgr, window, 9, 1);
+ wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
+
+ uifw_trace("ico_uxf_window_raise: Leave(EOK)");
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_lower: lower window(surface)
+ *
+ * @param[in] window window Id(same as ico_window_mgr surface Id)
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_ENOENT error(layer dose not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_window_lower(const int window)
+{
+ Ico_Uxf_Mng_Window *winmng;
+
+ uifw_trace("ico_uxf_window_lower: Enter(%08x)", window);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_window_lower: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ winmng = ico_uxf_mng_window(window, 0);
+ if ((! winmng) || (! winmng->mng_display)) {
+ uifw_warn("ico_uxf_window_lower: Leave(ENOENT)");
+ return ICO_UXF_ENOENT;
+ }
+
+ uifw_trace("ico_uxf_window_lower: ico_window_mgr_set_visible(%08x,%d,%d)", window, 9, 0);
+ ico_window_mgr_set_visible(gIco_Uxf_Api_Mng.Wayland_WindowMgr, window, 9, 0);
+ wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
+
+ uifw_trace("ico_uxf_window_lower: Leave(EOK)");
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_active: active window(surface)
+ *
+ * @param[in] window window Id(same as ico_window_mgr surface Id)
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_ENOENT error(layer dose not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_window_active(const int window)
+{
+ Ico_Uxf_Mng_Window *winmng;
+ Ico_Uxf_Mng_Process *proc;
+ Ico_Uxf_Mng_Process *aproc;
+ int hash;
+
+ uifw_trace("ico_uxf_window_active: Enter(%08x)", window);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_window_active: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ winmng = ico_uxf_mng_window(window, 0);
+ if ((! winmng) || (! winmng->mng_display)) {
+ uifw_warn("ico_uxf_window_active: Leave(ENOENT)");
+ return ICO_UXF_ENOENT;
+ }
+
+ uifw_trace("ico_uxf_window_active: ico_window_mgr_set_active(%08x)", window);
+ ico_window_mgr_set_active(gIco_Uxf_Api_Mng.Wayland_WindowMgr, window);
+ wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
+
+ /* reset all active window widthout target window */
+ for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++) {
+ winmng = gIco_Uxf_Api_Mng.Hash_WindowId[hash];
+ while (winmng) {
+ if (winmng->attr.window == window) {
+ winmng->attr.active = 1;
+ }
+ else {
+ winmng->attr.active = 0;
+ }
+ winmng = winmng->nextidhash;
+ }
+ }
+
+ /* reset all active application without this application */
+ aproc = NULL;
+ for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++) {
+ proc = gIco_Uxf_Api_Mng.Hash_ProcessId[hash];
+ while (proc) {
+ if (proc->attr.mainwin.window == window) {
+ aproc = proc;
+ }
+ else {
+ proc->attr.active = 0;
+ }
+ proc = proc->nextidhash;
+ }
+ }
+ aproc->attr.active = 1;
+
+ uifw_trace("ico_uxf_window_active: Leave(EOK)");
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_event_mask: set window(surface) event mask
+ *
+ * @param[in] window window Id(same as ico_window_mgr surface Id)
+ * @param[in] mask event mask
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_ENOENT error(layer dose not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_window_event_mask(const int window, const unsigned int mask)
+{
+ Ico_Uxf_Mng_Window *winmng;
+
+ uifw_trace("ico_uxf_window_event_mask: Enter(%08x,%08x)", window, mask);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_window_event_mask: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ winmng = ico_uxf_mng_window(window, 0);
+ if (! winmng) {
+ uifw_warn("ico_uxf_window_event_mask: Leave(ENOENT)");
+ return ICO_UXF_ENOENT;
+ }
+
+ winmng->attr.eventmask = mask;
+
+ uifw_trace("ico_uxf_window_event_mask: Leave(EOK)");
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_attribute_get: get window(surface) attribute
+ *
+ * @param[in] window window Id(same as ico_window_mgr surface Id)
+ * @param[out] attr window attribute
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_ENOENT error(layer dose not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_window_attribute_get(const int window, Ico_Uxf_WindowAttr *attr)
+{
+ Ico_Uxf_Mng_Window *winmng;
+
+ uifw_trace("ico_uxf_window_attribute_get: Enter(%08x)", window);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_window_attribute_get: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ winmng = ico_uxf_mng_window(window, 0);
+ if (! winmng) {
+ uifw_warn("ico_uxf_window_attribute_get: Leave(ENOENT)");
+ return ICO_UXF_ENOENT;
+ }
+
+ memcpy((char *)attr, (char *)&(winmng->attr), sizeof(Ico_Uxf_WindowAttr));
+
+ uifw_trace("ico_uxf_window_attribute_get: Leave(EOK)");
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_query_windows: get all windows attribute
+ *
+ * @param[in] display target display Id
+ * @param[out] attr window attribute array
+ * @param[in] num number of window attribute area
+ * @return result
+ * @retval >= 0 success(number of windows)
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_EINVAL error(illegal parameter 'num')
+ * @retval ICO_UXF_E2BIG error(number of windows over 'num')
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_window_query_windows(const int display, Ico_Uxf_WindowAttr attr[], const int num)
+{
+ int n;
+ Ico_Uxf_Mng_Window *winmng;
+ int hash;
+
+ uifw_trace("ico_uxf_window_query_windows: Enter(%d,,%d)", display, num);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_window_query_windows: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ if (num <= 0) {
+ uifw_warn("ico_uxf_window_query_windows: Leave(EINVAL)");
+ return ICO_UXF_EINVAL;
+ }
+
+ n = 0;
+ for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++) {
+ winmng = gIco_Uxf_Api_Mng.Hash_WindowId[hash];
+ while (winmng) {
+ if (n >= num) break;
+ memcpy((char *)(&attr[n]), (char *)&(winmng->attr), sizeof(Ico_Uxf_WindowAttr));
+ n ++;
+ winmng = winmng->nextidhash;
+ }
+ if (winmng) break;
+ }
+ if (winmng) {
+ n = ICO_UXF_E2BIG;
+ uifw_trace("ico_uxf_window_query_windows: Leave(E2BIG)");
+ }
+ else {
+ uifw_trace("ico_uxf_window_query_windows: Leave(%d)", n);
+ }
+ return n;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_control: target window control from AppsController
+ *
+ * @param[in] appid Application Id
+ * @param[in] winidx Window index
+ * @param[in] control Window control
+ * ICO_UXF_APPSCTL_INVISIBLE: Invisible by low priority
+ * ICO_UXF_APPSCTL_REGULATION: Invisible by regulation
+ * ICO_UXF_APPSCTL_TEMPVISIBLE: Visible as HomeScreen menu
+ * @param[in] onoff Flag On(1)/Off(0)
+ * ICO_UXF_APPSCTL_INVISIBLE: On(1) is invisible
+ * ICO_UXF_APPSCTL_REGULATION: On(1) is invisible
+ * ICO_UXF_APPSCTL_TEMPVISIBLE: On(1) is visible(menu)
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_ENOENT error(not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_window_control(const char *appid, const int winidx,
+ const int control, const int onoff)
+{
+#define MAX_APP_WINDOWS 20
+ Ico_Uxf_ProcessWin procattr[MAX_APP_WINDOWS];
+ int nwin;
+ Ico_Uxf_Mng_Window *winmng; /* window management table */
+ int hash;
+ int newcontrol;
+ int i;
+
+ uifw_trace("ico_uxf_window_control: Enter(%s,%d,%x,%d)",
+ appid, winidx, control, onoff);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_window_control: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ if (control == ICO_UXF_APPSCTL_TEMPVISIBLE) {
+ if (onoff != gIco_Uxf_Api_Mng.AppsCtlVisible) {
+ if (onoff > 0) gIco_Uxf_Api_Mng.AppsCtlVisible = 1;
+ else gIco_Uxf_Api_Mng.AppsCtlVisible = 0;
+
+ /* control all windows */
+ for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++) {
+ winmng = gIco_Uxf_Api_Mng.Hash_WindowId[hash];
+ while (winmng) {
+ if ((winmng->attr.window > 0) && (winmng->attr.visible)) {
+ if ((gIco_Uxf_Api_Mng.AppsCtlVisible != 0) ||
+ (winmng->attr.control == 0)) {
+ i = 1;
+ }
+ else {
+ i = 0;
+ }
+ uifw_trace("ico_uxf_window_control: ico_window_mgr_set_visible"
+ "(%08x,%d,9)", winmng->attr.window, i);
+ ico_window_mgr_set_visible(gIco_Uxf_Api_Mng.Wayland_WindowMgr,
+ winmng->attr.window, i, 9);
+ wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
+ }
+ winmng = winmng->nextidhash;
+ }
+ }
+ }
+ uifw_trace("ico_uxf_window_control: Leave(EOK)");
+ }
+ else {
+ /* get current application status */
+ if (winidx >= 0) {
+ nwin = ico_uxf_process_window_get_one(appid, procattr, winidx);
+ if (nwin == 0) nwin = 1;
+ }
+ else {
+ /* all window */
+ nwin = ico_uxf_process_window_get(appid, procattr, MAX_APP_WINDOWS);
+ }
+ if (nwin == ICO_UXF_E2BIG) nwin = MAX_APP_WINDOWS;
+ if (nwin < 0) {
+ uifw_trace("ico_uxf_window_control: Leave(Unknown appid(%s))", appid);
+ return ICO_UXF_ENOENT;
+ }
+ for (i = 0; i < nwin; i++) {
+ if (procattr[i].window == 0) continue;
+ winmng = ico_uxf_mng_window(procattr[i].window, 0);
+ if (! winmng) {
+ uifw_trace("ico_uxf_window_control: winid=%08x not exist",
+ procattr[i].window);
+ continue;
+ }
+ newcontrol = winmng->attr.control;
+ if (onoff) newcontrol |= control;
+ else newcontrol &= (~control);
+
+ uifw_trace("ico_uxf_window_control: control %08x %02x=>%02x",
+ procattr[i].window, winmng->attr.control, newcontrol);
+ if (winmng->attr.control != newcontrol) {
+ winmng->attr.control = newcontrol;
+ if (winmng->attr.visible != 0) {
+ if (gIco_Uxf_Api_Mng.AppsCtlVisible) newcontrol = 0;
+ /* request to Weston(Window Manager) */
+ uifw_trace("ico_uxf_window_control: visible(%08x,%d) to weston",
+ procattr[i].window, (newcontrol != 0) ? 0 : 1);
+ ico_window_mgr_set_visible(gIco_Uxf_Api_Mng.Wayland_WindowMgr,
+ procattr[i].window,
+ (newcontrol != 0) ? 0 : 1, 9);
+ wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
+ }
+ }
+ uifw_trace("ico_uxf_window_control: Leave(EOK) control=%x(%d) visible=%d",
+ winmng->attr.control, gIco_Uxf_Api_Mng.AppsCtlVisible,
+ winmng->attr.visible);
+ }
+ }
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_show: show a target window
+ * if target window's state is visible, do nothing and return success
+ *
+ * @param[in] window Window identity
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_ENOENT error(not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_window_show(const int window)
+{
+ Ico_Uxf_Mng_Window *winmng; /* window management table */
+
+ uifw_trace("ico_uxf_window_show: Enter(%08x)", window);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_window_show: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ winmng = ico_uxf_mng_window(window, 0);
+ if ((! winmng) || (! winmng->mng_display)) {
+ uifw_warn("ico_uxf_window_show: Leave(ENOENT)");
+ return ICO_UXF_ENOENT;
+ }
+ winmng->attr.visible = 1;
+
+ if (winmng->attr.control == 0) {
+ /* request to display to Weston(Window Manager) */
+ uifw_trace("ico_uxf_window_show: ico_window_mgr_set_visible(%08x,%d,%d)",
+ window, 1, 9);
+ ico_window_mgr_set_visible(gIco_Uxf_Api_Mng.Wayland_WindowMgr, window, 1, 9);
+ wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
+ }
+ uifw_trace("ico_uxf_window_show: Leave(EOK) control=%x", winmng->attr.control);
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_hide: hide a target window
+ * if target window's state is unvisible, do nothing and return success
+ *
+ * @param[in] window target window identity
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_ENOENT error(not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_window_hide(const int window)
+{
+ Ico_Uxf_Mng_Window *winmng; /* window management table */
+
+ uifw_trace("ico_uxf_window_hide: Enter(%08x)", window);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_window_hide: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ winmng = ico_uxf_mng_window(window, 0);
+ if ((! winmng) || (! winmng->mng_display)) {
+ uifw_warn("ico_uxf_window_hide: Leave(ENOENT)");
+ return ICO_UXF_ENOENT;
+ }
+ winmng->attr.visible = 0;
+
+ /* request to hide to Weston(Window Manager) */
+ uifw_trace("ico_uxf_window_hide: ico_window_mgr_set_visible(%08x,%d,%d)", window, 0, 9);
+ ico_window_mgr_set_visible(gIco_Uxf_Api_Mng.Wayland_WindowMgr, window, 0, 9);
+ wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
+
+ uifw_trace("ico_uxf_window_hide: Leave(EOK)");
+ return ICO_UXF_EOK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ico_uxf_window_visible_raise: control status of visible(show/hide)
+ * and order(raise/lower)
+ *
+ * @param[in] window target window identity
+ * @param[in] visible visible(1)/unvisible(0)
+ * @param[in] raise forefront(1)/maximum back(0)
+ * @return result
+ * @retval ICO_UXF_EOK success
+ * @retval ICO_UXF_ESRCH error(not initialized)
+ * @retval ICO_UXF_ENOENT error(not exist)
+ */
+/*--------------------------------------------------------------------------*/
+ICO_APF_API int
+ico_uxf_window_visible_raise(const int window, const int visible, const int raise)
+{
+ Ico_Uxf_Mng_Window *winmng; /* window management table */
+ int vis = visible;
+
+ uifw_trace("ico_uxf_window_visible_raise: Enter(%08x,%d,%d)", window, visible, raise);
+
+ if (gIco_Uxf_Api_Mng.Initialized <= 0) {
+ uifw_warn("ico_uxf_window_visible_raise: Leave(ESRCH)");
+ return ICO_UXF_ESRCH;
+ }
+
+ winmng = ico_uxf_mng_window(window, 0);
+ if ((! winmng) || (! winmng->mng_display)) {
+ uifw_warn("ico_uxf_window_visible_raise: Leave(ENOENT)");
+ return ICO_UXF_ENOENT;
+ }
+
+ if (vis == 0) {
+ winmng->attr.visible = 0;
+ }
+ else if (vis == 1) {
+ winmng->attr.visible = 1;
+ if ((winmng->attr.control != 0) && (gIco_Uxf_Api_Mng.AppsCtlVisible == 0)) {
+ uifw_trace("ico_uxf_window_visible_raise: change to hide(control=%x menu=%d",
+ winmng->attr.control, gIco_Uxf_Api_Mng.AppsCtlVisible);
+ vis = 0;
+ }
+ }
+
+ if ((vis != 9) || (raise != 9)) {
+ /* request to visible status and order status to Weston(Window Manager) */
+ uifw_trace("ico_uxf_window_visible_raise: ico_window_mgr_set_visible(%08x,%d,%d)",
+ window, vis, raise);
+ ico_window_mgr_set_visible(gIco_Uxf_Api_Mng.Wayland_WindowMgr, window, vis, raise);
+ wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
+ }
+ uifw_trace("ico_uxf_window_visible_raise: Leave(EOK)");
+ return ICO_UXF_EOK;
+}
+
--- /dev/null
+lib_LTLIBRARIES = libico-app-fw.la \
+ libico-app-fw-efl.la
+
+#include_HEADERS = \
+# ico_apf.h \
+# ico_apf_error.h \
+# ico_apf_resource_control.h \
+# ico_apf_ecore.h
+
+noinst_PROGRAMS = \
+ test_server \
+ test_client
+
+libico_app_fw_la_CFLAGS = -I../include -I/usr/include/ico-uxf-weston-plugin $(AUL_CFLAGS) @GLIB_CFLAGS@
+libico_app_fw_la_LDFLAGS = -version-info 0:5:0
+libico_app_fw_la_SOURCES = \
+ ico_syc_log.c \
+ ico_uxfw_conf_common.c \
+ ico_uxfw_conf_sys.c \
+ ico_uxfw_conf_app.c \
+ ico_uxfw_init.c \
+ ico_uxfw_launcher.c \
+ ico_uxfw_window.c \
+ ico_apf_communication.c \
+ ico_apf_resource_control.c \
+ ico_apf_appmgr.c
+
+libico_app_fw_efl_la_CFLAGS = -I../include $(EFL_CFLAGS) @GLIB_CFLAGS@
+libico_app_fw_efl_la_LDFLAGS = -version-info 0:5:0
+libico_app_fw_efl_la_SOURCES = \
+ ico_apf_ecore.c
+
+AM_CFLAGS = $(GCC_CFLAGS)
+AM_CPPFLAGS = $(GCC_CFLAGS) \
+ -DDATADIR='"$(datadir)"' \
+ -DMODULEDIR='"$(moduledir)"' \
+ -DLIBEXECDIR='"$(libexecdir)"'
+AM_LDFLAGS = -module -avoid-version -rpath $(libdir) -lwayland-egl -lEGL -lGLESv2
+
+check_PROGRAMS = test_client
+
+test_client_lib = ./.libs/libico-app-fw-efl.so ./.libs/libico-app-fw.so -lico-uxf-weston-plugin -laul
+test_server_lib = ./.libs/libico-app-fw-efl.so ./.libs/libico-app-fw.so -lico-uxf-weston-plugin -laul
+test_efl_libs = -lecore_evas -lecore -levas -lecore_wayland -lelementary
+
+test_client_SOURCE = test_client.c
+test_client_CFLAGS = -I../include $(EFL_CFLAGS) @GLIB_CFLAGS@
+test_client_LDADD = $(test_client_lib) $(test_efl_libs) -lwebsockets -lrt -lm
+
+test_server_SOURCE = test_client.c
+test_server_CFLAGS = -I../include $(EFL_CFLAGS) @GLIB_CFLAGS@
+test_server_LDADD = $(test_server_lib) $(test_efl_libs) -lwebsockets -lrt -lm
+
+.FORCE :
+
--- /dev/null
+#!/bin/sh
+
+export LD_LIBRARY_PATH=./.libs:$LD_LIBRARY_PATH
+./test_client
+
--- /dev/null
+#!/bin/sh
+
+export LD_LIBRARY_PATH=./.libs:$LD_LIBRARY_PATH
+./test_server
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief client program for application resource control test
+ *
+ * @date Feb-28-2013
+ */
+#ifdef HAVE_CONFIG_H
+#undef HAVE_CONFIG_H
+#endif
+
+#ifdef HAVE_CONFIG_H
+
+#include "config.h"
+#else
+#define __UNUSED__
+#define PACKAGE_EXAMPLES_DIR "."
+#endif
+
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+#include <stdio.h>
+#include "ico_apf.h"
+#include "ico_apf_ecore.h"
+#include "ico_uxfw_conf.h"
+
+#define WIDTH (520)
+#define HEIGHT (380)
+
+static int loop = 0;
+
+static Ecore_Evas *ee;
+static const char *border_img_path = PACKAGE_EXAMPLES_DIR "/red.png";
+
+static void
+_on_destroy(Ecore_Evas *ee __UNUSED__)
+{
+ ecore_main_loop_quit();
+}
+
+static int callno = 0;
+
+static void
+send_command(const int cno)
+{
+ int ret = 0;
+ char device[32];
+
+ sprintf(device, "Dev%03d", cno+1);
+
+ switch (cno) {
+ case 0:
+ ret = ico_apf_resource_get_screen_mode(device, cno+101);
+ break;
+ case 1:
+ ret = ico_apf_resource_release_screen_mode(device, cno+101);
+ break;
+ case 2:
+ ret = ico_apf_resource_get_int_screen_mode(device, cno+201, cno+101);
+ break;
+ case 3:
+ ret = ico_apf_resource_get_int_screen_mode_disp(device, cno+101);
+ break;
+ case 4:
+ ret = ico_apf_resource_release_int_screen_mode(device, cno+201, cno+101);
+ break;
+ case 5:
+ ret = ico_apf_resource_release_int_screen_mode_disp(device, cno+101);
+ break;
+ case 6:
+ ret = ico_apf_resource_get_sound_mode(device, cno+101, cno+301);
+ break;
+ case 7:
+ ret = ico_apf_resource_release_sound_mode(device, cno+101);
+ break;
+ case 8:
+ ret = ico_apf_resource_get_int_sound_mode(device, cno+101, cno+301);
+ break;
+ case 9:
+ ret = ico_apf_resource_release_int_sound_mode(device, cno+101);
+ break;
+ case 10:
+ ret = ico_apf_resource_add_input_event(device, cno+101);
+ break;
+ case 11:
+ ret = ico_apf_resource_change_input_event(device, cno+101);
+ break;
+ case 12:
+ ret = ico_apf_resource_delete_input_event(device, cno+101);
+ break;
+ default:
+ break;
+ }
+
+ if (ret == 0) {
+ printf("## Client send command(%d) dev=%s\n", cno, device);
+ }
+ else {
+ printf("## Client send command(%d) Error[%d]\n", cno, ret);
+ }
+ fflush(stdout);
+}
+
+static void
+res_callback(ico_apf_resource_notify_info_t* info, void *user_data)
+{
+ printf("##==> Client callbacked! evt=%d res=%d id=%d bid=%d appid=%s "
+ "dev=%s user_data=%d\n",
+ info->state, info->resid, info->id, info->bid, info->appid,
+ info->device, (int)user_data);
+ fflush(stdout);
+
+ callno ++;
+ if ((loop !=0) && (callno > 12)) {
+ callno = 0;
+ }
+ if (callno <= 12) {
+ send_command(callno);
+ }
+}
+
+int
+main(int argc, char *argv[])
+{
+ Evas *canvas, *sub_canvas;
+ Evas_Object *bg, *r1, *r2, *r3; /* "sub" canvas objects */
+ Evas_Object *border, *img; /* canvas objects */
+ Ecore_Evas *sub_ee;
+ int i;
+ int width;
+ int height;
+ unsigned int color;
+ int r, g, b, a;
+ int appno = 1;
+ int no_callback = 0;
+ char sTitle[64];
+
+ width = WIDTH;
+ height = HEIGHT;
+ color = 0xc0c0c0c0;
+ for (i = 1; i < argc; i++) {
+ if (argv[i][0] == '@') {
+ appno = strtol(&argv[i][1], (char **)0, 0);
+ }
+ if (argv[i][0] != '-') continue;
+ if (strncasecmp(argv[i], "-width=", 7) == 0) {
+ width = strtol(&argv[i][7], (char **)0, 0);
+ }
+ else if (strncasecmp(argv[i], "-height=", 8) == 0) {
+ height = strtol(&argv[i][8], (char **)0, 0);
+ }
+ else if (strncasecmp(argv[i], "-color=", 7) == 0) {
+ color = strtoul(&argv[i][7], (char **)0, 0);
+ }
+ else if (strncasecmp(argv[i], "-nocb", 5) == 0) {
+ no_callback = 1;
+ }
+ else if (strncasecmp(argv[i], "-loop", 5) == 0) {
+ loop = 1;
+ }
+ }
+
+ ecore_evas_init();
+
+ /* configuration test */
+ (void)ico_uxf_getSysConfig();
+ (void)ico_uxf_getAppConfig();
+
+ if( ico_apf_ecore_init(NULL) != ICO_APF_E_NONE) {
+ fprintf(stderr, "ico_apf_ecore_init() Error\n"); fflush(stderr);
+ ecore_evas_shutdown();
+ return -1;
+ }
+ if (no_callback == 0) {
+ ico_apf_resource_set_event_cb(res_callback, (void*)1);
+ }
+
+ /* this will give you a window with an Evas canvas under the first engine available */
+ ee = ecore_evas_new(NULL, 0, 0, width, height, "frame=0");
+ if (!ee) goto error;
+
+ ecore_evas_size_min_set(ee, width, height);
+ ecore_evas_size_max_set(ee, width, height);
+
+ ecore_evas_callback_delete_request_set(ee, _on_destroy);
+ sprintf(sTitle, "EFL Native Application %d", appno);
+ ecore_evas_title_set(ee, sTitle);
+ ecore_evas_show(ee);
+
+ canvas = ecore_evas_get(ee);
+
+ bg = evas_object_rectangle_add(canvas);
+ r = (color>>16)&0x0ff;
+ g = (color>>8)&0x0ff;
+ b = color&0x0ff;
+ a = (color>>24)&0x0ff;
+ if (a != 255) {
+ r = (r * a) / 255;
+ g = (g * a) / 255;
+ b = (b * a) / 255;
+ }
+ evas_object_color_set(bg, r, g, b, a); /* bg color */
+ evas_object_move(bg, 0, 0); /* at origin */
+ evas_object_resize(bg, width, height); /* covers full canvas */
+ evas_object_show(bg);
+
+ /* this is a border around the image containing a scene of another * canvas */
+ border = evas_object_image_filled_add(canvas);
+ evas_object_image_file_set(border, border_img_path, NULL);
+ evas_object_image_border_set(border, 3, 3, 3, 3);
+ evas_object_image_border_center_fill_set(border, EVAS_BORDER_FILL_NONE);
+
+ evas_object_move(border, width / 6, height / 6);
+ evas_object_resize(border, (2 * width) / 3, (2 * height) / 3);
+ evas_object_show(border);
+
+ img = ecore_evas_object_image_new(ee);
+ evas_object_image_filled_set(img, EINA_TRUE);
+ evas_object_image_size_set(
+ img, ((2 * width) / 3) - 6, ((2 * height) / 3) - 6);
+ sub_ee = ecore_evas_object_ecore_evas_get(img);
+ sub_canvas = ecore_evas_object_evas_get(img);
+
+ evas_object_move(img, (width / 6) + 3, (height / 6) + 3);
+
+ /* apply the same size on both! */
+ evas_object_resize(img, ((2 * width) / 3) - 6, ((2 * height) / 3) - 6);
+ ecore_evas_resize(sub_ee, ((2 * width) / 3) - 6, ((2 * height) / 3) - 6);
+
+ r1 = evas_object_rectangle_add(sub_canvas);
+ evas_object_color_set(r1, g, b, r, 255);
+ evas_object_move(r1, 10, 10);
+ evas_object_resize(r1, 100, 100);
+ evas_object_show(r1);
+
+ r2 = evas_object_rectangle_add(sub_canvas);
+ evas_object_color_set(r2, b/2, g/2, r/2, 128);
+ evas_object_move(r2, 10, 10);
+ evas_object_resize(r2, 50, 50);
+ evas_object_show(r2);
+
+ r3 = evas_object_rectangle_add(sub_canvas);
+ evas_object_color_set(r3, b, r, g, 255);
+ evas_object_move(r3, 60, 60);
+ evas_object_resize(r3, 50, 50);
+ evas_object_show(r3);
+
+ evas_object_show(img);
+
+ /* get screen */
+ send_command(0);
+ if (no_callback) {
+ int ii;
+
+ for (ii = 1; ii <= 12; ii++) {
+ send_command(ii);
+ }
+
+ /* check receive buffer overflow */
+ for (ii = 0; ii < 64; ii++) {
+ send_command(ii);
+ }
+ }
+
+ ecore_main_loop_begin();
+
+ ico_apf_ecore_term();
+
+ ecore_evas_free(ee);
+ ecore_evas_shutdown();
+
+ return 0;
+
+error:
+ fprintf(stderr, "You got to have at least one Evas engine built"
+ " and linked up to ecore-evas for this example to run"
+ " properly.\n");
+ ecore_evas_shutdown();
+ return -1;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief server(HomeScreen) program for application control
+ *
+ * @date Feb-28-2013
+ */
+#ifdef HAVE_CONFIG_H
+#undef HAVE_CONFIG_H
+#endif
+
+#ifdef HAVE_CONFIG_H
+
+#include "config.h"
+#else
+#define __UNUSED__
+#define PACKAGE_EXAMPLES_DIR "."
+#endif
+
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+#include <stdio.h>
+#include "ico_apf.h"
+#include "ico_apf_ecore.h"
+
+#define WIDTH (520)
+#define HEIGHT (380)
+
+static Ecore_Evas *ee;
+static const char *border_img_path = PACKAGE_EXAMPLES_DIR "/red.png";
+
+static void
+_on_destroy(Ecore_Evas *ee __UNUSED__)
+{
+ ecore_main_loop_quit();
+}
+
+static void
+res_callback(ico_apf_resource_notify_info_t* info, void *user_data)
+{
+ printf("##==> Server callbacked! cmd=%d res=%d id=%d bid=%d appid=%s "
+ "dev=%s user_data=%d\n",
+ info->state, info->resid, info->id, info->bid, info->appid,
+ info->device, (int)user_data);
+ fflush(stdout);
+
+ if ((info->state == ICO_APF_RESOURCE_COMMAND_GET) ||
+ (info->state == ICO_APF_RESOURCE_COMMAND_RELEASE) ||
+ (info->state == ICO_APF_RESOURCE_COMMAND_ADD) ||
+ (info->state == ICO_APF_RESOURCE_COMMAND_CHANGE) ||
+ (info->state == ICO_APF_RESOURCE_COMMAND_DELETE)) {
+ switch (info->id % 4) {
+ case 0:
+ ico_apf_resource_send_to_client(
+ info->appid, ICO_APF_RESOURCE_STATE_ACQUIRED, info->resid,
+ info->device[0] ? info->device : "UnKnown", info->id);
+ printf("##==> Server send %d %d dev=%s id=%d\n",
+ ICO_APF_RESOURCE_STATE_ACQUIRED, info->resid, info->device, info->id);
+ break;
+ case 1:
+ ico_apf_resource_send_to_client(
+ info->appid, ICO_APF_RESOURCE_STATE_DEPRIVED, info->resid,
+ info->device[0] ? info->device : "UnKnown", info->id);
+ printf("##==> Server send %d %d dev=%s id=%d\n",
+ ICO_APF_RESOURCE_STATE_DEPRIVED, info->resid, info->device, info->id);
+ break;
+ case 2:
+ ico_apf_resource_send_to_client(
+ info->appid, ICO_APF_RESOURCE_STATE_WAITTING, info->resid,
+ info->device[0] ? info->device : "UnKnown", info->id);
+ printf("##==> Server send %d %d dev=%s id=%d\n",
+ ICO_APF_RESOURCE_STATE_WAITTING, info->resid, info->device, info->id);
+ break;
+ case 3:
+ ico_apf_resource_send_to_client(
+ info->appid, ICO_APF_RESOURCE_STATE_RELEASED, info->resid,
+ info->device[0] ? info->device : "UnKnown", info->id);
+ printf("##==> Server send %d %d dev=%s id=%d\n",
+ ICO_APF_RESOURCE_STATE_RELEASED, info->resid, info->device, info->id);
+ break;
+ default:
+ break;
+ }
+ }
+ else {
+ printf("##==> Server receive illegal command(%d)\n", info->state);
+ }
+ fflush(stdout);
+}
+
+int
+main(int argc, char *argv[])
+{
+ Evas *canvas, *sub_canvas;
+ Evas_Object *bg, *r1, *r2, *r3; /* "sub" canvas objects */
+ Evas_Object *border, *img; /* canvas objects */
+ Ecore_Evas *sub_ee;
+ int i;
+ int width;
+ int height;
+ unsigned int color;
+ int r, g, b, a;
+ int appno = 1;
+ char sTitle[64];
+
+ width = WIDTH;
+ height = HEIGHT;
+ color = 0xc080b0e0;
+ for (i = 1; i < argc; i++) {
+ if (argv[i][0] == '@') {
+ appno = strtol(&argv[i][1], (char **)0, 0);
+ }
+ if (argv[i][0] != '-') continue;
+ if (strncasecmp(argv[i], "-width=", 7) == 0) {
+ width = strtol(&argv[i][7], (char **)0, 0);
+ }
+ else if (strncasecmp(argv[i], "-height=", 8) == 0) {
+ height = strtol(&argv[i][8], (char **)0, 0);
+ }
+ else if (strncasecmp(argv[i], "-color=", 7) == 0) {
+ color = strtoul(&argv[i][7], (char **)0, 0);
+ }
+ }
+
+ ecore_evas_init();
+
+ if( ico_apf_ecore_init_server(NULL) != ICO_APF_E_NONE) {
+ fprintf(stderr, "ico_apf_ecore_init_server() Error\n"); fflush(stderr);
+ ecore_evas_shutdown();
+ return -1;
+ }
+ ico_apf_resource_set_event_cb(res_callback, (void*)2);
+
+ /* this will give you a window with an Evas canvas under the first
+ * engine available */
+ ee = ecore_evas_new(NULL, 0, 0, width, height, "frame=0");
+ if (!ee) goto error;
+
+ ecore_evas_size_min_set(ee, width, height);
+ ecore_evas_size_max_set(ee, width, height);
+
+ ecore_evas_callback_delete_request_set(ee, _on_destroy);
+ sprintf(sTitle, "EFL Native Application %d", appno);
+ ecore_evas_title_set(ee, sTitle);
+ ecore_evas_show(ee);
+
+ canvas = ecore_evas_get(ee);
+
+ bg = evas_object_rectangle_add(canvas);
+ r = (color>>16)&0x0ff;
+ g = (color>>8)&0x0ff;
+ b = color&0x0ff;
+ a = (color>>24)&0x0ff;
+ if (a != 255) {
+ r = (r * a) / 255;
+ g = (g * a) / 255;
+ b = (b * a) / 255;
+ }
+ evas_object_color_set(bg, r, g, b, a); /* bg color */
+ evas_object_move(bg, 0, 0); /* at origin */
+ evas_object_resize(bg, width, height); /* covers full canvas */
+ evas_object_show(bg);
+
+ /* this is a border around the image containing a scene of another * canvas */
+ border = evas_object_image_filled_add(canvas);
+ evas_object_image_file_set(border, border_img_path, NULL);
+ evas_object_image_border_set(border, 3, 3, 3, 3);
+ evas_object_image_border_center_fill_set(border, EVAS_BORDER_FILL_NONE);
+
+ evas_object_move(border, width / 6, height / 6);
+ evas_object_resize(border, (2 * width) / 3, (2 * height) / 3);
+ evas_object_show(border);
+
+ img = ecore_evas_object_image_new(ee);
+ evas_object_image_filled_set(img, EINA_TRUE);
+ evas_object_image_size_set(
+ img, ((2 * width) / 3) - 6, ((2 * height) / 3) - 6);
+ sub_ee = ecore_evas_object_ecore_evas_get(img);
+ sub_canvas = ecore_evas_object_evas_get(img);
+
+ evas_object_move(img, (width / 6) + 3, (height / 6) + 3);
+
+ /* apply the same size on both! */
+ evas_object_resize(img, ((2 * width) / 3) - 6, ((2 * height) / 3) - 6);
+ ecore_evas_resize(sub_ee, ((2 * width) / 3) - 6, ((2 * height) / 3) - 6);
+
+ r1 = evas_object_rectangle_add(sub_canvas);
+ evas_object_color_set(r1, g, b, r, 255);
+ evas_object_move(r1, 10, 10);
+ evas_object_resize(r1, 100, 100);
+ evas_object_show(r1);
+
+ r2 = evas_object_rectangle_add(sub_canvas);
+ evas_object_color_set(r2, b/2, g/2, r/2, 128);
+ evas_object_move(r2, 10, 10);
+ evas_object_resize(r2, 50, 50);
+ evas_object_show(r2);
+
+ r3 = evas_object_rectangle_add(sub_canvas);
+ evas_object_color_set(r3, b, r, g, 255);
+ evas_object_move(r3, 60, 60);
+ evas_object_resize(r3, 50, 50);
+ evas_object_show(r3);
+
+ evas_object_show(img);
+
+ ecore_main_loop_begin();
+
+ ico_apf_ecore_term_server();
+
+ ecore_evas_free(ee);
+ ecore_evas_shutdown();
+
+ return 0;
+
+error:
+ fprintf(stderr, "You got to have at least one Evas engine built"
+ " and linked up to ecore-evas for this example to run"
+ " properly.\n");
+ ecore_evas_shutdown();
+ return -1;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief header file of homescreen application
+ *
+ * @date Feb-15-2013
+ */
+
+#ifndef _HOME_SCREEN_H_
+#define _HOME_SCREEN_H_
+
+#include "ico_uxf.h"
+
+/*============================================================================*/
+/* definition */
+/*============================================================================*/
+#define ICO_HS_OK (0)
+#define ICO_HS_ERR (-1)
+
+#define ICO_HS_TOUCH_TOBE_HIDE (1)
+#define ICO_HS_TOUCH_TOBE_SHOW (2)
+#define ICO_HS_TOUCH_IN_HIDE (3)
+#define ICO_HS_TOUCH_IN_SHOW (4)
+
+#define ICO_HS_TILE_SMALL (11)
+#define ICO_HS_TILE_HWIDE (21)
+#define ICO_HS_TILE_VWIDE (12)
+#define ICO_HS_TILE_LARGE (22)
+#define ICO_HS_TILE_OTHERS (0)
+
+#define ICO_HS_TILE_CHAN (18)
+#define ICO_HS_TILE_SIZE_S (170)
+#define ICO_HS_TILE_SIZE_W (ICO_HS_TILE_SIZE_S*2 + ICO_HS_TILE_CHAN)
+
+#define ICO_HS_CONFIG_HOMESCREEN "homescreen"
+#define ICO_HS_CONFIG_ONSCREEN "onscreen"
+#define ICO_HS_CONFIG_STATUBAR "statusbar"
+#define ICO_HS_CONFIG_SOUND "sound"
+
+#define ICO_HS_CONFIG_TILE_COLCNT "tileinfo_colcnt"
+#define ICO_HS_CONFIG_TILE_ROWCNT "tileinfo_rowcnt"
+#define ICO_HS_CONFIG_TILE_VALID "tileinfo_valid"
+#define ICO_HS_CONFIG_TILE_TYPE "tileinfo_type"
+#define ICO_HS_CONFIG_TILE_APP "tileinfo_app"
+
+#define ICO_HS_CONFIG_TILE_ROWCNT_DEFAULT (4)
+#define ICO_HS_CONFIG_TILE_COLCNT_DEFAULT (5)
+#define ICO_HS_CONFIG_TILE_APP_DEFAULT "none"
+
+#define ICO_HS_CONFIG_WS_PORT "wsport"
+#define ICO_HS_CONFIG_ORIENTAION "orientation"
+
+#define ICO_HS_CONFIG_BG "bgimage"
+
+#define ICO_HS_CONFIG_SB "statusbar"
+#define ICO_HS_CONFIG_ONS "onscreen"
+#define ICO_HS_APPID_DEFAULT_SB "org.tizen.ico.statusbar" /* default status bar appid */
+#define ICO_HS_APPID_DEFAULT_ONS "org.tizen.ico.onscreen" /* default on screen appid */
+#define ICO_HS_APPID_DEFAULT_TOUCH "TOUCH_SCREEN" /* default touch screen name */
+
+#define ICO_HS_GROUP_SPECIAL "menu"
+
+#define ICO_HS_ONS_APPLI_KILL_NAME "appli_kill.edj"
+#define ICO_HS_ONS_APPLI_LIST_NAME "appli_list.edj"
+#define ICO_HS_ONS_PART_RECT_NAME "rect_"
+#define ICO_HS_ONS_PART_NEXT_NAME "next_bt"
+#define ICO_HS_ONS_PART_CANCEL_NAME "cancel_bt"
+
+#define ICO_HS_WS_PORT (10001)
+
+#define ICO_HS_APP_NUM_MAX (128)
+#define ICO_HS_WINDOW_NUM_MAX (10)
+#define ICO_HS_MSG_SIZE (1024)
+#define ICO_HS_TEMP_BUF_SIZE (256)
+
+#define ICO_HS_PROTOCOL_CM "gui-protocol"
+ /* protocol to communicate external tools */
+#define ICO_HS_PROTOCOL_SB "statusbar-protocol"
+ /* protocol to communicate status bar */
+#define ICO_HS_PROTOCOL_OS "onscreen-protocol"
+ /* protocol to communicate onscreen */
+#define ICO_HS_PROTOCOL_APP "app-protocol"
+ /* protocol to communicate application(not used)*/
+#define ICO_HS_PROTOCOL_TYPE_CM (1)
+#define ICO_HS_PROTOCOL_TYPE_SB (2)
+#define ICO_HS_PROTOCOL_TYPE_OS (3)
+#define ICO_HS_PROTOCOL_TYPE_APP (4)
+
+#define ICO_HS_SIZE_SB_HEIGHT (64)
+#define ICO_HS_SIZE_LAYOUT_WIDTH (768)
+#define ICO_HS_SIZE_LAYOUT_HEIGHT (1024)
+
+/* define for sound configuration */
+#define ICO_HS_SND_TYPE_DEFAULT (1)
+
+#define ICO_HS_SND_CNAME_DEFAULT "sound_default"
+#define ICO_HS_SND_FNAME_DEFAULT "default.wav"
+
+/*============================================================================*/
+/* definition */
+/*============================================================================*/
+typedef struct _hs_window_data hs_window_data_t;
+struct _hs_window_data {
+ char appid[ICO_UXF_MAX_PROCESS_NAME+1];
+ char exe_name[ICO_UXF_MAX_PROCESS_NAME+1];
+ int terminate;
+ int visible;
+ int raise;
+ int resize_w;
+ int resize_h;
+ int move_x;
+ int move_y;
+ int category;
+};
+
+/*============================================================================*/
+/* functions */
+/*============================================================================*/
+extern void hs_tile_free_app(int idx);
+extern void hs_tile_kill_app(const char *appid);
+extern void hs_tile_set_app(int idx, const char *appid);
+extern int hs_tile_get_index_app(const char *appid);
+extern int hs_tile_get_index_pos(int x, int y, int w, int h);
+extern int hs_tile_get_minchange(void);
+extern void hs_tile_show_screen(void);
+extern int hs_get_index_appscreendata(const char *appid);
+extern void hs_req_ctlr_tile(void);
+extern void hs_click_escutcheon(void);
+extern void hs_show_onscreen(void);
+extern void hs_hide_onscreen(void);
+extern void hs_show_appscreen(const char *appid);
+
+extern void hs_get_image_path(char *buff, int len);
+extern void hs_get_sound_path(char *buff, int len);
+extern void hs_get_edj_path(char *buff, int len);
+extern void hs_get_ons_edj_path(char *buff, int len);
+extern void hs_get_conf_path(char *buff, int len);
+
+extern hs_window_data_t hs_command_tile_req[ICO_HS_APP_NUM_MAX];
+extern hs_window_data_t hs_app_screen_window[ICO_HS_APP_NUM_MAX];
+extern char hs_name_homescreen[ICO_UXF_MAX_PROCESS_NAME+1];
+extern char hs_kill_appid[ICO_UXF_MAX_PROCESS_NAME];
+extern char hs_active_onscreen[ICO_UXF_MAX_PROCESS_NAME];
+
+extern int hs_snd_play(char *wav_file);
+extern char *hs_snd_get_filename(int type);
+extern int hs_snd_init(void);
+#endif /* _HOME_SCREEN_H_ */
+
+/**
+ * End of File. (home_screen.h)
+ */
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief header file of homescreen configuration
+ *
+ * @date Feb-15-2013
+ */
+
+#ifndef _HOME_SCREEN_CONF_H_
+#define _HOME_SCREEN_CONF_H_
+
+#include <glib.h>
+#include "ico_uxf_sysdef.h"
+#include "ico_uxf_def.h"
+#include "ico_apf_log.h"
+
+/*============================================================================*/
+/* definition */
+/*============================================================================*/
+#define ICO_HOMESCREEN_CONFIG_FILE "homescreen.conf"
+#define ICO_ONSCREEN_CONFIG_FILE "onscreen.conf"
+#define ICO_STATUSBAR_CONFIG_FILE "statusbar.conf"
+
+/*============================================================================*/
+/* functions */
+/*============================================================================*/
+extern int initHomeScreenConfig(const char *conf);
+extern int hs_conf_get_integer(const char *group_name,
+ const char *key, int default_value);
+extern const char *hs_conf_get_string(const char *group_name,
+ const char *key, const char *default_value);
+
+#endif /* _HOME_SCREEN_CONF_H_ */
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief header file for homescreen communication
+ *
+ * @date Feb-15-2013
+ */
+
+#ifndef __HOME_SCREEN_LIB_H__
+#define __HOME_SCREEN_LIB_H__
+
+/*============================================================================*/
+/* definition */
+/*============================================================================*/
+struct socket_data {
+ struct libwebsocket_context *ws_context;
+ int port;
+};
+
+/*============================================================================*/
+/* functions */
+/*============================================================================*/
+extern int hs_lib_main(int port);
+extern int hs_lib_event_message(int type, char *format, ...);
+
+#endif /* __HOME_SCREEN_LIB_H__ */
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief header file of command parser tools
+ *
+ * @date Feb-15-2013
+ */
+
+#ifndef _HOME_SCREEN_PARSER_H_
+#define _HOME_SCREEN_PARSER_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <getopt.h>
+#include <glib-object.h>
+#include <json-glib/json-glib.h>
+
+#include "ico_uxf.h"
+#include "home_screen.h"
+#include "ico_uxf_conf.h"
+
+/*============================================================================*/
+/* definition */
+/*============================================================================*/
+#define UNEXECUTED 0
+#define EXECUTED 1
+
+#define IGNORE (-1)
+#define EXECUTE (0)
+
+typedef struct _hs_command_req hs_command_req_t;
+struct _hs_command_req {
+ struct {
+ char appid[ICO_UXF_MAX_PROCESS_NAME+1];
+ struct {
+ char *appid;
+ } execute;
+ struct {
+ char *appid;
+ } terminate;
+ struct {
+ char *appid;
+ } suspend;
+ struct {
+ char *appid;
+ } resume;
+ } program;
+ struct {
+ int status;
+ struct {
+ int window;
+ } show;
+ struct {
+ int window;
+ } hide;
+ struct {
+ int window;
+ int visible;
+ int raise;
+ } visible_raise;
+ struct {
+ int window;
+ int w;
+ int h;
+ } resize;
+ struct {
+ int window;
+ int size_m;
+ int size_n;
+ } resize_tile;
+ struct {
+ int window;
+ int x;
+ int y;
+ } move;
+ struct {
+ int window;
+ int m;
+ int n;
+ } move_tile;
+ struct {
+ int window;
+ } raise;
+ struct {
+ int window;
+ } lower;
+ struct {
+ int window;
+ unsigned int mask;
+ } event_mask;
+ } window[ICO_HS_WINDOW_NUM_MAX];
+ struct {
+ struct {
+ int input;
+ } add_app;
+ struct {
+ int input;
+ } del_app;
+ } input;
+};
+
+/*============================================================================*/
+/* functions */
+/*============================================================================*/
+extern int hs_parse_form(char *, int);
+extern int hs_conftrol_form(const char*, int);
+extern void hs_dump_app(void);
+extern int hs_control_app_screen(void);
+extern void hs_get_tilescreendata(void);
+
+extern int hs_req_touch;
+extern int hs_stat_touch;
+
+#endif /* _HOME_SCREEN_PARSER_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief header file of homescreen resource
+ *
+ * @date Feb-15-2013
+ */
+
+#ifndef HOME_SCREEN_RES_H
+#define HOME_SCREEN_RES_H
+
+/* file_path */
+#define default_path "./"
+#define edj_path "/opt/apps/%s/res/edj/"
+#define image_path "/opt/apps/%s/res/images/"
+#define sound_path "/opt/apps/%s/res/sounds/"
+#define manifest_path "/opt/apps/%s/res/config/"
+#define local_top_path "/home/tizen/HomeScreen"
+#define local_edj_path "%s/src/"
+#define local_image_path "%s/res/images/"
+#define local_sound_path "%s/res/sounds/"
+#define local_manifest_path "%s/res/apps/org.tizen.ico.homescreen/"
+
+#define fname_api_all_off "api_all_off.png"
+#define fname_api_all_on "api_all_on.png"
+
+#define fname_backboard "back_b_01.png"
+#define fname_back_bg "back_b_01.png"
+
+/* file name (appli list) */
+#define fname_api01_off "api_s_01_off.png"
+#define fname_api02_off "api_s_02_off.png"
+#define fname_api03_off "api_s_03_off.png"
+#define fname_api04_off "api_s_04_off.png"
+#define fname_api05_off "api_s_05_off.png"
+#define fname_api06_off "api_s_06_off.png"
+#define fname_api07_off "api_s_07_off.png"
+#define fname_api08_off "api_s_08_off.png"
+#define fname_api09_off "api_s_09_off.png"
+#define fname_api10_off "api_s_10_off.png"
+#define fname_api11_off "api_s_11_off.png"
+#define fname_api12_off "api_s_12_off.png"
+#define fname_api13_off "api_s_13_off.png"
+#define fname_api14_off "api_s_14_off.png"
+#define fname_api15_off "api_s_15_off.png"
+#define fname_api16_off ""
+#define fname_api17_off ""
+#define fname_api18_off ""
+#define fname_api19_off ""
+#define fname_api20_off ""
+#define fname_api01_on "api_s_01_on.png"
+#define fname_api02_on "api_s_02_on.png"
+#define fname_api03_on "api_s_03_on.png"
+#define fname_api04_on "api_s_04_on.png"
+#define fname_api05_on "api_s_05_on.png"
+#define fname_api06_on "api_s_06_on.png"
+#define fname_api07_on "api_s_07_on.png"
+#define fname_api08_on "api_s_08_on.png"
+#define fname_api09_on "api_s_09_on.png"
+#define fname_api10_on "api_s_10_on.png"
+#define fname_api11_on "api_s_11_on.png"
+#define fname_api12_on "api_s_12_on.png"
+#define fname_api13_on "api_s_13_on.png"
+#define fname_api14_on "api_s_14_on.png"
+#define fname_api15_on "api_s_15_on.png"
+#define fname_api16_on ""
+#define fname_api17_on ""
+#define fname_api18_on ""
+#define fname_api19_on ""
+#define fname_api20_on ""
+#define fname_ok_off "ok_bt_off.png"
+#define fname_ok_on "ok_bt_on.png"
+#define fname_next_off "next_bt_off.png"
+#define fname_next_on "next_bt_on.png"
+#define fname_cancel_on "cancel_bt_on.png"
+#define fname_cancel_off "cancel_bt_off.png"
+
+/* file name (ARnavi config) */
+#define fname_na_bt1_on "na_bt1_on.png"
+#define fname_na_bt1_off "na_bt1_off.png"
+#define fname_na_bt2_on "na_bt2_on.png"
+#define fname_na_bt2_off "na_bt2_off.png"
+#define fname_na_pa1 "na_pa_01.png"
+#define fname_na_pa2 "na_pa_02.png"
+#define fname_na_pa3 "na_pa_03.png"
+#define fname_na_pa4 "na_pa_04.png"
+#define fname_nai1_off "nai_01_off.png"
+#define fname_nai1_on "nai_01_on.png"
+#define fname_nai2_off "nai_02_off.png"
+#define fname_nai3_off "nai_03_off.png"
+#define fname_nai4_off "nai_04_off.png"
+#define fname_nai5_off "nai_05_off.png"
+#define fname_nai6_off "nai_06_off.png"
+#define fname_nai7_off "nai_07_off.png"
+#define fname_nai8_off "nai_08_off.png"
+#define fname_nai9_off "nai_09_off.png"
+#define fname_nai10_off "nai_10_off.png"
+#define fname_nai11_off "nai_11_off.png"
+#define fname_nai12_off "nai_12_off.png"
+#define fname_nai12_on "nai_12_on.png"
+
+/* file name (onscreen)*/
+#define fname_backboard2 "back_b_02.png"
+
+/* file name (status bar)*/
+#define fname_logo_off "st_logo_off.png"
+#define fname_logo_on "st_logo_on.png"
+#define fname_am "time_am.png"
+#define fname_pm "time_pm.png"
+#define fname_num1 "time_1.png"
+#define fname_num2 "time_2.png"
+#define fname_num3 "time_3.png"
+#define fname_num4 "time_4.png"
+#define fname_num5 "time_5.png"
+#define fname_num6 "time_6.png"
+#define fname_num7 "time_7.png"
+#define fname_num8 "time_8.png"
+#define fname_num9 "time_9.png"
+#define fname_num0 "time_0.png"
+#define fname_colon "time_ten.png"
+
+#endif /* HOME_SCREEN_RES_H */
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief header file of Application Framework
+ *
+ * @date Feb-28-2013
+ */
+
+#ifndef __ICO_APF_H__
+#define __ICO_APF_H__
+
+#include "ico_apf_resource_control.h"
+#include "ico_apf_error.h"
+
+#endif /*__ICO_APF_H__*/
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief header file of Apprication Framework (for Ecode(EFL) based application)
+ *
+ * @date Feb-28-2013
+ */
+
+#ifndef __ICO_APF_ECORE_H__
+#define __ICO_APF_ECORE_H__
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Initialize AppsController interface for Ecode(EFL) based application
+ *
+ * @param[in] uri server URI
+ * @return result status
+ * @retval ICO_APF_E_NONE success
+ * @retval ICO_APF_E_IO_ERROR error(failed)
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_ecore_init(const char *uri);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Terminame AppsController interface for Ecode(EFL) based application
+ *
+ * @param none
+ * @return result status
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void ico_apf_ecore_term(void);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Initialize AppsController interface for server(AppsController)
+ *
+ * @param[in] uri my URI
+ * @return result status
+ * @retval ICO_APF_E_NONE success
+ * @retval ICO_APF_E_IO_ERROR error(failed)
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_ecore_init_server(const char *uri);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Terminame AppsController interface for server(AppsController)
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void ico_apf_ecore_term_server(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ICO_APF_ECORE_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief header file of Apprication Framework (declaration of API error code)
+ *
+ * @date Feb-28-2013
+ */
+
+#ifndef __ICO_APF_ERROR_H__
+#define __ICO_APF_ERROR_H__
+
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Enumerations of common error code for Application Framework.
+ */
+typedef enum
+{
+ ICO_APF_E_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ ICO_APF_E_INVALID_PARAM = TIZEN_ERROR_INVALID_PARAMETER,
+ ICO_APF_E_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,
+ ICO_APF_E_IO_ERROR = TIZEN_ERROR_IO_ERROR,
+ ICO_APF_E_UNKNOWN = TIZEN_ERROR_UNKNOWN
+} ico_app_fw_error_e;
+
+/**
+ * @brief Enumerations of error code for Application Communication.
+ */
+typedef enum
+{
+ ICO_APF_COM_E_CREATE_CTX = -200, /**< Create context failed */
+ ICO_APF_COM_E_CLT_CONNECT = -201, /**< Client connect failed */
+ ICO_APF_COM_E_CLOSED = -202, /**< Connection closed */
+ ICO_APF_COM_E_WRITE = -203, /**< libwebsocket_write error */
+ ICO_APF_COM_E_RESERVED = -204, /**< Reserve data failed */
+ ICO_APF_COM_E_NO_EXIST = -205, /**< Uri does not exist */
+ ICO_APF_COM_E_UNKNOWN = -300, /**< Other error */
+} ico_app_fw_com_error_e;
+
+/**
+ *@brief Enumerations of error code for Application Manager.
+ */
+typedef enum
+{
+ ICO_APP_CTL_E_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ ICO_APP_CTL_E_INVALID_PARAM = TIZEN_ERROR_INVALID_PARAMETER,
+ ICO_APP_CTL_E_OUT_OF_MEM = TIZEN_ERROR_OUT_OF_MEMORY,
+ ICO_APP_CTL_E_IO_ERR = TIZEN_ERROR_IO_ERROR,
+} ico_app_ctl_error_e;
+
+/**
+ * @brief Enumerations of error code for Resource Manager.
+ */
+typedef enum _resmgr_error {
+ ICO_APF_RESOURCE_E_NONE = 0, /* Successful */
+ ICO_APF_RESOURCE_E_UNKOWN = -1, /* unkown error */
+ ICO_APF_RESOURCE_E_INVAL = -2, /* invalid parameter */
+ ICO_APF_RESOURCE_E_NOT_IMPLEMENTED = -3, /* not implemented */
+ ICO_APF_RESOURCE_E_NOT_INITIALIZED = -4, /* not initialized resmger module */
+ ICO_APF_RESOURCE_E_INIT_COM_FAILD = -5, /* intialize communication error */
+ ICO_APF_RESOURCE_E_COMMUNICATION = -6, /* communication error */
+ ICO_APF_RESOURCE_E_MSG_PARSER = -7, /* message parser faild */
+ ICO_APF_RESOURCE_E_SERVER_CLOSED = -8, /* server colosed */
+ ICO_APF_RESOURCE_E_SEND_DATA = -9, /* send data faile */
+} ico_apf_resmgr_error_e;
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __ICO_APF_ERROR_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief Application Framework public header for log output
+ *
+ * @date Feb-15-2013
+ */
+
+#ifndef _ICO_APF_LOG_H_
+#define _ICO_APF_LOG_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Log output destination */
+#ifndef ICO_APF_LOG_STDOUT
+#define ICO_APF_LOG_STDOUT 0 /* Log output to stdout(=1) or file(=0) */
+#endif /*ICO_APF_LOG_STDOUT*/
+#define ICO_APF_LOG_DIR "/var/log/ico"
+ /* Directory name of Log destination */
+
+/* Maximum lines/files */
+#define ICO_APF_LOG_MAXLINES 10000 /* Maximum output lines of one log file */
+#define ICO_APF_LOG_MAXFILES 6 /* Maximum number of the log file */
+
+/* Log output level */
+#define ICO_APF_LOG_DEBUG 128 /* Debug write */
+#define ICO_APF_LOG_INFO 64 /* Information */
+#define ICO_APF_LOG_WARNING 16 /* Warning */
+#define ICO_APF_LOG_CRITICAL 8 /* Critical */
+#define ICO_APF_LOG_ERROR 4 /* Error */
+
+/* Log output flush */
+#define ICO_APF_LOG_FLUSH 0x4000 /* Log outout with log flush */
+#define ICO_APF_LOG_NOFLUSH 0x2000 /* Log output without log flush */
+
+/* Function prototypes */
+void ico_apf_log_print(const char *fmt, ...);
+void ico_apf_log_open(const char *Prog);
+void ico_apf_log_close(void);
+void ico_apf_log_flush(void);
+char *ico_apf_log_curtime(const char *level);
+void ico_apf_log_setlevel(const int loglevel);
+
+/* Current log output level */
+extern int ico_apf_log_level;
+
+/* Macros for log output */
+#define ICO_APF_DEBUG(fmt,...) \
+ {if( ico_apf_log_level >= ICO_APF_LOG_DEBUG) {ico_apf_log_print("%s> "fmt" (%s,%s:%d)\n",ico_apf_log_curtime("DBG"),##__VA_ARGS__,__func__,__FILE__,__LINE__);} }
+#define ICO_APF_INFO(fmt,...) \
+ {if( ico_apf_log_level >= ICO_APF_LOG_INFO) {ico_apf_log_print("%s> "fmt" (%s,%s:%d)\n",ico_apf_log_curtime("INF"),##__VA_ARGS__,__func__,__FILE__,__LINE__);} }
+#define ICO_APF_WARN(fmt,...) \
+ {if( ico_apf_log_level >= ICO_APF_LOG_WARNING) {ico_apf_log_print("%s> "fmt" (%s,%s:%d)\n",ico_apf_log_curtime("WRN"),##__VA_ARGS__,__func__,__FILE__,__LINE__);} }
+#define ICO_APF_CRITICAL(fmt,...) \
+ {if( ico_apf_log_level >= ICO_APF_LOG_CRITICAL) {ico_apf_log_print("%s> "fmt" (%s,%s:%d)\n",ico_apf_log_curtime("CRI"),##__VA_ARGS__,__func__,__FILE__,__LINE__);} }
+#define ICO_APF_ERROR(fmt,...) \
+ {if( ico_apf_log_level >= ICO_APF_LOG_ERROR) {ico_apf_log_print("%s> "fmt" (%s,%s:%d)\n",ico_apf_log_curtime("ERR"),##__VA_ARGS__,__func__,__FILE__,__LINE__);} }
+
+/* Macros for compativility */
+#ifndef apfw_trace
+#define apfw_debug ICO_APF_DEBUG
+#define apfw_trace ICO_APF_DEBUG
+#define apfw_info ICO_APF_INFO
+#define apfw_warn ICO_APF_WARN
+#define apfw_critical ICO_APF_CRITICAL
+#define apfw_error ICO_APF_ERROR
+#define apfw_logflush ico_apf_log_flush
+#endif /*apfw_trace*/
+
+#define uim_debug ICO_APF_DEBUG
+#define uifw_debug ICO_APF_DEBUG
+#define uifw_trace ICO_APF_DEBUG
+#define uifw_info ICO_APF_INFO
+#define uifw_warn ICO_APF_WARN
+#define uifw_critical ICO_APF_CRITICAL
+#define uifw_error ICO_APF_ERROR
+#define uifw_logflush ico_apf_log_flush
+
+#define ICO_UXF_DEBUG ICO_APF_DEBUG
+#define ICO_UXF_INFO ICO_APF_INFO
+#define ICO_UXF_WARN ICO_APF_WARN
+#define ICO_UXF_CRITICAL ICO_APF_CRITICAL
+#define ICO_UXF_ERROR ICO_APF_ERROR
+
+#define ico_uxf_log_open ico_apf_log_open
+#define ico_uxf_log_close ico_apf_log_close
+#define ico_uxf_log_flush ico_apf_log_flush
+#define ico_uxf_log_setlevel ico_apf_log_setlevel
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _ICO_APF_LOG_H_ */
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief header file of Apprication Framework (Resource Control)
+ *
+ * @date Feb-28-2013
+ */
+
+#include "ico_uxf_sysdef.h"
+
+#ifndef __ICO_APF_RESOURCE_CONTROL_H__
+#define __ICO_APF_RESOURCE_CONTROL_H__
+
+/*
+ * id of resource
+ */
+typedef enum _resid {
+ ICO_APF_RESID_BASIC_SCREEN = 1, /* basic screen */
+ ICO_APF_RESID_INT_SCREEN = 2, /* interrupt screen */
+ ICO_APF_RESID_ON_SCREEN = 3, /* onscreeen */
+ ICO_APF_RESID_BASIC_SOUND = 4, /* basic sound */
+ ICO_APF_RESID_INT_SOUND = 5, /* interrupt sound */
+ ICO_APF_RESID_INPUT_DEV = 6, /* input device */
+} ico_apf_resid_e;
+#define ICO_APF_RESOURCE_RESID_MIN ((int)(ICO_APF_RESID_BASIC_SCREEN))
+#define ICO_APF_RESOURCE_RESID_MAX ((int)(ICO_APF_RESID_INPUT_DEV))
+
+/*
+ * state of resource
+ */
+typedef enum _resource_state {
+ ICO_APF_RESOURCE_STATE_ACQUIRED = 1, /* acquired */
+ ICO_APF_RESOURCE_STATE_DEPRIVED = 2, /* deprived */
+ ICO_APF_RESOURCE_STATE_WAITTING = 3, /* waitting */
+ ICO_APF_RESOURCE_STATE_RELEASED = 4, /* released */
+
+ ICO_APF_RESOURCE_COMMAND_GET = 5, /* get command */
+ ICO_APF_RESOURCE_COMMAND_RELEASE = 6, /* release command */
+ ICO_APF_RESOURCE_COMMAND_ADD = 7, /* add command */
+ ICO_APF_RESOURCE_COMMAND_CHANGE = 8, /* change command */
+ ICO_APF_RESOURCE_COMMAND_DELETE = 9, /* delete command */
+
+ ICO_APF_RESOURCE_REPLY_OK = 10, /* OK reply */
+ ICO_APF_RESOURCE_REPLY_NG = 11, /* NG reply */
+ ICO_APF_RESOURCE_STATE_CONNECTED = 12, /* connected */
+ ICO_APF_RESOURCE_STATE_DISCONNECTED = 13, /* disconnected */
+} ico_apf_resource_state_e;
+#define ICO_APF_RESOURCE_COMMAND_MIN ((int)(ICO_APF_RESOURCE_STATE_ACQUIRED))
+#define ICO_APF_RESOURCE_COMMAND_MAX ((int)(ICO_APF_RESOURCE_STATE_DISCONNECTED))
+
+/*
+ * sound control
+ */
+typedef enum _sound_resource {
+ ICO_APF_SOUND_COMMAND_MUTEON = 21, /* mute on */
+ ICO_APF_SOUND_COMMAND_MUTEOFF = 22, /* mute off */
+ ICO_APF_SOUND_COMMAND_CANCEL = 23, /* cancel */
+ ICO_APF_SOUND_COMMAND_GETLIST = 24, /* get stream list */
+ ICO_APF_SOUND_COMMAND_FRESH = 25, /* fresh */
+ ICO_APF_SOUND_COMMAND_ALLMUTEON = 26, /* mute on all streams*/
+ ICO_APF_SOUND_COMMAND_ALLMUTEOFF = 27, /* mute off all streams*/
+
+ ICO_APF_SOUND_EVENT_NEW = 28, /* created new stream*/
+ ICO_APF_SOUND_EVENT_FREE = 29, /* destoryed stream */
+
+ ICO_APF_SOUND_REPLY_LIST = 30 /* reply on stream list*/
+} ico_apf_sound_state_e;
+#define ICO_APF_SOUND_COMMAND_MIN ((int)(ICO_APF_SOUND_COMMAND_MUTEON))
+#define ICO_APF_SOUND_COMMAND_CMD ((int)(ICO_APF_SOUND_COMMAND_ALLMUTEOFF))
+#define ICO_APF_SOUND_COMMAND_MAX ((int)(ICO_APF_SOUND_REPLY_LIST))
+
+/*
+ * notify callback information
+ */
+typedef struct _resmgr_notify_info {
+ ico_apf_resid_e resid;
+ int id;
+ int bid;
+ int pid;
+ char appid[ICO_UXF_MAX_PROCESS_NAME+1];
+ ico_apf_resource_state_e state;
+ char device[ICO_UXF_MAX_DEVICE_NAME+1];
+} ico_apf_resource_notify_info_t;
+
+typedef void (*ico_apf_resource_notify_cb_t)(ico_apf_resource_notify_info_t* info,
+ void *user_data);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Initialize resouce manager component for client Application
+ *
+ * @param[in] uri server URI
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_INIT_COM_FAILD can not create connection
+ * @retval ICO_APF_RESOURCE_E_INIT_COMMUNICATION initialize communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_init_client(const char *uri);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Terminame resouce manager component
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void ico_apf_resource_term_client(void);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Initialize resouce manager component for sever(AppsController)
+ *
+ * @param[in] uri my URI
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_INIT_COM_FAILD can not create connection
+ * @retval ICO_APF_RESOURCE_E_INIT_COMMUNICATION initialize communication error
+ * @retval ICO_APF_RESOURCE_E_INVALID_PARAMETER appid is null
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_init_server(const char *uri);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Terminame resouce manager component for server(AppsController)
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void ico_apf_resource_term_server(void);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Set event callback function
+ *
+ * @param[in] callbacks callback functions
+ * @param[in] user_data passed data on called callback function
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_INVAL callbacks is null
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_set_event_cb(ico_apf_resource_notify_cb_t callbacks,
+ void *user_data);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Unset event callback function
+ *
+ * @param none
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success(At present, always give back this)
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_unset_event_cb(void);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Get the rights of basic screen
+ *
+ * @param[in] disp_dev display device uri
+ * @param[in] src_id id of basic screen
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_get_screen_mode(const char* disp_dev, int scr_id);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Release the rights of basic screen
+ *
+ * @param[in] disp_dev display device uri
+ * @param[in] src_id id of basic screen
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_release_screen_mode(const char* disp_dev, int scr_id);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Reply the basic screen status change event
+ *
+ * @param[in] disp_dev display device uri
+ * @param[in] src_id id of basic screen
+ * @param[in] ok OK(1) or NG(0)
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_reply_screen_mode(const char* disp_dev, int scr_id, const int ok);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Release the rights of interrupt screen
+ *
+ * @param[in] disp_dev display device uri
+ * @param[in] src_id id of basic screen
+ * @param[in] int_src_id id of interrupt screen
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_get_int_screen_mode(const char* disp_dev,
+ int scr_id, int int_scr_id);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Release the rights of interrupt screen on basic screen
+ *
+ * @param[in] disp_dev display device uri
+ * @param[in] src_id id of basic screen
+ * @param[in] int_scr_id id of interrupt screen
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_release_int_screen_mode(const char* disp_dev,
+ int scr_id, int int_scr_id);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Reply the rights of interrupt screen on basic screen
+ *
+ * @param[in] disp_dev display device uri
+ * @param[in] src_id id of basic screen
+ * @param[in] int_src_id id of interrupt screen
+ * @param[in] ok OK(1) or NG(0)
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_reply_int_screen_mode(const char* disp_dev,
+ int scr_id, int int_scr_id, const int ok);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Get the rights of interrupt screen on display
+ *
+ * @param[in] disp_dev display device uri
+ * @param[in] int_scr_id id of interrupt screen
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_get_int_screen_mode_disp(const char* disp_dev,
+ int int_scr_id);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Release the rights of interrupt screen on display
+ *
+ * @param[in] disp_dev display device uri
+ * @param[in] int_scr_id id of interrupt screen
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_release_int_screen_mode_disp(const char* disp_dev,
+ int int_scr_id);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Reply the rights of interrupt screen on display
+ *
+ * @param[in] disp_dev display device uri
+ * @param[in] int_scr_id id of interrupt screen
+ * @param[in] ok OK(1) or NG(0)
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_reply_int_screen_mode_disp(const char* disp_dev,
+ int int_scr_id, const int ok);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Get the rights of basic sound on zone
+ *
+ * @param[in] zone sound device uri
+ * @param[in] snd_id id of basic sound
+ * @param[in] adjust adjust acction
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_get_sound_mode(const char* zone, int snd_id, int adjust);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Release the rights of basic sound on zone
+ *
+ * @param[in] zone sound device uri
+ * @param[in] snd_id id of basic sound
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_release_sound_mode(const char* zone, int snd_id);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Reply the rights of basic sound on zone
+ *
+ * @param[in] zone sound device uri
+ * @param[in] snd_id id of basic sound
+ * @param[in] ok OK(1) or NG(0)
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_reply_sound_mode(const char* zone, int snd_id, const int ok);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Get the rights of interrupt sound on zone
+ *
+ * @param[in] zone sound device uri
+ * @param[in] int_snd_id id of basic sound
+ * @param[in] adjust adjust action
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_get_int_sound_mode(const char* zone,
+ int int_snd_id, int adjust);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Release the rights of interrupt sound on zone
+ *
+ * @param[in] zone sound device uri
+ * @param[in] int_snd_id id of interrupt sound
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_release_int_sound_mode(const char* zone, int int_snd_id);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Reply the rights of interrupt sound on zone
+ *
+ * @param[in] zone sound device uri
+ * @param[in] int_snd_id id of interrupt sound
+ * @param[in] ok OK(1) or NG(0)
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_reply_int_sound_mode(const char* zone,
+ int int_snd_id, const int ok);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Add the input event notification from input device
+ *
+ * @param[in] input_dev input device uri
+ * @param[in] events notify input events
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_add_input_event(const char* input_dev, int events);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Change the input event notification from input device
+ *
+ * @param[in] input_dev input device uri
+ * @param[in] events notify input events
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_change_input_event(const char* input_dev, int events);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Delete the input event notification from input device
+ *
+ * @param[in] input_dev input device uri
+ * @param[in] events notify input events
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_delete_input_event(const char* input_dev, int events);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Send responce form server(AppsController) to client application
+ *
+ * @param[in] appid client application id
+ * @param[in] event event
+ * @param[in] resource target resource
+ * @param[in] device display device / sound zone
+ * @param[in] id application defined object id
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ * @retval ICO_APF_RESOURCE_E_INVAL illegal appid or event code
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_send_to_client(const char *appid, const int event,
+ const int resource, const char *device, const int id);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Send request to Multi Input Manager
+ *
+ * @param[in] cmd send command
+ * @param[in] pid target pid
+ * @return result status
+ * @retval ICO_APF_RESOURCE_E_NONE success
+ * @retval ICO_APF_RESOURCE_E_NOT_INITIALIZED not initialized
+ * @retval ICO_APF_RESOURCE_E_COMMUNICATION communication error
+ */
+/*--------------------------------------------------------------------------*/
+int ico_apf_resource_send_to_soundctl(const ico_apf_sound_state_e cmd, const int pid);
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief Get aplication Id
+ *
+ * @param[in] pid process id (if 0, current process id)
+ * @param[out] appid client application id
+ * @return result status
+ * @retval ICO_APP_CTL_E_NONE success
+ * @retval ICO_APP_CTL_E_INVALID_PARAM error(pid dose not exist)
+ */
+/*--------------------------------------------------------------------------*/
+/* Applicaton Manager */
+int ico_apf_get_app_id(const int pid, char *appid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__ICO_APF_RESOURCE_CONTROL_H__*/
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief header file of Apprications Controller
+ *
+ * @date Feb-28-2013
+ */
+
+#ifndef _ICO_SYC_APC_H_
+#define _ICO_SYC_APC_H_
+
+#include "ico_apf_log.h"
+#include "ico_uxf_sysdef.h"
+#include "ico_uxf_conf.h"
+#include "ico_uxf_def.h"
+#include "ico_syc_error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Vehicle information values */
+#define ICO_SYC_APC_REGULATION_SPEED_RUNNING (4.0)
+#define ICO_SYC_APC_REGULATION_SHIFT_NEUTRALS (0)
+#define ICO_SYC_APC_REGULATION_SHIFT_1ST (1)
+#define ICO_SYC_APC_REGULATION_SHIFT_2ND (2)
+#define ICO_SYC_APC_REGULATION_SHIFT_3RD (3)
+#define ICO_SYC_APC_REGULATION_SHIFT_DRIVE (4)
+#define ICO_SYC_APC_REGULATION_SHIFT_REVERSES (128)
+#define ICO_SYC_APC_REGULATION_SHIFT_PARKING (255)
+#define ICO_SYC_APC_REGULATION_BLINKER_LEFT (2)
+#define ICO_SYC_APC_REGULATION_BLINKER_RIGHT (1)
+
+#define ICO_SYC_APC_REGULATION_NOCHANGE (9)
+#define ICO_SYC_APC_REGULATION_NOREGULATION (1)
+#define ICO_SYC_APC_REGULATION_REGULATION (0)
+
+typedef struct _ico_apc_reguration_control {
+ unsigned char display; /* display(1=visible/0=invisible) */
+ unsigned char sound; /* sound(1=play/0=mute) */
+ unsigned char input; /* inputsw(1=use/0=unuse) */
+ unsigned char res; /* (unused) */
+} ico_apc_reguration_control_t;
+ /* application context (pointer only)*/
+typedef struct _ico_apc_context *ico_apc_context_h;
+
+ /* regulation event callback function*/
+typedef void (*ico_apc_regulation_cb_t)(const int appcategory,
+ const ico_apc_reguration_control_t control,
+ void *user_data);
+ /* respurce control */
+typedef void (*ico_apc_resource_control_t)(const Ico_Uxf_conf_application *conf,
+ const int control);
+
+/* API prototype */
+/* Apps Controller initialize/terminate */
+ /* initialize Apps Controller */
+int ico_syc_apc_init(ico_apc_resource_control_t display,
+ ico_apc_resource_control_t sound,
+ ico_apc_resource_control_t input);
+ /* Terminate Apps Controller */
+void ico_syc_apc_term(void);
+ /* Select active application */
+void ico_syc_apc_active(const char *appid);
+
+/* Apps Controller regulation control */
+ /* regulation controller initialize */
+int ico_syc_apc_regulation_init(void);
+ /* regulation controller terminate */
+int ico_syc_apc_regulation_term(void);
+ /* set regulation change listener */
+void ico_syc_apc_regulation_listener(ico_apc_regulation_cb_t func, void *user_data);
+ /* get application visible control */
+int ico_syc_apc_regulation_app_visible(const int category);
+ /* get application sound control */
+int ico_syc_apc_regulation_app_sound(const int category);
+ /* get application input control */
+int ico_syc_apc_regulation_app_input(const int category);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /*_ICO_SYC_APC_H_*/
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief System Controller public header for permanent value
+ *
+ * @date Feb-28-2013
+ */
+
+#ifndef _ICO_SYC_DEF_H_
+#define _ICO_SYC_DEF_H_
+
+#include "ico_apf_error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* common API error code */
+#define ICO_SYC_EOK ICO_APF_RESOURCE_E_NONE /* OK */
+#define ICO_SYC_ENOENT ICO_APF_RESOURCE_E_UNKOWN /* No such object */
+#define ICO_SYC_ESRCH ICO_APF_RESOURCE_E_NOT_INITIALIZED /* Not initialized */
+#define ICO_SYC_EIO ICO_APF_RESOURCE_E_COMMUNICATION /* I/O error */
+#define ICO_SYC_ENOMEM ICO_APF_RESOURCE_E_NOT_IMPLEMENTED /* Out of memory */
+#define ICO_SYC_EINVAL ICO_APF_RESOURCE_E_INVAL /* Invalid argument */
+#define ICO_SYC_ENOSYS (-99) /* System error */
+
+/* Vehicle information internal key */
+enum _ico_syc_regulation_vehicleinfo_id {
+ ICO_SYC_VEHICLEINFO_VEHICLE_SPEED = 1, /* vehicle speed */
+ ICO_SYC_VEHICLEINFO_SHIFT_POSITION, /* shift position */
+ ICO_SYC_VEHICLEINFO_BLINKER, /* blinker(not inpliment in AMB) */
+
+ ICO_SYC_VEHICLEINFO_MAX /* maximum number of type */
+};
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _ICO_SYC_DEF_H_ */
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief user experiance library public header file
+ *
+ * @date Feb-28-2013
+ */
+
+#ifndef _ICO_UXF_H_
+#define _ICO_UXF_H_
+
+#include <ico_apf_log.h> /* Macros for log output */
+#include <ico_uxf_sysdef.h> /* System definition values */
+#include <ico_uxf_def.h> /* Public permanent define symbols */
+#include <ico_uxf_typedef.h> /* ublic data and structue types */
+#include <ico_uxf_proto.h> /* Prototypic declaration of APIs */
+
+#endif /* _ICO_UXF_H_ */
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief user experiance library public header file(configuration)
+ *
+ * @date Feb-28-2013
+ */
+
+#ifndef ICO_UXF_CONF_H_
+#define ICO_UXF_CONF_H_
+
+#include <glib.h>
+#include "ico_uxf_conf_def.h"
+#include "ico_uxf_sysdef.h"
+#include "ico_uxf_def.h"
+#include "ico_uxf_typedef.h"
+#include "ico_apf_log.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _ico_uxf_conf_misc {
+ char topdir[ICO_UXF_CONF_DIR_MAX+1];
+ char confdir[ICO_UXF_CONF_DIR_MAX+1];
+ short myhostId;
+ short masterhostId;
+ char *myhostName;
+ char *myaddress;
+ char *homescreen;
+ char *masterhostaddress;
+ short default_hostId;
+ short default_kindId;
+ short default_categoryId;
+ short default_displayId;
+ short default_layerId;
+ short default_dispzoneId;
+ short default_soundId;
+ short default_soundzoneId;
+ short default_inputdevId;
+ short default_inputswId;
+ int appscontrollerport;
+ int soundpluginport;
+ int loglevel;
+ int logflush;
+} Ico_Uxf_conf_misc;
+
+typedef struct _ico_uxf_conf_host {
+ int id;
+ char *name;
+ char *address;
+ int type;
+ char *homescreen;
+} Ico_Uxf_conf_host;
+
+typedef struct _ico_uxf_conf_category {
+ int id;
+ char *name;
+ short view;
+ short type;
+ short sound;
+ short input;
+ short priority;
+ short res; /* (unused) */
+} Ico_Uxf_conf_category;
+
+typedef struct _ico_uxf_conf_kind {
+ int id;
+ char *name;
+ short priv;
+ short priority;
+} Ico_Uxf_conf_kind;
+
+typedef struct _ico_uxf_conf_appdisplay {
+ short displayId;
+ short layerId;
+ short zoneId;
+ short res; /* (unused) */
+} Ico_Uxf_conf_appdisplay;
+
+typedef struct _ico_uxf_conf_appsound {
+ short soundId;
+ short zoneId;
+} Ico_Uxf_conf_appsound;
+
+typedef struct _ico_uxf_conf_appinput {
+ short inputdevId;
+ short inputswId;
+} Ico_Uxf_conf_appinput;
+
+typedef struct _ico_uxf_conf_application {
+ char *appid;
+ char *name;
+ char *group;
+ char *exec;
+ char *type;
+ int hostId;
+ char *location;
+ char *icon_key_name;
+ short kindId;
+ short categoryId;
+ short autostart;
+ short displayzoneNum;
+ short soundzoneNum;
+ short inputdevNum;
+ Ico_Uxf_conf_appdisplay display[ICO_UXF_APPDISPLAY_MAX];
+ Ico_Uxf_conf_appsound sound[ICO_UXF_APPSOUND_MAX];
+ Ico_Uxf_conf_appinput input[ICO_UXF_APPINPUT_MAX];
+ struct _ico_uxf_conf_application *nextidhash;
+ struct _ico_uxf_conf_application *nextnamehash;
+} Ico_Uxf_conf_application;
+
+typedef struct _ico_uxf_conf_display_layer {
+ int id;
+ char *name;
+} Ico_Uxf_conf_display_layer;
+
+#define ZONE_MAX_OVERLAP (ICO_UXF_DISPLAY_ZONE_MAX-1)
+typedef struct _ico_uxf_conf_display_zone {
+ int id;
+ char *name;
+ short x;
+ short y;
+ short width;
+ short height;
+ short zoneidx;
+ short res; /* (unused) */
+ struct _ico_uxf_conf_display *display;
+ unsigned char overlapNum;
+ unsigned char overlap[ZONE_MAX_OVERLAP];
+} Ico_Uxf_conf_display_zone;
+
+typedef struct _ico_uxf_conf_display {
+ int id;
+ char *name;
+ short hostId;
+ short displayno;
+ short type;
+ short width;
+ short height;
+ short inch;
+ short layerNum;
+ short zoneNum;
+ char *wayland;
+ Ico_Uxf_conf_display_layer *layer;
+ Ico_Uxf_conf_display_zone *zone;
+} Ico_Uxf_conf_display;
+
+typedef struct _ico_uxf_conf_sound_zone {
+ int id;
+ char *name;
+ short zoneidx;
+ short res; /* (unused) */
+ struct _ico_uxf_conf_sound *sound;
+ unsigned char overlapNum;
+ unsigned char overlap[ZONE_MAX_OVERLAP];
+} Ico_Uxf_conf_sound_zone;
+
+typedef struct _ico_uxf_conf_sound {
+ int id;
+ char *name;
+ short hostId;
+ short soundno;
+ short type;
+ short zoneNum;
+ Ico_Uxf_conf_sound_zone *zone;
+} Ico_Uxf_conf_sound;
+
+typedef struct _ico_uxf_conf_inputsw {
+ struct _ico_uxf_conf_inputdev *inputdev;
+ char *name;
+ char *appid;
+} Ico_Uxf_conf_inputsw;
+
+typedef struct _ico_uxf_conf_inputdev {
+ int id;
+ char *name;
+ short inputswNum;
+ short res; /* (unused) */
+ Ico_Uxf_conf_inputsw *inputsw;
+} Ico_Uxf_conf_inputdev;
+
+typedef struct _ico_uxf_sys_config {
+ Ico_Uxf_conf_misc misc;
+ short hostNum;
+ short categoryNum;
+ short kindNum;
+ short displayNum;
+ short soundNum;
+ short inputdevNum;
+ Ico_Uxf_conf_host *host;
+ Ico_Uxf_conf_category *category;
+ Ico_Uxf_conf_kind *kind;
+ Ico_Uxf_conf_display *display;
+ Ico_Uxf_conf_sound *sound;
+ Ico_Uxf_conf_inputdev *inputdev;
+} Ico_Uxf_Sys_Config;
+
+typedef struct _ico_uxf_app_config {
+ int applicationNum;
+ Ico_Uxf_conf_application *application;
+ Ico_Uxf_conf_application *hashidtable[ICO_UXF_MISC_HASHSIZE];
+ Ico_Uxf_conf_application *hashnametable[ICO_UXF_MISC_HASHSIZE];
+} Ico_Uxf_App_Config;
+
+const Ico_Uxf_Sys_Config* ico_uxf_getSysConfig(void);
+const Ico_Uxf_Sys_Config* ico_uxf_ifGetSysConfig(void);
+const Ico_Uxf_App_Config* ico_uxf_getAppConfig(void);
+
+void ico_uxf_closeSysConfig(void);
+void ico_uxf_closeAppConfig(void);
+
+int ico_uxf_getSysKindByName(const char *skind);
+int ico_uxf_getSysCategoryByName(const char *scategory);
+int ico_uxf_getSysHostByName(const char *shost);
+int ico_uxf_getSysHostTypeByName(const char *stype);
+int ico_uxf_getSysDisplayByName(const char *sdisplay);
+int ico_uxf_getSysDispTypeByName(const char *stype);
+int ico_uxf_getSysLayerByName(const int display, const char *slayer);
+int ico_uxf_getSysDispZoneByName(const int display, const char *sdispzone);
+int ico_uxf_getSysSoundByName(const char *ssound);
+int ico_uxf_getSysSoundZoneByName(const int sound, const char *ssoundzone);
+int ico_uxf_getSysInputdevByName(const char *sinputdev);
+int ico_uxf_getSysInputswByName(const int inputdev, const char *sinputsw);
+int ico_uxf_getSysBoolByName(const char *sbool);
+int ico_uxf_getAppDisplay(const Ico_Uxf_conf_application *app, const int idx,
+ int *x, int *y, int *width, int *height);
+
+const Ico_Uxf_conf_host* ico_uxf_getSysHostById(const int hostId);
+const Ico_Uxf_conf_application* ico_uxf_getAppByAppid(const char *appid);
+const Ico_Uxf_conf_application* ico_uxf_getAppByName(const char *name);
+const Ico_Uxf_conf_category* ico_uxf_getAppCategoryById(const int categoryId);
+const Ico_Uxf_conf_display* ico_uxf_getSysDisplayById(const int displayId);
+const char *ico_uxf_get_SysLocation( const int hostId );
+
+/* define log macros */
+#ifndef uifw_trace
+#define uifw_debug ICO_UXF_DEBUG
+#define uifw_trace ICO_UXF_DEBUG
+#define uifw_critical ICO_UXF_CRITICAL
+#define uifw_info ICO_UXF_INFO
+#define uifw_warn ICO_UXF_WARN
+#define uifw_error ICO_UXF_ERROR
+#define uifw_logflush ico_uxf_log_flush
+#endif /*uifw_trace*/
+
+void ico_uxf_closeSysConfig(void);
+
+#define ICO_UXF_EVENT_WAIT_DEFAULT (0)
+#define ICO_UXF_EVENT_WAIT_WAYLAND (1)
+#define ICO_UXF_EVENT_WAIT_WEBSOCKET (2)
+#define ICO_UXF_EVENT_WAIT_JULIUS (3)
+
+#define ICO_UXF_EFFECT_NONE (0)
+#define ICO_UXF_EFFECT_GRAYOUT (1)
+#define ICO_UXF_EFFECT_BLACKOUT (2)
+#define ICO_UXF_EFFECT_INVISIBLE (3)
+#define ICO_UXF_EFFECT_TERMINATE (4)
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* ICO_UXF_CONF_H_ */
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief user experiance library public header file(configuration)
+ *
+ * @date Feb-28-2013
+ */
+
+#ifndef ICO_UXF_CONF_COMMON_H_
+#define ICO_UXF_CONF_COMMON_H_
+
+#include <glib.h>
+
+#include "ico_uxf_sysdef.h"
+#include "ico_uxf_def.h"
+#include "ico_uxf_conf.h"
+#include "ico_apf_log.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Prototyypes of configuration functions */
+int ico_uxf_conf_getUint(const char* str);
+GList* ico_uxf_conf_countNumericalKey(GKeyFile *keyfile, const char* group);
+const char* ico_uxf_conf_appendStr(const char* str1, const char* str2);
+void ico_uxf_conf_checkGerror(GError** error);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* ICO_UXF_CONF_COMMON_H_ */
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief user experiance library public header file(configuration)
+ *
+ * @date Feb-28-2013
+ */
+
+#ifndef ICO_UXF_CONF_DEF_H_
+#define ICO_UXF_CONF_DEF_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Environment variable for UI-FW top directory */
+#define ICO_UXF_TOP_ENV "UIFW_TOPDIR"
+
+/* Default top directory of UI-FW */
+#define ICO_UXF_TOP_TOPDIR "/opt/apps/org.tizen.ico.homescreen"
+
+/* Environment variable for top directory of cconfiguration files */
+#define ICO_UXF_CONFIG_ENV "UIFW_CONFDIR"
+
+/* Default top directory of cconfiguration files */
+#define ICO_UXF_CONFIG_DIR "res/config"
+
+/* Configuration file names */
+#define ICO_UXF_CONFIG_SYSTEM "system.conf"
+
+/* Directory of application manifest */
+#define ICO_UXF_CONFIG_APPSDIR "apps"
+
+/* Maximum length of the configuration directory name */
+#define ICO_UXF_CONF_DIR_MAX 63
+
+/* Maximum length of Wayland connection name */
+#define ICO_UXF_CONF_WAYLAND_NAME 39
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* ICO_UXF_CONF_DEF_H_ */
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief header file of user experience liblary for HomeScreen(define symbols)
+ *
+ * @date Feb-28-2013
+ */
+
+#ifndef _ICO_UXF_DEF_H_
+#define _ICO_UXF_DEF_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ECU type */
+#define ICO_UXF_HOSTTYPE_CENTER 0 /* Center display */
+#define ICO_UXF_HOSTTYPE_METER 1 /* Meter display */
+#define ICO_UXF_HOSTTYPE_REMOTE 2 /* Information device(mobile device)*/
+#define ICO_UXF_HOSTTYPE_PASSENGER 3 /* Passenger display */
+#define ICO_UXF_HOSTTYPE_REAR 4 /* Rear-seat entertainment */
+#define ICO_UXF_HOSTTYPE_REARLEFT 5 /* Rear-seat entertainment(Left)*/
+#define ICO_UXF_HOSTTYPE_REARRIGHT 6 /* Rear-seat entertainment(right)*/
+
+/* Default DisplayId */
+#define ICO_UXF_DISPLAY_DEFAULT 0 /* Default display */
+
+/* Display type */
+#define ICO_UXF_DISPLAYTYPE_CENTER 0 /* Center display */
+#define ICO_UXF_DISPLAYTYPE_METER 1 /* Meter display */
+#define ICO_UXF_DISPLAYTYPE_REMOTE 2 /* Information device(mobile device)*/
+#define ICO_UXF_DISPLAYTYPE_PASSENGER 3 /* Passenger display */
+#define ICO_UXF_DISPLAYTYPE_REAR 4 /* Rear-seat display */
+#define ICO_UXF_DISPLAYTYPE_REARLEFT 5 /* Rear-seat display(left) */
+#define ICO_UXF_DISPLAYTYPE_REARRIGHT 6 /* Rear-seat display(right) */
+
+/* Window active status */
+#define ICO_UXF_WINDOW_INACTIVE 0 /* not active */
+#define ICO_UXF_WINDOW_ACTIVE 1 /* active */
+#define ICO_UXF_WINDOW_SELECT 2 /* window selected by operation */
+
+/* Policy */
+#define ICO_UXF_POLICY_ALWAYS 0 /* No control */
+#define ICO_UXF_POLICY_RUNNING 1 /* Runnning only */
+#define ICO_UXF_POLICY_PARKED 2 /* Parked only */
+#define ICO_UXF_POLICY_SHIFT_PARKING 3 /* Shift-position is park */
+#define ICO_UXF_POLICY_SHIFT_REVERSES 4 /* Shift-position is reverses */
+#define ICO_UXF_POLICY_BLINKER_LEFT 5 /* Blinker is left */
+#define ICO_UXF_POLICY_BLINKER_RIGHT 6 /* Blinker is right */
+
+/* Privilege */
+#define ICO_UXF_PRIVILEGE_ALMIGHTY 0 /* almighty privilege */
+#define ICO_UXF_PRIVILEGE_SYSTEM 1 /* system level */
+#define ICO_UXF_PRIVILEGE_MAKER 2 /* maker level */
+#define ICO_UXF_PRIVILEGE_CERTIFICATE 3 /* certificated */
+#define ICO_UXF_PRIVILEGE_NONE 4 /* no privilege */
+
+/* Event values */
+#define ICO_UXF_EVENT_ALL 0xffffffff /* Mask value of all events */
+#define ICO_UXF_EVENT_VISIBLE 0x00000001 /* Change window visibility */
+#define ICO_UXF_EVENT_RESIZE 0x00000002 /* Change window position/size */
+#define ICO_UXF_EVENT_VISIBLE_REQ 0x00000004 /* Request for window visibility*/
+#define ICO_UXF_EVENT_RESIZE_REQ 0x00000008 /* request for window position/size*/
+#define ICO_UXF_EVENT_NEWWINDOW 0x00000010 /* Created new window */
+#define ICO_UXF_EVENT_DESTORYWINDOW 0x00000020 /* Destroyed a window */
+#define ICO_UXF_EVENT_ACTIVEWINDOW 0x00000040 /* Change window active status */
+#define ICO_UXF_EVENT_TERMPROCESS 0x00000200 /* Application stopped */
+#define ICO_UXF_EVENT_EXINPUT 0x00200000 /* extra input event */
+
+#define ICO_UXF_EVENT_VALIDALL 0x8020027f /* Set of the event with a meaning*/
+
+/* Application status */
+#define ICO_UXF_PROCSTATUS_STOP 0x00000000 /* Stopped */
+#define ICO_UXF_PROCSTATUS_INIT 0x00000001 /* Initializing */
+#define ICO_UXF_PROCSTATUS_RUN 0x00000002 /* Running */
+#define ICO_UXF_PROCSTATUS_TERM 0x00000004 /* Terminating */
+
+/* Window controll hook code */
+#define ICO_UXF_HOOK_WINDOW_CREATE_MAIN 0x00 /* created main window */
+#define ICO_UXF_HOOK_WINDOW_CREATE_SUB 0x01 /* created sub window */
+#define ICO_UXF_HOOK_WINDOW_DESTORY_MAIN 0x10 /* destoryed main window */
+#define ICO_UXF_HOOK_WINDOW_DESTORY_SUB 0x11 /* destoryed sub window */
+
+/* API return code */
+#define ICO_UXF_EOK 0 /* OK */
+#define ICO_UXF_EPERM -1 /* Operation not permitted */
+#define ICO_UXF_ENOENT -2 /* No such object */
+#define ICO_UXF_ESRCH -3 /* Not initialized */
+#define ICO_UXF_EIO -5 /* I/O(send/receive) error */
+#define ICO_UXF_ENXIO -6 /* Not exist */
+#define ICO_UXF_E2BIG -7 /* Buffer size too smale */
+#define ICO_UXF_EBADF -9 /* Illegal data type */
+#define ICO_UXF_EAGAIN -11 /* Try again */
+#define ICO_UXF_ENOMEM -12 /* Out of memory */
+#define ICO_UXF_EFAULT -14 /* Bad address */
+#define ICO_UXF_EBUSY -16 /* Not available now */
+#define ICO_UXF_EEXIST -17 /* Multiple define */
+#define ICO_UXF_EINVAL -22 /* Invalid argument */
+#define ICO_UXF_ENOSYS -38 /* System error */
+
+/* AppsControol control flag */
+#define ICO_UXF_APPSCTL_INVISIBLE 0x01 /* invisibled by AppsController */
+#define ICO_UXF_APPSCTL_REGULATION 0x02 /* invisibled by Regulation */
+#define ICO_UXF_APPSCTL_TEMPVISIBLE 0x10 /* tempolary visible for menu */
+
+/* Log output level */
+#define ICO_UXF_LOGLEVEL_ERROR 4 /* Error */
+#define ICO_UXF_LOGLEVEL_CRITICAL 8 /* Critical */
+#define ICO_UXF_LOGLEVEL_WARNING 16 /* Warning */
+#define ICO_UXF_LOGLEVEL_INFO 64 /* Information */
+#define ICO_UXF_LOGLEVEL_DEBUG 128 /* Debug write */
+
+/* Macros for generate hash value */
+extern int ico_uxf_misc_hashByName(const char *name);
+#define ICO_UXF_MISC_HASHSIZE 64 /* Hash table size(must be 2's factorial*/
+#define ICO_UXF_MISC_HASHBYID(v) (v & (ICO_UXF_MISC_HASHSIZE-1))
+#define ICO_UXF_MISC_HASHBYNAME(name) ico_uxf_misc_hashByName(name)
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _ICO_UXF_DEF_H_ */
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief header file of user experience library for HomeScreen
+ *
+ * @date Feb-28-2013
+ */
+
+#ifndef _ICO_UXF_PROTO_H_
+#define _ICO_UXF_PROTO_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Initialize/terminate/MainLoop/Others */
+struct wl_display;
+int ico_uxf_init(const char *name);
+ /* Initialize(for general application) */
+int ico_uxf_shutdown(void);
+ /* Terminate */
+void ico_uxf_main_loop_iterate(void);
+ /* Iterate mainLoop */
+int ico_uxf_callback_set(const unsigned int mask,
+ Ico_Uxf_Event_Cb func, const int arg);
+ /* Add event callback function */
+int ico_uxf_callback_remove(const unsigned int mask,
+ Ico_Uxf_Event_Cb func, const int arg);
+ /* Remove event callback function */
+
+/* Control window */
+int ico_uxf_window_event_mask(const int window, const unsigned int mask);
+ /* Set event to receive through the window*/
+int ico_uxf_window_attribute_get(const int window, Ico_Uxf_WindowAttr *attr);
+ /* Get window attribute */
+int ico_uxf_window_query_display(const int display, Ico_Uxf_DisplayAttr *attr);
+ /* Get display attribute */
+int ico_uxf_window_query_displays(Ico_Uxf_DisplayAttr attr[], const int num);
+ /* Get all displays attribute */
+int ico_uxf_window_query_layer(const int display, const int layer,
+ Ico_Uxf_LayerAttr *attr);
+ /* Get layer attribute */
+int ico_uxf_window_query_layers(const int display,
+ Ico_Uxf_LayerAttr attr[], const int num);
+ /* Get all layers attribute */
+int ico_uxf_window_query_windows(const int display,
+ Ico_Uxf_WindowAttr attr[], const int num);
+ /* Get all windows attribute */
+void ico_uxf_window_screen_size_get(int *width, int *height);
+ /* Get display size */
+int ico_uxf_window_layer(const int window, const int layer);
+ /* Set window layer */
+int ico_uxf_layer_visible(const int display, const int layer, const int visible);
+ /* Show/Hide layer */
+int ico_uxf_window_show(const int window);
+ /* Show window */
+int ico_uxf_window_hide(const int window);
+ /* Hide window */
+int ico_uxf_window_visible_raise(const int window,
+ const int visible, const int raise);
+ /* Set window show/hide and raise/lower */
+int ico_uxf_window_resize(const int window, const int w, const int h);
+ /* Resize window size */
+int ico_uxf_window_move(const int window, const int x, const int y);
+ /* Move window */
+int ico_uxf_window_raise(const int window);
+ /* Raise window */
+int ico_uxf_window_lower(const int window);
+ /* Lower window */
+int ico_uxf_window_active(const int window);
+ /* Activate window */
+int ico_uxf_window_control(const char *appid, const int winidx,
+ const int control, const int onoff);
+ /* Window visible control from AppsController*/
+void ico_uxf_window_hook(Ico_Uxf_Hook func);
+ /* Set window control hook */
+/* Input switch */
+Ico_Uxf_InputDev *ico_uxf_inputdev_attribute_get(const int devidx);
+ /* get input device attribute */
+Ico_Uxf_InputSw *ico_uxf_inputsw_attribute_get(Ico_Uxf_InputDev *inputdev, const int swidx);
+ /* get input switch attribute */
+int ico_uxf_input_control(const int add, const char *appid,
+ const char *device, const int input);
+ /* control input switch */
+/* Launcher API */
+int ico_uxf_process_execute(const char *name);
+ /* Start application */
+int ico_uxf_process_terminate(const char *process);
+ /* Stop application */
+int ico_uxf_process_attribute_get(const char *process, Ico_Uxf_ProcessAttr *attr);
+ /* Get application status */
+int ico_uxf_process_is_active(const char *process);
+ /* Get application activity */
+void *ico_uxf_process_exttable_get(const char *process);
+ /* Get extended table address */
+int ico_uxf_process_exttable_set(const char *process, void *table);
+ /* Set extended table address */
+int ico_uxf_process_window_get(const char *process,
+ Ico_Uxf_ProcessWin *attr, const int num);
+ /* Get all windows of one application */
+int ico_uxf_process_window_get_one(const char *process,
+ Ico_Uxf_ProcessWin *attr, const int winidx);
+ /* Get one windows of one application */
+int ico_uxf_process_query_processes(Ico_Uxf_ProcessAttr attr[], const int num);
+ /* Get all aplications attribute */
+
+/* Wayland depend function */
+int ico_uxf_wl_display_fd(void);
+ /* Get wayland connect file descriptor */
+struct wl_display *ico_uxf_wl_display(void);
+ /* Get wayland display */
+struct wl_compositor *ico_uxf_wl_compositor(void);
+ /* Get wayland compositor */
+struct wl_egl_window *ico_uxf_wl_egl_window(const int window);
+ /* Get EGL window(surface) */
+struct wl_surface *ico_uxf_wayland_surface(const int window);
+ /* Get wayland surface */
+int ico_uxf_wl_display_fd(void);
+ /* Get wayland connect file descriptor */
+#ifdef __cplusplus
+}
+#endif
+#endif /* _ICO_UXF_PROTO_H_ */
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief user experiance library public header file(system limit vaule)
+ *
+ * @date Feb-28-2013
+ */
+
+#ifndef _ICO_UXF_SYSDEF_H_
+#define _ICO_UXF_SYSDEF_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Default values */
+#define ICO_UXF_PROC_DEFAULT_HOMESCREEN "org.tizen.ico.homescreen"
+ /* Default application ID of HomeScreen */
+#define ICO_UXF_ENV_APPINF "ICO_UXF_ENV_APPINF"
+ /* The name of the environment variable that*/
+ /* an application manager hands to application*/
+/* Maximum values on system wide */
+#define ICO_UXF_HOST_MAX 16 /* Maximum number of ECUs */
+#define ICO_UXF_DISPLAY_LAYER_MAX 16 /* Maximum number of Layers */
+#define ICO_UXF_CATEGORY_MAX 20 /* Maximum number of application categorys*/
+#define ICO_UXF_DISPLAY_ZONE_MAX 10 /* Maximum zone on display in car */
+#define ICO_UXF_SOUND_ZONE_MAX 10 /* Maximum zone on sound in car */
+#define ICO_UXF_INPUT_SW_MAX 50 /* Maximum input sw in car */
+#define ICO_UXF_REGULATION_VIC_MAX 20 /* Maxumum vehicle info for regulation */
+
+/* Maximum length of string (with out last NULL) */
+#define ICO_UXF_MAX_PROCESS_NAME 63 /* Maximum length of application name */
+#define ICO_UXF_MAX_WIN_NAME 23 /* Maximum length of window name */
+#define ICO_UXF_MAX_DISP_NAME 23 /* Maximum length of display name */
+#define ICO_UXF_MAX_SOUND_NAME 23 /* Maximum length of sound device name */
+#define ICO_UXF_MAX_DEVICE_NAME 63 /* Maximum length of resource device name*/
+#define ICO_UXF_MAX_STREAM_NAME 63 /* Maximum length of sound stream name */
+
+/* Maximum values on each application */
+#define ICO_UXF_APPDISPLAY_MAX 5 /* Maximum display zones for a application*/
+#define ICO_UXF_APPSOUND_MAX 5 /* Maximum sound zones for a application*/
+#define ICO_UXF_APPINPUT_MAX 20 /* Maximum input switch for a application*/
+
+/* Number to manage the processing internall block */
+#define ICO_UXF_MNG_BLOCK_ALLOCS 20 /* Number to assign dynamic management block*/
+
+/* Priority of resource */
+#define ICO_UXF_PRIO_INTSCREEN 0x00000080 /* interrupt screen on basic screen */
+#define ICO_UXF_PRIO_CATEGORY 0x00000100 /* application category */
+#define ICO_UXF_PRIO_ACTIVEAPP 0x0fff0000 /* active application count */
+#define ICO_UXF_PRIO_ACTIVECOUNT 0x00010000 /* active application */
+#define ICO_UXF_PRIO_ONSCREEN 0x10000000 /* interrupt screen/sound */
+#define ICO_UXF_PRIO_REGULATION 0x40000000 /* no regulation controlled */
+
+/* maximum value */
+#define ICO_UXF_MAX_COORDINATE 16384 /* maximum coordinate position + 1 */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _ICO_UXF_SYSDEF_H_ */
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief header file of user experience library for HomeScreen(data structure)
+ *
+ * @date Feb-28-2013
+ */
+
+#ifndef _ICO_UXF_TYPEDEF_H_
+#define _ICO_UXF_TYPEDEF_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Structure of display attribute */
+typedef struct _Ico_Uxf_DisplayAttr {
+ int display; /* Display ID */
+ int type; /* Type */
+ short num_layers; /* Number of layers */
+ short hostId; /* Host ID */
+ short displayNo; /* Consecutive numbers */
+ short w; /* The number of the lateral pixels */
+ short h; /* The number of vertical pixels */
+ short inch; /* Screen physical size(0.1 inches of units)*/
+ short pWidth; /* compositor width */
+ short pHeight; /* compositor height */
+ short orientation;
+#define ICO_UXF_ORIENTATION_HORIZONTAL (0)
+#define ICO_UXF_ORIENTATION_VERTICAL (1)
+ char name[ICO_UXF_MAX_WIN_NAME+1];
+ /* Display name */
+} Ico_Uxf_DisplayAttr;
+
+/* Structure of layer attribute */
+typedef struct _Ico_Uxf_LayerAttr {
+ int layer; /* Layer ID */
+ int display; /* Display ID */
+ short w; /* The number of the lateral pixels */
+ short h; /* The number of vertical pixels */
+} Ico_Uxf_LayerAttr;
+
+/* Structure of display zone attribute */
+typedef struct _Ico_Uxf_DispZoneAttr {
+ int zone; /* Zone ID */
+ int display; /* Display ID */
+ short x; /* Left upper X coordinate of the screen*/
+ short y; /* Left upper Y coordinate of the screen*/
+ short w; /* The number of the lateral pixels */
+ short h; /* The number of vertical pixels */
+} Ico_Uxf_DispZoneAttr;
+
+/* Structure of window attribute */
+typedef struct _Ico_Uxf_WindowAttr {
+ int window; /* Window ID */
+ int display; /* Display ID */
+ int layer; /* Layer ID */
+ int zone; /* Display Zone ID */
+ char process[ICO_UXF_MAX_PROCESS_NAME+1];
+ /* Application ID */
+ int subwindow; /* Main window(=0) or Sub window(>0) */
+ unsigned int eventmask; /* Event to receive through this window */
+ short x; /* Upper left X coordinate of the window*/
+ short y; /* Upper left Y coordinate of the window*/
+ short w; /* Width of window */
+ short h; /* height of window */
+ char control; /* Visibility control from AppsController*/
+ char visible; /* Visibility */
+ char raise; /* Raise/Lower */
+ char active; /* Active/Inactive */
+} Ico_Uxf_WindowAttr;
+
+/* Structure of input code */
+typedef struct _Ico_Uxf_InputCode {
+ int code; /* input switch code value */
+ char codename[20]; /* input switch code name */
+} Ico_Uxf_InputCode;
+
+/* Structure of input switch */
+typedef struct _Ico_Uxf_InputSw {
+ struct _Ico_Uxf_InputSw *next; /* next input switch table */
+ char swname[20]; /* input switch name */
+ int input; /* input switch number */
+ short fix; /* fixed application switch */
+ short numCode; /* number of codes */
+ Ico_Uxf_InputCode inputCode[8]; /* code table */
+} Ico_Uxf_InputSw;
+
+/* Structure of input device */
+typedef struct _Ico_Uxf_InputDev {
+ struct _Ico_Uxf_InputDev *next; /* next input device */
+ char device[32]; /* input device name */
+ int type; /* input device type(unused) */
+ int numInputSw; /* number of input switch */
+ Ico_Uxf_InputSw *inputSw; /* input switch list */
+} Ico_Uxf_InputDev;
+
+/* Structure of window of application */
+typedef struct _Ico_Uxf_ProcessWin {
+ int window; /* Window ID */
+ /* (0 if window not create) */
+ int windowtype; /* Type */
+ int display; /* Display ID */
+ int layer; /* Layer ID */
+ int zone; /* Zone ID */
+ short x; /* Default X coordinate of the window */
+ short y; /* Default Y coordinate of the window */
+ short w; /* Default width of window */
+ short h; /* Default height of window */
+ char name[ICO_UXF_MAX_WIN_NAME+1];
+ /* Window name */
+} Ico_Uxf_ProcessWin;
+
+/* Structure of application attribute */
+typedef struct _Ico_Uxf_ProcessAttr {
+ char process[ICO_UXF_MAX_PROCESS_NAME+1];
+ /* Application ID */
+ int internalid; /* ProcessID */
+ int type; /* Type */
+ short hostId; /* Host ID who works of the application */
+ short myHost; /* Works in my host(=1) or Other host(=0)*/
+ short numwindows; /* Number of windows */
+ short numsounds; /* Number of sound */
+ short numinputs; /* Number of input */
+ Ico_Uxf_ProcessWin mainwin; /* Main window of application */
+ Ico_Uxf_ProcessWin *subwin; /* Sub window of application */
+ short status; /* Running status */
+ char active; /* Active/Inactive */
+ char res; /* (unused) */
+} Ico_Uxf_ProcessAttr;
+
+/* Detail of event */
+typedef union _Ico_Uxf_EventDetail {
+ int event; /* Event number */
+ struct { /* Window event */
+ int event; /* Event number */
+ /* Event about the state conversion of the window */
+ /* ICO_UXF_EVENT_VISIBLE,RESIZE,MOVE,REDRAW,NEWWINDOW,DESTORYWINDOW */
+ int display; /* Display ID */
+ int window; /* Window ID */
+ int layer; /* layer ID */
+ short x; /* Window position */
+ short y;
+ short w; /* Window size */
+ short h;
+ char visible; /* Visibility */
+ char raise; /* Raise/Lower */
+ char active; /* Active/inactive(not impliment) */
+ char res; /* (unuse) */
+ } window;
+
+ struct { /* Application event */
+ int event; /* Event number */
+ /* Event about the operating conditions change of the application */
+ /* TERMPROCESS */
+ char process[ICO_UXF_MAX_PROCESS_NAME+1];
+ /* Application ID */
+ int status; /* Running status */
+ int regulation; /* Current regulation */
+ } process;
+
+ struct { /* Input Manager event */
+ int event; /* Event number */
+ /* Multi Input Manager event */
+ /* ICO_UXF_EVENT_EXINPUT */
+ char device[32]; /* input device name */
+ int input; /* input number */
+ int code; /* input code */
+ int state; /* input status */
+ } exinput;
+
+} Ico_Uxf_EventDetail;
+
+/* Event callback function */
+typedef void (*Ico_Uxf_Event_Cb)(const int event,
+ const Ico_Uxf_EventDetail detail, int arg);
+
+/* Hook function */
+typedef void (*Ico_Uxf_Hook)(const char *appid, const int info1, const int info2);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _ICO_UXF_TYPEDEF_H_ */
+
--- /dev/null
+#!/bin/sh
+
+rm -rf /opt/apps/org.tizen.ico.dummy*
+rm -rf /opt/share/applications/org.tizen.ico.dummy*
+
+#library(libico-app-fw)
+rm -fr /usr/lib/libico-app-fw-efl.*
+cp ico-app-framework/.libs/libico-app-fw-efl.so.0.0.5 /usr/lib
+ln -s /usr/lib/libico-app-fw-efl.so.0.0.5 /usr/lib/libico-app-fw-efl.so.0
+ln -s /usr/lib/libico-app-fw-efl.so.0.0.5 /usr/lib/libico-app-fw-efl.so
+chmod 0755 /usr/lib/libico-app-fw-efl.so.0.0.5
+rm -fr /usr/lib/libico-app-fw.*
+cp ico-app-framework/.libs/libico-app-fw.so.0.0.5 /usr/lib
+ln -s /usr/lib/libico-app-fw.so.0.0.5 /usr/lib/libico-app-fw.so.0
+ln -s /usr/lib/libico-app-fw.so.0.0.5 /usr/lib/libico-app-fw.so
+chmod 0755 /usr/lib/libico-app-fw.so.0.0.5
+
+#HomeScreen
+HOMESCREEN=org.tizen.ico.homescreen
+rm -rf /opt/apps/$HOMESCREEN/var
+rm -rf /opt/apps/$HOMESCREEN/res
+mkdir -p /opt/apps/$HOMESCREEN/res/images
+mkdir -p /opt/apps/$HOMESCREEN/res/edj
+mkdir -p /opt/apps/$HOMESCREEN/res/config
+cp -rf res/config /opt/apps/$HOMESCREEN/res
+cp -rf data/apps/$HOMESCREEN /opt/apps/
+mkdir -p /opt/apps/$HOMESCREEN/bin/
+cp src/HomeScreen /opt/apps/$HOMESCREEN/bin/
+cp src/home_screen_bg.edj /opt/apps/$HOMESCREEN/res/edj
+cp src/home_screen_touch.edj /opt/apps/$HOMESCREEN/res/edj
+chmod 666 /opt/apps/$HOMESCREEN/res/edj/home_screen_*
+cp res/images/api_all_off.png /opt/apps/$HOMESCREEN/res/images
+cp res/images/api_all_on.png /opt/apps/$HOMESCREEN/res/images
+chmod 666 /opt/apps/$HOMESCREEN/res/images/api_all_*
+cp data/share/applications/$HOMESCREEN.desktop /opt/share/applications/
+cp res/apps/$HOMESCREEN/* /opt/apps/$HOMESCREEN/res/config
+
+#StatusBar
+PKGNAME=org.tizen.ico.statusbar
+rm -rf /opt/apps/$PKGNAME/res
+mkdir -p /opt/apps/$PKGNAME/res/images
+mkdir -p /opt/apps/$PKGNAME/res/edj
+mkdir -p /opt/apps/$PKGNAME/res/config
+cp -rf data/apps/$PKGNAME /opt/apps/
+mkdir -p /opt/apps/$PKGNAME/bin/
+cp src/StatusBar /opt/apps/$PKGNAME/bin/
+cp res/images/time*.png /opt/apps/$PKGNAME/res/images
+chmod 666 /opt/apps/$PKGNAME/res/images/time*.png
+cp data/share/applications/$PKGNAME.desktop /opt/share/applications/
+cp res/apps/$PKGNAME/* /opt/apps/$PKGNAME/res/config
+
+#OnScreen
+PKGNAME=org.tizen.ico.onscreen
+rm -rf /opt/apps/$PKGNAME/res
+mkdir -p /opt/apps/$PKGNAME/res/images
+mkdir -p /opt/apps/$PKGNAME/res/edj
+mkdir -p /opt/apps/$PKGNAME/res/config
+cp -rf data/apps/$PKGNAME /opt/apps/
+mkdir -p /opt/apps/$PKGNAME/bin/
+cp src/OnScreen /opt/apps/$PKGNAME/bin/
+cp src/appli_list.edj /opt/apps/$PKGNAME/res/edj
+cp src/appli_kill.edj /opt/apps/$PKGNAME/res/edj
+chmod 666 /opt/apps/$PKGNAME/res/edj/*.edj
+chmod 666 /opt/apps/$PKGNAME/res/images/*.png
+cp data/share/applications/$PKGNAME.desktop /opt/share/applications/
+cp res/apps/$PKGNAME/* /opt/apps/$PKGNAME/res/config
+
+#delete dummy apps
+rm -rf /opt/apps/org.tizen.ico.sample.*
+rm -f /opt/share/applications/org.tizen.ico.sample.*
+
+#reload AppCore database
+cd /opt/dbspace
+rm -rf .app_info*
+/usr/bin/ail_initdb
+
--- /dev/null
+#!/bin/sh
+killall ico_ictl-touch_egalax 2> /dev/null
+killall weston 2> /dev/null
+killall org.tizen.ico.homescreen 2> /dev/null
+
+killall HomeScreen 2> /dev/null
+
+sleep 2
+
+killall -9 org.tizen.ico.homescreen 2> /dev/null
+killall -9 HomeScreen 2> /dev/null
+killall -9 weston 2> /dev/null
+killall -9 ico_ictl-touch_egalax 2> /dev/null
+
+killall -9 OnScreen 2> /dev/null
+killall -9 StatusBar 2> /dev/null
+killall -9 browser 2> /dev/null
+killall -9 gallery 2> /dev/null
+killall -9 music-player 2> /dev/null
+killall -9 setting 2> /dev/null
+killall -9 calendar 2> /dev/null
+killall -9 dialer 2> /dev/null
+killall -9 calculator 2> /dev/null
+killall -9 memo 2> /dev/null
+killall -9 smartsearch 2> /dev/null
+
--- /dev/null
+* Fri Apr 26 2013 Shibata Makoto <shibata@mac.tec.toyota.co.jp> d21d2c0
+- Import initial.
+
--- /dev/null
+Name: ico-uxf-HomeScreen
+Summary: sample homescreen
+Version: 0.3.01
+Release: 1.1
+Group: TO_BE/FILLED_IN
+License: Apache License, Version 2.0
+URL: ""
+Source0: %{name}-%{version}.tar.bz2
+
+BuildRequires: pkgconfig(wayland-client) >= 1.0
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: ico-uxf-weston-plugin-devel >= 0.5.0
+BuildRequires: pkgconfig(eina)
+BuildRequires: pkgconfig(evas)
+BuildRequires: pkgconfig(eina)
+BuildRequires: pkgconfig(edje)
+BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(ecore-wayland)
+BuildRequires: pkgconfig(ecore-x)
+BuildRequires: pkgconfig(dbus-1)
+BuildRequires: pkgconfig(json-glib-1.0)
+BuildRequires: pkgconfig(aul)
+BuildRequires: pkgconfig(bundle)
+BuildRequires: pkgconfig(ail)
+BuildRequires: libwebsockets-devel
+BuildRequires: capi-base-common-devel
+BuildRequires: edje-tools
+Requires: weston >= 1.0
+Requires: ico-uxf-weston-plugin >= 0.5.0
+
+%description
+sample homescreen application
+
+%package devel
+Summary: Development files for %{name}
+Group: Development/GUI/Libraries
+Requires: %{name} = %{version}-%{release}
+Requires: capi-base-common-devel
+Requires: pkgconfig(eina)
+Requires: pkgconfig(evas)
+Requires: pkgconfig(eina)
+Requires: pkgconfig(edje)
+Requires: pkgconfig(elementary)
+Requires: pkgconfig(ecore-wayland)
+Requires: pkgconfig(ecore-x)
+
+%description devel
+Development files for application that communicate homescreen.
+
+%prep
+%setup -q -n %{name}-%{version}
+
+%define PREFIX /opt/apps/
+
+%build
+autoreconf --install
+
+%autogen
+
+%configure
+make %{?_smp_mflags}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%define ictl_conf /opt/etc/ico-uxf-device-input-controller
+mkdir -p %{buildroot}/opt/share/applications/
+
+# include
+mkdir -p %{buildroot}/%{_includedir}/ico-appfw/
+cp -f include/ico_apf.h %{buildroot}/%{_includedir}/ico-appfw/
+cp -f include/ico_apf_error.h %{buildroot}/%{_includedir}/ico-appfw/
+cp -f include/ico_apf_resource_control.h %{buildroot}/%{_includedir}/ico-appfw/
+cp -f include/ico_apf_ecore.h %{buildroot}/%{_includedir}/ico-appfw/
+cp -f include/ico_apf_log.h %{buildroot}/%{_includedir}/ico-appfw/
+cp -f include/ico_uxf_sysdef.h %{buildroot}/%{_includedir}/ico-appfw/
+
+# homescreen
+%define APP org.tizen.ico.homescreen
+%define APPSDIR %{PREFIX}/%{APP}
+mkdir -p %{buildroot}%{APPSDIR}/bin/
+mkdir -p %{buildroot}%{APPSDIR}/res/edj
+mkdir -p %{buildroot}%{APPSDIR}/res/images
+mkdir -p %{buildroot}%{APPSDIR}/res/config
+cp -rf data/apps/%{APP} %{buildroot}/%{PREFIX}/
+cp -rf res/config %{buildroot}%{APPSDIR}/res/
+cp -rf res/apps/%{APP}/* %{buildroot}%{APPSDIR}/res/config/
+install -m 0755 src/HomeScreen %{buildroot}%{APPSDIR}/bin/
+install -m 0644 src/home_screen_bg.edj %{buildroot}%{APPSDIR}/res/edj
+install -m 0644 src/home_screen_touch.edj %{buildroot}%{APPSDIR}/res/edj
+install -m 0644 res/images/api_all_off.png %{buildroot}%{APPSDIR}/res/images
+install -m 0644 res/images/api_all_on.png %{buildroot}%{APPSDIR}/res/images
+install -m 0644 data/share/applications/%{APP}.desktop %{buildroot}/opt/share/applications/
+
+#statusbar
+%define APP org.tizen.ico.statusbar
+%define APPSDIR %{PREFIX}/%{APP}
+mkdir -p %{buildroot}%{APPSDIR}/bin/
+mkdir -p %{buildroot}%{APPSDIR}/res/edj
+mkdir -p %{buildroot}%{APPSDIR}/res/images
+mkdir -p %{buildroot}%{APPSDIR}/res/config
+cp -rf data/apps/%{APP} %{buildroot}/%{PREFIX}/
+cp -rf res/apps/%{APP}/* %{buildroot}%{APPSDIR}/res/config/
+install -m 0755 src/StatusBar %{buildroot}%{APPSDIR}/bin/
+install -m 0644 res/images/time*.png %{buildroot}%{APPSDIR}/res/images/
+install -m 0644 data/share/applications/%{APP}.desktop %{buildroot}/opt/share/applications/
+
+#onscreen
+%define APP org.tizen.ico.onscreen
+%define APPSDIR %{PREFIX}/%{APP}
+mkdir -p %{buildroot}%{APPSDIR}/bin/
+mkdir -p %{buildroot}%{APPSDIR}/res/edj
+mkdir -p %{buildroot}%{APPSDIR}/res/images
+mkdir -p %{buildroot}%{APPSDIR}/res/config
+cp -rf data/apps/%{APP} %{buildroot}/%{PREFIX}/
+cp -rf res/apps/%{APP}/* %{buildroot}%{APPSDIR}/res/config/
+install -m 0755 src/OnScreen %{buildroot}%{APPSDIR}/bin/
+install -m 0644 src/appli_list.edj %{buildroot}%{APPSDIR}/res/edj/
+install -m 0644 src/appli_kill.edj %{buildroot}%{APPSDIR}/res/edj/
+install -m 0644 data/share/applications/%{APP}.desktop %{buildroot}/opt/share/applications/
+
+#settings
+mkdir -p %{buildroot}/opt/etc/ico/
+install -m 0644 settings/mediation_table.txt %{buildroot}/opt/etc/ico/
+mkdir -p %{buildroot}/etc/rc.d/init.d/
+install -m 0755 settings/ico_weston %{buildroot}/etc/rc.d/init.d/
+
+%files
+%defattr(-,root,root,-)
+%{PREFIX}/org.tizen.ico.homescreen
+%{PREFIX}/org.tizen.ico.statusbar
+%{PREFIX}/org.tizen.ico.onscreen
+/opt/share/applications/*.desktop
+
+%{_libdir}/*.so*
+%{_bindir}/ico_*
+
+/opt/etc/ico/mediation_table.txt
+/etc/rc.d/init.d/ico_weston
+
+%files devel
+%defattr(-,root,root,-)
+%{_includedir}/ico-appfw/ico_apf.h
+%{_includedir}/ico-appfw/ico_apf_error.h
+%{_includedir}/ico-appfw/ico_apf_resource_control.h
+%{_includedir}/ico-appfw/ico_apf_ecore.h
+%{_includedir}/ico-appfw/ico_apf_log.h
+%{_includedir}/ico-appfw/ico_uxf_sysdef.h
+%{_libdir}/*.so*
--- /dev/null
+[homescreen]
+tileinfo_rowcnt=3
+tileinfo_colcnt=5
+tileinfo_valid=1;0;1;1;0;0;0;1;1;1;1;1;0;1;1
+tileinfo_type=22;0;11;12;0;0;0;21;11;11;11;11;0;11;0
+tileinfo_app0=org.tizen.browser
+tileinfo_app3=org.tizen.music-player
+tileinfo_app2=org.tizen.gallery
+tileinfo_app7=org.tizen.setting
+tileinfo_app8=org.tizen.calendar
+tileinfo_app9=org.tizen.dialer
+tileinfo_app10=org.tizen.calculator
+tileinfo_app11=org.tizen.memo
+tileinfo_app13=org.tizen.smartsearch
+
+statusbar=org.tizen.ico.statusbar
+onscreen=org.tizen.ico.onscreen
+
+bgimage=/opt/share/settings/Wallpapers/Home_default.jpg
+
+[sound]
+#configuration for sounds
+sound_default=/usr/share/sounds/mm-camcorder/af_succeed.wav
+
--- /dev/null
+## onscreen private configration
+[onscreen]
+wsport=10001
+#orientaion(1:VERTICAL, 2:HORIZONTAL)
+#orientaion=2
+
+
+[sound]
+#configuration for sounds
+sound_default=/usr/share/sounds/mm-camcorder/af_succeed.wav
+
--- /dev/null
+## statusbar private configration
+[statusbar]
+wsport=10001
+#orientaion(1:VERTICAL, 2:HORIZONTAL)
+#orientaion=2
+
+[sound]
+#configuration for sounds
+sound_default=/usr/share/sounds/mm-camcorder/af_succeed.wav
--- /dev/null
+## OpenPF System Configurations
+## /opt/etc/ico-system-controller/system/system.conf
+## Feb-15-2013
+
+## System ECUs
+[host]
+## Center Display ECU
+# ECU name
+0=Center
+# ECU type
+0.type=Center
+# IP address(if environment valiable'SYSHOSTIP0' NOT defined)
+0.ip=127.0.0.1
+# This ECU has HomeScreen(null:no, not null:applicationId of HomeScreen)
+0.homescreen=org.tizen.ico.homescreen
+#
+
+## Displays
+[display]
+## Center Display
+# Display name
+0=Center
+# ECU name
+0.host=Center
+# Display Number
+0.displayno=0
+# Wayland connection name(ex.'wayland-0')
+0.wayland=wayland-0
+# Display Type
+0.type=Center
+# Display Size
+0.width=1920
+0.height=1080
+# number of Layers
+0.layer=5
+# inch (in 0.1 inchs)
+0.inch=101
+# Display Layer
+0.layer.0=BackGround
+0.layer.1=HomeScreen
+0.layer.2=Application
+0.layer.3=Touch
+0.layer.4=OnScreen
+# Display Zone
+## id=name;x;y;width;height[;overlap-zone;overlap-zone;...]
+## if 'id=name', size is all of display, no overlap
+0.zone.0=Base
+0.zone.1=Full;0;64;dispw;disph-64;Upper;Lower;UpperLeft;UpperRight;LowerLeft;LowerRight
+0.zone.2=Upper;0;64;dispw;disph-64/2;Full;UpperLeft;UpperRight
+0.zone.3=Lower;0;heigh-64/2+64;dispw;disph-64/2;Full;LowerLeft;LowerRight
+0.zone.4=UpperLeft;0;64;dispw/2;disph-64/2;Full;Upper
+0.zone.5=UpperRight;dispw/2;64;dispw/2;disph-64/2;Full;Upper
+0.zone.6=LowerLeft;0;heigh-64/2+64;dispw/2;disph-64/2;Full;Lower
+0.zone.7=LowerRight;dispw/2;heigh-64/2+64;dispw/2;disph-64/2;Full;Lower
+#
+## Sound
+[sound]
+## Center ECU
+# Sound device name
+0=Center
+# ECU name
+0.host=Center
+# Device Number
+0.soundno=0
+# Sound Zone
+## id=name[;overlap;overlap-zone;overlap-zone;...]
+0.zone.0=Base
+0.zone.1=Full
+0.zone.2=Driver
+
+## Port Numbers
+[port]
+# AppsController Port Number
+appscontrollerport=18081
+# PulseAudio UIFW-PlugIn Port Number
+soundpluginport=8088
+
+## Application Category name
+[category]
+0=Menu
+0.type=system
+0.view=always
+0.sound=always
+0.input=always
+0.priority=4
+1=Message
+1.type=message
+1.view=always
+1.sound=always
+1.input=always
+1.priority=5
+2=Map
+2.type=map
+2.view=always
+2.sound=always
+2.input=always
+2.priority=3
+3=Driving
+3.type=maker
+3.view=run
+3.sound=run
+3.input=run
+3.priority=2
+4=CarSetting
+4.type=maker
+4.view=parked
+4.sound=parked
+4.input=parked
+4.priority=2
+5=Camera.Back
+5.type=maker
+5.view=shift_back
+5.sound=shift_back
+5.input=shift_back
+5.priority=6
+6=Camera.Left
+6.type=maker
+6.view=blinker_left
+6.sound=blinker_left
+6.input=blinker_left
+6.priority=6
+7=Camera.Right
+7.type=maker
+7.view=blinker_right
+7.sound=blinker_right
+7.input=blinker_right
+7.priority=6
+8=Entertainment
+8.type=unknown
+8.view=parked
+8.sound=parked
+8.input=parked
+8.priority=0
+9=Entertainment.audio
+9.type=unknown
+9.view=parked
+9.sound=always
+9.input=always
+9.priority=0
+10=Entertainment.visiual
+10.type=unknown
+10.view=always
+10.sound=parked
+10.input=always
+10.priority=0
+#
+## Application Kind
+[kind]
+0=SysApp
+0.privilege=almighty
+0.priority=4
+1=HomeScreen
+1.privilege=system
+1.priority=3
+2=Maker
+2.privilege=maker
+2.priority=2
+3=Certificate
+3.privilege=certificate
+3.priority=1
+4=UnKnown
+4.privilege=none
+4.priority=0
+#
+## Input Sw
+[input]
+0=DrivingForceGT
+0.sw.0=JS_UpDown
+0.sw.1=JS_LR
+0.sw.2=JS_Cross;org.tizen.ico.app-soundsample
+0.sw.3=JS_Square;org.tizen.ico.homescreen
+0.sw.4=JS_Circle;org.tizen.ico.app-soundsample
+0.sw.5=JS_Triangle;org.tizen.ico.homescreen
+#
+## Default target
+[default]
+host=Center
+kind=UnKnown
+category=Entertainment.audio
+display=Center
+layer=Application
+displayzone=Full
+sound=Center
+soundzone=Full
+inputdev=DrivingForceGT
+inputsw=JS_UpDown
+#
+## default transition
+[transition]
+transition=none
+#
+## Log
+[log]
+# loglevel:ERROR=4,CRITICAL=8,WARNING=16,INFO=64,DEBUG=128
+loglevel=128
+# log flush on log output
+logflush=yes
+
+#
+## default categories for each application
+[app-category]
+DemoMeterApp=Map
+
--- /dev/null
+#! /bin/sh
+# Provides: weston
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Weston compositor boot script for ico-ivi
+# Description: This script starts the Weston compositor and ico-uxf-HomeScreen at boot.
+
+# Do NOT "set -e"
+
+backend=
+
+# Use the Weston DRM backend if $DISPLAY is set and X isn't running
+#since Weston won't be able use the X11 backend.
+#
+# This allows this script to start Weston with either the X11 or DRM
+#backends.
+if [ -z `pidof Xorg` ] && [ -n "$DISPLAY" ]; then
+ backend="--backend=drm-backend.so"
+fi
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC="Weston compositor"
+NAME=weston
+DAEMON=/usr/bin/weston
+DAEMON_ARGS="$backend --idle-time=0 --log=/var/log/weston.log"
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+export HOME="/opt/home/root"
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
+# and status_of_proc is working.
+. /lib/lsb/init-functions
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+ # Make sure we have a sane XDG_RUNTIME_DIR environment
+ # variable set.
+ if [ -z "${XDG_RUNTIME_DIR}" ]; then
+ . /etc/profile.d/weston.sh
+ fi
+
+ # Return
+ # 0 if daemon has been started
+ # 1 if daemon was already running
+ # 2 if daemon could not be started
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
+ || return 1
+
+ # kill pulseaudio and weston, and start pulseaudio
+ /usr/bin/killall pulseaudio > /dev/null 2>&1
+ /usr/bin/killall weston > /dev/null 2>&1
+ /bin/sleep 0.2
+ /usr/bin/killall -9 pulseaudio > /dev/null 2>&1
+ /usr/bin/killall -9 weston > /dev/null 2>&1
+ /bin/sleep 0.2
+ /usr/bin/pulseaudio --system &
+ /bin/sleep 0.2
+
+ # Start Device Input Controller for eGalax TouchPanel
+ #/usr/bin/ico_ictl-touch_egalax -t
+ /usr/bin/ico_ictl-touch_egalax
+ # Remove weston log
+ /bin/rm -f /var/log/weston.log
+ /bin/ps ax | /bin/grep launchpad_preloading | /bin/grep -v grep > /dev/null
+ if [ "$?" = "0" ] ; then
+ /usr/bin/killall launchpad_preloading_preinitializing_daemon
+ /bin/sleep 0.3
+ fi
+ /usr/bin/launchpad_preloading_preinitializing_daemon &
+
+ # start-stop-daemon --start --background --quiet --pidfile $PIDFILE --exec $DAEMON -- \
+ # $DAEMON_ARGS \
+ # || return 2
+ $DAEMON $DAEMON_ARGS &
+ weston_pid=$!
+ /bin/sleep 0.2
+
+ if [ $weston_pid = 0 ]; then
+ return 2
+ else
+ echo $weston_pid > $PIDFILE
+ fi
+
+ # Add code here, if necessary, that waits for the process to be ready
+ # to handle requests from services started subsequently which depend
+ # on this one. As a last resort, sleep for some time.
+
+ # ************************************************************
+ # HACK TO WORK AROUND INSUFFICIENT ACCESS PERMISSIONS FOR
+ # UNPRIVILEGED USERS.
+ #
+ # Ideally we should launch weston with weston-launch with the
+ # appropriate --user flag. Unfortunately, weston-launch isn't
+ # available due to missing package dependencies.
+ # ************************************************************
+ wayland_socket="$XDG_RUNTIME_DIR/wayland-0"
+ MAX_ATTEMPTS=8
+ attempt=0
+ while [ ! -f $wayland_socket ] && [ $attempt -lt $MAX_ATTEMPTS ]
+ do
+ /bin/sleep 0.5
+ attempt=$[$attempt + 1]
+ done
+ /bin/chmod 777 $wayland_socket
+
+ # Start wayland-client for display mouse cursor
+ #/usr/bin/nice -19 /usr/bin/wayland-smoke &
+
+ ## if pulseaudio dose not start ... kick pulseaudio
+ /bin/ps ax | /bin/grep pulseaudio | /bin/grep -v grep > /dev/null
+ if [ "$?" = "1" ] ; then
+ /usr/bin/pulseaudio --system &
+ /bin/sleep 1
+ fi
+
+ # Start HomeScreen
+ /bin/sleep 1
+ /bin/mkdir /tmp/log/
+ /bin/chmod -R 0777 /tmp/log
+ /bin/rm -f /tmp/log/*
+ /usr/bin/killall menu-screen
+ /usr/bin/killall menu-daemon
+ /usr/bin/killall power_manager
+ /usr/bin/launch_app org.tizen.ico.homescreen &
+
+ # ***********************************************************
+ # HACK TO WORK AROUND BROKEN INFINITE LOOPS IN BOOT ANIMATION
+ # VIRTUAL KEYBOARD BOOT SCRIPTS.
+ # ***********************************************************
+ touch /tmp/.X0-lock
+ touch /tmp/.wm_ready
+ # ***********************************************************
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+ # Return
+ # 0 if daemon has been stopped
+ # 1 if daemon was already stopped
+ # 2 if daemon could not be stopped
+ # other if a failure occurred
+ #start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
+ start-stop-daemon --stop --quiet --pidfile $PIDFILE --name $NAME
+ RETVAL="$?"
+ [ "$RETVAL" = 2 ] && return 2
+ # Wait for children to finish too if this is a daemon that forks
+ # and if the daemon is only ever run from this initscript.
+ # If the above conditions are not satisfied then add some other code
+ # that waits for the process to drop all resources that could be
+ # needed by services started subsequently. A last resort is to
+ # sleep for some time.
+ #start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
+ start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
+ [ "$?" = 2 ] && return 2
+ # Many daemons don't delete their pidfiles when they exit.
+ rm -f $PIDFILE
+ return "$RETVAL"
+}
+
+#
+# Function that sends a SIGHUP to the daemon/service
+#
+do_reload() {
+ #
+ # If the daemon can reload its configuration without
+ # restarting (for example, when it is sent a SIGHUP),
+ # then implement that here.
+ #
+ start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
+ return 0
+}
+
+case "$1" in
+ start)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+ do_start
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ stop)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ status)
+ status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+ ;;
+ #reload|force-reload)
+ #
+ # If do_reload() is not implemented then leave this commented out
+ # and leave 'force-reload' as an alias for 'restart'.
+ #
+ #log_daemon_msg "Reloading $DESC" "$NAME"
+ #do_reload
+ #log_end_msg $?
+ #;;
+ restart|force-reload)
+ #
+ # If the "reload" option is implemented then remove the
+ # 'force-reload' alias
+ #
+ log_daemon_msg "Restarting $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1)
+ do_start
+ case "$?" in
+ 0) log_end_msg 0 ;;
+ 1) log_end_msg 1 ;; # Old process is still running
+ *) log_end_msg 1 ;; # Failed to start
+ esac
+ ;;
+ *)
+ # Failed to stop
+ log_end_msg 1
+ ;;
+ esac
+ ;;
+ *)
+ #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
+ echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
+ exit 3
+ ;;
+esac
+
+:
--- /dev/null
+#! /bin/sh
+# Provides: weston
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Weston compositor boot script for ico-ivi
+# Description: This script starts the Weston compositor and ico-uxf-HomeScreen at boot.
+
+# Do NOT "set -e"
+
+backend=
+
+# Use the Weston DRM backend if $DISPLAY is set and X isn't running
+#since Weston won't be able use the X11 backend.
+#
+# This allows this script to start Weston with either the X11 or DRM
+#backends.
+if [ -z `pidof Xorg` ] && [ -n "$DISPLAY" ]; then
+ backend="--backend=drm-backend.so"
+fi
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC="Weston compositor"
+NAME=weston
+DAEMON=/usr/bin/weston
+DAEMON_ARGS="$backend --idle-time=0 --log=/var/log/ico/weston.log"
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+export HOME="/opt/home/root"
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
+# and status_of_proc is working.
+. /lib/lsb/init-functions
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+ # Make sure we have a sane XDG_RUNTIME_DIR environment
+ # variable set.
+ if [ -z "${XDG_RUNTIME_DIR}" ]; then
+ . /etc/profile.d/weston.sh
+ fi
+
+ # Return
+ # 0 if daemon has been started
+ # 1 if daemon was already running
+ # 2 if daemon could not be started
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
+ || return 1
+
+ # make and clean log
+ /bin/mkdir /var/log/ico
+ /bin/chmod -R 0777 /var/log/ico
+ /bin/rm -f /var/log/ico/*
+
+ # kill pulseaudio and weston, and start pulseaudio
+ /usr/bin/killall pulseaudio > /dev/null 2>&1
+ /usr/bin/killall weston > /dev/null 2>&1
+ /bin/sleep 0.2
+ /usr/bin/killall -9 pulseaudio > /dev/null 2>&1
+ /usr/bin/killall -9 weston > /dev/null 2>&1
+
+ # Start Device Input Controller for eGalax TouchPanel
+ #/usr/bin/ico_ictl-touch_egalax -t
+ /usr/bin/ico_ictl-touch_egalax
+
+ # re-load launchpad
+ /bin/ps ax | /bin/grep launchpad_preloading | /bin/grep -v grep > /dev/null
+ if [ "$?" = "0" ] ; then
+ /usr/bin/killall launchpad_preloading_preinitializing_daemon
+ /bin/sleep 0.3
+ fi
+ /usr/bin/launchpad_preloading_preinitializing_daemon &
+
+ # start-stop-daemon --start --background --quiet --pidfile $PIDFILE --exec $DAEMON -- \
+ # $DAEMON_ARGS \
+ # || return 2
+ $DAEMON $DAEMON_ARGS &
+ weston_pid=$!
+ /bin/sleep 0.2
+
+ if [ $weston_pid = 0 ]; then
+ return 2
+ else
+ echo $weston_pid > $PIDFILE
+ fi
+
+ # Add code here, if necessary, that waits for the process to be ready
+ # to handle requests from services started subsequently which depend
+ # on this one. As a last resort, sleep for some time.
+
+ # ************************************************************
+ # HACK TO WORK AROUND INSUFFICIENT ACCESS PERMISSIONS FOR
+ # UNPRIVILEGED USERS.
+ #
+ # Ideally we should launch weston with weston-launch with the
+ # appropriate --user flag. Unfortunately, weston-launch isn't
+ # available due to missing package dependencies.
+ # ************************************************************
+ wayland_socket="$XDG_RUNTIME_DIR/wayland-0"
+ MAX_ATTEMPTS=8
+ attempt=0
+ while [ ! -f $wayland_socket ] && [ $attempt -lt $MAX_ATTEMPTS ]
+ do
+ /bin/sleep 0.5
+ attempt=$[$attempt + 1]
+ done
+ /bin/chmod 777 $wayland_socket
+
+ # Start wayland-client for display mouse cursor
+ #/usr/bin/nice -19 /usr/bin/wayland-smoke &
+
+ ## if pulseaudio dose not start ... kick pulseaudio
+ /bin/ps ax | /bin/grep pulseaudio | /bin/grep -v grep > /dev/null
+ if [ "$?" = "1" ] ; then
+ /usr/bin/pulseaudio --log-level=3 --log-target=file:/var/log/ico/pulse.log --system -D
+ /bin/sleep 0.2
+ fi
+
+ # Start HomeScreen
+ /bin/sleep 0.5
+ /usr/bin/killall menu-screen
+ /usr/bin/killall menu-daemon
+ /usr/bin/killall power_manager
+ /usr/bin/launch_app org.tizen.ico.homescreen &
+
+ # ***********************************************************
+ # HACK TO WORK AROUND BROKEN INFINITE LOOPS IN BOOT ANIMATION
+ # VIRTUAL KEYBOARD BOOT SCRIPTS.
+ # ***********************************************************
+ touch /tmp/.X0-lock
+ touch /tmp/.wm_ready
+ # ***********************************************************
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+ # Return
+ # 0 if daemon has been stopped
+ # 1 if daemon was already stopped
+ # 2 if daemon could not be stopped
+ # other if a failure occurred
+ #start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
+ start-stop-daemon --stop --quiet --pidfile $PIDFILE --name $NAME
+ RETVAL="$?"
+ [ "$RETVAL" = 2 ] && return 2
+ # Wait for children to finish too if this is a daemon that forks
+ # and if the daemon is only ever run from this initscript.
+ # If the above conditions are not satisfied then add some other code
+ # that waits for the process to drop all resources that could be
+ # needed by services started subsequently. A last resort is to
+ # sleep for some time.
+ #start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
+ start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
+ [ "$?" = 2 ] && return 2
+ # Many daemons don't delete their pidfiles when they exit.
+ rm -f $PIDFILE
+ return "$RETVAL"
+}
+
+#
+# Function that sends a SIGHUP to the daemon/service
+#
+do_reload() {
+ #
+ # If the daemon can reload its configuration without
+ # restarting (for example, when it is sent a SIGHUP),
+ # then implement that here.
+ #
+ start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
+ return 0
+}
+
+case "$1" in
+ start)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+ do_start
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ stop)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ status)
+ status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+ ;;
+ #reload|force-reload)
+ #
+ # If do_reload() is not implemented then leave this commented out
+ # and leave 'force-reload' as an alias for 'restart'.
+ #
+ #log_daemon_msg "Reloading $DESC" "$NAME"
+ #do_reload
+ #log_end_msg $?
+ #;;
+ restart|force-reload)
+ #
+ # If the "reload" option is implemented then remove the
+ # 'force-reload' alias
+ #
+ log_daemon_msg "Restarting $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1)
+ do_start
+ case "$?" in
+ 0) log_end_msg 0 ;;
+ 1) log_end_msg 1 ;; # Old process is still running
+ *) log_end_msg 1 ;; # Failed to start
+ esac
+ ;;
+ *)
+ # Failed to stop
+ log_end_msg 1
+ ;;
+ esac
+ ;;
+ *)
+ #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
+ echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
+ exit 3
+ ;;
+esac
+
+:
--- /dev/null
+[sound source]
+HOMESCREEN_BEEP=interrupt;beep;99;mute;non;non
+
+[application name]
+
+[application category]
--- /dev/null
+AM_CFLAGS = $(GCC_CFLAGS)
+AM_CPPFLAGS = $(GCC_CFLAGS)
+
+COMMON_LIBS = -lm -lwebsockets -lico-uxf-weston-plugin
+
+noinst_PROGRAMS = \
+ HomeScreen \
+ OnScreen \
+ StatusBar
+
+
+HomeScreen_SOURCES = \
+ home_screen_main.c \
+ home_screen_conf.c \
+ home_screen_parser.c \
+ home_screen_lib.c \
+ home_screen_sound.c \
+ resource_conf.c
+HomeScreen_CFLAGS = -I../include $(EFL_CFLAGS) $(OPT_CFLAGS) $(WL_CFLAGS) $(AUL_CFLAGS)
+HomeScreen_LDADD = $(EFL_LIBS) $(OPT_LIBS) $(WL_LIBS) $(COMMON_LIBS) ../apps_controller/libico_syc-apc.a ../ico-app-framework/.libs/libico-app-fw-efl.so ../ico-app-framework/.libs/libico-app-fw.so $(AUL_LIBS)
+
+OnScreen_SOURCES = \
+ on_screen.c \
+ home_screen_conf.c \
+ home_screen_sound.c \
+ resource_conf.c
+OnScreen_CFLAGS = -I../include $(EFL_CFLAGS) $(OPT_CFLAGS) $(WL_CFLAGS) $(AUL_CFLAGS)
+OnScreen_LDADD = $(EFL_LIBS) $(OPT_LIBS) $(WL_LIBS) $(COMMON_LIBS) ../apps_controller/libico_syc-apc.a ../ico-app-framework/.libs/libico-app-fw-efl.so ../ico-app-framework/.libs/libico-app-fw.so $(AUL_LIBS)
+
+StatusBar_SOURCES = \
+ status_bar.c \
+ home_screen_conf.c \
+ home_screen_sound.c \
+ resource_conf.c
+StatusBar_CFLAGS = -I../include $(EFL_CFLAGS) $(OPT_CFLAGS) $(WL_CFLAGS) $(AUL_CFLAGS)
+StatusBar_LDADD = $(EFL_LIBS) $(OPT_LIBS) $(WL_LIBS) $(COMMON_LIBS) ../apps_controller/libico_syc-apc.a ../ico-app-framework/.libs/libico-app-fw-efl.so ../ico-app-framework/.libs/libico-app-fw.so $(AUL_LIBS)
+
+SUFFIXES = .edc .edj
+
+BUILT_SOURCES = \
+ home_screen_bg.edj \
+ home_screen_touch.edj \
+ appli_list.edj \
+ appli_kill.edj
+
+.edc.edj:
+ edje_cc $< -id ../res/images -fd ../res/images -sd ../res/sounds -o $@
+
+CLEANFILES = $(BUILT_SOURCES)
--- /dev/null
+fonts{
+ font:"DejaVuSans.ttf" "DejaVuSans";
+ font:"ttf-japanese-gothic.ttf" "fonts-japanese-gothic";
+}
+images{
+ image:"back_b_02.png" COMP;
+ image:"cancel_bt_off.png" COMP;
+ image:"cancel_bt_on.png" COMP;
+ image:"ok_bt_off.png" COMP;
+ image:"ok_bt_on.png" COMP;
+}
+
+collections {
+ group {
+ name: "appli_kill";
+ parts {
+
+ part {
+ name: "back_b";
+ type: IMAGE;
+ description {
+ state: "default" 0.0;
+ color: 255 255 255 255;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 44 410;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 724 680;
+ }
+ image{
+ normal: "back_b_02.png";
+ }
+ }
+ }
+
+ part { // OK
+ name: "ok_bt";
+ type: IMAGE;
+ mouse_events: 1;
+ access: 1;
+ description {
+ state: "default" 0.0;
+ color: 255 255 255 255;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 69 603;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 374 653;
+ }
+ image{
+ normal: "ok_bt_off.png";
+ }
+ }
+ description {
+ state: "ok_bt_on" 0.0;
+ color: 255 255 255 255;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 69 603;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 374 653;
+ }
+ image{
+ normal: "ok_bt_on.png";
+ }
+ }
+ }
+
+ part { // Cancel
+ name: "cancel_bt";
+ type: IMAGE;
+ mouse_events: 1;
+ access: 1;
+ description {
+ state: "default" 0.0;
+ color: 255 255 255 255;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 394 603;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 699 653;
+ }
+ image{
+ normal: "cancel_bt_off.png";
+ }
+ }
+ description {
+ state: "cancel_bt_on" 0.0;
+ color: 255 255 255 255;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 394 603;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 699 653;
+ }
+ image{
+ normal: "cancel_bt_on.png";
+ }
+ }
+ }
+ part {
+ name: "appli_kill_text";
+ type: TEXT; // plain boring rectangle
+ access: 1;
+ description {
+ state: "default" 0.0; // must always exist
+ color: 255 255 255 255; // white
+ rel1 { // top-left point at (0, 0) [WIDTH * 0 + 0, HEIGHT * 0 + 0]
+ relative: 0.0 0.0;
+ offset: 132 492;
+ }
+ rel2 { // bottom-right point at (WIDTH * 1.0 - 1, HEIGHT * 1.0 - 1)
+ relative: 0.0 0.0;
+ offset: 700 492;
+ }
+ text {
+ font: "fonts-japanese-gothic"; // using fontconfig name!
+ size: 25;
+ align: 0 0;
+ text: "Are you sure you want to terminate the App?";
+ }
+ }
+ }
+
+ }
+
+ programs {
+ program {
+ name:"trigger_ok_01";
+ signal: "mouse,down,*";
+ source: "ok_bt";
+ action: STATE_SET "ok_bt_on" 0.0;
+ target: "ok_bt";
+ transition: LINEAR 0.1;
+ }
+ program {
+ name:"trigger_ok_02";
+ signal: "mouse,up,*";
+ source: "ok_bt";
+ action: STATE_SET "ok_bt_off" 0.0;
+ target: "ok_bt";
+ transition: LINEAR 0.1;
+ }
+ program {
+ name:"trigger_cancel_01";
+ signal: "mouse,down,*";
+ source: "cancel_bt";
+ action: STATE_SET "cancel_bt_on" 0.0;
+ target: "cancel_bt";
+ transition: LINEAR 0.1;
+ }
+ program {
+ name:"trigger_cancel_02";
+ signal: "mouse,up,*";
+ source: "cancel_bt";
+ action: STATE_SET "cancel_bt_off" 0.0;
+ target: "cancel_bt";
+ transition: LINEAR 0.1;
+ }
+ }
+ }
+}
+
+
--- /dev/null
+images{
+ image:"back_b_01.png" COMP;
+ image:"cancel_bt_off.png" COMP;
+ image:"cancel_bt_on.png" COMP;
+ image:"next_bt_off.png" COMP;
+ image:"next_bt_on.png" COMP;
+}
+
+collections {
+ group {
+ name: "appli_list_01";
+ parts {
+
+ part {
+ name: "back_b";
+ type: IMAGE;
+ description {
+ state: "default" 0.0;
+ color: 255 255 255 255;
+
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 44 294;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 724 794;
+ }
+ image{
+ normal: "back_b_01.png";
+ }
+ }
+ }
+
+ part {
+ name: "rect_01";
+ type: RECT;
+ mouse_events: 1;
+ access: 1;
+ description {
+ state: "default" 0.0;
+ color: 0 0 0 0;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 69 319;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 179 429;
+ }
+ }
+ }
+
+ part {
+ name: "rect_02";
+ type: RECT;
+ mouse_events: 1;
+ access: 1;
+ description {
+ state: "default" 0.0;
+ color: 0 0 0 0;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 199 319;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 309 429;
+ }
+ }
+ }
+
+ part {
+ name: "rect_03";
+ type: RECT;
+ mouse_events: 1;
+ access: 1;
+ description {
+ state: "default" 0.0;
+ color: 0 0 0 0;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 329 319;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 439 429;
+ }
+ }
+ }
+
+ part {
+ name: "rect_04";
+ type: RECT;
+ mouse_events: 1;
+ access: 1;
+ description {
+ state: "default" 0.0;
+ color: 0 0 0 0;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 459 319;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 569 429;
+ }
+ }
+ }
+
+ part {
+ name: "rect_05";
+ type: RECT;
+ mouse_events: 1;
+ access: 1;
+ description {
+ state: "default" 0.0;
+ color: 0 0 0 0;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 589 319;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 699 429;
+ }
+ }
+ }
+
+ part {
+ name: "rect_06";
+ type: RECT;
+ mouse_events: 1;
+ access: 1;
+ description {
+ state: "default" 0.0;
+ color: 0 0 0 0;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 69 449;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 179 559;
+ }
+ }
+ }
+
+ part {
+ name: "rect_07";
+ type: RECT;
+ mouse_events: 1;
+ access: 1;
+ description {
+ state: "default" 0.0;
+ color: 0 0 0 0;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 199 449;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 309 559;
+ }
+ }
+ }
+
+ part {
+ name: "rect_08";
+ type: RECT;
+ mouse_events: 1;
+ access: 1;
+ description {
+ state: "default" 0.0;
+ color: 0 0 0 0;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 329 449;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 439 559;
+ }
+ }
+ }
+
+ part {
+ name: "rect_09";
+ type: RECT;
+ mouse_events: 1;
+ access: 1;
+ description {
+ state: "default" 0.0;
+ color: 0 0 0 0;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 459 449;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 569 559;
+ }
+ }
+ }
+
+ part {
+ name: "rect_10";
+ type: RECT;
+ mouse_events: 1;
+ access: 1;
+ description {
+ state: "default" 0.0;
+ color: 0 0 0 0;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 589 449;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 699 559;
+ }
+ }
+ }
+
+ part {
+ name: "rect_11";
+ type: RECT;
+ mouse_events: 1;
+ access: 1;
+ description {
+ state: "default" 0.0;
+ color: 0 0 0 0;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 69 579;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 179 689;
+ }
+ }
+ }
+
+ part {
+ name: "rect_12";
+ type: RECT;
+ mouse_events: 1;
+ access: 1;
+ description {
+ state: "default" 0.0;
+ color: 0 0 0 0;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 199 579;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 309 689;
+ }
+ }
+ }
+
+ part {
+ name: "rect_13";
+ type: RECT;
+ mouse_events: 1;
+ access: 1;
+ description {
+ state: "default" 0.0;
+ color: 0 0 0 0;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 329 579;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 439 689;
+ }
+ }
+ }
+
+ part {
+ name: "rect_14";
+ type: RECT;
+ mouse_events: 1;
+ access: 1;
+ description {
+ state: "default" 0.0;
+ color: 0 0 0 0;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 459 579;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 569 689;
+ }
+ }
+ }
+
+ part {
+ name: "rect_15";
+ type: RECT;
+ mouse_events: 1;
+ access: 1;
+ description {
+ state: "default" 0.0;
+ color: 0 0 0 0;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 589 579;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 699 689;
+ }
+ }
+ }
+
+ part { // Next
+ name: "next_bt";
+ type: IMAGE;
+ mouse_events: 1;
+ access: 1;
+ description {
+ state: "default" 0.0;
+ color: 255 255 255 255;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 69 719;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 374 769;
+ }
+ image{
+ normal: "next_bt_off.png";
+ }
+ }
+ description {
+ state: "next_bt_on" 0.0;
+ color: 255 255 255 255;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 69 719;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 374 769;
+ }
+ image{
+ normal: "next_bt_on.png";
+ }
+ }
+ }
+
+ part { // Cancel
+ name: "cancel_bt";
+ type: IMAGE;
+ mouse_events: 1;
+ access: 1;
+ description {
+ state: "default" 0.0;
+ color: 255 255 255 255;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 394 719;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 699 769;
+ }
+ image{
+ normal: "cancel_bt_off.png";
+ }
+ }
+ description {
+ state: "cancel_bt_on" 0.0;
+ color: 255 255 255 255;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 394 719;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 699 769;
+ }
+ image{
+ normal: "cancel_bt_on.png";
+ }
+ }
+ }
+ }
+
+ programs {
+ program {
+ name:"trigger_next_01";
+ signal: "mouse,down,*";
+ source: "next_bt";
+ action: STATE_SET "next_bt_on" 0.0;
+ target: "next_bt";
+ transition: LINEAR 0.1;
+ }
+ program {
+ name:"trigger_next_02";
+ signal: "mouse,up,*";
+ source: "next_bt";
+ action: STATE_SET "next_bt_off" 0.0;
+ target: "next_bt";
+ transition: LINEAR 0.1;
+ }
+ program {
+ name:"trigger_cancel_01";
+ signal: "mouse,down,*";
+ source: "cancel_bt";
+ action: STATE_SET "cancel_bt_on" 0.0;
+ target: "cancel_bt";
+ transition: LINEAR 0.1;
+ }
+ program {
+ name:"trigger_cancel_02";
+ signal: "mouse,up,*";
+ source: "cancel_bt";
+ action: STATE_SET "cancel_bt_off" 0.0;
+ target: "cancel_bt";
+ transition: LINEAR 0.1;
+ }
+ }
+ }
+}
--- /dev/null
+collections {
+ group {
+ name: "home_screen_bg"; // must be the same as in home_screen_main.c
+ parts {
+ part {
+ name: "background";
+ type: RECT; // plain boring rectangle
+ description {
+ state: "default" 0.0; // must always exist
+ color: 0 0 0 255; // black
+ rel1 { // top-left point at (0, 0) [WIDTH * 0 + 0, HEIGHT * 0 + 0]
+ relative: 0.0 0.0;
+ offset: 0 0;
+ }
+ rel2 { // bottom-right point at (WIDTH * 1.0 - 1, HEIGHT * 1.0 - 1)
+ relative: 1.0 1.0;
+ offset: -1 -1;
+ }
+ }
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief load configuratoin file
+ *
+ * @date Feb-15-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <glib.h>
+
+#include "ico_uxf_conf.h"
+#include "home_screen_conf.h"
+#include "home_screen.h"
+
+/*============================================================================*/
+/* variables and tables */
+/*============================================================================*/
+static GKeyFile *hs_config_key = NULL;
+gboolean hs_is_open_config = FALSE;
+
+/*============================================================================*/
+/* functions */
+/*============================================================================*/
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief initHomeScreenConfig
+ * read and initialize for homescreen configuration
+ *
+ * @param[in] conf configuration file name
+ * @return result
+ * @retval ICO_HS_OK success
+ * @retval ICO_HS_ERR error
+ */
+/*--------------------------------------------------------------------------*/
+int
+initHomeScreenConfig(const char *conf)
+{
+ GError *error = NULL;
+ char path[ICO_HS_TEMP_BUF_SIZE];
+ GKeyFile *homescreen;
+ GString *filepath;
+
+ if (hs_is_open_config == TRUE) {
+ return ICO_HS_ERR;
+ }
+
+ homescreen = g_key_file_new();
+ hs_config_key = homescreen;
+ filepath = g_string_new("test");
+ hs_get_conf_path(path, sizeof(path));
+ g_string_printf(filepath, "%s/%s", path, conf);
+ if (!g_file_test(filepath->str, G_FILE_TEST_IS_REGULAR)) {
+ return ICO_HS_ERR;
+ }
+
+ g_key_file_load_from_file(homescreen, filepath->str,
+ G_KEY_FILE_KEEP_COMMENTS
+ | G_KEY_FILE_KEEP_TRANSLATIONS, &error);
+ if (error != NULL) {
+ uifw_warn("%s: %s", filepath->str, error->message);
+ g_error_free(error);
+ }
+
+ g_string_free(filepath, TRUE);
+ if (error != NULL) {
+ uifw_warn("%s: %s", filepath->str, error->message);
+ g_error_free(error);
+ hs_is_open_config = TRUE;
+ return ICO_HS_ERR;
+ }
+ return ICO_HS_OK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_conf_get_integer
+ * Return integer value in homescreen configuration file.
+ * If not exist,return defaultvlaue in params.
+ *
+ * @param[in] group_name configuration group name
+ * @param[in] key configuration name
+ * @param[in] default_value default value
+ * @return config integer
+ */
+/*--------------------------------------------------------------------------*/
+int
+hs_conf_get_integer(const char *group_name, const char *key, int default_value)
+{
+ GError *error = NULL;
+
+ if (hs_config_key == NULL) {
+ if (initHomeScreenConfig(ICO_HOMESCREEN_CONFIG_FILE) != ICO_HS_OK) {
+ return default_value;
+ }
+ }
+
+ int value = g_key_file_get_integer(hs_config_key, group_name, key, &error);
+ if (error != NULL) {
+ uifw_warn("%s", error->message);
+ g_error_free(error);
+ return default_value;
+ }
+ return value;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_conf_get_string
+ * Return string value in homescreen configuration file.
+ * If not exist,return defaultvlaue in params.
+ *
+ * @param[in] group_name configuration group name
+ * @param[in] key configuration name
+ * @param[in] default_value default value
+ * @return config string
+ */
+/*--------------------------------------------------------------------------*/
+const char *
+hs_conf_get_string(const char *group_name, const char *key,
+ const char *default_value)
+{
+ GError *error = NULL;
+
+ if (hs_config_key == NULL) {
+ if (initHomeScreenConfig(ICO_HOMESCREEN_CONFIG_FILE) != ICO_HS_OK) {
+ return default_value;
+ }
+ }
+
+ const char *value = g_key_file_get_string(hs_config_key, group_name, key,
+ &error);
+ if (error != NULL) {
+ uifw_warn("%s", error->message);
+ g_error_free(error);
+ return default_value;
+ }
+ return value;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief library to communicate with outer process
+ *
+ * @date Feb-15-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+#include <string.h>
+#include <math.h>
+#include <glib.h>
+#include <stdbool.h>
+#include <sys/epoll.h>
+
+#include <getopt.h>
+#include <libwebsockets.h>
+
+#include <Eina.h>
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+#include <Edje.h>
+
+#include "ico_uxf.h"
+#include "ico_uxf_conf_common.h"
+
+#include "home_screen_parser.h"
+#include "home_screen.h"
+#include "home_screen_lib.h"
+
+/*============================================================================*/
+/* definition */
+/*============================================================================*/
+#define WEBSOCKET_MAX_BUFFER (4096)
+#define HS_REQ_ANS_HELLO "REQ_ANS_HELLO"
+typedef struct _hs_lib_poll hs_lib_poll_t;
+typedef struct _hs_lib_handle hs_lib_handle_t;
+typedef struct _hs_lib_msg hs_lib_msg_t;
+
+/* management connection */
+struct _hs_lib_handle {
+ hs_lib_handle_t *next; /* next handle */
+ int fd; /* Socket file descriptor */
+ int service_on;
+ int type;
+ struct libwebsocket_context *wsi_context;
+ /* Context of libwebsockets */
+ struct libwebsocket *wsi; /* WSI of libwebsockets */
+ hs_lib_poll_t *poll;
+ char appid[ICO_UXF_MAX_PROCESS_NAME];
+};
+
+struct _hs_lib_poll {
+ hs_lib_poll_t *next;
+ int fd;
+ int flags;
+ void *user_data;
+ hs_lib_handle_t *handle;
+};
+
+struct _hs_lib_msg {
+ hs_lib_msg_t *next;
+ char *data;
+ int len;
+ int type;
+ hs_lib_handle_t *handle;
+};
+
+/*============================================================================*/
+/* variabe */
+/*============================================================================*/
+static struct libwebsocket_context *hs_wsicontext = NULL;
+static hs_lib_msg_t *hs_send_msg = NULL;
+static hs_lib_msg_t *hs_recv_msg = NULL;
+static hs_lib_msg_t *hs_free_msg = NULL;
+static hs_lib_handle_t *hs_handles = NULL;
+static hs_lib_handle_t *hs_handles_free = NULL;
+static hs_lib_poll_t *hs_polls = NULL;
+static hs_lib_poll_t *hs_polls_free = NULL;
+
+/*============================================================================*/
+/* Function prototype for static(internal) functions */
+/*============================================================================*/
+static void hs_lib_handle_command(hs_lib_msg_t *msg);
+static void hs_lib_handle_application(hs_lib_msg_t *msg);
+static void hs_lib_handle_onscreen(hs_lib_msg_t *msg);
+static hs_lib_msg_t *hs_lib_alloc_msg(char *data, int len);
+static void hs_lib_free_msg(hs_lib_msg_t *msg);
+static void hs_lib_free_handle(hs_lib_handle_t *handle);
+static hs_lib_handle_t *hs_lib_alloc_handle(void);
+static void hs_lib_realsend(hs_lib_msg_t *msg);
+static hs_lib_msg_t *hs_lib_get_sendmsg(int type);
+static int hs_lib_put_sendmsg(hs_lib_msg_t *send);
+static hs_lib_msg_t *hs_lib_get_recvmsg(void);
+static void hs_lib_put_recvmsg(hs_lib_msg_t *recv);
+static void hs_lib_com_dispatch(hs_lib_handle_t *_handle, int timeoutms);
+static void hs_lib_poll_fd_event(hs_lib_poll_t *poll, int flags);
+static Eina_Bool hs_lib_ecore_fdevent(void *data, Ecore_Fd_Handler *handler);
+static void hs_lib_control_fd(hs_lib_poll_t *fd_ctl[], const int num_fds);
+static int hs_lib_add_poll_fd(int fd, int flags);
+static void hs_lib_del_poll_fd(int fd);
+static void hs_lib_set_mode_poll_fd(int fd, int flags);
+static void hs_lib_clear_mode_poll_fd(int fd, int flags);
+static char *get_parsed_str(char *in, char *out, int len, int arg_idx);
+static char *getFileName(char *filepath, int len);
+static int hs_lib_callback_http(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user,
+ void *in, size_t len);
+static int hs_lib_callback_command(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user,
+ void *in, size_t len);
+static int hs_lib_callback_statusbar(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason,
+ void *user, void *in, size_t len);
+static int hs_lib_callback_onscreen(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user,
+ void *in, size_t len);
+static int hs_lib_callback_app(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user,
+ void *in, size_t len);
+
+/*============================================================================*/
+/* table */
+/*============================================================================*/
+static struct libwebsocket_protocols protocols[] = {
+ {
+ "http-only",
+ hs_lib_callback_http,
+ 0
+ },
+ { /* HomeScreen - command */
+ ICO_HS_PROTOCOL_CM,
+ hs_lib_callback_command,
+ 0
+ },
+ { /* HomeScreen - StatusBar */
+ ICO_HS_PROTOCOL_SB,
+ hs_lib_callback_statusbar,
+ 0
+ },
+ { /* HomeScreen - OnScreen */
+ ICO_HS_PROTOCOL_OS,
+ hs_lib_callback_onscreen,
+ 0
+ },
+ { /* HomeScreen - OtherNatiiveApps */
+ ICO_HS_PROTOCOL_APP,
+ hs_lib_callback_app,
+ 0
+ },
+ {
+ NULL,
+ NULL,
+ 0
+ }
+};
+
+/*============================================================================*/
+/* functions */
+/*============================================================================*/
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_handle_command
+ * callback at received message from external command tools,
+ * and handle the message.
+ *
+ * @param[in] msg received message
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_lib_handle_command(hs_lib_msg_t *msg)
+{
+ int cnt = 0;
+ int ret;
+ char buff[ICO_HS_MSG_SIZE];
+ hs_lib_msg_t *send;
+
+ uifw_trace("hs_lib_handle_command: Enter");
+
+ if (strcmp(msg->data, HS_REQ_ANS_HELLO) == 0) {
+ memset(buff, 0, sizeof(buff));
+
+ send = hs_lib_alloc_msg("ANS HELLO", strlen("ANS HELLO"));
+ if (!send) {
+ uifw_warn("hs_lib_handle_command: ERROR(allocate send msg)");
+ return;
+ }
+ send->type = ICO_HS_PROTOCOL_TYPE_CM;
+
+ hs_lib_put_sendmsg(send);
+
+ uifw_trace("hs_lib_handle_command: Leave");
+
+ return;
+ }
+
+ /* data sent by command is parsed and controlled for the window */
+ ret = hs_parse_form(msg->data, msg->len);
+ if (hs_req_touch == ICO_HS_TOUCH_TOBE_HIDE) {
+ hs_show_appscreen(NULL);
+ hs_control_app_screen();
+ }
+ else if (hs_req_touch == ICO_HS_TOUCH_TOBE_SHOW) {
+ hs_get_tilescreendata();
+ hs_dump_app();
+ hs_req_ctlr_tile();
+ }
+
+ /* return message */
+ memset(buff, 0, sizeof(buff));
+ if (ret == 0) {
+ cnt = snprintf(buff, sizeof(buff), "ANS %s OK", msg->data);
+ }
+ else {
+ cnt = snprintf(buff, sizeof(buff), "ERR %s FAILED", msg->data);
+ }
+
+ if (cnt > 0) {
+ send = hs_lib_alloc_msg(buff, cnt);
+ if (!send) {
+ uifw_warn("hs_lib_handle_command: ERROR(allocate send msg)");
+ return;
+ }
+ send->type = ICO_HS_PROTOCOL_TYPE_CM;
+
+ hs_lib_put_sendmsg(send);
+ }
+
+ uifw_trace("hs_lib_handle_command: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_handle_application
+ * callback at received message from a application, and handle the
+ * message.
+ *
+ * @param[in] msg received message
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_lib_handle_application(hs_lib_msg_t *msg)
+{
+ char *app_id;
+ char msg_data[ICO_HS_MSG_SIZE];
+ char tmp_buf[ICO_HS_MSG_SIZE];
+ char *data = msg->data;
+ hs_lib_msg_t *send;
+
+ uifw_trace("hs_lib_handle_application: Enter");
+
+ if (strncmp("OPEN", data, 4) == 0) {
+ strncpy(msg_data, get_parsed_str(data, tmp_buf, sizeof(tmp_buf), 2),
+ sizeof(msg_data));
+ app_id = msg_data;
+ uifw_trace("hs_lib_callback_app: app_id = %s, msg_data - %s, in - %s",
+ app_id, msg_data, data);
+ strncpy(hs_active_onscreen, app_id, sizeof(hs_active_onscreen));
+ strncpy(msg->handle->appid, app_id, sizeof(hs_active_onscreen));
+
+ send = hs_lib_alloc_msg(data, msg->len);
+ if (!send) {
+ uifw_warn("hs_lib_callback_app: ERROR(allocate send msg)");
+ return;
+ }
+ send->type = ICO_HS_PROTOCOL_TYPE_OS;
+
+ hs_lib_put_sendmsg(send);
+ }
+ else if (strncmp("CLOSE", data, 5) == 0) {
+ /* native apps only */
+ hs_hide_onscreen();
+ memset(hs_active_onscreen, 0, sizeof(hs_active_onscreen));
+ /* disconnect app-protocol */
+ if ((msg->handle != NULL) && (msg->handle->wsi != NULL)) {
+ libwebsocket_close_and_free_session(msg->handle->wsi_context,
+ msg->handle->wsi,
+ LWS_CLOSE_STATUS_NORMAL);
+ }
+ }
+ uifw_trace("hs_lib_handle_application: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_handle_onscreen
+ * callback at received message from onscreen, and handle the
+ * message.
+ *
+ * @param[in] msg received message
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_lib_handle_onscreen(hs_lib_msg_t *msg)
+{
+ char msg_buf[ICO_HS_MSG_SIZE];
+ char msg_data[ICO_HS_MSG_SIZE];
+ char tmp_buf[ICO_HS_MSG_SIZE];
+ char *p_msg_data;
+ char *ptr;
+ int ret, idx;
+ const Ico_Uxf_conf_application *appConf = NULL;
+ char *data = msg->data;
+ hs_lib_handle_t *handle;
+ hs_lib_msg_t *send;
+
+ uifw_trace("hs_lib_handle_onscreen: Enter");
+
+ /* init buffers */
+ memset(msg_data, 0x00, sizeof(msg_data));
+ p_msg_data = &msg_data[0];
+ strncpy(p_msg_data, data, msg->len);
+
+ uifw_trace("hs_lib_handle_onscreen: hs_active_onscreen = %s",
+ hs_active_onscreen);
+ /* parse message from OnScreen */
+ if (strncmp("RESULT", p_msg_data, 6) == 0) {
+ /* get 2nd phrase */
+ ptr = get_parsed_str(p_msg_data, tmp_buf, sizeof(tmp_buf), 1);
+ if (strncmp("SUCCESS", ptr, 7) == 0) {
+ /* loaded edje: success */
+ hs_show_onscreen();
+ send = hs_lib_alloc_msg(data, msg->len);
+ if (!send) {
+ uifw_warn("hs_lib_handle_onscreen: ERROR(allocate send msg)");
+ return;
+ }
+ send->type = ICO_HS_PROTOCOL_TYPE_APP;
+ hs_lib_put_sendmsg(send);
+ }
+ else if (strncmp("FAILED", ptr, 6) == 0) {
+ /* not loaded edje: failed */
+ if (strcmp(hs_active_onscreen, ICO_UXF_PROC_DEFAULT_HOMESCREEN)
+ == 0) {
+ /* appli_list or appli_kill: raise touch layer */
+ hs_hide_onscreen();
+ }
+ else {
+ /* native apps: raise own */
+ hs_hide_onscreen();
+ }
+ memset(hs_active_onscreen, 0, sizeof(hs_active_onscreen));
+ /* disconnect app-protocol */
+ handle = hs_handles;
+ while (handle) {
+ if (handle->type == ICO_HS_PROTOCOL_TYPE_APP) {
+ libwebsocket_close_and_free_session(handle->wsi_context,
+ handle->wsi,
+ LWS_CLOSE_STATUS_NORMAL);
+
+ }
+ handle = handle->next;
+ }
+ }
+ }
+ else if (strncmp("TOUCH", data, 5) == 0) {
+ if (strlen(hs_active_onscreen) == 0) {
+ /* do nothing */
+ }
+ else if (strcmp(hs_active_onscreen, ICO_UXF_PROC_DEFAULT_HOMESCREEN)
+ == 0) {
+ /* get 2nd phrase */
+ ptr = get_parsed_str(p_msg_data, tmp_buf, sizeof(tmp_buf), 1);
+ if (strncmp(getFileName(ptr, strlen(ptr)),
+ ICO_HS_ONS_APPLI_LIST_NAME,
+ sizeof(ICO_HS_ONS_APPLI_LIST_NAME)) == 0) {
+ /* get 3rd phrase */
+ ptr = get_parsed_str(p_msg_data, tmp_buf, sizeof(tmp_buf), 2);
+ appConf = ico_uxf_getAppByAppid(ptr);
+ uifw_trace(
+ "hs_lib_handle_onscreen: hs_tile_get_index_app = %d(%s)",
+ (int)appConf, ptr);
+ if (appConf != NULL) {
+ sprintf(msg_buf, "FOCUS %s", ptr);
+ send = hs_lib_alloc_msg(msg_buf, strlen(msg_buf));
+ if (!send) {
+ uifw_warn(
+ "hs_lib_handle_onscreen: ERROR(allocate send msg)");
+ return;
+ }
+ send->type = ICO_HS_PROTOCOL_TYPE_CM;
+ ret = hs_lib_put_sendmsg(send);
+ if (ret < 0) {
+ ret = ico_uxf_process_execute(ptr);
+ hs_hide_onscreen();
+ if ((ret == ICO_UXF_EOK) || (ret == ICO_UXF_EBUSY)) {
+ idx = hs_tile_get_index_app(ptr);
+ if (idx < 0) {
+ idx = hs_tile_get_minchange();
+ }
+ hs_tile_set_app(idx, ptr);
+ }
+ hs_tile_show_screen();
+ }
+ else {
+ usleep(100000);
+ hs_hide_onscreen();
+ }
+ memset(hs_active_onscreen, 0, sizeof(hs_active_onscreen));
+ }
+ else {
+ if (strncmp(ptr, "next_bt", 7) == 0) {
+ hs_get_ons_edj_path(tmp_buf, sizeof(tmp_buf));
+ sprintf(msg_buf, "OPEN %s%s %s", tmp_buf,
+ ICO_HS_ONS_APPLI_LIST_NAME,
+ ICO_UXF_PROC_DEFAULT_HOMESCREEN);
+ uifw_trace("send '%s' to onscreen", msg_buf);
+ send = hs_lib_alloc_msg(msg_buf, strlen(msg_buf));
+ if (!send) {
+ uifw_warn(
+ "hs_lib_handle_onscreen: ERROR(allocate send msg)");
+ return;
+ }
+ send->type = ICO_HS_PROTOCOL_TYPE_OS;
+ (void)hs_lib_put_sendmsg(send);
+ }
+ else if (strncmp(ptr, "cancel_bt", 8) == 0) {
+ hs_hide_onscreen();
+ memset(hs_active_onscreen, 0,
+ sizeof(hs_active_onscreen));
+ }
+ }
+ }
+ else if (strncmp(getFileName(ptr, strlen(ptr)),
+ ICO_HS_ONS_APPLI_KILL_NAME,
+ sizeof(ICO_HS_ONS_APPLI_KILL_NAME)) == 0) {
+ /* get 3rd phrase */
+ ptr = get_parsed_str(p_msg_data, tmp_buf, sizeof(tmp_buf), 2);
+ if (strncmp(ptr, "ok_bt", 5) == 0) {
+ uifw_trace("%s: ok_bt", ICO_HS_ONS_APPLI_KILL_NAME);
+ if (strlen(hs_kill_appid) == 0) {
+ hs_hide_onscreen();
+ memset(hs_active_onscreen, 0,
+ sizeof(hs_active_onscreen));
+ return;
+ }
+ sprintf((char *)msg_buf, "FOCUS %s", hs_kill_appid);
+ uifw_trace("send '%s' to command", msg_buf);
+ send = hs_lib_alloc_msg(msg_buf, strlen(msg_buf));
+ if (!send) {
+ uifw_warn(
+ "hs_lib_handle_onscreen: ERROR(allocate send msg)");
+ return;
+ }
+ send->type = ICO_HS_PROTOCOL_TYPE_CM;
+ ret = hs_lib_put_sendmsg(send);
+ if (ret < 0) {
+ hs_hide_onscreen();
+ hs_tile_kill_app(hs_kill_appid);
+ hs_tile_show_screen();
+ }
+ else {
+ hs_hide_onscreen();
+ }
+ }
+ else if (strncmp(ptr, "cancel_bt", 8) == 0) {
+ uifw_trace("%s: cancel_bt", ICO_HS_ONS_APPLI_KILL_NAME);
+ hs_hide_onscreen();
+ hs_tile_show_screen();
+ }
+ else {
+ uifw_trace("%s: else %s", ICO_HS_ONS_APPLI_KILL_NAME, ptr);
+ hs_hide_onscreen();
+ }
+ memset(hs_active_onscreen, 0, sizeof(hs_active_onscreen));
+ memset(hs_kill_appid, 0, sizeof(hs_kill_appid));
+ }
+ }
+ else {
+ uifw_trace("send %s to app", data);
+ send = hs_lib_alloc_msg(data, msg->len);
+ if (!send) {
+ uifw_warn("hs_lib_handle_onscreen: ERROR(allocate send msg)");
+ return;
+ }
+ send->type = ICO_HS_PROTOCOL_TYPE_APP;
+ hs_lib_put_sendmsg(send);
+ }
+ }
+
+ uifw_trace("hs_lib_handle_onscreen: Leave");
+}
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_handle_statusbar
+ * callback at received message from statusbar, and handle the
+ * message.
+ *
+ * @param[in] msg received message
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_lib_handle_statusbar(hs_lib_msg_t *msg)
+{
+ uifw_trace("hs_lib_handle_statusbar: Enter");
+ /* clicked escutcheon button and send a command to outer commander */
+ if (strncmp("CLICK ESCUTCHEON", msg->data, 16) == 0) {
+ hs_click_escutcheon();
+ }
+ uifw_trace("hs_lib_handle_statusbar: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_alloc_msg
+ * Allocate a msg structure
+ *
+ * @param[in] data data
+ * @param[in] len data length
+ * @return address
+ * @retval > 0 success
+ * @retval NULL error
+ */
+/*--------------------------------------------------------------------------*/
+static hs_lib_msg_t *
+hs_lib_alloc_msg(char *data, int len)
+{
+ hs_lib_msg_t *msg;
+
+ if (!hs_free_msg) {
+ msg = malloc(sizeof(hs_lib_msg_t));
+ if (!msg) {
+ return NULL;
+ }
+ }
+ else {
+ msg = hs_free_msg;
+ hs_free_msg = hs_free_msg->next;
+ }
+ memset(msg, 0, sizeof(hs_lib_msg_t));
+
+ msg->len = len;
+ msg->data = strdup(data);
+ if (!msg->data) {
+ free(msg);
+ return NULL;
+ }
+
+ return msg;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_free_msg
+ * free the msg
+ *
+ * @param[in] data data
+ * @param[in] free data lenght
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_lib_free_msg(hs_lib_msg_t *msg)
+{
+ if (!msg) {
+ return;
+ }
+
+ if (msg->data) {
+ free(msg->data);
+ }
+
+ memset(msg, 0, sizeof(hs_lib_msg_t));
+
+ msg->next = hs_free_msg;
+ hs_free_msg = msg;
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_free_handle
+ * free the indecated handle.
+ *
+ * @param handle handle to free
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_lib_free_handle(hs_lib_handle_t *handle)
+{
+ hs_lib_handle_t *free;
+ hs_lib_handle_t *bfree;
+
+ free = hs_handles;
+ bfree = NULL;
+ while (free) {
+ if (free == handle)
+ break;
+ bfree = free;
+ free = free->next;
+ }
+ if (free) {
+ if (bfree) {
+ bfree->next = free->next;
+ }
+ else {
+ hs_handles = free->next;
+ }
+ free->next = hs_handles_free;
+ hs_handles_free = free;
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_alloc_handle
+ * Allocate handle.
+ *
+ * @param none
+ * @return address
+ * @retval > 0 success
+ * @retval NULL error
+ */
+/*--------------------------------------------------------------------------*/
+static hs_lib_handle_t *
+hs_lib_alloc_handle(void)
+{
+ hs_lib_handle_t *handle;
+
+ if (!hs_handles_free) {
+ handle = malloc(sizeof(hs_lib_handle_t));
+ if (!handle) {
+ return NULL;
+ }
+ }
+ else {
+ handle = hs_handles_free;
+ hs_handles_free = hs_handles_free->next;
+ }
+ memset(handle, 0, sizeof(hs_lib_handle_t));
+
+ if (hs_handles) {
+ handle->next = hs_handles;
+ }
+ hs_handles = handle;
+
+ return handle;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_realsend
+ * write send message to websocket actually.
+ *
+ * @param[in] msg write message
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_lib_realsend(hs_lib_msg_t *msg)
+{
+ unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 512
+ + LWS_SEND_BUFFER_POST_PADDING];
+ unsigned char *pt = &buf[LWS_SEND_BUFFER_PRE_PADDING];
+ int n;
+
+ strcpy((char*)pt, msg->data);
+
+ uifw_trace("hs_lib_realsend: send(wsi=%x, type=h:%d(m:%d), len=%d, msg=%s)",
+ msg->handle->wsi, msg->handle->type, msg->type, msg->len, msg->data);
+ n = libwebsocket_write(msg->handle->wsi, pt, strlen((char *)pt),
+ LWS_WRITE_TEXT);
+
+ if (n < 0) {
+ uifw_warn("hs_lib_realsend: ERROR(fail to write ws)");
+ }
+
+ uifw_warn("hs_lib_realsend: Leave(send len = %d)", n);
+
+ usleep(200);
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_get_sendmsg
+ * get the send message from the send queue.
+ *
+ * @param[in] type receiver
+ * @return send message address
+ * @retval > 0 success
+ * @retval NULL error
+ */
+/*--------------------------------------------------------------------------*/
+static hs_lib_msg_t *
+hs_lib_get_sendmsg(int type)
+{
+ hs_lib_msg_t *msg;
+ hs_lib_msg_t *bmsg;
+
+ msg = hs_send_msg;
+ bmsg = NULL;
+ while (msg) {
+ if (msg->type == type) {
+ break;
+ }
+ bmsg = msg;
+ msg = msg->next;
+ }
+ if (msg) {
+ if (!bmsg) {
+ /* top */
+ hs_send_msg = msg->next;
+ msg->next = NULL;
+ }
+ else {
+ bmsg->next = msg->next;
+ msg->next = NULL;
+ }
+ }
+
+ return msg;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_put_sendmsg
+ * put the send message to the send queue end.
+ *
+ * @param[in] data send message
+ * @return result
+ * @retval ICO_HS_OK success
+ * @retval ICO_HS_ERR error
+ */
+/*--------------------------------------------------------------------------*/
+static int
+hs_lib_put_sendmsg(hs_lib_msg_t *send)
+{
+ hs_lib_msg_t *msg;
+ hs_lib_handle_t *handle;
+
+ uifw_trace("hs_lib_put_sendmsg: Enter");
+
+ handle = hs_handles;
+ while (handle) {
+ if (handle->type == send->type) {
+ break;
+ }
+ handle = handle->next;
+ }
+ if (!handle) {
+ uifw_trace("hs_lib_put_sendmsg: Leave(target(type:%d) does not exist", send->type);
+ return ICO_HS_ERR;
+ }
+
+ msg = hs_send_msg;
+ while (msg) {
+ if (!msg->next) {
+ break;
+ }
+ msg = msg->next;
+ }
+ if (!msg) {
+ hs_send_msg = send;
+ }
+ else {
+ msg->next = send;
+ }
+
+ if (handle) {
+ send->handle = handle;
+ uifw_trace("hs_lib_put_sendmsg: libwebsocket_callback_on_writable"
+ "(wsi_ctx=%x, wsi=%x", handle->wsi_context, handle->wsi);
+ libwebsocket_callback_on_writable(handle->wsi_context, handle->wsi);
+
+ hs_lib_com_dispatch(handle, 0);
+ }
+
+ uifw_trace("hs_lib_put_sendmsg: Leave");
+
+ return ICO_HS_OK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_get_recvmsg
+ * get the receive message from the receive queue end.
+ *
+ * @param none
+ * @return recv message address
+ * @retval > 0 success
+ * @retval NULL error
+ */
+/*--------------------------------------------------------------------------*/
+static hs_lib_msg_t *
+hs_lib_get_recvmsg(void)
+{
+ hs_lib_msg_t *msg;
+
+ msg = hs_recv_msg;
+ if (msg) {
+ hs_recv_msg = msg->next;
+ msg->next = NULL;
+ }
+
+ return msg;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_put_recvmsg
+ * put the receive message to the receive queue end.
+ *
+ * @param[in] data receive message
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_lib_put_recvmsg(hs_lib_msg_t *recv)
+{
+ hs_lib_msg_t *msg;
+
+ msg = hs_recv_msg;
+ while (msg) {
+ if (!msg->next) {
+ break;
+ }
+ msg = msg->next;
+ }
+ if (!msg) {
+ hs_recv_msg = recv;
+ }
+ else {
+ msg->next = recv;
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_com_dispatch
+ * The accumulated data that transmitted or received is procecssed
+ *
+ * @param[in] _handle connect handle,
+ * if NULL target is all connection
+ * @param[in] timeoutms maximum wait time on miri-sec.
+ * 0 is no wait, -1 is wait forever.
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_lib_com_dispatch(hs_lib_handle_t *_handle, int timeoutms)
+{
+ hs_lib_handle_t *handle;
+ hs_lib_msg_t *msg;
+
+ if (_handle) {
+ handle = _handle;
+ }
+ else {
+ handle = hs_handles;
+ }
+
+ while (handle) {
+ uifw_warn("hs_lib_com_dispatch: wsi=%x", handle->wsi_context);
+ if (libwebsocket_service(handle->wsi_context, timeoutms) < 0) {
+ uifw_warn("hs_lib_com_dispatch: fd=%d is done", handle->fd);
+ }
+
+ /* treate received buffer */
+ msg = hs_lib_get_recvmsg();
+ while (msg) {
+ switch (msg->type) {
+ case ICO_HS_PROTOCOL_TYPE_CM:
+ hs_lib_handle_command(msg);
+ break;
+
+ case ICO_HS_PROTOCOL_TYPE_SB:
+ hs_lib_handle_statusbar(msg);
+ break;
+
+ case ICO_HS_PROTOCOL_TYPE_OS:
+ hs_lib_handle_onscreen(msg);
+ break;
+
+ case ICO_HS_PROTOCOL_TYPE_APP:
+ hs_lib_handle_application(msg);
+ break;
+
+ default:
+ break;
+ }
+ hs_lib_free_msg(msg);
+ msg = hs_lib_get_recvmsg();
+ }
+
+ if (_handle)
+ break;
+ handle = handle->next;
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_poll_fd_event
+ * Notify the changes of file descriptor's state
+ *
+ * @param[in] fd_ctl The structure of file descriptor's controller
+ * @param[in] flags Flags
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_lib_poll_fd_event(hs_lib_poll_t *poll, int flags)
+{
+ hs_lib_handle_t *handle = poll->handle;
+
+ uifw_trace("hs_lib_ecore_fdevent: Enter(flags=%08x)", flags);
+
+ /* try to ws service */
+ hs_lib_com_dispatch(handle, 0);
+
+ /* control polling fd's event? */
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_ecore_fdevent
+ * callback function called by Ecore when the websocket's file
+ * descriptor had change
+ *
+ * @param[in] data user data(ico_apf_com_poll_t)
+ * @param[in] handler Ecore file descriptor handler
+ * @return call back setting
+ * @retval ECORE_CALLBACK_RENEW set callback
+ */
+/*--------------------------------------------------------------------------*/
+static Eina_Bool
+hs_lib_ecore_fdevent(void *data, Ecore_Fd_Handler *handler)
+{
+ int flags;
+
+ uifw_trace("hs_lib_ecore_fdevent: Enter");
+
+ flags
+ = (ecore_main_fd_handler_active_get(handler, ECORE_FD_READ))
+ ? EPOLLIN
+ : 0;
+ if (ecore_main_fd_handler_active_get(handler, ECORE_FD_WRITE)) {
+ flags |= ECORE_FD_WRITE;
+ }
+ if (ecore_main_fd_handler_active_get(handler, ECORE_FD_ERROR)) {
+ flags |= EPOLLERR;
+ }
+
+ hs_lib_poll_fd_event((hs_lib_poll_t *)data, flags);
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_control_fd
+ * control file descriptors to add or delete ecore event handler
+ *
+ * @param[in] fd_ctl file descriptors
+ * @param[in] num_fds number of file descriptors
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_lib_control_fd(hs_lib_poll_t *fd_ctl[], const int num_fds)
+{
+ int ii;
+ Ecore_Fd_Handler_Flags flags;
+
+ for (ii = 0; ii < num_fds; ii++) {
+ if (fd_ctl[ii]->flags) {
+ flags = (fd_ctl[ii]->flags & EPOLLIN) ? ECORE_FD_READ : 0;
+ if (fd_ctl[ii]->flags & EPOLLOUT) {
+ flags |= ECORE_FD_WRITE;
+ }
+ if (fd_ctl[ii]->flags & (EPOLLERR | EPOLLPRI)) {
+ flags |= ECORE_FD_ERROR;
+ }
+ if (!fd_ctl[ii]->user_data) {
+ uifw_trace(
+ "hs_lib_control_fd: ADD(fd=%d, flg=%08x, eflg=%08x)",
+ fd_ctl[ii]->fd, fd_ctl[ii]->flags, flags);
+ fd_ctl[ii]->user_data
+ = (void *)ecore_main_fd_handler_add(
+ fd_ctl[ii]->fd,
+ flags,
+ hs_lib_ecore_fdevent,
+ (void *)fd_ctl[ii],
+ NULL, NULL);
+ }
+ else {
+ uifw_trace(
+ "hs_lib_control_fd: CHANGE(fd=%d, flg=%08x, eflg=%08x)",
+ fd_ctl[ii]->fd, fd_ctl[ii]->flags, flags);
+ ecore_main_fd_handler_active_set(
+ (Ecore_Fd_Handler *)fd_ctl[ii]->user_data,
+ flags);
+ }
+ }
+ else {
+ /* remove file descriptor */
+ uifw_trace("hs_lib_control_fd: DELL(fd=%d)", fd_ctl[ii]->fd);
+ ecore_main_fd_handler_del((Ecore_Fd_Handler *)fd_ctl[ii]->user_data);
+ }
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_add_poll_fd
+ * add file descriptor of websocket for poll
+ *
+ * @param[in] fd file descriptor
+ * @param[in] flags event flag
+ * @return result
+ * @retval ICO_HS_OK success
+ * @retval ICO_HS_ERR error
+ */
+/*--------------------------------------------------------------------------*/
+static int
+hs_lib_add_poll_fd(int fd, int flags)
+{
+ hs_lib_poll_t *poll;
+ hs_lib_poll_t *fds[0];
+ hs_lib_handle_t *handle;
+
+ /* get management table */
+ poll = hs_polls;
+ while (poll) {
+ if (poll->fd == fd) {
+ break;
+ }
+ poll = poll->next;
+ }
+ if (!poll) {
+ if (hs_polls_free) {
+ poll = hs_polls_free;
+ hs_polls_free = poll->next;
+ poll->user_data = NULL;
+ }
+ else {
+ poll = calloc(sizeof(hs_lib_poll_t), 1);
+ if (!poll) {
+ uifw_warn("hs_lib_add_poll_fd: ERR(allocate poll table failed)");
+ return ICO_HS_ERR;
+ }
+ }
+ poll->fd = fd;
+ poll->next = hs_polls;
+ hs_polls = poll;
+ }
+ poll->flags = flags;
+
+ /* if the fd is same as wsi_context, set the handle */
+ handle = hs_handles;
+ while (handle) {
+ if (handle->fd == fd)
+ break;
+ handle = handle->next;
+ }
+ if (handle) {
+ poll->handle = handle;
+ handle->poll = poll;
+ }
+ else {
+ poll->handle = NULL;
+ }
+
+ /* control fds */
+ fds[0] = poll;
+ hs_lib_control_fd(fds, 1);
+
+ return ICO_HS_OK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_del_poll_fd
+ * delete file descriptor of websocket for poll
+ *
+ * @param[in] fd file descriptor
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_lib_del_poll_fd(int fd)
+{
+ hs_lib_poll_t *poll;
+ hs_lib_poll_t *fds[0];
+
+ /* get management table */
+ poll = hs_polls;
+ while (poll) {
+ if (poll->fd == fd) {
+ hs_polls = poll->next;
+
+ /* control fds */
+ poll->flags = 0;
+ fds[0] = poll;
+ hs_lib_control_fd(fds, 1);
+
+ /* add free polls */
+ poll->next = hs_polls_free;
+ hs_polls_free = poll;
+ break;
+ }
+ poll = poll->next;
+ }
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_set_mode_poll_fd
+ * set event to file descriptor of websocket for poll
+ *
+ * @param[in] fd file descriptor
+ * @param[in] flags event flag
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_lib_set_mode_poll_fd(int fd, int flags)
+{
+ hs_lib_poll_t *poll;
+ hs_lib_poll_t *fds[0];
+
+ /* get management table */
+ poll = hs_polls;
+ while (poll) {
+ if (poll->fd == fd) {
+ /* control fds */
+ poll->flags |= flags;
+ fds[0] = poll;
+ hs_lib_control_fd(fds, 1);
+ }
+ poll = poll->next;
+ }
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_clear_mode_poll_fd
+ * clear event to file descriptor of websocket for poll
+ *
+ * @param[in] fd file descriptor
+ * @param[in] flags event flag
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_lib_clear_mode_poll_fd(int fd, int flags)
+{
+ hs_lib_poll_t *poll;
+ hs_lib_poll_t *fds[0];
+
+ /* get management table */
+ poll = hs_polls;
+ while (poll) {
+ if (poll->fd == fd) {
+ /* control fds */
+ poll->flags &= ~flags;
+ fds[0] = poll;
+ hs_lib_control_fd(fds, 1);
+ }
+ poll = poll->next;
+ }
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief get_parsed_str
+ * extract word by the given arg_idx.
+ *
+ * @param[in] in source char array
+ * @param[in] out char array store word
+ * @param[in] len char array length
+ * @param[in] arg_idx index
+ * @return none
+ * @retval >=0 pointer to extract word
+ */
+/*--------------------------------------------------------------------------*/
+static char *
+get_parsed_str(char *in, char *out, int len, int arg_idx)
+{
+ int ii;
+ char *data;
+
+ uifw_trace("get_parsed_str: %s arg = %d", in, arg_idx);
+
+ memset(out, 0, len);
+ strncpy(out, in, len);
+ data = strtok(out, " ");
+ for (ii = 0; ii < arg_idx; ii++) {
+ data = strtok(NULL, " ");
+ }
+
+ uifw_trace("get_parsed_str data: %s", data);
+
+ return data;
+}
+
+/* get filename from the full path */
+static char *
+getFileName(char *filepath, int len)
+{
+ int ii;
+ char *name = filepath;
+
+ for (ii = 0; ii < len - 1; ii++) {
+ if (filepath[ii] == 0)
+ break;
+ if (filepath[ii] == '/')
+ name = &filepath[ii + 1];
+ }
+
+ uifw_trace("getFileName name: %s", name);
+
+ return name;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_event_message
+ * send message
+ *
+ * @param[in] type receiver
+ * @param[in] fromat message to send
+ * @return result
+ * @retval ICO_HS_OK success
+ * @retval ICO_HS_ERR error
+ */
+/*--------------------------------------------------------------------------*/
+int
+hs_lib_event_message(int type, char *format, ...)
+{
+ va_list list;
+ char message[ICO_HS_MSG_SIZE];
+ hs_lib_msg_t *send;
+
+ memset(message, 0, sizeof(message));
+
+ va_start(list, format);
+ vsnprintf(message, sizeof(message), format, list);
+ va_end(list);
+
+ uifw_trace("hs_lib_event_message: message to %d, %s", type, message);
+ send = hs_lib_alloc_msg(message, strlen(message));
+ if (!send) {
+ uifw_warn("hs_lib_event_message: ERROR(allocate send msg)");
+ return ICO_HS_ERR;
+ }
+ send->type = type;
+
+ return hs_lib_put_sendmsg(send);
+}
+
+/*--------------------------------------------------------------------------*/
+/*
+ * @brief hs_lib_callback_http
+ * Connection status is notified from libwebsockets.
+ *
+ * @param[in] context libwebsockets context
+ * @param[in] wsi libwebsockets management table
+ * @param[in] reason event type
+ * @param[in] user intact
+ * @param[in] in receive message
+ * @param[in] len message size[BYTE]
+ * @return result
+ * @retval =0 success
+ * @retval =1 error
+ */
+/*--------------------------------------------------------------------------*/
+static int
+hs_lib_callback_http(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user,
+ void *in, size_t len)
+{
+ int fd;
+
+ uifw_trace("hs_lib_callback_http: context=%p", context);
+ uifw_trace("HS-REASON %d", reason);
+
+ fd = libwebsocket_get_socket_fd(wsi);
+ switch (reason) {
+ case LWS_CALLBACK_ADD_POLL_FD:
+ uifw_trace("LWS_CALLBACK_ADD_POLL_FD: wsi_fd=%d fd=%d flg=%08x", fd,
+ (int)(long)user, (int)len);
+ (void)hs_lib_add_poll_fd(fd, (int)len);
+ break;
+
+ case LWS_CALLBACK_DEL_POLL_FD:
+ uifw_trace("LWS_CALLBACK_DEL_POLL_FD: wsi_fd=%d fd=%d flg=%08x", fd,
+ (int)(long)user, (int)len);
+ hs_lib_del_poll_fd(fd);
+ break;
+
+ case LWS_CALLBACK_SET_MODE_POLL_FD:
+ uifw_trace("LWS_CALLBACK_SET_MODE_POLL_FD: wsi_fd=%d fd=%d flg=%08x",
+ fd, (int)(long)user, (int)len);
+ hs_lib_set_mode_poll_fd(fd, (int)len);
+ break;
+
+ case LWS_CALLBACK_CLEAR_MODE_POLL_FD:
+ uifw_trace("LWS_CALLBACK_CLEAR_MODE_POLL_FD: wsi_fd=%d fd=%d flg=%08x",
+ fd, (int)(long)user, (int)len);
+ hs_lib_clear_mode_poll_fd(fd, (int)len);
+ break;
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/*
+ * @brief hs_lib_callback_command
+ * this callback function is notified from libwebsockets
+ * command protocol
+ *
+ * @param[in] context libwebsockets context
+ * @param[in] wsi libwebsockets management table
+ * @param[in] reason event type
+ * @param[in] user intact
+ * @param[in] in receive message
+ * @param[in] len message size[BYTE]
+ * @return result
+ * @retval =0 success
+ * @retval =1 error
+ */
+/*--------------------------------------------------------------------------*/
+static int
+hs_lib_callback_command(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user,
+ void *in, size_t len)
+{
+ int fd;
+ hs_lib_handle_t *handle;
+ hs_lib_poll_t *poll;
+ hs_lib_msg_t *msg;
+
+ uifw_trace("hs_lib_callback_command: Enter(ctx=%p, wsi_fd=%d, reason=%d",
+ context, libwebsocket_get_socket_fd(wsi), reason);
+
+ fd = libwebsocket_get_socket_fd(wsi);
+ if (reason == LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION) {
+ /* connect from client. the client must exist only one */
+ uifw_trace("hs_lib_callback_command: "
+ "LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION(fd=%d)", fd);
+ handle = hs_handles;
+ while (handle) {
+ if (handle->fd == fd)
+ break;
+ handle = handle->next;
+ }
+ if (!handle) {
+ handle = hs_lib_alloc_handle();
+ if (!handle) {
+ uifw_warn("hs_lib_callback_command: ERROR(allocate handle)");
+ }
+ }
+ handle->wsi_context = hs_wsicontext;
+ handle->wsi = wsi;
+ handle->fd = fd;
+ handle->type = ICO_HS_PROTOCOL_TYPE_CM;
+
+ poll = hs_polls;
+ while (poll) {
+ if (poll->fd == handle->fd) {
+ poll->handle = handle;
+ handle->poll = poll;
+ }
+ poll = poll->next;
+ }
+ return 0;
+ }
+
+ handle = hs_handles;
+ while (handle) {
+ if (handle->wsi == wsi)
+ break;
+ handle = handle->next;
+ }
+
+ switch (reason) {
+ case LWS_CALLBACK_ESTABLISHED:
+ uifw_trace("hs_lib_callback_command: "
+ "LWS_CALLBACK_ESTABLISHED(wsi=%x)", wsi);
+ handle->service_on = 1;
+
+ msg = hs_lib_alloc_msg(HS_REQ_ANS_HELLO, strlen(HS_REQ_ANS_HELLO));
+ if (!msg) {
+ uifw_warn("hs_lib_callback_command: ERROR(allocate recv msg)");
+ break;
+ }
+ msg->type = ICO_HS_PROTOCOL_TYPE_CM;
+ msg->handle = handle;
+
+ hs_lib_put_recvmsg(msg);
+ uifw_trace("hs_lib_callback_command: "
+ "LWS_CALLBACK_ESTABLISHED: Leave");
+ break;
+
+ case LWS_CALLBACK_RECEIVE:
+ uifw_trace("hs_lib_callback_command: "
+ "LWS_CALLBACK_RECEIVE:(len=%d \"%s\")", len, in);
+ if (strlen(in) == 0)
+ break;
+
+ msg = hs_lib_alloc_msg((char *)in, len);
+ if (!msg) {
+ uifw_warn("hs_lib_callback_command: ERROR(allocate recv msg)");
+ break;
+ }
+ msg->type = ICO_HS_PROTOCOL_TYPE_CM;
+ msg->handle = handle;
+
+ hs_lib_put_recvmsg(msg);
+ uifw_trace("hs_lib_callback_command: "
+ "LWS_CALLBACK_RECEIVE: Leave");
+ break;
+
+ case LWS_CALLBACK_CLOSED:
+ uifw_trace("hs_lib_callback_command: "
+ "LWS_CALLBACK_CLOSED:(wsi=%x)", wsi);
+ hs_lib_free_handle(handle);
+ break;
+
+ case LWS_CALLBACK_SERVER_WRITEABLE:
+ uifw_trace("hs_lib_callback_command: "
+ "LWS_CALLBACK_SERVER_WRITEABLE:(wsi=%x)", wsi);
+ hs_lib_realsend(hs_lib_get_sendmsg(ICO_HS_PROTOCOL_TYPE_CM));
+
+ default:
+ uifw_trace("HS-REASON %d", reason);
+ break;
+ }
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/*
+ * @brief hs_lib_callback_statusbar
+ * this callback function is notified from libwebsockets
+ * statusbar protocol
+ *
+ * @param[in] context libwebsockets context
+ * @param[in] wsi libwebsockets management table
+ * @param[in] reason event type
+ * @param[in] user intact
+ * @param[in] in receive message
+ * @param[in] len message size[BYTE]
+ * @return result
+ * @retval =0 success
+ * @retval =1 error
+ */
+/*--------------------------------------------------------------------------*/
+static int
+hs_lib_callback_statusbar(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason,
+ void *user, void *in, size_t len)
+{
+ int fd;
+ hs_lib_handle_t *handle;
+ hs_lib_poll_t *poll;
+ hs_lib_msg_t *msg;
+
+ uifw_trace("hs_lib_callback_statusbar: Enter(ctx=%p, wsi_fd=%d, reason=%d",
+ context, libwebsocket_get_socket_fd(wsi), reason);
+
+ fd = libwebsocket_get_socket_fd(wsi);
+ if (reason == LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION) {
+ /* connect from client. the client must exist only one */
+ uifw_trace("hs_lib_callback_statusbar: "
+ "LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION(fd=%d)", fd);
+ handle = hs_handles;
+ while (handle) {
+ if (handle->fd == fd)
+ break;
+ handle = handle->next;
+ }
+ if (!handle) {
+ handle = hs_lib_alloc_handle();
+ if (!handle) {
+ uifw_warn("hs_lib_callback_statusbar: ERROR(allocate handle)");
+ }
+ }
+ handle->wsi_context = hs_wsicontext;
+ handle->wsi = wsi;
+ handle->fd = fd;
+ handle->type = ICO_HS_PROTOCOL_TYPE_SB;
+
+ poll = hs_polls;
+ while (poll) {
+ if (poll->fd == handle->fd) {
+ poll->handle = handle;
+ handle->poll = poll;
+ }
+ poll = poll->next;
+ }
+ return 0;
+ }
+
+ handle = hs_handles;
+ while (handle) {
+ if (handle->wsi == wsi)
+ break;
+ handle = handle->next;
+ }
+
+ switch (reason) {
+ case LWS_CALLBACK_ESTABLISHED:
+ uifw_trace("hs_lib_callback_statusbar: "
+ "LWS_CALLBACK_ESTABLISHED(wsi=%x)", wsi);
+ handle->service_on = 1;
+ break;
+
+ case LWS_CALLBACK_RECEIVE:
+ uifw_trace("hs_lib_callback_statusbar: "
+ "LWS_CALLBACK_RECEIVE:(len=%d \"%s\")", len, in);
+
+ if (strlen(in) == 0)
+ break;
+
+ msg = hs_lib_alloc_msg((char *)in, len);
+ if (!msg) {
+ uifw_warn("hs_lib_callback_statusbar: ERROR(allocate recv msg)");
+ break;
+ }
+ msg->type = ICO_HS_PROTOCOL_TYPE_SB;
+ msg->handle = handle;
+
+ hs_lib_put_recvmsg(msg);
+ uifw_trace("hs_lib_callback_statusbar: "
+ "LWS_CALLBACK_RECEIVE: Leave");
+ break;
+
+ case LWS_CALLBACK_CLOSED:
+ uifw_trace("hs_lib_callback_statusbar: "
+ "LWS_CALLBACK_CLOSED:(wsi=%x)", wsi);
+ hs_lib_free_handle(handle);
+ break;
+
+ case LWS_CALLBACK_SERVER_WRITEABLE:
+ uifw_trace("hs_lib_callback_statusbar: "
+ "LWS_CALLBACK_SERVER_WRITEABLE:(wsi=%x)", wsi);
+ hs_lib_realsend(hs_lib_get_sendmsg(ICO_HS_PROTOCOL_TYPE_SB));
+
+ default:
+ uifw_trace("HS-REASON %d", reason);
+ break;
+ }
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/*
+ * @brief hs_lib_callback_onscreen
+ * this callback function is notified from libwebsockets
+ * statusbar protocol
+ *
+ * @param[in] context libwebsockets context
+ * @param[in] wsi libwebsockets management table
+ * @param[in] reason event type
+ * @param[in] user intact
+ * @param[in] in receive message
+ * @param[in] len message size[BYTE]
+ * @return result
+ * @retval =0 success
+ * @retval =1 error
+ */
+/*--------------------------------------------------------------------------*/
+static int
+hs_lib_callback_onscreen(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user,
+ void *in, size_t len)
+{
+ int fd;
+ hs_lib_handle_t *handle;
+ hs_lib_poll_t *poll;
+ hs_lib_msg_t *msg;
+
+ uifw_trace("hs_lib_callback_onscreen: Enter(ctx=%p, wsi_fd=%d, reason=%d",
+ context, libwebsocket_get_socket_fd(wsi), reason);
+
+ fd = libwebsocket_get_socket_fd(wsi);
+ if (reason == LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION) {
+ /* connect from client. the client must exist only one */
+ uifw_trace("hs_lib_callback_onscreen: "
+ "LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION(fd=%d)", fd);
+ handle = hs_handles;
+ while (handle) {
+ if (handle->fd == fd)
+ break;
+ handle = handle->next;
+ }
+ if (!handle) {
+ handle = hs_lib_alloc_handle();
+ if (!handle) {
+ uifw_warn("hs_lib_callback_onscreen: ERROR(allocate handle)");
+ }
+ }
+ handle->wsi_context = hs_wsicontext;
+ handle->wsi = wsi;
+ handle->fd = fd;
+ handle->type = ICO_HS_PROTOCOL_TYPE_OS;
+
+ poll = hs_polls;
+ while (poll) {
+ if (poll->fd == handle->fd) {
+ poll->handle = handle;
+ handle->poll = poll;
+ }
+ poll = poll->next;
+ }
+ return 0;
+ }
+
+ handle = hs_handles;
+ while (handle) {
+ if (handle->wsi == wsi)
+ break;
+ handle = handle->next;
+ }
+
+ switch (reason) {
+ case LWS_CALLBACK_ESTABLISHED:
+ uifw_trace("hs_lib_callback_onscreen: "
+ "LWS_CALLBACK_ESTABLISHED(wsi=%x)", wsi);
+ handle->service_on = 1;
+ break;
+
+ case LWS_CALLBACK_RECEIVE:
+ uifw_trace("hs_lib_callback_onscreen: "
+ "LWS_CALLBACK_RECEIVE:(len=%d \"%s\")", len, in);
+
+ if (strlen(in) == 0)
+ break;
+
+ msg = hs_lib_alloc_msg((char *)in, len);
+ if (!msg) {
+ uifw_warn("hs_lib_callback_onscreen: ERROR(allocate recv msg)");
+ break;
+ }
+ msg->type = ICO_HS_PROTOCOL_TYPE_OS;
+ msg->handle = handle;
+
+ hs_lib_put_recvmsg(msg);
+ uifw_trace("hs_lib_callback_onscreen: "
+ "LWS_CALLBACK_RECEIVE: Leave");
+ break;
+
+ case LWS_CALLBACK_CLOSED:
+ uifw_trace("hs_lib_callback_onscreen: "
+ "LWS_CALLBACK_CLOSED:(wsi=%x)", wsi);
+ hs_lib_free_handle(handle);
+ break;
+
+ case LWS_CALLBACK_SERVER_WRITEABLE:
+ uifw_trace("hs_lib_callback_onscreen: "
+ "LWS_CALLBACK_SERVER_WRITEABLE:(wsi=%x)", wsi);
+ hs_lib_realsend(hs_lib_get_sendmsg(ICO_HS_PROTOCOL_TYPE_OS));
+
+ break;
+
+ default:
+ uifw_trace("hs_lib_callback_onscreen: HS-REASON %d", reason);
+ break;
+ }
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/*
+ * @brief hs_lib_callback_app
+ * this callback function is notified from libwebsockets
+ * application protocol
+ *
+ * @param[in] context libwebsockets context
+ * @param[in] wsi libwebsockets management table
+ * @param[in] reason event type
+ * @param[in] user intact
+ * @param[in] in receive message
+ * @param[in] len message size[BYTE]
+ * @return result
+ * @retval =0 success
+ * @retval =1 error
+ */
+/*--------------------------------------------------------------------------*/
+static int
+hs_lib_callback_app(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user,
+ void *in, size_t len)
+{
+ int fd;
+ hs_lib_handle_t *handle;
+ hs_lib_poll_t *poll;
+ hs_lib_msg_t *msg;
+
+ uifw_trace("hs_lib_callback_app: Enter(ctx=%p, wsi_fd=%d, reason=%d",
+ context, libwebsocket_get_socket_fd(wsi), reason);
+
+ fd = libwebsocket_get_socket_fd(wsi);
+ if (reason == LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION) {
+ /* connect from client.*/
+ uifw_trace("hs_lib_callback_app: "
+ "LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION(fd=%d)", fd);
+ handle = hs_handles;
+ while (handle) {
+ if (handle->fd == fd)
+ break;
+ handle = handle->next;
+ }
+ if (!handle) {
+ handle = hs_lib_alloc_handle();
+ if (!handle) {
+ uifw_warn("hs_lib_callback_app: ERROR(allocate handle)");
+ }
+ }
+ handle->wsi_context = hs_wsicontext;
+ handle->wsi = wsi;
+ handle->fd = fd;
+ handle->type = ICO_HS_PROTOCOL_TYPE_APP;
+
+ poll = hs_polls;
+ while (poll) {
+ if (poll->fd == handle->fd) {
+ poll->handle = handle;
+ handle->poll = poll;
+ }
+ poll = poll->next;
+ }
+ return 0;
+ }
+
+ handle = hs_handles;
+ while (handle) {
+ if (handle->wsi == wsi)
+ break;
+ handle = handle->next;
+ }
+
+ switch (reason) {
+ case LWS_CALLBACK_ESTABLISHED:
+ uifw_trace("hs_lib_callback_app: "
+ "LWS_CALLBACK_ESTABLISHED(wsi=%x)", wsi);
+ handle->service_on = 1;
+ break;
+
+ case LWS_CALLBACK_RECEIVE:
+ uifw_trace("hs_lib_callback_app: "
+ "LWS_CALLBACK_RECEIVE:(len=%d \"%s\")", len, in);
+
+ if (strlen(in) == 0)
+ break;
+
+ msg = hs_lib_alloc_msg((char *)in, len);
+ if (!msg) {
+ uifw_warn("hs_lib_callback_app: ERROR(allocate recv msg)");
+ break;
+ }
+ msg->type = ICO_HS_PROTOCOL_TYPE_APP;
+ msg->handle = handle;
+
+ hs_lib_put_recvmsg(msg);
+ uifw_trace("hs_lib_callback_app: "
+ "LWS_CALLBACK_RECEIVE: Leave");
+ break;
+
+ case LWS_CALLBACK_CLOSED:
+ uifw_trace("hs_lib_callback_app: "
+ "LWS_CALLBACK_CLOSED:(wsi=%x)", wsi);
+ hs_lib_free_handle(handle);
+ break;
+
+ case LWS_CALLBACK_SERVER_WRITEABLE:
+ uifw_trace("hs_lib_callback_app: "
+ "LWS_CALLBACK_SERVER_WRITEABLE:(wsi=%x)", wsi);
+ hs_lib_realsend(hs_lib_get_sendmsg(ICO_HS_PROTOCOL_TYPE_APP));
+
+ default:
+ uifw_trace("hs_lib_callback_app: HS-REASON %d", reason);
+ break;
+ }
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_lib_main
+ * initialize homescreen lib to connect statusbar and onscreen,
+ * external command tools.
+ *
+ * @param[in] port websocket port
+ * @return result
+ * @retval ICO_HS_OK success
+ * @retval ICO_HS_ERR error
+ */
+/*--------------------------------------------------------------------------*/
+int
+hs_lib_main(int port)
+{
+ int opts = 0;
+ hs_lib_handle_t *handle;
+
+ handle = hs_lib_alloc_handle();
+ handle->wsi_context
+ = libwebsocket_create_context(ICO_HS_WS_PORT, NULL, protocols,
+ libwebsocket_internal_extensions,
+ NULL, NULL, -1, -1, opts);
+ if (handle->wsi_context == NULL) {
+ uifw_warn(
+ "home_screen_lib_main: ERROR(libwebsocket_create_context failed.)");
+ return ICO_HS_ERR;
+ }
+ hs_wsicontext = handle->wsi_context;
+
+ return ICO_HS_OK;
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief homescreen application main
+ *
+ * @date Feb-15-2013
+ */
+
+#include <Eina.h>
+#include <Evas.h>
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+#include <Ecore_Wayland.h>
+#include <Edje.h>
+#include <Elementary.h>
+
+#include <stdio.h>
+#include <pthread.h>
+#include <libwebsockets.h>
+
+#include "ico_uxf.h"
+#include "ico_uxf_conf.h"
+
+#include "ico_apf_log.h"
+#include "home_screen_lib.h"
+#include "home_screen_res.h"
+#include "home_screen_conf.h"
+#include "home_screen_parser.h"
+#include "ico_uxf_conf_common.h"
+#include "ico_syc_apc.h"
+
+/*============================================================================*/
+/* definition */
+/*============================================================================*/
+#define ICO_HS_WINDOW_TYPE_BG (1)
+#define ICO_HS_WINDOW_TYPE_TOUCH (2)
+#define ICO_HS_TOUCH_TIME_OUT (1.0) /* Long press for timer */
+typedef struct _hs_tile_info hs_tile_info_t;
+
+struct _hs_tile_info {
+ int idx; /* index: 0 to ... */
+ int valid; /* 0: invalid, 1:valid */ /* dont't touch now */
+ char appid[ICO_UXF_MAX_PROCESS_NAME]; /* active app id */
+ int type; /* 11:small, 21:h-wide, 12:v-wide, 22:large, 0:others */
+ int l_press; /* 1: long press */
+ int change;
+ int size_x;
+ int size_y;
+ int coord_x;
+ int coord_y;
+};
+
+#define HS_DISPLAY_HOMESCREEN 0 /* HomeScreen target display Id */
+#define HS_LAYER_BACKGROUND 0 /* layer of BackGround */
+#define HS_LAYER_HOMESCREEN 1 /* layer of HomeScreen menu */
+#define HS_LAYER_APPLICATION 2 /* layer of Application */
+#define HS_LAYER_TOUCH 3 /* layer of TouchPanel */
+#define HS_LAYER_ONSCREEN 4 /* layer of OnScreen */
+
+/*============================================================================*/
+/* static(internal) functions prototype */
+/*============================================================================*/
+static int hs_is_special_app(const char *appid);
+static void hs_set_invisible_all(void);
+static void hs_set_appscreen(const char *appid);
+static void hs_tile_start_apps(void);
+static int hs_tile_init_info(void);
+static void hs_convert_tile_config(char *in, int *out, int cnt, int val);
+static Eina_Bool hs_ecore_uxf_eventfd(void *data, Ecore_Fd_Handler *handler);
+static void hs_uxf_event(int ev, Ico_Uxf_EventDetail dd, int arg);
+static int hs_get_process_window(const char *appid);
+static void hs_display_control(const Ico_Uxf_conf_application *conf, const int show);
+static void hs_sound_control(const Ico_Uxf_conf_application *conf, const int adjust);
+static void hs_input_control(const Ico_Uxf_conf_application *conf, const int inputsw);
+static void *hs_create_window(int type);
+static void hs_touch_up_api_list(void *data, Evas *evas, Evas_Object *obj,
+ void *event_info);
+static void hs_touch_down_api_list(void *data, Evas *evas, Evas_Object *obj,
+ void *event_info);
+static Eina_Bool hs_ecore_timer_event(void *data);
+static void hs_touch_up_tile(void *data, Evas *evas, Evas_Object *obj, void *event_info);
+static void hs_touch_down_tile(void *data, Evas *evas, Evas_Object *obj, void *event_info);
+static void hs_add_touch_listener(Evas *canvas_fg);
+static void hs_add_bg_image(Evas *canvas_bg);
+static void hs_terminate_all_app(void);
+
+/*============================================================================*/
+/* variables and tables */
+/*============================================================================*/
+char hs_kill_appid[ICO_UXF_MAX_PROCESS_NAME];
+ /* set kill 'app id' in touch layer */
+char hs_active_onscreen[ICO_UXF_MAX_PROCESS_NAME];
+ /* stack 'app id' at active onscreen */
+hs_window_data_t hs_command_tile_req[ICO_HS_APP_NUM_MAX];
+hs_window_data_t hs_app_screen_window[ICO_HS_APP_NUM_MAX];
+char hs_name_homescreen[ICO_UXF_MAX_PROCESS_NAME + 1];
+static char gStatusbarName[ICO_UXF_MAX_PROCESS_NAME + 1];
+static char gOnscreenName[ICO_UXF_MAX_PROCESS_NAME + 1];
+static hs_tile_info_t *hs_tile_info;
+static int hs_tile_cnt = 0;
+
+/*============================================================================*/
+/* functions */
+/*============================================================================*/
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_uxf_event
+ * callback function called by UXF.
+ *
+ * @param[in] ev event kinds
+ * @param[in] dd event detail structure
+ * @param[in] arg user data
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_uxf_event(int ev, Ico_Uxf_EventDetail dd, int arg)
+{
+ uifw_trace("... Event=%08x Arg=%d", ev, arg);
+
+ Ico_Uxf_WindowAttr winAttr;
+ int ret;
+ int idx;
+ int dispW, dispH;
+
+ if (ev == ICO_UXF_EVENT_NEWWINDOW) {
+ uifw_trace(
+ " D(Window) ev=%08x disp=%d win=%x x/y=%d/%d w/h=%d/%d v/r/a=%d/%d/%d",
+ dd.event, dd.window.display, dd.window.window,
+ dd.window.x, dd.window.y, dd.window.w, dd.window.h,
+ dd.window.visible, dd.window.raise, dd.window.active);
+ ret = ico_uxf_window_attribute_get(dd.window.window, &winAttr);
+ if (ret == ICO_UXF_EOK) {
+ uifw_trace(" D(Window) appid=%s sub=%d", winAttr.process,
+ winAttr.subwindow);
+ if (strncmp(winAttr.process, hs_name_homescreen,
+ ICO_UXF_MAX_PROCESS_NAME) == 0) {
+ ico_uxf_window_screen_size_get(&dispW, &dispH);
+ /* HomeScreen APP: BG or TOUCH */
+ ico_uxf_window_resize(dd.window.window, dispW, dispH
+ - ICO_HS_SIZE_SB_HEIGHT);
+ ico_uxf_window_move(dd.window.window, 0, ICO_HS_SIZE_SB_HEIGHT);
+ ico_uxf_window_show(dd.window.window);
+ if (winAttr.subwindow > 0) {
+ /* set layer of HomeScreen TouchPanel window */
+ ico_uxf_window_layer(dd.window.window, HS_LAYER_TOUCH);
+ hs_tile_show_screen();
+ }
+ else {
+ /* set layer of HomeScreen BackGround window */
+ ico_uxf_window_layer(dd.window.window, HS_LAYER_BACKGROUND);
+ }
+ }
+ else if (strncmp(winAttr.process, gStatusbarName,
+ ICO_UXF_MAX_PROCESS_NAME) == 0) {
+ /* set layer of StatusBar window */
+ ico_uxf_window_layer(dd.window.window, HS_LAYER_ONSCREEN);
+ /* show status bar */
+ ico_uxf_window_show(dd.window.window);
+ ico_uxf_window_move(dd.window.window, 0, 0);
+ ico_uxf_window_screen_size_get(&dispW, &dispH);
+ ico_uxf_window_resize(dd.window.window, dispW, ICO_HS_SIZE_SB_HEIGHT);
+ }
+ else if (strncmp(winAttr.process, gOnscreenName,
+ ICO_UXF_MAX_PROCESS_NAME) == 0) {
+ /* set layer of OnScreen window */
+ ico_uxf_window_layer(dd.window.window, HS_LAYER_BACKGROUND);
+ ico_uxf_window_visible_raise(dd.window.window, 1, 0);
+ }
+ else {
+ /* other normal application */
+ if (hs_is_special_app(winAttr.process) == FALSE) {
+ if (hs_stat_touch == ICO_HS_TOUCH_IN_SHOW) {
+ /* set layer of Application in HomeScreen menu */
+ ico_uxf_window_layer(dd.window.window, HS_LAYER_HOMESCREEN);
+ hs_tile_show_screen();
+ }
+ if (hs_stat_touch == ICO_HS_TOUCH_IN_HIDE) {
+ /* set layer of Application */
+ ico_uxf_window_layer(dd.window.window, HS_LAYER_APPLICATION);
+ hs_set_appscreen(winAttr.process);
+ }
+ }
+ }
+ }
+ }
+ else if (ev == ICO_UXF_EVENT_TERMPROCESS) {
+ uifw_trace("hs_uxf_event: ICO_UXF_EVENT_TERMPROCESS");
+
+ if (strlen(dd.process.process) != 0) {
+ idx = hs_tile_get_index_app(dd.process.process);
+ if (idx >= 0) {
+ hs_tile_free_app(idx);
+ }
+ }
+ }
+ else if (ev == ICO_UXF_EVENT_ACTIVEWINDOW) {
+ /* set active window */
+ if (dd.window.active == ICO_UXF_WINDOW_SELECT) {
+ if (ico_uxf_window_attribute_get(dd.window.window, &winAttr) == ICO_UXF_EOK) {
+ if ((strncmp(winAttr.process, hs_name_homescreen, ICO_UXF_MAX_PROCESS_NAME)
+ != 0) &&
+ (strncmp(winAttr.process, gStatusbarName, ICO_UXF_MAX_PROCESS_NAME)
+ != 0) &&
+ (strncmp(winAttr.process, gOnscreenName, ICO_UXF_MAX_PROCESS_NAME)
+ != 0)) {
+ ico_uxf_window_active(dd.window.window);
+ ico_uxf_window_raise(dd.window.window);
+ ico_syc_apc_active(winAttr.process);
+ }
+ }
+ }
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_ecore_uxf_eventfd
+ * callback function of wayland fd event that is used in UXF.
+ * if the fd has event, ecore call this function.
+ *
+ * @param[in] data user data
+ * @param[in] handler handler
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static Eina_Bool
+hs_ecore_uxf_eventfd(void *data, Ecore_Fd_Handler *handler)
+{
+#if 0 /* too many tracelog, change to comment out */
+ uifw_trace("hs_ecore_uxf_eventfd: Enter(fd=%d)",
+ ecore_main_fd_handler_fd_get(handler));
+
+ if (ecore_main_fd_handler_active_get(handler, ECORE_FD_READ)) {
+ uifw_trace("hs_ecore_uxf_eventfd: ECORE_FD_READ");
+ }
+ else if (ecore_main_fd_handler_active_get(handler, ECORE_FD_WRITE)) {
+ uifw_trace("hs_ecore_uxf_eventfd: ECORE_FD_WRITE");
+ }
+ else if (ecore_main_fd_handler_active_get(handler, ECORE_FD_ERROR)) {
+ uifw_trace("hs_ecore_uxf_eventfd: ECORE_FD_ERROR");
+ }
+#endif /* too many tracelog, change to comment out */
+
+ ico_uxf_main_loop_iterate();
+
+ return EINA_TRUE;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_convert_tile_config
+ * for read configuration.
+ * convert configuration string to integer array.
+ *
+ * @param[in] in configuration
+ * @param[out] out integer array
+ * @param[in] cnt count
+ * @param[in] val default value
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_convert_tile_config(char *in, int *out, int cnt, int val)
+{
+ int idx;
+ char *tok;
+ char *s = ";";
+
+ for (idx = 0; idx < cnt; idx++) {
+ out[idx] = val;
+ }
+ if (in != NULL) {
+ tok = strtok(in, s);
+ for (idx = 0; idx < cnt; idx++) {
+ out[idx] = atoi(tok);
+ tok = strtok(NULL, s);
+ if (tok == NULL) {
+ break;
+ }
+ }
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_get_index_appscreendata
+ * get applicaton screen data index.
+ *
+ * @param[in] appid application id
+ * @return result
+ * @retval >=0 app index
+ * @retval -1 not exist
+ */
+/*--------------------------------------------------------------------------*/
+int
+hs_get_index_appscreendata(const char *appid)
+{
+ int idx = -1;
+ int ii;
+
+ for (ii = 0; ii < ICO_HS_APP_NUM_MAX; ii++) {
+ if (hs_app_screen_window[ii].appid[0] == 0) {
+ if (idx == -1) {
+ idx = ii;
+ }
+ continue;
+ }
+ if (strncmp(hs_app_screen_window[ii].appid, appid,
+ ICO_UXF_MAX_PROCESS_NAME) == 0) {
+ return ii;
+ }
+ }
+
+ if (idx >= 0) {
+ strncpy(hs_app_screen_window[idx].appid, appid,
+ ICO_UXF_MAX_PROCESS_NAME);
+ }
+ return idx;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_set_appscreen
+ * set the application screen's status to the applicaton window,
+ * and visible raise the application window.
+ *
+ * @param[in] appid application id
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_set_appscreen(const char *appid)
+{
+ int idx;
+ int ret;
+ Ico_Uxf_ProcessWin window;
+
+ idx = hs_get_index_appscreendata(appid);
+
+ if (idx < 0) {
+ return;
+ }
+
+ /* visible raise */
+ ret = ico_uxf_process_window_get(hs_app_screen_window[idx].appid, &window, 1);
+ if ((ret > 0) || (ret == ICO_UXF_E2BIG)) {
+ uifw_trace(
+ "hs_set_appscreen: app[%d]:visible=%d raise=%d %dx%d(%d,%d)",
+ idx, hs_app_screen_window[idx].visible,
+ hs_app_screen_window[idx].raise,
+ hs_app_screen_window[idx].resize_w,
+ hs_app_screen_window[idx].resize_h,
+ hs_app_screen_window[idx].move_x,
+ hs_app_screen_window[idx].move_y);
+ /* move application window to application layer */
+ ico_uxf_window_layer(window.window, HS_LAYER_APPLICATION);
+ ico_uxf_window_move(window.window, hs_app_screen_window[idx].move_x,
+ hs_app_screen_window[idx].move_y);
+ ico_uxf_window_resize(window.window,
+ hs_app_screen_window[idx].resize_w,
+ hs_app_screen_window[idx].resize_h);
+ ico_uxf_window_visible_raise(window.window,
+ hs_app_screen_window[idx].visible,
+ hs_app_screen_window[idx].raise);
+ /* show application layer */
+ ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_APPLICATION, 1);
+ /* hide HomeScreen layer */
+ ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_HOMESCREEN, 0);
+ }
+ ico_uxf_main_loop_iterate();
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_set_invisible_all
+ * set all applicatoin except special applicaion(homescreen
+ * /statusbar/onscreen) in invisible.
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_set_invisible_all(void)
+{
+ uifw_trace("hs_set_invisible_all: Enter");
+
+ /* hide application layer */
+ ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_APPLICATION, 0);
+ /* hide HomeScreen layer menu */
+ ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_HOMESCREEN, 0);
+
+ uifw_trace("hs_set_invisible_all: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_show_appscreen
+ * show applicaton screen and raise the indicated application.
+ *
+ * @param[in] appid application id
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+hs_show_appscreen(const char *appid)
+{
+ Ico_Uxf_ProcessWin window;
+ const Ico_Uxf_conf_application *appConf = NULL;
+ int ii, idx;
+ int ret;
+ int dispW, dispH;
+ int sid;
+
+ uifw_trace("hs_show_appscreen: Enter(appid=%s)", appid ? appid : "(NULL)");
+ /* change to noraml mode for AppsControler */
+ ico_uxf_window_control(NULL, -1, ICO_UXF_APPSCTL_TEMPVISIBLE, 0);
+
+ /* touch to invisible */
+ sid = hs_get_process_window(ICO_HS_APPID_DEFAULT_TOUCH);
+ if (sid >= 0) {
+ ico_uxf_window_hide(sid);
+ }
+ /* all apps invisible */
+ hs_set_invisible_all();
+
+ /* show other apps */
+ for (ii = 0; ii < ICO_HS_APP_NUM_MAX; ii++) {
+ if (hs_app_screen_window[ii].appid[0] == 0)
+ continue;
+ appConf = ico_uxf_getAppByAppid(hs_app_screen_window[ii].appid);
+ if (appConf != NULL) {
+ hs_app_screen_window[ii].category = appConf->categoryId;
+ }
+ if (hs_is_special_app(hs_app_screen_window[ii].appid))
+ continue;
+ if ((appid != NULL) && strncmp(hs_app_screen_window[ii].appid, appid,
+ ICO_UXF_MAX_PROCESS_NAME) == 0)
+ continue;
+
+ /* if invisible */
+ ret = ico_uxf_process_window_get(hs_app_screen_window[ii].appid,
+ &window, 1);
+ uifw_trace("hs_show_appscreen: window_get app[%s] = %d(visible=%d)",
+ hs_app_screen_window[ii].appid, ret,
+ hs_app_screen_window[ii].visible);
+ if ((ret > 0) || (ret == ICO_UXF_E2BIG)) {
+ if (hs_app_screen_window[ii].visible == 0) {
+ }
+ else {
+ uifw_trace("hs_show_appscreen: move %d=%dx%d(%d,%d)", ii,
+ hs_app_screen_window[ii].resize_w,
+ hs_app_screen_window[ii].resize_h,
+ hs_app_screen_window[ii].move_x,
+ hs_app_screen_window[ii].move_y);
+ /* move application window to application layer */
+ ico_uxf_window_resize(window.window,
+ hs_app_screen_window[ii].resize_w,
+ hs_app_screen_window[ii].resize_h);
+ ico_uxf_window_move(window.window,
+ hs_app_screen_window[ii].move_x,
+ hs_app_screen_window[ii].move_y);
+ ico_uxf_window_show(window.window);
+ ico_uxf_window_layer(window.window, HS_LAYER_APPLICATION);
+ }
+ }
+ }
+ /* show application layer */
+ ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_APPLICATION, 1);
+ /* hide HomeScreen layer menu */
+ ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_HOMESCREEN, 0);
+
+ /* show own apps */
+ if (appid != NULL) {
+ idx = hs_get_index_appscreendata(appid);
+ /* if not set pos, load default */
+ appConf = ico_uxf_getAppByAppid(appid);
+ if (appConf != NULL) {
+ int x, y, width, height;
+ (void)ico_uxf_getAppDisplay(appConf, 0, &x, &y, &width, &height);
+
+ if ((hs_app_screen_window[idx].resize_w == -1)
+ || (hs_app_screen_window[idx].resize_h == -1)) {
+ hs_app_screen_window[idx].resize_w = width;
+ hs_app_screen_window[idx].resize_h = height;
+ }
+ if ((hs_app_screen_window[idx].move_x == -1)
+ || (hs_app_screen_window[idx].move_y == -1)) {
+ hs_app_screen_window[idx].move_x = x;
+ hs_app_screen_window[idx].move_y = y;
+ }
+ if ((hs_app_screen_window[idx].resize_w == 0)
+ && (hs_app_screen_window[idx].resize_h == 0)
+ && (hs_app_screen_window[idx].move_x == 0)
+ && (hs_app_screen_window[idx].move_y == 0)) {
+ /* not have manifest, set default */
+ ico_uxf_window_screen_size_get(&dispW, &dispH);
+ hs_app_screen_window[idx].resize_w = dispW;
+ hs_app_screen_window[idx].resize_h = (dispH - ICO_HS_SIZE_SB_HEIGHT) / 2;
+ hs_app_screen_window[idx].move_x = 0;
+ hs_app_screen_window[idx].move_y = ICO_HS_SIZE_SB_HEIGHT;
+ }
+ }
+
+ /* show */
+ ret = ico_uxf_process_window_get(appid, &window, 1);
+ uifw_trace("hs_show_appscreen: window_get app[%s] = %d", appid, ret);
+ if ((ret > 0) || (ret == ICO_UXF_E2BIG)) {
+ uifw_trace("hs_show_appscreen: move %d=%dx%d(%d,%d)", idx,
+ hs_app_screen_window[idx].resize_w,
+ hs_app_screen_window[idx].resize_h,
+ hs_app_screen_window[idx].move_x,
+ hs_app_screen_window[idx].move_y);
+ /* activate application window */
+ ico_uxf_window_active(window.window);
+ ico_uxf_window_raise(window.window);
+ ico_syc_apc_active(appid);
+
+ /* move application window to application layer */
+ ico_uxf_window_resize(window.window,
+ hs_app_screen_window[idx].resize_w,
+ hs_app_screen_window[idx].resize_h);
+ ico_uxf_window_move(window.window,
+ hs_app_screen_window[idx].move_x,
+ hs_app_screen_window[idx].move_y);
+ ico_uxf_window_visible_raise(window.window, 1, 1);
+ ico_uxf_window_layer(window.window, HS_LAYER_APPLICATION);
+ hs_app_screen_window[idx].visible = 1;
+ /* show application layer */
+ ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_APPLICATION, 1);
+ /* hide HomeScreen layer */
+ ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_HOMESCREEN, 0);
+ }
+ }
+
+ hs_stat_touch = ICO_HS_TOUCH_IN_HIDE;
+ ico_uxf_main_loop_iterate();
+
+ uifw_trace("hs_show_appscreen: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_tile_start_apps
+ * launch the default application that indicated by configuration
+ * file.
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_tile_start_apps(void)
+{
+ char cName[ICO_UXF_MAX_PROCESS_NAME + 1];
+ int idx, ret;
+ const char *appName;
+ hs_tile_info_t *tinfo;
+
+ /* excute */
+ for (idx = 0; idx < hs_tile_cnt; idx++) {
+ tinfo = &hs_tile_info[idx];
+ if (tinfo->valid == 0)
+ continue; sprintf(cName, ICO_HS_CONFIG_TILE_APP"%d", idx);
+ appName = hs_conf_get_string(ICO_HS_CONFIG_HOMESCREEN, cName, NULL);
+ if ((appName != NULL) && (strcmp(appName, "none") != 0)) {
+ ret = ico_uxf_process_execute(appName);
+ if (ret >= 0) {
+ uifw_trace("hs_tile_start_apps: execute tile[%d]=%s", idx,
+ appName);
+ memset(tinfo->appid, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
+ strncpy(tinfo->appid, appName, ICO_UXF_MAX_PROCESS_NAME);
+ }
+ }
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_tile_init_info
+ * initialize tile information.
+ *
+ * @param none
+ * @return result
+ * @retval ICO_HS_OK success
+ * @retval ICO_HS_ERR err
+ */
+/*--------------------------------------------------------------------------*/
+static int
+hs_tile_init_info(void)
+{
+ int idx, row, column;
+ char *sValid = NULL;
+ char *sType = NULL;
+ int *valid = NULL;
+ int *type = NULL;
+ int dispW, dispH;
+ int width, height;
+ int mSide, mTop;
+ int colcnt, rowcnt, tilecnt, tilesize;
+ int try = 0;
+ hs_tile_info_t *tinfo;
+
+ /* count tile */
+ colcnt = hs_conf_get_integer(ICO_HS_CONFIG_HOMESCREEN,
+ ICO_HS_CONFIG_TILE_COLCNT,
+ ICO_HS_CONFIG_TILE_COLCNT_DEFAULT);
+ rowcnt = hs_conf_get_integer(ICO_HS_CONFIG_HOMESCREEN,
+ ICO_HS_CONFIG_TILE_ROWCNT,
+ ICO_HS_CONFIG_TILE_ROWCNT_DEFAULT);
+ tilecnt = colcnt * rowcnt;
+
+ /* allocate tile info structure */
+ hs_tile_info = malloc(sizeof(hs_tile_info_t) * tilecnt);
+ valid = (int *)malloc(sizeof(int) * tilecnt);
+ type = (int *)malloc(sizeof(int) * tilecnt);
+ if (!hs_tile_info || !valid || !type) {
+ uifw_warn("hs_tile_init_info: Leave(err malloc tile str failed)");
+ return ICO_HS_ERR;
+ }
+
+ /* get screen size */
+ ico_uxf_window_screen_size_get(&dispW, &dispH);
+ while ((dispW < 0) || (dispH < 0)) {
+ ico_uxf_main_loop_iterate();
+ try++;
+ if (try > 10) {
+ uifw_warn("hs_tile_init_info: Leave(cannot get screen size)");
+ return ICO_HS_ERR;
+ }
+ usleep(10000);
+ ico_uxf_window_screen_size_get(&dispW, &dispH);
+ }
+ width = dispW;
+ height = dispH - ICO_HS_SIZE_SB_HEIGHT;
+
+ /* determin tile size (interval the tile is 10 percent of the tile width) */
+ if (((float)width / (float)colcnt) > ((float)height / (float)rowcnt)) {
+ /* tile size based height */
+ tilesize = height / (1.0 * rowcnt + 0.1 * (rowcnt + 1));
+ mSide = (width - (tilesize * colcnt + tilesize * 0.1 * (colcnt + 1)))
+ / 2;
+ mTop = 0;
+ }
+ else {
+ /* tile size based width */
+ tilesize = width / (1.0 * colcnt + 0.1 * (colcnt + 1));
+ mSide = 0;
+ mTop = (height - (tilesize * rowcnt + tilesize * 0.1 * (rowcnt + 1)))
+ / 2;
+ }
+ uifw_trace("hs_tile_init_info: mSide=%d mTop=%d disp(%dx%d)", mSide, mTop,
+ dispW, dispH);
+
+ /* get tile config */
+ sValid = (char *)hs_conf_get_string(ICO_HS_CONFIG_HOMESCREEN,
+ ICO_HS_CONFIG_TILE_VALID, NULL);
+ sType = (char *)hs_conf_get_string(ICO_HS_CONFIG_HOMESCREEN,
+ ICO_HS_CONFIG_TILE_TYPE, NULL);
+ hs_convert_tile_config(sValid, valid, tilecnt, 1);
+ hs_convert_tile_config(sType, type, tilecnt, ICO_HS_TILE_SMALL);
+
+ /* set tile parameter */
+ for (idx = 0; idx < tilecnt; idx++) {
+ tinfo = &hs_tile_info[idx];
+ row = idx / colcnt;
+ column = idx % colcnt;
+ tinfo->idx = idx;
+ memset(tinfo->appid, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
+ tinfo->valid = valid[idx];
+ tinfo->type = type[idx];
+ if (idx == tilecnt - 1) {
+ tinfo->type = ICO_HS_TILE_OTHERS;
+ }
+ tinfo->l_press = 0;
+ tinfo->change = 0;
+
+ tinfo->coord_x = mSide + tilesize * 0.1 + (tilesize + tilesize * 0.1)
+ * column;
+ tinfo->coord_y = mTop + ICO_HS_SIZE_SB_HEIGHT + tilesize * 0.1 + (tilesize
+ + tilesize * 0.1) * row;
+ switch (tinfo->type) {
+ case ICO_HS_TILE_SMALL:
+ tinfo->size_x = tilesize;
+ tinfo->size_y = tilesize;
+ break;
+ case ICO_HS_TILE_HWIDE:
+ tinfo->size_x = tilesize;
+ tinfo->size_y = tilesize * 2.1;
+ break;
+ case ICO_HS_TILE_VWIDE:
+ tinfo->size_x = tilesize * 2.1;
+ tinfo->size_y = tilesize;
+ break;
+ case ICO_HS_TILE_LARGE:
+ tinfo->size_x = tilesize * 2.1;
+ tinfo->size_y = tilesize * 2.1;
+ break;
+ default:
+ tinfo->size_x = tilesize;
+ tinfo->size_y = tilesize;
+ break;
+ }
+
+ uifw_trace("TILE_INFO:tile[%d]={%d,%d,%s,%d,%d,%d,(%dx%d),(%d,%d)}",
+ idx, tinfo->idx, tinfo->valid, tinfo->appid, tinfo->type,
+ tinfo->l_press, tinfo->change, tinfo->size_x, tinfo->size_y,
+ tinfo->coord_x, tinfo->coord_y);
+ }
+
+ hs_tile_cnt = tilecnt;
+
+ return ICO_HS_OK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_tile_free_app
+ * delete all information of the indicated tile.
+ *
+ * @param[in] idx tile index
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+hs_tile_free_app(int idx)
+{
+ hs_tile_info_t *tinfo;
+
+ if ((idx >= 0) && (idx < hs_tile_cnt)) {
+ tinfo = &hs_tile_info[idx];
+ memset(tinfo->appid, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_tile_show_screen
+ * show tile screen again.
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+hs_tile_show_screen(void)
+{
+ Ico_Uxf_ProcessWin window;
+ int ret;
+ int idx, sid;
+ hs_tile_info_t *tinfo;
+
+ /* all apps invisible */
+ /* hide HomeScreen layer menu */
+ ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_HOMESCREEN, 0);
+
+ /* show application tile */
+ for (idx = 0; idx < hs_tile_cnt; idx++) {
+ tinfo = &hs_tile_info[idx];
+ if (tinfo->appid[0] == 0)
+ continue;
+
+ ret = ico_uxf_process_window_get(tinfo->appid, &window, 1);
+ uifw_trace("hs_tile_show_screen: window_get app[%s] = %d(%08x)",
+ tinfo->appid, ret, window.window);
+ if (((ret > 0) || (ret == ICO_UXF_E2BIG)) && (window.window != 0)) {
+ uifw_trace("hs_tile_show_screen: move %d=%dx%d(%d,%d)", idx,
+ tinfo->size_x, tinfo->size_y, tinfo->coord_x, tinfo->coord_y);
+ /* move application window to HomeScreen layer */
+ ico_uxf_window_layer(window.window, HS_LAYER_HOMESCREEN);
+ ico_uxf_window_resize(window.window, tinfo->size_x, tinfo->size_y);
+ ico_uxf_window_move(window.window, tinfo->coord_x, tinfo->coord_y);
+ ico_uxf_window_visible_raise(window.window, 1, 1);
+ }
+ }
+
+ hs_stat_touch = ICO_HS_TOUCH_IN_SHOW;
+ /* visible and raise touch layer */
+ sid = hs_get_process_window(ICO_HS_APPID_DEFAULT_TOUCH);
+ if (sid >= 0) {
+ ico_uxf_window_visible_raise(sid, 1, 1);
+ }
+ /* show HomeScreen layer menu */
+ ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_HOMESCREEN, 1);
+ /* hide application layer */
+ ico_uxf_layer_visible(HS_DISPLAY_HOMESCREEN, HS_LAYER_APPLICATION, 0);
+
+ /* chnage to noraml mode for AppsControler */
+ ico_uxf_window_control(NULL, -1, ICO_UXF_APPSCTL_TEMPVISIBLE, 1);
+
+ ico_uxf_main_loop_iterate();
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_tile_get_index_app
+ * Get tile index that has indicated application id.
+ *
+ * @param[in] appid application id
+ * @return result
+ * @retval >=0 tile index
+ * @retval -1 not exist
+ */
+/*--------------------------------------------------------------------------*/
+int
+hs_tile_get_index_app(const char *appid)
+{
+ int idx;
+ hs_tile_info_t *tinfo;
+
+ for (idx = 0; idx < hs_tile_cnt; idx++) {
+ tinfo = &hs_tile_info[idx];
+ if (strncmp(tinfo->appid, appid, ICO_UXF_MAX_PROCESS_NAME) == 0) {
+ return idx;
+ }
+ }
+
+ return -1;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_tile_get_minchange
+ * Get a application tile index that has no application
+ * or is changed minimum
+ *
+ * @param none
+ * @return result
+ * @retval >= success(tile index)
+ * @retval < 0 error
+ */
+/*--------------------------------------------------------------------------*/
+int
+hs_tile_get_minchange(void)
+{
+ int ii;
+ int idx = -1;
+ int min = -1;
+ hs_tile_info_t *tinfo;
+
+ for (ii = 0; ii < hs_tile_cnt; ii++) {
+ tinfo = &hs_tile_info[ii];
+ if ((tinfo->type != ICO_HS_TILE_OTHERS) && ((tinfo->change <= min)
+ || (min == -1))) {
+ idx = ii;
+ min = tinfo->change;
+ }
+ if ((tinfo->type != ICO_HS_TILE_OTHERS) && (strlen(tinfo->appid) == 0)) {
+ return ii;
+ }
+ }
+
+ return idx;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_tile_kill_app
+ * terminate the indicated application, and free the tile
+ * that have the application.
+ *
+ * @param[in] appid application id
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+hs_tile_kill_app(const char *appid)
+{
+ int idx, ret;
+
+ idx = hs_tile_get_index_app(appid);
+ if (idx < 0) {
+ return;
+ }
+
+ ret = ico_uxf_process_terminate(appid);
+ if (ret == ICO_UXF_EOK) {
+ hs_tile_free_app(idx);
+ }
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_tile_get_index_pos
+ * get the tile index of the position.
+ *
+ * @param[in] appid application id
+ * @return tile index
+ * @retval >=0 success
+ * @retval ICO_HS_ERR error
+ */
+/*--------------------------------------------------------------------------*/
+int
+hs_tile_get_index_pos(int x, int y, int w, int h)
+{
+ int idx = -1;
+ hs_tile_info_t *tinfo;
+
+ for (idx = 0; idx < hs_tile_cnt; idx++) {
+ tinfo = &hs_tile_info[idx];
+ if ((tinfo->coord_x == x) && (tinfo->coord_y == y) && (tinfo->size_x
+ == w) && (tinfo->size_y == h)) {
+ return idx;
+ }
+ }
+
+ return ICO_HS_ERR;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_tile_set_app
+ * set the applicaton to the tile of the indicated index.
+ *
+ * @param[in] idx tile index
+ * @param[in] appid application id
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+hs_tile_set_app(int idx, const char *appid)
+{
+ hs_tile_info_t *tinfo;
+
+ uifw_trace("hs_tile_set_app: Enter(idx=%d appid=%s)", idx, appid);
+
+ if (idx >= 0) {
+ tinfo = &hs_tile_info[idx];
+ if (tinfo->valid > 0) {
+ int oldwin = hs_get_process_window(tinfo->appid);
+ if (oldwin > 0) {
+ (void) ico_uxf_window_hide(oldwin);
+ }
+ strncpy(tinfo->appid, appid, ICO_UXF_MAX_PROCESS_NAME);
+ tinfo->change++;
+ }
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_get_process_window
+ * get window surface from applicatoin id including special id.
+ *
+ * @param[in] appid application id
+ * @return result
+ * @retval >=0 surface
+ * @retval -1 not exist
+ */
+/*--------------------------------------------------------------------------*/
+static int
+hs_get_process_window(const char *appid)
+{
+ Ico_Uxf_ProcessWin wins[2];
+ int ret;
+
+ if (strcmp(appid, ICO_HS_APPID_DEFAULT_TOUCH) == 0) {
+ ret = ico_uxf_process_window_get(hs_name_homescreen, wins, 2);
+ if ((ret > 1) || (ret == ICO_UXF_E2BIG)) {
+ return wins[1].window;
+ }
+ }
+ else {
+ ret = ico_uxf_process_window_get(appid, wins, 1);
+ if ((ret > 0) || (ret == ICO_UXF_E2BIG)) {
+ return wins[0].window;
+ }
+ }
+
+ return -1;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_show_onscreen
+ * set onscreen window to visible.
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+hs_show_onscreen(void)
+{
+ Ico_Uxf_ProcessWin window;
+ int ret;
+
+ ret = ico_uxf_process_window_get(ICO_HS_APPID_DEFAULT_ONS, &window, 1);
+
+ if ((ret > 0) || (ret == ICO_UXF_E2BIG)) {
+ ico_uxf_window_layer(window.window, HS_LAYER_ONSCREEN);
+ }
+
+ usleep(10000);
+
+ ico_uxf_main_loop_iterate();
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_hide_onscreen
+ * set onscreen window to invisible.
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+hs_hide_onscreen(void)
+{
+ Ico_Uxf_ProcessWin window;
+ int ret;
+
+ ret = ico_uxf_process_window_get(ICO_HS_APPID_DEFAULT_ONS, &window, 1);
+
+ if ((ret > 0) || (ret == ICO_UXF_E2BIG)) {
+ ico_uxf_window_layer(window.window, HS_LAYER_BACKGROUND);
+ ico_uxf_window_lower(window.window);
+ }
+
+ usleep(10000);
+
+ ico_uxf_main_loop_iterate();
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_click_escutcheon
+ * processing when escutcheon button is clicked.
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+hs_click_escutcheon(void)
+{
+ uifw_trace("hs_click_escutcheon: Enter");
+
+ if (strlen(hs_active_onscreen) > 0) {
+ uifw_trace("hs_click_escutcheon: do nothing(active=%s)", hs_active_onscreen);
+ return;
+ }
+
+ if (hs_stat_touch == ICO_HS_TOUCH_IN_SHOW) {
+ uifw_trace("hs_click_escutcheon: hs_show_appscreen");
+ hs_show_appscreen(NULL);
+ }
+ else if (hs_stat_touch == ICO_HS_TOUCH_IN_HIDE) {
+ uifw_trace("hs_click_escutcheon: hs_tile_show_screen");
+ hs_tile_show_screen();
+ }
+ uifw_trace("hs_click_escutcheon: Leave");
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_is_special_app
+ * return 1 if the application is special one(homescreen)
+ * /statusbar/onscreen).
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static int
+hs_is_special_app(const char *appid)
+{
+ uifw_trace("hs_is_special_app: Enter(%s)", appid);
+ if ((strncmp(appid, hs_name_homescreen, ICO_UXF_MAX_PROCESS_NAME) == 0)
+ || (strncmp(appid, gStatusbarName, ICO_UXF_MAX_PROCESS_NAME) == 0)
+ || (strncmp(appid, gOnscreenName, ICO_UXF_MAX_PROCESS_NAME) == 0)
+ || (strncmp(appid, ICO_HS_APPID_DEFAULT_TOUCH,
+ ICO_UXF_MAX_PROCESS_NAME) == 0)) {
+ uifw_trace("hs_is_special_app: Leave(TURE)");
+ return 1;
+ }
+ uifw_trace("hs_is_special_app: Leave(FALSE)");
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_terminate_all_app
+ * terminate all application that homescreen handled
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_terminate_all_app(void)
+{
+ Ico_Uxf_ProcessAttr procs[ICO_HS_APP_NUM_MAX];
+ int cnt;
+ int ii = 0;
+
+ cnt = ico_uxf_process_query_processes(procs, ICO_HS_APP_NUM_MAX);
+ if (cnt == ICO_UXF_E2BIG)
+ cnt = ICO_HS_APP_NUM_MAX;
+ uifw_trace("hs_terminate_all_app: ico_uxf_process_query_processes() = %d",
+ cnt);
+ for (ii = 0; ii < cnt; ii++) {
+ if (hs_is_special_app(procs[ii].process))
+ continue;
+ uifw_trace("hs_terminate_all_app: terminate(%s)", procs[ii].process);
+ ico_uxf_process_terminate(procs[ii].process);
+ }
+ ico_uxf_process_terminate(gStatusbarName);
+ ico_uxf_process_terminate(gOnscreenName);
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_req_ctlr_tile
+ * processing when homescreen received json command from extra
+ * tools.
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+hs_req_ctlr_tile(void)
+{
+ int ii, ret;
+ int idx;
+
+ for (ii = 0; ii < ICO_HS_APP_NUM_MAX; ii++) {
+ if ((hs_command_tile_req[ii].appid[0] == 0)
+ || (hs_is_special_app(hs_command_tile_req[ii].appid) == TRUE)) {
+ continue;
+ }
+
+ idx = hs_tile_get_index_app(hs_command_tile_req[ii].appid);
+
+ /* terminate app */
+ if (hs_command_tile_req[ii].terminate != IGNORE) {
+ ret = ico_uxf_process_terminate(hs_command_tile_req[ii].appid);
+ if (ret == ICO_UXF_EOK) {
+ if (idx >= 0) {
+ hs_tile_free_app(idx);
+ }
+ }
+ }
+
+ /* execute app */
+ if (strlen(hs_command_tile_req[ii].exe_name) > 0) {
+ ico_uxf_process_execute(hs_command_tile_req[ii].exe_name);
+ }
+ }
+ hs_tile_show_screen();
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_touch_up_api_list
+ * processing when application list button touch up.
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_touch_up_api_list(void *data, Evas *evas, Evas_Object *obj, void *event_info)
+{
+ int idx = *(int *)data;
+ char buf[ICO_HS_TEMP_BUF_SIZE];
+ char path[ICO_HS_TEMP_BUF_SIZE];
+ hs_tile_info_t *tinfo;
+
+ tinfo = &hs_tile_info[idx];
+
+ /* set the image */
+ hs_get_image_path(path, sizeof(path));
+ sprintf(buf, "%s"fname_api_all_off, path);
+ evas_object_image_file_set(obj, buf, NULL);
+ /* move and resize in the image */
+ evas_object_move(obj, tinfo->coord_x, tinfo->coord_y - ICO_HS_SIZE_SB_HEIGHT);
+ evas_object_resize(obj, tinfo->size_x, tinfo->size_y);
+ /* show the image */
+ evas_object_show(obj);
+
+ uifw_trace("hs_touch_up_api_list: idx=%d", idx);
+ strncpy(hs_active_onscreen, ICO_UXF_PROC_DEFAULT_HOMESCREEN,
+ sizeof(hs_active_onscreen));
+ hs_get_ons_edj_path(path, sizeof(path));
+ sprintf(buf, "OPEN %s%s %s", path, ICO_HS_ONS_APPLI_LIST_NAME,
+ ICO_UXF_PROC_DEFAULT_HOMESCREEN);
+ uifw_trace("send '%s' to onscreen", buf);
+ if (hs_lib_event_message(ICO_HS_PROTOCOL_TYPE_OS, buf) < 0) {
+ memset(hs_active_onscreen, 0, sizeof(hs_active_onscreen));
+ }
+ hs_snd_play(hs_snd_get_filename(ICO_HS_SND_TYPE_DEFAULT));
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_touch_down_api_list
+ * processing when application list button touch down.
+ *
+ * @param none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_touch_down_api_list(void *data, Evas *evas, Evas_Object *obj,
+ void *event_info)
+{
+ int idx = *(int *)data;
+ char buf[ICO_HS_TEMP_BUF_SIZE];
+ char path[ICO_HS_TEMP_BUF_SIZE];
+ hs_tile_info_t *tinfo;
+
+ tinfo = &hs_tile_info[idx];
+
+ /* set the image */
+ hs_get_image_path(path, sizeof(path));
+ sprintf(buf, "%s"fname_api_all_off, path);
+ evas_object_image_file_set(obj, buf, NULL);
+ /* move and resize in the image */
+ evas_object_move(obj, tinfo->coord_x, tinfo->coord_y - ICO_HS_SIZE_SB_HEIGHT);
+ evas_object_resize(obj, tinfo->size_x, tinfo->size_y);
+ /* show the image */
+ evas_object_show(obj);
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_ecore_timer_event
+ * handler called when applicaton tile is pushed long term
+ * to terminate application.
+ *
+ * @param[in] data user data
+ * @return result
+ * @retval ECORE_CALLBACK_CANCEL
+ * delete this handler
+ */
+/*--------------------------------------------------------------------------*/
+static Eina_Bool
+hs_ecore_timer_event(void *data)
+{
+ int idx = *(int *)data;
+ char buf[ICO_HS_TEMP_BUF_SIZE];
+ char tmp[ICO_HS_TEMP_BUF_SIZE];
+ hs_tile_info_t *tinfo;
+
+ tinfo = &hs_tile_info[idx];
+ if (tinfo->l_press == 1) {
+ /* flag reset */
+ tinfo->l_press = 0;
+ /* set terminate app id for onscrAppliKill */
+ if (strlen(tinfo->appid) != 0) {
+ strncpy(hs_kill_appid, tinfo->appid, sizeof(hs_kill_appid));
+ uifw_trace("hs_ecore_timer_event :hs_kill_appid = %s", hs_kill_appid);
+ strncpy(hs_active_onscreen, ICO_UXF_PROC_DEFAULT_HOMESCREEN,
+ sizeof(hs_active_onscreen));
+ sprintf(buf, "OPEN HomeScreen/src/appli_kill.edj %s",
+ ICO_UXF_PROC_DEFAULT_HOMESCREEN);
+ hs_get_ons_edj_path(tmp, sizeof(tmp));
+ sprintf(buf, "OPEN %s%s %s", tmp, ICO_HS_ONS_APPLI_KILL_NAME,
+ ICO_UXF_PROC_DEFAULT_HOMESCREEN);
+ uifw_trace("hs_ecore_timer_event: send %s to onscreen", buf);
+ hs_lib_event_message(ICO_HS_PROTOCOL_TYPE_OS, buf);
+ }
+ }
+ return ECORE_CALLBACK_CANCEL;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_touch_up_tile
+ * processing when application tile button touch up.
+ *
+ * @param[in] data user data
+ * @param[in] obj evas object of the button
+ * @param[in] event_info evas event infomation
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_touch_up_tile(void *data, Evas *evas, Evas_Object *obj, void *event_info)
+{
+ int idx = *(int *)data;
+ int ret;
+ char buf[64];
+ hs_tile_info_t *tinfo;
+
+ uifw_trace("hs_touch_up_tile: idx=%d", idx);
+ tinfo = &hs_tile_info[idx];
+ if (tinfo->l_press == 1) {
+ /* flag reset */
+ tinfo->l_press = 0;
+ /* send a message to extra tools */
+ if (strlen(tinfo->appid) != 0) {
+ sprintf(buf, "FOCUS %s", tinfo->appid);
+ uifw_trace("hs_touch_up_tile: send '%s' to extra tools", buf);
+ ret = hs_lib_event_message(ICO_HS_PROTOCOL_TYPE_CM, buf);
+ if (ret < 0) {
+ hs_show_appscreen(tinfo->appid);
+
+ hs_snd_play(hs_snd_get_filename(ICO_HS_SND_TYPE_DEFAULT));
+ }
+ }
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_touch_down_tile
+ * processing when application tile button touch down.
+ *
+ * @param[in] data user data
+ * @param[in] obj evas object of the button
+ * @param[in] event_info evas event infomation
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_touch_down_tile(void *data, Evas *evas, Evas_Object *obj, void *event_info)
+{
+ int idx = *(int *)data;
+ hs_tile_info_t *tinfo;
+
+ uifw_trace("hs_touch_down_tile: idx=%d", idx);
+
+ tinfo = &hs_tile_info[idx];
+ tinfo->l_press = 1;
+ if (strlen(tinfo->appid) != 0) {
+ }
+ /* add timer to detect long push */
+ ecore_timer_add(ICO_HS_TOUCH_TIME_OUT, hs_ecore_timer_event, &tinfo->idx);
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_add_bg_image
+ * add image to background. if config does not have image file or
+ * image file is not exsit, background show default edj.
+ *
+ * @param[in] canvas_bg evas of background
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_add_bg_image(Evas *canvas_bg)
+{
+ char img[ICO_HS_TEMP_BUF_SIZE];
+ char path[ICO_HS_TEMP_BUF_SIZE];
+ char *fname;
+ Evas_Object *canvas;
+ Evas_Load_Error err;
+ int dispW, dispH;
+
+ fname = (char *)hs_conf_get_string(ICO_HS_CONFIG_HOMESCREEN,
+ ICO_HS_CONFIG_BG, NULL);
+ if (!fname) {
+ uifw_trace("hs_add_bg_image: backgound config is not exist");
+ return;
+ }
+ if (fname[0] == '/') {
+ snprintf(img, sizeof(img), "%s", fname);
+ }
+ else {
+ hs_get_image_path(path, sizeof(path));
+ snprintf(img, sizeof(img), "%s/%s", path, fname);
+ }
+
+ ico_uxf_window_screen_size_get(&dispW, &dispH);
+
+ canvas = evas_object_image_filled_add(canvas_bg);
+ evas_object_image_file_set(canvas, img, NULL);
+ err = evas_object_image_load_error_get(canvas);
+ if (err != EVAS_LOAD_ERROR_NONE) {
+ uifw_trace("hs_add_bg_image: backgound image is not exist");
+ }
+ else {
+ evas_object_image_fill_set(canvas, 0, 0, dispW, dispH - ICO_HS_SIZE_SB_HEIGHT);
+ evas_object_resize(canvas, dispW, dispH - ICO_HS_SIZE_SB_HEIGHT);
+ evas_object_show(canvas);
+ }
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_add_touch_listener
+ * make and add listener to application tile button.
+ *
+ * @param[in] canvas_fg evas of tile screen
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_add_touch_listener(Evas *canvas_fg)
+{
+ int idx;
+ char img[ICO_HS_TEMP_BUF_SIZE];
+ char path[ICO_HS_TEMP_BUF_SIZE];
+ Evas_Object * canvas;
+ hs_tile_info_t *tinfo;
+
+ /* set image path */
+ hs_get_image_path(path, sizeof(path));
+ sprintf(img, "%s"fname_api_all_off, path);
+
+ /* setup tile */
+ for (idx = 0; idx < hs_tile_cnt - 1; idx++) {
+ tinfo = &hs_tile_info[idx];
+ if (tinfo->valid == 0)
+ continue;
+ /* Creates a reclangle */
+ canvas = evas_object_rectangle_add(canvas_fg);
+ /* Set a color or image */
+ evas_object_color_set(canvas, 0, 0, 0, 0);
+ /* Move and resize the rectangle */
+ evas_object_move(canvas, tinfo->coord_x, tinfo->coord_y - ICO_HS_SIZE_SB_HEIGHT);
+ evas_object_resize(canvas, tinfo->size_x, tinfo->size_y);
+ /* add event the rectangle */
+ evas_object_event_callback_add(canvas, EVAS_CALLBACK_MOUSE_UP,
+ hs_touch_up_tile, &tinfo->idx);
+ evas_object_event_callback_add(canvas, EVAS_CALLBACK_MOUSE_DOWN,
+ hs_touch_down_tile, &tinfo->idx);
+ /* show the rectangle */
+ evas_object_show(canvas);
+ }
+ /* application menu icon */
+ tinfo = &hs_tile_info[hs_tile_cnt - 1];
+ canvas = evas_object_image_filled_add(canvas_fg);
+ evas_object_image_file_set(canvas, img, NULL);
+ evas_object_move(canvas, tinfo->coord_x, tinfo->coord_y - ICO_HS_SIZE_SB_HEIGHT);
+ evas_object_resize(canvas, tinfo->size_x, tinfo->size_y);
+ evas_object_event_callback_add(canvas, EVAS_CALLBACK_MOUSE_UP,
+ hs_touch_up_api_list, &tinfo->idx);
+ evas_object_event_callback_add(canvas, EVAS_CALLBACK_MOUSE_DOWN,
+ hs_touch_down_api_list, &tinfo->idx);
+ evas_object_show(canvas);
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_create_window
+ * create background and tile screen window of ecore.
+ *
+ * @param[in] type background or tile screen
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void *
+hs_create_window(int type)
+{
+ Evas_Object *edje;
+ Ecore_Evas * window;
+ Evas * canvas;
+ int dispW, dispH;
+ int width, height;
+ char path[ICO_HS_TEMP_BUF_SIZE];
+ char edjfile[ICO_HS_TEMP_BUF_SIZE];
+
+ window = ecore_evas_new(NULL, 0, 0, 1, 1, "frame=0");
+
+ ecore_main_loop_iterate();
+ ico_uxf_window_screen_size_get(&dispW, &dispH);
+ width = dispW;
+ height = dispH - ICO_HS_SIZE_SB_HEIGHT;
+
+ if (!window) {
+ uifw_warn("HomeScreen: could not create window.");
+ return NULL;
+ }
+
+ canvas = ecore_evas_get(window);
+ edje = edje_object_add(canvas);
+ /* NULL is aborted */
+ if (!edje) {
+ uifw_warn("HomeScreen: could not create edje object!");
+ return NULL;
+ }
+
+ hs_get_edj_path(path, sizeof(path));
+
+ if (type == ICO_HS_WINDOW_TYPE_BG) {
+ ecore_evas_move(window, 0, 0);
+ ecore_evas_resize(window, width, height);
+ ecore_evas_show(window);
+ {
+ int err = edje_object_load_error_get(edje);
+ const char *errmsg = edje_load_error_str(err);
+ sprintf(edjfile, "%s/home_screen_bg.edj", path);
+ if (!edje_object_file_set(edje, edjfile, "home_screen_bg")) {
+ uifw_warn(
+ "HomeScreen: could not load 'home_screen_bg' from %s: %s",
+ edjfile, errmsg);
+ evas_object_del(edje);
+ return NULL;
+ }
+ }
+ evas_object_move(edje, 0, 0);
+ evas_object_resize(edje, width, height);
+ evas_object_show(edje);
+
+ hs_add_bg_image(canvas);
+ }
+ else {
+ ecore_evas_move(window, 0, 0);
+ ecore_evas_resize(window, width, height);
+ ecore_evas_alpha_set(window, EINA_TRUE);
+ ecore_evas_show(window);
+ {
+ int err = edje_object_load_error_get(edje);
+ const char *errmsg = edje_load_error_str(err);
+ sprintf(edjfile, "%s/home_screen_touch.edj", path);
+ if (!edje_object_file_set(edje, edjfile, "home_screen_touch")) {
+ uifw_warn(
+ "HomeScreen: could not load 'home_screen_touch' from %s: %s",
+ edjfile, errmsg);
+ evas_object_del(edje);
+ return NULL;
+ }
+ }
+ evas_object_move(edje, 0, 0);
+ evas_object_resize(edje, width, height);
+ evas_object_show(edje);
+
+ hs_add_touch_listener(canvas);
+ }
+
+ return edje;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_display_control
+ * callback function
+ *
+ * @param[in] conf configuration
+ * @param[in] show show
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_display_control(const Ico_Uxf_conf_application *conf, const int show)
+{
+ uifw_trace("hs_display_control: app=%s show=%d", conf->appid, show);
+ /* no need, because all control in AppsController */
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_sound_control
+ * callback function
+ *
+ * @param[in] conf configuration
+ * @param[in] adjust adjust
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_sound_control(const Ico_Uxf_conf_application *conf, const int adjust)
+{
+ uifw_trace("hs_sound_control: app=%s adjust=%d", conf->appid, adjust);
+ /* no need, because all control in AppsController */
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_input_control
+ * callback function
+ *
+ * @param[in] conf configuration
+ * @param[in] inputsw input switch
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hs_input_control(const Ico_Uxf_conf_application *conf, const int inputsw)
+{
+ uifw_trace("hs_input_control: app=%s inputsw=%d", conf->appid, inputsw);
+ /* no need, because all control in AppsController */
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief main
+ * homescreen main. initialize UXF, app manager, and ecore.
+ *
+ * @param[in] argc counts of argment
+ * @param[in] argv argment
+ * @return result
+ * @retval >=0 success
+ * @retval -1 error
+ */
+/*--------------------------------------------------------------------------*/
+int
+main(int argc, char *argv[])
+{
+ int ii = 0;
+ int ret;
+ int port;
+
+ /* get pkg name */
+ char *pkg;
+ printf("main: %s: %s", getenv("HOME"), getenv("PKG_NAME"));
+ pkg = getenv("PKG_NAME");
+ memset(hs_name_homescreen, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
+ if (pkg) {
+ strncpy(hs_name_homescreen, pkg, ICO_UXF_MAX_PROCESS_NAME);
+ }
+ else {
+ strncpy(hs_name_homescreen, ICO_UXF_PROC_DEFAULT_HOMESCREEN,
+ ICO_UXF_MAX_PROCESS_NAME);
+ }
+ strncpy(gStatusbarName,
+ (char *)hs_conf_get_string(ICO_HS_CONFIG_HOMESCREEN,
+ ICO_HS_CONFIG_SB,
+ ICO_HS_APPID_DEFAULT_SB),
+ ICO_UXF_MAX_PROCESS_NAME);
+ strncpy(gOnscreenName,
+ (char *)hs_conf_get_string(ICO_HS_CONFIG_HOMESCREEN,
+ ICO_HS_CONFIG_ONS,
+ ICO_HS_APPID_DEFAULT_ONS),
+ ICO_UXF_MAX_PROCESS_NAME);
+ hs_snd_init();
+
+ /* init for window mgr */
+ ret = ico_uxf_init(hs_name_homescreen);
+ if (ret != ICO_UXF_EOK) {
+ uifw_error("ico_uxf_init err=%d", ret);
+ exit(8);
+ }
+ ico_uxf_callback_set(ICO_UXF_EVENT_ALL, hs_uxf_event, 0);
+ memset(hs_app_screen_window, 0, sizeof(hs_app_screen_window));
+ for (ii = 0; ii < ICO_HS_APP_NUM_MAX; ii++) {
+ hs_app_screen_window[ii].resize_w = -1;
+ hs_app_screen_window[ii].resize_h = -1;
+ hs_app_screen_window[ii].move_x = -1;
+ hs_app_screen_window[ii].move_y = -1;
+ }
+ ico_uxf_main_loop_iterate();
+
+ /* init tile info */
+ ret = hs_tile_init_info();
+ if (ret < 0) {
+ uifw_warn("hs_tile_init_info err=%d", ret);
+ }
+
+ /* start onscreen & statusbar apps */
+ ret = ico_uxf_process_execute(gOnscreenName);
+ if (ret < 0) {
+ uifw_warn("ico_uxf_process_execute(%s) err=%d", gOnscreenName, ret);
+ }
+ ret = ico_uxf_process_execute(gStatusbarName);
+ if (ret < 0) {
+ uifw_warn("ico_uxf_process_execute(%s) err=%d", gStatusbarName, ret);
+ }
+ ico_uxf_main_loop_iterate();
+
+ /* init EFL */
+ ecore_evas_init();
+ edje_init();
+
+ /* for communicate other process */
+ port = hs_conf_get_integer(ICO_HS_CONFIG_HOMESCREEN,
+ ICO_HS_CONFIG_WS_PORT,
+ ICO_HS_WS_PORT);
+ hs_lib_main(port);
+
+ /* initialize Application Controller */
+ ret = ico_syc_apc_init(hs_display_control, hs_sound_control, hs_input_control);
+ if (ret != ICO_SYC_EOK) {
+ uifw_error("ico_syc_apc_init err=%d", ret);
+ exit(9);
+ }
+
+ /* start default tile apps */
+ hs_tile_start_apps();
+ ico_uxf_main_loop_iterate();
+
+ /* HomeScreen Menu(background) */
+ hs_create_window(ICO_HS_WINDOW_TYPE_BG);
+ /* add callbacks for wayland(wl_window_mgr) */
+ ecore_main_fd_handler_add(ico_uxf_wl_display_fd(), ECORE_FD_READ,
+ hs_ecore_uxf_eventfd, NULL, /* data */
+ NULL, NULL);
+ ecore_main_loop_iterate();
+ ico_uxf_main_loop_iterate();
+
+ /* HomeScreen Menu(touch) */
+ hs_create_window(ICO_HS_WINDOW_TYPE_TOUCH);
+
+ /* wait events */
+ ecore_main_loop_begin();
+
+ /* terminate Application Controller */
+ (void) ico_syc_apc_term();
+
+ /* terminate all known application */
+ hs_terminate_all_app();
+
+ /* shutdown EFL */
+ edje_shutdown();
+ ecore_evas_shutdown();
+
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief parser of jason receive from external homescreen tools
+ *
+ * @date Feb-15-2013
+ */
+
+#include "home_screen_parser.h"
+
+/*============================================================================*/
+/* static(internal) functions prototype */
+/*============================================================================*/
+static int hs_parse_value_string(JsonObject *, char *, char *);
+static int hs_parse_value_integer(JsonObject *, char *, int *);
+static int hs_hs_parse_value_integer2(JsonObject *, char *, int *, int *);
+static int hs_hs_parse_value_integer3(JsonObject *, char *, int *, int *, int *);
+static int hs_parse_program(JsonNode *, int);
+static int hs_parse_input(JsonNode *, int);
+static int hs_parse_window(JsonNode *, int, int);
+static int hs_parse_application(JsonNode *, int);
+
+/*============================================================================*/
+/* variables and tables */
+/*============================================================================*/
+int hs_req_touch = ICO_HS_TOUCH_TOBE_SHOW; /* request about TOUCH */
+int hs_stat_touch = ICO_HS_TOUCH_IN_SHOW; /* status of TOUCH */
+static hs_command_req_t hs_command_req[ICO_HS_APP_NUM_MAX];
+static int hs_command_delay;
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_parse_form
+ * parse json command main
+ *
+ * @param[in] data json data
+ * @param[in] length json data length
+ * @return result
+ * @retval 0 Success
+ * @retval 1 Failed
+ */
+/*--------------------------------------------------------------------------*/
+int
+hs_parse_form(char *data, int length)
+{
+ GError *error;
+
+ int st;
+ int ii, jj;
+ int n;
+ JsonParser *parser;
+ JsonNode *root;
+ JsonObject *object;
+ JsonArray *array;
+ JsonNode *node;
+
+ hs_command_delay = 0;
+ memset(hs_command_req, 0, sizeof(hs_command_req));
+
+ for (ii = 0; ii < ICO_HS_APP_NUM_MAX; ii++) {
+ hs_command_req[ii].program.execute.appid = NULL;
+ hs_command_req[ii].program.terminate.appid = NULL;
+ hs_command_req[ii].program.suspend.appid = NULL;
+ hs_command_req[ii].program.resume.appid = NULL;
+ for (jj = 0; jj < ICO_HS_WINDOW_NUM_MAX; jj++) {
+ hs_command_req[ii].window[jj].status = UNEXECUTED;
+ hs_command_req[ii].window[jj].show.window = IGNORE;
+ hs_command_req[ii].window[jj].hide.window = IGNORE;
+ hs_command_req[ii].window[jj].visible_raise.window = IGNORE;
+ hs_command_req[ii].window[jj].resize.window = IGNORE;
+ hs_command_req[ii].window[jj].resize_tile.window = IGNORE;
+ hs_command_req[ii].window[jj].move.window = IGNORE;
+ hs_command_req[ii].window[jj].move_tile.window = IGNORE;
+ hs_command_req[ii].window[jj].raise.window = IGNORE;
+ hs_command_req[ii].window[jj].lower.window = IGNORE;
+ hs_command_req[ii].window[jj].event_mask.window = IGNORE;
+ }
+ hs_command_req[ii].input.add_app.input = IGNORE;
+ hs_command_req[ii].input.del_app.input = IGNORE;
+ }
+
+ g_type_init();
+
+ parser = json_parser_new();
+
+ error = NULL;
+ json_parser_load_from_data(parser, data, length, &error);
+ if (error) {
+ uifw_error("json_parser_load_from_data = %s", error->message);
+ g_error_free(error);
+ g_object_unref(parser);
+ return 1;
+ }
+
+ root = json_parser_get_root(parser);
+ if (!root) {
+ uifw_error("json_parser_get_root");
+ g_object_unref(parser);
+ return 1;
+ }
+
+ if (JSON_NODE_TYPE(root) != JSON_NODE_OBJECT) {
+ uifw_error("type error = %d", JSON_NODE_TYPE(root));
+ return 1;
+ }
+
+ object = json_node_get_object(root);
+ if (!object) {
+ uifw_error("json_node_get_object");
+ g_object_unref(parser);
+ return 1;
+ }
+
+ n = json_object_get_size(object);
+ if (n < 1) {
+ uifw_error("json_object_get_size = %d", n);
+ g_object_unref(parser);
+ return 1;
+ }
+ else if (n > 1) {
+ st = hs_parse_value_integer(object, "delay", &hs_command_delay);
+ if (st != 0) {
+ uifw_error("hs_parse_value_integer = %d", st);
+ }
+ uifw_debug("delay = %d", hs_command_delay);
+ }
+
+ node = json_object_get_member(object, "application");
+ if (!node) {
+ uifw_error("json_object_get_member(%s)", "application");
+ g_object_unref(parser);
+ return 1;
+ }
+
+ if (JSON_NODE_TYPE(node) != JSON_NODE_ARRAY) {
+ uifw_error("type error = %d", JSON_NODE_TYPE(node));
+ g_object_unref(parser);
+ return 1;
+ }
+
+ array = json_node_get_array(node);
+ if (!array) {
+ uifw_error("json_node_get_array");
+ g_object_unref(parser);
+ return 1;
+ }
+
+ n = json_array_get_length(array);
+ if (n < 0) {
+ uifw_error("json_array_get_length = %d", n);
+ g_object_unref(parser);
+ return 1;
+ }
+
+ for (ii = 0; ii < n; ii++) {
+ node = json_array_get_element(array, ii);
+ if (!node) {
+ uifw_error("json_array_get_element");
+ g_object_unref(parser);
+ return 1;
+ }
+
+ if (JSON_NODE_TYPE(node) != JSON_NODE_OBJECT) {
+ uifw_error("type error = %d", JSON_NODE_TYPE(node));
+ g_object_unref(parser);
+ return 1;
+ }
+
+ st = hs_parse_application(node, ii);
+ if (st != 0) {
+ uifw_error("hs_parse_application = %d", st);
+ g_object_unref(parser);
+ return 1;
+ }
+ }
+
+ g_object_unref(parser);
+
+ /* get now status of TOUCH */
+ if (hs_stat_touch == ICO_HS_TOUCH_IN_HIDE) {
+ hs_req_touch = ICO_HS_TOUCH_TOBE_HIDE;
+ }
+ else if (hs_stat_touch == ICO_HS_TOUCH_IN_SHOW) {
+ hs_req_touch = ICO_HS_TOUCH_TOBE_SHOW;
+ }
+ /* check if TOUCH is raise or not */
+ for (ii = 0; ii < ICO_HS_APP_NUM_MAX; ii++) {
+ /* is TOUCH? */
+ uifw_debug("hs_parse_form: Appid = %s",
+ hs_command_req[ii].program.appid);
+ if (strlen(hs_command_req[ii].program.appid) == 0)
+ break;
+ if (strncmp(hs_command_req[ii].program.appid,
+ ICO_HS_APPID_DEFAULT_TOUCH, ICO_UXF_MAX_PROCESS_NAME) != 0) {
+ continue;
+ }
+
+ if ((hs_command_req[ii].window[0].hide.window != IGNORE)
+ || ((hs_command_req[ii].window[0].visible_raise.window
+ != IGNORE)
+ && (hs_command_req[ii].window[0].visible_raise.visible
+ == 0))) {
+ /* TOUCH is to be hide */
+ hs_req_touch = ICO_HS_TOUCH_TOBE_HIDE;
+ }
+ else if ((hs_command_req[ii].window[0].show.window != IGNORE)
+ || ((hs_command_req[ii].window[0].visible_raise.window
+ != IGNORE)
+ && (hs_command_req[ii].window[0].visible_raise.visible
+ == 1))) {
+ /* TOUCH is to be show */
+ hs_req_touch = ICO_HS_TOUCH_TOBE_SHOW;
+ }
+ }
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_control_app_screen
+ * this function is called when received json command, and change
+ * applicatoin window that json command indicate.
+ *
+ * @param none
+ * @return result
+ * @retval 0 Success
+ * @retval 1 Failed
+ */
+/*--------------------------------------------------------------------------*/
+int
+hs_control_app_screen(void)
+{
+ int ii, jj, ret, winNo, idx;
+ Ico_Uxf_ProcessWin wins[2];
+ Ico_Uxf_ProcessAttr proc;
+ char appid[ICO_UXF_MAX_PROCESS_NAME + 1];
+
+ for (ii = 0; ii < ICO_HS_APP_NUM_MAX; ii++) {
+ if (strlen(hs_command_req[ii].program.appid) == 0)
+ break;
+ memset(appid, 0, sizeof(appid));
+ strncpy(appid, hs_command_req[ii].program.appid,
+ ICO_UXF_MAX_PROCESS_NAME);
+ winNo = 0;
+ if (strncmp(hs_command_req[ii].program.appid,
+ ICO_HS_APPID_DEFAULT_TOUCH, ICO_UXF_MAX_PROCESS_NAME) == 0) {
+ memset(appid, 0, sizeof(appid));
+ strncpy(appid, hs_name_homescreen, ICO_UXF_MAX_PROCESS_NAME);
+ winNo = 1;
+ }
+ ret = ico_uxf_process_attribute_get(appid, &proc);
+ if (ret < 0)
+ continue;
+ if ((proc.status == ICO_UXF_PROCSTATUS_STOP) || (proc.status
+ == ICO_UXF_PROCSTATUS_TERM)) {
+ if (hs_command_req[ii].program.execute.appid != NULL) {
+ ret = ico_uxf_process_execute(
+ hs_command_req[ii].program.execute.appid);
+ if (ret >= 0) {
+ idx = hs_tile_get_minchange();
+ hs_tile_set_app(idx,
+ hs_command_req[ii].program.execute.appid);
+ }
+ uifw_debug("HOMESCREEN excute %s = %d",
+ hs_command_req[ii].program.execute.appid, 0);
+ if (hs_command_delay > 0)
+ usleep(hs_command_delay);
+ }
+ }
+
+ /* regist app screen info */
+ idx = hs_get_index_appscreendata(hs_command_req[ii].program.appid);
+ if (idx >= 0) {
+ if (hs_command_req[ii].program.execute.appid != NULL) {
+ strcpy(hs_app_screen_window[idx].exe_name,
+ hs_command_req[ii].program.execute.appid);
+ }
+ for (jj = 0; jj < ICO_HS_WINDOW_NUM_MAX; jj++) {
+ /* default invisible */
+ if (hs_command_req[ii].window[jj].visible_raise.window
+ != IGNORE) {
+ hs_app_screen_window[idx].visible
+ = hs_command_req[ii].window[jj].visible_raise.visible; /* visible */
+ hs_app_screen_window[idx].raise
+ = hs_command_req[ii].window[jj].visible_raise.raise; /* raise */
+ }
+ if (hs_command_req[ii].window[jj].show.window != IGNORE) {
+ hs_app_screen_window[idx].visible = 1;
+ }
+ if (hs_command_req[ii].window[jj].hide.window != IGNORE) {
+ hs_app_screen_window[idx].visible = 0;
+ }
+ if (hs_command_req[ii].window[jj].raise.window != IGNORE) {
+ hs_app_screen_window[idx].raise = 1;
+ }
+ if (hs_command_req[ii].window[jj].lower.window != IGNORE) {
+ hs_app_screen_window[idx].raise = 0;
+ }
+ if (hs_command_req[ii].window[jj].resize.window != IGNORE) {
+ hs_app_screen_window[idx].resize_w
+ = hs_command_req[ii].window[jj].resize.w; /* resize_x */
+ hs_app_screen_window[idx].resize_h
+ = hs_command_req[ii].window[jj].resize.h; /* resize_y */
+ }
+ if (hs_command_req[ii].window[jj].move.window != IGNORE) {
+ hs_app_screen_window[idx].move_x
+ = hs_command_req[ii].window[jj].move.x; /* move_x */
+ hs_app_screen_window[idx].move_y
+ = hs_command_req[ii].window[jj].move.y; /* move_y */
+ }
+ }
+ }
+
+ ret = ico_uxf_process_window_get(appid, wins, 2);
+ if (ret >= 0) {
+ hs_conftrol_form(hs_command_req[ii].program.appid,
+ wins[winNo].window);
+ }
+ }
+ if (hs_req_touch == ICO_HS_TOUCH_TOBE_SHOW) {
+ hs_stat_touch = ICO_HS_TOUCH_IN_SHOW;
+ }
+ else if (hs_req_touch == ICO_HS_TOUCH_TOBE_HIDE) {
+ hs_stat_touch = ICO_HS_TOUCH_IN_HIDE;
+ }
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_conftrol_form
+ * change the application window parameter.
+ *
+ * @param[in] process applicatoin id
+ * @return window window
+ * @retval 0 Success
+ * @retval 1 Failed
+ */
+/*--------------------------------------------------------------------------*/
+int
+hs_conftrol_form(const char *process, int window)
+{
+ int ii, jj, kk, idx;
+ int st = 0;
+
+ uifw_trace("in(%s,%d)", process, window);
+
+ Ico_Uxf_WindowAttr windows[ICO_HS_APP_NUM_MAX];
+ int num = ico_uxf_window_query_windows(ICO_UXF_DISPLAY_DEFAULT, windows,
+ ICO_HS_APP_NUM_MAX);
+ int count;
+ int target;
+
+ for (ii = 0; ii < ICO_HS_APP_NUM_MAX; ii++) {
+ if (strncmp(hs_command_req[ii].program.appid, process,
+ ICO_UXF_MAX_PROCESS_NAME) != 0)
+ continue;
+
+ if (hs_command_req[ii].program.terminate.appid != NULL) {
+ st = ico_uxf_process_terminate(hs_command_req[ii].program.terminate.appid);
+ idx = hs_tile_get_index_app(hs_command_req[ii].program.terminate.appid);
+ if (idx >= 0) {
+ hs_tile_free_app(idx);
+ }
+ uifw_debug("FORM terminate %s = %d",
+ hs_command_req[ii].program.terminate.appid, st);
+ if (hs_command_delay > 0)
+ usleep(hs_command_delay);
+ }
+
+ if (window == 0)
+ continue;
+
+ for (jj = 0; jj < ICO_HS_WINDOW_NUM_MAX; jj++) {
+ if (hs_command_req[ii].window[jj].status == EXECUTED)
+ continue;
+
+ if (hs_command_req[ii].window[jj].hide.window != IGNORE) {
+ target = -1;
+ if (hs_command_req[ii].window[jj].hide.window == 0) {
+ target = window;
+ }
+ else {
+ count = 0;
+ for (kk = 0; kk < num; kk++) {
+ if (process != windows[kk].process)
+ continue;
+ if (count == hs_command_req[ii].window[jj].hide.window) {
+ target = windows[kk].window;
+ break;
+ }
+ count++;
+ }
+ }
+ if (target >= 0) {
+ st = ico_uxf_window_hide(target);
+ }
+ uifw_debug("FORM hide %d = %d", target, st);
+ if (hs_command_delay > 0)
+ usleep(hs_command_delay);
+ }
+
+ if (hs_command_req[ii].window[jj].resize.window != IGNORE) {
+ target = -1;
+ if (hs_command_req[ii].window[jj].resize.window == 0) {
+ target = window;
+ }
+ else {
+ count = 0;
+ for (kk = 0; kk < num; kk++) {
+ if (process != windows[kk].process)
+ continue;
+ if (count == hs_command_req[ii].window[jj].resize.window) {
+ target = windows[kk].window;
+ break;
+ }
+ count++;
+ }
+ }
+ if (target >= 0) {
+ st = ico_uxf_window_resize(target,
+ hs_command_req[ii].window[jj].resize.w,
+ hs_command_req[ii].window[jj].resize.h);
+ }
+ uifw_debug("FORM resize %d %d %d = %d", target,
+ hs_command_req[ii].window[jj].resize.w,
+ hs_command_req[ii].window[jj].resize.h, st);
+ if (hs_command_delay > 0)
+ usleep(hs_command_delay);
+ }
+
+ if (hs_command_req[ii].window[jj].move.window != IGNORE) {
+ target = -1;
+ if (hs_command_req[ii].window[jj].move.window == 0) {
+ target = window;
+ }
+ else {
+ count = 0;
+ for (kk = 0; kk < num; kk++) {
+ if (process != windows[kk].process)
+ continue;
+ if (count == hs_command_req[ii].window[jj].move.window) {
+ target = windows[kk].window;
+ break;
+ }
+ count++;
+ }
+ }
+ if (target >= 0) {
+ st = ico_uxf_window_move(target,
+ hs_command_req[ii].window[jj].move.x,
+ hs_command_req[ii].window[jj].move.y);
+ }
+ uifw_debug("FORM move %d %d %d = %d", target,
+ hs_command_req[ii].window[jj].move.x,
+ hs_command_req[ii].window[jj].move.y, st);
+ if (hs_command_delay > 0)
+ usleep(hs_command_delay);
+ }
+
+ if (hs_command_req[ii].window[jj].visible_raise.window != IGNORE) {
+ target = -1;
+ if (hs_command_req[ii].window[jj].visible_raise.window == 0) {
+ target = window;
+ }
+ else {
+ count = 0;
+ for (kk = 0; kk < num; kk++) {
+ if (process != windows[kk].process)
+ continue;
+ if (count == hs_command_req[ii].window[jj].visible_raise.window) {
+ target = windows[kk].window;
+ break;
+ }
+ count++;
+ }
+ }
+ if (target >= 0) {
+ st = ico_uxf_window_visible_raise(target,
+ hs_command_req[ii].window[jj].visible_raise.visible,
+ hs_command_req[ii].window[jj].visible_raise.raise);
+ }
+ uifw_debug("FORM visible_raise %d %d %d = %d", target,
+ hs_command_req[ii].window[jj].visible_raise.visible,
+ hs_command_req[ii].window[jj].visible_raise.raise,
+ st);
+ if (hs_command_delay > 0)
+ usleep(hs_command_delay);
+ }
+
+ if (hs_command_req[ii].window[jj].raise.window != IGNORE) {
+ target = -1;
+ if (hs_command_req[ii].window[jj].raise.window == 0) {
+ target = window;
+ }
+ else {
+ count = 0;
+ for (kk = 0; kk < num; kk++) {
+ if (process != windows[kk].process)
+ continue;
+ if (count == hs_command_req[ii].window[jj].raise.window) {
+ target = windows[kk].window;
+ break;
+ }
+ count++;
+ }
+ }
+ if (target >= 0) {
+ st = ico_uxf_window_raise(target);
+ }
+ uifw_debug("FORM raise %d = %d", target, st);
+ if (hs_command_delay > 0)
+ usleep(hs_command_delay);
+ }
+
+ if (hs_command_req[ii].window[jj].lower.window != IGNORE) {
+ target = -1;
+ if (hs_command_req[ii].window[jj].lower.window == 0) {
+ target = window;
+ }
+ else {
+ count = 0;
+ for (kk = 0; kk < num; kk++) {
+ if (process != windows[kk].process)
+ continue;
+ if (count == hs_command_req[ii].window[jj].lower.window) {
+ target = windows[kk].window;
+ break;
+ }
+ count++;
+ }
+ }
+ if (target >= 0) {
+ st = ico_uxf_window_lower(target);
+ }
+ uifw_debug("FORM lower %d = %d", target, st);
+ if (hs_command_delay > 0)
+ usleep(hs_command_delay);
+ }
+
+ if (hs_command_req[ii].window[jj].event_mask.window != IGNORE) {
+ target = -1;
+ if (hs_command_req[ii].window[jj].event_mask.window == 0) {
+ target = window;
+ }
+ else {
+ count = 0;
+ for (kk = 0; kk < num; kk++) {
+ if (process != windows[kk].process)
+ continue;
+ if (count == hs_command_req[ii].window[jj].event_mask.window) {
+ target = windows[kk].window;
+ break;
+ }
+ count++;
+ }
+ }
+ if (target >= 0) {
+ st = ico_uxf_window_event_mask(target,
+ hs_command_req[ii].window[jj].event_mask.mask);
+ }
+ uifw_debug("FORM event_mask %d %08x = %d", target,
+ hs_command_req[ii].window[jj].event_mask.mask, st);
+ if (hs_command_delay > 0)
+ usleep(hs_command_delay);
+ }
+
+ /* last show */
+ if (hs_command_req[ii].window[jj].show.window != IGNORE) {
+ target = -1;
+ if (hs_command_req[ii].window[jj].show.window == 0) {
+ target = window;
+ }
+ else {
+ count = 0;
+ for (kk = 0; kk < num; kk++) {
+ if (process != windows[kk].process)
+ continue;
+ if (count == hs_command_req[ii].window[jj].show.window) {
+ target = windows[kk].window;
+ break;
+ }
+ count++;
+ }
+ }
+ if (target >= 0) {
+ st = ico_uxf_window_show(target);
+ }
+ uifw_debug("FORM show %d = %d", target, st);
+ if (hs_command_delay > 0)
+ usleep(hs_command_delay);
+ }
+
+ hs_command_req[ii].window[jj].status = EXECUTED;
+ }
+ }
+
+ uifw_debug("out(%d)", st);
+ return st;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_dump_app
+ * dump application window status.
+ *
+ * @param[in] none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+hs_dump_app(void)
+{
+ int ii, jj;
+ for (ii = 0; ii < ICO_HS_APP_NUM_MAX; ii++) {
+ if (hs_command_req[ii].program.appid[0] == 0)
+ continue;
+ uifw_debug("id: %s", hs_command_req[ii].program.appid);
+ if (hs_command_req[ii].program.execute.appid != NULL) {
+ uifw_debug(" execute: %s", hs_command_req[ii].program.execute.appid);
+ }
+ if (hs_command_req[ii].program.terminate.appid != NULL) {
+ uifw_debug(" terminate: %s",
+ hs_command_req[ii].program.terminate.appid);
+ }
+ if (hs_command_req[ii].program.suspend.appid != NULL) {
+ uifw_debug(" suspend: %s", hs_command_req[ii].program.suspend.appid);
+ }
+ if (hs_command_req[ii].program.resume.appid != NULL) {
+ uifw_debug(" resume: %d", hs_command_req[ii].program.resume.appid);
+ }
+ for (jj = 0; jj < ICO_HS_WINDOW_NUM_MAX; jj++) {
+ if (hs_command_req[ii].window[jj].show.window != IGNORE) {
+ uifw_debug(" show: %d",
+ hs_command_req[ii].window[jj].show.window);
+ }
+ if (hs_command_req[ii].window[jj].hide.window != IGNORE) {
+ uifw_debug(" hide: %d",
+ hs_command_req[ii].window[jj].hide.window);
+ }
+ if (hs_command_req[ii].window[jj].visible_raise.window != IGNORE) {
+ uifw_debug(" visible_raise: %d %d %d",
+ hs_command_req[ii].window[jj].visible_raise.window,
+ hs_command_req[ii].window[jj].visible_raise.visible,
+ hs_command_req[ii].window[jj].visible_raise.raise);
+ }
+ if (hs_command_req[ii].window[jj].resize.window != IGNORE) {
+ uifw_debug(" resize: %d %d %d",
+ hs_command_req[ii].window[jj].resize.window,
+ hs_command_req[ii].window[jj].resize.w,
+ hs_command_req[ii].window[jj].resize.h);
+ }
+ if (hs_command_req[ii].window[jj].resize_tile.window != IGNORE) {
+ uifw_debug(" resize_tile: %d %d %d",
+ hs_command_req[ii].window[jj].resize_tile.window,
+ hs_command_req[ii].window[jj].resize_tile.size_m,
+ hs_command_req[ii].window[jj].resize_tile.size_n);
+ }
+ if (hs_command_req[ii].window[jj].move.window != IGNORE) {
+ uifw_debug(" move: %d %d %d",
+ hs_command_req[ii].window[jj].move.window,
+ hs_command_req[ii].window[jj].move.x,
+ hs_command_req[ii].window[jj].move.y);
+ }
+ if (hs_command_req[ii].window[jj].move_tile.window != IGNORE) {
+ uifw_debug(" move_tile: %d %d %d",
+ hs_command_req[ii].window[jj].move_tile.window,
+ hs_command_req[ii].window[jj].move_tile.m,
+ hs_command_req[ii].window[jj].move_tile.n);
+ }
+ if (hs_command_req[ii].window[jj].raise.window != IGNORE) {
+ uifw_debug(" raise: %d",
+ hs_command_req[ii].window[jj].raise.window);
+ }
+ if (hs_command_req[ii].window[jj].lower.window != IGNORE) {
+ uifw_debug(" lower: %d",
+ hs_command_req[ii].window[jj].lower.window);
+ }
+ if (hs_command_req[ii].window[jj].event_mask.window != IGNORE) {
+ uifw_debug(" event_mask: %d %08x",
+ hs_command_req[ii].window[jj].event_mask.window,
+ hs_command_req[ii].window[jj].event_mask.mask);
+ }
+ }
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_get_tilescreendata
+ * check json command for tile screen
+ *
+ * @param none
+ * @return result
+ * @retval 0 Success
+ * @retval 1 Failed
+ */
+/*--------------------------------------------------------------------------*/
+void
+hs_get_tilescreendata(void)
+{
+ int ii, jj, idx = -1;
+ memset(hs_command_tile_req, 0x00, sizeof(hs_command_tile_req)); /* init */
+ for (ii = 0; ii < ICO_HS_APP_NUM_MAX; ii++) {
+ if (strlen(hs_command_req[ii].program.appid) == 0)
+ continue;
+ strncpy(hs_command_tile_req[ii].appid,
+ hs_command_req[ii].program.appid, ICO_UXF_MAX_PROCESS_NAME);
+ if (hs_command_req[ii].program.execute.appid != NULL) {
+ strncpy(hs_command_tile_req[ii].exe_name,
+ hs_command_req[ii].program.execute.appid,
+ ICO_UXF_MAX_PROCESS_NAME); /* execute name */
+ }
+ hs_command_tile_req[ii].terminate = IGNORE;
+ if (hs_command_req[ii].program.terminate.appid != NULL) {
+ hs_command_tile_req[ii].terminate = EXECUTE; /* terminate id */
+ }
+ for (jj = 0; jj < ICO_HS_WINDOW_NUM_MAX; jj++) {
+ if (hs_command_req[ii].window[jj].visible_raise.window != IGNORE) {
+ hs_command_tile_req[ii].visible
+ = hs_command_req[ii].window[jj].visible_raise.visible; /* visible */
+ hs_command_tile_req[ii].raise
+ = hs_command_req[ii].window[jj].visible_raise.raise; /* raise */
+ }
+ if (hs_command_req[ii].window[jj].resize.window != IGNORE) {
+ hs_command_tile_req[ii].resize_w
+ = hs_command_req[ii].window[jj].resize.w; /* resize_x */
+ hs_command_tile_req[ii].resize_h
+ = hs_command_req[ii].window[jj].resize.h; /* resize_y */
+ }
+ if (hs_command_req[ii].window[jj].move.window != IGNORE) {
+ hs_command_tile_req[ii].move_x
+ = hs_command_req[ii].window[jj].move.x; /* move_x */
+ hs_command_tile_req[ii].move_y
+ = hs_command_req[ii].window[jj].move.y; /* move_y */
+ }
+ }
+
+ /* set app to tile */
+ idx = hs_tile_get_index_app(hs_command_tile_req[ii].appid);
+ if (idx >= 0) {
+ hs_tile_free_app(idx);
+ }
+ if (hs_command_tile_req[ii].terminate == IGNORE) {
+ idx = hs_tile_get_index_pos(hs_command_tile_req[ii].move_x,
+ hs_command_tile_req[ii].move_y,
+ hs_command_tile_req[ii].resize_w,
+ hs_command_tile_req[ii].resize_h);
+ uifw_debug("hs_get_tilescreendata: hs_tile_get_index_pos=%d(%d, %d, %d, %d)",
+ idx, hs_command_tile_req[ii].move_x,
+ hs_command_tile_req[ii].move_y,
+ hs_command_tile_req[ii].resize_w,
+ hs_command_tile_req[ii].resize_h);
+ if (idx >= 0) {
+ hs_tile_set_app(idx, hs_command_tile_req[ii].appid);
+ }
+ }
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_parse_value_string
+ * read the string value that indicated by the key name
+ *
+ * @param[in] object json data
+ * @param[in] name key name
+ * @param[out] value the value stored
+ * @return result
+ * @retval 0 Success
+ * @retval 1 Failed
+ */
+/*--------------------------------------------------------------------------*/
+static int
+hs_parse_value_string(JsonObject *object, char *name, char *value)
+{
+ JsonNode *node;
+
+ node = json_object_get_member(object, name);
+ if (!node) {
+ return 1;
+ }
+
+ if (JSON_NODE_TYPE(node) != JSON_NODE_VALUE) {
+ uifw_error("type error = %d", JSON_NODE_TYPE(node));
+ return 1;
+ }
+
+ GValue data = G_VALUE_INIT;
+ json_node_get_value(node, &data);
+
+ strcpy(value, g_value_get_string(&data));
+
+ uifw_trace("out");
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_parse_value_integer
+ * read the interger value that indicated by the key name
+ *
+ * @param[in] object json data
+ * @param[in] name key name
+ * @param[out] value the value stored
+ * @return result
+ * @retval 0 Success
+ * @retval 1 Failed
+ */
+/*--------------------------------------------------------------------------*/
+static int
+hs_parse_value_integer(JsonObject *object, char *name, int *value)
+{
+ JsonNode *node;
+ node = json_object_get_member(object, name);
+ if (!node) {
+ return 1;
+ }
+
+ if (JSON_NODE_TYPE(node) != JSON_NODE_VALUE) {
+ uifw_error("type error = %d", JSON_NODE_TYPE(node));
+ return 1;
+ }
+
+ GValue data = G_VALUE_INIT;
+ json_node_get_value(node, &data);
+
+ char temp[ICO_HS_TEMP_BUF_SIZE];
+
+ strcpy(temp, g_value_get_string(&data));
+
+ char *p;
+ p = strtok(temp, ",");
+ if (!p) {
+ uifw_error("strtok error = %s", temp);
+ return 1;
+ }
+
+ if (strncmp(p, "0x", 2) == 0) {
+ *value = strtol(p, NULL, 16);
+ }
+ else {
+ *value = strtol(p, NULL, 10);
+ }
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_hs_parse_value_integer2
+ * read the two interger value that indicated by the key name
+ *
+ * @param[in] object json data
+ * @param[in] name key name
+ * @param[out] value1 the 1st value stored
+ * @param[out] value2 the 2nd value stored
+ * @return result
+ * @retval 0 Success
+ * @retval 1 Failed
+ */
+/*--------------------------------------------------------------------------*/
+static int
+hs_hs_parse_value_integer2(JsonObject *object, char *name, int *value1,
+ int *value2)
+{
+ JsonNode *node;
+ node = json_object_get_member(object, name);
+ if (!node) {
+ return 1;
+ }
+
+ if (JSON_NODE_TYPE(node) != JSON_NODE_VALUE) {
+ uifw_error("type error = %d", JSON_NODE_TYPE(node));
+ return 1;
+ }
+
+ GValue data = G_VALUE_INIT;
+ json_node_get_value(node, &data);
+
+ char temp[ICO_HS_TEMP_BUF_SIZE];
+
+ strcpy(temp, g_value_get_string(&data));
+
+ char *p;
+ p = strtok(temp, ",");
+ if (!p) {
+ uifw_error("strtok error = %s", temp);
+ return 1;
+ }
+
+ if (strncmp(p, "0x", 2) == 0) {
+ *value1 = strtol(p, NULL, 16);
+ }
+ else {
+ *value1 = strtol(p, NULL, 10);
+ }
+
+ p = strtok(NULL, ",");
+ if (!p) {
+ uifw_error("strtok error = %s", temp);
+ return 1;
+ }
+
+ if (strncmp(p, "0x", 2) == 0) {
+ *value2 = strtol(p, NULL, 16);
+ }
+ else {
+ *value2 = strtol(p, NULL, 10);
+ }
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_hs_parse_value_integer3
+ * read the three interger value that indicated by the key name
+ *
+ * @param[in] object json data
+ * @param[in] name key name
+ * @param[out] value1 the 1st value stored
+ * @param[out] value2 the 2nd value stored
+ * @param[out] value3 the 3rd value stored
+ * @return result
+ * @retval 0 Success
+ * @retval 1 Failed
+ */
+/*--------------------------------------------------------------------------*/
+static int
+hs_hs_parse_value_integer3(JsonObject *object, char *name, int *value1,
+ int *value2, int *value3)
+{
+ JsonNode *node;
+ node = json_object_get_member(object, name);
+ if (!node) {
+ return 1;
+ }
+
+ if (JSON_NODE_TYPE(node) != JSON_NODE_VALUE) {
+ uifw_error("type error = %d", JSON_NODE_TYPE(node));
+ return 1;
+ }
+
+ GValue data = G_VALUE_INIT;
+ json_node_get_value(node, &data);
+
+ char temp[ICO_HS_TEMP_BUF_SIZE];
+
+ strcpy(temp, g_value_get_string(&data));
+
+ char *p;
+ p = strtok(temp, ",");
+ if (!p) {
+ uifw_error("strtok error = %s", temp);
+ return 1;
+ }
+
+ if (strncmp(p, "0x", 2) == 0) {
+ *value1 = strtol(p, NULL, 16);
+ }
+ else {
+ *value1 = strtol(p, NULL, 10);
+ }
+
+ p = strtok(NULL, ",");
+ if (!p) {
+ uifw_error("strtok error = %s", temp);
+ return 1;
+ }
+
+ if (strncmp(p, "0x", 2) == 0) {
+ *value2 = strtol(p, NULL, 16);
+ }
+ else {
+ *value2 = strtol(p, NULL, 10);
+ }
+
+ p = strtok(NULL, ",");
+ if (!p) {
+ uifw_error("strtok error = %s", temp);
+ return 1;
+ }
+
+ if (strncmp(p, "0x", 2) == 0) {
+ *value3 = strtol(p, NULL, 16);
+ }
+ else {
+ *value3 = strtol(p, NULL, 10);
+ }
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_parse_program
+ * parse "program" section
+ *
+ * @param[in] node json node
+ * @param[in] id sequence number of the node
+ * @return result
+ * @retval 0 Success
+ * @retval 1 Failed
+ */
+/*--------------------------------------------------------------------------*/
+static int
+hs_parse_program(JsonNode *node, int id)
+{
+ int st;
+ JsonObject *object;
+ char tmp[ICO_UXF_MAX_PROCESS_NAME + 1];
+
+ object = json_node_get_object(node);
+ if (!object) {
+ uifw_error("json_node_get_object");
+ return 1;
+ }
+
+ st = hs_parse_value_string(object, "id", hs_command_req[id].program.appid);
+ if (st != 0) {
+ uifw_error("hs_parse_value_string = %d", st);
+ memset(hs_command_req[id].program.appid, 0, ICO_UXF_MAX_PROCESS_NAME
+ + 1);
+ return 1;
+ }
+
+ st = hs_parse_value_string(object, "execute", tmp);
+ if (st != 0) {
+ uifw_error("hs_parse_value_string = %d", st);
+ }
+ else {
+ hs_command_req[id].program.execute.appid
+ = hs_command_req[id].program.appid;
+ }
+
+ st = hs_parse_value_string(object, "terminate", tmp);
+ if (st != 0) {
+ uifw_error("hs_parse_value_string = %d", st);
+ }
+ else {
+ hs_command_req[id].program.terminate.appid
+ = hs_command_req[id].program.appid;
+ }
+
+ st = hs_parse_value_string(object, "suspend", tmp);
+ if (st != 0) {
+ uifw_error("hs_parse_value_string = %d", st);
+ }
+ else {
+ hs_command_req[id].program.suspend.appid
+ = hs_command_req[id].program.appid;
+ }
+
+ st = hs_parse_value_string(object, "resume", tmp);
+ if (st != 0) {
+ uifw_error("hs_parse_value_string = %d", st);
+ }
+ else {
+ hs_command_req[id].program.resume.appid
+ = hs_command_req[id].program.appid;
+ }
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_parse_input
+ * parse "input" section
+ *
+ * @param[in] node json node
+ * @param[in] id sequence number of the node
+ * @return result
+ * @retval 0 Success
+ * @retval 1 Failed
+ */
+/*--------------------------------------------------------------------------*/
+static int
+hs_parse_input(JsonNode *node, int id)
+{
+ int st;
+ JsonObject *object;
+ int tmp;
+
+ object = json_node_get_object(node);
+ if (!object) {
+ uifw_error("json_node_get_object");
+ return 1;
+ }
+
+ st = hs_parse_value_integer(object, "add_app", &tmp);
+ if (st != 0) {
+ hs_command_req[id].input.add_app.input = IGNORE;
+ }
+ else {
+ hs_command_req[id].input.add_app.input = tmp;
+ }
+
+ st = hs_parse_value_integer(object, "del_app", &tmp);
+ if (st != 0) {
+ hs_command_req[id].input.del_app.input = IGNORE;
+ }
+ else {
+ hs_command_req[id].input.del_app.input = tmp;
+ }
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_parse_window
+ * parse "window" section
+ *
+ * @param[in] node json node
+ * @param[in] id1 sequence number of the node
+ * @param[in] id2 sequence number of the window in the node
+ * @return result
+ * @retval 0 Success
+ * @retval 1 Failed
+ */
+/*--------------------------------------------------------------------------*/
+static int
+hs_parse_window(JsonNode *node, int id1, int id2)
+{
+ int st;
+ JsonObject *object;
+
+ object = json_node_get_object(node);
+ if (!object) {
+ uifw_error("json_node_get_object");
+ return 1;
+ }
+
+ st = hs_parse_value_integer(object, "show",
+ &hs_command_req[id1].window[id2].show.window);
+ if (st != 0) {
+ hs_command_req[id1].window[id2].show.window = IGNORE;
+ }
+
+ st = hs_parse_value_integer(object, "hide",
+ &hs_command_req[id1].window[id2].hide.window);
+ if (st != 0) {
+ hs_command_req[id1].window[id2].hide.window = IGNORE;
+ }
+
+ st = hs_hs_parse_value_integer3(object,
+ "visible_raise",
+ &hs_command_req[id1].window[id2].visible_raise.window,
+ &hs_command_req[id1].window[id2].visible_raise.visible,
+ &hs_command_req[id1].window[id2].visible_raise.raise);
+ if (st != 0) {
+ hs_command_req[id1].window[id2].visible_raise.window = IGNORE;
+ }
+
+ st = hs_hs_parse_value_integer3(object,
+ "resize",
+ &hs_command_req[id1].window[id2].resize.window,
+ &hs_command_req[id1].window[id2].resize.w,
+ &hs_command_req[id1].window[id2].resize.h);
+ if (st != 0) {
+ hs_command_req[id1].window[id2].resize.window = IGNORE;
+ }
+
+ st = hs_hs_parse_value_integer3(object,
+ "resize_tile",
+ &hs_command_req[id1].window[id2].resize_tile.window,
+ &hs_command_req[id1].window[id2].resize_tile.size_m,
+ &hs_command_req[id1].window[id2].resize_tile.size_n);
+ if (st != 0) {
+ hs_command_req[id1].window[id2].resize_tile.window = IGNORE;
+ }
+
+ st = hs_hs_parse_value_integer3(object,
+ "move",
+ &hs_command_req[id1].window[id2].move.window,
+ &hs_command_req[id1].window[id2].move.x,
+ &hs_command_req[id1].window[id2].move.y);
+ if (st != 0) {
+ hs_command_req[id1].window[id2].move.window = IGNORE;
+ }
+
+ st = hs_hs_parse_value_integer3(object,
+ "move_tile",
+ &hs_command_req[id1].window[id2].move_tile.window,
+ &hs_command_req[id1].window[id2].move_tile.m,
+ &hs_command_req[id1].window[id2].move_tile.n);
+ if (st != 0) {
+ hs_command_req[id1].window[id2].move_tile.window = IGNORE;
+ }
+
+ st = hs_parse_value_integer(object, "raise",
+ &hs_command_req[id1].window[id2].raise.window);
+ if (st != 0) {
+ hs_command_req[id1].window[id2].raise.window = IGNORE;
+ }
+
+ st = hs_parse_value_integer(object, "lower",
+ &hs_command_req[id1].window[id2].lower.window);
+ if (st != 0) {
+ hs_command_req[id1].window[id2].lower.window = IGNORE;
+ }
+
+ st = hs_hs_parse_value_integer2(object,
+ "event_mask",
+ &hs_command_req[id1].window[id2].event_mask.window,
+ (int *)&hs_command_req[id1].window[id2].event_mask.mask);
+ if (st != 0) {
+ hs_command_req[id1].window[id2].event_mask.window = IGNORE;
+ }
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_parse_application
+ * parse "application" section
+ *
+ * @param[in] node json node
+ * @param[in] id sequence number of the node
+ * @return result
+ * @retval 0 Success
+ * @retval 1 Failed
+ */
+/*--------------------------------------------------------------------------*/
+static int
+hs_parse_application(JsonNode *node, int id)
+{
+ int st;
+ int ii;
+ int n;
+ JsonObject *object;
+ JsonNode *program_node;
+ JsonNode *window_node;
+ JsonArray *window_array;
+ JsonNode *input_node;
+
+ object = json_node_get_object(node);
+ if (!object) {
+ uifw_error("json_node_get_object");
+ return 1;
+ }
+
+ program_node = json_object_get_member(object, "program");
+ if (!node) {
+ uifw_error("json_object_get_member(%s)", "program");
+ return 1;
+ }
+
+ if (JSON_NODE_TYPE(program_node) != JSON_NODE_OBJECT) {
+ uifw_error("type error = %d", JSON_NODE_TYPE(program_node));
+ return 1;
+ }
+
+ st = hs_parse_program(program_node, id);
+ if (st != 0) {
+ uifw_error("hs_parse_program = %d", st);
+ return 1;
+ }
+
+ window_node = json_object_get_member(object, "window");
+ if (!node) {
+ uifw_error("json_object_get_member(%s)", "window");
+ return 1;
+ }
+
+ if (JSON_NODE_TYPE(window_node) != JSON_NODE_ARRAY) {
+ uifw_error("type error = %d", JSON_NODE_TYPE(window_node));
+ return 1;
+ }
+
+ window_array = json_node_get_array(window_node);
+ if (!window_array) {
+ uifw_error("json_node_get_array");
+ return 1;
+ }
+
+ n = json_array_get_length(window_array);
+ if (n < 0) {
+ uifw_error("json_array_get_length = %d", n);
+ return 1;
+ }
+
+ for (ii = 0; ii < n; ii++) {
+ window_node = json_array_get_element(window_array, ii);
+ if (!window_node) {
+ uifw_error("json_array_get_element");
+ return 1;
+ }
+
+ if (JSON_NODE_TYPE(window_node) != JSON_NODE_OBJECT) {
+ uifw_warn("type error = %d", JSON_NODE_TYPE(window_node));
+ return 1;
+ }
+
+ st = hs_parse_window(window_node, id, ii);
+ if (st != 0) {
+ uifw_warn("hs_parse_window = %d", st);
+ return 1;
+ }
+ }
+
+ input_node = json_object_get_member(object, "input");
+ if (!input_node) {
+ uifw_error("json_object_get_member(%s)", "input");
+ return 0;
+ }
+
+ if (JSON_NODE_TYPE(input_node) != JSON_NODE_OBJECT) {
+ uifw_debug("type not exist = %d", JSON_NODE_TYPE(input_node));
+ return 0;
+ }
+
+ st = hs_parse_input(input_node, id);
+ if (st != 0) {
+ uifw_error("hs_parse_input = %d", st);
+ return 0;
+ }
+
+ return 0;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief sound an operation of homescreen
+ *
+ * @date Apr-04-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdbool.h>
+
+#include "ico_uxf.h"
+#include "ico_uxf_conf_def.h"
+#include "home_screen.h"
+#include "home_screen_res.h"
+#include "home_screen_conf.h"
+
+/*============================================================================*/
+/* definition */
+/*============================================================================*/
+typedef struct _hs_snd_conf hs_snd_conf_t;
+struct _hs_snd_conf {
+ hs_snd_conf_t *next;
+ int type; /* operation type */
+ char *file; /* sound file name */
+};
+
+/*============================================================================*/
+/* static(internal) functions prototype */
+/*============================================================================*/
+static hs_snd_conf_t *hs_snd_read_configuration(int type, char *conf_name);
+
+/*============================================================================*/
+/* variabe */
+/*============================================================================*/
+static int hs_snd_is_initialize = false;
+static hs_snd_conf_t *hs_sound_files = NULL;
+
+/*============================================================================*/
+/* functions */
+/*============================================================================*/
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_snd_play
+ * play the given sound file(.wav).
+ *
+ * @param[in] wav_file wav formated file.
+ * @return result
+ * @retval ICO_HS_OK success
+ * @retval ICO_HS_ERR err
+ */
+/*--------------------------------------------------------------------------*/
+int
+hs_snd_play(char *wav_file)
+{
+ int pid;
+ int ret;
+ char command[ICO_HS_TEMP_BUF_SIZE];
+ char path[ICO_HS_TEMP_BUF_SIZE];
+
+ if (hs_snd_is_initialize != true) {
+ ret = hs_snd_init();
+ if (ret != ICO_HS_OK) {
+ return ICO_HS_ERR;
+ }
+ }
+
+ if (!wav_file) {
+ uifw_warn("hs_snd_play: Leave(error file name is NULL");
+ return ICO_HS_ERR;
+ }
+
+ if (wav_file[0] == '/') {
+ /* given by full file path */
+ snprintf(command, sizeof(command),
+ "paplay --stream-name=HOMESCREEN_BEEP %s", wav_file);
+ }
+ else {
+ hs_get_sound_path(path, sizeof(path));
+ snprintf(command, sizeof(command),
+ "paplay --stream-name=HOMESCREEN_BEEP %s/%s", path, wav_file);
+ }
+
+ uifw_trace("hs_snd_play: system(%s)", command);
+ pid = fork();
+ if (!pid) {
+ system(command);
+ exit(0);
+ }
+
+ return ICO_HS_OK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_snd_init
+ * initialize to sound a operation
+ *
+ * @param none
+ * @return result
+ * @retval ICO_HS_OK success
+ * @retval ICO_HS_ERR err
+ */
+/*--------------------------------------------------------------------------*/
+int
+hs_snd_init(void)
+{
+ if (hs_snd_is_initialize != true) {
+ /* read sound file name from configuration */
+ hs_snd_read_configuration(ICO_HS_SND_TYPE_DEFAULT,
+ ICO_HS_SND_CNAME_DEFAULT);
+ hs_snd_is_initialize = true;
+ }
+
+ return ICO_HS_OK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_snd_get_filename
+ * get the file name by given operation type
+ *
+ * @param[in] type operation type
+ * @return pointer to the file name
+ * @retval >=0 success
+ * @retval NULL err
+ */
+/*--------------------------------------------------------------------------*/
+char *
+hs_snd_get_filename(int type)
+{
+ hs_snd_conf_t *conf;
+
+ if (hs_snd_is_initialize != true) {
+ hs_snd_init();
+ }
+
+ conf = hs_sound_files;
+ while (conf) {
+ if (conf->type == type) {
+ return conf->file;
+ }
+ conf = conf->next;
+ }
+
+ return NULL;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_snd_read_configuration
+ * read configuration and set
+ *
+ * @param[in] type operation type
+ * @param[in] conf_name configuration name
+ * @return result
+ * @retval >=0 success
+ * @retval NULL err
+ */
+/*--------------------------------------------------------------------------*/
+static hs_snd_conf_t *
+hs_snd_read_configuration(int type, char *conf_name)
+{
+ char *file;
+ hs_snd_conf_t *conf;
+
+ conf = calloc(sizeof(hs_snd_conf_t), 1);
+ if (!conf) {
+ uifw_warn("hs_snd_read_configuration: Leave(fail to alloc memory");
+ return NULL;
+ }
+
+ if (strcmp(conf_name, ICO_HS_SND_CNAME_DEFAULT) == 0) {
+ file = (char *)hs_conf_get_string(ICO_HS_CONFIG_SOUND,
+ conf_name,
+ ICO_HS_SND_FNAME_DEFAULT);
+ }
+ else {
+ file = (char *)hs_conf_get_string(ICO_HS_CONFIG_HOMESCREEN,
+ conf_name,
+ NULL);
+ }
+
+ if (!file) {
+ uifw_trace("hs_snd_read_configuration: Leave(given config is not exist");
+ free(conf);
+ return NULL;
+ }
+
+ conf->file = file;
+ conf->type = type;
+
+ conf->next = hs_sound_files;
+ hs_sound_files = conf;
+
+ return conf;
+}
--- /dev/null
+collections {
+ group {
+ name: "home_screen_touch"; // must be the same as in home_screen_main.c
+ parts {
+ part {
+ name: "transparent";
+ type: RECT; // plain boring rectangle
+ description {
+ state: "default" 0.0; // must always exist
+ color: 0 0 0 0; // black
+ rel1 { // top-left point at (0, 0) [WIDTH * 0 + 0, HEIGHT * 0 + 0]
+ relative: 0.0 0.0;
+ offset: 0 0;
+ }
+ rel2 { // bottom-right point at (WIDTH * 1.0 - 1, HEIGHT * 1.0 - 1)
+ relative: 1.0 1.0;
+ offset: -1 -1;
+ }
+ }
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief onscreen application
+ *
+ * @date Feb-15-2013
+ */
+
+#include <unistd.h>
+#include <Eina.h>
+#include <Evas.h>
+#include <Ecore.h>
+#include <Ecore_Wayland.h>
+#include <Ecore_Evas.h>
+#include <Edje.h>
+
+#include "ico_uxf.h"
+#include "ico_uxf_conf.h"
+
+#include "home_screen.h"
+#include "home_screen_res.h"
+#include "home_screen_conf.h"
+
+#include <libwebsockets.h>
+
+/*============================================================================*/
+/* Define data types */
+/*============================================================================*/
+#define ICO_ONS_WS_TIMEOUT 0.1
+#define ICO_ONS_WS_ADDRESS "127.0.0.1"
+#define ICO_ONS_WS_PROTOCOL_NAME ICO_HS_PROTOCOL_OS
+#define ICO_ONS_BUF_SIZE (1024)
+#define ICO_ONS_APPLI_NUM (15) /* only for applist */
+
+#define ICO_ONS_VERTICAL (1)
+#define ICO_ONS_HORIZONTAL (2)
+
+#define ICO_ONS_CMD_WAIT (1)
+#define ICO_ONS_NO_WAIT (2)
+
+typedef struct _ons_msg ons_msg_t;
+struct _ons_msg {
+ ons_msg_t *next;
+ char *data;
+ int len;
+};
+
+/*============================================================================*/
+/* static(internal) functions prototype */
+/*============================================================================*/
+static int ons_loadinons_edje_file(const char *edje_file);
+static void ons_event_message(char *format, ...);
+static ons_msg_t *ons_alloc_seendmsg(char *data, int len);
+static ons_msg_t *ons_get_sendmsg(void);
+static int ons_put_sendmsg(ons_msg_t *send);
+static char *ons_edje_parse_str(void *in, int arg_num);
+static int ons_callback_http(
+ struct libwebsocket_context *context, struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user, void *in,
+ size_t len);
+static int ons_callback_onscreen(
+ struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user,
+ void *in, size_t len);
+static void ons_create_context(void);
+static Eina_Bool ons_ecore_event(void *data);
+static void ons_on_destroy(Ecore_Evas *ee);
+static void ons_touch_up_edje(void *data, Evas *evas,
+ Evas_Object *obj, void *event_info);
+static void ons_touch_up_next(void *data, Evas *evas, Evas_Object *obj,
+ void *event_info);
+static const char *ons_get_fname(const char *filepath);
+static int ons_get_appindex(int idx);
+static void ons_set_appicon(Evas *evas, Evas_Object *edje, Evas_Object* part,
+ const char *partname);
+
+/*============================================================================*/
+/* variabe & table */
+/*============================================================================*/
+static int ons_ws_port = ICO_HS_WS_PORT;
+static int ons_ws_connected = 0;
+static struct libwebsocket_context *ons_ws_context = NULL;
+static struct libwebsocket *ons_wsi_mirror = NULL;
+static char ons_edje_str[ICO_ONS_BUF_SIZE];
+static char ons_respath[ICO_ONS_BUF_SIZE];
+
+static Ecore_Evas *ons_window; /* ecore-evas object */
+static Evas *ons_evas = NULL; /* evas object */
+static Evas_Object *ons_edje = NULL; /* loaded edje objects */
+static Eina_List *ons_img_list = NULL;
+static int ons_width, ons_height;
+static int ons_applist_idx = 0; /* only for applist, it's index */
+static int ons_app_cnt = 0; /* only for applist. a number of app to listed */
+
+static ons_msg_t *ons_free_msg = NULL;
+static ons_msg_t *ons_send_msg = NULL;
+
+static int ons_command_wait = ICO_ONS_NO_WAIT;
+
+static struct libwebsocket_protocols ws_protocols[] = {
+ {
+ "http-only",
+ ons_callback_http,
+ 0
+ },
+ {
+ "onscreen-protocol",
+ ons_callback_onscreen,
+ 0,
+ },
+ {
+ /* end of list */
+ NULL,
+ NULL,
+ 0
+ }
+};
+
+/*============================================================================*/
+/* functions */
+/*============================================================================*/
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ons_event_message
+ * send message
+ *
+ * @param[in] wsi libwebsockets management table to send
+ * @param[in] fromat message to send
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ons_event_message(char *format, ...)
+{
+ va_list list;
+ char message[ICO_HS_TEMP_BUF_SIZE];
+ ons_msg_t *send;
+
+ va_start(list, format);
+ vsnprintf(message, sizeof(message), format, list);
+ va_end(list);
+
+ uifw_trace("OnScreen: ons_event_message %s", message);
+
+ send = ons_alloc_seendmsg(message, strlen(message));
+ if (!send) {
+ uifw_warn("ons_event_message: ERROR(allocate send msg)");
+ }
+ else {
+ ons_put_sendmsg(send);
+ }
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ons_get_sendmsg
+ * get the send message from the send buffer.
+ *
+ * @param none
+ * @return send buffer address
+ * @retval > 0 success
+ * @retval NULL error
+ */
+/*--------------------------------------------------------------------------*/
+static ons_msg_t *
+ons_get_sendmsg(void)
+{
+ ons_msg_t *msg;
+
+ msg = ons_send_msg;
+ if (msg) {
+ ons_send_msg = msg->next;
+ msg->next = NULL;
+ }
+
+ return msg;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ons_put_sendmsg
+ * put the send message to the send queue end.
+ *
+ * @param[in] data send message
+ * @return result
+ * @retval ICO_HS_OK success
+ * @retval ICO_HS_ERR error
+ */
+/*--------------------------------------------------------------------------*/
+static int
+ons_put_sendmsg(ons_msg_t *send)
+{
+ ons_msg_t *msg;
+
+ uifw_trace("ons_put_sendmsg: Enter");
+
+ msg = ons_send_msg;
+ while (msg) {
+ if (!msg->next) {
+ break;
+ }
+ msg = msg->next;
+ }
+ if (!msg) {
+ ons_send_msg = send;
+ }
+ else {
+ msg->next = send;
+ }
+
+ if (ons_ws_context && ons_wsi_mirror) {
+ uifw_trace("ons_put_sendmsg: libwebsocket_callback_on_writable"
+ "(wsi_ctx=%x, wsi=%x", ons_ws_context, ons_wsi_mirror);
+ libwebsocket_callback_on_writable(ons_ws_context, ons_wsi_mirror);
+ }
+ else {
+ uifw_trace("ons_put_sendmsg: Leave(do not have wsi)");
+ return ICO_HS_ERR;
+ }
+
+ uifw_trace("ons_put_sendmsg: Leave");
+
+ return ICO_HS_OK;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ons_alloc_seendmsg
+ * Allocate a send message buffer.
+ *
+ * @param[in] data data
+ * @param[in] len data length
+ * @return address
+ * @retval > 0 success
+ * @retval NULL error
+ */
+/*--------------------------------------------------------------------------*/
+static ons_msg_t *
+ons_alloc_seendmsg(char *data, int len)
+{
+ ons_msg_t *msg;
+
+ if (!ons_free_msg) {
+ msg = malloc(sizeof(ons_msg_t));
+ if (!msg) {
+ return NULL;
+ }
+ }
+ else {
+ msg = ons_free_msg;
+ ons_free_msg = ons_free_msg->next;
+ }
+ memset(msg, 0, sizeof(ons_msg_t));
+
+ msg->len = len;
+ msg->data = strdup(data);
+ if (!msg->data) {
+ free(msg);
+ return NULL;
+ }
+
+ return msg;
+}
+
+static char *
+ons_edje_parse_str(void *in, int arg_num)
+{
+ int i;
+ char *data;
+
+ uifw_trace("ons_edje_parse_str %s, arg = %d", in, arg_num);
+ data = strtok(in, " ");
+ /* arg_num : 0 to n */
+ for (i = 0; i < arg_num; i++) {
+ data = strtok(NULL, " ");
+ }
+ uifw_trace("ons_edje_parse_str data: %s", data);
+ return data;
+}
+
+/*--------------------------------------------------------------------------*/
+/*
+ * @brief ons_callback_http
+ * Connection status is notified from libwebsockets.
+ *
+ * @param[in] context libwebsockets context
+ * @param[in] wsi libwebsockets management table
+ * @param[in] reason event type
+ * @param[in] user intact
+ * @param[in] in receive message
+ * @param[in] len message size[BYTE]
+ * @return result
+ * @retval =0 success
+ * @retval =1 error
+ */
+/*--------------------------------------------------------------------------*/
+static int
+ons_callback_http(struct libwebsocket_context *context, struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user, void *in,
+ size_t len)
+{
+ uifw_trace("ons_callback_http %p", context);
+ uifw_trace("OS-REASON %d", reason);
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/*
+ * @brief ons_callback_onscreen
+ * this callback function is notified from libwebsockets
+ * onscreen protocol
+ *
+ * @param[in] context libwebsockets context
+ * @param[in] wsi libwebsockets management table
+ * @param[in] reason event type
+ * @param[in] user intact
+ * @param[in] in receive message
+ * @param[in] len message size[BYTE]
+ * @return result
+ * @retval =0 success
+ * @retval =1 error
+ */
+/*--------------------------------------------------------------------------*/
+static int
+ons_callback_onscreen(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user,
+ void *in, size_t len)
+{
+ int n = 0;
+ unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 512
+ + LWS_SEND_BUFFER_POST_PADDING];
+ unsigned char *p = &buf[LWS_SEND_BUFFER_PRE_PADDING];
+ ons_msg_t *msg;
+
+ uifw_trace("ons_callback_onscreen %p", context);
+
+ switch (reason) {
+ case LWS_CALLBACK_CLIENT_ESTABLISHED:
+ uifw_trace("OS-ESTABLISHED %x", wsi);
+ ons_wsi_mirror = wsi;
+ ons_event_message("ANS HELLO");
+ break;
+
+ case LWS_CALLBACK_CLIENT_RECEIVE:
+ uifw_trace("OS-RECEIVE[%d] %s", len, in);
+
+ if (strlen(in) == 0)
+ break;
+ ons_command_wait = ICO_ONS_NO_WAIT;
+ /* onscreen activate request */
+ if (strncmp("OPEN", in, 4) == 0) {
+ uifw_trace("%s", in);
+ strncpy(ons_edje_str, ons_edje_parse_str(in, 1), sizeof(ons_edje_str));
+ uifw_trace("ons_loadinons_edje_file: %s", &ons_edje_str[0]);
+ if (ons_loadinons_edje_file(&ons_edje_str[0]) == 0) {
+ ons_event_message("RESULT SUCCESS");
+ }
+ else {
+ ons_event_message("RESULT FAILED");
+ }
+ }
+ break;
+
+ case LWS_CALLBACK_CLOSED:
+ uifw_trace("OS-CLOSE");
+ ons_wsi_mirror = NULL;
+ break;
+
+ case LWS_CALLBACK_CLIENT_WRITEABLE:
+ uifw_trace("LWS_CALLBACK_CLIENT_WRITEABLE:(wsi=%x)", wsi);
+
+ msg = ons_get_sendmsg();
+ if (msg) {
+ strcpy((char *)p, msg->data);
+ n = libwebsocket_write(wsi, p, strlen((char *)p), LWS_WRITE_TEXT);
+ if (n < 0) {
+ uifw_warn("ons_callback_onscreen: ERROR(fail to write ws)");
+ }
+ }
+ if (ons_send_msg) {
+ libwebsocket_callback_on_writable(context, wsi);
+ }
+
+ usleep(200);
+ break;
+
+ default:
+ uifw_trace("OS-REASON %d", reason);
+ break;
+ }
+
+ uifw_trace("ons_callback_onscreen: Leave");
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ons_create_context
+ * connect to the homescreen using websocket.
+ *
+ * @param[in] none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ons_create_context(void)
+{
+ ons_ws_context
+ = libwebsocket_create_context(CONTEXT_PORT_NO_LISTEN, NULL,
+ ws_protocols,
+ libwebsocket_internal_extensions,
+ NULL, NULL, -1, -1, 0);
+ uifw_trace("OnScreen: ons_create_context ctx = %p", ons_ws_context);
+
+ ons_ws_connected = 0;
+ if (ons_ws_context == NULL) {
+ uifw_trace("OnScreen: libwebsocket_create_context failed.");
+ }
+ else {
+ ons_wsi_mirror = libwebsocket_client_connect(ons_ws_context,
+ ICO_ONS_WS_ADDRESS, ons_ws_port, 0, "/",
+ ICO_ONS_WS_ADDRESS, NULL,
+ ICO_ONS_WS_PROTOCOL_NAME, -1);
+ uifw_trace("OnScreen: ons_create_context wsi = %p", ons_wsi_mirror);
+ if (ons_wsi_mirror != NULL) {
+ ons_ws_connected = 1;
+ }
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ons_ecore_event
+ * timer handler called by Ecore.
+ *
+ * @param[in] data user data
+ * @return call back setting
+ * @retval ECORE_CALLBACK_RENEW set callback
+ */
+/*--------------------------------------------------------------------------*/
+static Eina_Bool
+ons_ecore_event(void *data)
+{
+ if (ons_ws_connected) {
+ libwebsocket_service(ons_ws_context, 0);
+ }
+ else {
+ if (ons_ws_context != NULL) {
+ libwebsocket_context_destroy(ons_ws_context);
+ }
+ ons_ws_context
+ = libwebsocket_create_context(CONTEXT_PORT_NO_LISTEN, NULL,
+ ws_protocols,
+ libwebsocket_internal_extensions,
+ NULL, NULL, -1, -1, 0);
+ if (ons_ws_context == NULL) {
+ uifw_trace("OnScreen: libwebsocket_create_context failed.");
+ }
+ else {
+ ons_wsi_mirror = libwebsocket_client_connect(ons_ws_context,
+ ICO_ONS_WS_ADDRESS, ons_ws_port, 0,
+ "/", ICO_ONS_WS_ADDRESS, NULL,
+ ICO_ONS_WS_PROTOCOL_NAME, -1);
+ if (ons_wsi_mirror != NULL) {
+ ons_ws_connected = 1;
+ }
+ }
+ }
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+/*--------------------------------------------------------------------------*/
+/*
+ * @brief ons_on_destroy
+ * callback function called by EFL when ecore destroyed.
+ * exit ecore main loop.
+ *
+ * @param[in] ee ecore evas object
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ons_on_destroy(Ecore_Evas *ee)
+{
+ uifw_trace("ons_on_destroy: Enter");
+
+ ecore_main_loop_quit();
+ libwebsocket_context_destroy(ons_ws_context);
+ edje_shutdown();
+}
+
+static void
+ons_touch_up_edje(void *data, Evas *evas, Evas_Object *obj, void *event_info)
+{
+ if (ons_command_wait == ICO_ONS_CMD_WAIT) return;
+ ons_command_wait = ICO_ONS_CMD_WAIT;
+
+ /* get name from userdata */
+ if (data != NULL) {
+ uifw_trace("OnScreen: user data is %s", (const char *)data);
+ }
+ else {
+ uifw_trace("OnScreen: user data is NULL");
+ }
+ ons_event_message("TOUCH %s %s", ons_edje_str, data);
+
+ /* operation sound */
+ hs_snd_play(hs_snd_get_filename(ICO_HS_SND_TYPE_DEFAULT));
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ons_touch_up_next
+ * processing when next button touch up.
+ *
+ * @param[in] data user data
+ * @param[in] obj evas object of the button
+ * @param[in] event_info evas event infomation
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+ons_touch_up_next(void *data, Evas *evas, Evas_Object *obj, void *event_info)
+{
+ int listcnt;
+
+ if (ons_command_wait == ICO_ONS_CMD_WAIT) return;
+ ons_command_wait = ICO_ONS_CMD_WAIT;
+
+ if (ons_app_cnt > 0) {
+ listcnt = ((ons_app_cnt - 1) / ICO_ONS_APPLI_NUM) + 1;
+ }
+ else {
+ listcnt = 1;
+ }
+ ons_applist_idx += 1;
+ if (ons_applist_idx >= listcnt) {
+ ons_applist_idx = 0;
+ }
+
+ /* get name from userdata */
+ if (data != NULL) {
+ uifw_trace("OnScreen: user data is %s", (const char *)data);
+ }
+ else {
+ uifw_trace("OnScreen: user data is NULL");
+ }
+ ons_event_message("TOUCH %s %s", ons_edje_str, data);
+
+ /* operation sound */
+ hs_snd_play(hs_snd_get_filename(ICO_HS_SND_TYPE_DEFAULT));
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ons_get_fname
+ * get filename from the full path
+ *
+ * @param[in] filepath file path
+ * @return filename
+ */
+/*--------------------------------------------------------------------------*/
+static const char *
+ons_get_fname(const char *filepath)
+{
+ int ii;
+ const char *name = filepath;
+
+ for (ii = 0; ii < ICO_ONS_BUF_SIZE - 1; ii++) {
+ if (filepath[ii] == 0)
+ break;
+ if (filepath[ii] == '/')
+ name = &filepath[ii + 1];
+ }
+
+ return name;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief ons_get_appindex
+ * return a application index that to be set indicated index.
+ *
+ * @param[in] filepath file path
+ * @return filename
+ */
+/*--------------------------------------------------------------------------*/
+static int
+ons_get_appindex(int idx)
+{
+ int ii;
+ int appidx = idx + ons_applist_idx * ICO_ONS_APPLI_NUM + 1;
+ int cnt = 0;
+ Ico_Uxf_App_Config *appconf = (Ico_Uxf_App_Config *)ico_uxf_getAppConfig();
+
+ uifw_trace("ons_get_appindex: idx=%d appidx=%d appcnt=%d", idx, appidx,
+ ons_app_cnt);
+
+ for (ii = 0; ii < appconf->applicationNum; ii++) {
+ if (strcmp(appconf->application[ii].type, ICO_HS_GROUP_SPECIAL) != 0) {
+ cnt++;
+ }
+ if (cnt == appidx) {
+ return ii;
+ }
+ }
+
+ return -1;
+}
+
+/* set App Icon on rect */
+static void
+ons_set_appicon(Evas *evas, Evas_Object *edje, Evas_Object* part,
+ const char *partname)
+{
+ int x, y, w, h;
+ int idx; /* rect index */
+ int appidx; /* appli index */
+ char imgfile[ICO_ONS_BUF_SIZE];
+ Ico_Uxf_App_Config *appconf;
+ Evas_Object *img = NULL;
+
+ memset(imgfile, 0, sizeof(imgfile));
+ /* check name, if part is rect/next_bt/cancel_bt */
+ if (strncmp(partname, ICO_HS_ONS_PART_RECT_NAME,
+ sizeof(ICO_HS_ONS_PART_RECT_NAME) - 1) == 0) {
+ img = evas_object_image_filled_add(ons_evas);
+ /* get rect index from partname(rect_01, rect_02, ...) */
+ sscanf(partname, ICO_HS_ONS_PART_RECT_NAME"%d", &idx);
+ idx -= 1;
+
+ appconf = (Ico_Uxf_App_Config *)ico_uxf_getAppConfig();
+
+ appidx = ons_get_appindex(idx);
+ uifw_trace("ons_set_appicon: idx=%d appidx=%d", idx, appidx);
+ if ((appidx < 0) || (appidx > appconf->applicationNum)) {
+ evas_object_del(img);
+ return;
+ }
+
+ /* set icon file name */
+ snprintf(imgfile, ICO_ONS_BUF_SIZE, "%s",
+ appconf->application[appidx].icon_key_name);
+ uifw_trace("ons_set_appicon: set image = %s(%d/%d), app=%s, group=%s",
+ imgfile, appidx, ons_app_cnt,
+ appconf->application[appidx].appid,
+ appconf->application[appidx].group);
+ /* set mouse call back function */
+ evas_object_event_callback_add(img, EVAS_CALLBACK_MOUSE_UP,
+ ons_touch_up_edje,
+ appconf->application[appidx].appid);
+ }
+ else if (strcmp(partname, ICO_HS_ONS_PART_NEXT_NAME) == 0) {
+ evas_object_event_callback_add(part, EVAS_CALLBACK_MOUSE_UP,
+ ons_touch_up_next, partname);
+ }
+ else if (strcmp(partname, ICO_HS_ONS_PART_CANCEL_NAME) == 0) {
+ evas_object_event_callback_add(part, EVAS_CALLBACK_MOUSE_UP,
+ ons_touch_up_edje, partname);
+ }
+ else {
+ return;
+ }
+
+ if (strlen(imgfile) > 0) {
+ /* calculation icon pos */
+ edje_object_part_geometry_get(ons_edje, partname, &x, &y, &w, &h);
+ x += (ons_width - ICO_HS_SIZE_LAYOUT_WIDTH) / 2;
+ y += (ons_height - ICO_HS_SIZE_LAYOUT_HEIGHT) / 2;
+
+ evas_object_image_file_set(img, imgfile, NULL);
+ evas_object_move(img, x, y);
+ evas_object_resize(img, w, h);
+ evas_object_show(img);
+ }
+
+ ons_img_list = eina_list_append(ons_img_list, img);
+}
+
+static int
+ons_loadinons_edje_file(const char *edje_file)
+{
+ Evas_Object *part; /* part handle */
+ Eina_List *group; /* edje group list */
+ Eina_List *list; /* part list in edje */
+ int group_count = 0; /* group counter */
+ int name_count = 0; /* name counter */
+ int moveX, moveY; /* move list to center */
+ Eina_List *l, *l_next;
+ Evas_Object *data;
+ Evas_Object *canvas;
+
+ if (!ons_evas) {
+ ons_evas = ecore_evas_get(ons_window);
+ if (!ons_evas) {
+ uifw_trace("OnScreen: could not create evas.");
+ return -1;
+ }
+ /* set color */
+ canvas = evas_object_rectangle_add(ons_evas);
+ evas_object_color_set(canvas, 0, 0, 0, 191);
+ evas_object_move(canvas, 0, 0);
+ evas_object_resize(canvas, ons_width, ons_height);
+ evas_object_show(canvas);
+ }
+
+ /* delete pre image */
+ uifw_trace("OnScreen: img list is %08x", ons_img_list);
+ EINA_LIST_FOREACH_SAFE(ons_img_list, l, l_next, data) {
+ uifw_trace("OnScreen: del data is %08x", data);
+ evas_object_del(data);
+ ons_img_list = eina_list_remove_list(ons_img_list, l);
+ }
+
+ /* delete edje */
+ if (ons_edje) {
+ evas_object_del(ons_edje);
+ }
+
+ /* create and add object in canvas from edje */
+ ons_edje = edje_object_add(ons_evas);
+ if (!ons_edje) {
+ uifw_trace("OnScreen: could not create edje object!");
+ return -1;
+ }
+
+ uifw_trace("OnScreen: w=%d h=%d", ons_width, ons_height);
+
+ /* calc move */
+ moveX = (ons_width - ICO_HS_SIZE_LAYOUT_WIDTH) / 2;
+ moveY = (ons_height - ICO_HS_SIZE_LAYOUT_HEIGHT) / 2;
+
+ /* Put in the image */
+ evas_object_move(ons_edje, moveX, moveY);
+ /* Resize the image */
+ evas_object_resize(ons_edje, ons_width, ons_height);
+ /* Show the image */
+ evas_object_show(ons_edje);
+
+ /* get group list */
+ group = edje_file_collection_list(edje_file);
+ while (group != NULL) {
+ /* Set the edj file */
+ if (!edje_object_file_set(ons_edje, edje_file, (const char *)group->data)) {
+ int err = edje_object_load_error_get(ons_edje);
+ const char *errmsg = edje_load_error_str(err);
+ uifw_trace("OnScreen: could not load %s: %s", edje_file, errmsg);
+
+ edje_file_collection_list_free(group);
+ evas_object_del(ons_edje);
+ return -1;
+ }
+ uifw_trace("OnScreen: group[%d] data : %s", group_count,
+ (const char *)group->data);
+
+ /* get list */
+ list = edje_object_access_part_list_get(ons_edje);
+ while (list != NULL) {
+ uifw_trace("OnScreen: list[%d] data : %s", name_count,
+ (const char *)list->data);
+
+ /* set callback for part name */
+ part = (Evas_Object *)edje_object_part_object_get(ons_edje,
+ (const char *)list->data);
+ if (part != NULL) {
+ uifw_trace("OnScreen: list[%d] name : %s", name_count,
+ (const char *)list->data);
+
+ /* if not applist */
+ if (strncmp(ons_get_fname(edje_file), ICO_HS_ONS_APPLI_LIST_NAME,
+ sizeof(ICO_HS_ONS_APPLI_LIST_NAME) - 1) != 0) {
+ evas_object_event_callback_add(part,
+ EVAS_CALLBACK_MOUSE_UP,
+ ons_touch_up_edje, list->data);
+ }
+ /* if applist */
+ else {
+ ons_set_appicon(ons_evas, ons_edje, part, (const char *)list->data);
+ }
+ }
+ else {
+ uifw_trace("OnScreen: list[%d] is NULL", name_count);
+ }
+ /* to next list */
+ list = list->next;
+ name_count++;
+ }
+ /* to next group */
+ group = group->next;
+ group_count++;
+ }
+ uifw_trace("OnScreen: group num is %d", group_count);
+ uifw_trace("OnScreen: name num is %d", name_count);
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/*
+ * @brief onscreen application
+ * main routine
+ *
+ * @param main() finction's standard parameter (argc,argv)
+ * @return result
+ * @retval 0 success
+ * @retval 1 failed
+ */
+/*--------------------------------------------------------------------------*/
+int
+main(int argc, char *argv[])
+{
+ int width, height;
+ Ico_Uxf_App_Config *appconf;
+ int appidx, idx, cnt;
+ int orientation = ICO_ONS_HORIZONTAL;
+ int ii;
+ int ret;
+
+ /* configure */
+ if (getenv("PKG_NAME")) {
+ ico_uxf_log_open(getenv("PKG_NAME"));
+ }
+ else {
+ ico_uxf_log_open(ICO_HS_APPID_DEFAULT_ONS);
+ }
+
+ /* get argment */
+ for (ii = 1; ii < argc; ii++) {
+ if (argv[ii][0] != '-')
+ continue;
+ if (strncasecmp(argv[ii], "-orientaion=", strlen("-orientaion=")) == 0) {
+ if (strcmp(&argv[ii][strlen("-orientaion=")], "vertical") == 0) {
+ orientation = ICO_ONS_VERTICAL;
+ }
+ else if (strcmp(&argv[ii][strlen("-orientaion=")], "horizontal")
+ == 0) {
+ orientation = ICO_ONS_HORIZONTAL;
+ }
+ }
+ }
+
+ /* load configuration */
+ ret = initHomeScreenConfig(ICO_ONSCREEN_CONFIG_FILE);
+ if (ret == ICO_HS_OK) {
+ ons_ws_port = hs_conf_get_integer(ICO_HS_CONFIG_ONSCREEN,
+ ICO_HS_CONFIG_WS_PORT,
+ ICO_HS_WS_PORT);
+ orientation = hs_conf_get_integer(ICO_HS_CONFIG_ONSCREEN,
+ ICO_HS_CONFIG_ORIENTAION,
+ orientation);
+ }
+ hs_snd_init();
+
+ hs_get_image_path(ons_respath, ICO_ONS_BUF_SIZE);
+ appconf = (Ico_Uxf_App_Config *)ico_uxf_getAppConfig();
+ ons_app_cnt = appconf->applicationNum;
+ for (appidx = 0; appidx < appconf->applicationNum; appidx++) {
+ if (strcmp(appconf->application[appidx].type, ICO_HS_GROUP_SPECIAL)
+ == 0) {
+ ons_app_cnt--;
+ }
+ }
+ cnt = 0;
+ for (idx = 0; idx < ons_app_cnt; idx++) {
+ appidx = ons_get_appindex(idx);
+ if (appidx > 0) {
+ uifw_trace("Application list: appid=%s seat=%d idx=%d seatcnt=%d",
+ appconf->application[appidx].appid, cnt
+ / ICO_ONS_APPLI_NUM, idx - ICO_ONS_APPLI_NUM
+ * (cnt / ICO_ONS_APPLI_NUM), ((ons_app_cnt - 1)
+ / ICO_ONS_APPLI_NUM) + 1);
+ cnt++;
+ }
+ }
+
+ /* Reset a ecore_evas */
+ ecore_evas_init();
+
+ /* Initialize a edje */
+ edje_init();
+
+ /* Make a new ecore_evas */
+ ons_window = ecore_evas_new(NULL, 0, 0, 1, 1, "frame=0");
+
+ /* if not for a window, return NULL */
+ if (!ons_window) {
+ EINA_LOG_CRIT("OnScreen: could not create ons_window.");
+ return -1;
+ }
+ ecore_evas_callback_destroy_set(ons_window, ons_on_destroy);
+
+ /* resize window */
+ ecore_main_loop_iterate();
+ ecore_wl_screen_size_get(&width, &height);
+ if (orientation == ICO_ONS_VERTICAL) {
+ ons_width = width > height ? height : width;
+ ons_height = width > height ? width : height;
+ }
+ else {
+ ons_width = width < height ? height : width;
+ ons_height = width < height ? width : height;
+ }
+ ecore_evas_resize(ons_window, ons_width, ons_height);
+
+ /* Show the window */
+ /* evas_output_framespace_set(ecore_evas_get(ons_window), 0, 0, 0, 0); */
+ ecore_evas_alpha_set(ons_window, EINA_TRUE);
+ ecore_evas_show(ons_window);
+
+ /* Init websockets */
+ ons_create_context();
+ ecore_timer_add(ICO_ONS_WS_TIMEOUT, ons_ecore_event, NULL);
+
+ /* Start main loop */
+ ecore_main_loop_begin();
+
+ /* end the ecore_evas */
+ ecore_evas_shutdown();
+
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief configuration of resource path
+ *
+ * @date Feb-15-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "ico_uxf_conf_def.h"
+#include "home_screen.h"
+#include "home_screen_res.h"
+
+/*============================================================================*/
+/* functions */
+/*============================================================================*/
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_get_image_path
+ * set the directory path of the image files.
+ *
+ * @param[out] buff buffer that the pass set
+ * @param[in] len buffer length
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+hs_get_image_path(char *buff, int len)
+{
+ char *pkg;
+
+ memset(buff, 0, len);
+ pkg = getenv("PKG_NAME");
+ if (pkg) {
+ snprintf(buff, len, image_path, pkg);
+ }
+ else {
+ pkg = getenv(ICO_UXF_TOP_ENV);
+ snprintf(buff, len, local_image_path, pkg ? pkg : local_top_path);
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_get_sound_path
+ * set the directory path of the sounds files.
+ *
+ * @param[out] buff buffer that the pass set
+ * @param[in] len buffer length
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+hs_get_sound_path(char *buff, int len)
+{
+ char *pkg;
+
+ memset(buff, 0, len);
+ pkg = getenv("PKG_NAME");
+ if (pkg) {
+ snprintf(buff, len, sound_path, pkg);
+ }
+ else {
+ pkg = getenv(ICO_UXF_TOP_ENV);
+ snprintf(buff, len, local_sound_path, pkg ? pkg : local_top_path);
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_get_edj_path
+ * set the directory path of efj files.
+ *
+ * @param[out] buff buffer that the pass set
+ * @param[in] len buffer length
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+hs_get_edj_path(char *buff, int len)
+{
+ char *pkg;
+
+ memset(buff, 0, len);
+ pkg = getenv("PKG_NAME");
+ if (pkg) {
+ snprintf(buff, len, edj_path, pkg);
+ }
+ else {
+ pkg = getenv(ICO_UXF_TOP_ENV);
+ snprintf(buff, len, local_edj_path, pkg ? pkg : local_top_path);
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_get_ons_edj_path
+ * set the directory path of edj files for onscreen.
+ *
+ * @param[out] buff buffer that the pass set
+ * @param[in] len buffer length
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+hs_get_ons_edj_path(char *buff, int len)
+{
+ char *pkg;
+
+ memset(buff, 0, len);
+ pkg = getenv("PKG_NAME");
+ if (pkg) {
+ snprintf(buff, len, edj_path, ICO_HS_APPID_DEFAULT_ONS);
+ }
+ else {
+ pkg = getenv(ICO_UXF_TOP_ENV);
+ snprintf(buff, len, local_edj_path, pkg ? pkg : local_top_path);
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hs_get_conf_path
+ * set the directory path of edj files for onscreen.
+ *
+ * @param[out] buff buffer that the pass set
+ * @param[in] len buffer length
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+void
+hs_get_conf_path(char *buff, int len)
+{
+ char *pkg;
+
+ memset(buff, 0, len);
+ pkg = getenv("PKG_NAME");
+ if (pkg) {
+ snprintf(buff, len, manifest_path, pkg);
+ }
+ else {
+ pkg = getenv(ICO_UXF_TOP_ENV);
+ snprintf(buff, len, local_manifest_path, pkg ? pkg : local_top_path);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief statusbar application
+ *
+ * @date Feb-15-2013
+ */
+
+#include <stdio.h>
+#include <time.h>
+#include <pthread.h>
+
+#include <libwebsockets.h>
+
+#include <Ecore.h>
+#include <Ecore_Wayland.h>
+#include <Ecore_Evas.h>
+#include <Elementary.h>
+
+#include "ico_uxf.h"
+#include "ico_uxf_conf.h"
+
+#include "home_screen.h"
+#include "home_screen_res.h"
+#include "home_screen_conf.h"
+
+/*============================================================================*/
+/* Define data types */
+/*============================================================================*/
+#define ICO_SB_TIME_AM (10) /* f_name in sb_time_data */
+#define ICO_SB_TIME_PM (11) /* f_name in sb_time_data */
+#define ICO_SB_TIME_IMG_PARTS (12) /* total counts of sb_time_data */
+#define ICO_SB_TIMEOUT (0.2)
+
+#define ICO_SB_WS_TIMEOUT (0.05)
+#define ICO_SB_WS_ADDRESS "127.0.0.1"
+#define ICO_SB_WS_PROTOCOL_NAME ICO_HS_PROTOCOL_SB
+#define ICO_SB_BUF_SIZE (1024)
+#define ICO_SB_VERTICAL (1)
+#define ICO_SB_HORIZONTAL (2)
+
+#define ICO_SB_POS_Y (0)
+#define ICO_SB_POS_COLON_X (689)
+#define ICO_SB_POS_COLON_Y (30)
+#define ICO_SB_POS_AMPM_X (582)
+#define ICO_SB_POS_AMPM_Y (27)
+#define ICO_SB_POS_HOUR1_X (640)
+#define ICO_SB_POS_HOUR1_Y (18)
+#define ICO_SB_POS_HOUR2_X (662)
+#define ICO_SB_POS_HOUR2_Y (18)
+#define ICO_SB_POS_MIN1_X (703)
+#define ICO_SB_POS_MIN1_Y (18)
+#define ICO_SB_POS_MIN2_X (725)
+#define ICO_SB_POS_MIN2_Y (18)
+
+#define ICO_SB_SIZE_COLON_W (6)
+#define ICO_SB_SIZE_COLON_H (17)
+#define ICO_SB_SIZE_NUM_W (20)
+#define ICO_SB_SIZE_NUM_H (30)
+#define ICO_SB_SIZE_AMPM_W (47)
+#define ICO_SB_SIZE_AMPM_H (27)
+
+/*============================================================================*/
+/* static(internal) functions prototype */
+/*============================================================================*/
+static void sb_on_destroy(Ecore_Evas *ee);
+static int sb_callback_http(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user, void *in,
+ size_t len);
+static int sb_callback_statusbar(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user,
+ void *in, size_t len);
+static void sb_create_ws_context(void);
+static void sb_time_hour(struct tm *t_st);
+static void sb_time_min(struct tm *t_st);
+static Eina_Bool sb_time_show(void* thread_data);
+static void sb_touch_up_escathion(void *data, Evas_Object *obj, void *event_info);
+static void sb_clock_display_fixation(Evas *canvas);
+
+/*============================================================================*/
+/* variabe & table */
+/*============================================================================*/
+static int sb_ws_port = ICO_HS_WS_PORT;
+static int sb_ws_connected = 0;
+static struct libwebsocket_context *sb_ws_context;
+static struct libwebsocket *sb_wsi_mirror;
+
+static int sb_width = 0;
+static char sb_respath[ICO_SB_BUF_SIZE];
+static struct tm sb_st_buf;
+static Evas_Object *sb_ampm;
+static Evas_Object *sb_hour1;
+static Evas_Object *sb_hour2;
+static Evas_Object *sb_min1;
+static Evas_Object *sb_min2;
+
+struct _sb_time_data {
+ char f_name[64];
+ Evas_Object *time_img;
+};
+
+struct _sb_time_data sb_time_data[ICO_SB_TIME_IMG_PARTS] = {
+ {fname_num0, }, {fname_num1, },
+ {fname_num2, }, {fname_num3, },
+ {fname_num4, }, {fname_num5, },
+ {fname_num6, }, {fname_num7, },
+ {fname_num8, }, {fname_num9, },
+ {fname_am, }, {fname_pm, }
+};
+
+static struct libwebsocket_protocols ws_protocols[] = {
+ {
+ "http-only",
+ sb_callback_http,
+ 0
+ },
+ {
+ "statusbar-protocol",
+ sb_callback_statusbar,
+ 0,
+ },
+ {
+ /* end of list */
+ NULL,
+ NULL,
+ 0
+ }
+};
+
+/*============================================================================*/
+/* functions */
+/*============================================================================*/
+/*--------------------------------------------------------------------------*/
+/*
+ * @brief sb_on_destroy
+ * callback function called by EFL when ecore destroyed.
+ * exit ecore main loop.
+ *
+ * @param[in] ee ecore evas object
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+sb_on_destroy(Ecore_Evas *ee)
+{
+ /* Quits the main loop */
+ ecore_main_loop_quit();
+}
+
+/*--------------------------------------------------------------------------*/
+/*
+ * @brief sb_callback_http
+ * Connection status is notified from libwebsockets.
+ *
+ * @param[in] context libwebsockets context
+ * @param[in] wsi libwebsockets management table
+ * @param[in] reason event type
+ * @param[in] user intact
+ * @param[in] in receive message
+ * @param[in] len message size[BYTE]
+ * @return result
+ * @retval =0 success
+ * @retval =1 error
+ */
+/*--------------------------------------------------------------------------*/
+static int
+sb_callback_http(struct libwebsocket_context *context, struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user, void *in,
+ size_t len)
+{
+ uifw_trace("sb_callback_http %p", context);
+ uifw_trace("SB-REASON %d", reason);
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/*
+ * @brief sb_callback_statusbar
+ * this callback function is notified from libwebsockets
+ * statusbar protocol
+ *
+ * @param[in] context libwebsockets context
+ * @param[in] wsi libwebsockets management table
+ * @param[in] reason event type
+ * @param[in] user intact
+ * @param[in] in receive message
+ * @param[in] len message size[BYTE]
+ * @return result
+ * @retval =0 success
+ * @retval =1 error
+ */
+/*--------------------------------------------------------------------------*/
+static int
+sb_callback_statusbar(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user,
+ void *in, size_t len)
+{
+ int n = 0;
+ unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 512
+ + LWS_SEND_BUFFER_POST_PADDING];
+ unsigned char *p = &buf[LWS_SEND_BUFFER_PRE_PADDING];
+
+ uifw_trace("sb_callback_statusbar %p", context);
+
+ switch (reason) {
+ case LWS_CALLBACK_CLIENT_ESTABLISHED:
+ uifw_trace("SB-ESTABLISHED %x", wsi);
+ sb_wsi_mirror = wsi;
+ n = sprintf((char *)p, "%s", "ANS HELLO");
+ break;
+ case LWS_CALLBACK_CLIENT_RECEIVE:
+ uifw_trace("SB-RECEIVE[%d] %s", len, in);
+ sb_wsi_mirror = wsi;
+ n = sprintf((char *)p, "ANS %s OK", (char *)in);
+ break;
+ case LWS_CALLBACK_CLOSED:
+ uifw_trace("SB-CLOSE");
+ sb_wsi_mirror = NULL;
+ break;
+ default:
+ uifw_trace("SB-REASON %d", reason);
+ break;
+ }
+
+ if (n != 0) {
+ n = libwebsocket_write(wsi, p, n, LWS_WRITE_TEXT);
+ }
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief sb_create_ws_context
+ * connect to the homescreen using websocket.
+ *
+ * @param[in] none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+sb_create_ws_context(void)
+{
+ sb_ws_context
+ = libwebsocket_create_context(CONTEXT_PORT_NO_LISTEN, NULL,
+ ws_protocols,
+ libwebsocket_internal_extensions,
+ NULL, NULL, -1, -1, 0);
+ uifw_trace("sb_create_ws_context ctx = %p", sb_ws_context);
+
+ sb_ws_connected = 0;
+ if (sb_ws_context == NULL) {
+ uifw_trace("libwebsocket_create_context failed.");
+ }
+ else {
+ sb_wsi_mirror
+ = libwebsocket_client_connect(sb_ws_context, ICO_SB_WS_ADDRESS,
+ sb_ws_port, 0, "/",
+ ICO_SB_WS_ADDRESS, NULL,
+ ICO_SB_WS_PROTOCOL_NAME, -1);
+ uifw_trace("sb_create_ws_context wsi = %p", sb_wsi_mirror);
+ if (sb_wsi_mirror != NULL) {
+ sb_ws_connected = 1;
+ }
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief sb_ecore_event
+ * timer handler called by Ecore.
+ *
+ * @param[in] data user data
+ * @return call back setting
+ * @retval ECORE_CALLBACK_RENEW set callback
+ */
+/*--------------------------------------------------------------------------*/
+static Eina_Bool
+sb_ecore_event(void *data)
+{
+ if (sb_ws_connected) {
+ libwebsocket_service(sb_ws_context, 0);
+ }
+ else {
+ if (sb_ws_context != NULL) {
+ libwebsocket_context_destroy(sb_ws_context);
+ }
+ sb_ws_context
+ = libwebsocket_create_context(CONTEXT_PORT_NO_LISTEN, NULL,
+ ws_protocols,
+ libwebsocket_internal_extensions,
+ NULL, NULL, -1, -1, 0);
+ if (sb_ws_context == NULL) {
+ uifw_trace("libwebsocket_create_context failed.");
+ }
+ else {
+ sb_wsi_mirror
+ = libwebsocket_client_connect(sb_ws_context,
+ ICO_SB_WS_ADDRESS,
+ sb_ws_port, 0, "/",
+ ICO_SB_WS_ADDRESS, NULL,
+ ICO_SB_WS_PROTOCOL_NAME, -1);
+ if (sb_wsi_mirror != NULL) {
+ sb_ws_connected = 1;
+ }
+ }
+ }
+ return ECORE_CALLBACK_RENEW;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief sb_time_hour
+ * show the clock's hour image on statubar
+ *
+ * @param[in] tm time data
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+sb_time_hour(struct tm *t_st)
+{
+ char file[ICO_SB_BUF_SIZE];
+ if (t_st->tm_hour < 12) {
+ sprintf(file, "%s%s", sb_respath, sb_time_data[ICO_SB_TIME_AM].f_name);
+ evas_object_image_file_set(sb_ampm, file, NULL);
+ sprintf(file, "%s%s", sb_respath,
+ sb_time_data[t_st->tm_hour / 10].f_name);
+ evas_object_image_file_set(sb_hour1, file, NULL);
+ sprintf(file, "%s%s", sb_respath,
+ sb_time_data[t_st->tm_hour % 10].f_name);
+ evas_object_image_file_set(sb_hour2, file, NULL);
+ }
+ else {
+ sprintf(file, "%s%s", sb_respath, sb_time_data[ICO_SB_TIME_PM].f_name);
+ evas_object_image_file_set(sb_ampm, file, NULL);
+ sprintf(file, "%s%s", sb_respath, sb_time_data[(t_st->tm_hour - 12)
+ / 10].f_name);
+ evas_object_image_file_set(sb_hour1, file, NULL);
+ sprintf(file, "%s%s", sb_respath, sb_time_data[(t_st->tm_hour - 12)
+ % 10].f_name);
+ evas_object_image_file_set(sb_hour2, file, NULL);
+ }
+
+ /*Makes the given Evas object visible*/
+ evas_object_show(sb_ampm);
+ evas_object_show(sb_hour1);
+ evas_object_show(sb_hour2);
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief sb_time_hour
+ * show the clock's minite image on statubar
+ *
+ * @param[in] tm time data
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+sb_time_min(struct tm *t_st)
+{
+ char file[ICO_SB_BUF_SIZE];
+ sprintf(file, "%s%s", sb_respath, sb_time_data[t_st->tm_min / 10].f_name);
+ evas_object_image_file_set(sb_min1, file, NULL);
+ sprintf(file, "%s%s", sb_respath, sb_time_data[t_st->tm_min % 10].f_name);
+ evas_object_image_file_set(sb_min2, file, NULL);
+
+ /*Makes the given Evas object visible*/
+ evas_object_show(sb_min1);
+ evas_object_show(sb_min2);
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief sb_time_show
+ * callback function called by Ecore.
+ * get time data, and show the clock's image on statubar.
+ *
+ * @param[in] thread_data user data
+ * @return call back setting
+ * @retval ECORE_CALLBACK_RENEW set callback
+ */
+/*--------------------------------------------------------------------------*/
+static Eina_Bool
+sb_time_show(void *thread_data)
+{
+ time_t timer;
+ struct tm *t_st, *old_t_st;
+
+ old_t_st = &sb_st_buf;
+
+ /* get time */
+ time(&timer);
+ t_st = localtime(&timer);
+
+ if (old_t_st->tm_hour != t_st->tm_hour) {
+ /* hour file set */
+ sb_time_hour(t_st);
+ }
+ if (old_t_st->tm_min != t_st->tm_min) {
+ /* min file set */
+ sb_time_min(t_st);
+ }
+ memcpy(old_t_st, t_st, sizeof(struct tm));
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief sb_touch_up_escathion
+ * processing when change button touch up.
+ *
+ * @param[in] data user data
+ * @param[in] obj evas object of the button
+ * @param[in] event_info evas event infomation
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+sb_touch_up_escathion(void *data, Evas_Object *obj, void *event_info)
+{
+ int n = 0;
+ unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 512
+ + LWS_SEND_BUFFER_POST_PADDING];
+ unsigned char *p = &buf[LWS_SEND_BUFFER_PRE_PADDING];
+
+ if (sb_wsi_mirror != NULL) {
+ n = sprintf((char *)p, "%s", "CLICK ESCUTCHEON 1");
+ libwebsocket_write(sb_wsi_mirror, p, n,
+ LWS_WRITE_CLIENT_IGNORE_XOR_MASK | LWS_WRITE_TEXT);
+ uifw_trace("SB: CLICK ESCUTCHEON 1");
+ }
+
+ /* operation sound */
+ hs_snd_play(hs_snd_get_filename(ICO_HS_SND_TYPE_DEFAULT));
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief sb_clock_display_fixation
+ * set up fixed images on status bar
+ *
+ * @param[in] canvas evas to draw
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+sb_clock_display_fixation(Evas *canvas)
+{
+ Evas_Object *title, *colon;
+ int moveH;
+ int escPosX;
+ char file[ICO_SB_BUF_SIZE];
+
+ moveH = sb_width - ICO_HS_SIZE_LAYOUT_WIDTH;
+ escPosX = sb_width / 2 - ICO_HS_SIZE_SB_HEIGHT / 2;
+
+ /* show escutcheon */
+ Evas_Object *icon, *btn;
+ title = evas_object_rectangle_add(canvas);
+ evas_object_move(title, escPosX, ICO_SB_POS_Y);
+ evas_object_resize(title, ICO_HS_SIZE_SB_HEIGHT, ICO_HS_SIZE_SB_HEIGHT);
+ evas_object_show(title);
+
+ icon = elm_icon_add(title);
+ elm_icon_standard_set(icon, "refresh");
+
+ btn = elm_button_add(title);
+ elm_object_part_content_set(btn, "icon", icon);
+ evas_object_move(btn, escPosX, ICO_SB_POS_Y);
+ evas_object_resize(btn, ICO_HS_SIZE_SB_HEIGHT, ICO_HS_SIZE_SB_HEIGHT);
+ evas_object_smart_callback_add(btn, "clicked", sb_touch_up_escathion, NULL );
+ evas_object_show(btn);
+
+ /* show clock's colon */
+ /*Creates a new image object*/
+ colon = evas_object_image_filled_add(canvas);
+ /*Set the image file */
+ sprintf(file, "%s%s", sb_respath, fname_colon);
+ evas_object_image_file_set(colon, file, NULL);
+ /*This function will make layout change*/
+ evas_object_move(colon, moveH + ICO_SB_POS_COLON_X, ICO_SB_POS_COLON_Y);
+ /*This function will make size change of a picture*/
+ evas_object_resize(colon, ICO_SB_SIZE_COLON_W, ICO_SB_SIZE_COLON_H);
+ /*Makes the given Evas object visible*/
+ evas_object_show(colon);
+}
+
+/*--------------------------------------------------------------------------*/
+/*
+ * @brief status bar application
+ * main routine
+ *
+ * @param main() finction's standard parameter (argc,argv)
+ * @return result
+ * @retval 0 success
+ * @retval 1 failed
+ */
+/*--------------------------------------------------------------------------*/
+int
+main(int argc, char *argv[])
+{
+ Evas * canvas;
+ time_t timer;
+ struct tm *t_st;
+ Evas_Object *bg;
+ char file[ICO_SB_BUF_SIZE];
+ int width, height;
+ int moveH = 0;
+ int orientation = ICO_SB_HORIZONTAL;
+ int ii;
+ int ret;
+ static Ecore_Evas *ee;
+
+ /* configure */
+ hs_get_image_path(sb_respath, ICO_SB_BUF_SIZE);
+
+ /* configure */
+ if (getenv("PKG_NAME")) {
+ ico_uxf_log_open(getenv("PKG_NAME"));
+ }
+ else {
+ ico_uxf_log_open(ICO_HS_APPID_DEFAULT_SB);
+
+ }
+
+ /* get argment */
+ for (ii = 1; ii < argc; ii++) {
+ if (argv[ii][0] != '-')
+ continue;
+ if (strncasecmp(argv[ii], "-orientaion=", strlen("-orientaion=")) == 0) {
+ if (strcmp(&argv[ii][strlen("-orientaion=")], "vertical") == 0) {
+ orientation = ICO_SB_VERTICAL;
+ }
+ else if (strcmp(&argv[ii][strlen("-orientaion=")], "horizontal")
+ == 0) {
+ orientation = ICO_SB_HORIZONTAL;
+ }
+ }
+ }
+
+ /* load configuration */
+ ret = initHomeScreenConfig(ICO_STATUSBAR_CONFIG_FILE);
+ if (ret == ICO_HS_OK) {
+ sb_ws_port = hs_conf_get_integer(ICO_HS_CONFIG_STATUBAR,
+ ICO_HS_CONFIG_WS_PORT,
+ ICO_HS_WS_PORT);
+ orientation = hs_conf_get_integer(ICO_HS_CONFIG_STATUBAR,
+ ICO_HS_CONFIG_ORIENTAION,
+ orientation);
+ }
+ hs_snd_init();
+
+ /* Initialize a new system of Ecore_Evas */
+ ecore_evas_init();
+
+ /* Generate Ecore_Evas */
+ ee = ecore_evas_new(NULL, 0, 0, 1, 1, "frame=0");
+ if (!ee)
+ goto error;
+
+ ecore_main_loop_iterate();
+ ecore_wl_screen_size_get(&width, &height);
+
+ if (orientation == ICO_SB_VERTICAL) {
+ sb_width = width > height ? height : width;
+ moveH = sb_width - ICO_HS_SIZE_LAYOUT_WIDTH;
+ }
+ else {
+ sb_width = width < height ? height : width;
+ moveH = sb_width - ICO_HS_SIZE_LAYOUT_WIDTH;
+ }
+
+ /* Set the window size of the maximum and minimum */
+ ecore_evas_size_min_set(ee, sb_width, ICO_HS_SIZE_SB_HEIGHT);
+ ecore_evas_size_max_set(ee, sb_width, ICO_HS_SIZE_SB_HEIGHT);
+
+ /* Set a callback for Ecore_Evas delete request events */
+ ecore_evas_callback_delete_request_set(ee, sb_on_destroy);
+
+ /* Set the title of an Ecore_Evas window */
+ /* ecore_evas_title_set(ee, "Ecore_Evas buffer (image) example"); */
+
+ ecore_evas_move(ee, 0, 0);
+ ecore_evas_resize(ee, sb_width, ICO_HS_SIZE_SB_HEIGHT);
+ ecore_evas_show(ee);
+
+ /* Wrapper of Evas */
+ canvas = ecore_evas_get(ee);
+
+ /* BG color set */
+ bg = evas_object_rectangle_add(canvas);
+ evas_object_color_set(bg, 0, 0, 0, 255);
+ evas_object_move(bg, 0, 0);
+ evas_object_resize(bg, sb_width, ICO_HS_SIZE_SB_HEIGHT);
+ evas_object_show(bg);
+
+ /* Call the function */
+ elm_init(argc, argv);
+ sb_clock_display_fixation(canvas);
+
+ /* ... */
+ sb_ampm = evas_object_image_filled_add(canvas);
+ sb_hour1 = evas_object_image_filled_add(canvas);
+ sb_hour2 = evas_object_image_filled_add(canvas);
+ sb_min1 = evas_object_image_filled_add(canvas);
+ sb_min2 = evas_object_image_filled_add(canvas);
+
+ /* This function will make layout change */
+ evas_object_move(sb_ampm, moveH + ICO_SB_POS_AMPM_X, ICO_SB_POS_AMPM_Y);
+ evas_object_move(sb_hour1, moveH + ICO_SB_POS_HOUR1_X, ICO_SB_POS_HOUR1_Y);
+ evas_object_move(sb_hour2, moveH + ICO_SB_POS_HOUR2_X, ICO_SB_POS_HOUR2_Y);
+
+ /* This function will make size change of picture */
+ evas_object_resize(sb_ampm, ICO_SB_SIZE_AMPM_W, ICO_SB_SIZE_AMPM_H);
+ evas_object_resize(sb_hour1, ICO_SB_SIZE_NUM_W, ICO_SB_SIZE_NUM_H);
+ evas_object_resize(sb_hour2, ICO_SB_SIZE_NUM_W, ICO_SB_SIZE_NUM_H);
+
+ /* Makes the given Evas object visible */
+ evas_object_show(sb_ampm);
+ evas_object_show(sb_hour1);
+ evas_object_show(sb_hour2);
+
+ /* Change default layout of Evas object */
+ evas_object_move(sb_min1, moveH + ICO_SB_POS_MIN1_X, ICO_SB_POS_MIN1_Y);
+ evas_object_move(sb_min2, moveH + ICO_SB_POS_MIN2_X, ICO_SB_POS_MIN2_Y);
+
+ /* Change default size of Evas object */
+ evas_object_resize(sb_min1, ICO_SB_SIZE_NUM_W, ICO_SB_SIZE_NUM_H);
+ evas_object_resize(sb_min2, ICO_SB_SIZE_NUM_W, ICO_SB_SIZE_NUM_H);
+
+ /* Makes the given Evas object visible */
+ evas_object_show(sb_min1);
+ evas_object_show(sb_min2);
+
+ time(&timer);
+ t_st = localtime(&timer);
+ sb_time_hour(t_st);
+ sb_time_min(t_st);
+
+ /* Set the image file */
+ for (ii = 0; ii < ICO_SB_TIME_IMG_PARTS; ii++) {
+ sb_time_data[ii].time_img = evas_object_image_filled_add(canvas);
+ sprintf(file, "%s%s", sb_respath, sb_time_data[ii].f_name);
+ evas_object_image_file_set(sb_time_data[ii].time_img, file, NULL);
+ }
+ ecore_timer_add(ICO_SB_TIMEOUT, sb_time_show, NULL);
+
+ /* Init websockets */
+ sb_create_ws_context();
+ ecore_timer_add(ICO_SB_WS_TIMEOUT, sb_ecore_event, NULL);
+
+ /* Runs the application main loop */
+ ecore_main_loop_begin();
+ /* Free an Ecore_Evas */
+ ecore_evas_free(ee);
+ /* Shut down the Ecore_Evas system */
+ ecore_evas_shutdown();
+ return 0;
+
+error:
+ uifw_warn("status_bar: error use ecore")
+ ecore_evas_shutdown();
+ return -1;
+}
+
--- /dev/null
+fonts{
+ font:"DejaVuSans.ttf" "DejaVuSans";
+ font:"ttf-japanese-gothic.ttf" "TakaoPGothic";
+}
+
+collections {
+ group {
+ name: "translucent_bg"; // must be the same as in onscreen_*.c
+ parts {
+ part {
+ name: "translucent_bg";
+ type: RECT; // plain boring rectangle
+ description {
+ state: "default" 0.0; // must always exist
+ color: 0 0 0 192; // translucent black
+ rel1 { // top-left point at (0, 0) [WIDTH * 0 + 0, HEIGHT * 0 + 0]
+ relative: 0.0 0.0;
+ offset: 0 0;
+ }
+ rel2 { // bottom-right point at (WIDTH * 1.0 - 1, HEIGHT * 1.0 - 1)
+ relative: 1.0 1.0;
+ offset: -1 -1;
+ }
+ }
+ }
+ }
+ }
+}
--- /dev/null
+#!/bin/sh
+
+# 1. kill pulseaudio and weston, and start pulseaudio
+/usr/bin/killall pulseaudio > /dev/null 2>&1
+/usr/bin/killall weston > /dev/null 2>&1
+/bin/sleep 0.2
+/usr/bin/killall -9 pulseaudio > /dev/null 2>&1
+/usr/bin/killall -9 weston > /dev/null 2>&1
+
+# 2. Delete log file
+/bin/mkdir /var/log/ico > /dev/null 2>&1
+/bin/chmod -R 0777 /var/log/ico > /dev/null 2>&1
+/bin/rm -f /var/log/ico/* > /dev/null 2>&1
+
+# 3. Weston/Wayland Envionment
+export XDG_RUNTIME_DIR=/tmp/run-root
+export QT_QPA_PLATFORM=wayland
+export ELM_ENGINE=wayland_egl
+export ECORE_EVAS_ENGINE=wayland_egl
+#export ELM_ENGINE=wayland_shm
+#export ECORE_EVAS_ENGINE=wayland_shm
+export EVAS_FONT_DPI=72
+export ECORE_IMF_MODULE=isf
+export ELM_MODULES="ctxpopup_copypasteUI>entry/api:datetime_input_ctxpopup>datetime/api"
+export ELM_SCALE="0.7"
+export ELM_PROFILE=mobile
+
+# 4. Start Device Input Controller for eGalax TouchPanel
+#/usr/bin/ico_ictl-touch_egalax -t
+/usr/bin/ico_ictl-touch_egalax
+sleep 0.3
+
+# 5. Start Weston
+ORG_UMASK=`umask`
+umask 000
+/usr/bin/weston --backend=drm-backend.so --idle-time=0 --log=/var/log/ico/weston.log &
+sync;sync
+sleep 0.8
+if [ -f $XDG_RUNTIME_DIR/wayland-0 ] ; then
+ chmod 0777 $XDG_RUNTIME_DIR/wayland-0
+fi
+umask $ORG_UMASK
+
+## if pulseaudio dose not start ... kick pulseaudio
+/bin/ps ax | /bin/grep pulseaudio | /bin/grep -v grep > /dev/null
+if [ "$?" = "1" ] ; then
+ /usr/bin/pulseaudio --log-level=3 --log-target=file:/var/log/ico/pulse.log --system -D
+ sleep 0.5
+fi
+
+# 5 start sample wayland client for display cursor
+sync;sync
+/usr/bin/nice -19 /usr/bin/wayland-smoke &
+sleep 0.3
+
+# 6 start app core daemon
+/bin/ps ax | /bin/grep launchpad_preloading_preinitializing_daemon | /bin/grep -v grep > /dev/null
+if [ "$?" = "1" ] ; then
+ /usr/bin/launchpad_preloading_preinitializing_daemon &
+ sleep 1
+fi
+
+# 7 start homescreen
+/usr/bin/launch_app org.tizen.ico.homescreen &
+
--- /dev/null
+AM_CFLAGS = $(GCC_CFLAGS)
+AM_CPPFLAGS = $(GCC_CFLAGS)
+
+bin_PROGRAMS = \
+ ico_set_vehicleinfo \
+ ico_send_inputevent \
+ ico_send_hscommand
+
+check_PROGRAMS = \
+ ico_set_vehicleinfo \
+ ico_send_inputevent
+
+ico_set_vehicleinfo_SOURCES = \
+ ico_set_vehicleinfo.c
+ico_set_vehicleinfo_LDADD = -lwebsockets
+
+ico_send_inputevent_SOURCE = \
+ ico_send_inputevent.c
+
+ico_send_hscommand_SOURCES = \
+ ico_send_hscommand.c
+ico_send_hscommand_CFLAGS = -I../include
+ico_send_hscommand_LDADD = -lwebsockets
+
--- /dev/null
+#!/bin/sh
+
+# Define
+SCREEN_IS_FHD=1
+GUI_TEST_NEXT_DAT=gui-test-FHD-next.dat
+GUI_TEST_DAT=gui-test-FHD.dat
+# for GUI test launch
+LAUNCH_APP=org.tizen.music-player
+LAUNCH_APP_SEAT=0
+LAUNCH_APP_INDEX=0
+LAUNCH_APP_SEATCNT=0
+LAUNCH_APP_X=0
+LAUNCH_APP_Y=0
+SHIFT_X=896
+SHIFT_Y=448
+
+#determin screen size 768x1024 or 1080x1920
+/bin/grep "ico_uxf_window_screen_size_get width=768 height=1024" $HOMESCREEN_LOG
+if [ "$?" = 0 ]; then
+ SCREEN_IS_FHD=0
+ SHIFT_X=0
+ SHIFT_Y=0
+ GUI_TEST_NEXT_DAT=gui-test-XGA-next.dat
+ GUI_TEST_DAT=gui-test-XGA.dat
+fi
+
+#determin launch app index/position on application list
+for str in `/bin/grep "Application list: appid=$LAUNCH_APP" $ONSCREEN_LOG`
+do
+ para=`echo $str|cut -d "=" -f 1`
+ val=`echo $str|cut -d "=" -f 2`
+ if [ "$para" = "seat" ]; then
+ LAUNCH_APP_SEAT=$val
+ fi
+ if [ "$para" = "idx" ]; then
+ LAUNCH_APP_INDEX=$val
+ fi
+ if [ "$para" = "seatcnt" ]; then
+ LAUNCH_APP_SEATCNT=$val
+ fi
+done
+
+LAUNCH_APP_X=`expr $LAUNCH_APP_INDEX % 5 \* 130 + 124 + $SHIFT_X`
+LAUNCH_APP_Y=`expr $LAUNCH_APP_INDEX / 5 \* 130 + 374 + $SHIFT_Y`
+
+/bin/cp testdata/$GUI_TEST_DAT testdata/gui-test.dat
+
+if [ $LAUNCH_APP_SEATCNT = 2 ]; then
+ if [ $LAUNCH_APP_SEAT = 0 ]; then
+ cat testdata/$GUI_TEST_NEXT_DAT >> testdata/gui-test.dat
+ fi
+elif [ $LAUNCH_APP_SEATCNT -gt 2 ]; then
+ num=0
+ if [ $LAUNCH_APP_SEAT = 0 ]; then
+ num=`expr $LAUNCH_APP_SEATCNT - 1`
+ elif [ $LAUNCH_APP_SEAT -gt 1 ]; then
+ num=`expr $LAUNCH_APP_SEATCNT - $LAUNCH_APP_SEAT`
+ fi
+ for i in `seq 1 1 $num`; do
+ cat testdata/$GUI_TEST_NEXT_DAT >> testdata/gui-test.dat
+ done
+fi
+
+cat testdata/gui-test-launch-template.dat >> testdata/gui-test.dat
+sed -i "s/COORD_X/$LAUNCH_APP_X/g" testdata/gui-test.dat
+sed -i "s/COORD_Y/$LAUNCH_APP_Y/g" testdata/gui-test.dat
+
+
--- /dev/null
+#!/bin/sh
+
+# 1 Delete log file
+rm -fr /var/log/weston.log
+
+# 2 Weston/Wayland Envionment
+export XDG_RUNTIME_DIR=/tmp/run-root
+export QT_QPA_PLATFORM=wayland
+export ELM_ENGINE=wayland_egl
+export ECORE_EVAS_ENGINE=wayland_egl
+#export ELM_ENGINE=wayland_shm
+#export ECORE_EVAS_ENGINE=wayland_shm
+export EVAS_FONT_DPI=72
+export ECORE_IMF_MODULE=isf
+export ELM_MODULES="ctxpopup_copypasteUI>entry/api:datetime_input_ctxpopup>datetime/api"
+export ELM_SCALE="0.7"
+export ELM_PROFILE=mobile
+
+# 3 Start Device Input Controller for eGalax TouchPanel
+/usr/bin/ico_ictl-touch_egalax -t
+sleep 0.3
+
+# 4 Start Weston
+ORG_UMASK=`umask`
+umask 000
+/usr/bin/weston --backend=drm-backend.so --idle-time=0 --log=/var/log/weston.log &
+sleep 0.5
+if [ -f $XDG_RUNTIME_DIR/wayland-0 ] ; then
+ chmod 0777 $XDG_RUNTIME_DIR/wayland-0
+fi
+umask $ORG_UMASK
+
+# 5 start app core daemon
+sleep 1
+/usr/bin/launchpad_preloading_preinitializing_daemon &
+
+# 6 start homescreen
+rm -fr /tmp/log
+mkdir /tmp/log/
+chmod -R 0777 /tmp/log
+/usr/bin/launch_app org.tizen.ico.homescreen &
+
+# 7 start test shell
+sleep 5
+./homescreen-test.sh
--- /dev/null
+#!/bin/sh
+
+## log file
+export HOMESCREEN_LOG=/tmp/log/org.tizen.ico.homescreen.log
+export ONSCREEN_LOG=/tmp/log/org.tizen.ico.onscreen.log
+
+## make dat
+./homescreen-test-makedat.sh
+
+## GUI test
+./ico_send_inputevent -m < testdata/gui-test.dat
+
+## CUI test
+#Hide tile screen
+./ico_send_hscommand json/hide-tile.json
+sleep 3
+#Show tile screen
+./ico_send_hscommand json/show-tile.json
+sleep 3
+#Show application
+./ico_send_hscommand json/hide-tile.json
+sleep 3
+./ico_send_hscommand json/show-app1.json
+sleep 3
+#Move and resize application
+./ico_send_hscommand json/geom-app1-1.json
+sleep 3
+./ico_send_hscommand json/geom-app1-2.json
+sleep 3
+./ico_send_hscommand json/geom-app1-3.json
+sleep 3
+#Terminate application
+./ico_send_hscommand json/term-app1.json
+sleep 3
+./ico_send_hscommand json/show-tile.json
+sleep 3
+#Terminate application
+./ico_send_hscommand json/hide-tile.json
+sleep 3
+./ico_send_hscommand json/exec-app1.json
+sleep 3
+#Application on tile screen
+./ico_send_hscommand json/show-tile.json
+sleep 3
+
+## Check Error
+FOUND_ERR=0
+/bin/grep -i "err" $HOMESCREEN_LOG
+if [ "$?" != "1" ] ; then
+ FOUND_ERR=1
+fi
+/bin/grep -i "err" $ONSCREEN_LOG
+if [ "$?" != "1" ] ; then
+ FOUND_ERR=1
+fi
+/bin/grep -i "fail" $HOMESCREEN_LOG
+if [ "$?" != "1" ] ; then
+ FOUND_ERR=1
+fi
+/bin/grep -i "fail" $ONSCREEN_LOG
+if [ "$?" != "1" ] ; then
+ FOUND_ERR=1
+fi
+
+## delete dat file
+rm -f testdata/gui-test.dat
+
+if [ $FOUND_ERR = 0 ] ; then
+ echo "org.tizen.ico.homescreen Test: OK"
+else
+ echo "org.tizen.ico.homescreen Test: ERROR"
+fi
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief applicatoin that send a command to homescreen
+ *
+ * @date Feb-15-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <pthread.h>
+
+#include <libwebsockets.h>
+
+#include "home_screen.h"
+#include "home_screen_res.h"
+
+
+/*============================================================================*/
+/* Define data types */
+/*============================================================================*/
+#define ICO_HSCMD_WS_TIMEOUT 0.05
+#define ICO_HSCMD_WS_ADDRESS "127.0.0.1"
+#define ICO_HSCMD_WS_PROTOCOL_NAME ICO_HS_PROTOCOL_CM
+
+/*============================================================================*/
+/* static(internal) functions prototype */
+/*============================================================================*/
+static int hscmd_callback_http(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user,
+ void *in, size_t len);
+static int hscmd_callback_command(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason,
+ void *user, void *in, size_t len);
+static void hscmd_create_ws_context(void);
+static void hscmd_destroy_ws_context(void);
+static void hscmd_ws_service_loop(void);
+static void hscmd_usage(const char *prog);
+
+/*============================================================================*/
+/* variabe & table */
+/*============================================================================*/
+static int hscmd_ws_port = ICO_HS_WS_PORT;
+static int hscmd_ws_connected = 0;
+static struct libwebsocket_context *hscmd_ws_context;
+static struct libwebsocket *hscmd_wsi_mirror;
+static FILE *hscmd_fp;
+
+static struct libwebsocket_protocols ws_protocols[] = {
+ {
+ "http-only",
+ hscmd_callback_http,
+ 0
+ },
+ {
+ "gui-protocol",
+ hscmd_callback_command,
+ 0,
+ },
+ {
+ /* end of list */
+ NULL,
+ NULL,
+ 0
+ }
+};
+
+/*============================================================================*/
+/* functions */
+/*============================================================================*/
+static int
+hscmd_callback_http(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user,
+ void *in, size_t len)
+{
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/*
+ * @brief hscmd_callback_command
+ * Connection status is notified from libwebsockets.
+ *
+ * @param[in] context libwebsockets context
+ * @param[in] wsi libwebsockets management table
+ * @param[in] reason event type
+ * @param[in] user intact
+ * @param[in] in receive message
+ * @param[in] len message size[BYTE]
+ * @return result
+ * @retval =0 success
+ * @retval =1 error
+ */
+/*--------------------------------------------------------------------------*/
+static int
+hscmd_callback_command(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason,
+ void *user, void *in, size_t len)
+{
+ long fsize;
+ char *sendMsg;
+
+ switch(reason) {
+ case LWS_CALLBACK_CLIENT_ESTABLISHED:
+ break;
+ case LWS_CALLBACK_CLIENT_RECEIVE:
+ if(strncmp("ANS HELLO", in, 9) == 0) {
+ fseek(hscmd_fp, 0, SEEK_END);
+ fsize = ftell(hscmd_fp);
+ fseek(hscmd_fp, 0L, SEEK_SET);
+
+ sendMsg = (void *)malloc((int)fsize);
+
+ memset(sendMsg, 0, fsize);
+
+ fread(sendMsg, 1, fsize, hscmd_fp);
+ libwebsocket_write( wsi, (unsigned char *)sendMsg, fsize, LWS_WRITE_BINARY);
+ hscmd_destroy_ws_context();
+ }
+ break;
+ case LWS_CALLBACK_CLOSED:
+ hscmd_wsi_mirror = NULL;
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hscmd_create_ws_context
+ * connect to the homescreen using websocket.
+ *
+ * @param[in] none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hscmd_create_ws_context(void)
+{
+ hscmd_ws_context
+ = libwebsocket_create_context(CONTEXT_PORT_NO_LISTEN, NULL, ws_protocols,
+ libwebsocket_internal_extensions,
+ NULL, NULL, -1, -1, 0);
+
+ hscmd_ws_connected = 0;
+ if (hscmd_ws_context == NULL) {
+ fprintf(stderr, "libwebsocket_create_context failed.\n");
+ } else {
+ hscmd_wsi_mirror
+ = libwebsocket_client_connect(
+ hscmd_ws_context, ICO_HSCMD_WS_ADDRESS, hscmd_ws_port,
+ 0, "/", ICO_HSCMD_WS_ADDRESS, NULL,
+ ICO_HSCMD_WS_PROTOCOL_NAME, -1);
+ if(hscmd_wsi_mirror != NULL) {
+ hscmd_ws_connected = 1;
+ }
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief hscmd_destroy_ws_context
+ * destroy websokets connection.
+ *
+ * @param[in] none
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+hscmd_destroy_ws_context(void)
+{
+ if (hscmd_ws_context) {
+ libwebsocket_context_destroy(hscmd_ws_context);
+ hscmd_ws_context = NULL;
+ hscmd_ws_connected = 0;
+ }
+}
+
+static void
+hscmd_ws_service_loop(void)
+{
+ while (hscmd_ws_connected) {
+ libwebsocket_service(hscmd_ws_context, 100);
+ }
+}
+
+static void
+hscmd_usage(const char *prog)
+{
+ fprintf(stderr, "Usage: %s filename\n", prog);
+ exit(0);
+}
+
+/*--------------------------------------------------------------------------*/
+/*
+ * @brief test command tools
+ * send json format command to
+ * main routine
+ *
+ * @param main() finction's standard parameter (argc,argv)
+ * @return result
+ * @retval 0 success
+ * @retval 1 failed
+ */
+/*--------------------------------------------------------------------------*/
+int
+main(int argc, char *argv[])
+{
+
+ /* read json file */
+ if (argc < 1) {
+ hscmd_usage(argv[0]);
+ }
+
+ hscmd_fp = fopen(argv[1], "rb");
+ if (hscmd_fp == NULL) {
+ hscmd_usage(argv[0]);
+ }
+
+ /* Init websockets */
+ hscmd_create_ws_context();
+
+ hscmd_ws_service_loop();
+
+ hscmd_destroy_ws_context();
+
+ fclose(hscmd_fp);
+
+ return 0;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief System Test Tool for send device input event
+ *
+ * @date Feb-20-2013
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+#include <linux/joystick.h>
+
+#define DEV_TOUCH 0
+#define DEV_JS 1
+#define SPECIALTYPE_XY 9991
+
+static const struct {
+ char *prop;
+ short devtype;
+ short type;
+ short code;
+ short value;
+} event_key[] = {
+ { "X", DEV_TOUCH, EV_ABS, ABS_X, -1 },
+ { "Y", DEV_TOUCH, EV_ABS, ABS_Y, -1 },
+ { "Down", DEV_TOUCH, EV_KEY, BTN_TOUCH, 1 },
+ { "Up", DEV_TOUCH, EV_KEY, BTN_TOUCH, 0 },
+ { "Touch", DEV_TOUCH, EV_KEY, BTN_TOUCH, -1 },
+ { "XY", DEV_TOUCH, SPECIALTYPE_XY, 0, -1 },
+ { "SYN", DEV_TOUCH, 0, 0, 0 },
+ { "Button", DEV_TOUCH, EV_KEY, BTN_LEFT, -1 },
+ { "ButtonOn", DEV_TOUCH, EV_KEY, BTN_LEFT, 1 },
+ { "ButtonOff", DEV_TOUCH, EV_KEY, BTN_LEFT, 0 },
+
+ { "UpDown", DEV_JS, 2, 3, 1 },
+ { "UD", DEV_JS, 2, 3, 1 },
+ { "LeftRight", DEV_JS, 2, 2, 2 },
+ { "LR", DEV_JS, 2, 2, 2 },
+ { "Cross", DEV_JS, 1, 0, 3 },
+ { "Squere", DEV_JS, 1, 1, 4 },
+ { "Circle", DEV_JS, 1, 2, 5 },
+ { "Triangle", DEV_JS, 1, 3, 6 },
+ { "\0", 0, 0, 0, 0 } };
+
+static int uifd = -1;
+static int mqid = -1;
+static int mDebug = 0;
+static int mRun = 1;
+static int mTouch = 1;
+
+static void
+term_signal(const int signo)
+{
+ mRun = 0;
+}
+
+static void
+init_mq(const int mqkey)
+{
+ char dummy[256];
+
+ if (mqkey == 0) {
+ mqid = -1;
+ }
+ else {
+ mqid = msgget(mqkey, 0);
+ if (mqid < 0) {
+ mqid = msgget(mqkey, IPC_CREAT);
+ }
+ if (mqid < 0) {
+ fprintf(stderr, "Can not create message queue(%d(0x%x))[%d]\n",
+ mqkey, mqkey, errno);
+ fflush(stderr);
+ return;
+ }
+ while (msgrcv(mqid, dummy, sizeof(dummy)-sizeof(long), 0, IPC_NOWAIT) > 0) ;
+ }
+}
+
+static void
+init_device(const char *device)
+{
+ int fd;
+ int ii;
+ char devFile[64];
+ char devName[64];
+ struct uinput_user_dev uinputDevice;
+ uifd = open("/dev/uinput", O_RDWR);
+
+ if (uifd < 0) {
+ fprintf(stderr, "/dev/uinput open error[%d]\n", errno);
+ fflush(stderr);
+ exit(1);
+ }
+
+ memset(&uinputDevice, 0, sizeof(uinputDevice));
+ strcpy(uinputDevice.name, device);
+ uinputDevice.absmax[ABS_X] = 1920;
+ uinputDevice.absmax[ABS_Y] = 1080;
+
+ /* uinput device configuration */
+ if (write(uifd, &uinputDevice, sizeof(uinputDevice)) < (int)sizeof(uinputDevice)) {
+ fprintf(stderr, "/dev/uinput regist error[%d]\n", errno);
+ fflush(stderr);
+ close(uifd);
+ exit(1);
+ }
+
+ /* uinput set event bits */
+ ioctl(uifd, UI_SET_EVBIT, EV_SYN);
+
+ if ((mTouch != 0) && (mTouch != 3)) {
+ ioctl(uifd, UI_SET_EVBIT, EV_ABS);
+ ioctl(uifd, UI_SET_ABSBIT, ABS_X);
+ ioctl(uifd, UI_SET_ABSBIT, ABS_Y);
+ ioctl(uifd, UI_SET_EVBIT, EV_KEY);
+ if (mTouch == 1) {
+ ioctl(uifd, UI_SET_KEYBIT, BTN_LEFT);
+ }
+ else {
+ ioctl(uifd, UI_SET_KEYBIT, BTN_TOUCH);
+ ioctl(uifd, UI_SET_KEYBIT, BTN_TOOL_PEN);
+ }
+ }
+ else {
+ ioctl(uifd, UI_SET_EVBIT, EV_REL);
+ ioctl(uifd, UI_SET_RELBIT, REL_X);
+ ioctl(uifd, UI_SET_RELBIT, REL_Y);
+ ioctl(uifd, UI_SET_RELBIT, REL_Z);
+ ioctl(uifd, UI_SET_RELBIT, REL_RX);
+ ioctl(uifd, UI_SET_RELBIT, REL_RY);
+ ioctl(uifd, UI_SET_RELBIT, REL_RZ);
+ ioctl(uifd, UI_SET_EVBIT, EV_KEY);
+ ioctl(uifd, UI_SET_KEYBIT, KEY_RESERVED);
+ ioctl(uifd, UI_SET_KEYBIT, KEY_ESC);
+ ioctl(uifd, UI_SET_KEYBIT, KEY_1);
+ ioctl(uifd, UI_SET_KEYBIT, KEY_2);
+ ioctl(uifd, UI_SET_KEYBIT, KEY_3);
+ ioctl(uifd, UI_SET_KEYBIT, KEY_4);
+ ioctl(uifd, UI_SET_KEYBIT, KEY_5);
+ ioctl(uifd, UI_SET_KEYBIT, KEY_6);
+ ioctl(uifd, UI_SET_KEYBIT, KEY_7);
+ ioctl(uifd, UI_SET_KEYBIT, KEY_8);
+ ioctl(uifd, UI_SET_KEYBIT, KEY_9);
+ ioctl(uifd, UI_SET_KEYBIT, KEY_0);
+ }
+
+ ioctl(uifd, UI_SET_EVBIT, EV_MSC);
+ ioctl(uifd, UI_SET_MSCBIT, MSC_SCAN);
+
+ /* create event device */
+ if (ioctl(uifd, UI_DEV_CREATE, NULL) < 0) {
+ fprintf(stderr, "/dev/uinput create error[%d]\n", errno);
+ fflush(stderr);
+ close(uifd);
+ exit(1);
+ }
+
+ for (ii = 0; ii < 16; ii++) {
+ snprintf(devFile, 64, "/dev/input/event%d", ii);
+ fd = open(devFile, O_RDONLY);
+ if (fd < 0) continue;
+
+ memset(devName, 0, sizeof(devName));
+ ioctl(fd, EVIOCGNAME(sizeof(devName)), devName);
+ close(fd);
+ }
+}
+
+static int
+convert_value(const char *value, char **errp, int base)
+{
+ int i;
+
+ for (i = 0; value[i]; i++) {
+ if ((value[i] == ',') || (value[i] == ';') ||
+ (value[i] == ';') || (value[i] == ' ')) {
+ break;
+ }
+ }
+ if (errp) {
+ *errp = (char *)&value[i];
+ }
+
+ if ((strncasecmp(value, "on", i) == 0) ||
+ (strncasecmp(value, "true", i) == 0) ||
+ (strncasecmp(value, "push", i) == 0) ||
+ (strncasecmp(value, "down", i) == 0) ||
+ (strncasecmp(value, "right", i) == 0)) {
+ return 1;
+ }
+ else if ((strncasecmp(value, "off", i) == 0) ||
+ (strncasecmp(value, "false", i) == 0) ||
+ (strncasecmp(value, "pop", i) == 0) ||
+ (strncasecmp(value, "up", i) == 0) ||
+ (strncasecmp(value, "left", i) == 0)) {
+ return 0;
+ }
+ return strtol(value, (char **)0, 0);
+}
+
+static void
+send_event(const char *cmd)
+{
+ int i, j;
+ int key;
+ char prop[64];
+ char value[128];
+ int sec, msec;
+ char *errp;
+ struct input_event event;
+ struct js_event js;
+
+ j = 0;
+ for (i = 0; cmd[i]; i++) {
+ if ((cmd[i] == '=') || (cmd[i] == ' ')) break;
+ if (j < (int)(sizeof(prop)-1)) {
+ prop[j++] = cmd[i];
+ }
+ }
+
+ prop[j] = 0;
+ j = 0;
+ if (cmd[i] != 0) {
+ for (i++; cmd[i]; i++) {
+ if (cmd[i] == ' ') continue;
+ if (j < (int)(sizeof(value)-1)) {
+ value[j++] = cmd[i];
+ }
+ }
+ }
+ value[j] = 0;
+
+ if (strcasecmp(prop, "sleep") == 0) {
+ sec = 0;
+ msec = 0;
+ for (i = 0; value[i]; i++) {
+ if (value[i] == '.') break;
+ sec = sec * 10 + (value[i] & 0x0f);
+ }
+ if (value[i] == '.') {
+ i++;
+ if (value[i] != 0) {
+ msec = (value[i] & 0x0f) * 100;
+ i++;
+ }
+ if (value[i] != 0) {
+ msec = msec + (value[i] & 0x0f) * 10;
+ i++;
+ }
+ if (value[i] != 0) {
+ msec = msec + (value[i] & 0x0f);
+ }
+ }
+ if (sec > 0) sleep(sec);
+ if (msec > 0) usleep(msec * 1000);
+
+ return;
+ }
+
+ for (key = 0; event_key[key].prop[0]; key++) {
+ if (strcasecmp(prop, event_key[key].prop) == 0) break;
+ }
+ if (! event_key[key].prop[0]) {
+ fprintf(stderr, "UnKnown Event name[%s]\n", prop);
+ return;
+ }
+
+ if (mTouch != 0) {
+ memset(&event, 0, sizeof(event));
+ gettimeofday(&event.time, NULL);
+ if (event_key[key].type == SPECIALTYPE_XY) {
+ event.type = EV_ABS;
+ event.code = ABS_X;
+ event.value = convert_value(value, &errp, 0);
+ if (write(uifd, &event, sizeof(struct input_event)) < 0) {
+ fprintf(stderr, "event write error 1[%d]\n", errno);
+ fflush(stderr);
+ return;
+ }
+ event.code = ABS_Y;
+ if (*errp == ',') {
+ event.value = convert_value(errp + 1, (char **)0, 0);
+ }
+ else {
+ event.value = 0;
+ }
+ event.time.tv_usec += 200;
+ if (event.time.tv_usec >= 1000000) {
+ event.time.tv_sec ++;
+ event.time.tv_usec -= 1000000;
+ }
+ }
+ else {
+ event.type = event_key[key].type;
+
+ if (event_key[key].code == -1) {
+ event.code = convert_value(value, (char **)0, 0);
+ }
+ else {
+ event.code = event_key[key].code;
+ event.value = convert_value(value, (char **)0, 0);
+ }
+ if (mDebug) {
+ if ((event.type == EV_ABS) && (event.code == ABS_X)) {
+ }
+ else if ((event.type == EV_ABS) && (event.code == ABS_Y)) {
+ }
+ else if ((event.type == EV_KEY) && (event.code == BTN_LEFT) && (event.value == 1)) {
+ }
+ else if ((event.type == EV_KEY) && (event.code == BTN_LEFT) && (event.value == 0)) {
+ }
+ else {
+ if ((event.type == EV_REL) && (event.value == 0)) {
+ event.value = 9;
+ }
+ else if ((event.type == EV_KEY) && (event.code == 0)) {
+ event.code = 9;
+ }
+ }
+ }
+ }
+ if (write(uifd, &event, sizeof(struct input_event)) < 0) {
+ fprintf(stderr, "event write error 2[%d]\n", errno);
+ fflush(stderr);
+ }
+ else {
+ /* send EV_SYN */
+ memset(&event, 0, sizeof(event));
+ gettimeofday(&event.time, NULL);
+ event.type = EV_SYN;
+ event.code = SYN_REPORT;
+ if (write(uifd, &event, sizeof(struct input_event)) < 0) {
+ fprintf(stderr, "syn event write error 3[%d]\n", errno);
+ }
+ }
+ }
+ else {
+ memset(&js, 0, sizeof(js));
+ gettimeofday(&event.time, NULL);
+ js.time = (event.time.tv_sec * 1000) + (event.time.tv_usec / 1000);
+ js.type = event_key[key].type;
+ js.number = event_key[key].code;
+ js.value = convert_value(value, (char **)0, 0);
+ if (write(uifd, &js, sizeof(struct js_event)) < 0) {
+ fprintf(stderr, "event write error 4[%d]\n", errno);
+ fflush(stderr);
+ }
+ }
+}
+
+static void
+usage(const char *prog)
+{
+ fprintf(stderr, "Usage: %s [-device=device] [{-m/-t/-j}] [-mq[=key]] [-d] [event=value] [event=value] ...\n", prog);
+ exit(0);
+}
+
+int
+main(int argc, char *argv[])
+{
+ int i, j, k;
+ int mqkey = 0;
+ struct {
+ long mtype;
+ char buf[240];
+ } mqbuf;
+ char buf[240];
+
+ j = 0;
+ strcpy(buf, "ico_test_device");
+ for (i = 1; i < argc; i++) {
+ if (argv[i][0] == '-') {
+ if (strncasecmp(argv[i], "-device=", 8) == 0) {
+ strcpy(buf, &argv[i][8]);
+ }
+ else if (strcasecmp(argv[i], "-m") == 0) {
+ mTouch = 1; /* Simulate mouse */
+ }
+ else if (strcasecmp(argv[i], "-t") == 0) {
+ mTouch = 2; /* Simulate touch-panel */
+ }
+ else if (strcmp(argv[i], "-j") == 0) {
+ mTouch = 0; /* Simulate joystick */
+ }
+ else if (strcmp(argv[i], "-J") == 0) {
+ mTouch = 3; /* Simulate joystick, but event is mouse */
+ }
+ else if (strncasecmp(argv[i], "-mq", 3) == 0) {
+ if (argv[i][3] == '=') {
+ mqkey = strtol(&argv[i][4], (char **)0, 0);
+ }
+ else {
+ mqkey = 55551; /* default message queue key */
+ }
+ }
+ else if (strcasecmp(argv[i], "-d") == 0) {
+ mDebug = 1;
+ }
+ else {
+ usage(argv[0]);
+ }
+ }
+ else {
+ j++;
+ }
+ }
+
+ init_mq(mqkey);
+
+ init_device(buf);
+
+ mRun = 1;
+
+ signal(SIGTERM, term_signal);
+ signal(SIGINT, term_signal);
+
+ if (mqid >= 0) {
+ while (mRun) {
+ memset(&mqbuf, 0, sizeof(mqbuf));
+ if (msgrcv(mqid, &mqbuf, sizeof(mqbuf)-sizeof(long), 0, 0) < 0) {
+ if (errno == EINTR) continue;
+ fprintf(stderr, "test-send_event: mq(%d) receive error[%d]\n",
+ mqkey, errno);
+ fflush(stderr);
+ break;
+ }
+ k = 0;
+ j = -1;
+ for (i = 0; mqbuf.buf[i]; i++) {
+ if ((mqbuf.buf[i] == '#') || (mqbuf.buf[i] == '\n')
+ || (mqbuf.buf[i] == '\r')) break;
+ if (mqbuf.buf[i] == '\t') buf[k++] = ' ';
+ else buf[k++] = mqbuf.buf[i];
+ if ((j < 0) && (mqbuf.buf[i] != ' ')) j = i;
+ }
+ if (j < 0) continue;
+ buf[k] = 0;
+ send_event(&buf[j]);
+ }
+ msgctl(mqid, IPC_RMID, NULL);
+ }
+ else if (j <= 0) {
+ while ((mRun != 0) && (fgets(buf, sizeof(buf), stdin) != NULL)) {
+ j = -1;
+ for (i = 0; buf[i]; i++) {
+ if ((buf[i] == '#') || (buf[i] == '\n') || (buf[i] == '\r')) break;
+ if (buf[i] == '\t') buf[i] = ' ';
+ if ((j < 0) && (buf[i] != ' ')) j = i;
+ }
+ if (j < 0) continue;
+ buf[i] = 0;
+ send_event(&buf[j]);
+ }
+ }
+ else {
+ for (i = 1; i < argc; i++) {
+ if (argv[i][0] == '-') continue;
+ if (mRun == 0) break;
+ send_event(argv[i]);
+ }
+ }
+ exit(0);
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+/**
+ * @brief System Test Tool for set VehicleInfo
+ *
+ * @date Apr-09-2013
+ */
+
+#define MSG_INTERFACE 0 /* 1= Message Queue Interface */
+#define LWS_INTERFACE 1 /* 1= WebSockets Interface */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#if LWS_INTERFACE > 0 /* WebSocket Interface */
+#include <libwebsockets.h>
+#endif /*LWS_INTERFACE*/ /* WebSocket Interface */
+
+#define TYPE_NULL 0
+#define TYPE_BOOL 1
+#define TYPE_BYTE 2
+#define TYPE_INT16 3
+#define TYPE_UINT16 4
+#define TYPE_INT32 5
+#define TYPE_UINT32 6
+#define TYPE_DOUBLE 7
+#define TYPE_STRING 8
+
+#if LWS_INTERFACE > 0 /* WebSocket Interface */
+#define LWS_DEFAULTIP "127.0.0.1" /* websockets default ip(localhost) */
+#define LWS_DEFAULTPORT 25010 /* websockets default port */
+#define LWS_PROTOCOLNAME "standarddatamessage-only"
+ /* websockets protocol name */
+#endif /*LWS_INTERFACE*/ /* WebSocket Interface */
+
+static const struct {
+ char *prop;
+ char *eventtype;
+ unsigned char datatype[4];
+} vehicleinfo_key[] = {
+ { "VehicleSpeed", "VELOCITY", {TYPE_UINT16, TYPE_NULL, 0,0} },
+ { "Speed", "VELOCITY", {TYPE_UINT16, TYPE_NULL, 0,0} },
+ { "Velocity", "VELOCITY", {TYPE_UINT16, TYPE_NULL, 0,0} },
+ { "Location", "LOCATION", {TYPE_DOUBLE, TYPE_DOUBLE, TYPE_DOUBLE, TYPE_NULL} },
+ { "Direction", "DIRECTION", {TYPE_DOUBLE, TYPE_NULL, 0,0} },
+ { "Shift", "SHIFT", {TYPE_BYTE, TYPE_BYTE, TYPE_NULL, 0} },
+ { "ShiftPosition", "SHIFT", {TYPE_BYTE, TYPE_BYTE, TYPE_NULL, 0} },
+ { "Break_Signal", "BRAKE_SIGNAL", {TYPE_BOOL, TYPE_NULL, 0,0} },
+ { "BreakSignal", "BRAKE_SIGNAL", {TYPE_BOOL, TYPE_NULL, 0,0} },
+ { "Break", "BRAKE_SIGNAL", {TYPE_BOOL, TYPE_NULL, 0,0} },
+ { "WATER_TEMP", "WATER_TEMP", {TYPE_UINT16, TYPE_INT32, TYPE_UINT16, TYPE_NULL} },
+ { "\0", "\0", {TYPE_NULL, 0,0,0} } };
+
+struct KeyDataMsg_t
+{
+#if MSG_INTERFACE > 0 /* Message Queue Interface */
+ long mtype;
+#endif /*MSG_INTERFACE*/ /* Message Queue Interface */
+ char KeyEventType[64];
+ struct timeval recordtime;
+ struct KeyData
+ {
+ int common_status;
+ char status[];
+ } data;
+};
+
+#if MSG_INTERFACE > 0 /* Message Queue Interface */
+static int sndqueuekey = 55555;
+static int sndqueueid = 0;
+
+static int mqid = -1;
+#endif /*MSG_INTERFACE*/ /* Message Queue Interface */
+
+#if LWS_INTERFACE > 0 /* WebSocket Interface */
+static struct libwebsocket_context *context = NULL;
+ /* websockets context */
+static struct libwebsocket *websocket = NULL;
+ /* websockets connection */
+static int connected = 0; /* connection flag */
+
+static int lws_callback(struct libwebsocket_context *context, struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason,
+ void *user, void *in, size_t len);
+
+static struct libwebsocket_protocols protocols[] = {
+ {LWS_PROTOCOLNAME, lws_callback, 0},
+ {NULL, NULL, -1}
+ };
+#endif /*LWS_INTERFACE*/ /* WebSocket Interface */
+
+#if MSG_INTERFACE > 0 /* Message Queue Interface */
+static void
+init_comm(const int mqkey)
+{
+ char dummy[256];
+
+ if (mqkey == 0) {
+ mqid = -1;
+ }
+ else {
+ mqid = msgget(mqkey, 0);
+ if (mqid < 0) {
+ mqid = msgget(mqkey, IPC_CREAT);
+ }
+ if (mqid < 0) {
+ fprintf(stderr, "Can not create message queue(%d(0x%x))[%d]\n",
+ mqkey, mqkey, errno);
+ return;
+ }
+ while (msgrcv(mqid, dummy, sizeof(dummy)-sizeof(long), 0, IPC_NOWAIT) > 0) ;
+ }
+}
+#endif /*MSG_INTERFACE*/ /* Message Queue Interface */
+
+#if LWS_INTERFACE > 0 /* WebSocket Interface */
+static int
+lws_callback(struct libwebsocket_context *context, struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user,
+ void *in, size_t len)
+{
+ if (reason == LWS_CALLBACK_CLIENT_ESTABLISHED) {
+ connected = 1;
+ }
+ /* do nothing */
+ return 0;
+}
+
+static void
+init_comm(const int port, const char *spadr)
+{
+ int rep;
+
+ context = libwebsocket_create_context(CONTEXT_PORT_NO_LISTEN,
+ spadr, protocols,
+ libwebsocket_internal_extensions,
+ NULL, NULL, -1, -1, 0);
+ if (context == NULL) {
+ fprintf(stderr, "Can not create libwebsockets context(ip=%s port=%d)\n",
+ spadr, port);
+ exit(2);
+ }
+
+ connected = 0;
+ websocket = libwebsocket_client_connect(context, spadr, port,
+ 0, "/", spadr, "websocket",
+ protocols[0].name, -1);
+ if (websocket == NULL) {
+ fprintf(stderr, "Can not connect libwebsockets context(ip=%s port=%d)\n",
+ spadr, port);
+ exit(2);
+ }
+ /* wait for connection */
+ for (rep = 0; rep < (2*1000); rep += 50) {
+ if (connected) break;
+ libwebsocket_service(context, 50);
+ }
+}
+#endif /*LWS_INTERFACE*/ /* WebSocket Interface */
+
+static void
+init_vehicleinfo(void)
+{
+#if MSG_INTERFACE > 0 /* Message Queue Interface */
+ sndqueueid = msgget(sndqueuekey, 0);
+ if (sndqueueid < 0) {
+ fprintf(stderr, "Send Message Queue(%d(0x%x)) dose not exist[%d].\n",
+ sndqueuekey, sndqueuekey, errno);
+ }
+#endif /*MSG_INTERFACE*/ /* Message Queue Interface */
+}
+
+static void
+set_vehicleinfo(const char *cmd)
+{
+ int i, j;
+ int idx, key, pt;
+ int msgsize;
+ char prop[64];
+ char value[128];
+ int sec, msec;
+ struct {
+ struct KeyDataMsg_t msg;
+ char dummy[128];
+ } msg;
+#if LWS_INTERFACE > 0 /* WebSocket Interface */
+ unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 512 + LWS_SEND_BUFFER_POST_PADDING];
+ unsigned char *bufpt = &buf[LWS_SEND_BUFFER_PRE_PADDING];
+#endif /*LWS_INTERFACE*/ /* WebSocket Interface */
+
+ j = 0;
+ for (i = 0; cmd[i]; i++) {
+ if ((cmd[i] == '=') || (cmd[i] == ' ')) break;
+ if (j < (int)(sizeof(prop)-1)) {
+ prop[j++] = cmd[i];
+ }
+ }
+
+ prop[j] = 0;
+ j = 0;
+ if (cmd[i] != 0) {
+ for (i++; cmd[i]; i++) {
+ if (cmd[i] == ' ') continue;
+ if (j < (int)(sizeof(value)-1)) {
+ value[j++] = cmd[i];
+ }
+ }
+ }
+ value[j] = 0;
+
+ if (strcasecmp(prop, "sleep") == 0) {
+ sec = 0;
+ msec = 0;
+ for (i = 0; value[i]; i++) {
+ if (value[i] == '.') break;
+ sec = sec * 10 + (value[i] & 0x0f);
+ }
+ if (value[i] == '.') {
+ i++;
+ if (value[i] != 0) {
+ msec = (value[i] & 0x0f) * 100;
+ i++;
+ }
+ if (value[i] != 0) {
+ msec = msec + (value[i] & 0x0f) * 10;
+ i++;
+ }
+ if (value[i] != 0) {
+ msec = msec + (value[i] & 0x0f);
+ }
+ }
+ if (sec > 0) sleep(sec);
+ if (msec > 0) usleep(msec * 1000);
+
+ return;
+ }
+
+ for (key = 0; vehicleinfo_key[key].prop[0]; key++) {
+ if (strcasecmp(prop, vehicleinfo_key[key].prop) == 0) break;
+ }
+ if (! vehicleinfo_key[key].prop[0]) {
+ fprintf(stderr, "VehicleInfo UnKnown property[%s]\n", prop);
+ return;
+ }
+
+ memset(&msg, 0, sizeof(msg));
+#if MSG_INTERFACE > 0 /* Message Queue Interface */
+ msg.msg.mtype = 1;
+#endif /*MSG_INTERFACE*/ /* Message Queue Interface */
+ strcpy(msg.msg.KeyEventType, vehicleinfo_key[key].eventtype);
+ gettimeofday(&(msg.msg.recordtime), NULL);
+#if MSG_INTERFACE > 0 /* Message Queue Interface */
+ msgsize = sizeof(msg) - 128 - sizeof(long);
+#endif /*MSG_INTERFACE*/ /* Message Queue Interface */
+#if LWS_INTERFACE > 0 /* WebSocket Interface */
+ msgsize = sizeof(msg) - 128;
+#endif /*LWS_INTERFACE*/ /* WebSocket Interface */
+
+ i = 0;
+ pt = 0;
+ for (idx = 0; idx < 4; idx++) {
+ if (vehicleinfo_key[key].datatype[idx] == TYPE_NULL) break;
+
+ if (value[i]) {
+ for (j = i; value[j]; j++) {
+ if ((value[j] == ',') || (value[j] == ';') ||
+ (value[j] == ':') || (value[j] == ' ')) break;
+ }
+ if (value[j] != 0) {
+ value[j++] = 0;
+ }
+ switch (vehicleinfo_key[key].datatype[idx]) {
+ case TYPE_BOOL:
+ case TYPE_BYTE:
+ msg.msg.data.status[pt++] = strtoul(&value[i], (char **)0, 0);
+ msgsize += 1;
+ break;
+ case TYPE_INT16:
+ case TYPE_UINT16:
+ *((short *)&msg.msg.data.status[pt]) = strtol(&value[i], (char **)0, 0);
+ pt += sizeof(short);
+ msgsize += sizeof(short);
+ break;
+ case TYPE_INT32:
+ case TYPE_UINT32:
+ *((int *)&msg.msg.data.status[pt]) = strtol(&value[i], (char **)0, 0);
+ pt += sizeof(int);
+ msgsize += sizeof(int);
+ break;
+ case TYPE_DOUBLE:
+ *((double *)&msg.msg.data.status[pt]) = strtod(&value[i], (char **)0);
+ pt += sizeof(double);
+ msgsize += sizeof(double);
+ break;
+ default:
+ break;
+ }
+ i = j;
+ }
+ else {
+ switch (vehicleinfo_key[key].datatype[idx]) {
+ case TYPE_BOOL:
+ case TYPE_BYTE:
+ msgsize += 1;
+ break;
+ case TYPE_INT16:
+ case TYPE_UINT16:
+ msgsize += sizeof(short);
+ break;
+ case TYPE_INT32:
+ case TYPE_UINT32:
+ msgsize += sizeof(int);
+ break;
+ case TYPE_DOUBLE:
+ msgsize += sizeof(double);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+#if MSG_INTERFACE > 0 /* Message Queue Interface */
+ if (msgsnd(sndqueueid, &msg, msgsize, 0) < 0) {
+ fprintf(stderr, "Message Queue(%d(0x%x)) send error[%d].\n",
+ sndqueuekey, sndqueuekey, errno);
+ }
+#endif /*MSG_INTERFACE*/ /* Message Queue Interface */
+#if LWS_INTERFACE > 0 /* WebSocket Interface */
+ memcpy(bufpt, &msg, msgsize);
+ if (libwebsocket_write(websocket, bufpt, msgsize, LWS_WRITE_BINARY) < 0) {
+ fprintf(stderr, "libwebsockets send error\n"); fflush(stderr);
+ }
+#endif /*LWS_INTERFACE*/ /* WebSocket Interface */
+}
+
+static void
+usage(const char *prog)
+{
+#if LWS_INTERFACE > 0 /* WebSocket Interface */
+ fprintf(stderr, "Usage: %s [-port=port] [-ip=ip_addr] [propaty=value] [propaty=value] ...\n", prog);
+#endif /*LWS_INTERFACE*/ /* WebSocket Interface */
+#if MSG_INTERFACE > 0 /* Message Queue Interface */
+ fprintf(stderr, "Usage: %s [-ambkey=key] [-mq[=key]] [propaty=value] [propaty=value] ...\n", prog);
+#endif /*MSG_INTERFACE*/ /* Message Queue Interface */
+ exit(0);
+}
+
+int
+main(int argc, char *argv[])
+{
+ int i, j;
+#if LWS_INTERFACE > 0 /* WebSocket Interface */
+ int port = LWS_DEFAULTPORT;
+ char spadr[64];
+#endif /*LWS_INTERFACE*/ /* WebSocket Interface */
+#if MSG_INTERFACE > 0 /* Message Queue Interface */
+ int mqkey = 0;
+ struct {
+ long mtype;
+ char buf[240];
+ } mqbuf;
+#endif /*MSG_INTERFACE*/ /* Message Queue Interface */
+ char buf[240];
+
+#if LWS_INTERFACE > 0 /* WebSocket Interface */
+ strcpy(spadr, LWS_DEFAULTIP);
+#endif /*LWS_INTERFACE*/ /* WebSocket Interface */
+
+ j = 0;
+ for (i = 1; i < argc; i++) {
+ if (argv[i][0] == '-') {
+#if MSG_INTERFACE > 0 /* Message Queue Interface */
+ if (strncasecmp(argv[i], "-ambkey=", 8) == 0) {
+ sndqueuekey = strtoul(&argv[i][8], (char **)0, 0);
+ }
+ else if (strncasecmp(argv[i], "-mq", 3) == 0) {
+ if (argv[i][3] == '=') {
+ mqkey = strtol(&argv[i][4], (char **)0, 0);
+ }
+ else {
+ mqkey = 55552; /* default message queue key */
+ }
+ }
+#endif /*MSG_INTERFACE*/ /* Message Queue Interface */
+#if LWS_INTERFACE > 0 /* WebSocket Interface */
+ if (strncasecmp(argv[i], "-port=", 6) == 0) {
+ port = strtoul(&argv[i][6], (char **)0, 0);
+ }
+ else if (strncasecmp(argv[i], "-ip=", 4) == 0) {
+ memset(spadr, 0, sizeof(spadr));
+ strncpy(spadr, &argv[i][4], sizeof(spadr)-1);
+ }
+#endif /*LWS_INTERFACE*/ /* WebSocket Interface */
+ else {
+ usage(argv[0]);
+ }
+ }
+ else {
+ j++;
+ }
+ }
+
+#if MSG_INTERFACE > 0 /* Message Queue Interface */
+ init_comm(mqkey);
+#endif /*MSG_INTERFACE*/ /* Message Queue Interface */
+#if LWS_INTERFACE > 0 /* WebSocket Interface */
+ init_comm(port, spadr);
+#endif /*LWS_INTERFACE*/ /* WebSocket Interface */
+
+ init_vehicleinfo();
+
+#if MSG_INTERFACE > 0 /* Message Queue Interface */
+ if (mqid >= 0) {
+ while (1) {
+ memset(&mqbuf, 0, sizeof(mqbuf));
+ if (msgrcv(mqid, &mqbuf, sizeof(mqbuf)-sizeof(long), 0, 0) < 0) break;
+ k = 0;
+ j = -1;
+ for (i = 0; mqbuf.buf[i]; i++) {
+ if ((mqbuf.buf[i] == '#') || (mqbuf.buf[i] == '\n')
+ || (mqbuf.buf[i] == '\r')) break;
+ if (mqbuf.buf[i] == '\t') buf[k++] = ' ';
+ else buf[k++] = mqbuf.buf[i];
+ if ((j < 0) && (mqbuf.buf[i] != ' ')) j = i;
+ }
+ if (j < 0) continue;
+ buf[k] = 0;
+ set_vehicleinfo(&buf[j]);
+ }
+ msgctl(mqid, IPC_RMID, NULL);
+ }
+ else
+#endif /*MSG_INTERFACE*/ /* Message Queue Interface */
+ if (j <= 0) {
+ while (fgets(buf, sizeof(buf), stdin)) {
+ j = -1;
+ for (i = 0; buf[i]; i++) {
+ if ((buf[i] == '#') || (buf[i] == '\n') || (buf[i] == '\r')) break;
+ if (buf[i] == '\t') buf[i] = ' ';
+ if ((j < 0) && (buf[i] != ' ')) j = i;
+ }
+ if (j < 0) continue;
+ buf[i] = 0;
+ set_vehicleinfo(&buf[j]);
+ }
+ }
+ else {
+ for (i = 1; i < argc; i++) {
+ if (argv[i][0] == '-') continue;
+ set_vehicleinfo(argv[i]);
+ }
+ }
+#if LWS_INTERFACE > 0 /* WebSocket Interface */
+ if (context) {
+ libwebsocket_context_destroy(context);
+ }
+#endif /*LWS_INTERFACE*/ /* WebSocket Interface */
+
+ exit(0);
+}
+
--- /dev/null
+{
+ "application": [
+ {
+ "program": {
+ "id":"org.tizen.music-player",
+ "execute":"org.tizen.music-player"
+ },
+ "window": [
+ {
+ "resize":"0,100,100",
+ "move":"0,0,64",
+ "visible_raise":"0,1,1"
+ }
+ ]
+ }
+ ]
+}
--- /dev/null
+{
+ "application": [
+ {
+ "program": {
+ "id":"org.tizen.music-player"
+ },
+ "window": [
+ {
+ "resize":"0,200,200",
+ "move":"0,100,164",
+ "visible_raise":"0,1,1"
+ }
+ ]
+ }
+ ]
+}
--- /dev/null
+{
+ "application": [
+ {
+ "program": {
+ "id":"org.tizen.music-player"
+ },
+ "window": [
+ {
+ "resize":"0,400,400",
+ "move":"0,200,264",
+ "visible_raise":"0,1,1"
+ }
+ ]
+ }
+ ]
+}
--- /dev/null
+{
+ "application": [
+ {
+ "program": {
+ "id":"org.tizen.music-player"
+ },
+ "window": [
+ {
+ "resize":"0,800,800",
+ "move":"0,300,364",
+ "visible_raise":"0,1,1"
+ }
+ ]
+ }
+ ]
+}
--- /dev/null
+{
+ "application": [
+ {
+ "program": {
+ "id":"TOUCH_SCREEN"
+ },
+ "window": [
+ {
+ "hide":"0"
+ }
+ ]
+ }
+ ]
+}
--- /dev/null
+{
+ "application": [
+ {
+ "program": {
+ "id":"org.tizen.music-player"
+ },
+ "window": [
+ {
+ "resize":"0,100,100",
+ "move":"0,0,64",
+ "visible_raise":"0,1,1"
+ }
+ ]
+ }
+ ]
+}
--- /dev/null
+{
+ "application": [
+ {
+ "program": {
+ "id":"TOUCH_SCREEN"
+ },
+ "window": [
+ {
+ "show":"0"
+ }
+ ]
+ }
+ ]
+}
--- /dev/null
+{
+ "application": [
+ {
+ "program": {
+ "id":"org.tizen.music-player",
+ "terminate":"org.tizen.music-player"
+ },
+ "window": [
+ {
+ "resize":"0,100,100",
+ "move":"0,0,64",
+ "visible_raise":"0,1,1"
+ }
+ ]
+ }
+ ]
+}
--- /dev/null
+XY=669,900
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
--- /dev/null
+#wait for starting weston
+sleep 5
+
+#Change button pushed at tile screen
+XY=960,30
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Change button pushed at application screen
+XY=960,30
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Application is selected
+XY=1466,242
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Hide shown application
+XY=960,30
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Holiding down a application tile
+XY=1466,242
+sleep 0.1
+Button=Down
+sleep 3
+Button=Up
+sleep 2
+
+#Cancel selected on confirmation screen
+XY=994,784
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#OK selected on confirmation screen
+XY=1466,242
+sleep 0.1
+Button=Down
+sleep 3
+Button=Up
+sleep 2
+XY=669,784
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Application list button is pushed
+XY=1615,898
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Next selected on applicaton list
+XY=669,900
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Cancel selected on applicaton list
+XY=994,900
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#application icon selected on applicaton list
+XY=1615,898
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+
--- /dev/null
+XY=221,774
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
--- /dev/null
+#wait for starting weston
+sleep 5
+
+#Change button pushed at tile screen
+XY=384,30
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Change button pushed at application screen
+XY=384,30
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Application is selected
+XY=666,168
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Hide shown application
+XY=384,30
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Holiding down a application tile
+XY=666,168
+sleep 0.1
+Button=Down
+sleep 3
+Button=Up
+sleep 2
+
+#Cancel selected on confirmation screen
+XY=546,628
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#OK selected on confirmation screen
+XY=666,168
+sleep 0.1
+Button=Down
+sleep 3
+Button=Up
+sleep 2
+XY=221,628
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Application list button is pushed
+XY=666,920
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Next selected on applicaton list
+XY=221,744
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Cancel selected on applicaton list
+XY=546,744
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#application icon selected on applicaton list
+XY=666,920
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+
--- /dev/null
+XY=COORD_X,COORD_Y
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
--- /dev/null
+#wait for starting weston
+sleep 5
+
+#Change button pushed at tile screen
+XY=960,30
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Change button pushed at application screen
+XY=960,30
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Application is selected
+XY=1466,242
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Hide shown application
+XY=960,30
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Holiding down a application tile
+XY=1466,242
+sleep 0.1
+Button=Down
+sleep 3
+Button=Up
+sleep 2
+
+#Cancel selected on confirmation screen
+XY=994,784
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#OK selected on confirmation screen
+XY=1466,242
+sleep 0.1
+Button=Down
+sleep 3
+Button=Up
+sleep 2
+XY=669,784
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Application list button is pushed
+XY=1615,898
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Next selected on applicaton list
+XY=669,900
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#Cancel selected on applicaton list
+XY=994,900
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+#application icon selected on applicaton list
+XY=1615,898
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2
+
+
+XY=1410,822
+sleep 0.1
+Button=Down
+sleep 0.1
+Button=Up
+sleep 2