contentstorage/castorage/src/casqlitestorage.cpp
changeset 61 8e5041d13c84
parent 60 f62f87b200ec
child 66 32469d7d46ff
equal deleted inserted replaced
60:f62f87b200ec 61:8e5041d13c84
    21 #include "casqlquerycreator.h"
    21 #include "casqlquerycreator.h"
    22 #include "cainnerentry.h"
    22 #include "cainnerentry.h"
    23 #include "cainnerquery.h"
    23 #include "cainnerquery.h"
    24 #include "caarraycleanup.inl"
    24 #include "caarraycleanup.inl"
    25 #include "calocalizationentry.h"
    25 #include "calocalizationentry.h"
       
    26 #include "cainternaltypes.h"
       
    27 #include "cadef.h"
    26 
    28 
    27 // ---------------------------------------------------------------------------
    29 // ---------------------------------------------------------------------------
    28 // CCASqLiteStorage::CCpStorageEngine()
    30 // CCASqLiteStorage::CCpStorageEngine()
    29 //
    31 //
    30 // ---------------------------------------------------------------------------
    32 // ---------------------------------------------------------------------------
    48     User::LeaveIfError( CreatePrivateDirPath( iPrivatePathZDriveDb, KZDrive,
    50     User::LeaveIfError( CreatePrivateDirPath( iPrivatePathZDriveDb, KZDrive,
    49             KDbName ) );
    51             KDbName ) );
    50 
    52 
    51     User::LeaveIfError( CreatePrivateDirPath( iPrivatePathCDrive, KCDrive,
    53     User::LeaveIfError( CreatePrivateDirPath( iPrivatePathCDrive, KCDrive,
    52             KNullDesC ) );
    54             KNullDesC ) );
       
    55     
    53 
    56 
    54     if( iSqlDb.Open( iPrivatePathCDriveDb, &KSqlDbConfig ) )
    57     if( iSqlDb.Open( iPrivatePathCDriveDb, &KSqlDbConfig ) )
    55         {
    58         {
    56         //we could not load data base from C-drive lets try Rom
    59         //we could not load data base from C-drive lets try Rom
    57         LoadDataBaseFromRomL();
    60         LoadDataBaseFromRomL();
       
    61         }
       
    62     else
       
    63         {
       
    64         TBuf<KCaMaxAttrNameLen> versionValue;
       
    65         DbPropertyL(KCaDbPropVersion, versionValue);
       
    66         ASSERT(versionValue.Length()>0);
       
    67         if( versionValue.CompareC( KCaDbVersion ) )
       
    68             {
       
    69             // database loaded from C: is obsolete, load from Z:
       
    70             iSqlDb.Close();
       
    71             LoadDataBaseFromRomL();
       
    72             }
    58         }
    73         }
    59     }
    74     }
    60 
    75 
    61 // ---------------------------------------------------------------------------
    76 // ---------------------------------------------------------------------------
    62 // CCASqLiteStorage::NewL()
    77 // CCASqLiteStorage::NewL()
    72                 iPrivatePathCDriveDb ) );
    87                 iPrivatePathCDriveDb ) );
    73         }
    88         }
    74 
    89 
    75     if( !( BaflUtils::FileExists( iRfs, iPrivatePathZDriveDb ) ) )
    90     if( !( BaflUtils::FileExists( iRfs, iPrivatePathZDriveDb ) ) )
    76         {
    91         {
    77         User::Panic( _L("fatal error - castoragedb not exists in ROM"),
    92         User::Panic( _L("fatal error - castorage.db not exists in ROM"),
    78                 KErrNotFound );
    93                 KErrNotFound );
    79         }
    94         }
    80     else
    95     else
    81         {
    96         {
    82         if( !( BaflUtils::FolderExists( iRfs, iPrivatePathCDrive ) ) )
    97         if( !( BaflUtils::FolderExists( iRfs, iPrivatePathCDrive ) ) )
   182         sqlGetAttributesQuery->BindEntryIdsL( aResultContainer );
   197         sqlGetAttributesQuery->BindEntryIdsL( aResultContainer );
   183         sqlGetAttributesQuery->ExecuteL( aResultContainer,
   198         sqlGetAttributesQuery->ExecuteL( aResultContainer,
   184                 CCaSqlQuery::EAttribute );
   199                 CCaSqlQuery::EAttribute );
   185         CleanupStack::PopAndDestroy( sqlGetAttributesQuery );
   200         CleanupStack::PopAndDestroy( sqlGetAttributesQuery );
   186         }
   201         }
       
   202     
   187     //  set entries if proper order if they were fetched by ids
   203     //  set entries if proper order if they were fetched by ids
   188     if( aQuery->GetIds().Count() > 0 )
   204     if( aQuery->GetIds().Count() > 0 )
   189         {
   205         {
   190         SetEntriesInProperOrderL( aQuery->GetIds(), aResultContainer );
   206         SetEntriesInProperOrderL( aQuery->GetIds(), aResultContainer );
   191         }
   207         }
   227     sqlGetEntriesIdsQuery->PrepareL();
   243     sqlGetEntriesIdsQuery->PrepareL();
   228     sqlGetEntriesIdsQuery->BindValuesForGetEntriesL( aQuery );
   244     sqlGetEntriesIdsQuery->BindValuesForGetEntriesL( aQuery );
   229     sqlGetEntriesIdsQuery->ExecuteL( aResultIdArray,
   245     sqlGetEntriesIdsQuery->ExecuteL( aResultIdArray,
   230             CCaSqlQuery::EEntryTable );
   246             CCaSqlQuery::EEntryTable );
   231     CleanupStack::PopAndDestroy( sqlGetEntriesIdsQuery );
   247     CleanupStack::PopAndDestroy( sqlGetEntriesIdsQuery );
       
   248 
   232     }
   249     }
   233 
   250 
   234 // ---------------------------------------------------------------------------
   251 // ---------------------------------------------------------------------------
   235 // CCASqLiteStorage::GetEntriesIdsL
   252 // CCASqLiteStorage::GetEntriesIdsL
   236 //
   253 //
   797             }
   814             }
   798         case TCaOperationParams::EPrepend:
   815         case TCaOperationParams::EPrepend:
   799         case TCaOperationParams::EAppend:
   816         case TCaOperationParams::EAppend:
   800         default:
   817         default:
   801             {
   818             {
   802             //            TODO: do nothing when default
       
   803             break;
   819             break;
   804             }
   820             }
   805         }
   821         }
   806     }
   822     }
   807 
   823