harvester/monitorplugins/mmcplugin/src/mmcmonitorplugin.cpp
branchRCL_3
changeset 53 29d87345eaeb
parent 50 85f623e1ef41
child 63 e538444823de
equal deleted inserted replaced
50:85f623e1ef41 53:29d87345eaeb
   114     
   114     
   115     TChar driveLetter( 0 );
   115     TChar driveLetter( 0 );
   116 	TBool presentState( EFalse );
   116 	TBool presentState( EFalse );
   117     
   117     
   118 	TUint32 hdMediaId( 0 );
   118 	TUint32 hdMediaId( 0 );
   119     hdMediaId = iMountTask->GetInternalDriveMediaId();
   119 	TBool hdPresent( EFalse );
       
   120     hdMediaId = iMountTask->GetInternalDriveMediaId( hdPresent );
   120     
   121     
   121     for( TInt i = medias.Count() - 1; i >=0; i-- )
   122     for( TInt i = medias.Count() - 1; i >=0; i-- )
   122     	{
   123     	{
   123     	TRAP_IGNORE( iMdEClient->GetMediaL( medias[i].iMediaId, driveLetter, presentState ) );
   124     	TRAP_IGNORE( iMdEClient->GetMediaL( medias[i].iMediaId, driveLetter, presentState ) );
   124     	
   125     	
   135     		TRAP_IGNORE( iMmcScanner = CMmcScannerAO::NewL( medias[i].iMediaId, iMdEClient, iObserver,
   136     		TRAP_IGNORE( iMmcScanner = CMmcScannerAO::NewL( medias[i].iMediaId, iMdEClient, iObserver,
   136     		    				aHarvesterPluginFactory, CActive::EPriorityUserInput ) );
   137     		    				aHarvesterPluginFactory, CActive::EPriorityUserInput ) );
   137     		}
   138     		}
   138     	}
   139     	}
   139  
   140  
   140     if( hdMediaId == 0 )
   141     if( hdMediaId == 0 || !hdPresent )
   141         {
   142         {
   142         // Try to fetch internall mass storage media id again if it was not mounted
   143         // Try to fetch internall mass storage media id again if it was not mounted
   143         hdMediaId = iMountTask->GetInternalDriveMediaId();
   144         hdMediaId = iMountTask->GetInternalDriveMediaId( hdPresent );
   144         }
   145         }
   145     
   146     
   146     // scan mass storage to catch all chances even if battery dies during operation that should  be catched
   147     // scan mass storage to catch all chances even if battery dies during operation that should  be catched
   147     if( hdMediaId )
   148     if( hdMediaId )
   148 		{
   149 		{
   149 		TBool exists( EFalse );
   150 		TBool exists( EFalse );
   150 		TRAP_IGNORE( exists= iMdEClient->GetMediaL( hdMediaId, driveLetter, presentState ) );
   151 		TRAP_IGNORE( exists= iMdEClient->GetMediaL( hdMediaId, driveLetter, presentState ) );
   151 		
   152 		
   152 		if ( exists )
   153 		if ( exists && hdPresent )
   153 			{
   154 			{
   154 			WRITELOG("CMMCMonitorPlugin::StartMonitoring - start mass storage scan");
   155 			WRITELOG("CMMCMonitorPlugin::StartMonitoring - start mass storage scan");
   155 			
   156 			
   156 			TMdEMediaInfo hdInfo;
   157 			TMdEMediaInfo hdInfo;
   157 			hdInfo.iMediaId = hdMediaId;
   158 			hdInfo.iMediaId = hdMediaId;
   265                 TVolumeInfo internalMassStorageVolumeInfo;
   266                 TVolumeInfo internalMassStorageVolumeInfo;
   266                 internalMassStorageError = iFs.Volume( internalMassStorageVolumeInfo, drive );
   267                 internalMassStorageError = iFs.Volume( internalMassStorageVolumeInfo, drive );
   267                 if( internalMassStorageError == KErrNone )
   268                 if( internalMassStorageError == KErrNone )
   268                     {
   269                     {
   269                     const TUint32 massStorageMediaId( internalMassStorageVolumeInfo.iUniqueID );
   270                     const TUint32 massStorageMediaId( internalMassStorageVolumeInfo.iUniqueID );
   270                     TUint32 mmcMediaId( 0 );
   271                     if( massStorageMediaId == aMediaID &&
   271                     TInt mmcError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, drive ) );
   272                         massStorageMediaId != 0 )
   272                     if( mmcError == KErrNone )
       
   273                         {
   273                         {
   274                         TVolumeInfo mmcVolumeInfo;
   274                         TUint32 mmcMediaId( 0 );
   275                         mmcError = iFs.Volume( mmcVolumeInfo, drive );
   275                         TInt mmcDrive( -1 );
       
   276                         TInt mmcError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, mmcDrive ) );
   276                         if( mmcError == KErrNone )
   277                         if( mmcError == KErrNone )
   277                             {
   278                             {
   278                             mmcMediaId = mmcVolumeInfo.iUniqueID;
   279                             if( drive != mmcDrive )
       
   280                                 {
       
   281                                 TVolumeInfo mmcVolumeInfo;
       
   282                                 mmcError = iFs.Volume( mmcVolumeInfo, mmcDrive );
       
   283                                 if( mmcError == KErrNone )
       
   284                                     {
       
   285                                     mmcMediaId = mmcVolumeInfo.iUniqueID;
       
   286                                     }                        
       
   287                                 }
       
   288                             else
       
   289                                 {
       
   290                                 mmcMediaId = massStorageMediaId;
       
   291                                 }
   279                             }
   292                             }
   280                         }
       
   281                     
   293                     
   282                     // If removable storage is not found, assume internal mass storage was mounted
   294                         // If removable storage is not found, assume internal mass storage was mounted
   283                     if( mmcError )
   295                         if( mmcError )
   284                         {
   296                             {
   285                         if( massStorageMediaId != 0 && 
   297                             iMdEClient->CheckMassStorageMediaId( massStorageMediaId );              
   286                             massStorageMediaId == aMediaID )
   298                             }
       
   299                         else if( massStorageMediaId != mmcMediaId )
   287                             {
   300                             {
   288                             iMdEClient->CheckMassStorageMediaId( massStorageMediaId );
   301                             iMdEClient->CheckMassStorageMediaId( massStorageMediaId );
   289                             }                    
   302                             }          
   290                         }
   303                         }                    
   291                     else if( massStorageMediaId != mmcMediaId && 
       
   292                                 massStorageMediaId != 0 && 
       
   293                                 massStorageMediaId == aMediaID )
       
   294                         {
       
   295                         iMdEClient->CheckMassStorageMediaId( massStorageMediaId );
       
   296                         }          
       
   297                     }
   304                     }
   298                 }
   305                 }
   299             
   306             
   300             TRAPD(err, iMountTask->StartMountL( *mountData ))
   307             TRAPD(err, iMountTask->StartMountL( *mountData ))
   301 			
   308