harvester/monitorplugins/mmcplugin/src/mmcmounttaskao.cpp
branchRCL_3
changeset 22 29d87345eaeb
parent 21 85f623e1ef41
equal deleted inserted replaced
21:85f623e1ef41 22:29d87345eaeb
   112 	
   112 	
   113 void CMMCMountTaskAO::StartMountL( TMountData& aMountData )
   113 void CMMCMountTaskAO::StartMountL( TMountData& aMountData )
   114 	{
   114 	{
   115 	WRITELOG("CMMCMountTaskAO::StartMount");
   115 	WRITELOG("CMMCMountTaskAO::StartMount");
   116 	
   116 	
       
   117 	// Remove pending mount request for the same drive
       
   118 	// if for example USB cable is pluged and unpluged
       
   119 	// several times in a row
       
   120 	for( TInt i = iMountDataQueue.Count() - 1; i >=0; i-- )
       
   121 	    {
       
   122 	    WRITELOG( "CMMCMountTaskAO::StartUnmountL - checking for pending mount notifications" );
       
   123 	    TMountData* tempData = iMountDataQueue[i];
       
   124 	    if( tempData->iMediaID == aMountData.iMediaID &&
       
   125 	        tempData->iMountType == TMountData::EMount &&
       
   126 	        aMountData.iMountType == TMountData::EMount &&
       
   127 	        tempData->iDrivePath == aMountData.iDrivePath )
       
   128 	        {
       
   129 	        WRITELOG( "CMMCMountTaskAO::StartUnmountL - removing obsolite mount notifications" );
       
   130 	        iMountDataQueue.Remove(i);
       
   131 	        delete tempData;
       
   132 	        tempData = NULL;
       
   133 	        }
       
   134 	    }
       
   135 
   117 	User::LeaveIfError( iMountDataQueue.Append( &aMountData ));
   136 	User::LeaveIfError( iMountDataQueue.Append( &aMountData ));
   118 	
   137 	
   119 	if ( iNextRequest == ERequestIdle )
   138 	if ( iNextRequest == ERequestIdle )
   120 		{
   139 		{
   121 		SetNextRequest( ERequestStartTask );
   140 		SetNextRequest( ERequestStartTask );
   133 			{
   152 			{
   134 			Cancel();
   153 			Cancel();
   135 			Deinitialize();
   154 			Deinitialize();
   136 			}
   155 			}
   137 		}
   156 		}
   138 		
   157 
       
   158     // Remove pending unmount request for the same drive
       
   159     // if for example USB cable is pluged and unpluged
       
   160     // several times in a row
       
   161     for( TInt i = iMountDataQueue.Count() - 1; i >=0; i-- )
       
   162         {
       
   163         WRITELOG( "CMMCMountTaskAO::StartUnmountL - checking for pending unmount notifications" );
       
   164         TMountData* tempData = iMountDataQueue[i];
       
   165         if( tempData->iMediaID == aMountData.iMediaID &&
       
   166             tempData->iMountType == TMountData::EUnmount &&
       
   167             aMountData.iMountType == TMountData::EUnmount &&
       
   168             tempData->iDrivePath == aMountData.iDrivePath )
       
   169             {
       
   170             WRITELOG( "CMMCMountTaskAO::StartUnmountL - removing obsolite unmount notifications" );
       
   171             iMountDataQueue.Remove(i);
       
   172             delete tempData;
       
   173             tempData = NULL;
       
   174             }
       
   175         }
       
   176 	
   139 	User::LeaveIfError( iMountDataQueue.Append( &aMountData ));
   177 	User::LeaveIfError( iMountDataQueue.Append( &aMountData ));
   140 		
   178 		
   141 	SetNextRequest( ERequestStartTask );
   179 	SetNextRequest( ERequestStartTask );
   142 	}
   180 	}
   143 	
   181 	
   179 				iMountData = iMountDataQueue[0];
   217 				iMountData = iMountDataQueue[0];
   180 				iMountDataQueue.Remove(0);
   218 				iMountDataQueue.Remove(0);
   181 
   219 
   182 				WRITELOG1( "iMountData.iMountType: %d", iMountData->iMountType );
   220 				WRITELOG1( "iMountData.iMountType: %d", iMountData->iMountType );
   183 				WRITELOG1( "iMountData.iDrivePath: %S", &iMountData->iDrivePath );
   221 				WRITELOG1( "iMountData.iDrivePath: %S", &iMountData->iDrivePath );
   184 				WRITELOG1( "iMountData.iMediaID: %d", iMountData->iMediaID );
   222 				WRITELOG1( "iMountData.iMediaID: %u", iMountData->iMediaID );
   185 
   223 
   186 				if ( iMountData->iMountType == TMountData::EMount )
   224 				if ( iMountData->iMountType == TMountData::EMount )
   187 					{
   225 					{
   188 					SetNextRequest( ERequestMount );
   226 					SetNextRequest( ERequestMount );
   189 					}
   227 					}
   391 TInt CMMCMountTaskAO::RunError( TInt )
   429 TInt CMMCMountTaskAO::RunError( TInt )
   392 #endif
   430 #endif
   393 	{
   431 	{
   394 	WRITELOG1( "CMMCMountTaskAO::RunError with error code: %d", aError );
   432 	WRITELOG1( "CMMCMountTaskAO::RunError with error code: %d", aError );
   395 	Deinitialize();
   433 	Deinitialize();
       
   434 	SetNextRequest( ERequestStartTask );
   396 	return KErrNone;
   435 	return KErrNone;
   397 	}
   436 	}
   398 
   437 
   399 void CMMCMountTaskAO::DoCancel()
   438 void CMMCMountTaskAO::DoCancel()
   400 	{
   439 	{
   413 		}
   452 		}
   414 	}
   453 	}
   415 
   454 
   416 void CMMCMountTaskAO::SetNotPresentToMDE()
   455 void CMMCMountTaskAO::SetNotPresentToMDE()
   417 	{
   456 	{
   418 	WRITELOG1("CMMCMountTaskAO::SetNotPresentToMDE - MediaID %d", iMountData->iMediaID);
   457 	WRITELOG1("CMMCMountTaskAO::SetNotPresentToMDE - MediaID %u", iMountData->iMediaID);
   419 	if ( iMountData->iMediaID )
   458 	if ( iMountData->iMediaID )
   420 		{
   459 		{
   421 		iMdeSession->SetFilesToNotPresent( iMountData->iMediaID );
   460 		iMdeSession->SetFilesToNotPresent( iMountData->iMediaID );
   422 		}
   461 		}
   423 	else
   462 	else
   536 		delete iMountData;
   575 		delete iMountData;
   537 		iMountData = NULL;
   576 		iMountData = NULL;
   538 		}
   577 		}
   539 	}
   578 	}
   540 
   579 
   541 TUint32 CMMCMountTaskAO::GetInternalDriveMediaId()
   580 TUint32 CMMCMountTaskAO::GetInternalDriveMediaId( TBool& aPresent )
   542 	{
   581 	{
   543     WRITELOG( "CMMCMountTaskAO::GetInternalDriveMediaId" );
   582     WRITELOG( "CMMCMountTaskAO::GetInternalDriveMediaId" );
   544 	    
   583 	    
   545 	TDriveInfo driveInfo;
   584 	TDriveInfo driveInfo;
   546 	TDriveList driveList;
   585 	TDriveList driveList;
   579 	        if ( driveInfo.iType == EMediaHardDisk )
   618 	        if ( driveInfo.iType == EMediaHardDisk )
   580 	        	{
   619 	        	{
   581 	        	// check if disk is internal
   620 	        	// check if disk is internal
   582 	        	TUint driveStatus;
   621 	        	TUint driveStatus;
   583 	        	const TInt err = DriveInfo::GetDriveStatus( iFs, i, driveStatus );
   622 	        	const TInt err = DriveInfo::GetDriveStatus( iFs, i, driveStatus );
   584 	        	if ( (err == KErrNone ) && ( driveStatus & DriveInfo::EDriveInternal ) )
   623 	        	if ( ( err == KErrNone ) && 
       
   624 	        	     ( driveStatus & DriveInfo::EDriveInternal ))
   585 	        		{
   625 	        		{
   586 	        		// get media id
   626 	        		// get media id
   587 	        		hdMediaId = FSUtil::MediaID( iFs, i );
   627 	        		hdMediaId = FSUtil::MediaID( iFs, i );
       
   628 	        		if( driveStatus & DriveInfo::EDrivePresent )
       
   629 	        		    {
       
   630 	        		    aPresent = ETrue;
       
   631 	        		    }
   588 	        		break;
   632 	        		break;
   589 	        		}
   633 	        		}
   590 	        	}
   634 	        	}
   591 	    	}
   635 	    	}
   592 		}
   636 		}