harvester/monitorplugins/mmcplugin/src/mmcmonitorplugin.cpp
branchRCL_3
changeset 22 29d87345eaeb
parent 21 85f623e1ef41
--- a/harvester/monitorplugins/mmcplugin/src/mmcmonitorplugin.cpp	Wed Sep 01 12:24:24 2010 +0100
+++ b/harvester/monitorplugins/mmcplugin/src/mmcmonitorplugin.cpp	Tue Sep 14 22:10:25 2010 +0300
@@ -116,7 +116,8 @@
 	TBool presentState( EFalse );
     
 	TUint32 hdMediaId( 0 );
-    hdMediaId = iMountTask->GetInternalDriveMediaId();
+	TBool hdPresent( EFalse );
+    hdMediaId = iMountTask->GetInternalDriveMediaId( hdPresent );
     
     for( TInt i = medias.Count() - 1; i >=0; i-- )
     	{
@@ -137,10 +138,10 @@
     		}
     	}
  
-    if( hdMediaId == 0 )
+    if( hdMediaId == 0 || !hdPresent )
         {
         // Try to fetch internall mass storage media id again if it was not mounted
-        hdMediaId = iMountTask->GetInternalDriveMediaId();
+        hdMediaId = iMountTask->GetInternalDriveMediaId( hdPresent );
         }
     
     // scan mass storage to catch all chances even if battery dies during operation that should  be catched
@@ -149,7 +150,7 @@
 		TBool exists( EFalse );
 		TRAP_IGNORE( exists= iMdEClient->GetMediaL( hdMediaId, driveLetter, presentState ) );
 		
-		if ( exists )
+		if ( exists && hdPresent )
 			{
 			WRITELOG("CMMCMonitorPlugin::StartMonitoring - start mass storage scan");
 			
@@ -267,33 +268,39 @@
                 if( internalMassStorageError == KErrNone )
                     {
                     const TUint32 massStorageMediaId( internalMassStorageVolumeInfo.iUniqueID );
-                    TUint32 mmcMediaId( 0 );
-                    TInt mmcError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, drive ) );
-                    if( mmcError == KErrNone )
+                    if( massStorageMediaId == aMediaID &&
+                        massStorageMediaId != 0 )
                         {
-                        TVolumeInfo mmcVolumeInfo;
-                        mmcError = iFs.Volume( mmcVolumeInfo, drive );
+                        TUint32 mmcMediaId( 0 );
+                        TInt mmcDrive( -1 );
+                        TInt mmcError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, mmcDrive ) );
                         if( mmcError == KErrNone )
                             {
-                            mmcMediaId = mmcVolumeInfo.iUniqueID;
+                            if( drive != mmcDrive )
+                                {
+                                TVolumeInfo mmcVolumeInfo;
+                                mmcError = iFs.Volume( mmcVolumeInfo, mmcDrive );
+                                if( mmcError == KErrNone )
+                                    {
+                                    mmcMediaId = mmcVolumeInfo.iUniqueID;
+                                    }                        
+                                }
+                            else
+                                {
+                                mmcMediaId = massStorageMediaId;
+                                }
                             }
-                        }
                     
-                    // If removable storage is not found, assume internal mass storage was mounted
-                    if( mmcError )
-                        {
-                        if( massStorageMediaId != 0 && 
-                            massStorageMediaId == aMediaID )
+                        // If removable storage is not found, assume internal mass storage was mounted
+                        if( mmcError )
+                            {
+                            iMdEClient->CheckMassStorageMediaId( massStorageMediaId );              
+                            }
+                        else if( massStorageMediaId != mmcMediaId )
                             {
                             iMdEClient->CheckMassStorageMediaId( massStorageMediaId );
-                            }                    
-                        }
-                    else if( massStorageMediaId != mmcMediaId && 
-                                massStorageMediaId != 0 && 
-                                massStorageMediaId == aMediaID )
-                        {
-                        iMdEClient->CheckMassStorageMediaId( massStorageMediaId );
-                        }          
+                            }          
+                        }                    
                     }
                 }