2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 * @brief user experiance library(read configuration file in all system)
17 #include <sys/types.h>
25 #include "ico_apf_log.h"
26 #include "ico_apf_apimacro.h"
27 #include "ico_uxf_conf_common.h"
29 static Ico_Uxf_Sys_Config *reloadSysConfig(void);
31 static Ico_Uxf_Sys_Config *_ico_sys_config = NULL;
34 /*--------------------------------------------------------------------------*/
36 * @brief ico_uxf_getSysConfig: get system configurations
39 * @return system configuration table
40 * @retval != NULL success(system configuration table address)
41 * @retval == NULL error(can not read configuration file)
43 /*--------------------------------------------------------------------------*/
44 ICO_APF_API const Ico_Uxf_Sys_Config *
45 ico_uxf_getSysConfig(void)
47 if (_ico_sys_config) {
48 return _ico_sys_config;
50 _ico_sys_config = g_new0(Ico_Uxf_Sys_Config,1);
51 return reloadSysConfig();
54 /*--------------------------------------------------------------------------*/
56 * @brief ico_uxf_ifGetSysConfig: get system configurations
59 * @return system configuration table
60 * @retval != NULL success(system configuration table address)
61 * @retval == NULL error(the configuration file is not yet read)
63 /*--------------------------------------------------------------------------*/
64 ICO_APF_API const Ico_Uxf_Sys_Config *
65 ico_uxf_ifGetSysConfig(void)
67 return _ico_sys_config;
70 /*--------------------------------------------------------------------------*/
72 * @brief pars_dispposition: calculate an expression about display size(static function)
74 * @param[in] exp expression
75 * @param[in] display display configuration table
76 * @return calculation result
78 /*--------------------------------------------------------------------------*/
80 pars_dispposition(const char *exp, Ico_Uxf_conf_display *display)
90 if (exp[i] == ' ') continue;
91 if ((exp[i] == 0) || (exp[i] == '+') || (exp[i] == '-') ||
92 (exp[i] == '*') || (exp[i] == '-') || (exp[i] == '/')) {
95 if ((strcasecmp(word, "dispw") == 0) ||
96 (strcasecmp(word, "width") == 0)) {
97 wval = display->width;
99 else if ((strcasecmp(word, "disph") == 0) ||
100 (strcasecmp(word, "heigh") == 0)) {
101 wval = display->height;
104 wval = strtol(word, (char **)0, 0);
130 if (exp[i] == '+') sign = 1;
131 else if (exp[i] == '-') sign = 2;
132 else if (exp[i] == '*') sign = 3;
133 else if (exp[i] == '/') sign = 4;
137 if ((sign > 0) && (exp[i] == '-')) {
141 if (exp[i] == '+') sign = 1;
142 else if (exp[i] == '-') sign = 2;
143 else if (exp[i] == '*') sign = 3;
144 else if (exp[i] == '/') sign = 4;
148 if (exp[i] == 0) break;
151 if (j < ((int)sizeof(word)-1)) {
159 /*--------------------------------------------------------------------------*/
161 * @brief reloadSysConfig: load system configuration file(static function)
164 * @return system configuration table
165 * @retval != NULL success(system configuration table address)
166 * @retval == NULL error(can not read configuration file)
168 /*--------------------------------------------------------------------------*/
169 static Ico_Uxf_Sys_Config *
170 reloadSysConfig(void)
174 GError *error = NULL;
182 apfw_trace("reloadSysConfig: Enter");
184 /* decide top directory in all configurations */
185 dirp = getenv(ICO_UXF_TOP_ENV);
187 dirp = ICO_UXF_TOP_TOPDIR;
189 strncpy(_ico_sys_config->misc.topdir, dirp, ICO_UXF_CONF_DIR_MAX);
191 /* decide top directory in configuration file's */
192 dirp = getenv(ICO_UXF_CONFIG_ENV);
194 strncpy(_ico_sys_config->misc.confdir, dirp, ICO_UXF_CONF_DIR_MAX);
197 snprintf(_ico_sys_config->misc.confdir, ICO_UXF_CONF_DIR_MAX,
198 "%s/%s", _ico_sys_config->misc.topdir, ICO_UXF_CONFIG_DIR);
199 dirp = _ico_sys_config->misc.confdir;
202 /* A system-wide definition */
203 keyfile = g_key_file_new();
204 flags = G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS;
206 GString* filepath = g_string_new("xx");
207 g_string_printf(filepath, "%s/%s", dirp, ICO_UXF_CONFIG_SYSTEM);
209 if (!g_key_file_load_from_file(keyfile, filepath->str, flags, &error)) {
210 fprintf(stderr, "%s: %s\n", (char *)filepath->str, error->message);
211 g_string_free(filepath, TRUE);
214 g_string_free(filepath, TRUE);
217 _ico_sys_config->misc.loglevel
218 = g_key_file_get_integer(keyfile, "log", "loglevel", &error);
219 ico_uxf_conf_checkGerror(&error);
220 _ico_sys_config->misc.logflush =
221 ico_uxf_getSysBoolByName(g_key_file_get_string(keyfile, "log", "logflush", &error));
222 ico_uxf_conf_checkGerror(&error);
225 if (getenv("ICO_IVI_NO_LOG")) {
226 ico_uxf_log_setlevel(0);
229 ico_uxf_log_setlevel(_ico_sys_config->misc.loglevel |
230 ((_ico_sys_config->misc.logflush) ?
231 ICO_APF_LOG_FLUSH : ICO_APF_LOG_NOFLUSH));
234 /* [category] application category name and attributes */
235 idlist = ico_uxf_conf_countNumericalKey(keyfile, "category");
236 length = g_list_length(idlist);
237 _ico_sys_config->categoryNum = length;
238 _ico_sys_config->category = g_malloc0(sizeof(Ico_Uxf_conf_category) * length);
240 for (i = 0; i < (int)length; i++) {
241 const char* key = (const char*) g_list_nth_data(idlist, i);
242 const char* g = "category";
243 _ico_sys_config->category[i].id = ico_uxf_conf_getUint(key);
244 ico_uxf_conf_checkGerror(&error);
245 _ico_sys_config->category[i].name = g_key_file_get_string(keyfile, g, key, &error);
246 ico_uxf_conf_checkGerror(&error);
248 strp = (char *)g_key_file_get_string(keyfile, g,
249 ico_uxf_conf_appendStr(key, ".view"), &error);
250 ico_uxf_conf_checkGerror(&error);
251 if (strncasecmp(strp, "alway", 5) == 0) {
252 _ico_sys_config->category[i].view = ICO_UXF_POLICY_ALWAYS;
254 else if (strncasecmp(strp, "run", 3) == 0) {
255 _ico_sys_config->category[i].view = ICO_UXF_POLICY_RUNNING;
257 else if (strncasecmp(strp, "park", 4) == 0) {
258 _ico_sys_config->category[i].view = ICO_UXF_POLICY_PARKED;
260 else if (strncasecmp(strp, "shift_park", 10) == 0) {
261 _ico_sys_config->category[i].view = ICO_UXF_POLICY_SHIFT_PARKING;
263 else if ((strncasecmp(strp, "shift_back", 10) == 0) ||
264 (strncasecmp(strp, "shift_rev", 9) == 0)) {
265 _ico_sys_config->category[i].view = ICO_UXF_POLICY_SHIFT_REVERSES;
267 else if (strcasecmp(strp, "blinker_left") == 0) {
268 _ico_sys_config->category[i].view = ICO_UXF_POLICY_BLINKER_LEFT;
270 else if (strcasecmp(strp, "blinker_right") == 0) {
271 _ico_sys_config->category[i].view = ICO_UXF_POLICY_BLINKER_RIGHT;
274 fprintf(stderr, "[%s.view: %s] Unknown view mode\n", key, strp);
275 g_list_free_full(idlist,g_free);
276 g_key_file_free(keyfile);
280 strp = (char *)g_key_file_get_string(keyfile, g,
281 ico_uxf_conf_appendStr(key, ".sound"), &error);
282 ico_uxf_conf_checkGerror(&error);
283 if (strncasecmp(strp, "alway", 5) == 0) {
284 _ico_sys_config->category[i].sound = ICO_UXF_POLICY_ALWAYS;
286 else if (strncasecmp(strp, "run", 3) == 0) {
287 _ico_sys_config->category[i].sound = ICO_UXF_POLICY_RUNNING;
289 else if (strncasecmp(strp, "park", 4) == 0) {
290 _ico_sys_config->category[i].sound = ICO_UXF_POLICY_PARKED;
292 else if (strncasecmp(strp, "shift_park", 10) == 0) {
293 _ico_sys_config->category[i].sound = ICO_UXF_POLICY_SHIFT_PARKING;
295 else if ((strncasecmp(strp, "shift_back", 10) == 0) ||
296 (strncasecmp(strp, "shift_rev", 9) == 0)) {
297 _ico_sys_config->category[i].sound = ICO_UXF_POLICY_SHIFT_REVERSES;
299 else if (strcasecmp(strp, "blinker_left") == 0) {
300 _ico_sys_config->category[i].sound = ICO_UXF_POLICY_BLINKER_LEFT;
302 else if (strcasecmp(strp, "blinker_right") == 0) {
303 _ico_sys_config->category[i].sound = ICO_UXF_POLICY_BLINKER_RIGHT;
306 fprintf(stderr, "[%s.view: %s] Unknown sound mode\n", key, strp);
307 g_list_free_full(idlist,g_free);
308 g_key_file_free(keyfile);
312 strp = (char *)g_key_file_get_string(keyfile, g,
313 ico_uxf_conf_appendStr(key, ".input"), &error);
314 ico_uxf_conf_checkGerror(&error);
315 if (strncasecmp(strp, "alway", 5) == 0) {
316 _ico_sys_config->category[i].input = ICO_UXF_POLICY_ALWAYS;
318 else if (strncasecmp(strp, "run", 3) == 0) {
319 _ico_sys_config->category[i].input = ICO_UXF_POLICY_RUNNING;
321 else if (strncasecmp(strp, "park", 4) == 0) {
322 _ico_sys_config->category[i].input = ICO_UXF_POLICY_PARKED;
324 else if (strncasecmp(strp, "shift_park", 10) == 0) {
325 _ico_sys_config->category[i].input = ICO_UXF_POLICY_SHIFT_PARKING;
327 else if ((strncasecmp(strp, "shift_back", 10) == 0) ||
328 (strncasecmp(strp, "shift_rev", 9) == 0)) {
329 _ico_sys_config->category[i].input = ICO_UXF_POLICY_SHIFT_REVERSES;
331 else if (strcasecmp(strp, "blinker_left") == 0) {
332 _ico_sys_config->category[i].input = ICO_UXF_POLICY_BLINKER_LEFT;
334 else if (strcasecmp(strp, "blinker_right") == 0) {
335 _ico_sys_config->category[i].input = ICO_UXF_POLICY_BLINKER_RIGHT;
338 fprintf(stderr, "[%s.view: %s] Unknown input mode\n", key, strp);
339 g_list_free_full(idlist,g_free);
340 g_key_file_free(keyfile);
343 _ico_sys_config->category[i].priority =
344 g_key_file_get_integer(keyfile, g,
345 ico_uxf_conf_appendStr(key,".priority"), &error);
346 ico_uxf_conf_checkGerror(&error);
348 apfw_trace("Categry.%d id=%d name=%s view=%d sound=%d input=%d prio=%d",
349 i, _ico_sys_config->category[i].id, _ico_sys_config->category[i].name,
350 _ico_sys_config->category[i].view, _ico_sys_config->category[i].sound,
351 _ico_sys_config->category[i].input,
352 _ico_sys_config->category[i].priority);
354 g_list_free_full(idlist,g_free);
356 /* [kind] application kind name and attributes */
357 idlist = ico_uxf_conf_countNumericalKey(keyfile, "kind");
358 length = g_list_length(idlist);
359 _ico_sys_config->kindNum = length;
360 _ico_sys_config->kind = g_malloc0(sizeof(Ico_Uxf_conf_kind) * length);
362 for (i = 0; i < (int)length; i++) {
363 const char* key = (const char*) g_list_nth_data(idlist, i);
364 const char* g = "kind";
365 _ico_sys_config->kind[i].id = ico_uxf_conf_getUint(key);
366 ico_uxf_conf_checkGerror(&error);
367 _ico_sys_config->kind[i].name = g_key_file_get_string(keyfile, g, key, &error);
368 ico_uxf_conf_checkGerror(&error);
369 strp = (char *)g_key_file_get_string(
370 keyfile, g, ico_uxf_conf_appendStr(key, ".privilege"), &error);
371 ico_uxf_conf_checkGerror(&error);
372 if (strcasecmp(strp, "almighty") == 0) {
373 _ico_sys_config->kind[i].priv = ICO_UXF_PRIVILEGE_ALMIGHTY;
375 else if (strcasecmp(strp, "system") == 0) {
376 _ico_sys_config->kind[i].priv = ICO_UXF_PRIVILEGE_SYSTEM;
378 else if (strcasecmp(strp, "system.audio") == 0) {
379 _ico_sys_config->kind[i].priv = ICO_UXF_PRIVILEGE_SYSTEM_AUDIO;
381 else if (strcasecmp(strp, "system.visible") == 0) {
382 _ico_sys_config->kind[i].priv = ICO_UXF_PRIVILEGE_SYSTEM_VISIBLE;
384 else if (strcasecmp(strp, "maker") == 0) {
385 _ico_sys_config->kind[i].priv = ICO_UXF_PRIVILEGE_MAKER;
387 else if (strcasecmp(strp, "certificate") == 0) {
388 _ico_sys_config->kind[i].priv = ICO_UXF_PRIVILEGE_CERTIFICATE;
390 else if (strcasecmp(strp, "none") == 0) {
391 _ico_sys_config->kind[i].priv = ICO_UXF_PRIVILEGE_NONE;
394 fprintf(stderr, "[%s.view: %s] Unknown privilege mode\n", key, strp);
395 g_list_free_full(idlist,g_free);
396 g_key_file_free(keyfile);
399 apfw_trace("Kind.%d id=%d name=%s privilege=%d",
400 i, _ico_sys_config->kind[i].id, _ico_sys_config->kind[i].name,
401 _ico_sys_config->kind[i].priv);
403 g_list_free_full(idlist,g_free);
405 /* [port] port numbers */
406 _ico_sys_config->misc.appscontrollerport
407 = g_key_file_get_integer(keyfile, "port", "appscontrollerport", &error);
408 ico_uxf_conf_checkGerror(&error);
409 _ico_sys_config->misc.soundpluginport
410 = g_key_file_get_integer(keyfile, "port", "soundpluginport", &error);
411 ico_uxf_conf_checkGerror(&error);
412 if (_ico_sys_config->misc.appscontrollerport <= 0)
413 _ico_sys_config->misc.appscontrollerport = 18081;
414 if (_ico_sys_config->misc.soundpluginport <= 0)
415 _ico_sys_config->misc.soundpluginport = 18082;
418 idlist = ico_uxf_conf_countNumericalKey(keyfile, "host");
419 length = g_list_length(idlist);
420 _ico_sys_config->hostNum = length;
421 _ico_sys_config->host = g_malloc0(sizeof(Ico_Uxf_conf_host) * length);
423 for (i = 0; i < (int)length; i++) {
424 char* key = (char*) g_list_nth_data(idlist, i);
425 const char* g = "host";
426 _ico_sys_config->host[i].id = ico_uxf_conf_getUint(key);
427 _ico_sys_config->host[i].name = g_key_file_get_string(keyfile, g, key, &error);
428 ico_uxf_conf_checkGerror(&error);
430 _ico_sys_config->host[i].address
431 = g_key_file_get_string(keyfile, g, ico_uxf_conf_appendStr(key, ".ip"), &error);
432 ico_uxf_conf_checkGerror(&error);
433 if (g_hostname_is_ip_address(_ico_sys_config->host[i].address)!= TRUE){
434 apfw_error("host[%d] = %s is not ip address style",
435 _ico_sys_config->host[i].id, _ico_sys_config->host[i].address);
439 _ico_sys_config->host[i].type =
440 ico_uxf_getSysHostTypeByName(
441 g_key_file_get_string(keyfile, g,
442 ico_uxf_conf_appendStr(key, ".type"), &error));
443 ico_uxf_conf_checkGerror(&error);
445 _ico_sys_config->host[i].homescreen =
446 g_key_file_get_string(keyfile, g,
447 ico_uxf_conf_appendStr(key, ".homescreen"), &error);
448 ico_uxf_conf_checkGerror(&error);
449 apfw_trace("Host.%d: Id=%d Name=%s Type=%d Ip=%s HomeScreen=%s",
450 i, _ico_sys_config->host[i].id, (char *)_ico_sys_config->host[i].name,
451 _ico_sys_config->host[i].type, (char *)_ico_sys_config->host[i].address,
452 _ico_sys_config->host[i].homescreen);
454 g_list_free_full(idlist,g_free);
457 const char *penv = getenv(ICO_UXF_ENV_APPINF);
459 int dmy1, dmy2, dmy3;
462 if (sscanf(penv, "%d %d %d %s %d", &dmy1, &dmy2, &dmy3, cdmy4, &hostid) < 5) {
465 apfw_trace("reloadSysConfig: Env(%s) = %s, hostId = %d",
466 ICO_UXF_ENV_APPINF, penv, hostid);
470 if ((gethostname(cdmy4, sizeof(cdmy4)-1) >= 0) &&
471 (strncmp(cdmy4, "localhost", 9) != 0)) {
472 apfw_trace("hostname = %s", cdmy4);
473 for (j = 0; cdmy4[j]; j++) {
474 if ((cdmy4[j] == ' ') || (cdmy4[j] == '(') ||
475 (cdmy4[j] == '@') || (cdmy4[j] == ':')) {
480 for (j = 0; j < _ico_sys_config->hostNum; j++) {
481 if (strcasecmp(_ico_sys_config->host[j].name, cdmy4) == 0) {
482 hostid = _ico_sys_config->host[j].id;
490 FILE *fp = popen("/sbin/ifconfig", "r");
495 while (fgets(sBuf, sizeof(sBuf)-1, fp)) {
496 if ((! foundeth) || (sBuf[0] != ' ')) {
498 /* skip to "eth" device */
499 if (sBuf[0] == ' ' || sBuf[0] == '\t') continue;
500 if (strncmp(sBuf, "eth", 3) != 0) continue;
504 for (j = 0; sBuf[j]; j++) {
505 if (strncmp(&sBuf[j], "inet6", 5) == 0) continue;
506 if (strncmp(&sBuf[j], "inet", 4) == 0) break;
509 /* forget "inet" device */
511 for (; sBuf[j]; j++) {
512 if (sBuf[j] == ':') break;
517 for (k = j +1; sBuf[k]; k++) {
518 if (sBuf[k] == ' ' || sBuf[k] == '\t' ||
519 sBuf[k] == '\n' || sBuf[k] == '\r') {
524 apfw_trace("My Inet Addr = %s", &sBuf[j]);
525 for (k = 0; k < _ico_sys_config->hostNum; k++) {
526 if (strcmp(_ico_sys_config->host[k].address, &sBuf[j]) == 0) {
527 hostid = _ico_sys_config->host[k].id;
533 if (hostid >= 0) break;
539 _ico_sys_config->misc.myhostId = hostid;
542 apfw_trace("Default Host = 0, %s", ico_uxf_get_SysLocation(0));
543 _ico_sys_config->misc.myhostId = _ico_sys_config->host[0].id;
546 /* The validity of MyHost is checked. */
547 Ico_Uxf_conf_host *myhost = (Ico_Uxf_conf_host *)
548 ico_uxf_getSysHostById(_ico_sys_config->misc.myhostId);
550 apfw_critical("MyHostId.%d dose not exist, default 0",
551 _ico_sys_config->misc.myhostId);
552 myhost = &_ico_sys_config->host[0];
554 apfw_error("HostId.0 dose not exist, GiveUp!");
557 _ico_sys_config->misc.myhostId = myhost->id;
560 _ico_sys_config->misc.myaddress =
561 (char *)ico_uxf_get_SysLocation(_ico_sys_config->misc.myhostId);
562 _ico_sys_config->misc.myhostName = myhost->name;
564 _ico_sys_config->misc.homescreen = myhost->homescreen;
566 if (myhost->homescreen) {
567 _ico_sys_config->misc.masterhostId = myhost->id;
570 _ico_sys_config->misc.masterhostId = _ico_sys_config->misc.myhostId;
572 for (i = 0; i < _ico_sys_config->hostNum; i++) {
573 if (_ico_sys_config->host[i].homescreen) {
574 _ico_sys_config->misc.masterhostId = _ico_sys_config->host[i].id;
579 _ico_sys_config->misc.masterhostaddress =
580 (char *)ico_uxf_get_SysLocation(_ico_sys_config->misc.masterhostId);
582 apfw_trace("MyHost %d[%s] Master Host %d(%s)", _ico_sys_config->misc.myhostId,
583 _ico_sys_config->misc.myaddress, _ico_sys_config->misc.masterhostId,
584 _ico_sys_config->misc.masterhostaddress);
586 _ico_sys_config->misc.default_hostId = ico_uxf_getSysHostByName(
587 g_key_file_get_string(keyfile, "default", "host", &error));
588 ico_uxf_conf_checkGerror(&error);
591 idlist = ico_uxf_conf_countNumericalKey(keyfile, "display");
592 length = g_list_length(idlist);
593 _ico_sys_config->displayNum = length;
594 _ico_sys_config->display = g_malloc0(sizeof(Ico_Uxf_conf_display) * length);
597 for (i = 0; i < (int)length; i++) {
598 const char* key = (const char*) g_list_nth_data(idlist, i);
599 const char* g = "display";
600 Ico_Uxf_conf_display *display = &_ico_sys_config->display[i];
601 display->id = ico_uxf_conf_getUint(key);
602 ico_uxf_conf_checkGerror(&error);
603 display->name = g_key_file_get_string(keyfile, g, key, &error);
604 ico_uxf_conf_checkGerror(&error);
607 ico_uxf_getSysHostByName(
608 g_key_file_get_string(keyfile, g,
609 ico_uxf_conf_appendStr(key,".host"), &error));
610 ico_uxf_conf_checkGerror(&error);
612 g_key_file_get_integer(keyfile, g,
613 ico_uxf_conf_appendStr(key,".displayno"), &error);
615 display->displayno = -1;
616 g_clear_error(&error);
619 g_key_file_get_string(keyfile, g,
620 ico_uxf_conf_appendStr(key,".wayland"), &error);
621 ico_uxf_conf_checkGerror(&error);
624 ico_uxf_getSysDispTypeByName(g_key_file_get_string(keyfile, g,
625 ico_uxf_conf_appendStr(key,".type"), &error));
626 ico_uxf_conf_checkGerror(&error);
629 g_key_file_get_integer(keyfile, g, ico_uxf_conf_appendStr(key,".width"), &error);
630 ico_uxf_conf_checkGerror(&error);
632 g_key_file_get_integer(keyfile, g, ico_uxf_conf_appendStr(key,".height"), &error);
633 ico_uxf_conf_checkGerror(&error);
635 g_key_file_get_integer(keyfile, g, ico_uxf_conf_appendStr(key,".layer"), &error);
636 ico_uxf_conf_checkGerror(&error);
640 g_key_file_get_integer(keyfile,g,ico_uxf_conf_appendStr(key,".inch"),&error);
641 ico_uxf_conf_checkGerror(&error);
643 apfw_trace("Display.%d Id=%d Name=%s Host=%d DispNo=%d W/H=%d/%d Wayland=%s inch=%d",
644 i, display->id, (char *)display->name, display->hostId,
645 display->displayno, display->width, display->height,
646 display->wayland, display->inch);
649 int displayer_length;
652 GString* layer_key = g_string_new("");
653 for (displayer_length = 0;
654 displayer_length < ICO_UXF_DISPLAY_LAYER_MAX; displayer_length++) {
655 g_string_printf(layer_key,"%s.layer.%d",key,displayer_length);
656 if (g_key_file_has_key(keyfile,g,layer_key->str,NULL) != TRUE) break;
658 apfw_trace("Display.%d layerNum = %d" ,i, displayer_length);
659 display->layerNum = displayer_length;
660 display->layer = g_malloc0(sizeof(Ico_Uxf_conf_display_layer)*displayer_length);
662 for (j = 0; j < displayer_length; j++) {
663 g_string_printf(layer_key,"%s.layer.%d",key,j);
664 display->layer[j].id = j;
665 layerlist = g_key_file_get_string_list(keyfile, g, layer_key->str,
667 ico_uxf_conf_checkGerror(&error);
668 if (layersize <= 0) {
669 apfw_error("Display.%d Layer.%d has no name", i, j);
672 display->layer[j].name = strdup((char *)layerlist[0]);
673 for (k = 1; k < (int)layersize; k++) {
674 if (strcasecmp((char *)layerlist[k], "menuoverlap") == 0) {
675 display->layer[j].menuoverlap = 1;
678 apfw_trace("Display.%d Layer.%d id=%d name=%s overlap=%d", i, j,
679 display->layer[j].id, display->layer[j].name,
680 display->layer[j].menuoverlap);
682 if (layerlist) g_strfreev(layerlist);
684 g_string_free(layer_key,TRUE);
688 GString* zone_key = g_string_new("");
689 for (dispzone_length = 0;
690 dispzone_length < ICO_UXF_DISPLAY_ZONE_MAX; dispzone_length++) {
691 g_string_printf(zone_key,"%s.zone.%d",key,dispzone_length);
692 if (g_key_file_has_key(keyfile,g,zone_key->str,NULL) != TRUE) break;
694 apfw_trace("Display.%d zoneNum = %d" ,i, dispzone_length);
695 display->zoneNum = dispzone_length;
696 display->zone = g_malloc0(sizeof(Ico_Uxf_conf_display_zone)*dispzone_length);
698 gsize zonesizes[ICO_UXF_DISPLAY_ZONE_MAX];
699 gchar **zonelists[ICO_UXF_DISPLAY_ZONE_MAX];
701 Ico_Uxf_conf_display_zone *zone;
703 for (j = 0; j < dispzone_length; j++) {
704 g_string_printf(zone_key,"%s.zone.%d",key,j);
705 zonelists[j] = g_key_file_get_string_list(
706 keyfile, g, zone_key->str, &zonesizes[j], &error);
707 ico_uxf_conf_checkGerror(&error);
708 if ((! zonelists[j]) || (zonesizes[j] <= 0)) {
709 apfw_error("reloadSysConfig: display.%d zone.%d dose not exist",i,j);
713 for (j = 0; j < dispzone_length; j++) {
714 zone = &(display->zone[j]);
716 zone->zoneidx = zoneidx++;
717 zone->display = display;
718 zone->node = ICO_UXF_NODEDISP_2_NODEID(display->hostId, display->displayno);
720 if (zonesizes[j] <= 0) continue;
722 zonelist = zonelists[j];
723 zone->name = strdup((char*)zonelist[0]);
724 if (zonesizes[j] < 5) {
725 /* default zone is full screen */
728 zone->width = display->width;
729 zone->height = display->height;
732 zone->x = pars_dispposition((char *)zonelist[1], display);
733 zone->y = pars_dispposition((char *)zonelist[2], display);
734 zone->width = pars_dispposition((char *)zonelist[3], display);
735 zone->height = pars_dispposition((char *)zonelist[4], display);
738 for (j = 0; j < dispzone_length; j++) {
740 if (zonesizes[j] <= 5) continue;
741 zonelist = zonelists[j];
742 zone = &(display->zone[j]);
744 for (k = 5; (m < ZONE_MAX_OVERLAP) && (k < (int)zonesizes[j]); k++) {
745 for (l = 0; l < dispzone_length; l++) {
746 if (l == j) continue;
747 if (strcasecmp(zonelist[k], display->zone[l].name) == 0) {
748 for (n = 0; n < m; n++) {
749 if (zone->overlap[n] == display->zone[l].id) break;
752 zone->overlap[m++] = display->zone[l].id;
757 if (l >= dispzone_length) {
758 apfw_error("reloadSysConfig: disp.%d zone.%d overlap zone(%s) "
759 "dose not exist", i, j, (char *)zonelist[k]);
762 zone->overlapNum = m;
764 for (j = 0; j < dispzone_length; j++) {
765 if (zonelists[j]) g_strfreev(zonelists[j]);
766 zone = &(display->zone[j]);
767 apfw_trace("Disp.%d zone.%d node=%x x/y=%d/%d w/h=%d/%d over=%d.%d %d %d %d %d",
768 i, j, zone->node, zone->x, zone->y, zone->width, zone->height,
769 zone->overlapNum, zone->overlap[0], zone->overlap[1],
770 zone->overlap[2], zone->overlap[3], zone->overlap[4]);
772 g_string_free(zone_key,TRUE);
774 g_list_free_full(idlist,g_free);
777 idlist = ico_uxf_conf_countNumericalKey(keyfile, "sound");
778 length = g_list_length(idlist);
779 _ico_sys_config->soundNum = length;
780 _ico_sys_config->sound = g_malloc0(sizeof(Ico_Uxf_conf_sound) * length);
783 for (i = 0; i < (int)length; i++) {
784 const char* key = (const char*) g_list_nth_data(idlist, i);
785 const char* g = "sound";
786 Ico_Uxf_conf_sound *sound = &_ico_sys_config->sound[i];
787 sound->id = ico_uxf_conf_getUint(key);
788 ico_uxf_conf_checkGerror(&error);
789 sound->name = g_key_file_get_string(keyfile, g, key, &error);
790 ico_uxf_conf_checkGerror(&error);
793 ico_uxf_getSysHostByName(g_key_file_get_string(
794 keyfile, g, ico_uxf_conf_appendStr(key,".host"), &error));
795 ico_uxf_conf_checkGerror(&error);
797 g_key_file_get_integer(keyfile, g,
798 ico_uxf_conf_appendStr(key,".soundno"), &error);
801 g_clear_error(&error);
804 apfw_trace("Sound.%d Id=%d Name=%s Host=%d SoundNo=%d",
805 i, sound->id, (char *)sound->name, sound->hostId, sound->soundno);
809 GString* sound_key = g_string_new("");
810 for (sound_length = 0;
811 sound_length < ICO_UXF_SOUND_ZONE_MAX; sound_length++) {
812 g_string_printf(sound_key,"%s.zone.%d", key, sound_length);
813 if (g_key_file_has_key(keyfile,g,sound_key->str,NULL) != TRUE) break;
815 apfw_trace("Sound.%d zoneNum = %d" ,i, sound_length);
816 sound->zoneNum = sound_length;
817 sound->zone = g_malloc0(sizeof(Ico_Uxf_conf_sound_zone)*sound_length);
819 gsize zonesizes[ICO_UXF_SOUND_ZONE_MAX];
820 gchar **zonelists[ICO_UXF_SOUND_ZONE_MAX];
822 Ico_Uxf_conf_sound_zone *zone;
824 for (j = 0; j < sound_length; j++) {
825 g_string_printf(sound_key,"%s.zone.%d",key,j);
827 g_key_file_get_string_list(keyfile,g,sound_key->str,&zonesizes[j],&error);
828 ico_uxf_conf_checkGerror(&error);
829 if ((! zonelists[j]) || (zonesizes[j] <= 0)) {
830 apfw_error("reloadSysConfig: sound.%d zone.%d dose not exist",i,j);
834 for (j = 0; j < sound_length; j++) {
835 zone = &(sound->zone[j]);
837 zone->zoneidx = zoneidx++;
839 if (zonesizes[j] <= 0) continue;
841 zonelist = zonelists[j];
842 zone->name = strdup((char*)zonelist[0]);
844 for (j = 0; j < sound_length; j++) {
846 if (zonesizes[j] <= 1) continue;
847 zonelist = zonelists[j];
848 zone = &(sound->zone[j]);
850 for (k = 1; (m < ZONE_MAX_OVERLAP) && (k < (int)zonesizes[j]); k++) {
851 for (l = 0; l < sound_length; l++) {
852 if (l == j) continue;
853 if (strcasecmp((char*)zonelist[k], sound->zone[l].name) == 0) {
854 for (n = 0; n < m; n++) {
855 if (zone->overlap[n] == sound->zone[l].id) break;
858 zone->overlap[m++] = sound->zone[l].id;
863 if (l >= sound_length) {
864 apfw_error("reloadSysConfig: sound.%d zone.%d overlap zone(%s) "
865 "dose not exist", i, j, (char *)zonelist[k]);
868 zone->overlapNum = m;
870 for (j = 0; j < sound_length; j++) {
871 if (zonelists[j]) g_strfreev(zonelists[j]);
872 zone = &(sound->zone[j]);
873 apfw_trace("Sound.%d zone.%d(%s) over=%d.%d %d %d %d %d",
875 zone->overlapNum, zone->overlap[0], zone->overlap[1],
876 zone->overlap[2], zone->overlap[3], zone->overlap[4]);
878 g_string_free(sound_key,TRUE);
880 g_list_free_full(idlist,g_free);
883 idlist = ico_uxf_conf_countNumericalKey(keyfile, "input");
884 length = g_list_length(idlist);
885 _ico_sys_config->inputdevNum = length;
886 _ico_sys_config->inputdev = g_malloc0(sizeof(Ico_Uxf_conf_inputdev) * length);
888 for (i = 0; i < (int)length; i++) {
889 const char* key = (const char*) g_list_nth_data(idlist, i);
890 const char* g = "input";
891 Ico_Uxf_conf_inputdev *inputdev = &_ico_sys_config->inputdev[i];
892 inputdev->id = ico_uxf_conf_getUint(key);
893 ico_uxf_conf_checkGerror(&error);
894 inputdev->name = g_key_file_get_string(keyfile, g, key, &error);
895 ico_uxf_conf_checkGerror(&error);
899 GString* sw_key = g_string_new("");
900 for (sw_length = 0;; sw_length++) {
901 g_string_printf(sw_key,"%s.sw.%d",key,sw_length);
902 if (g_key_file_has_key(keyfile,g,sw_key->str,NULL) != TRUE) break;
904 apfw_trace("Input.%d swNum = %d" ,i, sw_length);
905 inputdev->inputswNum = sw_length;
906 inputdev->inputsw = g_malloc0(sizeof(Ico_Uxf_conf_inputsw)*sw_length);
911 for (j = 0; j < sw_length; j++) {
912 g_string_printf(sw_key,"%s.sw.%d",key,j);
913 swlist = g_key_file_get_string_list(keyfile,g,sw_key->str,&swsize,&error);
914 ico_uxf_conf_checkGerror(&error);
915 if ((!swlist) || (swsize <= 0)) {
916 apfw_error("reloadSysConfig: input.%d sw.%d dose not exist",i,j);
920 inputdev->inputsw[j].inputdev = inputdev;
921 inputdev->inputsw[j].name = strdup((char *)swlist[0]);
923 inputdev->inputsw[j].appid = strdup((char *)swlist[1]);
925 inputdev->inputsw[j].keycode = strtol((char *)swlist[2],
931 uifw_trace("Input %s.%s app=%s key=%d",
933 inputdev->inputsw[j].name ? inputdev->inputsw[j].name : " ",
934 inputdev->inputsw[j].appid ? inputdev->inputsw[j].appid : " ",
935 inputdev->inputsw[j].keycode);
937 g_string_free(sw_key,TRUE);
939 g_list_free_full(idlist,g_free);
941 _ico_sys_config->misc.default_kindId = ico_uxf_getSysKindByName(
942 g_key_file_get_string(keyfile, "default", "kind", &error));
943 ico_uxf_conf_checkGerror(&error);
944 _ico_sys_config->misc.default_categoryId = ico_uxf_getSysCategoryByName(
945 g_key_file_get_string(keyfile, "default", "category", &error));
946 ico_uxf_conf_checkGerror(&error);
947 _ico_sys_config->misc.default_displayId = ico_uxf_getSysDisplayByName(
948 g_key_file_get_string(keyfile, "default", "display", &error));
949 ico_uxf_conf_checkGerror(&error);
950 _ico_sys_config->misc.default_layerId = ico_uxf_getSysLayerByName(
951 _ico_sys_config->misc.default_displayId,
952 g_key_file_get_string(keyfile, "default", "layer", &error));
953 ico_uxf_conf_checkGerror(&error);
954 _ico_sys_config->misc.default_dispzoneId = ico_uxf_getSysDispZoneByName(
955 _ico_sys_config->misc.default_displayId,
956 g_key_file_get_string(keyfile, "default", "displayzone", &error));
957 _ico_sys_config->misc.default_soundId = ico_uxf_getSysSoundByName(
958 g_key_file_get_string(keyfile, "default", "sound", &error));
959 _ico_sys_config->misc.default_soundzoneId = ico_uxf_getSysSoundZoneByName(
960 _ico_sys_config->misc.default_soundId,
961 g_key_file_get_string(keyfile, "default", "soundzone", &error));
962 ico_uxf_conf_checkGerror(&error);
963 _ico_sys_config->misc.default_inputdevId = ico_uxf_getSysInputdevByName(
964 g_key_file_get_string(keyfile, "default", "inputdev", &error));
965 _ico_sys_config->misc.default_inputswId = ico_uxf_getSysInputswByName(
966 _ico_sys_config->misc.default_inputdevId,
967 g_key_file_get_string(keyfile, "default", "inputsw", &error));
968 ico_uxf_conf_checkGerror(&error);
970 apfw_trace("Default host=%d kind=%d category=%d disp=%d layer=%d dispzone=%d "
971 "sound=%d soundzone=%d input=%d/%d",
972 _ico_sys_config->misc.default_hostId,
973 _ico_sys_config->misc.default_kindId,
974 _ico_sys_config->misc.default_categoryId,
975 _ico_sys_config->misc.default_displayId,
976 _ico_sys_config->misc.default_layerId,
977 _ico_sys_config->misc.default_dispzoneId,
978 _ico_sys_config->misc.default_soundId,
979 _ico_sys_config->misc.default_soundzoneId,
980 _ico_sys_config->misc.default_inputdevId,
981 _ico_sys_config->misc.default_inputswId);
982 g_key_file_free(keyfile);
984 apfw_trace("reloadSysConfig: Leave");
985 return _ico_sys_config;
988 /*--------------------------------------------------------------------------*/
990 * @brief ico_uxf_getSysHostById: get host configuration by host Id
992 * @param[in] hostId host Id
993 * @return host configuration table
994 * @retval != NULL success(host configuration table address)
995 * @retval == NULL error(host Id dose not exist)
997 /*--------------------------------------------------------------------------*/
998 ICO_APF_API const Ico_Uxf_conf_host *
999 ico_uxf_getSysHostById(const int hostId)
1003 if (!_ico_sys_config) {
1004 (void)ico_uxf_getSysConfig();
1007 for (i = 0; i < _ico_sys_config->hostNum; i++) {
1008 if (_ico_sys_config->host[i].id == hostId) {
1009 return &_ico_sys_config->host[i];
1012 apfw_warn("ico_uxf_getSysHostById(%d) Illegal Host Number", hostId);
1016 /*--------------------------------------------------------------------------*/
1018 * @brief ico_uxf_get_SysLocation: get host location by host Id
1020 * @param[in] hostId host Id
1021 * @return host location name
1022 * @retval != NULL success(host location name)
1023 * @retval == NULL error(host Id dose not exist)
1025 /*--------------------------------------------------------------------------*/
1026 ICO_APF_API const char *
1027 ico_uxf_get_SysLocation(const int hostId)
1031 if (!_ico_sys_config) {
1032 (void)ico_uxf_getSysConfig();
1035 for (i = 0; i < _ico_sys_config->hostNum; i++) {
1036 if (_ico_sys_config->host[i].id == hostId) {
1037 return _ico_sys_config->host[i].address;
1040 apfw_warn("Ico_uxf_get_SysLocation(%d) Illegal Host Number", hostId);
1044 /*--------------------------------------------------------------------------*/
1046 * @brief ico_uxf_getSysDisplayById: get display configuration by display Id
1048 * @param[in] displayId display Id
1049 * @return display configuration table address
1050 * @retval != NULL success(host oy configuration tabel address)
1051 * @retval == NULL error(displayd dose not exist)
1053 /*--------------------------------------------------------------------------*/
1054 ICO_APF_API const Ico_Uxf_conf_display *
1055 ico_uxf_getSysDisplayById(const int displayId)
1059 if (!_ico_sys_config) {
1060 (void)ico_uxf_getSysConfig();
1063 for (i = 0; i < _ico_sys_config->displayNum; i++) {
1064 if (_ico_sys_config->display[i].id == displayId) {
1065 return &_ico_sys_config->display[i];
1068 apfw_warn("ico_uxf_getSysDisplayById(%d) Illegal Display Number", displayId);
1072 /*--------------------------------------------------------------------------*/
1074 * @brief ico_uxf_getSysHostByName: get host Id bu host name
1076 * @param[in] shost host name
1077 * @return host Id number
1079 /*--------------------------------------------------------------------------*/
1081 ico_uxf_getSysHostByName(const char *shost)
1085 if (!_ico_sys_config) {
1086 (void)ico_uxf_getSysConfig();
1088 if (_ico_sys_config->hostNum <= 0) {
1089 apfw_critical("ico_uxf_getSysHostByName: can not read configuration file");
1090 return _ico_sys_config->misc.default_hostId;
1093 if ((! shost) || (*shost == 0)) {
1094 return _ico_sys_config->host[0].id;
1097 for (i = 0; i < _ico_sys_config->hostNum; i++) {
1098 if (strcasecmp(shost, _ico_sys_config->host[i].name) == 0) {
1099 return _ico_sys_config->host[i].id;
1102 apfw_warn("ico_uxf_getSysHostByName(%s) Illegal Host Name", shost);
1103 return _ico_sys_config->misc.default_hostId;
1106 /*--------------------------------------------------------------------------*/
1108 * @brief ico_uxf_getSysHostTypeByName: get host type number by name(internal function)
1110 * @param[in] stype host type name
1111 * @return host type number
1113 /*--------------------------------------------------------------------------*/
1115 ico_uxf_getSysHostTypeByName(const char *stype)
1117 if ((! stype) || (*stype == 0)) {
1118 return ICO_UXF_HOSTTYPE_CENTER;
1120 if (strcasecmp(stype, "center") == 0) {
1121 return ICO_UXF_HOSTTYPE_CENTER;
1123 else if (strcasecmp(stype, "meter") == 0) {
1124 return ICO_UXF_HOSTTYPE_METER;
1126 else if (strcasecmp(stype, "remote") == 0) {
1127 return ICO_UXF_HOSTTYPE_REMOTE;
1129 else if (strcasecmp(stype, "passenger") == 0) {
1130 return ICO_UXF_HOSTTYPE_PASSENGER;
1132 else if (strcasecmp(stype, "rear") == 0) {
1133 return ICO_UXF_HOSTTYPE_REAR;
1135 else if (strcasecmp(stype, "rearleft") == 0) {
1136 return ICO_UXF_HOSTTYPE_REARLEFT;
1138 else if (strcasecmp(stype, "rearright") == 0) {
1139 return ICO_UXF_HOSTTYPE_REARRIGHT;
1141 apfw_warn("ico_uxf_getSysHostTypeByName(%s) Illegal HostType Name", stype);
1142 return strtol(stype, (char **)0, 0);
1145 /*--------------------------------------------------------------------------*/
1147 * @brief ico_uxf_getSysDispTypeByName: get display type number by name(internal function)
1149 * @param[in] stype display type name
1150 * @return display type number
1152 /*--------------------------------------------------------------------------*/
1154 ico_uxf_getSysDispTypeByName(const char *stype)
1156 if ((! stype) || (*stype == 0)) {
1157 apfw_critical("ico_uxf_getSysDispTypeByName(NULL) Illegal HostType Name");
1160 if (strcasecmp(stype, "center") == 0) {
1161 return ICO_UXF_DISPLAYTYPE_CENTER;
1163 else if (strcasecmp(stype, "meter") == 0) {
1164 return ICO_UXF_DISPLAYTYPE_METER;
1166 else if (strcasecmp(stype, "remote") == 0) {
1167 return ICO_UXF_DISPLAYTYPE_REMOTE;
1169 else if (strcasecmp(stype, "passenger") == 0) {
1170 return ICO_UXF_DISPLAYTYPE_PASSENGER;
1172 else if (strcasecmp(stype, "rear") == 0) {
1173 return ICO_UXF_DISPLAYTYPE_REAR;
1175 else if (strcasecmp(stype, "rearleft") == 0) {
1176 return ICO_UXF_DISPLAYTYPE_REARLEFT;
1178 else if (strcasecmp(stype, "rearright") == 0) {
1179 return ICO_UXF_DISPLAYTYPE_REARRIGHT;
1181 apfw_warn("ico_uxf_getSysDispTypeByName(%s) Illegal DisplayType Name", stype);
1182 return strtol(stype, (char **)0, 0);
1185 /*--------------------------------------------------------------------------*/
1187 * @brief ico_uxf_getSysBoolByName: get boolian value(internal function)
1189 * @param[in] sbool boolian value string
1190 * @return boolian value
1194 /*--------------------------------------------------------------------------*/
1196 ico_uxf_getSysBoolByName(const char *sbool)
1198 if ((! sbool) || (*sbool == 0)) {
1201 if ((strcasecmp(sbool, "true") == 0) ||
1202 (strcasecmp(sbool, "yes") == 0) ||
1203 (strcasecmp(sbool, "1") == 0)) {
1209 /*--------------------------------------------------------------------------*/
1211 * @brief ico_uxf_getSysDisplayByName: get display Id by display name
1213 * @param[in] sdisplay display name
1214 * @return display Id
1216 /*--------------------------------------------------------------------------*/
1218 ico_uxf_getSysDisplayByName(const char *sdisplay)
1222 if (!_ico_sys_config) {
1223 (void)ico_uxf_getSysConfig();
1225 if ((! sdisplay) || (*sdisplay == 0)) {
1226 apfw_trace("ico_uxf_getSysDisplayByName(NULL) Illegal Display Name");
1227 return _ico_sys_config->misc.default_displayId;
1230 for (i = 0; i < _ico_sys_config->displayNum; i++) {
1231 if (strcasecmp(sdisplay, _ico_sys_config->display[i].name) == 0) {
1232 return _ico_sys_config->display[i].id;
1235 apfw_warn("ico_uxf_getSysDisplayByName(%s) Illegal Display Name", sdisplay);
1236 return _ico_sys_config->misc.default_displayId;
1239 /*--------------------------------------------------------------------------*/
1241 * @brief ico_uxf_getSysLayerByName: get layer Id by layer name
1243 * @param[in] display display Id
1244 * @param[in] slayer layer name
1247 /*--------------------------------------------------------------------------*/
1249 ico_uxf_getSysLayerByName(const int display, const char *slayer)
1254 if (!_ico_sys_config) {
1255 (void)ico_uxf_getSysConfig();
1258 if ((display < 0) || (display >= _ico_sys_config->displayNum)) {
1259 apfw_warn("ico_uxf_getSysLayerByName(%d,%s) Illegal Display Number",
1261 return _ico_sys_config->misc.default_layerId;
1263 if ((! slayer) || (*slayer == 0)) {
1264 apfw_trace("ico_uxf_getSysLayerByName(NULL) Illegal Layer Name");
1265 return _ico_sys_config->misc.default_layerId;
1268 for (i = 0; i < _ico_sys_config->display[display].layerNum; i++) {
1269 if (strcasecmp(slayer, _ico_sys_config->display[display].layer[i].name) == 0) {
1270 return _ico_sys_config->display[display].layer[i].id;
1275 i = strtol(slayer, &errp, 0);
1276 if ((errp) && (*errp != 0)) {
1277 apfw_warn("ico_uxf_getSysLayerByName(%d,%s) Illegal Layer Name", display, slayer);
1278 i = _ico_sys_config->misc.default_layerId;
1283 /*--------------------------------------------------------------------------*/
1285 * @brief ico_uxf_getSysKindByName: get kind Id by kind name
1287 * @param[in] skind kind name
1290 /*--------------------------------------------------------------------------*/
1292 ico_uxf_getSysKindByName(const char *skind)
1296 if (!_ico_sys_config) {
1297 (void)ico_uxf_getSysConfig();
1299 if (_ico_sys_config->kindNum <= 0) {
1300 apfw_critical("ico_uxf_getSysKindByName: can not read configuration file");
1301 return _ico_sys_config->misc.default_kindId;
1304 if ((skind) && (*skind != 0)) {
1305 for (i = 0; i < _ico_sys_config->kindNum; i++) {
1306 if (strcasecmp(skind, _ico_sys_config->kind[i].name) == 0) {
1307 return _ico_sys_config->kind[i].id;
1311 apfw_warn("ico_uxf_getSysKindByName(%s) Illegal kind name", skind);
1312 return _ico_sys_config->misc.default_kindId;
1315 /*--------------------------------------------------------------------------*/
1317 * @brief ico_uxf_getSysCategoryByName: get category Id by category name
1319 * @param[in] scategory category name
1320 * @return category Id
1322 /*--------------------------------------------------------------------------*/
1324 ico_uxf_getSysCategoryByName(const char *scategory)
1328 if (!_ico_sys_config) {
1329 (void)ico_uxf_getSysConfig();
1331 if (_ico_sys_config->categoryNum <= 0) {
1332 apfw_critical("ico_uxf_getSysCategoryByName: can not read configuration file");
1333 return _ico_sys_config->misc.default_categoryId;
1336 if ((scategory) && (*scategory != 0)) {
1337 for (i = 0; i < _ico_sys_config->categoryNum; i++) {
1338 if (strcasecmp(scategory, _ico_sys_config->category[i].name) == 0) {
1339 return _ico_sys_config->category[i].id;
1343 apfw_warn("ico_uxf_getSysCategoryByName(%s) Illegal category name", scategory);
1344 return _ico_sys_config->misc.default_categoryId;
1347 /*--------------------------------------------------------------------------*/
1349 * @brief ico_uxf_getSysDispZoneByName: get display zone Id by display zone name
1351 * @param[in] display display Id
1352 * @param[in] sdispzone displahy zone name
1353 * @return display zone Id
1355 /*--------------------------------------------------------------------------*/
1357 ico_uxf_getSysDispZoneByName(const int display, const char *sdispzone)
1361 if (!_ico_sys_config) {
1362 (void)ico_uxf_getSysConfig();
1364 if ((display < 0) || (display >= _ico_sys_config->displayNum) ||
1365 (_ico_sys_config->display[display].zoneNum <= 0)) {
1366 apfw_critical("ico_uxf_getSysDispZoneByName: can not read configuration file");
1367 return _ico_sys_config->misc.default_dispzoneId;
1370 if ((sdispzone) && (*sdispzone != 0)) {
1371 for (i = 0; i < _ico_sys_config->display[display].zoneNum; i++) {
1372 if (strcasecmp(sdispzone, _ico_sys_config->display[display].zone[i].name) == 0) {
1373 return _ico_sys_config->display[display].zone[i].id;
1377 apfw_warn("ico_uxf_getSysDispZoneByName(%s) Illegal zone name", sdispzone);
1378 return _ico_sys_config->misc.default_dispzoneId;
1381 /*--------------------------------------------------------------------------*/
1383 * @brief ico_uxf_getSysSoundByName: get sound Id by sound name
1385 * @param[in] ssound sound name
1388 /*--------------------------------------------------------------------------*/
1390 ico_uxf_getSysSoundByName(const char *ssound)
1394 if (!_ico_sys_config) {
1395 (void)ico_uxf_getSysConfig();
1397 if (_ico_sys_config->soundNum <= 0) {
1398 apfw_critical("ico_uxf_getSysSoundByName: can not read configuration file");
1399 return _ico_sys_config->misc.default_soundId;
1402 if ((ssound) && (*ssound != 0)) {
1403 for (i = 0; i < _ico_sys_config->soundNum; i++) {
1404 if (strcasecmp(ssound, _ico_sys_config->sound[i].name) == 0) {
1405 return _ico_sys_config->sound[i].id;
1409 apfw_warn("ico_uxf_getSysSoundByName(%s) Illegal sound name", ssound);
1410 return _ico_sys_config->misc.default_soundId;
1413 /*--------------------------------------------------------------------------*/
1415 * @brief ico_uxf_getSysSoundZoneByName: get sound zone Id by sound zone name
1417 * @param[in] sound sound Id
1418 * @param[in] ssoundzone sound zone name
1419 * @return sound zone Id
1421 /*--------------------------------------------------------------------------*/
1423 ico_uxf_getSysSoundZoneByName(const int sound, const char *ssoundzone)
1427 if (!_ico_sys_config) {
1428 (void)ico_uxf_getSysConfig();
1430 if ((sound < 0) || (sound >= _ico_sys_config->soundNum) ||
1431 (_ico_sys_config->sound[sound].zoneNum <= 0)) {
1432 apfw_critical("ico_uxf_getSysSoundZoneByName: can not read configuration file");
1433 return _ico_sys_config->misc.default_soundzoneId;
1436 if ((ssoundzone) && (*ssoundzone != 0)) {
1437 for (i = 0; i < _ico_sys_config->sound[sound].zoneNum; i++) {
1438 if (strcasecmp(ssoundzone, _ico_sys_config->sound[sound].zone[i].name) == 0) {
1439 return _ico_sys_config->sound[sound].zone[i].id;
1443 apfw_warn("ico_uxf_getSysSoundZoneByName(%s) Illegal zone name", ssoundzone);
1444 return _ico_sys_config->misc.default_soundzoneId;
1447 /*--------------------------------------------------------------------------*/
1449 * @brief ico_uxf_getSysInputdevByName: get input device Id by input device name
1451 * @param[in] sinputdev input device name
1452 * @return input device Id
1454 /*--------------------------------------------------------------------------*/
1456 ico_uxf_getSysInputdevByName(const char *sinputdev)
1460 if (!_ico_sys_config) {
1461 (void)ico_uxf_getSysConfig();
1463 if (_ico_sys_config->inputdevNum <= 0) {
1464 apfw_critical("ico_uxf_getSysInputdevByName: can not read configuration file");
1465 return _ico_sys_config->misc.default_inputdevId;
1468 if ((! sinputdev) || (*sinputdev == 0)) {
1469 return _ico_sys_config->misc.default_inputdevId;
1472 for (i = 0; i < _ico_sys_config->inputdevNum; i++) {
1473 if (strcasecmp(sinputdev, _ico_sys_config->inputdev[i].name) == 0) {
1474 return _ico_sys_config->inputdev[i].id;
1477 apfw_warn("ico_uxf_getSysInputdevByName(%s) Illegal device Name", sinputdev);
1478 return _ico_sys_config->misc.default_inputdevId;
1481 /*--------------------------------------------------------------------------*/
1483 * @brief ico_uxf_getSysInputswByName: get input switch Id by input switch name
1485 * @param[in] inputdev input device Id
1486 * @param[in] sinputsw input switch name
1487 * @return input switch Id
1489 /*--------------------------------------------------------------------------*/
1491 ico_uxf_getSysInputswByName(const int inputdev, const char *sinputsw)
1495 if (!_ico_sys_config) {
1496 (void)ico_uxf_getSysConfig();
1498 if ((inputdev < 0) || (inputdev >= _ico_sys_config->inputdevNum) ||
1499 (_ico_sys_config->inputdev[inputdev].inputswNum <= 0)) {
1500 apfw_critical("ico_uxf_getSysInputswByName: can not read configuration file");
1504 if ((sinputsw) && (*sinputsw != 0)) {
1505 for (i = 0; i < _ico_sys_config->inputdev[inputdev].inputswNum; i++) {
1506 if (strcasecmp(sinputsw, _ico_sys_config->inputdev[inputdev].inputsw[i].name)
1512 apfw_warn("ico_uxf_getSysInputswByName(%s) Illegal sw name",
1513 sinputsw ? sinputsw : "(NULL)");
1517 /*--------------------------------------------------------------------------*/
1519 * @brief ico_uxf_closeSysConfig: close and release system configuration table
1524 /*--------------------------------------------------------------------------*/
1526 ico_uxf_closeSysConfig(void)
1528 if (_ico_sys_config != NULL) {
1529 g_free(_ico_sys_config->host);
1530 g_free(_ico_sys_config->display);
1531 g_free(_ico_sys_config);
1532 _ico_sys_config = NULL;