… | |
… | |
38 | { |
38 | { |
39 | char *str=g_strdup(text); |
39 | char *str=g_strdup(text); |
40 | jstring string; |
40 | jstring string; |
41 | int i; |
41 | int i; |
42 | |
42 | |
|
|
43 | /* |
43 | if (this->flags & 2) { |
44 | if (this->flags & 2) |
|
|
45 | { |
44 | for (i = 0 ; i < strlen(str) ; i++) { |
46 | for (i = 0 ; i < strlen(str) ; i++) |
|
|
47 | { |
45 | if (str[i] == 0xc3 && str[i+1] == 0x84) { |
48 | if (str[i] == 0xc3 && str[i+1] == 0x84) { |
46 | str[i]='A'; |
49 | str[i]='A'; |
47 | str[i+1]='e'; |
50 | str[i+1]='e'; |
48 | } |
51 | } |
49 | if (str[i] == 0xc3 && str[i+1] == 0x96) { |
52 | if (str[i] == 0xc3 && str[i+1] == 0x96) { |
… | |
… | |
70 | str[i]='s'; |
73 | str[i]='s'; |
71 | str[i+1]='s'; |
74 | str[i+1]='s'; |
72 | } |
75 | } |
73 | } |
76 | } |
74 | } |
77 | } |
|
|
78 | */ |
|
|
79 | |
75 | string = (*jnienv)->NewStringUTF(jnienv, str); |
80 | string = (*jnienv)->NewStringUTF(jnienv, str); |
76 | dbg(0,"enter %s\n",str); |
81 | // dbg(0,"enter %s\n",str); |
77 | (*jnienv)->CallVoidMethod(jnienv, this->NavitSpeech, this->NavitSpeech_say, string); |
82 | (*jnienv)->CallVoidMethod(jnienv, this->NavitSpeech, this->NavitSpeech_say, string); |
78 | (*jnienv)->DeleteLocalRef(jnienv, string); |
83 | (*jnienv)->DeleteLocalRef(jnienv, string); |
|
|
84 | |
79 | g_free(str); |
85 | g_free(str); |
80 | |
86 | |
81 | return 1; |
87 | return 1; |
82 | } |
88 | } |
83 | |
89 | |
… | |
… | |
92 | }; |
98 | }; |
93 | |
99 | |
94 | static int |
100 | static int |
95 | speech_android_init(struct speech_priv *ret) |
101 | speech_android_init(struct speech_priv *ret) |
96 | { |
102 | { |
|
|
103 | dbg(0,"EEnter\n"); |
|
|
104 | |
97 | jmethodID cid; |
105 | jmethodID cid; |
98 | char *class="com/zoffcc/applications/zanavi/NavitSpeech2"; |
106 | char *class="com/zoffcc/applications/zanavi/NavitSpeech2"; |
99 | |
107 | |
100 | if (ret->flags & 1) |
108 | if (ret->flags & 1) |
|
|
109 | { |
101 | class="com/zoffcc/applications/zanavi/NavitSpeech"; |
110 | class="com/zoffcc/applications/zanavi/NavitSpeech"; |
|
|
111 | } |
102 | |
112 | |
103 | if (!android_find_class_global(class, &ret->NavitSpeechClass)) { |
113 | if (!android_find_class_global(class, &ret->NavitSpeechClass)) |
|
|
114 | { |
104 | dbg(0,"No class found\n"); |
115 | dbg(0,"No class found\n"); |
105 | return 0; |
116 | return 0; |
106 | } |
117 | } |
|
|
118 | |
107 | dbg(0,"at 3\n"); |
119 | dbg(0,"at 3\n"); |
108 | cid = (*jnienv)->GetMethodID(jnienv, ret->NavitSpeechClass, "<init>", "(Lcom/zoffcc/applications/zanavi/Navit;)V"); |
120 | cid = (*jnienv)->GetMethodID(jnienv, ret->NavitSpeechClass, "<init>", "(Lcom/zoffcc/applications/zanavi/Navit;)V"); |
109 | if (cid == NULL) { |
121 | if (cid == NULL) |
|
|
122 | { |
110 | dbg(0,"no method found\n"); |
123 | dbg(0,"no method found\n"); |
111 | return 0; /* exception thrown */ |
124 | return 0; /* exception thrown */ |
112 | } |
125 | } |
113 | if (!android_find_method(ret->NavitSpeechClass, "say", "(Ljava/lang/String;)V", &ret->NavitSpeech_say)) |
126 | if (!android_find_method(ret->NavitSpeechClass, "say", "(Ljava/lang/String;)V", &ret->NavitSpeech_say)) |
114 | return 0; |
127 | { |
|
|
128 | return 0; |
|
|
129 | } |
115 | dbg(0,"at 4 android_activity=%p\n",android_activity); |
130 | dbg(0,"at 4 android_activity=%p\n",android_activity); |
116 | ret->NavitSpeech=(*jnienv)->NewObject(jnienv, ret->NavitSpeechClass, cid, android_activity); |
131 | ret->NavitSpeech=(*jnienv)->NewObject(jnienv, ret->NavitSpeechClass, cid, android_activity); |
117 | dbg(0,"result=%p\n",ret->NavitSpeech); |
132 | dbg(0,"result=%p\n",ret->NavitSpeech); |
118 | if (!ret->NavitSpeech) |
133 | if (!ret->NavitSpeech) |
|
|
134 | { |
119 | return 0; |
135 | return 0; |
|
|
136 | } |
120 | if (ret->NavitSpeech) |
137 | if (ret->NavitSpeech) |
121 | (*jnienv)->NewGlobalRef(jnienv, ret->NavitSpeech); |
138 | { |
|
|
139 | ret->NavitSpeech = (*jnienv)->NewGlobalRef(jnienv, ret->NavitSpeech); |
|
|
140 | } |
122 | return 1; |
141 | return 1; |
123 | } |
142 | } |
124 | |
143 | |
125 | static struct speech_priv * |
144 | static struct speech_priv * |
126 | speech_android_new(struct speech_methods *meth, struct attr **attrs, struct attr *parent) { |
145 | speech_android_new(struct speech_methods *meth, struct attr **attrs, struct attr *parent) |
|
|
146 | { |
|
|
147 | dbg(0,"EEnter\n"); |
127 | struct speech_priv *this; |
148 | struct speech_priv *this; |
128 | struct attr *flags; |
149 | struct attr *flags; |
129 | *meth=speech_android_meth; |
150 | *meth=speech_android_meth; |
130 | this=g_new0(struct speech_priv,1); |
151 | this=g_new0(struct speech_priv,1); |
|
|
152 | |
131 | if (!speech_android_init(this)) { |
153 | if (!speech_android_init(this)) |
|
|
154 | { |
132 | g_free(this); |
155 | g_free(this); |
133 | this=NULL; |
156 | this=NULL; |
134 | } |
157 | } |
135 | if (android_version < 4) |
158 | if (android_version < 4) |
136 | this->flags=3; |
159 | this->flags=3; |