multimediacommsengine/tsrc/testdriver/siptester/src/CTcSIPContext.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2004 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:  See class definition below.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CTCSIPCONTEXT_H__
       
    19 #define __CTCSIPCONTEXT_H__
       
    20 
       
    21 // INCLUDES
       
    22 #include <e32base.h>
       
    23 #include <centralrepository.h>
       
    24 #include "CTcContextBase.h"
       
    25 #include "CTcIAPManager.h"
       
    26 #include <sipobserver.h>
       
    27 #include <sipprofileregistryobserver.h>
       
    28 #include "TTcProfileReceived.h"
       
    29 #include "sipclientsimulatorcli.h"
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CSIP;
       
    33 class CTcSIPConnectionContainer;
       
    34 class CTcSIPProfileContainer;
       
    35 class CTcSIPHttpDigestContainer;
       
    36 class CTcSIPClientDiscoveryContainer;
       
    37 class CTcFreezer;
       
    38 class CTcFileHandler;
       
    39 class CTcSIPIMSAuthenticator;
       
    40 class CTcSIPIMSAuthenticationParams;
       
    41 
       
    42 // CLASS DEFINITION
       
    43 /**
       
    44  * CTcSIPContext implements the test context (MTcTestContext) for SIP testing.
       
    45  */
       
    46 class CTcSIPContext
       
    47 	: public CTcContextBase,
       
    48 	  public MSIPObserver
       
    49 	{
       
    50 	public:	// Constructors and destructor
       
    51 
       
    52 		/**
       
    53 		 * Static constructor. Leaves pointer to cleanup stack.
       
    54 		 *
       
    55 		 * @param aCodec Reference to CTRL codec object,
       
    56 		 *				 initialized to a valid request.
       
    57 		 * @param aIAPId IAPId as selected by user from TC settings.
       
    58          * @param aIsMandatory  used for determining if the SIP stack 
       
    59          *        is automatically started. If default value (ETrue) is used, 
       
    60          *        then SIP stack is started automatically.
       
    61 		 * @return An initialized instance of this class.
       
    62 		 */
       
    63 		static CTcSIPContext* NewLC( CTcCTRLCodec& aCodec,
       
    64 									 TInt aIAPId,
       
    65                                      TBool aIsMandatory );
       
    66 
       
    67 		/// Destructor
       
    68 		~CTcSIPContext();
       
    69 
       
    70 	private:
       
    71 
       
    72 		/**
       
    73 		 * Constructor.
       
    74 		 *
       
    75 		 * @param aCodec Reference to CTRL codec object,
       
    76 		 *				 initialized to a valid request.
       
    77 		 */
       
    78 		CTcSIPContext( CTcCTRLCodec& aCodec );
       
    79 
       
    80 		/// Default constructor. Not implemented.
       
    81 		CTcSIPContext();
       
    82 
       
    83 		/**
       
    84 		 * 2nd phase constructor
       
    85 		 *
       
    86 		 * @param aIAPId IAPId as selected by user from TC settings.
       
    87          * @param aIsMandatory  used for determining if the SIP stack 
       
    88          *        is automatically started. If default value (ETrue) is used, 
       
    89          *        then SIP stack is started automatically.
       
    90 		 */
       
    91 		void ConstructL( TInt aIAPId, TBool aIsMandatory  );
       
    92 
       
    93 	protected: // From CTcContextBase
       
    94 
       
    95 		TTcCommandBase* CreateCommandL( TTcIdentifier& aId,
       
    96 										MTcTestContext& aContext );
       
    97 
       
    98 	public: // From MSIPObserver
       
    99 
       
   100 		void IncomingRequest( TUint32 aIapId,
       
   101 							  CSIPServerTransaction* aTransaction );
       
   102 		void TimedOut( CSIPServerTransaction& aSIPServerTransaction );
       
   103     
       
   104 	public: // New methods
       
   105 
       
   106 		/// @return Reference to the default SIP connection.
       
   107 		inline CTcSIPConnectionContainer& Connection()
       
   108 				{ return *iSipConnection; }
       
   109 
       
   110         /// @return Reference to the default SIP profile.
       
   111         inline CTcSIPProfileContainer& Profile()
       
   112                 { return *iSipProfile; }
       
   113                 
       
   114         /// @return Reference to the FileHandler
       
   115         inline CTcFileHandler& FileHandler()
       
   116                 { return *iFileHandler; }     
       
   117 
       
   118 		/// @return Reference to the SIP stack.
       
   119 		inline CSIP& SIP()
       
   120 				{ return *iSip; }
       
   121 
       
   122 		/// @return Reference to the Internet Access Point name array
       
   123 		inline const MDesC8Array& IAPNames() const
       
   124 				{ return *iIapManager; }
       
   125 
       
   126 		/**
       
   127 		 * Lookup the CommDb IAP Id matching the provided IAP name.
       
   128 		 *
       
   129 		 * @param aName IAP name
       
   130 		 * @return IAP id
       
   131 		 */
       
   132 		inline TUint32 IAPIdL( const TDesC8& aName ) const
       
   133 				{ return iIapManager->IdForNameL( aName ); };
       
   134 
       
   135 		/**
       
   136 		 * Lookup the IAP Name matching the provided CommDb IAP Id.
       
   137 		 *
       
   138 		 * @param aIapId IAP id
       
   139 		 * @return IAP name reference
       
   140 		 */
       
   141 		inline const TDesC8& IAPNameL( TInt aIapId ) const
       
   142 				{ return iIapManager->NameForIdL( aIapId ); };
       
   143 
       
   144 		/**
       
   145 		 * Get reference to GetMandatoryValue
       
   146 		 * This is used only if SIP stack is created manually
       
   147 		 * @return boolean value indicating the 
       
   148          *         SIP stack state (ETrue==created)
       
   149 		 */
       
   150 		TBool GetMandatoryValue( void ) const;
       
   151 
       
   152 		/**
       
   153 		 * Create SIP stack
       
   154          * Create CSIP, CSIPConnection, CTcSIPConnectionContainer
       
   155          * and CTcSIPProfileContainer
       
   156 		 * This is used only if SIP stack is created manually
       
   157 		 */
       
   158         void CreateSipStack( void );
       
   159 		CTcSIPConnectionContainer* CreateSipStack( const TDesC8& aName ); //16.9.
       
   160 
       
   161         /**
       
   162          * Gives reference to the default SIP Http Digest container or 
       
   163          * leaves with KErrNotFound if container doesn't exist
       
   164          *
       
   165          */
       
   166         CTcSIPHttpDigestContainer& DigestContainerL();
       
   167         
       
   168         /**
       
   169 		 * Remove HttpDigest container 
       
   170 		 *
       
   171 		 */
       
   172 		void RemoveDigestContainer();
       
   173 		
       
   174 		/**
       
   175 		* Creates SIP ClientDiscovery container
       
   176 		* leaves with KErrAlreadyExists if container exists already
       
   177 		*/
       
   178 		void CreateClientDiscoveryL( TUid aUid );
       
   179 		
       
   180 		/**
       
   181 		* Removes SIP ClientDiscovery container
       
   182 		*/
       
   183 		void RemoveClientDiscovery();
       
   184 		
       
   185 		 /**
       
   186          * Gives reference to the SIP ClientDiscovery container or 
       
   187          * leaves with KErrNotFound if container doesn't exist
       
   188          *
       
   189          */
       
   190 		CTcSIPClientDiscoveryContainer& ClientDiscoveryL();
       
   191 		
       
   192 		/**
       
   193 		 * Freeze Tester thread asynchronously
       
   194 		 *
       
   195 		 */
       
   196 		void IssueFreezeL( TInt aFreezeTimeSeconds );
       
   197 		
       
   198 		/**
       
   199 		 * Freeze tester timer callback
       
   200 		 *
       
   201 		 */
       
   202 		static TInt Freeze( TAny* aAny );
       
   203 		
       
   204 		
       
   205 		/**
       
   206 		 * Authenticate
       
   207 		 */
       
   208 		CTcSIPIMSAuthenticationParams& AuthenticateL( const TDesC8& aNonce );
       
   209 		
       
   210 		/**
       
   211 		 * Map a CSIP error code to a verbose description
       
   212 		 *
       
   213 		 * @param aError One of CSIP::TError codes
       
   214 		 * @return Error message for the code
       
   215 		 */
       
   216 		const TDesC8& SIPErrorToText( TInt aError );
       
   217 
       
   218         RSipClientSimulator& SipClientSimulator();
       
   219         
       
   220         CRepository& Repository();
       
   221 
       
   222 	private: // data
       
   223 
       
   224         /// Boolean value indicating the SIP stack creation. Owned.
       
   225         TBool iIsMandatory;
       
   226 
       
   227 		/// Internet Access Point name/id list. Owned.
       
   228 		CTcIAPManager* iIapManager;
       
   229     
       
   230         /// IAP id. Owned.
       
   231         TInt iIAPId;
       
   232 
       
   233 		/// SIP stack. Owned.
       
   234 		CSIP* iSip;
       
   235 
       
   236 		/// Default SIP connection. Owned.
       
   237 		CTcSIPConnectionContainer* iSipConnection;
       
   238 
       
   239 		/// Default SIP profile. Owned.
       
   240 		CTcSIPProfileContainer* iSipProfile;
       
   241 		
       
   242 		/// Defaul SIP Http Digest. Owned.
       
   243 		CTcSIPHttpDigestContainer* iSipHttpDigest;
       
   244 		
       
   245 		/// Defaul SIP ClientDiscover. Owned.
       
   246 		CTcSIPClientDiscoveryContainer* iSipClientDiscovery;
       
   247 		
       
   248 		/// For Tester thread freezing
       
   249 		CDeltaTimer* iFreezer;
       
   250 		
       
   251 		TInt iFreezeTimeSeconds;
       
   252 		
       
   253 		TDeltaTimerEntry iTimerEntry;
       
   254 		
       
   255 		/// For file creation and deletion. Owned.
       
   256 		CTcFileHandler* iFileHandler;
       
   257 		
       
   258 		/// For IMS authentication. Owned.
       
   259 		CTcSIPIMSAuthenticator* iIMSAuthenticator;
       
   260 		
       
   261 		RSipClientSimulator iSipClientSimulator;
       
   262 		CRepository* iCenRep;
       
   263 	};
       
   264 
       
   265 #endif // __CTCSIPCONTEXT_H__