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