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: // SpeechRecognitionUtility.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include sl@0: #include "SpeechRecognitionUtilityBody.h" sl@0: sl@0: //_LIT(KMMFSpeechRecognitionUtilityPanic,"Speech Recognition Utility Bad State"); sl@0: enum ASRPanics sl@0: { sl@0: KMMFSpeechRecognitionUtilityPanicBadState, sl@0: KMMFSpeechRecognitionUtilityPanicUnrecognisedEvent sl@0: }; sl@0: sl@0: CSpeechRecognitionUtility::CBody* CSpeechRecognitionUtility::CBody::NewL( TUid aClientUid, MSpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver) sl@0: { sl@0: CSpeechRecognitionUtility::CBody* self = CSpeechRecognitionUtility::CBody::NewLC(aClientUid, aSpeechRecognitionUtilityObserver); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CSpeechRecognitionUtility::CBody* CSpeechRecognitionUtility::CBody::NewLC(TUid aClientUid, MSpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver) sl@0: { sl@0: CSpeechRecognitionUtility::CBody* self = new(ELeave) CSpeechRecognitionUtility::CBody(aClientUid, aSpeechRecognitionUtilityObserver); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: return self; sl@0: } sl@0: sl@0: void CSpeechRecognitionUtility::CBody::ConstructL() sl@0: { sl@0: iAudioPriority = EMdaPriorityNormal; sl@0: iTrainPreference = EMdaPriorityPreferenceNone; sl@0: iRecognitionPreference = EMdaPriorityPreferenceNone; sl@0: iPlaybackPreference = EMdaPriorityPreferenceNone; sl@0: sl@0: iPrioritySettings.iPriority = iAudioPriority; sl@0: iPrioritySettings.iPref = iTrainPreference; sl@0: sl@0: iControllerEventMonitor = CMMFControllerEventMonitor::NewL(*this, iMMFController); sl@0: sl@0: RMMFControllerImplInfoArray controllers; sl@0: CleanupResetAndDestroyPushL(controllers); sl@0: sl@0: CMMFControllerPluginSelectionParameters* cSelect = CMMFControllerPluginSelectionParameters::NewLC(); sl@0: sl@0: // Select the media IDs to allow sl@0: RArray mediaIds; sl@0: CleanupClosePushL(mediaIds); sl@0: User::LeaveIfError(mediaIds.Append(KUidMediaTypeASR)); sl@0: cSelect->SetMediaIdsL(mediaIds,CMMFPluginSelectionParameters::EAllowOnlySuppliedMediaIds); sl@0: CleanupStack::PopAndDestroy(&mediaIds); sl@0: sl@0: cSelect->ListImplementationsL(controllers); sl@0: sl@0: //[ Open and configure a controller] sl@0: iControllerEventMonitor->Cancel(); sl@0: iMMFController.Close(); sl@0: //[check controller array is not empty] sl@0: if( ! controllers.Count() ) sl@0: User::Leave( KErrNotFound ); sl@0: sl@0: //[ simply open the first controller in the array ] sl@0: User::LeaveIfError( iMMFController.Open(controllers[0]->Uid(), iPrioritySettings)); sl@0: iControllerEventMonitor->Start(); sl@0: sl@0: iSrCustomCommands.SetClientUid(iClientUid); sl@0: sl@0: CleanupStack::PopAndDestroy(2, &controllers);//controllers, cSelect sl@0: sl@0: } sl@0: sl@0: CSpeechRecognitionUtility::CBody::CBody(TUid aClientUid, MSpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver) sl@0: : iSrCustomCommands(iMMFController), sl@0: iSpeechRecognitionUtilityObserver(&aSpeechRecognitionUtilityObserver), sl@0: iClientUid(aClientUid) sl@0: { sl@0: } sl@0: sl@0: CSpeechRecognitionUtility::CBody::~CBody() sl@0: { sl@0: if (iControllerEventMonitor) sl@0: { sl@0: iControllerEventMonitor->Cancel(); sl@0: delete iControllerEventMonitor; sl@0: } sl@0: iMMFController.Close(); sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::GetEngineProperties(const RArray& aPropertyIDs, RArray& aPropertyValues) sl@0: { sl@0: aPropertyValues.Reset(); sl@0: return iSrCustomCommands.GetEngineProperties(aPropertyIDs, aPropertyValues); sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::AddPronunciation(TLexiconID aLexiconID, TModelBankID aModelBankID, TModelID aModelID, TPronunciationID& aPronunciationID) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: TInt err = iSrCustomCommands.AddPronunciation(aLexiconID, aModelBankID, aModelID, aPronunciationID); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy=ETrue; sl@0: return err; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::AddRule(TGrammarID aGrammarID, TLexiconID aLexiconID, TPronunciationID aPronunciationID, TRuleID& aRuleID) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: TInt err = iSrCustomCommands.AddRule(aGrammarID, aLexiconID, aPronunciationID, aRuleID); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy=ETrue; sl@0: return err; sl@0: sl@0: } sl@0: sl@0: void CSpeechRecognitionUtility::CBody::Cancel() sl@0: { sl@0: iSrCustomCommands.Cancel(); sl@0: // Now cancel has been called, so remove any pointers storing references to arrays to be filled sl@0: // These arrays are not owned by this object, so they must not be destroyed sl@0: iPronunciationIDs = NULL; sl@0: iRuleIDs = NULL; sl@0: iModelIDs = NULL; sl@0: iAsyncCallBusy = EFalse; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::CommitChanges() sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: return iSrCustomCommands.CommitChanges(); sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::CreateGrammar(TGrammarID& aGrammarID) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: TInt err = iSrCustomCommands.CreateGrammar(aGrammarID); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy=ETrue; sl@0: return err; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::CreateLexicon(TLexiconID& aLexiconID) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: TInt err = iSrCustomCommands.CreateLexicon(aLexiconID); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy=ETrue; sl@0: return err; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::LoadModels(TModelBankID aModelBankID) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: TInt err = iSrCustomCommands.LoadModels(aModelBankID); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy=ETrue; sl@0: sl@0: return err; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::LoadGrammar(TGrammarID aGrammarID) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: TInt err = iSrCustomCommands.LoadGrammar(aGrammarID); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy=ETrue; sl@0: sl@0: return err; sl@0: sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::LoadLexicon(TLexiconID aLexiconID) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: TInt err = iSrCustomCommands.LoadLexicon(aLexiconID); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy=ETrue; sl@0: sl@0: return err; sl@0: sl@0: } sl@0: sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::GetUtteranceDuration(TModelBankID aModelBankID, TModelID aModelID, TTimeIntervalMicroSeconds32& aDuration) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: TInt err = iSrCustomCommands.GetUtteranceDuration(aModelBankID, aModelID, aDuration); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy=ETrue; sl@0: sl@0: return err; sl@0: } sl@0: sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::PlayUtterance(TModelBankID aModelBankID, TModelID aModelID) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: iPrioritySettings.iPriority = iAudioPriority; sl@0: iPrioritySettings.iPref = iPlaybackPreference; sl@0: sl@0: TInt err = iMMFController.SetPrioritySettings(iPrioritySettings); sl@0: sl@0: if (err == KErrNone) sl@0: err = iSrCustomCommands.PlayUtterance(aModelBankID, aModelID); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy=ETrue; sl@0: sl@0: return err; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::GetModelCount(TModelBankID aModelBankID, TInt& aModelCount) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: TInt err = iSrCustomCommands.GetModelCount(aModelBankID, aModelCount); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy=ETrue; sl@0: sl@0: return err; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::StartRecSession(TRecognitionMode aMode) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: return iSrCustomCommands.StartRecSession(aMode); sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::EndRecSession() sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: return iSrCustomCommands.EndRecSession(); sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::Recognize(CSDClientResultSet& aResultSet) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: ASSERT(iResultSet==NULL); // this should be NULL unless we have problems sl@0: sl@0: iPrioritySettings.iPriority = iAudioPriority; sl@0: iPrioritySettings.iPref = iRecognitionPreference; sl@0: TInt err = iMMFController.SetPrioritySettings(iPrioritySettings); sl@0: sl@0: if (err == KErrNone) sl@0: err = iSrCustomCommands.Recognize(aResultSet); sl@0: sl@0: if (err == KErrNone) sl@0: { sl@0: iResultSet = &aResultSet; sl@0: iAsyncCallBusy = ETrue; sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::Record(TTimeIntervalMicroSeconds32 aRecordTime) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: TInt err = iSrCustomCommands.Record(aRecordTime); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy=ETrue; sl@0: sl@0: return err; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::RemoveGrammar(TGrammarID aGrammarID) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: TInt err = iSrCustomCommands.RemoveGrammar(aGrammarID); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy = ETrue; sl@0: return err; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::RemovePronunciation(TLexiconID aLexiconID, TPronunciationID aPronunciationID) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: TInt err = iSrCustomCommands.RemovePronunciation(aLexiconID, aPronunciationID); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy = ETrue; sl@0: return err; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::RemoveLexicon(TLexiconID aLexiconID) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: TInt err = iSrCustomCommands.RemoveLexicon(aLexiconID); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy = ETrue; sl@0: return err; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::RemoveModel(TModelBankID aModelBankID, TModelID aModelID) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: TInt err = iSrCustomCommands.RemoveModel(aModelBankID, aModelID); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy = ETrue; sl@0: sl@0: return err; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::RemoveRule(TGrammarID aGrammarID, TRuleID aRuleID) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: TInt err = iSrCustomCommands.RemoveRule(aGrammarID, aRuleID); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy = ETrue; sl@0: sl@0: return err; sl@0: sl@0: } sl@0: TInt CSpeechRecognitionUtility::CBody::Train(TModelBankID aModelBankID, TModelID& aModelID) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: iPrioritySettings.iPriority = iAudioPriority; sl@0: iPrioritySettings.iPref = iTrainPreference; sl@0: TInt err = iMMFController.SetPrioritySettings(iPrioritySettings); sl@0: sl@0: if (err == KErrNone) sl@0: err = iSrCustomCommands.Train(aModelBankID, aModelID); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy = ETrue; sl@0: sl@0: return err; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::UnloadRule(TGrammarID aGrammarID, TRuleID aRuleID) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: TInt err = iSrCustomCommands.UnloadRule(aGrammarID, aRuleID); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy = ETrue; sl@0: sl@0: return err; sl@0: sl@0: } sl@0: sl@0: void CSpeechRecognitionUtility::CBody::SetEventHandler(MSpeechRecognitionUtilityObserver* aSpeechRecognitionUtilityObserver) sl@0: { sl@0: iSpeechRecognitionUtilityObserver = aSpeechRecognitionUtilityObserver; sl@0: } sl@0: sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::GetAllPronunciationIDs(TLexiconID aLexiconID, RArray & aPronunciationIDs) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: ASSERT(iPronunciationIDs==NULL); sl@0: sl@0: TInt err = iSrCustomCommands.GetAllPronunciationIDs(aLexiconID); sl@0: sl@0: if (err==KErrNone) sl@0: { sl@0: iPronunciationIDs = &aPronunciationIDs; sl@0: iPronunciationIDs->Reset(); sl@0: iAsyncCallBusy = ETrue; sl@0: } sl@0: sl@0: return err; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::GetAllModelIDs(TModelBankID aModelBankID, RArray & aModelIDs) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: ASSERT(iModelIDs==NULL); sl@0: sl@0: TInt err = iSrCustomCommands.GetAllModelIDs(aModelBankID); sl@0: sl@0: if (err==KErrNone) sl@0: { sl@0: iModelIDs = &aModelIDs; sl@0: iModelIDs->Reset(); sl@0: iAsyncCallBusy = ETrue; sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::GetAllRuleIDs(TGrammarID aGrammarID, RArray & aRuleIDs) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: ASSERT(iRuleIDs==NULL); sl@0: sl@0: TInt err = iSrCustomCommands.GetAllRuleIDs(aGrammarID); sl@0: sl@0: if (err==KErrNone) sl@0: { sl@0: iRuleIDs = &aRuleIDs; sl@0: iRuleIDs->Reset(); sl@0: iAsyncCallBusy = ETrue; sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::GetAllClientLexiconIDs(RArray & aLexiconIDs) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: ASSERT(iLexiconIDs==NULL); sl@0: sl@0: TInt err = iSrCustomCommands.GetAllClientLexiconIDs(); sl@0: sl@0: if (err==KErrNone) sl@0: { sl@0: iLexiconIDs = &aLexiconIDs; sl@0: iLexiconIDs->Reset(); sl@0: iAsyncCallBusy = ETrue; sl@0: } sl@0: sl@0: return err; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::GetAllClientModelBankIDs(RArray & aModelBankIDs) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: ASSERT(iModelBankIDs==NULL); sl@0: sl@0: TInt err = iSrCustomCommands.GetAllClientModelBankIDs(); sl@0: sl@0: if (err==KErrNone) sl@0: { sl@0: iModelBankIDs = &aModelBankIDs; sl@0: iModelBankIDs->Reset(); sl@0: iAsyncCallBusy = ETrue; sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::GetAllClientGrammarIDs(RArray & aGrammarIDs) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: ASSERT(iGrammarIDs==NULL); sl@0: sl@0: TInt err = iSrCustomCommands.GetAllClientGrammarIDs(); sl@0: sl@0: if (err==KErrNone) sl@0: { sl@0: iGrammarIDs = &aGrammarIDs; sl@0: iGrammarIDs->Reset(); sl@0: iAsyncCallBusy = ETrue; sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::GetAllLexiconIDs(RArray & aLexiconIDs) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: ASSERT(iLexiconIDs==NULL); sl@0: sl@0: TInt err = iSrCustomCommands.GetAllLexiconIDs(); sl@0: sl@0: if (err==KErrNone) sl@0: { sl@0: iLexiconIDs = &aLexiconIDs; sl@0: iLexiconIDs->Reset(); sl@0: iAsyncCallBusy = ETrue; sl@0: } sl@0: sl@0: return err; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::GetAllModelBankIDs(RArray & aModelBankIDs) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: ASSERT(iModelBankIDs==NULL); sl@0: sl@0: TInt err = iSrCustomCommands.GetAllModelBankIDs(); sl@0: sl@0: if (err==KErrNone) sl@0: { sl@0: iModelBankIDs = &aModelBankIDs; sl@0: iModelBankIDs->Reset(); sl@0: iAsyncCallBusy = ETrue; sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::GetAllGrammarIDs(RArray & aGrammarIDs) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: ASSERT(iGrammarIDs==NULL); sl@0: sl@0: TInt err = iSrCustomCommands.GetAllGrammarIDs(); sl@0: sl@0: if (err==KErrNone) sl@0: { sl@0: iGrammarIDs = &aGrammarIDs; sl@0: iGrammarIDs->Reset(); sl@0: iAsyncCallBusy = ETrue; sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::GetRuleValidity(TGrammarID aGrammarID, TRuleID aRuleID, TBool& aValid) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: TInt err = iSrCustomCommands.GetRuleValidity(aGrammarID, aRuleID, aValid); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy = ETrue; sl@0: return err; sl@0: } sl@0: sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::CreateModelBank(TModelBankID& aModelBankID) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: TInt err = iSrCustomCommands.CreateModelBank(aModelBankID); sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy = ETrue; sl@0: return err; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::RemoveModelBank(TModelBankID aModelBankID) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: TInt err = iSrCustomCommands.RemoveModelBank(aModelBankID); sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy = ETrue; sl@0: return err; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::GetAvailableStorage(TInt& aAvailableStorage) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: TInt err = iSrCustomCommands.GetAvailableStorage(aAvailableStorage); sl@0: sl@0: if (err == KErrNone) sl@0: iAsyncCallBusy = ETrue; sl@0: sl@0: return err; sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::LoadEngineParameters(const RArray& aParameterId, const RArray& aParameterValue) sl@0: { sl@0: if (iAsyncCallBusy) sl@0: return KErrInUse; sl@0: sl@0: return iSrCustomCommands.LoadEngineParameters(aParameterId, aParameterValue); sl@0: } sl@0: sl@0: TInt CSpeechRecognitionUtility::CBody::SetAudioPriority(TInt aPriority, TInt aTrainPreference, TInt aPlaybackPreference, TInt aRecognitionPreference) sl@0: { sl@0: iAudioPriority = aPriority; sl@0: iTrainPreference = (TMdaPriorityPreference)aTrainPreference; sl@0: iPlaybackPreference = (TMdaPriorityPreference)aPlaybackPreference; sl@0: iRecognitionPreference = (TMdaPriorityPreference)aRecognitionPreference; sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: void CSpeechRecognitionUtility::CBody::HandleEvent(const TMMFEvent& aEvent) sl@0: { sl@0: TBool cancelled = EFalse; sl@0: TBool asyncCallComplete = ETrue; sl@0: sl@0: TUid event = aEvent.iEventType; sl@0: TInt errorCode = aEvent.iErrorCode; sl@0: sl@0: sl@0: switch (event.iUid) sl@0: { sl@0: case KUidAsrEventGetAllPronunciationIDsVal : sl@0: { sl@0: if (iPronunciationIDs) sl@0: { sl@0: if (errorCode==KErrNone) sl@0: TRAP(errorCode, iSrCustomCommands.GetPronunciationIDArrayL(*iPronunciationIDs)); sl@0: // async operation complete, so get rid of reference to array sl@0: iPronunciationIDs = NULL; sl@0: } sl@0: else sl@0: cancelled = ETrue; sl@0: } sl@0: break; sl@0: case KUidAsrEventGetAllRuleIDsVal : sl@0: { sl@0: if (iRuleIDs) sl@0: { sl@0: if (errorCode==KErrNone) sl@0: TRAP(errorCode, iSrCustomCommands.GetRuleIDArrayL(*iRuleIDs)); sl@0: // async operation complete, so get rid of reference to array sl@0: iRuleIDs = NULL; sl@0: } sl@0: else sl@0: cancelled = ETrue; sl@0: } sl@0: break; sl@0: case KUidAsrEventGetAllModelIDsVal : sl@0: { sl@0: if (iModelIDs) sl@0: { sl@0: if (errorCode==KErrNone) sl@0: TRAP(errorCode, iSrCustomCommands.GetModelIDArrayL(*iModelIDs)); sl@0: // async operation complete, so get rid of reference to array sl@0: iModelIDs = NULL; sl@0: } sl@0: else sl@0: cancelled = ETrue; sl@0: } sl@0: break; sl@0: case KUidAsrEventGetAllClientModelBankIDsVal : sl@0: case KUidAsrEventGetAllModelBankIDsVal : sl@0: { sl@0: if (iModelBankIDs) sl@0: { sl@0: if (errorCode==KErrNone) sl@0: TRAP(errorCode, iSrCustomCommands.GetModelBankIDArrayL(*iModelBankIDs)); sl@0: // async operation complete, so get rid of reference to array sl@0: iModelBankIDs = NULL; sl@0: } sl@0: else sl@0: cancelled = ETrue; sl@0: } sl@0: break; sl@0: case KUidAsrEventGetAllClientGrammarIDsVal : sl@0: case KUidAsrEventGetAllGrammarIDsVal : sl@0: { sl@0: if (iGrammarIDs) sl@0: { sl@0: if (errorCode==KErrNone) sl@0: TRAP(errorCode, iSrCustomCommands.GetGrammarIDArrayL(*iGrammarIDs)); sl@0: // async operation complete, so get rid of reference to array sl@0: iGrammarIDs = NULL; sl@0: } sl@0: else sl@0: cancelled = ETrue; sl@0: } sl@0: break; sl@0: case KUidAsrEventGetAllClientLexiconIDsVal : sl@0: case KUidAsrEventGetAllLexiconIDsVal : sl@0: { sl@0: if (iLexiconIDs) sl@0: { sl@0: if (errorCode==KErrNone) sl@0: TRAP(errorCode, iSrCustomCommands.GetLexiconIDArrayL(*iLexiconIDs)); sl@0: // async operation complete, so get rid of reference to array sl@0: iLexiconIDs = NULL; sl@0: } sl@0: else sl@0: cancelled = ETrue; sl@0: } sl@0: break; sl@0: sl@0: case KUidAsrEventRecognitionVal : sl@0: { sl@0: if (iResultSet) sl@0: { sl@0: if (errorCode==KErrNone) sl@0: TRAP(errorCode, iSrCustomCommands.GetResultSetL(*iResultSet)); sl@0: iResultSet = NULL; sl@0: } sl@0: else sl@0: cancelled = ETrue; sl@0: } sl@0: break; sl@0: case KUidAsrEventTrainVal: sl@0: break; sl@0: case KUidAsrEventPlayStartedVal: sl@0: case KUidAsrEventRecordStartedVal: sl@0: asyncCallComplete = EFalse; sl@0: break; sl@0: default: sl@0: break; sl@0: sl@0: } sl@0: if (event == KMMFErrorCategoryControllerGeneralError) sl@0: { sl@0: // clear these, as the error callback sl@0: iPronunciationIDs = NULL; sl@0: iRuleIDs = NULL; sl@0: iModelIDs = NULL; sl@0: iLexiconIDs = NULL; sl@0: iGrammarIDs = NULL; sl@0: iModelBankIDs = NULL; sl@0: } sl@0: if (asyncCallComplete) sl@0: iAsyncCallBusy = EFalse; sl@0: sl@0: if (iSpeechRecognitionUtilityObserver && !cancelled) sl@0: iSpeechRecognitionUtilityObserver->MsruoEvent(event, errorCode); sl@0: sl@0: } sl@0: