Merge branch 'upstream-svn' into upstream
authorHenning Heinold <heinold@inf.fu-berlin.de>
Sun, 17 Jan 2010 02:10:39 +0000 (03:10 +0100)
committerHenning Heinold <heinold@inf.fu-berlin.de>
Sun, 17 Jan 2010 02:10:39 +0000 (03:10 +0100)
Conflicts:
navit/graphics/win32/Makefile.am
navit/support/libc/Makefile.am

19 files changed:
Makefile.am
configure.in
navit/Makefile.am
navit/binding/dbus/binding_dbus.c
navit/font/freetype/font_freetype.c
navit/graphics.c
navit/main.c
navit/map/garmin/garmin.c
navit/maptool/osm.c
navit/plugin.c
navit/plugin_def.h
navit/speech.c
navit/speech/Makefile.am
navit/speech/dbus/Makefile.am [new file with mode: 0644]
navit/speech/dbus/speech_dbus.c [new file with mode: 0644]
navit/speech/espeak/Makefile.am
navit/vehicle/Makefile.am
navit/vehicle/maemo/Makefile.am [new file with mode: 0644]
navit/vehicle/maemo/vehicle_maemo.c [new file with mode: 0644]

index 1880728..29d6172 100644 (file)
@@ -2,6 +2,14 @@ ACLOCAL_AMFLAGS= -I m4
 include $(top_srcdir)/Makefile.inc
 SUBDIRS=
 if ENABLE_NLS
+XCFLAGS=-DINSTALLPREFIX=INSTALLDIR
+if SUPPORT_WIN32
+XCFLAGS+=-DSUBLANG_BENGALI_BANGLADESH=0x03 -DSUBLANG_PUNJABI_PAKISTAN=0x03 -DSUBLANG_ROMANIAN_MOLDOVA=0x03
+endif
+if SUPPORT_ANDROID
+XCFLAGS+=-Xcompiler -nostartfiles
+endif
+export XCFLAGS
 SUBDIRS+=intl po
 endif
 SUBDIRS+=navit
index c3f3a0f..4d83836 100644 (file)
@@ -51,6 +51,7 @@ graphics_sdl=yes; graphics_sdl_reason=default
 graphics_win32=no; graphics_win32_reason=default
 speech_android=no; speech_android_reason=default
 speech_cmdline=yes; speech_cmdline_reason=default
+speech_dbus=no; speech_dbus_reason=default
 speech_espeak=no; speech_espeak_reason=default
 speech_speech_dispatcher=yes; speech_speech_dispatcher_reason=default
 vehicle_demo=yes; vehicle_demo_reason=default
@@ -63,6 +64,10 @@ vehicle_wince=no; vehicle_wince_reason=default
 vehicle_iphone=no; vehicle_iphone_reason=default
 vehicle_android=no; vehicle_android_reason=default
 graphics_android=no; graphics_android_reason=default
+vehicle_maemo=no; vehicle_maemo_reason=default
+
+shared_libnavit=no
+bin_navit=yes
 
 AC_CANONICAL_HOST
 win32=no
@@ -87,10 +92,11 @@ mingw32)
        graphics_win32=yes; graphics_win32_reason="host_os is mingw32"
        speech_espeak=yes; speech_espeak_reason="host_os is mingw32"
        support_libpng=yes
-       LIBS="$LIBS -lwinmm"
        ;;
 linux*_android)
        android=yes
+       shared_libnavit=yes
+       bin_navit=no
        AC_DEFINE(HAVE_API_ANDROID, 1, [Have Android API])
        echo "void dl_unwind_find_exidx(void) {}" >crt0.c
        $CC -c crt0.c
@@ -98,7 +104,8 @@ linux*_android)
        vehicle_android=yes; vehicle_android_reason="host_os is android"
        graphics_android=yes; graphics_android_reason="host_os is android"
        speech_android=yes; speech_android_reason="host_os is android"
-       MODULE_LDFLAGS="-Xcompiler -nostdlib"
+       MODULE_LDFLAGS="-module -Xcompiler -nostdlib"
+       MODULE_LIBADD="-llog"
        NAVIT_MODULE_LDFLAGS="$MODULE_LDFLAGS -L\$(top_builddir)/navit -lnavit"
        ;;
 esac
@@ -121,6 +128,7 @@ fi
 AM_CONDITIONAL(SUPPORT_LIBPNG, [test "x$support_libpng" = "xyes"])
 
 AC_SUBST(MODULE_LDFLAGS)
+AC_SUBST(MODULE_LIBADD)
 AC_SUBST(NAVIT_MODULE_LDFLAGS)
 
 LIBS="$LIBS -lm"
@@ -260,11 +268,17 @@ if test "x${plugins}" = "xyes"; then
                [],
                Define to 1 if you have plugins.
        )
+       if test "x${win32}" = "xyes"; then
+               shared_libnavit=yes
+               NAVIT_MODULE_LDFLAGS="-no-undefined -L\$(top_builddir)/navit -lnavit -L\$(top_builddir)/intl -lintl"
+       fi
 else
        AC_DISABLE_SHARED
        AC_ENABLE_STATIC
 fi
 AM_CONDITIONAL(PLUGINS, [test "x$plugins" = "xyes"])
+AM_CONDITIONAL(SHARED_LIBNAVIT, [test "x$shared_libnavit" = "xyes"])
+AM_CONDITIONAL(BIN_NAVIT, [test "x$bin_navit" = "xyes"])
 AC_PROG_LIBTOOL
 
 AM_CONDITIONAL(EVENT_GLIB, [test "x$glib" = "xyes"])
@@ -526,11 +540,14 @@ if test "x${binding_dbus}" = "xyes" ; then
        AC_DEFINE(USE_BINDING_DBUS, 1, [Build with binding dbus])
        vehicle_gpsd_dbus="yes"
        vehicle_gpsd_dbus_reason="dbus binding present"
+       speech_dbus="yes"
+       speech_dbus_reason="dbus binding present"
 fi
 AC_SUBST(DBUS_CFLAGS)
 AC_SUBST(DBUS_LIBS)
 AM_CONDITIONAL(BINDING_DBUS, test "x${binding_dbus}" = "xyes")
 AM_CONDITIONAL(VEHICLE_GPSD_DBUS, test "x${vehicle_gpsd_dbus}" = "xyes")
+AM_CONDITIONAL(SPEECH_DBUS, test "x${speech_dbus}" = "xyes")
 AC_ARG_WITH(dbus-service-dir, [ --with-dbus-service-dir   specify where the dbus service dir resides], DBUS_SERVICE_DIR=$withval, DBUS_SERVICE_DIR="$datarootdir/dbus-1/services")
 AC_SUBST(DBUS_SERVICE_DIR)
 
@@ -633,7 +650,7 @@ AC_SUBST(MOFILES)
 AC_SUBST(POFILES)
 AC_SUBST(POIFILES)
 AM_GNU_GETTEXT_VERSION
-AM_GNU_GETTEXT(no-libtool, need-ngettext, \$(top_builddir)/intl/)
+AM_GNU_GETTEXT(use-libtool, need-ngettext, \$(top_builddir)/intl/)
 AC_SUBST(LIBINTL)
 AC_SUBST(LTLIBINTL)
 if test x"$LIBINTL" != "x" ;then
@@ -782,6 +799,19 @@ fi
 AC_SUBST(GYPSY_CFLAGS)
 AC_SUBST(GYPSY_LIBS)
 AM_CONDITIONAL(VEHICLE_GYPSY, test "x${vehicle_gypsy}" = "xyes")
+# maemo
+AC_ARG_ENABLE(vehicle-maemo, [  --disable-vehicle-maemo             disable vehicle type maemo], vehicle_maemo=$enableval;vehicle_maemo_reason="configure parameter")
+if test "x${vehicle_maemo}" = "xyes" ; then
+       PKG_CHECK_MODULES(LIBLOCATION, liblocation, [
+               AC_SUBST(LIBLOCATION_CFLAGS)
+               AC_SUBST(LIBLOCATION_LIBS)
+               ], [
+               AC_MSG_RESULT(no)
+               vehicle_maemo=no
+               vehicle_maemo_reason="no maemo location library found"
+       ])
+fi
+AM_CONDITIONAL(VEHICLE_MAEMO, test "x${vehicle_maemo}" = "xyes")
 # null
 AC_ARG_ENABLE(vehicle-null, [  --enable-vehicle-null             enable vehicle type null], vehicle_null=$enableval;vehicle_null_reason="configure parameter")
 AM_CONDITIONAL(VEHICLE_NULL, test "x${vehicle_null}" = "xyes")
@@ -844,6 +874,7 @@ navit/osd/core/Makefile
 navit/speech/Makefile
 navit/speech/android/Makefile
 navit/speech/cmdline/Makefile
+navit/speech/dbus/Makefile
 navit/speech/espeak/Makefile
 navit/speech/speech_dispatcher/Makefile
 navit/support/Makefile
@@ -861,6 +892,7 @@ navit/vehicle/file/Makefile
 navit/vehicle/gpsd/Makefile
 navit/vehicle/gpsd_dbus/Makefile
 navit/vehicle/gypsy/Makefile
+navit/vehicle/maemo/Makefile
 navit/vehicle/null/Makefile
 navit/vehicle/demo/Makefile
 navit/vehicle/wince/Makefile
@@ -951,6 +983,7 @@ echo "  python:            $binding_python ($binding_python_reason)"
 echo "Speech types:"
 echo "  android:           $speech_android ($speech_android_reason)"
 echo "  cmdline:           $speech_cmdline ($speech_cmdline_reason)"
+echo "  dbus:              $speech_dbus ($speech_dbus_reason)"
 echo "  espeak:            $speech_espeak ($speech_espeak_reason)"
 echo "  speech_dispatcher: $speech_speech_dispatcher ($speech_speech_dispatcher_reason)"
 
@@ -961,6 +994,7 @@ echo "  file:              $vehicle_file ($vehicle_file_reason)"
 echo "  gpsd:              $vehicle_gpsd ($vehicle_gpsd_reason)"
 echo "  gpsd_dbus:         $vehicle_gpsd_dbus ($vehicle_gpsd_dbus_reason)"
 echo "  gypsy:             $vehicle_gypsy ($vehicle_gypsy_reason)"
+echo "  maemo:             $vehicle_maemo ($vehicle_maemo_reason)"
 echo "  null:              $vehicle_null ($vehicle_null_reason)"
 echo "  wince:             $vehicle_wince ($vehicle_wince_reason)"
 echo "  iphone:            $vehicle_iphone ($vehicle_iphone_reason)"
index 6907600..0846d7b 100644 (file)
@@ -24,13 +24,15 @@ endif
 AM_CPPFLAGS = -I$(top_srcdir)/navit/fib-1.1 @NAVIT_CFLAGS@ @ZLIB_CFLAGS@ -DPREFIX=\"@prefix@\" -DLIBDIR=\"@libdir@\" -DMODULE=navit
 BUILT_SOURCES = version.h navit_config.h
 
-if SUPPORT_ANDROID
-  lib_LTLIBRARIES        = libnavit.la
-  libnavit_la_LDFLAGS = -module -avoid-version @MODULE_LDFLAGS@ -Wl,--no-undefined
-  libnavit_la_LIBADD = @NAVIT_LIBS@ @WORDEXP_LIBS@ @ZLIB_LIBS@ @INTLLIBS@ -Lfib-1.1 -lfib -llog
+if BIN_NAVIT
+  bin_PROGRAMS = navit
+endif
 
+if SHARED_LIBNAVIT
+  lib_LTLIBRARIES        = libnavit.la
+  libnavit_la_LDFLAGS = -avoid-version @MODULE_LDFLAGS@ -no-undefined -Wl,--no-undefined
+  libnavit_la_LIBADD = @NAVIT_LIBS@ @WORDEXP_LIBS@ @ZLIB_LIBS@ @INTLLIBS@ -Lfib-1.1 -lfib @MODULE_LIBADD@
 else
-  bin_PROGRAMS = navit
   noinst_LTLIBRARIES        = libnavit.la
 endif
 
@@ -105,9 +107,9 @@ endif
 if SUPPORT_WIN32
   navit_LDADD += resource.rsc
 if SUPPORT_WIN32CE
-  navit_LDADD += -lcommctrl
+  navit_LDADD += -lcommctrl -Lsupport/libc
 else
-  navit_LDADD += -lgdi32 -lcomctl32
+  navit_LDADD += -lgdi32 -lcomctl32 -lwinmm
 endif
 
 resource.rsc: $(top_srcdir)/navit/gui/win32/resources/resource.rc
index d9f1d7b..f5f06a0 100644 (file)
@@ -1596,8 +1596,11 @@ dbus_cmd_send_signal(struct navit *navit, char *command, struct attr **in, struc
        dbg(0,"enter %s %s %s\n",opath,command,interface);
        msg = dbus_message_new_signal(opath, interface, "signal");
        if (msg) {
-               if (in && in[0]) {
-                       encode_attr(msg, in[0]);
+               if (in) {
+                       while (*in) {
+                               encode_attr(msg, *in);
+                               in++;
+                       }
                }
                dbus_connection_send(connection, msg, &dbus_serial);
                dbus_connection_flush(connection);
index 7fb77e9..4b277a7 100644 (file)
@@ -357,7 +357,7 @@ font_freetype_font_new(struct graphics_priv *gr,
        }
        font->size=size;
 #ifdef HAVE_FONTCONFIG
-       dbg(2, " about to search for fonts, prefered = %s\n", fontfamily);
+       dbg(2, " about to search for fonts, preferred = %s\n", fontfamily);
        family = g_malloc(sizeof(fontfamilies) + sizeof(fontfamily));
        if (fontfamily) {
                memcpy(family, &fontfamily, sizeof(fontfamily));
index 8804cfb..bacd9f8 100644 (file)
@@ -1774,7 +1774,7 @@ graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transfor
                        }
                        break;
                default:
-                       dbg(0,"dont know how to draw %d\n", e->type);
+                       dbg(0,"don't know how to draw %d\n", e->type);
                }
                graphics_gc_destroy(gc);
                es=g_list_next(es);
index f056ead..0bc92a0 100644 (file)
@@ -132,6 +132,7 @@ char *nls_table[][3]={
        {"DEU","DEU","de_DE"},
        {"DEA","AUT","de_AT"},
        {"ENU","USA","en_US"},
+       {"FRA","FRA","fr_FR"},
        {"RUS","RUS","ru_RU"},
        {NULL,NULL,NULL},
 };
index da0f580..de75be6 100644 (file)
@@ -418,7 +418,7 @@ point_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
                        attr->u.num |= AF_SEGMENTED;
                return 1;
        default:
-               dlog(1, "Dont know about attribute %d[%04X]=%s yet\n", attr_type,attr_type, attr_to_name(attr_type));
+               dlog(1, "Don't know about attribute %d[%04X]=%s yet\n", attr_type,attr_type, attr_to_name(attr_type));
        }
 
        return 0;
@@ -567,7 +567,7 @@ search_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
        case attr_town_streets_item:
                return 0;
        default:
-               dlog(1, "Dont know about attribute %d[%04X]=%s yet\n",
+               dlog(1, "Don't know about attribute %d[%04X]=%s yet\n",
                                attr_type,attr_type, attr_to_name(attr_type));
        }
 
index 6c164c1..b6d8714 100644 (file)
@@ -92,28 +92,33 @@ struct country_table {
        { 36,"Australia,AUS"},
        { 40,"Austria,Österreich,AUT"},
        { 56,"Belgium"},
+       { 70,"Bosnia and Herzegovina,Bosna i Hercegovina,Босна и Херцеговина"},
+       {100,"Bulgaria,България"},
        {124,"Canada"},
        {152,"Chile"},
        {191,"Croatia,Republika Hrvatska,HR"},
        {203,"Czech Republic,Česká republika,CZ"},
        {208,"Denmark,Danmark,DK"},
-       {234,"Faroe Islands"},
+       {234,"Faroe Islands,Føroyar"},
        {246,"Finland,Suomi"},
        {250,"France,République française,FR"},
        {276,"Germany,Deutschland,Bundesrepublik Deutschland"},
        {348,"Hungary"},
        {380,"Italy,Italia"},
        {442,"Luxembourg"},
+       {499,"Montenegro,Црна Гора,Crna Gora"},
        {528,"Nederland,The Netherlands,Niederlande,NL"},
        {578,"Norway,Norge,Noreg,NO"},
        {616,"Poland,Polska,PL"},
        {642,"România,Romania,RO"},
        {643,"Россия,Российская Федерация,Russia,Russian Federation"},
+       {688,"Srbija,Србија,Serbia"},
        {703,"Slovakia,Slovensko,SK"},
        {705,"Slovenia,Republika Slovenija,SI"},
        {724,"Spain,Espana,España,Reino de Espana"},
        {752,"Sweden,Sverige,Konungariket Sverige,SE"},
        {756,"Schweiz"}, 
+       {807,"Macedonia,Македонија"},
        {826,"United Kingdom,UK"},
        {840,"USA"},
        {999,"Unknown"},
index 991eb50..3080ba2 100644 (file)
 #ifdef HAVE_GMODULE
 #include <gmodule.h>
 #else
+#ifdef HAVE_API_WIN32_BASE
+#include <windows.h>
+#else
 #include <dlfcn.h>
 #endif
 #endif
+#endif
 #include "plugin.h"
 #include "file.h"
 #define PLUGIN_C
@@ -45,6 +49,49 @@ g_module_supported(void)
        return 1;
 }
 
+#ifdef HAVE_API_WIN32_BASE
+
+static DWORD last_error;
+static char errormsg[64];
+
+static void *
+g_module_open(char *name, int flags)
+{
+       HINSTANCE handle;
+       int len=MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, 0, 0);
+       wchar_t filename[len];
+       MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, filename, len) ;
+
+       handle = LoadLibraryW (filename);
+       if (!handle)
+               last_error=GetLastError();
+       return handle;
+}
+
+static char *
+g_module_error(void)
+{
+       sprintf(errormsg,"dll error %d",(int)last_error);
+       return errormsg;
+}
+
+static int
+g_module_symbol(GModule *handle, char *symbol, gpointer *addr)
+{
+       *addr=GetProcAddress ((HANDLE)handle, symbol);
+       if (*addr)
+               return 1;
+       last_error=GetLastError();
+       return 0;
+}
+
+static void
+g_module_close(GModule *handle)
+{
+       FreeLibrary((HANDLE)handle);
+}
+
+#else
 static void *
 g_module_open(char *name, int flags)
 {
@@ -71,7 +118,7 @@ g_module_close(GModule *handle)
 {
        dlclose(handle);
 }
-
+#endif
 #endif
 #endif
 
index 4eec845..682ca59 100644 (file)
@@ -27,7 +27,7 @@ PLUGIN_TYPE(graphics, (struct navit *nav, struct graphics_methods *meth, struct
 PLUGIN_TYPE(gui, (struct navit *nav, struct gui_methods *meth, struct attr **attrs, struct gui *gui)) 
 PLUGIN_TYPE(map, (struct map_methods *meth, struct attr **attrs)) 
 PLUGIN_TYPE(osd, (struct navit *nav, struct osd_methods *meth, struct attr **attrs))
-PLUGIN_TYPE(speech, (struct speech_methods *meth, struct attr **attrs)) 
+PLUGIN_TYPE(speech, (struct speech_methods *meth, struct attr **attrs, struct attr *parent)) 
 PLUGIN_TYPE(vehicle, (struct vehicle_methods *meth, struct callback_list *cbl, struct attr **attrs)) 
 PLUGIN_TYPE(event, (struct event_methods *meth)) 
 PLUGIN_TYPE(font, (void *meth)) 
index b3df169..c3e77f0 100644 (file)
@@ -35,7 +35,7 @@ struct speech *
 speech_new(struct attr *parent, struct attr **attrs) 
 {
        struct speech *this_;
-       struct speech_priv *(*speech_new)(struct speech_methods *meth, struct attr **attrs);
+       struct speech_priv *(*speech_new)(struct speech_methods *meth, struct attr **attrs, struct attr *parent);
        struct attr *attr;
 
     attr=attr_search(attrs, NULL, attr_type);
@@ -51,7 +51,7 @@ speech_new(struct attr *parent, struct attr **attrs)
                 return NULL;
        }
        this_=g_new0(struct speech, 1);
-       this_->priv=speech_new(&this_->meth, attrs);
+       this_->priv=speech_new(&this_->meth, attrs, parent);
     this_->attrs=attr_list_dup(attrs);
        dbg(1, "say=%p\n", this_->meth.say);
        dbg(1,"priv=%p\n", this_->priv);
index ddab19c..3c232db 100644 (file)
@@ -5,6 +5,9 @@ endif
 if SPEECH_CMDLINE
   SUBDIRS += cmdline
 endif
+if SPEECH_DBUS
+  SUBDIRS += dbus
+endif
 if SPEECH_ESPEAK
   SUBDIRS += espeak
 endif
diff --git a/navit/speech/dbus/Makefile.am b/navit/speech/dbus/Makefile.am
new file mode 100644 (file)
index 0000000..abe285b
--- /dev/null
@@ -0,0 +1,5 @@
+include $(top_srcdir)/Makefile.inc
+AM_CPPFLAGS = @NAVIT_CFLAGS@ -I$(top_srcdir)/navit -DMODULE=speech_dbus
+modulespeech_LTLIBRARIES = libspeech_dbus.la
+libspeech_dbus_la_SOURCES = speech_dbus.c
+libspeech_dbus_la_LDFLAGS = -module -avoid-version @NAVIT_MODULE_LDFLAGS@
diff --git a/navit/speech/dbus/speech_dbus.c b/navit/speech/dbus/speech_dbus.c
new file mode 100644 (file)
index 0000000..53ab46f
--- /dev/null
@@ -0,0 +1,77 @@
+/**
+ * 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 <stdlib.h>
+#include <glib.h>
+#include "config.h"
+#include "item.h"
+#include "plugin.h"
+#include "navit.h"
+#include "attr.h"
+#include "callback.h"
+#include "speech.h"
+
+struct speech_priv {
+       struct navit *nav;
+};
+
+static int 
+speech_dbus_say(struct speech_priv *this, const char *text)
+{
+       struct attr attr1,attr2,cb,*attr_list[3];
+       int valid=0;
+       attr1.type=attr_type;
+       attr1.u.str="speech";
+       attr2.type=attr_data;
+       attr2.u.str=(char *)text;
+       attr_list[0]=&attr1;
+       attr_list[1]=&attr2;
+       attr_list[2]=NULL;
+       if (navit_get_attr(this->nav, attr_callback_list, &cb, NULL))
+               callback_list_call_attr_4(cb.u.callback_list, attr_command, "dbus_send_signal", attr_list, NULL, &valid);
+       return 0;
+}
+
+static void 
+speech_dbus_destroy(struct speech_priv *this) {
+       g_free(this);
+}
+
+static struct speech_methods speech_dbus_meth = {
+       speech_dbus_destroy,
+       speech_dbus_say,
+};
+
+static struct speech_priv *
+speech_dbus_new(struct speech_methods *meth, struct attr **attrs, struct attr *parent) {
+       struct speech_priv *this;
+       if (!parent || parent->type != attr_navit)
+               return NULL;
+       this=g_new(struct speech_priv,1);
+       this->nav=parent->u.navit;
+       *meth=speech_dbus_meth;
+       return this;
+}
+
+
+void
+plugin_init(void)
+{
+       plugin_register_speech_type("dbus", speech_dbus_new);
+}
index fa635ae..1bdeb38 100644 (file)
@@ -2,5 +2,4 @@ include $(top_srcdir)/Makefile.inc
 AM_CPPFLAGS = @NAVIT_CFLAGS@ -I$(top_srcdir)/navit -DMODULE=speech_espeak
 modulespeech_LTLIBRARIES = libspeech_espeak.la
 libspeech_espeak_la_SOURCES = speak.c 
-libspeech_espeak_la_LDFLAGS = -module -avoid-version @NAVIT_MODULE_LDFLAGS@
-
+libspeech_espeak_la_LDFLAGS = -module -avoid-version @NAVIT_MODULE_LDFLAGS@ -L$(top_builddir)/navit/support/espeak -lsupport_espeak -Wl,-lwinmm
index c3765fb..f4c9293 100644 (file)
@@ -1,4 +1,7 @@
 SUBDIRS=
+if VEHICLE_MAEMO
+  SUBDIRS += maemo
+endif
 if VEHICLE_ANDROID
   SUBDIRS += android
 endif
diff --git a/navit/vehicle/maemo/Makefile.am b/navit/vehicle/maemo/Makefile.am
new file mode 100644 (file)
index 0000000..d82bdb6
--- /dev/null
@@ -0,0 +1,6 @@
+include $(top_srcdir)/Makefile.inc
+AM_CPPFLAGS = @NAVIT_CFLAGS@ @LIBLOCATION_CFLAGS@ -I$(top_srcdir)/navit -DMODULE=vehicle_maemo
+modulevehicle_LTLIBRARIES = libvehicle_maemo.la
+libvehicle_maemo_la_SOURCES = vehicle_maemo.c
+libvehicle_maemo_la_LIBADD = @LIBLOCATION_LIBS@
+libvehicle_maemo_la_LDFLAGS = -module -avoid-version
diff --git a/navit/vehicle/maemo/vehicle_maemo.c b/navit/vehicle/maemo/vehicle_maemo.c
new file mode 100644 (file)
index 0000000..5db10cd
--- /dev/null
@@ -0,0 +1,324 @@
+/**
+ * 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.
+ */
+
+
+/* 
+       Plugin for new Maemo's  liblocation API.
+       <vehicle source="maemo://any" retry_interval="1"/>
+   source cound be on of "any","cwp","acwp","gnss","agnss"
+   retry_interval could be one of "1","2","5","10","20","30","60","120" measured in seconds
+*/
+
+#include <config.h>
+#include <string.h>
+#include <glib.h>
+#include <math.h>
+#include <location/location-gps-device.h>
+#include <location/location-gpsd-control.h>
+#include "debug.h"
+#include "callback.h"
+#include "plugin.h"
+#include "coord.h"
+#include "item.h"
+#include "vehicle.h"
+#include "event.h"
+
+static struct vehicle_priv {
+       LocationGPSDControl *control;
+       LocationGPSDevice *device;
+       char *source;
+       guint retry_interval;
+       struct callback_list *cbl;
+       struct attr ** attrs;
+       int sats; // satellites_in_view
+       int sats_used; //satellites_in_user
+       int fix_type; //mode
+       struct coord_geo geo; //lattigute&longittude
+       double speed; //speed:)
+       double direction; //track
+       double height; //altitude
+       double hdop; //eph
+       time_t fix_time; //time
+       char fixiso8601[128];
+};
+
+static void vehicle_maemo_callback(LocationGPSDevice *device, gpointer user_data) {
+       struct vehicle_priv *priv=(struct vehicle_priv*)user_data;
+
+       priv->sats=device->satellites_in_view;
+       priv->sats_used=device->satellites_in_use;
+       callback_list_call_attr_0(priv->cbl, attr_position_sats);
+
+       dbg(1,"Got update with %u/%u satellites\n",priv->sats_used,priv->sats);
+
+       if (device->fix) {
+               switch(device->fix->mode) {
+               case LOCATION_GPS_DEVICE_MODE_NOT_SEEN:
+               case LOCATION_GPS_DEVICE_MODE_NO_FIX:
+                   priv->fix_type=0;
+                   break;
+               case LOCATION_GPS_DEVICE_MODE_2D:
+               case LOCATION_GPS_DEVICE_MODE_3D:
+                   priv->fix_type=1;
+                   break;
+               }
+
+               if (device->fix->fields & LOCATION_GPS_DEVICE_LATLONG_SET) {
+                       priv->geo.lat=device->fix->latitude;
+                       priv->geo.lng=device->fix->longitude;
+                       priv->hdop=device->fix->eph/100;
+                       callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
+                       dbg(1,"Position: %f %f with error %f meters\n",priv->geo.lat,priv->geo.lng,priv->hdop);
+               }
+
+               if (device->fix->fields & LOCATION_GPS_DEVICE_SPEED_SET) {
+                       priv->speed=device->fix->speed;
+                       callback_list_call_attr_0(priv->cbl, attr_position_speed);
+                       dbg(1,"Speed: %f\n ",priv->speed);
+               }
+
+               if (device->fix->fields & LOCATION_GPS_DEVICE_TRACK_SET) {
+                       priv->direction=device->fix->track;
+                       dbg(1,"Direction: %f\n",priv->direction);
+               }
+
+               if (device->fix->fields & LOCATION_GPS_DEVICE_TIME_SET) {
+                       priv->fix_time=device->fix->time;
+                       dbg(1,"Time: %f\n",priv->fix_time);
+               }
+
+       }
+
+       return;
+}
+static void vehicle_maemo_error(LocationGPSDControl *control, LocationGPSDControlError error, gpointer user_data)
+{ 
+  switch (error) {
+  case LOCATION_ERROR_USER_REJECTED_DIALOG:
+    dbg(0,"User didn't enable requested methods\n");
+    break;
+  case LOCATION_ERROR_USER_REJECTED_SETTINGS:
+    dbg(0,"User changed settings, which disabled location\n");
+    break;
+  case LOCATION_ERROR_BT_GPS_NOT_AVAILABLE:
+    dbg(0,"Problems with BT GPS\n");
+    break;
+  case LOCATION_ERROR_METHOD_NOT_ALLOWED_IN_OFFLINE_MODE:
+    dbg(0,"Requested method is not allowed in offline mode\n");
+    break;
+  case LOCATION_ERROR_SYSTEM:
+    dbg(0,"System error\n");
+    break;
+  }
+}
+
+/**
+ * Instantiate liblocation objects
+ */
+static void
+vehicle_maemo_open(struct vehicle_priv *priv)
+{
+
+       priv->control = location_gpsd_control_get_default();
+       priv->device = g_object_new(LOCATION_TYPE_GPS_DEVICE, NULL);
+
+       if (!strcasecmp(priv->source+8,"cwp")) {
+               g_object_set(G_OBJECT(priv->control),   "preferred-method", LOCATION_METHOD_CWP, NULL);
+               dbg(1,"Method set: CWP\n");
+       } else if (!strcasecmp(priv->source+8,"acwp")) {
+               g_object_set(G_OBJECT(priv->control),   "preferred-method", LOCATION_METHOD_ACWP, NULL);
+               dbg(1,"Method set: ACWP\n");
+       } else if (!strcasecmp(priv->source+8,"gnss")) {
+               g_object_set(G_OBJECT(priv->control),   "preferred-method", LOCATION_METHOD_GNSS, NULL);
+               dbg(1,"Method set: GNSS\n");
+       } else if (!strcasecmp(priv->source+8,"agnss")) {
+               g_object_set(G_OBJECT(priv->control),   "preferred-method", LOCATION_METHOD_AGNSS, NULL); 
+               dbg(1,"Method set: AGNSS\n");
+       } else {
+               g_object_set(G_OBJECT(priv->control),   "preferred-method", LOCATION_METHOD_USER_SELECTED, NULL); 
+               dbg(1,"Method set: ANY\n");
+       }
+
+       switch (priv->retry_interval) {
+       case 2:
+               g_object_set(G_OBJECT(priv->control),   "preferred-interval", LOCATION_INTERVAL_2S,     NULL);
+               dbg(1,"Interval set: 2s\n");
+               break;
+       case 5:
+               g_object_set(G_OBJECT(priv->control),   "preferred-interval", LOCATION_INTERVAL_5S,     NULL);
+               dbg(1,"Interval set: 5s\n");
+               break;
+       case 10:
+               g_object_set(G_OBJECT(priv->control),   "preferred-interval", LOCATION_INTERVAL_10S,    NULL);
+               dbg(1,"Interval set: 10s\n");
+               break;
+       case 20:
+               g_object_set(G_OBJECT(priv->control),   "preferred-interval", LOCATION_INTERVAL_20S,    NULL);
+               dbg(1,"Interval set: 20s\n");
+               break;
+       case 30:
+               g_object_set(G_OBJECT(priv->control),   "preferred-interval", LOCATION_INTERVAL_30S,    NULL);
+               dbg(1,"Interval set: 30s\n");
+               break;
+       case 60:
+               g_object_set(G_OBJECT(priv->control),   "preferred-interval", LOCATION_INTERVAL_60S,    NULL);
+               dbg(1,"Interval set: 60s\n");
+               break;
+       case 120:
+               g_object_set(G_OBJECT(priv->control),   "preferred-interval", LOCATION_INTERVAL_120S,   NULL);
+               dbg(1,"Interval set: 120s\n");
+               break;
+       case 1:
+       default:
+               g_object_set(G_OBJECT(priv->control),   "preferred-interval", LOCATION_INTERVAL_1S,     NULL);
+               dbg(1,"Interval set: 1s\n");
+               break;
+       }
+
+       g_signal_connect(priv->device, "changed", G_CALLBACK(vehicle_maemo_callback), priv);
+       g_signal_connect(priv->control, "error-verbose", G_CALLBACK(vehicle_maemo_error), priv);
+
+       location_gpsd_control_start(priv->control);
+
+       return;
+}
+
+static void
+vehicle_maemo_destroy(struct vehicle_priv *priv)
+{
+       location_gpsd_control_stop(priv->control);
+
+       g_object_unref(priv->device);
+       g_object_unref(priv->control);
+
+       return;
+}
+
+static int
+vehicle_maemo_position_attr_get(struct vehicle_priv *priv,
+                              enum attr_type type, struct attr *attr)
+{
+       struct attr * active=NULL;
+       switch (type) {
+       case attr_position_fix_type:
+               dbg(1,"Attr requested: position_fix_type\n");
+               attr->u.num = priv->fix_type;
+               break;
+       case attr_position_height:
+               dbg(1,"Attr requested: position_height\n");
+               attr->u.numd = &priv->height;
+               break;
+       case attr_position_speed:
+               dbg(1,"Attr requested: position_speed\n");
+               attr->u.numd = &priv->speed;
+               break;
+       case attr_position_direction:
+               dbg(1,"Attr requested: position_direction\n");
+               attr->u.numd = &priv->direction;
+               break;
+       case attr_position_hdop:
+               dbg(1,"Attr requested: position_hdop\n");
+               attr->u.numd = &priv->hdop;
+               break;
+       case attr_position_sats:
+               dbg(1,"Attr requested: position_sats_signal\n");
+               attr->u.num = priv->sats;
+               break;
+       case attr_position_sats_used:
+               dbg(1,"Attr requested: position_sats_used\n");
+               attr->u.num = priv->sats_used;
+               break;
+       case attr_position_coord_geo:
+               dbg(1,"Attr requested: position_coord_geo\n");
+               attr->u.coord_geo = &priv->geo;
+               break;
+       case attr_position_time_iso8601:
+               {
+               struct tm tm;
+               dbg(1,"Attr requested: position_time_iso8601\n");
+               if (!priv->fix_time)
+                       return 0;
+               if (gmtime_r(&priv->fix_time, &tm)) {
+                       strftime(priv->fixiso8601, sizeof(priv->fixiso8601),
+                               "%Y-%m-%dT%TZ", &tm);
+                       attr->u.str=priv->fixiso8601;
+               } else
+                       return 0;
+               }
+               break;
+       case attr_active:
+               dbg(1,"Attr requested: position_active\n");
+               active = attr_search(priv->attrs,NULL,attr_active);
+               if(active != NULL) {
+                       attr->u.num=active->u.num;
+                       return 1;
+               } else
+                       return 0;
+                       break;
+       default:
+                       return 0;
+       }
+       attr->type = type;
+       return 1;
+}
+
+struct vehicle_methods vehicle_maemo_methods = {
+       vehicle_maemo_destroy,
+       vehicle_maemo_position_attr_get,
+};
+
+static struct vehicle_priv *
+vehicle_maemo_new_maemo(struct vehicle_methods
+                     *meth, struct callback_list
+                     *cbl, struct attr **attrs)
+{
+       struct vehicle_priv *ret;
+       struct attr *source, *retry_int;
+
+       dbg(1, "enter\n");
+       source = attr_search(attrs, NULL, attr_source);
+       ret = g_new0(struct vehicle_priv, 1);
+       ret->source = g_strdup(source->u.str);
+       retry_int = attr_search(attrs, NULL, attr_retry_interval);
+       if (retry_int) {
+               ret->retry_interval = retry_int->u.num;
+               if (ret->retry_interval !=1 && ret->retry_interval !=2 && ret->retry_interval !=5 && ret->retry_interval !=10 && ret->retry_interval !=20 && ret->retry_interval !=30 && ret->retry_interval !=60 && ret->retry_interval !=120 ) {
+                       dbg(0, "Retry interval %d invalid, setting to 1\n", ret->retry_interval,1);
+                       ret->retry_interval = 1;
+               }
+       } else {
+               ret->retry_interval = 1;
+       }
+       dbg(1,"source: %s, interval: %u\n",ret->source,ret->retry_interval);
+       ret->cbl = cbl;
+       *meth = vehicle_maemo_methods;
+       ret->attrs = attrs;
+       vehicle_maemo_open(ret);
+       return ret;
+}
+
+void
+plugin_init(void)
+{
+       dbg(1, "enter\n");
+       plugin_register_vehicle_type("maemo", vehicle_maemo_new_maemo);
+}