phoneapp/phoneuiutils/src/cphonerecoverysystem.cpp
branchRCL_3
changeset 25 5266b1f337bd
parent 24 41a7f70b3818
equal deleted inserted replaced
24:41a7f70b3818 25:5266b1f337bd
    43     
    43     
    44     if ( !instance )
    44     if ( !instance )
    45         {
    45         {
    46         TRAPD( err, instance = CPhoneRecoverySystem::NewL() );
    46         TRAPD( err, instance = CPhoneRecoverySystem::NewL() );
    47         if ( err )
    47         if ( err )
    48             {
    48 	        {
    49             Panic( EPhoneUtilsCouldNotCreateSingleton );    
    49 	        Panic( EPhoneUtilsCouldNotCreateSingleton );	
    50             }
    50 	        }
    51         }
    51         }
    52     return instance;
    52     return instance;
    53     }
    53     }
    54 
    54 
    55 // ---------------------------------------------------------
    55 // ---------------------------------------------------------
   101     TCallBack aCallBack, 
   101     TCallBack aCallBack, 
   102     TRecoveryPriority aPriority, 
   102     TRecoveryPriority aPriority, 
   103     CTeleRecoverySystem::TRecoveryState aState )
   103     CTeleRecoverySystem::TRecoveryState aState )
   104     {
   104     {
   105     if ( !iRecoverySystem )
   105     if ( !iRecoverySystem )
   106         {
   106 	    {
   107         iRecoverySystem = CreateRecoverySystemL();  
   107 	    iRecoverySystem = CreateRecoverySystemL();	
   108         }
   108 	    }
   109         
   109 	    
   110     TRecoveryId id = iRecoverySystem->AddL( 
   110     TRecoveryId id = iRecoverySystem->AddL( 
   111         aCallBack, 
   111         aCallBack, 
   112         aPriority, 
   112         aPriority, 
   113         aState );
   113         aState );
   114 
   114 
   115     try
   115     try
   116         {
   116 	    {
   117         AddIdToContainer( id ); 
   117 	    AddIdToContainer( id );	
   118         }
   118 	    }
   119     catch( TInt exception )
   119 	catch( TInt exception )
   120         {
   120 		{
   121         __ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsBufferOverflow ) );   
   121 		__ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsBufferOverflow ) );	
   122         }
   122 		}
   123     
   123 	
   124     return id;
   124 	return id;
   125     }
   125     }
   126     
   126     
   127 // -----------------------------------------------------------------------------
   127 // -----------------------------------------------------------------------------
   128 // CPhoneRecoverySystem::Add
   128 // CPhoneRecoverySystem::Add
   129 // -----------------------------------------------------------------------------
   129 // -----------------------------------------------------------------------------
   196     TBool aAllSteps )
   196     TBool aAllSteps )
   197     {
   197     {
   198     __ASSERT_DEBUG( iRecoverySystem, Panic( EPhoneUtilsInvariant ) );
   198     __ASSERT_DEBUG( iRecoverySystem, Panic( EPhoneUtilsInvariant ) );
   199     
   199     
   200     if ( !iRecoverySystem )
   200     if ( !iRecoverySystem )
   201         {
   201 	    {
   202         TRAPD( error, iRecoverySystem = CreateRecoverySystemL() )
   202 	    TRAPD( error, iRecoverySystem = CreateRecoverySystemL() )
   203         if( error != KErrNone )
   203         if( error != KErrNone )
   204             {
   204             {
   205             return error;
   205             return error;
   206             }
   206             }
   207         }
   207 	    }
   208     return iRecoverySystem->RecoverNow( aId, aPriority, aAllSteps );
   208     return iRecoverySystem->RecoverNow( aId, aPriority, aAllSteps );
   209     }
   209     }
   210 
   210 
   211 // -----------------------------------------------------------------------------
   211 // -----------------------------------------------------------------------------
   212 // CPhoneRecoverySystem::EnablePreconditionL
   212 // CPhoneRecoverySystem::EnablePreconditionL
   215 EXPORT_C void CPhoneRecoverySystem::EnablePreconditionL()
   215 EXPORT_C void CPhoneRecoverySystem::EnablePreconditionL()
   216     {
   216     {
   217     __ASSERT_DEBUG( iRecoverySystem, Panic( EPhoneUtilsInvariant ) );
   217     __ASSERT_DEBUG( iRecoverySystem, Panic( EPhoneUtilsInvariant ) );
   218     
   218     
   219     if ( !iRecoverySystem )
   219     if ( !iRecoverySystem )
   220         {
   220 	    {
   221         iRecoverySystem = CreateRecoverySystemL();
   221         iRecoverySystem = CreateRecoverySystemL();
   222         }
   222 	    }
   223         
   223 	    
   224     iRecoverySystem->EnablePrecondition();
   224     iRecoverySystem->EnablePrecondition();
   225     }
   225     }
   226 
   226 
   227 // -----------------------------------------------------------------------------
   227 // -----------------------------------------------------------------------------
   228 // CPhoneRecoverySystem::AddIdToContainer
   228 // CPhoneRecoverySystem::AddIdToContainer
   229 // -----------------------------------------------------------------------------
   229 // -----------------------------------------------------------------------------
   230 //
   230 //
   231 void CPhoneRecoverySystem::AddIdToContainer( TRecoveryId aId )
   231 void CPhoneRecoverySystem::AddIdToContainer( TRecoveryId aId )
   232     {
   232 	{
   233     __ASSERT_DEBUG( iIdContainer.Count() == KIdContainerSize, Panic( EPhoneUtilsInvariant ) );
   233 	__ASSERT_DEBUG( iIdContainer.Count() == KIdContainerSize, Panic( EPhoneUtilsInvariant ) );
   234     for( TInt i = 0; i < KIdContainerSize; i++ )
   234 	for( TInt i = 0; i < KIdContainerSize; i++ )
   235         {
   235 		{
   236         if( iIdContainer[ i ] == KEmptySlot )
   236 		if( iIdContainer[ i ] == KEmptySlot )
   237             {
   237 			{
   238             iIdContainer[ i ] = aId;
   238 			iIdContainer[ i ] = aId;
   239             return;             
   239 			return;				
   240             }
   240 			}
   241         }
   241 		}
   242     
   242 	
   243     // All slots checked, no space - throw exception    
   243 	// All slots checked, no space - throw exception	
   244     throw KErrNoSpace;      
   244 	throw KErrNoSpace;		
   245     }
   245 	}
   246 
   246 
   247 // -----------------------------------------------------------------------------
   247 // -----------------------------------------------------------------------------
   248 // CPhoneRecoverySystem::RemoveFromContainer
   248 // CPhoneRecoverySystem::RemoveFromContainer
   249 // -----------------------------------------------------------------------------
   249 // -----------------------------------------------------------------------------
   250 //
   250 //
   251 void CPhoneRecoverySystem::RemoveFromContainer( TRecoveryId aId )
   251 void CPhoneRecoverySystem::RemoveFromContainer( TRecoveryId aId )
   252     {
   252 	{
   253     __ASSERT_DEBUG( iIdContainer.Count() == KIdContainerSize, Panic( EPhoneUtilsInvariant ) );
   253 	__ASSERT_DEBUG( iIdContainer.Count() == KIdContainerSize, Panic( EPhoneUtilsInvariant ) );
   254     for( TInt i = 0; i < KIdContainerSize; i++ )
   254 	for( TInt i = 0; i < KIdContainerSize; i++ )
   255         {
   255 		{
   256         if( iIdContainer[ i ] == aId )
   256 		if( iIdContainer[ i ] == aId )
   257             {
   257 			{
   258             iIdContainer[ i ] = KEmptySlot;
   258 			iIdContainer[ i ] = KEmptySlot;
   259             }
   259 			}
   260         }
   260 		}
   261     }
   261 	}
   262 
   262 
   263 // -----------------------------------------------------------------------------
   263 // -----------------------------------------------------------------------------
   264 // CPhoneRecoverySystem::RemoveAllIdsFromContainer
   264 // CPhoneRecoverySystem::RemoveAllIdsFromContainer
   265 // -----------------------------------------------------------------------------
   265 // -----------------------------------------------------------------------------
   266 //
   266 //
   267 void CPhoneRecoverySystem::RemoveAllIdsFromContainer()
   267 void CPhoneRecoverySystem::RemoveAllIdsFromContainer()
   268     {
   268 	{
   269     __ASSERT_DEBUG( iIdContainer.Count() == KIdContainerSize, Panic( EPhoneUtilsInvariant ) );
   269 	__ASSERT_DEBUG( iIdContainer.Count() == KIdContainerSize, Panic( EPhoneUtilsInvariant ) );
   270     for( TInt i = 0; i < KIdContainerSize; i++ )
   270 	for( TInt i = 0; i < KIdContainerSize; i++ )
   271         {
   271 		{
   272         if( iIdContainer[ i ] != KEmptySlot )
   272 		if( iIdContainer[ i ] != KEmptySlot )
   273             {
   273 			{
   274             RemoveId( iIdContainer[ i ] );
   274 			RemoveId( iIdContainer[ i ] );
   275             }
   275 			}
   276         }       
   276 		}		
   277     }
   277 	}
   278 
   278 
   279 //  End of File  
   279 //  End of File