metadataengine/server/src/mdsdiskspacenotifier.cpp
changeset 20 6dfc5f825351
parent 0 c53acadfccc6
child 21 50bf9db68373
equal deleted inserted replaced
3:b73a2e62868f 20:6dfc5f825351
    55 		TInt status = iStatus.Int();
    55 		TInt status = iStatus.Int();
    56 		
    56 		
    57 		switch( status )
    57 		switch( status )
    58 			{
    58 			{
    59 			case KErrNone:
    59 			case KErrNone:
    60 				iFileServerSession.Volume( volumeInfo, iDrive );
    60 				const TInt error = iFileServerSession.Volume( volumeInfo, iDrive );
       
    61 				if( error != KErrNone )
       
    62 				    {
       
    63 				    StartNotifier();
       
    64 				    break;
       
    65 				    }
    61 				
    66 				
    62 				// Check if free space is less than threshold level
    67 				// Check if free space is less than threshold level
    63 				if( volumeInfo.iFree < iThreshold )
    68 				if( volumeInfo.iFree < iThreshold )
    64 					{
    69 					{
    65 					iObserver.HandleDiskSpaceNotificationL( MMdSDiskSpaceNotifierObserver::ELess );
    70 					iObserver.HandleDiskSpaceNotificationL( MMdSDiskSpaceNotifierObserver::ELess );
    87 			}
    92 			}
    88 		}
    93 		}
    89 	else if ( iState == CMdSDiskSpaceNotifierAO::EIterate )
    94 	else if ( iState == CMdSDiskSpaceNotifierAO::EIterate )
    90 		{
    95 		{
    91 		const TInt KMaxIterations = 10;
    96 		const TInt KMaxIterations = 10;
    92 		
    97         TInt error = iFileServerSession.Volume( volumeInfo, iDrive );
    93 		iFileServerSession.Volume( volumeInfo, iDrive );
    98         if( error != KErrNone )
       
    99             {
       
   100             iState = ENormal;
       
   101             iIterationCount = 0;
       
   102             StartNotifier();
       
   103             return;
       
   104             }
       
   105 
    94 		if ( volumeInfo.iFree < iThreshold )
   106 		if ( volumeInfo.iFree < iThreshold )
    95 			{
   107 			{
    96 			iObserver.HandleDiskSpaceNotificationL( MMdSDiskSpaceNotifierObserver::ELess );
   108 			iObserver.HandleDiskSpaceNotificationL( MMdSDiskSpaceNotifierObserver::ELess );
    97 			++iIterationCount;
   109 			++iIterationCount;
    98 			if ( iIterationCount < KMaxIterations )
   110 			if ( iIterationCount < KMaxIterations )
   102 				User::RequestComplete( status, KErrNone );
   114 				User::RequestComplete( status, KErrNone );
   103 				return;
   115 				return;
   104 				}
   116 				}
   105 			else
   117 			else
   106 				{
   118 				{
   107 				iFileServerSession.Volume( volumeInfo, iDrive );
   119 		        error = iFileServerSession.Volume( volumeInfo, iDrive );
       
   120 		        if( error != KErrNone )
       
   121 		            {
       
   122 		            iState = ENormal;
       
   123 		            iIterationCount = 0;
       
   124 		            StartNotifier();
       
   125 		            return;
       
   126 		            }
   108 				if ( volumeInfo.iFree >= iThreshold )
   127 				if ( volumeInfo.iFree >= iThreshold )
   109 					{
   128 					{
   110 					iDiskFull = EFalse;
   129 					iDiskFull = EFalse;
   111 					}
   130 					}
   112 				}
   131 				}
   153 	TInt KMessageSlotCount = 2; // slots for NotifyDiskSpace and NotifyDiskSpaceCancel
   172 	TInt KMessageSlotCount = 2; // slots for NotifyDiskSpace and NotifyDiskSpaceCancel
   154 
   173 
   155 	User::LeaveIfError( iFileServerSession.Connect( KMessageSlotCount ) );
   174 	User::LeaveIfError( iFileServerSession.Connect( KMessageSlotCount ) );
   156 	
   175 	
   157 	TVolumeInfo volumeInfo;
   176 	TVolumeInfo volumeInfo;
   158 	iFileServerSession.Volume( volumeInfo, iDrive );	
   177 	const TInt error = iFileServerSession.Volume( volumeInfo, iDrive );	
   159 	if ( volumeInfo.iFree < iThreshold )
   178 	if ( (error != KErrNone) || volumeInfo.iFree < iThreshold )
   160 		{
   179 		{
   161 		iDiskFull = ETrue;
   180 		iDiskFull = ETrue;
   162 		}
   181 		}
   163 
   182 
   164 	StartNotifier();
   183 	StartNotifier();