summaryrefslogtreecommitdiff
path: root/navit/speech
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-08-14 13:28:46 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-08-14 13:28:46 +0000
commitc745fbe6420b5d9b38b24a0781e5e9b9a8332c83 (patch)
treede5b9ed5d7a3b6a4f1b924a1bc985a178557f57c /navit/speech
parentf34436edda97da783c3206e38de42190451f4746 (diff)
downloadnavit-svn-c745fbe6420b5d9b38b24a0781e5e9b9a8332c83.tar.gz
Add:Core:Next round of android work
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2462 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/speech')
-rw-r--r--navit/speech/android/Makefile.am16
-rw-r--r--navit/speech/android/speech_android.c134
2 files changed, 150 insertions, 0 deletions
diff --git a/navit/speech/android/Makefile.am b/navit/speech/android/Makefile.am
new file mode 100644
index 00000000..f8573fb1
--- /dev/null
+++ b/navit/speech/android/Makefile.am
@@ -0,0 +1,16 @@
+include $(top_srcdir)/Makefile.inc
+AM_CPPFLAGS = @NAVIT_CFLAGS@ -I$(top_srcdir)/navit -DMODULE=speech_android
+if PLUGINS
+modulespeech_LTLIBRARIES = libspeech_android.la
+else
+noinst_LTLIBRARIES = libspeech_android.la
+endif
+libspeech_android_la_SOURCES = speech_android.c
+libspeech_android_la_LDFLAGS = -module -avoid-version -Xcompiler -nostdlib
+
+android: libspeech_android.la
+ mkdir -p ../../android/libs/armeabi/navit/speech
+ cp .libs/libspeech_android.so ../../android/libs/armeabi
+
+push: libspeech_android.la
+ adb push .libs/libspeech_android.so /data/data/org.navitproject.navit/lib
diff --git a/navit/speech/android/speech_android.c b/navit/speech/android/speech_android.c
new file mode 100644
index 00000000..d1c4f968
--- /dev/null
+++ b/navit/speech/android/speech_android.c
@@ -0,0 +1,134 @@
+/**
+ * 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 "debug.h"
+#include "plugin.h"
+#include "android.h"
+#include "speech.h"
+
+struct speech_priv {
+ jclass NavitSpeechClass;
+ jobject NavitSpeech;
+ jmethodID NavitSpeech_say;
+};
+
+static int
+speech_android_say(struct speech_priv *this, const char *text)
+{
+ char *str=g_strdup(text);
+ jstring string;
+ int i;
+
+ for (i = 0 ; i < strlen(str) ; i++) {
+ if (str[i] == 0xc3 && str[i+1] == 0x84) {
+ str[i]='A';
+ str[i+1]='e';
+ }
+ if (str[i] == 0xc3 && str[i+1] == 0x96) {
+ str[i]='O';
+ str[i+1]='e';
+ }
+ if (str[i] == 0xc3 && str[i+1] == 0x9c) {
+ str[i]='U';
+ str[i+1]='e';
+ }
+ if (str[i] == 0xc3 && str[i+1] == 0xa4) {
+ str[i]='a';
+ str[i+1]='e';
+ }
+ if (str[i] == 0xc3 && str[i+1] == 0xb6) {
+ str[i]='o';
+ str[i+1]='e';
+ }
+ if (str[i] == 0xc3 && str[i+1] == 0xbc) {
+ str[i]='u';
+ str[i+1]='e';
+ }
+ if (str[i] == 0xc3 && str[i+1] == 0x9f) {
+ str[i]='s';
+ str[i+1]='s';
+ }
+ }
+ string = (*jnienv)->NewStringUTF(jnienv, str);
+ dbg(0,"enter %s\n",str);
+ (*jnienv)->CallVoidMethod(jnienv, this->NavitSpeech, this->NavitSpeech_say, string);
+ (*jnienv)->DeleteLocalRef(jnienv, string);
+ g_free(str);
+
+ return 1;
+}
+
+static void
+speech_android_destroy(struct speech_priv *this) {
+ g_free(this);
+}
+
+static struct speech_methods speech_android_meth = {
+ speech_android_destroy,
+ speech_android_say,
+};
+
+static int
+speech_android_init(struct speech_priv *ret)
+{
+ jmethodID cid;
+
+ if (!android_find_class_global("org/navitproject/navit/NavitSpeech", &ret->NavitSpeechClass))
+ return 0;
+ dbg(0,"at 3\n");
+ cid = (*jnienv)->GetMethodID(jnienv, ret->NavitSpeechClass, "<init>", "(Landroid/content/Context;)V");
+ if (cid == NULL) {
+ dbg(0,"no method found\n");
+ return 0; /* exception thrown */
+ }
+ if (!android_find_method(ret->NavitSpeechClass, "say", "(Ljava/lang/String;)V", &ret->NavitSpeech_say))
+ return 0;
+ dbg(0,"at 4 android_activity=%p\n",android_activity);
+ ret->NavitSpeech=(*jnienv)->NewObject(jnienv, ret->NavitSpeechClass, cid, android_activity);
+ dbg(0,"result=%p\n",ret->NavitSpeech);
+ if (!ret->NavitSpeech)
+ return 0;
+ if (ret->NavitSpeech)
+ (*jnienv)->NewGlobalRef(jnienv, ret->NavitSpeech);
+ return 1;
+}
+
+static struct speech_priv *
+speech_android_new(struct speech_methods *meth, struct attr **attrs) {
+ struct speech_priv *this;
+ *meth=speech_android_meth;
+ this=g_new(struct speech_priv,1);
+ if (!speech_android_init(this)) {
+ g_free(this);
+ this=NULL;
+ }
+ speech_android_say(this, "Demnächst der Straße folgen");
+ return this;
+}
+
+
+void
+plugin_init(void)
+{
+ plugin_register_speech_type("android", speech_android_new);
+}