predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsKeyMap.h
changeset 0 e686773b3f54
child 6 e8e3147d53eb
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2006-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 "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".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Class to hold the character to key mappings
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CPCS_KEY_MAP_H__
       
    19 #define __CPCS_KEY_MAP_H__
       
    20 
       
    21 // INCLUDES
       
    22 #include <e32base.h>
       
    23 #include <PtiEngine.h>
       
    24 #include <PtiKeyMappings.h>
       
    25 #include <AvkonInternalCRKeys.h>
       
    26 #include <e32property.h>
       
    27 
       
    28 class CPsQuery;
       
    29 
       
    30 class TKeyMappingData
       
    31     {
       
    32     public:
       
    33         // Keep the following order as it follows the search priority
       
    34         enum TCharArraySelector
       
    35             {
       
    36             EKeyMapSingleCharArr = 0,
       
    37             EKeyMapUILangArr,
       
    38             EKeyMapEnglishLangArr,
       
    39             EKeyMapOthersLangArr,
       
    40             EKeyMapNumberArr
       
    41             };
       
    42 
       
    43         TFixedArray<RArray<TUint>, TKeyMappingData::EKeyMapNumberArr> iKeyMapCharArr; 
       
    44         
       
    45         /* Help for deciding the key from the char in devices language variants
       
    46          *   iKeyMapCharArr[EKeyMapSingleCharArr]:  All the single chars for the languages
       
    47          * 
       
    48          * Sharing the chars in the following 3 classes helps for guessing the key from the key
       
    49          * in a more appropriate way (giving language preferences) when the same character can be mapped
       
    50          * to more keys considering all the supported languages together
       
    51          *   iKeyMapCharArr[EKeyMapUILangArr]:      All chars mapped to the key for UI Language
       
    52          *   iKeyMapCharArr[EKeyMapEnglishLangArr]: All remaining chars mapped to the key for English Language
       
    53          *   iKeyMapCharArr[EKeyMapOthersLangArr]:  All remaining chars mapped to the key for the other languages
       
    54          */
       
    55     };
       
    56 
       
    57 // CLASS DECLARATION
       
    58 class CPcsKeyMap : public CBase
       
    59 {
       
    60 
       
    61     public:
       
    62 
       
    63         /**
       
    64          * Two phase construction
       
    65          */
       
    66         static CPcsKeyMap* NewL();
       
    67 
       
    68         /**
       
    69          * Destructor
       
    70          */
       
    71         virtual ~CPcsKeyMap();
       
    72 
       
    73 		/**
       
    74 		 * Convert functions to get the key string from query and/or chars string
       
    75 		 */
       
    76 		void GetMixedKeyStringForQueryL(CPsQuery& aSrcQuery, TDes& aDestStr);
       
    77 		void GetMixedKeyStringForDataL(CPsQuery& aSrcQuery, const TDesC& aSrcData, TDes& aDestStr);
       
    78 		
       
    79 		/**
       
    80 		 * Returns true if the character is mapped to the key
       
    81 		 */
       
    82 		TBool CharacterForKeyMappingExists(TKeyMappingData& aKeyMap, const TUint aIntChar);
       
    83 
       
    84 #ifdef _DEBUG
       
    85 		/**
       
    86 		 * Check potential error conditions for KeyForCharacterMultiMatch
       
    87 		 */
       
    88 		void CheckPotentialErrorConditions(RArray<TInt>& aPoolIndexArr, const TChar& aChar);
       
    89 #endif // _DEBUG
       
    90 
       
    91         /**
       
    92          * Returns the numeric key id corresponding to a specific character
       
    93          * Considers possible multiple matches for some phone variants
       
    94          */
       
    95         TPtiKey KeyForCharacterMultiMatch(const TChar& aChar);
       
    96 
       
    97         /**
       
    98          * Returns true if the characters "0" and " " are on the same key
       
    99          */
       
   100         TBool GetSpaceAndZeroOnSameKey();
       
   101 
       
   102         /**
       
   103          * Returns true if this language is supported
       
   104          */
       
   105         TBool IsLanguageSupported(TInt aLang);
       
   106 
       
   107         /**
       
   108          * Returns the pool Id for a key
       
   109          */
       
   110         TInt PoolIdForKey(const TPtiKey aKey);
       
   111 
       
   112         /**
       
   113          * Returns the pool Id for a character
       
   114          */
       
   115         TInt PoolIdForCharacter(const TChar& aChar);
       
   116 
       
   117         /**
       
   118          * Returns total number of pools
       
   119          */
       
   120         TInt PoolCount();
       
   121 
       
   122     private:
       
   123 
       
   124         /**
       
   125          * Constructor
       
   126          */
       
   127         CPcsKeyMap();
       
   128 
       
   129         /**
       
   130          * Second phase constructor
       
   131          */
       
   132         void ConstructL();
       
   133 
       
   134         /**
       
   135          * Helper functions to get Key Mappings and Key Mappings Data depending
       
   136          * on keyboard type
       
   137          */
       
   138         MPtiKeyMappings* GetKeyboardKeyMapping(CPtiCoreLanguage& aCurrLanguage);
       
   139         CPtiKeyMapData* GetKeyMapData(CPtiCoreLanguage& aCurrLanguage);
       
   140 
       
   141         /**
       
   142          * Helper functions to construct Key List for different keyboards
       
   143          */
       
   144         void AppendEntryWithFakeKeyToKeyList();
       
   145         void CreateKeyListFromITUTHardcodedKeys();
       
   146         void CreateKeyListFromKeyBindingTable( CPtiEngine* aPtiEngine );
       
   147         void CreateKeyListL( CPtiEngine* aPtiEngine );
       
   148 
       
   149         /**
       
   150          * Helper function to construct Key Mappings
       
   151          */
       
   152         void CreateKeyMappingL();
       
   153 
       
   154         /**
       
   155          * Helper functions to populate Keyboard Key Mappings (Characters for
       
   156          * all Keys) for the Active Language
       
   157          */
       
   158         void AddKeyMappingForActiveLanguageL(CPtiEngine* aPtiEngine, TLanguage aLanguage);
       
   159         void GetCharactersForKey(MPtiKeyMappings& aPtiKeyMappings,
       
   160                                  TPtiKey aKey,
       
   161                                  TPtiTextCase aTextCase,
       
   162                                  TDes& aResult);
       
   163         void AddCharactersToKey(MPtiKeyMappings& aPtiKeyMappings,
       
   164                                 TPtiKey aKey,
       
   165                                 TPtiTextCase aTextCase,
       
   166                                 TKeyMappingData& aKeyDataList,
       
   167                                 RArray<TUint>& aKeyMapLang,
       
   168                                 TBool& aIsSingleCharForKey,
       
   169                                 TUint& aSingleChar);
       
   170 
       
   171         /**
       
   172          * Sets attribute to true if the characters "0" and " " are on the same key
       
   173          */
       
   174         void SetSpaceAndZeroOnSameKey();
       
   175 
       
   176     private:
       
   177 
       
   178         /**
       
   179          * Array to hold the list of languages not supported
       
   180          */
       
   181         RArray<TLanguage> iLanguageNotSupported;
       
   182 
       
   183         /**
       
   184          * UI Language
       
   185          */
       
   186         TLanguage iUILanguage;
       
   187 
       
   188         /**
       
   189          * Flag to indicate if Phone is Chinese variant
       
   190          */
       
   191         RArray<TPtiKey> iKeysArr;
       
   192 
       
   193         /**
       
   194          * Contains all the keys and the characters mapped to each key own
       
   195          */
       
   196         RPointerArray<TKeyMappingData> iKeyMapPtrArr;
       
   197 
       
   198         /**
       
   199          * Type of keyboard for example, half-qwerty, 4x10 qwerty etc
       
   200          */
       
   201         TPtiKeyboardType iKeyboardType;
       
   202         
       
   203         /**
       
   204          * True if "0" and " " are on the same key
       
   205          */
       
   206         TBool iSpaceAndZeroOnSameKey;
       
   207 };
       
   208 
       
   209 #endif // __CPCS_KEY_MAP_H__
       
   210 
       
   211 // End of file