realtimenetprots/sipfw/SIP/ConnectionMgr/src/TStateActiveResolving.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Name        : TStateActiveResolving.h
       
    16 * Part of     : NetworkMonitor
       
    17 * See class definition below.
       
    18 * Version     : SIP/4.0
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 #ifndef __TSTATEACTIVERESOLVING_H__
       
    25 #define __TSTATEACTIVERESOLVING_H__
       
    26 
       
    27 // INCLUDES
       
    28 #include "TStateBase.h"
       
    29 #include "Lwtimer.h"
       
    30 
       
    31 // CONSTANTS
       
    32 const TUint KInitialResolvingTimer( 1000 ); // milliseconds
       
    33 const TUint KStartDoublingTimerValue( 4000 ); // milliseconds
       
    34 const TUint KMaximumResolvingTimer( 32000 ); // milliseconds
       
    35 
       
    36 // CLASS DEFINITION
       
    37 /**
       
    38  * TStateActiveResolving implements the Active:Resolving state
       
    39  */
       
    40 class TStateActiveResolving
       
    41 	: public TStateBase,
       
    42 	  public MExpirationHandler
       
    43 	{
       
    44 	public:	// Constructors and destructor
       
    45 
       
    46 		/**
       
    47 		 * Constructor.
       
    48 		 * @param aOwner State model that owns us.
       
    49 		 * @param aContext Reference to SIP connection context
       
    50 		 */
       
    51 		TStateActiveResolving( MStateModel& aOwner,
       
    52 							   MSIPConnectionContext& aContext,
       
    53 							   MTimerManager& aTimer )
       
    54 			: TStateBase( aOwner, aContext ), 
       
    55 			  iTimer( aTimer ),
       
    56 			  iTimerId( 0 ),
       
    57 			  iTimerValue( KInitialResolvingTimer ),
       
    58 			  iCumulativeTimerValue( KInitialResolvingTimer ) {}
       
    59 
       
    60 	public: // From TStateBase
       
    61 
       
    62 		void Enter( TInt aError );
       
    63 		void Exit();
       
    64 		void NetworkStateChanged( MSIPNetworkObserver::TNetworkState aState,
       
    65 								  TInt aError );
       
    66 
       
    67 	public: // From MExpirationHandler
       
    68 
       
    69 		void TimerExpiredL( TTimerId aTimerId, TAny* aTimerParam );
       
    70 
       
    71 	private: // New methods
       
    72 
       
    73 		/// @return ETrue if MSIPConnectionContext has a valid IP address
       
    74 		TBool HasAddress();
       
    75 		
       
    76 		TUint CalculateTimerValue();
       
    77 		void EnterActiveResolvedState();
       
    78 
       
    79 	private: // Data
       
    80 
       
    81 		/// Reference to the global timer manager.
       
    82 		MTimerManager& iTimer;
       
    83 
       
    84 		/// Handle to our timer (when active)
       
    85 		TTimerId iTimerId;
       
    86 		
       
    87 		TUint iTimerValue;
       
    88 		
       
    89 		TUint iCumulativeTimerValue;
       
    90 		
       
    91 	private: // For unit testing purposes
       
    92 #ifdef CPPUNIT_TEST
       
    93 	    friend class CStateModel_test;
       
    94 #endif
       
    95 	};
       
    96 
       
    97 #endif // __TSTATEACTIVERESOLVING_H__