diff -r b73252188534 -r f23c07ec56e2 metadataengine/server/src/mdssqlobjectmanipulate.cpp --- a/metadataengine/server/src/mdssqlobjectmanipulate.cpp Thu Aug 19 10:20:41 2010 +0300 +++ b/metadataengine/server/src/mdssqlobjectmanipulate.cpp Tue Aug 31 15:37:30 2010 +0300 @@ -2271,8 +2271,8 @@ TPtrC16 uri = aBuffer.ReceivePtr16L(); objectId = SearchObjectByUriL( uri, flags ); if ( objectId != KNoId && - objectId != KSystemFavouritesAlbumId && - objectId != KSystemCapturedAlbumId ) + uri != KSystemFavouritesAlbumUri && + uri != KSystemCapturedAlbumUri ) { // unlock object, so update is no possible anymore if ( iLockList.IsLocked( *iNamespaceDef, objectId ) ) @@ -3431,7 +3431,13 @@ // rowDataDel, commonClauseOne CleanupStack::PopAndDestroy( 7, &commonClauseOne ); - // When this is reached, all garbage collection steps have been fully executed +#ifdef MDS_PLAYLIST_HARVESTING_ENABLED + if( updateResult == 0 ) + { + updateResult = CleanPlaylistsL(); + } +#endif + return EFalse; } @@ -3441,6 +3447,42 @@ db.DoAnalyzeL(); } +#ifdef MDS_PLAYLIST_HARVESTING_ENABLED +TInt CMdSSqlObjectManipulate::CleanPlaylistsL() + { + _LIT( KDeleteWholePlaylists, "DELETE FROM Object%u WHERE ObjectId IN (SELECT ObjectId FROM AudioPlaylistItem%u WHERE PlaylistID NOT IN (SELECT ObjectId FROM Object%u));" ); + + RClauseBuffer commonClauseOne(*this, KDeleteWholePlaylists().Length()); + CleanupClosePushL( commonClauseOne ); + CMdsClauseBuffer& buffer = commonClauseOne.BufferL(); + + RRowData rowDataDel; + CleanupClosePushL( rowDataDel ); + + const RPointerArray& namespaceDefs = + iSchema.NamespaceDefs(); + + CMdSSqLiteConnection& connection = MMdSDbConnectionPool::GetDefaultDBL(); + const TInt updateResult = 0; // once all files to be cleaned are handled, no need to continue + + const TInt count = namespaceDefs.Count(); + + for( TInt i = 0; i < count; ++i ) + { + const TDefId nmspId = namespaceDefs[i]->GetId(); + + buffer.BufferL().Format( KDeleteWholePlaylists, nmspId, nmspId, nmspId ); + User::LeaveIfError( connection.ExecuteL( + buffer.ConstBufferL(), rowDataDel ) ); + } + + // rowDataDel, commonClauseOne + CleanupStack::PopAndDestroy( 2, &commonClauseOne ); + + return updateResult; + } +#endif + CMdSSqlObjectManipulate::RClauseBuffer::RClauseBuffer( CMdSSqlObjectManipulate& aSOM, TInt aSize ) : iBuffers( aSOM.iBuffers ), iBuffer( NULL ), iNr( -1 ), iSize( aSize ) {