|
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: This is the common header file for the speaker independent |
|
15 * controller. It is used by both the client & server side. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef NSSSISPEECHRECOGNITIONCUSTOMCOMMANDCOMMON_H |
|
21 #define NSSSISPEECHRECOGNITIONCUSTOMCOMMANDCOMMON_H |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include <nsssispeechrecognitiondataclient.h> |
|
25 #include <nsssispeechrecognitiondatacommon.h> |
|
26 |
|
27 // CONSTANTS |
|
28 // (8CA6 = UID for dependent recognition) |
|
29 const TUid KUidInterfaceSpeakerIndependent = {0x101F8CA7}; |
|
30 |
|
31 const TInt KExpandSize = 5; |
|
32 |
|
33 // Initial assumption for buffer size. If the text is larger, |
|
34 // the buffer is expanded. |
|
35 const TInt KDefaultPhraseLen = 50; |
|
36 // Hard upper limit on number of languages. |
|
37 const TInt KMaxLanguages = 10; |
|
38 // Hard upper limit on number of "segments" in the voice tag text |
|
39 const TInt KMaxPartitionsInText = 5; |
|
40 |
|
41 // FORWARD DECLARATIONS |
|
42 class TSrsRecognize; |
|
43 class TSrsAddPronunciation; |
|
44 class TSrsAddRule; |
|
45 class TSrsRuleValidity; |
|
46 class TSrsGetUtteranceDuration; |
|
47 class TSrsGetUtteranceDuration; |
|
48 class TSrsPlayUtterance; |
|
49 class TSrsAddVoiceTag; |
|
50 class TSrsAddSindeVoiceTag; |
|
51 class TSrsAddRuleVariant; |
|
52 class TSrsAddPronunciationSI; |
|
53 |
|
54 // DATA TYPES |
|
55 |
|
56 // These are the custom commands messages used to communicate with |
|
57 // the server. |
|
58 enum TSrCustomCommandMessages |
|
59 { |
|
60 ESrActivateGrammar, |
|
61 ESrAddPronunciation, |
|
62 ESrAddRule, |
|
63 ESrCancel, |
|
64 ESrCommitTrain, |
|
65 ESrCreateGrammar, |
|
66 ESrCreateLexicon, |
|
67 ESrCreateModelBank, |
|
68 ESrDeactivateGrammar, |
|
69 ESrEndRecSession, |
|
70 ESrGetAllModelIDs, |
|
71 ESrGetAllPronunciationIDs, |
|
72 ESrGetAllRuleIDs, |
|
73 ESrGetAvailableStorage, |
|
74 ESrGetEngineProperties, |
|
75 ESrGetModelCount, |
|
76 ESrGetRuleValidity, |
|
77 ESrUtteranceDuration, |
|
78 ESrLoadGrammar, |
|
79 ESrLoadLexicon, |
|
80 ESrLoadModels, |
|
81 ESrPlayUtterance, |
|
82 ESrRecognize, |
|
83 ESrRecord, |
|
84 ESrRemoveGrammar, |
|
85 ESrRemoveLexicon, |
|
86 ESrRemoveModelBank, |
|
87 ESrRemoveModel, |
|
88 ESrRemovePronunciation, |
|
89 ESrRemoveRule, |
|
90 ESrStartRecSession, |
|
91 ESrTrain, |
|
92 ESrUnloadRule, |
|
93 ESrLoadEngineParameters, |
|
94 ESrGetPronunciationIDArraySize, |
|
95 ESrGetPronunciationIDArrayContents, |
|
96 ESrGetRuleIDArraySize, |
|
97 ESrGetRuleIDArrayContents, |
|
98 ESrGetModelIDArraySize, |
|
99 ESrGetModelIDArrayContents, |
|
100 ESrGetClientResultSetSize, |
|
101 ESrGetClientResultSet, |
|
102 ESrSetClientUid, |
|
103 ESrCommitChanges, |
|
104 ESrGetAllClientGrammarIDs, |
|
105 ESrGetAllClientLexiconIDs, |
|
106 ESrGetAllClientModelBankIDs, |
|
107 ESrGetAllGrammarIDs, |
|
108 ESrGetAllLexiconIDs, |
|
109 ESrGetAllModelBankIDs, |
|
110 ESrGetGrammarIDArraySize, |
|
111 ESrGetGrammarIDArrayContents, |
|
112 ESrGetLexiconIDArraySize, |
|
113 ESrGetLexiconIDArrayContents, |
|
114 ESrGetModelBankIDArraySize, |
|
115 ESrGetModelBankIDArrayContents |
|
116 // SI extensions |
|
117 , |
|
118 ESrAdapt, |
|
119 ESrAddPronunciationSI, |
|
120 ESrAddRuleVariant, |
|
121 ESrAddVoiceTag, |
|
122 ESrAddVoiceTags, |
|
123 ESrCreateRule, |
|
124 ESrEndRecord, |
|
125 ESrRecognizeSI, |
|
126 ESrUnloadGrammar, |
|
127 ESrGetClientResultSetSizeSI, |
|
128 ESrRemoveRules, |
|
129 ESrAddSindeVoiceTag, |
|
130 ESrAddSindeVoiceTags, |
|
131 ESrPreStartSampling |
|
132 }; |
|
133 |
|
134 typedef TPckgBuf<TSrsRecognize> TSrsRecognizePckg; |
|
135 typedef TPckgBuf<TSrsAddPronunciation> TSrsAddPronunciationPckg; |
|
136 typedef TPckgBuf<TSrsAddRule> TSrsAddRulePckg; |
|
137 typedef TPckgBuf<TSrsRuleValidity> TSrsRuleValidityPckg; |
|
138 typedef TPckgBuf<TSrsGetUtteranceDuration> TSrsGetUtteranceDurationPckg; |
|
139 typedef TPckgBuf<TSrsPlayUtterance> TSrsPlayUtterancePckg; |
|
140 |
|
141 typedef TPckgBuf<TInt*> TSrsIntPtrPckg; |
|
142 typedef TPckgBuf<TNSSRecognitionMode> TSrsRecognitionModePckg; |
|
143 typedef TPckgBuf<TTimeIntervalMicroSeconds32> TSrsTimeIntervalMicroSeconds32Pckg; |
|
144 typedef TPckgBuf<TUid> TSrsUidPckg; |
|
145 |
|
146 typedef TPckgBuf<TSIGrammarID > TSrsGrammarIDPckg; |
|
147 typedef TPckgBuf<TSIGrammarID*> TSrsGrammarIDPtrPckg; |
|
148 typedef TPckgBuf<TSILexiconID> TSrsLexiconIDPckg; |
|
149 typedef TPckgBuf<TSILexiconID*> TSrsLexiconIDPtrPckg; |
|
150 typedef TPckgBuf<TSIModelID> TSrsModelIDPckg; |
|
151 typedef TPckgBuf<TSIModelID*> TSrsModelIDPtrPckg; |
|
152 typedef TPckgBuf<TSIModelBankID> TSrsModelBankIDPckg; |
|
153 typedef TPckgBuf<TSIModelBankID*> TSrsModelBankIDPtrPckg; |
|
154 typedef TPckgBuf<TSIPronunciationID> TSrsPronunciationIDPckg; |
|
155 typedef TPckgBuf<TSIRuleID> TSrsRuleIDPckg; |
|
156 typedef TPckgBuf<TSIRuleID*> TSrsRuleIDPtrPckg; |
|
157 |
|
158 typedef TPckgBuf<TSrsAddVoiceTag> TSrsAddVoiceTagPckg; |
|
159 typedef TPckgBuf<TSrsAddSindeVoiceTag> TSrsAddSindeVoiceTagPckg; |
|
160 typedef TPckgBuf<TSrsAddRuleVariant> TSrsAddRuleVariantPckg; |
|
161 typedef TPckgBuf<TSrsAddPronunciationSI> TSrsAddPronunciationSIPckg; |
|
162 |
|
163 // CLASS DECLARATION |
|
164 |
|
165 /** |
|
166 * This is the TSrsRecognize class declaration. |
|
167 * |
|
168 * @lib SpeechRecognitionCustomCommands.lib |
|
169 * @since 2.0 |
|
170 */ |
|
171 #if(0) |
|
172 class TSrsRecognize |
|
173 { |
|
174 public: |
|
175 |
|
176 /** |
|
177 * C++ constructor for this class. |
|
178 * @since 2.0 |
|
179 * @param - |
|
180 * @return - |
|
181 */ |
|
182 TSrsRecognize() {} |
|
183 |
|
184 /** |
|
185 * C++ constructor for this class. |
|
186 * @since 2.0 |
|
187 * @param aClientResultSet Pointer to client result set object. |
|
188 * @return - |
|
189 */ |
|
190 TSrsRecognize(CSDClientResultSet* aClientResultSet) : |
|
191 iClientResultSet(aClientResultSet){} |
|
192 |
|
193 // member variable pointer to result set |
|
194 CSDClientResultSet* iClientResultSet; |
|
195 |
|
196 }; |
|
197 #endif |
|
198 /** |
|
199 * This is the TSrsAddPronunciationSI class declaration. |
|
200 * |
|
201 * @lib SpeechRecognitionCustomCommands.lib |
|
202 * @since 2.0 |
|
203 */ |
|
204 class TSrsAddPronunciation |
|
205 { |
|
206 public: |
|
207 |
|
208 /** |
|
209 * C++ constructor for this class. |
|
210 * @since 2.0 |
|
211 * @param - |
|
212 * @return - |
|
213 */ |
|
214 TSrsAddPronunciation() {} |
|
215 |
|
216 /** |
|
217 * C++ constructor for this class. |
|
218 * @since 2.0 |
|
219 * @param aLexiconID lexicon ID |
|
220 * @param aModelBankID model bank ID |
|
221 * @param aModelID model ID |
|
222 * @param aPronunciationID pronunciation ID |
|
223 * @return - |
|
224 */ |
|
225 TSrsAddPronunciation(TSILexiconID aLexiconID, TSIModelBankID aModelBankID, |
|
226 TSIModelID aModelID, TSIPronunciationID* aPronunciationID) : |
|
227 iLexiconID(aLexiconID), iModelBankID(aModelBankID), |
|
228 iModelID(aModelID), iPronunciationID(aPronunciationID) |
|
229 {} |
|
230 |
|
231 // lexicon ID member variable |
|
232 TSILexiconID iLexiconID; |
|
233 // model bank ID member variable |
|
234 TSIModelBankID iModelBankID; |
|
235 // model ID member variable |
|
236 TSIModelID iModelID; |
|
237 // pronunciation ID pointer member variable |
|
238 TSIPronunciationID* iPronunciationID; |
|
239 }; |
|
240 |
|
241 |
|
242 /** |
|
243 * This is the TSrsAddRule class declaration. |
|
244 * |
|
245 * @lib SpeechRecognitionCustomCommands.lib |
|
246 * @since 2.0 |
|
247 */ |
|
248 class TSrsAddRule |
|
249 { |
|
250 public: |
|
251 /** |
|
252 * C++ constructor for this class. |
|
253 * @since 2.0 |
|
254 * @param - |
|
255 * @return - |
|
256 */ |
|
257 TSrsAddRule() {} |
|
258 |
|
259 /** |
|
260 * C++ constructor for this class. |
|
261 * @since 2.0 |
|
262 * @param aGrammarID grammar ID |
|
263 * @param aLexiconID lexicon ID |
|
264 * @param aPronunciationID pronunciation ID |
|
265 * @param aRuleID rule ID |
|
266 * @return - |
|
267 */ |
|
268 TSrsAddRule(TSIGrammarID aGrammarID, TSILexiconID aLexiconID, |
|
269 TSIPronunciationID aPronunciationID, TSIRuleID* aRuleID) : |
|
270 iGrammarID(aGrammarID), iLexiconID(aLexiconID), |
|
271 iPronunciationID(aPronunciationID), iRuleID(aRuleID) {} |
|
272 |
|
273 // grammar ID member variable |
|
274 TSIGrammarID iGrammarID; |
|
275 // lexicon ID member variable |
|
276 TSILexiconID iLexiconID; |
|
277 // pronunciation ID member variable |
|
278 TSIPronunciationID iPronunciationID; |
|
279 // rule ID pointer member variable |
|
280 TSIRuleID* iRuleID; |
|
281 |
|
282 }; |
|
283 |
|
284 |
|
285 /** |
|
286 * This is the TSrsRuleValidity class declaration. |
|
287 * |
|
288 * @lib SpeechRecognitionCustomCommands.lib |
|
289 * @since 2.0 |
|
290 */ |
|
291 class TSrsRuleValidity |
|
292 { |
|
293 public: |
|
294 /** |
|
295 * C++ constructor for this class. |
|
296 * @since 2.0 |
|
297 * @param - |
|
298 * @return - |
|
299 */ |
|
300 TSrsRuleValidity() {} |
|
301 |
|
302 /** |
|
303 * C++ constructor for this class. |
|
304 * @since 2.0 |
|
305 * @param aGrammarID grammar ID |
|
306 * @param aRuleID rule ID |
|
307 & @param aRuldValid indicates if the rule is valid |
|
308 * @return - |
|
309 */ |
|
310 TSrsRuleValidity(TSIGrammarID aGrammarID, TSIRuleID aRuleID, TBool* aRuleValid) : |
|
311 iGrammarID(aGrammarID), iRuleID(aRuleID), iRuleValid(aRuleValid) {} |
|
312 |
|
313 // grammar ID member variable |
|
314 TSIGrammarID iGrammarID; |
|
315 // rule ID pointer member variable |
|
316 TSIRuleID iRuleID; |
|
317 // rule valid member variable |
|
318 TBool* iRuleValid; |
|
319 }; |
|
320 |
|
321 /** |
|
322 * This is the TSrsGetUtteranceDuration class declaration. |
|
323 * |
|
324 * @lib SpeechRecognitionCustomCommands.lib |
|
325 * @since 2.0 |
|
326 */ |
|
327 class TSrsGetUtteranceDuration |
|
328 { |
|
329 public: |
|
330 /** |
|
331 * C++ constructor for this class. |
|
332 * @since 2.0 |
|
333 * @param - |
|
334 * @return - |
|
335 */ |
|
336 TSrsGetUtteranceDuration() {} |
|
337 |
|
338 /** |
|
339 * C++ constructor for this class. |
|
340 * @since 2.0 |
|
341 * @param aModelBankID model bank ID |
|
342 * @param aModelID model ID |
|
343 * @return - |
|
344 */ |
|
345 TSrsGetUtteranceDuration(TSIModelBankID aModelBankID, TSIModelID aModelID, |
|
346 TTimeIntervalMicroSeconds32* aDuration) : |
|
347 iModelBankID(aModelBankID), iModelID(aModelID), |
|
348 iDuration(aDuration) {} |
|
349 |
|
350 // model bank ID member variable |
|
351 TSIModelBankID iModelBankID; |
|
352 // model ID member variable |
|
353 TSIModelID iModelID; |
|
354 // utterance duration |
|
355 TTimeIntervalMicroSeconds32* iDuration; |
|
356 }; |
|
357 |
|
358 /** |
|
359 * This is the TSrsPlayUtterance class declaration. |
|
360 * |
|
361 * @lib SpeechRecognitionCustomCommands.lib |
|
362 * @since 2.0 |
|
363 */ |
|
364 class TSrsPlayUtterance |
|
365 { |
|
366 public: |
|
367 /** |
|
368 * C++ constructor for this class. |
|
369 * @since 2.0 |
|
370 * @param - |
|
371 * @return - |
|
372 */ |
|
373 TSrsPlayUtterance() {} |
|
374 |
|
375 /** |
|
376 * C++ constructor for this class. |
|
377 * @since 2.0 |
|
378 * @param aModelBankID model bank ID |
|
379 * @param aModelID model ID |
|
380 * @return - |
|
381 */ |
|
382 TSrsPlayUtterance(TSIModelBankID aModelBankID, TSIModelID aModelID) : |
|
383 iModelBankID(aModelBankID), iModelID(aModelID) {} |
|
384 |
|
385 // model bank ID member variable |
|
386 TSIModelBankID iModelBankID; |
|
387 // model ID member variable |
|
388 TSIModelID iModelID; |
|
389 }; |
|
390 |
|
391 /** |
|
392 * This class is used to moves data required by AddPronunciation method |
|
393 * over the MMF client-server barrier. |
|
394 * |
|
395 * @lib SpekaerIndependentCustomCommands.lib |
|
396 * @since 2.8 |
|
397 */ |
|
398 class TSrsAddPronunciationSI |
|
399 { |
|
400 public: |
|
401 /** |
|
402 * C++ constructor for this class. |
|
403 * @since 2.8 |
|
404 * @param - |
|
405 * @return - |
|
406 */ |
|
407 TSrsAddPronunciationSI() {} |
|
408 |
|
409 /** |
|
410 * C++ constructor for this class. |
|
411 * @since 2.8 |
|
412 * @param aLexiconID Lexicon identifier |
|
413 * @param aTextLength Length of the text to be trained. |
|
414 * @param aLanguage Pronunciation language |
|
415 * @param aPronunciation New pronunciation identifier |
|
416 * will be assigned to this variable. |
|
417 * @return - |
|
418 */ |
|
419 |
|
420 TSrsAddPronunciationSI( |
|
421 TSILexiconID aLexiconID, |
|
422 TInt aTextLength, |
|
423 TLanguage aLanguage, |
|
424 TSIPronunciationID& aPronunciationID ) |
|
425 { |
|
426 iLexiconID = aLexiconID; |
|
427 iLanguage = aLanguage; |
|
428 iPronunciationIDPtr = &aPronunciationID; |
|
429 iTextLength = aTextLength; |
|
430 } |
|
431 |
|
432 TSILexiconID iLexiconID; |
|
433 TLanguage iLanguage; |
|
434 TInt iTextLength; |
|
435 TSIPronunciationID *iPronunciationIDPtr; |
|
436 }; |
|
437 |
|
438 |
|
439 /** |
|
440 * This class is used to moves data required by AddRuleVariant method |
|
441 * over the MMF client-server barrier. |
|
442 * |
|
443 * @lib SpekaerIndependentCustomCommands.lib |
|
444 * @since 2.8 |
|
445 */ |
|
446 class TSrsAddRuleVariant |
|
447 { |
|
448 public: |
|
449 /** |
|
450 * C++ constructor for this class. |
|
451 * @since 2.8 |
|
452 * @param - |
|
453 * @return - |
|
454 */ |
|
455 TSrsAddRuleVariant() {} |
|
456 |
|
457 /** |
|
458 * C++ constructor for this class. |
|
459 * @since 2.8 |
|
460 * @param aLexiconID Lexicon identifier |
|
461 * @param aTrainText Text to be trained. LESS THAN KMaxPhraseLen CHARACTERS. |
|
462 * @param aLanguage Pronunciation language |
|
463 * @param aPronunciation New pronunciation identifier |
|
464 * will be assigned to this variable. |
|
465 * @return - |
|
466 */ |
|
467 |
|
468 TSrsAddRuleVariant( |
|
469 TSIGrammarID aGrammarID, |
|
470 TSILexiconID aLexiconID, |
|
471 TInt aPronunIDCount, |
|
472 TSIRuleID aRuleID, |
|
473 TSIRuleVariantID* aRuleVariantID |
|
474 ) : |
|
475 iGrammarID( aGrammarID ), |
|
476 iLexiconID( aLexiconID ), |
|
477 iPronunIDCount( aPronunIDCount ), |
|
478 iRuleID( aRuleID ), |
|
479 iRuleVariantID( aRuleVariantID ) |
|
480 { |
|
481 // Nothing |
|
482 } |
|
483 |
|
484 TSIGrammarID iGrammarID; |
|
485 TSILexiconID iLexiconID; |
|
486 TInt iPronunIDCount; |
|
487 TSIRuleID iRuleID; |
|
488 TSIRuleVariantID* iRuleVariantID; |
|
489 }; |
|
490 |
|
491 /** |
|
492 * This class is used to moves data required by AddVoiceTags method |
|
493 * over the MMF client-server barrier. |
|
494 * |
|
495 * @lib NssSpeakerIndependentCustomCommands.lib |
|
496 * @since 2.8 |
|
497 */ |
|
498 class TSrsAddVoiceTag |
|
499 { |
|
500 public: |
|
501 /** |
|
502 * C++ constructor for this class. |
|
503 * @since 2.8 |
|
504 */ |
|
505 TSrsAddVoiceTag() {} |
|
506 |
|
507 /** |
|
508 * C++ constructor for this class. |
|
509 * @since 2.8 |
|
510 * |
|
511 * @param aLexiconID Lexicon identifier |
|
512 * @param aGrammarID Grammar identifier |
|
513 * @param aRuleID |
|
514 * @param aLanguageTable Pronunciation languages |
|
515 */ |
|
516 TSrsAddVoiceTag( TSILexiconID aLexiconID, |
|
517 TSIGrammarID aGrammarID, |
|
518 TSIRuleID* aRuleID, |
|
519 const RArray<TLanguage>& aLanguageTable ) : |
|
520 iLexiconID( aLexiconID ), |
|
521 iGrammarID( aGrammarID ), |
|
522 iRuleID( aRuleID ) |
|
523 { |
|
524 TInt languageCount = 0; |
|
525 |
|
526 if ( &aLanguageTable != NULL ) |
|
527 { |
|
528 languageCount = aLanguageTable.Count(); |
|
529 } |
|
530 |
|
531 for ( TInt k = 0; k < KMaxLanguages; k++ ) |
|
532 { |
|
533 if ( k < languageCount ) |
|
534 { |
|
535 // If aLanguageTable == NULL, languageCount == 0 and |
|
536 // this is never called. |
|
537 iLanguages[ k ] = aLanguageTable[ k ]; |
|
538 } |
|
539 else |
|
540 { |
|
541 iLanguages[ k ] = ELangNone; |
|
542 } |
|
543 } |
|
544 } |
|
545 |
|
546 /** |
|
547 * Returns a copy of language ids in RArray |
|
548 * |
|
549 * @since 2.8 |
|
550 * @param aLangArray Array which is filled |
|
551 */ |
|
552 void ListLanguagesL( RArray<TLanguage>& aLangArray ) |
|
553 { |
|
554 for ( TInt k = 0; iLanguages[ k ] != ELangNone; k++ ) |
|
555 { |
|
556 User::LeaveIfError( aLangArray.Append( iLanguages[ k ] ) ); |
|
557 } |
|
558 } |
|
559 |
|
560 TSILexiconID iLexiconID; |
|
561 TSIGrammarID iGrammarID; |
|
562 TSIRuleID* iRuleID; |
|
563 TLanguage iLanguages[ KMaxLanguages ]; |
|
564 }; |
|
565 |
|
566 /** |
|
567 * This class is used to moves data required by AddSindeVoiceTags method |
|
568 * over the MMF client-server barrier. |
|
569 * |
|
570 * @lib NssSpeakerIndependentCustomCommands.lib |
|
571 * @since 3.1 |
|
572 */ |
|
573 class TSrsAddSindeVoiceTag |
|
574 { |
|
575 public: |
|
576 /** |
|
577 * C++ constructor |
|
578 * @since 3.1 |
|
579 */ |
|
580 TSrsAddSindeVoiceTag() {} |
|
581 |
|
582 /** |
|
583 * C++ constructor. |
|
584 * Makes a copy LanguageArray. |
|
585 * |
|
586 * @since 3.1 |
|
587 * @param aLexiconID Lexicon identifier |
|
588 * @param aGrammarID Grammar identifier |
|
589 * @param aRuleID |
|
590 * @param aLanguageTable Pronunciation languages |
|
591 */ |
|
592 TSrsAddSindeVoiceTag( TSILexiconID aLexiconID, |
|
593 TSIGrammarID aGrammarID, |
|
594 TSIRuleID* aRuleID, |
|
595 const RArray<RLanguageArray>& aLanguageTable ) : |
|
596 iLexiconID( aLexiconID ), |
|
597 iGrammarID( aGrammarID ), |
|
598 iRuleID( aRuleID ) |
|
599 { |
|
600 // Find out how many arrays there are inside the language array |
|
601 TInt languageArrayCount = aLanguageTable.Count(); |
|
602 |
|
603 for ( TInt partsInText = 0; partsInText < KMaxPartitionsInText; partsInText++ ) |
|
604 { |
|
605 RLanguageArray languages; |
|
606 TInt languageCount = 0; |
|
607 if ( partsInText < languageArrayCount ) |
|
608 { |
|
609 languages = aLanguageTable[ partsInText ]; |
|
610 languageCount = languages.Count(); |
|
611 } |
|
612 |
|
613 for ( TInt languageCounter = 0; languageCounter < KMaxLanguages; languageCounter++ ) |
|
614 { |
|
615 if ( languageCounter < languageCount ) |
|
616 { |
|
617 // Store real value |
|
618 iLanguages[ KMaxLanguages * partsInText + languageCounter ] = languages[ languageCounter ]; |
|
619 iGrouping[ KMaxLanguages * partsInText + languageCounter ] = partsInText; |
|
620 } |
|
621 else |
|
622 { |
|
623 // Fill in ELangNone & KErrNotFound to empty spaces |
|
624 iLanguages[ KMaxLanguages * partsInText + languageCounter ] = ELangNone; |
|
625 iGrouping[ KMaxLanguages * partsInText + languageCounter ] = KErrNotFound; |
|
626 } |
|
627 } |
|
628 } |
|
629 } |
|
630 |
|
631 /** |
|
632 * Returns a copy of language ids in RArray<RLanguageArray> |
|
633 * |
|
634 * @since 3.1 |
|
635 * @param aLangArray Array which is filled |
|
636 */ |
|
637 void ListLanguagesL( RArray<RLanguageArray>& aLangArray ) |
|
638 { |
|
639 aLangArray.Reset(); |
|
640 RLanguageArray langArr; |
|
641 CleanupClosePushL( langArr ); |
|
642 TInt previousGroup( KErrNotFound ); |
|
643 for ( TInt k = 0; k < KMaxLanguages * KMaxPartitionsInText; k++ ) |
|
644 { |
|
645 if ( iLanguages[k] != ELangNone ) |
|
646 { |
|
647 if ( ( previousGroup != iGrouping[k] ) && ( previousGroup != KErrNotFound ) ) |
|
648 { |
|
649 User::LeaveIfError( aLangArray.Append( langArr ) ); |
|
650 // Ownership transferred |
|
651 CleanupStack::Pop( &langArr ); |
|
652 // Create new array for next bunch of languages |
|
653 langArr = RLanguageArray(); |
|
654 CleanupClosePushL( langArr ); |
|
655 } |
|
656 User::LeaveIfError( langArr.Append( iLanguages[k] ) ); |
|
657 previousGroup = iGrouping[k]; |
|
658 } |
|
659 } // for |
|
660 // Append the last one if there just is something |
|
661 if ( langArr.Count() > 0 ) |
|
662 { |
|
663 User::LeaveIfError( aLangArray.Append( langArr ) ); |
|
664 } |
|
665 CleanupStack::Pop( &langArr ); |
|
666 } |
|
667 |
|
668 // Lexicon ID |
|
669 TSILexiconID iLexiconID; |
|
670 |
|
671 // Grammar ID |
|
672 TSIGrammarID iGrammarID; |
|
673 |
|
674 // Rule ID pointer, used as a return value to client thread, not owned |
|
675 TSIRuleID* iRuleID; |
|
676 |
|
677 private: |
|
678 // Linear array of language ids |
|
679 TLanguage iLanguages[ KMaxLanguages * KMaxPartitionsInText ]; |
|
680 |
|
681 // Array which maps languages in iLanguages to groups |
|
682 TInt iGrouping[ KMaxLanguages * KMaxPartitionsInText ]; |
|
683 }; |
|
684 |
|
685 #endif // NSSSISPEECHRECOGNITIONCUSTOMCOMMANDCOMMON_H |
|
686 |
|
687 // End of file |