realtimenetprots/sipfw/SIP/TransactionUser/src/UserAgentClient.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2007-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          : UserAgentClient.h
       
    16 * Part of       : TransactionUser
       
    17 * Version       : SIP/6.0
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 /**
       
    25  @internalComponent
       
    26 */
       
    27 
       
    28 #ifndef USERAGENTCLIENT_H
       
    29 #define USERAGENTCLIENT_H
       
    30 
       
    31 // INCLUDES
       
    32 #include "sipsecobserver.h"
       
    33 #include "MSIPServerResolverObserver.h"
       
    34 #include "CUserAgent.h"
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 class RStringF;
       
    38 class CSIPViaHeader;
       
    39 class CSIPSec;
       
    40 class CRouteSet;
       
    41 class CResolvingResults;
       
    42 
       
    43 // CLASS DECLARATION
       
    44 
       
    45 /**
       
    46  * This is a base class for all UACs. 
       
    47  */
       
    48 class CUserAgentClient :
       
    49 	public CUserAgent,
       
    50 	public MSIPServerResolverObserver,
       
    51 	public MSIPSecObserver
       
    52 	{
       
    53 public: // Destructor
       
    54 
       
    55 	virtual ~CUserAgentClient();
       
    56 
       
    57 public: // From CUserAgent
       
    58 
       
    59 	TBool IsUAS() const;
       
    60 
       
    61 protected: // From CUserAgent
       
    62 
       
    63 	virtual void CreateTransactionL() = 0;
       
    64 
       
    65 private:  // From CUserAgent
       
    66 
       
    67 	TRegistrationId RegistrationId() const;
       
    68 
       
    69 	/**
       
    70 	 * UAC detaches all references to the outgoing SIP message.
       
    71 	 * Depending on the current state of UAC; it may need to stop as in
       
    72 	 * certain states it cannot proceed without the outgoing SIP request.
       
    73 	 *
       
    74 	 * @post iOutgoingMsg = NULL
       
    75 	 */
       
    76 	virtual void DetachOutgoingMsg();
       
    77 
       
    78 public: // From MSIPServerResolverObserver
       
    79 
       
    80 	void CompletedL();
       
    81 
       
    82 	void ErrorOccured(TInt aError);	
       
    83 
       
    84 public:	// From MSIPSecObserver
       
    85 
       
    86 	void SIPSecCacheUpdated(TBool aSuccess);
       
    87 
       
    88 public: //New functions
       
    89 
       
    90 	/**
       
    91 	 * Handle a SIP request sent by upper layer. Request is checked, filled and
       
    92 	 * the remote address is determined and resolved. Transaction related parts
       
    93 	 * of the request are stored in CTransactionStore.
       
    94 	 *	 
       
    95 	 * @pre aReq != NULL
       
    96 	 *
       
    97 	 * @param aReq SIP request message. Ownership is transferred.
       
    98 	 * @param aRegistrationId Registration id by which TU tries to find an
       
    99 	 *	outbound proxy for the request.
       
   100 	 * @param aRemoteTarget Remote target of the request
       
   101      * @param aResolve State the UAC will enter when it starts resolving URI
       
   102 	 */
       
   103 	void HandleSendRequestL(CSIPRequest* aReq,
       
   104 							TRegistrationId aRegisterId,
       
   105 							const CURIContainer& aRemoteTarget,
       
   106                             const CUserAgentState& aResolve);
       
   107 
       
   108 	/**
       
   109 	 * Handle a SIP response received from network.
       
   110 	 *	 
       
   111 	 * @pre aResp != NULL
       
   112 	 *
       
   113 	 * @param aResp SIP response, ownership is transferred
       
   114 	 * @param aResolve State the UAC enters if it starts resolving URI
       
   115 	 * @param aWaitResponse State the UAC enters if it sends the request again
       
   116 	 * @param aWaitAckFromApp State InviteUAC enters if a 2xx response is
       
   117 	 *	passed to upper layer
       
   118 	 * @param aWaitTransactionToEnd State InviteUAC enters if an error response
       
   119 	 *	is passed to upper layer	 
       
   120 	 */	
       
   121 	virtual void ReceiveResponseL(CSIPResponse* aResp,						  
       
   122 						  const CUserAgentState& aResolve,
       
   123 						  const CUserAgentState& aWaitResponse,
       
   124 						  const CUserAgentState& aWaitAckFromApp,
       
   125 						  const CUserAgentState& aWaitTransactionToEnd) = 0;
       
   126 	
       
   127 	/**
       
   128 	 * Sets the value for CUserAgent::iOwnsOutgoingMsg
       
   129 	 *
       
   130 	 * @param aOwnsRequest ETrue: UAC owns the request in the send buffer
       
   131 	 *	(CUserAgent::iOutgoingMsg), EFalse: UAC doesn't own the request.
       
   132 	 */	
       
   133 	void SetRequestOwnership(TBool aOwnsRequest);
       
   134 
       
   135 	/**
       
   136 	 * Store the SIP response for asynchronous processing.
       
   137 	 *	 
       
   138 	 * @pre iIncomingMsg == NULL
       
   139 	 *
       
   140 	 * @param aResponse SIP response, ownership is transferred.
       
   141 	 */	
       
   142 	void StoreResponse(CSIPResponse* aResponse);
       
   143 
       
   144 	/**
       
   145 	 * Pick the next remote address and transport protocol from the resolved
       
   146 	 * addresses.
       
   147 	 *	 
       
   148 	 * @pre iOutgoingMsg != NULL && iResolvingResults != NULL
       
   149 	 *
       
   150 	 * @return ETrue if an address and protocol were found. EFalse if no more
       
   151 	 *	addresses are to try.
       
   152 	 */	
       
   153 	TBool SelectNextRemoteAddressL();
       
   154 
       
   155 	/**
       
   156 	 * The remote address has now been resolved and UAC can send the SIP
       
   157 	 * request to CTransaction.
       
   158 	 *
       
   159 	 * @param aNextState State where UAC moves after sending the request	 
       
   160 	 */	
       
   161 	void RemoteAddressResolvedL(const CUserAgentState& aNextState);	
       
   162 
       
   163 	/**
       
   164 	 * Returns information whether the UserAgent has passed a final response to
       
   165 	 * the upper layer.
       
   166 	 *
       
   167 	 * @return ETrue: UAC has already passed a final response, no more
       
   168 	 *	responses can be passed. EFalse: final response not passed.
       
   169 	 */
       
   170 	TBool FinalRespPassed() const;
       
   171 
       
   172 	/**
       
   173 	 * Dummy timer used to make a synchronous SIPSec call to work as
       
   174 	 * asynchronous, has completed.
       
   175 	 */
       
   176 	void SIPSecTimerExpiredL();
       
   177 
       
   178 	/**
       
   179 	 * SIPSec processing has been completed.
       
   180 	 */
       
   181 	TInt SIPSecReady(TBool aSuccess);
       
   182 
       
   183 	/**
       
   184 	 * SIPSec has completed updating the cache.
       
   185 	 *
       
   186 	 * @pre iIncomingMsg != NULL	 
       
   187 	 * @post iIncomingMsg == NULL
       
   188 	 *
       
   189 	 * @param aSuccess status of the authorized SIP request
       
   190 	 *		  ETrue: SIPSec has executed successfully
       
   191 	 *		  EFalse: otherwise
       
   192 	 * @param aResolve State the UAC enters if it starts resolving URI
       
   193 	 * @param aWaitResponse State the UAC enters if it sends the request again
       
   194 	 * @param aWaitAckFromApp State InviteUAC enters if a 2xx response is
       
   195 	 *	passed to upper layer
       
   196 	 * @param aWaitTransactionToEnd State InviteUAC enters if an error response
       
   197 	 *	is passed to upper layer	 
       
   198 	 *	upper layer	 
       
   199 	 */
       
   200 	void SIPSecCacheUpdatedL(TBool aSuccess,
       
   201 						     const CUserAgentState& aResolve,
       
   202 						     const CUserAgentState& aWaitResponse,
       
   203 							 const CUserAgentState& aWaitAckFromApp,
       
   204 							 const CUserAgentState& aWaitTransactionToEnd);
       
   205 
       
   206 	/**
       
   207 	 * Offers the aResp to SIPSec for processing.
       
   208 	 * Provisional responses are not offered.
       
   209 	 *
       
   210 	 * @pre iOutgoingMsg != NULL && iRemoteTarget != NULL
       
   211 	 *
       
   212 	 * @param aResp SIP response received from the network.
       
   213      * @return ETrue  SIPSec processes the response asynchronously.     
       
   214      *		   EFalse SIPSec has synchronously processed the response.     
       
   215 	 */
       
   216 	TBool PassResponseToSIPSecL(CSIPResponse& aResp);
       
   217 
       
   218     /**
       
   219 	 * If UAC has more remote addresses to try, updates the SIP request and
       
   220 	 * sends it to the next address using a new CTransaction object.
       
   221 	 *
       
   222 	 * @param aError Reason why the next address will be tried. If aError is
       
   223 	 *	KErrNone, aResp must have a SIP response. If aError is not KErrNone,
       
   224 	 *	aResp must be NULL.
       
   225 	 * @param aResolve State which UAC will enter if it decides to resolve the
       
   226 	 *	outbound proxy.
       
   227 	 * @param aWaitResponse State which UAC enters if it decides to send
       
   228 	 *	request to the next ip-address.
       
   229 	 * @param aResp If transaction ended because of SIP response, this is the
       
   230 	 *	response. Ownership is transferred if TryNextAddressL returns ETrue.
       
   231      * @return value ETrue if the request will be sent to next address.
       
   232      *	Ownership of aResp has been taken.
       
   233 	 *	EFalse If request won't be sent again. Ownership of aResp has not been
       
   234 	 *	taken.
       
   235 	 */
       
   236 	TBool TryNextAddressL(TInt aError,
       
   237 						  const CUserAgentState& aResolve,
       
   238 						  const CUserAgentState& aWaitResponse,
       
   239 						  CSIPResponse* aResp = NULL);
       
   240 
       
   241 	/**
       
   242 	 * UAC receives a response from network. Determines whether UAC should
       
   243 	 * send the original request again, possibly to another address, or should
       
   244 	 * UAC pass the response to upper layer.
       
   245 	 *
       
   246 	 * @pre aResp != NULL	 
       
   247 	 *
       
   248 	 * @param aResp SIP response. If UAC sends the original request again, the
       
   249 	 *	ownership of aResp is transferred.
       
   250 	 * @param aResolve State which UAC enters if it decides to resolve the
       
   251 	 *	outbound proxy.
       
   252 	 * @param aWaitResponse State which UAC enters if it decides to send
       
   253 	 *	request to the next ip-address.
       
   254 	 * @return ETrue: UAC sends the request again and aResp isn't passed to
       
   255 	 *	upper layer. Ownership of aResp has been taken.
       
   256 	 *	EFalse: aResp should be passed to upper layer and it's ownership has
       
   257 	 *  not been taken.
       
   258 	 */
       
   259 	TBool ShouldUaTryAgainL(CSIPResponse* aResp,
       
   260 						    const CUserAgentState& aResolve,
       
   261 						    const CUserAgentState& aWaitResponse);
       
   262 
       
   263 	/**
       
   264 	 * CTransaction has ended before a final response was received
       
   265 	 *
       
   266 	 * @param aReason Reason why CTransaction ended
       
   267 	 * @param aResolve State which UAC will enter if it decides to resolve URI
       
   268 	 * @param aWaitResponse State which UAC enters if it decides to send
       
   269 	 *	request to the next ip-address.	 
       
   270 	 */    
       
   271 	void TransactionEndsWithoutFinalResponseL(TInt aReason,
       
   272 									 const CUserAgentState& aResolve,
       
   273 									 const CUserAgentState& aWaitResponse);
       
   274 
       
   275     /**
       
   276 	 * Remove message headers from CTransactionStore, so that in case a
       
   277      * retransmission of a response is received, it will be dropped.
       
   278      * This is required when ClientTransaction terminates before SIPSec has
       
   279      * completed adding authentication parameters to the request.	 
       
   280 	 */
       
   281     void IgnoreResponseRetransmissionsL();	
       
   282 
       
   283     /**
       
   284 	 * Cancel a pending asynchronous request issued to SIPSec.	 
       
   285 	 */
       
   286     void CancelSIPSecRequest();
       
   287 
       
   288 	/**
       
   289 	 * Stores the remote target, replacing the possibly existing value.
       
   290 	 *
       
   291 	 * @param aRemoteTarget Remote target
       
   292 	 */
       
   293 	void StoreRemoteTargetL(const CURIContainer& aRemoteTarget);	
       
   294 
       
   295 	/**
       
   296 	 * Handle the situation when resolving address has failed.
       
   297 	 *	 
       
   298 	 * @param aResolve State which UAC will enter if it decides to resolve
       
   299 	 *	another address
       
   300 	 * @param aWaitResponse State which UAC enters if it decides to send
       
   301 	 *	request to the next ip-address.	 
       
   302 	 */							  
       
   303 	void HandleResolvingFailure(const CUserAgentState& aResolve,
       
   304 						  		const CUserAgentState& aWaitResponse);
       
   305 
       
   306     /**
       
   307 	 * Returns the next hop address.	 
       
   308 	 */
       
   309 	const TInetAddr& NextHopIP() const;
       
   310 	
       
   311 protected:
       
   312 
       
   313 	CUserAgentClient(CUserAgentCreateParams& aParams,
       
   314 					 MSipUriResolver& aResolver,
       
   315 					 CSIPSec& aSIPSec,
       
   316 					 TUint32 aCSeqNumber);
       
   317 
       
   318 	void ConstructL();	
       
   319 
       
   320 	/**
       
   321 	 * Fills new Via header with branch, to the aReq.
       
   322 	 * Host part will be filled later by ConnectionMgr.
       
   323 	 *
       
   324 	 * @post aReq has one Via header
       
   325 	 * @param aReq SIP request
       
   326 	 * @param aBranch The branch value to put into the Via-header.
       
   327 	 *		  If this is an empty string, a new branch is generated.
       
   328 	 */
       
   329 	void FillNewViaL(CSIPRequest& aReq, RStringF aBranch) const;
       
   330 
       
   331     /**
       
   332 	 * Stores the Request-URI of aReq into iRequestUri member. If iRequestUri
       
   333 	 * already had a value, it is replaced with the new value.
       
   334 	 *
       
   335 	 * @pre aReq.RequestURI() != NULL
       
   336 	 * @post iRequestUri != NULL
       
   337 	 *
       
   338 	 * @param aReq SIP request
       
   339 	 */
       
   340 	void StoreRequestUriL(CSIPRequest &aReq);
       
   341 
       
   342 	/**
       
   343 	 * Updates the SIP request, so it can be re-sent after modifying it, or
       
   344 	 * after obtaining another address.
       
   345 	 * Current Via is removed and an updated Via with a new branch and
       
   346 	 * transport to match the new remote address. CSeq is always updated.	 
       
   347 	 *
       
   348 	 * @pre iOutgoingMsg != NULL
       
   349 	 * @post The request in iOutgoingMsg has new Via branch & CSeq number
       
   350 	 */
       
   351 	void UpdateViaAndCSeqL() const;
       
   352 
       
   353 	/**
       
   354 	 * Updates transaction object and some SIP message headers to the
       
   355 	 * CTransactionStore.
       
   356 	 *
       
   357 	 * @param aReq SIP request from where a certain headers are updated to
       
   358 	 *	the store. If NULL, the headers are not updated.
       
   359 	 */
       
   360 	void UpdateInfoToStoreL(CSIPRequest* aReq) const;
       
   361 
       
   362 	/**
       
   363 	 * Sends the SIP request in the send buffer (CUserAgent::iOutgoingMsg) to
       
   364 	 * network. If the request is ACK, it is sent directly with CTransmitter.
       
   365 	 * Other requests are sent using CTransaction.
       
   366 	 *
       
   367 	 * @pre iOutgoingMsg != NULL
       
   368 	 */
       
   369 	void SendRequestToNetworkL();
       
   370 
       
   371 	/**
       
   372 	 * Passes the response to upper layer, except 100 response.	 
       
   373 	 *
       
   374 	 * @pre aResp != NULL, iFinalRespPassed == EFalse	 
       
   375 	 *
       
   376 	 * @param aResp SIP response, ownership is transferred
       
   377 	 * @param aUserAgent If non-NULL, points to UserAgent which has aTimer
       
   378 	 * @param aTimer If non-NULL, points to timer that will be stopped
       
   379 	 */
       
   380 	void PassRespToTransactionOwnerL(CSIPResponse* aResp,
       
   381 									 CUserAgent* aUserAgent=NULL,
       
   382 									 CUserAgentTimer* aTimer=NULL);
       
   383 	
       
   384 	/**
       
   385 	 * Copies the currently used remote address and transport protocol from the
       
   386 	 * given UAC (aSrc).
       
   387 	 *
       
   388 	 * @param aSrc UAC from which the address is copied
       
   389 	 */	
       
   390 	void CopyRemoteAddress(const CUserAgentClient& aSrc);
       
   391 
       
   392 	/**
       
   393 	 * Copies the route set and remote target from the given UAC (aSrc).
       
   394 	 *
       
   395 	 * @pre iRouteSet = NULL
       
   396 	 * @pre iRemoteTarget = NULL
       
   397 	 * @pre aSrc.iRouteSet != NULL
       
   398 	 * @pre aSrc.iRemoteTarget != NULL
       
   399 	 * @param aSrc UAC from which the route set and remote target are copied
       
   400 	 */
       
   401 	void CopyRouteSetAndRemoteTargetL(const CUserAgentClient& aSrc);    
       
   402 
       
   403 	/**
       
   404 	 * If UAC used a pre-configured route, but that failed, UAC tries to send
       
   405 	 * the request to outbound proxy (if one has been configured).
       
   406 	 *
       
   407 	 * @param aResolve State which UAC will enter if it decides to try and
       
   408 	 *	resolve the outbound proxy.
       
   409 	 * @return value ETrue if the request will be sent to next address,
       
   410 	 *	EFalse otherwise
       
   411 	 */
       
   412 	TBool TryOutboundProxyL(const CUserAgentState& aResolve);	
       
   413 
       
   414 	/**
       
   415 	 * Gets the next hop URI.
       
   416 	 *
       
   417 	 * @pre iRouteSet != NULL
       
   418 	 * @pre iRemoteTarget != NULL
       
   419 	 * @param aUseResolvedProxy, ETrue if resolved address of registration
       
   420 	 * @return CURIContainer& Next hop URI
       
   421 	 */
       
   422 	CURIContainer& NextHopL(TBool aUseResolvedProxy = EFalse) const;
       
   423 
       
   424 	/**
       
   425 	 * Resolves the next hop URI.
       
   426 	 *  
       
   427 	 * @param aCheckSigComp ETrue if sigcomp support is checked, EFalse
       
   428 	 * @param aUseResolvedProxy, ETrue if resolved address of registration
       
   429 	 *	otherwise.
       
   430 	 */
       
   431 	void ResolveNextHopL(TBool aCheckSigComp,TBool aUseResolvedProxy = EFalse);
       
   432     
       
   433 	/**
       
   434 	 * Makes sure the CTransmitter is ready to be used for an updated request.
       
   435 	 *
       
   436      * @param aNewTransactionId TransactionId that is given to the old
       
   437      *  transaction.
       
   438 	 */
       
   439     virtual void PrepareTxForNewRequestL(TTransactionId& aNewTransactionId) = 0;
       
   440 
       
   441     /**
       
   442 	 * Let SIPSec fill the security parameters into outgoing request.
       
   443 	 *
       
   444 	 * @pre iOutgoingMsg != NULL, iRemoteTarget != NULL
       
   445 	 *
       
   446 	 * @return value ETrue if successful, EFalse in case of error
       
   447 	 */
       
   448 	TBool FillSecurityParamsL();
       
   449 
       
   450 protected: // Data
       
   451 
       
   452 	//SIP Security subsystem
       
   453 	CSIPSec& iSIPSec;
       
   454 
       
   455 	//CSeq sequence number to use in the SIP request, unless filled by upper
       
   456 	//layer.
       
   457 	TUint32 iCSeqNumber;
       
   458 
       
   459 	//Address where the request is sent
       
   460 	TInetAddr iRemoteAddr;
       
   461 
       
   462 	//ETrue if the transport of iRemoteAddr must not be changed from UDP
       
   463 	TBool iForceUDP;
       
   464 
       
   465 	//RegistrationId provided by the upper layer when it sent the request.	
       
   466 	TRegistrationId iRegisterId;
       
   467 
       
   468     //Route set associated with the SIP request, owned.
       
   469     CRouteSet* iRouteSet;
       
   470 
       
   471 	//Remote target of the SIP request, owned.
       
   472     CURIContainer* iRemoteTarget;
       
   473 
       
   474 	//Resolver subsystem
       
   475 	MSipUriResolver& iResolver;
       
   476 
       
   477 	//Results obtained from resolving an URI. Owned.
       
   478 	CResolvingResults* iResolvingResults;
       
   479 	
       
   480 	//SIPSec Error
       
   481 	TInt iSipSecError;
       
   482 
       
   483 private:
       
   484 
       
   485 	/**
       
   486 	 * Fill the transaction related headers to the SIP request, unless they
       
   487 	 * have already been filled.
       
   488 	 *
       
   489 	 * @pre aReq must contain From header
       
   490 	 * @pre iRemoteTarget != NULL	 
       
   491 	 *
       
   492 	 * @param aReq SIP request which is filled	 
       
   493 	 */
       
   494 	void FillRequestL(CSIPRequest& aReq) const;
       
   495 
       
   496 	/**
       
   497 	 * Fills Call-ID header into aReq
       
   498 	 *
       
   499 	 * @param aReq SIP request	 
       
   500 	 */
       
   501 	void FillNewCallIdL(CSIPRequest& aReq) const;	
       
   502 
       
   503 	/**
       
   504 	 * Sets branch parameter to Via header.
       
   505 	 *
       
   506 	 * @post aVia Via header
       
   507 	 * @param aBranch The branch value to put into the Via-header.
       
   508 	 *		  If this is an empty string, a new branch is generated.
       
   509 	 */
       
   510 	void SetBranchL(CSIPViaHeader& aVia, RStringF aBranch) const;
       
   511 
       
   512 	/**
       
   513 	 * Processes the status of a SIPSec operation that can leave. If SIPSec
       
   514 	 * reported an error, UAC is stopped and HandleSIPSecErrorL leaves.
       
   515 	 *
       
   516 	 * @param aError If leave occurred from the SIPSec operation, this is the
       
   517 	 *				 leave code. Otherwise KErrNone.
       
   518 	 * @leave If aError != KErrNone, HandleSIPSecErrorL will leave.
       
   519 	 */
       
   520 	void HandleSIPSecErrorL(TInt aError);
       
   521 
       
   522     /**
       
   523 	 * Client transaction terminated because of a timeout.
       
   524      * If the request was sent compressed, send it uncompressed to the same
       
   525      * address. Otherwise if there are other addresses to try, they are
       
   526      * used and resolved if necessary.
       
   527 	 *
       
   528 	 * @param aResolve UAC will enter this state if it decides to resolve URI.
       
   529 	 *	Resolving isn't done if UAC already has more resolving results to try.
       
   530 	 * @param aWaitResponse UAC enters this state if it sends request again.
       
   531 	 * @return value ETrue if UAC sends the request again or resolves another
       
   532      *  address. EFalse if UAC can't continue and will end.
       
   533 	 */
       
   534     TBool HandleTimeoutL(const CUserAgentState& aResolve,
       
   535     					 const CUserAgentState& aWaitResponse);	
       
   536 
       
   537     /**
       
   538 	 * Updates Request-URI and Route-headers of the request when reverting to
       
   539      * try the outbound proxy.
       
   540 	 *
       
   541 	 * @param aProxy Outbound proxy URI	 	 
       
   542 	 */
       
   543     void UpdateRequestUriAndRouteL(const CURIContainer& aProxy);
       
   544 	
       
   545 	/**
       
   546 	 * Detach the current CTransaction object owned by the UserAgent. If the
       
   547 	 * CTransaction has reached Terminated state, it is freed using DeleteMgr,
       
   548 	 * otherwise it'll run independently of the UserAgent and when it enters
       
   549 	 * Terminated state, it'll delete itself using DeleteMgr.	 
       
   550 	 */	
       
   551 	void DetachCurrentTransactionL();
       
   552 
       
   553 	/**
       
   554 	 * Updates the SIP request and sends it using a new CTransaction object.
       
   555 	 *
       
   556 	 * The information of the current CTransaction object is removed from
       
   557 	 * CTransactionStore, and the old CTransaction is detached from UserAgent.
       
   558 	 * A new CTransaction instance is created and its information is added into
       
   559 	 * the CTransactionStore and the SIP request is sent to the new
       
   560 	 * CTransaction.
       
   561 	 *	 
       
   562 	 * @pre iOutgoingMsg != NULL
       
   563 	 *	 
       
   564 	 * @param aResolve UAC enters this state
       
   565 	 */
       
   566 	void UpdateAndSendRequestL(const CUserAgentState& aWaitResponse);
       
   567 
       
   568 	/**
       
   569 	 * Updates the SIP request, resolves the next hop URI and enters state
       
   570 	 * aResolve.
       
   571 	 *
       
   572 	 * @pre iOutgoingMsg != NULL
       
   573 	 *	 
       
   574 	 * @param aCheckSigComp ETrue if sigcomp is checked from aUri
       
   575 	 * @param aResolve UAC enters this state
       
   576 	 */
       
   577 	void UpdateAndResolveL(TBool aCheckSigComp,
       
   578 						   const CUserAgentState& aResolve);
       
   579 
       
   580     /**
       
   581 	 * Stop with a previously stored error code. If a stored response exists,
       
   582 	 * pass it to upper layer before stopping.
       
   583 	 */
       
   584 	void StopWithLastError();	
       
   585 
       
   586 	/**
       
   587 	 * If the next hop is an outbound proxy, this function returns the outbound
       
   588 	 * proxy as descriptor. Otherwise returns an empty descriptor.	 
       
   589 	 *
       
   590 	 * @return const TDesC8& Outbound proxy, or empty descritor.
       
   591 	 */
       
   592 	const TDesC8& ProxyL() const;
       
   593 
       
   594 	/**
       
   595 	 * Determine if SIP messages should be handed to SIPSec or not.
       
   596 	 * @return ETrue if SIP messages are given to SIPSec, EFalse otherwise
       
   597 	 */
       
   598 	TBool UseSIPSec() const;
       
   599 
       
   600 private: // Data
       
   601 
       
   602 	// Indicates if UAC has passed a final response to MTransactionOwner
       
   603 	TBool iFinalRespPassed;
       
   604 
       
   605 	// Tells if any SIP response has been received.
       
   606 	TBool iResponseReceived;
       
   607 
       
   608     // ETrue if UAC has attempted to resolve the outbound proxy, or sent a
       
   609     // request to the outbound proxy. EFalse otherwise.
       
   610     TBool iOutboundProxyHasBeenTried;
       
   611 
       
   612 	// Request-URI of the request, owned
       
   613 	CURIContainer* iRequestUri;
       
   614 
       
   615     // Incremented each time a request and response are passed to SIPSec.
       
   616     // Prevents infinite loop if the server always re-challenges.
       
   617     TInt iSIPSecCounter;
       
   618 
       
   619 	// If transaction fails and UAC resolves the current URI again, the reason
       
   620 	// why transaction failed is stored here. If resolving the same URI fails,
       
   621 	// the stored error is passed to upper layer.
       
   622     TInt iLastError;
       
   623 
       
   624 	// Normally EFalse. Temporarily set to ETrue to ignore SIPSec's callback
       
   625 	// when UAC cancels its pending SIPSec requests.
       
   626 	TBool iIgnoreSIPSecCallback;
       
   627 
       
   628 private: // For testing purposes
       
   629 
       
   630 #ifdef CPPUNIT_TEST	
       
   631 	friend class CUserAgentClient_Test;
       
   632 	friend class CTransactionUser_Test;
       
   633 	friend class CNormalUAC_ResolveAddress_Test;
       
   634 	friend class CNormalUAC_WaitResponse_Test;
       
   635 	friend class CInviteUAC_ResolveAddress_Test;
       
   636 	friend class CInviteUAC_WaitResponse_Test;
       
   637 	friend class CInviteUAC_WaitAckFromApp_Test;
       
   638 	friend class CInviteUAC_ResolveAckAddress_Test;
       
   639 	friend class CInviteUAC_SendingAck_Test;
       
   640 	friend class CInviteUAC_Start_Test;
       
   641 	friend class CUserAgent_Test;
       
   642 	friend class CTransactionStore_Test;	
       
   643 #endif
       
   644 
       
   645 	void __DbgTestInvariant() const;
       
   646 
       
   647 	};
       
   648 
       
   649 #endif // end of USERAGENTCLIENT_H
       
   650 
       
   651 // End of File