phoneapp/phoneuiutils/tsrc/ut_cphoneresourceresolverbase/Src/tphonetouchbuttonconfigstub.cpp
changeset 77 2be0b271d017
equal deleted inserted replaced
72:c76a0b1755b9 77:2be0b271d017
       
     1 /*
       
     2 * Copyright (c) 2009 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: Touch button configuration stub.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <centralrepository.h>
       
    20 #include <barsread.h>
       
    21 #include <coemain.h>
       
    22 
       
    23 #include "phoneresourceids.h"
       
    24 #include "tphonetouchbuttonconfig.h"
       
    25 #include "PhoneUI.pan"
       
    26 
       
    27 // CenRep keys
       
    28 const TUid KCRUidTelTouchButtonsVariation = {0x2001B2E6};
       
    29 const TUint32 KTelButtonsIncomingCall = 1;
       
    30 
       
    31 // ======== MEMBER FUNCTIONS ========
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // Constructs and returns an application object.
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 TPhoneTouchButtonConfig::TPhoneTouchButtonConfig()
       
    38     {
       
    39     for ( TInt i = 0; i < iConfiguration.Count(); i++ )
       
    40         {
       
    41         iConfiguration[i] = KErrNotFound;
       
    42         }
       
    43     }
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // ReadConfiguration
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 TInt TPhoneTouchButtonConfig::ReadConfiguration()
       
    50     {
       
    51     TFixedArray<TInt,EPhoneButtonConfigCount> keys;
       
    52             
       
    53     TRAPD( err,
       
    54         {
       
    55         // read configuration key values
       
    56         ReadCenRepKeysL( keys );
       
    57         // read button set resource ids
       
    58         ReadConfigResourceL( keys );        
       
    59         } );
       
    60     
       
    61     return err;
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // ReadCenRepKeysL
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 void TPhoneTouchButtonConfig::ReadCenRepKeysL( 
       
    69     TFixedArray<TInt,KTelButtonsConfigKeyCount>& aKeyValues ) const
       
    70     {
       
    71     CRepository* repository = NULL;
       
    72     TRAPD( err, repository = CRepository::NewL( 
       
    73             KCRUidTelTouchButtonsVariation ) );
       
    74 
       
    75     if ( err == KErrNone )
       
    76         {
       
    77         for ( TInt i = 0; i < KTelButtonsConfigKeyCount; i ++ )
       
    78             {
       
    79             TInt key = MapToCenRepKey(i);
       
    80             if ( key != KErrNotFound )
       
    81                 {
       
    82                 err = repository->Get( key, aKeyValues[i] );
       
    83                 aKeyValues[i] -= 1; // map to range 0..n
       
    84                 if ( err )
       
    85                     {
       
    86                     aKeyValues[i] = 0; // default
       
    87                     }
       
    88                 }
       
    89             else
       
    90                 {
       
    91                 aKeyValues[i] = 0; // default
       
    92                 }
       
    93             }
       
    94         }
       
    95 
       
    96     delete repository;
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // ReadConfigResourceL
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 void TPhoneTouchButtonConfig::ReadConfigResourceL( 
       
   104     const TFixedArray<TInt,KTelButtonsConfigKeyCount>& aKeyValues )
       
   105     {
       
   106     if( aKeyValues[0] == 1 )
       
   107         {
       
   108      //   iConfiguration[0] = R_PHONEUI_INCOMING_CALL_SILENCE_BUTTONS;    
       
   109         }
       
   110     else if ( aKeyValues[0] == 0 )
       
   111         {
       
   112         iConfiguration[0] = R_PHONEUI_INCOMING_CALL_BUTTONS;
       
   113         }
       
   114     else
       
   115         {
       
   116         iConfiguration[0] = KErrNotFound;
       
   117         }
       
   118     }
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // MapToCenRepKey
       
   122 // ---------------------------------------------------------------------------
       
   123 //
       
   124 TInt TPhoneTouchButtonConfig::MapToCenRepKey( TInt aButtons ) const
       
   125     {
       
   126     switch ( aButtons )
       
   127         {
       
   128         case EPhoneConfigIncomingCallButtons:
       
   129             return KTelButtonsIncomingCall;
       
   130         default:
       
   131             return KErrNotFound;
       
   132         }
       
   133     }
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // ResourceId
       
   137 // ---------------------------------------------------------------------------
       
   138 //
       
   139 TInt TPhoneTouchButtonConfig::ResourceId(
       
   140     TPhoneUIConfigurableButtons aButtons,
       
   141     TInt aDefaultResourceId )  const
       
   142     {
       
   143     if ( iConfiguration[aButtons] != KErrNotFound )
       
   144         {
       
   145         return iConfiguration[aButtons];    
       
   146         }
       
   147     else
       
   148         {
       
   149         return aDefaultResourceId;
       
   150         }
       
   151     
       
   152     }
       
   153 
       
   154 //  End of File