os/mm/mmdevicefw/speechrecogsupport/ASR/src/SpeechRecognitionCustomCommandParser.cpp
Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #include <mmf/common/speechrecognitioncustomcommandparser.h>
18 #include "SpeechRecognitionCustomCommandCommon.h"
20 const TInt KExpandSize = 10;
23 EXPORT_C CSpeechRecognitionCustomCommandParser* CSpeechRecognitionCustomCommandParser::NewL(
24 MSpeechRecognitionCustomCommandImplementor& aImplementor)
26 CSpeechRecognitionCustomCommandParser* self = new (ELeave) CSpeechRecognitionCustomCommandParser(aImplementor);
30 EXPORT_C CSpeechRecognitionCustomCommandParser::~CSpeechRecognitionCustomCommandParser()
32 iPronunciationIDs.Close();
35 iModelBankIDs.Close();
39 delete iResultCopyBuffer;
42 void CSpeechRecognitionCustomCommandParser::HandleRequest(TMMFMessage& aMessage)
45 if (aMessage.Destination().InterfaceId() == KUidInterfaceSpeechRecognition)
47 TRAP(err, DoHandleRequestL(aMessage));
48 aMessage.Complete(err);
51 aMessage.Complete(KErrNotSupported);
55 CSpeechRecognitionCustomCommandParser::CSpeechRecognitionCustomCommandParser(MSpeechRecognitionCustomCommandImplementor& aImplementor)
56 : CMMFCustomCommandParserBase(KUidInterfaceSpeechRecognition), iImplementor(aImplementor)
61 void CSpeechRecognitionCustomCommandParser::DoHandleRequestL(TMMFMessage& aMessage)
63 TPckgBuf<TInt> pckgSize;
65 switch (aMessage.Function())
67 case ESrAddPronunciation:
68 DoAddPronunciationL(aMessage);
76 case ESrCommitChanges:
79 case ESrCreateGrammar:
80 DoCreateGrammarL(aMessage);
82 case ESrCreateLexicon:
83 DoCreateLexiconL(aMessage);
85 case ESrCreateModelBank:
86 DoCreateModelBankL(aMessage);
88 case ESrEndRecSession:
91 case ESrGetAllModelIDs:
92 DoGetAllModelIDsL(aMessage);
94 case ESrGetAllPronunciationIDs:
95 DoGetAllPronunciationIDsL(aMessage);
97 case ESrGetAllRuleIDs:
98 DoGetAllRuleIDsL(aMessage);
100 case ESrGetAllModelBankIDs:
101 DoGetAllModelBankIDsL();
103 case ESrGetAllLexiconIDs:
104 DoGetAllLexiconIDsL();
106 case ESrGetAllGrammarIDs:
107 DoGetAllGrammarIDsL();
109 case ESrGetAllClientModelBankIDs:
110 DoGetAllClientModelBankIDsL();
112 case ESrGetAllClientLexiconIDs:
113 DoGetAllClientLexiconIDsL();
115 case ESrGetAllClientGrammarIDs:
116 DoGetAllClientGrammarIDsL();
118 case ESrGetAvailableStorage:
119 DoGetAvailableStorageL(aMessage);
121 case ESrGetEngineProperties:
122 DoGetEnginePropertiesL(aMessage);
124 case ESrGetModelCount:
125 DoGetModelCountL(aMessage);
127 case ESrGetRuleValidity:
128 DoGetRuleValidityL(aMessage);
130 case ESrUtteranceDuration:
131 DoGetUtteranceDurationL(aMessage);
134 DoLoadGrammarL(aMessage);
137 DoLoadLexiconL(aMessage);
140 DoLoadModelsL(aMessage);
142 case ESrPlayUtterance:
143 DoPlayUtteranceL(aMessage);
146 DoRecognizeL(aMessage);
151 case ESrRemoveGrammar:
152 DoRemoveGrammarL(aMessage);
154 case ESrRemoveLexicon:
155 DoRemoveLexiconL(aMessage);
157 case ESrRemoveModelBank:
158 DoRemoveModelBankL(aMessage);
161 DoRemoveModelL(aMessage);
163 case ESrRemovePronunciation:
164 DoRemovePronunciationL(aMessage);
167 DoRemoveRuleL(aMessage);
169 case ESrStartRecSession:
170 DoStartRecSessionL(aMessage);
176 DoUnloadRuleL(aMessage);
178 case ESrLoadEngineParameters:
179 DoLoadEngineParametersL(aMessage);
181 case ESrGetPronunciationIDArraySize:
182 pckgSize() = iPronunciationIDs.Count();
183 aMessage.WriteDataToClientL(pckgSize);
185 case ESrGetPronunciationIDArrayContents:
186 DoCopyPronunciationIDArrayL(aMessage);
188 case ESrGetRuleIDArraySize:
189 pckgSize() = iRuleIDs.Count();
190 aMessage.WriteDataToClientL(pckgSize);
192 case ESrGetRuleIDArrayContents:
193 DoCopyRuleIDArrayL(aMessage);
195 case ESrGetModelIDArraySize:
196 pckgSize() = iModelIDs.Count();
197 aMessage.WriteDataToClientL(pckgSize);
199 case ESrGetModelIDArrayContents:
200 DoCopyModelIDArrayL(aMessage);
202 case ESrGetLexiconIDArraySize:
203 pckgSize() = iLexiconIDs.Count();
204 aMessage.WriteDataToClientL(pckgSize);
206 case ESrGetLexiconIDArrayContents:
207 DoCopyLexiconIDArrayL(aMessage);
209 case ESrGetGrammarIDArraySize:
210 pckgSize() = iGrammarIDs.Count();
211 aMessage.WriteDataToClientL(pckgSize);
213 case ESrGetGrammarIDArrayContents:
214 DoCopyGrammarIDArrayL(aMessage);
216 case ESrGetModelBankIDArraySize:
217 pckgSize() = iModelBankIDs.Count();
218 aMessage.WriteDataToClientL(pckgSize);
220 case ESrGetModelBankIDArrayContents:
221 DoCopyModelBankIDArrayL(aMessage);
223 case ESrGetClientResultSetSize:
224 DoExternalizeResultSetL();
225 pckgSize() = iResultCopyBuffer->Size();
226 aMessage.WriteDataToClientL(pckgSize);
228 case ESrGetClientResultSet:
229 DoCopyResultSetL(aMessage);
231 case ESrSetClientUid:
232 DoSetClientUidL(aMessage);
235 User::Leave(KErrNotSupported);
240 void CSpeechRecognitionCustomCommandParser::DoAddPronunciationL(TMMFMessage& aMessage)
242 TSrsAddPronunciationPckg pckg;
243 aMessage.ReadData1FromClientL(pckg);
244 iImplementor.MSrAddPronunciationL(pckg().iLexiconID, pckg().iModelBankID, pckg().iModelID, *pckg().iPronunciationID);
247 void CSpeechRecognitionCustomCommandParser::DoAddRuleL(TMMFMessage& aMessage)
249 TSrsAddRulePckg pckg;
250 aMessage.ReadData1FromClientL(pckg);
251 iImplementor.MSrAddRuleL(pckg().iGrammarID, pckg().iLexiconID, pckg().iPronunciationID, *pckg().iRuleID);
254 void CSpeechRecognitionCustomCommandParser::DoCancel()
256 iImplementor.MSrCancel();
259 void CSpeechRecognitionCustomCommandParser::DoCommitChangesL()
261 iImplementor.MSrCommitChangesL();
264 void CSpeechRecognitionCustomCommandParser::DoCreateGrammarL(TMMFMessage& aMessage)
266 TSrsGrammarIDPtrPckg pckg;
267 aMessage.ReadData1FromClientL(pckg);
268 iImplementor.MSrCreateGrammarL(*pckg());
271 void CSpeechRecognitionCustomCommandParser::DoCreateLexiconL(TMMFMessage& aMessage)
273 TSrsLexiconIDPtrPckg pckg;
274 aMessage.ReadData1FromClientL(pckg);
275 iImplementor.MSrCreateLexiconL(*pckg());
278 void CSpeechRecognitionCustomCommandParser::DoCreateModelBankL(TMMFMessage& aMessage)
280 TSrsModelBankIDPtrPckg pckg;
281 aMessage.ReadData1FromClientL(pckg);
282 iImplementor.MSrCreateModelBankL(*pckg());
285 void CSpeechRecognitionCustomCommandParser::DoEndRecSessionL()
287 iImplementor.MSrEndRecSessionL();
290 void CSpeechRecognitionCustomCommandParser::DoGetAllModelIDsL(TMMFMessage& aMessage)
292 TSrsModelBankIDPckg pckgModelBank;
294 aMessage.ReadData1FromClientL(pckgModelBank);
295 iImplementor.MSrGetAllModelIDsL(pckgModelBank(), iModelIDs);
298 void CSpeechRecognitionCustomCommandParser::DoGetAllPronunciationIDsL(TMMFMessage& aMessage)
300 TSrsLexiconIDPckg pckgLexicon;
301 iPronunciationIDs.Reset();
302 aMessage.ReadData1FromClientL(pckgLexicon);
303 iImplementor.MSrGetAllPronunciationIDsL(pckgLexicon(), iPronunciationIDs);
306 void CSpeechRecognitionCustomCommandParser::DoGetAllRuleIDsL(TMMFMessage& aMessage)
308 TSrsGrammarIDPckg pckgGrammar;
310 aMessage.ReadData1FromClientL(pckgGrammar);
311 iImplementor.MSrGetAllRuleIDsL(pckgGrammar(), iRuleIDs);
314 void CSpeechRecognitionCustomCommandParser::DoGetAllModelBankIDsL()
316 iModelBankIDs.Reset();
317 iImplementor.MSrGetAllModelBankIDsL(iModelBankIDs);
320 void CSpeechRecognitionCustomCommandParser::DoGetAllLexiconIDsL()
323 iImplementor.MSrGetAllLexiconIDsL(iLexiconIDs);
326 void CSpeechRecognitionCustomCommandParser::DoGetAllGrammarIDsL()
329 iImplementor.MSrGetAllGrammarIDsL(iGrammarIDs);
333 void CSpeechRecognitionCustomCommandParser::DoGetAllClientModelBankIDsL()
335 iModelBankIDs.Reset();
336 iImplementor.MSrGetAllClientModelBankIDsL(iModelBankIDs);
339 void CSpeechRecognitionCustomCommandParser::DoGetAllClientLexiconIDsL()
342 iImplementor.MSrGetAllClientLexiconIDsL(iLexiconIDs);
345 void CSpeechRecognitionCustomCommandParser::DoGetAllClientGrammarIDsL()
348 iImplementor.MSrGetAllClientGrammarIDsL(iGrammarIDs);
352 void CSpeechRecognitionCustomCommandParser::DoGetAvailableStorageL(TMMFMessage& aMessage)
355 aMessage.ReadData1FromClientL(pckg);
356 iImplementor.MSrGetAvailableStorageL(*pckg());
360 void CSpeechRecognitionCustomCommandParser::DoGetModelCountL(TMMFMessage& aMessage)
362 TSrsModelBankIDPckg pckgModelBank;
363 TSrsIntPtrPckg pckgResult;
364 aMessage.ReadData1FromClientL(pckgModelBank);
365 aMessage.ReadData2FromClientL(pckgResult);
366 iImplementor.MSrGetModelCountL(pckgModelBank(),*pckgResult());
369 void CSpeechRecognitionCustomCommandParser::DoGetRuleValidityL(TMMFMessage& aMessage)
371 TSrsRuleValidityPckg pckg;
372 aMessage.ReadData1FromClientL(pckg);
373 iImplementor.MSrGetRuleValidityL(pckg().iGrammarID, pckg().iRuleID, *pckg().iRuleValid);
376 void CSpeechRecognitionCustomCommandParser::DoGetUtteranceDurationL(TMMFMessage& aMessage)
378 TSrsGetUtteranceDurationPckg pckg;
379 aMessage.ReadData1FromClientL(pckg);
380 iImplementor.MSrGetUtteranceDurationL(pckg().iModelBankID, pckg().iModelID, *pckg().iDuration);
383 void CSpeechRecognitionCustomCommandParser::DoLoadGrammarL(TMMFMessage& aMessage)
385 TSrsGrammarIDPckg pckg;
386 aMessage.ReadData1FromClientL(pckg);
387 iImplementor.MSrLoadGrammarL(pckg());
390 void CSpeechRecognitionCustomCommandParser::DoLoadLexiconL(TMMFMessage& aMessage)
392 TSrsLexiconIDPckg pckg;
393 aMessage.ReadData1FromClientL(pckg);
394 iImplementor.MSrLoadLexiconL(pckg());
397 void CSpeechRecognitionCustomCommandParser::DoLoadModelsL(TMMFMessage& aMessage)
399 TSrsModelBankIDPckg pckg;
400 aMessage.ReadData1FromClientL(pckg);
401 iImplementor.MSrLoadModelsL(pckg());
404 void CSpeechRecognitionCustomCommandParser::DoPlayUtteranceL(TMMFMessage& aMessage)
406 TSrsPlayUtterancePckg pckg;
407 aMessage.ReadData1FromClientL(pckg);
408 iImplementor.MSrPlayUtteranceL(pckg().iModelBankID, pckg().iModelID);
411 void CSpeechRecognitionCustomCommandParser::DoSetClientUidL(TMMFMessage& aMessage)
414 aMessage.ReadData1FromClientL(pckg);
415 iImplementor.MSrSetClientUid(pckg());
419 void CSpeechRecognitionCustomCommandParser::DoRecognizeL(TMMFMessage& aMessage)
422 User::Leave(KErrInUse);
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();
433 TRAP(err, iResultSet->InternalizeL(stream));
436 TRAP(err, iImplementor.MSrRecognizeL(*iResultSet));
444 CleanupStack::PopAndDestroy(2, dataBuffer);//dataBuffer, stream
447 void CSpeechRecognitionCustomCommandParser::DoRecordL(TMMFMessage& aMessage)
449 TSrsTimeIntervalMicroSeconds32Pckg pckg;
450 aMessage.ReadData1FromClientL(pckg);
451 iImplementor.MSrRecordL(pckg());
454 void CSpeechRecognitionCustomCommandParser::DoRemoveGrammarL(TMMFMessage& aMessage)
456 TSrsGrammarIDPckg pckg;
457 aMessage.ReadData1FromClientL(pckg);
458 iImplementor.MSrRemoveGrammarL(pckg());
461 void CSpeechRecognitionCustomCommandParser::DoRemoveLexiconL(TMMFMessage& aMessage)
463 TSrsLexiconIDPckg pckg;
464 aMessage.ReadData1FromClientL(pckg);
465 iImplementor.MSrRemoveLexiconL(pckg());
468 void CSpeechRecognitionCustomCommandParser::DoRemoveModelBankL(TMMFMessage& aMessage)
470 TSrsModelBankIDPckg pckg;
471 aMessage.ReadData1FromClientL(pckg);
472 iImplementor.MSrRemoveModelBankL(pckg());
475 void CSpeechRecognitionCustomCommandParser::DoRemoveModelL(TMMFMessage& aMessage)
477 TSrsModelBankIDPckg pckgModelBankID;
478 TSrsModelIDPckg pckgModelID;
479 aMessage.ReadData1FromClientL(pckgModelBankID);
480 aMessage.ReadData2FromClientL(pckgModelID);
481 iImplementor.MSrRemoveModelL(pckgModelBankID(), pckgModelID());
484 void CSpeechRecognitionCustomCommandParser::DoRemovePronunciationL(TMMFMessage& aMessage)
486 TSrsLexiconIDPckg pckgLexicon;
487 TSrsPronunciationIDPckg pckgPronunciation;
488 aMessage.ReadData1FromClientL(pckgLexicon);
489 aMessage.ReadData2FromClientL(pckgPronunciation);
490 iImplementor.MSrRemovePronunciationL(pckgLexicon(), pckgPronunciation());
493 void CSpeechRecognitionCustomCommandParser::DoRemoveRuleL(TMMFMessage& aMessage)
495 TSrsGrammarIDPckg pckgGrammar;
496 TSrsRuleIDPckg pckgRule;
497 aMessage.ReadData1FromClientL(pckgGrammar);
498 aMessage.ReadData2FromClientL(pckgRule);
499 iImplementor.MSrRemoveRuleL(pckgGrammar(), pckgRule());
502 void CSpeechRecognitionCustomCommandParser::DoStartRecSessionL(TMMFMessage& aMessage)
504 TSrsRecognitionModePckg pckg;
505 aMessage.ReadData1FromClientL(pckg);
506 iImplementor.MSrStartRecSessionL(pckg());
509 void CSpeechRecognitionCustomCommandParser::DoTrainL(TMMFMessage& aMessage)
511 TSrsModelBankIDPckg pckgModelBankID;
512 TSrsModelIDPtrPckg pckgModelIDPtr;
513 aMessage.ReadData1FromClientL(pckgModelBankID);
514 aMessage.ReadData2FromClientL(pckgModelIDPtr);
515 iImplementor.MSrTrainL(pckgModelBankID(),*pckgModelIDPtr());
518 void CSpeechRecognitionCustomCommandParser::DoUnloadRuleL(TMMFMessage& aMessage)
520 TSrsGrammarIDPckg pckgGrammar;
521 TSrsRuleIDPckg pckgRule;
522 aMessage.ReadData1FromClientL(pckgGrammar);
523 aMessage.ReadData2FromClientL(pckgRule);
524 iImplementor.MSrUnloadRuleL(pckgGrammar(), pckgRule());
527 void CSpeechRecognitionCustomCommandParser::DoLoadEngineParametersL(TMMFMessage& aMessage)
529 RArray<TInt> parameters;
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
539 void CSpeechRecognitionCustomCommandParser::DoGetEnginePropertiesL(TMMFMessage& aMessage)
541 RArray<TInt> propertyIDs;
542 RArray<TInt> propertyValues;
543 CleanupClosePushL(propertyIDs);
544 CleanupClosePushL(propertyValues);
545 DoExtractIntArrayFromData1L(aMessage, propertyIDs);
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
554 void CSpeechRecognitionCustomCommandParser::DoCopyPronunciationIDArrayL(TMMFMessage& aMessage)
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]);
564 aMessage.WriteDataToClientL(dataBuffer->Ptr(0));
566 iPronunciationIDs.Close();
567 CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream
569 void CSpeechRecognitionCustomCommandParser::DoCopyModelIDArrayL(TMMFMessage& aMessage)
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]);
579 aMessage.WriteDataToClientL(dataBuffer->Ptr(0));
582 CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream
585 void CSpeechRecognitionCustomCommandParser::DoCopyRuleIDArrayL(TMMFMessage& aMessage)
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]);
595 aMessage.WriteDataToClientL(dataBuffer->Ptr(0));
598 CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream
601 //------------------------------------------------------------------------------------------------------------------
603 void CSpeechRecognitionCustomCommandParser::DoCopyLexiconIDArrayL(TMMFMessage& aMessage)
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]);
613 aMessage.WriteDataToClientL(dataBuffer->Ptr(0));
616 CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream
618 void CSpeechRecognitionCustomCommandParser::DoCopyModelBankIDArrayL(TMMFMessage& aMessage)
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]);
628 aMessage.WriteDataToClientL(dataBuffer->Ptr(0));
630 iModelBankIDs.Close();
631 CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream
634 void CSpeechRecognitionCustomCommandParser::DoCopyGrammarIDArrayL(TMMFMessage& aMessage)
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]);
644 aMessage.WriteDataToClientL(dataBuffer->Ptr(0));
647 CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream
651 //--------------------------------------------------------------------------------------------------------------------
654 void CSpeechRecognitionCustomCommandParser::DoCopyIntArrayL(TMMFMessage& aMessage, const RArray<TInt>& aArray)
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]);
664 aMessage.WriteDataToClientL(dataBuffer->Ptr(0));
665 CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream
668 void CSpeechRecognitionCustomCommandParser::DoExtractIntArrayFromData1L(TMMFMessage& aMessage, RArray<TInt>& aArray)
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);
679 void CSpeechRecognitionCustomCommandParser::DoExtractIntArrayFromData2L(TMMFMessage& aMessage, RArray<TInt>& aArray)
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);
691 void CSpeechRecognitionCustomCommandParser::DoExtractIntArrayL(TDes8& aDescriptor, RArray<TInt>& aArray)
693 RDesReadStream stream(aDescriptor);
694 CleanupClosePushL(stream);
697 numberElements = stream.ReadInt32L();
699 for (TInt i=0; i<numberElements; i++)
701 User::LeaveIfError(aArray.Append(stream.ReadInt32L()));
703 CleanupStack::PopAndDestroy(&stream); //stream
707 void CSpeechRecognitionCustomCommandParser::DoExternalizeResultSetL()
710 iResultCopyBuffer = CBufFlat::NewL(KExpandSize);
711 RBufWriteStream stream;
712 stream.Open(*iResultCopyBuffer);
713 CleanupClosePushL(stream);
714 iResultSet->ExternalizeL(stream);
717 CleanupStack::PopAndDestroy(&stream); //stream
719 void CSpeechRecognitionCustomCommandParser::DoCopyResultSetL(TMMFMessage& aMessage)
721 aMessage.WriteDataToClientL(iResultCopyBuffer->Ptr(0));
722 delete iResultCopyBuffer;
723 iResultCopyBuffer = NULL;