contentpublishingsrv/contentpublishingserver/cpsqlitestorage/src/cpstorageengine.cpp
branchRCL_3
changeset 19 edd621764147
parent 8 d0529222e3f0
child 23 ace62b58f4b2
equal deleted inserted replaced
16:b276298d5729 19:edd621764147
    27 // ---------------------------------------------------------------------------
    27 // ---------------------------------------------------------------------------
    28 // CCpStorageEngine::CCpStorageEngine()
    28 // CCpStorageEngine::CCpStorageEngine()
    29 //
    29 //
    30 // ---------------------------------------------------------------------------
    30 // ---------------------------------------------------------------------------
    31 //
    31 //
    32 CCpStorageEngine::CCpStorageEngine()
    32 CCpStorageEngine::CCpStorageEngine(TLiwVariant& aDataMapCache) :
       
    33     iDataMapCache(aDataMapCache)
    33     {
    34     {
    34     }
    35     }
    35 
    36 
    36 // ---------------------------------------------------------------------------
    37 // ---------------------------------------------------------------------------
    37 // CCpStorageEngine::ConstructL()
    38 // CCpStorageEngine::ConstructL()
    70 // ---------------------------------------------------------------------------
    71 // ---------------------------------------------------------------------------
    71 // CCpStorageEngine::NewL()
    72 // CCpStorageEngine::NewL()
    72 //
    73 //
    73 // ---------------------------------------------------------------------------
    74 // ---------------------------------------------------------------------------
    74 //
    75 //
    75 CCpStorageEngine* CCpStorageEngine::NewL()
    76 CCpStorageEngine* CCpStorageEngine::NewL(TLiwVariant& aDataMapCache)
    76     {
    77     {
    77     CCpStorageEngine* self = CCpStorageEngine::NewLC( );
    78     CCpStorageEngine* self = CCpStorageEngine::NewLC(aDataMapCache);
    78     CleanupStack::Pop( self );
    79     CleanupStack::Pop( self );
    79     return self;
    80     return self;
    80     }
    81     }
    81 
    82 
    82 // ---------------------------------------------------------------------------
    83 // ---------------------------------------------------------------------------
    83 // CCpStorageEngine::NewLC()
    84 // CCpStorageEngine::NewLC()
    84 //
    85 //
    85 // ---------------------------------------------------------------------------
    86 // ---------------------------------------------------------------------------
    86 //
    87 //
    87 CCpStorageEngine* CCpStorageEngine::NewLC()
    88 CCpStorageEngine* CCpStorageEngine::NewLC(TLiwVariant& aDataMapCache)
    88     {
    89     {
    89     CCpStorageEngine* self = new (ELeave) CCpStorageEngine();
    90     CCpStorageEngine* self = new (ELeave) CCpStorageEngine(aDataMapCache);
    90     CleanupStack::PushL( self );
    91     CleanupStack::PushL( self );
    91     self->ConstructL( );
    92     self->ConstructL( );
    92     return self;
    93     return self;
    93     }
    94     }
    94 
    95 
   134 void CCpStorageEngine::GetListL( const CLiwMap* aMap,
   135 void CCpStorageEngine::GetListL( const CLiwMap* aMap,
   135     CLiwGenericParamList& aList )
   136     CLiwGenericParamList& aList )
   136     {
   137     {
   137     CP_DEBUG( _L8("CCpStorageEngine::GetListL()") );
   138     CP_DEBUG( _L8("CCpStorageEngine::GetListL()") );
   138     const CCPLiwMap* map = static_cast<const CCPLiwMap*>(aMap);
   139     const CCPLiwMap* map = static_cast<const CCPLiwMap*>(aMap);
       
   140     
   139     RArray<TInt32> itemsToDelete;
   141     RArray<TInt32> itemsToDelete;
       
   142     CleanupClosePushL( itemsToDelete );
       
   143     
   140     TUint numberOfItems = map->GetListL( iSqlDb, &aList, itemsToDelete );
   144     TUint numberOfItems = map->GetListL( iSqlDb, &aList, itemsToDelete );
   141     //delete outdated items
   145     //delete outdated items
   142     CContentMap* removeItemMap = CContentMap::NewLC( );
   146     CContentMap* removeItemMap = CContentMap::NewLC( );
   143     for ( TInt i = 0; i<itemsToDelete.Count( ); i++ )
   147     for ( TInt i = 0; i<itemsToDelete.Count( ); i++ )
   144         {
   148         {
   146         removeItemMap->InsertL( KType, TLiwVariant( KCpData ) );
   150         removeItemMap->InsertL( KType, TLiwVariant( KCpData ) );
   147         RemoveL( removeItemMap );
   151         RemoveL( removeItemMap );
   148         removeItemMap->Remove( KId );
   152         removeItemMap->Remove( KId );
   149         }
   153         }
   150     CleanupStack::PopAndDestroy( removeItemMap );
   154     CleanupStack::PopAndDestroy( removeItemMap );
   151     itemsToDelete.Reset( );
   155     CleanupStack::PopAndDestroy( &itemsToDelete );
   152 
   156 
   153     if ( numberOfItems == 0 )
   157     if ( numberOfItems == 0 )
   154         {
   158         {
   155         User::Leave( KErrNotFound );
   159         User::Leave( KErrNotFound );
   156         }
   160         }
   168     const CCPLiwMap* map = static_cast<const CCPLiwMap*>(aMap);
   172     const CCPLiwMap* map = static_cast<const CCPLiwMap*>(aMap);
   169     if ( iCallback )
   173     if ( iCallback )
   170         {
   174         {
   171         CLiwDefaultList* listOfMaps = CLiwDefaultList::NewLC( );
   175         CLiwDefaultList* listOfMaps = CLiwDefaultList::NewLC( );
   172         id = map->AddL( iSqlDb, listOfMaps );
   176         id = map->AddL( iSqlDb, listOfMaps );
       
   177         iDataMapCache.Reset();
       
   178         map->FindL(KDataMap, iDataMapCache);
   173         iCallback->HandleChangeL( listOfMaps );
   179         iCallback->HandleChangeL( listOfMaps );
   174         CleanupStack::PopAndDestroy( listOfMaps ) ;
   180         CleanupStack::PopAndDestroy( listOfMaps ) ;
   175         }
   181         }
   176     else
   182     else
   177         {
   183         {