Add:Core:Again android...
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sat, 15 Aug 2009 15:36:16 +0000 (15:36 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sat, 15 Aug 2009 15:36:16 +0000 (15:36 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit@2466 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/Makefile.am
navit/android.c
navit/debug.c
navit/start.c [deleted file]
navit/start_real.c [new file with mode: 0644]

index c0c9b7d..bcb410c 100644 (file)
@@ -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
index 5ff1b25..e6b7ee7 100644 (file)
@@ -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
index 9b3edaa..3b3eb8a 100644 (file)
 #include <time.h>
 #include <sys/time.h>
 #include <glib.h>
+#include "config.h"
 #include "file.h"
 #include "item.h"
 #include "debug.h"
 
+#ifdef HAVE_API_ANDROID
+#include <android/log.h>
+#endif
+
 #ifdef DEBUG_WIN32_CE_MESSAGEBOX
 #include <windows.h>
 #include <windowsx.h>
@@ -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/start.c b/navit/start.c
deleted file mode 100644 (file)
index f31631b..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-/**
- * Navit, a modular navigation system.
- * Copyright (C) 2005-2008 Navit Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA  02110-1301, USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <glib.h>
-#include <getopt.h>
-#include "config.h"
-#include "version.h"
-#include "item.h"
-#include "coord.h"
-#include "main.h"
-#include "route.h"
-#include "navigation.h"
-#include "track.h"
-#include "debug.h"
-#include "event.h"
-#include "event_glib.h"
-#include "xmlconfig.h"
-#include "file.h"
-#include "search.h"
-#include "navit_nls.h"
-#include "atom.h"
-#ifdef HAVE_API_WIN32_CE
-#include <windows.h>
-#include <winbase.h>
-#endif
-
-char *version=PACKAGE_VERSION" "SVN_VERSION""NAVIT_VARIANT; 
-
-static void
-print_usage(void)
-{
-       printf(_("navit usage:\nnavit [options] [configfile]\n\t-c <file>: use <file> as config file\n\t-d <n>: set the debug output level to <n>. (TODO)\n\t-h: print this usage info and exit.\n\t-v: Print the version and exit.\n"));
-}
-
-
-static gchar *
-get_home_directory(void)
-{
-       static gchar *homedir = NULL;
-
-       if (homedir) return homedir;
-       homedir = getenv("HOME");
-       if (!homedir)
-       {
-               dbg(0,"Could not find home directory. Using current directory as home directory.\n");
-               homedir = ".";
-       } else {
-               homedir=g_strdup(homedir);
-       }
-       return homedir;
-}
-
-int main(int argc, char **argv)
-{
-       xmlerror *error = NULL;
-       char *config_file = NULL;
-       int opt;
-       char *cp;
-
-       GList *list = NULL, *li;
-
-
-#ifdef HAVE_GLIB
-       event_glib_init();
-#endif
-       atom_init();
-       main_init(argv[0]);
-       main_init_nls();
-       debug_init(argv[0]);
-       
-       cp = getenv("NAVIT_LOGFILE");
-       if (cp)
-               debug_set_logfile(cp);
-#ifdef HAVE_API_WIN32_CE
-       else
-               debug_set_logfile("/Storage Card/navit.log");
-#endif
-       file_init();
-#ifndef USE_PLUGINS
-       extern void builtin_init(void);
-       builtin_init();
-#endif
-       route_init();
-       navigation_init();
-       tracking_init();
-       search_init();
-       linguistics_init();
-       config_file=NULL;
-       opterr=0;  //don't bomb out on errors.
-       if (argc > 1) {
-               /* DEVELOPPERS : don't forget to update the manpage if you modify theses options */
-               while((opt = getopt(argc, argv, ":hvc:d:")) != -1) {
-                       switch(opt) {
-                       case 'h':
-                               print_usage();
-                               exit(0);
-                               break;
-                       case 'v':
-                               printf("%s %s\n", "navit", version); 
-                               exit(0);
-                               break;
-                       case 'c':
-                               printf("config file n is set to `%s'\n", optarg);
-                   config_file = optarg;
-                               break;
-                       case 'd':
-                               printf("TODO Verbose option is set to `%s'\n", optarg);
-                               break;
-                       case ':':
-                               fprintf(stderr, "navit: Error - Option `%c' needs a value\n", optopt);
-                               print_usage();
-                               exit(1);
-                               break;
-                       case '?':
-                               fprintf(stderr, "navit: Error - No such option: `%c'\n", optopt);
-                               print_usage();
-                               exit(1);
-                       }
-           }
-       }
-       // use 1st cmd line option that is left for the config file
-       if (optind < argc) config_file = argv[optind];
-
-    // if config file is explicitely given only look for it, otherwise try std paths
-       if (config_file) list = g_list_append(list,g_strdup(config_file));
-    else {
-               list = g_list_append(list,g_strjoin(NULL,get_home_directory(), "/.navit/navit.xml" , NULL));
-               list = g_list_append(list,g_strdup("navit.xml.local"));
-               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
-               list = g_list_append(list,g_strdup("/etc/navit/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);
-               }
-        // Try the next config file possibility from the list
-               config_file = li->data;
-               if (file_exists(config_file))
-                       break;
-               else
-                       g_free(config_file);
-               li = g_list_next(li);
-       }
-
-       if (!config_load(config_file, &error)) {
-               dbg(0, _("Error parsing '%s': %s\n"), config_file, error ? error->message : "");
-       } else {
-               dbg(0, _("Using '%s'\n"), config_file);
-       }
-       while (li) {
-               g_free(li->data);
-               li = g_list_next(li);
-       }
-       g_list_free(list);
-       if (! main_get_navit(NULL)) {
-               dbg(0, _("No instance has been created, exiting\n"));
-               exit(1);
-       }
-       event_main_loop_run();
-
-       return 0;
-}
diff --git a/navit/start_real.c b/navit/start_real.c
new file mode 100644 (file)
index 0000000..e152294
--- /dev/null
@@ -0,0 +1,190 @@
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2008 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <getopt.h>
+#include "config.h"
+#include "version.h"
+#include "item.h"
+#include "coord.h"
+#include "main.h"
+#include "route.h"
+#include "navigation.h"
+#include "track.h"
+#include "debug.h"
+#include "event.h"
+#include "event_glib.h"
+#include "xmlconfig.h"
+#include "file.h"
+#include "search.h"
+#include "navit_nls.h"
+#include "atom.h"
+#ifdef HAVE_API_WIN32_CE
+#include <windows.h>
+#include <winbase.h>
+#endif
+
+char *version=PACKAGE_VERSION" "SVN_VERSION""NAVIT_VARIANT; 
+
+static void
+print_usage(void)
+{
+       printf(_("navit usage:\nnavit [options] [configfile]\n\t-c <file>: use <file> as config file\n\t-d <n>: set the debug output level to <n>. (TODO)\n\t-h: print this usage info and exit.\n\t-v: Print the version and exit.\n"));
+}
+
+
+static gchar *
+get_home_directory(void)
+{
+       static gchar *homedir = NULL;
+
+       if (homedir) return homedir;
+       homedir = getenv("HOME");
+       if (!homedir)
+       {
+               dbg(0,"Could not find home directory. Using current directory as home directory.\n");
+               homedir = ".";
+       } else {
+               homedir=g_strdup(homedir);
+       }
+       return homedir;
+}
+
+int main_real(int argc, char **argv)
+{
+       xmlerror *error = NULL;
+       char *config_file = NULL;
+       int opt;
+       char *cp;
+
+       GList *list = NULL, *li;
+
+
+#ifdef HAVE_GLIB
+       event_glib_init();
+#endif
+       atom_init();
+       main_init(argv[0]);
+       main_init_nls();
+       debug_init(argv[0]);
+       
+       cp = getenv("NAVIT_LOGFILE");
+       if (cp)
+               debug_set_logfile(cp);
+#ifdef HAVE_API_WIN32_CE
+       else
+               debug_set_logfile("/Storage Card/navit.log");
+#endif
+       file_init();
+#ifndef USE_PLUGINS
+       extern void builtin_init(void);
+       builtin_init();
+#endif
+       route_init();
+       navigation_init();
+       tracking_init();
+       search_init();
+       linguistics_init();
+       config_file=NULL;
+       opterr=0;  //don't bomb out on errors.
+       if (argc > 1) {
+               /* DEVELOPPERS : don't forget to update the manpage if you modify theses options */
+               while((opt = getopt(argc, argv, ":hvc:d:")) != -1) {
+                       switch(opt) {
+                       case 'h':
+                               print_usage();
+                               exit(0);
+                               break;
+                       case 'v':
+                               printf("%s %s\n", "navit", version); 
+                               exit(0);
+                               break;
+                       case 'c':
+                               printf("config file n is set to `%s'\n", optarg);
+                   config_file = optarg;
+                               break;
+                       case 'd':
+                               printf("TODO Verbose option is set to `%s'\n", optarg);
+                               break;
+                       case ':':
+                               fprintf(stderr, "navit: Error - Option `%c' needs a value\n", optopt);
+                               print_usage();
+                               exit(1);
+                               break;
+                       case '?':
+                               fprintf(stderr, "navit: Error - No such option: `%c'\n", optopt);
+                               print_usage();
+                               exit(1);
+                       }
+           }
+       }
+       // use 1st cmd line option that is left for the config file
+       if (optind < argc) config_file = argv[optind];
+
+    // if config file is explicitely given only look for it, otherwise try std paths
+       if (config_file) list = g_list_append(list,g_strdup(config_file));
+    else {
+               list = g_list_append(list,g_strjoin(NULL,get_home_directory(), "/.navit/navit.xml" , NULL));
+               list = g_list_append(list,g_strdup("navit.xml.local"));
+               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
+               list = g_list_append(list,g_strdup("/etc/navit/navit.xml"));
+#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
+                       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;
+               if (file_exists(config_file))
+                       break;
+               else
+                       g_free(config_file);
+               li = g_list_next(li);
+       }
+
+       if (!config_load(config_file, &error)) {
+               dbg(0, _("Error parsing '%s': %s\n"), config_file, error ? error->message : "");
+       } else {
+               dbg(0, _("Using '%s'\n"), config_file);
+       }
+       while (li) {
+               g_free(li->data);
+               li = g_list_next(li);
+       }
+       g_list_free(list);
+       if (! main_get_navit(NULL)) {
+               dbg(0, _("No instance has been created, exiting\n"));
+               exit(1);
+       }
+       event_main_loop_run();
+
+       return 0;
+}