phoneapp/phoneuiutils/src/cphonecenrepproxy.cpp
changeset 0 5f000ab63145
child 21 92ab7f8d0eab
child 61 41a7f70b3818
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     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     iCenRepAccessoryEventHandler = CPhoneCenRepEventHandler::NewL( 
       
   151         KCRUidAccessorySettings );
       
   152     iCenRepNetworkEventHandler = CPhoneCenRepEventHandler::NewL( 
       
   153         KCRUidNetworkSettings );
       
   154     iCenRepThemesEventHandler = CPhoneCenRepEventHandler::NewL( 
       
   155         KCRUidThemes );
       
   156     iCenRepLanguageEventHandler = CPhoneCenRepEventHandler::NewL( 
       
   157         KCRUidAknFep );
       
   158     iCenRepQwertyEventHandler = CPhoneCenRepEventHandler::NewL( 
       
   159         KCRUidAvkon );
       
   160     iCenRepKDRMHelperEventHandler = CPhoneCenRepEventHandler::NewL( 
       
   161         KCRUidDRMHelperServer );
       
   162     }
       
   163 
       
   164 // ---------------------------------------------------------
       
   165 // CPhoneCenRepProxy::HandleNotifyL
       
   166 // ---------------------------------------------------------
       
   167 //
       
   168 void CPhoneCenRepProxy::HandleNotify( 
       
   169     const TUid& aUid, 
       
   170     const TUint aId )
       
   171     {
       
   172     TInt index = FindByUidId( aUid, aId, 0 );
       
   173     while ( index != KErrNotFound )
       
   174         {
       
   175         __ASSERT_DEBUG( index < iObserverArray->Count(), 
       
   176             Panic( EPhoneUtilsIndexOutOfBounds ) );
       
   177         const TCenRepObserverTag& observerTag = iObserverArray->At( index );
       
   178         TRAP_IGNORE( observerTag.iObserver->HandleCenRepChangeL( aUid, aId ) );
       
   179         index = FindByUidId( aUid, aId, index+1 );
       
   180         }
       
   181     }
       
   182 
       
   183 // ---------------------------------------------------------
       
   184 // CPhoneCenRepProxy::SetInt
       
   185 // ---------------------------------------------------------
       
   186 //
       
   187 EXPORT_C TInt CPhoneCenRepProxy::SetInt( 
       
   188     const TUid& aUid, 
       
   189     const TUint aId,
       
   190     const TInt aValue )
       
   191     {
       
   192     CRepository* repository = NULL;
       
   193     TRAPD( err, repository = CRepository::NewL( aUid ) );
       
   194     if ( err == KErrNone )
       
   195         {
       
   196         err = repository->Set( aId, aValue );
       
   197         }
       
   198     delete repository;
       
   199 
       
   200     if ( err != KErrNone )
       
   201         {
       
   202         __PHONELOG1( 
       
   203             EBasic, 
       
   204             EPhonePhoneapp, 
       
   205             "CPhoneCenRepProxy::SetInt() error: %d", 
       
   206             err );
       
   207         __ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) );
       
   208         }
       
   209 
       
   210     return err;
       
   211     }
       
   212 
       
   213 // ---------------------------------------------------------
       
   214 // CPhoneCenRepProxy::SetString
       
   215 // ---------------------------------------------------------
       
   216 //
       
   217 EXPORT_C TInt CPhoneCenRepProxy::SetString( 
       
   218     const TUid& aUid, 
       
   219     const TUint aId,
       
   220     const TDesC& aValue )
       
   221     {
       
   222     CRepository* repository = NULL;
       
   223     TRAPD( err, repository = CRepository::NewL( aUid ) );
       
   224     if ( err == KErrNone )
       
   225         {
       
   226         err = repository->Set( aId, aValue );
       
   227         }
       
   228     delete repository;
       
   229 
       
   230     if ( err != KErrNone )
       
   231         {
       
   232         __PHONELOG1( 
       
   233             EBasic, 
       
   234             EPhonePhoneapp, 
       
   235             "CPhoneCenRepProxy::SetString() error: %d", 
       
   236             err );
       
   237         __ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) );
       
   238         }
       
   239 
       
   240     return err;
       
   241     }
       
   242 
       
   243 // ---------------------------------------------------------
       
   244 // CPhoneCenRepProxy::SetReal
       
   245 // ---------------------------------------------------------
       
   246 //
       
   247 EXPORT_C TInt CPhoneCenRepProxy::SetReal( 
       
   248     const TUid& aUid, 
       
   249     const TUint aId,
       
   250     const TReal aValue )
       
   251     {
       
   252     CRepository* repository = NULL;
       
   253     TRAPD( err, repository = CRepository::NewL( aUid ) );
       
   254     if ( err == KErrNone )
       
   255         {
       
   256         err = repository->Set( aId, aValue );
       
   257         }
       
   258     delete repository;
       
   259 
       
   260     if ( err != KErrNone )
       
   261         {
       
   262         __PHONELOG1( 
       
   263             EBasic, 
       
   264             EPhonePhoneapp, 
       
   265             "CPhoneCenRepProxy::SetReal() error: %d", 
       
   266             err );
       
   267         __ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) );
       
   268         }
       
   269 
       
   270     return err;
       
   271     }
       
   272 
       
   273 // ---------------------------------------------------------
       
   274 // CPhoneCenRepProxy::GetInt
       
   275 // ---------------------------------------------------------
       
   276 //
       
   277 EXPORT_C TInt CPhoneCenRepProxy::GetInt( 
       
   278     const TUid& aUid, 
       
   279     const TUint aId,
       
   280     TInt& aValue ) const
       
   281     {
       
   282     CRepository* repository = NULL;
       
   283     TRAPD( err, repository = CRepository::NewL( aUid ) );
       
   284     if ( err == KErrNone )
       
   285         {
       
   286         err = repository->Get( aId, aValue );
       
   287         delete repository;
       
   288         }
       
   289 
       
   290     if ( err != KErrNone)
       
   291         {
       
   292         __PHONELOG1( 
       
   293             EBasic, 
       
   294             EPhonePhoneapp, 
       
   295             "CPhoneCenRepProxy::GetInt() error: %d", 
       
   296             err );
       
   297         __ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) );
       
   298         }
       
   299 
       
   300     return err;
       
   301     }
       
   302 
       
   303 // ---------------------------------------------------------
       
   304 // CPhoneCenRepProxy::GetString
       
   305 // ---------------------------------------------------------
       
   306 //
       
   307 EXPORT_C TInt CPhoneCenRepProxy::GetString( 
       
   308     const TUid& aUid, 
       
   309     const TUint aId,
       
   310     TDes& aValue ) const
       
   311     {
       
   312     CRepository* repository = NULL;
       
   313     TRAPD( err, repository = CRepository::NewL( aUid ) );
       
   314     if ( err == KErrNone )
       
   315         {
       
   316         err = repository->Get( aId, aValue );
       
   317         delete repository;
       
   318         }
       
   319 
       
   320     if ( err != KErrNone)
       
   321         {
       
   322         __PHONELOG1( 
       
   323             EBasic, 
       
   324             EPhonePhoneapp, 
       
   325             "CPhoneCenRepProxy::GetString() error: %d", 
       
   326             err );
       
   327         __ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) );
       
   328         }
       
   329 
       
   330     return err;
       
   331     }
       
   332 
       
   333 // ---------------------------------------------------------
       
   334 // CPhoneCenRepProxy::GetReal
       
   335 // ---------------------------------------------------------
       
   336 //
       
   337 EXPORT_C TInt CPhoneCenRepProxy::GetReal( 
       
   338     const TUid& aUid, 
       
   339     const TUint aId,
       
   340     TReal& aValue ) const
       
   341     {
       
   342     CRepository* repository = NULL;
       
   343     TRAPD( err, repository = CRepository::NewL( aUid ) );
       
   344     if ( err == KErrNone )
       
   345         {
       
   346         err = repository->Get( aId, aValue );
       
   347         delete repository;
       
   348         }
       
   349 
       
   350     if ( err != KErrNone)
       
   351         {
       
   352         __PHONELOG1( 
       
   353             EBasic, 
       
   354             EPhonePhoneapp, 
       
   355             "CPhoneCenRepProxy::GetReal() error: %d", 
       
   356             err );
       
   357         __ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) );
       
   358         }
       
   359 
       
   360     return err;
       
   361     }
       
   362 
       
   363 // ---------------------------------------------------------
       
   364 // CPhoneCenRepProxy::NotifyChangeL
       
   365 // ---------------------------------------------------------
       
   366 //
       
   367 EXPORT_C void CPhoneCenRepProxy::NotifyChangeL( 
       
   368     const TUid& aUid, 
       
   369     const TUint aId, 
       
   370     MPhoneCenRepObserver* aObserver )
       
   371     {
       
   372     // Make sure this request hasn't been request by this observer yet
       
   373     if ( FindByUidIdObserver( aUid, aId, aObserver ) == KErrNotFound )
       
   374         {
       
   375         TCenRepObserverTag tag;
       
   376         tag.iUid = aUid;
       
   377         tag.iId = aId;
       
   378         tag.iObserver = aObserver;
       
   379     
       
   380         iObserverArray->AppendL( tag );
       
   381         }
       
   382     }
       
   383 
       
   384 // ---------------------------------------------------------
       
   385 // CPhoneCenRepProxy::CancelNotify
       
   386 // ---------------------------------------------------------
       
   387 //
       
   388 EXPORT_C void CPhoneCenRepProxy::CancelNotify( 
       
   389     MPhoneCenRepObserver* aObserver, 
       
   390     const TUint aId )
       
   391     {
       
   392     TInt index = FindByObserverId( aObserver, aId );
       
   393     // This class may be destroyded by CCoeEnv::DestroyEnvironmentStatic() 
       
   394     // before CancelNotifys are called.
       
   395     if( index == KErrNotFound )
       
   396         {
       
   397         return;            
       
   398         }
       
   399     
       
   400     __ASSERT_DEBUG( index < iObserverArray->Count(),
       
   401         Panic( EPhoneUtilsIndexOutOfBounds ) );
       
   402         
       
   403     TCenRepObserverTag observerTag = iObserverArray->At( index );
       
   404     iObserverArray->Delete( index );
       
   405     }
       
   406 
       
   407 // ---------------------------------------------------------
       
   408 // CPhoneCenRepProxy::CancelAllObserverNotifies
       
   409 // ---------------------------------------------------------
       
   410 //
       
   411 void CPhoneCenRepProxy::CancelAllObserverNotifies( 
       
   412     MPhoneCenRepObserver* aObserver )
       
   413     {
       
   414     const TInt count = iObserverArray->Count();
       
   415     for ( TInt i = count-1; i >=0; i-- )
       
   416         {
       
   417         const TCenRepObserverTag& observerTag = iObserverArray->At( i );
       
   418         if ( observerTag.iObserver == aObserver )
       
   419             {
       
   420             iObserverArray->Delete( i );
       
   421             }
       
   422         }
       
   423     }
       
   424 
       
   425 // ---------------------------------------------------------
       
   426 // CPhoneCenRepProxy::CancelAllNotifies
       
   427 // ---------------------------------------------------------
       
   428 //
       
   429 void CPhoneCenRepProxy::CancelAllNotifies()
       
   430     {
       
   431     const TInt count = iObserverArray->Count();
       
   432     for ( TInt i = count-1; i >=0; i-- )
       
   433         {
       
   434         const TCenRepObserverTag& observerTag = iObserverArray->At( i );
       
   435         iObserverArray->Delete( i );
       
   436         }
       
   437     }
       
   438 
       
   439 // ---------------------------------------------------------
       
   440 // CPhoneCenRepProxy::FindByUidId
       
   441 // ---------------------------------------------------------
       
   442 //
       
   443 TInt CPhoneCenRepProxy::FindByUidId( 
       
   444     const TUid& aUid,
       
   445     const TUint aId, 
       
   446     TInt aFromIndex )
       
   447     {
       
   448     const TInt count = iObserverArray->Count();
       
   449     TInt result = KErrNotFound;
       
   450     for ( TInt i = aFromIndex; i < count; i++ )
       
   451         {
       
   452         const TCenRepObserverTag& observerTag = iObserverArray->At( i );
       
   453         if ( observerTag.iUid == aUid  && observerTag.iId == aId ) 
       
   454             {
       
   455             result = i;
       
   456             break;
       
   457             }
       
   458         }
       
   459     return result;
       
   460     }
       
   461 
       
   462 // ---------------------------------------------------------
       
   463 // CPhoneCenRepProxy::FindByObserverId
       
   464 // ---------------------------------------------------------
       
   465 //
       
   466 TInt CPhoneCenRepProxy::FindByObserverId( 
       
   467     const MPhoneCenRepObserver* aObserver,
       
   468     const TUint aId )
       
   469     {
       
   470     const TInt count = iObserverArray->Count();
       
   471     TInt result = KErrNotFound;
       
   472     for ( TInt i = 0; i < count; i++ )
       
   473         {
       
   474         const TCenRepObserverTag& observerTag = iObserverArray->At( i );
       
   475         if ( observerTag.iObserver == aObserver && observerTag.iId == aId ) 
       
   476             {
       
   477             result = i;
       
   478             break;
       
   479             }
       
   480         }
       
   481     return result;
       
   482     }
       
   483 
       
   484 // ---------------------------------------------------------
       
   485 // CPhoneCenRepProxy::FindByUidIdObserver
       
   486 // ---------------------------------------------------------
       
   487 //
       
   488 TInt CPhoneCenRepProxy::FindByUidIdObserver( 
       
   489     const TUid& aUid, 
       
   490     const TUint aId, 
       
   491     MPhoneCenRepObserver* aObserver )
       
   492     {
       
   493     TInt pos = FindByUidId( aUid, aId, 0 );
       
   494     TInt result = KErrNotFound;
       
   495     while ( pos != KErrNotFound )
       
   496         {
       
   497         __ASSERT_DEBUG( pos < iObserverArray->Count(), 
       
   498             Panic( EPhoneUtilsIndexOutOfBounds ) );
       
   499         const TCenRepObserverTag& observerTag = iObserverArray->At( pos );
       
   500         if ( observerTag.iObserver == aObserver )
       
   501             {
       
   502             result = pos;
       
   503             break;
       
   504             }
       
   505 
       
   506         pos++;
       
   507         pos = FindByUidId( aUid, aId, pos );
       
   508         }
       
   509 
       
   510     return result;
       
   511     }   
       
   512 
       
   513 // -----------------------------------------------------------------------------
       
   514 // CPhoneCenRepProxy::IsTelephonyFeatureSupported
       
   515 // -----------------------------------------------------------------------------
       
   516 //
       
   517 EXPORT_C TBool CPhoneCenRepProxy::IsTelephonyFeatureSupported( 
       
   518     const TInt aFeatureId )
       
   519     {
       
   520     return ( aFeatureId & iTelephonyVariantReadOnlyValues );
       
   521     }
       
   522 
       
   523 // -----------------------------------------------------------------------------
       
   524 // CPhoneCenRepProxy::GetTelephonyVariantData
       
   525 // -----------------------------------------------------------------------------
       
   526 //
       
   527 TInt CPhoneCenRepProxy::GetTelephonyVariantData()
       
   528     {
       
   529     TInt err = KErrNone;
       
   530 
       
   531     // Variation data should be unchangable during run-time, 
       
   532     // therefore, if once succesfully read, later reads are
       
   533     // not allowed.
       
   534     if( iTelephonyVariantReadOnlyValues == KPhoneVariantReadOnlyDefaultValue )
       
   535         {
       
   536         err = GetInt( 
       
   537             KCRUidTelVariation, 
       
   538             KTelVariationFlags, 
       
   539             iTelephonyVariantReadOnlyValues );
       
   540         }
       
   541 
       
   542     return err;
       
   543     }
       
   544 
       
   545 // -----------------------------------------------------------------------------
       
   546 // CPhoneCenRepProxy::IsPhoneUIFeatureSupported
       
   547 // -----------------------------------------------------------------------------
       
   548 //
       
   549 EXPORT_C TBool CPhoneCenRepProxy::IsPhoneUIFeatureSupported( 
       
   550     const TInt aFeatureId )
       
   551     {
       
   552     return ( aFeatureId & iPhoneUIVariantReadOnlyValues );
       
   553     }
       
   554 
       
   555 // -----------------------------------------------------------------------------
       
   556 // CPhoneCenRepProxy::GetPhoneUIVariantData
       
   557 // -----------------------------------------------------------------------------
       
   558 //
       
   559 TInt CPhoneCenRepProxy::GetPhoneUIVariantData()
       
   560     {
       
   561     TInt err = KErrNone;
       
   562 /*
       
   563     // Variation data should be unchangable during run-time, 
       
   564     // therefore, if once succesfully read, later reads are
       
   565     // not allowed.
       
   566     if ( iPhoneUIVariantReadOnlyValues == KPhoneVariantReadOnlyDefaultValue )
       
   567         {
       
   568         err = GetInt( 
       
   569             KCRUidPhoneAppS60Variation, 
       
   570             KPhoneAppS60VariationFlags, 
       
   571             iPhoneAppS60VariantReadOnlyValues );
       
   572         }
       
   573 */
       
   574     return err;
       
   575     }
       
   576 
       
   577 // ---------------------------------------------------------
       
   578 // CPhoneCenRepProxy::Find
       
   579 // ---------------------------------------------------------
       
   580 //
       
   581 EXPORT_C TInt CPhoneCenRepProxy::Find(
       
   582     const TUid& aUid,
       
   583     const TUint32 aPartial, 
       
   584     const TUint32 aMask,
       
   585     RArray<TUint32>& aValues ) const
       
   586     {
       
   587     CRepository* repository = NULL;
       
   588     TRAPD( err, repository = CRepository::NewL( aUid ) );
       
   589     if ( err == KErrNone )
       
   590         {
       
   591         TRAP( err, repository->FindL( aPartial, aMask, aValues ) );
       
   592         delete repository;
       
   593         }
       
   594 
       
   595     if ( err != KErrNone)
       
   596         {
       
   597         __PHONELOG1( 
       
   598             EBasic, 
       
   599             EPhonePhoneapp, 
       
   600             "CPhoneCenRepProxy::GetInt() error: %d", 
       
   601             err );
       
   602         __ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) );
       
   603         }
       
   604 
       
   605     return err;
       
   606     }
       
   607 
       
   608 // -----------------------------------------------------------------------------
       
   609 // CPhoneCenRepProxy::FetchValuesFromCenRepL
       
   610 // -----------------------------------------------------------------------------
       
   611 //
       
   612 EXPORT_C void CPhoneCenRepProxy::FetchValuesFromCenRepL( 
       
   613                                                 TPhoneCmdParamAppInfo& aAppInfo,
       
   614                                                 TKeyCode aCode, 
       
   615                                                 HBufC8* aAppParam,
       
   616                                                 TBool& aValuesFetched )
       
   617     {
       
   618     const TUint32     KPartialKey = 0xFF0000;
       
   619     const TUint32   KLaunchGroupIdMask = 0x00FF00;
       
   620     const TUint32   KLaunchPlaceIdMask = 0x0000FF;
       
   621     const TUint32     KIdmask = 0xFF0000;
       
   622     
       
   623     const TUint32   KLaunchGroupIdShift = 8;
       
   624     const TInt      KUidId = 2;
       
   625     const TInt      KParamId = 3;
       
   626 
       
   627     RArray<TUint32> foundKeys;
       
   628     CleanupClosePushL( foundKeys );    
       
   629     
       
   630     CRepository* repository = NULL;
       
   631     repository = CRepository::NewL( KCRUidTelPrivateVariation );
       
   632     
       
   633     TInt err( KErrNone );
       
   634     
       
   635     if ( repository )
       
   636         {
       
   637         CleanupStack::PushL( repository );
       
   638         err = repository->FindL( KPartialKey, KIdmask, foundKeys );
       
   639         }
       
   640 
       
   641     if ( KErrNone != err )
       
   642         {
       
   643         __PHONELOG1( 
       
   644             EBasic, 
       
   645             EPhonePhoneapp, 
       
   646             "CPhoneCenRepProxy::FetchValuesFromCenRepL() error: %d", 
       
   647             err );
       
   648         User::Leave( err );
       
   649         }        
       
   650     
       
   651     TInt uid(0);
       
   652     TInt code(0);
       
   653     HBufC* param = HBufC::NewL( KMaxParamLength );
       
   654     TPtr paramPtr = param->Des();
       
   655     CleanupStack::PushL( param );
       
   656     
       
   657     for ( TInt i = 0; i < foundKeys.Count(); i++ )
       
   658         {
       
   659         User::LeaveIfError( repository->Get(
       
   660                 foundKeys[i], code ) );       
       
   661         
       
   662         //peekIndex is used to check if foundKeys-array has a next 
       
   663         //element. For this reason (i+1) is used.
       
   664         TInt peekIndex(i+1);
       
   665         TInt peekGroupId(0);
       
   666         TInt launchGroupID 
       
   667             = ( foundKeys[i] & KLaunchGroupIdMask ) >> KLaunchGroupIdShift;        
       
   668         
       
   669         if( peekIndex < foundKeys.Count() && code == aCode )
       
   670             {
       
   671             peekGroupId =
       
   672             ( foundKeys[peekIndex] & KLaunchGroupIdMask ) 
       
   673                     >> KLaunchGroupIdShift;
       
   674         
       
   675             // Check that group Id is the same as for the key fetched earlier
       
   676             // (KKeyId) and the key id for this key is (KUidId).
       
   677             if( launchGroupID == peekGroupId &&
       
   678                 KUidId == ( foundKeys[peekIndex] & KLaunchPlaceIdMask ) )  
       
   679                 {
       
   680                 User::LeaveIfError( repository->Get(
       
   681                         foundKeys[++i], uid ) );
       
   682                 }
       
   683             
       
   684             peekIndex = i+1; // peekIndex update. The actual value is dependant on
       
   685                               // whether variable i was incremented or not in previous if.
       
   686 
       
   687             if( peekIndex < foundKeys.Count() )
       
   688                 {
       
   689                 peekGroupId = 
       
   690                        ( foundKeys[peekIndex] & KLaunchGroupIdMask ) 
       
   691                                >> KLaunchGroupIdShift;
       
   692                 // Check that group Id is still the same as for the keys fetched 
       
   693                 // earlier (KKeyId and KUidId)
       
   694                 // and the key id for this key is (KParamId).
       
   695                 if( launchGroupID == peekGroupId &&
       
   696                         KParamId == ( foundKeys[peekIndex] & KLaunchPlaceIdMask ) )
       
   697                     {                
       
   698                     User::LeaveIfError( repository->Get( 
       
   699                             foundKeys[++i], paramPtr ) );
       
   700                     break;
       
   701                     }
       
   702                 }
       
   703             }
       
   704         else
       
   705             {
       
   706             i++; // skip uid index (wrong code)
       
   707             i++; // skip parameter index (wrong code)
       
   708             }
       
   709         }
       
   710     
       
   711     if ( uid != 0 )
       
   712         {
       
   713         aAppInfo.SetAppUid( TUid::Uid( uid ) );
       
   714         // TDesc16 to TDesc8 conversion. Central repository supports only
       
   715         // 16 bit buffers, setParam function in TPhoneCmdParamAppInfo wants
       
   716         // 8 bit.
       
   717         TPtr8 eightBitParamPtr = aAppParam->Des();
       
   718         CnvUtfConverter::ConvertFromUnicodeToUtf8( eightBitParamPtr, 
       
   719                 paramPtr );         
       
   720         
       
   721         aAppInfo.SetParam( eightBitParamPtr );
       
   722         aValuesFetched = ETrue;
       
   723         }
       
   724     
       
   725     CleanupStack::PopAndDestroy( param ); 
       
   726     CleanupStack::PopAndDestroy( repository );
       
   727     CleanupStack::PopAndDestroy( &foundKeys );
       
   728     }
       
   729 
       
   730 //  End of File