realtimenetprots/sipfw/SIP/ConnectionMgr/src/CStateModel.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        : CStateModel.h
       
    16 * Part of     : NetworkMonitor
       
    17 * See class definition below.
       
    18 * Version     : SIP/4.0
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 /**
       
    26  @internalComponent
       
    27 */
       
    28 
       
    29 #ifndef __CSTATEMODEL_H__
       
    30 #define __CSTATEMODEL_H__
       
    31 
       
    32 // INCLUDES
       
    33 #include <e32base.h>
       
    34 #include "MStateModel.h"
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 class MSIPConnectionContext;
       
    38 class MTimerManager;
       
    39 class TStateBase;
       
    40 
       
    41 // CLASS DEFINITION
       
    42 /**
       
    43  * CStateModel implements a state model for CSipConnection
       
    44  */
       
    45 class CStateModel
       
    46 	: public CBase,
       
    47 	  public MStateModel
       
    48 	{
       
    49 	public:	// Constructors and destructor
       
    50 
       
    51 		/**
       
    52 		 * Static constructor.
       
    53 		 *
       
    54 		 * @param aContext Reference to SIP Connection Context (~CSipConnection)
       
    55 		 * @param aTimer Reference to the global timer manager.
       
    56 		 * @return An initialized instance of this class.
       
    57 		 */
       
    58 		static CStateModel* NewL( MSIPConnectionContext& aContext,
       
    59 								  MTimerManager& aTimer );
       
    60 
       
    61 		/// Destructor
       
    62 		~CStateModel();
       
    63 
       
    64 	public: // From MStateModel
       
    65 
       
    66 		void SendL( const TSIPTransportParams& aParams,
       
    67 		            CSIPRequest& aRequest,
       
    68 		            TBool aForceUDP,
       
    69 		            const CUri8* aOutboundProxy,
       
    70 					const TInetAddr& aRemoteAddr,
       
    71 					TRequestStatus& aStatus );
       
    72 
       
    73  		void SendL( const TSIPTransportParams& aParams,
       
    74  		            CSIPResponse& aResponse,
       
    75                     TTransactionId aId,
       
    76 					TRequestStatus& aStatus );
       
    77 
       
    78 		MStateModel::TState StateValue() const;
       
    79 
       
    80 		void EnterState( MStateModel::TState aState, TInt aError );
       
    81 		
       
    82 		TInt Error() const;
       
    83 
       
    84 	public: // From MSIPNetworkObserver
       
    85 
       
    86 		void NetworkStateChanged( MSIPNetworkObserver::TNetworkState aState,
       
    87 								  TInt aError );
       
    88 
       
    89 	private: // New methods
       
    90 
       
    91 		/// @return Reference to the active state instance.
       
    92 		inline TStateBase& State() const;
       
    93 
       
    94 	private: // Constructors
       
    95 
       
    96 		/// Default constructor. Not implemented.
       
    97 		CStateModel();
       
    98 
       
    99 		/**
       
   100 		 * Constructor.
       
   101 		 *
       
   102 		 * @param aContext Reference to SIP Connection Context (~CSipConnection)
       
   103 		 * @param aTimer Reference to the global timer manager.
       
   104 		 */
       
   105 		CStateModel( MSIPConnectionContext& aContext,
       
   106 					 MTimerManager& aTimer );
       
   107 
       
   108 		/// 2nd phase constructor
       
   109 		void ConstructL();
       
   110 
       
   111 	private: // Data
       
   112 
       
   113 		/// Reference to SIP Connection Context (~CSipConnection)
       
   114 		MSIPConnectionContext& iContext;
       
   115 
       
   116 		/// Reference to the global timer manager.
       
   117 		MTimerManager& iTimer;
       
   118 
       
   119 		/// State instances. Owned.
       
   120 		CArrayVarFlat< TStateBase > iStates;
       
   121 
       
   122 		/// Current state as enumeration value
       
   123 		MStateModel::TState iStateValue;
       
   124 		
       
   125 		/// Stores connection error
       
   126 		TInt iError;
       
   127 	private: //For testing purposes
       
   128 #ifdef CPPUNIT_TEST	
       
   129 		friend class CStateModel_test;
       
   130 #endif
       
   131 	};
       
   132 
       
   133 #endif // __CSTATEMODEL_H__