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.
24 //#include <VehicleInfo.h>
26 #include <Ecore_Evas.h>
28 #include <dbus/dbus.h> /* dbus */
29 #include <string.h> /* test log output */
30 #include <stdbool.h> // bool type define //TEST
32 //#include "app_log.h"
34 #include "ico_apf_ecore.h"
35 #include "ico_apf_log.h"
36 //#include "ico_uxf_conf_common.h"
38 //#define DEBUG_PRINT(...) ICO_UXF_DEBUG(__VA_ARGS__)
39 //#define ERROR_PRINT(...) ICO_UXF_WARN(__VA_ARGS__)
45 #define DEBUG_PRINT(...) LOG_PRINT(__VA_ARGS__)
46 #define LOG_PRINT(fmt,...) \
47 {log_print("%s> "fmt" (%s,%s:%d)\n", log_curtime("DBG"), ##__VA_ARGS__,\
48 __func__, __FILE__, __LINE__); }
50 static FILE *sDbgFd = (FILE *) 0;
51 void log_print(const char *fmt, ...)
56 vfprintf(sDbgFd, fmt, list);
61 /* local time difference(sec) */
62 static int sTimeZone = (99 * 60 * 60);
64 char *log_curtime(const char *level)
67 struct timeval NowTime;
71 gettimeofday(&NowTime, (struct timezone *) 0);
72 if (sTimeZone > (24 * 60 * 60)) {
76 NowTime.tv_sec -= sTimeZone;
78 sprintf(sBuf, "%02d:%02d:%02d.%03d[%s]@%d",
79 (int) ((NowTime.tv_sec / 3600) % 24),
80 (int) ((NowTime.tv_sec / 60) % 60),
81 (int) (NowTime.tv_sec % 60),
82 (int) NowTime.tv_usec / 1000, level, getpid());
88 /*============================================================================*/
89 /* Define fixed parameters */
90 /*============================================================================*/
91 #define WIDTH (700) /* Background width */
92 #define HEIGHT (934) /* Background height */
94 /* Count vehicle information */
95 static int property_num = 0;
97 /* max size of vehicle information */
98 #define MAX_PARA_NUM 32
100 /* vehicle information ID */
101 #define VEHICLESPEED 0
102 #define ACCELERATIONX 1
103 #define SHIFTPOSITION 2
104 #define ENGINESPEED 3
107 #define GEARPOSITION 6
112 #define BRAKEPRESSURE 10
115 #define BRAKESIGNAL 13
117 /* Definition for use with D-Bus */
118 #define DBUS_SERVICE "org.automotive.message.broker"
119 #define DBUS_INTERFACE "org.freedesktop.DBus.Properties"
120 #define DBUS_METHOD "Get"
122 /* Definition for files */
123 //#define CONFIG_FILE "/home/rpf/src/app/vic_inf_dspTP/vicsample_config.txt"
124 //#define TMP_LOG "/home/rpf/var/log/uifw/tmp_vic_inf_dspTP.log"
125 //#define LOG_NAME "/home/rpf/var/log/uifw/vic_inf_dspTP.log"
126 #define CONFIG_FILE "/opt/apps/org.tizen.ico.app-vicsample/res/vicsample_config.txt"
127 #define TMP_LOG "/tmp/tmp_ico-app-vicsample.log"
128 #define LOG_NAME "/tmp/ico-app-vicsample.log"
131 /* coordinates of vehicle information table frame */
132 #define VTX_SX 50.0F /* X position of the upper left corner */
133 #define VTX_SY 30.0F /* Y position of the upper left corner */
134 #define VTX_EX 650.0F /* X position of the lower right */
135 #define VTX_EY 830.0F /* Y position of the lower right */
136 #define FIX_LINE_NUM 6 /* The number of lines of the table */
137 /* Percentage of the column 13 = 1+4+4+4 */
138 /* No.[1]:Name(JP)[4]:Name(EN)[4]:Value[4] */
139 #define FIX_SEQ_BASE (VTX_EX - VTX_SX) / 13
140 /* X position of the 1st frame vertical line */
141 #define FIX_SEQ_LINE1 VTX_SX + FIX_SEQ_BASE
142 /* X position of the 2nd frame vertical line */
143 #define FIX_SEQ_LINE2 FIX_SEQ_LINE1 + (FIX_SEQ_BASE * 4)
144 /* X position of the 3rd frame vertical line */
145 #define FIX_SEQ_LINE3 FIX_SEQ_LINE2 + (FIX_SEQ_BASE * 4)
147 /* Horizontal line interval size */
148 #define UFIX_LINE_BASE (VTX_EY - VTX_SY)/MAX_PARA_NUM
150 /*============================================================================*/
151 /* Define data types */
152 /*============================================================================*/
155 dbus_int32_t i32_val;
156 dbus_int32_t i16_val;
157 dbus_uint32_t u32_val;
158 dbus_uint16_t u16_val;
170 char interface_name[64];
171 char property_name[32];
174 struct vic_key_data_t
180 /*============================================================================*/
181 /* Function prototype for static(internal) functions */
182 /*============================================================================*/
183 static void _canvas_resize_cb(Ecore_Evas *ee);
184 static void _on_destroy(Ecore_Evas *ee __UNUSED__);
185 static Eina_Bool _timer_cb(void *data);
186 static void cmdlog_output(int key);
187 static void drawVehicleInfo(void);
188 static void _on_mousedown(void *data, Evas *evas, Evas_Object *o,
190 static int getVehicleInfo(int key, union VicVal_t *vic_val_p);
191 static bool parse_elementary_value(union VicVal_t *vic_val_p,
192 DBusMessageIter *iter);
194 static bool parse_value(union VicVal_t *vic_val_p, DBusMessageIter *iter);
196 static bool parse_dict_entry(union VicVal_t *vic_val_p,
197 DBusMessageIter *iter);
199 static bool parse_array(union VicVal_t *vic_val_p, DBusMessageIter *iter);
201 static bool parse_struct(union VicVal_t *vic_val_p, DBusMessageIter *iter);
202 static int get_config(void);
204 /*============================================================================*/
205 /* Tables and Valiables */
206 /*============================================================================*/
207 const static char Bus_name[] = DBUS_SERVICE;
208 static struct vic_data_t vic_data[MAX_PARA_NUM];
210 const struct vic_key_data_t vic_key_data[] = {
211 {VEHICLESPEED, "VehicleSpeed"},
212 {ACCELERATIONX, "AccelerationX"},
213 {SHIFTPOSITION, "ShiftPosition"},
214 {ENGINESPEED, "EngineSpeed"},
215 {LATITUDE, "Latitude"},
216 {ALTITUDE, "Altitude"},
217 {GEARPOSITION, "GearPosition"},
218 {LONGITUDE, "Longitude"},
220 {DIRECTION, "Direction"},
221 {BRAKEPRESSURE, "BrakePressure"},
222 {LEFTTURN, "LeftTurn"},
223 {RIGHTTURN, "RightTurn"},
224 {BRAKESIGNAL, "BrakeSignal"},
228 /* Storage area of vehicle information */
229 static union VicVal_t s_vic_val[MAX_PARA_NUM];
230 /* Object for displaying vehicle information */
231 static Evas_Object *vic_val_text[MAX_PARA_NUM];
233 /* Table border line */
234 const static Evas_Coord f_vtx[FIX_LINE_NUM][4] = {
235 {VTX_SX, VTX_SY, VTX_SX, VTX_EY}, // Border of the Left frame
236 {VTX_EX, VTX_SY, VTX_EX, VTX_EY}, // Border of the Right frame
237 {VTX_SX, VTX_SY, VTX_EX, VTX_SY}, // Border of the upper frame
238 {VTX_SX, VTX_EY, VTX_EX, VTX_EY}, // Border of the lower frame
240 {FIX_SEQ_LINE1, VTX_SY, FIX_SEQ_LINE1, VTX_EY}, // Border of the column 1
241 {FIX_SEQ_LINE2, VTX_SY, FIX_SEQ_LINE2, VTX_EY}, // Border of the column 2
242 //{FIX_SEQ_LINE3, VTX_SY, FIX_SEQ_LINE3, VTX_EY} // Border of the column 3
245 //#define WIDTH (300)
246 //#define HEIGHT (300)
248 static Ecore_Evas *ee;
249 static Evas_Object *text, *bg;
250 static char sscrntype[32];
252 static const char commands[] =
254 "\tm - impose a minumum size to the window\n"
255 "\tx - impose a maximum size to the window\n"
256 "\tb - impose a base size to the window\n"
257 "\ts - impose a step size (different than 1 px) to the window\n"
258 "\th - print help\n";
260 /* to inform current window's size */
261 static void _canvas_resize_cb(Ecore_Evas *ee)
266 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
267 snprintf(buf, sizeof(buf), "%s %d x %d", sscrntype, w, h);
268 evas_object_text_text_set(text, buf);
269 evas_object_move(text, VTX_SX, VTX_SY - 22);
270 evas_object_resize(bg, w, h);
273 static void _on_destroy(Ecore_Evas *ee __UNUSED__)
275 ecore_main_loop_quit();
278 /* drawing current time */
279 static Eina_Bool _timer_cb(void *data)
284 timer = time(NULL); /* get time in seconds */
285 date = localtime(&timer); /* Converted to calendar time */
286 sprintf(str, "%s", asctime(date));
287 evas_object_text_text_set((Evas_Object *) data, str);
289 // drawVehicleInfo(); /* Get the vehicle information than AMB */ TEST
291 return EINA_TRUE; /* Continuation of the timer */
294 /* log output for DBUS command result (Debug functin) */
295 static void cmdlog_output(int key)
299 "dbus-send --system --dest=org.automotive.message.broker --type=method_call --print-reply";
300 char mes2[] = "org.freedesktop.DBus.Properties.Get";
301 char mes3[] = "string:";
303 sprintf(str, "%s %s %s %s\"%s\" %s\"%s\" > %s",
304 mes1, vic_data[key].path_name, mes2, mes3,
305 vic_data[key].interface_name, mes3, vic_data[key].property_name,
308 DEBUG_PRINT("%s(D-bus Command Result)", vic_data[key].name);
317 static void drawVehicleInfo()
319 union VicVal_t vic_val[32];
324 for (i = 0; i < property_num; i++) {
325 result = getVehicleInfo(i, vic_val);
328 uim_debug("Err getVehicleInfo : %s", vic_data[i].name);
332 switch (vic_data[i].property) {
334 uim_debug("%s(D-bus I/F Result) = %d", vic_data[i].name,
338 // if (vic_val[0].i32_val != s_vic_val[i].i32_val) {
339 // uim_debug("%s update Front:%d Back:%d", vic_data[i].name,
340 // s_vic_val[i].i32_val, vic_val[0].i32_val);
341 s_vic_val[i].i32_val = vic_val[0].i32_val;
344 sprintf(vic_str, "%d", vic_val[0].i32_val);
345 evas_object_text_text_set(vic_val_text[i], vic_str);
349 // uim_debug("%s no update:%d", vic_data[i].name,
350 // vic_val[0].i32_val);
356 uim_debug("%s(D-bus I/F Result) = %d", vic_data[i].name,
360 // if (vic_val[0].u16_val != s_vic_val[i].u16_val) {
361 // uim_debug("%s update Front:%d Back:%d", vic_data[i].name,
362 // s_vic_val[i].u16_val, vic_val[0].u16_val);
363 s_vic_val[i].u16_val = vic_val[0].u16_val;
366 sprintf(vic_str, "%d", vic_val[0].i32_val);
367 sprintf(vic_str, "%d", vic_val[0].u16_val);
368 evas_object_text_text_set(vic_val_text[i], vic_str);
371 // uim_debug("%s no update:%d", vic_data[i].name,
372 // vic_val[0].u16_val);
378 uim_debug("%s(D-bus I/F Result) = %d", vic_data[i].name,
379 vic_val[0].byte_val);
382 // if (vic_val[0].byte_val != s_vic_val[i].byte_val) {
383 // uim_debug("%s update Front:%d Back:%d", vic_data[i].name,
384 // s_vic_val[i].byte_val, vic_val[0].byte_val);
385 s_vic_val[i].byte_val = vic_val[0].byte_val;
388 sprintf(vic_str, "%d", vic_val[0].byte_val);
389 evas_object_text_text_set(vic_val_text[i], vic_str);
392 // uim_debug("%s noupdate:%d", vic_data[i].name,
393 // vic_val[0].byte_val);
401 uim_debug("%s(D-bus I/F Result) = %d", vic_data[i].name,
404 s_vic_val[i].i32_val = vic_val[0].i32_val;
405 sprintf(vic_str, "%d", vic_val[0].i32_val);
406 evas_object_text_text_set(vic_val_text[i], vic_str);
412 uim_debug("%s(D-bus I/F Result) = %f", vic_data[i].name,
415 s_vic_val[i].d_val = vic_val[0].d_val;
416 sprintf(vic_str, "%f", vic_val[0].d_val);
417 evas_object_text_text_set(vic_val_text[i], vic_str);
422 uim_debug("%s(D-bus I/F Result) = %d", vic_data[i].name,
423 vic_val[0].byte_val);
425 s_vic_val[i].byte_val = vic_val[0].byte_val;
426 sprintf(vic_str, "%d", vic_val[0].byte_val);
427 evas_object_text_text_set(vic_val_text[i], vic_str);
433 uim_debug("%s(D-bus I/F Result) = %d", vic_data[i].name,
436 s_vic_val[i].b_val = vic_val[0].b_val;
437 if (vic_val[0].b_val == TRUE) {
438 sprintf(vic_str, "%s", "true");
441 sprintf(vic_str, "%s", "false");
443 evas_object_text_text_set(vic_val_text[i], vic_str);
447 uim_debug("Err no property : %s\n", vic_data[i].name);
454 static void _on_mousedown(void *data, Evas *evas, Evas_Object *o,
461 /* Get the vehicle information than AMB */
462 DBusConnection *g_connection = NULL;
463 static int getVehicleInfo(int key, union VicVal_t *vic_val_p)
466 DBusMessage *message;
469 const char *v_string[] = {
470 vic_data[key].interface_name,
471 vic_data[key].property_name
473 const char *dest = Bus_name;
475 int reply_timeout = 1000; /* Millisecond */
476 DBusMessageIter iter;
477 DBusMessageIter iter_array;
480 dbus_error_init(&error);
482 if (NULL == g_connection) {
483 /* obtain the right to use dbus */
484 g_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
486 if (g_connection == NULL) {
487 uim_debug("Err dbus_bus_get");
489 /* Release err parameter */
490 dbus_error_free(&error);
494 /* Constructs a new message */
495 message = dbus_message_new_method_call(DBUS_SERVICE,
496 vic_data[key].path_name,
497 DBUS_INTERFACE, DBUS_METHOD);
498 if (message == NULL) {
499 uim_debug("Err dbus_message_new_method_call");
501 /* Release the connection */
502 dbus_connection_unref(g_connection);
507 /* Gets the type of a message */
508 result = dbus_message_append_args(message,
512 &v_string[1], DBUS_TYPE_INVALID);
514 uim_debug("Err dbus_message_append_args");
516 /* Release the connection */
517 dbus_connection_unref(g_connection);
519 /* Release the message */
520 dbus_message_unref(message);
525 /* Gets the error name */
526 if ((dest) && (!dbus_message_set_destination(message, dest))) {
527 uim_debug("Err dbus_message_new_method_call");
529 /* Release the connection */
530 dbus_connection_unref(g_connection);
533 /* Release the message */
534 dbus_message_unref(message);
539 /* Queues a message to send */
540 reply = dbus_connection_send_with_reply_and_block(g_connection,
542 reply_timeout, &error);
544 uim_debug("Err dbus_connection_send_with_reply_and_block");
546 /* Release the connection */
547 dbus_connection_unref(g_connection);
550 /* Release the message */
551 dbus_message_unref(message);
553 /* Release err parameter */
554 dbus_error_free(&error);
559 /* Gets the result */
560 dbus_message_iter_init(reply, &iter);
561 dbus_message_iter_recurse(&iter, &iter_array);
563 /* Type conversion of the resulting value */
564 // result = parse_elementary_value(vic_val_p, &iter_array);
565 union VicVal_t *tmp_vic_val_p = vic_val_p; //TEST
566 result = parse_value(tmp_vic_val_p, &iter_array); //TEST
568 if (result != TRUE) {
569 uim_debug("Err parse_elementary_value");
571 /* Release the connection */
572 dbus_connection_unref(g_connection);
575 /* Release the message */
576 dbus_message_unref(message);
577 dbus_message_unref(reply);
582 /* Release the message */
583 dbus_message_unref(message);
584 dbus_message_unref(reply);
589 /* Parse of the value */
590 static bool parse_elementary_value(union VicVal_t *vic_val_p,
591 DBusMessageIter *iter)
593 dbus_int32_t i32_val;
594 dbus_int32_t i16_val;
595 dbus_uint32_t u32_val;
596 dbus_uint16_t u16_val;
605 if ((vic_val_p == NULL) || (iter == NULL)) {
606 uim_debug("Err Parameter NG ");
610 sig = dbus_message_iter_get_arg_type(iter);
613 case DBUS_TYPE_INT32:
614 dbus_message_iter_get_basic(iter, &i32_val);
615 vic_val_p->i32_val = i32_val;
618 case DBUS_TYPE_INT16:
619 dbus_message_iter_get_basic(iter, &i16_val);
620 vic_val_p->i16_val = i16_val;
623 case DBUS_TYPE_UINT32:
624 dbus_message_iter_get_basic(iter, &u32_val);
625 vic_val_p->u32_val = u32_val;
628 case DBUS_TYPE_UINT16:
629 dbus_message_iter_get_basic(iter, &u16_val);
630 vic_val_p->u16_val = u16_val;
633 case DBUS_TYPE_BOOLEAN:
634 dbus_message_iter_get_basic(iter, &b_val);
635 vic_val_p->b_val = b_val;
639 dbus_message_iter_get_basic(iter, &byte_val);
640 vic_val_p->byte_val = byte_val;
643 case DBUS_TYPE_DOUBLE:
644 dbus_message_iter_get_basic(iter, &d_val);
645 vic_val_p->d_val = d_val;
648 case DBUS_TYPE_STRING:
649 dbus_message_iter_get_basic(iter, &s_val);
650 w_s_val = (char *) malloc(strlen(s_val) + 1); // Release required
651 if (w_s_val == NULL) {
652 uim_debug("Err malloc");
655 strncpy(w_s_val, s_val, strlen(s_val));
656 vic_val_p->s_val = w_s_val;
658 // vic_val_p->s_val = s_val;
661 uim_debug("Err parse_elementary_value: unknown type");
668 static bool parse_value(union VicVal_t *vic_val_p, DBusMessageIter *iter)
672 if ((vic_val_p == NULL) || (iter == NULL)) {
673 uim_debug("Err Parameter NG ");
677 curr = dbus_message_iter_get_arg_type(iter);
681 case DBUS_TYPE_BOOLEAN:
682 case DBUS_TYPE_INT16:
683 case DBUS_TYPE_INT32:
684 case DBUS_TYPE_UINT16:
685 case DBUS_TYPE_UINT32:
686 case DBUS_TYPE_DOUBLE:
687 case DBUS_TYPE_STRING:
688 return parse_elementary_value(vic_val_p, iter);
689 case DBUS_TYPE_ARRAY:
690 return parse_array(vic_val_p, iter);
691 case DBUS_TYPE_STRUCT:
692 return parse_struct(vic_val_p, iter);
693 case DBUS_TYPE_DICT_ENTRY:
694 // goto error; /* these are handled from parse_array */
696 case DBUS_TYPE_INVALID:
704 static bool parse_array(union VicVal_t *vic_val_p, DBusMessageIter *iter)
706 DBusMessageIter new_iter;
709 if ((vic_val_p == NULL) || (iter == NULL)) {
710 uim_debug("Err Parameter NG ");
717 element_type = dbus_message_iter_get_element_type(iter);
719 dbus_message_iter_recurse(iter, &new_iter);
721 /* the problem: if the value inside array is a dict entry, the
722 * indexing of elements need to be done with dict keys instead
725 if (element_type == DBUS_TYPE_DICT_ENTRY) {
726 while (dbus_message_iter_get_arg_type(&new_iter) != DBUS_TYPE_INVALID) {
728 parse_dict_entry(vic_val_p, &new_iter);
729 dbus_message_iter_next(&new_iter);
734 while (dbus_message_iter_get_arg_type(&new_iter) != DBUS_TYPE_INVALID) {
737 // lua_pushinteger(L, i++);
739 parse_value(vic_val_p, &new_iter);
740 dbus_message_iter_next(&new_iter);
742 /* put the values to the table */
743 // lua_settable(L, -3);
750 static bool parse_dict_entry(union VicVal_t *vic_val_p,
751 DBusMessageIter *iter)
753 DBusMessageIter new_iter;
755 if ((vic_val_p == NULL) || (iter == NULL)) {
756 uim_debug("Err Parameter NG ");
760 dbus_message_iter_recurse(iter, &new_iter);
762 while (dbus_message_iter_get_arg_type(&new_iter) != DBUS_TYPE_INVALID) {
764 /* key must be elementary, value can be anything */
766 parse_elementary_value(vic_val_p, &new_iter);
767 dbus_message_iter_next(&new_iter);
769 parse_value(vic_val_p, &new_iter);
770 dbus_message_iter_next(&new_iter);
772 /* put the values to the table */
773 // lua_settable(L, -3);
779 static bool parse_struct(union VicVal_t *vic_val_p, DBusMessageIter *iter)
781 DBusMessageIter new_iter;
783 if ((vic_val_p == NULL) || (iter == NULL)) {
784 uim_debug("Err Parameter NG ");
788 /* initialize the table */
791 dbus_message_iter_recurse(iter, &new_iter);
793 while (dbus_message_iter_get_arg_type(&new_iter) != DBUS_TYPE_INVALID) {
796 // lua_pushinteger(L, i++);
798 parse_value(vic_val_p, &new_iter);
799 dbus_message_iter_next(&new_iter);
801 /* put the values to the table */
802 // lua_settable(L, -3);
808 /* Read configuration file */
809 static int get_config(void)
819 fp = fopen(CONFIG_FILE, "r");
821 uim_debug("File open error");
825 for (m = 0; k < MAX_PARA_NUM; m++) {
826 if (fgets(buff, sizeof(buff) - 2, fp) != NULL) {
827 tp = strtok(buff, clm);
830 for (j = 0; vic_key_data[j].id != -1; j++) {
831 if (strcmp(tp, vic_key_data[j].name) == 0) {
832 vic_data[k].property = vic_key_data[j].id;
833 strcpy(vic_data[k].name, tp);
834 strcpy(vic_data[k].path_name, strtok(NULL, clm));
835 strcpy(vic_data[k].interface_name,
837 strcpy(vic_data[k].property_name,
839 uim_debug("vic_data[%d].property=%d", k,
840 vic_data[k].property);
841 uim_debug("vic_data[%d].name=%s", k,
843 uim_debug("vic_data[%d].path_name=%s", k,
844 vic_data[k].path_name);
845 uim_debug("vic_data[%d].interface_name=%s", k,
846 vic_data[k].interface_name);
847 uim_debug("vic_data[%d].property_name=%s", k,
848 vic_data[k].property_name);
854 if (vic_key_data[j].id == -1) {
855 uim_debug("Err vicsample_config.txt Line:%d Unregistered"
856 " parameter name", m + 1);
862 ("vicsample_config.txt Line:%d Comment out '#'Discovery",
867 uim_debug("vicsample_config.txt Line:%d Comment out Null line",
872 uim_debug("vicsample_config.txt The end of data reading");
879 if (property_num == 0) {
880 uim_debug("vicsample_config.txt No valid data");
886 static void res_callback(ico_apf_resource_notify_info_t *info,
891 uim_debug("##==> Callbacked evt=%d res=%d id=%d bid=%d appid=%s dev=%s"
892 " user_data=%d", info->state, info->resid, info->id,
893 info->bid, info->appid, info->device, (int) user_data);
894 switch (info->state) {
895 case ICO_APF_RESOURCE_STATE_ACQUIRED:
896 case ICO_APF_RESOURCE_STATE_DEPRIVED:
897 case ICO_APF_RESOURCE_STATE_WAITTING:
898 case ICO_APF_RESOURCE_STATE_RELEASED:
899 if (info->resid == ICO_APF_RESID_INT_SCREEN) {
900 ret = ico_apf_resource_reply_int_screen_mode(info->device,
903 uim_debug("##==> callback reply int_screen(%s,%d,%d,1) = %d",
904 info->device, info->bid, info->id, ret);
906 else if (info->resid == ICO_APF_RESID_ON_SCREEN) {
907 ret = ico_apf_resource_reply_int_screen_mode_disp(info->device,
909 uim_debug("##==> callback reply on_screen(%s,%d,1) = %d",
910 info->device, info->id, ret);
914 ico_apf_resource_reply_screen_mode(info->device, info->id, 1);
915 uim_debug("##==> callback reply screen(%s,%d,1) = %d",
916 info->device, info->id, ret);
925 int main(int argc, char *argv[])
930 char appid[ICO_UXF_MAX_PROCESS_NAME + 1];
935 b = bundle_import_from_argv(argc, argv);
939 val = bundle_get_val(b, "rightoption");
941 if (strcasecmp(val, "-basescreen") == 0) {
942 getscreen = 1; /* get base screen */
943 strcpy(sscrntype, "BasicScreen");
944 uim_debug("BasicScreen");
946 else if (strcasecmp(val, "-intscreen") == 0) {
947 getscreen = 2; /* get interrupt screen */
948 strcpy(sscrntype, "IntScreen");
950 else if (strcasecmp(val, "-onscreen") == 0) {
951 getscreen = 3; /* get on screen */
952 strcpy(sscrntype, "OnScreen");
957 if (!ecore_evas_init()) {
960 /* Setting the log output */
961 if (ico_apf_get_app_id(0, appid) == ICO_APP_CTL_E_NONE) {
962 ico_apf_log_open(appid);
965 uim_debug("main ENTER");
967 /* Read configuration file */
968 if (get_config() != 0) {
969 uim_debug("Err get_config");
974 /* initialize resource control for Ecore */
975 if (ico_apf_ecore_init(NULL) != ICO_APF_E_NONE) {
976 uim_debug("ico_apf_ecore_init() Error");
977 ecore_evas_shutdown();
981 /* set resource request callback */
982 ico_apf_resource_set_event_cb(res_callback, NULL);
984 /* acquire a right to display a screen */
985 if (getscreen == 1) {
986 ico_apf_resource_get_screen_mode(NULL, 0);
988 else if (getscreen == 2) {
989 ico_apf_resource_get_int_screen_mode(NULL, 0, 0);
992 ico_apf_resource_get_int_screen_mode_disp(NULL, 0);
996 /* this will give you a window with an Evas canvas under the first
997 * engine available */
998 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, "frame=0");
1003 ecore_evas_callback_delete_request_set(ee, _on_destroy);
1004 ecore_evas_title_set(ee, "Ecore_Evas window sizes example");
1005 ecore_evas_callback_resize_set(ee, _canvas_resize_cb);
1006 ecore_evas_show(ee);
1008 evas = ecore_evas_get(ee);
1010 /* Background printing */
1011 bg = evas_object_rectangle_add(evas);
1012 evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
1013 evas_object_move(bg, 0, 0); /* at canvas' origin */
1014 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
1015 evas_object_show(bg);
1017 evas_object_focus_set(bg, EINA_TRUE);
1019 /* Drawing window */
1020 text = evas_object_text_add(evas);
1021 evas_object_color_set(text, 255, 0, 0, 255);
1022 evas_object_resize(text, 150, 50);
1023 evas_object_text_font_set(text, "Sans", 20);
1024 evas_object_show(text);
1026 /* Button on the output drawing vehicle information */
1027 static Evas_Object *sikaku;
1028 sikaku = evas_object_rectangle_add(evas);
1029 evas_object_color_set(sikaku, 255, 0, 0, 100);
1030 evas_object_move(sikaku, 50, ((int) VTX_EY) + 7);
1031 int hsz = HEIGHT - (int) VTX_EY - 7 - 7;
1032 evas_object_resize(sikaku, 200, hsz);
1033 evas_object_show(sikaku);
1036 static Evas_Object *fix_line[FIX_LINE_NUM];
1038 for (i = 0; i < FIX_LINE_NUM; i++) {
1039 fix_line[i] = evas_object_line_add(evas);
1040 evas_object_color_set(fix_line[i], 55, 55, 55, 255);
1041 evas_object_line_xy_set(fix_line[i], f_vtx[i][0], f_vtx[i][1],
1042 f_vtx[i][2], f_vtx[i][3]);
1043 evas_object_show(fix_line[i]);
1046 /* draw order line */
1047 static Evas_Object *ufix_line[MAX_PARA_NUM - 1];
1049 for (i = 0; i < MAX_PARA_NUM - 1; i++) {
1050 ufix_line[i] = evas_object_line_add(evas);
1051 evas_object_color_set(ufix_line[i], 55, 55, 55, 255);
1052 evas_object_line_xy_set(ufix_line[i],
1053 VTX_SX, VTX_SY + UFIX_LINE_BASE * (i + 1),
1054 VTX_EX, VTX_SY + UFIX_LINE_BASE * (i + 1));
1055 evas_object_show(ufix_line[i]);
1058 /* draw table item */
1059 static Evas_Object *num_text[MAX_PARA_NUM];
1061 static Evas_Object *pname_text2[MAX_PARA_NUM];
1063 for (i = 0; i < MAX_PARA_NUM; i++) {
1064 /* draw table item (No.) */
1065 num_text[i] = evas_object_text_add(evas);
1066 evas_object_color_set(num_text[i], 0, 0, 0, 255);
1067 evas_object_resize(num_text[i], FIX_SEQ_BASE, UFIX_LINE_BASE);
1068 evas_object_text_font_set(num_text[i], "Sans",
1069 (UFIX_LINE_BASE / 3) * 2);
1070 evas_object_show(num_text[i]);
1071 sprintf(str, "%d", i + 1);
1072 evas_object_text_text_set(num_text[i], str);
1073 evas_object_move(num_text[i], VTX_SX + FIX_SEQ_BASE / 4,
1074 VTX_SY + UFIX_LINE_BASE * (i) + UFIX_LINE_BASE / 6);
1076 /* draw table item (Name of vehicle information) */
1077 pname_text2[i] = evas_object_text_add(evas);
1078 evas_object_color_set(pname_text2[i], 0, 0, 0, 255);
1079 evas_object_resize(pname_text2[i], 150, 50);
1080 evas_object_text_font_set(pname_text2[i], "Sans",
1081 (UFIX_LINE_BASE / 3) * 2);
1082 evas_object_show(pname_text2[i]);
1083 evas_object_text_text_set(pname_text2[i], vic_data[i].name);
1084 evas_object_move(pname_text2[i], FIX_SEQ_LINE1 + FIX_SEQ_BASE / 4,
1085 VTX_SY + UFIX_LINE_BASE * (i) + UFIX_LINE_BASE / 6);
1087 /* draw table item (Value of vehicle information) */
1088 vic_val_text[i] = evas_object_text_add(evas);
1089 evas_object_color_set(vic_val_text[i], 0, 0, 0, 255);
1090 evas_object_resize(vic_val_text[i], FIX_SEQ_BASE, UFIX_LINE_BASE);
1091 evas_object_text_font_set(vic_val_text[i], "Sans",
1092 (UFIX_LINE_BASE / 3) * 2);
1093 evas_object_show(vic_val_text[i]);
1094 evas_object_move(vic_val_text[i], FIX_SEQ_LINE2 + FIX_SEQ_BASE / 4,
1095 VTX_SY + UFIX_LINE_BASE * (i) + UFIX_LINE_BASE / 6);
1098 /* entry of the function event callback Vehicle Information */
1099 evas_object_event_callback_add(sikaku, EVAS_CALLBACK_MOUSE_DOWN,
1100 _on_mousedown, vic_val_text);
1102 /* drawing current time */
1103 static Evas_Object *time_text;
1105 time_text = evas_object_text_add(evas);
1106 evas_object_color_set(time_text, 0, 0, 0, 255);
1107 evas_object_resize(time_text, 150, 50);
1108 evas_object_text_font_set(time_text, "Sans", 20);
1109 evas_object_show(time_text);
1110 evas_object_move(time_text, 400, VTX_SY - 22);
1112 /* entry of the function event Interval Timer */
1113 ecore_timer_add(0.1, _timer_cb, time_text);
1115 _canvas_resize_cb(ee);
1116 fprintf(stdout, commands);
1117 ecore_main_loop_begin();
1119 ico_apf_ecore_term();
1121 ecore_evas_free(ee);
1122 ecore_evas_shutdown();
1124 if (NULL != g_connection) {
1125 dbus_connection_unref(g_connection);
1126 g_connection = NULL;
1128 uim_debug("main EXIT");
1132 fprintf(stderr, "You got to have at least one Evas engine built"
1133 " and linked up to ecore-evas for this example to run"
1135 ecore_evas_shutdown();
1136 if (NULL != g_connection) {
1137 dbus_connection_unref(g_connection);
1138 g_connection = NULL;