Revise: add manifest file for SMACK label setting. Log output level correction.(perfo...
[profile/ivi/ico-uxf-homescreen-sample-apps.git] / ico-app-vicsample / src / vicsample.c
1 /*
2  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
3  *
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
7  *
8  */
9 /**
10  * @brief   Vehicles Sample APP
11  *          Vehicles information is displayed.
12  *
13  * @date    Mar-04-2013
14  */
15
16 #include <Elementary.h>
17 #include <E_DBus.h>
18 #include <app.h>
19 #include <dbus/dbus.h>
20 #include <string.h>
21 #include <stdbool.h>
22 #include <bundle.h>
23 #include <aul.h>
24 #include "ico_log.h"
25 #include "ico_dbus_amb_efl.h"
26
27 /*============================================================================*/
28 /* Define fixed parameters                                                    */
29 /*============================================================================*/
30 #define STATUS_BAR_HEIGHT   (64)
31 #define CTRL_BAR_HEIGHT     (128)
32 #define BAR_HEIGHT          (STATUS_BAR_HEIGHT + CTRL_BAR_HEIGHT)
33 #define WIDTH               (1080)      /* Base Background width  */
34 #define HEIGHT              (1920 - BAR_HEIGHT) /* Base Background height */
35
36 /* Base */
37 #define CTG_BX_W            530
38 #define CTG_BX_H            250
39 #define VIC_LI_W            1060
40 #define VIC_LI_H            1240
41
42 #define CTG_BX_X            10
43 #define CTG_BX_Y            40
44 #define VIC_LI_X            10
45 #define VIC_LI_Y            450
46
47 /* font */
48 #define FONT_SIZE           48
49 #define FONT_FAMILY         (char *)"Sans"      /* Mono, Sans, Serif */
50
51 /* Text class name */
52 #define TEXT_BUTTON         (char *)"button"
53 #define TEXT_LIST_ITEM      (char *)"list_item"
54 #define TEXT_LABEL          (char *)"label"
55
56 /* max size of vehicle information */
57 #define MAX_PARA_NUM        32
58
59 /* vehicle information ID */
60 #define VEHICLESPEED             0
61 #define ACCELERATIONX            1
62 #define SHIFTPOSITION            2
63 #define ENGINESPEED              3
64 #define LATITUDE                 4
65 #define ALTITUDE                 5
66 #define GEARPOSITION             6
67 #define LONGITUDE                7
68 #define MODE                     8
69 #define DIRECTION                9
70 #define WHEELBRAKEPRESSURE       10
71 #define LEFTTURNLIGHT            11
72 #define RIGHTTURNLIGHT           12
73 #define BRAKESIGNAL              13
74 #define ACCELERATIONY            14
75 #define ACCELERATIONZ            15
76 #define EXTERIORBRIGHTNESS       16
77 #define TURNSIGNAL               17
78 #define ENGINECOOLANTTEMPERATURE 18
79 #define STEERINGWHEELANGLE       19
80 #define HEADLIGHT                20
81 #define PARKINGLIGHT             21
82
83 /* maximum categories */
84 #define MAX_CATEGORY_NUM    8
85
86 /* vehicle information Parameter Category */
87 #define DRIVINGSAFETY       0
88 #define ELECTRICVEHICLE     1
89 #define ENVIRONMENT         2
90 #define MAINTENANCE         3
91 #define PARKING             4
92 #define PERSONALIZATION     5
93 #define RUNNINGSTATUS       6
94 #define VEHICLEINFO         7
95
96 /* Definition of files */
97 #define BASE_DIR            "/usr/apps/org.tizen.ico.app-vicsample"
98 #define IMAGE_DIR           BASE_DIR"/res/images"
99 #define CONFIG_FILE         BASE_DIR"/res/vicsample_config.txt"
100 #define BG_IMAGE_FILE       IMAGE_DIR"/vicinfo_bg.png"
101
102 /* Module name */
103 #define MODULE_NAME         "org.tizen.ico.app-vicsample"
104
105 #define DMY_DATA            "000000000000000"
106 #define DIGIT_NUM_OVER_DATA "############"
107 #define MAX_DRAW_VAL_LEM    15
108 #define MAX_NAME_LEM        32
109
110 /*============================================================================*/
111 /* Define data types                                                          */
112 /*============================================================================*/
113 struct vic_data_t
114 {
115     int idx;
116     int property;
117     int category;
118     dbus_type type;
119     int zone;
120     char name[MAX_NAME_LEM];
121     char objpath_name[MAX_NAME_LEM];
122     char property_name[MAX_NAME_LEM];
123 };
124
125 struct vic_key_data_t
126 {
127     int id;
128     int category;
129     int type;
130     char name[MAX_NAME_LEM];
131 };
132
133 struct vic_category_data_t
134 {
135     int category;
136     char name[MAX_NAME_LEM];
137 };
138
139 struct appdata_t
140 {
141     Evas_Object *win;           //main window
142     Evas_Object *bg;
143
144     Evas_Object *ctg_bx;
145     Evas_Object *ctg_bx2;
146     Evas_Object *ctg_btn[MAX_CATEGORY_NUM];
147     Evas_Object *vic_ini_li;
148     Evas_Object *vic_li[MAX_CATEGORY_NUM];
149     Evas_Object *vic_val_text[MAX_PARA_NUM];
150     Evas_Object *vic_val_dmy_text[MAX_CATEGORY_NUM];
151 };
152
153 /*============================================================================*/
154 /* Function prototype for static(internal) functions                          */
155 /*============================================================================*/
156 static void on_ctg_mousedown(void *data, Evas_Object *obj, void *event_info);
157 static void amb_get_property_cb(const char *objectname, const char *property,
158                                 dbus_type type,
159                                 union dbus_value_variant value,
160                                 void *user_data);
161 static void amb_subscribe_property_cb(const char *objectname,
162                                       const char *property, dbus_type type,
163                                       union dbus_value_variant value,
164                                       int sequence, struct timeval tv,
165                                       void *user_data);
166 static void set_vic_text_data(Evas_Object *obj, const char *text);
167 static void set_vic_data(union dbus_value_variant value, void *user_data);
168 static int amb_get_property(int key);
169 static int amb_subscribe_property(int key);
170 static Eina_Bool amb_init(void);
171 static int get_config(void);
172 static void win_del(void *data, Evas_Object *obj, void *event_info);
173 static void elmListCreate(void);
174 static void winCreate(void);
175 static Evas_Object *create_win(const char *name);
176
177 /*============================================================================*/
178 /* Tables and Valiables                                                       */
179 /*============================================================================*/
180 static struct vic_data_t vic_data[MAX_PARA_NUM];
181 static int property_num = 0;
182 static int ListDispSts = -1;
183 static struct appdata_t Ad;
184
185 const struct vic_category_data_t vic_category_data[MAX_CATEGORY_NUM] = {
186     {DRIVINGSAFETY, "Driving safety"},
187     {ELECTRICVEHICLE, "Electric Vehicle"},
188     {ENVIRONMENT, "Environment"},
189     {MAINTENANCE, "Maintenance"},
190     {PARKING, "Parking"},
191     {PERSONALIZATION, "Personalization"},
192     {RUNNINGSTATUS, "Running Status"},
193     {VEHICLEINFO, "Vehicle Info"}
194 };
195
196 const struct vic_key_data_t vic_key_data[] = {
197     {VEHICLESPEED, RUNNINGSTATUS, DBUS_TYPE_UINT16, "VehicleSpeed"},
198     {ACCELERATIONX, RUNNINGSTATUS, DBUS_TYPE_UINT16, "AccelerationX"},
199     {SHIFTPOSITION, RUNNINGSTATUS, DBUS_TYPE_INT32, "ShiftPosition"},
200     {ENGINESPEED, RUNNINGSTATUS, DBUS_TYPE_UINT16, "EngineSpeed"},
201     {LATITUDE, RUNNINGSTATUS, DBUS_TYPE_DOUBLE, "Latitude"},
202     {ALTITUDE, RUNNINGSTATUS, DBUS_TYPE_DOUBLE, "Altitude"},
203     {GEARPOSITION, RUNNINGSTATUS, DBUS_TYPE_INT32, "GearPosition"},
204     {LONGITUDE, RUNNINGSTATUS, DBUS_TYPE_DOUBLE, "Longitude"},
205     {MODE, RUNNINGSTATUS, DBUS_TYPE_INT32, "Mode"},
206     {DIRECTION, RUNNINGSTATUS, DBUS_TYPE_UINT16, "Direction"},
207     {WHEELBRAKEPRESSURE, RUNNINGSTATUS, DBUS_TYPE_UINT16,
208      "WheelBrakePressure"},
209     {LEFTTURNLIGHT, RUNNINGSTATUS, DBUS_TYPE_BOOLEAN, "LeftTurnLight"},
210     {RIGHTTURNLIGHT, RUNNINGSTATUS, DBUS_TYPE_BOOLEAN, "RightTurnLight"},
211     {BRAKESIGNAL, RUNNINGSTATUS, DBUS_TYPE_BOOLEAN, "BrakeSignal"},
212     {ACCELERATIONY, RUNNINGSTATUS, DBUS_TYPE_UINT16, "AccelerationY"},
213     {ACCELERATIONZ, RUNNINGSTATUS, DBUS_TYPE_UINT16, "AccelerationZ"},
214     {EXTERIORBRIGHTNESS, ENVIRONMENT, DBUS_TYPE_UINT16, "ExteriorBrightness"},
215     {TURNSIGNAL, RUNNINGSTATUS, DBUS_TYPE_INT32, "TurnSignal"},
216     {ENGINECOOLANTTEMPERATURE, RUNNINGSTATUS, DBUS_TYPE_INT32,
217      "EngineCoolantTemperature"},
218     {STEERINGWHEELANGLE, RUNNINGSTATUS, DBUS_TYPE_UINT16,
219      "SteeringWheelAngle"},
220     {HEADLIGHT, RUNNINGSTATUS, DBUS_TYPE_BOOLEAN, "HeadLight"},
221     {PARKINGLIGHT, RUNNINGSTATUS, DBUS_TYPE_BOOLEAN, "ParkingLight"},
222     {-1, -1, -1, "END"}
223 };
224
225 /*============================================================================*/
226 /* Function                                                                   */
227 /*============================================================================*/
228 /**
229  * @brief on_ctg_mousedown
230  */
231 static void on_ctg_mousedown(void *data, Evas_Object *obj, void *event_info)
232 {
233     ICO_DBG("on_ctg_mousedown Enter");
234
235     int category = -1;
236     if (data != NULL) {
237         category = *((int *) data);
238     }
239
240     if ((category != -1) && (category != ListDispSts)) {
241         if (ListDispSts != -1) {
242             evas_object_color_set(Ad.ctg_btn[ListDispSts], 255, 255, 255,
243                                   255);
244             evas_object_hide(Ad.vic_li[ListDispSts]);
245         }
246         else {
247             evas_object_hide(Ad.vic_ini_li);
248             elm_list_clear(Ad.vic_ini_li);
249         }
250         evas_object_color_set(Ad.ctg_btn[category], 0, 255, 255, 255);
251         elm_list_go(Ad.vic_li[category]);
252         evas_object_show(Ad.vic_li[category]);
253         ListDispSts = category;
254     }
255
256     ICO_DBG("on_ctg_mousedown Leave");
257     return;
258 }
259
260 /**
261  * @brief amb_get_property_cb
262  */
263 static void amb_get_property_cb(const char *objectname, const char *property,
264                                 dbus_type type,
265                                 union dbus_value_variant value,
266                                 void *user_data)
267 {
268     ICO_DBG("amb_get_property_cb Enter");
269
270     if (user_data == NULL) {
271         ICO_ERR("No user data");
272         return;
273     }
274
275     set_vic_data(value, user_data);
276
277     ICO_DBG("amb_get_property_cb Leave");
278     return;
279 }
280
281 /**
282  * @brief amb_subscribe_property_cb
283  */
284 static void amb_subscribe_property_cb(const char *objectname,
285                                       const char *property, dbus_type type,
286                                       union dbus_value_variant value,
287                                       int sequence, struct timeval tv,
288                                       void *user_data)
289 {
290     ICO_DBG("amb_subscribe_property_cb Enter");
291
292     if (user_data == NULL) {
293         ICO_ERR("No user data");
294         return;
295     }
296
297     set_vic_data(value, user_data);
298
299     ICO_DBG("amb_subscribe_property_cb Leave");
300     return;
301 }
302
303 /**
304  * @brief set_vic_text_data
305  */
306 static void set_vic_text_data(Evas_Object *obj, const char *text)
307 {
308     ICO_PRF("CHG_VIC_INF set_vic_text_data Enter");
309
310     if (obj == NULL) {
311         ICO_ERR("Parameter NG obj NULL");
312         return;
313     }
314
315     if (text == NULL) {
316         ICO_ERR("Parameter NG text NULL");
317         return;
318     }
319
320     if (strlen(text) <= MAX_DRAW_VAL_LEM) {
321         elm_object_text_set(obj, text);
322     }
323     else {
324         elm_object_text_set(obj, DIGIT_NUM_OVER_DATA);
325     }
326
327     ICO_PRF("CHG_VIC_INF set_vic_text_data Leave");
328     return;
329 }
330
331 /**
332  * @brief set_vic_data
333  */
334 static void set_vic_data(union dbus_value_variant value, void *user_data)
335 {
336     ICO_PRF("CHG_VIC_INF set_vic_data Enter");
337
338     int idx = -1;
339     char vic_str[256];
340
341     if (user_data == NULL) {
342         ICO_ERR("No user data");
343         return;
344     }
345
346     idx = *((int *) (user_data));
347
348     if (idx < 0 || idx > property_num) {
349         ICO_ERR("Inaccurate user data :idx = %d", idx);
350         return;
351     }
352
353     switch (vic_data[idx].property) {
354     case SHIFTPOSITION:
355     case GEARPOSITION:
356     case MODE:
357     case TURNSIGNAL:
358     case ENGINECOOLANTTEMPERATURE:
359         ICO_PRF("CHG_VIC_INF %s(D-bus I/F Result) = %d", vic_data[idx].name,
360                 value.i32val);
361         sprintf(vic_str, "%d", value.i32val);
362         set_vic_text_data(Ad.vic_val_text[idx], vic_str);
363         break;
364
365     case VEHICLESPEED:
366     case ENGINESPEED:
367     case DIRECTION:
368     case ACCELERATIONX:
369     case ACCELERATIONY:
370     case ACCELERATIONZ:
371     case WHEELBRAKEPRESSURE:
372     case EXTERIORBRIGHTNESS:
373     case STEERINGWHEELANGLE:
374         ICO_PRF("CHG_VIC_INF %s(D-bus I/F Result) = %d", vic_data[idx].name,
375                 value.ui16val);
376         sprintf(vic_str, "%d", value.ui16val);
377         set_vic_text_data(Ad.vic_val_text[idx], vic_str);
378         break;
379
380 //    case XXXXXXXX:
381 //        ICO_PRF("CHG_VIC_INF %s(D-bus I/F Result) = %d", vic_data[idx].name,
382 //                  value.yval);
383 //        sprintf(vic_str, "%d", value.yval);
384 //        set_vic_text_data(Ad.vic_val_text[idx], vic_str);
385 //        break;
386
387     case LATITUDE:
388     case ALTITUDE:
389     case LONGITUDE:
390         ICO_PRF("CHG_VIC_INF %s(D-bus I/F Result) = %f", vic_data[idx].name,
391                 value.dval);
392         sprintf(vic_str, "%f", value.dval);
393         set_vic_text_data(Ad.vic_val_text[idx], vic_str);
394         break;
395
396     case HEADLIGHT:
397     case LEFTTURNLIGHT:
398     case RIGHTTURNLIGHT:
399     case PARKINGLIGHT:
400     case BRAKESIGNAL:
401         ICO_PRF("CHG_VIC_INF %s(D-bus I/F Result) = %d", vic_data[idx].name,
402                 value.bval);
403         if (value.bval == TRUE) {
404             sprintf(vic_str, "%s", "true");
405         }
406         else {
407             sprintf(vic_str, "%s", "false");
408         }
409         set_vic_text_data(Ad.vic_val_text[idx], vic_str);
410         break;
411
412     default:
413         ICO_ERR("Err no property : vic_data[%d]property  = %d", idx,
414                 vic_data[idx].property);
415         break;
416     }
417
418     ICO_PRF("CHG_VIC_INF set_vic_data Leave");
419     return;
420 }
421
422 /**
423  * @brief amb_get_property
424  */
425 static int amb_get_property(int key)
426 {
427     ICO_DBG("amb_get_property Enter");
428
429     int result = 0;
430
431     result = ico_dbus_amb_get(vic_data[key].objpath_name,
432                               vic_data[key].property_name,
433                               vic_data[key].zone,
434                               vic_data[key].type,
435                               amb_get_property_cb,
436                               (void *) (&(vic_data[key].idx))
437         );
438
439     if (result != 0) {
440         ICO_ERR("Can't make dbus get message.");
441         return -1;
442     }
443
444     ICO_DBG("amb_get_property Leave");
445     return 0;
446 }
447
448 /**
449  * @brief amb_subscribe_property
450  */
451 static int amb_subscribe_property(int key)
452 {
453     ICO_DBG("amb_subscribe_property Enter");
454
455     int result = 0;
456
457     result = ico_dbus_amb_subscribe(vic_data[key].objpath_name,
458                                     vic_data[key].property_name,
459                                     vic_data[key].zone,
460                                     vic_data[key].type,
461                                     amb_subscribe_property_cb,
462                                     (void *) (&(vic_data[key].idx))
463         );
464
465     if (result != 0) {
466         ICO_ERR("Can't make dbus subscribe message.");
467         return -1;
468     }
469
470     ICO_DBG("amb_subscribe_property Leave");
471     return 0;
472 }
473
474 /**
475  * @brief amb_init
476  */
477 static Eina_Bool amb_init(void)
478 {
479     ICO_DBG("amb_init Enter");
480
481     int i = 0;
482     int result = 0;
483
484     result = ico_dbus_amb_start();
485     if (result != 0) {
486         ICO_ERR("Can't get dbus bus.");
487         return EINA_FALSE;
488     }
489
490     /* First get properties */
491     for (i = 0; i < property_num; i++) {
492         result = amb_get_property(i);
493         if (result != 0) {
494             ICO_ERR("amb_get_property : get ng [%s]", vic_data[i].name);
495         }
496     }
497
498     /* Signal registration */
499     for (i = 0; i < property_num; i++) {
500         result = amb_subscribe_property(i);
501         if (result != 0) {
502             ICO_ERR("amb_subscribe_property : subscribe ng [%s]",
503                     vic_data[i].name);
504         }
505     }
506
507     ICO_DBG("amb_init Leave");
508     return EINA_TRUE;
509 }
510
511 /**
512  * @brief get_config
513  */
514 /* Read configuration file */
515 static int get_config(void)
516 {
517     ICO_DBG("get_config Enter");
518
519     FILE *fp;
520     int k = 0;
521     int j = 0;
522     int m = 0;
523     char buff[512];
524     char *tp;
525     char *clm = " \n";
526
527     fp = fopen(CONFIG_FILE, "r");
528     if (fp == NULL) {
529         ICO_ERR("File open error");
530         return -1;
531     }
532
533     for (m = 0; k < MAX_PARA_NUM; m++) {
534         if (fgets(buff, sizeof(buff) - 2, fp) == NULL) {
535             ICO_DBG("vicsample_config.txt The end of data reading");
536             break;
537         }
538
539         tp = strtok(buff, clm);
540         if (tp == NULL) {
541             ICO_DBG("vicsample_config.txt Line:%d Comment out  Null line",
542                     m + 1);
543             continue;
544         }
545
546         if (tp[0] == '#') {
547             ICO_DBG("vicsample_config.txt Line:%d Comment out  '#'Discovery",
548                     m + 1);
549             continue;
550         }
551
552         for (j = 0; vic_key_data[j].id != -1; j++) {
553             if (strcmp(tp, vic_key_data[j].name) == 0) {
554                 vic_data[k].idx = k;
555                 vic_data[k].property = vic_key_data[j].id;
556                 vic_data[k].category = vic_key_data[j].category;
557                 vic_data[k].type = vic_key_data[j].type;
558                 strcpy(vic_data[k].name, tp);
559                 strcpy(vic_data[k].objpath_name, strtok(NULL, clm));
560                 strcpy(vic_data[k].property_name, strtok(NULL, clm));
561                 vic_data[k].zone = atoi(strtok(NULL, clm));
562
563                 ICO_DBG("vic_data[%d].idx=%d", k, vic_data[k].idx);
564                 ICO_DBG("vic_data[%d].property=%d", k, vic_data[k].property);
565                 ICO_DBG("vic_data[%d].category=%d", k, vic_data[k].category);
566                 ICO_DBG("vic_data[%d].type=%d", k, vic_data[k].type);
567                 ICO_DBG("vic_data[%d].zone=%d", k, vic_data[k].zone);
568                 ICO_DBG("vic_data[%d].name=%s", k, vic_data[k].name);
569                 ICO_DBG("vic_data[%d].objpath_name=%s", k,
570                         vic_data[k].objpath_name);
571                 ICO_DBG("vic_data[%d].property_name=%s", k,
572                         vic_data[k].property_name);
573                 k++;
574                 break;
575             }
576         }
577
578         if (vic_key_data[j].id == -1) {
579             ICO_ERR("Err vicsample_config.txt Line:%d Unregistered"
580                     " parameter name", m + 1);
581         }
582     }
583
584     fclose(fp);
585
586     property_num = k;
587     if (property_num == 0) {
588         ICO_ERR("vicsample_config.txt No valid data");
589         return -1;
590     }
591
592     ICO_DBG("get_config Leave");
593     return 0;
594 }
595
596 /**
597  * @brief win_del
598  */
599 static void win_del(void *data, Evas_Object *obj, void *event_info)
600 {
601     ICO_DBG("win_del Enter");
602
603     elm_exit();
604
605     ICO_DBG("win_del Leave");
606     return;
607 }
608
609 /**
610  * @brief app_terminate
611  */
612 static void app_terminate(void *data)
613 {
614     ICO_DBG("app_terminate Enter");
615
616     // Release all resources
617     int i = 0;
618     int result = 0;
619
620     if (Ad.win) {
621         evas_object_del(Ad.win);
622         Ad.win = NULL;
623     }
624
625     if (Ad.bg) {
626         evas_object_del(Ad.bg);
627         Ad.bg = NULL;
628     }
629
630     if (Ad.ctg_bx) {
631         evas_object_del(Ad.ctg_bx);
632         Ad.ctg_bx = NULL;
633     }
634
635     if (Ad.ctg_bx2) {
636         evas_object_del(Ad.ctg_bx2);
637         Ad.ctg_bx2 = NULL;
638     }
639
640     for (i = 0; i < MAX_CATEGORY_NUM; i++) {
641         if (Ad.ctg_btn[i]) {
642             evas_object_del(Ad.ctg_btn[i]);
643             Ad.ctg_btn[i] = NULL;
644         }
645
646         if (Ad.vic_li[i]) {
647             evas_object_del(Ad.vic_li[i]);
648             Ad.vic_li[i] = NULL;
649         }
650
651         if (Ad.vic_val_dmy_text[i]) {
652             evas_object_del(Ad.vic_val_dmy_text[i]);
653             Ad.vic_val_dmy_text[i] = NULL;
654         }
655     }
656
657     if (Ad.vic_ini_li) {
658         evas_object_del(Ad.vic_ini_li);
659         Ad.vic_ini_li = NULL;
660     }
661
662     for (i = 0; i < MAX_PARA_NUM; i++) {
663         if (Ad.vic_val_text[i]) {
664             evas_object_del(Ad.vic_val_text[i]);
665             Ad.vic_val_text[i] = NULL;
666         }
667     }
668
669     for (i = 0; i < property_num; i++) {
670         result =
671             ico_dbus_amb_unsubscribe(vic_data[i].objpath_name,
672                                      vic_data[i].property_name,
673                                      vic_data[i].zone);
674
675         if (result != 0) {
676             if (result == -1) {
677                 ICO_ERR("Valid vehicle information name is not entered.");
678             }
679             else if (result == -2) {
680                 ICO_ERR("property is not subscribe.");
681             }
682         }
683     }
684     result = ico_dbus_amb_end();
685
686     ICO_DBG("app_terminate Leave");
687     return;
688 }
689
690 /**
691  * @brief elmListCreate
692  */
693 static void elmListCreate(void)
694 {
695     ICO_DBG("elmListCreate Enter");
696
697     int i;
698
699     if (NULL == Ad.win) {
700         ICO_ERR("main window is un-creating.");
701         return;
702     }
703
704     for (i = 0; i < property_num; i++) {
705         Ad.vic_val_text[i] = elm_label_add(Ad.win);
706         elm_list_item_append(Ad.vic_li[vic_data[i].category],
707                              vic_data[i].name, NULL, Ad.vic_val_text[i], NULL,
708                              NULL);
709     }
710
711     /* dummy set */
712     for (i = 0; i < MAX_CATEGORY_NUM; i++) {
713         Ad.vic_val_dmy_text[i] = elm_label_add(Ad.win);
714         elm_object_text_set(Ad.vic_val_dmy_text[i], DMY_DATA);
715         evas_object_color_set(Ad.vic_val_dmy_text[i], 255, 255, 255, 0);
716         elm_list_item_append(Ad.vic_li[i], NULL, NULL, Ad.vic_val_dmy_text[i],
717                              NULL, NULL);
718     }
719
720     ICO_DBG("elmListCreate Leave");
721     return;
722 }
723
724 /**
725  * @breif winCreate
726  */
727 static void winCreate(void)
728 {
729     ICO_DBG("winCreate Enter");
730
731     int i = 0;
732
733     if (NULL == Ad.win) {
734         ICO_ERR("main window is un-creating.");
735         return;
736     }
737
738     Ad.ctg_bx = elm_box_add(Ad.win);
739     evas_object_resize(Ad.ctg_bx, CTG_BX_W, CTG_BX_H);
740     evas_object_move(Ad.ctg_bx, CTG_BX_X, CTG_BX_Y);
741     evas_object_show(Ad.ctg_bx);
742
743     Ad.ctg_bx2 = elm_box_add(Ad.win);
744     evas_object_resize(Ad.ctg_bx2, CTG_BX_W, CTG_BX_H);
745     evas_object_move(Ad.ctg_bx2, (CTG_BX_X + CTG_BX_W), CTG_BX_Y);
746     evas_object_show(Ad.ctg_bx2);
747
748     for (i = 0; i < MAX_CATEGORY_NUM; i++) {
749         /* category buttn create */
750         Ad.ctg_btn[i] = elm_button_add(Ad.win);
751         elm_object_text_set(Ad.ctg_btn[i], vic_category_data[i].name);
752         if (i < (MAX_CATEGORY_NUM / 2)) {
753             elm_box_pack_end(Ad.ctg_bx, Ad.ctg_btn[i]);
754         }
755         else {
756             elm_box_pack_end(Ad.ctg_bx2, Ad.ctg_btn[i]);
757         }
758
759         /* The present category to support "Running Status" "Eenvironment" */
760         if ((vic_category_data[i].category == RUNNINGSTATUS)
761             || (vic_category_data[i].category == ENVIRONMENT)) {
762             evas_object_smart_callback_add(Ad.ctg_btn[i], "clicked",
763                                            on_ctg_mousedown,
764                                            &(vic_category_data[i].category));
765         }
766         else {
767             /* Unsupported Grayout */
768             evas_object_color_set(Ad.ctg_btn[i], 128, 128, 128, 255);
769         }
770
771         evas_object_size_hint_weight_set(Ad.ctg_btn[i], EVAS_HINT_EXPAND, 0);
772         evas_object_size_hint_align_set(Ad.ctg_btn[i], EVAS_HINT_FILL, 0);
773         evas_object_show(Ad.ctg_btn[i]);
774
775         /* list create */
776         Ad.vic_li[i] = elm_list_add(Ad.win);
777         elm_list_select_mode_set(Ad.vic_li[i], ELM_OBJECT_SELECT_MODE_NONE);
778         evas_object_resize(Ad.vic_li[i], VIC_LI_W, VIC_LI_H);
779         evas_object_move(Ad.vic_li[i], VIC_LI_X, VIC_LI_Y);
780     }
781
782     /* Initial list display */
783     Ad.vic_ini_li = elm_list_add(Ad.win);
784     elm_list_select_mode_set(Ad.vic_ini_li, ELM_OBJECT_SELECT_MODE_NONE);
785     evas_object_resize(Ad.vic_ini_li, VIC_LI_W, VIC_LI_H);
786     evas_object_move(Ad.vic_ini_li, VIC_LI_X, VIC_LI_Y);
787     elm_list_item_append(Ad.vic_ini_li, NULL, NULL, NULL, NULL, NULL);
788     elm_list_go(Ad.vic_ini_li);
789     evas_object_show(Ad.vic_ini_li);
790
791     ICO_DBG("winCreate Leave");
792     return;
793 }
794
795 /**
796  * @brief create_win
797  */
798 static Evas_Object *create_win(const char *name)
799 {
800     ICO_DBG("create_win Enter");
801
802     Evas_Object *eo;
803     eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
804     if (eo) {
805         elm_win_title_set(eo, name);
806         evas_object_smart_callback_add(eo, "delete,request", win_del, NULL);
807     }
808
809     ICO_DBG("create_win Leave");
810     return eo;
811 }
812
813 /**
814  * @brief app_create
815  */
816 static bool app_create(void *data)
817 {
818     ICO_DBG("app_create Enter");
819
820     /* main widnow */
821     Ad.win = create_win(MODULE_NAME);
822     if (Ad.win == NULL) {
823         ICO_ERR("main window is un-creating.");
824         return FALSE;
825     }
826     evas_object_show(Ad.win);
827
828     elm_win_indicator_mode_set(Ad.win, ELM_WIN_INDICATOR_SHOW);
829     elm_win_fullscreen_set(Ad.win, EINA_TRUE);
830
831     Ad.bg = elm_bg_add(Ad.win);
832     elm_win_resize_object_add(Ad.win, Ad.bg);
833     evas_object_size_hint_weight_set(Ad.bg, EVAS_HINT_EXPAND,
834                                      EVAS_HINT_EXPAND);
835     elm_bg_file_set(Ad.bg, BG_IMAGE_FILE, NULL);
836     evas_object_show(Ad.bg);
837
838     evas_object_resize(Ad.win, WIDTH, HEIGHT);
839
840     /* set font size */
841     (void) elm_config_font_overlay_set(TEXT_LIST_ITEM, FONT_FAMILY,
842                                        FONT_SIZE);
843     (void) elm_config_font_overlay_set(TEXT_BUTTON, FONT_FAMILY, FONT_SIZE);
844     (void) elm_config_font_overlay_set(TEXT_LABEL, FONT_FAMILY, FONT_SIZE);
845     (void) elm_config_font_overlay_apply();
846
847     winCreate();
848
849     elmListCreate();
850
851     ICO_DBG("app_create Leave");
852     return TRUE;                /* EXIT_SUCCESS */
853 }
854
855 int main(int argc, char *argv[])
856 {
857     char appid[256];
858     app_event_callback_s event_callback;
859     int pid = 0;
860     int result = 0;
861
862     /* Setting the log output */
863     memset(appid, 0x00, sizeof(appid));
864     pid = getpid();
865     if (aul_app_get_appid_bypid(pid, appid, sizeof(appid)) == AUL_R_OK) {
866         ico_log_open(appid);
867     }
868     else {
869         ico_log_open(MODULE_NAME);
870     }
871     ICO_INF("START_MODULE %s", MODULE_NAME);
872     ICO_DBG("main Enter");
873
874     /* Read configuration file */
875     if (get_config() != 0) {
876         ICO_ERR("get_config NG");
877         return EXIT_FAILURE;
878     }
879
880     /* Setting AMB */
881     if (amb_init() != EINA_TRUE) {
882         ICO_ERR("amb_init NG");
883         return EXIT_FAILURE;
884     }
885
886     /* set callback fanc */
887     event_callback.create = app_create;
888     event_callback.terminate = app_terminate;
889     event_callback.pause = NULL;
890     event_callback.resume = NULL;
891     event_callback.service = NULL;
892     event_callback.low_memory = NULL;
893     event_callback.low_battery = NULL;
894     event_callback.device_orientation = NULL;
895     event_callback.language_changed = NULL;
896     event_callback.region_format_changed = NULL;
897
898     memset(&Ad, 0x0, sizeof(struct appdata_t));
899
900     result = app_efl_main(&argc, &argv, &event_callback, &Ad);
901
902     ICO_DBG("main Leave");
903     ICO_INF("END_MODULE %s", MODULE_NAME);
904     return result;
905 }