harvester/monitorplugins/mmcplugin/src/mmcmounttaskao.cpp
branchRCL_3
changeset 63 e538444823de
parent 53 29d87345eaeb
--- a/harvester/monitorplugins/mmcplugin/src/mmcmounttaskao.cpp	Wed Sep 15 12:40:59 2010 +0300
+++ b/harvester/monitorplugins/mmcplugin/src/mmcmounttaskao.cpp	Wed Oct 13 15:02:02 2010 +0300
@@ -79,7 +79,6 @@
 	iHarvestEntryArray.Close();
 	
 	delete iMdeSession;
-	iMdeSession = NULL;
   
 	Deinitialize();
 	
@@ -89,7 +88,6 @@
 		}
 	
 	delete iMmcFileList;
-	iMmcFileList = NULL;
 	iHdArray.ResetAndDestroy();
 	iHdArray.Close();
 	}
@@ -110,38 +108,17 @@
 	iHarvesterPluginFactory = aPluginFactory;
 	}
 	
-void CMMCMountTaskAO::StartMountL( TMountData& aMountData )
+void CMMCMountTaskAO::StartMount( TMountData& aMountData )
 	{
 	WRITELOG("CMMCMountTaskAO::StartMount");
-	
-	// Remove pending mount request for the same drive
-	// if for example USB cable is pluged and unpluged
-	// several times in a row
-	for( TInt i = iMountDataQueue.Count() - 1; i >=0; i-- )
-	    {
-	    WRITELOG( "CMMCMountTaskAO::StartUnmountL - checking for pending mount notifications" );
-	    TMountData* tempData = iMountDataQueue[i];
-	    if( tempData->iMediaID == aMountData.iMediaID &&
-	        tempData->iMountType == TMountData::EMount &&
-	        aMountData.iMountType == TMountData::EMount &&
-	        tempData->iDrivePath == aMountData.iDrivePath )
-	        {
-	        WRITELOG( "CMMCMountTaskAO::StartUnmountL - removing obsolite mount notifications" );
-	        iMountDataQueue.Remove(i);
-	        delete tempData;
-	        tempData = NULL;
-	        }
-	    }
-
-	User::LeaveIfError( iMountDataQueue.Append( &aMountData ));
-	
+	iMountDataQueue.Append( &aMountData );
 	if ( iNextRequest == ERequestIdle )
 		{
 		SetNextRequest( ERequestStartTask );
 		}
 	}
 	
-void CMMCMountTaskAO::StartUnmountL(TMountData& aMountData)
+void CMMCMountTaskAO::StartUnmount(TMountData& aMountData)
 	{
 	WRITELOG("CMMCMountTaskAO::StartUnmount");
 	
@@ -154,28 +131,8 @@
 			Deinitialize();
 			}
 		}
-
-    // Remove pending unmount request for the same drive
-    // if for example USB cable is pluged and unpluged
-    // several times in a row
-    for( TInt i = iMountDataQueue.Count() - 1; i >=0; i-- )
-        {
-        WRITELOG( "CMMCMountTaskAO::StartUnmountL - checking for pending unmount notifications" );
-        TMountData* tempData = iMountDataQueue[i];
-        if( tempData->iMediaID == aMountData.iMediaID &&
-            tempData->iMountType == TMountData::EUnmount &&
-            aMountData.iMountType == TMountData::EUnmount &&
-            tempData->iDrivePath == aMountData.iDrivePath )
-            {
-            WRITELOG( "CMMCMountTaskAO::StartUnmountL - removing obsolite unmount notifications" );
-            iMountDataQueue.Remove(i);
-            delete tempData;
-            tempData = NULL;
-            }
-        }
-	
-	User::LeaveIfError( iMountDataQueue.Append( &aMountData ));
 		
+	iMountDataQueue.Append( &aMountData );
 	SetNextRequest( ERequestStartTask );
 	}
 	
@@ -189,10 +146,7 @@
 		{
 		if ( iMountData )
 			{
-			if( iMountDataQueue.Insert( iMountData, 0 ) != KErrNone)
-			    {
-                delete iMountData;
-			    }
+			iMountDataQueue.Insert( iMountData, 0 );
 			iMountData = NULL;
 			}
 		Deinitialize();
@@ -219,7 +173,7 @@
 
 				WRITELOG1( "iMountData.iMountType: %d", iMountData->iMountType );
 				WRITELOG1( "iMountData.iDrivePath: %S", &iMountData->iDrivePath );
-				WRITELOG1( "iMountData.iMediaID: %u", iMountData->iMediaID );
+				WRITELOG1( "iMountData.iMediaID: %d", iMountData->iMediaID );
 
 				if ( iMountData->iMountType == TMountData::EMount )
 					{
@@ -251,11 +205,7 @@
 			TRAPD( err, iMmcFileList->BuildFileListL( iFs, iMountData->iDrivePath, iEntryArray ));
 			if ( err == KErrNoMemory )
 				{
-				if( iMountDataQueue.Insert( iMountData, 0 ) != KErrNone)
-				    {
-                    delete iMountData;
-				    }
-					
+				iMountDataQueue.Insert( iMountData, 0 );
 				iMountData = NULL;
 				Deinitialize();
 				SetNextRequest( ERequestStartTask );
@@ -334,14 +284,9 @@
 					{
 					if( err == KErrNoMemory )
 						{
-						if(iMountDataQueue.Insert( iMountData, 0 ) != KErrNone)
-						    {
-                            delete iMountData;
-						    }
-							
+						iMountDataQueue.Insert( iMountData, 0 );
 						iMountData = NULL;
 						}
-						
 					Deinitialize();
 					SetNextRequest( ERequestStartTask );
 					break;
@@ -454,7 +399,7 @@
 
 void CMMCMountTaskAO::SetNotPresentToMDE()
 	{
-	WRITELOG1("CMMCMountTaskAO::SetNotPresentToMDE - MediaID %u", iMountData->iMediaID);
+	WRITELOG1("CMMCMountTaskAO::SetNotPresentToMDE - MediaID %d", iMountData->iMediaID);
 	if ( iMountData->iMediaID )
 		{
 		iMdeSession->SetFilesToNotPresent( iMountData->iMediaID );
@@ -493,7 +438,6 @@
 			hd->SetEventType( EHarvesterEdit );
 			hd->SetObjectType( ENormal );
 			delete ei;
-			ei = NULL;
 			}
 		else
 			{
@@ -502,12 +446,7 @@
 			hd->SetClientData( ei );
 			}
 		
-		if(iHdArray.Append( hd ) != KErrNone )
-		    {
-            delete hd;
-            hd = NULL;
-		    }
-			
+		iHdArray.Append( hd );
 		aArray.Remove( i );
 		}
 	
@@ -577,7 +516,7 @@
 		}
 	}
 
-TUint32 CMMCMountTaskAO::GetInternalDriveMediaId( TBool& aPresent )
+TUint32 CMMCMountTaskAO::GetInternalDriveMediaId()
 	{
     WRITELOG( "CMMCMountTaskAO::GetInternalDriveMediaId" );
 	    
@@ -620,15 +559,10 @@
 	        	// check if disk is internal
 	        	TUint driveStatus;
 	        	const TInt err = DriveInfo::GetDriveStatus( iFs, i, driveStatus );
-	        	if ( ( err == KErrNone ) && 
-	        	     ( driveStatus & DriveInfo::EDriveInternal ))
+	        	if ( (err == KErrNone ) && ( driveStatus & DriveInfo::EDriveInternal ) )
 	        		{
 	        		// get media id
 	        		hdMediaId = FSUtil::MediaID( iFs, i );
-	        		if( driveStatus & DriveInfo::EDrivePresent )
-	        		    {
-	        		    aPresent = ETrue;
-	        		    }
 	        		break;
 	        		}
 	        	}