From df1d4609028435bea47748f88dd480afbe33b1ca Mon Sep 17 00:00:00 2001 From: martin-s Date: Sat, 15 Aug 2009 15:36:16 +0000 Subject: [PATCH] Add:Core:Again android... git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@2466 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/Makefile.am | 7 +++++-- navit/navit/android.c | 2 +- navit/navit/debug.c | 37 +++++++++++++++++++++++------------ navit/navit/{start.c => start_real.c} | 13 +++++++----- 4 files changed, 38 insertions(+), 21 deletions(-) rename navit/navit/{start.c => start_real.c} (95%) diff --git a/navit/navit/Makefile.am b/navit/navit/Makefile.am index c0c9b7d..bcb410c 100644 --- a/navit/navit/Makefile.am +++ b/navit/navit/Makefile.am @@ -17,7 +17,8 @@ endif if SUPPORT_ANDROID lib_LTLIBRARIES = libnavit.la - libnavit_la_LDFLAGS = -module -avoid-version @MODULE_LDFLAGS@ + libnavit_la_LDFLAGS = -module -avoid-version @MODULE_LDFLAGS@ -Wl,--no-undefined + libnavit_la_LIBADD = @NAVIT_LIBS@ @ZLIB_LIBS@ @INTLLIBS@ -Lfib-1.1 -lfib -llog else bin_PROGRAMS = navit osm2navit @@ -31,7 +32,7 @@ EXTRA_DIST = navit.xml libnavit_la_SOURCES = announcement.c atom.c attr.c cache.c callback.c command.c compass.c coord.c country.c cursor.c data_window.c debug.c \ event.c event_glib.h file.c graphics.c gui.c item.c layout.c log.c main.c map.c \ linguistics.c mapset.c maptype.c menu.c messages.c navit.c navigation.c osd.c param.c phrase.c plugin.c popup.c \ - profile.c projection.c roadprofile.c route.c search.c speech.c transform.c track.c \ + profile.c projection.c roadprofile.c route.c search.c speech.c start_real.c transform.c track.c \ util.c vehicle.c vehicleprofile.c xmlconfig.c announcement.h atom.h attr.h attr_def.h cache.h callback.h color.h command.h compass.h coord.h country.h \ cursor.h data.h data_window.h data_window_int.h debug.h destination.h draw_info.h endianess.h event.h \ file.h graphics.h gtkext.h gui.h item.h item_def.h keys.h log.h layer.h layout.h linguistics.h main.h map-share.h map.h\ @@ -55,6 +56,8 @@ apk: all-am android/build.xml cp .libs/*.so */*/.libs/*.so android/libs/armeabi for i in $(shell cd xpm && echo *.xpm); do convert xpm/$$i android/res/drawable/$${i%.xpm}.png; done cp xpm/*.png android/res/drawable + mkdir -p android/res/raw + for i in $(shell cd ../po && echo *.mo); do cp ../po/$$i android/res/raw/$$( echo $$i | tr "[A-Z]" "[a-z]") ; done cd android && ant debug else diff --git a/navit/navit/android.c b/navit/navit/android.c index 5ff1b25..e6b7ee7 100644 --- a/navit/navit/android.c +++ b/navit/navit/android.c @@ -55,7 +55,7 @@ Java_org_navitproject_navit_Navit_NavitMain( JNIEnv* env, jobject thiz, jobject setenv("LANG",langstr,1); dbg(0,"enter env=%p thiz=%p activity=%p lang=%s\n",env,thiz,activity,langstr); (*env)->ReleaseStringUTFChars(env, lang, langstr); - main(1, strings); + main_real(1, strings); } JNIEXPORT void JNICALL diff --git a/navit/navit/debug.c b/navit/navit/debug.c index 9b3edaa..3b3eb8a 100644 --- a/navit/navit/debug.c +++ b/navit/navit/debug.c @@ -25,10 +25,15 @@ #include #include #include +#include "config.h" #include "file.h" #include "item.h" #include "debug.h" +#ifdef HAVE_API_ANDROID +#include +#endif + #ifdef DEBUG_WIN32_CE_MESSAGEBOX #include #include @@ -147,7 +152,24 @@ debug_vprintf(int level, const char *module, const int mlen, const char *functio sprintf(buffer, "%s:%s", module, function); if (debug_level_get(module) >= level || debug_level_get(buffer) >= level) { -#ifndef DEBUG_WIN32_CE_MESSAGEBOX +#if defined(DEBUG_WIN32_CE_MESSAGEBOX) || defined(HAVE_API_ANDROID) + char xbuffer[4096]; + wchar_t muni[4096]; + int len=0; + if (prefix) { + strcpy(xbuffer,buffer); + len=strlen(buffer); + xbuffer[len++]=':'; + } + vsprintf(xbuffer+len,fmt,ap); +#endif +#ifdef DEBUG_WIN32_CE_MESSAGEBOX + mbstowcs(muni, xbuffer, strlen(xbuffer)+1); + MessageBoxW(NULL, muni, TEXT("Navit - Error"), MB_APPLMODAL|MB_OK|MB_ICONERROR); +#else +#ifdef HAVE_API_ANDROID + __android_log_print(ANDROID_LOG_ERROR,"navit", "%s", xbuffer); +#else if (! fp) fp = stderr; if (timestamp_prefix) @@ -156,18 +178,7 @@ debug_vprintf(int level, const char *module, const int mlen, const char *functio fprintf(fp,"%s:",buffer); vfprintf(fp,fmt, ap); fflush(fp); -#else - wchar_t muni[4096]; - char xbuffer[4096]; - int len=0; - if (prefix) { - strcpy(xbuffer,buffer); - len=strlen(buffer); - xbuffer[len++]=':'; - } - vsprintf(xbuffer+len,fmt,ap); - mbstowcs(muni, xbuffer, strlen(xbuffer)+1); - MessageBoxW(NULL, muni, TEXT("Navit - Error"), MB_APPLMODAL|MB_OK|MB_ICONERROR); +#endif #endif } } diff --git a/navit/navit/start.c b/navit/navit/start_real.c similarity index 95% rename from navit/navit/start.c rename to navit/navit/start_real.c index f31631b..e152294 100644 --- a/navit/navit/start.c +++ b/navit/navit/start_real.c @@ -68,7 +68,7 @@ get_home_directory(void) return homedir; } -int main(int argc, char **argv) +int main_real(int argc, char **argv) { xmlerror *error = NULL; char *config_file = NULL; @@ -147,16 +147,19 @@ int main(int argc, char **argv) list = g_list_append(list,g_strdup("navit.xml")); list = g_list_append(list,g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/navit.xml.local" , NULL)); list = g_list_append(list,g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/navit.xml" , NULL)); - #ifndef _WIN32 +#ifndef _WIN32 list = g_list_append(list,g_strdup("/etc/navit/navit.xml")); - #endif +#endif +#ifdef HAVE_API_ANDROID + list = g_list_append(list,g_strdup("/sdcard/navit.xml")); +#endif } li = list; for (;;) { if (li == NULL) { // We have not found an existing config file from all possibilities - printf(_("No config file navit.xml, navit.xml.local found\n")); - exit(1); + dbg(0,_("No config file navit.xml, navit.xml.local found\n")); + return 1; } // Try the next config file possibility from the list config_file = li->data; -- 2.7.4