predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsKeyMap.h
branchRCL_3
changeset 6 e8e3147d53eb
parent 0 e686773b3f54
child 7 b3431bff8c19
equal deleted inserted replaced
5:81f8547efd4f 6:e8e3147d53eb
    18 #ifndef __CPCS_KEY_MAP_H__
    18 #ifndef __CPCS_KEY_MAP_H__
    19 #define __CPCS_KEY_MAP_H__
    19 #define __CPCS_KEY_MAP_H__
    20 
    20 
    21 // INCLUDES
    21 // INCLUDES
    22 #include <e32base.h>
    22 #include <e32base.h>
    23 #include <PtiEngine.h>
    23 #include <PtiDefs.h>
    24 #include <PtiKeyMappings.h>
       
    25 #include <AvkonInternalCRKeys.h>
    24 #include <AvkonInternalCRKeys.h>
    26 #include <e32property.h>
    25 #include <e32property.h>
       
    26 #include <CPcsDefs.h>
    27 
    27 
    28 class CPsQuery;
    28 class CPsQuery;
       
    29 class CPtiEngine;
       
    30 class CPtiCoreLanguage;
       
    31 
    29 
    32 
    30 class TKeyMappingData
    33 class TKeyMappingData
    31     {
    34     {
    32     public:
    35     public:
    33         // Keep the following order as it follows the search priority
    36         // Keep the following order as it follows the search priority
    68         /**
    71         /**
    69          * Destructor
    72          * Destructor
    70          */
    73          */
    71         virtual ~CPcsKeyMap();
    74         virtual ~CPcsKeyMap();
    72 
    75 
    73 		/**
    76         static TBool IsModePredictive( TKeyboardModes aKbMode );
    74 		 * Convert functions to get the key string from query and/or chars string
    77 
    75 		 */
    78         /**
    76 		void GetMixedKeyStringForQueryL(CPsQuery& aSrcQuery, TDes& aDestStr);
    79          * Convert functions to get the key string from query and/or chars string
    77 		void GetMixedKeyStringForDataL(CPsQuery& aSrcQuery, const TDesC& aSrcData, TDes& aDestStr);
    80          */
    78 		
    81         void GetMixedKeyStringForQueryL(CPsQuery& aSrcQuery, TDes& aDestStr) const;
    79 		/**
    82         void GetMixedKeyStringForDataL(CPsQuery& aSrcQuery, const TDesC& aSrcData, TDes& aDestStr) const;
    80 		 * Returns true if the character is mapped to the key
    83 
    81 		 */
    84         /**
    82 		TBool CharacterForKeyMappingExists(TKeyMappingData& aKeyMap, const TUint aIntChar);
    85          * Returns true if the character is mapped to the key
    83 
    86          */
    84 #ifdef _DEBUG
    87         TBool CharacterForKeyMappingExists(TKeyMappingData& aKeyMap, TUint aIntChar) const;
    85 		/**
       
    86 		 * Check potential error conditions for KeyForCharacterMultiMatch
       
    87 		 */
       
    88 		void CheckPotentialErrorConditions(RArray<TInt>& aPoolIndexArr, const TChar& aChar);
       
    89 #endif // _DEBUG
       
    90 
    88 
    91         /**
    89         /**
    92          * Returns the numeric key id corresponding to a specific character
    90          * Returns the numeric key id corresponding to a specific character
    93          * Considers possible multiple matches for some phone variants
    91          * Considers possible multiple matches for some phone variants
    94          */
    92          */
    95         TPtiKey KeyForCharacterMultiMatch(const TChar& aChar);
    93         TPtiKey KeyForCharacterMultiMatch( const TChar& aChar, TKeyboardModes aKbMode ) const;
    96 
    94 
    97         /**
    95         /**
    98          * Returns true if the characters "0" and " " are on the same key
    96          * Returns true if the characters "0" and " " are on the same key
    99          */
    97          */
   100         TBool GetSpaceAndZeroOnSameKey();
    98         TBool GetSpaceAndZeroOnSameKey( TKeyboardModes aKbMode );
   101 
    99 
   102         /**
   100         /**
   103          * Returns true if this language is supported
   101          * Returns true if this language is supported
   104          */
   102          */
   105         TBool IsLanguageSupported(TInt aLang);
   103         TBool IsLanguageSupported(TInt aLang);
   106 
   104 
   107         /**
   105         /**
       
   106          * Returns the pool Id for a character
       
   107          */
       
   108         TInt PoolIdForCharacter(const TChar& aChar, TKeyboardModes aKbMode);
       
   109 
       
   110         /**
       
   111          * Returns total number of pools
       
   112          */
       
   113         TInt PoolCount();
       
   114 
       
   115     private:
       
   116 
       
   117         /**
       
   118          * Constructor
       
   119          */
       
   120         CPcsKeyMap();
       
   121 
       
   122         /**
       
   123          * Second phase constructor
       
   124          */
       
   125         void ConstructL();
       
   126 
       
   127         /**
       
   128          * Select keyboard types according to available physical keyboard(s)
       
   129          */
       
   130         void SetupKeyboardTypesL();
       
   131 
       
   132         /**
   108          * Returns the pool Id for a key
   133          * Returns the pool Id for a key
   109          */
   134          */
   110         TInt PoolIdForKey(const TPtiKey aKey);
   135         TInt PoolIdForKey(const TPtiKey aKey, TKeyboardModes aKbMode);
   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 
   136 
   149         /**
   137         /**
   150          * Helper function to construct Key Mappings
   138          * Helper function to construct Key Mappings
   151          */
   139          */
   152         void CreateKeyMappingL();
   140         void CreateKeyMappingL( TKeyboardModes aKbMode );
       
   141 
       
   142         /**
       
   143          * Create list of PTI keys for the given keyboard type
       
   144          */
       
   145         void CreateKeyListFromKeyBindingTable( RArray<TPtiKey>& aKeyArray, TPtiKeyboardType aKbType, CPtiEngine* aPtiEngine );
       
   146 
       
   147         /**
       
   148          * Add a non-existing key ID in the end of given array
       
   149          */
       
   150         void AppendEntryWithFakeKeyToKeyList( RArray<TPtiKey>& aKeyArray );
   153 
   151 
   154         /**
   152         /**
   155          * Helper functions to populate Keyboard Key Mappings (Characters for
   153          * Helper functions to populate Keyboard Key Mappings (Characters for
   156          * all Keys) for the Active Language
   154          * all Keys) for the given Language
   157          */
   155          */
   158         void AddKeyMappingForActiveLanguageL(CPtiEngine* aPtiEngine, TLanguage aLanguage);
   156         void AddKeyMappingForLanguageL( CPtiEngine* aPtiEngine, 
   159         void GetCharactersForKey(MPtiKeyMappings& aPtiKeyMappings,
   157                                         TLanguage aLanguage,
       
   158                                         TPtiKeyboardType aKbType,
       
   159                                         const RArray<TPtiKey>& aPtiKeys,
       
   160                                         RPointerArray<TKeyMappingData>& aResultMapping );
       
   161         void GetCharactersForKey( CPtiCoreLanguage& aPtiLanguage,
       
   162                                   TPtiKeyboardType aKbType,
       
   163                                   TPtiKey aKey,
       
   164                                   TPtiTextCase aTextCase,
       
   165                                   TDes& aResult );
       
   166         void AddCharactersToKey( CPtiCoreLanguage& aPtiLanguage,
       
   167                                  TPtiKeyboardType aKbType,
   160                                  TPtiKey aKey,
   168                                  TPtiKey aKey,
   161                                  TPtiTextCase aTextCase,
   169                                  TPtiTextCase aTextCase,
   162                                  TDes& aResult);
   170                                  TKeyMappingData& aKeyDataList,
   163         void AddCharactersToKey(MPtiKeyMappings& aPtiKeyMappings,
   171                                  RArray<TUint>& aKeyMapLang,
   164                                 TPtiKey aKey,
   172                                  TBool& aIsSingleCharForKey,
   165                                 TPtiTextCase aTextCase,
   173                                  TUint& aSingleChar );
   166                                 TKeyMappingData& aKeyDataList,
       
   167                                 RArray<TUint>& aKeyMapLang,
       
   168                                 TBool& aIsSingleCharForKey,
       
   169                                 TUint& aSingleChar);
       
   170 
   174 
   171         /**
   175         /**
   172          * Sets attribute to true if the characters "0" and " " are on the same key
   176          * Sets attribute to true if the characters "0" and " " are on the same key
   173          */
   177          */
   174         void SetSpaceAndZeroOnSameKey();
   178         void SetSpaceAndZeroOnSameKey();
   175 
   179 
       
   180         /**
       
   181          * Gets predictive keyboard mapping data for given match mode.
       
   182          * @param   aKbMode      Matching mode for which data is asked. 
       
   183          * @param   aPtiKeys     On return, will point to the array of PtiKeys for the given mode.
       
   184          * @param   aKeyMappings On return, will point to key mapping array for the given mode.
       
   185          * @param   aKbType      On return, will hold the keyboard type for the given mode.
       
   186          */
       
   187         void GetPredictiveKeyboardData( TKeyboardModes aKbMode, 
       
   188                                         RArray<TPtiKey>*& aPtiKeys, 
       
   189                                         RPointerArray<TKeyMappingData>*& aKeyMappings, 
       
   190                                         TPtiKeyboardType& aKbType );
       
   191         /**
       
   192          * Constant overload of the GetPredictiveKeyboardData function.
       
   193          */
       
   194         void GetPredictiveKeyboardData( TKeyboardModes aKbMode, 
       
   195                                         const RArray<TPtiKey>*& aPtiKeys, 
       
   196                                         const RPointerArray<TKeyMappingData>*& aKeyMappings, 
       
   197                                         TPtiKeyboardType& aKbType ) const;
       
   198 
       
   199         /**
       
   200          * Resolve keyboard mode to "ITU-T predictive" or "QWERTY predictive".
       
   201          */
       
   202         TKeyboardModes ResolveKeyboardMode( TKeyboardModes aKbMode,
       
   203                                             TKeyboardModes aKbModeToResolve ) const;
       
   204 
       
   205 
       
   206 #ifdef _DEBUG
       
   207         /**
       
   208          * Check potential error conditions for KeyForCharacterMultiMatch
       
   209          */
       
   210         void CheckPotentialErrorConditions(const RArray<TInt>& aPoolIndexArr, 
       
   211                                            const TChar& aChar,
       
   212                                            const RArray<TPtiKey>& aPtiKeys,
       
   213                                            const RPointerArray<TKeyMappingData>& aKeyMappings) const;
       
   214 #endif // _DEBUG
       
   215 
   176     private:
   216     private:
   177 
   217 
   178         /**
   218         /**
   179          * Array to hold the list of languages not supported
   219          * Array to hold the list of languages not supported
   180          */
   220          */
   184          * UI Language
   224          * UI Language
   185          */
   225          */
   186         TLanguage iUILanguage;
   226         TLanguage iUILanguage;
   187 
   227 
   188         /**
   228         /**
   189          * Flag to indicate if Phone is Chinese variant
   229          * Type of keyboard used in ITU-T search mode. Typically this is
   190          */
   230          * standard ITU-T 12-key keypad.
   191         RArray<TPtiKey> iKeysArr;
   231          */
   192 
   232         TPtiKeyboardType iItutKeyboardType;
   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         
   233         
   203         /**
   234         /**
   204          * True if "0" and " " are on the same key
   235          * Type of keyboard used in QWERTY search mode. Typically this is either
   205          */
   236          * 3x11 or 4x10 QWERTY or EPtiKeyboardNone if there's no any kind of
   206         TBool iSpaceAndZeroOnSameKey;
   237          * QWERTY available. This may also be half-QWERTY.
       
   238          */
       
   239         TPtiKeyboardType iQwertyKeyboardType;
       
   240 
       
   241         /**
       
   242          * Type of keyboard used in Default Preditive search mode. This will
       
   243          * point to ITU-T or QWERTY keypad.
       
   244          */
       
   245         TKeyboardModes iPredictiveDefaultKeyboardMode;
       
   246 
       
   247         /**
       
   248          * Pti keys of ITU-T mode
       
   249          */
       
   250         RArray<TPtiKey> iItutKeys;
       
   251 
       
   252         /**
       
   253          * Pti keys of QWERTY mode
       
   254          */
       
   255         RArray<TPtiKey> iQwertyKeys;
       
   256 
       
   257         /**
       
   258          * Contains all the keys and the characters mapped to each key in ITU-T mode. Owned.
       
   259          */
       
   260         RPointerArray<TKeyMappingData> iItutKeyMaps;
       
   261 
       
   262         /**
       
   263          * Contains all the keys and the characters mapped to each key in QWERTY mode. Owned.
       
   264          */
       
   265         RPointerArray<TKeyMappingData> iQwertyKeyMaps;
       
   266 
       
   267         /**
       
   268          * True if "0" and " " are on the same key in the ITU-T mode
       
   269          */
       
   270         TBool iSpaceAndZeroOnSameKeyOnItut;
       
   271         
       
   272         /**
       
   273          * True if "0" and " " are on the same key in the QWERTY mode
       
   274          */
       
   275         TBool iSpaceAndZeroOnSameKeyOnQwerty;
       
   276 
   207 };
   277 };
   208 
   278 
   209 #endif // __CPCS_KEY_MAP_H__
   279 #endif // __CPCS_KEY_MAP_H__
   210 
   280 
   211 // End of file
   281 // End of file