phonebookengines/contactsmodel/cntplsql/src/cpcskeymap.cpp
changeset 31 2a11b5b00470
parent 27 de1630741fbe
child 46 efe85016a067
equal deleted inserted replaced
27:de1630741fbe 31:2a11b5b00470
    18 #include "cpcskeymap.h"
    18 #include "cpcskeymap.h"
    19 
    19 
    20 #if defined(USE_ORBIT_KEYMAP)
    20 #if defined(USE_ORBIT_KEYMAP)
    21 
    21 
    22 // If defined, only the currently used language's keymap is used
    22 // If defined, only the currently used language's keymap is used
    23 #define USE_ONLY_DEFAULT_LANG_KEYMAP
    23 //#define USE_ONLY_DEFAULT_LANG_KEYMAP
    24 
    24 
    25 
    25 
    26 #include <QLocale>
    26 #include <QLocale>
    27 #include <hbinputlanguage.h>
    27 #include <hbinputlanguage.h>
    28 #include <hbinputkeymap.h>
    28 #include <hbinputkeymap.h>
    53 
    53 
    54 // Separator character stored in predictive search table columns
    54 // Separator character stored in predictive search table columns
    55 _LIT(KSeparator, " ");
    55 _LIT(KSeparator, " ");
    56 
    56 
    57 #if defined(USE_ORBIT_KEYMAP)
    57 #if defined(USE_ORBIT_KEYMAP)
    58 // How many keys have mappings (keys 0..9 have mapping)
    58 // How many keys have mappings in ITU-T keypad (keys 0..9, * and # have mappings)
    59 const TInt KAmountOfKeys = 10;
    59 const TInt KAmountOfKeys = 12;
    60 
    60 
    61 // The first key of the keyboard has value zero ('1' in the 12-key virtual keypad) 
    61 // The first key of the keyboard has value zero ('1' in the 12-key virtual keypad) 
    62 enum TKeyId
    62 enum TKeyId
    63     {
    63     {
    64     EKey1 = 0,
    64     EKey1 = 0,
    68     EKey5,
    68     EKey5,
    69     EKey6,
    69     EKey6,
    70     EKey7,
    70     EKey7,
    71     EKey8,
    71     EKey8,
    72     EKey9,
    72     EKey9,
    73 	EKey0
    73 	EKey0,
       
    74 	EKeyStar,
       
    75 	EKeyHash,
       
    76 	ELastKey = EKeyHash
    74     };
    77     };
       
    78 
       
    79 const QChar KStar = '*';
       
    80 const QChar KPlus = '+';
       
    81 const QChar KHash = '#';
    75 #endif // #if defined(USE_ORBIT_KEYMAP)
    82 #endif // #if defined(USE_ORBIT_KEYMAP)
    76 
    83 
       
    84 // * key is mapped to this
       
    85 const TChar KMappedCharForStar = 'a';
       
    86 // # key is mapped to this
       
    87 const TChar KMappedCharForHash = 'b';
       
    88 // Unmapped (unknown) characters are replaced with this
       
    89 const TChar KPadChar = 'f';
       
    90 
       
    91 
    77 // ============================== MEMBER FUNCTIONS ============================
    92 // ============================== MEMBER FUNCTIONS ============================
    78 
    93 
    79 // ----------------------------------------------------------------------------
    94 // ----------------------------------------------------------------------------
    80 // CPcsKeyMap::NewL
    95 // CPcsKeyMap::NewL
    81 // ----------------------------------------------------------------------------
    96 // ----------------------------------------------------------------------------
    82 CPcsKeyMap* CPcsKeyMap::NewL()
    97 CPcsKeyMap* CPcsKeyMap::NewL()
    83 	{
    98 	{
    84     PRINT( _L("Enter CPcsKeyMap::NewL") );
    99     PRINT(_L("Enter CPcsKeyMap::NewL"));
    85     
   100     
    86     CPcsKeyMap* self = new ( ELeave ) CPcsKeyMap();
   101     CPcsKeyMap* self = new (ELeave) CPcsKeyMap();
    87     CleanupStack::PushL( self );
   102     CleanupStack::PushL(self);
    88     self->ConstructL();
   103     self->ConstructL();
    89     CleanupStack::Pop( self );
   104     CleanupStack::Pop(self);
    90 
   105 
    91     PRINT( _L("End CPcsKeyMap::NewL") );
   106     PRINT(_L("End CPcsKeyMap::NewL"));
    92     return self;
   107     return self;
    93 	}
   108 	}
    94 
   109 
    95 // ----------------------------------------------------------------------------
   110 // ----------------------------------------------------------------------------
    96 // CPcsKeyMap::~CPcsKeyMap
   111 // CPcsKeyMap::~CPcsKeyMap
    97 // ----------------------------------------------------------------------------
   112 // ----------------------------------------------------------------------------
    98 CPcsKeyMap::~CPcsKeyMap()
   113 CPcsKeyMap::~CPcsKeyMap()
    99     {
   114     {
   100     PRINT( _L("Enter CPcsKeyMap::~CPcsKeyMap") );    
   115     PRINT(_L("Enter CPcsKeyMap::~CPcsKeyMap"));    
   101     PRINT( _L("End CPcsKeyMap::~CPcsKeyMap") );
   116     PRINT(_L("End CPcsKeyMap::~CPcsKeyMap"));
   102     }
   117     }
   103 
   118 
   104 // ----------------------------------------------------------------------------
   119 // ----------------------------------------------------------------------------
   105 // CPcsKeyMap::GetNumericKeyStringL
   120 // CPcsKeyMap::GetNumericKeyStringL
   106 // If aPlainConversion is EFalse, supports sub-string searches and space is
   121 // If aPlainConversion is EFalse, supports sub-string searches and space is
   107 // converted to a separator character (not zero).
   122 // converted to a separator character (not zero).
   108 // ----------------------------------------------------------------------------
   123 // ----------------------------------------------------------------------------
   109 HBufC* CPcsKeyMap::GetNumericKeyStringL(const TDesC& aSource,
   124 HBufC* CPcsKeyMap::GetNumericKeyStringL(const TDesC& aSource,
   110                                         TBool aPlainConversion) const
   125                                         TBool aPlainConversion) const
   111     {
   126     {
   112     PRINT1( _L("Enter CPcsKeyMap::GetNumericKeyStringL input '%S'"), &aSource );    
   127     PRINT1(_L("Enter CPcsKeyMap::GetNumericKeyStringL input '%S'"), &aSource);
   113 
   128 
   114     TInt length = aSource.Length();
   129     TInt length = aSource.Length();
   115     HBufC* destination = HBufC::NewL(length);
   130     HBufC* destination = HBufC::NewL(length);
   116     TPtr ptr = destination->Des();
   131     TPtr ptr = destination->Des();
   117 
   132 
   131 			ptr.Append(GetNumericValueForChar(b));
   146 			ptr.Append(GetNumericValueForChar(b));
   132 #endif
   147 #endif
   133             }
   148             }
   134         }
   149         }
   135 
   150 
   136     PRINT1( _L("End CPcsKeyMap::GetNumericKeyStringL result '%S'"), destination );
   151     PRINT1(_L("End CPcsKeyMap::GetNumericKeyStringL result '%S'"), destination);
   137     return destination;
   152     return destination;
   138     }
   153     }
   139 
   154 
   140 #if defined(USE_ORBIT_KEYMAP)
   155 #if defined(USE_ORBIT_KEYMAP)
   141 // ----------------------------------------------------------------------------
   156 // ----------------------------------------------------------------------------
   151 // Fill QList with empty strings
   166 // Fill QList with empty strings
   152 // ----------------------------------------------------------------------------
   167 // ----------------------------------------------------------------------------
   153 CPcsKeyMap::CPcsKeyMap() :
   168 CPcsKeyMap::CPcsKeyMap() :
   154     iKeyMapping() 
   169     iKeyMapping() 
   155 	{
   170 	{
   156     for (TInt i = 0; i < KAmountOfKeys; ++i)
       
   157         {
       
   158         iKeyMapping << QString("");
       
   159         }
       
   160 	}
   171 	}
   161 
   172 
   162 // ----------------------------------------------------------------------------
   173 // ----------------------------------------------------------------------------
   163 // CPcsKeyMap::ConstructL
   174 // CPcsKeyMap::ConstructL
   164 // ----------------------------------------------------------------------------
   175 // ----------------------------------------------------------------------------
   165 void CPcsKeyMap::ConstructL()
   176 void CPcsKeyMap::ConstructL()
   166 	{
   177 	{
   167 	TBool ok(EFalse);
       
   168 	TInt err(KErrNone);
   178 	TInt err(KErrNone);
   169 	QT_TRYCATCH_ERROR(err, ok = ContructKeyboardMappings());
   179 	QT_TRYCATCH_ERROR(err, ContructKeyboardMappings());
   170     if (err != KErrNone)
   180     if (err != KErrNone)
   171         {
   181         {
   172         PRINT1(_L("ContructKeyboardMappings threw exception, err=%d"), err);
   182         PRINT1(_L("ContructKeyboardMappings threw exception, err=%d"), err);
   173         User::Leave(err);
   183         User::Leave(err);
   174         }
   184         }
   175 	if (!ok)
       
   176         {
       
   177         PRINT(_L("ContructKeyboardMappings returns error"));
       
   178         User::Leave(KErrGeneral);
       
   179         }
       
   180 	}
   185 	}
   181 
   186 
   182 // ----------------------------------------------------------------------------
   187 // ----------------------------------------------------------------------------
   183 // CPcsKeyMap::ContructKeyboardMappings
   188 // CPcsKeyMap::ContructKeyboardMappings
   184 // Fetch keymap for every language/country pair present.
   189 // Fetch keymap for every language/country pair present.
   185 // 10.1 only has virtual 12 key ITU-T keyboard
   190 // Even though most languages map *, + and # to 1-key, they are here mapped to
   186 // ----------------------------------------------------------------------------
   191 // the distinct *-key or #-key of the 12-key ITU-T keypad.
   187 TBool CPcsKeyMap::ContructKeyboardMappings()
   192 // ----------------------------------------------------------------------------
   188 	{
   193 void CPcsKeyMap::ContructKeyboardMappings()
   189     PRINT( _L("Enter CPcsKeyMap::ContructKeyboardMappings") );
   194 	{
       
   195     PRINT(_L("Enter CPcsKeyMap::ContructKeyboardMappings"));
       
   196 
       
   197 	for (TInt i = 0; i < KAmountOfKeys; ++i)
       
   198         {
       
   199         iKeyMapping << QString("");
       
   200         }
       
   201 	
       
   202 	iKeyMapping[EKeyStar].append(KStar);
       
   203 	iKeyMapping[EKeyStar].append(KPlus);
       
   204 	iKeyMapping[EKeyHash].append(KHash);
       
   205 	iHardcodedChars.append(KStar);
       
   206 	iHardcodedChars.append(KPlus);
       
   207 	iHardcodedChars.append(KHash);
   190 
   208 
   191 #if defined(_DEBUG)
   209 #if defined(_DEBUG)
   192     TInt count(0);
   210     TInt count(0);
   193 #endif
   211 #endif
   194 
       
   195     TInt err(KErrNone);
       
   196     QList<HbInputLanguage> languages;
   212     QList<HbInputLanguage> languages;
   197 #if defined(USE_ONLY_DEFAULT_LANG_KEYMAP)
   213 #if defined(USE_ONLY_DEFAULT_LANG_KEYMAP)
   198 	HbInputLanguage inputLanguage(QLocale::system().language()); 
   214 	HbInputLanguage inputLanguage(QLocale::system().language()); 
   199 	languages << inputLanguage;
   215 	languages << inputLanguage;
   200 #else
   216 #else
   201     languages = AvailableLanguages();
   217     languages = AvailableLanguages();
   202 #endif
   218 #endif
   203 	// Calling HbKeymapFactory::keymap() causes "no memory" exception after
   219 	TInt languageCount = languages.size();
   204 	// ~20 different language/variant combinations in emulator.
   220 	for (TInt lang = 0; lang < languageCount; ++lang)
   205 	// In text shell all languages can be handled successfully.
       
   206 	// In device, already the first call to HbKeymapFactory::keymap()
       
   207 	// crashes.
       
   208 	const TInt KMaxLanguages = 30;
       
   209 	TInt handleMaxLanguages = languages.size();
       
   210 	if (handleMaxLanguages > KMaxLanguages)
       
   211 	    {
       
   212         handleMaxLanguages = KMaxLanguages;
       
   213 	    }
       
   214 	PRINT1( _L("handle %d languages"), handleMaxLanguages ); // test
       
   215 
       
   216 	for (TInt lang = 0; lang < handleMaxLanguages; ++lang)
       
   217 		{
   221 		{
   218 //        PRINT1( _L("handle language %d"), languages[lang].language() ); // test
   222         PRINT2(_L("(%d) handle language %d"), lang, languages[lang].language());
   219 		if (IsLanguageSupported(languages[lang].language()))
   223 		if (IsLanguageSupported(languages[lang].language()))
   220 			{
   224 			{
   221 			PRINT2(_L("Constructing keymap for lang=%d,var=%d"),
   225 /*			PRINT2(_L("Constructing keymap for lang=%d,var=%d"),
   222 				   languages[lang].language(),
   226 				   languages[lang].language(),
   223 				   languages[lang].variant());
   227 				   languages[lang].variant()); */
   224 			const HbKeymap* keymap =
   228 			const HbKeymap* keymap =
   225 				HbKeymapFactory::instance()->keymap(languages[lang].language(),
   229 				HbKeymapFactory::instance()->keymap(languages[lang].language(),
   226                                                     languages[lang].variant());
   230                                                     languages[lang].variant());
   227 			if (keymap)
   231 			if (keymap)
   228 			    {
   232 			    {
   229 				for (TInt key = EKey1; key <= EKey0; ++key) 
   233 				for (TInt key = EKey1; key <= ELastKey; ++key) 
   230                     {
   234                     {
   231                     PRINT1( _L("handle key(enum value %d)"), key ); // test
   235 //                    PRINT1(_L("handle key(enum value %d)"), key); // test
   232                     const HbMappedKey* mappedKey = keymap->keyForIndex(HbKeyboardVirtual12Key, key);
   236                     const HbMappedKey* mappedKey = keymap->keyForIndex(HbKeyboardVirtual12Key, key);
   233                     if (!mappedKey)
   237 					// mappedKey can be NULL, as most languages don't have mapping for EKeyStar, EKeyHash
       
   238                     if (mappedKey)
   234                         {
   239                         {
   235                         PRINT1(_L("Mapped key not found, key(%d)"), KeyIdToNumber(key));
   240 						const QString lowerCase = mappedKey->characters(HbModifierNone); // "abc2.."
   236                         return EFalse;
   241 						const QString upperCase = mappedKey->characters(HbModifierShiftPressed); // "ABC2.."
   237                         }
   242 						const QString charsForKey = lowerCase + upperCase; 
   238                     // Get both upper and lowercase letters
   243 	    
   239                     const QString lowerCase = mappedKey->characters(HbModifierNone); // e.g. "abc2.."
   244 						// Filter out duplicate characters
   240                     const QString upperCase = mappedKey->characters(HbModifierShiftPressed); // e.g. "ABC2.."
   245 						for (TInt i = charsForKey.length() - 1; i >= 0 ; --i) 
   241                     const QString charsForKey = lowerCase + upperCase; 
   246 							{
   242     
   247 							QChar ch = charsForKey[i];
   243                     // Filter out duplicate characters
   248 							if (!iKeyMapping[key].contains(ch) &&
   244                     for (TInt i = charsForKey.length() - 1; i >= 0 ; --i) 
   249 								!iHardcodedChars.contains(ch))
   245                         {
   250 								{
   246                         QChar ch = charsForKey[i];
   251 /*								PRINT3(_L("CPcsKeyMap: map key(%d) <-> char='%c'(0x%x)"),
   247                         // Key '1' is at index 0 in iKeyMapping, key '2' at index 1 etc.
   252 									   KeyIdToNumber(key),
   248                         // and key '0' at the last index.
   253 									   ch.toAscii(),
   249                         TInt index = key - EKey1;
   254 									   ch.toAscii()); */
   250                         if (!iKeyMapping[index].contains(ch))
       
   251                             {
       
   252 /*
       
   253                             PRINT3(_L("CPcsKeyMap: map key(%d) <-> char='%c'(0x%x)"),
       
   254                                    KeyIdToNumber(key),
       
   255                                    ch.toAscii(),
       
   256                                    ch.toAscii()); */
       
   257 #if defined(_DEBUG)
   255 #if defined(_DEBUG)
   258                             ++count;
   256 								++count;
   259 #endif
   257 #endif
   260                             iKeyMapping[index] += ch;
   258 								iKeyMapping[key] += ch;
   261                             }
   259 								}
   262                         }
   260 							}
       
   261 						}
   263                     }
   262                     }
   264 			    }
   263 			    }
   265 			else
   264 			else
   266                 {
   265                 {
   267                 PRINT(_L("CPcsKeyMap::ContructKeyboardMapping keymap not found"));
   266                 PRINT(_L("CPcsKeyMap::ContructKeyboardMapping keymap not found"));
   268                 }
   267                 }
   269 			}
   268 			}
   270 		}
   269 		}
   271 
   270 
   272 #if defined(_DEBUG)
   271 #if defined(_DEBUG)
   273     PRINT1( _L("End CPcsKeyMap::ContructKeyboardMappings keymap has %d chars"), count );
   272     PRINT1(_L("End CPcsKeyMap::ContructKeyboardMappings keymap has %d chars"), count);
   274 #endif
   273 #endif
   275 	return ETrue;
       
   276 	}
   274 	}
   277 
   275 
   278 // ----------------------------------------------------------------------------
   276 // ----------------------------------------------------------------------------
   279 // CPcsKeyMap::AvailableLanguages
   277 // CPcsKeyMap::AvailableLanguages
   280 // Put default language at the beginning of the language list, so that
   278 // Put default language at the beginning of the language list, so that
   281 // ContructKeyboardMappingsL handles it first. 
   279 // ContructKeyboardMappingsL handles it first. 
   282 // ----------------------------------------------------------------------------
   280 // ----------------------------------------------------------------------------
   283 QList<HbInputLanguage> CPcsKeyMap::AvailableLanguages() const
   281 QList<HbInputLanguage> CPcsKeyMap::AvailableLanguages() const
   284     {
   282     {
   285     PRINT( _L("Enter CPcsKeyMap::AvailableLanguages") );
   283     PRINT(_L("Enter CPcsKeyMap::AvailableLanguages"));
   286 
   284 
   287 	QList<HbInputLanguage> languages = HbKeymapFactory::availableLanguages();
   285 	QList<HbInputLanguage> languages = HbKeymapFactory::availableLanguages();
   288 
   286 
   289 #if 0 // This code would make sure the default language is at the beginning of
   287 #if 1 // This code would make sure the default language is at the beginning of
   290 	  // list of available languages. But since there is resource leak, the code
   288 	  // list of available languages. But since there is resource leak, the code
   291 	  // is currently commented out until the leak is fixed.
   289 	  // is currently commented out until the leak is fixed.
   292 	QLocale::Language currentLanguage = QLocale::system().language();
   290 	QLocale::Language currentLanguage = QLocale::system().language();
   293     if (!IsLanguageSupported(currentLanguage))
   291     if (!IsLanguageSupported(currentLanguage))
   294         {
   292         {
   295         PRINT( _L("current lang not supported, use english") ); //test
   293         PRINT(_L("current lang not supported, use english")); //test
   296         currentLanguage = QLocale::English;
   294         currentLanguage = QLocale::English;
   297         }
   295         }
   298     HbInputLanguage defaultLanguage(currentLanguage);    
   296     HbInputLanguage defaultLanguage(currentLanguage);    
   299     if (languages.contains(defaultLanguage))
   297     if (languages.contains(defaultLanguage))
   300         {
   298         {
   301         PRINT( _L("remove default lang") ); //test
   299         PRINT(_L("remove default lang")); //test
   302         languages.removeOne(defaultLanguage);
   300         languages.removeOne(defaultLanguage);
   303         }
   301         }
   304     PRINT( _L("insert default lang as first lang") ); //test
   302     PRINT(_L("insert default lang as first lang")); //test
   305     languages.prepend(defaultLanguage); // THIS LEAKS RESOURCES!
   303     languages.prepend(defaultLanguage); // THIS LEAKS RESOURCES!
   306 #endif
   304 #endif
   307 
   305 
   308     PRINT1( _L("End CPcsKeyMap::AvailableLanguages found %d languages"),
   306     PRINT1(_L("End CPcsKeyMap::AvailableLanguages found %d languages"),
   309             languages.count() );
   307            languages.count());
   310     return languages;
   308     return languages;
   311     }
   309     }
   312 
   310 
   313 // ----------------------------------------------------------------------------
   311 // ----------------------------------------------------------------------------
   314 // CPcsKeyMap::IsLanguageSupported
   312 // CPcsKeyMap::IsLanguageSupported
   322 // CPcsKeyMap::KeyForCharacter
   320 // CPcsKeyMap::KeyForCharacter
   323 // Loop all QStrings of iKeyMapping to find one containing the character.
   321 // Loop all QStrings of iKeyMapping to find one containing the character.
   324 // If the character is not mapped, use the character itself.
   322 // If the character is not mapped, use the character itself.
   325 // ----------------------------------------------------------------------------
   323 // ----------------------------------------------------------------------------
   326 TChar CPcsKeyMap::KeyForCharacter(const TChar& aChar) const
   324 TChar CPcsKeyMap::KeyForCharacter(const TChar& aChar) const
   327     {
   325 	{
   328     TUint charValue(aChar);
   326     TUint charValue(aChar);
   329     QChar ch(charValue);
   327     QChar ch(charValue);
   330     
   328     for (TInt index = 0; index < KAmountOfKeys; ++index) 
   331     for (TInt index = 0; index < KAmountOfKeys; ++index)
       
   332         {
   329         {
   333         if (iKeyMapping[index].contains(ch))
   330         if (iKeyMapping[index].contains(ch))
   334             {
   331             {
   335             return ArrayIndexToNumberChar(index);
   332             return ArrayIndexToNumberChar(index);
   336             }
   333             }
   337         }
   334         }
   338 
   335 
   339     PRINT2( _L("CPcsKeyMap::KeyForCharacter no mapping for char '%c' (0x%x)"),
   336     PRINT2(_L("CPcsKeyMap::KeyForCharacter no mapping for char '%c' (0x%x)"),
   340             (TUint)aChar, (TUint)aChar ); // test
   337            (TUint)aChar, (TUint)aChar);
   341     return aChar;
   338 	return KPadChar;
   342     }
   339     }
   343 
   340 
       
   341 #if defined(_DEBUG)
   344 // ----------------------------------------------------------------------------
   342 // ----------------------------------------------------------------------------
   345 // CPcsKeyMap::KeyIdToNumber
   343 // CPcsKeyMap::KeyIdToNumber
   346 // Map Orbit API's key id to the number that the key results when pressed. 
   344 // Map Orbit API's key id to the number that the key results when pressed. 
   347 // ----------------------------------------------------------------------------
   345 // ----------------------------------------------------------------------------
   348 TInt CPcsKeyMap::KeyIdToNumber(TInt aKeyId) const
   346 TInt CPcsKeyMap::KeyIdToNumber(TInt aKeyId) const
   356 		case EKey5:
   354 		case EKey5:
   357 		case EKey6:
   355 		case EKey6:
   358 		case EKey7:
   356 		case EKey7:
   359 		case EKey8:
   357 		case EKey8:
   360 		case EKey9:
   358 		case EKey9:
       
   359 		case EKeyStar:
       
   360 		case EKeyHash:
   361 			return aKeyId + 1;
   361 			return aKeyId + 1;
   362 		case EKey0:
   362 		case EKey0:
   363 			return 0;
   363 			return 0;
   364 		default:
   364 		default:
   365 		    PRINT1( _L("CPcsKeyMap::KeyIdToNumber invalid index %d"), aKeyId );
   365 		    PRINT1(_L("CPcsKeyMap::KeyIdToNumber invalid index %d"), aKeyId);
   366 			User::Panic(_L("CPcsKeyMap::KeyIdToNumber"), KErrArgument);
   366 			User::Panic(_L("CPcsKeyMap::KeyIdToNumber"), KErrArgument);
   367 			return 0;
   367 			return 0;
   368 		}
   368 		}
   369 	}
   369 	}
       
   370 #endif
   370 
   371 
   371 // ----------------------------------------------------------------------------
   372 // ----------------------------------------------------------------------------
   372 // CPcsKeyMap::ArrayIndexToNumberChar
   373 // CPcsKeyMap::ArrayIndexToNumberChar
   373 // Map index of iKeyMapping list, to the number char that the mapping is for.
   374 // Map index of iKeyMapping list, to the number char that the mapping is for.
   374 // ----------------------------------------------------------------------------
   375 // ----------------------------------------------------------------------------
   375 TChar CPcsKeyMap::ArrayIndexToNumberChar(TInt aArrayIndex) const
   376 TChar CPcsKeyMap::ArrayIndexToNumberChar(TInt aArrayIndex) const
   376 	{
   377 	{
   377 	__ASSERT_DEBUG(aArrayIndex < KAmountOfKeys,
   378 	__ASSERT_DEBUG(aArrayIndex < KAmountOfKeys,
   378 				   User::Panic(_L("CPcsKeyMap::ArrayIndexToNumberChar"),
   379 				   User::Panic(_L("CPcsKeyMap::ArrayIndexToNumberChar"),
   379 				   KErrOverflow));
   380 				   KErrOverflow));
   380 	if (aArrayIndex == KAmountOfKeys - 1)
   381 	switch (aArrayIndex)
   381 		{
   382 		{
   382 		return '0';
   383 		case EKey0:
       
   384 			return '0';
       
   385 		case EKeyStar:
       
   386 			return KMappedCharForStar;
       
   387 		case EKeyHash:
       
   388 			return KMappedCharForHash;
       
   389 		default:
       
   390 			return aArrayIndex + '1';
   383 		}
   391 		}
   384 	return aArrayIndex + '1';
       
   385 	}
   392 	}
   386 #else // #if defined(USE_ORBIT_KEYMAP)
   393 #else // #if defined(USE_ORBIT_KEYMAP)
   387 CPcsKeyMap::CPcsKeyMap()
   394 CPcsKeyMap::CPcsKeyMap()
   388 	{
   395 	{
   389 	}
   396 	}
   390 
   397 
   391 void CPcsKeyMap::ConstructL()
   398 void CPcsKeyMap::ConstructL()
   392 	{   
   399 	{
   393 	}
   400 	}
   394 
   401 
   395 TChar CPcsKeyMap::GetNumericValueForChar(TChar input ) const
   402 TChar CPcsKeyMap::GetNumericValueForChar(TChar input) const
   396     {
   403     {
   397 	TChar ret = '0';
   404 	TChar ret = '0';
   398     switch (input)
   405     switch (input)
   399         {
   406         {
   400         case 'A': 
   407         case 'A': 
   401         case 'B': 
   408         case 'B': 
   402         case 'C':
   409         case 'C':
   403                ret = '2';
   410             ret = '2';
   404                break;
   411             break;
       
   412 
   405         case 'D': 
   413         case 'D': 
   406         case 'E':
   414         case 'E':
   407         case 'F':
   415         case 'F':
   408             ret = '3';
   416             ret = '3';
   409             break;
   417             break;
   443         case 'X':
   451         case 'X':
   444         case 'Y': 
   452         case 'Y': 
   445         case 'Z':
   453         case 'Z':
   446             ret = '9';
   454             ret = '9';
   447             break;
   455             break;
   448             
   456 
   449 		case ' ':
   457 		case '*':
   450 			ret = '0';
   458 		case '+':
   451 			break;
   459 		    ret = KMappedCharForStar;
   452 
   460 		    break;
   453 		default: // Other chars, e.g. numbers
   461 		    
   454 			ret = input;
   462 		case '#':
       
   463 		    ret = KMappedCharForHash;
       
   464 		    break;
       
   465 
       
   466 		case '0':
       
   467 		case '1':
       
   468 		case '2':
       
   469 		case '3':
       
   470 		case '4':
       
   471         case '5':
       
   472         case '6':
       
   473         case '7':
       
   474         case '8':
       
   475         case '9':
       
   476         case ' ':
       
   477             ret = input; // Numbers and space
       
   478             break;
       
   479 
       
   480 		default: // Other (unknown) chars
       
   481 		    ret = KPadChar;
   455         }
   482         }
   456     return ret;    
   483     return ret;    
   457     }
   484     }
   458 #endif // #if defined(USE_ORBIT_KEYMAP)
   485 #endif // #if defined(USE_ORBIT_KEYMAP)
   459 
   486