|
1 /* |
|
2 * Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32std.h> |
|
21 #include "nssttscustomcommandparser.h" |
|
22 #include "nssttscustomcommandcommon.h" |
|
23 #include "rubydebug.h" |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS =============================== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CTtsCustomCommandParser::CTtsCustomCommandParser |
|
29 // C++ constructor. |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 CTtsCustomCommandParser::CTtsCustomCommandParser( MTtsCustomCommandImplementor& aImplementor ) : |
|
33 CMMFCustomCommandParserBase( KUidInterfaceTts ), |
|
34 iImplementor( aImplementor ) |
|
35 { |
|
36 // Nothing |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CTtsCustomCommandParser::NewL |
|
41 // Two-phased constructor. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 EXPORT_C CTtsCustomCommandParser* CTtsCustomCommandParser::NewL( |
|
45 MTtsCustomCommandImplementor& aImplementor ) |
|
46 { |
|
47 return new ( ELeave ) CTtsCustomCommandParser(aImplementor); |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CTtsCustomCommandParser::~CTtsCustomCommandParser |
|
52 // Destructor for CTtsCustomCommandParser class |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 EXPORT_C CTtsCustomCommandParser::~CTtsCustomCommandParser() |
|
56 { |
|
57 // Nothing |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CTtsCustomCommandParser::HandleRequest |
|
62 // Handles the client side request. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 void CTtsCustomCommandParser::HandleRequest( TMMFMessage& aMessage ) |
|
66 { |
|
67 ASSERT( aMessage.Destination().InterfaceId() == KUidInterfaceTts ); |
|
68 TRAPD( error, DoHandleRequestL( aMessage ) ); |
|
69 if ( error ) |
|
70 { |
|
71 aMessage.Complete( error ); |
|
72 } |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CTtsCustomCommandParser::DoHandleRequestL |
|
77 // Decodes aMessage and calls the correct function. This function is trapped by |
|
78 // HandleRequest() and the leave code, if any, sent to the client. |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CTtsCustomCommandParser::DoHandleRequestL( TMMFMessage& aMessage ) |
|
82 { |
|
83 |
|
84 // Call required function to do the requested operation |
|
85 switch( aMessage.Function() ) |
|
86 { |
|
87 case ETtsAddStyle: |
|
88 DoAddStyleL( aMessage ); |
|
89 break; |
|
90 |
|
91 case ETtsDeleteStyle: |
|
92 DoDeleteStyleL( aMessage ); |
|
93 break; |
|
94 |
|
95 case ETtsGetPosition: |
|
96 DoGetPositionL( aMessage ); |
|
97 break; |
|
98 |
|
99 case ETtsNumberOfStyles: |
|
100 DoNumberOfStylesL( aMessage ); |
|
101 break; |
|
102 |
|
103 case ETtsOpenParsedText: |
|
104 DoOpenParsedTextL( aMessage ); |
|
105 break; |
|
106 |
|
107 case ETtsSetPosition: |
|
108 DoSetPositionL( aMessage ); |
|
109 break; |
|
110 |
|
111 case ETtsStyleID: |
|
112 DoStyleIDL( aMessage ); |
|
113 break; |
|
114 |
|
115 case ETtsStyleIndex: |
|
116 DoStyleIndexL( aMessage ); |
|
117 break; |
|
118 |
|
119 case ETtsSetDefaultStyle: |
|
120 DoSetDefaultStyleL( aMessage ); |
|
121 break; |
|
122 |
|
123 case ETtsGetDefaultStyle: |
|
124 DoGetDefaultStyleL( aMessage ); |
|
125 break; |
|
126 |
|
127 case ETtsSetSpeakingRate: |
|
128 DoSetSpeakingRateL( aMessage ); |
|
129 break; |
|
130 |
|
131 case ETtsGetSpeakingRate: |
|
132 DoGetSpeakingRateL( aMessage ); |
|
133 break; |
|
134 |
|
135 case ETtsSupportedLanguages: |
|
136 DoGetSupportedLanguagesL( aMessage ); |
|
137 break; |
|
138 |
|
139 case ETtsSupportedLanguagesCount: |
|
140 DoGetSupportedLanguagesCountL( aMessage ); |
|
141 break; |
|
142 |
|
143 case ETtsSupportedVoices: |
|
144 DoGetSupportedVoicesL( aMessage ); |
|
145 break; |
|
146 |
|
147 case ETtsSupportedVoicesCount: |
|
148 DoGetSupportedVoicesCountL( aMessage ); |
|
149 break; |
|
150 |
|
151 default: |
|
152 User::Leave( KErrNotSupported ); |
|
153 |
|
154 } // End of switch |
|
155 |
|
156 aMessage.Complete( KErrNone ); |
|
157 |
|
158 } |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // CTtsCustomCommandParser::DoAddStyleL |
|
162 // Calls the controller plugin to add a style. |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 void CTtsCustomCommandParser::DoAddStyleL( TMMFMessage& aMessage ) |
|
166 { |
|
167 TTtsStylePtrPckg stylePtrPckg; |
|
168 TTtsStyleIDPtrPckg styleIDPtrPckg; |
|
169 |
|
170 aMessage.ReadData1FromClientL( stylePtrPckg ); |
|
171 aMessage.ReadData2FromClientL( styleIDPtrPckg ); |
|
172 |
|
173 TTtsStyle* style = stylePtrPckg(); |
|
174 TTtsStyleID* ID = styleIDPtrPckg(); |
|
175 |
|
176 *ID = iImplementor.MttscAddStyleL( *style ); |
|
177 |
|
178 RUBY_DEBUG2( "CTtsCustomCommandParser::DoAddStyleL: %d, %x", *ID, style ); |
|
179 } |
|
180 |
|
181 // ----------------------------------------------------------------------------- |
|
182 // CTtsCustomCommandParser::DoDeleteStyleL |
|
183 // Calls the controller plugin to delete a style. |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 void CTtsCustomCommandParser::DoDeleteStyleL( TMMFMessage& aMessage ) |
|
187 { |
|
188 TTtsStyleIDPckg styleIDPckg; |
|
189 |
|
190 aMessage.ReadData1FromClientL( styleIDPckg ); |
|
191 |
|
192 TTtsStyleID ID = styleIDPckg(); |
|
193 |
|
194 User::LeaveIfError( iImplementor.MttscDeleteStyle( ID ) ); |
|
195 |
|
196 RUBY_DEBUG1( "CTtsCustomCommandParser::DoDeleteStyleL: %d", ID ); |
|
197 } |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // CTtsCustomCommandParser::DoGetPositionL |
|
201 // Calls the controller plugin to get the synthesis position. |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 void CTtsCustomCommandParser::DoGetPositionL( TMMFMessage& aMessage ) |
|
205 { |
|
206 TTtsIntPtrPckg intPtrPckg; |
|
207 |
|
208 aMessage.ReadData1FromClientL( intPtrPckg ); |
|
209 |
|
210 TInt* wordIndex = intPtrPckg(); |
|
211 |
|
212 iImplementor.MttscGetPositionL( *wordIndex ); |
|
213 |
|
214 RUBY_DEBUG1( "CTtsCustomCommandParser::DoGetPositionL: %d", *wordIndex ); |
|
215 } |
|
216 |
|
217 // ----------------------------------------------------------------------------- |
|
218 // CTtsCustomCommandParser::DoNumberOfStylesL |
|
219 // Calls the controller plugin to get the number of styles. |
|
220 // ----------------------------------------------------------------------------- |
|
221 // |
|
222 void CTtsCustomCommandParser::DoNumberOfStylesL( TMMFMessage& aMessage ) |
|
223 { |
|
224 TTtsUintPtrPckg uintPtrPckg; |
|
225 |
|
226 aMessage.ReadData1FromClientL( uintPtrPckg ); |
|
227 |
|
228 TUint16* count = uintPtrPckg(); |
|
229 |
|
230 *count = iImplementor.MttscNumberOfStyles(); |
|
231 |
|
232 RUBY_DEBUG1( "CTtsCustomCommandParser::DoNumberOfStylesL: %d", *count ); |
|
233 } |
|
234 |
|
235 // ----------------------------------------------------------------------------- |
|
236 // CTtsCustomCommandParser::DoOpenParsedTextL |
|
237 // Calls the controller plugin to open a parsed text source. |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 void CTtsCustomCommandParser::DoOpenParsedTextL( TMMFMessage& aMessage ) |
|
241 { |
|
242 TTtsParsedTextPckg parsedTextPckg; |
|
243 |
|
244 aMessage.ReadData1FromClientL( parsedTextPckg ); |
|
245 |
|
246 CTtsParsedText* parsedText = parsedTextPckg().iParsedText; |
|
247 |
|
248 iImplementor.MttscOpenParsedTextL( *parsedText ); |
|
249 |
|
250 RUBY_DEBUG1( "CTtsCustomCommandParser::DoOpenParsedTextL: %x", parsedText ); |
|
251 } |
|
252 |
|
253 // ----------------------------------------------------------------------------- |
|
254 // CTtsCustomCommandParser::DoSetPositionL |
|
255 // Calls the controller plugin to set the synthesis position. |
|
256 // ----------------------------------------------------------------------------- |
|
257 // |
|
258 void CTtsCustomCommandParser::DoSetPositionL( TMMFMessage& aMessage ) |
|
259 { |
|
260 TTtsIntPckg intPckg; |
|
261 |
|
262 aMessage.ReadData1FromClientL( intPckg ); |
|
263 |
|
264 TInt index = intPckg(); |
|
265 |
|
266 iImplementor.MttscSetPositionL( index ); |
|
267 |
|
268 RUBY_DEBUG1( "CTtsCustomCommandParser::DoSetPositionL: %d", index ); |
|
269 } |
|
270 |
|
271 // ----------------------------------------------------------------------------- |
|
272 // CTtsCustomCommandParser::DoStyleIDL |
|
273 // Calls the controller plugin to get the style based on ID. |
|
274 // ----------------------------------------------------------------------------- |
|
275 // |
|
276 void CTtsCustomCommandParser::DoStyleIDL( TMMFMessage& aMessage ) |
|
277 { |
|
278 TTtsStyleIDPckg styleIDPckg; |
|
279 TTtsStylePtrPckg stylePckg; |
|
280 |
|
281 aMessage.ReadData1FromClientL( styleIDPckg ); |
|
282 aMessage.ReadData2FromClientL( stylePckg ); |
|
283 |
|
284 TTtsStyleID ID = styleIDPckg(); |
|
285 TTtsStyle* style = stylePckg(); |
|
286 |
|
287 style = &( iImplementor.MttscStyleL( ID ) ); |
|
288 |
|
289 RUBY_DEBUG2( "CTtsCustomCommandParser::DoStyleIDL: %d, %x", ID, style ); |
|
290 } |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // CTtsCustomCommandParser::DoStyleIndexL |
|
294 // Calls the controller plugin to get the style based on ID. |
|
295 // ----------------------------------------------------------------------------- |
|
296 // |
|
297 void CTtsCustomCommandParser::DoStyleIndexL( TMMFMessage& aMessage ) |
|
298 { |
|
299 TTtsUintPckg uintPckg; |
|
300 TTtsStylePtrPckg stylePckg; |
|
301 |
|
302 aMessage.ReadData1FromClientL( uintPckg ); |
|
303 aMessage.ReadData2FromClientL( stylePckg ); |
|
304 |
|
305 TUint16 index = uintPckg(); |
|
306 TTtsStyle* style = stylePckg(); |
|
307 |
|
308 style = &( iImplementor.MttscStyleL( index ) ); |
|
309 |
|
310 RUBY_DEBUG2( "CTtsCustomCommandParser::DoStyleIndexL: %d, %x", index, style ); |
|
311 } |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // CTtsCustomCommandParser::DoSetDefaultStyleL |
|
315 // Calls the controller plugin to set the default style |
|
316 // ----------------------------------------------------------------------------- |
|
317 // |
|
318 void CTtsCustomCommandParser::DoSetDefaultStyleL( TMMFMessage& aMessage ) |
|
319 { |
|
320 TTtsStylePtrPckg stylePtrPckg; |
|
321 |
|
322 aMessage.ReadData1FromClientL( stylePtrPckg ); |
|
323 |
|
324 TTtsStyle* style = stylePtrPckg(); |
|
325 |
|
326 iImplementor.MttscSetDefaultStyleL( *style ); |
|
327 |
|
328 RUBY_DEBUG0( "CTtsCustomCommandParser::DoSetDefaultStyleL" ); |
|
329 } |
|
330 |
|
331 // ----------------------------------------------------------------------------- |
|
332 // CTtsCustomCommandParser::DoGetDefaultStyleL |
|
333 // Calls the controller plugin to get the default style |
|
334 // ----------------------------------------------------------------------------- |
|
335 // |
|
336 void CTtsCustomCommandParser::DoGetDefaultStyleL( TMMFMessage& aMessage ) |
|
337 { |
|
338 TTtsStylePtrPckg stylePtrPckg; |
|
339 |
|
340 aMessage.ReadData1FromClientL( stylePtrPckg ); |
|
341 |
|
342 TTtsStyle* style = stylePtrPckg(); |
|
343 |
|
344 *style = iImplementor.MttscDefaultStyleL(); |
|
345 |
|
346 RUBY_DEBUG1( "CTtsCustomCommandParser::DoGetDefaultStyleL: %x", style ); |
|
347 } |
|
348 |
|
349 // ----------------------------------------------------------------------------- |
|
350 // CTtsCustomCommandParser::DoSetSpeakingRateL |
|
351 // Calls the controller plugin to set the speaking rate |
|
352 // ----------------------------------------------------------------------------- |
|
353 // |
|
354 void CTtsCustomCommandParser::DoSetSpeakingRateL( TMMFMessage& aMessage ) |
|
355 { |
|
356 TTtsIntPckg intPckg; |
|
357 |
|
358 aMessage.ReadData1FromClientL( intPckg ); |
|
359 |
|
360 TInt rate = intPckg(); |
|
361 |
|
362 iImplementor.MttscSetSpeakingRateL( rate ); |
|
363 |
|
364 RUBY_DEBUG1( "CTtsCustomCommandParser::DoSetSpeakingRateL: %d", rate ); |
|
365 } |
|
366 |
|
367 // ----------------------------------------------------------------------------- |
|
368 // CTtsCustomCommandParser::DoGetSpeakingRateL |
|
369 // Calls the controller plugin to get the current speaking rate setting |
|
370 // ----------------------------------------------------------------------------- |
|
371 // |
|
372 void CTtsCustomCommandParser::DoGetSpeakingRateL( TMMFMessage& aMessage ) |
|
373 { |
|
374 TTtsIntPtrPckg intPtrPckg; |
|
375 |
|
376 aMessage.ReadData1FromClientL( intPtrPckg ); |
|
377 |
|
378 TInt* rate = intPtrPckg(); |
|
379 |
|
380 *rate = iImplementor.MttscSpeakingRateL(); |
|
381 |
|
382 RUBY_DEBUG1( "CTtsCustomCommandParser::DoGetSpeakingRateL: %d", *rate ); |
|
383 } |
|
384 |
|
385 // ----------------------------------------------------------------------------- |
|
386 // CTtsCustomCommandParser::DoGetSupportedLanguagesL |
|
387 // Calls the controller plugin to get the supported languages |
|
388 // ----------------------------------------------------------------------------- |
|
389 // |
|
390 void CTtsCustomCommandParser::DoGetSupportedLanguagesL( TMMFMessage& aMessage ) |
|
391 { |
|
392 TTtsRArrayLanguagePtrPckg rArrayLanguagePtrPckg; |
|
393 |
|
394 aMessage.ReadData1FromClientL( rArrayLanguagePtrPckg ); |
|
395 |
|
396 RArray<TLanguage> languages = *rArrayLanguagePtrPckg(); |
|
397 |
|
398 RArray<TLanguage> tmp; |
|
399 CleanupClosePushL( tmp ); |
|
400 |
|
401 iImplementor.MttscGetSupportedLanguagesL( tmp ); |
|
402 |
|
403 if ( languages.Count() == tmp.Count() ) |
|
404 { |
|
405 for ( TInt i( 0 ); i < languages.Count(); i++ ) |
|
406 { |
|
407 languages[i] = tmp[i]; |
|
408 } |
|
409 } |
|
410 CleanupStack::PopAndDestroy( &tmp ); |
|
411 |
|
412 RUBY_DEBUG1( "CTtsCustomCommandParser::DoGetSupportedLanguagesL: Number of languages %d", |
|
413 languages.Count() ); |
|
414 } |
|
415 |
|
416 // ----------------------------------------------------------------------------- |
|
417 // CTtsCustomCommandParser::DoGetSupportedLanguagesCountL |
|
418 // Calls the controller plugin to get the number of supported languages |
|
419 // ----------------------------------------------------------------------------- |
|
420 // |
|
421 void CTtsCustomCommandParser::DoGetSupportedLanguagesCountL( TMMFMessage& aMessage ) |
|
422 { |
|
423 TTtsIntPtrPckg intPtrPckg; |
|
424 |
|
425 aMessage.ReadData1FromClientL( intPtrPckg ); |
|
426 |
|
427 TInt* languageCount = intPtrPckg(); |
|
428 |
|
429 RArray<TLanguage> languages; |
|
430 iImplementor.MttscGetSupportedLanguagesL( languages ); |
|
431 *languageCount = languages.Count(); |
|
432 |
|
433 languages.Close(); |
|
434 } |
|
435 |
|
436 // ----------------------------------------------------------------------------- |
|
437 // CTtsCustomCommandParser::DoGetSupportedVoicesL |
|
438 // Calls the controller plugin to get the voices of specified language |
|
439 // ----------------------------------------------------------------------------- |
|
440 // |
|
441 void CTtsCustomCommandParser::DoGetSupportedVoicesL( TMMFMessage& aMessage ) |
|
442 { |
|
443 TTtsLanguagePckg languagePckg; |
|
444 TTtsRArrayTtsStylePtrPckg rArrayTtsStylePtrPckg; |
|
445 |
|
446 aMessage.ReadData1FromClientL( languagePckg ); |
|
447 aMessage.ReadData2FromClientL( rArrayTtsStylePtrPckg ); |
|
448 |
|
449 TLanguage language = languagePckg(); |
|
450 RArray<TTtsStyle> voices = *rArrayTtsStylePtrPckg(); |
|
451 |
|
452 RArray<TTtsStyle> tmp; |
|
453 CleanupClosePushL( tmp ); |
|
454 |
|
455 iImplementor.MttscGetSupportedVoicesL( language, tmp ); |
|
456 |
|
457 if ( voices.Count() == tmp.Count() ) |
|
458 { |
|
459 for ( TInt i( 0 ); i < voices.Count(); i++ ) |
|
460 { |
|
461 voices[i] = tmp[i]; |
|
462 } |
|
463 } |
|
464 CleanupStack::PopAndDestroy( &tmp ); |
|
465 |
|
466 RUBY_DEBUG2( "CTtsCustomCommandParser::DoGetSupportedVoicesL: %d voices for language %d", |
|
467 voices.Count(), (TInt)language ); |
|
468 } |
|
469 |
|
470 // ----------------------------------------------------------------------------- |
|
471 // CTtsCustomCommandParser::DoGetSupportedVoicesCountL |
|
472 // Calls the controller plugin to get the number of voices of specified language |
|
473 // ----------------------------------------------------------------------------- |
|
474 // |
|
475 void CTtsCustomCommandParser::DoGetSupportedVoicesCountL( TMMFMessage& aMessage ) |
|
476 { |
|
477 TTtsLanguagePckg languagePckg; |
|
478 TTtsIntPtrPckg intPtrPckg; |
|
479 |
|
480 aMessage.ReadData1FromClientL( languagePckg ); |
|
481 aMessage.ReadData2FromClientL( intPtrPckg ); |
|
482 |
|
483 TLanguage language = languagePckg(); |
|
484 TInt* voiceCount = intPtrPckg(); |
|
485 |
|
486 RArray<TTtsStyle> voices; |
|
487 iImplementor.MttscGetSupportedVoicesL( language, voices ); |
|
488 *voiceCount = voices.Count(); |
|
489 |
|
490 voices.Close(); |
|
491 } |
|
492 // End of File |