realtimenetprots/sipfw/SIP/TransactionUser/src/NormalUACStates.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Name          : NormalUACStates.cpp
       
    15 // Part of       : TransactionUser
       
    16 // Version       : SIP/5.0
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 #include "siperr.h"
       
    22 #include "SipAssert.h"
       
    23 #include "sipresponse.h"
       
    24 #include "sipaddress.h"
       
    25 #include "sipuri.h"
       
    26 #include "siphostport.h"
       
    27 
       
    28 #include "NormalUAC.h"
       
    29 #include "NormalUACStates.h"
       
    30 
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CNormalUAC_Start::CNormalUAC_Start
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CNormalUAC_Start::CNormalUAC_Start()
       
    37 	{
       
    38 	}
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // CNormalUAC_Start::~CNormalUAC_Start
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 CNormalUAC_Start::~CNormalUAC_Start()
       
    45 	{
       
    46 	}
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CNormalUAC_Start::SetNeighbourStates
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 void CNormalUAC_Start::SetNeighbourStates(CUserAgentState& aResolveAddress)
       
    53 	{    
       
    54 	iResolveAddress = &aResolveAddress;
       
    55 	}
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CNormalUAC_Start::SendRequestL
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 void CNormalUAC_Start::SendRequestL(CUserAgent& aUserAgent,
       
    62 									CSIPRequest* aReq,
       
    63 									TRegistrationId aRegisterId,
       
    64 									const CURIContainer& aRemoteTarget) const
       
    65 	{
       
    66     __SIP_ASSERT_LEAVE(aReq, KErrArgument);
       
    67 
       
    68 	CNormalUAC::Ptr(aUserAgent).HandleSendRequestL(aReq,
       
    69                                                    aRegisterId,
       
    70                                                    aRemoteTarget,
       
    71                                                    *iResolveAddress);
       
    72 	}
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // CNormalUAC_ResolveAddress::CNormalUAC_ResolveAddress
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 CNormalUAC_ResolveAddress::CNormalUAC_ResolveAddress()
       
    79 	{
       
    80 	}
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CNormalUAC_ResolveAddress::~CNormalUAC_ResolveAddress
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 CNormalUAC_ResolveAddress::~CNormalUAC_ResolveAddress()
       
    87 	{
       
    88 	}
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CNormalUAC_ResolveAddress::SetNeighbourStates
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 void
       
    95 CNormalUAC_ResolveAddress::SetNeighbourStates(CUserAgentState& aWaitResponse)
       
    96 	{    
       
    97 	iWaitResponse = &aWaitResponse;
       
    98 	}
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // CNormalUAC_ResolveAddress::IsResolving
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 TBool CNormalUAC_ResolveAddress::IsResolving() const
       
   105 	{
       
   106 	return ETrue;
       
   107 	}
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CNormalUAC_ResolveAddress::AddressResolvedL
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 void CNormalUAC_ResolveAddress::AddressResolvedL(CUserAgent& aUserAgent) const
       
   114 	{	
       
   115 	CNormalUAC::Ptr(aUserAgent).RemoteAddressResolvedL(*iWaitResponse);
       
   116 	}
       
   117 
       
   118 // -----------------------------------------------------------------------------
       
   119 // CNormalUAC_ResolveAddress::ResolvingFailed
       
   120 // -----------------------------------------------------------------------------
       
   121 //
       
   122 void CNormalUAC_ResolveAddress::ResolvingFailed(CUserAgent& aUserAgent) const
       
   123 	{
       
   124 	CNormalUAC::Ptr(aUserAgent).HandleResolvingFailure(*this, *iWaitResponse);
       
   125 	}
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // CNormalUAC_WaitResponse::CNormalUAC_WaitResponse
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 CNormalUAC_WaitResponse::CNormalUAC_WaitResponse()
       
   132 	{
       
   133 	}
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // CNormalUAC_WaitResponse::~CNormalUAC_WaitResponse
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 CNormalUAC_WaitResponse::~CNormalUAC_WaitResponse()
       
   140 	{
       
   141 	}
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // CNormalUAC_WaitResponse::SetNeighbourStates
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 void CNormalUAC_WaitResponse::SetNeighbourStates(
       
   148 	CUserAgentState& aResolveAddress,
       
   149 	CUserAgentState& aWaitAuthentication)
       
   150 	{
       
   151 	iResolveAddress = &aResolveAddress;
       
   152 	iWaitAuthentication = &aWaitAuthentication;
       
   153 	}
       
   154 
       
   155 // -----------------------------------------------------------------------------
       
   156 // CNormalUAC_WaitResponse::CanContinueWithoutOutgoingMsg
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 TBool CNormalUAC_WaitResponse::CanContinueWithoutOutgoingMsg(
       
   160 	TBool aFinalRespPassed) const
       
   161 	{
       
   162 	return aFinalRespPassed;
       
   163 	}
       
   164 
       
   165 // -----------------------------------------------------------------------------
       
   166 // CNormalUAC_WaitResponse::ReceiveL
       
   167 // -----------------------------------------------------------------------------
       
   168 //
       
   169 void CNormalUAC_WaitResponse::ReceiveL(CUserAgent& aUserAgent,
       
   170 	                                   CSIPResponse* aResponse) const
       
   171 	{
       
   172     __SIP_ASSERT_LEAVE(aResponse, KErrArgument);    
       
   173 
       
   174 	CNormalUAC& ua = CNormalUAC::Ptr(aUserAgent);
       
   175 	if (ua.PassResponseToSIPSecL(*aResponse))
       
   176 		{
       
   177 		ua.StoreResponse(aResponse);
       
   178 		aUserAgent.ChangeState(*iWaitAuthentication);
       
   179 		}
       
   180 	else
       
   181 		{
       
   182 		ua.ReceiveResponseL(aResponse, *iResolveAddress, *this, *this, *this);
       
   183 		}
       
   184 	}
       
   185 
       
   186 // -----------------------------------------------------------------------------
       
   187 // CNormalUAC_WaitResponse::TransactionEndsL
       
   188 // -----------------------------------------------------------------------------
       
   189 //
       
   190 void CNormalUAC_WaitResponse::TransactionEndsL(CUserAgent& aUserAgent,
       
   191 											   TInt aReason) const
       
   192 	{
       
   193 	CNormalUAC& ua = CNormalUAC::Ptr(aUserAgent);
       
   194 	if (ua.FinalRespPassed())
       
   195 		{
       
   196 		// MTransactionOwner got final response, so it sees the transaction has
       
   197 		//succeeded, even if aReason is an error now.		
       
   198 		aUserAgent.Stop(KErrNone);
       
   199 		}
       
   200 	else
       
   201 		{
       
   202 		ua.TransactionEndsWithoutFinalResponseL(aReason,
       
   203 											    *iResolveAddress,
       
   204 											    *this);
       
   205 		}
       
   206 	}
       
   207 
       
   208 // -----------------------------------------------------------------------------
       
   209 // CNormalUAC_WaitAuthentication::CNormalUAC_WaitAuthentication
       
   210 // -----------------------------------------------------------------------------
       
   211 //
       
   212 CNormalUAC_WaitAuthentication::CNormalUAC_WaitAuthentication()
       
   213 	{
       
   214 	}
       
   215 
       
   216 // -----------------------------------------------------------------------------
       
   217 // CNormalUAC_WaitAuthentication::~CNormalUAC_WaitAuthentication
       
   218 // -----------------------------------------------------------------------------
       
   219 //
       
   220 CNormalUAC_WaitAuthentication::~CNormalUAC_WaitAuthentication()
       
   221 	{
       
   222 	}
       
   223 
       
   224 // -----------------------------------------------------------------------------
       
   225 // CNormalUAC_WaitAuthentication::SetNeighbourStates
       
   226 // -----------------------------------------------------------------------------
       
   227 //
       
   228 void CNormalUAC_WaitAuthentication::SetNeighbourStates(
       
   229 	CUserAgentState& aResolveAddress,
       
   230 	CUserAgentState& aWaitResponse)
       
   231 	{
       
   232 	iResolveAddress = &aResolveAddress;
       
   233 	iWaitResponse = &aWaitResponse;
       
   234 	}
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // CNormalUAC_WaitAuthentication::SIPSecCacheUpdatedL
       
   238 // -----------------------------------------------------------------------------
       
   239 //
       
   240 void CNormalUAC_WaitAuthentication::SIPSecCacheUpdatedL(CUserAgent& aUserAgent,
       
   241 												   	    TBool aSuccess) const
       
   242 	{
       
   243 	CNormalUAC::Ptr(aUserAgent).SIPSecCacheUpdatedL(aSuccess,
       
   244 												    *iResolveAddress,
       
   245                                                     *iWaitResponse,
       
   246                                                     *iWaitResponse,
       
   247                                                     *iWaitResponse);
       
   248 	}
       
   249 
       
   250 // -----------------------------------------------------------------------------
       
   251 // CNormalUAC_WaitAuthentication::TransactionEndsL
       
   252 // -----------------------------------------------------------------------------
       
   253 //
       
   254 void CNormalUAC_WaitAuthentication::TransactionEndsL(CUserAgent& aUserAgent,
       
   255 													 TInt /*aReason*/) const
       
   256 	{
       
   257 	aUserAgent.RequestDeletionOfTransactionL();    
       
   258     CNormalUAC::Ptr(aUserAgent).IgnoreResponseRetransmissionsL();
       
   259 	}