realtimenetprots/sipfw/SIP/TransactionUser/src/NormalUASStates.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          : NormalUASStates.cpp
       
    15 // Part of       : TransactionUser
       
    16 // Version       : SIP/5.0
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 #include "siperr.h"
       
    22 #include "siprequest.h"
       
    23 #include "sipresponse.h"
       
    24 #include "SipAssert.h"
       
    25 
       
    26 #include "NormalUAS.h"
       
    27 #include "NormalUASStates.h"
       
    28 #include "SIPMessageUtility.h"
       
    29 
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // CNormalUAS_Start::CNormalUAS_Start
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CNormalUAS_Start::CNormalUAS_Start()
       
    36 	{
       
    37 	}
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CNormalUAS_Start::~CNormalUAS_Start
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 CNormalUAS_Start::~CNormalUAS_Start()
       
    44 	{
       
    45 	}
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CNormalUAS_Start::SetNeighbourStates
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 void CNormalUAS_Start::SetNeighbourStates(CUserAgentState& aGetTxOwner,
       
    52 										  CUserAgentState& aWaitRespFromApp,
       
    53 										  CUserAgentState& aFinalRespSent)
       
    54 	{
       
    55 	iGetTxOwner = &aGetTxOwner;
       
    56 	iWaitRespFromApp = &aWaitRespFromApp;
       
    57 	iFinalRespSent = &aFinalRespSent;
       
    58 	}
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // CNormalUAS_Start::TransactionEndsL
       
    62 // Happens if MSIPRequestRouter leaves.
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 void
       
    66 CNormalUAS_Start::TransactionEndsL(CUserAgent& aUserAgent, TInt aReason) const
       
    67 	{
       
    68 	aUserAgent.Stop(aReason);
       
    69 	}
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CNormalUAS_Start::ReceiveL
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 void
       
    76 CNormalUAS_Start::ReceiveL(CUserAgent& aUserAgent, CSIPRequest* aRequest) const
       
    77 	{
       
    78     __SIP_ASSERT_LEAVE(aRequest, KErrArgument);    
       
    79 
       
    80 	CNormalUAS::Ptr(aUserAgent).InitialRequestReceivedL(aRequest,
       
    81 													    *iGetTxOwner,
       
    82 													    *iWaitRespFromApp,
       
    83 													    *iFinalRespSent);
       
    84 	}
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CNormalUAS_Start::SendResponseL
       
    88 // Application shouldn't know about this transaction yet.
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 void
       
    92 CNormalUAS_Start::SendResponseL(CUserAgent& /*aUserAgent*/,
       
    93 								CSIPResponse* aResp,
       
    94 								const TSIPTransportParams& /*aParams*/) const
       
    95 	{
       
    96     __SIP_ASSERT_LEAVE(aResp, KErrArgument);
       
    97 
       
    98 	User::Leave(KErrSIPInvalidTransactionState);
       
    99 	}
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CNormalUAS_GetTxOwner::CNormalUAS_GetTxOwner
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 CNormalUAS_GetTxOwner::CNormalUAS_GetTxOwner()
       
   106 	{
       
   107 	}
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CNormalUAS_GetTxOwner::~CNormalUAS_GetTxOwner
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 CNormalUAS_GetTxOwner::~CNormalUAS_GetTxOwner()
       
   114 	{
       
   115 	}
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CNormalUAS_GetTxOwner::SetNeighbourStates
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 void
       
   122 CNormalUAS_GetTxOwner::SetNeighbourStates(CUserAgentState& aWaitRespFromApp,
       
   123 							   			  CUserAgentState& aFinalRespSent)
       
   124 	{
       
   125 	iWaitRespFromApp = &aWaitRespFromApp;
       
   126 	iFinalRespSent = &aFinalRespSent;
       
   127 	}
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CNormalUAS_GetTxOwner::OwnerFoundL
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 void CNormalUAS_GetTxOwner::OwnerFoundL(CUserAgent& aUserAgent,
       
   134                                         MTransactionOwner* aOwner) const
       
   135 	{
       
   136     __SIP_ASSERT_LEAVE(aOwner, KErrArgument);
       
   137 
       
   138 	CNormalUAS::Ptr(aUserAgent).HandleOwnerFoundL(aOwner, *iWaitRespFromApp);
       
   139 	}
       
   140 
       
   141 // -----------------------------------------------------------------------------
       
   142 // CNormalUAS_GetTxOwner::OwnerNotFoundL
       
   143 // No application found, MSIPRequestRouter gave a SIP response to send.
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 void CNormalUAS_GetTxOwner::OwnerNotFoundL(CUserAgent& aUserAgent,
       
   147 										   CSIPResponse* aResp) const
       
   148 	{
       
   149     __SIP_ASSERT_LEAVE(aResp, KErrArgument);
       
   150 
       
   151 	CNormalUAS::Ptr(aUserAgent).HandleOwnerNotFoundL(aResp, *iFinalRespSent);
       
   152 	}
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // CNormalUAS_GetTxOwner::RequestRouterErrorL
       
   156 // -----------------------------------------------------------------------------
       
   157 //
       
   158 void CNormalUAS_GetTxOwner::RequestRouterErrorL(CUserAgent& aUserAgent) const
       
   159 	{
       
   160 	static_cast<CUserAgentServer*>(&aUserAgent)->
       
   161         HandleRequestRouterErrorL(*iFinalRespSent);
       
   162 	}
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // CNormalUAS_GetTxOwner::SendResponseL
       
   166 // Application shouldn't know about this transaction yet.
       
   167 // -----------------------------------------------------------------------------
       
   168 //
       
   169 void CNormalUAS_GetTxOwner::SendResponseL(CUserAgent& /*aUserAgent*/,
       
   170 	CSIPResponse* aResp,
       
   171 	const TSIPTransportParams& /*aParams*/) const
       
   172 	{
       
   173     __SIP_ASSERT_LEAVE(aResp, KErrArgument);
       
   174 
       
   175 	User::Leave(KErrSIPInvalidTransactionState);
       
   176 	}
       
   177 
       
   178 // -----------------------------------------------------------------------------
       
   179 // CNormalUAS_GetTxOwner::TransactionEndsL
       
   180 // -----------------------------------------------------------------------------
       
   181 //
       
   182 void CNormalUAS_GetTxOwner::TransactionEndsL(CUserAgent& aUserAgent,
       
   183 											 TInt aReason) const
       
   184 	{
       
   185 	aUserAgent.Stop(aReason);
       
   186 	}
       
   187 
       
   188 // -----------------------------------------------------------------------------
       
   189 // CNormalUAS_GetTxOwner::TimerExpiredL
       
   190 // -----------------------------------------------------------------------------
       
   191 //
       
   192 void CNormalUAS_GetTxOwner::TimerExpiredL(CUserAgent& aUserAgent,
       
   193 									      TTimerId aTimerId,
       
   194 										  TAny* aTimerParam) const
       
   195 	{
       
   196     __SIP_ASSERT_LEAVE(aTimerParam, KErrArgument);    
       
   197 
       
   198 	HandleTimerExpirationL(aUserAgent, aTimerId, aTimerParam);
       
   199 	}
       
   200 
       
   201 // -----------------------------------------------------------------------------
       
   202 // CNormalUAS_WaitRespFromApp::CNormalUAS_WaitRespFromApp
       
   203 // -----------------------------------------------------------------------------
       
   204 //
       
   205 CNormalUAS_WaitRespFromApp::CNormalUAS_WaitRespFromApp()
       
   206 	{
       
   207 	}
       
   208 
       
   209 // -----------------------------------------------------------------------------
       
   210 // CNormalUAS_WaitRespFromApp::~CNormalUAS_WaitRespFromApp
       
   211 // -----------------------------------------------------------------------------
       
   212 //
       
   213 CNormalUAS_WaitRespFromApp::~CNormalUAS_WaitRespFromApp()
       
   214 	{
       
   215 	}
       
   216 
       
   217 // -----------------------------------------------------------------------------
       
   218 // CNormalUAS_WaitRespFromApp::SetNeighbourStates
       
   219 // -----------------------------------------------------------------------------
       
   220 //
       
   221 void
       
   222 CNormalUAS_WaitRespFromApp::SetNeighbourStates(CUserAgentState& aFinalRespSent)
       
   223 	{
       
   224 	iFinalRespSent = &aFinalRespSent;
       
   225 	}
       
   226 
       
   227 // -----------------------------------------------------------------------------
       
   228 // CNormalUAS_WaitRespFromApp::SendResponseL
       
   229 // -----------------------------------------------------------------------------
       
   230 //
       
   231 void CNormalUAS_WaitRespFromApp::SendResponseL(CUserAgent& aUserAgent,
       
   232 								   CSIPResponse* aResp,
       
   233 								   const TSIPTransportParams& aParams) const
       
   234 	{
       
   235     __SIP_ASSERT_LEAVE(aResp, KErrArgument);
       
   236 
       
   237 	CNormalUAS& ua = CNormalUAS::Ptr(aUserAgent);
       
   238 	ua.HandleSendResponseL(aResp, aParams);
       
   239 
       
   240 	//Enter next state before sending response, in case transaction terminates
       
   241 	//in SendResponseToTransactionL, UAS is already in the correct state.
       
   242     if (CSIPMessageUtility::IsFinalResponse(*aResp))
       
   243 		{
       
   244 		aUserAgent.ChangeState(*iFinalRespSent);
       
   245 		}
       
   246 
       
   247 	ua.SendResponseToTransactionL(aResp);
       
   248 	}
       
   249 
       
   250 // -----------------------------------------------------------------------------
       
   251 // CNormalUAS_WaitRespFromApp::TransactionEndsL
       
   252 // -----------------------------------------------------------------------------
       
   253 //
       
   254 void CNormalUAS_WaitRespFromApp::TransactionEndsL(CUserAgent& aUserAgent,
       
   255 											      TInt aReason) const
       
   256 	{
       
   257 	aUserAgent.Stop(aReason);
       
   258 	}
       
   259 
       
   260 // -----------------------------------------------------------------------------
       
   261 // CNormalUAS_FinalRespSent::CNormalUAS_FinalRespSent
       
   262 // -----------------------------------------------------------------------------
       
   263 //
       
   264 CNormalUAS_FinalRespSent::CNormalUAS_FinalRespSent()
       
   265 	{
       
   266 	}
       
   267 
       
   268 // -----------------------------------------------------------------------------
       
   269 // CNormalUAS_FinalRespSent::~CNormalUAS_FinalRespSent
       
   270 // -----------------------------------------------------------------------------
       
   271 //
       
   272 CNormalUAS_FinalRespSent::~CNormalUAS_FinalRespSent()
       
   273 	{
       
   274 	}
       
   275 
       
   276 // -----------------------------------------------------------------------------
       
   277 // CNormalUAS_FinalRespSent::TransactionEndsL
       
   278 // -----------------------------------------------------------------------------
       
   279 //
       
   280 void CNormalUAS_FinalRespSent::TransactionEndsL(CUserAgent& aUserAgent,
       
   281 											    TInt aReason) const
       
   282 	{    
       
   283 	aUserAgent.Stop(aReason);
       
   284 	}
       
   285 
       
   286 // -----------------------------------------------------------------------------
       
   287 // CNormalUAS_FinalRespSent::SendResponseL
       
   288 // Application tries to send another final response, after already sending one.
       
   289 // -----------------------------------------------------------------------------
       
   290 //
       
   291 void CNormalUAS_FinalRespSent::SendResponseL(CUserAgent& /*aUserAgent*/,
       
   292 								 CSIPResponse* aResp,
       
   293 								 const TSIPTransportParams& /*aParams*/) const
       
   294 	{
       
   295     __SIP_ASSERT_LEAVE(aResp, KErrArgument);
       
   296 
       
   297 	User::Leave(KErrSIPInvalidTransactionState);
       
   298 	}