XDMEngine/XdmSettingsApi/src/XdmSettingsApi.cpp
branchRCL_3
changeset 8 aca99fb8a3dd
parent 0 c8caa15ef882
child 25 e53c01f160bc
equal deleted inserted replaced
7:895b8e06c769 8:aca99fb8a3dd
    29 // ---------------------------------------------------------
    29 // ---------------------------------------------------------
    30 //
    30 //
    31 EXPORT_C TInt TXdmSettingsApi::CreateCollectionL( const CXdmSettingsCollection& aCollection )
    31 EXPORT_C TInt TXdmSettingsApi::CreateCollectionL( const CXdmSettingsCollection& aCollection )
    32     {
    32     {
    33     #ifdef _DEBUG
    33     #ifdef _DEBUG
    34         WriteToLog( _L8( "TXdmSettingsApi::CreateCollectionL()" ) );
    34         WriteToLog( _L8( "TXdmSettingsApi::CreateCollectionL() - begin" ) );
    35     #endif
    35     #endif
    36     TInt error = KErrArgument;
    36     TInt error = KErrArgument;
    37     CRepository* repository = CRepository::NewL( KCRUidXdmEngine );
    37     CRepository* repository = CRepository::NewL( KCRUidXdmEngine );
    38     CleanupStack::PushL( repository );
    38     CleanupStack::PushL( repository );  // CS: 1
    39     TInt row = LastRow( repository );
    39     TInt row = LastRow( repository );
    40     TInt count = aCollection.Count();
    40     TInt count = aCollection.Count();
    41     __ASSERT_DEBUG( count > 0, User::Leave( KErrArgument ) );
    41     __ASSERT_DEBUG( count > 0, User::Leave( KErrArgument ) );
    42     for( TInt i = 0;i < count;i++ )
    42     for( TInt i = 0;i < count;i++ )
    43         {
    43         {
   362 // ---------------------------------------------------------
   362 // ---------------------------------------------------------
   363 //
   363 //
   364 EXPORT_C CDesCArray* TXdmSettingsApi::CollectionNamesLC( RArray<TInt>& aSettingIds )
   364 EXPORT_C CDesCArray* TXdmSettingsApi::CollectionNamesLC( RArray<TInt>& aSettingIds )
   365     {
   365     {
   366     #ifdef _DEBUG
   366     #ifdef _DEBUG
   367         WriteToLog( _L8( "TXdmSettingsApi::CollectionNamesL()" ) );
   367         WriteToLog( _L8( "TXdmSettingsApi::CollectionNamesLC() - begin" ) );
   368     #endif
   368     #endif
       
   369     TInt nameError = KErrNone;
       
   370     TInt idError = KErrNone;
   369     TInt error = KErrNone;
   371     TInt error = KErrNone;
   370     CDesCArrayFlat* propertySet = new ( ELeave ) CDesCArrayFlat( 10 );
   372     CDesCArrayFlat* propertySet = new ( ELeave ) CDesCArrayFlat( 10 );
   371     CleanupStack::PushL( propertySet );
   373     CleanupStack::PushL( propertySet );
   372     CRepository* repository = CRepository::NewL( KCRUidXdmEngine );
   374     CRepository* repository = CRepository::NewL( KCRUidXdmEngine );
   373     CleanupStack::PushL( repository );
   375     CleanupStack::PushL( repository );
   388         for( TInt i = 0;i < count;i++ )
   390         for( TInt i = 0;i < count;i++ )
   389             {
   391             {
   390             identifier.Zero();
   392             identifier.Zero();
   391             name = HBufC::NewLC( NCentralRepositoryConstants::KMaxUnicodeStringLength );
   393             name = HBufC::NewLC( NCentralRepositoryConstants::KMaxUnicodeStringLength );
   392             TPtr desc( name->Des());
   394             TPtr desc( name->Des());
   393             error = repository->Get( nameKeys[i], desc );
   395             nameError = repository->Get( nameKeys[i], desc );
   394             error = repository->Get( idKeys[i], identifier );
   396             idError = repository->Get( idKeys[i], identifier );
   395             if( error == KErrNone && desc.Length() > 0 && identifier.Length() > 0 )
   397             if( idError == KErrNone && desc.Length() > 0 && identifier.Length() > 0 )
   396                 {
   398                 {
   397                 #ifdef _DEBUG
   399                 #ifdef _DEBUG
   398                     HBufC8* eightName = HBufC8::NewLC( desc.Length() );
   400                     HBufC8* eightName = HBufC8::NewLC( desc.Length() );
   399                     TPtr8 eightDesc( eightName->Des() );
   401                     TPtr8 eightDesc( eightName->Des() );
   400                     eightDesc.Copy( desc );
   402                     eightDesc.Copy( desc );
   407                 aSettingIds.Append( error == KErrNone ? numId : error );
   409                 aSettingIds.Append( error == KErrNone ? numId : error );
   408                 }
   410                 }
   409             else
   411             else
   410                 {
   412                 {
   411                 #ifdef _DEBUG
   413                 #ifdef _DEBUG
   412                     WriteToLog( _L8( " Fetching of the name no. %d failed with: %d" ), i, error );
   414                     WriteToLog( _L8( " Fetching of the name no. %d failed with idError:%d & nameError:%d" ), i, idError, nameError );
   413                 #endif
   415                 #endif
   414                 }
   416                 }
   415             CleanupStack::PopAndDestroy();  //name
   417             CleanupStack::PopAndDestroy();  //name
   416             }
   418             }
   417         }
   419         }
   418     CleanupStack::PopAndDestroy( 3 );   //idKeys, nameKeys, repository
   420     CleanupStack::PopAndDestroy( 3 );   //idKeys, nameKeys, repository
       
   421 #ifdef _DEBUG
       
   422         WriteToLog( _L8( "TXdmSettingsApi::CollectionNamesLC() - end" ) );
       
   423 #endif
   419     return propertySet;
   424     return propertySet;
   420     }
   425     }
   421                                             
   426                                             
   422 // ---------------------------------------------------------
   427 // ---------------------------------------------------------
   423 // TXdmSettingsApi::SettingsCollectionLC
   428 // TXdmSettingsApi::SettingsCollectionLC
   516         #endif
   521         #endif
   517         error = count > 0 ? KErrGeneral : KErrNotFound;
   522         error = count > 0 ? KErrGeneral : KErrNotFound;
   518         User::Leave( error );
   523         User::Leave( error );
   519         }
   524         }
   520     CleanupStack::PopAndDestroy( 2 );  //keys, repository
   525     CleanupStack::PopAndDestroy( 2 );  //keys, repository
       
   526     WriteToLog( _L8( "  Return:           %S" ), buf );
   521     return buf;
   527     return buf;
   522     }
   528     }
   523             
   529             
   524 // End of File
   530 // End of File
   525 
   531