/[zanavi_public1]/navit/navit/android.c
ZANavi

Diff of /navit/navit/android.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 29 Revision 30
51jmethodID send_generic_text; 51jmethodID send_generic_text;
52jclass NavitMapPreviewActivityClass = NULL; 52jclass NavitMapPreviewActivityClass = NULL;
53jmethodID DrawMapPreview_target; 53jmethodID DrawMapPreview_target;
54jmethodID DrawMapPreview_polyline = NULL; 54jmethodID DrawMapPreview_polyline = NULL;
55jmethodID DrawMapPreview_text = NULL; 55jmethodID DrawMapPreview_text = NULL;
56jmethodID NavitGraphics_send_osd_values2 = NULL;
57jmethodID NavitGraphics_set_vehicle_values2 = NULL;
58jmethodID NavitGraphics_set_vehicle_values3 = NULL;
56 59
57struct attr attr; 60struct attr attr;
58
59
60
61
62
63
64 61
65// ------------------------- COPIED STUFF --- this is generally bad ------------------ 62// ------------------------- COPIED STUFF --- this is generally bad ------------------
66// ------------------------- COPIED STUFF --- this is generally bad ------------------ 63// ------------------------- COPIED STUFF --- this is generally bad ------------------
67// ------------------------- COPIED STUFF --- this is generally bad ------------------ 64// ------------------------- COPIED STUFF --- this is generally bad ------------------
68 65
69 66
70// copyied from config_.c !!! (always keep in sync!!!) 67// copyied from config_.c !!! (always keep in sync!!!)
71struct config { 68struct config
69{
72 struct attr **attrs; 70 struct attr **attrs;
73 struct callback_list *cbl; 71 struct callback_list *cbl;
74} *config; 72}*config;
75
76 73
77// copied from gui_internal.c (always keep in sync!!!) 74// copied from gui_internal.c (always keep in sync!!!)
78struct gui_config_settings { 75struct gui_config_settings
76{
79 int font_size; 77 int font_size;
80 int icon_xs; 78 int icon_xs;
81 int icon_s; 79 int icon_s;
82 int icon_l; 80 int icon_l;
83 int spacing; 81 int spacing;
84}; 82};
85 83
86
87// dummy def!! 84// dummy def!!
88struct gui_internal_methods { 85struct gui_internal_methods
86{
89 int dummy; 87 int dummy;
90}; 88};
91 89
92// dummy def!! 90// dummy def!!
93struct gui_internal_widget_methods { 91struct gui_internal_widget_methods
92{
94 int dummy; 93 int dummy;
95}; 94};
96 95
97
98// forward def 96// forward def
99struct gui_priv; 97struct gui_priv;
100 98
101// copied from gui_internal.h (always keep in sync!!!) 99// copied from gui_internal.h (always keep in sync!!!)
102struct gui_internal_data { 100struct gui_internal_data
101{
103 struct gui_priv *priv; 102 struct gui_priv *priv;
104 struct gui_internal_methods *gui; 103 struct gui_internal_methods *gui;
105 struct gui_internal_widget_methods *widget; 104 struct gui_internal_widget_methods *widget;
106}; 105};
107 106
108// copied from gui_internal.c (always keep in sync!!!) 107// copied from gui_internal.c (always keep in sync!!!)
109struct route_data { 108struct route_data
109{
110 struct widget * route_table; 110 struct widget * route_table;
111 int route_showing; 111 int route_showing;
112 112
113}; 113};
114 114
115// copied from gui_internal.h (always keep in sync!!!) 115// copied from gui_internal.h (always keep in sync!!!)
116enum flags { 116enum flags
117 gravity_none=0x00, 117{
118 gravity_left=1, 118 gravity_none = 0x00, gravity_left = 1, gravity_xcenter = 2, gravity_right = 4, gravity_top = 8, gravity_ycenter = 16, gravity_bottom = 32, gravity_left_top = gravity_left | gravity_top, gravity_top_center = gravity_xcenter | gravity_top, gravity_right_top = gravity_right | gravity_top, gravity_left_center = gravity_left | gravity_ycenter, gravity_center = gravity_xcenter | gravity_ycenter, gravity_right_center = gravity_right | gravity_ycenter, gravity_left_bottom = gravity_left | gravity_bottom, gravity_bottom_center = gravity_xcenter | gravity_bottom, gravity_right_bottom = gravity_right | gravity_bottom, flags_expand = 0x100, flags_fill = 0x200, orientation_horizontal = 0x10000, orientation_vertical = 0x20000, orientation_horizontal_vertical = 0x40000,
119 gravity_xcenter=2,
120 gravity_right=4,
121 gravity_top=8,
122 gravity_ycenter=16,
123 gravity_bottom=32,
124 gravity_left_top=gravity_left|gravity_top,
125 gravity_top_center=gravity_xcenter|gravity_top,
126 gravity_right_top=gravity_right|gravity_top,
127 gravity_left_center=gravity_left|gravity_ycenter,
128 gravity_center=gravity_xcenter|gravity_ycenter,
129 gravity_right_center=gravity_right|gravity_ycenter,
130 gravity_left_bottom=gravity_left|gravity_bottom,
131 gravity_bottom_center=gravity_xcenter|gravity_bottom,
132 gravity_right_bottom=gravity_right|gravity_bottom,
133 flags_expand=0x100,
134 flags_fill=0x200,
135 orientation_horizontal=0x10000,
136 orientation_vertical=0x20000,
137 orientation_horizontal_vertical=0x40000,
138}; 119};
139 120
140// copied from gui_internal.h (always keep in sync!!!) 121// copied from gui_internal.h (always keep in sync!!!)
141enum widget_type { 122enum widget_type
142 widget_box=1, 123{
143 widget_button, 124 widget_box = 1, widget_button, widget_label, widget_image, widget_table, widget_table_row
144 widget_label,
145 widget_image,
146 widget_table,
147 widget_table_row
148}; 125};
149 126
150// copied from gui_internal.c (always keep in sync!!!) 127// copied from gui_internal.c (always keep in sync!!!)
151struct widget { 128struct widget
129{
152 enum widget_type type; 130 enum widget_type type;
153 struct graphics_gc *background,*text_background; 131 struct graphics_gc *background, *text_background;
154 struct graphics_gc *foreground_frame; 132 struct graphics_gc *foreground_frame;
155 struct graphics_gc *foreground; 133 struct graphics_gc *foreground;
156 char *text; 134 char *text;
157 struct graphics_image *img; 135 struct graphics_image *img;
158 void (*func)(struct gui_priv *priv, struct widget *widget, void *data); 136 void (*func)(struct gui_priv *priv, struct widget *widget, void *data);
159 int reason; 137 int reason;
160 int datai; 138 int datai;
161 void *data; 139 void *data;
162 void (*data_free)(void *data); 140 void (*data_free)(void *data);
163 void (*free) (struct gui_priv *this_, struct widget * w); 141 void (*free)(struct gui_priv *this_, struct widget * w);
164 char *prefix; 142 char *prefix;
165 char *name; 143 char *name;
166 char *speech; 144 char *speech;
167 char *command; 145 char *command;
168 struct pcoord c; 146 struct pcoord c;
169 struct item item; 147 struct item item;
170 int selection_id; 148 int selection_id;
171 int state; 149 int state;
172 struct point p; 150 struct point p;
173 int wmin,hmin; 151 int wmin, hmin;
174 int w,h; 152 int w, h;
175 int textw,texth; 153 int textw, texth;
176 int font_idx; 154 int font_idx;
177 int bl,br,bt,bb,spx,spy; 155 int bl, br, bt, bb, spx, spy;
178 int border; 156 int border;
179 int packed; 157 int packed;
180 int cols; 158 int cols;
181 enum flags flags; 159 enum flags flags;
182 int flags2; 160 int flags2;
193 struct menu_data *menu_data; 171 struct menu_data *menu_data;
194 struct form *form; 172 struct form *form;
195 GList *children; 173 GList *children;
196}; 174};
197 175
198
199// copied from gui_internal.c !!!!!! (always keep in sync!!!) 176// copied from gui_internal.c !!!!!! (always keep in sync!!!)
200struct gui_priv { 177struct gui_priv
178{
201 struct navit *nav; 179 struct navit *nav;
202 struct attr self; 180 struct attr self;
203 struct window *win; 181 struct window *win;
204 struct graphics *gra; 182 struct graphics *gra;
205 struct graphics_gc *background; 183 struct graphics_gc *background;
219 int pressed; 197 int pressed;
220 struct widget *widgets; 198 struct widget *widgets;
221 int widgets_count; 199 int widgets_count;
222 int redraw; 200 int redraw;
223 struct widget root; 201 struct widget root;
224 struct widget *highlighted,*editable; 202 struct widget *highlighted, *editable;
225 struct widget *highlighted_menu; 203 struct widget *highlighted_menu;
226 int clickp_valid, vehicle_valid; 204 int clickp_valid, vehicle_valid;
227 struct pcoord clickp, vehiclep; 205 struct pcoord clickp, vehiclep;
228 struct attr *click_coord_geo, *position_coord_geo; 206 struct attr *click_coord_geo, *position_coord_geo;
229 struct search_list *sl; 207 struct search_list *sl;
234 int speech; 212 int speech;
235 int keyboard; 213 int keyboard;
236 int keyboard_required; 214 int keyboard_required;
237 struct gui_config_settings config; 215 struct gui_config_settings config;
238 struct event_idle *idle; 216 struct event_idle *idle;
239 struct callback *motion_cb,*button_cb,*resize_cb,*keypress_cb,*window_closed_cb,*idle_cb, *motion_timeout_callback; 217 struct callback *motion_cb, *button_cb, *resize_cb, *keypress_cb, *window_closed_cb, *idle_cb, *motion_timeout_callback;
240 struct event_timeout *motion_timeout_event; 218 struct event_timeout *motion_timeout_event;
241 struct point current; 219 struct point current;
242 struct callback * vehicle_cb; 220 struct callback * vehicle_cb;
243 struct route_data route_data; 221 struct route_data route_data;
244 struct gui_internal_data data; 222 struct gui_internal_data data;
245 struct callback_list *cbl; 223 struct callback_list *cbl;
246 int flags; 224 int flags;
247 int cols; 225 int cols;
248 struct attr osd_configuration; 226 struct attr osd_configuration;
249 int pitch; 227 int pitch;
250 int flags_town,flags_street,flags_house_number; 228 int flags_town, flags_street, flags_house_number;
251 int radius; 229 int radius;
252 char *html_text; 230 char *html_text;
253 int html_depth; 231 int html_depth;
254 struct widget *html_container; 232 struct widget *html_container;
255 int html_skip; 233 int html_skip;
256 char *html_anchor; 234 char *html_anchor;
257 char *href; 235 char *href;
258 int html_anchor_found; 236 int html_anchor_found;
259 struct form *form; 237 struct form *form;
260 struct html { 238 struct html
239 {
261 int skip; 240 int skip;
262 enum html_tag { 241 enum html_tag
263 html_tag_none, 242 {
264 html_tag_a, 243 html_tag_none, html_tag_a, html_tag_h1, html_tag_html, html_tag_img, html_tag_script, html_tag_form, html_tag_input, html_tag_div,
265 html_tag_h1,
266 html_tag_html,
267 html_tag_img,
268 html_tag_script,
269 html_tag_form,
270 html_tag_input,
271 html_tag_div,
272 } tag; 244 } tag;
273 char *command; 245 char *command;
274 char *name; 246 char *name;
275 char *href; 247 char *href;
276 char *refresh_cond; 248 char *refresh_cond;
277 struct widget *w; 249 struct widget *w;
278 struct widget *container; 250 struct widget *container;
279 } html[10]; 251 } html[10];
280}; 252};
281 253
282
283// ------------------------- COPIED STUFF --- this is generally bad ------------------ 254// ------------------------- COPIED STUFF --- this is generally bad ------------------
284// ------------------------- COPIED STUFF --- this is generally bad ------------------ 255// ------------------------- COPIED STUFF --- this is generally bad ------------------
285// ------------------------- COPIED STUFF --- this is generally bad ------------------ 256// ------------------------- COPIED STUFF --- this is generally bad ------------------
286 257
287 258
288
289
290JavaVM *cachedJVM = NULL; 259JavaVM *cachedJVM = NULL;
291 260
292JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) 261JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved)
293{ 262{
294 JNIEnv *env_this; 263 JNIEnv *env_this;
295 cachedJVM = jvm; 264 cachedJVM = jvm;
296 if ((*jvm)->GetEnv(jvm, (void**)&env_this, JNI_VERSION_1_6)) 265 if ((*jvm)->GetEnv(jvm, (void**) &env_this, JNI_VERSION_1_6))
297 { 266 {
298 dbg(0,"Could not get JVM\n"); 267 // dbg(0,"Could not get JVM\n");
299 return JNI_ERR; 268 return JNI_ERR;
300 } 269 }
301 270
302 dbg(0,"++ Found JWM ++\n"); 271 // dbg(0,"++ Found JVM ++\n");
303 return JNI_VERSION_1_6; 272 return JNI_VERSION_1_6;
304} 273}
305 274
306JNIEnv* jni_getenv() 275JNIEnv* jni_getenv()
307{ 276{
308 JNIEnv* env_this; 277 JNIEnv* env_this;
309 (*cachedJVM)->GetEnv(cachedJVM, (void**)&env_this, JNI_VERSION_1_6); 278 (*cachedJVM)->GetEnv(cachedJVM, (void**) &env_this, JNI_VERSION_1_6);
310 return env_this; 279 return env_this;
311} 280}
312
313 281
314static void gui_internal_search_list_set_default_country2(struct gui_priv *this) 282static void gui_internal_search_list_set_default_country2(struct gui_priv *this)
315{ 283{
316#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 284#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
317 dbg(0,"+#+:enter\n"); 285 // dbg(0,"+#+:enter\n");
318#endif 286#endif
319 struct attr search_attr, country_name, country_iso2, *country_attr; 287 struct attr search_attr, country_name, country_iso2, *country_attr;
320 struct item *item; 288 struct item *item;
321 struct country_search *cs; 289 struct country_search *cs;
322 struct tracking *tracking; 290 struct tracking *tracking;
323 struct search_list_result *res; 291 struct search_list_result *res;
324 292
325 ////DBG dbg(0,"### 1"); 293 ////DBG // dbg(0,"### 1");
326 294
327 country_attr = country_default(); 295 country_attr = country_default();
328 tracking = navit_get_tracking(this->nav); 296 tracking = navit_get_tracking(this->nav);
329 297
330 if (tracking && tracking_get_attr(tracking, attr_country_id, &search_attr, NULL)) 298 if (tracking && tracking_get_attr(tracking, attr_country_id, &search_attr, NULL))
331 country_attr = &search_attr; 299 country_attr = &search_attr;
332 if (country_attr) 300 if (country_attr)
333 { 301 {
334 ////DBG dbg(0,"### 2"); 302 ////DBG // dbg(0,"### 2");
335 cs = country_search_new(country_attr, 0); 303 cs = country_search_new(country_attr, 0);
336 item = country_search_get_item(cs); 304 item = country_search_get_item(cs);
337 if (item && item_attr_get(item, attr_country_name, &country_name)) 305 if (item && item_attr_get(item, attr_country_name, &country_name))
338 { 306 {
339 search_attr.type = attr_country_all; 307 search_attr.type = attr_country_all;
340 ////DBG dbg(0,"country %s\n", country_name.u.str); 308 ////DBG // dbg(0,"country %s\n", country_name.u.str);
341 search_attr.u.str = country_name.u.str; 309 search_attr.u.str = country_name.u.str;
342 search_list_search(this->sl, &search_attr, 0); 310 search_list_search(this->sl, &search_attr, 0);
343 while ((res = search_list_get_result(this->sl))) 311 while ((res = search_list_get_result(this->sl)))
344 ; 312 ;
345 if (this->country_iso2) 313 if (this->country_iso2)
355 } 323 }
356 country_search_destroy(cs); 324 country_search_destroy(cs);
357 } 325 }
358 else 326 else
359 { 327 {
360 //DBG dbg(0, "warning: no default country found\n"); 328 //DBG // dbg(0, "warning: no default country found\n");
361 if (this->country_iso2) 329 if (this->country_iso2)
362 { 330 {
363 //DBG dbg(0, "attempting to use country '%s'\n", this->country_iso2); 331 //DBG // dbg(0, "attempting to use country '%s'\n", this->country_iso2);
364 search_attr.type = attr_country_iso2; 332 search_attr.type = attr_country_iso2;
365 search_attr.u.str = this->country_iso2; 333 search_attr.u.str = this->country_iso2;
366 search_list_search(this->sl, &search_attr, 0); 334 search_list_search(this->sl, &search_attr, 0);
367 while ((res = search_list_get_result(this->sl))) 335 while ((res = search_list_get_result(this->sl)))
368 ; 336 ;
369 } 337 }
370 } 338 }
371 ////DBG dbg(0,"### 99"); 339 ////DBG // dbg(0,"### 99");
372} 340}
373 341
342// forward rev
374struct navit *global_navit; 343struct navit *global_navit;
375 344
376int android_find_class_global(char *name, jclass *ret) 345int android_find_class_global(char *name, jclass *ret)
377{ 346{
378#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 347#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
379 dbg(0,"+#+:enter\n"); 348 // dbg(0,"+#+:enter\n");
380#endif 349#endif
350
351 JNIEnv *jnienv2;
352 jnienv2 = jni_getenv();
353
381 *ret = (*jnienv)->FindClass(jnienv, name); 354 *ret = (*jnienv2)->FindClass(jnienv2, name);
382 if (!*ret) 355 if (!*ret)
383 { 356 {
384 //DBG dbg(0, "Failed to get Class %s\n", name); 357 //DBG // dbg(0, "Failed to get Class %s\n", name);
385 return 0; 358 return 0;
386 } 359 }
387 //DBG dbg(0,"lclass %p\n", *ret); 360 //DBG // dbg(0,"lclass %p\n", *ret);
388 *ret = (*jnienv)->NewGlobalRef(jnienv, *ret); 361 *ret = (*jnienv2)->NewGlobalRef(jnienv2, *ret);
389 // ICS (*jnienv)->DeleteGlobalRef(jnienv, *lret); 362 // ICS (*jnienv2)->DeleteGlobalRef(jnienv2, *lret);
390 //DBG dbg(0,"gclass %p\n", *ret); 363 //DBG // dbg(0,"gclass %p\n", *ret);
391 return 1; 364 return 1;
392} 365}
393 366
394int android_find_method(jclass class, char *name, char *args, jmethodID *ret) 367int android_find_method(jclass class, char *name, char *args, jmethodID *ret)
395{ 368{
396#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 369#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
397 dbg(0,"+#+:enter\n"); 370 // dbg(0,"+#+:enter\n");
398#endif 371#endif
372
373 JNIEnv *jnienv2;
374 jnienv2 = jni_getenv();
375
399 *ret = (*jnienv)->GetMethodID(jnienv, class, name, args); 376 *ret = (*jnienv2)->GetMethodID(jnienv2, class, name, args);
400 if (*ret == NULL) 377 if (*ret == NULL)
401 { 378 {
402 //DBG dbg(0, "Failed to get Method %s with signature %s\n", name, args); 379 //DBG // dbg(0, "Failed to get Method %s with signature %s\n", name, args);
403 return 0; 380 return 0;
404 } 381 }
405 //DBG dbg(0,"l meth %p\n", *ret); 382 //DBG // dbg(0,"l meth %p\n", *ret);
406 return 1; 383 return 1;
407} 384}
408 385
409int android_find_static_method(jclass class, char *name, char *args, jmethodID *ret) 386int android_find_static_method(jclass class, char *name, char *args, jmethodID *ret)
410{ 387{
411#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 388#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
412 dbg(0,"+#+:enter\n"); 389 // dbg(0,"+#+:enter\n");
413#endif 390#endif
391
392 JNIEnv *jnienv2;
393 jnienv2 = jni_getenv();
394
414 *ret = (*jnienv)->GetStaticMethodID(jnienv, class, name, args); 395 *ret = (*jnienv2)->GetStaticMethodID(jnienv2, class, name, args);
415 if (*ret == NULL) 396 if (*ret == NULL)
416 { 397 {
417 //DBG dbg(0, "Failed to get static Method %s with signature %s\n", name, args); 398 //DBG // dbg(0, "Failed to get static Method %s with signature %s\n", name, args);
418 return 0; 399 return 0;
419 } 400 }
420 //DBG dbg(0,"l meth %p\n", *ret); 401 //DBG // dbg(0,"l meth %p\n", *ret);
421 return 1; 402 return 1;
422} 403}
423 404
424JNIEXPORT void JNICALL 405JNIEXPORT void JNICALL
425Java_com_zoffcc_applications_zanavi_Navit_NavitMain(JNIEnv* env, jobject thiz, jobject activity, jobject lang, int version, jobject display_density_string) 406Java_com_zoffcc_applications_zanavi_Navit_NavitMain(JNIEnv* env, jobject thiz, jobject activity, jobject lang, int version, jobject display_density_string)
426{ 407{
427#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 408#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
428 dbg(0,"+#+:enter\n"); 409 // dbg(0,"+#+:enter\n");
429#endif 410#endif
430 char *strings[] = 411
412 int thread_id = gettid();
413 // dbg(0, "THREAD ID=%d\n", thread_id);
414
431 { "/data/data/com.zoffcc.applications.zanavi/bin/navit", NULL }; 415 char *strings[] = { "/data/data/com.zoffcc.applications.zanavi/bin/navit", NULL };
432 const char *langstr; 416 const char *langstr;
433 const char *displaydensitystr; 417 const char *displaydensitystr;
434 android_version = version; 418 android_version = version;
435 //__android_log_print(ANDROID_LOG_ERROR,"test","called"); 419 //__android_log_print(ANDROID_LOG_ERROR,"test","called");
436 android_activity_cbl = callback_list_new(); 420 android_activity_cbl = callback_list_new();
437 421
438 // set global JNIenv here ---------- 422 // SET GLOBAL JNIENV here, this is bad!!
439 // set global JNIenv here ---------- 423 // SET GLOBAL JNIENV here, this is bad!!
440 // set global JNIenv here ---------- 424 // SET GLOBAL JNIENV here, this is bad!!
441 jnienv = env; 425 jnienv = env;
442 //dbg(0,"jnienv=%p\n", jnienv); 426 // dbg(0,"jnienv=%p\n", env);
443 // set global JNIenv here ---------- 427 // SET GLOBAL JNIENV here, this is bad!!
444 // set global JNIenv here ---------- 428 // SET GLOBAL JNIENV here, this is bad!!
445 // set global JNIenv here ---------- 429 // SET GLOBAL JNIENV here, this is bad!!
446 430
447 //jclass someClass = env->FindClass("SomeClass"); 431 //jclass someClass = env->FindClass("SomeClass");
448 //gSomeClass = env->NewGlobalRef(someClass); 432 //gSomeClass = env->NewGlobalRef(someClass);
449 433
450 434
451 // *only local* android_activity = activity; 435 // *only local* android_activity = activity;
452 // android_activity = (*jnienv)->NewGlobalRef(jnienv, activity); 436 // android_activity = (*jnienv)->NewGlobalRef(jnienv, activity);
453 android_activity = (*env)->NewGlobalRef(env, activity); 437 android_activity = (*env)->NewGlobalRef(env, activity);
454 langstr = (*env)->GetStringUTFChars(env, lang, NULL); 438 langstr = (*env)->GetStringUTFChars(env, lang, NULL);
455 //DBG dbg(0, "enter env=%p thiz=%p activity=%p lang=%s version=%d\n", env, thiz, activity, langstr, version); 439 //DBG // dbg(0, "enter env=%p thiz=%p activity=%p lang=%s version=%d\n", env, thiz, activity, langstr, version);
456 //DBG dbg(0, "enter env=%p thiz=%p activity=%p lang=%s version=%d\n", env, thiz, android_activity, langstr, version); 440 //DBG // dbg(0, "enter env=%p thiz=%p activity=%p lang=%s version=%d\n", env, thiz, android_activity, langstr, version);
457 setenv("LANG", langstr, 1); 441 setenv("LANG", langstr, 1);
458 (*env)->ReleaseStringUTFChars(env, lang, langstr); 442 (*env)->ReleaseStringUTFChars(env, lang, langstr);
459 443
460 displaydensitystr = (*env)->GetStringUTFChars(env, display_density_string, NULL); 444 displaydensitystr = (*env)->GetStringUTFChars(env, display_density_string, NULL);
461 //DBG dbg(0, "*****displaydensity=%s\n", displaydensitystr); 445 //DBG // dbg(0, "*****displaydensity=%s\n", displaydensitystr);
462 setenv("ANDROID_DENSITY", displaydensitystr, 1); 446 setenv("ANDROID_DENSITY", displaydensitystr, 1);
463 (*env)->ReleaseStringUTFChars(env, display_density_string, displaydensitystr); 447 (*env)->ReleaseStringUTFChars(env, display_density_string, displaydensitystr);
448
449 //// dbg(0,"before main_real call\n");
464 main_real(1, strings); 450 //main_real(1, strings);
465
466 dbg(0,"after main_real call\n"); 451 //// dbg(0,"after main_real call\n");
467 452
468#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 453#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
469 dbg(0,"+#+:leave\n"); 454 // dbg(0,"+#+:leave\n");
470#endif 455#endif
471 456
472} 457}
473 458
474JNIEXPORT void JNICALL 459JNIEXPORT void JNICALL
475Java_com_zoffcc_applications_zanavi_Navit_NavitActivity(JNIEnv* env, jobject thiz, int param) 460Java_com_zoffcc_applications_zanavi_Navit_NavitActivity(JNIEnv* env, jobject thiz, int param)
476{ 461{
477#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 462#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
478 dbg(0,"+#+:enter\n"); 463 // dbg(0,"+#+:enter\n");
479#endif 464#endif
465
480 dbg(0, "enter %d\n", param); 466 //dbg(0, "enter %d\n", param);
467
468 int thread_id = gettid();
469 // dbg(0, "THREAD ID=%d\n", thread_id);
481 470
482 if (param == -2) 471 if (param == -2)
483 { 472 {
484 // onStop() -> called in Java app 473 // onStop() -> called in Java app
485 // save center.txt 474 // save center.txt
486 if (global_navit->bookmarks) 475 if (global_navit->bookmarks)
487 { 476 {
488 config_get_attr(config, attr_navit, &attr, NULL); 477 config_get_attr(config, attr_navit, &attr, NULL);
489 //DBG dbg(0, "save position to file"); 478 //DBG // dbg(0, "save position to file");
490 char *center_file = bookmarks_get_center_file(TRUE); 479 char *center_file = bookmarks_get_center_file(TRUE);
491 bookmarks_write_center_to_file(attr.u.navit->bookmarks, center_file); 480 bookmarks_write_center_to_file(attr.u.navit->bookmarks, center_file);
492 dbg(0, "save pos to file -> ready"); 481 // dbg(0, "save pos to file -> ready");
493 g_free(center_file); 482 g_free(center_file);
494 // bookmarks_destroy(global_navit->bookmarks); 483 // bookmarks_destroy(global_navit->bookmarks);
495 } 484 }
496 } 485 }
497 486
504 // param == -3 // onDestroy 493 // param == -3 // onDestroy
505 // param == -4 // exit() [java function] 494 // param == -4 // exit() [java function]
506 495
507 if (param == 3) 496 if (param == 3)
508 { 497 {
498 // in onCreate at startup
499 char *strings[] = { "/data/data/com.zoffcc.applications.zanavi/bin/navit", NULL };
500
501 // dbg(0,"before main_real call\n");
502 main_real(1, strings);
503 // dbg(0,"after main_real call\n");
504
509 navit_draw(global_navit); 505 navit_draw(global_navit);
510 } 506 }
511 507
512 dbg(0, "acti: 001\n"); 508 // dbg(0, "acti: 001\n");
513 // callback_list_call_1(android_activity_cbl, param); 509 // callback_list_call_1(android_activity_cbl, param);
514 //dbg(0, "acti: 002\n"); 510 //// dbg(0, "acti: 002\n");
515 511
516 //if (param == -4) 512 //if (param == -4)
517 //{ 513 //{
518 // dbg(0, "acti: 003\n"); 514 // // dbg(0, "acti: 003\n");
519 // // *********EXIT******EXIT******** // exit(0); 515 // // *********EXIT******EXIT******** // exit(0);
520 //} 516 //}
521 517
522 if (param == -4) 518 if (param == -4)
523 { 519 {
524 dbg(0, "acti: 004\n"); 520 // dbg(0, "acti: 004\n");
525 navit_destroy(global_navit); 521 navit_destroy(global_navit);
526 dbg(0, "acti: 005\n"); 522 // dbg(0, "acti: 005\n");
527 event_main_loop_quit(); 523 event_main_loop_quit();
528 dbg(0, "acti: 006\n"); 524 // dbg(0, "acti: 006\n");
529 } 525 }
530} 526}
531
532 527
533JNIEXPORT void JNICALL 528JNIEXPORT void JNICALL
534Java_com_zoffcc_applications_zanavi_NavitGraphics_SizeChangedCallback(JNIEnv* env, jobject thiz, int w, int h) 529Java_com_zoffcc_applications_zanavi_NavitGraphics_SizeChangedCallbackReal(JNIEnv* env, jobject thiz, int w, int h)
535{ 530{
536#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 531#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
537 dbg(0,"+#+:enter\n"); 532 // dbg(0,"+#+:enter\n");
538#endif 533#endif
539 dbg(0,"enter %d %d\n", w, h); 534 // dbg(0,"enter %d %d\n", w, h);
535
536 int thread_id = gettid();
537 // dbg(0, "THREAD ID=%d\n", thread_id);
538
540 navit_handle_resize(global_navit, w, h); 539 navit_handle_resize(global_navit, w, h);
541#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 540#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
542 dbg(0,"+#+:leave\n"); 541 // dbg(0,"+#+:leave\n");
543#endif 542#endif
544} 543}
545
546 544
547JNIEXPORT void JNICALL 545JNIEXPORT void JNICALL
548Java_com_zoffcc_applications_zanavi_NavitGraphics_MotionCallback(JNIEnv* env, jobject thiz, int x1, int y1, int x2, int y2) 546Java_com_zoffcc_applications_zanavi_NavitGraphics_MotionCallbackReal(JNIEnv* env, jobject thiz, int x1, int y1, int x2, int y2)
549{ 547{
550#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 548#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
551 dbg(0,"+#+:enter\n"); 549 // dbg(0,"+#+:enter\n");
552#endif 550#endif
551
552 //int thread_id = gettid();
553 // dbg(0, "THREAD ID=%d\n", thread_id);
553 554
554 struct point p_end; 555 struct point p_end;
555 struct point p_start; 556 struct point p_start;
556 557
557 p_start.x = x1; 558 p_start.x = x1;
562 // graphics_draw_drag(this_->gra, NULL); 563 // graphics_draw_drag(this_->gra, NULL);
563 transform_copy(global_navit->trans, global_navit->trans_cursor); 564 transform_copy(global_navit->trans, global_navit->trans_cursor);
564 global_navit->moved = 1; 565 global_navit->moved = 1;
565 566
566 /* 567 /*
567 struct coord c; 568 struct coord c;
568 struct pcoord pc; 569 struct pcoord pc;
569 p.x = x; 570 p.x = x;
570 p.y = y; 571 p.y = y;
571 transform_reverse(global_navit->trans, &p, &c); 572 transform_reverse(global_navit->trans, &p, &c);
572 pc.x = c.x; 573 pc.x = c.x;
573 pc.y = c.y; 574 pc.y = c.y;
574 pc.pro = transform_get_projection(global_navit->trans); 575 pc.pro = transform_get_projection(global_navit->trans);
575 navit_set_position(global_navit, &pc); 576 navit_set_position(global_navit, &pc);
576 */ 577 */
577 578
578 dbg(0,"call async java draw -start-\n"); 579 // dbg(0,"call async java draw -start-\n");
579 navit_draw(global_navit); 580 navit_draw(global_navit);
580 // navit_draw_async(global_navit, 1); 581 // navit_draw_async(global_navit, 1);
581 dbg(0,"call async java draw --end--\n"); 582 // dbg(0,"call async java draw --end--\n");
582 583
583 // remove the "wait" screen 584 // remove the "wait" screen
584#ifdef HAVE_API_ANDROID 585 //#ifdef HAVE_API_ANDROID
585 android_return_generic_int(2, 0); 586 // android_return_generic_int(2, 0);
586#endif 587 //#endif
587 588
588} 589}
589
590 590
591JNIEXPORT void JNICALL 591JNIEXPORT void JNICALL
592Java_com_zoffcc_applications_zanavi_NavitTimeout_TimeoutCallback(JNIEnv* env, jobject thiz, int delete, int id) 592Java_com_zoffcc_applications_zanavi_NavitGraphics_TimeoutCallback(JNIEnv* env, jobject thiz, int delete, int id)
593{ 593{
594#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 594#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
595 dbg(0,"+#+:enter\n"); 595 // dbg(0,"+#+:enter\n");
596#endif 596#endif
597
598 JNIEnv *jnienv2;
599 jnienv2 = jni_getenv();
600
601 //int thread_id = gettid();
602 //dbg(0, "THREAD ID=%d\n", thread_id);
603
597 //DBG dbg(0,"enter %p %d %p\n",thiz, delete, (void *)id); 604 //DBG // dbg(0,"enter %p %d %p\n",thiz, delete, (void *)id);
598 //dbg(0,"timeout 1\n"); 605 //dbg(0,"timeout 1\n");
599 // ICS 606 // ICS
607 //if (id != 0)
608 //{
609 // dbg(0,"callback struct=%p %d\n", id, id);
600 callback_call_0((struct callback *) id); 610 callback_call_0((struct callback *) id);
611 //}
601 // ICS 612 // ICS
602 //dbg(0,"timeout 2\n"); 613 //dbg(0,"timeout 2\n");
614
615 /*
603 if (delete) 616 if (delete)
604 { 617 {
605 dbg(0,"timeout 3\n"); 618 //dbg(0,"timeout 3\n");
606 // ICS 619 // ICS
607 jobject this_global = (*jnienv)->NewGlobalRef(jnienv, thiz); 620 jobject this_global = (*jnienv2)->NewGlobalRef(jnienv2, thiz);
608 dbg(0,"timeout 3.1\n"); 621 //dbg(0,"timeout 3.1\n");
609 (*jnienv)->DeleteGlobalRef(jnienv, this_global); 622 (*jnienv2)->DeleteGlobalRef(jnienv2, this_global);
610 // ICS 623 // ICS
611 dbg(0,"timeout 4\n"); 624 //dbg(0,"timeout 4\n");
612 } 625 }
626 */
613} 627}
614 628
615JNIEXPORT void JNICALL 629JNIEXPORT void JNICALL
616Java_com_zoffcc_applications_zanavi_NavitIdle_IdleCallback(JNIEnv* env, jobject thiz, int id) 630Java_com_zoffcc_applications_zanavi_NavitIdle_IdleCallback(JNIEnv* env, jobject thiz, int id)
617{ 631{
618#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 632#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
619 dbg(0,"+#+:enter\n"); 633 // dbg(0,"+#+:enter\n");
620#endif 634#endif
635
636 //int thread_id = gettid();
637 // dbg(0, "THREAD ID=%d\n", thread_id);
638
621 //DBG dbg(0,"enter %p %p\n",thiz, (void *)id); 639 //DBG // dbg(0,"enter %p %p\n",thiz, (void *)id);
640 // dbg(0,"idlecall back 1\n");
622 callback_call_0((struct callback *) id); 641 callback_call_0((struct callback *) id);
642 // dbg(0,"idlecall back 2\n");
623} 643}
624 644
625JNIEXPORT void JNICALL 645JNIEXPORT void JNICALL
626Java_com_zoffcc_applications_zanavi_NavitWatch_poll(JNIEnv* env, jobject thiz, int fd, int cond) 646Java_com_zoffcc_applications_zanavi_NavitWatch_poll(JNIEnv* env, jobject thiz, int fd, int cond)
627{ 647{
628#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 648#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
629 dbg(0,"+#+:enter\n"); 649 // dbg(0,"+#+:enter\n");
630#endif 650#endif
631 struct pollfd pfd; 651 struct pollfd pfd;
632 pfd.fd = fd; 652 pfd.fd = fd;
633 //DBG dbg(0, "%p poll called for %d %d\n", env, fd, cond); 653 //DBG // dbg(0, "%p poll called for %d %d\n", env, fd, cond);
634 switch ((enum event_watch_cond) cond) 654 switch ((enum event_watch_cond) cond)
635 { 655 {
636 case event_watch_cond_read: 656 case event_watch_cond_read:
637 pfd.events = POLLIN; 657 pfd.events = POLLIN;
638 break; 658 break;
651 671
652JNIEXPORT void JNICALL 672JNIEXPORT void JNICALL
653Java_com_zoffcc_applications_zanavi_NavitWatch_WatchCallback(JNIEnv* env, jobject thiz, int id) 673Java_com_zoffcc_applications_zanavi_NavitWatch_WatchCallback(JNIEnv* env, jobject thiz, int id)
654{ 674{
655#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 675#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
656 dbg(0,"+#+:enter\n"); 676 // dbg(0,"+#+:enter\n");
657#endif 677#endif
658 //DBG dbg(0, "enter %p %p\n", thiz, (void *) id); 678 //DBG // dbg(0, "enter %p %p\n", thiz, (void *) id);
659 callback_call_0((struct callback *) id); 679 callback_call_0((struct callback *) id);
660} 680}
661 681
662JNIEXPORT void JNICALL 682JNIEXPORT void JNICALL
663Java_com_zoffcc_applications_zanavi_NavitSensors_SensorCallback(JNIEnv* env, jobject thiz, int id, int sensor, float x, float y, float z) 683Java_com_zoffcc_applications_zanavi_NavitSensors_SensorCallback(JNIEnv* env, jobject thiz, int id, int sensor, float x, float y, float z)
664{ 684{
665#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 685#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
666 dbg(0,"+#+:enter\n"); 686 // dbg(0,"+#+:enter\n");
667#endif 687#endif
688 // JNIEnv *jnienv2;
689 // jnienv2 = jni_getenv();
690
691 //int thread_id = gettid();
692 // dbg(0, "THREAD ID=%d\n", thread_id);
693
668 //DBG dbg(0, "enter %p %p %f %f %f\n", thiz, (void *) id, x, y, z); 694 //DBG // dbg(0, "enter %p %p %f %f %f\n", thiz, (void *) id, x, y, z);
669 callback_call_4((struct callback *) id, sensor, &x, &y, &z); 695 callback_call_4((struct callback *) id, sensor, &x, &y, &z);
670} 696}
671 697
672
673JNIEXPORT void JNICALL 698JNIEXPORT void JNICALL
674Java_com_zoffcc_applications_zanavi_NavitVehicle_VehicleCallback(JNIEnv * env, jobject thiz, jobject location) 699Java_com_zoffcc_applications_zanavi_NavitVehicle_VehicleCallback(JNIEnv *env, jobject thiz, jobject location)
675{ 700{
676#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 701#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
677 dbg(0,"+#+:enter\n"); 702 // dbg(0,"+#+:enter\n");
678#endif 703#endif
704
705 // JNIEnv *jnienv2;
706 // jnienv2 = jni_getenv();
707 //int thread_id = gettid();
708 //dbg(0, "THREAD ID=%d\n", thread_id);
709
679 //dbg(0,"location=%p\n", location); 710 //dbg(0,"VehicleCallback location=%p\n", location);
680 jobject location2 = (*jnienv)->NewGlobalRef(jnienv, location); 711 jobject location2 = (*env)->NewGlobalRef(env, location);
681 (*jnienv)->DeleteLocalRef(jnienv, location); 712 (*env)->DeleteLocalRef(env, location);
682 //dbg(0,"location=%p\n", location2); 713 //// dbg(0,"location=%p\n", location2);
683 714
715 if ((global_navit) && (global_navit->vehicle) && (global_navit->vehicle->vehicle))
716 {
684 vehicle_update_(global_navit->vehicle->vehicle, location2); 717 vehicle_update_(global_navit->vehicle->vehicle, location2);
718 }
719 else
720 {
721 dbg(0, "no vehicle set !!\n");
722 }
685 723
724 //dbg(0,"leave\n");
725
686#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 726#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
687 dbg(0,"+#+:leave\n"); 727 // dbg(0,"+#+:leave\n");
688#endif 728#endif
689} 729}
690
691 730
692void android_return_search_result(struct jni_object *jni_o, char *str) 731void android_return_search_result(struct jni_object *jni_o, char *str)
693{ 732{
694#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 733#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
695 dbg(0,"+#+:enter\n"); 734 // dbg(0,"+#+:enter\n");
696#endif 735#endif
697 //DBG dbg(0,"EEnter\n"); 736 //DBG // dbg(0,"EEnter\n");
737
738 // int thread_id = gettid();
739 // dbg(0, "THREAD ID=%d\n", thread_id);
740
698 jstring js2 = NULL; 741 jstring js2 = NULL;
699 JNIEnv* env2; 742 JNIEnv* env2;
700 env2 = jni_o->env; 743 env2 = jni_o->env;
701 js2 = (*env2)->NewStringUTF(jni_o->env, str); 744 js2 = (*env2)->NewStringUTF(jni_o->env, str);
702 (*env2)->CallVoidMethod(jni_o->env, jni_o->jo, jni_o->jm, js2); 745 (*env2)->CallVoidMethod(jni_o->env, jni_o->jo, jni_o->jm, js2);
704} 747}
705 748
706void android_return_generic_int(int id, int i) 749void android_return_generic_int(int id, int i)
707{ 750{
708#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 751#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
709 dbg(0,"+#+:enter\n"); 752 // dbg(0,"+#+:enter\n");
710#endif 753#endif
711 //DBG dbg(0,"Enter\n"); 754 //DBG // dbg(0,"Enter\n");
755
756 // int thread_id = gettid();
757 // dbg(0, "THREAD ID=%d\n", thread_id);
712 758
713 JNIEnv *jnienv2; 759 JNIEnv *jnienv2;
714 jnienv2 = jni_getenv(); 760 jnienv2 = jni_getenv();
715 761
716 if (NavitGraphicsClass2 == NULL) 762 if (NavitGraphicsClass2 == NULL)
719 { 765 {
720 NavitGraphicsClass2 = NULL; 766 NavitGraphicsClass2 = NULL;
721 return; 767 return;
722 } 768 }
723 } 769 }
724 //DBG dbg(0,"xx1\n"); 770 //DBG // dbg(0,"xx1\n");
725 if (return_generic_int == NULL) 771 if (return_generic_int == NULL)
726 { 772 {
727 android_find_static_method(NavitGraphicsClass2, "return_generic_int", "(II)V", &return_generic_int); 773 android_find_static_method(NavitGraphicsClass2, "return_generic_int", "(II)V", &return_generic_int);
728 } 774 }
729 //DBG dbg(0,"xx2\n"); 775 //DBG // dbg(0,"xx2\n");
730 if (return_generic_int == NULL) 776 if (return_generic_int == NULL)
731 { 777 {
732 //DBG dbg(0, "no method found\n"); 778 //DBG // dbg(0, "no method found\n");
733 return; /* exception thrown */ 779 return; /* exception thrown */
734 } 780 }
735 //DBG dbg(0,"xa1\n"); 781 //DBG // dbg(0,"xa1\n");
736 // -crash- (*jnienv2)->CallVoidMethod(jnienv2, NavitGraphicsClass2, return_generic_int, id, i); 782 // -crash- (*jnienv2)->CallVoidMethod(jnienv2, NavitGraphicsClass2, return_generic_int, id, i);
737 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, return_generic_int, id, i); 783 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, return_generic_int, id, i);
738 // -works- (*jnienv2)->CallStaticObjectMethod(jnienv2, NavitGraphicsClass2, return_generic_int, id, i); 784 // -works- (*jnienv2)->CallStaticObjectMethod(jnienv2, NavitGraphicsClass2, return_generic_int, id, i);
739 //DBG dbg(0,"xa2\n"); 785 //DBG // dbg(0,"xa2\n");
740} 786}
741 787
742JNIEXPORT void JNICALL 788JNIEXPORT void JNICALL
743Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackSearchResultList(JNIEnv* env, jobject thiz, int id, int partial, jobject str, int search_flags, jobject search_country, jobject latlon, int radius) 789Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackSearchResultList(JNIEnv* env, jobject thiz, int id, int partial, jobject str, int search_flags, jobject search_country, jobject latlon, int radius)
744{ 790{
745#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 791#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
746 dbg(0,"+#+:enter\n"); 792 // dbg(0,"+#+:enter\n");
747#endif 793#endif
794
795 int thread_id = gettid();
796 // dbg(0, "THREAD ID=%d\n", thread_id);
797
748 const char *s; 798 const char *s;
749 s = (*env)->GetStringUTFChars(env, str, NULL); 799 s = (*env)->GetStringUTFChars(env, str, NULL);
750 ////DBG dbg(0,"*****string=%s\n",s); 800 ////DBG // dbg(0,"*****string=%s\n",s);
751 801
752 802
753 config_get_attr(config, attr_navit, &attr, NULL); 803 config_get_attr(config, attr_navit, &attr, NULL);
754 // attr.u.navit 804 // attr.u.navit
755 805
761 // ICS ??? 811 // ICS ???
762 812
763 jmethodID aMethodID = (*env)->GetMethodID(env, cls, "fillStringArray", "(Ljava/lang/String;)V"); 813 jmethodID aMethodID = (*env)->GetMethodID(env, cls, "fillStringArray", "(Ljava/lang/String;)V");
764 if (aMethodID == 0) 814 if (aMethodID == 0)
765 { 815 {
766 ////DBG dbg(0,"**** Unable to get methodID: fillStringArray"); 816 ////DBG // dbg(0,"**** Unable to get methodID: fillStringArray");
767 return; 817 return;
768 } 818 }
769 819
770 if (id) 820 if (id)
771 { 821 {
797 ret = search_by_address(ret, ms4, s, partial, &my_jni_object, flags, search_country_string); 847 ret = search_by_address(ret, ms4, s, partial, &my_jni_object, flags, search_country_string);
798 (*env)->ReleaseStringUTFChars(env, search_country, search_country_string); 848 (*env)->ReleaseStringUTFChars(env, search_country, search_country_string);
799 849
800 // free the memory 850 // free the memory
801 g_list_free(ret); 851 g_list_free(ret);
802 ////DBG dbg(0,"ret=%p\n",ret); 852 ////DBG // dbg(0,"ret=%p\n",ret);
803 853
804 854
805 //if (gp4->sl) 855 //if (gp4->sl)
806 //{ 856 //{
807 // //search_list_destroy(gp4->sl); 857 // //search_list_destroy(gp4->sl);
845 895
846JNIEXPORT jint JNICALL 896JNIEXPORT jint JNICALL
847Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackDestinationValid(JNIEnv* env, jobject thiz) 897Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackDestinationValid(JNIEnv* env, jobject thiz)
848{ 898{
849#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 899#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
850 dbg(0,"+#+:enter\n"); 900 // dbg(0,"+#+:enter\n");
851#endif 901#endif
852 //DBG dbg(0,"EEnter\n"); 902 //DBG // dbg(0,"EEnter\n");
853 config_get_attr(config, attr_navit, &attr, NULL); 903 config_get_attr(config, attr_navit, &attr, NULL);
854 // //DBG dbg(0,"destination_valid=%d\n",attr.u.navit->destination_valid); 904 // //DBG // dbg(0,"destination_valid=%d\n",attr.u.navit->destination_valid);
855 jint i = 0; 905 jint i = 0;
856 if (attr.u.navit->route) 906 if (attr.u.navit->route)
857 { 907 {
858 struct route *r; 908 struct route *r;
859 r = attr.u.navit->route; 909 r = attr.u.navit->route;
860 i = r->route_status; 910 i = r->route_status;
861 // //DBG dbg(0,"route_status=%d\n",i); 911 // //DBG // dbg(0,"route_status=%d\n",i);
862 } 912 }
863 return i; 913 return i;
864} 914}
865 915
866static void map_preview_label_line(struct point *p, int count, char *label, int font_size) 916static void map_preview_label_line(struct point *p, int count, char *label, int font_size)
867{ 917{
868#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 918#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
869 dbg(0,"+#+:enter\n"); 919 // dbg(0,"+#+:enter\n");
870#endif 920#endif
871 int i, x, y, tl, tlm, th, thm, tlsq, l; 921 int i, x, y, tl, tlm, th, thm, tlsq, l;
872 float lsq; 922 float lsq;
873 double dx, dy; 923 double dx, dy;
874 struct point p_t; 924 struct point p_t;
878 int xMin = 0; 928 int xMin = 0;
879 int yMin = 0; 929 int yMin = 0;
880 int yMax = 13 * font_size / 256; 930 int yMax = 13 * font_size / 256;
881 int xMax = 9 * font_size * len / 256; 931 int xMax = 9 * font_size * len / 256;
882 932
883 ////DBG dbg(0,"xMax=%d\n", xMax); 933 ////DBG // dbg(0,"xMax=%d\n", xMax);
884 ////DBG dbg(0,"yMax=%d\n", yMax); 934 ////DBG // dbg(0,"yMax=%d\n", yMax);
885 935
886 pb[0].x = xMin; 936 pb[0].x = xMin;
887 pb[0].y = -yMin; 937 pb[0].y = -yMin;
888 pb[1].x = xMin; 938 pb[1].x = xMin;
889 pb[1].y = -yMax; 939 pb[1].y = -yMax;
912 dy *= 32; 962 dy *= 32;
913 lsq = dx * dx + dy * dy; 963 lsq = dx * dx + dy * dy;
914 964
915 if (lsq > tlsq) 965 if (lsq > tlsq)
916 { 966 {
917 ////DBG dbg(0,"-------- label=%s\n",label); 967 ////DBG // dbg(0,"-------- label=%s\n",label);
918 ////DBG dbg(0,"px i=%d py i=%d px i+1=%d py i+1=%d\n",p[i].x,p[i].y,p[i+1].x,p[i+1].y); 968 ////DBG // dbg(0,"px i=%d py i=%d px i+1=%d py i+1=%d\n",p[i].x,p[i].y,p[i+1].x,p[i+1].y);
919 ////DBG dbg(0,"dx=%f dy=%f\n",dx,dy); 969 ////DBG // dbg(0,"dx=%f dy=%f\n",dx,dy);
920 l = (int) sqrtf(lsq); 970 l = (int) sqrtf(lsq);
921 ////DBG dbg(0,"l=%d lsq=%f\n",l,lsq); 971 ////DBG // dbg(0,"l=%d lsq=%f\n",l,lsq);
922 x = p[i].x; 972 x = p[i].x;
923 y = p[i].y; 973 y = p[i].y;
924 if (dx < 0) 974 if (dx < 0)
925 { 975 {
926 dx = -dx; 976 dx = -dx;
933 x -= dy * thm / l / 64; 983 x -= dy * thm / l / 64;
934 y += dx * thm / l / 64; 984 y += dx * thm / l / 64;
935 p_t.x = x; 985 p_t.x = x;
936 p_t.y = y; 986 p_t.y = y;
937 987
938 ////DBG dbg(0,"dx=%f dy=%f\n",dx,dy); 988 ////DBG // dbg(0,"dx=%f dy=%f\n",dx,dy);
939 ////DBG dbg(0,"dx=%d dy=%d\n",(int)dx,(int)dy); 989 ////DBG // dbg(0,"dx=%d dy=%d\n",(int)dx,(int)dy);
940 ////DBG dbg(0,"draw px=%d py=%d\n",p_t.x,p_t.y); 990 ////DBG // dbg(0,"draw px=%d py=%d\n",p_t.x,p_t.y);
941 ////DBG dbg(0,"l=%d\n",l); 991 ////DBG // dbg(0,"l=%d\n",l);
942 ////DBG dbg(0,"+++++++++++++\n"); 992 ////DBG // dbg(0,"+++++++++++++\n");
943 // **OLD and wrong** android_DrawMapPreview_text(p_t.x, p_t.y, label, font_size, dx*0x10000/l, dy*0x10000/l); 993 // **OLD and wrong** android_DrawMapPreview_text(p_t.x, p_t.y, label, font_size, dx*0x10000/l, dy*0x10000/l);
944 android_DrawMapPreview_text(p_t.x, p_t.y, label, font_size, (int) dx, (int) dy); 994 android_DrawMapPreview_text(p_t.x, p_t.y, label, font_size, (int) dx, (int) dy);
945 } 995 }
946 } 996 }
947} 997}
948 998
949JNIEXPORT void JNICALL 999JNIEXPORT void JNICALL
950Java_com_zoffcc_applications_zanavi_NavitMapPreviewActivity_DrawMapPreview(JNIEnv* env, jobject thiz, jobject latlonzoom, int width, int height, int font_size, int scale, int sel_range) 1000Java_com_zoffcc_applications_zanavi_NavitMapPreviewActivity_DrawMapPreview(JNIEnv* env, jobject thiz, jobject latlonzoom, int width, int height, int font_size, int scale, int sel_range)
951{ 1001{
952#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 1002#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
953 dbg(0,"+#+:enter\n"); 1003 // dbg(0,"+#+:enter\n");
954#endif 1004#endif
955 // config_get_attr(config, attr_navit, &attr, NULL); 1005 // config_get_attr(config, attr_navit, &attr, NULL);
956 1006
957 const char *s; 1007 const char *s;
958 int zoom; 1008 int zoom;
959 s = (*env)->GetStringUTFChars(env, latlonzoom, NULL); 1009 s = (*env)->GetStringUTFChars(env, latlonzoom, NULL);
960 char parse_str[strlen(s) + 1]; 1010 char parse_str[strlen(s) + 1];
961 strcpy(parse_str, s); 1011 strcpy(parse_str, s);
962 (*env)->ReleaseStringUTFChars(env, latlonzoom, s); 1012 (*env)->ReleaseStringUTFChars(env, latlonzoom, s);
963 ////DBG dbg(0,"*****string=%s\n",s); 1013 ////DBG // dbg(0,"*****string=%s\n",s);
964 1014
965 // show map preview for (lat#lon#zoom) 1015 // show map preview for (lat#lon#zoom)
966 struct coord_geo g; 1016 struct coord_geo g;
967 char *p; 1017 char *p;
968 char *stopstring; 1018 char *stopstring;
975 g.lng = strtof(p, &stopstring); 1025 g.lng = strtof(p, &stopstring);
976 // zoom 1026 // zoom
977 p = strtok(NULL, "#"); 1027 p = strtok(NULL, "#");
978 zoom = atoi(p); 1028 zoom = atoi(p);
979 1029
980 ////DBG dbg(0,"lat=%f\n",g.lat); 1030 ////DBG // dbg(0,"lat=%f\n",g.lat);
981 ////DBG dbg(0,"lng=%f\n",g.lng); 1031 ////DBG // dbg(0,"lng=%f\n",g.lng);
982 ////DBG dbg(0,"zoom=%d\n",zoom); 1032 ////DBG // dbg(0,"zoom=%d\n",zoom);
983 ////DBG dbg(0,"w=%d\n",width); 1033 ////DBG // dbg(0,"w=%d\n",width);
984 ////DBG dbg(0,"h=%d\n",height); 1034 ////DBG // dbg(0,"h=%d\n",height);
985 1035
986 struct coord c; 1036 struct coord c;
987 transform_from_geo(projection_mg, &g, &c); 1037 transform_from_geo(projection_mg, &g, &c);
988 1038
989 // struct pcoord pc; 1039 // struct pcoord pc;
1040 if (strncmp("_ms_sdcard_map:", map_name_attr.u.str, 15) == 0) 1090 if (strncmp("_ms_sdcard_map:", map_name_attr.u.str, 15) == 0)
1041 { 1091 {
1042 if (strncmp("_ms_sdcard_map:/sdcard/zanavi/maps/borders.bin", map_name_attr.u.str, 41) == 0) 1092 if (strncmp("_ms_sdcard_map:/sdcard/zanavi/maps/borders.bin", map_name_attr.u.str, 41) == 0)
1043 { 1093 {
1044 // country borders 1094 // country borders
1045 // //DBG dbg(0,"map name=%s",map_name_attr.u.str); 1095 // //DBG // dbg(0,"map name=%s",map_name_attr.u.str);
1046 mr = map_rect_new(map, NULL); 1096 mr = map_rect_new(map, NULL);
1047 if (mr) 1097 if (mr)
1048 { 1098 {
1049 while ((item = map_rect_get_item(mr))) 1099 while ((item = map_rect_get_item(mr)))
1050 { 1100 {
1055 { 1105 {
1056 continue; 1106 continue;
1057 } 1107 }
1058 count = transform(tr, pro, ca, pa, count, 0, 0, NULL); 1108 count = transform(tr, pro, ca, pa, count, 0, 0, NULL);
1059 1109
1060 // //DBG dbg(0,"uu %s\n",item_to_name(item->type)); 1110 // //DBG // dbg(0,"uu %s\n",item_to_name(item->type));
1061 1111
1062 if (item->type == type_border_country) 1112 if (item->type == type_border_country)
1063 { 1113 {
1064 // //DBG dbg(0,"BB** %s\n",item_to_name(item->type)); 1114 // //DBG // dbg(0,"BB** %s\n",item_to_name(item->type));
1065 android_DrawMapPreview_polyline(pa, count, 2); 1115 android_DrawMapPreview_polyline(pa, count, 2);
1066 } 1116 }
1067 } 1117 }
1068 map_rect_destroy(mr); 1118 map_rect_destroy(mr);
1069 } 1119 }
1070 } 1120 }
1071 else if (strncmp("_ms_sdcard_map:/sdcard/zanavi/maps/navitmap", map_name_attr.u.str, 38) == 0) 1121 else if (strncmp("_ms_sdcard_map:/sdcard/zanavi/maps/navitmap", map_name_attr.u.str, 38) == 0)
1072 { 1122 {
1073 // its an sdcard map 1123 // its an sdcard map
1074 // //DBG dbg(0,"map name=%s",map_name_attr.u.str); 1124 // //DBG // dbg(0,"map name=%s",map_name_attr.u.str);
1075 mr = map_rect_new(map, &sel); 1125 mr = map_rect_new(map, &sel);
1076 if (mr) 1126 if (mr)
1077 { 1127 {
1078 //char *streetname_last=NULL; 1128 //char *streetname_last=NULL;
1079 1129
1089 // count=item_coord_get(item, ca, item->type < type_line ? 1: max); 1139 // count=item_coord_get(item, ca, item->type < type_line ? 1: max);
1090 if (!count) 1140 if (!count)
1091 { 1141 {
1092 continue; 1142 continue;
1093 } 1143 }
1094 ////DBG dbg(0,"count 1=%d\n", count); 1144 ////DBG // dbg(0,"count 1=%d\n", count);
1095 1145
1096 if (count == max) 1146 if (count == max)
1097 { 1147 {
1098 ////DBG dbg(0,"count overflow!!\n"); 1148 ////DBG // dbg(0,"count overflow!!\n");
1099 } 1149 }
1100 1150
1101 struct attr attr_77; 1151 struct attr attr_77;
1102 if (item_attr_get(item, attr_flags, &attr_77)) 1152 if (item_attr_get(item, attr_flags, &attr_77))
1103 { 1153 {
1104 ////DBG dbg(0,"uuuuuuuuuuuuu %s uuuuu %d\n",item_to_name(item->type), attr_77.u.num); 1154 ////DBG // dbg(0,"uuuuuuuuuuuuu %s uuuuu %d\n",item_to_name(item->type), attr_77.u.num);
1105 item->flags = attr_77.u.num; 1155 item->flags = attr_77.u.num;
1106 } 1156 }
1107 else 1157 else
1108 { 1158 {
1109 item->flags = 0; 1159 item->flags = 0;
1114 // int i3; 1164 // int i3;
1115 // for (i3 = 0 ; i3 < count ; i3++) 1165 // for (i3 = 0 ; i3 < count ; i3++)
1116 // { 1166 // {
1117 // if (i3) 1167 // if (i3)
1118 // { 1168 // {
1119 // //DBG dbg(0,"1 x1=%d\n",ca[i3-1].x); 1169 // //DBG // dbg(0,"1 x1=%d\n",ca[i3-1].x);
1120 // //DBG dbg(0,"1 y1=%d\n",ca[i3-1].y); 1170 // //DBG // dbg(0,"1 y1=%d\n",ca[i3-1].y);
1121 // //DBG dbg(0,"1 x2=%d\n",ca[i3].x); 1171 // //DBG // dbg(0,"1 x2=%d\n",ca[i3].x);
1122 // //DBG dbg(0,"1 y2=%d\n",ca[i3].y); 1172 // //DBG // dbg(0,"1 y2=%d\n",ca[i3].y);
1123 // } 1173 // }
1124 // } 1174 // }
1125 //} 1175 //}
1126 1176
1127 count = transform(tr, pro, ca, pa, count, 0, 0, NULL); 1177 count = transform(tr, pro, ca, pa, count, 0, 0, NULL);
1128 1178
1129 ////DBG dbg(0,"count 2=%d\n", count); 1179 ////DBG // dbg(0,"count 2=%d\n", count);
1130 1180
1131 // --- LABEL --- 1181 // --- LABEL ---
1132 labels[1] = NULL; 1182 labels[1] = NULL;
1133 label_count = 0; 1183 label_count = 0;
1134 if (item_attr_get(item, attr_label, &attr)) 1184 if (item_attr_get(item, attr_label, &attr))
1135 { 1185 {
1136 labels[0] = attr.u.str; 1186 labels[0] = attr.u.str;
1137 ////DBG dbg(0,"labels[0]=%s\n",attr.u.str); 1187 ////DBG // dbg(0,"labels[0]=%s\n",attr.u.str);
1138 if (!label_count) 1188 if (!label_count)
1139 { 1189 {
1140 label_count = 2; 1190 label_count = 2;
1141 } 1191 }
1142 } 1192 }
1151 //int i3; 1201 //int i3;
1152 //for (i3 = 0 ; i3 < count ; i3++) 1202 //for (i3 = 0 ; i3 < count ; i3++)
1153 //{ 1203 //{
1154 // if (i3) 1204 // if (i3)
1155 // { 1205 // {
1156 // //DBG dbg(0,"2 x1=%d\n",pa[i3-1].x); 1206 // //DBG // dbg(0,"2 x1=%d\n",pa[i3-1].x);
1157 // //DBG dbg(0,"2 y1=%d\n",pa[i3-1].y); 1207 // //DBG // dbg(0,"2 y1=%d\n",pa[i3-1].y);
1158 // //DBG dbg(0,"2 x2=%d\n",pa[i3].x); 1208 // //DBG // dbg(0,"2 x2=%d\n",pa[i3].x);
1159 // //DBG dbg(0,"2 y2=%d\n",pa[i3].y); 1209 // //DBG // dbg(0,"2 y2=%d\n",pa[i3].y);
1160 // } 1210 // }
1161 //} 1211 //}
1162 android_DrawMapPreview_polyline(pa, count, 0); 1212 android_DrawMapPreview_polyline(pa, count, 0);
1163 if (labels[0] != NULL) 1213 if (labels[0] != NULL)
1164 { 1214 {
1167 } 1217 }
1168 else if (item_is_district(*item)) 1218 else if (item_is_district(*item))
1169 { 1219 {
1170 if (zoom > 6) 1220 if (zoom > 6)
1171 { 1221 {
1172 // //DBG dbg(0,"xx** %s - %s\n",item_to_name(item->type),labels[0]); 1222 // //DBG // dbg(0,"xx** %s - %s\n",item_to_name(item->type),labels[0]);
1173 if (count >= 1) 1223 if (count >= 1)
1174 { 1224 {
1175 android_DrawMapPreview_text(pa[0].x, pa[0].y, labels[0], font_size * 2, 0x10000, 0); 1225 android_DrawMapPreview_text(pa[0].x, pa[0].y, labels[0], font_size * 2, 0x10000, 0);
1176 } 1226 }
1177 } 1227 }
1178 } 1228 }
1179 else if (item_is_town(*item)) 1229 else if (item_is_town(*item))
1180 { 1230 {
1181 // //DBG dbg(0,"yy** %s - %s\n",item_to_name(item->type),labels[0]); 1231 // //DBG // dbg(0,"yy** %s - %s\n",item_to_name(item->type),labels[0]);
1182 if (count >= 1) 1232 if (count >= 1)
1183 { 1233 {
1184 android_DrawMapPreview_text(pa[0].x, pa[0].y, labels[0], font_size * 3, 0x10000, 0); 1234 android_DrawMapPreview_text(pa[0].x, pa[0].y, labels[0], font_size * 3, 0x10000, 0);
1185 } 1235 }
1186 } 1236 }
1187 1237
1188 //if (item_is_street(*item)) 1238 //if (item_is_street(*item))
1189 //{ 1239 //{
1190 // if (item_attr_get(item, attr_label, &attr)) 1240 // if (item_attr_get(item, attr_label, &attr))
1191 // { 1241 // {
1192 // ////DBG dbg(0,"street1=%s\n",map_convert_string(item->map, attr.u.str)); 1242 // ////DBG // dbg(0,"street1=%s\n",map_convert_string(item->map, attr.u.str));
1193 // if ( (streetname_last==NULL) || (strcmp(streetname_last,attr.u.str) != 0) ) 1243 // if ( (streetname_last==NULL) || (strcmp(streetname_last,attr.u.str) != 0) )
1194 // { 1244 // {
1195 // ////DBG dbg(0,"street2=%s\n",map_convert_string(item->map, attr.u.str)); 1245 // ////DBG // dbg(0,"street2=%s\n",map_convert_string(item->map, attr.u.str));
1196 // } 1246 // }
1197 // } 1247 // }
1198 //} 1248 //}
1199 } 1249 }
1200 //g_free(streetname_last); 1250 //g_free(streetname_last);
1219} 1269}
1220 1270
1221void android_DrawMapPreview_target(int x, int y) 1271void android_DrawMapPreview_target(int x, int y)
1222{ 1272{
1223#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 1273#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1224 dbg(0,"+#+:enter\n"); 1274 // dbg(0,"+#+:enter\n");
1225#endif 1275#endif
1276
1277 JNIEnv *jnienv2;
1278 jnienv2 = jni_getenv();
1279
1226 if (NavitMapPreviewActivityClass == NULL) 1280 if (NavitMapPreviewActivityClass == NULL)
1227 { 1281 {
1228 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitMapPreviewActivity", &NavitMapPreviewActivityClass)) 1282 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitMapPreviewActivity", &NavitMapPreviewActivityClass))
1229 { 1283 {
1230 NavitMapPreviewActivityClass = NULL; 1284 NavitMapPreviewActivityClass = NULL;
1235 { 1289 {
1236 android_find_static_method(NavitMapPreviewActivityClass, "DrawMapPreview_target", "(II)V", &DrawMapPreview_target); 1290 android_find_static_method(NavitMapPreviewActivityClass, "DrawMapPreview_target", "(II)V", &DrawMapPreview_target);
1237 } 1291 }
1238 if (DrawMapPreview_target == NULL) 1292 if (DrawMapPreview_target == NULL)
1239 { 1293 {
1240 //DBG dbg(0, "no method found\n"); 1294 //DBG // dbg(0, "no method found\n");
1241 return; /* exception thrown */ 1295 return; /* exception thrown */
1242 } 1296 }
1243 (*jnienv)->CallStaticVoidMethod(jnienv, NavitMapPreviewActivityClass, DrawMapPreview_target, x, y); 1297 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitMapPreviewActivityClass, DrawMapPreview_target, x, y);
1244} 1298}
1245 1299
1246void android_DrawMapPreview_text(int x, int y, char *text, int size, int dx, int dy) 1300void android_DrawMapPreview_text(int x, int y, char *text, int size, int dx, int dy)
1247{ 1301{
1248#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 1302#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1249 dbg(0,"+#+:enter\n"); 1303 // dbg(0,"+#+:enter\n");
1250#endif 1304#endif
1305
1306 JNIEnv *jnienv2;
1307 jnienv2 = jni_getenv();
1251 1308
1252 if (NavitMapPreviewActivityClass == NULL) 1309 if (NavitMapPreviewActivityClass == NULL)
1253 { 1310 {
1254 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitMapPreviewActivity", &NavitMapPreviewActivityClass)) 1311 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitMapPreviewActivity", &NavitMapPreviewActivityClass))
1255 { 1312 {
1261 { 1318 {
1262 android_find_static_method(NavitMapPreviewActivityClass, "DrawMapPreview_text", "(IILjava/lang/String;III)V", &DrawMapPreview_text); 1319 android_find_static_method(NavitMapPreviewActivityClass, "DrawMapPreview_text", "(IILjava/lang/String;III)V", &DrawMapPreview_text);
1263 } 1320 }
1264 if (DrawMapPreview_text == NULL) 1321 if (DrawMapPreview_text == NULL)
1265 { 1322 {
1266 //DBG dbg(0, "no method found\n"); 1323 //DBG // dbg(0, "no method found\n");
1267 return; /* exception thrown */ 1324 return; /* exception thrown */
1268 } 1325 }
1269 1326
1270 ////DBG dbg(0,"** dx=%d,dy=%d\n",dx,dy); 1327 ////DBG // dbg(0,"** dx=%d,dy=%d\n",dx,dy);
1271 1328
1272 jstring string1 = (*jnienv)->NewStringUTF(jnienv, text); 1329 jstring string1 = (*jnienv2)->NewStringUTF(jnienv2, text);
1273 (*jnienv)->CallStaticVoidMethod(jnienv, NavitMapPreviewActivityClass, DrawMapPreview_text, x, y, string1, size, dx, dy); 1330 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitMapPreviewActivityClass, DrawMapPreview_text, x, y, string1, size, dx, dy);
1274 (*jnienv)->DeleteLocalRef(jnienv, string1); 1331 (*jnienv2)->DeleteLocalRef(jnienv2, string1);
1275} 1332}
1276 1333
1277void android_DrawMapPreview_polyline(struct point *p, int count, int type) 1334void android_DrawMapPreview_polyline(struct point *p, int count, int type)
1278{ 1335{
1279#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 1336#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1280 dbg(0,"+#+:enter\n"); 1337 // dbg(0,"+#+:enter\n");
1281#endif 1338#endif
1282 // type: 1339 // type:
1283 // 0 -> normal street 1340 // 0 -> normal street
1284 // 2 -> country border 1341 // 2 -> country border
1285 1342
1343 JNIEnv *jnienv2;
1344 jnienv2 = jni_getenv();
1345
1286 if (NavitMapPreviewActivityClass == NULL) 1346 if (NavitMapPreviewActivityClass == NULL)
1287 { 1347 {
1288 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitMapPreviewActivity", &NavitMapPreviewActivityClass)) 1348 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitMapPreviewActivity", &NavitMapPreviewActivityClass))
1289 { 1349 {
1290 NavitMapPreviewActivityClass = NULL; 1350 NavitMapPreviewActivityClass = NULL;
1295 { 1355 {
1296 android_find_static_method(NavitMapPreviewActivityClass, "DrawMapPreview_polyline", "(I[I)V", &DrawMapPreview_polyline); 1356 android_find_static_method(NavitMapPreviewActivityClass, "DrawMapPreview_polyline", "(I[I)V", &DrawMapPreview_polyline);
1297 } 1357 }
1298 if (DrawMapPreview_polyline == NULL) 1358 if (DrawMapPreview_polyline == NULL)
1299 { 1359 {
1300 //DBG dbg(0, "no method found\n"); 1360 //DBG // dbg(0, "no method found\n");
1301 return; /* exception thrown */ 1361 return; /* exception thrown */
1302 } 1362 }
1303 1363
1304 jint pc[count * 2]; 1364 jint pc[count * 2];
1305 int i; 1365 int i;
1306 jintArray points; 1366 jintArray points;
1307 if (count <= 0) 1367 if (count <= 0)
1308 { 1368 {
1309 return; 1369 return;
1310 } 1370 }
1311 points = (*jnienv)->NewIntArray(jnienv, count * 2); 1371 points = (*jnienv2)->NewIntArray(jnienv2, count * 2);
1312 for (i = 0; i < count; i++) 1372 for (i = 0; i < count; i++)
1313 { 1373 {
1314 pc[i * 2] = p[i].x; 1374 pc[i * 2] = p[i].x;
1315 pc[i * 2 + 1] = p[i].y; 1375 pc[i * 2 + 1] = p[i].y;
1316 } 1376 }
1317 (*jnienv)->SetIntArrayRegion(jnienv, points, 0, count * 2, pc); 1377 (*jnienv2)->SetIntArrayRegion(jnienv2, points, 0, count * 2, pc);
1318 (*jnienv)->CallStaticVoidMethod(jnienv, NavitMapPreviewActivityClass, DrawMapPreview_polyline, type, points); 1378 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitMapPreviewActivityClass, DrawMapPreview_polyline, type, points);
1319 (*jnienv)->DeleteLocalRef(jnienv, points); 1379 (*jnienv2)->DeleteLocalRef(jnienv2, points);
1320} 1380}
1321 1381
1322JNIEXPORT jstring JNICALL 1382JNIEXPORT jstring JNICALL
1323Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackGeoCalc(JNIEnv* env, jobject thiz, int i, float a, float b) 1383Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackGeoCalc(JNIEnv* env, jobject thiz, int i, float a, float b)
1324{ 1384{
1325#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 1385#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1326 dbg(0,"+#+:enter\n"); 1386 // dbg(0,"+#+:enter\n");
1327#endif 1387#endif
1328 // dbg(0,"EEnter i=%d\n", i); 1388 // dbg(0,"EEnter i=%d\n", i);
1389
1390 int thread_id = gettid();
1391 // dbg(0, "THREAD ID=%d\n", thread_id);
1329 1392
1330 // const char *result; 1393 // const char *result;
1331 gchar *result; 1394 gchar *result;
1332 1395
1333 if (i == 1) 1396 if (i == 1)
1337 struct coord c22; 1400 struct coord c22;
1338 struct point p; 1401 struct point p;
1339 p.x = a; 1402 p.x = a;
1340 p.y = b; 1403 p.y = b;
1341 transform_reverse(global_navit->trans, &p, &c22); 1404 transform_reverse(global_navit->trans, &p, &c22);
1342 ////DBG dbg(0,"%f, %f\n",a, b); 1405 ////DBG // dbg(0,"%f, %f\n",a, b);
1343 ////DBG dbg(0,"%d, %d\n",p.x, p.y); 1406 ////DBG // dbg(0,"%d, %d\n",p.x, p.y);
1344 transform_to_geo(projection_mg, &c22, &g22); 1407 transform_to_geo(projection_mg, &c22, &g22);
1345 ////DBG dbg(0,"%d, %d, %f, %f\n",c22.x, c22.y, g22.lat, g22.lng); 1408 ////DBG // dbg(0,"%d, %d, %f, %f\n",c22.x, c22.y, g22.lat, g22.lng);
1346 result = g_strdup_printf("%f:%f", g22.lat, g22.lng); 1409 result = g_strdup_printf("%f:%f", g22.lat, g22.lng);
1347 } 1410 }
1348 else if (i == 2) 1411 else if (i == 2)
1349 { 1412 {
1350 // geo to pixel-on-screen 1413 // geo to pixel-on-screen
1351 struct coord c99; 1414 struct coord c99;
1352 struct coord_geo g99; 1415 struct coord_geo g99;
1353 g99.lat = a; 1416 g99.lat = a;
1354 g99.lng = b; 1417 g99.lng = b;
1355 ////DBG dbg(0,"zzzzz %f, %f\n",a, b); 1418 ////DBG // dbg(0,"zzzzz %f, %f\n",a, b);
1356 ////DBG dbg(0,"yyyyy %f, %f\n",g99.lat, g99.lng); 1419 ////DBG // dbg(0,"yyyyy %f, %f\n",g99.lat, g99.lng);
1357 transform_from_geo(projection_mg, &g99, &c99); 1420 transform_from_geo(projection_mg, &g99, &c99);
1358 ////DBG dbg(0,"%d %d %f %f\n",c99.x, c99.y, g99.lat, g99.lng); 1421 ////DBG // dbg(0,"%d %d %f %f\n",c99.x, c99.y, g99.lat, g99.lng);
1359 1422
1360 enum projection pro = transform_get_projection(global_navit->trans_cursor); 1423 enum projection pro = transform_get_projection(global_navit->trans_cursor);
1361 struct point pnt; 1424 struct point pnt;
1362 transform(global_navit->trans, pro, &c99, &pnt, 1, 0, 0, NULL); 1425 transform(global_navit->trans, pro, &c99, &pnt, 1, 0, 0, NULL);
1363 ////DBG dbg(0,"x=%d\n",pnt.x); 1426 ////DBG // dbg(0,"x=%d\n",pnt.x);
1364 ////DBG dbg(0,"y=%d\n",pnt.y); 1427 ////DBG // dbg(0,"y=%d\n",pnt.y);
1365 1428
1366 result = g_strdup_printf("%d:%d", pnt.x, pnt.y); 1429 result = g_strdup_printf("%d:%d", pnt.x, pnt.y);
1367 } 1430 }
1368 else if (i == 3) 1431 else if (i == 3)
1369 { 1432 {
1371 struct coord c99; 1434 struct coord c99;
1372 struct pcoord pc99; 1435 struct pcoord pc99;
1373 struct coord_geo g99; 1436 struct coord_geo g99;
1374 g99.lat = a; 1437 g99.lat = a;
1375 g99.lng = b; 1438 g99.lng = b;
1376 ////DBG dbg(0,"zzzzz %f, %f\n",a, b); 1439 ////DBG // dbg(0,"zzzzz %f, %f\n",a, b);
1377 ////DBG dbg(0,"yyyyy %f, %f\n",g99.lat, g99.lng); 1440 ////DBG // dbg(0,"yyyyy %f, %f\n",g99.lat, g99.lng);
1378 transform_from_geo(projection_mg, &g99, &c99); 1441 transform_from_geo(projection_mg, &g99, &c99);
1379 ////DBG dbg(0,"%d %d %f %f\n",c99.x, c99.y, g99.lat, g99.lng); 1442 ////DBG // dbg(0,"%d %d %f %f\n",c99.x, c99.y, g99.lat, g99.lng);
1380 1443
1381 //enum projection pro=transform_get_projection(global_navit->trans_cursor); 1444 //enum projection pro=transform_get_projection(global_navit->trans_cursor);
1382 //struct point pnt; 1445 //struct point pnt;
1383 //transform(global_navit->trans, pro, &c99, &pnt, 1, 0, 0, NULL); 1446 //transform(global_navit->trans, pro, &c99, &pnt, 1, 0, 0, NULL);
1384 ////DBG dbg(0,"x=%d\n",pnt.x); 1447 ////DBG // dbg(0,"x=%d\n",pnt.x);
1385 ////DBG dbg(0,"y=%d\n",pnt.y); 1448 ////DBG // dbg(0,"y=%d\n",pnt.y);
1386 pc99.x = c99.x; 1449 pc99.x = c99.x;
1387 pc99.y = c99.y; 1450 pc99.y = c99.y;
1388 pc99.pro = projection_mg; 1451 pc99.pro = projection_mg;
1389 1452
1390 navit_set_center(global_navit, &pc99, 0); 1453 navit_set_center(global_navit, &pc99, 0);
1495 c24.y = c22.y; 1558 c24.y = c22.y;
1496 c24.pro = transform_get_projection(global_navit->trans); 1559 c24.pro = transform_get_projection(global_navit->trans);
1497 result = navit_find_nearest_item_dump(global_navit->mapsets->data, &c24, 1); 1560 result = navit_find_nearest_item_dump(global_navit->mapsets->data, &c24, 1);
1498 } 1561 }
1499 1562
1500 // dbg(0, "result=%s\n", result); 1563 // // dbg(0, "result=%s\n", result);
1501 jstring js = (*env)->NewStringUTF(env, result); 1564 jstring js = (*env)->NewStringUTF(env, result);
1502 g_free(result); 1565 g_free(result);
1503 1566
1504 return js; 1567 return js;
1505} 1568}
1506 1569
1507JNIEXPORT jstring JNICALL 1570JNIEXPORT jstring JNICALL
1508Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackLocalizedString(JNIEnv* env, jobject thiz, jobject str) 1571Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackLocalizedString(JNIEnv* env, jobject thiz, jobject str)
1509{ 1572{
1510#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 1573#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1511 dbg(0,"+#+:enter\n"); 1574 // dbg(0,"+#+:enter\n");
1512#endif 1575#endif
1513 //DBG dbg(0,"EEnter\n"); 1576 // // dbg(0,"EEnter\n");
1577
1578 int thread_id = gettid();
1579 // dbg(0, "THREAD ID=%d\n", thread_id);
1514 1580
1515 const char *s; 1581 const char *s;
1516 const char *localized_str; 1582 const char *localized_str;
1517 1583
1518 s = (*env)->GetStringUTFChars(env, str, NULL); 1584 s = (*env)->GetStringUTFChars(env, str, NULL);
1519 ////DBG dbg(0,"*****string=%s\n",s); 1585 ////DBG // dbg(0,"*****string=%s\n",s);
1520 1586
1521 localized_str = gettext(s); 1587 localized_str = gettext(s);
1522 ////DBG dbg(0,"localized string=%s",localized_str); 1588 ////DBG // dbg(0,"localized string=%s",localized_str);
1523 1589
1524 // jstring dataStringValue = (jstring) localized_str; 1590 // jstring dataStringValue = (jstring) localized_str;
1525 jstring js = (*env)->NewStringUTF(env, localized_str); 1591 jstring js = (*env)->NewStringUTF(env, localized_str);
1526 1592
1527 (*env)->ReleaseStringUTFChars(env, str, s); 1593 (*env)->ReleaseStringUTFChars(env, str, s);
1528 1594
1529 return js; 1595 return js;
1530} 1596}
1531 1597
1598JNIEXPORT jint JNICALL
1599Java_com_zoffcc_applications_zanavi_NavitGraphics_GetThreadId(JNIEnv* env, jobject thiz)
1600{
1601#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1602 // dbg(0,"+#+:enter\n");
1603#endif
1604
1605 int thread_id = gettid();
1606 // // dbg(0, "THREAD ID=%d\n", thread_id);
1607
1608 jint i = thread_id;
1609 return i;
1610}
1611
1532JNIEXPORT void JNICALL 1612JNIEXPORT void JNICALL
1533Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackMessageChannel(JNIEnv* env, jobject thiz, int i, jobject str2) 1613Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackMessageChannelReal(JNIEnv* env, jobject thiz, int i, jobject str2)
1534{ 1614{
1535#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 1615#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1536 dbg(0,"+#+:enter\n"); 1616 // dbg(0,"+#+:enter\n");
1537#endif 1617#endif
1618
1619 int thread_id = gettid();
1620 // dbg(0, "THREAD ID=%d\n", thread_id);
1621
1538 const char *s; 1622 const char *s;
1539 jobject str = (*env)->NewGlobalRef(env, str2); 1623 jobject str = (*env)->NewGlobalRef(env, str2);
1540 1624
1541 //DBG dbg(0,"enter %d %p\n",i,str); 1625 // dbg(0,"enter %d\n",i);
1542 1626
1543 config_get_attr(config, attr_navit, &attr, NULL); 1627 config_get_attr(config, attr_navit, &attr, NULL);
1544 // attr.u.navit 1628 // attr.u.navit
1545 1629
1546 //DBG dbg(0,"c1\n"); 1630 //DBG // dbg(0,"c1\n");
1547 1631
1548 if (i) 1632 if (i)
1549 { 1633 {
1550 if (i == 1) 1634 if (i == 1)
1551 { 1635 {
1556 else if (i == 2) 1640 else if (i == 2)
1557 { 1641 {
1558 // zoom out 1642 // zoom out
1559 navit_zoom_out_cursor(global_navit, 2); 1643 navit_zoom_out_cursor(global_navit, 2);
1560 // navit_zoom_out_cursor(attr.u.navit, 2); 1644 // navit_zoom_out_cursor(attr.u.navit, 2);
1645 }
1646 else if (i == 75)
1647 {
1648 // stop demo vechile
1649 global_stop_demo_vehicle = 1;
1650 }
1651 else if (i == 74)
1652 {
1653 // allow demo vechile to move
1654 global_stop_demo_vehicle = 0;
1561 } 1655 }
1562 else if (i == 73) 1656 else if (i == 73)
1563 { 1657 {
1564 // update the route path and route graph (e.g. after setting new roadblocks) 1658 // update the route path and route graph (e.g. after setting new roadblocks)
1565 // this destroys the route graph and calcs everything totally new! 1659 // this destroys the route graph and calcs everything totally new!
1694 (*env)->ReleaseStringUTFChars(env, str, s); 1788 (*env)->ReleaseStringUTFChars(env, str, s);
1695 } 1789 }
1696 else if (i == 56) 1790 else if (i == 56)
1697 { 1791 {
1698 // draw polylines with/without circles at the end 1792 // draw polylines with/without circles at the end
1699 //dbg(0, "dpf1\n"); 1793 //// dbg(0, "dpf1\n");
1700 s = (*env)->GetStringUTFChars(env, str, NULL); 1794 s = (*env)->GetStringUTFChars(env, str, NULL);
1701 //dbg(0, "dpf2\n"); 1795 //// dbg(0, "dpf2\n");
1702 draw_polylines_fast = atoi(s); 1796 draw_polylines_fast = atoi(s);
1703 //dbg(0, "dpf=%d\n", draw_polylines_fast); 1797 //// dbg(0, "dpf=%d\n", draw_polylines_fast);
1704 (*env)->ReleaseStringUTFChars(env, str, s); 1798 (*env)->ReleaseStringUTFChars(env, str, s);
1705 } 1799 }
1706 else if (i == 55) 1800 else if (i == 55)
1707 { 1801 {
1708 // set cache size for (map-)files 1802 // set cache size for (map-)files
1709 //dbg(0, "csf1\n"); 1803 //// dbg(0, "csf1\n");
1710 s = (*env)->GetStringUTFChars(env, str, NULL); 1804 s = (*env)->GetStringUTFChars(env, str, NULL);
1711 //dbg(0, "csf2\n"); 1805 //// dbg(0, "csf2\n");
1712 cache_size_file = atoi(s); 1806 cache_size_file = atoi(s);
1713 file_cache_init(); 1807 file_cache_init();
1714 dbg(0, "csf=%d\n", cache_size_file); 1808 // dbg(0, "csf=%d\n", cache_size_file);
1715 (*env)->ReleaseStringUTFChars(env, str, s); 1809 (*env)->ReleaseStringUTFChars(env, str, s);
1716 } 1810 }
1717 else if (i == 54) 1811 else if (i == 54)
1718 { 1812 {
1719 // speak streetnames 1813 // speak streetnames
1759 1853
1760 speed.type = attr_speed; 1854 speed.type = attr_speed;
1761 speed.u.num = atoi(s); 1855 speed.u.num = atoi(s);
1762 1856
1763 interval.type = attr_interval; 1857 interval.type = attr_interval;
1764 interval.u.num = 1000; 1858 interval.u.num = 1000; // 1 sec.
1859 // interval.u.num = 5000; // 5 sec.
1765 1860
1766 attrs[0] = &source; 1861 attrs[0] = &source;
1767 attrs[1] = &active; 1862 attrs[1] = &active;
1768 attrs[2] = &follow; 1863 attrs[2] = &follow;
1769 attrs[3] = &speed; 1864 attrs[3] = &speed;
1770 attrs[4] = &interval; 1865 attrs[4] = &interval;
1771 attrs[5] = NULL; 1866 attrs[5] = NULL;
1772 // attr_source -> source->u.str='demo://' 1867 // attr_source -> source->u.str='demo://'
1773 // <!-- vehicle name="Demo" profilename="car" enabled="no" active="yes" source="demo://" --> 1868 // <!-- vehicle name="Demo" profilename="car" enabled="no" active="yes" source="demo://" -->
1774 struct vehicle *v; 1869 struct vehicle *v;
1775 //DBG dbg(0, "demo vehicle new start\n"); 1870 //DBG // dbg(0, "demo vehicle new start\n");
1776 v = vehicle_new(&parent, attrs); 1871 v = vehicle_new(&parent, attrs);
1777 //DBG dbg(0, "demo vehicle new end\n"); 1872 //DBG // dbg(0, "demo vehicle new end\n");
1778 1873
1779 if (v != NULL) 1874 if (v != NULL)
1780 { 1875 {
1781 //DBG dbg(0, "adding demo vehicle\n"); 1876 //DBG // dbg(0, "adding demo vehicle\n");
1782 navit_add_vehicle(global_navit, v); 1877 navit_add_vehicle(global_navit, v);
1783 //DBG dbg(0, "setting cursor\n"); 1878 //DBG // dbg(0, "setting cursor\n");
1784 navit_set_cursors(global_navit); 1879 navit_set_cursors(global_navit);
1785 1880
1786 struct attr follow2; 1881 struct attr follow2;
1787 follow2.type = attr_follow; 1882 follow2.type = attr_follow;
1788 follow2.u.num = 1; 1883 follow2.u.num = 1;
1794 attrx.u.num = 1; 1889 attrx.u.num = 1;
1795 navit_set_attr(global_navit, &attrx); 1890 navit_set_attr(global_navit, &attrx);
1796 } 1891 }
1797 else 1892 else
1798 { 1893 {
1799 //DBG dbg(0, "ERROR adding demo vehicle\n"); 1894 //DBG // dbg(0, "ERROR adding demo vehicle\n");
1800 } 1895 }
1801 // **no** navit_set_vehicle(global_navit, global_navit->vehicle); 1896 // **no** navit_set_vehicle(global_navit, global_navit->vehicle);
1802 //DBG dbg(0, "ready\n"); 1897 //DBG // dbg(0, "ready\n");
1803 1898
1804 (*env)->ReleaseStringUTFChars(env, str, s); 1899 (*env)->ReleaseStringUTFChars(env, str, s);
1805 } 1900 }
1806 else if (i == 51) 1901 else if (i == 51)
1807 { 1902 {
1808 // set position to pixel x,y 1903 // set position to pixel x,y
1809 //DBG dbg(0, "sp 1\n"); 1904 //DBG // dbg(0, "sp 1\n");
1810 char *pstr; 1905 char *pstr;
1811 struct point p; 1906 struct point p;
1812 struct coord c; 1907 struct coord c;
1813 struct pcoord pc; 1908 struct pcoord pc;
1814 1909
1823 p.x = atoi(pstr); 1918 p.x = atoi(pstr);
1824 // pixel-y 1919 // pixel-y
1825 pstr = strtok(NULL, "#"); 1920 pstr = strtok(NULL, "#");
1826 p.y = atoi(pstr); 1921 p.y = atoi(pstr);
1827 1922
1828 //DBG dbg(0, "sp 2\n"); 1923 //DBG // dbg(0, "sp 2\n");
1829 transform_reverse(global_navit->trans, &p, &c); 1924 transform_reverse(global_navit->trans, &p, &c);
1830 //DBG dbg(0, "sp 3\n"); 1925 //DBG // dbg(0, "sp 3\n");
1831 1926
1832 pc.x = c.x; 1927 pc.x = c.x;
1833 pc.y = c.y; 1928 pc.y = c.y;
1834 //DBG dbg(0, "sp 4\n"); 1929 //DBG // dbg(0, "sp 4\n");
1835 pc.pro = transform_get_projection(global_navit->trans); 1930 pc.pro = transform_get_projection(global_navit->trans);
1836 //DBG dbg(0, "sp 5\n"); 1931 //DBG // dbg(0, "sp 5\n");
1837 1932
1838 //DBG dbg(0, "%d %d\n", pc.x, pc.y); 1933 //DBG // dbg(0, "%d %d\n", pc.x, pc.y);
1839 // set position 1934 // set position
1840 //DBG dbg(0, "sp 6\n"); 1935 //DBG // dbg(0, "sp 6\n");
1841 navit_set_position(global_navit, &pc); 1936 navit_set_position(global_navit, &pc);
1842 //DBG dbg(0, "ready\n"); 1937 //DBG // dbg(0, "ready\n");
1843 } 1938 }
1844 else if (i == 50) 1939 else if (i == 50)
1845 { 1940 {
1846 // we request to stop drawing the map 1941 // we request to stop drawing the map
1847 // //DBG dbg(0, "cancel_drawing_global=1\n"); 1942 // dbg(0, "DO__DRAW:cancel_drawing_global=1\n");
1848 cancel_drawing_global = 1; 1943 cancel_drawing_global = 1;
1849 } 1944 }
1850 else if (i == 47) 1945 else if (i == 47)
1851 { 1946 {
1852 // change maps data dir 1947 // change maps data dir
1853 s = (*env)->GetStringUTFChars(env, str, NULL); 1948 s = (*env)->GetStringUTFChars(env, str, NULL);
1854 navit_maps_dir = g_strdup(s); 1949 navit_maps_dir = g_strdup(s);
1855 (*env)->ReleaseStringUTFChars(env, str, s); 1950 (*env)->ReleaseStringUTFChars(env, str, s);
1856 // //DBG dbg(0,"*****string use=%s\n",navit_maps_dir); 1951 // //DBG // dbg(0,"*****string use=%s\n",navit_maps_dir);
1857 } 1952 }
1858 else if (i == 46) 1953 else if (i == 46)
1859 { 1954 {
1860 // stop searching and show results found until now 1955 // stop searching and show results found until now
1861 offline_search_break_searching = 1; 1956 offline_search_break_searching = 1;
2041 allow_gui_internal = 0; 2136 allow_gui_internal = 0;
2042 } 2137 }
2043 else if (i == 8) 2138 else if (i == 8)
2044 { 2139 {
2045 // zoom to zoomlevel 2140 // zoom to zoomlevel
2046 //DBG dbg(0,"-8- a\n"); 2141 //DBG // dbg(0,"-8- a\n");
2047 navit_zoom_to_scale(global_navit, 524288); 2142 navit_zoom_to_scale(global_navit, 524288);
2048 //DBG dbg(0,"-8- b\n"); 2143 //DBG // dbg(0,"-8- b\n");
2049 } 2144 }
2050 else if (i == 7) 2145 else if (i == 7)
2051 { 2146 {
2052 // stop navigation 2147 // stop navigation
2053 if (attr.u.navit->destination_valid != 0) 2148 if (attr.u.navit->destination_valid != 0)
2061 } 2156 }
2062 else if (i == 5) 2157 else if (i == 5)
2063 { 2158 {
2064 // call a command (like in gui) --> seems not many commands really work with this :-( 2159 // call a command (like in gui) --> seems not many commands really work with this :-(
2065 s = (*env)->GetStringUTFChars(env, str, NULL); 2160 s = (*env)->GetStringUTFChars(env, str, NULL);
2066 ////DBG dbg(0,"*****string=%s\n",s); 2161 ////DBG // dbg(0,"*****string=%s\n",s);
2067 command_evaluate(&attr.u.navit->self, s); 2162 command_evaluate(&attr.u.navit->self, s);
2068 (*env)->ReleaseStringUTFChars(env, str, s); 2163 (*env)->ReleaseStringUTFChars(env, str, s);
2069 } 2164 }
2070 else if (i == 49) 2165 else if (i == 49)
2071 { 2166 {
2151 p = strtok(NULL, "#"); 2246 p = strtok(NULL, "#");
2152 g.lng = strtof(p, &stopstring); 2247 g.lng = strtof(p, &stopstring);
2153 // description 2248 // description
2154 name = strtok(NULL, "#"); 2249 name = strtok(NULL, "#");
2155 2250
2156 ////DBG dbg(0,"lat=%f\n",g.lat); 2251 ////DBG // dbg(0,"lat=%f\n",g.lat);
2157 ////DBG dbg(0,"lng=%f\n",g.lng); 2252 ////DBG // dbg(0,"lng=%f\n",g.lng);
2158 ////DBG dbg(0,"str1=%s\n",name); 2253 ////DBG // dbg(0,"str1=%s\n",name);
2159 2254
2160 struct coord c; 2255 struct coord c;
2161 transform_from_geo(projection_mg, &g, &c); 2256 transform_from_geo(projection_mg, &g, &c);
2162 2257
2163 struct pcoord pc; 2258 struct pcoord pc;
2175 char *name; 2270 char *name;
2176 s = (*env)->GetStringUTFChars(env, str, NULL); 2271 s = (*env)->GetStringUTFChars(env, str, NULL);
2177 char parse_str[strlen(s) + 1]; 2272 char parse_str[strlen(s) + 1];
2178 strcpy(parse_str, s); 2273 strcpy(parse_str, s);
2179 (*env)->ReleaseStringUTFChars(env, str, s); 2274 (*env)->ReleaseStringUTFChars(env, str, s);
2180 ////DBG dbg(0,"*****string=%s\n",s); 2275 ////DBG // dbg(0,"*****string=%s\n",s);
2181 2276
2182 // set destination to (lat#lon#title) 2277 // set destination to (lat#lon#title)
2183 struct coord_geo g; 2278 struct coord_geo g;
2184 char *p; 2279 char *p;
2185 char *stopstring; 2280 char *stopstring;
2191 p = strtok(NULL, "#"); 2286 p = strtok(NULL, "#");
2192 g.lng = strtof(p, &stopstring); 2287 g.lng = strtof(p, &stopstring);
2193 // description 2288 // description
2194 name = strtok(NULL, "#"); 2289 name = strtok(NULL, "#");
2195 2290
2196 ////DBG dbg(0,"lat=%f\n",g.lat); 2291 ////DBG // dbg(0,"lat=%f\n",g.lat);
2197 ////DBG dbg(0,"lng=%f\n",g.lng); 2292 ////DBG // dbg(0,"lng=%f\n",g.lng);
2198 ////DBG dbg(0,"str1=%s\n",name); 2293 ////DBG // dbg(0,"str1=%s\n",name);
2199 2294
2200 struct coord c; 2295 struct coord c;
2201 transform_from_geo(projection_mg, &g, &c); 2296 transform_from_geo(projection_mg, &g, &c);
2202 2297
2203 struct pcoord pc; 2298 struct pcoord pc;
2209 navit_set_destination(global_navit, &pc, name, 1); 2304 navit_set_destination(global_navit, &pc, name, 1);
2210 2305
2211 } 2306 }
2212 } 2307 }
2213 2308
2214 // dbg(0,"deleteglobalref\n");
2215
2216 (*env)->DeleteGlobalRef(env, str); 2309 (*env)->DeleteGlobalRef(env, str);
2217 str = NULL; 2310 str = NULL;
2218 2311
2219 // dbg(0,"leave\n"); 2312 // dbg(0,"leave %d\n",i);
2220 2313
2221} 2314}
2222 2315
2223void android_send_generic_text(int id, char *text) 2316void android_send_generic_text(int id, char *text)
2224{ 2317{
2225#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 2318#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2226 dbg(0,"+#+:enter\n"); 2319 // dbg(0,"+#+:enter\n");
2227#endif 2320#endif
2228 //DBG dbg(0,"Enter\n"); 2321 //DBG // dbg(0,"Enter\n");
2229 2322
2230 if (NavitGraphicsClass2 == NULL) 2323 if (NavitGraphicsClass2 == NULL)
2231 { 2324 {
2232 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitGraphics", &NavitGraphicsClass2)) 2325 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitGraphics", &NavitGraphicsClass2))
2233 { 2326 {
2234 NavitGraphicsClass2 = NULL; 2327 NavitGraphicsClass2 = NULL;
2235 return; 2328 return;
2236 } 2329 }
2237 } 2330 }
2238 //DBG dbg(0,"x1\n"); 2331 //DBG // dbg(0,"x1\n");
2239 if (send_generic_text == NULL) 2332 if (send_generic_text == NULL)
2240 { 2333 {
2241 android_find_static_method(NavitGraphicsClass2, "send_generic_text", "(ILjava/lang/String;)V", &send_generic_text); 2334 android_find_static_method(NavitGraphicsClass2, "send_generic_text", "(ILjava/lang/String;)V", &send_generic_text);
2242 } 2335 }
2243 //DBG dbg(0,"x2\n"); 2336 //DBG // dbg(0,"x2\n");
2244 if (send_generic_text == NULL) 2337 if (send_generic_text == NULL)
2245 { 2338 {
2246 //DBG dbg(0, "no method found\n"); 2339 //DBG // dbg(0, "no method found\n");
2247 return; /* exception thrown */ 2340 return; /* exception thrown */
2248 } 2341 }
2249 //DBG dbg(0,"x3\n"); 2342 //DBG // dbg(0,"x3\n");
2250 2343
2251 JNIEnv *jnienv2; 2344 JNIEnv *jnienv2;
2252 jnienv2 = jni_getenv(); 2345 jnienv2 = jni_getenv();
2253 2346
2254 jstring string1 = (*jnienv2)->NewStringUTF(jnienv2, text); 2347 jstring string1 = (*jnienv2)->NewStringUTF(jnienv2, text);
2255 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, send_generic_text, id, string1); 2348 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, send_generic_text, id, string1);
2256 (*jnienv2)->DeleteLocalRef(jnienv2, string1); 2349 (*jnienv2)->DeleteLocalRef(jnienv2, string1);
2257 2350
2258 //DBG dbg(0,"leave\n"); 2351 // // dbg(0,"leave\n");
2259} 2352}
2260 2353
2354void send_osd_values(char *id, char *text1, char *text2, char *text3, int i1, int i2, int i3, int i4, float f1, float f2, float f3)
2355{
2356 //DBG // dbg(0,"EEnter\n");
2357 JNIEnv *jnienv2;
2358 jnienv2 = jni_getenv();
2359
2360 jstring string1 = (*jnienv2)->NewStringUTF(jnienv2, id);
2361 jstring string2 = (*jnienv2)->NewStringUTF(jnienv2, text1);
2362 jstring string3 = (*jnienv2)->NewStringUTF(jnienv2, text2);
2363 jstring string4 = (*jnienv2)->NewStringUTF(jnienv2, text3);
2364
2365 // static
2366 if (NavitGraphicsClass2 == NULL)
2367 {
2368 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitGraphics", &NavitGraphicsClass2))
2369 {
2370 NavitGraphicsClass2 = NULL;
2371 return;
2372 }
2373 }
2374
2375 if (NavitGraphics_send_osd_values2 == NULL)
2376 {
2377 if (!android_find_static_method(NavitGraphicsClass2, "send_osd_values", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIIIFFF)V", &NavitGraphics_send_osd_values2))
2378 {
2379 return;
2380 }
2381 }
2382
2383 // static
2384 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, NavitGraphics_send_osd_values2, string1, string2, string3, string4, i1, i2, i3, i4, f1, f2, f3);
2385
2386 (*jnienv2)->DeleteLocalRef(jnienv2, string1);
2387 (*jnienv2)->DeleteLocalRef(jnienv2, string2);
2388 (*jnienv2)->DeleteLocalRef(jnienv2, string3);
2389 (*jnienv2)->DeleteLocalRef(jnienv2, string4);
2390}
2391
2392void set_vehicle_values_to_java(int x, int y, int angle, int speed)
2393{
2394 //DBG // dbg(0,"EEnter\n");
2395 JNIEnv *jnienv2;
2396 jnienv2 = jni_getenv();
2397
2398 //int thread_id = gettid();
2399 //dbg(0, "THREAD ID=%d\n", thread_id);
2400
2401 if (NavitGraphicsClass2 == NULL)
2402 {
2403 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitGraphics", &NavitGraphicsClass2))
2404 {
2405 NavitGraphicsClass2 = NULL;
2406 return;
2407 }
2408 }
2409
2410 if (NavitGraphics_set_vehicle_values2 == NULL)
2411 {
2412 if (!android_find_static_method(NavitGraphicsClass2, "set_vehicle_values", "(IIII)V", &NavitGraphics_set_vehicle_values2))
2413 {
2414 return;
2415 }
2416 }
2417
2418 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, NavitGraphics_set_vehicle_values2, x, y, angle, speed);
2419}
2420
2421void set_vehicle_values_to_java_delta(int dx, int dy, int dangle)
2422{
2423 JNIEnv *jnienv2;
2424 jnienv2 = jni_getenv();
2425
2426 //int thread_id = gettid();
2427 //dbg(0, "THREAD ID=%d\n", thread_id);
2428
2429 if (NavitGraphicsClass2 == NULL)
2430 {
2431 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitGraphics", &NavitGraphicsClass2))
2432 {
2433 NavitGraphicsClass2 = NULL;
2434 return;
2435 }
2436 }
2437
2438 if (NavitGraphics_set_vehicle_values3 == NULL)
2439 {
2440 if (!android_find_static_method(NavitGraphicsClass2, "set_vehicle_values_delta", "(III)V", &NavitGraphics_set_vehicle_values3))
2441 {
2442 return;
2443 }
2444 }
2445
2446 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, NavitGraphics_set_vehicle_values3, dx, dy, dangle);
2447}
2448

Legend:
Removed from v.29  
changed lines
  Added in v.30

   
Visit the ZANavi Wiki