epoc32/include/mw/ptilanguagedatabase.h
branchSymbian2
changeset 2 2fe1408b6811
parent 1 666f914201fb
child 4 837f303aceeb
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 ptilanguagedatabase.h
     1 /*
       
     2 * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:               Language database class declaration.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 
       
    31 #ifndef _PTI_LANGUAGE_DATABASE_H
       
    32 #define _PTI_LANGUAGE_DATABASE_H
       
    33 
       
    34 // INCLUDES
       
    35 #include <badesca.h> 
       
    36 #include "PtiDefs.h"
       
    37 
       
    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;
       
    42 
       
    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;
       
    47 
       
    48 const TInt KOpaqueDataLen = 8;
       
    49 
       
    50 
       
    51 //
       
    52 // TPtiLangDatabaseMapping
       
    53 //
       
    54 class TPtiLangDatabaseMapping
       
    55 	{
       
    56 	public:
       
    57 		TInt iUid;
       
    58 		TInt iLangCode;
       
    59 	};	
       
    60 
       
    61 //
       
    62 // TPtiLangDatabaseMappingOpaque
       
    63 //
       
    64 class TPtiLangDatabaseMappingOpaque
       
    65 	{
       
    66 	public:
       
    67 		TInt iUid;
       
    68 		TInt iLangCode;
       
    69 		TBuf8<KOpaqueDataLen> iOpaque;
       
    70 	};
       
    71 	
       
    72 	
       
    73 //
       
    74 // TPtiLangDatabaseOpaqueBinding
       
    75 //		
       
    76 class TPtiLangDatabaseOpaqueBinding
       
    77     {
       
    78     public:
       
    79         TInt iUid;
       
    80        	TBuf8<KOpaqueDataLen> iOpaque;    
       
    81     };	
       
    82 	
       
    83 	
       
    84 /**
       
    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).
       
    88 */	
       
    89 class MPtiLanguageDatabase
       
    90 	{
       
    91 	public:
       
    92 		/**
       
    93 		* Implementation UID for core object owning this data.
       
    94 		*
       
    95 		* @since S60 V3.0
       
    96 		* @return Implementation Uid value of owning core object.
       
    97 		*/	
       
    98 		virtual TInt CoreUID() const = 0;
       
    99 		
       
   100 		/**
       
   101 		* Number on languages implemented in this database.
       
   102 		* 
       
   103 		* @since S60 V3.0
       
   104 		* return Number languages implemented in this database.
       
   105 		*/
       
   106 		virtual TInt NumLanguages() const = 0;
       
   107 		
       
   108 		/**
       
   109 		* Symbian OS language code for language data.
       
   110 		*
       
   111 		* @since S60 V3.0
       
   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.
       
   116 		*/ 
       
   117 		virtual TInt LanguageCode(TInt aIndex) const = 0;
       
   118 		
       
   119 		/**
       
   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.
       
   123 		*
       
   124 		* @since S60 V3.0
       
   125 		* @return Sub-language id. 
       
   126 		*/ 
       
   127 		virtual TInt SubLanguageCode(TInt aIndex) const = 0;
       
   128 		
       
   129 		/**
       
   130 		* Returns pointer to raw language data. 
       
   131 		* on the core object implementation.
       
   132 		*
       
   133 		* @since S60 V3.0
       
   134 		* @param aIndex Index of language implementation.
       
   135 		* @return Pointer to language data array.
       
   136 		*/
       
   137 		virtual TInt8* LangData(TInt aIndex) const = 0;
       
   138 		
       
   139 		/**
       
   140 		* Returns pointer to language data. The meaning of the data in array depends
       
   141 		* on the core object implementation.
       
   142 		*
       
   143 		* @since S60 V3.0
       
   144 		* @param aIndex Index of language implementation.		
       
   145 		* @param aNativeParams Core object related extra parameters.
       
   146 		* @return Pointer to language data array.
       
   147 		*/
       
   148 		virtual TInt8* LangData(TInt aIndex, TAny* aNativeParams) const = 0;
       
   149 				
       
   150 		/**
       
   151 		* Returns pointer to PinYin phrase input related data.
       
   152 		*		
       
   153 		* @since S60 V3.0
       
   154 		* @return Pointer to PinYin phrase input data.
       
   155 		*/
       
   156 		virtual TInt8* PinyinPhraseData() const = 0;
       
   157 		
       
   158 		/**
       
   159 		* Returns pointer to ZhuYin phrase input related data.
       
   160 		*		
       
   161 		* @since S60 V3.0
       
   162 		* @return Pointer to ZhuYin phrase input data.
       
   163 		*/
       
   164 		virtual TInt8* ZhuyinPhraseData() const = 0;
       
   165 		
       
   166 		/**
       
   167 		* Returns core object's internal language id value. The meaning of this
       
   168 		* value depends on core object implementation.
       
   169 		*
       
   170 		* @since S60 V3.0
       
   171 		* @return Core object internal language id.
       
   172 		*/		
       
   173 		virtual TInt NativeId(TInt aIndex) const = 0;
       
   174 	};
       
   175 
       
   176 
       
   177 /**
       
   178 * Default implementation for MPtiLanguageDatabase interface.
       
   179 */
       
   180 class CPtiLanguageDatabase : public CBase, public MPtiLanguageDatabase
       
   181 	{
       
   182 	public: 
       
   183 		/**
       
   184 		* Creates a language database instance for given implemenation UID.
       
   185 		* 
       
   186 		* @since S60 V3.0
       
   187 		* @return Pointer to language database instance.
       
   188 		*         NULL if not found. 
       
   189 		*/
       
   190 		IMPORT_C static CPtiLanguageDatabase* CreateDatabaseL(TUid aImplUid);
       
   191 		
       
   192 		/**
       
   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.
       
   195 		*
       
   196 		* @since S60 V3.0
       
   197 		* @param aCoreUid Implementation uid for core object.
       
   198 		* @return Pointer to a list containing implemention uids of language databases.
       
   199 		*/
       
   200 		IMPORT_C static CArrayFix<TInt>* ListDatabasesLC(TInt aCoreUid);
       
   201 		
       
   202 		/**
       
   203 		* Returns Symbian OS language code for the first language in given language database.
       
   204 		*
       
   205 		* @since S60 V3.0
       
   206 		* @param aUid An implementation uid for language database.
       
   207 		* @return Symbian OS language constant.
       
   208 		*         0, if not found.
       
   209 		*/		
       
   210 		IMPORT_C static TInt LanguageCodeForUid(TInt aUid);
       
   211 		
       
   212 		/**
       
   213 		* Fills given array with TPtiLangDatabaseMapping bindings for given core object. 
       
   214 		* Items in list bind Symbian OS language code to language database implemantion
       
   215 		* uid.
       
   216 		*
       
   217 		* @since S60 V3.0
       
   218 		* @param aCoreUid Core object implemenation uid.
       
   219 		* @param aResult Resulting list.
       
   220 		* @return Number of items in aResult.
       
   221 		*/
       
   222 		IMPORT_C static TInt CreateMappingTableL(TInt aCoreUid, RArray<TPtiLangDatabaseMapping>& aResult);
       
   223 		IMPORT_C static TInt CreateMappingTableWithOpaqueL(TInt aCoreUid, RArray<TPtiLangDatabaseMappingOpaque>& aResult);
       
   224 
       
   225 	public: 
       
   226 		IMPORT_C ~CPtiLanguageDatabase();
       
   227 			
       
   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;
       
   238 
       
   239 	public:
       
   240 		inline void SetDestructorKeyId(TInt aDtorKeyId);
       
   241 
       
   242 	private:
       
   243 		TInt iDtorKeyId;
       
   244 		TInt Reserved_1;
       
   245 	};
       
   246 
       
   247 
       
   248 // ---------------------------------------------------------------------------
       
   249 // CPtiLanguageDatabase::SetDestructorKeyId
       
   250 // 
       
   251 // ---------------------------------------------------------------------------
       
   252 // 	
       
   253 inline void CPtiLanguageDatabase::SetDestructorKeyId(TInt aDtorKeyId)
       
   254 	{
       
   255 	iDtorKeyId = aDtorKeyId;
       
   256 	}
       
   257 
       
   258 #endif // _PTI_LANGUAGE_DATABASE_H
       
   259 
       
   260 // End of file
       
   261 
       
   262