harvester/monitorplugins/mmcplugin/src/mmcmounttaskao.cpp
changeset 45 a93990e5815e
parent 21 50bf9db68373
child 48 1389872e7c51
equal deleted inserted replaced
36:aa5a574040a4 45:a93990e5815e
    77 	iEntryArray.Close();
    77 	iEntryArray.Close();
    78 	iHarvestEntryArray.ResetAndDestroy();
    78 	iHarvestEntryArray.ResetAndDestroy();
    79 	iHarvestEntryArray.Close();
    79 	iHarvestEntryArray.Close();
    80 	
    80 	
    81 	delete iMdeSession;
    81 	delete iMdeSession;
       
    82 	iMdeSession = NULL;
    82   
    83   
    83 	Deinitialize();
    84 	Deinitialize();
    84 	
    85 	
    85 	if (iHEM)
    86 	if (iHEM)
    86 		{
    87 		{
    87 		iHEM->ReleaseInstance();
    88 		iHEM->ReleaseInstance();
    88 		}
    89 		}
    89 	
    90 	
    90 	delete iMmcFileList;
    91 	delete iMmcFileList;
       
    92 	iMmcFileList = NULL;
    91 	iHdArray.ResetAndDestroy();
    93 	iHdArray.ResetAndDestroy();
    92 	iHdArray.Close();
    94 	iHdArray.Close();
    93 	}
    95 	}
    94 	
    96 	
    95 void CMMCMountTaskAO::SetMonitorObserver( MMonitorPluginObserver& aObserver )
    97 void CMMCMountTaskAO::SetMonitorObserver( MMonitorPluginObserver& aObserver )
   106 void CMMCMountTaskAO::SetHarvesterPluginFactory( CHarvesterPluginFactory* aPluginFactory )
   108 void CMMCMountTaskAO::SetHarvesterPluginFactory( CHarvesterPluginFactory* aPluginFactory )
   107 	{
   109 	{
   108 	iHarvesterPluginFactory = aPluginFactory;
   110 	iHarvesterPluginFactory = aPluginFactory;
   109 	}
   111 	}
   110 	
   112 	
   111 void CMMCMountTaskAO::StartMount( TMountData& aMountData )
   113 void CMMCMountTaskAO::StartMountL( TMountData& aMountData )
   112 	{
   114 	{
   113 	WRITELOG("CMMCMountTaskAO::StartMount");
   115 	WRITELOG("CMMCMountTaskAO::StartMount");
   114 	iMountDataQueue.Append( &aMountData );
   116 	
       
   117 	User::LeaveIfError( iMountDataQueue.Append( &aMountData ));
       
   118 	
   115 	if ( iNextRequest == ERequestIdle )
   119 	if ( iNextRequest == ERequestIdle )
   116 		{
   120 		{
   117 		SetNextRequest( ERequestStartTask );
   121 		SetNextRequest( ERequestStartTask );
   118 		}
   122 		}
   119 	}
   123 	}
   120 	
   124 	
   121 void CMMCMountTaskAO::StartUnmount(TMountData& aMountData)
   125 void CMMCMountTaskAO::StartUnmountL(TMountData& aMountData)
   122 	{
   126 	{
   123 	WRITELOG("CMMCMountTaskAO::StartUnmount");
   127 	WRITELOG("CMMCMountTaskAO::StartUnmount");
   124 	
   128 	
   125 	// make sure that drive is not currently mounting
   129 	// make sure that drive is not currently mounting
   126 	if ( iMountData )
   130 	if ( iMountData )
   130 			Cancel();
   134 			Cancel();
   131 			Deinitialize();
   135 			Deinitialize();
   132 			}
   136 			}
   133 		}
   137 		}
   134 		
   138 		
   135 	iMountDataQueue.Append( &aMountData );
   139 	User::LeaveIfError( iMountDataQueue.Append( &aMountData ));
       
   140 		
   136 	SetNextRequest( ERequestStartTask );
   141 	SetNextRequest( ERequestStartTask );
   137 	}
   142 	}
   138 	
   143 	
   139 void CMMCMountTaskAO::RunL()
   144 void CMMCMountTaskAO::RunL()
   140 	{
   145 	{
   144 	
   149 	
   145 	if ( iCacheEvents )
   150 	if ( iCacheEvents )
   146 		{
   151 		{
   147 		if ( iMountData )
   152 		if ( iMountData )
   148 			{
   153 			{
   149 			iMountDataQueue.Insert( iMountData, 0 );
   154 			if( iMountDataQueue.Insert( iMountData, 0 ) != KErrNone)
       
   155 			    {
       
   156                 delete iMountData;
       
   157 			    }
   150 			iMountData = NULL;
   158 			iMountData = NULL;
   151 			}
   159 			}
   152 		Deinitialize();
   160 		Deinitialize();
   153 		return;
   161 		return;
   154 		}
   162 		}
   203 			StartNotifyL();
   211 			StartNotifyL();
   204 			SetNotPresentToMDE();
   212 			SetNotPresentToMDE();
   205 			TRAPD( err, iMmcFileList->BuildFileListL( iFs, iMountData->iDrivePath, iEntryArray ));
   213 			TRAPD( err, iMmcFileList->BuildFileListL( iFs, iMountData->iDrivePath, iEntryArray ));
   206 			if ( err == KErrNoMemory )
   214 			if ( err == KErrNoMemory )
   207 				{
   215 				{
   208 				iMountDataQueue.Insert( iMountData, 0 );
   216 				if( iMountDataQueue.Insert( iMountData, 0 ) != KErrNone)
       
   217 				    {
       
   218                     delete iMountData;
       
   219 				    }
       
   220 					
   209 				iMountData = NULL;
   221 				iMountData = NULL;
   210 				Deinitialize();
   222 				Deinitialize();
   211 				SetNextRequest( ERequestStartTask );
   223 				SetNextRequest( ERequestStartTask );
   212 				break;
   224 				break;
   213 				}
   225 				}
   282 						iHarvestEntryArray, iMountData->iMediaID, iHarvesterPluginFactory ));
   294 						iHarvestEntryArray, iMountData->iMediaID, iHarvesterPluginFactory ));
   283 				if ( err != KErrNone )
   295 				if ( err != KErrNone )
   284 					{
   296 					{
   285 					if( err == KErrNoMemory )
   297 					if( err == KErrNoMemory )
   286 						{
   298 						{
   287 						iMountDataQueue.Insert( iMountData, 0 );
   299 						if(iMountDataQueue.Insert( iMountData, 0 ) != KErrNone)
       
   300 						    {
       
   301                             delete iMountData;
       
   302 						    }
       
   303 							
   288 						iMountData = NULL;
   304 						iMountData = NULL;
   289 						}
   305 						}
       
   306 						
   290 					Deinitialize();
   307 					Deinitialize();
   291 					SetNextRequest( ERequestStartTask );
   308 					SetNextRequest( ERequestStartTask );
   292 					break;
   309 					break;
   293 					}
   310 					}
   294 				
   311 				
   435 			 ei->PresentState() == EMdsModified )
   452 			 ei->PresentState() == EMdsModified )
   436 			{
   453 			{
   437 			hd->SetEventType( EHarvesterEdit );
   454 			hd->SetEventType( EHarvesterEdit );
   438 			hd->SetObjectType( ENormal );
   455 			hd->SetObjectType( ENormal );
   439 			delete ei;
   456 			delete ei;
       
   457 			ei = NULL;
   440 			}
   458 			}
   441 		else
   459 		else
   442 			{
   460 			{
   443 			hd->SetEventType( EHarvesterAdd );
   461 			hd->SetEventType( EHarvesterAdd );
   444 			hd->SetObjectType( EPlaceholder );
   462 			hd->SetObjectType( EPlaceholder );
   445 			hd->SetClientData( ei );
   463 			hd->SetClientData( ei );
   446 			}
   464 			}
   447 		
   465 		
   448 		iHdArray.Append( hd );
   466 		if(iHdArray.Append( hd ) != KErrNone )
       
   467 		    {
       
   468             delete hd;
       
   469             hd = NULL;
       
   470 		    }
       
   471 			
   449 		aArray.Remove( i );
   472 		aArray.Remove( i );
   450 		}
   473 		}
   451 	
   474 	
   452     if( aArray.Count() == 0 )
   475     if( aArray.Count() == 0 )
   453         {
   476         {