From: martin-s Date: Fri, 8 Jan 2010 10:28:00 +0000 (+0000) Subject: Add:Core:speech_dbus X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=fc45288f22da548b328d2c772472d69f4c7049b0;p=navit-package Add:Core:speech_dbus git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit@2898 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- diff --git a/configure.in b/configure.in index c3f3a0f..81eeb4a 100644 --- a/configure.in +++ b/configure.in @@ -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 @@ -526,11 +527,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) @@ -844,6 +848,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 @@ -951,6 +956,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)" diff --git a/navit/binding/dbus/binding_dbus.c b/navit/binding/dbus/binding_dbus.c index d9f1d7b..f5f06a0 100644 --- a/navit/binding/dbus/binding_dbus.c +++ b/navit/binding/dbus/binding_dbus.c @@ -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); diff --git a/navit/plugin_def.h b/navit/plugin_def.h index 4eec845..682ca59 100644 --- a/navit/plugin_def.h +++ b/navit/plugin_def.h @@ -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)) diff --git a/navit/speech.c b/navit/speech.c index b3df169..c3e77f0 100644 --- a/navit/speech.c +++ b/navit/speech.c @@ -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); diff --git a/navit/speech/Makefile.am b/navit/speech/Makefile.am index ddab19c..3c232db 100644 --- a/navit/speech/Makefile.am +++ b/navit/speech/Makefile.am @@ -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 index 0000000..abe285b --- /dev/null +++ b/navit/speech/dbus/Makefile.am @@ -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 index 0000000..53ab46f --- /dev/null +++ b/navit/speech/dbus/speech_dbus.c @@ -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 +#include +#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); +}