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
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
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
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
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
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"
[],
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"])
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)
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
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")
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
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
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)"
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)"
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
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
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);
}
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));
}
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);
{"DEU","DEU","de_DE"},
{"DEA","AUT","de_AT"},
{"ENU","USA","en_US"},
+ {"FRA","FRA","fr_FR"},
{"RUS","RUS","ru_RU"},
{NULL,NULL,NULL},
};
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;
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));
}
{ 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"},
#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
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)
{
{
dlclose(handle);
}
-
+#endif
#endif
#endif
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))
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);
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);
if SPEECH_CMDLINE
SUBDIRS += cmdline
endif
+if SPEECH_DBUS
+ SUBDIRS += dbus
+endif
if SPEECH_ESPEAK
SUBDIRS += espeak
endif
--- /dev/null
+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@
--- /dev/null
+/**
+ * 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);
+}
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
SUBDIRS=
+if VEHICLE_MAEMO
+ SUBDIRS += maemo
+endif
if VEHICLE_ANDROID
SUBDIRS += android
endif
--- /dev/null
+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
--- /dev/null
+/**
+ * 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);
+}