Add:Core:speech_dbus
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 8 Jan 2010 10:28:00 +0000 (10:28 +0000)
committerHenning Heinold <heinold@inf.fu-berlin.de>
Thu, 4 Feb 2010 23:44:12 +0000 (00:44 +0100)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit@2898 ffa7fe5e-494d-0410-b361-a75ebd5db220

configure.in
navit/binding/dbus/binding_dbus.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]

index c3f3a0f..81eeb4a 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
@@ -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)"
 
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 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);
+}