sl@0: // Copyright (c) 2004-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: #ifndef __SDDATABASE_H__ sl@0: #define __SDDATABASE_H__ sl@0: sl@0: #include sl@0: sl@0: class CSecurityDecryptBase; sl@0: class CSecurityEncryptBase; sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: sl@0: class CSDDatabase : public CBase sl@0: { sl@0: public: sl@0: class TPronunciationData sl@0: { sl@0: public: sl@0: TPronunciationID iPronunciationID; sl@0: TModelBankID iModelBankID; sl@0: TModelID iModelID; sl@0: }; sl@0: sl@0: class TRuleData sl@0: { sl@0: public: sl@0: TRuleID iRuleID; sl@0: TLexiconID iLexiconID; sl@0: TPronunciationID iPronunciationID; sl@0: }; sl@0: sl@0: class TModelData sl@0: { sl@0: public: sl@0: TModelID iModelID; sl@0: TUint32 iUtteranceDurationMicroSeconds; sl@0: }; sl@0: sl@0: sl@0: sl@0: class RSDGrammarTable sl@0: { sl@0: public: sl@0: RSDGrammarTable(CSDDatabase& aDatabase); sl@0: sl@0: void OpenL(TBool aOwnedByClient = EFalse); sl@0: sl@0: void CreateGrammarL(TGrammarID& aGrammarID); sl@0: void AddGrammarL(TGrammarID aGrammarID); sl@0: void RemoveGrammarL(TGrammarID aGrammarID); sl@0: sl@0: TBool FindGrammarL(TGrammarID aGrammarID); sl@0: void GetAllGrammarIDsL(RArray& aGrammarIDs); sl@0: void Close(); sl@0: sl@0: private: sl@0: CSDDatabase& iDatabase; sl@0: RDbView iView; sl@0: }; sl@0: sl@0: class RSDLexiconTable sl@0: { sl@0: public: sl@0: RSDLexiconTable(CSDDatabase& aDatabase); sl@0: sl@0: void OpenL(TBool aOwnedByClient = EFalse); sl@0: sl@0: void CreateLexiconL(TLexiconID& aLexiconID); sl@0: void AddLexiconL(TLexiconID aLexiconID); sl@0: void RemoveLexiconL(TLexiconID aLexiconID); sl@0: sl@0: TBool FindLexiconL(TLexiconID aLexiconID); sl@0: void GetAllLexiconIDsL(RArray& aLexiconIDs); sl@0: void Close(); sl@0: sl@0: private: sl@0: CSDDatabase& iDatabase; sl@0: RDbView iView; sl@0: }; sl@0: sl@0: class RSDModelBankTable sl@0: { sl@0: public: sl@0: RSDModelBankTable(CSDDatabase& aDatabase); sl@0: sl@0: void OpenL(TBool aOwnedByClient = EFalse); sl@0: sl@0: TModelBankID CreateModelBankL(); sl@0: void AddModelBankL(TModelBankID aModelBankID); sl@0: void RemoveModelBankL(TModelBankID aModelBankID); sl@0: sl@0: TBool FindModelBankL(TModelBankID aModelBankID); sl@0: void GetAllModelBankIDsL(RArray& aModelBankIDs); sl@0: void Close(); sl@0: sl@0: private: sl@0: CSDDatabase& iDatabase; sl@0: RDbView iView; sl@0: }; sl@0: sl@0: class RSDRuleTable sl@0: { sl@0: public: sl@0: RSDRuleTable(CSDDatabase& aDatabase); sl@0: sl@0: void OpenL(TGrammarID aGrammarID); sl@0: sl@0: TRuleID CreateRuleL(TRuleData aRuleData); sl@0: void AddRuleL(TRuleData aRuleData); sl@0: void RemoveRuleL(TRuleID aRuleID); sl@0: sl@0: void GetRuleDataL(TRuleID aRuleID, TRuleData& aRuleData); sl@0: sl@0: TBool FindRuleL(TRuleID aRuleID); sl@0: TBool IsRuleValidL(TRuleID aRuleID); sl@0: void GetAllRuleIDsL(RArray& aRuleIDs); sl@0: void Close(); sl@0: sl@0: private: sl@0: CSDDatabase& iDatabase; sl@0: RDbView iView; sl@0: TGrammarID iGrammarID; sl@0: }; sl@0: sl@0: class RSDPronunciationTable sl@0: { sl@0: public: sl@0: RSDPronunciationTable(CSDDatabase& aDatabase); sl@0: sl@0: void OpenL(TLexiconID aLexiconID); sl@0: sl@0: TPronunciationID CreatePronunciationL(TPronunciationData aPronunciationData); sl@0: void AddPronunciationL(TPronunciationData aPronunciationData); sl@0: void RemovePronunciationL(TPronunciationID aPronunciationID); sl@0: void GetPronunciationDataL(TPronunciationID aPronunciationID, TPronunciationData& aPronunciationData); sl@0: sl@0: TBool FindPronunciationL(TPronunciationID aPronunciationID); sl@0: void GetAllPronunciationIDsL(RArray& aPronunciationIDs); sl@0: void Close(); sl@0: sl@0: private: sl@0: CSDDatabase& iDatabase; sl@0: RDbView iView; sl@0: TLexiconID iLexiconID; sl@0: }; sl@0: sl@0: sl@0: sl@0: sl@0: class RSDModelTable sl@0: { sl@0: public: sl@0: RSDModelTable(CSDDatabase& aDatabase); sl@0: sl@0: void OpenL(TModelBankID aModelBankID); sl@0: sl@0: TModelID CreateModelL(TModelData aModelData); sl@0: void AddModelL(TModelData aModelData); sl@0: void RemoveModelL(TModelID aModelID); sl@0: sl@0: void GetModelDataL(TModelID aModelID, TModelData& aModelData); sl@0: sl@0: TBool FindModelL(TModelID aModelID); sl@0: void GetAllModelIDsL(RArray& aModelIDs); sl@0: void Close(); sl@0: sl@0: private: sl@0: CSDDatabase& iDatabase; sl@0: RDbView iView; sl@0: TModelBankID iModelBankID; sl@0: }; sl@0: sl@0: class RSDSettingsTable sl@0: { sl@0: public: sl@0: RSDSettingsTable(CSDDatabase& aDatabase); sl@0: sl@0: void OpenL(); sl@0: sl@0: TUint32 GetValueL(TUint32 aIndex); sl@0: void SetValueL(TUint32 aIndex, TUint32 aValue); sl@0: sl@0: void Close(); sl@0: sl@0: private: sl@0: CSDDatabase& iDatabase; sl@0: RDbView iView; sl@0: }; sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: public: sl@0: static CSDDatabase* NewL(const TDesC& aFileName, TBool aUseExisting=ETrue); sl@0: sl@0: TGrammarID CreateGrammarL(); sl@0: void AddGrammarL(TGrammarID aGrammarID); sl@0: void RemoveGrammarL(TGrammarID aGrammarID); sl@0: void GetAllGrammarIDsL(RArray& aGrammarIDs, TBool aOwnedByClient=EFalse); sl@0: TBool GrammarExistsL(TGrammarID aGrammarID); sl@0: sl@0: TLexiconID CreateLexiconL(); sl@0: void AddLexiconL(TLexiconID aLexiconID); sl@0: void RemoveLexiconL(TLexiconID aLexiconID); sl@0: void GetAllLexiconIDsL(RArray& aLexiconIDs, TBool aOwnedByClient=EFalse); sl@0: TBool LexiconExistsL(TLexiconID aLexiconID); sl@0: sl@0: TModelBankID CreateModelBankL(); sl@0: void AddModelBankL(TModelBankID aModelBankID); sl@0: void RemoveModelBankL(TModelBankID aModelBankID); sl@0: void GetAllModelBankIDsL(RArray& aModelBankIDs, TBool aOwnedByClient=EFalse); sl@0: TBool ModelBankExistsL(TModelBankID aModelBankID); sl@0: sl@0: sl@0: TRuleID CreateRuleL(TGrammarID aGrammarID, TRuleData aRuleData); sl@0: void AddRuleL(TGrammarID aGrammarID, TRuleData aRuleData); sl@0: void RemoveRuleL(TGrammarID aGrammarID, TRuleID aRuleID); sl@0: void GetAllRuleIDsL(TGrammarID aGrammarID, RArray& aRuleIDs); sl@0: TBool RuleExistsL(TGrammarID aGrammarID, TRuleID aRuleID); sl@0: sl@0: TPronunciationID CreatePronunciationL(TLexiconID aLexiconID, TPronunciationData aPronunciationData); sl@0: void AddPronunciationL(TLexiconID aLexiconID, TPronunciationData aPronunciationData); sl@0: void RemovePronunciationL(TLexiconID aLexiconID, TPronunciationID aPronunciationID); sl@0: void GetPronunciationDataL(TLexiconID aLexiconID, TPronunciationID aPronunciationID, TPronunciationData& aPronunciation); sl@0: void GetAllPronunciationIDsL(TLexiconID aLexiconID, RArray& aPronunciationID); sl@0: TBool PronunciationExistsL(TLexiconID aLexiconID, TPronunciationID aPronunciationID); sl@0: sl@0: TModelID CreateModelL(TModelBankID aModelBankID, TModelData aModelData); sl@0: void AddModelL(TModelBankID aModelBankID, TModelData aModelData); sl@0: void RemoveModelL(TModelBankID aModelBankID, TModelID aModelID); sl@0: void GetModelDataL(TModelBankID aModelBankID, TModelID aModelID, TModelData& aModelData); sl@0: void GetAllModelIDsL(TModelBankID aModelBankID, RArray& aModelIDs); sl@0: TBool ModelExistsL(TModelBankID aModelBankID, TModelID aModelID); sl@0: sl@0: sl@0: TUid ClientUid(); sl@0: RDbDatabase& Database(); sl@0: sl@0: void StartTransactionL(); sl@0: void CommitChangesL(); sl@0: sl@0: TUint32 AllocNewIDL(); sl@0: void UpdateLastIDL(TUint32 aLastID); sl@0: sl@0: void SetClientUid(TUid aClientUid); sl@0: ~CSDDatabase(); sl@0: sl@0: void CreateTestDatabaseL(); sl@0: sl@0: private: sl@0: void OpenDatabaseL(const TDesC& aFileName); sl@0: void CreateDatabaseL(const TDesC& aFileName); sl@0: sl@0: void DoCreateTablesL(); sl@0: void DoCreateIndexesL(); sl@0: sl@0: CSDDatabase(); sl@0: sl@0: void ConstructL(const TDesC& aFileName, TBool aUseExisting); sl@0: sl@0: sl@0: TUid iClientUid; sl@0: CFileStore* iDbStore; sl@0: RDbStoreDatabase iDatabase; sl@0: TBool iDatabaseOpened; sl@0: sl@0: TUint32 iLastID; sl@0: sl@0: }; sl@0: sl@0: #endif //__SDDATABASE_H__