|
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 // INCLUDES |
|
17 #include <mmf/common/speechrecognitioncustomcommands.h> |
|
18 #include "SpeechRecognitionCustomCommandCommon.h" |
|
19 |
|
20 const TInt KExpandSize = 10; |
|
21 |
|
22 |
|
23 EXPORT_C RSpeechRecognitionCustomCommands::RSpeechRecognitionCustomCommands(RMMFController& aController) |
|
24 :RMMFCustomCommandsBase(aController, KUidInterfaceSpeechRecognition) |
|
25 { |
|
26 } |
|
27 |
|
28 EXPORT_C TInt RSpeechRecognitionCustomCommands::AddPronunciation(TLexiconID aLexiconID, |
|
29 TModelBankID aModelBankID, TModelID aModelID, |
|
30 TPronunciationID& aPronunciationID) |
|
31 { |
|
32 TSrsAddPronunciationPckg pckg(TSrsAddPronunciation(aLexiconID,aModelBankID,aModelID,&aPronunciationID)); |
|
33 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
34 ESrAddPronunciation, |
|
35 pckg, |
|
36 KNullDesC8); |
|
37 |
|
38 return err; |
|
39 } |
|
40 |
|
41 EXPORT_C TInt RSpeechRecognitionCustomCommands::SetClientUid(TUid aClientUid) |
|
42 { |
|
43 TSrsUidPckg pckg(aClientUid); |
|
44 |
|
45 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
46 ESrSetClientUid, |
|
47 pckg, |
|
48 KNullDesC8); |
|
49 return err; |
|
50 } |
|
51 |
|
52 EXPORT_C TInt RSpeechRecognitionCustomCommands::AddRule(TGrammarID aGrammarID, TLexiconID aLexiconID, |
|
53 TPronunciationID aPronunciationID, TRuleID& aRuleID) |
|
54 |
|
55 { |
|
56 TSrsAddRulePckg pckg(TSrsAddRule(aGrammarID, aLexiconID, aPronunciationID, &aRuleID)); |
|
57 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
58 ESrAddRule, |
|
59 pckg, |
|
60 KNullDesC8); |
|
61 |
|
62 return err; |
|
63 } |
|
64 |
|
65 EXPORT_C void RSpeechRecognitionCustomCommands::Cancel() |
|
66 { |
|
67 iController.CustomCommandSync(iDestinationPckg, |
|
68 ESrCancel, |
|
69 KNullDesC8, |
|
70 KNullDesC8); |
|
71 |
|
72 } |
|
73 |
|
74 EXPORT_C TInt RSpeechRecognitionCustomCommands::CommitChanges() |
|
75 { |
|
76 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
77 ESrCommitChanges, |
|
78 KNullDesC8, |
|
79 KNullDesC8); |
|
80 |
|
81 return err; |
|
82 |
|
83 } |
|
84 |
|
85 EXPORT_C TInt RSpeechRecognitionCustomCommands::CreateGrammar(TGrammarID& aGrammarID) |
|
86 { |
|
87 TSrsGrammarIDPtrPckg pckg(&aGrammarID); |
|
88 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
89 ESrCreateGrammar, |
|
90 pckg, |
|
91 KNullDesC8); |
|
92 |
|
93 return err; |
|
94 } |
|
95 |
|
96 EXPORT_C TInt RSpeechRecognitionCustomCommands::CreateLexicon(TLexiconID& aLexiconID) |
|
97 { |
|
98 TSrsLexiconIDPtrPckg pckg(&aLexiconID); |
|
99 |
|
100 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
101 ESrCreateLexicon, |
|
102 pckg, |
|
103 KNullDesC8); |
|
104 |
|
105 return err; |
|
106 |
|
107 |
|
108 } |
|
109 |
|
110 EXPORT_C TInt RSpeechRecognitionCustomCommands::CreateModelBank(TModelBankID& aModelBankID) |
|
111 { |
|
112 TSrsModelBankIDPtrPckg pckg(&aModelBankID); |
|
113 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
114 ESrCreateModelBank, |
|
115 pckg, |
|
116 KNullDesC8); |
|
117 |
|
118 return err; |
|
119 |
|
120 |
|
121 } |
|
122 |
|
123 EXPORT_C TInt RSpeechRecognitionCustomCommands::EndRecSession() |
|
124 |
|
125 { |
|
126 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
127 ESrEndRecSession, |
|
128 KNullDesC8, |
|
129 KNullDesC8); |
|
130 |
|
131 return err; |
|
132 |
|
133 |
|
134 } |
|
135 EXPORT_C TInt RSpeechRecognitionCustomCommands::GetAllModelIDs(TModelBankID aModelBankID) |
|
136 { |
|
137 TSrsModelBankIDPckg pckg(aModelBankID); |
|
138 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
139 ESrGetAllModelIDs, |
|
140 pckg, |
|
141 KNullDesC8); |
|
142 |
|
143 return err; |
|
144 } |
|
145 |
|
146 EXPORT_C TInt RSpeechRecognitionCustomCommands::GetAllPronunciationIDs(TLexiconID aLexiconID) |
|
147 { |
|
148 TSrsLexiconIDPckg pckg(aLexiconID); |
|
149 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
150 ESrGetAllPronunciationIDs, |
|
151 pckg, |
|
152 KNullDesC8); |
|
153 return err; |
|
154 |
|
155 } |
|
156 |
|
157 EXPORT_C TInt RSpeechRecognitionCustomCommands::GetAllRuleIDs(TGrammarID aGrammarID) |
|
158 { |
|
159 TSrsGrammarIDPckg pckg(aGrammarID); |
|
160 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
161 ESrGetAllRuleIDs, |
|
162 pckg, |
|
163 KNullDesC8); |
|
164 |
|
165 return err; |
|
166 } |
|
167 |
|
168 EXPORT_C TInt RSpeechRecognitionCustomCommands::GetAvailableStorage(TInt& aAvailableStorage) |
|
169 |
|
170 { |
|
171 TSrsIntPtrPckg pckg(&aAvailableStorage); |
|
172 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
173 ESrGetAvailableStorage, |
|
174 pckg, |
|
175 KNullDesC8); |
|
176 |
|
177 return err; |
|
178 |
|
179 } |
|
180 EXPORT_C TInt RSpeechRecognitionCustomCommands::GetEngineProperties(const RArray<TInt>& aPropertyId, |
|
181 RArray<TInt>& aPropertyValue) |
|
182 { |
|
183 |
|
184 TRAPD(err, DoGetEnginePropertiesL(aPropertyId, aPropertyValue)); |
|
185 return err; |
|
186 } |
|
187 |
|
188 EXPORT_C TInt RSpeechRecognitionCustomCommands::GetModelCount(TModelBankID aModelBankID, |
|
189 TInt& aModelCount) |
|
190 { |
|
191 TSrsModelBankIDPckg pckg(aModelBankID); |
|
192 TSrsIntPtrPckg resultpckg(&aModelCount); |
|
193 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
194 ESrGetModelCount, |
|
195 pckg, |
|
196 resultpckg); |
|
197 |
|
198 return err; |
|
199 } |
|
200 |
|
201 EXPORT_C TInt RSpeechRecognitionCustomCommands::GetRuleValidity(TGrammarID aGrammarID, TRuleID aRuleID, |
|
202 TBool& aValid) |
|
203 { |
|
204 TSrsRuleValidityPckg pckg(TSrsRuleValidity(aGrammarID, aRuleID, &aValid)); |
|
205 |
|
206 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
207 ESrGetRuleValidity, |
|
208 pckg, |
|
209 KNullDesC8); |
|
210 return err; |
|
211 |
|
212 } |
|
213 EXPORT_C TInt RSpeechRecognitionCustomCommands::GetUtteranceDuration(TModelBankID aModelBankID, |
|
214 TModelID aModelID, TTimeIntervalMicroSeconds32& aDuration) |
|
215 { |
|
216 TSrsGetUtteranceDurationPckg pckg(TSrsGetUtteranceDuration(aModelBankID, aModelID, &aDuration)); |
|
217 |
|
218 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
219 ESrUtteranceDuration, |
|
220 pckg, |
|
221 KNullDesC8); |
|
222 return err; |
|
223 |
|
224 } |
|
225 |
|
226 EXPORT_C TInt RSpeechRecognitionCustomCommands::LoadGrammar(TGrammarID aGrammarID) |
|
227 { |
|
228 TSrsGrammarIDPckg pckg(aGrammarID); |
|
229 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
230 ESrLoadGrammar, |
|
231 pckg, |
|
232 KNullDesC8); |
|
233 |
|
234 return err; |
|
235 } |
|
236 |
|
237 EXPORT_C TInt RSpeechRecognitionCustomCommands::LoadLexicon(TLexiconID aLexiconID) |
|
238 { |
|
239 TSrsLexiconIDPckg pckg(aLexiconID); |
|
240 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
241 ESrLoadLexicon, |
|
242 pckg, |
|
243 KNullDesC8); |
|
244 |
|
245 return err; |
|
246 } |
|
247 |
|
248 EXPORT_C TInt RSpeechRecognitionCustomCommands::LoadModels(TModelBankID aModelBankID) |
|
249 { |
|
250 TSrsModelBankIDPckg pckg(aModelBankID); |
|
251 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
252 ESrLoadModels, |
|
253 pckg, |
|
254 KNullDesC8); |
|
255 |
|
256 return err; |
|
257 } |
|
258 |
|
259 EXPORT_C TInt RSpeechRecognitionCustomCommands::PlayUtterance(TModelBankID aModelBankID, |
|
260 TModelID aModelID) |
|
261 { |
|
262 TSrsPlayUtterancePckg pckg(TSrsPlayUtterance(aModelBankID, aModelID)); |
|
263 |
|
264 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
265 ESrPlayUtterance, |
|
266 pckg, |
|
267 KNullDesC8); |
|
268 return err; |
|
269 |
|
270 } |
|
271 |
|
272 EXPORT_C TInt RSpeechRecognitionCustomCommands::Recognize(CSDClientResultSet& aResultSet) |
|
273 { |
|
274 TRAPD(err, DoRecognizeL(aResultSet)); |
|
275 return err; |
|
276 } |
|
277 |
|
278 |
|
279 EXPORT_C TInt RSpeechRecognitionCustomCommands::Record(TTimeIntervalMicroSeconds32 aRecordTime) |
|
280 { |
|
281 TSrsTimeIntervalMicroSeconds32Pckg pckg(aRecordTime); |
|
282 |
|
283 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
284 ESrRecord, |
|
285 pckg, |
|
286 KNullDesC8); |
|
287 return err; |
|
288 } |
|
289 |
|
290 EXPORT_C TInt RSpeechRecognitionCustomCommands::RemoveGrammar(TGrammarID aGrammarID) |
|
291 { |
|
292 TSrsGrammarIDPckg pckg(aGrammarID); |
|
293 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
294 ESrRemoveGrammar, |
|
295 pckg, |
|
296 KNullDesC8); |
|
297 |
|
298 return err; |
|
299 } |
|
300 |
|
301 EXPORT_C TInt RSpeechRecognitionCustomCommands::RemoveLexicon(TLexiconID aLexiconID) |
|
302 { |
|
303 TSrsLexiconIDPckg pckg(aLexiconID); |
|
304 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
305 ESrRemoveLexicon, |
|
306 pckg, |
|
307 KNullDesC8); |
|
308 |
|
309 return err; |
|
310 } |
|
311 |
|
312 EXPORT_C TInt RSpeechRecognitionCustomCommands::RemoveModelBank(TModelBankID aModelBankID) |
|
313 { |
|
314 TSrsModelBankIDPckg pckg(aModelBankID); |
|
315 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
316 ESrRemoveModelBank, |
|
317 pckg, |
|
318 KNullDesC8); |
|
319 |
|
320 return err; |
|
321 } |
|
322 |
|
323 EXPORT_C TInt RSpeechRecognitionCustomCommands::RemoveModel(TModelBankID aModelBankID, |
|
324 TModelID aModelID) |
|
325 { |
|
326 TSrsModelBankIDPckg pckgModelBankID(aModelBankID); |
|
327 TSrsModelIDPckg pckgModelID(aModelID); |
|
328 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
329 ESrRemoveModel, |
|
330 pckgModelBankID, |
|
331 pckgModelID); |
|
332 |
|
333 return err; |
|
334 } |
|
335 EXPORT_C TInt RSpeechRecognitionCustomCommands::RemovePronunciation(TLexiconID aLexiconID, |
|
336 TPronunciationID aPronunciationID) |
|
337 { |
|
338 TSrsLexiconIDPckg pckgLexiconID(aLexiconID); |
|
339 TSrsPronunciationIDPckg pckgPronunciationID(aPronunciationID); |
|
340 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
341 ESrRemovePronunciation, |
|
342 pckgLexiconID, |
|
343 pckgPronunciationID); |
|
344 |
|
345 return err; |
|
346 } |
|
347 |
|
348 EXPORT_C TInt RSpeechRecognitionCustomCommands::RemoveRule(TGrammarID aGrammarID, TRuleID aRuleID) |
|
349 { |
|
350 TSrsGrammarIDPckg pckgGrammarID(aGrammarID); |
|
351 TSrsRuleIDPckg pckgRuleID(aRuleID); |
|
352 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
353 ESrRemoveRule, |
|
354 pckgGrammarID, |
|
355 pckgRuleID); |
|
356 |
|
357 return err; |
|
358 } |
|
359 |
|
360 EXPORT_C TInt RSpeechRecognitionCustomCommands::StartRecSession(TRecognitionMode aMode) |
|
361 { |
|
362 TSrsRecognitionModePckg pckg(aMode); |
|
363 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
364 ESrStartRecSession, |
|
365 pckg, |
|
366 KNullDesC8); |
|
367 |
|
368 return err; |
|
369 |
|
370 } |
|
371 |
|
372 |
|
373 EXPORT_C TInt RSpeechRecognitionCustomCommands::Train(TModelBankID aModelBankID, TModelID& aModelID) |
|
374 { |
|
375 TSrsModelBankIDPckg pckgModelBankID(aModelBankID); |
|
376 TSrsModelIDPtrPckg pckgModelID(&aModelID); |
|
377 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
378 ESrTrain, |
|
379 pckgModelBankID, |
|
380 pckgModelID); |
|
381 |
|
382 return err; |
|
383 } |
|
384 EXPORT_C TInt RSpeechRecognitionCustomCommands::UnloadRule(TGrammarID aGrammarID, TRuleID aRuleID) |
|
385 { |
|
386 TSrsGrammarIDPckg pckgGrammarID(aGrammarID); |
|
387 TSrsRuleIDPckg pckgRuleID(aRuleID); |
|
388 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
389 ESrUnloadRule, |
|
390 pckgGrammarID, |
|
391 pckgRuleID); |
|
392 |
|
393 return err; |
|
394 } |
|
395 |
|
396 EXPORT_C TInt RSpeechRecognitionCustomCommands::LoadEngineParameters(const RArray<TInt>& aParameterId, |
|
397 const RArray<TInt>& aParameterValue) |
|
398 { |
|
399 TRAPD(err, DoLoadEngineParametersL(aParameterId, aParameterValue)); |
|
400 return err; |
|
401 } |
|
402 |
|
403 void RSpeechRecognitionCustomCommands::DoLoadEngineParametersL(const RArray<TInt>& aParameterId, |
|
404 const RArray<TInt>& aParameterValue) |
|
405 { |
|
406 CBufFlat* param1 = ExternalizeIntArrayL(aParameterId); |
|
407 CleanupStack::PushL(param1); |
|
408 CBufFlat* param2 = ExternalizeIntArrayL(aParameterValue); |
|
409 CleanupStack::PushL(param2); |
|
410 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, |
|
411 ESrLoadEngineParameters, |
|
412 param1->Ptr(0), |
|
413 param2->Ptr(0))); |
|
414 |
|
415 CleanupStack::PopAndDestroy(2,param1); //param1, param2 |
|
416 } |
|
417 |
|
418 |
|
419 |
|
420 EXPORT_C void RSpeechRecognitionCustomCommands::GetPronunciationIDArrayL(RArray<TPronunciationID>& aPronunciationIDs) |
|
421 { |
|
422 TPckgBuf<TInt> pckgSize; |
|
423 |
|
424 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, |
|
425 ESrGetPronunciationIDArraySize, |
|
426 KNullDesC8, |
|
427 KNullDesC8, |
|
428 pckgSize)); |
|
429 |
|
430 HBufC8* buf = HBufC8::NewLC(pckgSize()*sizeof(TPronunciationID)); |
|
431 TPtr8 ptr = buf->Des(); |
|
432 |
|
433 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, |
|
434 ESrGetPronunciationIDArrayContents, |
|
435 KNullDesC8, |
|
436 KNullDesC8, |
|
437 ptr)); |
|
438 |
|
439 RDesReadStream stream(ptr); |
|
440 CleanupClosePushL(stream); |
|
441 |
|
442 for (TInt i=0; i<pckgSize(); i++) |
|
443 { |
|
444 User::LeaveIfError(aPronunciationIDs.Append(stream.ReadInt32L())); |
|
445 } |
|
446 |
|
447 CleanupStack::PopAndDestroy(2);//stream, buf |
|
448 |
|
449 } |
|
450 |
|
451 |
|
452 EXPORT_C void RSpeechRecognitionCustomCommands::GetRuleIDArrayL(RArray<TRuleID>& aRuleIDs) |
|
453 { |
|
454 TPckgBuf<TInt> pckgSize; |
|
455 |
|
456 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, |
|
457 ESrGetRuleIDArraySize, |
|
458 KNullDesC8, |
|
459 KNullDesC8, |
|
460 pckgSize)); |
|
461 |
|
462 HBufC8* buf = HBufC8::NewLC(pckgSize()*sizeof(TRuleID)); |
|
463 TPtr8 ptr = buf->Des(); |
|
464 |
|
465 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, |
|
466 ESrGetRuleIDArrayContents, |
|
467 KNullDesC8, |
|
468 KNullDesC8, |
|
469 ptr)); |
|
470 |
|
471 RDesReadStream stream(ptr); |
|
472 CleanupClosePushL(stream); |
|
473 |
|
474 for (TInt i=0; i<pckgSize(); i++) |
|
475 { |
|
476 User::LeaveIfError(aRuleIDs.Append(stream.ReadInt32L())); |
|
477 } |
|
478 |
|
479 CleanupStack::PopAndDestroy(2);//stream, buf |
|
480 } |
|
481 |
|
482 |
|
483 EXPORT_C void RSpeechRecognitionCustomCommands::GetModelIDArrayL(RArray<TModelID>& aModelIDs) |
|
484 { |
|
485 TPckgBuf<TInt> pckgSize; |
|
486 |
|
487 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, |
|
488 ESrGetModelIDArraySize, |
|
489 KNullDesC8, |
|
490 KNullDesC8, |
|
491 pckgSize)); |
|
492 |
|
493 HBufC8* buf = HBufC8::NewLC(pckgSize()*sizeof(TModelID)); |
|
494 TPtr8 ptr = buf->Des(); |
|
495 |
|
496 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, |
|
497 ESrGetModelIDArrayContents, |
|
498 KNullDesC8, |
|
499 KNullDesC8, |
|
500 ptr)); |
|
501 |
|
502 RDesReadStream stream(ptr); |
|
503 CleanupClosePushL(stream); |
|
504 |
|
505 for (TInt i=0; i<pckgSize(); i++) |
|
506 { |
|
507 User::LeaveIfError(aModelIDs.Append(stream.ReadInt32L())); |
|
508 } |
|
509 |
|
510 CleanupStack::PopAndDestroy(2);//stream, buf |
|
511 } |
|
512 |
|
513 |
|
514 EXPORT_C void RSpeechRecognitionCustomCommands::GetResultSetL(CSDClientResultSet& aResultSet) |
|
515 { |
|
516 TPckgBuf<TInt> pckgSize; |
|
517 |
|
518 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, |
|
519 ESrGetClientResultSetSize, |
|
520 KNullDesC8, |
|
521 KNullDesC8, |
|
522 pckgSize)); |
|
523 |
|
524 HBufC8* buf = HBufC8::NewLC(pckgSize()); |
|
525 TPtr8 ptr = buf->Des(); |
|
526 |
|
527 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, |
|
528 ESrGetClientResultSet, |
|
529 KNullDesC8, |
|
530 KNullDesC8, |
|
531 ptr)); |
|
532 |
|
533 RDesReadStream stream(ptr); |
|
534 CleanupClosePushL(stream); |
|
535 |
|
536 aResultSet.InternalizeL(stream); |
|
537 CleanupStack::PopAndDestroy(2, buf);//buf, stream |
|
538 } |
|
539 |
|
540 void RSpeechRecognitionCustomCommands::DoRecognizeL(CSDClientResultSet& aResultSet) |
|
541 { |
|
542 CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize); |
|
543 CleanupStack::PushL(dataCopyBuffer); |
|
544 RBufWriteStream stream; |
|
545 stream.Open(*dataCopyBuffer); |
|
546 CleanupClosePushL(stream); |
|
547 |
|
548 aResultSet.ExternalizeL(stream); |
|
549 |
|
550 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, |
|
551 ESrRecognize, |
|
552 dataCopyBuffer->Ptr(0), |
|
553 KNullDesC8)); |
|
554 |
|
555 CleanupStack::PopAndDestroy(2); //stream,dataCopyBuffer |
|
556 } |
|
557 |
|
558 |
|
559 void RSpeechRecognitionCustomCommands::DoGetEnginePropertiesL(const RArray<TInt>& aPropertyId, |
|
560 RArray<TInt>& aPropertyValue) |
|
561 { |
|
562 CBufFlat* param1 = ExternalizeIntArrayL(aPropertyId); |
|
563 CleanupStack::PushL(param1); |
|
564 |
|
565 TInt aNumberResults = aPropertyId.Count(); // same number of values as properties |
|
566 |
|
567 HBufC8* buf = HBufC8::NewLC(aNumberResults *sizeof(TInt)); |
|
568 TPtr8 ptr = buf->Des(); |
|
569 |
|
570 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, |
|
571 ESrGetEngineProperties, |
|
572 param1->Ptr(0), |
|
573 KNullDesC8, |
|
574 ptr)); |
|
575 |
|
576 InternalizeIntArrayL(ptr,aNumberResults,aPropertyValue); |
|
577 |
|
578 CleanupStack::PopAndDestroy(2,param1);//param1, buf |
|
579 } |
|
580 |
|
581 CBufFlat* RSpeechRecognitionCustomCommands::ExternalizeIntArrayL(const RArray<TInt>& aArray) |
|
582 { |
|
583 CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize); |
|
584 CleanupStack::PushL(dataCopyBuffer); |
|
585 RBufWriteStream stream; |
|
586 stream.Open(*dataCopyBuffer); |
|
587 CleanupClosePushL(stream); |
|
588 |
|
589 stream.WriteInt32L(aArray.Count()); |
|
590 |
|
591 for (TInt i=0;i<aArray.Count();i++) |
|
592 stream.WriteUint32L(aArray[i]); |
|
593 |
|
594 CleanupStack::PopAndDestroy(1); //stream |
|
595 CleanupStack::Pop(); //dataCopyBuffer; |
|
596 return dataCopyBuffer; |
|
597 } |
|
598 |
|
599 void RSpeechRecognitionCustomCommands::InternalizeIntArrayL(TDes8& aDes, TInt aNumberElements, RArray<TInt>& aArray) |
|
600 { |
|
601 RDesReadStream stream(aDes); |
|
602 CleanupClosePushL(stream); |
|
603 |
|
604 for (TInt i=0; i<aNumberElements; i++) |
|
605 { |
|
606 User::LeaveIfError(aArray.Append(stream.ReadInt32L())); |
|
607 } |
|
608 |
|
609 CleanupStack::PopAndDestroy();//stream |
|
610 } |
|
611 |
|
612 EXPORT_C TInt RSpeechRecognitionCustomCommands::GetAllModelBankIDs() |
|
613 { |
|
614 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
615 ESrGetAllModelBankIDs, |
|
616 KNullDesC8, |
|
617 KNullDesC8); |
|
618 |
|
619 return err; |
|
620 } |
|
621 |
|
622 EXPORT_C TInt RSpeechRecognitionCustomCommands::GetAllLexiconIDs() |
|
623 { |
|
624 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
625 ESrGetAllLexiconIDs, |
|
626 KNullDesC8, |
|
627 KNullDesC8); |
|
628 return err; |
|
629 |
|
630 } |
|
631 |
|
632 EXPORT_C TInt RSpeechRecognitionCustomCommands::GetAllGrammarIDs() |
|
633 { |
|
634 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
635 ESrGetAllGrammarIDs, |
|
636 KNullDesC8, |
|
637 KNullDesC8); |
|
638 |
|
639 return err; |
|
640 } |
|
641 |
|
642 EXPORT_C TInt RSpeechRecognitionCustomCommands::GetAllClientModelBankIDs() |
|
643 { |
|
644 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
645 ESrGetAllClientModelBankIDs, |
|
646 KNullDesC8, |
|
647 KNullDesC8); |
|
648 |
|
649 return err; |
|
650 } |
|
651 |
|
652 EXPORT_C TInt RSpeechRecognitionCustomCommands::GetAllClientLexiconIDs() |
|
653 { |
|
654 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
655 ESrGetAllClientLexiconIDs, |
|
656 KNullDesC8, |
|
657 KNullDesC8); |
|
658 return err; |
|
659 |
|
660 } |
|
661 |
|
662 EXPORT_C TInt RSpeechRecognitionCustomCommands::GetAllClientGrammarIDs() |
|
663 { |
|
664 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
665 ESrGetAllClientGrammarIDs, |
|
666 KNullDesC8, |
|
667 KNullDesC8); |
|
668 |
|
669 return err; |
|
670 } |
|
671 |
|
672 |
|
673 EXPORT_C void RSpeechRecognitionCustomCommands::GetModelBankIDArrayL(RArray<TModelBankID>& aModelBankIDs) |
|
674 { |
|
675 TPckgBuf<TInt> pckgSize; |
|
676 |
|
677 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, |
|
678 ESrGetModelBankIDArraySize, |
|
679 KNullDesC8, |
|
680 KNullDesC8, |
|
681 pckgSize)); |
|
682 |
|
683 HBufC8* buf = HBufC8::NewLC(pckgSize()*sizeof(TModelID)); |
|
684 TPtr8 ptr = buf->Des(); |
|
685 |
|
686 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, |
|
687 ESrGetModelBankIDArrayContents, |
|
688 KNullDesC8, |
|
689 KNullDesC8, |
|
690 ptr)); |
|
691 |
|
692 RDesReadStream stream(ptr); |
|
693 CleanupClosePushL(stream); |
|
694 |
|
695 for (TInt i=0; i<pckgSize(); i++) |
|
696 { |
|
697 User::LeaveIfError(aModelBankIDs.Append(stream.ReadInt32L())); |
|
698 } |
|
699 |
|
700 CleanupStack::PopAndDestroy(2);//stream, buf |
|
701 } |
|
702 |
|
703 |
|
704 EXPORT_C void RSpeechRecognitionCustomCommands::GetGrammarIDArrayL(RArray<TGrammarID>& aGrammarIDs) |
|
705 { |
|
706 TPckgBuf<TInt> pckgSize; |
|
707 |
|
708 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, |
|
709 ESrGetGrammarIDArraySize, |
|
710 KNullDesC8, |
|
711 KNullDesC8, |
|
712 pckgSize)); |
|
713 |
|
714 HBufC8* buf = HBufC8::NewLC(pckgSize()*sizeof(TGrammarID)); |
|
715 TPtr8 ptr = buf->Des(); |
|
716 |
|
717 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, |
|
718 ESrGetGrammarIDArrayContents, |
|
719 KNullDesC8, |
|
720 KNullDesC8, |
|
721 ptr)); |
|
722 |
|
723 RDesReadStream stream(ptr); |
|
724 CleanupClosePushL(stream); |
|
725 |
|
726 for (TInt i=0; i<pckgSize(); i++) |
|
727 { |
|
728 User::LeaveIfError(aGrammarIDs.Append(stream.ReadInt32L())); |
|
729 } |
|
730 |
|
731 CleanupStack::PopAndDestroy(2);//stream, buf |
|
732 } |
|
733 |
|
734 |
|
735 EXPORT_C void RSpeechRecognitionCustomCommands::GetLexiconIDArrayL(RArray<TLexiconID>& aLexiconIDs) |
|
736 { |
|
737 TPckgBuf<TInt> pckgSize; |
|
738 |
|
739 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, |
|
740 ESrGetLexiconIDArraySize, |
|
741 KNullDesC8, |
|
742 KNullDesC8, |
|
743 pckgSize)); |
|
744 |
|
745 HBufC8* buf = HBufC8::NewLC(pckgSize()*sizeof(TLexiconID)); |
|
746 TPtr8 ptr = buf->Des(); |
|
747 |
|
748 User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, |
|
749 ESrGetLexiconIDArrayContents, |
|
750 KNullDesC8, |
|
751 KNullDesC8, |
|
752 ptr)); |
|
753 |
|
754 RDesReadStream stream(ptr); |
|
755 CleanupClosePushL(stream); |
|
756 |
|
757 for (TInt i=0; i<pckgSize(); i++) |
|
758 { |
|
759 User::LeaveIfError(aLexiconIDs.Append(stream.ReadInt32L())); |
|
760 } |
|
761 |
|
762 CleanupStack::PopAndDestroy(2);//stream, buf |
|
763 } |
|
764 |
|
765 |
|
766 enum TDllReason {}; |
|
767 EXPORT_C TInt E32Dll(TDllReason /* aReason */) |
|
768 { |
|
769 return (KErrNone); |
|
770 } |
|
771 |