sl@0: // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: sl@0: #include sl@0: #include "SpeechRecognitionCustomCommandCommon.h" sl@0: sl@0: const TInt KExpandSize = 10; sl@0: sl@0: sl@0: EXPORT_C CSpeechRecognitionCustomCommandParser* CSpeechRecognitionCustomCommandParser::NewL( sl@0: MSpeechRecognitionCustomCommandImplementor& aImplementor) sl@0: { sl@0: CSpeechRecognitionCustomCommandParser* self = new (ELeave) CSpeechRecognitionCustomCommandParser(aImplementor); sl@0: return self; sl@0: } sl@0: sl@0: EXPORT_C CSpeechRecognitionCustomCommandParser::~CSpeechRecognitionCustomCommandParser() sl@0: { sl@0: iPronunciationIDs.Close(); sl@0: iRuleIDs.Close(); sl@0: iModelIDs.Close(); sl@0: iModelBankIDs.Close(); sl@0: iGrammarIDs.Close(); sl@0: iLexiconIDs.Close(); sl@0: delete iResultSet; sl@0: delete iResultCopyBuffer; sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::HandleRequest(TMMFMessage& aMessage) sl@0: { sl@0: TInt err; sl@0: if (aMessage.Destination().InterfaceId() == KUidInterfaceSpeechRecognition) sl@0: { sl@0: TRAP(err, DoHandleRequestL(aMessage)); sl@0: aMessage.Complete(err); sl@0: } sl@0: else sl@0: aMessage.Complete(KErrNotSupported); sl@0: } sl@0: sl@0: sl@0: CSpeechRecognitionCustomCommandParser::CSpeechRecognitionCustomCommandParser(MSpeechRecognitionCustomCommandImplementor& aImplementor) sl@0: : CMMFCustomCommandParserBase(KUidInterfaceSpeechRecognition), iImplementor(aImplementor) sl@0: { sl@0: sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoHandleRequestL(TMMFMessage& aMessage) sl@0: { sl@0: TPckgBuf pckgSize; sl@0: sl@0: switch (aMessage.Function()) sl@0: { sl@0: case ESrAddPronunciation: sl@0: DoAddPronunciationL(aMessage); sl@0: break; sl@0: case ESrAddRule: sl@0: DoAddRuleL(aMessage); sl@0: break; sl@0: case ESrCancel: sl@0: DoCancel(); sl@0: break; sl@0: case ESrCommitChanges: sl@0: DoCommitChangesL(); sl@0: break; sl@0: case ESrCreateGrammar: sl@0: DoCreateGrammarL(aMessage); sl@0: break; sl@0: case ESrCreateLexicon: sl@0: DoCreateLexiconL(aMessage); sl@0: break; sl@0: case ESrCreateModelBank: sl@0: DoCreateModelBankL(aMessage); sl@0: break; sl@0: case ESrEndRecSession: sl@0: DoEndRecSessionL(); sl@0: break; sl@0: case ESrGetAllModelIDs: sl@0: DoGetAllModelIDsL(aMessage); sl@0: break; sl@0: case ESrGetAllPronunciationIDs: sl@0: DoGetAllPronunciationIDsL(aMessage); sl@0: break; sl@0: case ESrGetAllRuleIDs: sl@0: DoGetAllRuleIDsL(aMessage); sl@0: break; sl@0: case ESrGetAllModelBankIDs: sl@0: DoGetAllModelBankIDsL(); sl@0: break; sl@0: case ESrGetAllLexiconIDs: sl@0: DoGetAllLexiconIDsL(); sl@0: break; sl@0: case ESrGetAllGrammarIDs: sl@0: DoGetAllGrammarIDsL(); sl@0: break; sl@0: case ESrGetAllClientModelBankIDs: sl@0: DoGetAllClientModelBankIDsL(); sl@0: break; sl@0: case ESrGetAllClientLexiconIDs: sl@0: DoGetAllClientLexiconIDsL(); sl@0: break; sl@0: case ESrGetAllClientGrammarIDs: sl@0: DoGetAllClientGrammarIDsL(); sl@0: break; sl@0: case ESrGetAvailableStorage: sl@0: DoGetAvailableStorageL(aMessage); sl@0: break; sl@0: case ESrGetEngineProperties: sl@0: DoGetEnginePropertiesL(aMessage); sl@0: break; sl@0: case ESrGetModelCount: sl@0: DoGetModelCountL(aMessage); sl@0: break; sl@0: case ESrGetRuleValidity: sl@0: DoGetRuleValidityL(aMessage); sl@0: break; sl@0: case ESrUtteranceDuration: sl@0: DoGetUtteranceDurationL(aMessage); sl@0: break; sl@0: case ESrLoadGrammar: sl@0: DoLoadGrammarL(aMessage); sl@0: break; sl@0: case ESrLoadLexicon: sl@0: DoLoadLexiconL(aMessage); sl@0: break; sl@0: case ESrLoadModels: sl@0: DoLoadModelsL(aMessage); sl@0: break; sl@0: case ESrPlayUtterance: sl@0: DoPlayUtteranceL(aMessage); sl@0: break; sl@0: case ESrRecognize: sl@0: DoRecognizeL(aMessage); sl@0: break; sl@0: case ESrRecord: sl@0: DoRecordL(aMessage); sl@0: break; sl@0: case ESrRemoveGrammar: sl@0: DoRemoveGrammarL(aMessage); sl@0: break; sl@0: case ESrRemoveLexicon: sl@0: DoRemoveLexiconL(aMessage); sl@0: break; sl@0: case ESrRemoveModelBank: sl@0: DoRemoveModelBankL(aMessage); sl@0: break; sl@0: case ESrRemoveModel: sl@0: DoRemoveModelL(aMessage); sl@0: break; sl@0: case ESrRemovePronunciation: sl@0: DoRemovePronunciationL(aMessage); sl@0: break; sl@0: case ESrRemoveRule: sl@0: DoRemoveRuleL(aMessage); sl@0: break; sl@0: case ESrStartRecSession: sl@0: DoStartRecSessionL(aMessage); sl@0: break; sl@0: case ESrTrain: sl@0: DoTrainL(aMessage); sl@0: break; sl@0: case ESrUnloadRule: sl@0: DoUnloadRuleL(aMessage); sl@0: break; sl@0: case ESrLoadEngineParameters: sl@0: DoLoadEngineParametersL(aMessage); sl@0: break; sl@0: case ESrGetPronunciationIDArraySize: sl@0: pckgSize() = iPronunciationIDs.Count(); sl@0: aMessage.WriteDataToClientL(pckgSize); sl@0: break; sl@0: case ESrGetPronunciationIDArrayContents: sl@0: DoCopyPronunciationIDArrayL(aMessage); sl@0: break; sl@0: case ESrGetRuleIDArraySize: sl@0: pckgSize() = iRuleIDs.Count(); sl@0: aMessage.WriteDataToClientL(pckgSize); sl@0: break; sl@0: case ESrGetRuleIDArrayContents: sl@0: DoCopyRuleIDArrayL(aMessage); sl@0: break; sl@0: case ESrGetModelIDArraySize: sl@0: pckgSize() = iModelIDs.Count(); sl@0: aMessage.WriteDataToClientL(pckgSize); sl@0: break; sl@0: case ESrGetModelIDArrayContents: sl@0: DoCopyModelIDArrayL(aMessage); sl@0: break; sl@0: case ESrGetLexiconIDArraySize: sl@0: pckgSize() = iLexiconIDs.Count(); sl@0: aMessage.WriteDataToClientL(pckgSize); sl@0: break; sl@0: case ESrGetLexiconIDArrayContents: sl@0: DoCopyLexiconIDArrayL(aMessage); sl@0: break; sl@0: case ESrGetGrammarIDArraySize: sl@0: pckgSize() = iGrammarIDs.Count(); sl@0: aMessage.WriteDataToClientL(pckgSize); sl@0: break; sl@0: case ESrGetGrammarIDArrayContents: sl@0: DoCopyGrammarIDArrayL(aMessage); sl@0: break; sl@0: case ESrGetModelBankIDArraySize: sl@0: pckgSize() = iModelBankIDs.Count(); sl@0: aMessage.WriteDataToClientL(pckgSize); sl@0: break; sl@0: case ESrGetModelBankIDArrayContents: sl@0: DoCopyModelBankIDArrayL(aMessage); sl@0: break; sl@0: case ESrGetClientResultSetSize: sl@0: DoExternalizeResultSetL(); sl@0: pckgSize() = iResultCopyBuffer->Size(); sl@0: aMessage.WriteDataToClientL(pckgSize); sl@0: break; sl@0: case ESrGetClientResultSet: sl@0: DoCopyResultSetL(aMessage); sl@0: break; sl@0: case ESrSetClientUid: sl@0: DoSetClientUidL(aMessage); sl@0: break; sl@0: default: sl@0: User::Leave(KErrNotSupported); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoAddPronunciationL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsAddPronunciationPckg pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: iImplementor.MSrAddPronunciationL(pckg().iLexiconID, pckg().iModelBankID, pckg().iModelID, *pckg().iPronunciationID); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoAddRuleL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsAddRulePckg pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: iImplementor.MSrAddRuleL(pckg().iGrammarID, pckg().iLexiconID, pckg().iPronunciationID, *pckg().iRuleID); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoCancel() sl@0: { sl@0: iImplementor.MSrCancel(); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoCommitChangesL() sl@0: { sl@0: iImplementor.MSrCommitChangesL(); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoCreateGrammarL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsGrammarIDPtrPckg pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: iImplementor.MSrCreateGrammarL(*pckg()); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoCreateLexiconL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsLexiconIDPtrPckg pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: iImplementor.MSrCreateLexiconL(*pckg()); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoCreateModelBankL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsModelBankIDPtrPckg pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: iImplementor.MSrCreateModelBankL(*pckg()); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoEndRecSessionL() sl@0: { sl@0: iImplementor.MSrEndRecSessionL(); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoGetAllModelIDsL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsModelBankIDPckg pckgModelBank; sl@0: iModelIDs.Reset(); sl@0: aMessage.ReadData1FromClientL(pckgModelBank); sl@0: iImplementor.MSrGetAllModelIDsL(pckgModelBank(), iModelIDs); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoGetAllPronunciationIDsL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsLexiconIDPckg pckgLexicon; sl@0: iPronunciationIDs.Reset(); sl@0: aMessage.ReadData1FromClientL(pckgLexicon); sl@0: iImplementor.MSrGetAllPronunciationIDsL(pckgLexicon(), iPronunciationIDs); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoGetAllRuleIDsL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsGrammarIDPckg pckgGrammar; sl@0: iRuleIDs.Reset(); sl@0: aMessage.ReadData1FromClientL(pckgGrammar); sl@0: iImplementor.MSrGetAllRuleIDsL(pckgGrammar(), iRuleIDs); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoGetAllModelBankIDsL() sl@0: { sl@0: iModelBankIDs.Reset(); sl@0: iImplementor.MSrGetAllModelBankIDsL(iModelBankIDs); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoGetAllLexiconIDsL() sl@0: { sl@0: iLexiconIDs.Reset(); sl@0: iImplementor.MSrGetAllLexiconIDsL(iLexiconIDs); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoGetAllGrammarIDsL() sl@0: { sl@0: iGrammarIDs.Reset(); sl@0: iImplementor.MSrGetAllGrammarIDsL(iGrammarIDs); sl@0: } sl@0: sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoGetAllClientModelBankIDsL() sl@0: { sl@0: iModelBankIDs.Reset(); sl@0: iImplementor.MSrGetAllClientModelBankIDsL(iModelBankIDs); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoGetAllClientLexiconIDsL() sl@0: { sl@0: iLexiconIDs.Reset(); sl@0: iImplementor.MSrGetAllClientLexiconIDsL(iLexiconIDs); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoGetAllClientGrammarIDsL() sl@0: { sl@0: iGrammarIDs.Reset(); sl@0: iImplementor.MSrGetAllClientGrammarIDsL(iGrammarIDs); sl@0: } sl@0: sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoGetAvailableStorageL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsIntPtrPckg pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: iImplementor.MSrGetAvailableStorageL(*pckg()); sl@0: } sl@0: sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoGetModelCountL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsModelBankIDPckg pckgModelBank; sl@0: TSrsIntPtrPckg pckgResult; sl@0: aMessage.ReadData1FromClientL(pckgModelBank); sl@0: aMessage.ReadData2FromClientL(pckgResult); sl@0: iImplementor.MSrGetModelCountL(pckgModelBank(),*pckgResult()); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoGetRuleValidityL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsRuleValidityPckg pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: iImplementor.MSrGetRuleValidityL(pckg().iGrammarID, pckg().iRuleID, *pckg().iRuleValid); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoGetUtteranceDurationL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsGetUtteranceDurationPckg pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: iImplementor.MSrGetUtteranceDurationL(pckg().iModelBankID, pckg().iModelID, *pckg().iDuration); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoLoadGrammarL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsGrammarIDPckg pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: iImplementor.MSrLoadGrammarL(pckg()); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoLoadLexiconL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsLexiconIDPckg pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: iImplementor.MSrLoadLexiconL(pckg()); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoLoadModelsL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsModelBankIDPckg pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: iImplementor.MSrLoadModelsL(pckg()); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoPlayUtteranceL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsPlayUtterancePckg pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: iImplementor.MSrPlayUtteranceL(pckg().iModelBankID, pckg().iModelID); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoSetClientUidL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsUidPckg pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: iImplementor.MSrSetClientUid(pckg()); sl@0: } sl@0: sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoRecognizeL(TMMFMessage& aMessage) sl@0: { sl@0: if (iResultSet) sl@0: User::Leave(KErrInUse); sl@0: sl@0: TInt size; sl@0: size = User::LeaveIfError(aMessage.SizeOfData1FromClient()); sl@0: HBufC8* dataBuffer = HBufC8::NewLC(size); sl@0: TPtr8 buf = dataBuffer->Des(); sl@0: aMessage.ReadData1FromClientL(buf); sl@0: RDesReadStream stream(buf); sl@0: CleanupClosePushL(stream); sl@0: iResultSet = CSDClientResultSet::NewL(); sl@0: TInt err = KErrNone; sl@0: TRAP(err, iResultSet->InternalizeL(stream)); sl@0: if (err == KErrNone) sl@0: { sl@0: TRAP(err, iImplementor.MSrRecognizeL(*iResultSet)); sl@0: } sl@0: if (err!=KErrNone) sl@0: { sl@0: delete iResultSet; sl@0: iResultSet = NULL; sl@0: User::Leave(err); sl@0: } sl@0: CleanupStack::PopAndDestroy(2, dataBuffer);//dataBuffer, stream sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoRecordL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsTimeIntervalMicroSeconds32Pckg pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: iImplementor.MSrRecordL(pckg()); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoRemoveGrammarL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsGrammarIDPckg pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: iImplementor.MSrRemoveGrammarL(pckg()); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoRemoveLexiconL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsLexiconIDPckg pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: iImplementor.MSrRemoveLexiconL(pckg()); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoRemoveModelBankL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsModelBankIDPckg pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: iImplementor.MSrRemoveModelBankL(pckg()); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoRemoveModelL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsModelBankIDPckg pckgModelBankID; sl@0: TSrsModelIDPckg pckgModelID; sl@0: aMessage.ReadData1FromClientL(pckgModelBankID); sl@0: aMessage.ReadData2FromClientL(pckgModelID); sl@0: iImplementor.MSrRemoveModelL(pckgModelBankID(), pckgModelID()); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoRemovePronunciationL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsLexiconIDPckg pckgLexicon; sl@0: TSrsPronunciationIDPckg pckgPronunciation; sl@0: aMessage.ReadData1FromClientL(pckgLexicon); sl@0: aMessage.ReadData2FromClientL(pckgPronunciation); sl@0: iImplementor.MSrRemovePronunciationL(pckgLexicon(), pckgPronunciation()); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoRemoveRuleL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsGrammarIDPckg pckgGrammar; sl@0: TSrsRuleIDPckg pckgRule; sl@0: aMessage.ReadData1FromClientL(pckgGrammar); sl@0: aMessage.ReadData2FromClientL(pckgRule); sl@0: iImplementor.MSrRemoveRuleL(pckgGrammar(), pckgRule()); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoStartRecSessionL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsRecognitionModePckg pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: iImplementor.MSrStartRecSessionL(pckg()); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoTrainL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsModelBankIDPckg pckgModelBankID; sl@0: TSrsModelIDPtrPckg pckgModelIDPtr; sl@0: aMessage.ReadData1FromClientL(pckgModelBankID); sl@0: aMessage.ReadData2FromClientL(pckgModelIDPtr); sl@0: iImplementor.MSrTrainL(pckgModelBankID(),*pckgModelIDPtr()); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoUnloadRuleL(TMMFMessage& aMessage) sl@0: { sl@0: TSrsGrammarIDPckg pckgGrammar; sl@0: TSrsRuleIDPckg pckgRule; sl@0: aMessage.ReadData1FromClientL(pckgGrammar); sl@0: aMessage.ReadData2FromClientL(pckgRule); sl@0: iImplementor.MSrUnloadRuleL(pckgGrammar(), pckgRule()); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoLoadEngineParametersL(TMMFMessage& aMessage) sl@0: { sl@0: RArray parameters; sl@0: RArray values; sl@0: CleanupClosePushL(parameters); sl@0: CleanupClosePushL(values); sl@0: DoExtractIntArrayFromData1L(aMessage, parameters); sl@0: DoExtractIntArrayFromData2L(aMessage, values); sl@0: iImplementor.MSrLoadEngineParametersL(parameters,values); sl@0: CleanupStack::PopAndDestroy(2, ¶meters); // parameters, values sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoGetEnginePropertiesL(TMMFMessage& aMessage) sl@0: { sl@0: RArray propertyIDs; sl@0: RArray propertyValues; sl@0: CleanupClosePushL(propertyIDs); sl@0: CleanupClosePushL(propertyValues); sl@0: DoExtractIntArrayFromData1L(aMessage, propertyIDs); sl@0: sl@0: iImplementor.MSrGetEnginePropertiesL(propertyIDs,propertyValues); sl@0: // the custom command is aware of the size of the result, so it can copy the data back directly sl@0: DoCopyIntArrayL(aMessage, propertyValues); sl@0: CleanupStack::PopAndDestroy(2, &propertyIDs); // property IDs, property values sl@0: } sl@0: sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoCopyPronunciationIDArrayL(TMMFMessage& aMessage) sl@0: { sl@0: CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize); sl@0: CleanupStack::PushL(dataBuffer); sl@0: RBufWriteStream stream; sl@0: stream.Open(*dataBuffer); sl@0: CleanupClosePushL(stream); sl@0: for (TInt i=0;iPtr(0)); sl@0: sl@0: iPronunciationIDs.Close(); sl@0: CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream sl@0: } sl@0: void CSpeechRecognitionCustomCommandParser::DoCopyModelIDArrayL(TMMFMessage& aMessage) sl@0: { sl@0: CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize); sl@0: CleanupStack::PushL(dataBuffer); sl@0: RBufWriteStream stream; sl@0: stream.Open(*dataBuffer); sl@0: CleanupClosePushL(stream); sl@0: for (TInt i=0;iPtr(0)); sl@0: sl@0: iModelIDs.Close(); sl@0: CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoCopyRuleIDArrayL(TMMFMessage& aMessage) sl@0: { sl@0: CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize); sl@0: CleanupStack::PushL(dataBuffer); sl@0: RBufWriteStream stream; sl@0: stream.Open(*dataBuffer); sl@0: CleanupClosePushL(stream); sl@0: for (TInt i=0;iPtr(0)); sl@0: sl@0: iRuleIDs.Close(); sl@0: CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------------------------------------------ sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoCopyLexiconIDArrayL(TMMFMessage& aMessage) sl@0: { sl@0: CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize); sl@0: CleanupStack::PushL(dataBuffer); sl@0: RBufWriteStream stream; sl@0: stream.Open(*dataBuffer); sl@0: CleanupClosePushL(stream); sl@0: for (TInt i=0;iPtr(0)); sl@0: sl@0: iLexiconIDs.Close(); sl@0: CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream sl@0: } sl@0: void CSpeechRecognitionCustomCommandParser::DoCopyModelBankIDArrayL(TMMFMessage& aMessage) sl@0: { sl@0: CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize); sl@0: CleanupStack::PushL(dataBuffer); sl@0: RBufWriteStream stream; sl@0: stream.Open(*dataBuffer); sl@0: CleanupClosePushL(stream); sl@0: for (TInt i=0;iPtr(0)); sl@0: sl@0: iModelBankIDs.Close(); sl@0: CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoCopyGrammarIDArrayL(TMMFMessage& aMessage) sl@0: { sl@0: CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize); sl@0: CleanupStack::PushL(dataBuffer); sl@0: RBufWriteStream stream; sl@0: stream.Open(*dataBuffer); sl@0: CleanupClosePushL(stream); sl@0: for (TInt i=0;iPtr(0)); sl@0: sl@0: iGrammarIDs.Close(); sl@0: CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream sl@0: } sl@0: sl@0: sl@0: //-------------------------------------------------------------------------------------------------------------------- sl@0: sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoCopyIntArrayL(TMMFMessage& aMessage, const RArray& aArray) sl@0: { sl@0: CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize); sl@0: CleanupStack::PushL(dataBuffer); sl@0: RBufWriteStream stream; sl@0: stream.Open(*dataBuffer); sl@0: CleanupClosePushL(stream); sl@0: for (TInt i=0;iPtr(0)); sl@0: CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoExtractIntArrayFromData1L(TMMFMessage& aMessage, RArray& aArray) sl@0: { sl@0: TInt size = User::LeaveIfError(aMessage.SizeOfData1FromClient()); sl@0: HBufC8* buf = HBufC8::NewL(size); sl@0: CleanupStack::PushL(buf); sl@0: TPtr8 ptr = buf->Des(); sl@0: aMessage.ReadData1FromClientL(ptr); sl@0: DoExtractIntArrayL(ptr,aArray); sl@0: CleanupStack::PopAndDestroy(buf); sl@0: } sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoExtractIntArrayFromData2L(TMMFMessage& aMessage, RArray& aArray) sl@0: { sl@0: TInt size = User::LeaveIfError(aMessage.SizeOfData2FromClient()); sl@0: HBufC8* buf = HBufC8::NewL(size); sl@0: CleanupStack::PushL(buf); sl@0: TPtr8 ptr = buf->Des(); sl@0: aMessage.ReadData2FromClientL(ptr); sl@0: DoExtractIntArrayL(ptr,aArray); sl@0: CleanupStack::PopAndDestroy(buf); sl@0: } sl@0: sl@0: sl@0: void CSpeechRecognitionCustomCommandParser::DoExtractIntArrayL(TDes8& aDescriptor, RArray& aArray) sl@0: { sl@0: RDesReadStream stream(aDescriptor); sl@0: CleanupClosePushL(stream); sl@0: sl@0: TInt numberElements; sl@0: numberElements = stream.ReadInt32L(); sl@0: sl@0: for (TInt i=0; iExternalizeL(stream); sl@0: delete iResultSet; sl@0: iResultSet = NULL; sl@0: CleanupStack::PopAndDestroy(&stream); //stream sl@0: } sl@0: void CSpeechRecognitionCustomCommandParser::DoCopyResultSetL(TMMFMessage& aMessage) sl@0: { sl@0: aMessage.WriteDataToClientL(iResultCopyBuffer->Ptr(0)); sl@0: delete iResultCopyBuffer; sl@0: iResultCopyBuffer = NULL; sl@0: }