mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbhandler.cpp
changeset 22 ecf06a08d4d9
parent 19 4e84c994a771
child 25 3ec52facab4d
--- a/mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbhandler.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpserviceplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbhandler.cpp	Mon May 03 12:29:20 2010 +0300
@@ -795,7 +795,7 @@
     iDbManager->OpenDatabaseL(aDrive);
 
     // Verify the volume ID after a remount event
-    VerifyVolumeIdL();
+    VerifyVolumeIdL( aDrive );
     }
 
 // ----------------------------------------------------------------------------
@@ -1425,52 +1425,64 @@
 // Verifies that the volume ID of the database matches the drive
 // ----------------------------------------------------------------------------
 //
+void CMPXPodcastDbHandler::VerifyVolumeIdL( TInt aDrive )
+    {
+    MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL <--");
+
+    if( iDbManager->IsOpen(aDrive) )
+        {
+        TVolumeInfo volInfo;
+        iFs.Volume(volInfo, aDrive );
+        TUint curId(volInfo.iUniqueID);
+
+        TInt volId = iDbAuxiliary->IdL( aDrive );
+
+        // New database, no volume id set, mask out top bit because this is an uint
+        //
+        MPX_DEBUG3("CMPXPodcastDbHandler::VerifyVolumeIdL drive:%i db:%i", curId, volId);
+        if( volId == 0 && (curId&0x7FFFFFFF) )
+            {
+            MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- New ID");
+            BeginTransactionL();
+            TRAPD( err, iDbAuxiliary->SetIdL( aDrive, curId&0x7FFFFFFF ) );
+            EndTransactionL( err );
+
+            // KSqlDbCorrupted indicates DB corrupted, need to recreate.
+            if ( err == KSqlDbCorrupted )
+                {
+                MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- Corrupted DB");
+                iDbManager->RecreateDatabaseL( aDrive );
+                BeginTransactionL();
+                TRAPD( err, iDbAuxiliary->SetDBCorruptedL( ETrue ) );
+                EndTransactionL( err );
+                }
+            }
+        // Unmatched volume id, mark db as corrupt
+        //
+        else if ( (curId&0x7FFFFFFF) != (volId&0x7FFFFFFFF) )
+            {
+            MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- ID match FAILED");
+            iDbManager->RecreateDatabaseL( aDrive );
+            BeginTransactionL();
+            TRAPD( err, iDbAuxiliary->SetDBCorruptedL( ETrue ) );
+            EndTransactionL( err );
+            }
+        }
+    MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -->");
+    }
+
+
+// ----------------------------------------------------------------------------
+// Verifies that the volume ID of the database matches the drive
+// ----------------------------------------------------------------------------
+//
 void CMPXPodcastDbHandler::VerifyVolumeIdL()
     {
     MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL <--");
-
     TInt count( iDbDrives.Count() );
     for( TInt i=0; i<count; ++i )
         {
-        if( iDbManager->IsOpen(iDbDrives[i]) )
-            {
-            TVolumeInfo volInfo;
-            iFs.Volume(volInfo, iDbDrives[i] );
-            TUint curId(volInfo.iUniqueID);
-
-            TInt volId = iDbAuxiliary->IdL( iDbDrives[i] );
-
-            // New database, no volume id set, mask out top bit because this is an uint
-            //
-            MPX_DEBUG3("CMPXPodcastDbHandler::VerifyVolumeIdL drive:%i db:%i", curId, volId);
-            if( volId == 0 )
-                {
-                MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- New ID");
-                BeginTransactionL();
-                TRAPD( err, iDbAuxiliary->SetIdL( iDbDrives[i], curId&0x7FFFFFFF ) );
-                EndTransactionL( err );
-
-                // KSqlDbCorrupted indicates DB corrupted, need to recreate.
-                if ( err == KSqlDbCorrupted )
-                    {
-                    MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- Corrupted DB");
-                    iDbManager->RecreateDatabaseL(iDbDrives[i]);
-                    BeginTransactionL();
-                    TRAPD(err, iDbAuxiliary->SetDBCorruptedL( ETrue ) );
-                    EndTransactionL( err );
-                    }
-                }
-            // Unmatched volume id, mark db as corrupt
-            //
-            else if ( (curId&0x7FFFFFFF) != (volId&0x7FFFFFFFF) )
-                {
-                MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- ID match FAILED");
-                iDbManager->RecreateDatabaseL(iDbDrives[i]);
-                BeginTransactionL();
-                TRAPD(err, iDbAuxiliary->SetDBCorruptedL( ETrue ) );
-                EndTransactionL( err );
-                }
-            }
+        VerifyVolumeIdL(iDbDrives[i]);
         }
     MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -->");
     }