emailuis/emailui/src/FreestyleEmailUiShortcutBinding.cpp
branchRCL_3
changeset 25 3533d4323edc
equal deleted inserted replaced
24:d189ee25cf9d 25:3533d4323edc
       
     1 /*
       
     2 * Copyright (c) 2008 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: This file implements class CFSEmailUiShortcutBinding.
       
    15  *
       
    16  */
       
    17 
       
    18 
       
    19 #include "emailtrace.h"
       
    20 #include <PtiEngine.h>
       
    21 #include <PtiKeyMappings.h>
       
    22 #include <centralrepository.h>
       
    23 #include <AvkonInternalCRKeys.h>
       
    24 #include <eikmenup.h>
       
    25 
       
    26 #include "FreestyleEmailUiShortcutBinding.h"
       
    27 #include "FSEmail.pan"
       
    28 
       
    29 
       
    30 //////////////////////////////
       
    31 // The shortcut binding tables
       
    32 // ---------------------------
       
    33 // In case the same shortcut is assigned for multiple commands, the shortcut to 
       
    34 // command conversion will always return the first mapping.
       
    35 //
       
    36 // Shortcuts with modifiers must be listed before unmodifed shortcuts, at least when
       
    37 // the same key has different meaning as plain key and with modifier. Otherwise,
       
    38 // the unmodified mapping will be used also for the modified key.
       
    39 
       
    40 // Shortcuts for the mail list view
       
    41 const CFSEmailUiShortcutBinding::TShortcutBinding KMailListShortcuts[] = 
       
    42     {
       
    43         { 0,  'A', 0,     EFsEmailUiCmdActionsReplyAll },
       
    44         { 0,  'R', 0,     EFsEmailUiCmdActionsReply },
       
    45         { 0,  'F', 0,     EFsEmailUiCmdActionsForward }, 
       
    46         { 0,  'M', 0,     EFsEmailUiCmdActionsMove },
       
    47         { 0,    'Y', 0,     EFsEmailUiCmdActionsCopyMessage },
       
    48         { 0,    'D', 0,     EFsEmailUiCmdActionsDelete },
       
    49         { 0, EStdKeyBackspace, 0, EFsEmailUiCmdActionsDelete },
       
    50         { 0,  'T', 0,     EFsEmailUiCmdGoToTop },
       
    51         { 0,  'B', 0,     EFsEmailUiCmdGoToBottom },
       
    52         { 0,    'J', 0,     EFsEmailUiCmdPageUp },
       
    53         { 0,    'K', 0,     EFsEmailUiCmdPageDown },
       
    54         { 0,    'L', 0,     EFsEmailUiCmdActionsFlag },
       
    55         { 0,  'C', 0,     EFsEmailUiCmdCompose },
       
    56         { 0,    'E', 0,     EFsEmailUiCmdCalActionsAccept }, 
       
    57         { 0,    'G', 0,     EFsEmailUiCmdCalActionsTentative },
       
    58         { 0,    'V', 0,     EFsEmailUiCmdCalActionsDecline },
       
    59         { 0,    'O', 0,     EFsEmailUiCmdActionsOpen },
       
    60         { 0,  'Z', 0,     EFsEmailUiCmdSync },
       
    61         { 0,    'S', 0,     EFsEmailUiCmdSearch },
       
    62         { 0,    'Q', 0,     EFsEmailUiCmdGoToSwitchFolder },
       
    63         { 0,    'W', 0,     EFsEmailUiCmdGoToSwitchSorting },
       
    64         { 0,    'H', 0,     EFsEmailUiCmdHelp },
       
    65         
       
    66         { 0,  'U', 0,     EFsEmailUiCmdMarkAsReadUnreadToggle },
       
    67         { 0,  'U', 0,     EFsEmailUiCmdMarkAsRead },   
       
    68         { 0,  'U', 0,     EFsEmailUiCmdMarkAsUnread },
       
    69         
       
    70         { 0,    'I', 0,     EFsEmailUiCmdActionsCollapseExpandAllToggle },
       
    71         { 0,    'I', 0,     EFsEmailUiCmdActionsCollapseAll },
       
    72         { 0,    'I', 0,     EFsEmailUiCmdActionsExpandAll },
       
    73         
       
    74         { 0,  0, 0,       EFsEmailUiCmdMarkingModeFromPopUp },
       
    75         { 0,  0, 0,       EFsEmailUiCmdMarkingMode },
       
    76         { 0,  0, 0,       EFsEmailUiCmdMarkingModeDelete },
       
    77         { 0,  0, 0,       EFsEmailUiCmdMarkingModeUnread },
       
    78         { 0,  0, 0,       EFsEmailUiCmdMarkingModeRead },
       
    79         { 0,  0, 0,       EFsEmailUiCmdMarkingModeMove },
       
    80         { 0,  0, 0,       EFsEmailUiCmdMarkingModeFollowUp },
       
    81         { 0,  0, 0,       EFsEmailUiCmdMarkingModeMarkAll },
       
    82         { 0,  0, 0,       EFsEmailUiCmdMarkMark }, 
       
    83         { 0,  0, 0,       EFsEmailUiCmdMarkUnmark }
       
    84     };
       
    85 
       
    86 // Shortcuts for the mail viewer
       
    87 const CFSEmailUiShortcutBinding::TShortcutBinding KMailViewerShortcuts[] = 
       
    88     {
       
    89         { 0,    'C', EModifierCtrl, EFsEmailUiCmdActionsCopyToClipboard },
       
    90 
       
    91         { 0,  'A', 0,     EFsEmailUiCmdActionsReplyAll },
       
    92         { 0,  'R', 0,     EFsEmailUiCmdActionsReply },
       
    93         { 0,  'F', 0,     EFsEmailUiCmdActionsForward }, 
       
    94         { 0,  'F', 0,     EFsEmailUiCmdActionsForward2 }, 
       
    95         { 0,  'M', 0,     EFsEmailUiCmdActionsMoveMessage },
       
    96         { 0,    'Y', 0,     EFsEmailUiCmdActionsCopyMessage },
       
    97         { 0,    'D', 0,     EFsEmailUiCmdActionsDelete },
       
    98         { 0, EStdKeyBackspace, 0, EFsEmailUiCmdActionsDelete },
       
    99         { 0,  'T', 0,     EFsEmailUiCmdGoToTop },
       
   100         { 0,  'B', 0,     EFsEmailUiCmdGoToBottom },
       
   101         { 0,    'J', 0,     EFsEmailUiCmdPageUp },
       
   102         { 0,    'K', 0,     EFsEmailUiCmdPageDown },
       
   103         { 0,  'N', 0,     EFsEmailUiCmdNextMessage },
       
   104         { 0,  'P', 0,     EFsEmailUiCmdPreviousMessage },
       
   105         { 0,    'L', 0,     EFsEmailUiCmdActionsFlag },
       
   106         { 0,  'C', 0,     EFsEmailUiCmdCompose },
       
   107         { 0,    'H', 0,     EFsEmailUiCmdHelp },
       
   108         
       
   109         { 0,  'U', 0,     EFsEmailUiCmdMarkAsReadUnreadToggle },
       
   110         { 0,  'U', 0,     EFsEmailUiCmdMarkAsRead },   
       
   111         { 0,  'U', 0,     EFsEmailUiCmdMarkAsUnread }
       
   112     };
       
   113 
       
   114 // Shortcuts for the HTML viewer
       
   115 const CFSEmailUiShortcutBinding::TShortcutBinding KHtmlViewerShortcuts[] = 
       
   116     {
       
   117         { 0,  'A', 0,     EFsEmailUiCmdActionsReplyAll },
       
   118         { 0,  'R', 0,     EFsEmailUiCmdActionsReply },
       
   119         { 0,  'F', 0,     EFsEmailUiCmdActionsForward }, 
       
   120         { 0,    'D', 0,     EFsEmailUiCmdActionsDelete },
       
   121         { 0, EStdKeyBackspace, 0, EFsEmailUiCmdActionsDelete },
       
   122         { 0,    'H', 0,     EFsEmailUiCmdHelp },
       
   123         { 0,  '+', 0,     EFsEmailUiCmdZoomIn },
       
   124         { 0,  '-', 0,     EFsEmailUiCmdZoomOut },
       
   125         { 0,  'N', 0,     EFsEmailUiCmdNextMessage },
       
   126         { 0,  'P', 0,     EFsEmailUiCmdPreviousMessage },
       
   127         { 0,  EStdKeyLeftArrow, EModifierShift,     EFsEmailUiCmdPreviousMessage },
       
   128         { 0,  EStdKeyRightArrow, EModifierShift,     EFsEmailUiCmdNextMessage }
       
   129     };
       
   130 
       
   131 // Shortcuts for the search results view    
       
   132 const CFSEmailUiShortcutBinding::TShortcutBinding KSearchResultsShortcuts[] = 
       
   133     {
       
   134         { 0,    'O', 0,     EFsEmailUiCmdOpen },
       
   135         { 0,    'S', 0,     EFsEmailUiCmdSearch },
       
   136         { 0,    'S', 0,     EFsEmailUiCmdNewSearch },
       
   137         { 0,    'H', 0,     EFsEmailUiCmdHelp },
       
   138         { 0,  'T', 0,     EFsEmailUiCmdGoToTop },
       
   139         { 0,  'B', 0,     EFsEmailUiCmdGoToBottom },
       
   140         { 0,    'J', 0,     EFsEmailUiCmdPageUp },
       
   141         { 0,    'K', 0,     EFsEmailUiCmdPageDown },
       
   142         { 0,  'A', 0,     EFsEmailUiCmdActionsReplyAll },
       
   143         { 0,  'R', 0,     EFsEmailUiCmdActionsReply },
       
   144         { 0,  'F', 0,     EFsEmailUiCmdActionsForward }, 
       
   145         { 0,    'D', 0,     EFsEmailUiCmdActionsDelete },
       
   146         { 0, EStdKeyBackspace, 0, EFsEmailUiCmdActionsDelete },
       
   147         { 0,    'E', 0,     EFsEmailUiCmdCalActionsAccept }, 
       
   148         { 0,    'G', 0,     EFsEmailUiCmdCalActionsTentative },
       
   149         { 0,    'V', 0,     EFsEmailUiCmdCalActionsDecline },        
       
   150         { 0,  'U', 0,     EFsEmailUiCmdMarkAsReadUnreadToggle },
       
   151         { 0,  'U', 0,     EFsEmailUiCmdMarkAsRead },   
       
   152         { 0,  'U', 0,     EFsEmailUiCmdMarkAsUnread }
       
   153     };
       
   154 
       
   155 // Shortcuts for generic list views. These are used with Mail details, attachment list, etc.    
       
   156 const CFSEmailUiShortcutBinding::TShortcutBinding KGenericListShortcuts[] = 
       
   157     {
       
   158         { 0,    'C', EModifierCtrl, EFsEmailUiCmdActionsCopyToClipboard },
       
   159 
       
   160         { 0,    'O', 0,     EFsEmailUiCmdOpen },
       
   161         { 0,    'D', 0,     EFsEmailUiCmdActionsDelete },
       
   162         { 0, EStdKeyBackspace, 0, EFsEmailUiCmdActionsDelete },
       
   163         { 0,  'T', 0,     EFsEmailUiCmdGoToTop },
       
   164         { 0,  'B', 0,     EFsEmailUiCmdGoToBottom },
       
   165         { 0,    'J', 0,     EFsEmailUiCmdPageUp },
       
   166         { 0,    'K', 0,     EFsEmailUiCmdPageDown },
       
   167         { 0,    'H', 0,     EFsEmailUiCmdHelp },
       
   168 
       
   169         { 0,    'I', 0,     EFsEmailUiCmdActionsCollapseExpandAllToggle },
       
   170         { 0,    'I', 0,     EFsEmailUiCmdActionsCollapseAll },
       
   171         { 0,    'I', 0,     EFsEmailUiCmdActionsExpandAll }
       
   172     };
       
   173 
       
   174 // Shortcuts for the main grid
       
   175 const CFSEmailUiShortcutBinding::TShortcutBinding KMainGridShortcuts[] = 
       
   176     {
       
   177         { 0,    'O', 0,     EFsEmailUiCmdOpen },
       
   178         { 0,  'Z', 0,     EFsEmailUiCmdSync },
       
   179         { 0,  'Z', 0,     EFsEmailUiCmdSyncAll },
       
   180         { 0,    'H', 0,     EFsEmailUiCmdHelp },
       
   181     };
       
   182 
       
   183 // Shortcuts for send attachments list view
       
   184 const CFSEmailUiShortcutBinding::TShortcutBinding KSendAttachmentListShortcuts[] =
       
   185     {
       
   186         { 0,    'O', 0,     ESendAttachmentMenuOpen },
       
   187         { 0,    'D', 0,     ESendAttachmentMenuRemoveAttachment },
       
   188         { 0, EStdKeyBackspace, 0, ESendAttachmentMenuRemoveAttachment },
       
   189         { 0,  'T', 0,     EFsEmailUiCmdGoToTop },
       
   190         { 0,  'B', 0,     EFsEmailUiCmdGoToBottom },
       
   191         { 0,    'J', 0,     EFsEmailUiCmdPageUp },
       
   192         { 0,    'K', 0,     EFsEmailUiCmdPageDown },
       
   193         { 0,    'H', 0,     ESendAttachmentMenuHelp },
       
   194         { 0,    'I', 0,     EFsEmailUiCmdActionsCollapseExpandAllToggle }
       
   195     };
       
   196     
       
   197 // Shortcuts for settings and global settings views
       
   198 const CFSEmailUiShortcutBinding::TShortcutBinding KSettingsShortcuts[] =
       
   199     {
       
   200         { 0,    'O', 0,     EFsEmailUiCmdOpen },
       
   201         { 0,  'T', 0,     EFsEmailUiCmdGoToTop },
       
   202         { 0,  'B', 0,     EFsEmailUiCmdGoToBottom },
       
   203         { 0,    'J', 0,     EFsEmailUiCmdPageUp },
       
   204         { 0,    'K', 0,     EFsEmailUiCmdPageDown },
       
   205         { 0,    'H', 0,     EFsEmailUiCmdHelp }
       
   206     };
       
   207 
       
   208 ///////////////////////
       
   209 // The class definition 
       
   210 CFSEmailUiShortcutBinding* CFSEmailUiShortcutBinding::NewL()
       
   211     {
       
   212     FUNC_LOG;
       
   213     CFSEmailUiShortcutBinding* self = new (ELeave) CFSEmailUiShortcutBinding();
       
   214     CleanupStack::PushL( self );
       
   215     self->ConstructL();
       
   216     CleanupStack::Pop( self );
       
   217     return self;
       
   218     }
       
   219     
       
   220 // ----------------------------------------------------------------------------    
       
   221 CFSEmailUiShortcutBinding::~CFSEmailUiShortcutBinding()
       
   222     {
       
   223     FUNC_LOG;
       
   224     delete iPtiEngine;
       
   225     iQwertyMappings = NULL; // owned by iPtiEngine
       
   226     iHalfQwertyMappings = NULL; // ownned by iPtiEngine
       
   227     iKbLayoutProperty.Close();
       
   228     }
       
   229         
       
   230         
       
   231 // ----------------------------------------------------------------------------    
       
   232 TInt CFSEmailUiShortcutBinding::CommandForShortcutKey( const TKeyEvent& aKey, 
       
   233                                                        TShortcutContext aContext ) const
       
   234     {
       
   235     FUNC_LOG;
       
   236     TText shortcut = aKey.iScanCode;
       
   237     TBuf<1> keyData; // we are only interested about the first char of the key
       
   238     
       
   239     TKeyBoardType kbType = KeyBoardType();
       
   240 
       
   241     if ( kbType == EQwerty4x12 || kbType == EQwerty4x10 || 
       
   242          kbType == EQwerty3x11 || kbType == ECustomQwerty )
       
   243         {
       
   244         // One of the QWERTY modes
       
   245         // Map the key to the corresponding character on the current keyboard
       
   246         // If Fn is held depressed, use the Fn mappings, otherwise use upper case mappings.
       
   247         TPtiTextCase caseMode = EPtiCaseUpper;
       
   248 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
   249         if ( aKey.iModifiers&EModifierRightFunc )
       
   250             {
       
   251             caseMode = EPtiCaseFnLower;
       
   252             }
       
   253 #endif // RD_INTELLIGENT_TEXT_INPUT
       
   254         if ( iQwertyMappings )
       
   255             {
       
   256             iQwertyMappings->SetKeyboardType( static_cast<TPtiKeyboardType>( kbType ) );
       
   257             iQwertyMappings->GetDataForKey( static_cast<TPtiKey>(aKey.iScanCode), 
       
   258                     keyData, caseMode );
       
   259             }
       
   260         }
       
   261     else if ( kbType == EHalfQwerty )
       
   262         {
       
   263         // Half-QWERTY mode
       
   264         // Map the key to the corresponding character in the Fn mode
       
   265         if ( iHalfQwertyMappings )
       
   266             {
       
   267 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
   268             iQwertyMappings->SetKeyboardType( static_cast<TPtiKeyboardType>( kbType ) );
       
   269             iHalfQwertyMappings->GetDataForKey( static_cast<TPtiKey>(aKey.iScanCode), 
       
   270                     keyData, EPtiCaseFnLower );
       
   271 #endif // RD_INTELLIGENT_TEXT_INPUT
       
   272             }
       
   273         }
       
   274     else
       
   275         {
       
   276         // ITU-T mode, use scancode directly without mapping
       
   277         }
       
   278     
       
   279     // Substitute the scan code with the mapped character if available
       
   280     if ( keyData.Length() )
       
   281         {
       
   282         shortcut = keyData[0];
       
   283         }
       
   284     // Map hash and asterisk keys separately if they have not been mapped in PtiEngine
       
   285     else if ( shortcut == EStdKeyHash )
       
   286         {
       
   287         shortcut = '#';
       
   288         }
       
   289     else if ( shortcut == EStdKeyNkpAsterisk )
       
   290         {
       
   291         shortcut = '*';
       
   292         }
       
   293 
       
   294     return CommandForShortcut( shortcut, aContext, aKey.iModifiers );
       
   295     }
       
   296         
       
   297         
       
   298 // ----------------------------------------------------------------------------    
       
   299 TInt CFSEmailUiShortcutBinding::CommandForShortcut( TText aShortcut, 
       
   300                                                     TShortcutContext aContext,
       
   301                                                     TUint32 aModifiers )
       
   302     {
       
   303     FUNC_LOG;
       
   304     TInt command = KErrNotFound;
       
   305     
       
   306     if ( aShortcut ) // value 0 is used as mark for no shortcut
       
   307         {
       
   308         TInt count = 0;
       
   309         const TShortcutBinding* bindings = NULL;
       
   310 
       
   311         // Select appropriate binding table    
       
   312         GetBindingsForContext( bindings, count, aContext );
       
   313             
       
   314         // Search command from the binding table
       
   315         for ( TInt i=0 ; i<count && command==KErrNotFound  ; ++i )
       
   316             {
       
   317             TBool isItutShortcut = ( aShortcut == bindings[i].iItutShortcut );
       
   318             
       
   319             TBool isQwertyShortcut = ( aShortcut == bindings[i].iQwertyShortcut );
       
   320             // Check the modifier keys for the QWERTY shortcut
       
   321             if ( isQwertyShortcut )
       
   322                 {
       
   323                 TUint32 matchingModifiers = ( aModifiers & bindings[i].iQwertyModifiers );
       
   324                 if ( matchingModifiers != bindings[i].iQwertyModifiers )
       
   325                     {
       
   326                     isQwertyShortcut = EFalse;
       
   327                     }
       
   328                 }
       
   329                                        
       
   330             if ( isItutShortcut || isQwertyShortcut )
       
   331                 {
       
   332                 command = bindings[i].iCommandId;
       
   333                 }
       
   334             }
       
   335         }
       
   336         
       
   337     return command;
       
   338     }
       
   339     
       
   340     
       
   341 // ----------------------------------------------------------------------------    
       
   342 TText CFSEmailUiShortcutBinding::ShortcutForCommand( TInt aCommandId, 
       
   343                                                      TShortcutContext aContext, 
       
   344                                                      TBool aQwertyMode )
       
   345     {
       
   346     FUNC_LOG;
       
   347     TText shortcut = 0;
       
   348     TInt count = 0;
       
   349     const TShortcutBinding* bindings = NULL;
       
   350     
       
   351     // Select appropriate binding table
       
   352     GetBindingsForContext( bindings, count, aContext );
       
   353         
       
   354     // Search shortcut from the binding table
       
   355     for ( TInt i=0 ; i<count && !shortcut  ; ++i )
       
   356         {
       
   357         if ( aCommandId == bindings[i].iCommandId )
       
   358             {
       
   359             if ( aQwertyMode )
       
   360                 {
       
   361                 // Only single-key shortcuts are supported here.
       
   362                 if ( !bindings[i].iQwertyModifiers )
       
   363                     {
       
   364                     shortcut = bindings[i].iQwertyShortcut;
       
   365                     }
       
   366                 }
       
   367             else
       
   368                 {
       
   369                 shortcut = bindings[i].iItutShortcut;
       
   370                 }
       
   371             }
       
   372         }
       
   373         
       
   374     return shortcut;
       
   375     }
       
   376     
       
   377     
       
   378 // ----------------------------------------------------------------------------    
       
   379 void CFSEmailUiShortcutBinding::AppendShortcutHintsL(
       
   380 	CEikMenuPane& aMenuPane,
       
   381 	TShortcutContext aContext ) const
       
   382     {
       
   383     FUNC_LOG;
       
   384     TKeyBoardType kbType = KeyBoardType();
       
   385     TBool isQwerty = 
       
   386         ( kbType != ENoKeyboard && kbType != EItutKeyPad && kbType != EHalfQwerty );
       
   387     
       
   388     // Browse through the commands in the menu pane and append shortcuts
       
   389     // where available.
       
   390     TInt count = aMenuPane.NumberOfItemsInPane();
       
   391     
       
   392     for ( TInt i = 0; i < count; ++i )
       
   393         {
       
   394         CEikMenuPaneItem::SData& itemData = aMenuPane.ItemDataByIndexL( i );
       
   395         TText hint = ShortcutForCommand(
       
   396         	itemData.iCommandId, aContext, isQwerty );        
       
   397         if ( hint )
       
   398             {
       
   399             AppendHintToCaption( itemData.iText, hint );
       
   400             }
       
   401         }
       
   402     }
       
   403     
       
   404     
       
   405 // ----------------------------------------------------------------------------    
       
   406 CFSEmailUiShortcutBinding::CFSEmailUiShortcutBinding()
       
   407     {
       
   408     FUNC_LOG;
       
   409     }
       
   410 	
       
   411 	
       
   412 // ----------------------------------------------------------------------------    
       
   413 void CFSEmailUiShortcutBinding::ConstructL()
       
   414     {
       
   415     FUNC_LOG;
       
   416     iPtiEngine = CPtiEngine::NewL();
       
   417     
       
   418     // Always use English mappings for QWERTY keyboards. This is because it is not 
       
   419     // certain that the mappings of the current language hold latin alphabet at all.
       
   420     // English should be available in all device variants as an optional input language.
       
   421     CPtiCoreLanguage* lang = 
       
   422         static_cast<CPtiCoreLanguage*>( iPtiEngine->GetLanguage( ELangEnglish ) );
       
   423     if (lang)
       
   424         {
       
   425         iQwertyMappings = static_cast<CPtiQwertyKeyMappings*>( lang->GetQwertyKeymappings() );
       
   426 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
   427         iHalfQwertyMappings = static_cast<CPtiHalfQwertyKeyMappings*>( lang->GetHalfQwertyKeymappings() );
       
   428 #endif // RD_INTELLIGENT_TEXT_INPUT        
       
   429         }
       
   430     lang = NULL; // owned by iPtiEngine
       
   431     
       
   432     
       
   433     if ( !iQwertyMappings && !iHalfQwertyMappings )
       
   434         {
       
   435         // In non-QWERTY devices we can free up PtiEngine right away, because
       
   436         // it is not needed anyway.
       
   437         delete iPtiEngine;
       
   438         iPtiEngine = NULL;
       
   439         }
       
   440 
       
   441     iKbLayoutProperty.Attach( KCRUidAvkon, KAknKeyBoardLayout );
       
   442     }
       
   443 	
       
   444 	
       
   445 // ----------------------------------------------------------------------------    
       
   446 CFSEmailUiShortcutBinding::TKeyBoardType CFSEmailUiShortcutBinding::KeyBoardType() const
       
   447     {
       
   448     FUNC_LOG;
       
   449     TInt keyboardType = ENoKeyboard;
       
   450 
       
   451     // RProperty does not define Get() as a constant function. This is
       
   452     // probably just a flaw in the interface. Cast away constness to
       
   453     // circumvent this.
       
   454     RProperty& kbProperty = const_cast<RProperty&>(iKbLayoutProperty);
       
   455     kbProperty.Get( keyboardType );
       
   456     return static_cast<TKeyBoardType>( keyboardType );
       
   457     }
       
   458 
       
   459 	
       
   460 // ----------------------------------------------------------------------------    
       
   461 void CFSEmailUiShortcutBinding::GetBindingsForContext( const TShortcutBinding*& aBindingArray, 
       
   462                                                        TInt& aBindingCount,
       
   463                                                        TShortcutContext aContext )
       
   464     {
       
   465     FUNC_LOG;
       
   466     switch (aContext)
       
   467         {
       
   468         case EContextMailList:
       
   469             {
       
   470             aBindingCount = sizeof(KMailListShortcuts) / sizeof(TShortcutBinding);
       
   471             aBindingArray = KMailListShortcuts;
       
   472             }
       
   473         break;
       
   474 
       
   475         case EContextSearchResults:
       
   476             {
       
   477             aBindingCount = sizeof(KSearchResultsShortcuts) / sizeof(TShortcutBinding);
       
   478             aBindingArray = KSearchResultsShortcuts;
       
   479             }
       
   480         break;
       
   481 
       
   482         case EContextMailViewer:
       
   483             {
       
   484             aBindingCount = sizeof(KMailViewerShortcuts) / sizeof(TShortcutBinding);
       
   485             aBindingArray = KMailViewerShortcuts;
       
   486             }
       
   487         break;
       
   488 
       
   489         case EContextHtmlViewer:
       
   490             {
       
   491             aBindingCount = sizeof(KHtmlViewerShortcuts) / sizeof(TShortcutBinding);
       
   492             aBindingArray = KHtmlViewerShortcuts;
       
   493             }
       
   494         break;
       
   495         
       
   496         case EContextMailDetails:
       
   497         case EContextFolderList:
       
   498         case EContextAttachmentList:
       
   499         case EContextDownloadManager:
       
   500             {
       
   501             aBindingCount = sizeof(KGenericListShortcuts) / sizeof(TShortcutBinding);
       
   502             aBindingArray = KGenericListShortcuts;
       
   503             }
       
   504         break;
       
   505 
       
   506         case EContextMainGrid:
       
   507             {
       
   508             aBindingCount = sizeof(KMainGridShortcuts) / sizeof(TShortcutBinding);
       
   509             aBindingArray = KMainGridShortcuts;
       
   510             }
       
   511         break;
       
   512 
       
   513         case EContextSendAttachmentList:
       
   514             {
       
   515             aBindingCount = sizeof(KSendAttachmentListShortcuts) / sizeof(TShortcutBinding);
       
   516             aBindingArray = KSendAttachmentListShortcuts;
       
   517             }
       
   518         break;
       
   519         
       
   520         case EContextSettings:
       
   521             {
       
   522             aBindingCount = sizeof(KSettingsShortcuts) / sizeof(TShortcutBinding);
       
   523             aBindingArray = KSettingsShortcuts;
       
   524             }
       
   525         break;
       
   526         
       
   527         default:
       
   528             {
       
   529             Panic( EFSEmailUiUnexpectedValue );
       
   530             }
       
   531         break;
       
   532         }
       
   533     }                                         
       
   534 
       
   535 
       
   536 // ----------------------------------------------------------------------------    
       
   537 void CFSEmailUiShortcutBinding::AppendHintToCaption( TDes& aCaption, 
       
   538                                                      TText aHint )
       
   539     {
       
   540     FUNC_LOG;
       
   541     static const TInt KHintLength = 4; // e.g. " [X]"
       
   542     _LIT( KLeadingSeparator, " [" );
       
   543     _LIT( KTailingSeparator, "]" );
       
   544     
       
   545     if ( aCaption.MaxLength() >= aCaption.Length() + KHintLength )
       
   546         {
       
   547         aCaption.Append( KLeadingSeparator );
       
   548         aCaption.Append( aHint );
       
   549         aCaption.Append( KTailingSeparator );
       
   550         }
       
   551     }
       
   552