XDMEngine/XdmSettingsApi/src/XdmSettingsApi.cpp
changeset 0 c8caa15ef882
child 8 aca99fb8a3dd
equal deleted inserted replaced
-1:000000000000 0:c8caa15ef882
       
     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:   XDM Engine settings API
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <flogger.h>
       
    21 #include <centralrepository.h>
       
    22 #include "XdmSettingsApi.h"
       
    23 #include "XdmSettingsProperty.h"
       
    24 #include "XdmSettingsCollection.h"
       
    25 
       
    26 // ---------------------------------------------------------
       
    27 // TXdmSettingsApi::CreateCollectionL
       
    28 //
       
    29 // ---------------------------------------------------------
       
    30 //
       
    31 EXPORT_C TInt TXdmSettingsApi::CreateCollectionL( const CXdmSettingsCollection& aCollection )
       
    32     {
       
    33     #ifdef _DEBUG
       
    34         WriteToLog( _L8( "TXdmSettingsApi::CreateCollectionL()" ) );
       
    35     #endif
       
    36     TInt error = KErrArgument;
       
    37     CRepository* repository = CRepository::NewL( KCRUidXdmEngine );
       
    38     CleanupStack::PushL( repository );
       
    39     TInt row = LastRow( repository );
       
    40     TInt count = aCollection.Count();
       
    41     __ASSERT_DEBUG( count > 0, User::Leave( KErrArgument ) );
       
    42     for( TInt i = 0;i < count;i++ )
       
    43         {
       
    44         const CXdmSettingsProperty& prop = aCollection.Property( i );
       
    45         TInt32 column = prop.PropertyName();
       
    46         //Don't let the client set the settings ID, since
       
    47         //this might create conflicting IDs in the repository
       
    48         if( column != KXdmSettingsId )
       
    49             {
       
    50             //Now merge row & column
       
    51             TInt32 newKey = ( row * 0x100 ) | column;
       
    52             error = repository->Create( newKey, prop.PropertyValue() );
       
    53             #ifdef _DEBUG
       
    54                 HBufC8* buf = HBufC8::NewLC( prop.PropertyValue().Length() );
       
    55                 buf->Des().Copy( prop.PropertyValue() );
       
    56                 TPtrC8 des( buf->Des() );
       
    57                 WriteToLog( _L8( " New key [0x%08x] created - Name: %d  Value: %S" ), newKey, column, &des );
       
    58                 CleanupStack::PopAndDestroy();  //buf
       
    59             #endif
       
    60             }
       
    61         }
       
    62     error = CreateUniqueIdL( repository, row );
       
    63     #ifdef _DEBUG
       
    64         WriteToLog( _L8( " New settings ID created - ID: %d  Error: %d" ), row, error );
       
    65     #endif
       
    66     CleanupStack::PopAndDestroy();  //repository
       
    67     return error == KErrNone ? row : error;
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------
       
    71 // TXdmSettingsApi::RemoveCollectionL
       
    72 //
       
    73 // ---------------------------------------------------------
       
    74 //
       
    75 EXPORT_C void TXdmSettingsApi::RemoveCollectionL( TInt aSettingsId )
       
    76     {
       
    77     #ifdef _DEBUG
       
    78         WriteToLog( _L8( "TXdmSettingsApi::RemoveCollectionL() - ID: %d" ), aSettingsId );
       
    79     #endif
       
    80     CRepository* repository = CRepository::NewL( KCRUidXdmEngine );
       
    81     CleanupStack::PushL( repository );
       
    82     TInt row = FindRowL( aSettingsId, repository );
       
    83     if( row >= KErrNone )
       
    84         {
       
    85         TInt32 key = -1;
       
    86         TInt error = KErrNone;
       
    87         for( TInt i = 0;i < KXdmPropertyCount;i++ )
       
    88             {
       
    89             key = ( row * 0x100 ) | i;
       
    90             error = repository->Delete( key );
       
    91             #ifdef _DEBUG
       
    92                 WriteToLog( _L8( " Key %x deleted - Error: %d" ), key, error );
       
    93             #endif
       
    94             }
       
    95         }
       
    96     else User::Leave( KErrNotFound );
       
    97     CleanupStack::PopAndDestroy();
       
    98     }
       
    99     
       
   100 // ---------------------------------------------------------
       
   101 // TXdmSettingsApi::CreatePropertyL
       
   102 //
       
   103 // ---------------------------------------------------------
       
   104 //   
       
   105 EXPORT_C void TXdmSettingsApi::CreatePropertyL( TInt aSettingsId,
       
   106                                                 const TDesC& aPropertyValue,
       
   107                                                 TXdmSettingsProperty aPropertyName )
       
   108     {
       
   109     #ifdef _DEBUG
       
   110         WriteToLog( _L8( "TXdmSettingsApi::UpdatePropertyL()" ) );
       
   111         WriteToLog( _L8( "  Property:           %d" ), aPropertyName );
       
   112         WriteToLog( _L8( "  Property set ID:    %d" ), aSettingsId );
       
   113         WriteToLog( _L8( "  Property value:     %S" ), &aPropertyValue );
       
   114     #endif
       
   115     TInt error = KErrNotFound;
       
   116     CRepository* repository = CRepository::NewL( KCRUidXdmEngine );
       
   117     CleanupStack::PushL( repository );
       
   118     TInt row = FindRowL( aSettingsId, repository );
       
   119     if( row >= 0 )      
       
   120         {
       
   121         TInt32 key = ( row * 0x100 ) | aPropertyName;
       
   122         error = repository->Create( key, aPropertyValue );
       
   123         if( error != KErrNone )
       
   124             {
       
   125             #ifdef _DEBUG
       
   126                 WriteToLog( _L8( "  Create() failed with %d" ), error );
       
   127             #endif
       
   128             User::Leave( error );
       
   129             }
       
   130         }
       
   131     else                            //No keys or too many
       
   132         {
       
   133         #ifdef _DEBUG
       
   134             WriteToLog( _L8( "  Property set not found - Error: %d" ), row );
       
   135         #endif
       
   136         User::Leave( error );
       
   137         } 
       
   138     CleanupStack::PopAndDestroy();  //repository
       
   139     }
       
   140 
       
   141 // ---------------------------------------------------------
       
   142 // TXdmSettingsApi::UpdatePropertyL
       
   143 //
       
   144 // ---------------------------------------------------------
       
   145 //   
       
   146 EXPORT_C void TXdmSettingsApi::UpdatePropertyL( TInt aSettingsId,
       
   147                                                 const TDesC& aPropertyValue,
       
   148                                                 TXdmSettingsProperty aPropertyName )
       
   149 
       
   150     {
       
   151     #ifdef _DEBUG
       
   152         HBufC8* value = HBufC8::NewLC( aPropertyValue.Length() );
       
   153         TPtr8 prop( value->Des() );
       
   154         prop.Copy( aPropertyValue ); 
       
   155         WriteToLog( _L8( "TXdmSettingsApi::UpdatePropertyL()" ) );
       
   156         WriteToLog( _L8( "  Settings ID:      %d" ), aSettingsId );
       
   157         WriteToLog( _L8( "  Property name:    %d" ), aPropertyName );
       
   158         WriteToLog( _L8( "  Property value:   %S" ), &prop );
       
   159         CleanupStack::PopAndDestroy();  //value
       
   160     #endif
       
   161     TInt error = KErrAlreadyExists;
       
   162     CRepository* repository = CRepository::NewL( KCRUidXdmEngine );
       
   163     CleanupStack::PushL( repository );
       
   164     RArray<TUint32> keys = FindByIdL( aSettingsId, repository );
       
   165     CleanupClosePushL( keys );
       
   166     TInt count = keys.Count();
       
   167     if( count == 1 )      
       
   168         {
       
   169         TInt32 row = ( keys[0] & 0xFFFFFF00 ) / 0x100;
       
   170         TInt32 key = ( row * 0x100 ) | aPropertyName;
       
   171         #ifdef _DEBUG
       
   172             WriteToLog( _L8( "  Key to update:    0x%08x" ), key );
       
   173         #endif
       
   174         error = repository->Set( key, aPropertyValue );
       
   175         if( error != KErrNone )
       
   176             {
       
   177             #ifdef _DEBUG
       
   178                 WriteToLog( _L8( "  Set() failed with %d, try Create()" ), error );
       
   179             #endif
       
   180             error = repository->Create( key, aPropertyValue );
       
   181             #ifdef _DEBUG
       
   182                 WriteToLog( _L8( "  Create() completed with %d" ), error );
       
   183             #endif
       
   184             }
       
   185         }
       
   186     else                            //No keys or too many
       
   187         {
       
   188         #ifdef _DEBUG
       
   189             TBuf<32> errBuf;
       
   190             count > 0 ? errBuf.Append( _L( "Too many results" ) ) :
       
   191                         errBuf.Append( _L( "No results found" ) );
       
   192             WriteToLog( _L8( "  * Error - %S: %d" ), &errBuf, count );
       
   193         #endif
       
   194         TInt error = count > 0 ? KErrGeneral : KErrNotFound;
       
   195         User::Leave( error );
       
   196         } 
       
   197     CleanupStack::PopAndDestroy( 2 );  //keys, repository
       
   198     }
       
   199 
       
   200 // ---------------------------------------------------------
       
   201 // TXdmSettingsApi::RemovePropertyL
       
   202 //
       
   203 // ---------------------------------------------------------
       
   204 //
       
   205 EXPORT_C void TXdmSettingsApi::RemovePropertyL( TInt aSettingsId,
       
   206                                                 TXdmSettingsProperty aPropertyName )
       
   207     {
       
   208     #ifdef _DEBUG
       
   209         WriteToLog( _L8( "TXdmSettingsApi::RemovePropertyL() - ID: %d" ), aSettingsId );
       
   210     #endif
       
   211     TInt error = KErrNotFound;
       
   212     CRepository* repository = CRepository::NewL( KCRUidXdmEngine );
       
   213     CleanupStack::PushL( repository );
       
   214     TInt row = FindRowL( aSettingsId, repository );
       
   215     if( row >= 0 )      
       
   216         {
       
   217         TInt32 key = ( row * 0x100 ) | aPropertyName;
       
   218         error = repository->Delete( key );
       
   219         if( error != KErrNone )
       
   220             {
       
   221             #ifdef _DEBUG
       
   222                 WriteToLog( _L8( "  Delete() failed with %d" ), error );
       
   223             #endif
       
   224             User::Leave( error );
       
   225             }
       
   226         }
       
   227     else                            //No keys or too many
       
   228         {
       
   229         #ifdef _DEBUG
       
   230             WriteToLog( _L8( "  Property set not found - Error: %d" ), row );
       
   231         #endif
       
   232         User::Leave( error );
       
   233         } 
       
   234     CleanupStack::PopAndDestroy();  //repository
       
   235     }
       
   236     
       
   237 // ---------------------------------------------------------
       
   238 // TXdmSettingsApi::CreateUniqueIdL
       
   239 //
       
   240 // ---------------------------------------------------------
       
   241 //
       
   242 TInt TXdmSettingsApi::CreateUniqueIdL( CRepository* aRepository, TInt aRow )
       
   243     {
       
   244     TBuf<10> numBuf;
       
   245     numBuf.Zero();
       
   246     numBuf.AppendNum( aRow );
       
   247     TInt error = KErrNone;
       
   248     RArray<TUint32> keys;
       
   249     CleanupClosePushL( keys );
       
   250     const TInt32 KPartialIdMask = 0x000000FF;
       
   251     error = aRepository->FindEqL( KXdmSettingsId, KPartialIdMask, numBuf, keys );
       
   252     __ASSERT_DEBUG( error == KErrNotFound, User::Panic( _L( "CXdmSettingsApi" ), 1 ) );
       
   253     TInt32 newKey = ( aRow * 0x100 ) | KXdmSettingsId;
       
   254     error = aRepository->Create( newKey, numBuf );
       
   255     CleanupStack::PopAndDestroy();  //keys 
       
   256     return error;
       
   257     }
       
   258     
       
   259 // ---------------------------------------------------------
       
   260 // TXdmSettingsApi::LastRow
       
   261 //
       
   262 // ---------------------------------------------------------
       
   263 //
       
   264 TInt TXdmSettingsApi::LastRow( CRepository* aRepository )
       
   265     {
       
   266     RArray<TUint32> keys;
       
   267     CleanupClosePushL( keys );
       
   268     const TInt32 KPartialNameMask = 0x000000FF;
       
   269     TInt error = aRepository->FindL( KXdmSettingsId, KPartialNameMask, keys );
       
   270     TInt count = keys.Count();
       
   271     //Must check for existing IDs
       
   272     if( count > 0 )
       
   273         {
       
   274         TInt exists = FindRowL( count, aRepository );
       
   275         while( exists != KErrNotFound )
       
   276             {
       
   277             count++;
       
   278             exists = FindRowL( count, aRepository );
       
   279             }
       
   280         }
       
   281     CleanupStack::PopAndDestroy();  //keys
       
   282     return count;
       
   283     }
       
   284 
       
   285 // ---------------------------------------------------------
       
   286 // TXdmSettingsApi::FindRowL
       
   287 //
       
   288 // ---------------------------------------------------------
       
   289 //
       
   290 TInt TXdmSettingsApi::FindRowL( TInt aSettingsId,
       
   291                                 CRepository* aRepository )
       
   292     {
       
   293     TUint32 rowNum = 0;
       
   294     RArray<TUint32> keys;
       
   295     CleanupClosePushL( keys );
       
   296     TBuf<10> numBuf;
       
   297     numBuf.AppendNum( aSettingsId );
       
   298     const TInt32 KPartialNameMask = 0x000000FF;
       
   299     TInt error = aRepository->FindEqL( KXdmSettingsId, KPartialNameMask, numBuf, keys );
       
   300     if( error == KErrNone && keys.Count() == 1 )
       
   301         {
       
   302         //Extract row part from the key
       
   303         TInt row = keys[0] & 0xFFFFFF00;
       
   304         //e.g. 0x00000400 => 0x00000004
       
   305         rowNum = row / 0x100;
       
   306         }
       
   307     CleanupStack::PopAndDestroy();  //keys
       
   308     return error == KErrNone ? rowNum : error;
       
   309     }
       
   310            
       
   311 // ---------------------------------------------------------
       
   312 // TXdmSettingsApi::FindByIdL
       
   313 //
       
   314 // ---------------------------------------------------------
       
   315 //
       
   316 RArray<TUint32> TXdmSettingsApi::FindByIdL( TInt aSettingsId, CRepository* aRepository )
       
   317     {
       
   318     const TInt32 KPartialKeyMask = 0x000000FF;
       
   319     RArray<TUint32> keys;
       
   320     CleanupClosePushL( keys );
       
   321     TBuf<15> numBuf;
       
   322     numBuf.AppendNum( aSettingsId );
       
   323     TInt error = aRepository->FindEqL( KXdmSettingsId, KPartialKeyMask, numBuf, keys );
       
   324     CleanupStack::Pop();  //keys
       
   325     return keys;
       
   326     }
       
   327 
       
   328 // ---------------------------------------------------------
       
   329 // TXdmSettingsApi::FindByTypeL
       
   330 //
       
   331 // ---------------------------------------------------------
       
   332 //
       
   333 RArray<TUint32> TXdmSettingsApi::FindByTypeL( CRepository* aRepository,
       
   334                                               TXdmSettingsProperty aSingleProp )
       
   335     {
       
   336     const TInt32 KPartialKeyMask = 0x000000FF;
       
   337     RArray<TUint32> keys;
       
   338     CleanupClosePushL( keys );
       
   339     TInt error = aRepository->FindL( aSingleProp, KPartialKeyMask, keys );
       
   340     CleanupStack::Pop();  //keys
       
   341     return keys;
       
   342     }
       
   343 
       
   344 // ----------------------------------------------------------
       
   345 // TXdmSettingsApi::WriteToLog
       
   346 // 
       
   347 // ----------------------------------------------------------
       
   348 //
       
   349 void TXdmSettingsApi::WriteToLog( TRefByValue<const TDesC8> aFmt,... )                                 
       
   350     {
       
   351     VA_LIST list;
       
   352     VA_START( list, aFmt );
       
   353     TBuf8<KXdmSettingsLogBufferMaxSize> buf;
       
   354     buf.FormatList( aFmt, list );
       
   355     RFileLogger::Write( KXdmSettingsLogDir, KXdmSettingsLogFile, 
       
   356                         EFileLoggingModeAppend, buf );
       
   357     }
       
   358 
       
   359 // ---------------------------------------------------------
       
   360 // TXdmSettingsApi::CollectionNamesL
       
   361 //
       
   362 // ---------------------------------------------------------
       
   363 //
       
   364 EXPORT_C CDesCArray* TXdmSettingsApi::CollectionNamesLC( RArray<TInt>& aSettingIds )
       
   365     {
       
   366     #ifdef _DEBUG
       
   367         WriteToLog( _L8( "TXdmSettingsApi::CollectionNamesL()" ) );
       
   368     #endif
       
   369     TInt error = KErrNone;
       
   370     CDesCArrayFlat* propertySet = new ( ELeave ) CDesCArrayFlat( 10 );
       
   371     CleanupStack::PushL( propertySet );
       
   372     CRepository* repository = CRepository::NewL( KCRUidXdmEngine );
       
   373     CleanupStack::PushL( repository );
       
   374     RArray<TUint32> nameKeys = FindByTypeL( repository, EXdmPropName );
       
   375     CleanupClosePushL( nameKeys );
       
   376     RArray<TUint32> idKeys = FindByTypeL( repository, EXdmPropSettingsId );
       
   377     CleanupClosePushL( idKeys );
       
   378     #ifdef _DEBUG
       
   379         WriteToLog( _L8( "  ID key count: %d" ), idKeys.Count() );
       
   380         WriteToLog( _L8( "  Name key count: %d" ), nameKeys.Count() );
       
   381     #endif
       
   382     TInt count = nameKeys.Count();
       
   383     if( count > 0 )
       
   384         {
       
   385         TInt numId = 0; 
       
   386         HBufC* name = NULL;
       
   387         TBuf<10> identifier;
       
   388         for( TInt i = 0;i < count;i++ )
       
   389             {
       
   390             identifier.Zero();
       
   391             name = HBufC::NewLC( NCentralRepositoryConstants::KMaxUnicodeStringLength );
       
   392             TPtr desc( name->Des());
       
   393             error = repository->Get( nameKeys[i], desc );
       
   394             error = repository->Get( idKeys[i], identifier );
       
   395             if( error == KErrNone && desc.Length() > 0 && identifier.Length() > 0 )
       
   396                 {
       
   397                 #ifdef _DEBUG
       
   398                     HBufC8* eightName = HBufC8::NewLC( desc.Length() );
       
   399                     TPtr8 eightDesc( eightName->Des() );
       
   400                     eightDesc.Copy( desc );
       
   401                     WriteToLog( _L8( " Collection no. %d - Name: %S  ID: %S" ), i, &eightDesc, &identifier );
       
   402                     CleanupStack::PopAndDestroy();  //eightName
       
   403                 #endif
       
   404                 propertySet->AppendL( desc );
       
   405                 TLex id( identifier );
       
   406                 error = id.Val( numId );
       
   407                 aSettingIds.Append( error == KErrNone ? numId : error );
       
   408                 }
       
   409             else
       
   410                 {
       
   411                 #ifdef _DEBUG
       
   412                     WriteToLog( _L8( " Fetching of the name no. %d failed with: %d" ), i, error );
       
   413                 #endif
       
   414                 }
       
   415             CleanupStack::PopAndDestroy();  //name
       
   416             }
       
   417         }
       
   418     CleanupStack::PopAndDestroy( 3 );   //idKeys, nameKeys, repository
       
   419     return propertySet;
       
   420     }
       
   421                                             
       
   422 // ---------------------------------------------------------
       
   423 // TXdmSettingsApi::SettingsCollectionLC
       
   424 //
       
   425 // ---------------------------------------------------------
       
   426 //
       
   427 EXPORT_C CXdmSettingsCollection* TXdmSettingsApi::SettingsCollectionL( TInt aSettingsId )
       
   428     {
       
   429     #ifdef _DEBUG
       
   430         WriteToLog( _L8( "TXdmSettingsApi::SettingsCollectionL() - ID: %d" ), aSettingsId );
       
   431     #endif
       
   432     CXdmSettingsCollection* collection = NULL;
       
   433     CRepository* repository = CRepository::NewL( KCRUidXdmEngine );
       
   434     CleanupStack::PushL( repository );
       
   435     TInt row = FindRowL( aSettingsId, repository );
       
   436     if( row >= KErrNone )
       
   437         {
       
   438         TInt32 key = -1;
       
   439         HBufC* buf = NULL;
       
   440         TInt error = KErrNone;
       
   441         collection = new ( ELeave ) CXdmSettingsCollection();
       
   442         CleanupStack::PushL( collection );
       
   443         #ifdef _DEBUG
       
   444             WriteToLog( _L8( " Data in the specified colletion: " ) );
       
   445         #endif
       
   446         for( TInt i = 0;i < KXdmPropertyCount;i++ )
       
   447             {
       
   448             key = ( row * 0x100 ) | i;
       
   449             buf = HBufC::NewLC( NCentralRepositoryConstants::KMaxUnicodeStringLength );
       
   450             TPtr desc( buf->Des() );
       
   451             error = repository->Get( key, desc );
       
   452             if( error == KErrNone )
       
   453                 {
       
   454                 #ifdef _DEBUG
       
   455                     HBufC8* eight = HBufC8::NewLC( desc.Length() );
       
   456                     TPtr8 eightDesc( eight->Des() );
       
   457                     eightDesc.Copy( desc );
       
   458                     WriteToLog( _L8( "  Property %d [0x%08x]: %S" ), i, key, &eightDesc );
       
   459                     CleanupStack::PopAndDestroy();   //eight
       
   460                 #endif
       
   461                 collection->AppendL( desc, ( TXdmSettingsProperty )i );
       
   462                 }
       
   463             CleanupStack::PopAndDestroy();  //buf
       
   464             }
       
   465         CleanupStack::Pop();  //collection
       
   466         }
       
   467     else
       
   468         {
       
   469         #ifdef _DEBUG
       
   470             WriteToLog( _L8( "  Could not find the collection, leaves with KErrNotFound" ) );
       
   471         #endif
       
   472         User::Leave( KErrNotFound );
       
   473         }
       
   474     CleanupStack::PopAndDestroy();  //repository
       
   475     return collection;
       
   476     }
       
   477         
       
   478 // ---------------------------------------------------------
       
   479 // TXdmSettingsApi::PropertyL
       
   480 //
       
   481 // ---------------------------------------------------------
       
   482 //                                     
       
   483 EXPORT_C HBufC* TXdmSettingsApi::PropertyL( TInt aSettingsId,
       
   484                                             TXdmSettingsProperty aSingleProp )
       
   485     {
       
   486     #ifdef _DEBUG
       
   487         WriteToLog( _L8( "TXdmSettingsApi::PropertyLC()" ) );
       
   488         WriteToLog( _L8( "  Property:           %d" ), &aSingleProp );
       
   489         WriteToLog( _L8( "  Property set ID:    %d" ), aSettingsId );
       
   490     #endif
       
   491     HBufC* buf = NULL;
       
   492     TInt error = KErrGeneral;
       
   493     CRepository* repository = CRepository::NewL( KCRUidXdmEngine );
       
   494     CleanupStack::PushL( repository );
       
   495     RArray<TUint32> keys = FindByIdL( aSettingsId, repository );
       
   496     CleanupClosePushL( keys );
       
   497     TInt count = keys.Count();
       
   498     if( count == 1 )                //This is the normal case
       
   499         {
       
   500         TInt32 row = ( keys[0] & 0xFFFFFF00 ) / 0x100;
       
   501         TInt32 key = ( row * 0x100 ) | aSingleProp;
       
   502         buf = HBufC::NewL( NCentralRepositoryConstants::KMaxUnicodeStringLength );
       
   503         TPtr desc( buf->Des() );
       
   504         error = repository->Get( key, desc );
       
   505         #ifdef _DEBUG
       
   506             WriteToLog( _L8( "  Error:    %d" ), error );
       
   507         #endif
       
   508         }
       
   509     else                            //No keys or too many
       
   510         {
       
   511         #ifdef _DEBUG
       
   512             TBuf8<32> errBuf;
       
   513             count > 0 ? errBuf.Append( _L8( "Too many results" ) ) :
       
   514                         errBuf.Append( _L8( "No results found" ) );
       
   515             WriteToLog( _L8( "  * Error - %S: %d" ), &errBuf, count );
       
   516         #endif
       
   517         error = count > 0 ? KErrGeneral : KErrNotFound;
       
   518         User::Leave( error );
       
   519         }
       
   520     CleanupStack::PopAndDestroy( 2 );  //keys, repository
       
   521     return buf;
       
   522     }
       
   523             
       
   524 // End of File
       
   525