contentstorage/castorage/src/casqlitestorage.cpp
changeset 61 8e5041d13c84
parent 60 f62f87b200ec
child 66 32469d7d46ff
--- a/contentstorage/castorage/src/casqlitestorage.cpp	Fri Mar 19 09:35:23 2010 +0200
+++ b/contentstorage/castorage/src/casqlitestorage.cpp	Fri Apr 16 15:16:09 2010 +0300
@@ -23,6 +23,8 @@
 #include "cainnerquery.h"
 #include "caarraycleanup.inl"
 #include "calocalizationentry.h"
+#include "cainternaltypes.h"
+#include "cadef.h"
 
 // ---------------------------------------------------------------------------
 // CCASqLiteStorage::CCpStorageEngine()
@@ -50,12 +52,25 @@
 
     User::LeaveIfError( CreatePrivateDirPath( iPrivatePathCDrive, KCDrive,
             KNullDesC ) );
+    
 
     if( iSqlDb.Open( iPrivatePathCDriveDb, &KSqlDbConfig ) )
         {
         //we could not load data base from C-drive lets try Rom
         LoadDataBaseFromRomL();
         }
+    else
+        {
+        TBuf<KCaMaxAttrNameLen> versionValue;
+        DbPropertyL(KCaDbPropVersion, versionValue);
+        ASSERT(versionValue.Length()>0);
+        if( versionValue.CompareC( KCaDbVersion ) )
+            {
+            // database loaded from C: is obsolete, load from Z:
+            iSqlDb.Close();
+            LoadDataBaseFromRomL();
+            }
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -74,7 +89,7 @@
 
     if( !( BaflUtils::FileExists( iRfs, iPrivatePathZDriveDb ) ) )
         {
-        User::Panic( _L("fatal error - castoragedb not exists in ROM"),
+        User::Panic( _L("fatal error - castorage.db not exists in ROM"),
                 KErrNotFound );
         }
     else
@@ -184,6 +199,7 @@
                 CCaSqlQuery::EAttribute );
         CleanupStack::PopAndDestroy( sqlGetAttributesQuery );
         }
+    
     //  set entries if proper order if they were fetched by ids
     if( aQuery->GetIds().Count() > 0 )
         {
@@ -229,6 +245,7 @@
     sqlGetEntriesIdsQuery->ExecuteL( aResultIdArray,
             CCaSqlQuery::EEntryTable );
     CleanupStack::PopAndDestroy( sqlGetEntriesIdsQuery );
+
     }
 
 // ---------------------------------------------------------------------------
@@ -799,7 +816,6 @@
         case TCaOperationParams::EAppend:
         default:
             {
-            //            TODO: do nothing when default
             break;
             }
         }