harvester/monitorplugins/mmcplugin/src/mmcmonitorplugin.cpp
changeset 40 910a23996aa0
parent 28 c461c7fa72c2
child 43 c5e73110f733
equal deleted inserted replaced
38:5210ffae7137 40:910a23996aa0
    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             TRAPD(err, iMountTask->StartMountL( *mountData ))
       
   258 			
       
   259             if(err != KErrNone )
       
   260                 {
       
   261                 delete mountData;
       
   262                 mountData = NULL;
       
   263                 }
   252             }
   264             }
   253         break;
   265         break;
   254         
   266         
   255         case EDismounted:
   267         case EDismounted:
   256             {
   268             {
   260             	}
   272             	}
   261             if( mountData->iMediaID )
   273             if( mountData->iMediaID )
   262             	{
   274             	{
   263 	            WRITELOG( "CMMCMonitorPlugin::MountEvent with parameter EDismounted" );
   275 	            WRITELOG( "CMMCMonitorPlugin::MountEvent with parameter EDismounted" );
   264 	            mountData->iMountType = TMountData::EUnmount;
   276 	            mountData->iMountType = TMountData::EUnmount;
   265 	            iMountTask->StartUnmount( *mountData );
   277 	            TRAPD(err, iMountTask->StartUnmountL( *mountData ));
       
   278 	            
       
   279 	            if(err != KErrNone )
       
   280 	                {
       
   281 	                delete mountData;
       
   282 	                mountData = NULL;
       
   283 	                }
   266             	}
   284             	}
   267             else
   285             else
   268                 {
   286                 {
   269                 delete mountData;
   287                 delete mountData;
   270                 mountData = NULL;
   288                 mountData = NULL;
   274         
   292         
   275         case EFormatted:
   293         case EFormatted:
   276             {
   294             {
   277             WRITELOG( "CMMCMonitorPlugin::MountEvent with parameter EFormatted" );
   295             WRITELOG( "CMMCMonitorPlugin::MountEvent with parameter EFormatted" );
   278             mountData->iMountType = TMountData::EFormat;
   296             mountData->iMountType = TMountData::EFormat;
   279             iMountTask->StartUnmount( *mountData );
   297             TRAPD(err, iMountTask->StartUnmountL( *mountData ));
       
   298 			
       
   299             if(err != KErrNone)
       
   300                 {
       
   301                 delete mountData;
       
   302                 mountData = NULL;
       
   303                 }
   280             }
   304             }
   281         break;
   305         break;
   282         
   306         
   283         default:
   307         default:
   284             {
   308             {