More modularization
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sun, 8 Jul 2007 16:42:16 +0000 (16:42 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sun, 8 Jul 2007 16:42:16 +0000 (16:42 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit@279 ffa7fe5e-494d-0410-b361-a75ebd5db220

13 files changed:
Makefile.inc
configure.in
src/Makefile.am
src/binding/Makefile.am
src/binding/python/Makefile.am [new file with mode: 0644]
src/binding/python/binding_python.c [new file with mode: 0644]
src/main.c
src/phrase.c
src/python.c [deleted file]
src/python.h [deleted file]
src/speech.c
src/speech.h
src/speech/speech_dispatcher/speech_speech_dispatcher.c

index cc07c83..9d3a269 100644 (file)
@@ -1,3 +1,4 @@
+modulebindingdir=$(pkglibdir)/binding
 moduledatadir=$(pkglibdir)/data
 modulegraphicsdir=$(pkglibdir)/graphics
 moduleguidir=$(pkglibdir)/gui
index 58b5ccc..4e6e2ba 100644 (file)
@@ -69,14 +69,15 @@ fi
 AC_SUBST(IMLIB2_CFLAGS)
 AC_SUBST(IMLIB2_LIBS)
 
+
+AC_ARG_ENABLE(MODULE_GUI_SDL, [  --disable-speech-speechd             don't create speech speechd ], MODULE_SPEECH_SPEECHD=$enableval, MODULE_SPEECH_SPEECHD=yes)
 AC_CHECK_HEADER(libspeechd.h, AC_DEFINE([HAVE_LIBSPEECHD],[],Define to 1 if you have the <libspeechd.h> header file.) SPEECHD_LIBS="-lspeechd" speechd=yes,  AC_MSG_WARN([*** no libspeechd.h -- Speech output disabled]))
 AC_SUBST(SPEECHD_CFLAGS)
 AC_SUBST(SPEECHD_LIBS)
 AM_CONDITIONAL(SPEECH_SPEECH_DISPATCHER, [test "x$speechd" = "xyes"])
 
 
-AC_ARG_ENABLE(MODULE_GUI_SDL, [  --disable-gui-sdl             don't create gui sdl ],
-MODULE_GUI_SDL=$enableval, MODULE_GUI_SDL=yes)
+AC_ARG_ENABLE(MODULE_GUI_SDL, [  --disable-gui-sdl             don't create gui sdl ], MODULE_GUI_SDL=$enableval, MODULE_GUI_SDL=yes)
 if test "x$MODULE_GUI_GTK" = "xyes"; then
        AC_CHECK_HEADER(
                SDL/SDL.h,
@@ -134,38 +135,40 @@ AC_SUBST(GPSD_CFLAGS)
 AC_SUBST(GPSD_LIBS)
 AM_CONDITIONAL(VEHICLE_GPSD, [test "x$gpsd" = "xyes"])
 
-PYTHON_LIB=""
-PYTHON_INC=""
+AC_ARG_ENABLE(MODULE_BINDING_PYTHON, [  --disable-binding-python             don't create binding python ], MODULE_BINDING_PYTHON=$enableval, MODULE_BINDING_PYTHON=yes)
 if test "$cross_compiling" = no; then
-       AC_PATH_PROG(_PATH_PYTHON,[python])
-       dnl Libraries and flags for embedded Python.
-       dnl FIXME: I wish there was a less icky way to get this.
-       if test x"$_PATH_PYTHON" != x ; then
-               AC_MSG_CHECKING(for Python linkage)
-               py_prefix=`$_PATH_PYTHON -c 'import sys; print sys.prefix'`
-               py_ver=`$_PATH_PYTHON -c 'import sys; print sys.version[[:3]]'`
-               py_libdir="${py_prefix}/lib/python${py_ver}"
-               PYTHON_INC="-I${py_prefix}/include/python${py_ver}"
-               if test -f $py_libdir/config/Makefile ; then
-                       py_libs=`grep '^LIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
-                       py_libc=`grep '^LIBC=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
-                       py_libm=`grep '^LIBM=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
-                       py_liblocalmod=`grep '^LOCALMODLIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
-                       py_libbasemod=`grep '^BASEMODLIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
-                       PYTHON_LIB="-L$py_libdir/config $py_libs $py_libc $py_libm -lpython$py_ver $py_liblocalmod $py_libbasemod"
-                       PYTHON_LIB=`echo $PYTHON_LIB | sed -e 's/[ \\t]*/ /g'`
-                       CFLAGS="$CFLAGS $PYTHON_INC"
-                       LIBS="$LIBS $PYTHON_LIB"
-                       AC_MSG_RESULT($py_libdir)
-               else
-                       AC_MSG_WARN([$py_libdir/config/Makefile missing, support for python disabled])
+       if test "x$MODULE_BINDING_PYTHON" = "xyes"; then
+               AC_PATH_PROG(_PATH_PYTHON,[python])
+               dnl Libraries and flags for embedded Python.
+               dnl FIXME: I wish there was a less icky way to get this.
+               if test x"$_PATH_PYTHON" != x ; then
+                       AC_MSG_CHECKING(for Python linkage)
+                       py_prefix=`$_PATH_PYTHON -c 'import sys; print sys.prefix'`
+                       py_ver=`$_PATH_PYTHON -c 'import sys; print sys.version[[:3]]'`
+                       py_libdir="${py_prefix}/lib/python${py_ver}"
+                       PYTHON_CFLAGS="-I${py_prefix}/include/python${py_ver}"
+                       if test -f $py_libdir/config/Makefile ; then
+                               py_libs=`grep '^LIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
+                               py_libc=`grep '^LIBC=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
+                               py_libm=`grep '^LIBM=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
+                               py_liblocalmod=`grep '^LOCALMODLIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
+                               py_libbasemod=`grep '^BASEMODLIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
+                               PYTHON_LIBS="-L$py_libdir/config $py_libs $py_libc $py_libm -lpython$py_ver $py_liblocalmod $py_libbasemod"
+                               PYTHON_LIBS=`echo $PYTHON_LIB | sed -e 's/[ \\t]*/ /g'`
+                               AC_DEFINE(HAVE_PYTHON, 1, [Define to 1 if you have python])
+                               python=yes
+                               AC_MSG_RESULT($py_libdir)
+                       else
+                               AC_MSG_WARN([$py_libdir/config/Makefile missing, support for python disabled])
+                       fi
                fi
        fi
 else
        AC_MSG_WARN([*** cross compiling, support for python disabled])
 fi
-AC_SUBST(PYTHON_LIB)
-AC_SUBST(PYTHON_INC)
+AC_SUBST(PYTHON_CFLAGS)
+AC_SUBST(PYTHON_LIBS)
+AM_CONDITIONAL(BINDING_PYTHON, [test "x$python" = "xyes"])
 
 LIBS="$LIBS -lm -rdynamic"
 
@@ -173,6 +176,7 @@ AC_OUTPUT([
 Makefile
 src/Makefile
 src/binding/Makefile
+src/binding/python/Makefile
 src/data/Makefile
 src/data/mg/Makefile
 src/data/textfile/Makefile
index d33db0f..9225c3e 100644 (file)
@@ -1,7 +1,7 @@
 include $(top_srcdir)/Makefile.inc
 SUBDIRS=binding data fib-1.1 gui graphics osd speech vehicle xpm
 
-AM_CPPFLAGS = -I$(top_srcdir)/src/fib-1.1 @NAVIT_CFLAGS@ @SPEECHD_CFLAGS@ -DMODULE=\"navit\"
+AM_CPPFLAGS = -I$(top_srcdir)/src/fib-1.1 @NAVIT_CFLAGS@ -DMODULE=\"navit\"
 
 
 bin_PROGRAMS = navit
@@ -12,7 +12,7 @@ EXTRA_DIST = navit.xml
 navit_SOURCES = attr.c callback.c compass.c coord.c country.c cursor.c data_window.c debug.c \
        file.c graphics.c gui.c item.c layout.c log.c main.c map.c \
        mapset.c maptype.c menu.c navit.c navigation.c param.c phrase.c plugin.c popup.c \
-       profile.c python.c route.c search.c speech.c transform.c track.c \
+       profile.c route.c search.c speech.c transform.c track.c \
        util.c vehicle.c xmlconfig.c attr.h attr_def.h callback.h color.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 \
        file.h graphics.h gtkext.h gui.h item.h item_def.h log.h layer.h layout.h map-share.h map.h\
@@ -20,5 +20,5 @@ navit_SOURCES = attr.c callback.c compass.c coord.c country.c cursor.c data_wind
        param.h phrase.h plugin.h point.h plugin_def.h projection.h popup.h route.h profile.h search.h speech.h statusbar.h \
        transform.h track.h util.h vehicle.h xmlconfig.h
 
-navit_LDADD = @NAVIT_LIBS@ @GPSD_LIBS@ @SPEECHD_LIBS@ -Lfib-1.1 -lfib
+navit_LDADD = @NAVIT_LIBS@ @GPSD_LIBS@ -Lfib-1.1 -lfib
 
index e2baa04..80e20cc 100644 (file)
@@ -1 +1,4 @@
 SUBDIRS=
+if BINDING_PYTHON
+  SUBDIRS+=python
+endif
diff --git a/src/binding/python/Makefile.am b/src/binding/python/Makefile.am
new file mode 100644 (file)
index 0000000..27dd68d
--- /dev/null
@@ -0,0 +1,4 @@
+include $(top_srcdir)/Makefile.inc
+AM_CPPFLAGS = @NAVIT_CFLAGS@ @PYTHON_CFLAGS@ -I$(top_srcdir)/src -DMODULE=\"binding_python\"
+modulebinding_LTLIBRARIES = libbinding_python.la
+libbinding_python_la_SOURCES = binding_python.c
diff --git a/src/binding/python/binding_python.c b/src/binding/python/binding_python.c
new file mode 100644 (file)
index 0000000..fc84146
--- /dev/null
@@ -0,0 +1,281 @@
+#include "config.h"
+#include <Python.h>
+#include <fcntl.h>
+#include "coord.h"
+#include "map.h"
+#include "mapset.h"
+#include "plugin.h"
+
+#if defined(MS_WINDOWS) || defined(__CYGWIN__)
+#define Obj_HEAD PyObject_HEAD_INIT(NULL);
+#else
+#define Obj_HEAD PyObject_HEAD_INIT(&PyType_Type)
+#endif
+
+/* *** coord *** */
+
+typedef struct {
+       PyObject_HEAD
+       struct coord *c;
+} coordObject;
+
+static void coord_destroy_py(coordObject *self);
+
+PyTypeObject coord_Type = {
+       Obj_HEAD
+       .tp_name="coord",
+       .tp_basicsize=sizeof(coordObject),
+       .tp_dealloc=(destructor)coord_destroy_py,
+};
+
+
+/* *** map *** */
+
+typedef struct {
+       PyObject_HEAD
+       struct map *m;
+} mapObject;
+
+static void map_destroy_py(mapObject *self);
+static PyObject *map_getattr_py(PyObject *self, char *name);
+
+PyTypeObject map_Type = {
+       Obj_HEAD
+       .tp_name="map",
+       .tp_basicsize=sizeof(mapObject),
+       .tp_dealloc=(destructor)map_destroy_py,
+       .tp_getattr=map_getattr_py,
+};
+
+/* *** IMPLEMENTATIONS *** */
+
+/* *** coord *** */
+
+static PyObject *
+coord_new_py(PyObject *self, PyObject *args)
+{
+       coordObject *ret;
+       int x,y;
+       if (!PyArg_ParseTuple(args, "ii:navit.coord",&x,&y))
+               return NULL;
+       ret=PyObject_NEW(coordObject, &coord_Type);
+       ret->c=coord_new(x,y);
+       return (PyObject *)ret;
+}
+
+static void
+coord_destroy_py(coordObject *self)
+{
+               coord_destroy(self->c);
+}
+
+/* *** coord_rect *** */
+
+typedef struct {
+       PyObject_HEAD
+       struct coord_rect *r;
+} coord_rectObject;
+
+
+static void coord_rect_destroy_py(coord_rectObject *self);
+
+PyTypeObject coord_rect_Type = {
+#if defined(MS_WINDOWS) || defined(__CYGWIN__)
+       PyObject_HEAD_INIT(NULL);
+#else
+       PyObject_HEAD_INIT(&PyType_Type)
+#endif
+       .tp_name="coord_rect",
+       .tp_basicsize=sizeof(coord_rectObject),
+       .tp_dealloc=(destructor)coord_rect_destroy_py,
+};
+
+static PyObject *
+coord_rect_new_py(PyObject *self, PyObject *args)
+{
+       coord_rectObject *ret;
+       coordObject *lu,*rd;
+       if (!PyArg_ParseTuple(args, "O!O!:navit.coord_rect_rect",&coord_Type,&lu,&coord_Type,&rd))
+               return NULL;
+       ret=PyObject_NEW(coord_rectObject, &coord_rect_Type);
+       ret->r=coord_rect_new(lu->c,rd->c);
+       return (PyObject *)ret;
+}
+
+static void
+coord_rect_destroy_py(coord_rectObject *self)
+{
+       coord_rect_destroy(self->r);
+}
+
+/* *** map_rect *** */
+
+typedef struct {
+       PyObject_HEAD
+       struct map_rect *mr;
+} map_rectObject;
+
+
+static void map_rect_destroy_py(map_rectObject *self);
+
+PyTypeObject map_rect_Type = {
+#if defined(MS_WINDOWS) || defined(__CYGWIN__)
+       PyObject_HEAD_INIT(NULL);
+#else
+       PyObject_HEAD_INIT(&PyType_Type)
+#endif
+       .tp_name="map_rect",
+       .tp_basicsize=sizeof(map_rectObject),
+       .tp_dealloc=(destructor)map_rect_destroy_py,
+};
+
+static PyObject *
+map_rect_new_py(mapObject *self, PyObject *args)
+{
+       map_rectObject *ret;
+       coord_rectObject *r;
+       if (!PyArg_ParseTuple(args, "O!:navit.map_rect_rect",&coord_rect_Type,&r))
+               return NULL;
+       ret=PyObject_NEW(map_rectObject, &map_rect_Type);
+       ret->mr=map_rect_new(self->m, NULL);
+       return (PyObject *)ret;
+}
+
+static void
+map_rect_destroy_py(map_rectObject *self)
+{
+       map_rect_destroy(self->mr);
+}
+
+
+/* *** map *** */
+
+
+
+static PyMethodDef map_methods[] = {
+       {"map_rect_new",        (PyCFunction) map_rect_new_py, METH_VARARGS },
+       {NULL, NULL },
+};
+
+static PyObject *
+map_getattr_py(PyObject *self, char *name)
+{
+       return Py_FindMethod(map_methods, self, name);
+}
+
+
+static PyObject *
+map_new_py(PyObject *self, PyObject *args)
+{
+       mapObject *ret;
+       char *type, *filename;
+       
+       if (!PyArg_ParseTuple(args, "ss:navit.map", &type, &filename))
+               return NULL;
+       ret=PyObject_NEW(mapObject, &map_Type);
+       ret->m=map_new(type,filename);
+       return (PyObject *)ret;
+}
+
+static void
+map_destroy_py(mapObject *self)
+{
+       map_destroy(self->m);
+}
+
+/* *** mapset *** */
+
+
+typedef struct {
+       PyObject_HEAD
+       struct mapset *ms;
+} mapsetObject;
+
+
+static void mapset_destroy_py(mapsetObject *self);
+static PyObject *mapset_getattr_py(PyObject *self, char *name);
+
+PyTypeObject mapset_Type = {
+#if defined(MS_WINDOWS) || defined(__CYGWIN__)
+       PyObject_HEAD_INIT(NULL);
+#else
+       PyObject_HEAD_INIT(&PyType_Type)
+#endif
+       .tp_name="mapset",
+       .tp_basicsize=sizeof(mapsetObject),
+       .tp_dealloc=(destructor)mapset_destroy_py,
+       .tp_getattr=mapset_getattr_py,
+};
+
+static PyObject *
+mapset_add_py(mapsetObject *self, PyObject *args)
+{
+       mapObject *map;
+       if (!PyArg_ParseTuple(args, "O:navit.mapset", &map))
+               return NULL;
+       Py_INCREF(map);
+       mapset_add(self->ms, map->m);
+       return Py_BuildValue("");
+}
+
+static PyMethodDef mapset_methods[] = {
+       {"add", (PyCFunction) mapset_add_py, METH_VARARGS },
+       {NULL, NULL },
+};
+
+static PyObject *
+mapset_getattr_py(PyObject *self, char *name)
+{
+       return Py_FindMethod(mapset_methods, self, name);
+}
+
+static PyObject *
+mapset_new_py(PyObject *self, PyObject *args)
+{
+       mapsetObject *ret;
+       if (!PyArg_ParseTuple(args, ":navit.mapset"))
+               return NULL;
+       ret=PyObject_NEW(mapsetObject, &mapset_Type);
+       ret->ms=mapset_new();
+       return (PyObject *)ret;
+}
+
+static void
+mapset_destroy_py(mapsetObject *self)
+{
+       mapset_destroy(self->ms);
+}
+
+
+
+static PyMethodDef navitMethods[]={
+       {"coord", coord_new_py, METH_VARARGS, "Create a new coordinate point."},
+       {"coord_rect", coord_rect_new_py, METH_VARARGS, "Create a new coordinate rectangle."},
+       {"map", map_new_py, METH_VARARGS, "Create a new map."},
+       {"mapset", mapset_new_py, METH_VARARGS, "Create a new mapset."},
+       {NULL, NULL, 0, NULL}
+};
+
+
+void
+plugin_init(void)
+{
+       int fd,size;
+       char buffer[65536];
+
+       return;
+
+       Py_Initialize();
+       Py_InitModule("navit", navitMethods);
+       fd=open("startup.py",O_RDONLY);
+       if (fd >= 0) {
+               size=read(fd, buffer, 65535);
+               if (size > 0) {
+                       buffer[size]='\0';
+                       PyRun_SimpleString(buffer);
+               }
+       }
+       
+       Py_Finalize();
+       exit(0);
+}
index 464a70e..c2279a9 100644 (file)
@@ -11,9 +11,6 @@
 #include "debug.h"
 #include "navit.h"
 #include "gui.h"
-#ifdef HAVE_PYTHON
-#include "python.h"
-#endif
 #include "plugin.h"
 #include "xmlconfig.h"
 
@@ -70,9 +67,6 @@ int main(int argc, char **argv)
        gdk_rgb_init();
 #endif
 
-#ifdef HAVE_PYTHON
-       python_init();
-#endif
        if (argc > 1) 
                config_file=argv[1];
        else {
index b3fef2a..bbaadc0 100644 (file)
@@ -8,9 +8,11 @@
 void
 phrase_route_calc(void *speech)
 {
+#if 0
        if (! speech)
                return;
        speech_say(speech,"Die Route wird berechnet\n");        
+#endif
 }
 
 void
diff --git a/src/python.c b/src/python.c
deleted file mode 100644 (file)
index 4b85beb..0000000
+++ /dev/null
@@ -1,281 +0,0 @@
-#include "config.h"
-#ifdef HAVE_PYTHON
-#include <Python.h>
-#include <fcntl.h>
-#include "coord.h"
-#include "map.h"
-#include "mapset.h"
-
-#if defined(MS_WINDOWS) || defined(__CYGWIN__)
-#define Obj_HEAD PyObject_HEAD_INIT(NULL);
-#else
-#define Obj_HEAD PyObject_HEAD_INIT(&PyType_Type)
-#endif
-
-/* *** coord *** */
-
-typedef struct {
-       PyObject_HEAD
-       struct coord *c;
-} coordObject;
-
-static void coord_destroy_py(coordObject *self);
-
-PyTypeObject coord_Type = {
-       Obj_HEAD
-       .tp_name="coord",
-       .tp_basicsize=sizeof(coordObject),
-       .tp_dealloc=(destructor)coord_destroy_py,
-};
-
-
-/* *** map *** */
-
-typedef struct {
-       PyObject_HEAD
-       struct map *m;
-} mapObject;
-
-static void map_destroy_py(mapObject *self);
-static PyObject *map_getattr_py(PyObject *self, char *name);
-
-PyTypeObject map_Type = {
-       Obj_HEAD
-       .tp_name="map",
-       .tp_basicsize=sizeof(mapObject),
-       .tp_dealloc=(destructor)map_destroy_py,
-       .tp_getattr=map_getattr_py,
-};
-
-/* *** IMPLEMENTATIONS *** */
-
-/* *** coord *** */
-
-static PyObject *
-coord_new_py(PyObject *self, PyObject *args)
-{
-       coordObject *ret;
-       int x,y;
-       if (!PyArg_ParseTuple(args, "ii:navit.coord",&x,&y))
-               return NULL;
-       ret=PyObject_NEW(coordObject, &coord_Type);
-       ret->c=coord_new(x,y);
-       return (PyObject *)ret;
-}
-
-static void
-coord_destroy_py(coordObject *self)
-{
-               coord_destroy(self->c);
-}
-
-/* *** coord_rect *** */
-
-typedef struct {
-       PyObject_HEAD
-       struct coord_rect *r;
-} coord_rectObject;
-
-
-static void coord_rect_destroy_py(coord_rectObject *self);
-
-PyTypeObject coord_rect_Type = {
-#if defined(MS_WINDOWS) || defined(__CYGWIN__)
-       PyObject_HEAD_INIT(NULL);
-#else
-       PyObject_HEAD_INIT(&PyType_Type)
-#endif
-       .tp_name="coord_rect",
-       .tp_basicsize=sizeof(coord_rectObject),
-       .tp_dealloc=(destructor)coord_rect_destroy_py,
-};
-
-static PyObject *
-coord_rect_new_py(PyObject *self, PyObject *args)
-{
-       coord_rectObject *ret;
-       coordObject *lu,*rd;
-       if (!PyArg_ParseTuple(args, "O!O!:navit.coord_rect_rect",&coord_Type,&lu,&coord_Type,&rd))
-               return NULL;
-       ret=PyObject_NEW(coord_rectObject, &coord_rect_Type);
-       ret->r=coord_rect_new(lu->c,rd->c);
-       return (PyObject *)ret;
-}
-
-static void
-coord_rect_destroy_py(coord_rectObject *self)
-{
-       coord_rect_destroy(self->r);
-}
-
-/* *** map_rect *** */
-
-typedef struct {
-       PyObject_HEAD
-       struct map_rect *mr;
-} map_rectObject;
-
-
-static void map_rect_destroy_py(map_rectObject *self);
-
-PyTypeObject map_rect_Type = {
-#if defined(MS_WINDOWS) || defined(__CYGWIN__)
-       PyObject_HEAD_INIT(NULL);
-#else
-       PyObject_HEAD_INIT(&PyType_Type)
-#endif
-       .tp_name="map_rect",
-       .tp_basicsize=sizeof(map_rectObject),
-       .tp_dealloc=(destructor)map_rect_destroy_py,
-};
-
-static PyObject *
-map_rect_new_py(mapObject *self, PyObject *args)
-{
-       map_rectObject *ret;
-       coord_rectObject *r;
-       if (!PyArg_ParseTuple(args, "O!:navit.map_rect_rect",&coord_rect_Type,&r))
-               return NULL;
-       ret=PyObject_NEW(map_rectObject, &map_rect_Type);
-       ret->mr=map_rect_new(self->m, r->r, NULL, 0);
-       return (PyObject *)ret;
-}
-
-static void
-map_rect_destroy_py(map_rectObject *self)
-{
-       map_rect_destroy(self->mr);
-}
-
-
-/* *** map *** */
-
-
-
-static PyMethodDef map_methods[] = {
-       {"map_rect_new",        (PyCFunction) map_rect_new_py, METH_VARARGS },
-       {NULL, NULL },
-};
-
-static PyObject *
-map_getattr_py(PyObject *self, char *name)
-{
-       return Py_FindMethod(map_methods, self, name);
-}
-
-
-static PyObject *
-map_new_py(PyObject *self, PyObject *args)
-{
-       mapObject *ret;
-       char *type, *filename;
-       
-       if (!PyArg_ParseTuple(args, "ss:navit.map", &type, &filename))
-               return NULL;
-       ret=PyObject_NEW(mapObject, &map_Type);
-       ret->m=map_new(type,filename);
-       return (PyObject *)ret;
-}
-
-static void
-map_destroy_py(mapObject *self)
-{
-       map_destroy(self->m);
-}
-
-/* *** mapset *** */
-
-
-typedef struct {
-       PyObject_HEAD
-       struct mapset *ms;
-} mapsetObject;
-
-
-static void mapset_destroy_py(mapsetObject *self);
-static PyObject *mapset_getattr_py(PyObject *self, char *name);
-
-PyTypeObject mapset_Type = {
-#if defined(MS_WINDOWS) || defined(__CYGWIN__)
-       PyObject_HEAD_INIT(NULL);
-#else
-       PyObject_HEAD_INIT(&PyType_Type)
-#endif
-       .tp_name="mapset",
-       .tp_basicsize=sizeof(mapsetObject),
-       .tp_dealloc=(destructor)mapset_destroy_py,
-       .tp_getattr=mapset_getattr_py,
-};
-
-static PyObject *
-mapset_add_py(mapsetObject *self, PyObject *args)
-{
-       mapObject *map;
-       if (!PyArg_ParseTuple(args, "O:navit.mapset", &map))
-               return NULL;
-       Py_INCREF(map);
-       mapset_add(self->ms, map->m);
-       return Py_BuildValue("");
-}
-
-static PyMethodDef mapset_methods[] = {
-       {"add", (PyCFunction) mapset_add_py, METH_VARARGS },
-       {NULL, NULL },
-};
-
-static PyObject *
-mapset_getattr_py(PyObject *self, char *name)
-{
-       return Py_FindMethod(mapset_methods, self, name);
-}
-
-static PyObject *
-mapset_new_py(PyObject *self, PyObject *args)
-{
-       mapsetObject *ret;
-       if (!PyArg_ParseTuple(args, ":navit.mapset"))
-               return NULL;
-       ret=PyObject_NEW(mapsetObject, &mapset_Type);
-       ret->ms=mapset_new();
-       return (PyObject *)ret;
-}
-
-static void
-mapset_destroy_py(mapsetObject *self)
-{
-       mapset_destroy(self->ms);
-}
-
-
-
-static PyMethodDef navitMethods[]={
-       {"coord", coord_new_py, METH_VARARGS, "Create a new coordinate point."},
-       {"coord_rect", coord_rect_new_py, METH_VARARGS, "Create a new coordinate rectangle."},
-       {"map", map_new_py, METH_VARARGS, "Create a new map."},
-       {"mapset", mapset_new_py, METH_VARARGS, "Create a new mapset."},
-       {NULL, NULL, 0, NULL}
-};
-
-
-void python_init(void)
-{
-       int fd,size;
-       char buffer[65536];
-
-       return;
-
-       Py_Initialize();
-       Py_InitModule("navit", navitMethods);
-       fd=open("startup.py",O_RDONLY);
-       if (fd >= 0) {
-               size=read(fd, buffer, 65535);
-               if (size > 0) {
-                       buffer[size]='\0';
-                       PyRun_SimpleString(buffer);
-               }
-       }
-       
-       Py_Finalize();
-       exit(0);
-}
-#endif
diff --git a/src/python.h b/src/python.h
deleted file mode 100644 (file)
index 9829b13..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-void python_init(void);
-
index fa9ab33..7c32862 100644 (file)
@@ -1,78 +1 @@
-/* speechd simple client program
- * CVS revision: $Id: speech.c,v 1.4 2006-01-03 21:37:48 martin-s Exp $
- * Author: Tomas Cerha <cerha@brailcom.cz> */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <glib.h>
-#include <stdarg.h>
-#include "config.h"
-#ifdef HAVE_LIBSPEECHD
-#include <libspeechd.h>
-#endif
 #include "speech.h"
-
-struct speech {
-#ifdef HAVE_LIBSPEECHD
-       SPDConnection *conn;
-#endif
-};
-
-struct speech *
-speech_new(void) {
-#ifdef HAVE_LIBSPEECHD
-       struct speech *this;
-       SPDConnection *conn;
-
-       conn = spd_open("navit","main",NULL,SPD_MODE_SINGLE);
-       if (! conn) 
-               return NULL;
-       this=g_new(struct speech,1);
-       if (this) {
-               this->conn=conn;
-               spd_set_punctuation(conn, SPD_PUNCT_NONE);
-       }
-       return this;
-#else
-       return NULL;
-#endif
-}
-
-int 
-speech_say(struct speech *this, char *text) {
-#ifdef HAVE_LIBSPEECHD
-       int err;
-
-       err = spd_sayf(this->conn, SPD_MESSAGE, text);
-       if (err != 1)
-               return 1;
-#endif
-       return 0;
-}
-
-int
-speech_sayf(struct speech *this, char *format, ...) {
-#ifdef HAVE_LIBSPEECHD
-       char buffer[8192];
-       va_list ap;
-       va_start(ap,format);
-       vsnprintf(buffer, 8192, format, ap);
-       return speech_say(this, buffer);
-#else
-       return 0;
-#endif
-}
-
-int 
-speech_destroy(struct speech *this) {
-#ifdef HAVE_LIBSPEECHD
-       spd_close(this->conn);
-       g_free(this);
-#endif
-       return 0;
-}
index a4038e0..09217c6 100644 (file)
@@ -1,5 +1,7 @@
+#if 0
 struct speech;
 struct speech *speech_new(void);
 int speech_say(struct speech *this, char *text);
 int speech_sayf(struct speech *this, char *format, ...);
 int speech_destroy(struct speech *this);
+#endif
index 32be387..4c4ebed 100644 (file)
@@ -1,5 +1,66 @@
+
+/* speechd simple client program
+ * CVS revision: $Id: speech_speech_dispatcher.c,v 1.2 2007-07-08 16:42:16 martin-s Exp $
+ * Author: Tomas Cerha <cerha@brailcom.cz> */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <stdarg.h>
+#include "config.h"
+#include <libspeechd.h>
 #include "plugin.h"
+#include "speech.h"
+
+struct speech {
+       SPDConnection *conn;
+};
+
+struct speech *
+speech_new(void) {
+       struct speech *this;
+       SPDConnection *conn;
+
+       conn = spd_open("navit","main",NULL,SPD_MODE_SINGLE);
+       if (! conn) 
+               return NULL;
+       this=g_new(struct speech,1);
+       if (this) {
+               this->conn=conn;
+               spd_set_punctuation(conn, SPD_PUNCT_NONE);
+       }
+       return this;
+}
 
+static int 
+speech_say(struct speech *this, char *text) {
+       int err;
+
+       err = spd_sayf(this->conn, SPD_MESSAGE, text);
+       if (err != 1)
+               return 1;
+       return 0;
+}
+
+static int
+speech_sayf(struct speech *this, char *format, ...) {
+       char buffer[8192];
+       va_list ap;
+       va_start(ap,format);
+       vsnprintf(buffer, 8192, format, ap);
+       return speech_say(this, buffer);
+}
+
+static void 
+speech_destroy(struct speech *this) {
+       spd_close(this->conn);
+       g_free(this);
+}
 void
 plugin_init(void)
 {