2 * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0""
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Language database class declaration.
31 #ifndef _PTI_LANGUAGE_DATABASE_H
32 #define _PTI_LANGUAGE_DATABASE_H
38 // For accessing keyboard data through LangData() method. If aIndex
39 // parameter is higher than KKdbThreshold client is accessing
40 // keyboard data instead of ldb data.
41 const TInt KKdbThreshold = 500;
43 // For accessing key bindings through LangData() method. If aIndex
44 // parameter is higher than KKdbThreshold client is accessing
45 // key bindings data instead of ldb or kdb data.
46 const TInt KKdbBindingThreshold = 2500;
48 const TInt KOpaqueDataLen = 8;
52 // TPtiLangDatabaseMapping
54 class TPtiLangDatabaseMapping
62 // TPtiLangDatabaseMappingOpaque
64 class TPtiLangDatabaseMappingOpaque
69 TBuf8<KOpaqueDataLen> iOpaque;
74 // TPtiLangDatabaseOpaqueBinding
76 class TPtiLangDatabaseOpaqueBinding
80 TBuf8<KOpaqueDataLen> iOpaque;
85 * An interface class for wrapping language data. Core object may use this
86 * interface for accessing language data (but it is also ok to use any other
87 * way, since it is part of core object's internal implementation).
89 class MPtiLanguageDatabase
93 * Implementation UID for core object owning this data.
96 * @return Implementation Uid value of owning core object.
98 virtual TInt CoreUID() const = 0;
101 * Number on languages implemented in this database.
104 * return Number languages implemented in this database.
106 virtual TInt NumLanguages() const = 0;
109 * Symbian OS language code for language data.
112 * @param aIndex Index of language implementation (in case one database holds data
113 * for several languages).
114 * @return Symbian OS language code for language data identified by aIndex.
115 * 0, if aIndex is greater than number of languages in this database.
117 virtual TInt LanguageCode(TInt aIndex) const = 0;
120 * Returns sub-language code. The meaning of this value depends on core object
121 * implementation. Ususally this value is needed for enumerating several dialects
122 * that are related to one Symbian OS language constant.
125 * @return Sub-language id.
127 virtual TInt SubLanguageCode(TInt aIndex) const = 0;
130 * Returns pointer to raw language data.
131 * on the core object implementation.
134 * @param aIndex Index of language implementation.
135 * @return Pointer to language data array.
137 virtual TInt8* LangData(TInt aIndex) const = 0;
140 * Returns pointer to language data. The meaning of the data in array depends
141 * on the core object implementation.
144 * @param aIndex Index of language implementation.
145 * @param aNativeParams Core object related extra parameters.
146 * @return Pointer to language data array.
148 virtual TInt8* LangData(TInt aIndex, TAny* aNativeParams) const = 0;
151 * Returns pointer to PinYin phrase input related data.
154 * @return Pointer to PinYin phrase input data.
156 virtual TInt8* PinyinPhraseData() const = 0;
159 * Returns pointer to ZhuYin phrase input related data.
162 * @return Pointer to ZhuYin phrase input data.
164 virtual TInt8* ZhuyinPhraseData() const = 0;
167 * Returns core object's internal language id value. The meaning of this
168 * value depends on core object implementation.
171 * @return Core object internal language id.
173 virtual TInt NativeId(TInt aIndex) const = 0;
178 * Default implementation for MPtiLanguageDatabase interface.
180 class CPtiLanguageDatabase : public CBase, public MPtiLanguageDatabase
184 * Creates a language database instance for given implemenation UID.
187 * @return Pointer to language database instance.
190 IMPORT_C static CPtiLanguageDatabase* CreateDatabaseL(TUid aImplUid);
193 * Returns a list of all the availbale language databases related to given core object.
194 * List will be the topmost item in cleanup stack.
197 * @param aCoreUid Implementation uid for core object.
198 * @return Pointer to a list containing implemention uids of language databases.
200 IMPORT_C static CArrayFix<TInt>* ListDatabasesLC(TInt aCoreUid);
203 * Returns Symbian OS language code for the first language in given language database.
206 * @param aUid An implementation uid for language database.
207 * @return Symbian OS language constant.
210 IMPORT_C static TInt LanguageCodeForUid(TInt aUid);
213 * Fills given array with TPtiLangDatabaseMapping bindings for given core object.
214 * Items in list bind Symbian OS language code to language database implemantion
218 * @param aCoreUid Core object implemenation uid.
219 * @param aResult Resulting list.
220 * @return Number of items in aResult.
222 IMPORT_C static TInt CreateMappingTableL(TInt aCoreUid, RArray<TPtiLangDatabaseMapping>& aResult);
223 IMPORT_C static TInt CreateMappingTableWithOpaqueL(TInt aCoreUid, RArray<TPtiLangDatabaseMappingOpaque>& aResult);
226 IMPORT_C ~CPtiLanguageDatabase();
228 public: // Empty default implementations.
229 IMPORT_C TInt CoreUID() const;
230 IMPORT_C TInt NumLanguages() const;
231 IMPORT_C TInt LanguageCode(TInt aIndex) const;
232 IMPORT_C TInt SubLanguageCode(TInt aIndex) const;
233 IMPORT_C TInt8* LangData(TInt aIndex) const;
234 IMPORT_C TInt8* LangData(TInt aIndex, TAny* aNativeParams) const;
235 IMPORT_C TInt8* PinyinPhraseData() const;
236 IMPORT_C TInt8* ZhuyinPhraseData() const;
237 IMPORT_C TInt NativeId(TInt aIndex) const;
240 inline void SetDestructorKeyId(TInt aDtorKeyId);
248 // ---------------------------------------------------------------------------
249 // CPtiLanguageDatabase::SetDestructorKeyId
251 // ---------------------------------------------------------------------------
253 inline void CPtiLanguageDatabase::SetDestructorKeyId(TInt aDtorKeyId)
255 iDtorKeyId = aDtorKeyId;
258 #endif // _PTI_LANGUAGE_DATABASE_H