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 Vehicles Sample APP
11 * Vehicles information is displayed.
25 #include <Ecore_Evas.h>
26 #include <Elementary.h>
27 //#include <Ecore_X.h>
29 #include <dbus/dbus.h>
33 //#include "ico_apf.h"
34 //#include "ico_apf_ecore.h"
35 //#include "ico_apf_log.h"
39 /*============================================================================*/
40 /* Define fixed parameters */
41 /*============================================================================*/
42 #define STATUS_BAR_HEIGHT (64)
43 #define CTRL_BAR_HEIGHT (128)
44 #define WIDTH (1080) /* Base Background width */
45 #define HEIGHT (1920 - STATUS_BAR_HEIGHT - CTRL_BAR_HEIGHT) /* Base Background height */
48 #define SCRN_TYPE_W 800
49 #define SCRN_TYPE_H 20
52 //#define VIC_LI_W 1000
54 //#define VIC_LI_H 700
59 #define SCRN_TYPE_X 20
60 #define SCRN_TYPE_Y 20
63 //#define VIC_LI_X 900
66 //#define VIC_LI_Y 800
68 //#define GET_BTN_X 1000
69 //#define GET_BTN_Y 800
71 #define GET_BTN_Y 1530
75 #define FONT_FAMILY (char *)"Sans" // Mono, Sans, Serif
78 #define TEXT_BUTTON (char *)"button"
79 #define TEXT_LIST_ITEM (char *)"list_item"
80 #define TEXT_LABEL (char *)"label"
82 /* Count vehicle information */
83 static int property_num = 0;
85 /* max size of vehicle information */
86 #define MAX_PARA_NUM 32
88 /* vehicle information ID */
89 #define VEHICLESPEED 0
90 #define ACCELERATIONX 1
91 #define SHIFTPOSITION 2
95 #define GEARPOSITION 6
99 #define WHEELBRAKEPRESSURE 10
102 #define BRAKESIGNAL 13
103 #define ACCELERATIONY 14
104 #define ACCELERATIONZ 15
105 #define EXTERIORBRIGHTNESS 16
107 /* maximum categories */
108 #define PACKAG "ico-app-vicsample"
109 #define MAX_CATEGORY_NUM 8
111 /* vehicle information Parameter Category */
112 #define DRIVINGSAFETY 0
113 #define ELECTRICVEHICLE 1
114 #define ENVIRONMENT 2
115 #define MAINTENANCE 3
117 #define PERSONALIZATION 5
118 #define RUNNINGSTATUS 6
119 #define VEHICLEINFO 7
121 /* Definition for use with D-Bus */
122 #define DBUS_SERVICE "org.automotive.message.broker"
123 #define DBUS_INTERFACE "org.freedesktop.DBus.Properties"
124 #define DBUS_METHOD "Get"
126 /* Definition for files */
127 #define CONFIG_FILE "/usr/apps/org.tizen.ico.app-vicsample/res/vicsample_config.txt"
128 #define BG_IMAGE_FILE "/usr/apps/org.tizen.ico.app-vicsample/res/images/vicinfo_bg.png"
129 /*============================================================================*/
130 /* Define data types */
131 /*============================================================================*/
134 dbus_int32_t i32_val;
135 dbus_int32_t i16_val;
136 dbus_uint32_t u32_val;
137 dbus_uint16_t u16_val;
150 char interface_name[64];
151 char property_name[32];
154 struct vic_key_data_t
161 struct vic_category_data_t
169 Evas_Object *win; //main window
172 Evas_Object *scrn_type;
174 Evas_Object *ctg_bx2;
175 Evas_Object *ctg_btn[MAX_CATEGORY_NUM];
176 Evas_Object *vic_ini_li;
177 Evas_Object *vic_li[MAX_CATEGORY_NUM];
178 Evas_Object *vic_val_text[MAX_PARA_NUM];
179 Evas_Object *vic_val_dmy_text[MAX_CATEGORY_NUM];
180 Evas_Object *get_btn;
182 /*============================================================================*/
183 /* Function prototype for static(internal) functions */
184 /*============================================================================*/
185 static double Width = 0; /* Background width */
186 static double Height = 0; /* Background height */
187 static void drawVehicleInfo(void);
188 static void _on_mousedown(void *data, Evas_Object *obj, void *event_info);
189 static void _on_ctg_mousedown(void *data, Evas_Object *obj,
191 static int getVehicleInfo(int key, union VicVal_t *vic_val_p);
192 static bool parse_elementary_value(union VicVal_t *vic_val_p,
193 DBusMessageIter *iter);
195 static bool parse_value(union VicVal_t *vic_val_p, DBusMessageIter *iter);
197 static bool parse_dict_entry(union VicVal_t *vic_val_p,
198 DBusMessageIter *iter);
200 static bool parse_array(union VicVal_t *vic_val_p, DBusMessageIter *iter);
202 static bool parse_struct(union VicVal_t *vic_val_p, DBusMessageIter *iter);
204 static int get_config(void);
205 static void _winCreate(void);
206 static void elmListCreate(void);
207 /*============================================================================*/
208 /* Tables and Valiables */
209 /*============================================================================*/
210 const static char Bus_name[] = DBUS_SERVICE;
211 static struct vic_data_t vic_data[MAX_PARA_NUM];
212 static DBusConnection *g_connection = NULL;
213 static struct appdata_t Ad;
214 static char SscrnType[32];
215 static int ListDispSts = -1;
217 const struct vic_category_data_t vic_category_data[MAX_CATEGORY_NUM] = {
218 {DRIVINGSAFETY, "Driving safety"},
219 {ELECTRICVEHICLE, "Electric Vehicle"},
220 {ENVIRONMENT, "Environment"},
221 {MAINTENANCE, "Maintenance"},
222 {PARKING, "Parking"},
223 {PERSONALIZATION, "Personalization"},
224 {RUNNINGSTATUS, "Running Status"},
225 {VEHICLEINFO, "Vehicle Info"}
228 const struct vic_key_data_t vic_key_data[] = {
229 {VEHICLESPEED, RUNNINGSTATUS, "VehicleSpeed"},
230 {ACCELERATIONX, RUNNINGSTATUS, "AccelerationX"},
231 {SHIFTPOSITION, RUNNINGSTATUS, "ShiftPosition"},
232 {ENGINESPEED, RUNNINGSTATUS, "EngineSpeed"},
233 {LATITUDE, RUNNINGSTATUS, "Latitude"},
234 {ALTITUDE, RUNNINGSTATUS, "Altitude"},
235 {GEARPOSITION, RUNNINGSTATUS, "GearPosition"},
236 {LONGITUDE, RUNNINGSTATUS, "Longitude"},
237 {MODE, RUNNINGSTATUS, "Mode"},
238 {DIRECTION, RUNNINGSTATUS, "Direction"},
239 {WHEELBRAKEPRESSURE, RUNNINGSTATUS, "WheelBrakePressure"},
240 {LEFTTURN, RUNNINGSTATUS, "LeftTurn"},
241 {RIGHTTURN, RUNNINGSTATUS, "RightTurn"},
242 {BRAKESIGNAL, RUNNINGSTATUS, "BrakeSignal"},
243 {ACCELERATIONY, RUNNINGSTATUS, "AccelerationY"},
244 {ACCELERATIONZ, RUNNINGSTATUS, "AccelerationZ"},
245 {EXTERIORBRIGHTNESS, ENVIRONMENT, "ExteriorBrightness"},
249 /*============================================================================*/
251 /*============================================================================*/
252 static void drawVehicleInfo()
254 union VicVal_t vic_val[32];
259 for (i = 0; i < property_num; i++) {
260 result = getVehicleInfo(i, vic_val);
261 memset(vic_str, 0x00, sizeof(vic_str));
264 ICO_DBG("Err getVehicleInfo : %s", vic_data[i].name);
268 switch (vic_data[i].property) {
270 ICO_DBG("%s(D-bus I/F Result) = %d", vic_data[i].name,
273 sprintf(vic_str, "%d", vic_val[0].i32_val);
274 elm_object_text_set(Ad.vic_val_text[i], vic_str);
279 ICO_DBG("%s(D-bus I/F Result) = %d", vic_data[i].name,
282 sprintf(vic_str, "%d", vic_val[0].u16_val);
283 elm_object_text_set(Ad.vic_val_text[i], vic_str);
287 ICO_DBG("%s(D-bus I/F Result) = %d", vic_data[i].name,
288 vic_val[0].byte_val);
290 sprintf(vic_str, "%d", vic_val[0].byte_val);
291 elm_object_text_set(Ad.vic_val_text[i], vic_str);
296 case WHEELBRAKEPRESSURE:
298 ICO_DBG("%s(D-bus I/F Result) = %d", vic_data[i].name,
300 sprintf(vic_str, "%d", vic_val[0].i32_val);
301 elm_object_text_set(Ad.vic_val_text[i], vic_str);
307 ICO_DBG("%s(D-bus I/F Result) = %f", vic_data[i].name,
309 sprintf(vic_str, "%f", vic_val[0].d_val);
310 elm_object_text_set(Ad.vic_val_text[i], vic_str);
315 case EXTERIORBRIGHTNESS:
316 ICO_DBG("%s(D-bus I/F Result) = %d", vic_data[i].name,
317 vic_val[0].byte_val);
318 sprintf(vic_str, "%d", vic_val[0].byte_val);
319 elm_object_text_set(Ad.vic_val_text[i], vic_str);
325 ICO_DBG("%s(D-bus I/F Result) = %d", vic_data[i].name,
327 if (vic_val[0].b_val == TRUE) {
328 sprintf(vic_str, "%s", "true");
331 sprintf(vic_str, "%s", "false");
333 elm_object_text_set(Ad.vic_val_text[i], vic_str);
337 ICO_DBG("Err no property : %s\n", vic_data[i].name);
344 static void _on_mousedown(void *data, Evas_Object *obj, void *event_info)
350 static void _on_ctg_mousedown(void *data, Evas_Object *obj, void *event_info)
354 category = *((int *) data);
357 if ((category != -1) && (category != ListDispSts)) {
358 if (ListDispSts != -1) {
359 evas_object_color_set(Ad.ctg_btn[ListDispSts], 255, 255, 255,
361 evas_object_hide(Ad.vic_li[ListDispSts]);
364 evas_object_hide(Ad.vic_ini_li);
365 elm_list_clear(Ad.vic_ini_li);
367 evas_object_color_set(Ad.ctg_btn[category], 0, 255, 255, 255);
369 elm_list_go(Ad.vic_li[category]);
370 evas_object_show(Ad.vic_li[category]);
372 ListDispSts = category;
378 /* Get the vehicle information than AMB */
379 static int getVehicleInfo(int key, union VicVal_t *vic_val_p)
382 DBusMessage *message;
385 const char *v_string[] = {
386 vic_data[key].interface_name,
387 vic_data[key].property_name
389 const char *dest = Bus_name;
391 int reply_timeout = 1000; /* Millisecond */
392 DBusMessageIter iter;
393 DBusMessageIter iter_array;
396 dbus_error_init(&error);
398 if (NULL == g_connection) {
399 /* obtain the right to use dbus */
400 g_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
402 if (g_connection == NULL) {
403 ICO_DBG("Err dbus_bus_get");
405 /* Release err parameter */
406 dbus_error_free(&error);
410 /* Constructs a new message */
411 message = dbus_message_new_method_call(DBUS_SERVICE,
412 vic_data[key].path_name,
413 DBUS_INTERFACE, DBUS_METHOD);
414 if (message == NULL) {
415 ICO_DBG("Err dbus_message_new_method_call");
417 /* Release the connection */
418 dbus_connection_unref(g_connection);
423 /* Gets the type of a message */
424 result = dbus_message_append_args(message,
428 &v_string[1], DBUS_TYPE_INVALID);
430 ICO_DBG("Err dbus_message_append_args");
432 /* Release the connection */
433 dbus_connection_unref(g_connection);
435 /* Release the message */
436 dbus_message_unref(message);
441 /* Gets the error name */
442 if ((dest) && (!dbus_message_set_destination(message, dest))) {
443 ICO_DBG("Err dbus_message_new_method_call");
445 /* Release the connection */
446 dbus_connection_unref(g_connection);
449 /* Release the message */
450 dbus_message_unref(message);
455 /* Queues a message to send */
456 reply = dbus_connection_send_with_reply_and_block(g_connection,
458 reply_timeout, &error);
460 ICO_DBG("Err dbus_connection_send_with_reply_and_block");
462 /* Release the connection */
463 dbus_connection_unref(g_connection);
466 /* Release the message */
467 dbus_message_unref(message);
469 /* Release err parameter */
470 dbus_error_free(&error);
475 /* Gets the result */
476 dbus_message_iter_init(reply, &iter);
477 dbus_message_iter_recurse(&iter, &iter_array);
479 /* Type conversion of the resulting value */
480 // result = parse_elementary_value(vic_val_p, &iter_array);
481 union VicVal_t *tmp_vic_val_p = vic_val_p; //TEST
482 result = parse_value(tmp_vic_val_p, &iter_array); //TEST
484 if (result != TRUE) {
485 ICO_DBG("Err parse_elementary_value");
487 /* Release the connection */
488 dbus_connection_unref(g_connection);
491 /* Release the message */
492 dbus_message_unref(message);
493 dbus_message_unref(reply);
498 /* Release the message */
499 dbus_message_unref(message);
500 dbus_message_unref(reply);
505 /* Parse of the value */
506 static bool parse_elementary_value(union VicVal_t *vic_val_p,
507 DBusMessageIter *iter)
509 dbus_int32_t i32_val;
510 dbus_int32_t i16_val;
511 dbus_uint32_t u32_val;
512 dbus_uint16_t u16_val;
521 if ((vic_val_p == NULL) || (iter == NULL)) {
522 ICO_DBG("Err Parameter NG ");
526 sig = dbus_message_iter_get_arg_type(iter);
529 case DBUS_TYPE_INT32:
530 dbus_message_iter_get_basic(iter, &i32_val);
531 vic_val_p->i32_val = i32_val;
534 case DBUS_TYPE_INT16:
535 dbus_message_iter_get_basic(iter, &i16_val);
536 vic_val_p->i16_val = i16_val;
539 case DBUS_TYPE_UINT32:
540 dbus_message_iter_get_basic(iter, &u32_val);
541 vic_val_p->u32_val = u32_val;
544 case DBUS_TYPE_UINT16:
545 dbus_message_iter_get_basic(iter, &u16_val);
546 vic_val_p->u16_val = u16_val;
549 case DBUS_TYPE_BOOLEAN:
550 dbus_message_iter_get_basic(iter, &b_val);
551 vic_val_p->b_val = b_val;
555 dbus_message_iter_get_basic(iter, &byte_val);
556 vic_val_p->byte_val = byte_val;
559 case DBUS_TYPE_DOUBLE:
560 dbus_message_iter_get_basic(iter, &d_val);
561 vic_val_p->d_val = d_val;
564 case DBUS_TYPE_STRING:
565 dbus_message_iter_get_basic(iter, &s_val);
566 w_s_val = (char *) malloc(strlen(s_val) + 1); // Release required
567 if (w_s_val == NULL) {
568 ICO_DBG("Err malloc");
571 strncpy(w_s_val, s_val, strlen(s_val));
572 vic_val_p->s_val = w_s_val;
574 // vic_val_p->s_val = s_val;
577 ICO_DBG("Err parse_elementary_value: unknown type");
584 static bool parse_value(union VicVal_t *vic_val_p, DBusMessageIter *iter)
588 if ((vic_val_p == NULL) || (iter == NULL)) {
589 ICO_DBG("Err Parameter NG ");
593 curr = dbus_message_iter_get_arg_type(iter);
597 case DBUS_TYPE_BOOLEAN:
598 case DBUS_TYPE_INT16:
599 case DBUS_TYPE_INT32:
600 case DBUS_TYPE_UINT16:
601 case DBUS_TYPE_UINT32:
602 case DBUS_TYPE_DOUBLE:
603 case DBUS_TYPE_STRING:
604 return parse_elementary_value(vic_val_p, iter);
605 case DBUS_TYPE_ARRAY:
606 return parse_array(vic_val_p, iter);
607 case DBUS_TYPE_STRUCT:
608 return parse_struct(vic_val_p, iter);
609 case DBUS_TYPE_DICT_ENTRY:
610 // goto error; /* these are handled from parse_array */
612 case DBUS_TYPE_INVALID:
620 static bool parse_array(union VicVal_t *vic_val_p, DBusMessageIter *iter)
622 DBusMessageIter new_iter;
625 if ((vic_val_p == NULL) || (iter == NULL)) {
626 ICO_DBG("Err Parameter NG ");
633 element_type = dbus_message_iter_get_element_type(iter);
635 dbus_message_iter_recurse(iter, &new_iter);
637 /* the problem: if the value inside array is a dict entry, the
638 * indexing of elements need to be done with dict keys instead
641 if (element_type == DBUS_TYPE_DICT_ENTRY) {
642 while (dbus_message_iter_get_arg_type(&new_iter) != DBUS_TYPE_INVALID) {
644 parse_dict_entry(vic_val_p, &new_iter);
645 dbus_message_iter_next(&new_iter);
650 while (dbus_message_iter_get_arg_type(&new_iter) != DBUS_TYPE_INVALID) {
653 // lua_pushinteger(L, i++);
655 parse_value(vic_val_p, &new_iter);
656 dbus_message_iter_next(&new_iter);
658 /* put the values to the table */
659 // lua_settable(L, -3);
666 static bool parse_dict_entry(union VicVal_t *vic_val_p,
667 DBusMessageIter *iter)
669 DBusMessageIter new_iter;
671 if ((vic_val_p == NULL) || (iter == NULL)) {
672 ICO_DBG("Err Parameter NG ");
676 dbus_message_iter_recurse(iter, &new_iter);
678 while (dbus_message_iter_get_arg_type(&new_iter) != DBUS_TYPE_INVALID) {
680 /* key must be elementary, value can be anything */
682 parse_elementary_value(vic_val_p, &new_iter);
683 dbus_message_iter_next(&new_iter);
685 parse_value(vic_val_p, &new_iter);
686 dbus_message_iter_next(&new_iter);
688 /* put the values to the table */
689 // lua_settable(L, -3);
695 static bool parse_struct(union VicVal_t *vic_val_p, DBusMessageIter *iter)
697 DBusMessageIter new_iter;
699 if ((vic_val_p == NULL) || (iter == NULL)) {
700 ICO_DBG("Err Parameter NG ");
704 /* initialize the table */
707 dbus_message_iter_recurse(iter, &new_iter);
709 while (dbus_message_iter_get_arg_type(&new_iter) != DBUS_TYPE_INVALID) {
712 // lua_pushinteger(L, i++);
714 parse_value(vic_val_p, &new_iter);
715 dbus_message_iter_next(&new_iter);
717 /* put the values to the table */
718 // lua_settable(L, -3);
724 /* Read configuration file */
725 static int get_config(void)
727 ICO_DBG("ENTER get_config");
736 fp = fopen(CONFIG_FILE, "r");
738 ICO_DBG("File open error");
742 for (m = 0; k < MAX_PARA_NUM; m++) {
743 if (fgets(buff, sizeof(buff) - 2, fp) != NULL) {
744 tp = strtok(buff, clm);
747 for (j = 0; vic_key_data[j].id != -1; j++) {
748 if (strcmp(tp, vic_key_data[j].name) == 0) {
749 vic_data[k].property = vic_key_data[j].id;
750 vic_data[k].category = vic_key_data[j].category;
751 strcpy(vic_data[k].name, tp);
752 strcpy(vic_data[k].path_name, strtok(NULL, clm));
753 strcpy(vic_data[k].interface_name,
755 strcpy(vic_data[k].property_name,
757 ICO_DBG("vic_data[%d].property=%d", k,
758 vic_data[k].property);
759 ICO_DBG("vic_data[%d].name=%s", k,
761 ICO_DBG("vic_data[%d].path_name=%s", k,
762 vic_data[k].path_name);
763 ICO_DBG("vic_data[%d].interface_name=%s", k,
764 vic_data[k].interface_name);
765 ICO_DBG("vic_data[%d].property_name=%s", k,
766 vic_data[k].property_name);
772 if (vic_key_data[j].id == -1) {
774 ("Err vicsample_config.txt Line:%d Unregistered"
775 " parameter name", m + 1);
781 ("vicsample_config.txt Line:%d Comment out '#'Discovery",
787 ("vicsample_config.txt Line:%d Comment out Null line",
792 ICO_DBG("vicsample_config.txt The end of data reading");
799 if (property_num == 0) {
800 ICO_DBG("vicsample_config.txt No valid data");
804 ICO_DBG("LEAVE get_config");
808 static void res_callback(ico_apf_resource_notify_info_t *info,
813 ICO_DBG("##==> Callbacked evt=%d res=%d id=%d bid=%d appid=%s dev=%s"
814 " user_data=%d", info->state, info->resid, info->id,
815 info->bid, info->appid, info->device, (int) user_data);
816 switch (info->state) {
817 case ICO_APF_RESOURCE_STATE_ACQUIRED:
818 case ICO_APF_RESOURCE_STATE_DEPRIVED:
819 case ICO_APF_RESOURCE_STATE_WAITTING:
820 case ICO_APF_RESOURCE_STATE_RELEASED:
821 if (info->resid == ICO_APF_RESID_INT_SCREEN) {
822 ret = ico_apf_resource_reply_int_screen_mode(info->device,
825 ICO_DBG("##==> callback reply int_screen(%s,%d,%d,1) = %d",
826 info->device, info->bid, info->id, ret);
828 else if (info->resid == ICO_APF_RESID_ON_SCREEN) {
829 ret = ico_apf_resource_reply_int_screen_mode_disp(info->device,
831 ICO_DBG("##==> callback reply on_screen(%s,%d,1) = %d",
832 info->device, info->id, ret);
836 ico_apf_resource_reply_screen_mode(info->device, info->id, 1);
837 ICO_DBG("##==> callback reply screen(%s,%d,1) = %d",
838 info->device, info->id, ret);
850 static void _winCreate(void)
852 ICO_DBG("ENTER _winCreate");
858 if (NULL == Ad.win) {
859 ICO_DBG("Err Param NG");
863 w_mag = Width / WIDTH;
864 h_mag = Height / HEIGHT;
865 ICO_DBG("Width =%f,Height=%f", Width, Height);
866 ICO_DBG("w_mag =%f,h_magh=%f", w_mag, h_mag);
868 Ad.scrn_type = elm_label_add(Ad.win);
869 elm_object_text_set(Ad.scrn_type, SscrnType);
870 evas_object_resize(Ad.scrn_type, SCRN_TYPE_W * w_mag,
871 SCRN_TYPE_H * h_mag);
872 evas_object_move(Ad.scrn_type, SCRN_TYPE_X * w_mag, SCRN_TYPE_Y * h_mag);
873 evas_object_show(Ad.scrn_type);
875 Ad.ctg_bx = elm_box_add(Ad.win);
876 evas_object_resize(Ad.ctg_bx, CTG_BX_W * w_mag, CTG_BX_H * h_mag);
877 evas_object_move(Ad.ctg_bx, CTG_BX_X * w_mag, CTG_BX_Y * h_mag);
878 evas_object_show(Ad.ctg_bx);
880 Ad.ctg_bx2 = elm_box_add(Ad.win);
881 evas_object_resize(Ad.ctg_bx2, CTG_BX_W * w_mag , CTG_BX_H * h_mag);
882 evas_object_move(Ad.ctg_bx2, (CTG_BX_X + CTG_BX_W) * w_mag, CTG_BX_Y * h_mag);
883 evas_object_show(Ad.ctg_bx2);
885 for (i = 0; i < MAX_CATEGORY_NUM; i++) {
886 /* category buttn create */
887 Ad.ctg_btn[i] = elm_button_add(Ad.win);
888 elm_object_text_set(Ad.ctg_btn[i], vic_category_data[i].name);
889 if (i < (MAX_CATEGORY_NUM / 2)) {
890 elm_box_pack_end(Ad.ctg_bx, Ad.ctg_btn[i]);
893 elm_box_pack_end(Ad.ctg_bx2, Ad.ctg_btn[i]);
896 /* The present category to support "Running Status" "Eenvironment" */
897 if ((vic_category_data[i].category == RUNNINGSTATUS)
898 || (vic_category_data[i].category == ENVIRONMENT)) {
899 evas_object_smart_callback_add(Ad.ctg_btn[i], "clicked",
901 &(vic_category_data[i].category));
904 /* Unsupported Grayout */
905 evas_object_color_set(Ad.ctg_btn[i], 128, 128, 128, 255);
908 evas_object_size_hint_weight_set(Ad.ctg_btn[i], EVAS_HINT_EXPAND, 0);
909 evas_object_size_hint_align_set(Ad.ctg_btn[i], EVAS_HINT_FILL, 0);
910 evas_object_show(Ad.ctg_btn[i]);
913 Ad.vic_li[i] = elm_list_add(Ad.win);
914 elm_list_select_mode_set(Ad.vic_li[i], ELM_OBJECT_SELECT_MODE_NONE);
915 evas_object_resize(Ad.vic_li[i], VIC_LI_W * w_mag, VIC_LI_H * h_mag);
916 evas_object_move(Ad.vic_li[i], VIC_LI_X * w_mag, VIC_LI_Y * h_mag);
919 /* Initial list display */
920 Ad.vic_ini_li = elm_list_add(Ad.win);
921 elm_list_select_mode_set(Ad.vic_ini_li, ELM_OBJECT_SELECT_MODE_NONE);
922 evas_object_resize(Ad.vic_ini_li, VIC_LI_W * w_mag, VIC_LI_H * h_mag);
923 evas_object_move(Ad.vic_ini_li, VIC_LI_X * w_mag, VIC_LI_Y * h_mag);
924 elm_list_item_append(Ad.vic_ini_li, NULL, NULL, NULL, NULL, NULL);
925 elm_list_go(Ad.vic_ini_li);
926 evas_object_show(Ad.vic_ini_li);
928 Ad.get_btn = elm_button_add(Ad.win);
929 elm_object_text_set(Ad.get_btn, "Get VehicleInfo");
930 evas_object_smart_callback_add(Ad.get_btn, "clicked", _on_mousedown,
932 evas_object_resize(Ad.get_btn, GET_BTN_W * w_mag, GET_BTN_H * h_mag);
933 evas_object_move(Ad.get_btn, GET_BTN_X * w_mag, GET_BTN_Y * h_mag);
934 evas_object_show(Ad.get_btn);
936 ICO_DBG("LEAVE _winCreate");
941 * @brief elmListCreate
943 static void elmListCreate(void)
945 ICO_DBG("ENTER elmListCreate");
949 if (NULL == Ad.win) {
950 ICO_DBG("Err Param NG");
954 for (i = 0; vic_key_data[i].id != -1 && i < MAX_PARA_NUM; i++) {
955 Ad.vic_val_text[i] = elm_label_add(Ad.win);
956 elm_list_item_append(Ad.vic_li[vic_data[i].category],
957 vic_data[i].name, NULL, Ad.vic_val_text[i], NULL,
962 for (i = 0; i < MAX_CATEGORY_NUM; i++) {
963 Ad.vic_val_dmy_text[i] = elm_label_add(Ad.win);
964 elm_list_item_append(Ad.vic_li[i], NULL, NULL, NULL, NULL, NULL);
967 ICO_DBG("LEAVE elmListCreate");
972 * @brief app_terminate
974 static void app_terminate(void *data)
976 ICO_DBG("ENTER app_terminate");
977 // Release all resources
981 evas_object_del(Ad.win);
986 evas_object_del(Ad.bg);
991 evas_object_del(Ad.scrn_type);
996 evas_object_del(Ad.ctg_bx);
1001 evas_object_del(Ad.ctg_bx2);
1005 for (i = 0; i < MAX_CATEGORY_NUM; i++) {
1006 if (Ad.ctg_btn[i]) {
1007 evas_object_del(Ad.ctg_btn[i]);
1008 Ad.ctg_btn[i] = NULL;
1012 evas_object_del(Ad.vic_li[i]);
1013 Ad.vic_li[i] = NULL;
1016 if (Ad.vic_val_dmy_text[i]) {
1017 evas_object_del(Ad.vic_val_dmy_text[i]);
1018 Ad.vic_val_dmy_text[i] = NULL;
1022 if (Ad.vic_ini_li) {
1023 evas_object_del(Ad.vic_ini_li);
1024 Ad.vic_ini_li = NULL;
1027 for (i = 0; i < MAX_PARA_NUM; i++) {
1028 if (Ad.vic_val_text[i]) {
1029 evas_object_del(Ad.vic_val_text[i]);
1030 Ad.vic_val_text[i] = NULL;
1035 evas_object_del(Ad.get_btn);
1038 ICO_DBG("LEAVE app_terminate");
1045 static void _win_del(void *data, Evas_Object *obj, void *event_info)
1047 ICO_DBG("ENTER _win_del");
1051 ICO_DBG("LEAVE _win_del");
1056 * @brief _create_win
1058 static Evas_Object *_create_win(const char *name)
1060 ICO_DBG("ENTER _create_win");
1064 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
1066 elm_win_title_set(eo, name);
1067 evas_object_smart_callback_add(eo, "delete,request", _win_del, NULL);
1068 // ecore_x_window_size_get(ecore_x_window_root_first_get(), &w,
1070 // ICO_DBG("window size w=%d,h=%d",w,h);
1071 // evas_object_resize(eo, w, h - STATUS_BAR_HEIGHT);
1073 ICO_DBG("LEAVE _create_win");
1081 static bool app_create(void *data)
1083 ICO_DBG("ENTER app_create");
1088 /* get display size */
1089 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
1090 ICO_DBG("window size w=%d,h=%d", w, h);
1092 /* set app screen size */
1094 Height = h - STATUS_BAR_HEIGHT;
1101 Ad.win = _create_win(PACKAGE);
1102 if (Ad.win == NULL) {
1105 evas_object_show(Ad.win);
1107 elm_win_indicator_mode_set(Ad.win, ELM_WIN_INDICATOR_SHOW);
1108 elm_win_fullscreen_set(Ad.win, EINA_TRUE);
1110 Ad.bg = elm_bg_add(Ad.win);
1111 elm_win_resize_object_add(Ad.win, Ad.bg);
1112 evas_object_size_hint_weight_set(Ad.bg, EVAS_HINT_EXPAND,
1114 elm_bg_file_set(Ad.bg, BG_IMAGE_FILE, NULL);
1115 evas_object_show(Ad.bg);
1117 evas_object_resize(Ad.win, Width, Height);
1120 (void)elm_config_font_overlay_set(TEXT_LIST_ITEM, FONT_FAMILY, FONT_SIZE);
1121 (void)elm_config_font_overlay_set(TEXT_BUTTON, FONT_FAMILY, FONT_SIZE);
1122 (void)elm_config_font_overlay_set(TEXT_LABEL, FONT_FAMILY, FONT_SIZE);
1123 (void)elm_config_font_overlay_apply();
1129 ICO_DBG("LEAVE app_create");
1131 return TRUE; /* EXIT_SUCCESS */
1137 static int get_screen(int argc, char **argv)
1139 ICO_DBG("ENTER get_screen");
1145 b = bundle_import_from_argv(argc, argv);
1149 val = bundle_get_val(b, "rightoption");
1151 if (strcasecmp(val, "-basescreen") == 0) {
1152 getscreen = 1; /* get base screen */
1153 strcpy(SscrnType, "BasicScreen");
1154 ICO_DBG("BasicScreen");
1156 else if (strcasecmp(val, "-intscreen") == 0) {
1157 getscreen = 2; /* get interrupt screen */
1158 strcpy(SscrnType, "IntScreen");
1160 else if (strcasecmp(val, "-onscreen") == 0) {
1161 getscreen = 3; /* get on screen */
1162 strcpy(SscrnType, "OnScreen");
1167 if (getscreen > 0) {
1168 /* initialize resource control for Ecore */
1169 if (ico_apf_ecore_init(NULL) != ICO_APF_E_NONE) {
1170 ICO_DBG("ico_apf_ecore_init() Error");
1171 ecore_evas_shutdown();
1175 /* set resource request callback */
1176 ico_apf_resource_set_event_cb(res_callback, NULL);
1178 /* acquire a right to display a screen */
1179 if (getscreen == 1) {
1180 ico_apf_resource_get_screen_mode(NULL, 0);
1182 else if (getscreen == 2) {
1183 ico_apf_resource_get_int_screen_mode(NULL, 0, 0);
1186 ico_apf_resource_get_int_screen_mode_disp(NULL, 0);
1189 ICO_DBG("LEAVE get_screen");
1194 int main(int argc, char *argv[])
1196 // char appid[ICO_UXF_MAX_PROCESS_NAME + 1];
1199 app_event_callback_s event_callback;
1202 if (!ecore_evas_init()) {
1203 return EXIT_FAILURE;
1206 /* Setting the log output */
1207 // if (ico_apf_get_app_id(0, appid) == ICO_APP_CTL_E_NONE) {
1208 // ico_apf_log_open(appid);
1211 /* Setting the log output */
1212 memset(appid, 0, sizeof(appid));
1214 if (aul_app_get_appid_bypid(pid, appid, sizeof(appid)) == AUL_R_OK) {
1215 ico_log_open(appid);
1218 ico_log_open("org.tizen.ico.app-vicsample");
1221 ICO_DBG("ENTER main");
1223 /* Read configuration file */
1224 if (get_config() != 0) {
1225 ICO_DBG("Err get_config");
1226 return EXIT_FAILURE;
1230 // if (get_screen(argc, argv) != 0) {
1231 // ICO_DBG("Err get_argument");
1232 // return EXIT_FAILURE;
1235 /* set callback fanc */
1236 event_callback.create = app_create;
1237 event_callback.terminate = app_terminate;
1238 event_callback.pause = NULL;
1239 event_callback.resume = NULL;
1240 event_callback.service = NULL;
1241 event_callback.low_memory = NULL;
1242 event_callback.low_battery = NULL;
1243 event_callback.device_orientation = NULL;
1244 event_callback.language_changed = NULL;
1245 event_callback.region_format_changed = NULL;
1247 memset(&Ad, 0x0, sizeof(struct appdata_t));
1249 result = app_efl_main(&argc, &argv, &event_callback, &Ad);
1251 // ico_apf_ecore_term();
1252 ecore_evas_shutdown();
1254 if (NULL != g_connection) {
1255 dbus_connection_unref(g_connection);
1256 g_connection = NULL;
1258 ICO_DBG("EXIT main");