diff -r e78d6e055a5b -r b34d53f6acdf contentstorage/castorage/src/casqlitestorage.cpp --- a/contentstorage/castorage/src/casqlitestorage.cpp Fri Jul 23 14:03:00 2010 +0300 +++ b/contentstorage/castorage/src/casqlitestorage.cpp Fri Aug 06 13:40:46 2010 +0300 @@ -53,6 +53,9 @@ User::LeaveIfError( CreatePrivateDirPath( iPrivatePathCDrive, KCDrive, KNullDesC ) ); + User::LeaveIfError( CreatePrivateDirPath( iPrivatePathCDriveDbBackup, KCDrive, + KDbNameBackup ) ); + if( iSqlDb.Open( iPrivatePathCDriveDb, &KSqlDbConfig ) ) { @@ -108,6 +111,40 @@ } // --------------------------------------------------------------------------- +// +// +// --------------------------------------------------------------------------- +// +void CCaSqLiteStorage::SaveDatabaseL() + { + if( ( BaflUtils::FileExists( iRfs, iPrivatePathCDriveDb ) ) ) + { + iSqlDb.Close(); + User::LeaveIfError( BaflUtils::CopyFile( iRfs, + iPrivatePathCDriveDb, iPrivatePathCDriveDbBackup ) ); + User::LeaveIfError( iSqlDb.Open( iPrivatePathCDriveDb, + &KSqlDbConfig ) ); + } + } + +// --------------------------------------------------------------------------- +// +// +// --------------------------------------------------------------------------- +// +void CCaSqLiteStorage::RestoreDatabaseL() + { + if( ( BaflUtils::FileExists( iRfs, iPrivatePathCDriveDbBackup ) ) ) + { + iSqlDb.Close(); + User::LeaveIfError( BaflUtils::CopyFile( iRfs, + iPrivatePathCDriveDbBackup, iPrivatePathCDriveDb ) ); + User::LeaveIfError( iSqlDb.Open( iPrivatePathCDriveDb, + &KSqlDbConfig ) ); + } + } + +// --------------------------------------------------------------------------- // CCASqLiteStorage::NewL() // // --------------------------------------------------------------------------- @@ -214,7 +251,7 @@ void CCaSqLiteStorage::LocalizeEntryL( CCaLocalizationEntry& aLocalization ) { CCaSqlQuery* sqlLocalizeEntryQuery = CCaSqlQuery::NewLC( iSqlDb ); - if( aLocalization.GetAttributeName().Compare( KColumnEnText ) == 0 ) + if ( aLocalization.GetAttributeName().Compare( KColumnEnText ) == 0 ) { CaSqlQueryCreator::CreateLocalizationTableQueryL( sqlLocalizeEntryQuery, KSQLLocalizeTextEntry ); @@ -225,6 +262,16 @@ CaSqlQueryCreator::CreateLocalizationTableQueryL( sqlLocalizeEntryQuery, KSQLLocalizeDescriptionEntry ); } + else if ( aLocalization.GetAttributeName().Compare( KShortName ) == 0 ) + { + CaSqlQueryCreator::CreateLocalizationTableQueryL( sqlLocalizeEntryQuery, + KSQLLocalizeShortNameAttribute ); + } + else if ( aLocalization.GetAttributeName().Compare( KTitleName ) == 0 ) + { + CaSqlQueryCreator::CreateLocalizationTableQueryL( sqlLocalizeEntryQuery, + KSQLLocalizeTitleNameAttribute ); + } sqlLocalizeEntryQuery->PrepareL(); sqlLocalizeEntryQuery->BindValuesForLocalizeL( aLocalization ); sqlLocalizeEntryQuery->ExecuteL( ); @@ -410,10 +457,10 @@ // // --------------------------------------------------------------------------- // -void CCaSqLiteStorage::TouchL( const TInt aEntryId ) +void CCaSqLiteStorage::TouchL( const TInt aEntryId, TBool aRemovable ) { ExecuteStatementL( KSqlStatementBegin ); - TRAPD( err, ExecuteTouchL( aEntryId ) ); + TRAPD( err, ExecuteTouchL( aEntryId, aRemovable ) ); if( err ) { ExecuteStatementL( KSqlStatementRollback ); @@ -483,14 +530,43 @@ void CCaSqLiteStorage::CustomSortL( const RArray& aEntryIds, const TInt aGroupId ) { + RArray entryIds; + CleanupClosePushL( entryIds ); + for( TInt j=0; j oldIds; + CleanupClosePushL( oldIds ); + CCaInnerQuery* innerQuery = CCaInnerQuery::NewLC(); + innerQuery->SetParentId( aGroupId ); + + GetEntriesIdsL( innerQuery, oldIds ); + + if( oldIds.Count() != entryIds.Count() ) + { + for( TInt i=0; i constEntryIds( entryIds ); + RPointerArray sqlQueries; - CleanupResetAndDestroyPushL( sqlQueries ); + CleanupResetAndDestroyPushL( sqlQueries ); CaSqlQueryCreator::CreateCustomSortQueryL( - aEntryIds, sqlQueries, iSqlDb ); + constEntryIds, sqlQueries, iSqlDb ); ExecuteStatementL( KSqlStatementBegin ); - TRAPD( err, ExecuteCustomSortL( aEntryIds, aGroupId, sqlQueries ) ); + TRAPD( err, ExecuteCustomSortL( constEntryIds, aGroupId, sqlQueries ) ); if( err ) { ExecuteStatementL( KSqlStatementRollback ); @@ -499,6 +575,9 @@ ExecuteStatementL( KSqlStatementCommit ); CleanupStack::PopAndDestroy( &sqlQueries ); + CleanupStack::PopAndDestroy( innerQuery ); + CleanupStack::PopAndDestroy( &oldIds ); + CleanupStack::PopAndDestroy( &entryIds ); } // --------------------------------------------------------------------------- @@ -748,12 +827,12 @@ // // --------------------------------------------------------------------------- // -void CCaSqLiteStorage::ExecuteTouchL( const TInt aEntryId ) +void CCaSqLiteStorage::ExecuteTouchL( const TInt aEntryId, TBool aRemovable ) { RPointerArray sqlQuery; CleanupResetAndDestroyPushL( sqlQuery ); - CaSqlQueryCreator::CreateTouchQueryL( sqlQuery, iSqlDb ); + CaSqlQueryCreator::CreateTouchQueryL( sqlQuery, iSqlDb, aRemovable ); TTime time; time.UniversalTime();