phoneapp/phoneuiutils/src/cphonecenrepproxy.cpp
changeset 36 2eacb6118286
parent 30 ebdbd102c78a
child 37 ba76fc04e6c2
equal deleted inserted replaced
30:ebdbd102c78a 36:2eacb6118286
     1 /*
       
     2 * Copyright (c) 2005 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:  Central Repository proxy.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    <e32std.h>
       
    21 #include    <e32def.h>
       
    22 #include    <e32base.h>
       
    23 #include    <telinternalcrkeys.h>
       
    24 #include    <pslninternalcrkeys.h>
       
    25 #include    <LogsDomainCRKeys.h>
       
    26 #include    <accessoriescrkeys.h>
       
    27 #include    <settingsinternalcrkeys.h>
       
    28 #include    <UiklafInternalCRKeys.h>
       
    29 #include    <ProfileEngineDomainCRKeys.h>
       
    30 #include    <DRMHelperServerInternalCRKeys.h>
       
    31 #include    <AknFepInternalCRKeys.h>
       
    32 #include    <AvkonInternalCRKeys.h>
       
    33 #include    <btengdomaincrkeys.h> 
       
    34 #include    <utf.h>
       
    35 
       
    36 #include    "phoneui.pan"
       
    37 #include    "cphonecenrepproxy.h"
       
    38 #include    "mphonecenrepobserver.h"
       
    39 #include    "cphonecenrepeventhandler.h"
       
    40 #include    "phoneconstants.h"
       
    41 #include    "phonelogger.h"
       
    42 #include    "telprivatecrkeys.h"
       
    43 #include    "tphonecmdparamappinfo.h"
       
    44 
       
    45 //CONSTANTS
       
    46 const TInt KMaxParamLength = 1024;
       
    47 
       
    48 // ================= MEMBER FUNCTIONS =======================
       
    49 
       
    50 // ---------------------------------------------------------
       
    51 // CPhoneCenRepProxy::Instance
       
    52 // Initializes the singleton object
       
    53 // (other items were commented in a header).
       
    54 // ---------------------------------------------------------
       
    55 //
       
    56 EXPORT_C CPhoneCenRepProxy* CPhoneCenRepProxy::Instance()
       
    57     {
       
    58     CPhoneCenRepProxy* instance = static_cast<CPhoneCenRepProxy*> 
       
    59         ( CCoeEnv::Static ( KUidCenRepProxySingleton ) );
       
    60     
       
    61     if( !instance )
       
    62         {
       
    63         TRAPD( err, instance = CPhoneCenRepProxy::NewL() );
       
    64         if ( err )
       
    65             {
       
    66             Panic( EPhoneUtilsCouldNotCreateSingleton );    
       
    67             }
       
    68         }
       
    69     return instance;
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------
       
    73 // CPhoneCenRepProxy::CancelAllNotifies
       
    74 // Cancel the notification if the singleton still exists.
       
    75 // (other items were commented in a header).
       
    76 // ---------------------------------------------------------
       
    77 //
       
    78 EXPORT_C void CPhoneCenRepProxy::CancelAllNotifies( 
       
    79     MPhoneCenRepObserver* aObserver )
       
    80     {
       
    81     CPhoneCenRepProxy* instance = static_cast<CPhoneCenRepProxy*> 
       
    82         ( CCoeEnv::Static( KUidCenRepProxySingleton ) );
       
    83     
       
    84     // Ignore the call since the singleton has already been destroyed and the
       
    85     // notifications removed
       
    86     if( instance != NULL )
       
    87         {
       
    88         instance->CancelAllObserverNotifies( aObserver );
       
    89         }
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------
       
    93 // CPhoneCenRepProxy::NewL
       
    94 // ---------------------------------------------------------
       
    95 //
       
    96 CPhoneCenRepProxy* CPhoneCenRepProxy::NewL()
       
    97     {
       
    98     CPhoneCenRepProxy* self = 
       
    99         new (ELeave) CPhoneCenRepProxy();
       
   100     
       
   101     CleanupStack::PushL( self );
       
   102     self->ConstructL();
       
   103     CleanupStack::Pop( self );
       
   104 
       
   105     return self;
       
   106     }
       
   107 
       
   108 // ---------------------------------------------------------
       
   109 // CPhoneCenRepProxy::~CPhoneCenRepProxy
       
   110 // ---------------------------------------------------------
       
   111 //
       
   112 EXPORT_C CPhoneCenRepProxy::~CPhoneCenRepProxy()
       
   113     {
       
   114     // The Cancel should be always called before destroy the object
       
   115     CancelAllNotifies();
       
   116     
       
   117     delete iCenRepAccessoryEventHandler;
       
   118     delete iCenRepNetworkEventHandler;
       
   119     delete iCenRepThemesEventHandler;
       
   120     delete iCenRepLanguageEventHandler;
       
   121     delete iCenRepQwertyEventHandler;
       
   122     delete iCenRepKDRMHelperEventHandler;
       
   123     delete iObserverArray;
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------
       
   127 // CPhoneCenRepProxy::CPhoneCenRepProxy
       
   128 // ---------------------------------------------------------
       
   129 //
       
   130 CPhoneCenRepProxy::CPhoneCenRepProxy() :
       
   131     CCoeStatic( KUidCenRepProxySingleton, EThread )
       
   132     {
       
   133     }
       
   134 
       
   135 // ---------------------------------------------------------
       
   136 // CPhoneCenRepProxy::ConstructL
       
   137 // ---------------------------------------------------------
       
   138 //
       
   139 void CPhoneCenRepProxy::ConstructL()
       
   140     {
       
   141     iObserverArray = new ( ELeave ) CArrayFixFlat<TCenRepObserverTag>( 
       
   142         KPhoneCenRepObserversGranularity );
       
   143 
       
   144     iTelephonyVariantReadOnlyValues = KPhoneVariantReadOnlyDefaultValue;
       
   145     iPhoneUIVariantReadOnlyValues = KPhoneVariantReadOnlyDefaultValue;
       
   146     
       
   147     User::LeaveIfError( GetTelephonyVariantData() );
       
   148     User::LeaveIfError( GetPhoneUIVariantData() );
       
   149     }
       
   150 
       
   151 // ---------------------------------------------------------
       
   152 // CPhoneCenRepProxy::HandleNotifyL
       
   153 // ---------------------------------------------------------
       
   154 //
       
   155 void CPhoneCenRepProxy::HandleNotify( 
       
   156     const TUid& aUid, 
       
   157     const TUint aId )
       
   158     {
       
   159     TInt index = FindByUidId( aUid, aId, 0 );
       
   160     while ( index != KErrNotFound )
       
   161         {
       
   162         __ASSERT_DEBUG( index < iObserverArray->Count(), 
       
   163             Panic( EPhoneUtilsIndexOutOfBounds ) );
       
   164         const TCenRepObserverTag& observerTag = iObserverArray->At( index );
       
   165         TRAP_IGNORE( observerTag.iObserver->HandleCenRepChangeL( aUid, aId ) );
       
   166         index = FindByUidId( aUid, aId, index+1 );
       
   167         }
       
   168     }
       
   169 
       
   170 // ---------------------------------------------------------
       
   171 // CPhoneCenRepProxy::SetInt
       
   172 // ---------------------------------------------------------
       
   173 //
       
   174 EXPORT_C TInt CPhoneCenRepProxy::SetInt( 
       
   175     const TUid& aUid, 
       
   176     const TUint aId,
       
   177     const TInt aValue )
       
   178     {
       
   179     CRepository* repository = NULL;
       
   180     TRAPD( err, repository = CRepository::NewL( aUid ) );
       
   181     if ( err == KErrNone )
       
   182         {
       
   183         err = repository->Set( aId, aValue );
       
   184         }
       
   185     delete repository;
       
   186 
       
   187     if ( err != KErrNone )
       
   188         {
       
   189         __PHONELOG1( 
       
   190             EBasic, 
       
   191             EPhonePhoneapp, 
       
   192             "CPhoneCenRepProxy::SetInt() error: %d", 
       
   193             err );
       
   194         __ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) );
       
   195         }
       
   196 
       
   197     return err;
       
   198     }
       
   199 
       
   200 // ---------------------------------------------------------
       
   201 // CPhoneCenRepProxy::SetString
       
   202 // ---------------------------------------------------------
       
   203 //
       
   204 EXPORT_C TInt CPhoneCenRepProxy::SetString( 
       
   205     const TUid& aUid, 
       
   206     const TUint aId,
       
   207     const TDesC& aValue )
       
   208     {
       
   209     CRepository* repository = NULL;
       
   210     TRAPD( err, repository = CRepository::NewL( aUid ) );
       
   211     if ( err == KErrNone )
       
   212         {
       
   213         err = repository->Set( aId, aValue );
       
   214         }
       
   215     delete repository;
       
   216 
       
   217     if ( err != KErrNone )
       
   218         {
       
   219         __PHONELOG1( 
       
   220             EBasic, 
       
   221             EPhonePhoneapp, 
       
   222             "CPhoneCenRepProxy::SetString() error: %d", 
       
   223             err );
       
   224         __ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) );
       
   225         }
       
   226 
       
   227     return err;
       
   228     }
       
   229 
       
   230 // ---------------------------------------------------------
       
   231 // CPhoneCenRepProxy::SetReal
       
   232 // ---------------------------------------------------------
       
   233 //
       
   234 EXPORT_C TInt CPhoneCenRepProxy::SetReal( 
       
   235     const TUid& aUid, 
       
   236     const TUint aId,
       
   237     const TReal aValue )
       
   238     {
       
   239     CRepository* repository = NULL;
       
   240     TRAPD( err, repository = CRepository::NewL( aUid ) );
       
   241     if ( err == KErrNone )
       
   242         {
       
   243         err = repository->Set( aId, aValue );
       
   244         }
       
   245     delete repository;
       
   246 
       
   247     if ( err != KErrNone )
       
   248         {
       
   249         __PHONELOG1( 
       
   250             EBasic, 
       
   251             EPhonePhoneapp, 
       
   252             "CPhoneCenRepProxy::SetReal() error: %d", 
       
   253             err );
       
   254         __ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) );
       
   255         }
       
   256 
       
   257     return err;
       
   258     }
       
   259 
       
   260 // ---------------------------------------------------------
       
   261 // CPhoneCenRepProxy::GetInt
       
   262 // ---------------------------------------------------------
       
   263 //
       
   264 EXPORT_C TInt CPhoneCenRepProxy::GetInt( 
       
   265     const TUid& aUid, 
       
   266     const TUint aId,
       
   267     TInt& aValue ) const
       
   268     {
       
   269     CRepository* repository = NULL;
       
   270     TRAPD( err, repository = CRepository::NewL( aUid ) );
       
   271     if ( err == KErrNone )
       
   272         {
       
   273         err = repository->Get( aId, aValue );
       
   274         delete repository;
       
   275         }
       
   276 
       
   277     if ( err != KErrNone)
       
   278         {
       
   279         __PHONELOG1( 
       
   280             EBasic, 
       
   281             EPhonePhoneapp, 
       
   282             "CPhoneCenRepProxy::GetInt() error: %d", 
       
   283             err );
       
   284         __ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) );
       
   285         }
       
   286 
       
   287     return err;
       
   288     }
       
   289 
       
   290 // ---------------------------------------------------------
       
   291 // CPhoneCenRepProxy::GetString
       
   292 // ---------------------------------------------------------
       
   293 //
       
   294 EXPORT_C TInt CPhoneCenRepProxy::GetString( 
       
   295     const TUid& aUid, 
       
   296     const TUint aId,
       
   297     TDes& aValue ) const
       
   298     {
       
   299     CRepository* repository = NULL;
       
   300     TRAPD( err, repository = CRepository::NewL( aUid ) );
       
   301     if ( err == KErrNone )
       
   302         {
       
   303         err = repository->Get( aId, aValue );
       
   304         delete repository;
       
   305         }
       
   306 
       
   307     if ( err != KErrNone)
       
   308         {
       
   309         __PHONELOG1( 
       
   310             EBasic, 
       
   311             EPhonePhoneapp, 
       
   312             "CPhoneCenRepProxy::GetString() error: %d", 
       
   313             err );
       
   314         __ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) );
       
   315         }
       
   316 
       
   317     return err;
       
   318     }
       
   319 
       
   320 // ---------------------------------------------------------
       
   321 // CPhoneCenRepProxy::GetReal
       
   322 // ---------------------------------------------------------
       
   323 //
       
   324 EXPORT_C TInt CPhoneCenRepProxy::GetReal( 
       
   325     const TUid& aUid, 
       
   326     const TUint aId,
       
   327     TReal& aValue ) const
       
   328     {
       
   329     CRepository* repository = NULL;
       
   330     TRAPD( err, repository = CRepository::NewL( aUid ) );
       
   331     if ( err == KErrNone )
       
   332         {
       
   333         err = repository->Get( aId, aValue );
       
   334         delete repository;
       
   335         }
       
   336 
       
   337     if ( err != KErrNone)
       
   338         {
       
   339         __PHONELOG1( 
       
   340             EBasic, 
       
   341             EPhonePhoneapp, 
       
   342             "CPhoneCenRepProxy::GetReal() error: %d", 
       
   343             err );
       
   344         __ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) );
       
   345         }
       
   346 
       
   347     return err;
       
   348     }
       
   349 
       
   350 // ---------------------------------------------------------
       
   351 // CPhoneCenRepProxy::NotifyChangeL
       
   352 // ---------------------------------------------------------
       
   353 //
       
   354 EXPORT_C void CPhoneCenRepProxy::NotifyChangeL( 
       
   355     const TUid& aUid, 
       
   356     const TUint aId, 
       
   357     MPhoneCenRepObserver* aObserver )
       
   358     {
       
   359     // Make sure this request hasn't been request by this observer yet
       
   360     if ( FindByUidIdObserver( aUid, aId, aObserver ) == KErrNotFound )
       
   361         {
       
   362         TCenRepObserverTag tag;
       
   363         tag.iUid = aUid;
       
   364         tag.iId = aId;
       
   365         tag.iObserver = aObserver;
       
   366     
       
   367         iObserverArray->AppendL( tag );
       
   368         }
       
   369     }
       
   370 
       
   371 // ---------------------------------------------------------
       
   372 // CPhoneCenRepProxy::CancelNotify
       
   373 // ---------------------------------------------------------
       
   374 //
       
   375 EXPORT_C void CPhoneCenRepProxy::CancelNotify( 
       
   376     MPhoneCenRepObserver* aObserver, 
       
   377     const TUint aId )
       
   378     {
       
   379     TInt index = FindByObserverId( aObserver, aId );
       
   380     // This class may be destroyded by CCoeEnv::DestroyEnvironmentStatic() 
       
   381     // before CancelNotifys are called.
       
   382     if( index == KErrNotFound )
       
   383         {
       
   384         return;            
       
   385         }
       
   386     
       
   387     __ASSERT_DEBUG( index < iObserverArray->Count(),
       
   388         Panic( EPhoneUtilsIndexOutOfBounds ) );
       
   389         
       
   390     TCenRepObserverTag observerTag = iObserverArray->At( index );
       
   391     iObserverArray->Delete( index );
       
   392     }
       
   393 
       
   394 // ---------------------------------------------------------
       
   395 // CPhoneCenRepProxy::CancelAllObserverNotifies
       
   396 // ---------------------------------------------------------
       
   397 //
       
   398 void CPhoneCenRepProxy::CancelAllObserverNotifies( 
       
   399     MPhoneCenRepObserver* aObserver )
       
   400     {
       
   401     const TInt count = iObserverArray->Count();
       
   402     for ( TInt i = count-1; i >=0; i-- )
       
   403         {
       
   404         const TCenRepObserverTag& observerTag = iObserverArray->At( i );
       
   405         if ( observerTag.iObserver == aObserver )
       
   406             {
       
   407             iObserverArray->Delete( i );
       
   408             }
       
   409         }
       
   410     }
       
   411 
       
   412 // ---------------------------------------------------------
       
   413 // CPhoneCenRepProxy::CancelAllNotifies
       
   414 // ---------------------------------------------------------
       
   415 //
       
   416 void CPhoneCenRepProxy::CancelAllNotifies()
       
   417     {
       
   418     const TInt count = iObserverArray->Count();
       
   419     for ( TInt i = count-1; i >=0; i-- )
       
   420         {
       
   421         const TCenRepObserverTag& observerTag = iObserverArray->At( i );
       
   422         iObserverArray->Delete( i );
       
   423         }
       
   424     }
       
   425 
       
   426 // ---------------------------------------------------------
       
   427 // CPhoneCenRepProxy::FindByUidId
       
   428 // ---------------------------------------------------------
       
   429 //
       
   430 TInt CPhoneCenRepProxy::FindByUidId( 
       
   431     const TUid& aUid,
       
   432     const TUint aId, 
       
   433     TInt aFromIndex )
       
   434     {
       
   435     const TInt count = iObserverArray->Count();
       
   436     TInt result = KErrNotFound;
       
   437     for ( TInt i = aFromIndex; i < count; i++ )
       
   438         {
       
   439         const TCenRepObserverTag& observerTag = iObserverArray->At( i );
       
   440         if ( observerTag.iUid == aUid  && observerTag.iId == aId ) 
       
   441             {
       
   442             result = i;
       
   443             break;
       
   444             }
       
   445         }
       
   446     return result;
       
   447     }
       
   448 
       
   449 // ---------------------------------------------------------
       
   450 // CPhoneCenRepProxy::FindByObserverId
       
   451 // ---------------------------------------------------------
       
   452 //
       
   453 TInt CPhoneCenRepProxy::FindByObserverId( 
       
   454     const MPhoneCenRepObserver* aObserver,
       
   455     const TUint aId )
       
   456     {
       
   457     const TInt count = iObserverArray->Count();
       
   458     TInt result = KErrNotFound;
       
   459     for ( TInt i = 0; i < count; i++ )
       
   460         {
       
   461         const TCenRepObserverTag& observerTag = iObserverArray->At( i );
       
   462         if ( observerTag.iObserver == aObserver && observerTag.iId == aId ) 
       
   463             {
       
   464             result = i;
       
   465             break;
       
   466             }
       
   467         }
       
   468     return result;
       
   469     }
       
   470 
       
   471 // ---------------------------------------------------------
       
   472 // CPhoneCenRepProxy::FindByUidIdObserver
       
   473 // ---------------------------------------------------------
       
   474 //
       
   475 TInt CPhoneCenRepProxy::FindByUidIdObserver( 
       
   476     const TUid& aUid, 
       
   477     const TUint aId, 
       
   478     MPhoneCenRepObserver* aObserver )
       
   479     {
       
   480     TInt pos = FindByUidId( aUid, aId, 0 );
       
   481     TInt result = KErrNotFound;
       
   482     while ( pos != KErrNotFound )
       
   483         {
       
   484         __ASSERT_DEBUG( pos < iObserverArray->Count(), 
       
   485             Panic( EPhoneUtilsIndexOutOfBounds ) );
       
   486         const TCenRepObserverTag& observerTag = iObserverArray->At( pos );
       
   487         if ( observerTag.iObserver == aObserver )
       
   488             {
       
   489             result = pos;
       
   490             break;
       
   491             }
       
   492 
       
   493         pos++;
       
   494         pos = FindByUidId( aUid, aId, pos );
       
   495         }
       
   496 
       
   497     return result;
       
   498     }   
       
   499 
       
   500 // -----------------------------------------------------------------------------
       
   501 // CPhoneCenRepProxy::IsTelephonyFeatureSupported
       
   502 // -----------------------------------------------------------------------------
       
   503 //
       
   504 EXPORT_C TBool CPhoneCenRepProxy::IsTelephonyFeatureSupported( 
       
   505     const TInt aFeatureId )
       
   506     {
       
   507     return ( aFeatureId & iTelephonyVariantReadOnlyValues );
       
   508     }
       
   509 
       
   510 // -----------------------------------------------------------------------------
       
   511 // CPhoneCenRepProxy::GetTelephonyVariantData
       
   512 // -----------------------------------------------------------------------------
       
   513 //
       
   514 TInt CPhoneCenRepProxy::GetTelephonyVariantData()
       
   515     {
       
   516     TInt err = KErrNone;
       
   517 
       
   518     // Variation data should be unchangable during run-time, 
       
   519     // therefore, if once succesfully read, later reads are
       
   520     // not allowed.
       
   521     if( iTelephonyVariantReadOnlyValues == KPhoneVariantReadOnlyDefaultValue )
       
   522         {
       
   523         err = GetInt( 
       
   524             KCRUidTelVariation, 
       
   525             KTelVariationFlags, 
       
   526             iTelephonyVariantReadOnlyValues );
       
   527         }
       
   528 
       
   529     return err;
       
   530     }
       
   531 
       
   532 // -----------------------------------------------------------------------------
       
   533 // CPhoneCenRepProxy::IsPhoneUIFeatureSupported
       
   534 // -----------------------------------------------------------------------------
       
   535 //
       
   536 EXPORT_C TBool CPhoneCenRepProxy::IsPhoneUIFeatureSupported( 
       
   537     const TInt aFeatureId )
       
   538     {
       
   539     return ( aFeatureId & iPhoneUIVariantReadOnlyValues );
       
   540     }
       
   541 
       
   542 // -----------------------------------------------------------------------------
       
   543 // CPhoneCenRepProxy::GetPhoneUIVariantData
       
   544 // -----------------------------------------------------------------------------
       
   545 //
       
   546 TInt CPhoneCenRepProxy::GetPhoneUIVariantData()
       
   547     {
       
   548     TInt err = KErrNone;
       
   549 /*
       
   550     // Variation data should be unchangable during run-time, 
       
   551     // therefore, if once succesfully read, later reads are
       
   552     // not allowed.
       
   553     if ( iPhoneUIVariantReadOnlyValues == KPhoneVariantReadOnlyDefaultValue )
       
   554         {
       
   555         err = GetInt( 
       
   556             KCRUidPhoneAppS60Variation, 
       
   557             KPhoneAppS60VariationFlags, 
       
   558             iPhoneAppS60VariantReadOnlyValues );
       
   559         }
       
   560 */
       
   561     return err;
       
   562     }
       
   563 
       
   564 // ---------------------------------------------------------
       
   565 // CPhoneCenRepProxy::Find
       
   566 // ---------------------------------------------------------
       
   567 //
       
   568 EXPORT_C TInt CPhoneCenRepProxy::Find(
       
   569     const TUid& aUid,
       
   570     const TUint32 aPartial, 
       
   571     const TUint32 aMask,
       
   572     RArray<TUint32>& aValues ) const
       
   573     {
       
   574     CRepository* repository = NULL;
       
   575     TRAPD( err, repository = CRepository::NewL( aUid ) );
       
   576     if ( err == KErrNone )
       
   577         {
       
   578         TRAP( err, repository->FindL( aPartial, aMask, aValues ) );
       
   579         delete repository;
       
   580         }
       
   581 
       
   582     if ( err != KErrNone)
       
   583         {
       
   584         __PHONELOG1( 
       
   585             EBasic, 
       
   586             EPhonePhoneapp, 
       
   587             "CPhoneCenRepProxy::GetInt() error: %d", 
       
   588             err );
       
   589         __ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) );
       
   590         }
       
   591 
       
   592     return err;
       
   593     }
       
   594 
       
   595 // -----------------------------------------------------------------------------
       
   596 // CPhoneCenRepProxy::FetchValuesFromCenRepL
       
   597 // -----------------------------------------------------------------------------
       
   598 //
       
   599 EXPORT_C void CPhoneCenRepProxy::FetchValuesFromCenRepL( 
       
   600                                                 TPhoneCmdParamAppInfo& aAppInfo,
       
   601                                                 TKeyCode aCode, 
       
   602                                                 HBufC8* aAppParam,
       
   603                                                 TBool& aValuesFetched )
       
   604     {
       
   605     const TUint32     KPartialKey = 0xFF0000;
       
   606     const TUint32   KLaunchGroupIdMask = 0x00FF00;
       
   607     const TUint32   KLaunchPlaceIdMask = 0x0000FF;
       
   608     const TUint32     KIdmask = 0xFF0000;
       
   609     
       
   610     const TUint32   KLaunchGroupIdShift = 8;
       
   611     const TInt      KUidId = 2;
       
   612     const TInt      KParamId = 3;
       
   613 
       
   614     RArray<TUint32> foundKeys;
       
   615     CleanupClosePushL( foundKeys );    
       
   616     
       
   617     CRepository* repository = NULL;
       
   618     repository = CRepository::NewL( KCRUidTelPrivateVariation );
       
   619     
       
   620     TInt err( KErrNone );
       
   621     
       
   622     if ( repository )
       
   623         {
       
   624         CleanupStack::PushL( repository );
       
   625         err = repository->FindL( KPartialKey, KIdmask, foundKeys );
       
   626         }
       
   627 
       
   628     if ( KErrNone != err )
       
   629         {
       
   630         __PHONELOG1( 
       
   631             EBasic, 
       
   632             EPhonePhoneapp, 
       
   633             "CPhoneCenRepProxy::FetchValuesFromCenRepL() error: %d", 
       
   634             err );
       
   635         User::Leave( err );
       
   636         }        
       
   637     
       
   638     TInt uid(0);
       
   639     TInt code(0);
       
   640     HBufC* param = HBufC::NewL( KMaxParamLength );
       
   641     TPtr paramPtr = param->Des();
       
   642     CleanupStack::PushL( param );
       
   643     
       
   644     for ( TInt i = 0; i < foundKeys.Count(); i++ )
       
   645         {
       
   646         User::LeaveIfError( repository->Get(
       
   647                 foundKeys[i], code ) );       
       
   648         
       
   649         //peekIndex is used to check if foundKeys-array has a next 
       
   650         //element. For this reason (i+1) is used.
       
   651         TInt peekIndex(i+1);
       
   652         TInt peekGroupId(0);
       
   653         TInt launchGroupID 
       
   654             = ( foundKeys[i] & KLaunchGroupIdMask ) >> KLaunchGroupIdShift;        
       
   655         
       
   656         if( peekIndex < foundKeys.Count() && code == aCode )
       
   657             {
       
   658             peekGroupId =
       
   659             ( foundKeys[peekIndex] & KLaunchGroupIdMask ) 
       
   660                     >> KLaunchGroupIdShift;
       
   661         
       
   662             // Check that group Id is the same as for the key fetched earlier
       
   663             // (KKeyId) and the key id for this key is (KUidId).
       
   664             if( launchGroupID == peekGroupId &&
       
   665                 KUidId == ( foundKeys[peekIndex] & KLaunchPlaceIdMask ) )  
       
   666                 {
       
   667                 User::LeaveIfError( repository->Get(
       
   668                         foundKeys[++i], uid ) );
       
   669                 }
       
   670             
       
   671             peekIndex = i+1; // peekIndex update. The actual value is dependant on
       
   672                               // whether variable i was incremented or not in previous if.
       
   673 
       
   674             if( peekIndex < foundKeys.Count() )
       
   675                 {
       
   676                 peekGroupId = 
       
   677                        ( foundKeys[peekIndex] & KLaunchGroupIdMask ) 
       
   678                                >> KLaunchGroupIdShift;
       
   679                 // Check that group Id is still the same as for the keys fetched 
       
   680                 // earlier (KKeyId and KUidId)
       
   681                 // and the key id for this key is (KParamId).
       
   682                 if( launchGroupID == peekGroupId &&
       
   683                         KParamId == ( foundKeys[peekIndex] & KLaunchPlaceIdMask ) )
       
   684                     {                
       
   685                     User::LeaveIfError( repository->Get( 
       
   686                             foundKeys[++i], paramPtr ) );
       
   687                     break;
       
   688                     }
       
   689                 }
       
   690             }
       
   691         else
       
   692             {
       
   693             i++; // skip uid index (wrong code)
       
   694             i++; // skip parameter index (wrong code)
       
   695             }
       
   696         }
       
   697     
       
   698     if ( uid != 0 )
       
   699         {
       
   700         aAppInfo.SetAppUid( TUid::Uid( uid ) );
       
   701         // TDesc16 to TDesc8 conversion. Central repository supports only
       
   702         // 16 bit buffers, setParam function in TPhoneCmdParamAppInfo wants
       
   703         // 8 bit.
       
   704         TPtr8 eightBitParamPtr = aAppParam->Des();
       
   705         CnvUtfConverter::ConvertFromUnicodeToUtf8( eightBitParamPtr, 
       
   706                 paramPtr );         
       
   707         
       
   708         aAppInfo.SetParam( eightBitParamPtr );
       
   709         aValuesFetched = ETrue;
       
   710         }
       
   711     
       
   712     CleanupStack::PopAndDestroy( param ); 
       
   713     CleanupStack::PopAndDestroy( repository );
       
   714     CleanupStack::PopAndDestroy( &foundKeys );
       
   715     }
       
   716 
       
   717 //  End of File