|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 #include <mmf/common/speechrecognitioncustomcommandparser.h> |
|
18 #include "SpeechRecognitionCustomCommandCommon.h" |
|
19 |
|
20 const TInt KExpandSize = 10; |
|
21 |
|
22 |
|
23 EXPORT_C CSpeechRecognitionCustomCommandParser* CSpeechRecognitionCustomCommandParser::NewL( |
|
24 MSpeechRecognitionCustomCommandImplementor& aImplementor) |
|
25 { |
|
26 CSpeechRecognitionCustomCommandParser* self = new (ELeave) CSpeechRecognitionCustomCommandParser(aImplementor); |
|
27 return self; |
|
28 } |
|
29 |
|
30 EXPORT_C CSpeechRecognitionCustomCommandParser::~CSpeechRecognitionCustomCommandParser() |
|
31 { |
|
32 iPronunciationIDs.Close(); |
|
33 iRuleIDs.Close(); |
|
34 iModelIDs.Close(); |
|
35 iModelBankIDs.Close(); |
|
36 iGrammarIDs.Close(); |
|
37 iLexiconIDs.Close(); |
|
38 delete iResultSet; |
|
39 delete iResultCopyBuffer; |
|
40 } |
|
41 |
|
42 void CSpeechRecognitionCustomCommandParser::HandleRequest(TMMFMessage& aMessage) |
|
43 { |
|
44 TInt err; |
|
45 if (aMessage.Destination().InterfaceId() == KUidInterfaceSpeechRecognition) |
|
46 { |
|
47 TRAP(err, DoHandleRequestL(aMessage)); |
|
48 aMessage.Complete(err); |
|
49 } |
|
50 else |
|
51 aMessage.Complete(KErrNotSupported); |
|
52 } |
|
53 |
|
54 |
|
55 CSpeechRecognitionCustomCommandParser::CSpeechRecognitionCustomCommandParser(MSpeechRecognitionCustomCommandImplementor& aImplementor) |
|
56 : CMMFCustomCommandParserBase(KUidInterfaceSpeechRecognition), iImplementor(aImplementor) |
|
57 { |
|
58 |
|
59 } |
|
60 |
|
61 void CSpeechRecognitionCustomCommandParser::DoHandleRequestL(TMMFMessage& aMessage) |
|
62 { |
|
63 TPckgBuf<TInt> pckgSize; |
|
64 |
|
65 switch (aMessage.Function()) |
|
66 { |
|
67 case ESrAddPronunciation: |
|
68 DoAddPronunciationL(aMessage); |
|
69 break; |
|
70 case ESrAddRule: |
|
71 DoAddRuleL(aMessage); |
|
72 break; |
|
73 case ESrCancel: |
|
74 DoCancel(); |
|
75 break; |
|
76 case ESrCommitChanges: |
|
77 DoCommitChangesL(); |
|
78 break; |
|
79 case ESrCreateGrammar: |
|
80 DoCreateGrammarL(aMessage); |
|
81 break; |
|
82 case ESrCreateLexicon: |
|
83 DoCreateLexiconL(aMessage); |
|
84 break; |
|
85 case ESrCreateModelBank: |
|
86 DoCreateModelBankL(aMessage); |
|
87 break; |
|
88 case ESrEndRecSession: |
|
89 DoEndRecSessionL(); |
|
90 break; |
|
91 case ESrGetAllModelIDs: |
|
92 DoGetAllModelIDsL(aMessage); |
|
93 break; |
|
94 case ESrGetAllPronunciationIDs: |
|
95 DoGetAllPronunciationIDsL(aMessage); |
|
96 break; |
|
97 case ESrGetAllRuleIDs: |
|
98 DoGetAllRuleIDsL(aMessage); |
|
99 break; |
|
100 case ESrGetAllModelBankIDs: |
|
101 DoGetAllModelBankIDsL(); |
|
102 break; |
|
103 case ESrGetAllLexiconIDs: |
|
104 DoGetAllLexiconIDsL(); |
|
105 break; |
|
106 case ESrGetAllGrammarIDs: |
|
107 DoGetAllGrammarIDsL(); |
|
108 break; |
|
109 case ESrGetAllClientModelBankIDs: |
|
110 DoGetAllClientModelBankIDsL(); |
|
111 break; |
|
112 case ESrGetAllClientLexiconIDs: |
|
113 DoGetAllClientLexiconIDsL(); |
|
114 break; |
|
115 case ESrGetAllClientGrammarIDs: |
|
116 DoGetAllClientGrammarIDsL(); |
|
117 break; |
|
118 case ESrGetAvailableStorage: |
|
119 DoGetAvailableStorageL(aMessage); |
|
120 break; |
|
121 case ESrGetEngineProperties: |
|
122 DoGetEnginePropertiesL(aMessage); |
|
123 break; |
|
124 case ESrGetModelCount: |
|
125 DoGetModelCountL(aMessage); |
|
126 break; |
|
127 case ESrGetRuleValidity: |
|
128 DoGetRuleValidityL(aMessage); |
|
129 break; |
|
130 case ESrUtteranceDuration: |
|
131 DoGetUtteranceDurationL(aMessage); |
|
132 break; |
|
133 case ESrLoadGrammar: |
|
134 DoLoadGrammarL(aMessage); |
|
135 break; |
|
136 case ESrLoadLexicon: |
|
137 DoLoadLexiconL(aMessage); |
|
138 break; |
|
139 case ESrLoadModels: |
|
140 DoLoadModelsL(aMessage); |
|
141 break; |
|
142 case ESrPlayUtterance: |
|
143 DoPlayUtteranceL(aMessage); |
|
144 break; |
|
145 case ESrRecognize: |
|
146 DoRecognizeL(aMessage); |
|
147 break; |
|
148 case ESrRecord: |
|
149 DoRecordL(aMessage); |
|
150 break; |
|
151 case ESrRemoveGrammar: |
|
152 DoRemoveGrammarL(aMessage); |
|
153 break; |
|
154 case ESrRemoveLexicon: |
|
155 DoRemoveLexiconL(aMessage); |
|
156 break; |
|
157 case ESrRemoveModelBank: |
|
158 DoRemoveModelBankL(aMessage); |
|
159 break; |
|
160 case ESrRemoveModel: |
|
161 DoRemoveModelL(aMessage); |
|
162 break; |
|
163 case ESrRemovePronunciation: |
|
164 DoRemovePronunciationL(aMessage); |
|
165 break; |
|
166 case ESrRemoveRule: |
|
167 DoRemoveRuleL(aMessage); |
|
168 break; |
|
169 case ESrStartRecSession: |
|
170 DoStartRecSessionL(aMessage); |
|
171 break; |
|
172 case ESrTrain: |
|
173 DoTrainL(aMessage); |
|
174 break; |
|
175 case ESrUnloadRule: |
|
176 DoUnloadRuleL(aMessage); |
|
177 break; |
|
178 case ESrLoadEngineParameters: |
|
179 DoLoadEngineParametersL(aMessage); |
|
180 break; |
|
181 case ESrGetPronunciationIDArraySize: |
|
182 pckgSize() = iPronunciationIDs.Count(); |
|
183 aMessage.WriteDataToClientL(pckgSize); |
|
184 break; |
|
185 case ESrGetPronunciationIDArrayContents: |
|
186 DoCopyPronunciationIDArrayL(aMessage); |
|
187 break; |
|
188 case ESrGetRuleIDArraySize: |
|
189 pckgSize() = iRuleIDs.Count(); |
|
190 aMessage.WriteDataToClientL(pckgSize); |
|
191 break; |
|
192 case ESrGetRuleIDArrayContents: |
|
193 DoCopyRuleIDArrayL(aMessage); |
|
194 break; |
|
195 case ESrGetModelIDArraySize: |
|
196 pckgSize() = iModelIDs.Count(); |
|
197 aMessage.WriteDataToClientL(pckgSize); |
|
198 break; |
|
199 case ESrGetModelIDArrayContents: |
|
200 DoCopyModelIDArrayL(aMessage); |
|
201 break; |
|
202 case ESrGetLexiconIDArraySize: |
|
203 pckgSize() = iLexiconIDs.Count(); |
|
204 aMessage.WriteDataToClientL(pckgSize); |
|
205 break; |
|
206 case ESrGetLexiconIDArrayContents: |
|
207 DoCopyLexiconIDArrayL(aMessage); |
|
208 break; |
|
209 case ESrGetGrammarIDArraySize: |
|
210 pckgSize() = iGrammarIDs.Count(); |
|
211 aMessage.WriteDataToClientL(pckgSize); |
|
212 break; |
|
213 case ESrGetGrammarIDArrayContents: |
|
214 DoCopyGrammarIDArrayL(aMessage); |
|
215 break; |
|
216 case ESrGetModelBankIDArraySize: |
|
217 pckgSize() = iModelBankIDs.Count(); |
|
218 aMessage.WriteDataToClientL(pckgSize); |
|
219 break; |
|
220 case ESrGetModelBankIDArrayContents: |
|
221 DoCopyModelBankIDArrayL(aMessage); |
|
222 break; |
|
223 case ESrGetClientResultSetSize: |
|
224 DoExternalizeResultSetL(); |
|
225 pckgSize() = iResultCopyBuffer->Size(); |
|
226 aMessage.WriteDataToClientL(pckgSize); |
|
227 break; |
|
228 case ESrGetClientResultSet: |
|
229 DoCopyResultSetL(aMessage); |
|
230 break; |
|
231 case ESrSetClientUid: |
|
232 DoSetClientUidL(aMessage); |
|
233 break; |
|
234 default: |
|
235 User::Leave(KErrNotSupported); |
|
236 break; |
|
237 } |
|
238 } |
|
239 |
|
240 void CSpeechRecognitionCustomCommandParser::DoAddPronunciationL(TMMFMessage& aMessage) |
|
241 { |
|
242 TSrsAddPronunciationPckg pckg; |
|
243 aMessage.ReadData1FromClientL(pckg); |
|
244 iImplementor.MSrAddPronunciationL(pckg().iLexiconID, pckg().iModelBankID, pckg().iModelID, *pckg().iPronunciationID); |
|
245 } |
|
246 |
|
247 void CSpeechRecognitionCustomCommandParser::DoAddRuleL(TMMFMessage& aMessage) |
|
248 { |
|
249 TSrsAddRulePckg pckg; |
|
250 aMessage.ReadData1FromClientL(pckg); |
|
251 iImplementor.MSrAddRuleL(pckg().iGrammarID, pckg().iLexiconID, pckg().iPronunciationID, *pckg().iRuleID); |
|
252 } |
|
253 |
|
254 void CSpeechRecognitionCustomCommandParser::DoCancel() |
|
255 { |
|
256 iImplementor.MSrCancel(); |
|
257 } |
|
258 |
|
259 void CSpeechRecognitionCustomCommandParser::DoCommitChangesL() |
|
260 { |
|
261 iImplementor.MSrCommitChangesL(); |
|
262 } |
|
263 |
|
264 void CSpeechRecognitionCustomCommandParser::DoCreateGrammarL(TMMFMessage& aMessage) |
|
265 { |
|
266 TSrsGrammarIDPtrPckg pckg; |
|
267 aMessage.ReadData1FromClientL(pckg); |
|
268 iImplementor.MSrCreateGrammarL(*pckg()); |
|
269 } |
|
270 |
|
271 void CSpeechRecognitionCustomCommandParser::DoCreateLexiconL(TMMFMessage& aMessage) |
|
272 { |
|
273 TSrsLexiconIDPtrPckg pckg; |
|
274 aMessage.ReadData1FromClientL(pckg); |
|
275 iImplementor.MSrCreateLexiconL(*pckg()); |
|
276 } |
|
277 |
|
278 void CSpeechRecognitionCustomCommandParser::DoCreateModelBankL(TMMFMessage& aMessage) |
|
279 { |
|
280 TSrsModelBankIDPtrPckg pckg; |
|
281 aMessage.ReadData1FromClientL(pckg); |
|
282 iImplementor.MSrCreateModelBankL(*pckg()); |
|
283 } |
|
284 |
|
285 void CSpeechRecognitionCustomCommandParser::DoEndRecSessionL() |
|
286 { |
|
287 iImplementor.MSrEndRecSessionL(); |
|
288 } |
|
289 |
|
290 void CSpeechRecognitionCustomCommandParser::DoGetAllModelIDsL(TMMFMessage& aMessage) |
|
291 { |
|
292 TSrsModelBankIDPckg pckgModelBank; |
|
293 iModelIDs.Reset(); |
|
294 aMessage.ReadData1FromClientL(pckgModelBank); |
|
295 iImplementor.MSrGetAllModelIDsL(pckgModelBank(), iModelIDs); |
|
296 } |
|
297 |
|
298 void CSpeechRecognitionCustomCommandParser::DoGetAllPronunciationIDsL(TMMFMessage& aMessage) |
|
299 { |
|
300 TSrsLexiconIDPckg pckgLexicon; |
|
301 iPronunciationIDs.Reset(); |
|
302 aMessage.ReadData1FromClientL(pckgLexicon); |
|
303 iImplementor.MSrGetAllPronunciationIDsL(pckgLexicon(), iPronunciationIDs); |
|
304 } |
|
305 |
|
306 void CSpeechRecognitionCustomCommandParser::DoGetAllRuleIDsL(TMMFMessage& aMessage) |
|
307 { |
|
308 TSrsGrammarIDPckg pckgGrammar; |
|
309 iRuleIDs.Reset(); |
|
310 aMessage.ReadData1FromClientL(pckgGrammar); |
|
311 iImplementor.MSrGetAllRuleIDsL(pckgGrammar(), iRuleIDs); |
|
312 } |
|
313 |
|
314 void CSpeechRecognitionCustomCommandParser::DoGetAllModelBankIDsL() |
|
315 { |
|
316 iModelBankIDs.Reset(); |
|
317 iImplementor.MSrGetAllModelBankIDsL(iModelBankIDs); |
|
318 } |
|
319 |
|
320 void CSpeechRecognitionCustomCommandParser::DoGetAllLexiconIDsL() |
|
321 { |
|
322 iLexiconIDs.Reset(); |
|
323 iImplementor.MSrGetAllLexiconIDsL(iLexiconIDs); |
|
324 } |
|
325 |
|
326 void CSpeechRecognitionCustomCommandParser::DoGetAllGrammarIDsL() |
|
327 { |
|
328 iGrammarIDs.Reset(); |
|
329 iImplementor.MSrGetAllGrammarIDsL(iGrammarIDs); |
|
330 } |
|
331 |
|
332 |
|
333 void CSpeechRecognitionCustomCommandParser::DoGetAllClientModelBankIDsL() |
|
334 { |
|
335 iModelBankIDs.Reset(); |
|
336 iImplementor.MSrGetAllClientModelBankIDsL(iModelBankIDs); |
|
337 } |
|
338 |
|
339 void CSpeechRecognitionCustomCommandParser::DoGetAllClientLexiconIDsL() |
|
340 { |
|
341 iLexiconIDs.Reset(); |
|
342 iImplementor.MSrGetAllClientLexiconIDsL(iLexiconIDs); |
|
343 } |
|
344 |
|
345 void CSpeechRecognitionCustomCommandParser::DoGetAllClientGrammarIDsL() |
|
346 { |
|
347 iGrammarIDs.Reset(); |
|
348 iImplementor.MSrGetAllClientGrammarIDsL(iGrammarIDs); |
|
349 } |
|
350 |
|
351 |
|
352 void CSpeechRecognitionCustomCommandParser::DoGetAvailableStorageL(TMMFMessage& aMessage) |
|
353 { |
|
354 TSrsIntPtrPckg pckg; |
|
355 aMessage.ReadData1FromClientL(pckg); |
|
356 iImplementor.MSrGetAvailableStorageL(*pckg()); |
|
357 } |
|
358 |
|
359 |
|
360 void CSpeechRecognitionCustomCommandParser::DoGetModelCountL(TMMFMessage& aMessage) |
|
361 { |
|
362 TSrsModelBankIDPckg pckgModelBank; |
|
363 TSrsIntPtrPckg pckgResult; |
|
364 aMessage.ReadData1FromClientL(pckgModelBank); |
|
365 aMessage.ReadData2FromClientL(pckgResult); |
|
366 iImplementor.MSrGetModelCountL(pckgModelBank(),*pckgResult()); |
|
367 } |
|
368 |
|
369 void CSpeechRecognitionCustomCommandParser::DoGetRuleValidityL(TMMFMessage& aMessage) |
|
370 { |
|
371 TSrsRuleValidityPckg pckg; |
|
372 aMessage.ReadData1FromClientL(pckg); |
|
373 iImplementor.MSrGetRuleValidityL(pckg().iGrammarID, pckg().iRuleID, *pckg().iRuleValid); |
|
374 } |
|
375 |
|
376 void CSpeechRecognitionCustomCommandParser::DoGetUtteranceDurationL(TMMFMessage& aMessage) |
|
377 { |
|
378 TSrsGetUtteranceDurationPckg pckg; |
|
379 aMessage.ReadData1FromClientL(pckg); |
|
380 iImplementor.MSrGetUtteranceDurationL(pckg().iModelBankID, pckg().iModelID, *pckg().iDuration); |
|
381 } |
|
382 |
|
383 void CSpeechRecognitionCustomCommandParser::DoLoadGrammarL(TMMFMessage& aMessage) |
|
384 { |
|
385 TSrsGrammarIDPckg pckg; |
|
386 aMessage.ReadData1FromClientL(pckg); |
|
387 iImplementor.MSrLoadGrammarL(pckg()); |
|
388 } |
|
389 |
|
390 void CSpeechRecognitionCustomCommandParser::DoLoadLexiconL(TMMFMessage& aMessage) |
|
391 { |
|
392 TSrsLexiconIDPckg pckg; |
|
393 aMessage.ReadData1FromClientL(pckg); |
|
394 iImplementor.MSrLoadLexiconL(pckg()); |
|
395 } |
|
396 |
|
397 void CSpeechRecognitionCustomCommandParser::DoLoadModelsL(TMMFMessage& aMessage) |
|
398 { |
|
399 TSrsModelBankIDPckg pckg; |
|
400 aMessage.ReadData1FromClientL(pckg); |
|
401 iImplementor.MSrLoadModelsL(pckg()); |
|
402 } |
|
403 |
|
404 void CSpeechRecognitionCustomCommandParser::DoPlayUtteranceL(TMMFMessage& aMessage) |
|
405 { |
|
406 TSrsPlayUtterancePckg pckg; |
|
407 aMessage.ReadData1FromClientL(pckg); |
|
408 iImplementor.MSrPlayUtteranceL(pckg().iModelBankID, pckg().iModelID); |
|
409 } |
|
410 |
|
411 void CSpeechRecognitionCustomCommandParser::DoSetClientUidL(TMMFMessage& aMessage) |
|
412 { |
|
413 TSrsUidPckg pckg; |
|
414 aMessage.ReadData1FromClientL(pckg); |
|
415 iImplementor.MSrSetClientUid(pckg()); |
|
416 } |
|
417 |
|
418 |
|
419 void CSpeechRecognitionCustomCommandParser::DoRecognizeL(TMMFMessage& aMessage) |
|
420 { |
|
421 if (iResultSet) |
|
422 User::Leave(KErrInUse); |
|
423 |
|
424 TInt size; |
|
425 size = User::LeaveIfError(aMessage.SizeOfData1FromClient()); |
|
426 HBufC8* dataBuffer = HBufC8::NewLC(size); |
|
427 TPtr8 buf = dataBuffer->Des(); |
|
428 aMessage.ReadData1FromClientL(buf); |
|
429 RDesReadStream stream(buf); |
|
430 CleanupClosePushL(stream); |
|
431 iResultSet = CSDClientResultSet::NewL(); |
|
432 TInt err = KErrNone; |
|
433 TRAP(err, iResultSet->InternalizeL(stream)); |
|
434 if (err == KErrNone) |
|
435 { |
|
436 TRAP(err, iImplementor.MSrRecognizeL(*iResultSet)); |
|
437 } |
|
438 if (err!=KErrNone) |
|
439 { |
|
440 delete iResultSet; |
|
441 iResultSet = NULL; |
|
442 User::Leave(err); |
|
443 } |
|
444 CleanupStack::PopAndDestroy(2, dataBuffer);//dataBuffer, stream |
|
445 } |
|
446 |
|
447 void CSpeechRecognitionCustomCommandParser::DoRecordL(TMMFMessage& aMessage) |
|
448 { |
|
449 TSrsTimeIntervalMicroSeconds32Pckg pckg; |
|
450 aMessage.ReadData1FromClientL(pckg); |
|
451 iImplementor.MSrRecordL(pckg()); |
|
452 } |
|
453 |
|
454 void CSpeechRecognitionCustomCommandParser::DoRemoveGrammarL(TMMFMessage& aMessage) |
|
455 { |
|
456 TSrsGrammarIDPckg pckg; |
|
457 aMessage.ReadData1FromClientL(pckg); |
|
458 iImplementor.MSrRemoveGrammarL(pckg()); |
|
459 } |
|
460 |
|
461 void CSpeechRecognitionCustomCommandParser::DoRemoveLexiconL(TMMFMessage& aMessage) |
|
462 { |
|
463 TSrsLexiconIDPckg pckg; |
|
464 aMessage.ReadData1FromClientL(pckg); |
|
465 iImplementor.MSrRemoveLexiconL(pckg()); |
|
466 } |
|
467 |
|
468 void CSpeechRecognitionCustomCommandParser::DoRemoveModelBankL(TMMFMessage& aMessage) |
|
469 { |
|
470 TSrsModelBankIDPckg pckg; |
|
471 aMessage.ReadData1FromClientL(pckg); |
|
472 iImplementor.MSrRemoveModelBankL(pckg()); |
|
473 } |
|
474 |
|
475 void CSpeechRecognitionCustomCommandParser::DoRemoveModelL(TMMFMessage& aMessage) |
|
476 { |
|
477 TSrsModelBankIDPckg pckgModelBankID; |
|
478 TSrsModelIDPckg pckgModelID; |
|
479 aMessage.ReadData1FromClientL(pckgModelBankID); |
|
480 aMessage.ReadData2FromClientL(pckgModelID); |
|
481 iImplementor.MSrRemoveModelL(pckgModelBankID(), pckgModelID()); |
|
482 } |
|
483 |
|
484 void CSpeechRecognitionCustomCommandParser::DoRemovePronunciationL(TMMFMessage& aMessage) |
|
485 { |
|
486 TSrsLexiconIDPckg pckgLexicon; |
|
487 TSrsPronunciationIDPckg pckgPronunciation; |
|
488 aMessage.ReadData1FromClientL(pckgLexicon); |
|
489 aMessage.ReadData2FromClientL(pckgPronunciation); |
|
490 iImplementor.MSrRemovePronunciationL(pckgLexicon(), pckgPronunciation()); |
|
491 } |
|
492 |
|
493 void CSpeechRecognitionCustomCommandParser::DoRemoveRuleL(TMMFMessage& aMessage) |
|
494 { |
|
495 TSrsGrammarIDPckg pckgGrammar; |
|
496 TSrsRuleIDPckg pckgRule; |
|
497 aMessage.ReadData1FromClientL(pckgGrammar); |
|
498 aMessage.ReadData2FromClientL(pckgRule); |
|
499 iImplementor.MSrRemoveRuleL(pckgGrammar(), pckgRule()); |
|
500 } |
|
501 |
|
502 void CSpeechRecognitionCustomCommandParser::DoStartRecSessionL(TMMFMessage& aMessage) |
|
503 { |
|
504 TSrsRecognitionModePckg pckg; |
|
505 aMessage.ReadData1FromClientL(pckg); |
|
506 iImplementor.MSrStartRecSessionL(pckg()); |
|
507 } |
|
508 |
|
509 void CSpeechRecognitionCustomCommandParser::DoTrainL(TMMFMessage& aMessage) |
|
510 { |
|
511 TSrsModelBankIDPckg pckgModelBankID; |
|
512 TSrsModelIDPtrPckg pckgModelIDPtr; |
|
513 aMessage.ReadData1FromClientL(pckgModelBankID); |
|
514 aMessage.ReadData2FromClientL(pckgModelIDPtr); |
|
515 iImplementor.MSrTrainL(pckgModelBankID(),*pckgModelIDPtr()); |
|
516 } |
|
517 |
|
518 void CSpeechRecognitionCustomCommandParser::DoUnloadRuleL(TMMFMessage& aMessage) |
|
519 { |
|
520 TSrsGrammarIDPckg pckgGrammar; |
|
521 TSrsRuleIDPckg pckgRule; |
|
522 aMessage.ReadData1FromClientL(pckgGrammar); |
|
523 aMessage.ReadData2FromClientL(pckgRule); |
|
524 iImplementor.MSrUnloadRuleL(pckgGrammar(), pckgRule()); |
|
525 } |
|
526 |
|
527 void CSpeechRecognitionCustomCommandParser::DoLoadEngineParametersL(TMMFMessage& aMessage) |
|
528 { |
|
529 RArray<TInt> parameters; |
|
530 RArray<TInt> values; |
|
531 CleanupClosePushL(parameters); |
|
532 CleanupClosePushL(values); |
|
533 DoExtractIntArrayFromData1L(aMessage, parameters); |
|
534 DoExtractIntArrayFromData2L(aMessage, values); |
|
535 iImplementor.MSrLoadEngineParametersL(parameters,values); |
|
536 CleanupStack::PopAndDestroy(2, ¶meters); // parameters, values |
|
537 } |
|
538 |
|
539 void CSpeechRecognitionCustomCommandParser::DoGetEnginePropertiesL(TMMFMessage& aMessage) |
|
540 { |
|
541 RArray<TInt> propertyIDs; |
|
542 RArray<TInt> propertyValues; |
|
543 CleanupClosePushL(propertyIDs); |
|
544 CleanupClosePushL(propertyValues); |
|
545 DoExtractIntArrayFromData1L(aMessage, propertyIDs); |
|
546 |
|
547 iImplementor.MSrGetEnginePropertiesL(propertyIDs,propertyValues); |
|
548 // the custom command is aware of the size of the result, so it can copy the data back directly |
|
549 DoCopyIntArrayL(aMessage, propertyValues); |
|
550 CleanupStack::PopAndDestroy(2, &propertyIDs); // property IDs, property values |
|
551 } |
|
552 |
|
553 |
|
554 void CSpeechRecognitionCustomCommandParser::DoCopyPronunciationIDArrayL(TMMFMessage& aMessage) |
|
555 { |
|
556 CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize); |
|
557 CleanupStack::PushL(dataBuffer); |
|
558 RBufWriteStream stream; |
|
559 stream.Open(*dataBuffer); |
|
560 CleanupClosePushL(stream); |
|
561 for (TInt i=0;i<iPronunciationIDs.Count();i++) |
|
562 stream.WriteUint32L(iPronunciationIDs[i]); |
|
563 |
|
564 aMessage.WriteDataToClientL(dataBuffer->Ptr(0)); |
|
565 |
|
566 iPronunciationIDs.Close(); |
|
567 CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream |
|
568 } |
|
569 void CSpeechRecognitionCustomCommandParser::DoCopyModelIDArrayL(TMMFMessage& aMessage) |
|
570 { |
|
571 CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize); |
|
572 CleanupStack::PushL(dataBuffer); |
|
573 RBufWriteStream stream; |
|
574 stream.Open(*dataBuffer); |
|
575 CleanupClosePushL(stream); |
|
576 for (TInt i=0;i<iModelIDs.Count();i++) |
|
577 stream.WriteUint32L(iModelIDs[i]); |
|
578 |
|
579 aMessage.WriteDataToClientL(dataBuffer->Ptr(0)); |
|
580 |
|
581 iModelIDs.Close(); |
|
582 CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream |
|
583 } |
|
584 |
|
585 void CSpeechRecognitionCustomCommandParser::DoCopyRuleIDArrayL(TMMFMessage& aMessage) |
|
586 { |
|
587 CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize); |
|
588 CleanupStack::PushL(dataBuffer); |
|
589 RBufWriteStream stream; |
|
590 stream.Open(*dataBuffer); |
|
591 CleanupClosePushL(stream); |
|
592 for (TInt i=0;i<iRuleIDs.Count();i++) |
|
593 stream.WriteUint32L(iRuleIDs[i]); |
|
594 |
|
595 aMessage.WriteDataToClientL(dataBuffer->Ptr(0)); |
|
596 |
|
597 iRuleIDs.Close(); |
|
598 CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream |
|
599 } |
|
600 |
|
601 //------------------------------------------------------------------------------------------------------------------ |
|
602 |
|
603 void CSpeechRecognitionCustomCommandParser::DoCopyLexiconIDArrayL(TMMFMessage& aMessage) |
|
604 { |
|
605 CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize); |
|
606 CleanupStack::PushL(dataBuffer); |
|
607 RBufWriteStream stream; |
|
608 stream.Open(*dataBuffer); |
|
609 CleanupClosePushL(stream); |
|
610 for (TInt i=0;i<iLexiconIDs.Count();i++) |
|
611 stream.WriteUint32L(iLexiconIDs[i]); |
|
612 |
|
613 aMessage.WriteDataToClientL(dataBuffer->Ptr(0)); |
|
614 |
|
615 iLexiconIDs.Close(); |
|
616 CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream |
|
617 } |
|
618 void CSpeechRecognitionCustomCommandParser::DoCopyModelBankIDArrayL(TMMFMessage& aMessage) |
|
619 { |
|
620 CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize); |
|
621 CleanupStack::PushL(dataBuffer); |
|
622 RBufWriteStream stream; |
|
623 stream.Open(*dataBuffer); |
|
624 CleanupClosePushL(stream); |
|
625 for (TInt i=0;i<iModelBankIDs.Count();i++) |
|
626 stream.WriteUint32L(iModelBankIDs[i]); |
|
627 |
|
628 aMessage.WriteDataToClientL(dataBuffer->Ptr(0)); |
|
629 |
|
630 iModelBankIDs.Close(); |
|
631 CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream |
|
632 } |
|
633 |
|
634 void CSpeechRecognitionCustomCommandParser::DoCopyGrammarIDArrayL(TMMFMessage& aMessage) |
|
635 { |
|
636 CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize); |
|
637 CleanupStack::PushL(dataBuffer); |
|
638 RBufWriteStream stream; |
|
639 stream.Open(*dataBuffer); |
|
640 CleanupClosePushL(stream); |
|
641 for (TInt i=0;i<iGrammarIDs.Count();i++) |
|
642 stream.WriteUint32L(iGrammarIDs[i]); |
|
643 |
|
644 aMessage.WriteDataToClientL(dataBuffer->Ptr(0)); |
|
645 |
|
646 iGrammarIDs.Close(); |
|
647 CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream |
|
648 } |
|
649 |
|
650 |
|
651 //-------------------------------------------------------------------------------------------------------------------- |
|
652 |
|
653 |
|
654 void CSpeechRecognitionCustomCommandParser::DoCopyIntArrayL(TMMFMessage& aMessage, const RArray<TInt>& aArray) |
|
655 { |
|
656 CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize); |
|
657 CleanupStack::PushL(dataBuffer); |
|
658 RBufWriteStream stream; |
|
659 stream.Open(*dataBuffer); |
|
660 CleanupClosePushL(stream); |
|
661 for (TInt i=0;i<aArray.Count();i++) |
|
662 stream.WriteUint32L(aArray[i]); |
|
663 |
|
664 aMessage.WriteDataToClientL(dataBuffer->Ptr(0)); |
|
665 CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream |
|
666 } |
|
667 |
|
668 void CSpeechRecognitionCustomCommandParser::DoExtractIntArrayFromData1L(TMMFMessage& aMessage, RArray<TInt>& aArray) |
|
669 { |
|
670 TInt size = User::LeaveIfError(aMessage.SizeOfData1FromClient()); |
|
671 HBufC8* buf = HBufC8::NewL(size); |
|
672 CleanupStack::PushL(buf); |
|
673 TPtr8 ptr = buf->Des(); |
|
674 aMessage.ReadData1FromClientL(ptr); |
|
675 DoExtractIntArrayL(ptr,aArray); |
|
676 CleanupStack::PopAndDestroy(buf); |
|
677 } |
|
678 |
|
679 void CSpeechRecognitionCustomCommandParser::DoExtractIntArrayFromData2L(TMMFMessage& aMessage, RArray<TInt>& aArray) |
|
680 { |
|
681 TInt size = User::LeaveIfError(aMessage.SizeOfData2FromClient()); |
|
682 HBufC8* buf = HBufC8::NewL(size); |
|
683 CleanupStack::PushL(buf); |
|
684 TPtr8 ptr = buf->Des(); |
|
685 aMessage.ReadData2FromClientL(ptr); |
|
686 DoExtractIntArrayL(ptr,aArray); |
|
687 CleanupStack::PopAndDestroy(buf); |
|
688 } |
|
689 |
|
690 |
|
691 void CSpeechRecognitionCustomCommandParser::DoExtractIntArrayL(TDes8& aDescriptor, RArray<TInt>& aArray) |
|
692 { |
|
693 RDesReadStream stream(aDescriptor); |
|
694 CleanupClosePushL(stream); |
|
695 |
|
696 TInt numberElements; |
|
697 numberElements = stream.ReadInt32L(); |
|
698 |
|
699 for (TInt i=0; i<numberElements; i++) |
|
700 { |
|
701 User::LeaveIfError(aArray.Append(stream.ReadInt32L())); |
|
702 } |
|
703 CleanupStack::PopAndDestroy(&stream); //stream |
|
704 } |
|
705 |
|
706 |
|
707 void CSpeechRecognitionCustomCommandParser::DoExternalizeResultSetL() |
|
708 { |
|
709 ASSERT(iResultSet); |
|
710 iResultCopyBuffer = CBufFlat::NewL(KExpandSize); |
|
711 RBufWriteStream stream; |
|
712 stream.Open(*iResultCopyBuffer); |
|
713 CleanupClosePushL(stream); |
|
714 iResultSet->ExternalizeL(stream); |
|
715 delete iResultSet; |
|
716 iResultSet = NULL; |
|
717 CleanupStack::PopAndDestroy(&stream); //stream |
|
718 } |
|
719 void CSpeechRecognitionCustomCommandParser::DoCopyResultSetL(TMMFMessage& aMessage) |
|
720 { |
|
721 aMessage.WriteDataToClientL(iResultCopyBuffer->Ptr(0)); |
|
722 delete iResultCopyBuffer; |
|
723 iResultCopyBuffer = NULL; |
|
724 } |