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: #include "CustomMmfASRController.h" sl@0: sl@0: #include sl@0: #include "customcontrollertestconstants.h" sl@0: #include "Database/testdatabaseconstants.h" sl@0: sl@0: /* sl@0: TMmfAsrControllerPanics is an enumeration with the following entries: sl@0: sl@0: EBadArgument indicates a bad argument sl@0: EBadState indicates a state viaolation sl@0: EBadInvariant indicates an invariant violation sl@0: EBadReset indicates failed reset sl@0: EPostConditionViolation indicates a post condition violation sl@0: sl@0: */ sl@0: enum TMmfAsrControllerPanics sl@0: { sl@0: EBadArgument, sl@0: EBadState, sl@0: EBadInvariant, sl@0: EPreConditionViolation, sl@0: EPostConditionViolation, sl@0: EDeprecatedFunction sl@0: }; sl@0: sl@0: /** sl@0: * Panic sl@0: * This method generates a panic sl@0: * @param "TInt" sl@0: * @xxxx sl@0: */ sl@0: void Panic(TMmfAsrControllerPanics aPanicCode) sl@0: { sl@0: _LIT(KMMFAsrControllerPanicCategory, "MMFAsrTestController"); sl@0: User::Panic(KMMFAsrControllerPanicCategory, aPanicCode); sl@0: } sl@0: sl@0: sl@0: /** sl@0: * sl@0: * NewL sl@0: * sl@0: */ sl@0: CMMFController* CCustomMmfASRController::NewL() sl@0: { sl@0: CCustomMmfASRController* self = new(ELeave) CCustomMmfASRController; sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop( self ); sl@0: return STATIC_CAST( CMMFController*, self ); sl@0: } sl@0: sl@0: sl@0: /** sl@0: * sl@0: * SetState sl@0: * @param aState sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::SetState( TControllerState aState ) sl@0: { sl@0: iState=aState; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * ConstructL sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::ConstructL() sl@0: { sl@0: //[ Construct custom command parsers] sl@0: CSpeechRecognitionCustomCommandParser* asrParser = CSpeechRecognitionCustomCommandParser::NewL(*this); sl@0: CleanupStack::PushL(asrParser); sl@0: AddCustomCommandParserL(*asrParser); sl@0: CleanupStack::Pop( asrParser ); //asrParser sl@0: sl@0: SetState( ESTraining ); //state of the controller sl@0: iRecognitionMode = ESdMode; // recognition mode which is nonzero for now sl@0: iRecordTime = 0; // the duration of the recording for both recognition and trainning sl@0: sl@0: iRecognizeComplete = EFalse; sl@0: iLoadedGrammarID = 0; sl@0: iLoadedLexiconID = 0; sl@0: iLoadedModelBankID = 0; sl@0: sl@0: RFs fsSession; sl@0: RFile file; sl@0: User::LeaveIfError(fsSession.Connect()); sl@0: CleanupClosePushL(fsSession); sl@0: TInt err = file.Open(fsSession, KFileNameTestDatabase, EFileRead); sl@0: file.Close(); sl@0: if(err == KErrNone) sl@0: { sl@0: iDatabase = CSDDatabase::NewL(KFileNameTestDatabase); sl@0: } sl@0: else if(err == KErrNotFound) sl@0: { sl@0: iDatabase = CSDDatabase::NewL(KFileNameTestDatabase, EFalse); sl@0: } sl@0: else if(err == KErrPathNotFound) sl@0: { sl@0: TParse fullFileName; sl@0: if(fullFileName.Set(KFileNameTestDatabase, NULL, NULL) == KErrNone) sl@0: { sl@0: err = fsSession. MkDirAll(fullFileName.DriveAndPath()); sl@0: if(err == KErrNone) sl@0: { sl@0: iDatabase = CSDDatabase::NewL(KFileNameTestDatabase,EFalse); sl@0: } sl@0: else sl@0: { sl@0: User::LeaveIfError(err); sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: User::LeaveIfError(err); sl@0: } sl@0: CleanupStack::PopAndDestroy(); //fsSession sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: * sl@0: * ~CCustomMmfAudioController sl@0: * sl@0: */ sl@0: CCustomMmfASRController::~CCustomMmfASRController() sl@0: { sl@0: delete iDatabase; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * CCustomMmfAudioController sl@0: * sl@0: */ sl@0: CCustomMmfASRController::CCustomMmfASRController() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * CustomCommand sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::CustomCommand(TMMFMessage& /*aMessage*/) sl@0: { sl@0: // The custom command is the final stopping off point sl@0: // in the command processing chain and in this case it does sl@0: // nothing! sl@0: } sl@0: sl@0: /** sl@0: * AddDataSourceL sl@0: * sl@0: * Adds a data source to the controller sl@0: * sl@0: * @param aSource sl@0: * Preconditions: sl@0: * We are stopped sl@0: * Source does not already exist sl@0: * Postconditions: sl@0: * iDataSource != NULL sl@0: * iDataSourceAdded == ETrue sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::AddDataSourceL(MDataSource& /*aSource*/) sl@0: { sl@0: //[This function is deprecated and should not have been called] sl@0: Panic(EDeprecatedFunction); sl@0: } sl@0: sl@0: /** sl@0: * AddDataSinkL sl@0: * sl@0: * Adds a data sink to the controller sl@0: * sl@0: * @param aSink sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::AddDataSinkL(MDataSink& ) sl@0: { sl@0: //[This function is deprecated and should not have been called] sl@0: Panic(EDeprecatedFunction); sl@0: } sl@0: sl@0: /** sl@0: * PrimeL sl@0: * sl@0: * If Prime fails the client should reset the controller sl@0: * because as noted below this code is not transactional. sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::PrimeL() sl@0: { sl@0: //[This function is deprecated and should not have been called] sl@0: Panic(EDeprecatedFunction); sl@0: } sl@0: sl@0: /** sl@0: * ResetL sl@0: * This method resets the controller sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::ResetL() sl@0: { sl@0: //[This function is deprecated and should not have been called] sl@0: Panic(EDeprecatedFunction); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * PlayL sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::PlayL() sl@0: { sl@0: //[This function is deprecated and should not have been called] sl@0: Panic(EDeprecatedFunction); sl@0: } sl@0: sl@0: /** sl@0: * PauseL sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::PauseL() sl@0: { sl@0: //[This function is deprecated and should not have been called] sl@0: Panic(EDeprecatedFunction); sl@0: } sl@0: sl@0: /** sl@0: * StopL sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::StopL() sl@0: { sl@0: //[This function is deprecated and should not have been called] sl@0: Panic(EDeprecatedFunction); sl@0: } sl@0: sl@0: /** sl@0: * PositionL sl@0: * Preconditions: sl@0: * The Controller is in the state EPrimed sl@0: * @return TTimeIntervalMicroSeconds sl@0: * sl@0: */ sl@0: TTimeIntervalMicroSeconds CCustomMmfASRController::PositionL() const sl@0: { sl@0: //[This function is deprecated and should not have been called] sl@0: Panic(EDeprecatedFunction); sl@0: TTimeIntervalMicroSeconds position(0); sl@0: return position; sl@0: } sl@0: sl@0: /** sl@0: * SetPositionL sl@0: * sl@0: * @param aPosition sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::SetPositionL(const TTimeIntervalMicroSeconds& ) sl@0: { sl@0: //[This function is deprecated and should not have been called] sl@0: Panic(EDeprecatedFunction); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrAddPronunciationL sl@0: * @param aLexiconID sl@0: * @param aModelID sl@0: * @param aPronunciationID sl@0: * Add pronunciation to the lexicon sl@0: * @precondition lexicon is loaded sl@0: * @precondition lexicon has specified id sl@0: * @post condition lexicon has pronunciation sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::MSrAddPronunciationL( TLexiconID aLexiconID, TModelBankID aModelBankID, sl@0: TModelID aModelID, TPronunciationID& aPronunciationID ) sl@0: { sl@0: //[ assert the InVariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: //[ precondition that are in training mode ] sl@0: __ASSERT_ALWAYS( State() == ESTraining, Panic(EBadState) ); sl@0: sl@0: //[ add new pronunciation ] sl@0: TInt err = KErrNone; sl@0: sl@0: CSDDatabase::TPronunciationData pronunciationData=CSDDatabase::TPronunciationData(); sl@0: pronunciationData.iModelBankID = aModelBankID; sl@0: pronunciationData.iModelID = aModelID; sl@0: sl@0: TRAP(err, aPronunciationID = iDatabase->CreatePronunciationL(aLexiconID, pronunciationData)); sl@0: sl@0: TMMFEvent addPronunciationComplete( KUidAsrEventAddPronunciation, err ); sl@0: SendEventToClient( addPronunciationComplete ); sl@0: sl@0: // [ assert the Invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: } sl@0: sl@0: sl@0: sl@0: void CCustomMmfASRController::MSrSetClientUid( TUid aClientUid) sl@0: { sl@0: //[ assert the InVariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: iDatabase->SetClientUid(aClientUid); sl@0: sl@0: } sl@0: sl@0: sl@0: /** sl@0: * sl@0: * MSrAddRule sl@0: * @param aGrammarID sl@0: * @param aLexiconID sl@0: * @param aPronunciationID sl@0: * @param aRuleID sl@0: * @postcondition grammar has rule sl@0: */ sl@0: void CCustomMmfASRController::MSrAddRuleL( sl@0: TGrammarID aGrammarID, TLexiconID aLexiconID, sl@0: TPronunciationID aPronunciationID, TRuleID& aRuleID ) sl@0: { sl@0: //[ assert the InVariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: //[ precondition that are in training mode ] sl@0: __ASSERT_ALWAYS( State() == ESTraining, Panic(EBadState) ); sl@0: sl@0: sl@0: //[ if the grammar has the rule ] sl@0: TInt err = KErrNone; sl@0: CSDDatabase::TRuleData ruleData=CSDDatabase::TRuleData(); sl@0: ruleData.iLexiconID = aLexiconID; sl@0: ruleData.iPronunciationID = aPronunciationID; sl@0: sl@0: TRAP( err, aRuleID = iDatabase->CreateRuleL( aGrammarID, ruleData)); sl@0: sl@0: sl@0: TMMFEvent event( KUidAsrEventAddRule, err ); sl@0: SendEventToClient( event ); sl@0: sl@0: // [ assert the Invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: } sl@0: sl@0: sl@0: /** sl@0: * sl@0: * MSrCancel sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::MSrCancel() sl@0: { sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: // Send back a test event to the client to indicate this has been called, note this is test controller specific event sl@0: TMMFEvent testCancelEvent( KUidTestASRCancel, KErrNone ); sl@0: SendEventToClient( testCancelEvent ); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrCommitChangesL sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::MSrCommitChangesL() sl@0: { sl@0: //[ assert the Invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: iDatabase->CommitChangesL(); sl@0: sl@0: // [ assert the invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrCreateGrammarL sl@0: * Creates a Grammar and makes it the currently loaded grammar sl@0: * @param aGrammarID sl@0: * @precondition State == ESTraining sl@0: * @postcondition iAsrSchema has grammar with id aGrammarID sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::MSrCreateGrammarL( TGrammarID& aGrammarID ) sl@0: { sl@0: //[ assert the Invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: //[ precondition that we are in trainning state ] sl@0: __ASSERT_ALWAYS( State() == ESTraining, Panic(EBadState) ); sl@0: sl@0: aGrammarID = iDatabase->CreateGrammarL(); sl@0: sl@0: TMMFEvent event( KUidAsrEventCreateGrammar, KErrNone ); sl@0: SendEventToClient( event ); sl@0: sl@0: //[ assert the invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrCreateLexiconL sl@0: * @param aLexiconID sl@0: * Creates a Lexicon with Id aLexiconId sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::MSrCreateLexiconL( TLexiconID& aLexiconID ) sl@0: { sl@0: //[ assert the Invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: //[ precondition that we are in trainning state ] sl@0: __ASSERT_ALWAYS( State() == ESTraining, Panic(EBadState) ); sl@0: sl@0: //[ create the Lexicon ] sl@0: aLexiconID = iDatabase->CreateLexiconL(); sl@0: sl@0: TMMFEvent event( KUidAsrEventCreateLexicon, KErrNone ); sl@0: SendEventToClient( event ); sl@0: sl@0: //[ assert the invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrCreateModelBankL sl@0: * @param aModelBankID sl@0: * @precondition state == ESTraining sl@0: * @precondition invariant holds sl@0: * @postcondition currentModelbank id == modelbank id sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::MSrCreateModelBankL( TModelBankID& aModelBankID ) sl@0: { sl@0: //[ assert the Invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: //[ precondition that we are in trainning state ] sl@0: __ASSERT_ALWAYS( State() == ESTraining, Panic(EBadState) ); sl@0: sl@0: //[ create the new ModelBank] sl@0: TRAPD(err, aModelBankID = iDatabase->CreateModelBankL()); sl@0: sl@0: TMMFEvent event( KUidAsrEventCreateModelBank, err); sl@0: SendEventToClient( event ); sl@0: sl@0: //[ assert the invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrEndRecSessionL sl@0: * End a recognition session sl@0: * @precondition State is ESRecognition sl@0: * @postcondition State is Idle sl@0: */ sl@0: void CCustomMmfASRController::MSrEndRecSessionL() sl@0: { sl@0: //[ The Invariant must hold ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: //[ precondition that the state is recognise ] sl@0: __ASSERT_ALWAYS( State() == ESRecognition, Panic(EBadState) ); sl@0: //[ transitionn to Idle state ] sl@0: SetState( ESTraining ); sl@0: sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrGetAllModelIDsL sl@0: * Gets all the model ids in a model bank sl@0: * @precondition iModelBank is loaded sl@0: * @postcondition model ids are returned sl@0: * @postcondition invariant holds sl@0: */ sl@0: void CCustomMmfASRController::MSrGetAllModelIDsL( TModelBankID aModelBankID, RArray& aModelIDs ) sl@0: { sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: TRAPD(err, iDatabase->GetAllModelIDsL(aModelBankID, aModelIDs)); sl@0: sl@0: TMMFEvent event( KUidAsrEventGetAllModelIDs, err ); sl@0: SendEventToClient( event ); sl@0: sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrGetAllPronunciationIDsL sl@0: * @precondition InVariant holds sl@0: * @postcondition InVariantHolds sl@0: */ sl@0: void CCustomMmfASRController::MSrGetAllPronunciationIDsL( TLexiconID aLexiconID, RArray& aPronunciationIDs ) sl@0: { sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: TRAPD(err, iDatabase->GetAllPronunciationIDsL(aLexiconID, aPronunciationIDs)); sl@0: sl@0: TMMFEvent event( KUidAsrEventGetAllPronunciationIDs, err ); sl@0: SendEventToClient( event ); sl@0: sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrGetAllRuleIDsL sl@0: * Get all the rule ids contained in the grammar sl@0: * @param aLexiconID sl@0: * @param aRuleIDs sl@0: * @precondition Invariant holds sl@0: * @precondition Lexicon is Loaded sl@0: * @postcondition Invariant holds sl@0: */ sl@0: void CCustomMmfASRController::MSrGetAllRuleIDsL( TLexiconID aLexiconID, RArray& aRuleIDs ) sl@0: { sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: TRAPD(err, iDatabase->GetAllRuleIDsL(aLexiconID, aRuleIDs)); sl@0: sl@0: TMMFEvent event( KUidAsrEventGetAllRuleIDs, err ); sl@0: SendEventToClient( event ); sl@0: sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: } sl@0: sl@0: sl@0: void CCustomMmfASRController::MSrGetAllClientModelBankIDsL(RArray& aModelBankIDs ) sl@0: { sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: TRAPD(err, iDatabase->GetAllModelBankIDsL(aModelBankIDs,ETrue)); sl@0: sl@0: TMMFEvent event( KUidAsrEventGetAllClientModelBankIDs, err ); sl@0: SendEventToClient( event ); sl@0: sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: } sl@0: sl@0: void CCustomMmfASRController::MSrGetAllClientLexiconIDsL(RArray& aLexiconIDs ) sl@0: { sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: TRAPD(err, iDatabase->GetAllLexiconIDsL(aLexiconIDs, ETrue)); sl@0: sl@0: TMMFEvent event( KUidAsrEventGetAllClientLexiconIDs, err ); sl@0: SendEventToClient( event ); sl@0: sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: } sl@0: sl@0: void CCustomMmfASRController::MSrGetAllClientGrammarIDsL(RArray& aGrammarIDs ) sl@0: { sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: TRAPD(err, iDatabase->GetAllGrammarIDsL(aGrammarIDs, ETrue)); sl@0: sl@0: TMMFEvent event( KUidAsrEventGetAllClientGrammarIDs, err ); sl@0: SendEventToClient( event ); sl@0: sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: } sl@0: sl@0: void CCustomMmfASRController::MSrGetAllModelBankIDsL(RArray& aModelBankIDs ) sl@0: { sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: TRAPD(err, iDatabase->GetAllModelBankIDsL(aModelBankIDs)); sl@0: sl@0: TMMFEvent event( KUidAsrEventGetAllModelBankIDs, err ); sl@0: SendEventToClient( event ); sl@0: sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: } sl@0: sl@0: void CCustomMmfASRController::MSrGetAllLexiconIDsL(RArray& aLexiconIDs ) sl@0: { sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: TRAPD(err, iDatabase->GetAllLexiconIDsL(aLexiconIDs)); sl@0: sl@0: TMMFEvent event( KUidAsrEventGetAllLexiconIDs, err ); sl@0: SendEventToClient( event ); sl@0: sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: } sl@0: sl@0: void CCustomMmfASRController::MSrGetAllGrammarIDsL(RArray& aGrammarIDs ) sl@0: { sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: TRAPD(err, iDatabase->GetAllGrammarIDsL(aGrammarIDs)); sl@0: sl@0: TMMFEvent event( KUidAsrEventGetAllGrammarIDs, err ); sl@0: SendEventToClient( event ); sl@0: sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: } sl@0: sl@0: sl@0: /** sl@0: * sl@0: * MSrGetAvailableStorageL sl@0: * gets the available storage sl@0: * For this simulation the function always returns zero space available sl@0: * @parameter aCount sl@0: * @precondition Invariant holds sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::MSrGetAvailableStorageL( TInt& aCount ) sl@0: { sl@0: //[ assert the invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: //[ for now we will return no space available ] sl@0: aCount = 0; sl@0: sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrGetEnginePropertiesL sl@0: * @param aProperties sl@0: * @precondition Invariant holds sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::MSrGetEnginePropertiesL( const RArray& aPropertyId, sl@0: RArray& aPropertyValue ) sl@0: { sl@0: //[ assert the invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: //[ empty the src array ] sl@0: aPropertyValue.Reset(); sl@0: sl@0: //[ for all the ids specified ] sl@0: for( TInt count = 0; count < aPropertyId.Count(); count++ ) sl@0: { sl@0: //[ we are just faking this for the moment ] sl@0: aPropertyValue.Append( count ); sl@0: } sl@0: sl@0: //[assert there are properties for all the ids] sl@0: __ASSERT_ALWAYS( aPropertyValue.Count() == aPropertyId.Count(), Panic(EPostConditionViolation) ); sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrLoadEngineParametersL sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::MSrLoadEngineParametersL( const RArray& aParameterId, sl@0: const RArray& aParameterValue ) sl@0: { sl@0: TBool pass = ETrue; sl@0: if (aParameterId.Count()!=KNumParameters || sl@0: aParameterValue.Count()!=KNumParameters) sl@0: pass = EFalse; sl@0: else sl@0: { sl@0: TInt i; sl@0: for (i=0;i=0 sl@0: */ sl@0: void CCustomMmfASRController::MSrGetModelCountL( TModelBankID aModelBankID, TInt& aCount ) sl@0: { sl@0: //[ assert the invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: RArray ids; sl@0: CleanupClosePushL(ids); sl@0: TRAPD(err, iDatabase->GetAllModelIDsL(aModelBankID,ids)); sl@0: sl@0: if (err==KErrNone) sl@0: aCount = ids.Count(); sl@0: sl@0: CleanupStack::PopAndDestroy(&ids); sl@0: sl@0: TMMFEvent event( KUidAsrEventGetModelCount, err ); sl@0: SendEventToClient( event ); sl@0: sl@0: sl@0: //[ assert the invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: * sl@0: * MSrGetRuleValidityL sl@0: * @param aGrammarID sl@0: * @param aRuleID sl@0: * @param aValid sl@0: * @precondition InVariantHolds sl@0: * @precondition state is training or state is recognition sl@0: * @precondition grammar is loaded sl@0: * @postcondition InVariantHolds sl@0: */ sl@0: void CCustomMmfASRController::MSrGetRuleValidityL( TGrammarID aGrammarID, TRuleID aRuleID, TBool& aValid ) sl@0: { sl@0: //[ assert the invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: //[ precondition the schema exists ] sl@0: sl@0: CSDDatabase::RSDRuleTable ruleTable(*iDatabase); sl@0: CleanupClosePushL(ruleTable); sl@0: ruleTable.OpenL(aGrammarID); sl@0: TRAPD(err, aValid = ruleTable.IsRuleValidL(aRuleID)); sl@0: CleanupStack::PopAndDestroy(&ruleTable); sl@0: sl@0: TMMFEvent event( KUidAsrEventGetRuleValidity, err ); sl@0: SendEventToClient( event ); sl@0: sl@0: //[ assert the invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrGetUtteranceDurationL sl@0: * @param aModelBankID sl@0: * @param aModelID sl@0: * @param aDuration sl@0: * @param aFromMemory sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::MSrGetUtteranceDurationL( TModelBankID aModelBankID, TModelID aModelID, sl@0: TTimeIntervalMicroSeconds32& aDuration) sl@0: { sl@0: //[ assert the Invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: CSDDatabase::TModelData modelData = CSDDatabase::TModelData(); sl@0: sl@0: TInt err; sl@0: TRAP(err, iDatabase->GetModelDataL(aModelBankID, aModelID, modelData)); sl@0: if (err==KErrNone) sl@0: { sl@0: aDuration = modelData.iUtteranceDurationMicroSeconds; sl@0: } sl@0: sl@0: TMMFEvent event( KUidAsrEventGetUtteranceDuration, err ); sl@0: SendEventToClient( event ); sl@0: sl@0: sl@0: //[ assert the Invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrLoadGrammarL sl@0: * @param aGrammarID sl@0: * @precondition aGrammarId is supported by the test controller sl@0: * @postcondition aGrammarId == id of loaded grammar sl@0: */ sl@0: void CCustomMmfASRController::MSrLoadGrammarL( TGrammarID aGrammarID ) sl@0: { sl@0: //[ assert the Invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: sl@0: //[ must be in trainning or recognition state ] sl@0: __ASSERT_ALWAYS( (State() == ESRecognition ) || ( State() == ESTraining ), Panic(EBadState) ); sl@0: sl@0: TInt err = KErrNone; sl@0: if (iDatabase->GrammarExistsL(aGrammarID)) sl@0: { sl@0: iLoadedGrammarID = aGrammarID; sl@0: } sl@0: else sl@0: err = KErrNotFound; sl@0: sl@0: TMMFEvent event( KUidAsrEventLoadGrammar, err ); sl@0: SendEventToClient( event ); sl@0: sl@0: //[ assert the Invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrLoadLexiconL sl@0: * @param aLexiconID sl@0: * @precondition Invariant Holds sl@0: * @precondition state is Training or Recognition sl@0: * @precondition controller supports the lexicon sl@0: * @postcondition iLexicon has id aLexiconId sl@0: * @psotcondition InVariant holds sl@0: */ sl@0: void CCustomMmfASRController::MSrLoadLexiconL( TLexiconID aLexiconID ) sl@0: { sl@0: //[ assert the Invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: sl@0: //[ must be in trainning or recognition state ] sl@0: __ASSERT_ALWAYS( (State() == ESRecognition ) || ( State() == ESTraining ), Panic(EBadState)); sl@0: sl@0: TInt err = KErrNone; sl@0: if (iDatabase->LexiconExistsL(aLexiconID)) sl@0: { sl@0: iLoadedLexiconID = aLexiconID; sl@0: } sl@0: else sl@0: err = KErrNotFound; sl@0: sl@0: TMMFEvent event( KUidAsrEventLoadLexicon, err ); sl@0: SendEventToClient( event ); sl@0: sl@0: //[ assert the Invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrLoadModelsL sl@0: * @param aModelBankID sl@0: * @precondition InVariant holds sl@0: * @precondition state is training or recognition sl@0: * @precondition model bank is is supported by the controller sl@0: * @postcondition modelbank id is equal to aModelBankId sl@0: * @postcondition InVariant holds sl@0: */ sl@0: void CCustomMmfASRController::MSrLoadModelsL( TModelBankID aModelBankID ) sl@0: { sl@0: //[ assert the Invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: sl@0: //[ must be in trainning or recognition state ] sl@0: __ASSERT_ALWAYS( (State() == ESRecognition ) || ( State() == ESTraining ), Panic(EBadState)); sl@0: sl@0: TInt err = KErrNone; sl@0: if (iDatabase->ModelBankExistsL(aModelBankID)) sl@0: { sl@0: iLoadedModelBankID = aModelBankID; sl@0: } sl@0: else sl@0: err = KErrNotFound; sl@0: sl@0: TMMFEvent event( KUidAsrEventLoadModels, err ); sl@0: SendEventToClient( event ); sl@0: sl@0: //[ assert the Invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrPlayUtteranceL sl@0: * @param aModelBankID sl@0: * @param aModelID sl@0: * @param aPlayFromMemory sl@0: * Always plays froms memory sl@0: */ sl@0: void CCustomMmfASRController::MSrPlayUtteranceL( TModelBankID aModelBankID, TModelID aModelID ) sl@0: { sl@0: //[ assert the InVariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: sl@0: if (!iDatabase->ModelExistsL(aModelBankID, aModelID)) sl@0: { sl@0: User::Leave(KErrNotFound); sl@0: } sl@0: else sl@0: { sl@0: TMMFEvent aPlayStarted( KUidAsrEventPlayStarted, KErrNone ); sl@0: SendEventToClient( aPlayStarted ); sl@0: sl@0: TMMFEvent aPlayComplete( KUidAsrEventPlay, KErrNone ); sl@0: SendEventToClient( aPlayComplete ); sl@0: } sl@0: sl@0: //[ assert the InVariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrRecognizeL sl@0: * @param aResultSet sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::MSrRecognizeL( CSDClientResultSet& aResultSet ) sl@0: { sl@0: //[ assert the Invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: sl@0: //[ Precondition that we are in a recognition session ] sl@0: if( State() != ESRecognition ) sl@0: { sl@0: TMMFEvent recognitionFailed( KUidAsrEventRecognition, KErrNotReady ); sl@0: SendEventToClient( recognitionFailed ); sl@0: return; sl@0: } sl@0: sl@0: TMMFEvent recognitionReady( KUidAsrEventRecognitionReady,KErrNone ); sl@0: SendEventToClient( recognitionReady ); sl@0: sl@0: //[ return a result set ] sl@0: iMaxResults = aResultSet.MaxResults(); sl@0: iResultSet = &aResultSet; sl@0: sl@0: iRecognizeComplete = ETrue; sl@0: sl@0: //[ assert the Invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: } sl@0: sl@0: /* sl@0: * sl@0: * MSrRecordL sl@0: * @param aRecordTime sl@0: * @precondition InVariant holds sl@0: * @postcondition sl@0: */ sl@0: void CCustomMmfASRController::MSrRecordL( TTimeIntervalMicroSeconds32 aRecordTime ) sl@0: { sl@0: //[ assert the invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: sl@0: //[ remember the record time sl@0: // and for the purpose of simulation recording takes zero time ] sl@0: iRecordTime = aRecordTime ; sl@0: sl@0: TMMFEvent aRecordStartedEvent( KUidAsrEventRecordStarted, KErrNone ); sl@0: SendEventToClient( aRecordStartedEvent ); sl@0: sl@0: TMMFEvent aEndOfUtteranceEvent( KUidAsrEventEouDetected, KErrNone ); sl@0: SendEventToClient( aEndOfUtteranceEvent ); sl@0: sl@0: if( iRecognizeComplete ) sl@0: { sl@0: iRecognizeComplete = EFalse; sl@0: sl@0: for (TInt i=0;iAt(i)); sl@0: result.SetGrammarID(KResultsGrammarID[i]); sl@0: result.SetRuleID(KResultsRuleID[i]); sl@0: } sl@0: sl@0: TMMFEvent recognitionComplete( KUidAsrEventRecognition, KErrNone ); sl@0: SendEventToClient( recognitionComplete ); sl@0: } sl@0: sl@0: //[ assert the invaraint ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrRemoveGrammarL sl@0: * Interpreted as unload from memory here sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::MSrRemoveGrammarL( TGrammarID aGrammarID ) sl@0: { sl@0: //[ assert the invaraint ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant)); sl@0: sl@0: sl@0: if (iLoadedGrammarID == aGrammarID) sl@0: { sl@0: TMMFEvent event( KUidAsrEventRemoveGrammar, KErrInUse ); sl@0: SendEventToClient( event ); sl@0: } sl@0: else sl@0: { sl@0: TRAPD(err, iDatabase->RemoveGrammarL(aGrammarID)); sl@0: //[ send message to client of success ] sl@0: TMMFEvent event( KUidAsrEventRemoveGrammar, err ); sl@0: SendEventToClient( event ); sl@0: } sl@0: sl@0: //[ assert the invaraint ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrRemoveLexiconL sl@0: * @param aLexiconID sl@0: * slightly different interpretation here sl@0: */ sl@0: void CCustomMmfASRController::MSrRemoveLexiconL( TLexiconID aLexiconID ) sl@0: { sl@0: //[ assert the invaraint ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: sl@0: sl@0: if (iLoadedLexiconID == aLexiconID) sl@0: { sl@0: TMMFEvent event( KUidAsrEventRemoveLexicon, KErrInUse ); sl@0: SendEventToClient( event ); sl@0: } sl@0: else sl@0: { sl@0: TRAPD(err, iDatabase->RemoveLexiconL(aLexiconID)); sl@0: //[ send message to client of success ] sl@0: TMMFEvent event( KUidAsrEventRemoveLexicon, err ); sl@0: SendEventToClient( event ); sl@0: } sl@0: sl@0: //[ assert the invaraint ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: sl@0: sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrRemoveModelBankL sl@0: * sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::MSrRemoveModelBankL( TModelBankID aModelBankID ) sl@0: { sl@0: //[ assert the invaraint ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: sl@0: sl@0: if (iLoadedModelBankID == aModelBankID) sl@0: { sl@0: TMMFEvent event( KUidAsrEventRemoveModelBank, KErrInUse ); sl@0: SendEventToClient( event ); sl@0: } sl@0: else sl@0: { sl@0: TRAPD(err, iDatabase->RemoveModelBankL(aModelBankID)); sl@0: //[ send message to client of success ] sl@0: TMMFEvent event( KUidAsrEventRemoveModelBank, err ); sl@0: SendEventToClient( event ); sl@0: } sl@0: sl@0: //[ assert the invaraint ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrRemoveModelL sl@0: * @param aModelBankID sl@0: * @param aModeID sl@0: * @precondition InVariant holds sl@0: * @precondition model bank exists sl@0: * @precondition modelbank contains the model sl@0: * @postcondition model bank does not contain model sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::MSrRemoveModelL( TModelBankID aModelBankID, TModelID aModelID ) sl@0: { sl@0: //[ assert the invariant ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: sl@0: if (iLoadedModelBankID == aModelBankID) sl@0: { sl@0: TMMFEvent event( KUidAsrEventRemoveModelBank, KErrInUse ); sl@0: SendEventToClient( event ); sl@0: } sl@0: else sl@0: { sl@0: TInt err = KErrNone; sl@0: if (!iDatabase->ModelBankExistsL(aModelBankID)) sl@0: err = KErrNotFound; sl@0: else sl@0: { sl@0: CSDDatabase::RSDModelTable view(*iDatabase); sl@0: CleanupClosePushL(view); sl@0: view.OpenL(aModelBankID); sl@0: if (view.FindModelL(aModelID)) sl@0: { sl@0: view.RemoveModelL(aModelID); sl@0: } sl@0: else sl@0: err = KErrNotFound; sl@0: sl@0: CleanupStack::PopAndDestroy(&view); sl@0: } sl@0: //[ send message to client of success ] sl@0: TMMFEvent event( KUidAsrEventRemoveModel, err ); sl@0: SendEventToClient( event ); sl@0: } sl@0: sl@0: //[ assert the invaraint ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrRemovePronunciationL sl@0: * @param aLexiconID sl@0: * @param aPronunciationID sl@0: * @precondition lexicon exists sl@0: * @precondition lexicon has id specified sl@0: * @postconfition lexicon does not have pronunication sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::MSrRemovePronunciationL( TLexiconID aLexiconID, TPronunciationID aPronunciationID ) sl@0: { sl@0: //[ assert the invaraint ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: sl@0: if (iLoadedLexiconID == aLexiconID) sl@0: { sl@0: TMMFEvent event( KUidAsrEventRemovePronunciation, KErrInUse ); sl@0: SendEventToClient( event ); sl@0: } sl@0: else sl@0: { sl@0: TInt err = KErrNone; sl@0: if (!iDatabase->LexiconExistsL(aLexiconID)) sl@0: err = KErrNotFound; sl@0: else sl@0: { sl@0: CSDDatabase::RSDPronunciationTable view(*iDatabase); sl@0: CleanupClosePushL(view); sl@0: view.OpenL(aLexiconID); sl@0: if (view.FindPronunciationL(aPronunciationID)) sl@0: { sl@0: view.RemovePronunciationL(aPronunciationID); sl@0: } sl@0: else sl@0: err = KErrNotFound; sl@0: sl@0: CleanupStack::PopAndDestroy(&view); sl@0: } sl@0: //[ send message to client of success ] sl@0: TMMFEvent event( KUidAsrEventRemovePronunciation, err ); sl@0: SendEventToClient( event ); sl@0: } sl@0: sl@0: //[ assert the invaraint ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrRemoveRuleL sl@0: * @param aLexiconID sl@0: * @param aRuleID sl@0: * @precondition InVariant holds sl@0: * @precondition grammar is loaded sl@0: * @precondition grammar has id specified sl@0: * @postcondition grammar does not contain rule sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::MSrRemoveRuleL( TGrammarID aGrammarID, TRuleID aRuleID ) sl@0: { sl@0: //[ assert the invaraint ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: sl@0: if (iLoadedGrammarID == aGrammarID) sl@0: { sl@0: TMMFEvent event( KUidAsrEventRemoveRule, KErrInUse ); sl@0: SendEventToClient( event ); sl@0: } sl@0: else sl@0: { sl@0: TInt err = KErrNone; sl@0: if (!iDatabase->GrammarExistsL(aGrammarID)) sl@0: err = KErrNotFound; sl@0: else sl@0: { sl@0: CSDDatabase::RSDRuleTable view(*iDatabase); sl@0: CleanupClosePushL(view); sl@0: view.OpenL(aGrammarID); sl@0: if (view.FindRuleL(aRuleID)) sl@0: { sl@0: view.RemoveRuleL(aRuleID); sl@0: } sl@0: else sl@0: err = KErrNotFound; sl@0: sl@0: CleanupStack::PopAndDestroy(&view); sl@0: } sl@0: //[ send message to client of success ] sl@0: TMMFEvent event( KUidAsrEventRemoveRule, err ); sl@0: SendEventToClient( event ); sl@0: } sl@0: sl@0: //[ assert the invaraint ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrStartRecSessionL sl@0: * @param aMode sl@0: * @precondition mode is valid sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::MSrStartRecSessionL( TRecognitionMode aMode ) sl@0: { sl@0: //[ assert the invariant holds ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: sl@0: //[ precondition the mode is valid ] sl@0: if( (aMode < ESdMode ) || ( aMode > ESdSiMode) ) sl@0: { sl@0: User::Leave( KErrArgument ); sl@0: } sl@0: sl@0: //[ it does not matter which state we are in we can sl@0: // always transition to recognition ] sl@0: SetState( ESRecognition ); sl@0: sl@0: //[ set the recognition mode ] sl@0: iRecognitionMode = aMode ; sl@0: sl@0: //[ assert the Invariant holds ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: sl@0: //[ assert the post condition that the mode has been en sl@0: __ASSERT_ALWAYS( iRecognitionMode == aMode, Panic(EPostConditionViolation) ); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrTrainL sl@0: * @param aModelBankID sl@0: * @param aModelID sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::MSrTrainL( TModelBankID aModelBankID, TModelID& aModelID ) sl@0: { sl@0: // fixed duration to return for training sl@0: const TInt KUtteranceDuration = 2000; sl@0: //[ must be in training mode sl@0: // must have a lexicon that is not empty sl@0: // must have a grammar sl@0: // must have a model bank loaded ] sl@0: //[ presume train adds a new model id to the bank ] sl@0: //[ finally send event to client ] sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: TMMFEvent event( KUidAsrEventTrainReady, KErrNone ); sl@0: SendEventToClient( event ); sl@0: sl@0: // [ precondition model bank is loaded ] sl@0: if( iLoadedModelBankID != aModelBankID ) sl@0: { sl@0: TMMFEvent event( KUidAsrEventTrain, KErrNotReady ); sl@0: SendEventToClient( event ); sl@0: return; sl@0: } sl@0: sl@0: TInt err = KErrNone; sl@0: sl@0: CSDDatabase::TModelData modelData=CSDDatabase::TModelData(); sl@0: modelData.iUtteranceDurationMicroSeconds = KUtteranceDuration; sl@0: TRAP(err, aModelID = iDatabase->CreateModelL( aModelBankID, modelData)); sl@0: sl@0: TMMFEvent trainCompleteEvent( KUidAsrEventTrain, err ); sl@0: SendEventToClient( trainCompleteEvent ); sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * MSrUnloadRuleL sl@0: * @param aGrammarID sl@0: * @param aRuleID sl@0: * @precondition state == ESTraining sl@0: * @postcondition grammar does not contain rule sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::MSrUnloadRuleL( TGrammarID aGrammarID, TRuleID aRuleID ) sl@0: { sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: sl@0: //[ precondition grammar loaded is grammar with id ] sl@0: __ASSERT_ALWAYS( iLoadedGrammarID == aGrammarID, Panic(EPreConditionViolation) ); sl@0: sl@0: TBool ruleExists = EFalse; sl@0: sl@0: TRAPD(err, ruleExists = iDatabase->RuleExistsL(aGrammarID, aRuleID)); sl@0: sl@0: if (err == KErrNone) sl@0: { sl@0: if (!ruleExists) sl@0: err = KErrNotFound; sl@0: } sl@0: sl@0: //[ send message to client of success ] sl@0: TMMFEvent event( KUidAsrEventUnloadRule, err ); sl@0: SendEventToClient( event ); sl@0: sl@0: __ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));; sl@0: } sl@0: sl@0: /** sl@0: * SendEventToClient sl@0: * sl@0: * @param aEvent sl@0: */ sl@0: TInt CCustomMmfASRController::SendEventToClient(const TMMFEvent& aEvent) sl@0: { sl@0: //now send event to client... sl@0: return DoSendEventToClient(aEvent); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * GetNumberOfMetaDataEntriesL sl@0: * sl@0: * @param "TInt" sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::GetNumberOfMetaDataEntriesL(TInt& /*aNumberOfEntries*/ ) sl@0: { sl@0: //[This function is deprecated and should not have been called] sl@0: Panic(EDeprecatedFunction); sl@0: } sl@0: sl@0: /** sl@0: * GetMetaDataEntryL sl@0: * @param aIndex sl@0: * @returns "CMMFMetaDataEntry*" sl@0: */ sl@0: CMMFMetaDataEntry* CCustomMmfASRController::GetMetaDataEntryL(TInt /*aIndex*/ ) sl@0: { sl@0: //[This function is deprecated and should not have been called] sl@0: Panic(EDeprecatedFunction); sl@0: return NULL; sl@0: } sl@0: sl@0: /** sl@0: * RemoveDataSourceL sl@0: * @param aDataSource sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::RemoveDataSourceL(MDataSource& /*aDataSource*/ ) sl@0: { sl@0: //[This function is deprecated and should not have been called] sl@0: Panic(EDeprecatedFunction); sl@0: } sl@0: sl@0: /** sl@0: * RemoveDataSinkL sl@0: * sl@0: * @param aDataSink sl@0: * sl@0: */ sl@0: void CCustomMmfASRController::RemoveDataSinkL(MDataSink& /*aDataSink*/ ) sl@0: { sl@0: //[This function is deprecated and should not have been called] sl@0: Panic(EDeprecatedFunction); sl@0: } sl@0: sl@0: /** sl@0: * SetPrioritySettings sl@0: * sl@0: * @param aPrioritySettings sl@0: */ sl@0: void CCustomMmfASRController::SetPrioritySettings(const TMMFPrioritySettings& /*aPrioritySettings*/) sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * DurationL sl@0: * sl@0: * @returns TTimeIntervalMicroSeconds sl@0: * sl@0: */ sl@0: TTimeIntervalMicroSeconds CCustomMmfASRController::DurationL() const sl@0: { sl@0: TTimeIntervalMicroSeconds xx(0); sl@0: return xx; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * InVariant sl@0: * @returns TBool sl@0: * sl@0: */ sl@0: TBool CCustomMmfASRController::InVariant() const sl@0: { sl@0: TBool status = EFalse; sl@0: //[ for now the invariant is simply that we have a valid state ] sl@0: if( (iState == ESTraining ) || ( iState == ESTraining ) || ( iState == ESRecognition ) ) sl@0: { sl@0: status = ETrue; sl@0: } sl@0: sl@0: return status; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * State sl@0: * @returns TControllerState sl@0: * sl@0: */ sl@0: CCustomMmfASRController::TControllerState CCustomMmfASRController::State() const sl@0: { sl@0: return iState; sl@0: }