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 sample navigation application main
21 #include <dbus/dbus.h>
22 #include <libwebsockets.h>
26 #include <Ecore_Evas.h>
27 #include <Elementary.h>
28 #include "samplenavi.h"
31 #include "ico_apf_ecore.h"
32 #include "ico_apf_log.h"
39 //#define TEST_TIME 0.001
40 //#define TEST_TIME 0.066
43 //#define DEBUG_METER_TEXT_DSP
45 //#define DEBUG_VIC_INFO_SET
46 #ifdef DEBUG_VIC_INFO_SET
48 extern int route_data_count;
49 extern CsvRoute csv_route[MAX_ROUTE_POINTS];
50 static double test_lat = 35.47945;
51 static double test_lon = 139.40026;
52 static int test_dir = 0;
53 static int test_cnt = 0;
57 /*============================================================================*/
58 /* Define fixed parameters */
59 /*============================================================================*/
61 #define CONFIG_FILE "/opt/apps/org.tizen.ico.app-samplenavi/res/config.txt"
62 #define DBUS_SERVICE "org.automotive.message.broker"
63 #define DBUS_INTERFACE "org.freedesktop.DBus.Properties"
64 #define DBUS_METHOD "Get"
65 #define MAX_PARA_NUM 4 /* Lat,Lon,Dir,VicSpeed */
69 #define VEHICLESPEED 3
72 #define ICO_APP_BUF_SIZE (1024)
74 /*============================================================================*/
75 /* Define data types */
76 /*============================================================================*/
82 dbus_uint32_t u32_val;
83 dbus_uint16_t u16_val;
95 char interface_name[64];
96 char property_name[32];
105 /*============================================================================*/
106 /* Function prototype for static(internal) functions */
107 /*============================================================================*/
108 static double get_time();
109 static void set_default_data();
110 static void load_config_file();
111 static void e_ui_draw();
112 static void e_ui_init();
113 static void e_map_init();
114 static void e_map_draw();
116 static void convert_data_evas_cv(Evas_Object *eo, IplImage *iplimage);
117 static void evas_object_image_from_cv(Evas_Object *eo, const char *filepath);
119 static Eina_Bool _time_interval_navi_cb(void *cam);
120 static Eina_Bool _time_interval_map_renew_cb(void *data);
121 static Eina_Bool callback_listener(void *data);
122 static int callback_http(struct libwebsocket_context *context,
123 struct libwebsocket *wsi,
124 enum libwebsocket_callback_reasons reason,
125 void *user, void *in, size_t len);
126 static bool parse_elementary_value(union VicVal_t *vic_val_p,
127 DBusMessageIter *iter);
128 static bool parse_value(union VicVal_t *vic_val_p, DBusMessageIter *iter);
129 static int getAmbDbus(int key, union VicVal_t *vic_val_p);
130 static void getLocationFromAmb();
131 static int get_config();
132 static char *edje_parse_str(void *in, int arg_num);
133 static void event_message(struct libwebsocket *wsi, char *format, ...);
134 static void _touch_up_edje(void *data, Evas *evas, Evas_Object *obj,
136 static int loading_edje_file(const char *edje_file);
137 static void res_callback(ico_apf_resource_notify_info_t *info,
140 /*============================================================================*/
141 /* Tables and Valiables */
142 /*============================================================================*/
143 int conf_data[CONF_DATA_MAX];
144 static const char *config_path = RESOURCE_DIR "/samplenavi.conf";
145 static const char *setting_button_path = IMAGES_DIR "/na_bt3_off.png";
146 static const char *goal_text_img_path = IMAGES_DIR "/na_goal_text.png";
147 static const char *default_url =
148 "file:///opt/apps/org.tizen.ico.app-samplenavi/res/Map/map.html";
151 static char sscrntype[32];
155 static Evas_Object *g_edje; /* loaded edje objects */
156 static char edje_str[ICO_APP_BUF_SIZE];
159 static int ui_vicspeed = 0;
160 static Evas_Object *ui_vicspeed_text;
161 static Evas_Object *ui_meter_l;
162 static Evas_Object *ui_meter_c[10];
163 static Evas_Object *ui_meter_r[10];
164 static int fig_l = 0;
165 static int fig_c = 0;
166 static int fig_r = 0;
168 const static char *meter_l_path = {
169 IMAGES_DIR "/Meter/Meters_SpeedNum_1l.png"
172 const static char *meter_c_path[10] = {
173 IMAGES_DIR "/Meter/Meters_SpeedNum_0c.png",
174 IMAGES_DIR "/Meter/Meters_SpeedNum_1c.png",
175 IMAGES_DIR "/Meter/Meters_SpeedNum_2c.png",
176 IMAGES_DIR "/Meter/Meters_SpeedNum_3c.png",
177 IMAGES_DIR "/Meter/Meters_SpeedNum_4c.png",
178 IMAGES_DIR "/Meter/Meters_SpeedNum_5c.png",
179 IMAGES_DIR "/Meter/Meters_SpeedNum_6c.png",
180 IMAGES_DIR "/Meter/Meters_SpeedNum_7c.png",
181 IMAGES_DIR "/Meter/Meters_SpeedNum_8c.png",
182 IMAGES_DIR "/Meter/Meters_SpeedNum_9c.png"
185 const static char *meter_r_path[10] = {
186 IMAGES_DIR "/Meter/Meters_SpeedNum_0r.png",
187 IMAGES_DIR "/Meter/Meters_SpeedNum_1r.png",
188 IMAGES_DIR "/Meter/Meters_SpeedNum_2r.png",
189 IMAGES_DIR "/Meter/Meters_SpeedNum_3r.png",
190 IMAGES_DIR "/Meter/Meters_SpeedNum_4r.png",
191 IMAGES_DIR "/Meter/Meters_SpeedNum_5r.png",
192 IMAGES_DIR "/Meter/Meters_SpeedNum_6r.png",
193 IMAGES_DIR "/Meter/Meters_SpeedNum_7r.png",
194 IMAGES_DIR "/Meter/Meters_SpeedNum_8r.png",
195 IMAGES_DIR "/Meter/Meters_SpeedNum_9r.png"
199 static DBusConnection *g_connection = NULL; /* D-Bus Connection */
200 static int property_num = 0;
201 const static char Bus_name[] = DBUS_SERVICE;
202 static struct vic_data_t vic_data[MAX_PARA_NUM];
204 const struct vic_key_data_t vic_key_data[] = {
205 {LATITUDE , "Latitude" },
206 {LONGITUDE , "Longitude" },
207 {DIRECTION , "Direction" },
208 {VEHICLESPEED, "VehicleSpeed"},
213 static Ecore_Evas *window;
220 IplImage *captureImage;
221 static CvCapture *capture;
228 Evas_Object *ui_goal_text;
229 Evas_Object *ui_address;
233 Evas_Object *ui_fps_bg;
234 Evas_Object *ui_polygon_count;
235 Evas_Object *ui_polygon_count_bg;
239 Evas_Object *browser;
242 static const char *test_camera_path = IMAGES_DIR "/test_cameraview.png";
245 static int connected = 0;
246 static struct libwebsocket *socket_val = NULL;
247 static struct libwebsocket_context *context;
248 static struct libwebsocket_protocols protocols[] = {
250 "http-only", /* name */
251 callback_http, /* callback */
252 0 /* per_session_data_size */
258 static int port = 50414;
259 static char addr[16] = "127.0.0.1";
260 static char proxy_uri[512] = "";
262 /*============================================================================*/
264 /*============================================================================*/
265 /*--------------------------------------------------------------------------*/
268 * Time acquisition(second).
271 * @return time(second)
273 /*--------------------------------------------------------------------------*/
274 static double get_time()
276 struct timeval sec_timeofday;
277 gettimeofday(&sec_timeofday, NULL);
278 return ((sec_timeofday.tv_sec) + (sec_timeofday.tv_usec / 1000000.0));
281 /*--------------------------------------------------------------------------*/
283 * @brief set_default_data
284 * Set Default data without define in conf file.
289 /*--------------------------------------------------------------------------*/
290 static void set_default_data()
294 for (i = 0; i < CONF_DATA_MAX; i++) {
295 if (conf_data[i] == 0) {
298 conf_data[USB_CAMERA_ID] = DEF_USB_CAMERA_ID;
300 case LANDMARK_POSITION:
301 conf_data[LANDMARK_POSITION] = DEF_LANDMARK_POSITION;
303 case LANDMARK_ROTATION:
304 conf_data[LANDMARK_ROTATION] = DEF_LANDMARK_ROTATION;
311 /*--------------------------------------------------------------------------*/
313 * @brief load_config_file
314 * A config file is loaded.
319 /*--------------------------------------------------------------------------*/
320 static void load_config_file()
327 for (i = 0; i < CONF_DATA_MAX; i++) {
331 if ((fp = fopen(config_path, "r")) == NULL) {
332 fprintf(stderr, "%s\n",
333 "Error : can't open file.(samplenavi.conf)\n");
336 uim_debug("USB_CAMERA_ID = %d", conf_data[USB_CAMERA_ID]);
337 uim_debug("LANDMARK_POSITION = %d", conf_data[LANDMARK_POSITION]);
338 uim_debug("LANDMARK_ROTATION = %d", conf_data[LANDMARK_ROTATION]);
342 while (fscanf(fp, "%s", str) != EOF) {
343 if (strncmp(str, "USBCAMERAID", 11) == 0) {
344 valuestr = strtok((char *) (str) + 12, "=");
345 if (valuestr != NULL) {
346 conf_data[USB_CAMERA_ID] = atoi(valuestr);
349 else if (strncmp(str, "LANDMARKPOSITION", 16) == 0) {
350 valuestr = strtok((char *) (str) + 17, "=");
351 if (valuestr != NULL) {
352 conf_data[LANDMARK_POSITION] = atoi(valuestr);
355 else if (strncmp(str, "LANDMARKROTATION", 16) == 0) {
356 valuestr = strtok((char *) (str) + 17, "=");
357 if (valuestr != NULL) {
358 conf_data[LANDMARK_ROTATION] = atoi(valuestr);
361 else if (strncmp(str, "WEBSOCKETPORT", 13) == 0) {
362 valuestr = strtok((char *) (str) + 14, "=");
363 if (valuestr != NULL) {
364 port = atoi(valuestr);
367 else if (strncmp(str, "IPADDR", 6) == 0) {
368 valuestr = strtok((char *) (str) + 7, "=");
369 if (valuestr != NULL) {
370 strcpy(addr, valuestr);
373 else if (strncmp(str, "PROXYURI", 8) == 0) {
374 valuestr = strtok((char *) (str) + 9, "=");
375 if (valuestr != NULL) {
376 strcpy(proxy_uri, valuestr);
385 uim_debug("USB_CAMERA_ID = %d", conf_data[USB_CAMERA_ID]);
386 uim_debug("LANDMARK_POSITION = %d", conf_data[LANDMARK_POSITION]);
387 uim_debug("LANDMARK_ROTATION = %d", conf_data[LANDMARK_ROTATION]);
388 uim_debug("WEBSOKET_PORT = %d", port);
389 uim_debug("IP_ADDR = %s", addr);
390 uim_debug("PROXY_URI = %s", proxy_uri);
395 /*--------------------------------------------------------------------------*/
403 /*--------------------------------------------------------------------------*/
404 static void e_ui_draw()
415 evas_object_show(ui_bg);
416 evas_object_show(ui_btn);
419 #ifdef DEBUG_METER_TEXT_DSP
420 sprintf(str, "[kph] %d", ui_vicspeed);
421 evas_object_text_text_set(ui_vicspeed_text, str);
422 evas_object_show(ui_vicspeed_text);
424 evas_object_show(ui_vicspeed_text);
427 uim_debug("MAX SPEED OVER [%d]", value);
431 w_fig_r = (value % 10);
433 w_fig_c = (value % 10);
435 w_fig_l = (value % 10);
438 if (w_fig_r != fig_r) {
439 evas_object_hide(ui_meter_r[fig_r]);
440 evas_object_show(ui_meter_r[w_fig_r]);
444 if (w_fig_c != fig_c || fig_c == 0) {
445 evas_object_hide(ui_meter_c[fig_c]);
447 if (w_fig_c != 0 || w_fig_l == 1) {
448 evas_object_show(ui_meter_c[w_fig_c]);
454 if (w_fig_l != fig_l) {
455 evas_object_hide(ui_meter_l);
458 evas_object_show(ui_meter_l);
465 if (enable_navi == TRUE && set_route == TRUE) {
466 if (goal_square_length <= (GOAL_MESSAGE_LENGTH * GOAL_MESSAGE_LENGTH)) {
467 evas_object_show(ui_goal_text);
470 evas_object_hide(ui_goal_text);
475 sprintf(str, "FPS : %.2f", fps);
476 evas_object_text_text_set(ui_fps, str);
477 sprintf(str, "Polygon : %d", polygon_count);
478 evas_object_text_text_set(ui_polygon_count, str);
482 /*--------------------------------------------------------------------------*/
485 * Initialize UI Layer.
490 /*--------------------------------------------------------------------------*/
491 static void e_ui_init()
498 ui_bg = evas_object_rectangle_add(e_ui);
499 evas_object_color_set(ui_bg, 0, 34, 119, 255);
500 evas_object_move(ui_bg, W_TEXTAREA_X, W_TEXTAREA_Y);
501 evas_object_resize(ui_bg, W_TEXTAREA_WIDTH, W_TEXTAREA_HEIGHT);
502 evas_object_show(ui_bg);
503 evas_object_layer_set(ui_bg, LAYER_UI);
505 ui_btn = evas_object_image_add(e_ui);
506 evas_object_image_file_set(ui_btn, setting_button_path, NULL);
507 evas_object_image_fill_set(ui_btn, 0, 0, W_NAVIBUTTON_WIDTH,
508 W_NAVIBUTTON_HEIGHT);
509 evas_object_move(ui_btn, W_NAVIBUTTON_X, W_NAVIBUTTON_Y);
510 evas_object_resize(ui_btn, W_NAVIBUTTON_WIDTH, W_NAVIBUTTON_HEIGHT);
511 evas_object_show(ui_btn);
512 evas_object_layer_set(ui_btn, LAYER_UI);
514 ui_goal_text = evas_object_image_add(e_ui);
515 evas_object_image_file_set(ui_goal_text, goal_text_img_path, NULL);
516 evas_object_image_fill_set(ui_goal_text, 0, 0, W_GOALMESSAGE_WIDTH,
517 W_GOALMESSAGE_HEIGHT);
518 evas_object_move(ui_goal_text, W_GOALMESSAGE_X, W_GOALMESSAGE_Y);
519 evas_object_resize(ui_goal_text, W_GOALMESSAGE_WIDTH,
520 W_GOALMESSAGE_HEIGHT);
521 evas_object_hide(ui_goal_text);
522 evas_object_layer_set(ui_goal_text, LAYER_UI);
525 #ifdef DEBUG_METER_TEXT_DSP
526 ui_vicspeed_text = evas_object_text_add(e_ui);
527 evas_object_text_style_set(ui_vicspeed_text, EVAS_TEXT_STYLE_PLAIN);
528 evas_object_color_set(ui_vicspeed_text, 255, 255, 255, 255);
529 evas_object_text_font_set(ui_vicspeed_text, "Utopia", 28);
530 sprintf(str, "[kph] %d", ui_vicspeed);
531 evas_object_text_text_set(ui_vicspeed_text, str);
532 evas_object_move(ui_vicspeed_text, 0, 430);
533 evas_object_resize(ui_vicspeed_text, W_METER_UNIT_WIDTH,
534 W_METER_UNIT_HEIGHT);
535 evas_object_show(ui_vicspeed_text);
536 evas_object_layer_set(ui_vicspeed_text, LAYER_UI);
538 ui_meter_l = evas_object_image_add(e_ui);
539 evas_object_image_file_set(ui_meter_l, meter_l_path, NULL);
540 evas_object_image_fill_set(ui_meter_l, 0, 0, W_METER_HEIGHT,
542 evas_object_move(ui_meter_l, W_METER_X, W_METER_Y);
543 evas_object_resize(ui_meter_l, W_METER_HEIGHT, W_METER_WIDTH);
544 evas_object_hide(ui_meter_l);
545 evas_object_layer_set(ui_meter_l, LAYER_UI);
547 for (i = 0; i < 10; i++) {
548 ui_meter_c[i] = evas_object_image_add(e_ui);
549 evas_object_image_file_set(ui_meter_c[i], meter_c_path[i], NULL);
550 evas_object_image_fill_set(ui_meter_c[i], 0, 0, W_METER_HEIGHT,
552 evas_object_move(ui_meter_c[i], W_METER_X, W_METER_Y);
553 evas_object_resize(ui_meter_c[i], W_METER_HEIGHT, W_METER_WIDTH);
554 evas_object_hide(ui_meter_c[i]);
555 evas_object_layer_set(ui_meter_c[i], LAYER_UI);
557 ui_meter_r[i] = evas_object_image_add(e_ui);
558 evas_object_image_file_set(ui_meter_r[i], meter_r_path[i], NULL);
559 evas_object_image_fill_set(ui_meter_r[i], 0, 0, W_METER_HEIGHT,
561 evas_object_move(ui_meter_r[i], W_METER_X, W_METER_Y);
562 evas_object_resize(ui_meter_r[i], W_METER_HEIGHT, W_METER_WIDTH);
563 evas_object_hide(ui_meter_r[i]);
564 evas_object_layer_set(ui_meter_r[i], LAYER_UI);
566 evas_object_show(ui_meter_r[0]);
568 ui_vicspeed_text = evas_object_text_add(e_ui);
569 evas_object_text_style_set(ui_vicspeed_text, EVAS_TEXT_STYLE_PLAIN);
570 evas_object_color_set(ui_vicspeed_text, 255, 255, 255, 255);
571 evas_object_text_font_set(ui_vicspeed_text, "Utopia", 24);
572 evas_object_text_text_set(ui_vicspeed_text, "kph");
573 evas_object_move(ui_vicspeed_text, W_METER_UNIT_X, W_METER_UNIT_Y);
574 evas_object_resize(ui_vicspeed_text, W_METER_UNIT_WIDTH,
575 W_METER_UNIT_HEIGHT);
576 evas_object_show(ui_vicspeed_text);
578 evas_object_layer_set(ui_vicspeed_text, LAYER_UI);
582 sprintf(str, "FPS : %.2f", fps);
584 ui_fps_bg = evas_object_rectangle_add(e_ui);
585 evas_object_color_set(ui_fps_bg, 255, 255, 255, 255);
586 evas_object_move(ui_fps_bg, 0, 0);
587 evas_object_resize(ui_fps_bg, 150, 20);
588 evas_object_show(ui_fps_bg);
589 evas_object_layer_set(ui_fps_bg, LAYER_UI);
591 ui_fps = evas_object_text_add(e_ui);
592 evas_object_text_style_set(ui_fps, EVAS_TEXT_STYLE_PLAIN);
593 evas_object_color_set(ui_fps, 0, 0, 0, 255);
594 evas_object_text_font_set(ui_fps, "Utopia", 14);
595 evas_object_text_text_set(ui_fps, str);
596 evas_object_move(ui_fps, 0, 0);
597 evas_object_resize(ui_fps, 250, 250);
598 evas_object_show(ui_fps);
599 evas_object_layer_set(ui_fps, LAYER_UI);
601 sprintf(str, "Polygon : %d", polygon_count);
603 ui_polygon_count_bg = evas_object_rectangle_add(e_ui);
604 evas_object_color_set(ui_polygon_count_bg, 255, 255, 255, 255);
605 evas_object_move(ui_polygon_count_bg, 0, 20);
606 evas_object_resize(ui_polygon_count_bg, 150, 20);
607 evas_object_show(ui_polygon_count_bg);
608 evas_object_layer_set(ui_polygon_count_bg, LAYER_UI);
610 ui_polygon_count = evas_object_text_add(e_ui);
611 evas_object_text_style_set(ui_polygon_count, EVAS_TEXT_STYLE_PLAIN);
612 evas_object_color_set(ui_polygon_count, 0, 0, 0, 255);
613 evas_object_text_font_set(ui_polygon_count, "Utopia", 14);
614 evas_object_text_text_set(ui_polygon_count, str);
615 evas_object_move(ui_polygon_count, 0, 20);
616 evas_object_resize(ui_polygon_count, 250, 250);
617 evas_object_show(ui_polygon_count);
618 evas_object_layer_set(ui_polygon_count, LAYER_UI);
622 /*--------------------------------------------------------------------------*/
625 * Initialize MAP Layer.
630 /*--------------------------------------------------------------------------*/
631 static void e_map_init()
633 e_map = ecore_evas_get(window);
634 browser = ewk_view_add(e_map);
636 if(strlen(proxy_uri)) {
637 ewk_context_proxy_uri_set(ewk_view_context_get(browser), proxy_uri);
640 evas_object_move(browser, W_MAP_ORIGINE_X, W_MAP_ORIGINE_Y);
641 evas_object_resize(browser, W_MAP_WIDTH, W_MAP_HEIGHT);
642 evas_object_show(browser);
643 ewk_view_uri_set(browser, default_url);
644 evas_object_layer_set(browser, LAYER_MAP);
647 /*--------------------------------------------------------------------------*/
650 * Draw Map Layer(EWebKit2)
655 /*--------------------------------------------------------------------------*/
656 static void e_map_draw()
658 evas_object_show(browser);
662 /*--------------------------------------------------------------------------*/
664 * @brief convert_data_evas_cv
665 * Convert IplImage object to Evas_Object.
667 * @param[out] eo Evas_Object
668 * @param[in] iplimagenone IplImage object
671 /*--------------------------------------------------------------------------*/
672 static void convert_data_evas_cv(Evas_Object *eo, IplImage *iplimage)
674 int image_data_size = (iplimage->width) * iplimage->height * 4;
675 unsigned char image[image_data_size];
678 if (image_data_size == 0) {
679 uim_debug("convert_data_evas_cv: IplImage empty error.");
683 for (i = 0; i < (iplimage->width * iplimage->height); i++) {
684 image[i * 4] = iplimage->imageData[(3 * i)];
685 image[(i * 4) + 1] = iplimage->imageData[(3 * i) + 1];
686 image[(i * 4) + 2] = iplimage->imageData[(3 * i) + 2];
687 image[(i * 4) + 3] = 255;
690 /* convert to Evas_Object */
691 evas_object_image_colorspace_set(eo, EVAS_COLORSPACE_ARGB8888);
692 evas_object_image_size_set(eo, iplimage->width, iplimage->height);
693 evas_object_image_data_set(eo, image);
696 /*--------------------------------------------------------------------------*/
698 * @brief evas_object_image_from_cv
699 * Load the picture to an IplImage object.
701 * @param[out] eo Evas_Object
702 * @param[in] filepath path of the file
705 /*--------------------------------------------------------------------------*/
706 static void evas_object_image_from_cv(Evas_Object *eo, const char *filepath)
711 iplimage = cvLoadImage(filepath, CV_LOAD_IMAGE_COLOR);
713 uim_debug("cvLoadImageError.");
716 convert_data_evas_cv(eo, iplimage);
720 /*--------------------------------------------------------------------------*/
722 * @brief _time_interval_navi_cb
723 * main timer for navigation.
725 * @param[out] cam Evas_Object
727 * @retval ECORE_CALLBACK_RENEW Return value to keep a callback
728 * @retval ECORE_CALLBACK_CANCEL Return value to remove a callback
730 /*--------------------------------------------------------------------------*/
731 static Eina_Bool _time_interval_navi_cb(void *cam)
733 static double webcam_timer = 0;
737 static double total_frame_time = 0;
738 static int frame_count = 0;
744 webcam_timer += TIME_INTERVAL_AR;
746 if (webcam_timer >= TIME_INTERVAL_CAMERA) {
749 /* Capture from Camera */
750 cam = evas_object_image_add(e_cam);
752 captureImage = cvQueryFrame(capture);
753 convert_data_evas_cv(cam, captureImage);
755 evas_object_image_fill_set(cam, 0, 0, W_WIDTH, W_NAVI_HEIGHT);
756 evas_object_move(cam, W_NAVI_ORIGINE_X, W_NAVI_ORIGINE_Y);
757 evas_object_resize(cam, W_WIDTH, W_NAVI_HEIGHT);
758 evas_object_show(cam);
761 evas_object_image_fill_set(cam, 0, 0, W_NAVI_WIDTH, W_NAVI_HEIGHT);
762 evas_object_move(cam, W_NAVI_ORIGINE_X, W_NAVI_ORIGINE_Y);
763 evas_object_resize(cam, W_NAVI_WIDTH, W_NAVI_HEIGHT);
764 evas_object_show(cam);
767 getLocationFromAmb();
778 /* render Map View */
783 if (frame_count == 0) {
787 else if (frame_count < 5) {
789 total_frame_time += t1 - t0;
795 total_frame_time -= total_frame_time / 4;
796 total_frame_time += t1 - t0;
799 fps = 4.0 * 1.0 / total_frame_time;
804 return ECORE_CALLBACK_RENEW;
807 /*--------------------------------------------------------------------------*/
809 * @brief _time_interval_map_renew_cb
810 * timer for renewal of a map.
812 * @param[out] data user data(UNUSED)
814 * @retval ECORE_CALLBACK_RENEW Return value to keep a callback
815 * @retval ECORE_CALLBACK_CANCEL Return value to remove a callback
817 /*--------------------------------------------------------------------------*/
818 static Eina_Bool _time_interval_map_renew_cb(void *data)
821 #ifdef DEBUG_VIC_INFO_SET
826 if (test_cnt < route_data_count) {
827 test_lat = csv_route[test_cnt].lat;
828 test_lon = csv_route[test_cnt].lon;
830 if ((test_cnt + 1) != route_data_count) {
831 lat_tmp = csv_route[test_cnt + 1].lat - test_lat;
832 lon_tmp = csv_route[test_cnt + 1].lon - test_lon;
834 if (lat_tmp >= 0 && lon_tmp >= 0) {
837 atan((fabs(lon_tmp) / fabs(lat_tmp))) * 180.0 / (atan(1.0) *
840 else if (lat_tmp < 0 && lon_tmp >= 0) {
843 atan((fabs(lat_tmp) / fabs(lon_tmp))) * 180.0 / (atan(1.0) *
846 else if (lat_tmp < 0 && lon_tmp < 0) {
849 atan((fabs(lon_tmp) / fabs(lat_tmp))) * 180.0 / (atan(1.0) *
852 else if (lat_tmp >= 0 && lon_tmp < 0) {
855 atan((fabs(lat_tmp) / fabs(lon_tmp))) * 180.0 / (atan(1.0) *
858 test_dir = test_dir + add_angle;
860 camera_geocode.lat = test_lat;
861 camera_geocode.lon = test_lon;
862 camera_geocode.dir = test_dir;
865 uim_debug("test_lat = [%f]", test_lat);
866 uim_debug("test_lon = [%f]", test_lon);
867 uim_debug("test_dir = [%d]", test_dir);
873 && ((map_pos.lat != camera_geocode.lat)
874 || (map_pos.lon != camera_geocode.lon))) {
875 map_pos.lat = camera_geocode.lat;
876 map_pos.lon = camera_geocode.lon;
878 uim_debug("map_pos.lat = [%f]", map_pos.lat);
879 uim_debug("map_pos.lon = [%f]", map_pos.lon);
881 event_message(socket_val, "CHG VAL VIC_INFO LAT %f LON %f",
882 map_pos.lat, map_pos.lon);
883 uim_debug("SEND LAT LON TO SINARIO(samplenavi)");
886 return ECORE_CALLBACK_RENEW;
889 /*--------------------------------------------------------------------------*/
891 * @brief callback_listener
892 * timer for libwebsocket connection surveillance.
894 * @param[out] data libwebsocket context
896 * @retval ECORE_CALLBACK_RENEW Return value to keep a callback
897 * @retval ECORE_CALLBACK_CANCEL Return value to remove a callback
899 /*--------------------------------------------------------------------------*/
900 static Eina_Bool callback_listener(void *data)
903 libwebsocket_service((struct libwebsocket_context *) data, 0);
906 uim_debug("WEBSOCKET CONNECTED ERROR");
907 if (context != NULL) {
908 libwebsocket_context_destroy(context);
911 context = libwebsocket_create_context(port, NULL,
913 libwebsocket_internal_extensions,
914 NULL, NULL, -1, -1, 0);
916 if (context == NULL) {
917 uim_debug("libwebsocket_create_context failed. (line:%d)",
926 return ECORE_CALLBACK_RENEW;
929 /*--------------------------------------------------------------------------*/
931 * @brief callback_http
932 * this callback function is notified from libwebsockets
934 * @param[in] context libwebsocket context
935 * @param[in] wsi libwebsockets management table
936 * @param[in] reason event type
937 * @param[in] user intact
938 * @param[in] in receive message
939 * @param[in] len message size[BYTE]
944 /*--------------------------------------------------------------------------*/
946 callback_http(struct libwebsocket_context *context, struct libwebsocket *wsi,
947 enum libwebsocket_callback_reasons reason, void *user, void *in,
951 unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 512 +
952 LWS_SEND_BUFFER_POST_PADDING];
953 unsigned char *p = &buf[LWS_SEND_BUFFER_PRE_PADDING];
956 uim_debug("call callback_http! size = %d", len);
957 uim_debug("callback_http REASON %d", reason);
960 case LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION:
961 uim_debug("CONNECTION %x", wsi);
963 case LWS_CALLBACK_ESTABLISHED:
964 uim_debug("ESTABLISHED %x", wsi);
966 n = sprintf((char *) p, "%s", "ANS HELLO");
968 case LWS_CALLBACK_ADD_POLL_FD:
969 uim_debug("RECIEVE REASON LWS_CALLBACK_ADD_POLL_FD");
971 case LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED:
973 ("RECIEVE REASON LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED");
975 case LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER:
977 ("RECIEVE REASON LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER");
979 case LWS_CALLBACK_CLIENT_ESTABLISHED:
980 uim_debug("RECIEVE REASON LWS_CALLBACK_CLIENT_ESTABLISHED");
982 case LWS_CALLBACK_SET_MODE_POLL_FD:
983 uim_debug("RECIEVE REASON LWS_CALLBACK_SET_MODE_POLL_FD");
985 case LWS_CALLBACK_CLEAR_MODE_POLL_FD:
986 uim_debug("RECIEVE REASON LWS_CALLBACK_CLEAR_MODE_POLL_FD");
988 case LWS_CALLBACK_CLIENT_WRITEABLE:
989 uim_debug("RECIEVE REASON LWS_CALLBACK_CLIENT_WRITEABLE");
991 case LWS_CALLBACK_RECEIVE:
994 && (strncmp((char *) in, "OPEN", strlen("OPEN")) == 0)) {
996 uim_debug("OPEN loading_edje_file [%s]", (char *) in);
997 strncpy(edje_str, edje_parse_str(in, 1), sizeof(edje_str));
998 loading_edje_file(&edje_str[0]);
1000 event_message(socket_val, "RESULT SUCCESS");
1001 uim_debug("SEND RESULT SUCCESS");
1004 else if ((in != NULL) && (strncmp("CLOSE", in, strlen("CLOSE")) == 0)) {
1005 evas_object_hide(g_edje);
1006 evas_object_del(g_edje);
1007 uim_debug("ONSCREEN CLOSE");
1010 /* Get route from navi.js */
1011 if (strncmp((char *) in, "<route>", strlen("<route>")) == 0) {
1012 uim_debug("<route> recv");
1013 init_e3d(e_3d, in, len);
1018 memset(data, 0, sizeof(data));
1019 strncpy(data, (char *) in, len);
1020 uim_debug("RECIEVE[%d] %s", len, data);
1023 uim_debug("ERROR data=null (line:%d)", __LINE__);
1027 if (strncmp((char *) data, "CHG SEQ REQ_NAV", 15) == 0) {
1028 uim_debug("RECIEVE COMMAND CHG SEQ REQ_NAV");
1032 else if (strncmp((char *) data, "CHG SEQ END_NAV", 15) == 0) {
1033 uim_debug("RECIEVE COMMAND CHG SEQ END_NAV");
1035 enable_navi = FALSE;
1037 else if (strncmp((char *) data, "ERR", 3) == 0) {
1040 case LWS_CALLBACK_CLIENT_RECEIVE:
1041 memset(data, 0, sizeof(data));
1042 strncpy(data, (char *) in, len);
1043 uim_debug("CLIENT_RECIEVE[%d] %s", len, data);
1045 case LWS_CALLBACK_CLOSED:
1046 uim_debug("RECIEVE REASON LWS_CALLBACK_CLOSED");
1050 uim_debug("REASON %d", reason);
1057 /*--------------------------------------------------------------------------*/
1059 * @brief parse_elementary_value
1060 * The message content received from DBus is acquired.
1062 * @param[out] vic_val_p Vehicles information data
1063 * @param[in] iter message received from DBus
1065 * @retval TRUE success
1066 * @retval FALSE error
1068 /*--------------------------------------------------------------------------*/
1070 parse_elementary_value(union VicVal_t *vic_val_p, DBusMessageIter *iter)
1072 dbus_int32_t i32_val;
1073 dbus_int32_t i16_val;
1074 dbus_uint32_t u32_val;
1075 dbus_uint16_t u16_val;
1084 if (vic_val_p == NULL || iter == NULL) {
1085 uim_debug("Err Parameter NG ");
1089 sig = dbus_message_iter_get_arg_type(iter);
1092 case DBUS_TYPE_INT32:
1093 dbus_message_iter_get_basic(iter, &i32_val);
1094 vic_val_p->i32_val = i32_val;
1097 case DBUS_TYPE_INT16:
1098 dbus_message_iter_get_basic(iter, &i16_val);
1099 vic_val_p->i16_val = i16_val;
1102 case DBUS_TYPE_UINT32:
1103 dbus_message_iter_get_basic(iter, &u32_val);
1104 vic_val_p->u32_val = u32_val;
1107 case DBUS_TYPE_UINT16:
1108 dbus_message_iter_get_basic(iter, &u16_val);
1109 vic_val_p->u16_val = u16_val;
1112 case DBUS_TYPE_BOOLEAN:
1113 dbus_message_iter_get_basic(iter, &b_val);
1114 vic_val_p->b_val = b_val;
1117 case DBUS_TYPE_BYTE:
1118 dbus_message_iter_get_basic(iter, &byte_val);
1119 vic_val_p->byte_val = byte_val;
1122 case DBUS_TYPE_DOUBLE:
1123 dbus_message_iter_get_basic(iter, &d_val);
1124 vic_val_p->d_val = d_val;
1127 case DBUS_TYPE_STRING:
1129 dbus_message_iter_get_basic(iter, &s_val);
1130 w_s_val = (char *) malloc(strlen(s_val) + 1);
1131 if (w_s_val == NULL) {
1132 uim_debug("Err malloc");
1135 strncpy(w_s_val, s_val, strlen(s_val));
1136 vic_val_p->s_val = w_s_val;
1141 uim_debug("Err parse_elementary_value: unknown type");
1148 /*--------------------------------------------------------------------------*/
1150 * @brief parse_value
1151 * parse message received from DBus
1153 * @param[out] vic_val_p Vehicles information data
1154 * @param[in] iter message received from DBus
1156 * @retval TRUE success
1157 * @retval FALSE error
1159 /*--------------------------------------------------------------------------*/
1160 static bool parse_value(union VicVal_t *vic_val_p, DBusMessageIter *iter)
1164 if (vic_val_p == NULL || iter == NULL) {
1165 uim_debug("Err Parameter NG ");
1169 curr = dbus_message_iter_get_arg_type(iter);
1172 case DBUS_TYPE_BYTE:
1173 case DBUS_TYPE_BOOLEAN:
1174 case DBUS_TYPE_INT16:
1175 case DBUS_TYPE_INT32:
1176 case DBUS_TYPE_UINT16:
1177 case DBUS_TYPE_UINT32:
1178 case DBUS_TYPE_DOUBLE:
1179 case DBUS_TYPE_STRING:
1180 return parse_elementary_value(vic_val_p, iter);
1181 case DBUS_TYPE_ARRAY:
1182 case DBUS_TYPE_STRUCT:
1183 case DBUS_TYPE_DICT_ENTRY:
1185 case DBUS_TYPE_INVALID:
1193 /*--------------------------------------------------------------------------*/
1196 * Vehicle information is acquired from AMB.(D-Bus)
1198 * @param[in] key vic_data index
1199 * @param[out] vic_val_p Vehicles information data
1201 * @retval = 0 success
1204 /*--------------------------------------------------------------------------*/
1205 static int getAmbDbus(int key, union VicVal_t *vic_val_p)
1207 /* local variable */
1208 DBusMessage *message;
1211 const char *v_string[] = { vic_data[key].interface_name,
1212 vic_data[key].property_name
1214 const char *dest = Bus_name;
1216 int reply_timeout = 1000; /* Millisecond */
1217 DBusMessageIter iter;
1218 DBusMessageIter iter_array;
1219 union VicVal_t *tmp_vic_val_p = vic_val_p;
1222 dbus_error_init(&error);
1224 if (NULL == g_connection) {
1225 /* obtain the right to use dbus */
1226 g_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
1228 if (g_connection == NULL) {
1229 uim_debug("Err dbus_bus_get");
1231 /* Release err parameter */
1232 dbus_error_free(&error);
1237 /* Constructs a new message */
1238 message = dbus_message_new_method_call(DBUS_SERVICE,
1239 vic_data[key].path_name,
1240 DBUS_INTERFACE, DBUS_METHOD);
1241 if (message == NULL) {
1242 uim_debug("Err dbus_message_new_method_call");
1244 /* Release the connection */
1245 dbus_connection_unref(g_connection);
1246 g_connection = NULL;
1250 /* Gets the type of a message */
1251 result = dbus_message_append_args(message,
1255 &v_string[1], DBUS_TYPE_INVALID);
1258 uim_debug("Err dbus_message_append_args");
1260 /* Release the connection */
1261 dbus_connection_unref(g_connection);
1262 g_connection = NULL;
1264 /* Release the message */
1265 dbus_message_unref(message);
1270 /* Gets the error name */
1271 if (dest && !dbus_message_set_destination(message, dest)) {
1272 uim_debug("Err dbus_message_new_method_call");
1274 /* Release the connection */
1275 dbus_connection_unref(g_connection);
1276 g_connection = NULL;
1278 /* Release the message */
1279 dbus_message_unref(message);
1284 /* Queues a message to send */
1285 reply = dbus_connection_send_with_reply_and_block(g_connection,
1287 reply_timeout, &error);
1288 if (reply == NULL) {
1289 uim_debug( "Err dbus_connection_send_with_reply_and_block" );
1291 /* Release the connection */
1292 dbus_connection_unref(g_connection);
1293 g_connection = NULL;
1295 /* Release the message */
1296 dbus_message_unref(message);
1298 /* Release err parameter */
1299 dbus_error_free(&error);
1304 /* Gets the result */
1305 dbus_message_iter_init(reply, &iter);
1306 dbus_message_iter_recurse(&iter, &iter_array);
1308 /* Type conversion of the resulting value */
1309 result = parse_value(tmp_vic_val_p, &iter_array);
1310 if (result != TRUE) {
1311 uim_debug("Err parse_elementary_value");
1313 /* Release the connection */
1314 dbus_connection_unref(g_connection);
1315 g_connection = NULL;
1317 /* Release the message */
1318 dbus_message_unref(message);
1319 dbus_message_unref(reply);
1324 /* Release the message */
1325 dbus_message_unref(message);
1326 dbus_message_unref(reply);
1331 /*--------------------------------------------------------------------------*/
1333 * @brief getLocationFromAmb
1334 * Location information acquisition from AMB.
1339 /*--------------------------------------------------------------------------*/
1340 static void getLocationFromAmb()
1342 union VicVal_t vic_val[32];
1346 for (i = 0; i < property_num; i++) {
1347 result = getAmbDbus(i, vic_val);
1350 uim_debug("Err getAmbDbus : Unacquired [%s]",vic_data[i].name);
1354 switch (vic_data[i].property) {
1356 if ((camera_geocode.lat != vic_val[0].d_val) &&
1357 (vic_val[0].d_val != 0)) {
1358 uim_debug("%s(%f)", vic_data[i].name, vic_val[0].d_val);
1359 camera_geocode.lat = vic_val[0].d_val;
1363 if ((camera_geocode.lon != vic_val[0].d_val) &&
1364 (vic_val[0].d_val != 0)) {
1365 uim_debug("%s(%f)", vic_data[i].name, vic_val[0].d_val);
1366 camera_geocode.lon = vic_val[0].d_val;
1370 if (camera_geocode.dir != vic_val[0].i32_val) {
1371 uim_debug("%s(%d)", vic_data[i].name, vic_val[0].i32_val);
1372 camera_geocode.dir = vic_val[0].i32_val;
1376 if (ui_vicspeed != vic_val[0].i32_val) {
1377 uim_debug("%s(%d)", vic_data[i].name, vic_val[0].i32_val);
1378 ui_vicspeed = vic_val[0].i32_val;
1382 uim_debug("ERROR no property : %s", vic_data[i].name);
1389 /*--------------------------------------------------------------------------*/
1392 * The config file for vehicle information acquisition is read.
1396 * @retval = 0 success
1399 /*--------------------------------------------------------------------------*/
1400 static int get_config()
1409 fp = fopen(CONFIG_FILE, "r");
1411 uim_debug("File open error");
1415 for (m = 0; k < MAX_PARA_NUM; m++) {
1416 if (fgets(buff, sizeof(buff) - 2, fp) != NULL) {
1417 tp = strtok(buff, clm);
1420 for (j = 0; vic_key_data[j].id != -1; j++) {
1421 if (strcmp(tp, vic_key_data[j].name) == 0) {
1422 vic_data[k].property = vic_key_data[j].id;
1423 strcpy(vic_data[k].name, tp);
1424 strcpy(vic_data[k].path_name, strtok(NULL, clm));
1425 strcpy(vic_data[k].interface_name,
1427 strcpy(vic_data[k].property_name,
1430 uim_debug("vic_data[%d].property=%d", k,
1431 vic_data[k].property);
1432 uim_debug("vic_data[%d].name=%s", k,
1434 uim_debug("vic_data[%d].path_name=%s", k,
1435 vic_data[k].path_name);
1436 uim_debug("vic_data[%d].interface_name=%s", k,
1437 vic_data[k].interface_name);
1438 uim_debug("vic_data[%d].property_name=%s", k,
1439 vic_data[k].property_name);
1444 if (vic_key_data[j].id == -1) {
1446 ("Err config.txt Line:%d Unregistered parameter name",
1452 uim_debug("config.txt Line:%d Comment out '#'Discovery",
1457 uim_debug("config.txt Line:%d Comment out Null line", m + 1);
1461 uim_debug("config.txt The end of data reading");
1468 if (property_num == 0) {
1469 uim_debug("config.txt No valid data");
1476 /*--------------------------------------------------------------------------*/
1478 * @brief edje_parse_str
1479 * A character string is decomposed by a delimiter.
1481 * @param[in] key vic_data index
1482 * @param[in] vic_val_p Vehicles information data
1483 * @return The pointer address to a lexical token
1484 * @retval > 0 success
1485 * @retval NULL error
1487 /*--------------------------------------------------------------------------*/
1488 static char *edje_parse_str(void *in, int arg_num)
1493 uim_debug("edje_parse_str %s, arg = %d", in, arg_num);
1494 data = strtok(in, " ");
1495 /* arg_num : 0 to n */
1496 for (i = 0; i < arg_num; i++) {
1497 data = strtok(NULL, " ");
1499 uim_debug("edje_parse_str data: %s", data);
1503 /*--------------------------------------------------------------------------*/
1505 * @brief event_message
1508 * @param[in] wsi libwebsockets management table to send
1509 * @param[in] fromat message to send
1512 /*--------------------------------------------------------------------------*/
1513 static void event_message(struct libwebsocket *wsi, char *format, ...)
1518 va_start(list, format);
1519 vsnprintf(message, sizeof(message), format, list);
1522 uim_debug("Setting screen: event_message wsi = %p, %s", wsi, message);
1525 unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 512 +
1526 LWS_SEND_BUFFER_POST_PADDING];
1527 unsigned char *p = &buf[LWS_SEND_BUFFER_PRE_PADDING];
1529 n = sprintf((char *) p, "%s", message);
1530 n = libwebsocket_write(wsi, p, n, LWS_WRITE_TEXT);
1531 uim_debug("Setting screen: libwebsocket_write return = %d", n);
1534 uim_debug("Setting screen: wsi is not initialized");
1540 /*--------------------------------------------------------------------------*/
1542 * @brief _touch_up_edje
1543 * Touch-up event processing.
1545 * @param[in] data user data
1546 * @param[in] obj evas object of the button
1547 * @param[in] event_info evas event infomation
1550 /*--------------------------------------------------------------------------*/
1552 _touch_up_edje(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1554 /* get name from userdata */
1556 uim_debug("Setting screen: user data is %s", (const char *) data);
1559 event_message(socket_val, "TOUCH %s %s", edje_str, data);
1560 uim_debug("SEND TOUCH %s ", data);
1564 uim_debug("Setting screen: user data is NULL");
1568 /*--------------------------------------------------------------------------*/
1570 * @brief loading_edje_file
1571 * Loading of edje file.
1573 * @param[in] edje_file edje file
1575 * @retval = 0 success
1578 /*--------------------------------------------------------------------------*/
1579 static int loading_edje_file(const char *edje_file)
1581 Evas_Object *part; /* part handle */
1582 Eina_List *group; /* edje group list */
1583 Eina_List *list; /* part list in edje */
1584 int group_count = 0; /* group counter */
1585 int name_count = 0; /* name counter */
1587 g_evas = ecore_evas_get(window);
1589 uim_debug("Setting screen: could not create evas.");
1594 evas_object_del(g_edje);
1596 /* create and add object in canvas from edje */
1597 g_edje = edje_object_add(g_evas);
1599 uim_debug("Setting screen: could not create edje object!");
1603 /* get group list */
1604 group = edje_file_collection_list(edje_file);
1605 while (group != NULL) {
1606 /* Set the edj file */
1607 if (!edje_object_file_set
1608 (g_edje, edje_file, (const char *) group->data)) {
1609 int err = edje_object_load_error_get(g_edje);
1610 const char *errmsg = edje_load_error_str(err);
1611 uim_debug("Setting screen: could not load %s: %s", edje_file,
1614 edje_file_collection_list_free(group);
1615 evas_object_del(g_edje);
1618 uim_debug("Setting screen: group[%d] data : %s", group_count,
1619 (const char *) group->data);
1622 list = edje_object_access_part_list_get(g_edje);
1623 while (list != NULL) {
1624 uim_debug("Setting screen: list[%d] data : %s", name_count,
1625 (const char *) list->data);
1627 /* set callback for part name */
1629 edje_object_part_object_get((const Evas_Object *) g_edje,
1630 (const char *) list->data);
1632 uim_debug("Setting screen: list[%d] name : %s", name_count,
1633 (const char *) list->data);
1634 evas_object_event_callback_add(part, EVAS_CALLBACK_MOUSE_UP,
1635 _touch_up_edje, list->data);
1638 uim_debug("Setting screen: list[%d] is NULL", name_count);
1647 group = group->next;
1650 uim_debug("Setting screen: group num is %d", group_count);
1651 uim_debug("Setting screen: name num is %d", name_count);
1653 /* Put in the image */
1654 evas_object_move(g_edje, 0, 0);
1655 /* Resize the image */
1656 evas_object_resize(g_edje, W_WIDTH, W_HEIGHT);
1657 /* Show the image */
1658 evas_object_show(g_edje);
1660 evas_object_layer_set(g_edje, LAYER_UI);
1665 /*--------------------------------------------------------------------------*/
1667 * @brief res_callback
1668 * Notice event processing of a resource state.
1670 * @param[in] info rsource information
1671 * @param[in] user_data user data(UNUSED)
1674 /*--------------------------------------------------------------------------*/
1676 res_callback(ico_apf_resource_notify_info_t *info, void *user_data)
1680 uim_debug("##==> Callbacked evt=%d res=%d id=%d bid=%d appid=%s dev=%s"
1681 " user_data=%d", info->state, info->resid, info->id, info->bid,
1682 info->appid, info->device, (int) user_data);
1684 switch (info->state) {
1685 case ICO_APF_RESOURCE_STATE_ACQUIRED:
1686 case ICO_APF_RESOURCE_STATE_DEPRIVED:
1687 case ICO_APF_RESOURCE_STATE_WAITTING:
1688 case ICO_APF_RESOURCE_STATE_RELEASED:
1689 if (info->resid == ICO_APF_RESID_INT_SCREEN) {
1691 ico_apf_resource_reply_int_screen_mode(info->device,
1692 info->bid, info->id,
1694 uim_debug("##==> callback reply int_screen(%s,%d,%d,1) = %d",
1695 info->device, info->bid, info->id, ret);
1697 else if (info->resid == ICO_APF_RESID_ON_SCREEN) {
1699 ico_apf_resource_reply_int_screen_mode_disp(info->device,
1701 uim_debug("##==> callback reply on_screen(%s,%d,1) = %d",
1702 info->device, info->id, ret);
1706 ico_apf_resource_reply_screen_mode(info->device, info->id, 1);
1707 uim_debug("##==> callback reply screen(%s,%d,1) = %d",
1708 info->device, info->id, ret);
1717 /*--------------------------------------------------------------------------*/
1719 * @brief sample navigation application
1722 * @param main() finction's standard parameter (argc,argv)
1724 * @retval =0 success
1725 * @retval =-1 failed
1727 /*--------------------------------------------------------------------------*/
1728 int main(int argc, char *argv[])
1732 char appid[ICO_UXF_MAX_PROCESS_NAME + 1];
1736 /* Setting the log output */
1737 if (ico_apf_get_app_id(0, appid) == ICO_APP_CTL_E_NONE) {
1738 ico_apf_log_open(appid);
1743 elm_init(argc, argv);
1745 enable_navi = FALSE;
1749 if (0 != get_config()) {
1750 uim_debug("ERROR get_config()");
1756 for (i = 1; i < argc; i++) {
1757 if (argv[i][0] == '-') {
1758 if (strcasecmp(argv[i], "-basescreen") == 0) {
1759 getscreen = 1; /* get base screen */
1760 strcpy(sscrntype, "BasicScreen");
1761 uim_debug("BasicScreen");
1763 else if (strcasecmp(argv[i], "-intscreen") == 0) {
1764 getscreen = 2; /* get interrupt screen */
1765 strcpy(sscrntype, "IntScreen");
1767 else if (strcasecmp(argv[i], "-onscreen") == 0) {
1768 getscreen = 3; /* get on screen */
1769 strcpy(sscrntype, "OnScreen");
1776 if (getscreen > 0) {
1777 /* initialize resource control for Ecore */
1778 if (ico_apf_ecore_init(NULL) != ICO_APF_E_NONE) {
1779 uim_debug("ico_apf_ecore_init() Error");
1780 ecore_evas_shutdown();
1784 /* set resource request callback */
1785 ico_apf_resource_set_event_cb(res_callback, NULL);
1787 /* acquire a right to display a screen */
1788 if (getscreen == 1) {
1789 ret = ico_apf_resource_get_screen_mode(NULL, 0);
1791 else if (getscreen == 2) {
1792 ret = ico_apf_resource_get_int_screen_mode(NULL, 0, 0);
1795 ret = ico_apf_resource_get_int_screen_mode_disp(NULL, 0);
1798 uim_debug("getscreen = %d, ret = %d", getscreen, ret);
1801 window = ecore_evas_new(NULL, 0, 0, W_WIDTH, W_HEIGHT, "frame=0");
1805 ecore_evas_show(window);
1808 e_cam = ecore_evas_get(window);
1809 cam = evas_object_image_add(e_cam);
1811 capture = cvCreateCameraCapture(conf_data[USB_CAMERA_ID]);
1813 uim_debug("cvCaptureFromCAM failed.");
1817 captureImage = cvQueryFrame(capture);
1818 uim_debug("camera width = %d, height = %d", captureImage->width,
1819 captureImage->height);
1820 convert_data_evas_cv(cam, captureImage);
1824 evas_object_image_from_cv(cam, test_camera_path);
1825 #else /* _USE_OPENCV_ */
1826 evas_object_image_file_set(cam, test_camera_path, NULL);
1827 #endif /* _USE_OPENCV_ */
1831 evas_object_image_fill_set(cam, 0, 0, W_NAVI_WIDTH, W_NAVI_HEIGHT);
1832 evas_object_move(cam, W_NAVI_ORIGINE_X, W_NAVI_ORIGINE_Y);
1833 evas_object_resize(cam, W_NAVI_WIDTH, W_NAVI_HEIGHT);
1834 evas_object_show(cam);
1837 e_3d = ecore_evas_get(window);
1840 e_ui = ecore_evas_get(window);
1845 libwebsocket_create_context(port, NULL, protocols,
1846 libwebsocket_internal_extensions, NULL,
1848 if (context == NULL) {
1849 fprintf(stderr, "libwebsocket_create_context failed.");
1854 ecore_timer_add(0.05, callback_listener, context);
1856 /* Browser(Map) Layer */
1862 ecore_timer_add(TIME_INTERVAL_AR, _time_interval_navi_cb, cam);
1864 ecore_timer_add(TEST_TIME, _time_interval_map_renew_cb, NULL);
1867 ecore_main_loop_begin();
1873 cvReleaseCapture(&capture);
1876 if (NULL != g_connection) {
1877 dbus_connection_unref(g_connection);
1878 g_connection = NULL;
1881 ico_apf_ecore_term();
1883 ecore_evas_free(window);
1884 ecore_evas_shutdown();
1889 fprintf(stderr, "Evas engine error.");
1890 ecore_evas_shutdown();