predictivesearch/PcsAlgorithm/Algorithm2/inc/CPcsKeyMap.h
changeset 0 e686773b3f54
child 7 b3431bff8c19
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_ALGORITHM_2_H__
       
    19 #define __CPCS_KEY_MAP_ALGORITHM_2_H__
       
    20 
       
    21 // The macro is used for a hack which fix a problem of PtiEngine with Sonja keyboard.
       
    22 // The problem is that J/# key can't returned character code ('J', 'j', '#') 
       
    23 #define HACK_FOR_E72_J_KEY
       
    24 
       
    25 // INCLUDES
       
    26 #include <e32base.h>
       
    27 #include <PtiEngine.h>
       
    28 #include <PtiKeyMappings.h>
       
    29 #include <AvkonInternalCRKeys.h>
       
    30 #include <e32property.h>
       
    31 
       
    32 class CPcsAlgorithm2;
       
    33 class     CPtiEngine;
       
    34 
       
    35 class TKeyMappingData
       
    36     {
       
    37 public:
       
    38     TPtiKey key; // key
       
    39     RArray<TInt> iKeyMappingArray; // All the characters mapped to the key
       
    40     };
       
    41 
       
    42 // CLASS DECLARATION
       
    43 class CPcsKeyMap : public CBase
       
    44     {
       
    45 
       
    46 public:
       
    47 
       
    48     /**
       
    49      * Two phase construction
       
    50      */
       
    51     static CPcsKeyMap* NewL(CPcsAlgorithm2* aAlgorithm);
       
    52 
       
    53     /**
       
    54      * Destructor
       
    55      */
       
    56     virtual ~CPcsKeyMap();
       
    57 
       
    58     /**
       
    59      * Converts the alphanumeric string to numeric string
       
    60      */
       
    61     void GetNumericKeyString(const TDesC& alphaNumericStr, TDes& numericStr);
       
    62 
       
    63     /**
       
    64      * Returns the numeric key id corresponding to a specific character		                          
       
    65      */
       
    66     TInt KeyForCharacter(const TChar& aChar);
       
    67 
       
    68     /**
       
    69      * Returns ETrue if this language is supported
       
    70      */
       
    71     TBool IsLanguageSupportedL(const TUint32 aLanguage);
       
    72 
       
    73     void ReconstructKeymapL();
       
    74     /**
       
    75      * Returns the pool Id for a key                               
       
    76      */
       
    77     TInt CPcsKeyMap::PoolIdForCharacter(const TChar& aChar);
       
    78     /**
       
    79      * Returns total number of pools                                
       
    80      */
       
    81     TInt PoolCount();
       
    82 
       
    83 private:
       
    84 
       
    85     /**
       
    86      * Constructor
       
    87      */
       
    88     CPcsKeyMap();
       
    89 
       
    90     /**
       
    91      * Second phase constructor
       
    92      */
       
    93     void ConstructL(CPcsAlgorithm2* aAlgorithm);
       
    94 
       
    95     /**
       
    96      * Helper function to construct keyboard specific mappings
       
    97      */
       
    98     void ContructForItutKeyboardL(TLanguage aLanguage);
       
    99     void ContructForHalfQwertyKeyboardL(TLanguage aLanguage);
       
   100     void ContructFor4x10QwertyKeyboardL(TLanguage aLanguage);
       
   101 
       
   102     /**
       
   103      * Helper function to populate Itut key mappings
       
   104      */
       
   105     void AddKeyMapforItutL(TLanguage aLanguage);
       
   106 
       
   107     void AddDataForItutKeyboardL(CPtiKeyMappings* aPtiKeyMappings,
       
   108             TPtiKey aKey, TKeyMappingData& aKeyDataList);
       
   109     /**
       
   110      * Helper function to populate 4x10 Qwerty Keyboard  key mappings
       
   111      */
       
   112     void AddKeyMapfor4x10QwertyKeyboardL(TLanguage aLanguage);
       
   113 
       
   114     void AddDataFor4x10QwertyKeyboardL(
       
   115             CPtiQwertyKeyMappings* aPtiKeyMappings, TPtiKey aKey,
       
   116             TKeyMappingData& aKeyDataList);
       
   117     
       
   118 #ifdef HACK_FOR_E72_J_KEY
       
   119     void AddDataFor4x10QwertyKeyboardE72HackL(); // Hack for E72 (J/# key)
       
   120 #endif  // HACK_FOR_E72_J_KEY
       
   121     
       
   122     /**
       
   123      * Helper function to populate alfQwerty Keyboard key mappings
       
   124      */
       
   125     void AddKeyMapforHalfQwertyKeyboardL(TLanguage aLanguage);
       
   126 
       
   127     void AddDataForHalfQwertyKeyboardL(CPtiHalfQwertyKeyMappings* aPtiKeyMappings,
       
   128             TPtiKey aKey, TKeyMappingData& aKeyDataList);
       
   129 
       
   130     void ResetKeyMap();
       
   131     /**
       
   132      * Function to construct key mappings for a particula language
       
   133      * 
       
   134      */
       
   135     void ConstructKeymapL();
       
   136     
       
   137     /**
       
   138      * Get the current keyboard type.
       
   139      * @return current keyboard type.
       
   140      */
       
   141     TInt CurrentKeyBoardTypeL();
       
   142     
       
   143     /**
       
   144      * 
       
   145      * Construct keymap by type and language
       
   146      * @ aKeyboardType, the current keyboard type.
       
   147      * @ aLanguage, the keymap construct language.
       
   148      */
       
   149     void ConstructConcreteKeyMapL( TInt aKeyboardType, TLanguage aLanguage );
       
   150     
       
   151     /**
       
   152      * 
       
   153      * Add keymap for keyboard by type and language
       
   154      * @ aKeyboardType, the current keyboard type.
       
   155      * @ aLanguage, the keymap construct language.
       
   156      */
       
   157     void AddKeyMapforConcreteKeyboardL( TInt aKeyboardType, TLanguage aLanguage );
       
   158 
       
   159 private:
       
   160     CPtiEngine* iPtiEngine;
       
   161 
       
   162     CPcsAlgorithm2* iAlgorithm;
       
   163     /**
       
   164      * Array to hold the list of languages not supported
       
   165      */
       
   166     RArray<TLanguage> iLanguageNotSupported;
       
   167 
       
   168     /**
       
   169      * Flag to indicate if Phone is Chinese variant 
       
   170      */
       
   171     RArray<TPtiKey> iKeysForPoolFormation;
       
   172 
       
   173     /**
       
   174      * Contains all the keys and the characters mapped to each key
       
   175      * own
       
   176      */
       
   177     RPointerArray<TKeyMappingData> iAllKeyMappingsPtrArr;
       
   178     
       
   179     };
       
   180 
       
   181 #endif // __CPCS_KEY_MAP_ALGORITHM_2_H__
       
   182 
       
   183 // End of file