harvester/monitorplugins/mmcplugin/src/mmcmonitorplugin.cpp
branchRCL_3
changeset 47 b73252188534
parent 27 4a4892eec172
child 49 f23c07ec56e2
equal deleted inserted replaced
46:63c982fb92f2 47:b73252188534
    58     
    58     
    59     if (iMMCMonitor)
    59     if (iMMCMonitor)
    60     	{
    60     	{
    61     	iMMCMonitor->StopMonitoring();
    61     	iMMCMonitor->StopMonitoring();
    62     	delete iMMCMonitor;
    62     	delete iMMCMonitor;
       
    63     	iMMCMonitor = NULL;
    63     	}
    64     	}
    64     
    65     
    65 	if (iUsbMonitor)
    66 	if (iUsbMonitor)
    66     	{
    67     	{
    67     	iUsbMonitor->StopMonitoring();
    68     	iUsbMonitor->StopMonitoring();
    68     	delete iUsbMonitor;
    69     	delete iUsbMonitor;
       
    70     	iUsbMonitor = NULL;
    69     	}
    71     	}
    70     
    72     
    71 	if (iMountTask)
    73 	if (iMountTask)
    72     	{
    74     	{
    73     	delete iMountTask;
    75     	delete iMountTask;
       
    76     	iMountTask = NULL;
    74     	}
    77     	}
    75 	
    78 	
    76 	delete iMmcScanner;
    79 	delete iMmcScanner;
       
    80 	iMmcScanner = NULL;
    77 	delete iHddScanner;
    81 	delete iHddScanner;
       
    82 	iHddScanner = NULL;
    78 	
    83 	
    79 	iFs.Close();
    84 	iFs.Close();
    80     }
    85     }
    81 
    86 
    82 TBool CMMCMonitorPlugin::StartMonitoring( MMonitorPluginObserver& aObserver,
    87 TBool CMMCMonitorPlugin::StartMonitoring( MMonitorPluginObserver& aObserver,
   217     {
   222     {
   218     WRITELOG( "CMMCMonitorPlugin::MountEvent" );
   223     WRITELOG( "CMMCMonitorPlugin::MountEvent" );
   219 
   224 
   220     TMountData* mountData = NULL;
   225     TMountData* mountData = NULL;
   221     mountData = new TMountData;
   226     mountData = new TMountData;
       
   227     
   222     if ( !mountData )
   228     if ( !mountData )
   223         {
   229         {
   224         return;
   230         return;
   225         }
   231         }
   226     if( aMediaID != 0 && aEventType == EMounted)
   232     if( aMediaID != 0 && aEventType == EMounted)
   246         {
   252         {
   247         case EMounted:
   253         case EMounted:
   248             {
   254             {
   249             WRITELOG( "CMMCMonitorPlugin::MountEvent with parameter EMounted" );
   255             WRITELOG( "CMMCMonitorPlugin::MountEvent with parameter EMounted" );
   250             mountData->iMountType = TMountData::EMount;
   256             mountData->iMountType = TMountData::EMount;
   251             iMountTask->StartMount( *mountData );
   257             
       
   258             // If mass storage mounting was delayed in boot so that mount event
       
   259             // occures in mmc monitor, update the mass storage media id in the
       
   260             // db in case factory settings were reseted and mass storage formatted
       
   261             TInt drive( -1 );
       
   262             TInt internalMassStorageError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, drive ) );
       
   263             if( internalMassStorageError == KErrNone )
       
   264                 {
       
   265                 TVolumeInfo internalMassStorageVolumeInfo;
       
   266                 internalMassStorageError = iFs.Volume( internalMassStorageVolumeInfo, drive );
       
   267                 if( internalMassStorageError == KErrNone )
       
   268                     {
       
   269                     const TUint32 massStorageMediaId( internalMassStorageVolumeInfo.iUniqueID );
       
   270                     TUint32 mmcMediaId( 0 );
       
   271                     TInt mmcError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, drive ) );
       
   272                     if( mmcError == KErrNone )
       
   273                         {
       
   274                         TVolumeInfo mmcVolumeInfo;
       
   275                         mmcError = iFs.Volume( mmcVolumeInfo, drive );
       
   276                         if( mmcError == KErrNone )
       
   277                             {
       
   278                             mmcMediaId = mmcVolumeInfo.iUniqueID;
       
   279                             }
       
   280                         }
       
   281                     
       
   282                     // If removable storage is not found, assume internal mass storage was mounted
       
   283                     if( mmcError )
       
   284                         {
       
   285                         if( massStorageMediaId != 0 && 
       
   286                             massStorageMediaId == aMediaID )
       
   287                             {
       
   288                             iMdEClient->CheckMassStorageMediaId( massStorageMediaId );
       
   289                             }                    
       
   290                         }
       
   291                     else if( massStorageMediaId != mmcMediaId && 
       
   292                                 massStorageMediaId != 0 && 
       
   293                                 massStorageMediaId == aMediaID )
       
   294                         {
       
   295                         iMdEClient->CheckMassStorageMediaId( massStorageMediaId );
       
   296                         }          
       
   297                     }
       
   298                 }
       
   299             
       
   300             TRAPD(err, iMountTask->StartMountL( *mountData ))
       
   301 			
       
   302             if(err != KErrNone )
       
   303                 {
       
   304                 delete mountData;
       
   305                 mountData = NULL;
       
   306                 }
   252             }
   307             }
   253         break;
   308         break;
   254         
   309         
   255         case EDismounted:
   310         case EDismounted:
   256             {
   311             {
   260             	}
   315             	}
   261             if( mountData->iMediaID )
   316             if( mountData->iMediaID )
   262             	{
   317             	{
   263 	            WRITELOG( "CMMCMonitorPlugin::MountEvent with parameter EDismounted" );
   318 	            WRITELOG( "CMMCMonitorPlugin::MountEvent with parameter EDismounted" );
   264 	            mountData->iMountType = TMountData::EUnmount;
   319 	            mountData->iMountType = TMountData::EUnmount;
   265 	            iMountTask->StartUnmount( *mountData );
   320 	            TRAPD(err, iMountTask->StartUnmountL( *mountData ));
       
   321 	            
       
   322 	            if(err != KErrNone )
       
   323 	                {
       
   324 	                delete mountData;
       
   325 	                mountData = NULL;
       
   326 	                }
   266             	}
   327             	}
   267             else
   328             else
   268                 {
   329                 {
   269                 delete mountData;
   330                 delete mountData;
   270                 mountData = NULL;
   331                 mountData = NULL;
   274         
   335         
   275         case EFormatted:
   336         case EFormatted:
   276             {
   337             {
   277             WRITELOG( "CMMCMonitorPlugin::MountEvent with parameter EFormatted" );
   338             WRITELOG( "CMMCMonitorPlugin::MountEvent with parameter EFormatted" );
   278             mountData->iMountType = TMountData::EFormat;
   339             mountData->iMountType = TMountData::EFormat;
   279             iMountTask->StartUnmount( *mountData );
   340             TRAPD(err, iMountTask->StartUnmountL( *mountData ));
       
   341 			
       
   342             if(err != KErrNone)
       
   343                 {
       
   344                 delete mountData;
       
   345                 mountData = NULL;
       
   346                 }
   280             }
   347             }
   281         break;
   348         break;
   282         
   349         
   283         default:
   350         default:
   284             {
   351             {